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, this event can be detected by a Hit Crossing block, which will generate a message corresponding to this event. The generated message will trigger the server to release the tank.
The model includes the following components:
Tank Generator: Generates tanks periodically with each tank having an arbitrarily assigned Capacity attribute.
Waiting Queue: Queues tanks waiting to be filled
Fill This Tank: Serves tanks and calls into the Simulink Function
startFilling to pass the tank's capacity attribute to the time-based section of the model.
Tank Filling: Models the process of filling each tank up to capacity
Sensor: 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. Sensor serves as a bridge between the time-based section and even-based section.
Processor: Receives message generated from the Sensor and decides which tank to be released from the Server. It then call the Simulink Function named
release to generate a release message for a specific tank.
Selection Gate: Receives a release message, and in response, opens the gate to let the specific tank through.
Configure Demo: Sets the number of gas pumps in the gas station and turns on/off of the animation. To show the animation, please use a gas pump number between 1 and 20.
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 input port of the Entity Queue block that is connected to the Hit Crossing 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" shows the results of the simulation.
Show Animation check box is selected in Configure Demo, an animation window appears for visualizing the demo. A screenshot of the animation with four gas pumps is shown below: