I am having an issue with setting the portion size of a valve during run time. It appears to always take the values placed in the 'Properties' input boxes as its first/initial portion size. I want to have this value read in from a database during start up (ie. In Main > On Start up).
Attempt 1
If I assign the value that I read in from the database to a variable "parcel_size" and I place the variable name "parcel_size" in the PortionSize input, it tells be that the PortionSize cannot be zero. I assume that means it is trying to assign the value before I read it in from the database. If I give the varaible "parcel_size" a default value, it just takes that value as the first Portion Size.
Attempt 2
I also tried putting in a numerical value in the PortionSize input and then assigning a value during Main > On Start up using:
valve.set_portionSize(parcel_size, TON);
While this successfully assigns the subsequent portion sizes, it still takes the initial numerical value as the initial PortionSize.
I thought it may be possible bypass this issue by setting a very small value as the initial portion size - however it does not work for me as my action is also dependent on the "parcel_size":
valve2.dispense(parcel_size, TON);
So what would happen is that it will trigger dispensing the 'parcel_size' amount but when portion_size passed on valve is small. I need these to be the same amount.
Attempt 3
I then tried un-checking the "Recurrent action on portion" box first and then putting the following code in Main > Startup:
valve.set_portionSize(parcel_size, TON);
valve.actionOnPortion = true;
However this gives me an error of "Volume and mass parameters are incompatible"
Changing the code using cubic meter does not help:
valve.set_portionSize(parcel_size, CUBIC_METER);
valve.actionOnPortion = true;
Is there a way around this?
Can anyone suggest a way around this?
Sorry for the long post, but hope that it has explained my problem properly.