question

Xu Chunqi avatar image
0 Likes"
Xu Chunqi asked Xu Chunqi commented

AGV startRecharge

I want to use startRecharge command to simulate agv electronic. The agv is created by the usercommand, because the agv number is flexsible.

When I use the agv network's way point logic, it did work,as the gif1.

But when I use my user command to create a new agv ,then use a customer code activity to startRecharge, it didnot work the first time,I must run second time ,and then the startRecharge command will work.Such as the gif2.

Because my model is special, I need to use the customer code activity to realize my logic. Can you tell me why it has to run second time which just like a update, is there any other way?agv-chargev1924-1.fsmagv-chargev1924.fsm

FlexSim 19.2.4
agv recharge
1121.gif (10.1 MiB)
1122.gif (9.7 MiB)
agv-chargev1924.fsm (41.5 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.

Joshua S avatar image Joshua S commented ·

@Shiny Xu

Have you tried to use resources for your AGVs? It allows you to set the amount of AGVs you will use at the start of your model.

0 Likes 0 ·

1 Answer

Brandon Peterson avatar image
2 Likes"
Brandon Peterson answered Xu Chunqi commented

Shiny Xu,

The reason that you are having a problem with the model is that a specific data node is not being created/updated properly until after you run the model once. if you add the following line of code to the end of your user command "createagv" your model will work the first time you hit reset and run.

function_s(getvarnode(aa, "navigator").first.value, "assertStatistic", "BatteryLevel");

If for some reason you think that someone will just try to hit run without hitting reset first you can also add the command "resetmodel()" after the line above.

I want to give a shout out to @anthony.johnson for supplying me with the line of code that fixed the problem. I wouldn't have been able to do it without him!

Good Luck with the rest of your model! Brandon

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

Xu Chunqi avatar image Xu Chunqi commented ·

Thank you and Anthony for your answer.

It's very helpful.

1 Like 1 ·