question

Jennifer F avatar image
1 Like"
Jennifer F asked Arun Kr commented

How do i change the speed of AGV using flexscript?

Hello!

I'm new to flexsim. I need to change the speed of the AGV using flexscript. Could anybody help with that?

FlexSim 19.2.4
flexscriptflexsim 19.2.4agv speed
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

Arun Kr avatar image
2 Likes"
Arun Kr answered Arun Kr commented

Hi @Jennifer F,

When you use the AGV Module

You can use the sampler to get the reference of the AGV speed parameters from the AGV network properties and then use that reference to change the speed. For Eg:

int SpeedValue = 5;

Model.find("AGVNetwork>variables/agvTypes/DefaultAGV/speeds/Straight/Empty")

ForwardSpeed.value = SpeedValue;

You may use this code in the process flow or in your waypoint logic in the model.

When you don't use AGV Module

int SpeedValue = 5;

treenode ForwardSpeed = getvarnode(Model.find("TaskExecuter1"), "maxspeed")

ForwardSpeed.value = SpeedValue;

You may use this code in the process flow or in the triggers in your model

Regards,

Arun KR



· 4
5 |100000

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

Jennifer F avatar image Jennifer F commented ·

@Arun KR Thanks for your support. Is there a way to start with flexscript? Any idea pr suggestions sir!

0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦♦ Jennifer F commented ·

In addition to @Jörg Vogel's I'd say that you can try small sections of FlexScript in the Script window if you want to test loops etc and write the results to the script return value (using the return keyword) or print to the output console if you want to see multiple values. Also you can step through any FlexSript code using breakpoints and then in the debugger look at the values of variables by hovering your mouse over them or checking the "local variables" window. You can also check any expression in the context of the executing code by entering it in the "Watch expression" window. The script window can also excute via the debugger directly using the debug option of the run button as shown here:

1 Like 1 ·
Joerg Vogel avatar image Joerg Vogel Jennifer F commented ·

Some years ago I learned it by looking into source code of picklist templates. Currently this is not useful anymore, because some source code is outdated. The actual command structure depends on dot-syntax and FlexScript Classes. The outdated source code is functional syntax by commands. The change is still in progress and both structures co-exist. There is a lot of code deprecated. When you move your mouse pointer over it, the pop up hints tells you the deprecated state and advise you to use a class method or property instead. You can mix them and sometimes you have to do this, because you don’t find a substitute in a class for a command. But if you know, that dot-syntax is the currently preferred syntax, you can still try to understand template source code.
I recommend to get rid of the template tags in source code editor. An icon on the left bottom canvas of the edit area deletes all property tags. Then you are not able to edit the properties anymore, but the source code looks tidier and has much more to do with the structure in the reference manual.

0 Likes 0 ·
Arun Kr avatar image Arun Kr commented ·

Adding on to both @Jörg Vogel and @jason.lightfoot, I'd also recommend you to go through the coding in FlexSim topic in the manual to have a basic understanding of the syntax of Flexscript and it's usage.

https://docs.flexsim.com/en/20.2/Reference/CodingInFlexSim/WritingLogic/

Regards,

Arun KR

0 Likes 0 ·