question

SerenaCR avatar image
0 Likes"
SerenaCR asked Jeanette F commented

Problems with loading and unloading custom code

Producto_Terminado - COPIA1.fsm

Hi!

I'm having problems with the logic I created for loading and unloading trucks (see custom codes "staging a salida" & "camion a salida")

1. The boxes are stacked vertically inside the truck (code "staging a salida")

2. The truck does not unload in the sink "Salida Exar" (code "camion a salida")

3. Is there a way to make the trucks return to the default position once finishing unloading (written as code)?


Besides this, maybe you can help me with the following:

4. How can I make the logic so the transporter "Transp_despacho" waits for the truck to return to the default position before unloading? (If possible as custom code)


The overall idea of the logic is that the transporter "Transp_despacho" loads the truck ("Camion1" or "Camion2", depending on token label: token.camion).

Then when the truck has reached its maximum capacity it has to unload the boxes in the sink "Salida Exar" and return to its default position.

The transporter has to wait for the truck to arrive before unloading.

Attached is my model.

I really appreciate any help you can provide.


FlexSim 23.0.2
custom codetruckpacking methodtransportingloadunload
· 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 ·

@SerenaCR, There are some suggestion in best practices of this answer site like “Ask one question at a time. When composing a new question, limit yourself to a single question…”.

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

Hi @SerenaCR, was one of Logan Gold's or Jeanette F'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 unaccept and comment back to reopen your question.

0 Likes 0 ·
Logan Gold avatar image
0 Likes"
Logan Gold answered

1.) The trucks are just TaskExecuter objects with a different 3D Shape applied to them. So they stack flowitems the same way as the TaskExecuters. If you want to change how flowitems stack, you will need to do something like this:

https://answers.flexsim.com/questions/96390/packing-method-on-task-executer.html

Or you may just want to clear the checkmark for "Show Contents" on the trucks (under Visuals > More Visuals), as this will make the boxes invisible.


2.) The Unload task in "camion a salida" is not referencing the contents of the truck being sent over to the Sink. It is referencing the first item in the next group of items that will be unloaded to the truck.

To fix this, you will need to change how you reference the contents of the truck. If you want to use unload tasks in the custom code, then you need to have an unload task for every item you want to unload, probably with a for loop.

You might find it easier to do this with more activities in Process Flow instead of one Custom Code activity. You can use a Decide activity to handle the check, then the various Task Sequence activities to replicate the code you are using now. You can also use a Move Object activity to move the entire contents of the truck all at once to the Sink.


3.) There's not really a straightforward way to have a task executer return to its reset position without resetting the model. You do have access to its reset position location and rotation with TaskExecuter.resetPosition.location, and TaskExecuter.resetPosition.rotation. But that can get complicated trying to make sure the trucks are at the correct position and rotation just in code. Although, you can tell the truck to travel to its reset location (or with a 3D shape like you're doing now), and then just set its rotation to the reset rotation. That will make it instantly "teleport" if you're okay with that.

It would be easier to have something like an AGV network or Network Nodes that forces the trucks to travel in a specific way so they always travel back to the original position with the correct rotation.


4.) I would use Process Flow in some way to restrict when Transp_despacho can unload. Maybe with a List or a Resource for the trucks that can be acquired and released depending on when the truck is available. It would be harder to do it all in code, but you might be able to do it with CALLSUBTASKS or WAITFORTASK on Transp_despacho. It's been awhile since I've tried to do this outside of Process Flow, but it should be possible.

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
0 Likes"
Jeanette F answered Jeanette F edited

Hello @SerenaCR

For the stacking of the flow items you can set an on entry trigger that sets the location of the items.

Instead of using custom code to create the task sequence I would use process flow activities.

1674767992562.png

producto-terminado-copia1 (1)_2.fsm


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.