question

Amanda Prado avatar image
0 Likes"
Amanda Prado asked Amanda Prado commented

Diferent move times as per subnodes

unload-batch-with-same-label-just-once_SubnodesRobot.fsmHello Everyone,

In my attached model, I need help with the following:
When my robot get items in queue "Placas Testadas_FCT", the items could be "pass" and "fail".

In process flow, a "custom code" change the robot MOVE TIME when this process occurs, but I need that the MOVE TIME being different if one item being fail.
Exemple: when robot gets 4 items pass, the move time will be : 5 seconds, but if just one item be fail the move time will be 7, because the process get more time.

If only one item is "fail" the time changes.


I understand that the robot's subnodes must be analyzed and that it is necessary to do an "if", but I don't know how to do this.


if the robot's subnodes are all pass: move time 5


else: move time 7


Could you help me?

Thank you very much !



FlexSim 25.0.0
robotsubnodesmove time
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

Gustavo Teodoro avatar image
0 Likes"
Gustavo Teodoro answered Amanda Prado commented

I have added a code in which the token examines all the items in the "Placas Testadas_FCT" queue. If any one of them is assigned the label "fail", the movement value is set to 7; otherwise, the value is set to 5. The code below was added to the custom code:

Object current = param(1);
treenode activity = param(2);
Token token = param(3);
treenode processFlow = ownerobject(activity);

//All items need to get the unit 5
double Time = 5;

//if one of the item is failed, change the time
//Get the queue
Object Queue = Model.find("Placas Testadas_FCT");
//Analyse if one of the item is Failed
for (int iItem = 1; iItem <= Queue.subnodes.length; iItem ++){
//Get the object in the Queue
Object item = Queue.subnodes[iItem];
//If one of them is Failed, set the time 7
if (item.Type == "Fail"){
Time = 7;
break;
}
}


token.resource.setProperty("MoveTime", Time);/**/


1742395388934.png

FX_Solution.fsm


1742395388934.png (60.8 KiB)
fx-solution.fsm (63.6 KiB)
· 3
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Amanda Prado avatar image Amanda Prado commented ·

Gustavo,


Thank you very much, but I would like the code to be applied to the robot and not the queue. When the robot loads the items from the queue (always 4 at a time) , there may be pass and fail signs.

From what I understand, the code is analyzing the contents of the queue, but I would like it to analyze the contents of the robot. I believe it is a similar logic.

0 Likes 0 ·
Gustavo Teodoro avatar image Gustavo Teodoro Amanda Prado commented ·

Try this code:


/**Custom Code*/
Object current = param(1);
treenode activity = param(2);
Token token = param(3);
treenode processFlow = ownerobject(activity);

//All items need to get the unit 5
double Time = 5;

//if one of the item is failed, change the time
//Get the items
Array Items = token.Items;
//Analyse if one of the item is Failed
for (int iItem = 1; iItem <= Items.length; iItem ++){
//Get the item that is in the robot
Object item = Items[iItem];
//If one of them is Failed, set the time 7
if (item.Type == "Fail"){
Time = 7;
break;
}
}

fx-solution.fsm

0 Likes 0 ·
fx-solution.fsm (63.7 KiB)
Amanda Prado avatar image Amanda Prado Gustavo Teodoro commented ·
Thank you very much, Gustavo !!
0 Likes 0 ·