Storage

The storage model is to replicate the input to output with a lag. If an input is present before the replication to output, so this input is ignored.

Code explanation
Model's attributs

As the model Generator,mDuration is a parameter that will allow us to store the time step between the reception of an event and its replication. The attributemStorage store entrance to replicate. In our example, an entry is represented by a real. mSigma will allow us to calculate the remaining time between each event received to continue to replicate the first entry received. mState will serve to situate us in the state of the model : if it's waiting for input or if it's in the process of replicating. And finally, mLastTime, as in the model Generator used to store the date of the last event.

Constructor / Destructor 

There are exactly the same as for the model Generator, the constructor retrieves the duration parameter, and the destructor is empty but obligatory.

Init

We init the attribute mSigma at parameter duration, mLastime at the start. At the begining of the simulation, we wait an input so we init mState to PASSIVE. Finaly, we return infinity to wait indefinitely until a reception of an entry.

Output

We xant replicate what we have recieved in entry. First we create an event nammed event which will be sent on the port out. We add at this new event the attribute mStorage (which contains what must be replicated) and which will be send on the port out. Finaly we add the event which will be sent by the output function.

TimeAdvance (Ta)

If we waiting en event in model's entry, we wait indefinitely. If we replicating an entry (RESPOND state), we return the time remaining before sending the replicated entry.

InternalTransition

The internal transition happens only during the replication of entry. We set mLastTime to time for update mSigma if the next transition is an external transition. We set back mSigma to mDuration and mState to PASSIVE because we begining a new waiting of entry.

ExternalTransition

First, we watch if we are in a stay state (PASSIVE) or if we yet have an entry to replicate (RESPOND).

If we waiting an entry, we retrieve this entry on the port in with :

We then reset mSigma to the parameter duration, update mLastTime an set instate of replication (RESPOND)

Else, if we are already replicating (RESPOND), we update mSigma giving it as value the time remaining before the end of the replication. We update mLastTime at the same time.

ConfluentTransitions

As the model [[Generator], this function say that when a conflict arises, we ignore external events and we do the internal transition only.