question

Ryosuke S avatar image
0 Likes"
Ryosuke S asked Ryosuke S commented

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

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();

agv_instancecreate_and_run.fsm

FlexSim 20.0.8
flexscripttaskexecuterflexsim 20.0.8
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

Matthew Gillespie avatar image
0 Likes"
Matthew Gillespie answered Ryosuke S commented

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



· 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.

Ryosuke S avatar image Ryosuke S commented ·

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 0 ·