question

Manuel M43 avatar image
0 Likes"
Manuel M43 asked Ryan Clark commented

How can I put two different speeds in one crane?

The idea is to assign different speeds according to the type of product being transported

FlexSim 22.0.0
cranecrane movement
· 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.

Ryan Clark avatar image Ryan Clark commented ·

Hi @Manuel M43, was Felix Möhlmann's answer helpful? If so, please click the "Accept" button at the bottom of their answer. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always unaccept and comment back to reopen your question.

0 Likes 0 ·

1 Answer

Felix Möhlmann avatar image
0 Likes"
Felix Möhlmann answered Phil BoBo commented

The speed and acceleration values are stored in the crane's "variables" tree.

1639071444876.png

You can set these using code with the following syntax:

Model.find("craneName>variables/cranespeeds/Part/var").value = N

"Part" should be replaced with which speed you want to set (Gantry, Trolley, Hoist_Lift or Hoist_Drop). "var" should "1" to set the maximum speed, "2" for the acceleration and "3" for the deceleration. This can also be seen in the tree in the "Gantry" node, but for the others the subnodes are not named so they have to be referenced by rank.

To change the speeds depending on item, you could use this in the load trigger of the crane. In that case the expression can be shortened because the crane is already referenced with "current" variable - a reference to the ownerobject of the event, in this case the crane itself.

If you only have a few different types you can use if - else condition to set the speed. With numerous values I'd suggest to use the switch - case syntax.

https://docs.flexsim.com/en/19.2/Reference/CodingInFlexSim/WritingLogic/#flow

In the "Unload" and "Reset" you then reset the speeds/acceleration/deceleration to their default values. Attached is an example model in which items of type 1 (red) are transport with a max speed of 4 and type 2 (green) with a max speed of 1.

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

Phil BoBo avatar image Phil BoBo ♦♦ commented ·

Rather than adjusting the variables nodes directly, you should use the Object.getProperty() and Object.setProperty() methods:

Object crane = Model.find("Crane1");
var craneSpeeds = crane.getProperty("CraneSpeeds");
//return craneSpeeds;
craneSpeeds[2][1] = 3; // change Trolley Max_Speed
crane.setProperty("CraneSpeeds", craneSpeeds);
return craneSpeeds;

1639085738740.png

https://docs.flexsim.com/en/22.0/Reference/3DObjects/TaskExecuters/Crane/Crane.html#properties

https://docs.flexsim.com/en/22.0/Reference/CodingInFlexSim/FlexScriptAPIReference/Tree/Object.html#Method-getProperty

2 Likes 2 ·
1639085738740.png (239.6 KiB)