question

Martin Edviken avatar image
1 Like"
Martin Edviken asked Brandon Peterson edited

Checking the status of an input port

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?

FlexSim 16.0.1
flexsim commandsinput portopenclosed
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

·
Jeff Nordgren avatar image
1 Like"
Jeff Nordgren answered

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.


portsample-fs1.fsm (15.7 KiB)
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.