Making agv travel after createinstance(), resetmodel() then go

Making agv travel after createinstance(), resetmodel() then go

sakamoto_ryosuke
Collaborator Collaborator
16 Views
2 Replies
Message 1 of 3

Making agv travel after createinstance(), resetmodel() then go

sakamoto_ryosuke
Collaborator
Collaborator

[ FlexSim 20.0.8 ]

Hello, I have createdinstance of agv by flexscript then make it run on the path. I have succeeded in creating the agv but then I can not make it travel. What could be the problem?

In the first customecode, the code looks like this

Object agv = createinstance(library().find("?TaskExecuter"),model());
agv.name = "TR001
contextdragconnection(agv, model().find("ControlPoint1"),"A")
resetmodel();

Second customcode is as follows:

go();

32679-capture007.jpg

agv_instancecreate_and_run.fsm

0 Likes
Accepted solutions (1)
17 Views
2 Replies
Replies (2)
Message 2 of 3

Matthew_Gillespie
Autodesk
Autodesk
Accepted solution

First of all, calling resetmodel() from a process flow activity isn't going to work. Stuff in process flow happens after reset, so when you call resetmodel() it deletes all the tokens in process flow and you never get a token going to the Breathe activity. Instead of calling resetmodel() you should add an OnModelReset trigger and put this code in there.

Second, using the contextdragconnection() command with AGVs causes a menu to open and thus doesn't work correctly for an automated script. You should call the "addMember" function on the AGVNavigator object instead.

Here's what the code looks like that you should put in the OnModelReset trigger:

Object agv = Model.find("TR001");

if (agv)
    agv.destroy();

agv = createinstance(library().find("?TaskExecuter"), model());
agv.name = "TR001";

function_s(Model.find("AGVNetwork"), "addMember", agv, Model.find("ControlPoint1"));

agv-instancecreate-and-run_1.fsm




Matthew Gillespie
FlexSim Software Developer

0 Likes
Message 3 of 3

sakamoto_ryosuke
Collaborator
Collaborator

Hi @matthew.gillespie, Thank you for your reply. I get the whole point. Also thank you for mentioning about the menu upon connecting agv to the cp. I was going to give up on that part. It's great to know there is way to avoid it.

0 Likes