question

Gabriel illescas Cavazos avatar image
0 Likes"
Gabriel illescas Cavazos asked Ben Wilson answered

How can I close/open an specific port?

ports control
5 |100000

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

Cameron Pluim avatar image
1 Like"
Cameron Pluim answered

@Gabriel illescas Cavazos, The documentation for openip() and closeip() says the following:

"Modelers should only use this command when working with fluid objects because the internal behavior of discrete objects controls the opening and closing of their ports, and therefore this command may be overridden."

There really isn't a good way to close specific ports, and typically in order to close only one port you need to close either the output port(s) of the object flowing in through that port, or the input port(s) of the object the specific port flows to.

In your situation, if the upstream object has multiple output ports, and you don't want all of them to be closed you will have to write some custom logic to make sure the "Send To Port" field doesn't return the output port of the object you are trying to close the input.

5 |100000

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

Ben Wilson avatar image
1 Like"
Ben Wilson answered

closeinput(object) and closeoutput(object) are the commands that you should use, however, they will close all input/output ports, not just a single specified port.

For a situation where you have an upstream object with multiple outputs, and the downstream object with multiple inputs, and you don't want to close all the outputs of the upstream, or all the inputs of the downstream, then a workaround with no code is to place a "dummy" queue in between the two, which only has a single input coming from the upstream object, and a single output to the downstream. Then inputs/outputs could be closed on this dummy queue, without affecting the flow of any other objects.

You do have to take capacities into consideration. Closing inputs on the dummy queue will probably be the right approach to keep things the simplest, though it will depend on your own unique situation. You should also probably set the max content of the dummy queue to 1.

5 |100000

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

Kari Payton avatar image
1 Like"
Kari Payton answered Sam Stubbs converted comment to answer

@Gabriel illescas Cavazos If you're using process flow you can use the command "object.input.close()".

Another tip if you're looking for commands, search the command helper. It's in the help drop-down menu in the toolbar. You can find all kinds of commands and even ideas for commands to use.

· 1
5 |100000

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

Gabriel illescas Cavazos avatar image Gabriel illescas Cavazos commented ·

Im not using process flow, I use flexsim normal, and I use closeip(current,1); but it doesnt work, can you help me to close port 1 and leave port 2 in open form

0 Likes 0 ·

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.