Adding up the block statistics for two adjacent blocks in Simevents
Show older comments
Hi
I've spent two days tearing my hair out trying to understand upgraded Simevents (Legacy Simevents much easier!). Frustration aside....
I have two adjacent Entity Servers, one feeding the next. (One is a one item painting rack for widgets, followed by an 8 item shelf drying rack for the painted widgets).
I would like to create a scope with a counter showing the number of widegts in both servers i.e. a sum. I have created "Number of entities in Block, n" data ports for the blocks in Statistics but can't for the life of me add the two numbers together and output to:
- A scope or
- A function (I'd like to do some switching up and down stream based on how many are here)
I know this will be ridiculously easy but .....
Thanks for the help.
Accepted Answer
More Answers (1)
Abdolkarim Mohammadi
on 4 Sep 2020
Edited: Abdolkarim Mohammadi
on 4 Sep 2020
0 votes
If I have understood you correctly, you want to calculate the system's WIP (Work In Progress). You can use the Add block to sum up the number of entities in each of the blocks. For example:

The scope shows:

2 Comments
Paul
on 5 Sep 2020
Abdolkarim Mohammadi
on 5 Sep 2020
Edited: Abdolkarim Mohammadi
on 5 Sep 2020
Many thanks, Paul.
1) They just differ visually. I prefer rectangular because it is visually consistent with other blocks.
2) You want the function to be callable from event actions, so you should use Simulink Function. And you want to write textual MATLAB functions within it, so it should contain MATLAB function block. I have attached an example, where the Entry event action of the second server calls GetWIP() function. 

Categories
Find more on Discrete-Event Simulation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!