question

Ana Gabriela L avatar image
1 Like"
Ana Gabriela L asked Ana Gabriela L commented

How to combine two custom codes that work separately?

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.

FlexSim 20.0.0
custom codeflexsim 20.0.0coordinated task sequence
custom-codes.fsm (50.9 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.

1 Answer

·
Jeanette F avatar image
2 Likes"
Jeanette F answered Ana Gabriela L commented

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.


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

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);


1 Like 1 ·
Ana Gabriela L avatar image Ana Gabriela L Jeanette F ♦♦ commented ·

Thankyou!!

0 Likes 0 ·
Ana Gabriela L avatar image Ana Gabriela L commented ·

@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 0 ·
Joerg Vogel avatar image Joerg Vogel Ana Gabriela L commented ·

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.

0 Likes 0 ·
sync-task.png (25.2 KiB)
Ana Gabriela L avatar image Ana Gabriela L Joerg Vogel commented ·

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