question

anon-user avatar image
0 Likes"
anon-user asked tannerp commented

How to create a pie chart by tracking the state of a variable?

Hey,

I want to create a pie chart by separate between the overall time when the variable "tasksequencequeue" from the Dispatcher is bigger then 0, to the overall time when the variable tasksequencequeue is equal to 0.

I already know, that I have to track the variable with the Model.find("Dispatcher1>variables/tasksequencequeue").subnodes.length statement, but I don't know how to bring the variable to the pie chart as in the picture.

I thought the solution might be similar to the solution in this article, but my tries didn't work so far: https://answers.flexsim.com/articles/42399/statistics-collector-utilization.html

Thanks in advance!

Marc

dispatchervariablechart
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

·
Jordan Johnson avatar image
3 Likes"
Jordan Johnson answered Jordan Johnson commented

pie-chart-dispatcher-variable-with-chart.fsm

This is a great example of a custom statistic! As you have noticed, FlexSim doesn't really track how many task sequences there are, at least not in the same way it tracks other statistics. But we can still get the statistic you wanted.

The basic steps are:

  1. Derive the data from dispatcher events using a Process Flow, and store it on a token label
  2. Create a table that reads the token's label using a Statistics Collector

So first, the Process Flow. The flow itself is not complicated, but there are two main things that it does. First, it creates a Tracked Variable label on a token. Since this is a kind of state, I chose a Categorical Tracked Variable, and I used a profile. This kind of Tracked Variable remembers how long its been in each category, which is perfect for this situation. The second thing the flow does is it listens to events when the Dispatcher's task sequence list could change. This could happen either when a task sequence is received, or when a Task Executer becomes available. When either of these things happen, we want to re-examine the list of task sequences, to see if it has anything in it. If it does, we set the token's label to 1. If not, set it back to 0.

Now we have a token that has a label that knows what is on the task sequence list, and how long it has either had something or nothing. All we have to do now is get it in to a table. This is where the Statistics Collector comes in. The Statistics Collector listens to the OnExit of CreateHasTasks. It creates one row per token, and uses the token as the row value. In our case, there is only one token, so there will only be one row. The token has a label that refers to the dispatcher it is observing, so we reference that in the Dispatcher column.

The next two columns are almost identical. They update Always, and they both have code that looks like this:

data.rowValue.labels["HasTasks"].as(TrackedVariable).getTotalTimeAt(0)

Here's the breakdown: data.rowValue is the token that we care about (because we set the Row Value to token). That token has a label that is a Tracked Variable. We don't just want the value, though. We want to know how long the label has been set to a certain value. If we said

data.rowValue.HasTasks

then we would just get a 1 or a 0 back, because that syntax gets the current value.

Instead, we want to get some different information from the label. This means we have to use the .labels property. This property can be used to get the label itself, rather than the value of the label. Then, since we know that this label is a Tracked Variable, we can access the Tracked Variable API using .as(TrackedVariable). Finally, we can as the Tracked Variable how long it has been at a certain value (0 in this case).

Hopefully, that makes some sense. Let me know if you have any questions!


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

anon-user avatar image anon-user commented ·

Hi @jordan.johnson,

many thanks to your answer!

Your chart is almost exactly doing what I was looking for!

My problem with your solution is that it considers also that time when there is no production. So, I have to consider the time schedule of the production. Sorry, that I didn't tell you in my first description

Is it possible to modify your solution to consider the time schedule of the production?

16238-pie-chart-dispatcher-variable-with-chart-wit.fsm

Thanks in advance!

Marc

0 Likes 0 ·
tannerp avatar image tannerp anon-user commented ·

Is it possible to subtract the "time when there is no production" from the "Time Empty" data and obtain the statistic you're looking for?

0 Likes 0 ·
Jordan Johnson avatar image Jordan Johnson ♦♦ anon-user commented ·

I added some logic to the Process Flow. The idea is to listen to the time table. If the time table brings objects down, I put the HasTasks label at "2", and wait for the time table to resume the objects.

pie-chart-dispatcher-exclude-downtime.fsm

0 Likes 0 ·

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.