question

sachin T3 avatar image
0 Likes"
sachin T3 asked sachin T3 answered

onReset open and close port not working.

hello, I am trying to control the number of successor a object should send part for processing. So I am opening and closing the input ports of the successor processors onreset. The program is not throwing any error. but its not working.


forexample i want to activate only 1 successive processor out of 3 so onreset I am closing the ports of all and then opening the port of only 1 processor. But when i run the model its sending parts to 2. and no matter what, it always send part to 2 processors, even if i open all 3 ports. Please check the program on reset and let me know what I am missing. question.fsm


FlexSim 21.2.0
flexsim 21.2.0onreset
question.fsm (28.4 KiB)
· 2
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 ·

Opening and closing ports are only Features on some very special objects available like fluid objects. Try the opposite and close the input of following processors instead. I would suggest you read carefully the manual before you start experiments with unknown commands.

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().

From: https://docs.flexsim.com/en/21.2/Reference/CodingInFlexSim/CommandReference/Commands.html#closeop

0 Likes 0 ·
sachin T3 avatar image sachin T3 Joerg Vogel commented ·

hi Joerg,

Thank you for your answer. But as you said, i am closing the input port of the successor object., not the current object itself. Also the feature must work because its the function of the processor, I am probably doing something wrong. I am simply letting closing the input port of the successor or next object so that the object from current processor cannot go to that processor.

Model.find("CurrentProcessor").as(Object).outObjects[1].input.close;


@Matthew Gillespie




0 Likes 0 ·
Felix Möhlmann avatar image
1 Like"
Felix Möhlmann answered

The issue is that FlexSim automatically resets all connections to their default state (in this case open). This apparently happens after the "OnModelReset" trigger has run, so it overwrites your previous closing of the port.

If you instead close the ports in "On Reset" triggers on the processors itself, they will stay closed, as that trigger happens after the internal logic.

If you want to keep your code, you can instead use it in the "OnRunStart" model trigger. This one fires every time the model changes from a stopped to a running state. To make sure the ports are only closed on the initial start of the run, enclose your code in the following condition.

if(Model.time == 0)
{  }

There is too little throughput through the first processor ("Zone11") to utilize all three connected processors. As Jörg Vogel mentioned, use a different option in "Send to Port" (for example "Round Robin") if you want to distribute the items differently.

question_fm.fsm


question-fm.fsm (28.4 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.

sachin T3 avatar image
0 Likes"
sachin T3 answered

this is what i want. thank you.

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.