In my model there are an entity generator, some attribute function(out_attrName)
and an entity sink. How do I get the sum of all attrName
values of every entity? I want to get the value of every entity before it gets to the sink and accumulates this value.
I tried to use a 'Cumulative Sum' block but no luck. This block requires discrete time on the input, so I use Discrete-Time Integrator. Can't say I use it in correct way: for example if values to sum are 34 and 40, the total sum can be some thing like 12344 instead of correct 74.
EDIT:
Example:
consider the following model: 10 entities go to the server and then to the sink.
There are 2 Set attribute
blocks:
- First one for
StartTime
(current time from Clock, before the server) - Second one for
EndTime
(current time from Clock, after the server)
One Attribute function
block to set ServiceTime
attribute = EndTime
- StartTime
.
The model is pretty simple, so ServiceTime
attribute is always equal 10. We can see it on the Signal scope
.
We've got 10 entities. In each entity there is an attribute ServiceTime
== 10. Now I want to get sum of ServiceTime
attributes for all entities. 10*10=100. How do I do that?
Details: