question

Andrea F. avatar image
0 Likes"
Andrea F. asked Jordan Johnson answered

Editing code into FlexSim library permanently?

Hi Team,

in my project, I need to move the item from an AGV to a conveyor with a certain delay: from the time when the AGV stops to when the item arrives at the station (located in the middle of the conveyor), a well-defined amount of time (Ttot) must pass. Passing the item directly from the AGV to the entry transfer, however, takes less time (Tconv) than I need (Tconv < Ttot). Therefore, I added a delay (Tdel) which equals: Tdel = Ttot - Tconv.

So, since the item as soon as it enters the conveyor has its front edge coincident with the beginning of the conveyor, and since the station is set to interact with the center of the item, let's better define Tconv:

  • staLoc = position of the station along the conveyor
  • itemLength = length of the item on the axis parallel to the direction of travel of the conveyor
  • convSpeed = speed of the conveyor

Tconv = [staLoc + (itemLength / 2)] / convSpeed


No problems so far.

At this point I wanted to better parameterize this delay so that it would dynamically adjust as the size of the item (itemLength) changed.

I struggled a bit to find a way to retrieve the exact length of the item based on the "entry orientation" setup of the entry transfer. I eventually came to the following conclusion:

int direction = entryTransfer.find(">variables/entryOrientation").evaluate();

if ((direction >= 1) && (direction <= 8))
    itemLength = item.size.x;
else
if ((direction >= 9) && (direction <= 16))
    itemLength = item.size.y;
else
if ((direction >= 17) && (direction <= 24))
    itemLength = item.size.z;

This is where my problem begins.

The function entryTransfer.find(“>variables/entryOrientation”).evaluate() would execute the following code:

image-001.png

But at the time I run this code, the item has entered neither the entry transfer nor the conveyor (it is still in the AGV), so an error comes up (even though the item variable is useless).

I currently solved it by modifying that entry transfer code as follows:

image-002.png

Now the code works, but if I add a new conveyor to my project, the related entry transfer is created with that part of the code unmodified.

Is there any way to modify the FlexSim library itself so that every time it creates a new entry transfer, it generates the transfer with that portion of code already modified?


I found that code in the library: Main/project/library/conveyor/EntryTransfer>variables/entryOrientation

but if I edit it and then close and reopen FlexSim it comes back unedited as before.


If what I am asking is impossible, is there any other way to find which orientation the item will enter the conveyor before the item actually enters it?

FlexSim 24.1.0
libraryentrytransferflow item orientation
image-001.png (24.4 KiB)
image-002.png (24.6 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

Jordan Johnson avatar image
1 Like"
Jordan Johnson answered

It looks to me like you just need to pass in the item and conveyor:

// Get a reference to the conveyor from the transfer, if you don't already have it
// /1+/~ => go to the first subnode, follow the path/pointer, get the ownerobject
treenode conveyor = entryTransfer.find(">variables/transferPoint/1+/~");
int direction = entryTransfer.find(">variables/entryOrientation").evaluate(conveyor, item);

When you use evaluate(), the first value you pass in is available as param(1), the second you pass in is available as param(2), etc. If you pass in the expected parameters, I think the code will work properly.

It will probably work in this case, but it's not always feasible to call a pick option at a different time than when that pick option was designed for.

Overall, though, it really just feels like you need to release the AGV when the item arrives at the station. You shouldn't have to write code to figure out the delay time. Instead, you can just listen for events.

Here is an example with some concepts:

AGVDelayDemo.fsm

The basic idea is to use a Process Flow task sequence instead of the default task sequence. There's many variations on this concept, but the core is the same. If you use the Create Task Sequence activity, then the task sequence won't finish until the Finish Task Sequence activity happens, even if there is no active task.

You can use this to create a task sequence that includes a Wait for Event activity, where you wait for the item to arrive at the station before finishing the AGV's task.

So I wouldn't recommend modifying FlexSim in this case. But to answer your original question, if you really, really want to change things in the main or view trees, you should create a module. Modules have the ability to add or replace nodes, including code nodes, in FlexSim.

https://docs.flexsim.com/en/25.0/Reference/DeveloperAdvancedUser/ModuleSDK/ModuleDevelopment/ModuleDevelopment.html#AddingReplacement

So there is a road to modifying FlexSim generally. However, this seems like a case for configuring your model, not changing FlexSim.


agvdelaydemo.fsm (50.7 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.