How to combine two custom codes that work separately?

How to combine two custom codes that work separately?

ana_gabriela_l
Not applicable
35 Views
6 Replies
Message 1 of 7

How to combine two custom codes that work separately?

ana_gabriela_l
Not applicable

[ FlexSim 20.0.0 ]

Hi!

I would like to create a custom code for my model to do the following:

  1. An operator will arrive to Queue1 and will have a delay time of 5 seconds.
  2. Once the delay time is over, 3 operators will arrive to Queue1.
  3. The 4 operators (at the same time) will load an item and onload it in Queue 2 (it doesnt matter if only one operator actually loads the item and the other ones just follow him).

I have created 2 separate custom codes that kind of do what I want my model to do separately. The first one is located in Queue 1, I tried to apply the code of the Coordinated Task Sequence Example 2 for 4 operator instead of 2 but couldn't do it correctly. The second code is located in Queue3 and works the way I want for it to work.

I would like to correct the logic of Queue 1 and see a way of combining these two tasks into one code.

Thankyou in advance for your help!

CUSTOM CODES.fsm

**I know this can be easly done with Process Flow, but I want to try with code.

Accepted solutions (1)
36 Views
6 Replies
Replies (6)
Message 2 of 7

Jeanette_Fullmer
Community Manager
Community Manager
Accepted solution

Hello @Ana Gabriela L,

Great job on the coding! The code in Queue1 had an error in line 31 and 32. The code that hadn't changed the op2travelkey to op3travelkey and then op4travelkey, so it wasn't allocating Operator3 and Operator4 correctly. After I corrected this in your model it ran how you described above.

34637-incorrect-operator-called.png

Message 3 of 7

ana_gabriela_l
Not applicable

@Jeanette F thankyou so much for your help!

Is there a way to combine this two codes so it executes the delay and the coordinated task sequence in the same queue?

0 Likes
Message 4 of 7

joerg_vogel_HsH
Mentor
Mentor

You can insert more proxytasks to your coordinated task sequence. You have to decide when or after which tasks you want to sychronize the activities.

34643-sync-task.png

0 Likes
Message 5 of 7

ana_gabriela_l
Not applicable

@Jörg Vogel

Thankyou! I tried what you suggested, but I am still having some problems. I want Operator 1 to arrive to queue 1 and execute the delay only when the boxes enter. Once the delay is over the 4 operators will load and unload the items form queue 1 to queue 2.

In this model CUSTOM CODE 2.fsm the simulation works fine until the oprators arrive to queue 2.

0 Likes
Message 6 of 7

Jeanette_Fullmer
Community Manager
Community Manager

Hello @Ana Gabriela L,

I inserted the following code after your acquire the operators.

insertproxytask(myts, operator1key, TASKTYPE_TRAVEL, current, NULL, 0,0,0,0);
int Op1Inspection = insertproxytask(myts, operator1key,TASKTYPE_DELAY,NULL,NULL,10,STATE_INSPECTING);
insertsynctask(myts, Op1Inspection);


Message 7 of 7

ana_gabriela_l
Not applicable

Thankyou!!

0 Likes