question

tall_pauhl avatar image
0 Likes"
tall_pauhl asked Felix Möhlmann answered

Open and close ports based on Tracked Variable

Hello everyone,

I´m at a beginners level with the software and am trying to figure out how to open and close a Queue Port based on the amount of Items in the Queue.

First I added a tracked variable (Warteschlangeee), which is supposed to be monitored by Set Tracked Variable. Herefore I added Set Tracked Variable on Entry with increment by 1. I did the same thing for the Exit -> Set tracked variable and added decrement by 1. This should give me the amount in the Queue. If the Amount is 0 (or less), the Port (out Kasse 2) should be closed. If there are 20 items or more in the Queue it should open, so that those items distribute evenly.

Problems:

1. Somehow tho it only decrements the variable.

2. The port doesn`t open or close.

I would really appreciate feedback. If there`s another wa to tackle this, I´m open to use which ever way (process flow etc.).


Thanks in Advance

Paul

flexsim-kasse-wechseln-01.pngflexsim-kasse-wechseln-02.pngflexsim-kasse-wechseln-03.png

FlexSim 23.2.2
close and open ports
· 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.

Joerg Vogel avatar image Joerg Vogel commented ·

from manual: closeop(obj object, num outputportnum)

Close just outputportnum of object. Closing an output port of an object will block the exit from the object through that port. 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. For discrete objects the modeler is referred to closeoutput() and stopoutput().

You can still use internal send to port logic to restrict access to ports or divert to other ports still. But by command to close an output port is not possible.

You can evaluate a label or a value in Port By Case template and set an output port number an item is sent to. You can even replace the output port number by a label or an element of an label array. Then you can change it, while model run to different return values for set cases.

1 Like 1 ·

1 Answer

Felix Möhlmann avatar image
1 Like"
Felix Möhlmann answered

I can't say why the variable is only decrementing without looking at the model.

However, you don't really need to use a tracked variable. You can just use the content of the queue directly, to close/open the second register ("current.subnodes.length").

As Jörg said, you can't close an individual port, only the entire output. Currently your logic would close the output of Kasse2. Instead, you want to close the input of Kasse2, so the queue can no longer send items there. Lastly, according to what you wrote the input of Kasse2 should start closed, which you can do in its On Reset trigger.

5 |100000

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