question

Jon Abbott avatar image
0 Likes"
Jon Abbott asked Jon Abbott commented

How do I retrieve the % complete for each active batch in a batch step?

I would like to use FlexScript to programmatically retrieve the percentages of completion for the items actively going through a batch step in Process Flow, like these:

I see in the Model Tree that the currentQuantity and batchQuantity for each batch are stored in nodes under:

Tools/ProcessFlow/ProcessFlow/BatchTask/stats/instances/ProcessFlow/batches/

The currentQuantity and batchQuantity values appear to map to the fractions in the batches shown above, but I’m not sure how best to programmatically extract those values for all of the active batches in a batch step. Thanks in advance for your help.

@anthony.johnson - this is to populate the custom GUI that you recently showed me.

FlexSim 20.0.2
process flowflexscriptcodebatch
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

·
Regan Blackett avatar image
0 Likes"
Regan Blackett answered Jon Abbott commented

@Jon Abbott

You could use a Statistics Collector to build a table that would have a row for each unique batch ID and then show the progress as columns. The Batch activity has two events you would want to listen to, On Create Batch and On Batch Change. Those give you access to the target batch size and the current tokens in the batch so far.

Then you could use the Unique Row Values row mode with the batchID as the row value, and create columns for the batchID, the number of tokens collected so far, and the target, and then a fourth column that does the percentage math. Here's an attached example.


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

Jon Abbott avatar image Jon Abbott commented ·

Thanks @Regan Blackett! This works great. I combined this solution with the following code to retrieve the percent complete values using FlexScript:

Table.query("SELECT PercentComplete FROM StatisticsCollector1 WHERE BatchID = X")[1][1]

...in this case, "X" is replaced with the BatchID number being requested.

1 Like 1 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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