question

Ankur A3 avatar image
0 Likes"
Ankur A3 asked Jeanette F commented

How to open and close port based on object reference?

Hi Team,

I am developing a model where I need to use object reference directly irrespective of port number to close or input the port between them.


For eg: I would like to open/close the ports of "Processor1" and "Queue1" based on content condition in Queue1.

1676626264900.png

Can you help me with it?

Thank you!

FlexSim 23.0.0
objectreferenceportconnection
1676626264900.png (9.1 KiB)
· 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.

Felix Möhlmann avatar image
0 Likes"
Felix Möhlmann answered Ankur A3 commented

You shouldn't open/close individual port connections, as those are controlled by the internal logic of the fixed resource and your command might be overridden.

To stop items from flowing in your example you would only close the (entire) input of Queue1. For that you only need a reference to Queue1 ("object.input.close()").

If Queue1 had multiple input connections and you only wanted to prevent items flowing through one, you could use intermediate queues with only one input each and close their input.

For completeness: You can get the port number which an object connects to on an upstream or downstream object with "ipopno()" and "opipno" (see command helper in FlexSim for further explanation)

· 7
5 |100000

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

Jason Lightfoot avatar image
0 Likes"
Jason Lightfoot answered Jason Lightfoot edited

It might be simplest to create your own object using a BasicFR and control the ports yourself.

Or you could use the pull to determine if you are taking items from the upstream object as described below using a Map.

In the attached model at reset I create a Map label 'portMapIn' that is keyed on the input objects so that you can look up the port number quickly - this is a user command 'createPortMapIn'.

There are two other commands closeConnection() and openConnection() that take the receiver and send objects as parameters and update a portClosed label array on the receiver that is referenced by the pull.

If you run to the stop point in the model and step past it you'll see Queue2 received an item from Processor1. If you then repeat that but run the script to close the connection between those two, the transfer does not take place when you perform a step. The transfer then takes place immediately when you open the connection.

portMapforReferencingInobjects.fsm


5 |100000

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