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?

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:

double dSpeed = 4;
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.

Craig DIckson avatar image Craig DIckson commented ·

@Jeff Nordgren

Jeff,

Thanks, that gets me closer. Now it does set the value, but it doesn't take effect until you reset the model, which unfortunately kind of defeats the purpose. Is there another command that forces the change?

By the way, my second example does seem to actually work, though it too requires a reset to take effect.

Here is the code I have now:

// Speed m/s
double dSpeed = gettablenum("Inputs_Equipment_UnitSorter_1", 6, 1);
settablenum(getvarnode(node("ConveyorSystem", model()), "conveyorTypes"), 2, 16, dSpeed);


double dInterval = 3; //gettablenum("Inputs_Equipment_UnitSorter_1", 7, 1);
setnodenum(node("/ConveyorSystem>variables/conveyorTypes/ConveyorType2/fixedIntervalPattern/1", model()),dInterval);

Thanks,

Craig

0 Likes 0 ·
Joerg Vogel avatar image Joerg Vogel Craig DIckson commented ·

Please look for yourself for answers of @phil.bobo when he has written about the conveyor module to change the position of decision points, photoeyes or length. There are some commands to execute if you want update the conveyor system by code without reseting the model. Maybe you must search the old forum, too.Old Flexsim Forum

1 Like 1 ·