question

ana.pc2 avatar image
0 Likes"
ana.pc2 asked ana.pc2 commented

Choose Travel Network path

Hi everybody!

How are you? I was wondering if there is a way to decide the path based on a label (without using process flow if possible, just through flexscript). Basically, if the item has Type 1, choose one path, and if the item has Type 2, choose the other path to go to the combiner.

Closing the other path each time won't be useful because there are more transporters sharing the network doing other things, and they can't be affected by this decision.

Please find attached an example model.

Thanks for the help!!

example_path.fsm

FlexSim 20.2.3
flexsim 20.2.3travelpathnetwork
example-path.fsm (36.6 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.

ana.pc2 avatar image ana.pc2 commented ·

I am trying on Entry for the transport, the following code:

Object current = ownerobject(c);
Object item = param(1);
int port = param(2);

/**Custom Code*/

Dispatcher resource = current;

if (item.Type == 1)
{
    Object dest = /**\nDestination: *//***tag:destination*//**/Model.find("NN4")/**/;
    /** \n\n*/
    if (objectexists(gettenavigator(resource))) 
    {
            int requirement = 0;
            double var2 = 0;
            // the requirement prevents stack overflow (I only want to travel there if I'm not there yet)
            if (objectexists(gettenetnode(resource))) 
            {
                requirement = distancetotravel(resource, dest) > 0.5*xsize(resource);
                var2 = 1;
            } else
                requirement = distancetotravel(resource, dest) > xsize(resource) + 0.2 * max(xsize(dest),ysize(dest));
            if (requirement) 
            {
                TaskSequence ts = TaskSequence.create(resource);
                ts.addTask(TASKTYPE_TRAVEL, dest, NULL, 0, var2);
                // and for good measure to absolutely make sure it doesn't get into stack overflow
                // I do a delay of 0. Where otherwise stack overflow would occur, here the model
                // will simply not progress.
                ts.addTask(TASKTYPE_DELAY, NULL, NULL, 0, STATE_IDLE);
                ts.dispatch();
                return 1;
            }
    } 
}
else
{
    Object dest = /**\nDestination: *//***tag:destination*//**/Model.find("NN7")/**/;
    /** \n\n*/
    if (objectexists(gettenavigator(resource))) 
    {
            int requirement = 0;
            double var2 = 0;
            // the requirement prevents stack overflow (I only want to travel there if I'm not there yet)
            if (objectexists(gettenetnode(resource))) 
            {
                requirement = distancetotravel(resource, dest) > 0.5*xsize(resource);
                var2 = 1;
            } else
                requirement = distancetotravel(resource, dest) > xsize(resource) + 0.2 * max(xsize(dest),ysize(dest));
            if (requirement) 
            {
                TaskSequence ts = TaskSequence.create(resource);
                ts.addTask(TASKTYPE_TRAVEL, dest, NULL, 0, var2);
                // and for good measure to absolutely make sure it doesn't get into stack overflow
                // I do a delay of 0. Where otherwise stack overflow would occur, here the model
                // will simply not progress.
                ts.addTask(TASKTYPE_DELAY, NULL, NULL, 0, STATE_IDLE);
                ts.dispatch();
                return 1;
            }
    } 
}


But this is sending a new task right after the transport finishes the task of moving from queue to combiner... is there any way to modify the current task in order to send it to one edge or the other?


Thanks!!

0 Likes 0 ·

1 Answer

·
Marcello Rosadini avatar image
1 Like"
Marcello Rosadini answered ana.pc2 commented

In your example, one alternative would be to make the transport travel to the last node in the path instead of traveling to the Object. In a more complex network this might not work but you could add intermediate destinations to force the routing, since you cannot close the paths.

In the attached model I have modidfied the Example Task Sequence 1 just to change the destination of the travel depending on the item Type

support altran.fsm




support-altran.fsm (35.8 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.

ana.pc2 avatar image ana.pc2 commented ·

Oh, thanks for the help!!

I also figured out another way ->

Using on Arrival at the queue node:

    if(traveler.subnodes[1].Type == 1)
    {
        Object dest = Model.find("NN8");
        redirectnetworktraveler(traveler, dest);
        return 1;
    }
    else
    {
        Object dest = Model.find("NN5");
        redirectnetworktraveler(traveler, dest);
        return 2;        
    }

But I will need to create a label to the item for only reading this code when is this operation and don't affect the other transports... so, I think I will try yours first to check if it works on the complex model!

Thanks :D

1 Like 1 ·

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.