Simbody
3.7
|
An EventHandler is an object that defines an event that can occur within a system. More...
Public Member Functions | |
virtual | ~EventHandler () |
virtual void | handleEvent (State &state, Real accuracy, bool &shouldTerminate) const =0 |
This method is invoked to handle the event. More... | |
An EventHandler is an object that defines an event that can occur within a system.
It is an abstract class. Subclasses define how to determine when the event occurs, and what happens when it does. You will not generally subclass EventHandler directly. Instead, subclass ScheduledEventHandler (for events that occur at a particular time that is know in advance) or TriggeredEventHandler (for events that occur when some condition is satisfied within the system). ScheduledEventHandler also has another subclass, PeriodicEventHandler, for the common situation of events that occur at regular intervals.
An EventHandler should be thought of as an integral part of the system it belongs to, and may alter the physical properties or behavior of the system.
If you merely want to observe the system but not to alter it, you should generally use a EventReporter instead.
Once you have created an EventHandler, you can add it to a System by calling addEventHandler() on the System.
|
virtual |
|
pure virtual |
This method is invoked to handle the event.
It is given a State which describes the system at the time when the event occurs, and it is permitted to modify any aspect of the state except the time. In doing so, it should respect the specified accuracy requirements for the continuous variables and constraints.
state | The state of the system when the event occurred. This method should modify state to reflect the changes caused by the event. |
accuracy | The accuracy to which this simulation is being computed. If your handler performs any approximate operation it should do so consistent with the simulation accuracy. |
shouldTerminate | If the event handler sets this to true, it will cause the simulation to terminate immediately. This does not necessarily indicate an error condition. |
Implemented in SimTK::GeodHitPlaneEvent.