TweeMansLeger Posted May 16, 2019 Share Posted May 16, 2019 Please help, I am at a loss, I have been trying for hours now and I assume the solution to be very simple and I'm just overlooking it. I have three entities going through my system; Ship, Truck and Train. All three entities have different carbon emissions. I want to create a status label that shows the total carbon emissions per entity based on kilometers traveled in the system. The label should show something like 'ShipEntity.Totaldistancetraveled * 0.323 (or whatever co2 output is for that entity)'. However you can't set 'totaldistancetraveled' or record it with any variable for these entities, only the 'ModelEntity' that I didnt create myself but is always there when you start. Also, I don't want to use vehicles. I just want to use entities through my system. Please help me. I have attached the model for your reference, I dont know if that is necessary or if it helps. Kind regards, Jason Corridor Model 0.06.spfx Link to comment Share on other sites More sharing options...
GFurtado Posted May 17, 2019 Share Posted May 17, 2019 Each entity running on a model is actually an instance of another model (a model entity). You'll se each individual distance travaled if you add an attached label on your ship entity, or else you'd need to reference that particular instance somehow. In the model attached in this post, I get the distance traveled of the last entity created. You also could set a "checkpoint" that assigns ModelEntity.TotalDistanceTraveled to a state whenever that entity goes through it. AttachedLabel.spfx Link to comment Share on other sites More sharing options...
gocken Posted May 17, 2019 Share Posted May 17, 2019 Quote You also could set a "checkpoint" that assigns ModelEntity.TotalDistanceTraveled to a state whenever that entity goes through it. The best way to collect such an statistic which belongs to modelentity's is to assign it to a model state variable. You should determine when to collect them appropriately. In your case it seems you have just two points to collect this statistic. 1) when it arrives its destination(s) (total loaded delivery distance) 2) before destroying it (total loaded and unloaded delivery distance). AttachedLabel (2).spfx Link to comment Share on other sites More sharing options...
Recommended Posts