<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to create a pie chart by tracking the state of a variable? in FlexSim Forum</title>
    <link>https://forums.autodesk.com/t5/flexsim-forum/how-to-create-a-pie-chart-by-tracking-the-state-of-a-variable/m-p/13485763#M4324</link>
    <description>&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&lt;A id="16492" href="https://answers.flexsim.com/storage/temp/16492-pie-chart-dispatcher-exclude-downtime.fsm"&gt;pie-chart-dispatcher-exclude-downtime.fsm&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 18 Dec 2018 00:09:30 GMT</pubDate>
    <dc:creator>JordanLJohnson</dc:creator>
    <dc:date>2018-12-18T00:09:30Z</dc:date>
    <item>
      <title>How to create a pie chart by tracking the state of a variable?</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/how-to-create-a-pie-chart-by-tracking-the-state-of-a-variable/m-p/13485759#M4320</link>
      <description>&lt;P&gt;Hey,&lt;/P&gt; 
&lt;P&gt;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.&lt;/P&gt; 
&lt;P&gt;&lt;/P&gt; 
&lt;P&gt;I already know, that I have to track the variable with the Model.find("Dispatcher1&amp;gt;variables/tasksequencequeue").subnodes.length statement, but I don't know how to bring the variable to the pie chart as in the picture. &lt;/P&gt; 
&lt;P&gt;I thought the solution might be similar to the solution in this article, but my tries didn't work so far: &lt;A target="_blank"&gt;https://answers.flexsim.com/articles/42399/statistics-collector-utilization.html&lt;/A&gt;&lt;/P&gt; 
&lt;P&gt;&lt;IMG alt="" /&gt;&lt;/P&gt; 
&lt;P&gt;Thanks in advance!&lt;/P&gt; 
&lt;P&gt;Marc&lt;/P&gt;</description>
      <pubDate>Wed, 05 Dec 2018 11:39:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/how-to-create-a-pie-chart-by-tracking-the-state-of-a-variable/m-p/13485759#M4320</guid>
      <dc:creator>__ANON_USER__1</dc:creator>
      <dc:date>2018-12-05T11:39:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a pie chart by tracking the state of a variable?</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/how-to-create-a-pie-chart-by-tracking-the-state-of-a-variable/m-p/13485760#M4321</link>
      <description>&lt;P&gt;&lt;A id="16238" href="https://answers.flexsim.com/storage/attachments/16238-pie-chart-dispatcher-variable-with-chart.fsm"&gt;pie-chart-dispatcher-variable-with-chart.fsm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="16239-ts-pie.png"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1498270iFC58670F1BB97505/image-size/large?v=v2&amp;amp;px=999" role="button" title="16239-ts-pie.png" alt="16239-ts-pie.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;The basic steps are:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Derive the data from dispatcher events using a Process Flow, and store it on a token label&lt;/LI&gt;&lt;LI&gt;Create a table that reads the token's label using a Statistics Collector&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;The next two columns are almost identical. They update Always, and they both have code that looks like this:&lt;/P&gt;&lt;PRE&gt;data.rowValue.labels["HasTasks"].as(TrackedVariable).getTotalTimeAt(0)&lt;/PRE&gt;&lt;P&gt;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&lt;/P&gt;&lt;PRE&gt;data.rowValue.HasTasks&lt;/PRE&gt;&lt;P&gt;then we would just get a 1 or a 0 back, because that syntax gets the current value.&lt;/P&gt;&lt;P&gt;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).&lt;/P&gt;&lt;P&gt;Hopefully, that makes some sense. Let me know if you have any questions!&lt;/P&gt;</description>
      <pubDate>Wed, 05 Dec 2018 23:53:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/how-to-create-a-pie-chart-by-tracking-the-state-of-a-variable/m-p/13485760#M4321</guid>
      <dc:creator>JordanLJohnson</dc:creator>
      <dc:date>2018-12-05T23:53:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a pie chart by tracking the state of a variable?</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/how-to-create-a-pie-chart-by-tracking-the-state-of-a-variable/m-p/13485761#M4322</link>
      <description>&lt;P&gt;Hi &lt;A rel="user" href="https://answers.flexsim.com/users/220/jordan.j.html" nodeid="220"&gt;@jordan.johnson&lt;/A&gt;,&lt;/P&gt;
&lt;P&gt;many thanks to your answer!&lt;/P&gt;
&lt;P&gt;Your chart is almost exactly doing what I was looking for! &lt;BR /&gt;&lt;BR /&gt;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&lt;BR /&gt;&lt;BR /&gt;Is it possible to modify your solution to consider the time schedule of the production?&lt;/P&gt;
&lt;P&gt;&lt;A id="16310" href="https://answers.flexsim.com/storage/attachments/16310-16238-pie-chart-dispatcher-variable-with-chart-wit.fsm"&gt;16238-pie-chart-dispatcher-variable-with-chart-wit.fsm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Thanks in advance!&lt;/P&gt;
&lt;P&gt;Marc &lt;/P&gt;</description>
      <pubDate>Mon, 10 Dec 2018 08:54:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/how-to-create-a-pie-chart-by-tracking-the-state-of-a-variable/m-p/13485761#M4322</guid>
      <dc:creator>__ANON_USER__1</dc:creator>
      <dc:date>2018-12-10T08:54:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a pie chart by tracking the state of a variable?</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/how-to-create-a-pie-chart-by-tracking-the-state-of-a-variable/m-p/13485762#M4323</link>
      <description>&lt;P&gt;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?&lt;/P&gt;</description>
      <pubDate>Fri, 14 Dec 2018 19:11:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/how-to-create-a-pie-chart-by-tracking-the-state-of-a-variable/m-p/13485762#M4323</guid>
      <dc:creator>tanner_p</dc:creator>
      <dc:date>2018-12-14T19:11:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a pie chart by tracking the state of a variable?</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/how-to-create-a-pie-chart-by-tracking-the-state-of-a-variable/m-p/13485763#M4324</link>
      <description>&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&lt;A id="16492" href="https://answers.flexsim.com/storage/temp/16492-pie-chart-dispatcher-exclude-downtime.fsm"&gt;pie-chart-dispatcher-exclude-downtime.fsm&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Dec 2018 00:09:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/how-to-create-a-pie-chart-by-tracking-the-state-of-a-variable/m-p/13485763#M4324</guid>
      <dc:creator>JordanLJohnson</dc:creator>
      <dc:date>2018-12-18T00:09:30Z</dc:date>
    </item>
  </channel>
</rss>

