Simulator
simulator
Classes:
-
NoSimulator
–Dummy place holder Simulator class for demonstration purposes
-
Simulator
–Abstract class for execution of operations and collection of data in the simulation software.
-
SimulatorActivity
–An activity is something that happened in the simulator.
-
SimulatorEvent
–Simulator event base class.
-
SimulatorInstruction
–An Instruction to be submitted to and performed by the simulator:
-
SimulatorVariable
–A specialised variable to monitor in the simulator
-
SimulatorVariableEvent
–Data Update Event
NoSimulator
NoSimulator(cockpit, environ)
Dummy place holder Simulator class for demonstration purposes
Methods:
-
activity_factory
–Returns data or create a new internal variable
-
add_simulator_events_to_monitor
–Adds supplied data to Simulator monitoring.
-
clean_simulator_event_to_monitor
–Removes all data from Simulator monitoring.
-
clean_simulator_variable_to_monitor
–Removes all data from Simulator monitoring.
-
datetime
–Returns the current simulator date and time
-
get_internal_variable
–Returns the InternalVariable or creates it if it is the first time it is accessed.
-
get_simulator_variable_value
–Gets the value of a SimulatorVariable monitored by Cockpitdecks
-
get_variable
–Returns data or create a new one, internal if path requires it
-
inc
–Increment a SimulatorVariable
-
inc_internal_variable
–Incretement an InternalVariable
-
register
–Registers a SimulatorVariable to be monitored by Cockpitdecks.
-
remove_all_simulator_event
–Removes all data from Simulator.
-
remove_all_simulator_variable
–Removes all data from Simulator.
-
remove_simulator_events_to_monitor
–Removes supplied data from Simulator monitoring.
-
set_internal_variable
–Sets the value of an InternalVariable. If the data does not exist, it is created first.
activity_factory
activity_factory(name: str, creator: str = None) -> Activity
Returns data or create a new internal variable
add_simulator_events_to_monitor
add_simulator_events_to_monitor(simulator_events: set, reason: str = None)
Adds supplied data to Simulator monitoring.
clean_simulator_event_to_monitor
clean_simulator_event_to_monitor()
Removes all data from Simulator monitoring.
clean_simulator_variable_to_monitor
clean_simulator_variable_to_monitor()
Removes all data from Simulator monitoring.
datetime
datetime(zulu: bool = False, system: bool = False) -> datetime
Returns the current simulator date and time
get_internal_variable
get_internal_variable(name: str, is_string: bool = False) -> Variable
Returns the InternalVariable or creates it if it is the first time it is accessed.
Args:
name (str): [description]
is_string (bool): [description] (default: False
)
Returns:
-
Variable
–
get_simulator_variable_value
get_simulator_variable_value(simulator_variable, default=None) -> Any | None
Gets the value of a SimulatorVariable monitored by Cockpitdecks
Args:
simulator_variable ([type]): [description]
default ([type]): [description] (default: None
)
Returns:
-
Any | None
–
get_variable
get_variable(name: str, is_string: bool = False) -> InternalVariable | SimulatorVariable
Returns data or create a new one, internal if path requires it
Important note: is_string has precedence over whatever type has the variable.
If is_string is true, and the variable is not of type string, it is forced to type string.
This is (probably) due to a first request to create the variable without being able to determine its data type.
Then later, another request to create the variable happens with the proper requested type, so we adjust it.
Parent objects always know what data type their variable is. (float is default, string is explicit.)
inc
Increment a SimulatorVariable
Parameters:
-
path
str
) –[description]
-
amount
float
, default:1.0
) –[description] (default:
1.0
) -
cascade
bool
, default:False
) –[description] (default:
False
)
inc_internal_variable
inc_internal_variable(name: str, amount: float, cascade: bool = False)
Incretement an InternalVariable
Args:
name (str): [description]
amount (float): [description]
cascade (bool): [description] (default: False
)
register
register(variable: Variable) -> Variable
Registers a SimulatorVariable to be monitored by Cockpitdecks.
Parameters:
-
simulator_variable
[type]
) –[description]
Returns:
-
Variable
–
remove_all_simulator_event
remove_all_simulator_event()
Removes all data from Simulator.
remove_all_simulator_variable
remove_all_simulator_variable()
Removes all data from Simulator.
remove_simulator_events_to_monitor
remove_simulator_events_to_monitor(simulator_events: set, reason: str = None)
Removes supplied data from Simulator monitoring.
set_internal_variable
set_internal_variable(name: str, value: float, cascade: bool)
Sets the value of an InternalVariable. If the data does not exist, it is created first.
Simulator
Simulator(cockpit, environ)
Abstract class for execution of operations and collection of data in the simulation software.
Methods:
-
activity_factory
–Returns data or create a new internal variable
-
add_simulator_events_to_monitor
–Adds supplied data to Simulator monitoring.
-
add_simulator_variables_to_monitor
–Adds supplied data to Simulator monitoring.
-
clean_simulator_event_to_monitor
–Removes all data from Simulator monitoring.
-
clean_simulator_variable_to_monitor
–Removes all data from Simulator monitoring.
-
datetime
–Returns the current simulator date and time
-
get_internal_variable
–Returns the InternalVariable or creates it if it is the first time it is accessed.
-
get_simulator_variable_value
–Gets the value of a SimulatorVariable monitored by Cockpitdecks
-
get_variable
–Returns data or create a new one, internal if path requires it
-
inc
–Increment a SimulatorVariable
-
inc_internal_variable
–Incretement an InternalVariable
-
is_night
–Returns whether simulator is night time
-
register
–Registers a SimulatorVariable to be monitored by Cockpitdecks.
-
remove_all_simulator_event
–Removes all data from Simulator.
-
remove_all_simulator_variable
–Removes all data from Simulator.
-
remove_simulator_events_to_monitor
–Removes supplied data from Simulator monitoring.
-
remove_simulator_variables_to_monitor
–Removes supplied data from Simulator monitoring.
-
replay_event_factory
–Recreates an Event from data included in the value.
-
same_host
–Returns whether Cockpitdecks runs on the same computer as the Simulator software
-
set_internal_variable
–Sets the value of an InternalVariable. If the data does not exist, it is created first.
-
start
–Starts Cockpitdecks Simulator class, that is start data monitoring and instruction
-
terminate
–Terminates Cockpitdecks Simulator class, stop monitoring SimulatorVariable and stop issuing
activity_factory
activity_factory(name: str, creator: str = None) -> Activity
Returns data or create a new internal variable
add_simulator_events_to_monitor
add_simulator_events_to_monitor(simulator_events: set, reason: str = None)
Adds supplied data to Simulator monitoring.
add_simulator_variables_to_monitor
add_simulator_variables_to_monitor(simulator_variables: dict, reason: str = None)
Adds supplied data to Simulator monitoring.
clean_simulator_event_to_monitor
clean_simulator_event_to_monitor()
Removes all data from Simulator monitoring.
clean_simulator_variable_to_monitor
clean_simulator_variable_to_monitor()
Removes all data from Simulator monitoring.
datetime
datetime(zulu: bool = False, system: bool = False) -> datetime
Returns the current simulator date and time
get_internal_variable
get_internal_variable(name: str, is_string: bool = False) -> Variable
Returns the InternalVariable or creates it if it is the first time it is accessed.
Args:
name (str): [description]
is_string (bool): [description] (default: False
)
Returns:
-
Variable
–
get_simulator_variable_value
get_simulator_variable_value(simulator_variable, default=None) -> Any | None
Gets the value of a SimulatorVariable monitored by Cockpitdecks
Args:
simulator_variable ([type]): [description]
default ([type]): [description] (default: None
)
Returns:
-
Any | None
–
get_variable
get_variable(name: str, is_string: bool = False) -> InternalVariable | SimulatorVariable
Returns data or create a new one, internal if path requires it
Important note: is_string has precedence over whatever type has the variable.
If is_string is true, and the variable is not of type string, it is forced to type string.
This is (probably) due to a first request to create the variable without being able to determine its data type.
Then later, another request to create the variable happens with the proper requested type, so we adjust it.
Parent objects always know what data type their variable is. (float is default, string is explicit.)
inc
Increment a SimulatorVariable
Parameters:
-
path
str
) –[description]
-
amount
float
, default:1.0
) –[description] (default:
1.0
) -
cascade
bool
, default:False
) –[description] (default:
False
)
inc_internal_variable
inc_internal_variable(name: str, amount: float, cascade: bool = False)
Incretement an InternalVariable
Args:
name (str): [description]
amount (float): [description]
cascade (bool): [description] (default: False
)
is_night
abstractmethod
is_night() -> bool
Returns whether simulator is night time
register
register(variable: Variable) -> Variable
Registers a SimulatorVariable to be monitored by Cockpitdecks.
Parameters:
-
simulator_variable
[type]
) –[description]
Returns:
-
Variable
–
remove_all_simulator_event
remove_all_simulator_event()
Removes all data from Simulator.
remove_all_simulator_variable
remove_all_simulator_variable()
Removes all data from Simulator.
remove_simulator_events_to_monitor
remove_simulator_events_to_monitor(simulator_events: set, reason: str = None)
Removes supplied data from Simulator monitoring.
remove_simulator_variables_to_monitor
remove_simulator_variables_to_monitor(simulator_variables: dict, reason: str = None)
Removes supplied data from Simulator monitoring.
replay_event_factory
abstractmethod
Recreates an Event from data included in the value.
Parameters:
-
name
str
) –[description]
-
value
[type]
) –[description]
same_host
abstractmethod
same_host() -> bool
Returns whether Cockpitdecks runs on the same computer as the Simulator software
set_internal_variable
set_internal_variable(name: str, value: float, cascade: bool)
Sets the value of an InternalVariable. If the data does not exist, it is created first.
start
abstractmethod
start()
Starts Cockpitdecks Simulator class, that is start data monitoring and instruction
execution if instructed to do so.
terminate
abstractmethod
terminate()
Terminates Cockpitdecks Simulator class, stop monitoring SimulatorVariable and stop issuing
instructionsto the simulator..
SimulatorActivity
SimulatorActivity(simulator: Simulator, name: str, value: Any | None = None)
An activity is something that happened in the simulator.
SimulatorEvent
Simulator event base class.
Defines required capability to handle event.
Keeps a timestamp when event was created
[description]
Parameters:
-
sim
Simulator
) –Simulator that produced the event
-
autorun
bool
, default:True
) –Whether to run the event
Methods:
-
handled
–Called when event has been processed
-
handling
–Called before event is processed
-
is_processed
–Returns whether event has been processed and marked as such
Attributes:
-
delay
(float
) –Returns event handling duration in seconds
-
duration
(float
) –Returns event handling duration in seconds
-
event
(str
) –Event type
-
timestamp
(float
) –Event creation timestamp
delay
property
delay: float
Returns event handling duration in seconds
duration
property
duration: float
Returns event handling duration in seconds
event
property
event: str
Event type
timestamp
property
timestamp: float
Event creation timestamp
handled
handled()
Called when event has been processed
handling
handling()
Called before event is processed
is_processed
is_processed() -> bool
Returns whether event has been processed and marked as such
SimulatorInstruction
SimulatorInstruction(name: str, simulator: Simulator, delay: float = 0.0, condition: str | None = None)
An Instruction to be submitted to and performed by the simulator:
Methods:
-
all_subclasses
–Returns the list of all subclasses.
all_subclasses
staticmethod
all_subclasses() -> list
Returns the list of all subclasses.
Recurses through all sub-sub classes
Returns:
-
list
–[list]: list of all subclasses
Raises:
-
ValueError
–If invalid class found in recursion (types, etc.)
SimulatorVariable
SimulatorVariable(name: str, simulator: Simulator, data_type: str = 'float', physical_unit: str = '')
A specialised variable to monitor in the simulator
Methods:
-
value_formatted
–Format value if format is supplied
value_formatted
value_formatted()
Format value if format is supplied
Returns:
formatted value
SimulatorVariableEvent
SimulatorVariableEvent(sim: Simulator, name: str, value: float | str, cascade: bool, autorun: bool = True)
Data Update Event
Args:
Methods:
-
handled
–Called when event has been processed
-
handling
–Called before event is processed
-
is_processed
–Returns whether event has been processed and marked as such
Attributes:
-
delay
(float
) –Returns event handling duration in seconds
-
duration
(float
) –Returns event handling duration in seconds
-
event
(str
) –Event type
-
timestamp
(float
) –Event creation timestamp
delay
property
delay: float
Returns event handling duration in seconds
duration
property
duration: float
Returns event handling duration in seconds
event
property
event: str
Event type
timestamp
property
timestamp: float
Event creation timestamp
handled
handled()
Called when event has been processed
handling
handling()
Called before event is processed
is_processed
is_processed() -> bool
Returns whether event has been processed and marked as such