question

CHRISTIAN B3 avatar image
0 Likes"
CHRISTIAN B3 asked CHRISTIAN B3 commented

Procrastinate Object Stop in TimeTable / Down Function / Stop Object

I need to improve the Stop Object Down Function script code of a TimeTable, so that the stop of a conveyor is procrastinated until the conveyor gets empty.


At first I thought about a waituntil function I would use in plantsim in such a case, but I could not find a similar function in Flexscript.

So the next idea is to use a while loop, so that the script stays blocked until the conveyor is empty. But I do not know which piece of code to place inside the while, withou causing splash.

Obs: all objects linked to the timetable are conveyors


1712162963371.png

Or any other way ? Is there any way to make the code wait some seconds before reassessing the condition ? In PlantSim there is the wait(60) to wait 60 seconds, any similar code in Flexscript ?


Thank you !

FlexSim 22.0.16
timetablesdown behaviorstop object
1712162963371.png (38.3 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.

Jeanette F avatar image Jeanette F ♦♦ commented ·

Hi @CHRISTIAN B3, was one of CHRISTIAN B3's or Gustavo Teodoro's or Joerg Vogel's answers helpful? If so, please click the "Accept" button at the bottom of the one that best answers your question. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always comment back to reopen your question.

0 Likes 0 ·
CHRISTIAN B3 avatar image CHRISTIAN B3 Jeanette F ♦♦ commented ·

Hi Jeanette, actually it was Felix Mohlmann who answered the question, in a comment to Gustavo Teodoro, but it seems there is no option to accept a comment as the answer. Any suggestion ?

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

The ability to suspend code execution for a predefined time or until a certain happens has been added to FlexSim in version 22.1. Though most of the time there is a more efficient solution than to periodically check for a condition.

https://docs.flexsim.com/en/22.1/Reference/CodingInFlexSim/WritingLogic/WritingLogic.html#coroutines

One such option would be to use a Process Flow as @Gustavo Teodoro suggested, but in conjunction with the time table by creating a token in the down function code. In the attached model I use a subflow, as this allows to use the conveyor as the instance object which saves having to set a label on the token. But that's honestly a very small detail, so a general Process Flow could work just as well.

conveyor-stop-empty-fm.fsm


· 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.

CHRISTIAN B3 avatar image CHRISTIAN B3 commented ·

Thank you Mr. Felix, I implemented both ways succesfully (await statement and create token).


I did not know about the await statement, I hope Flexsim will expand its functionalities and include all the Process Flow "Wait For Event" ones. In my opinion it should be an equivalent to it, but in the form of a script. At the moment it seems to me it can listen to only the ones in the conveyor trigger, right ? OnEntry, OnExit, OnReset, OnMessage. It cannot listen to the content yet, right ? It would be awesome if it could !.


The create token is powerfull and aced it, it allowed me to activate process flow starting from the Time Table downfunction activation.


One last question: how comes that you have referenced the conveyor in the Wait for Event, in the Stop and Resume Conveyor activities with "current". Is it due to the fact that when the token was created [ Token token = Token.create(downobject, activity, 1) ] you put the conveyor/downobject as ownerNode ?


Thanks again !!

0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦ CHRISTIAN B3 commented ·
Be careful with this - littering your model with await code will not be as transparent as using process flow wait activities and could become a debugging/verification headache.
2 Likes 2 ·
Gustavo Teodoro avatar image
0 Likes"
Gustavo Teodoro answered Jeanette F converted comment to answer

Another option to perform the stop is through the flow process. In the attached model, there is a conveyor stop flow. There is a delay representing the Time Between Failures (TBF) which will be drawn at each round. Then, there is a conveyor check to see if there are items still being transported. If there are, the conveyor entrance is closed, and it is necessary to wait for the items to exit (Wait for Event). With each item exiting, it is checked again if there are items on the conveyor. When the conveyor is completely emptied, the Time To Repair (TTR) is applied, and after that, the conveyor can receive items again, and the entrance door is released. The attached model follows below.
FX_STOPOBJECT.fsm


fx-stopobject.fsm (45.3 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.

CHRISTIAN B3 avatar image CHRISTIAN B3 commented ·

Thank you for you time and sharing the model. In process flow the Wait For Event helps a lot ! This solution could be a workaround, but still with complications cause I have several brakes through the day, and there is the weekend where the off shift time is longer the during the work days, so using MTBF/MTTR strategy would not be appropriate for this 30 days long simulation. I still think that I need to use the time table with the specific brakes, off schedule times, weekends, etc.. Isn't there a flexscript code that allows to consume time inside the script ? like wait 60 seconds ? or an equivalent to the "Wait For Event" inside flexscript ?


1712176061328.png

0 Likes 0 ·
1712176061328.png (37.5 KiB)
Joerg Vogel avatar image
0 Likes"
Joerg Vogel answered Joerg Vogel commented

close any input to your conveyor. If last item has left your conveyor, you can call a stop on your conveyor and you open the inputs again.

· 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.

CHRISTIAN B3 avatar image CHRISTIAN B3 commented ·

1712170393368.png


Actually, there is a backlog of parts behind the stopped conveyor, onto other previous conveyors, that has to be consumed totally. If we close the input, we prevent this backlog to be totally consumed. Any suggestion on how to use the while loop ? Or is there a way to listen to a condition inside flexscript like if it was a process flow "Wait For Event" ?

0 Likes 0 ·
1712170393368.png (53.3 KiB)
Joerg Vogel avatar image Joerg Vogel CHRISTIAN B3 commented ·
In reality you place a sensor and you place a Barriere into you flow. In FlexSim you put a photo eye object where you want to interrupt a flow on a conveyor. There is an option to stop any advance of conveyor items. You can let resume stopped items, for example by an ongoing message.

If you want to do it in Process Flow, then do this. There are templates in process flow custom code activity to support you.

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.