Checking the status of an input port

Checking the status of an input port

martin_edviken
Not applicable
19 Views
1 Reply
Message 1 of 2

Checking the status of an input port

martin_edviken
Not applicable

[ FlexSim 16.0.1 ]

I want to check if a port is open or closed. I have tried to use the command "outputopen" but it doesn't seem to work. I guess it only works when the symbol is red or green and not both? Is there any other command that works better?

Accepted solutions (1)
20 Views
1 Reply
Reply (1)
Message 2 of 2

jeff_nordgren
Not applicable
Accepted solution

If you want to check the status of an input port, you can do that either of two ways. You said you used "outputopen" with no success. If you were using that to check the status of an input port, you're right, it doesn't work. That command is used to check the status of an output port.

You can use "inputopen(obj)", which will return a zero if the port has been closed using the closeinput() command. Or it will return a 1 if it is open (no red bar).

You can use "ipopen(obj)", which will check the status of a specific port number. But, this is the "internal" status of the port (no red bar). It will return a 1 if the specified port is open (green triangle) regardless of whether or not there is a red bar (closed by code). Or it will return zero if the internal status of the port is closed (red triangle).

I've attached a sample model where in the bottom portion of the screen are 4 Script tabs. If you select a tab and press the green > icon, it will execute the code shown. By executing these snippets of code, you can see how it affects the model and the return values on tabs 3 and 4.