I am dynamically creating a fixed (as in, read from a parameter table) number of task executer flow items at the start of my simulation. I have put a custom state profile on them and am setting the states through various activities in my Process Flow. I would like to get some statistics such as a pie chart and Gantt chart on these items, so I tried to add them to a statistics collector. I found @jordan.johnsons example of a custom item trace Gantt, but that assumes that I have fixed resources in my model that I can use to trigger the Statistics Collector on. Of course I could add a dummy FR and send it a message every time I change my state, but I figured there should be a better solution.
First I tried pointing the Statistics Collector to the On State Change event of my flow item, hoping that when I 'instantiate' it the event listener would get copied along. Since that did not work, I put the flow item in a Group and had the Stats Collector listen to the On State Change for the group, but I guess that it adds event listeners to all the group members on reset.
I tried dynamically attaching my flow items to a statistics collector as follows:
treenode statsCollector = model().find("Tools/StatisticsCollectors/BargeStatevsTime"); function_s(statsCollector, "addEventReference", token.Barge, "OnStateChange");
but no data is added to its table (when I sample a fixed resource in the model, the table does get filled so the columns are set up correctly).
Could I get this to work somehow? If not, is what I want possible to achieve without the ugliest hacks (such as manually generating events on a Fixed Resource every I change the state or changing the model to use persisting task executers)?
EDIT: Here's a demo model.