Sampling

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 attributemSampling 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 want 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. If we are in the state CONFLICT (we receive a new entry and we want return one in the same time), we return 0 for directly send the news updated entry.

InternalTransition

The internal transition takes place only during the replication of the entry. We set mLastTime to time to can update mSigma is the next transition is an externalTransition. We set back mSigma to mDuration and mState to PASSIVE because we begining a new waiting of entry.

ExternalTransition