question

Craig DIckson avatar image
0 Likes"
Craig DIckson asked Adrian Haws edited

Change fixed interval via code?

Hi-

I am using a fixed interval conveyor, and I want to be able to set the interval on model startup, based on a value in a table (read from Excel).

I used the picker to select that node, and got the node. How can I change the value?

  1. node("/ConveyorSystem>variables/conveyorTypes/ConveyorType2/fixedIntervalPattern/1", model());

For other conveyor attributes like speed the picker can also give you a pointer to the table with the data and you can change that:

  1. double dSpeed = 4;
  2. settablenum(getvarnode(node("ConveyorSystem", model()), "conveyorTypes"), 2, 16, dSpeed);

Any suggestions?

Thanks

Craig

FlexSim 16.0.1
conveyorpower and free conveyorfixed interval conveyor
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

Jeff Nordgren avatar image
1 Like"
Jeff Nordgren answered Adrian Haws edited

@Craig DIckson

You should be able to use the setnodenum() function to set the value in your first example:

setnodenum(node("/ConveyorSystem>variables/conveyorTypes/ConveyorType2/fixedIntervalPattern/1", model()));

In your second example, the getvarnode() function is getting a value from the table, not a reference to the node (or in this case the table). You need to do the same thing as in your first example, get the reference to the table using, reftable(), then set the table value in the table using the settablenum() command. If you would like to send in your model or a sample, we could show you how to do it. But this may give you the information you need to proceed.

· 3
5 |100000

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