File kernel/src/simulationTools/Event.hpp

Go to the source code of this file

General interface for Events.

Functions

double rint(double x)

Variables

const double DEFAULT_TICK = 1e-16
class Event
#include <Event.hpp>

Abstract class that represents generic time events.

This base class simply records the time at which the event will take place. A pure virtual function named process will be invoked to execute the event. The time is represented with a mpz_t, from gmp library. See http://gmplib.org.

Derived classes:

  • TimeDiscretisationEvent: events that corresponds to user-defined time-discretisation points
  • NonSmoothEvent: specific events, detected during simulation, when constraints are violated (thanks to roots-finding algorithm)
  • SensorEvent: event dedicated to data capture through user-defined sensors.

Existing types of events: 0 -> undef 1 -> TimeDiscretisation 2 -> NonSmooth 3 -> Sensor 4 -> Observer 5 -> Actuator

Subclassed by NonSmoothEvent, TimeDiscretisationEvent, TimeDiscretisationEventNoSaveInMemory

Public Functions

Event(double time, int newType = 0, bool reschedule = false)

copy constructor ; private => no copy nor pass-by-value.

assignment operator private => no assign allowedconstructor with time value and type as input

Parameters
  • time: the starting type (a double)
  • newType: the Event type (an int)
  • reschedule: set this to true if the event has to be rescheduled

virtual ~Event()

destructor

void display() const

display Event data

double getDoubleTimeOfEvent() const

get the time of the present event (double format)

Return
a double

double getTick() const

get tick value

Return
a double

SP::TimeDiscretisation getTimeDiscretisation() const

Get the TimeDiscretisation.

Return
the TimeDiscretisation used in this Event

const mpz_t *getTimeOfEvent() const

get the time of the present event (mpz_t format)

Return
a mpz_t

int getType() const

get a type of the present event

Return
an std::string

void incrementTime(unsigned int step = 1)
virtual void process(Simulation &sim) = 0

virtual function which actions depends on event type

Parameters

bool reschedule() const
void setK(unsigned int newK)

Set the current step k.

Parameters
  • newK: the new value of _k

void setTime(double time)

set the time of the present event (double format)

Parameters
  • time: the new time

void setTimeDiscretisation(SP::TimeDiscretisation td)

Set the TimeDiscretisation.

Parameters

void setType(int newType)

set a new type for the present Event

Parameters
  • newType: the new Event type

virtual void update(unsigned int k = 0)

virtual function which actions depends on event type.

The generic implementation present in this object is to increment the TimeDiscretisation and to chamge the time of the current Event

Parameters
  • k: meaning depends on the type of event. See derived class.

Public Static Functions

static void setTick(double newTick)

set tick value

Parameters
  • newTick: the new tick value

Protected Functions

Event()

Default constructor.

ACCEPT_SERIALIZATION(Event)

serialization hooks

Protected Attributes

double _dTime

Date of the present event, represented with a double.

unsigned int _k

index for the current Event

bool _reschedule

For automatic rescheduling.

SP::TimeDiscretisation _td

TimeDiscretisation for the Event (unused only in the NonSmoothEvent)

mpz_t _tickIncrement

Number of ticks corresponding to a timestep.

mpz_t _timeOfEvent

Date of the present event, represented with a mpz_t.

int _type

Id or type of the Event.

Protected Static Attributes

bool _eventCreated

has one Event object been instanciated.

Use to detect in setTick potentially dangerous cases

double _tick

confidence interval used to convert double time value to mpz_t