SVM only supports real-time execution. However, virtual-time simulation is required sometimes. The clock component makes it possible to simulate DCharts models in an as-fast-as-possible way.
The textual description of the clock component is included below:
In a real-time simulation, a model schedules transitions simply with the special event. The transitions with this event are triggered after the specified number of seconds. In as-fast-as-possible simulation, scheduling becomes different. The simulator does not really wait. When no event is scheduled at the current time, the virtual time counter is immediately increased to be the next scheduled time, and the transitions scheduled at that time are fired without delay.
When the clock component is used, the model schedules transitions with the schedule event. This event is broadcast by other parts of the model, and it is handled by the clock component. Two parameters must be sent with this event:
For example, if an orthogonal component in the model has ID ``o1'' (arbitrarily determined by the designer), and it schedules a transition after 5.3 seconds, it may send the schedule event with action ``[EVENT("schedule", ["o1", 5.3])]'', which is then handled and recorded by the clock component.
The clock component increases the virtual time automatically when no more events are scheduled at the current time. At that time, all the orthogonal components are considered idle because they are waiting for notifiers from the clock. This condition is expressed with the following guard:
When all the other orthogonal components are idle, the clock component increases the time counter to the smallest scheduled time. It then broadcasts notifiers. A notifier is a notify event with the same parameters as the schedule event that schedules it. If multiple events are scheduled at exactly the same time, the clock component broadcasts multiple notifiers with different parameters. The transitions in other orthogonal components reacting to the notify event use guards to test whether they are the ones to be notified. To continue with the last example, ``[PARAMS]="o1"'' is the guard of the transition that reacts to the notify event.
In real-time simulation, the current time can be retrieved by calling the time function in the time Python library. This function returns the current time according to the hardware clock. However, as-fast-as-possible simulation uses a different concept of time. The current time is maintained in a time counter. To retrieve the current time from the clock component, a gettime event should be sent without parameter. When the clock component receives this event, it immediately replies with a timereturn event. The current time (a float number) is the only parameter with the event. The receiver retrieves the current time with ``[PARAMS]''.
The following are several rules for the current time broadcast by the clock component: