ATTENTION

This FlexSim Community Forum is read-only. Please post any new questions, ideas, or discussions to our new community (we call it Answers) at https://answers.flexsim.com/. Our new Question & Answer site brings a modern, mobile-friendly interface and more focus on getting answers quickly. There are a few differences between how our new Q&A community works vs. a classic, threaded-conversation-style forum like the one below, so be sure to read our Answers Best Practices.


flexsim.com

Go Back   FlexSim Community Forum > FlexSim Software > Q&A
Downloads

Q&A Using Flexsim and building models

  #1  
Old 04-17-2013
Abdul Mirza Abdul Mirza is offline
Flexsim User
 
Join Date: Jul 2012
Posts: 13
Downloads: 0
Uploads: 0
Thanks: 5
Thanked 1 Time in 1 Post
Rep Power: 94
Abdul Mirza is on a distinguished road
Default How to close ports of an object when a condition is true on another object?

Hi All,

I am working with fluid objects. In my model I am trying to close one of the output ports of a reservoir (Machine 1). When one of the tanks is full(Machine 2).


I know I can use closeop() method in Machine 2 when it becomes full.

But my problem is when I do that it gives me an error saying unknown Variable Machine 1.

I have attached the code below. Any advice will be much appreciated.

Code:
treenode current = ownerobject(c);
int mode = parval(1); // 1 = rising, 2 = falling
#define rising 1
#define falling 2
#define either mode
{ //************* PickOption Start *************\\
/**Open or Close Ports*/
/** \nFluid Mode: */
int curmode = /**/rising/**list:rising~falling~either*/;
/** \nObject: */
treenode involved = /**/current/**/;
if (mode == curmode)
{
/** \nAction: */ /**/closeinput(involved)/**closing reservoir port*/;
closeop(Machine1, 1); /**closing output port at Machine 1*/
}
/**\n\n*/
return 1;
} //******* PickOption End *******\\
  #2  
Old 04-17-2013
Jason Lightfoot Jason Lightfoot is offline
Flexsim Consultant
 
Join Date: Aug 2007
Location: Somerset, UK
Posts: 719
Downloads: 20
Uploads: 0
Thanks: 123
Thanked 953 Times in 446 Posts
Rep Power: 773
Jason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond reputeJason Lightfoot has a reputation beyond repute
Default

You must first set up the treenode variable Machine1. The usual options are:
  1. A global variable called Machine1.
  2. A local treenode variable referring to the object through:
    • port connection : eg. outobject(current,1) or centerobject(current,3)
    • model path : eg. node("/Machine1",model()) or node("/container/Machine1",model());
    • relative path : eg. node("../Machine1",current);
The Following User Says Thank You to Jason Lightfoot For This Useful Post:
Abdul Mirza (04-17-2013)
  #3  
Old 04-17-2013
Abdul Mirza Abdul Mirza is offline
Flexsim User
 
Join Date: Jul 2012
Posts: 13
Downloads: 0
Uploads: 0
Thanks: 5
Thanked 1 Time in 1 Post
Rep Power: 94
Abdul Mirza is on a distinguished road
Default

Thanks Jason appreciate the help.

I was able to use inObject(current,1) method. As it Machine1 was the predecessor to the object I was calling that trigger.


Thread Thread Starter Forum Replies Last Post
How to condition the opening/stoping of a conveyor port? Ayoub EL BOUCHTILI Flexsim Student Forum 2 01-22-2013 02:30 PM
Object as a subnode to another object.. Nischith Kashyap Q&A 1 05-06-2011 01:12 AM
RE: Change the rank of output ports of a object using flexscript gadirajus Q&A 3 04-21-2011 02:44 PM
send a flowitem from a mobile object to another mobile object KelvinHo Q&A 5 03-03-2010 08:24 AM
Transfer a mobile object by another mobile object KelvinHo Q&A 7 07-17-2008 09:32 AM


All times are GMT -6.
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Copyright 1993-2018 FlexSim Software Products, Inc.