symupy.runtime.logic package

Submodules

symupy.runtime.logic.base module

This module contains a base class definition representing a single generic state

class symupy.runtime.logic.base.State[source]

Bases: object

This class defines a state object which provides basic functionalities for individual states within the state machine.

on_event(event)[source]

Handle events that are delegated to this State.

symupy.runtime.logic.publisher module

Publisher

This module dedicates a generic object to generate a publisher pattern implementation responsible of specific methods.

class symupy.runtime.logic.publisher.Publisher(channels=('default',))[source]

Bases: symupy.abstractions.subject.AbsSubject

This generic class model implements a general publisher pattern to broadcast information towards different subscribers. Subscribers are intented to be objects such as vehicles or other objects that should be aware of the publisher.

In particular this creates a subject that can notify to a specific channel where subscribers are registered.

Example

Create a DataQuery for 2 type of channels, automated and regular and perform a subscription

>>> channels = ('auto','regular')
>>> p = Publisher(channels)
>>> s = Subscriber(p,'auto')  # Registers a s into p
attach(observer, channel: str, callback=None)[source]

Attach a new observer to a specific channel,, one can specify a method of the class to be called.

Parameters
  • channel (str) – channel name

  • observer (observer) – observer object

  • callback (callable) – method to be executed when publisher notifies.

property channels
detach(observer, channel: str)[source]

Detach observer from the subject

Parameters
  • channel (str) – channel name

  • observer (observer) – observer object

  • callback (callable) – method to be executed when publisher notifies.

dispatch(channel: str = 'default')[source]

Dispatches a message to a specific channel

Parameters

channel (str) – channel name

foo()[source]

Demo function

get_subscribers(channel)[source]

Retreive subscribers in a particular channel

symupy.runtime.logic.runtime module

This module describes classes and objects to perform a runtime of a single scenario

class symupy.runtime.logic.runtime.RuntimeDevice[source]

Bases: object

This class defines the runtime device describing a series of cyclic states required to be run

Returns

Runtime Device for controlling states of the simulation runtime

Return type

RuntimeDevice

next_state(cycle: bool = True) None[source]

Updates the state according to the state machine logic, possible states

  • Compliance

  • Connect

  • Initialize

  • PreRoutine

  • Query

  • Control

  • Push

  • PostRoutine

  • Terminate

Parameters

cycle (bool, optional) – Cycle parameter to return to PreRoutine state, defaults to True

reset_state() None[source]

Reset to initial state in case required

symupy.runtime.logic.sorted_frozen_set module

This is a class describing a sorted frozen set. This is a collection implementation for a set of ordered elements that establish specific protocols for iteration, information access, element identification.

class symupy.runtime.logic.sorted_frozen_set.SortedFrozenSet(items=None)[source]

Bases: collections.abc.Sequence, collections.abc.Set

This is a collection that provides a set of properties to create a sorted frozen set.

In particular

Parameters
  • Sequence (Sequence) – Inherits from the Sequence collection object.

  • Set (Set) – Inherits from the Set collection object.

count(value) integer -- return number of occurrences of value[source]
difference(iterable)[source]
index(value[, start[, stop]]) integer -- return first index of value.[source]

Raises ValueError if the value is not present.

Supporting start and stop arguments is optional, but recommended.

intersection(iterable)[source]
issubset(iterable)[source]
issuperset(iterable)[source]
symmetric_difference(iterable)[source]
union(iterable)[source]

symupy.runtime.logic.states module

This module defines the basic states required to execute and launch a simulation.

The states are defined as:

  • Compliance: This state is defined to check availability of files and candidates.

  • Connect: This state is defined to process

  • Initialize: This state perform initialization tasks. In example, loading the file scenarios into the simulator. Declaring initial conditions for the platoon, etc.

  • Preroutine: Tasks to be done before the querying information from the simulator

  • Query: Tasks of parsing data and querying information from the simulator

  • Control: Perform decision tasks for the platoon

  • Push: Push updated information to the simulator for platoon vehicles

  • Postroutine: Performs tasks after the information has been pushed.

class symupy.runtime.logic.states.Compliance[source]

Bases: symupy.runtime.logic.base.State

The state which declares an status to check file compliance .

on_event(event: str) None[source]

Handle events that are delegated to this State.

class symupy.runtime.logic.states.Connect[source]

Bases: symupy.runtime.logic.base.State

The state which declares the creation of a connection with the simulator

on_event(event: str)[source]

Handle events that are delegated to this State.

class symupy.runtime.logic.states.Control[source]

Bases: symupy.runtime.logic.base.State

The state which computes the control decision

on_event(event: str)[source]

Handle events that are delegated to this State.

class symupy.runtime.logic.states.Initialize[source]

Bases: symupy.runtime.logic.base.State

The state which initializes values for the scenario simulation

on_event(event: str)[source]

Handle events that are delegated to this State.

class symupy.runtime.logic.states.PostRoutine[source]

Bases: symupy.runtime.logic.base.State

The state which logs information or compute step indicators

on_event(event: str)[source]

Handle events that are delegated to this State.

class symupy.runtime.logic.states.PreRoutine[source]

Bases: symupy.runtime.logic.base.State

The state which performs task previous to the interaction with the simulator

on_event(event: str)[source]

Handle events that are delegated to this State.

class symupy.runtime.logic.states.Push[source]

Bases: symupy.runtime.logic.base.State

The state which pushes data back to the simulator

on_event(event: str)[source]

Handle events that are delegated to this State.

class symupy.runtime.logic.states.Query[source]

Bases: symupy.runtime.logic.base.State

The state which retrieves information from the simulator

on_event(event: str)[source]

Handle events that are delegated to this State.

class symupy.runtime.logic.states.Terminate[source]

Bases: symupy.runtime.logic.base.State

The state which declares the end of a simulation

on_event(event: str)[source]

Handle events that are delegated to this State.

symupy.runtime.logic.subscriber module

Subscriber

This module dedicates a generic object to generate an observer pattern implementation responsible of subscribing to a publisher

class symupy.runtime.logic.subscriber.Subscriber(publisher, channel='default')[source]

Bases: symupy.abstractions.observer.AbsObserver

This general dataquery model implements a general publisher pattern to broadcast information towards different subscribers. Subscribers are intented to be objects such as vehicles, front/rear gap coordinators.

This creates an subject that can notify to a specific channel where subscribers are registered or

Example

Create a DataQuery for 2 type of channels, automated and regular vehicles:

>>> channels = ('auto','regular')
>>> query = DataQuery(channels)
update()[source]

Local update method to retrieve subject data

Module contents

Runtime logic