This example shows a hybrid system with both continuous time and discrete event sections. The discrete event part models tanks, represented by entities, which are being queued and need to be filled up. Each tank has a "Capacity" attribute. The continuous time part models the process of filling up a tank, modeled by an Integrator. When a tank is filled to capacity, it is released by the Entity Gate and departs.
The model includes the following components:
Tank Generator: Generates tanks periodically with each tank having an arbitrarily assigned Capacity attribute.
Queue: Queues tanks waiting to be filled
Fill This Tank: Serves one tank entity at a time and calls into the Simulink Function
startFilling to pass the tank's capacity attribute to the time-based section of the model.
Integrator: Models the process of filling a tank up to capacity
Flip Completion Logic: Detects when the amount filled in the tank has reached capacity and when this happens, sends a message to the discrete-event section of the model.
Entity Gate: Receives a message from the time-based section of the model that signals that the tank has been filled to capacity, and in response, opens to let the tank through.
SimEvents automatically handles any exchange of data across the time and event domains by automatically inserting gateways where needed. These positions are annotated in the model using
E. In this model, a gateway has been inserted at the control input port of the Entity Gate block since it receives a message from the time domain section of the model.
The Scope block labeled "Fill Process" and "Trucks leaving after fill" show the results of the simulation.