Designing the water system

We will try to design a very simple system.

The Dispenser

The Dispenser is informed by the sensor (modeled by a simulated input) of it's current level of water. If the water is lower than a certain amount (constant parameter LVLMIN), the dispenser will send a "request" signal. And it will ask for an amount of water equals to (LVLRECO - lvl) where "LVLRECO" is a constant parameter giving the recommended level and "lvl" is a variable giving the current level.

When the pump is pumping into the dispenser we want to block the possibility of another request of water in order to have a stable system. As a consequence we also need to know about the current state of the pump.

We can therefore model this dispenser as an object having four attributes :

This object must also have three communication channels or "ports" :

The behavior of the Dispenser can be modeled as a state-machine which discriminate into "states" the different sets of possible behaviors of the Dispenser. Here we can discriminate three states :

In the end, we can draw a rough sketch of the behavior as follows :

The Pump

The Pump is listening to "request" signals from the Dispenser. If it receives one, it will store the requested amount, stop listening for request and pump with a fixed flow rate "FLOW" until the required amount is reached. When it is reached, the pump will resume listening to the Dispenser.

Therefore we can model the Pump with two attributes:

The Pump object must also have two ports :

The associated state-machine can be modeled with two states:

In the end, we can draw a rough sketch of the behavior as follows :