cosapp.multimode.event

Classes

Event(name, context, desc, trigger, …)

Class for events, to be used as local variables

EventState()

Interface describing the inner state of an event

FilteredEvent(event, condition)

Inner state of an event triggered by another event, filtered by a Boolean condition.

MergedEvents(*events)

Inner state of an event triggered by the merging of of other, external events.

SynchronizedEvent(event)

Inner state of an event synchronized with another event.

UndefinedEvent()

Inner state of an undefined, never occurring event

ZeroCrossingEvent(event, zeroxing)

Inner state of an event triggered by a zero-crossing expression

class cosapp.multimode.event.Event(name: str, context: cosapp.systems.System, desc: str = '', trigger: Optional[Union[str, cosapp.multimode.zeroCrossing.ZeroCrossing, cosapp.multimode.event.EventState, Event]] = None, final: bool = False)[source]

Bases: object

Class for events, to be used as local variables

property context
property contextual_name

Join context system name and event name.

If the event has no context, only its name is returned.

Type

str

property desc

Event description

Type

str

filter(condition: str)cosapp.multimode.event.FilteredEvent[source]

Filters event with an additional boolean condition.

  • condition [str]:

    Evaluable boolean condition.

  • trigger [FilteredEvent]:

    The filtered event state, to be used as trigger.

property final
full_name(trim_root=False)str[source]

Returns full name up to root context.

Parameters

trim_root (bool (optional, default False)) – Exclude root context name if True.

Returns

The event full name

Return type

str

property is_primitive
static merge(*events: cosapp.multimode.event.Event)cosapp.multimode.event.MergedEvents[source]

Merges events into a trigger condition.

  • *events [Event]:

    Enumeration of events to be merged.

  • trigger [MergedEvents]:

    The merged event state, to be used as trigger.

property name

Event name

Type

str

classmethod name_check(name: str)[source]
property present
reevaluate()None[source]

Reevaluates the current state of the event; used to update information about zero-crossing events after an integration time step was interrupted by the triggering of an event.

reset()None[source]

Resets the event.

step()bool[source]

bool : Indicates whether the event was just triggered.

Performs a step.

tick()None[source]

Ticks the event, and locks it if it is a primitive event that has just been triggered.

to_trigger()bool[source]

bool : Indicates whether the event has to be triggered in the next discrete step

property trigger
value()Any[source]

Returns the value associated with the event.

class cosapp.multimode.event.EventState[source]

Bases: abc.ABC

Interface describing the inner state of an event

property is_primitive

True if event triggering is self contained, False otherwise

Type

bool

lock()None[source]
abstract must_emit()bool[source]
reevaluate()None[source]
reset()None[source]
tick()None[source]
to_emit()bool[source]
value()Any[source]

Returns value associated with event. By default, equivalent to must_emit().

class cosapp.multimode.event.FilteredEvent(event: cosapp.multimode.event.Event, condition: str)[source]

Bases: cosapp.multimode.event.EventState

Inner state of an event triggered by another event, filtered by a Boolean condition.

must_emit()bool[source]
class cosapp.multimode.event.MergedEvents(*events: cosapp.multimode.event.Event)[source]

Bases: cosapp.multimode.event.EventState

Inner state of an event triggered by the merging of of other, external events.

must_emit()bool[source]

Returns True if at least one event is present, False otherwise.

class cosapp.multimode.event.SynchronizedEvent(event: cosapp.multimode.event.Event)[source]

Bases: cosapp.multimode.event.EventState

Inner state of an event synchronized with another event.

must_emit()bool[source]
class cosapp.multimode.event.UndefinedEvent[source]

Bases: cosapp.multimode.event.EventState

Inner state of an undefined, never occurring event

must_emit()bool[source]
class cosapp.multimode.event.ZeroCrossingEvent(event: cosapp.multimode.event.Event, zeroxing: cosapp.multimode.zeroCrossing.ZeroCrossing)[source]

Bases: cosapp.multimode.event.EventState

Inner state of an event triggered by a zero-crossing expression

is_primitive()bool[source]

bool: True if event triggering is self contained, False otherwise

lock()None[source]

Locks the event

must_emit()bool[source]

Checks whether the event is triggered in the current discrete step.

reevaluate()[source]

Forces the reevaluation of the zero-crossing function

reset()None[source]
tick()[source]

Performs a tick and checks whether the event can be unlocked

to_emit()bool[source]

Checks whether the event will have to be triggered in a new discrete step

value()float[source]

Evaluates and returns the zero-crossing function defining the event.

zero_detected(next_value)bool[source]

Is a zero detected between previous value and next_value?