OK, I’m back able to do some testing today and this is what I’m seeing.
When I change the tag’s default format string to “#,##0.00000” I get this:
The logic that populates that tag is:
#if this is the first of the three campaigns, call the calcNumBatches to get
#batchData = Total Component Quantity for Order
#batchData = Number of batches
#& calclate the component qty percentage multiplier
if campNum == 1:
batches = shared.Northwind_Interface.calcNumBatches(tagPartAssignedPO, maxBatch, K)
orderQtyTot = batches
log.info("Component Qty Total: " + str(orderQtyTot))
numBat = batches
result = system.tag.write(tagPartNWDehy + '/batchNumTot', numBat)
#The batch percentage of order is used to calculate the amount of each component
#per batch. The value on campNum 1 is 1/total batches for order
#This %age can then be use to muptiply against the Req'd Qty for a componet (total order qty)
#to get the batch quantity for that component.
batchPercentOfOrder = 1.0 / numBat
log.info('Batch % of Order calculates to ' + str(batchPercentOfOrder) + '%')
Where numBat = the total number of batches, in this case 13. This value is written to the batchNumTotal tag shown above.
The logic is producing the “percentage” (actually the ratio) value of 0.08000.
When I use the Script Console to print the tag value I get the 0.08 value.
I wrote a short script to first get the tag value of the ratio that was previously calculated by the Shared script.
It read back and printed as above (0.08)
This script then calculates the ratio using the batchesNumTotal tag value (13) by dividing that tag value into 1 (1.0 / batchesNumTotal). This produces a “valid” value of 0.0769230769231
I then do the same with a constant value of 13, producing the same 0.0769230769231 value. I write that value to the tag, batchPercentOfOrder.
I then read that value back and get 0.08.
It looks like the tag is getting updated with the “valid” value of 0.0769… but not quick enough for the followup read get the updated value. If I put a while loop in that simply adds one to a counter, the counter the while loop is examining, I can get the updated value when I set the while loop to run when the counter is less than 10,000,000.
So it looks like the tag is not the issue.
That leaves the Shared script, but the logic calculating the ratio value there is the same as the logic being used in the Script Console. It is simply 1.0 / number of batches.
BTW, here is the tag value as calculated by the Script Console script: