Flexscript to remove an AGV from a network

Flexscript to remove an AGV from a network

jpokornyAXJ2L
Contributor Contributor
245 Views
4 Replies
Message 1 of 5

Flexscript to remove an AGV from a network

jpokornyAXJ2L
Contributor
Contributor

I have a larger model that I am working on.  I need to remove an AGV from a path so that it can be ignored by other AGVs for a specific condition.  Then I need to add the AGV back on the path so that it can be recognized again.  I think I have the code right to remove the AGV but when I try to add it back, it does not seem to work

code to remove: token.AGV.as(Object).setProperty("Navigator",NULL);

code to add back: function_s(Model.find("ControlPoint2"),"addConnection",-1,token.AGV);

0 Likes
246 Views
4 Replies
Replies (4)
Message 2 of 5

joerg_vogel_HsH
Mentor
Mentor

I would try if I can attach and detach a taskexecuter by contextdragconnection to an AGV network. 
Or a different try would be to deallocate a control point so that is allocatable by other AGV members. Later I would allocate the control point again. 

0 Likes
Message 3 of 5

FelixMoehlmann
Collaborator
Collaborator

I would place a dummy CP somewhere in the model (separate from the main network) and temporarily assign the AGV to it.

AGV(TE).currentCP = ...;
Message 4 of 5

jpokornyAXJ2L
Contributor
Contributor

Kind of new to coding trying to find current cp.  Why doesn't this work in custom code

 

AGV agv = token.AGV;
return agv.currentCP;

0 Likes
Message 5 of 5

FelixMoehlmann
Collaborator
Collaborator

You can't directly cast objects as an AGV class variable. You need to use the constructor.

https://docs.flexsim.com/en/26.0/Reference/CodingInFlexSim/FlexScriptAPIReference/AGV/AGV.html#Metho...

AGV agv = AGV(token.AGV);
return agv.currentCP;
0 Likes