Coding Error

Coding Error

tushar_hazare
Advocate Advocate
927 Views
6 Replies
Message 1 of 7

Coding Error

tushar_hazare
Advocate
Advocate

[ FlexSim 24.1.0 ]

Hello team,

I am trying to learn coding so i tried one code

1738759705205.png

its working only for first cycle.

I want to do is it will run continuously its means first 5 boxes will come then input port will close for 100 seconds and again open for next 5 boxes but for next cycle its continuously open

please correct me by using coding only

thank you in advance

0 Likes
Accepted solutions (1)
928 Views
6 Replies
Replies (6)
Message 2 of 7

FelixMoehlmann
Mentor
Mentor
Accepted solution

You are reading the input statistic of the queue which only ever increases (apart from being reset when a warmup time is set). You need a local counter, for example a label that you can reset back to 0 whenever the output gets closed.

I would also advice against using "await". It won't make a difference in this small example model. But it needs to store any variables from the code in a node so it can later resume the execution and is thus much slower than using messages or delayednodefunction(). With the latter you can call the same code again but pass in an additional parameter that changes what the code does. For starters, I would just use messages though.

1738766939867.png

0 Likes
Message 3 of 7

tushar_hazare
Advocate
Advocate

Hello ,


its working well but when i used two ports then its not coming as per counter

I have given counter 5 and coming 8 then and next cycle coming 7. can we fix this count for each cycle

trigger logic.fsm

0 Likes
Message 4 of 7

FelixMoehlmann
Mentor
Mentor

Same issue as in your previous question. https://answers.flexsim.com/questions/175581/event-source-start-without-completing-task.html

You need to close the input when the final transport is planned, not when it finishes.

0 Likes
Message 5 of 7

tushar_hazare
Advocate
Advocate
Can we do this in coding to close the input
0 Likes
Message 6 of 7

FelixMoehlmann
Mentor
Mentor
Sure, I would move the code that closes the input to the OnMessage trigger as well. Use different message parameters to control what the code does. Then the upstream objects only have to a message to the queue when it is clear that the item will move to the queue ("Use Transport" code when a transport is used, otherwise OnExit trigger).
0 Likes
Message 7 of 7

tushar_hazare
Advocate
Advocate
Thank you so much for your support.
0 Likes