ensemble.metaclass package

Submodules

ensemble.metaclass.connector module

Abstract Connector

This module implements a general metaclass for a connector.

class ensemble.metaclass.connector.AbsConnector[source]

Bases: object

abstract property get_vehicle_data

List of dictionaries containing vehicle data

abstract load_scenario(scenario: str)[source]

Method to load simulation into simulator

abstract load_simulator()[source]

Method to load the simulation platform

abstract push_data()[source]

Push data back to the simulator

abstract register_simulation(scenarioPath: str)[source]

Registers a scenario file into the simulator

abstract request_answer()[source]

Request answer from simulator

abstract property simulation_step

Current simulation iteration

ensemble.metaclass.controller module

Abstract Controller

This module implements a general metaclass for the operatinonal controller.

class ensemble.metaclass.controller.AbsController[source]

Bases: object

ensemble.metaclass.coordinator module

Abstract Gap Coordinator

This module implements a general metaclass for a vehicle gap coordinator.

class ensemble.metaclass.coordinator.AbsSingleGapCoord[source]

Bases: object

abstract property acceleration

Acceleration @current time

abstract cancel_join_request(value)[source]

Determines if a join request needs to be cancelled

abstract property comv2x

Communication availability

abstract property control

Applied control @current time

abstract property dv

Differential speed @current time

abstract property dx

Headway space @current time

abstract get_step_data() tuple[source]

Get single step data

abstract property history_control

Historical control

abstract property history_reference

Historical control

abstract property history_state

Historical status

abstract property joinable

Indicates if the coordinator is joinable

abstract property platoon

Platoon enabled

abstract property positionid

Position within the platoon

abstract property speed

Speed @current time

abstract property status

Platoon status @current time

abstract property ttd

Total travel distance @current time

abstract property vehid

Vehicle identifier

abstract property x

Distance on link @current time

ensemble.metaclass.dynamics module

Abstract Dynamics

This module implements a general metaclass for the dynamics.

class ensemble.metaclass.dynamics.AbsDynamics[source]

Bases: object

abstract property T

Current time step

abstract __call__()[source]

Callable Dynamics

ensemble.metaclass.observer module

Abstract Observer

This module implements a general metaclass of the observer.

class ensemble.metaclass.observer.AbsObserver[source]

Bases: object

abstract update(value)[source]

Local update method to retrieve subject data

ensemble.metaclass.state module

States

This module presents a state implementation that should be generic for state descriptions.

class ensemble.metaclass.state.AbsState[source]

Bases: object

__repr__()[source]

Leverages the __str__ method to describe the State.

__str__()[source]

Returns the name of the State.

abstract next_state()[source]

State to switch on event

ensemble.metaclass.stream module

Data Query

This module handles the Simulation response converting it into proper formats for querying data afterwards.

class ensemble.metaclass.stream.DataQuery(**kwargs)[source]

Bases: ensemble.logic.publisher.Publisher

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.

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
abstract property current_nbveh: int

Provides current number of vehicles

abstract property current_time: float

Provides current time step

filter_vehicle_property(property: str, *args)[source]

Filter out a property for a subset of vehicles

Parameters
  • property (str) – one of the following options abscissa, acceleration, distance, elevation, lane, link, ordinate, speed, vehid, vehtype,

  • vehids (int) – separate the vehid via commas to get the corresponding property

abstract get_vehicle_data() List[Dict[str, Union[str, int, float]]][source]

Provides current vehicle data

get_vehicle_properties(vehid: int) dict[source]

Return all properties for a given vehicle id

Returns

Dictionary with all vehicle properties

Return type

vehdata (dict)

get_vehicles_property(property: str) Tuple[Union[float, int, str]][source]

Extracts a specific property and returns a tuple containing this property for all vehicles in the buffer string

Parameters

property (str) – one of the following options abscissa, acceleration, distance, elevation, lane, link, ordinate, speed, vehid, vehtype,

Returns

tuple with corresponding values e.g (0,1), (0,),(None,)

Return type

values (tuple)

abstract is_vehicle_driven() bool[source]

True if the vehicle state is exposed to a driven state

Returns true if a vehicle is in a link at current state

Parameters
  • vehid (int) – vehicle id

  • link (str) – link name

Returns

True if veh is in link

Return type

present (bool)

is_vehicle_in_network(vehid: int, *args) bool[source]

True if veh id is in the network at current state, for multiple arguments. True if all veh ids are in the network.

Parameters

vehid (int) – Integer of vehicle id, comma separated if testing for multiple

Returns

True if vehicle is in the network otherwise false.

Return type

present (bool)

abstract property query

A method to store data as received from the simulator

abstract update_vehicle_registry(configurator)[source]

Updates the vehicle registry within the stream

vehicle_downstream_of(vehid: int) tuple[source]

Get ids of vehicles downstream to vehid

Parameters

vehid (str) – vehicle id

Returns

vehicles downstream of vehicle id

Return type

vehid (tuple)

vehicle_upstream_of(vehid: str) tuple[source]

Get ids of vehicles upstream to vehid

Parameters

vehid (str) – vehicle id

Returns

vehicles upstream of vehicle id

Return type

vehid (tuple)

Returns a tuple containing vehicle ids traveling on the same (link,lane) at current state

Parameters
  • link (str) – link name

  • lane (int) – lane number

Returns

set of vehicles in link/lane

Return type

vehs (tuple)

ensemble.metaclass.subject module

Abstract Subject

This module implements a general metaclass of the subject/publisher of information.

class ensemble.metaclass.subject.AbsSubject[source]

Bases: object

abstract classmethod attach(observer, channel, callback)[source]

Attach a new observer

abstract classmethod detach(observer, channel)[source]

Detach an existing observer

abstract classmethod dispatch(channel)[source]

Notify all observers by calling update method

Module contents