VehicleInterface
VehicleInterface
VehicleInterface (truck:tspace.config.vehicles.Truck, driver:tspace.config.drivers.Driver, can_server:tspace.config.messengers.CANMessenger, resume:bool=False, data_dir:Optional[pathlib.Path]=None, flash_count:int=0, episode_count:int=0, vcu_calib_table_row_start:int=0, torque_table_default:O ptional[pandas.core.frame.DataFrame]=None, torque_table _live:Optional[pandas.core.frame.DataFrame]=None, epi_countdown_time:float=3.0, lock_watchdog:<built- infunctionallocate_lock>=<unlocked _thread.lock object at 0x7f845e29d600>, capture_failure_count:int=0, flash_failure_count:int=0, logger:Optional[logging.Logger]=None, dict_logger:Optional[dict]=None)
*VehicleInterface is an ABC. It’s a Producer(get vehicle status), a Consumer(flasher) and a Filter(generate observation data)
Args:
truck: [`Truck`](https://Binjian.github.io/tspace/03.config.vehicles.html#truck) object
driver: [`Driver`](https://Binjian.github.io/tspace/03.config.drivers.html#driver) object
can_server: `CANMessenger` object
resume: resume from last table
data_dir: data directory
flash_count: flash count
episode_count: episode count
vcu_calib_table_row_start: vcu calibration table row start
torque_table_default: default torque table
torque_table_live: live torque table
epi_countdown_time: episode countdown time
lock_watchdog: lock for the following two watchdog variables
capture_failure_count: count of caputure failure
flash_failure_count: count of flash failure
logger: logger
dict_logger: dict logger*
VehicleInterface.init_vehicle
VehicleInterface.init_vehicle ()
initialize vehicle interface. Flashing the vehicle with initial/default table.
VehicleInterface.flash_vehicle
VehicleInterface.flash_vehicle (torque_table:pandas.core.frame.DataFrame)
Abstract method to flash the vehicle. Implemented by the concrete class Kvaser and Cloud.
VehicleInterface.hmi_control
VehicleInterface.hmi_control (hmi_pipeline:tspace.dataflow.pipeline.queu e.Pipeline[str], observe_pipeline:tspace.da taflow.pipeline.queue.Pipeline[pandas.core. frame.DataFrame], start_event:threading.Event, stop_event:threading.Event, interrupt_event:threading.Event, countdown_event:threading.Event, exit_event:threading.Event, flash_event:threading.Event)
HMI control logics by incoming events
| Type | Details | |
|---|---|---|
| hmi_pipeline | Pipeline | input HMI pipeline | 
| observe_pipeline | Pipeline | observation pipeline | 
| start_event | Event | input event start | 
| stop_event | Event | input event stop | 
| interrupt_event | Event | input event interrupt | 
| countdown_event | Event | input event countdown | 
| exit_event | Event | input event exit | 
| flash_event | Event | input event flash | 
| Returns | None | 
VehicleInterface.filter
VehicleInterface.filter (in_pipeline:tspace.dataflow.pipeline.deque.Pipel ineDQ[typing.Union[dict[str,str],dict[str,dict[s tr,list[typing.Union[str,list[list[str]]]]]]]], out_pipeline:tspace.dataflow.pipeline.queue.Pipe line[pandas.core.frame.DataFrame], start_event:Optional[threading.Event], stop_event:Optional[threading.Event], interrupt_event:Optional[threading.Event], flash_event:Optional[threading.Event], exit_event:Optional[threading.Event])
*Produce data into the pipeline
main entry to the capture thread sub-thread method*
| Type | Details | |
|---|---|---|
| in_pipeline | PipelineDQ | |
| out_pipeline | Pipeline | |
| start_event | Optional | |
| stop_event | Optional | |
| interrupt_event | Optional | input event | 
| flash_event | Optional | |
| exit_event | Optional | |
| Returns | None | 
VehicleInterface.init_internal_pipelines
VehicleInterface.init_internal_pipelines ()
Abstract method for initializing types of raw_pipeline and hmi_pipeline
VehicleInterface.ignite
VehicleInterface.ignite (observe_pipeline:tspace.dataflow.pipeline.queue. Pipeline[pandas.core.frame.DataFrame], flash_pip eline:tspace.dataflow.pipeline.queue.Pipeline[pa ndas.core.frame.DataFrame], start_event:threading.Event, stop_event:threading.Event, interrupt_event:threading.Event, flash_event:threading.Event, exit_event:threading.Event, watchdog_nap_time:float, watchdog_capture_error_upper_bound:int, watchdog_flash_error_upper_bound:int)
*creating the ThreadPool for handing the hmi, data capturing and data processing
main entry to the vehicle thread. will spawn three further threads for - input processing, HMI control and output processing - data into the pipeline - handle the input pipeline - guide observation data into the output pipeline - start/stop/interrupt/countdown/exit event to control the state machine main entry to the capture thread*
| Type | Details | |
|---|---|---|
| observe_pipeline | Pipeline | observation pipeline | 
| flash_pipeline | Pipeline | flash pipeline | 
| start_event | Event | input event start | 
| stop_event | Event | input event stop | 
| interrupt_event | Event | input event interrupt | 
| flash_event | Event | input event flash | 
| exit_event | Event | input event exit | 
| watchdog_nap_time | float | watch dog nap time in seconds | 
| watchdog_capture_error_upper_bound | int | capture error limit to exit for watch dog | 
| watchdog_flash_error_upper_bound | int | flash error limit to exit for watch dog | 
VehicleInterface.produce
VehicleInterface.produce (raw_pipeline:tspace.dataflow.pipeline.deque.Pip elineDQ[typing.Union[dict[str,str],dict[str,dic t[str,list[typing.Union[str,list[list[str]]]]]] ]], hmi_pipeline:Optional[tspace.dataflow.pipel ine.queue.Pipeline[str]]=None, exit_event:Optional[threading.Event]=None)
*Abstract method for producing data into the pipeline
main entry to the capture thread will spawn three further threads for input processing, HMI control and output processing*
| Type | Default | Details | |
|---|---|---|---|
| raw_pipeline | PipelineDQ | input pipeline for the raw data | |
| hmi_pipeline | Optional | None | |
| exit_event | Optional | None | input event exit | 
VehicleInterface.watch_dog
VehicleInterface.watch_dog (countdown_event:threading.Event, exit_event:threading.Event, watchdog_nap_time:float, watchdog_capture_error_upper_bound:int, watchdog_flash_error_upper_bound:int)
watch dog callback for the watch dog thread
| Type | Details | |
|---|---|---|
| countdown_event | Event | watch dog need to send trigger signal to end count down thread | 
| exit_event | Event | input event | 
| watchdog_nap_time | float | nap time for watch dog | 
| watchdog_capture_error_upper_bound | int | upperbound for capture failure | 
| watchdog_flash_error_upper_bound | int | upperbound for flash failure | 
VehicleInterface.countdown
VehicleInterface.countdown (observe_pipeline:tspace.dataflow.pipeline.que ue.Pipeline[pandas.core.frame.DataFrame], start_event:threading.Event, countdown_event:threading.Event, stop_event:threading.Event, exit_event:threading.Event)
countdown callback for the countdown thread
| Type | Details | |
|---|---|---|
| observe_pipeline | Pipeline | output pipeline | 
| start_event | Event | output event | 
| countdown_event | Event | input event | 
| stop_event | Event | output event | 
| exit_event | Event | input event | 
VehicleInterface.consume
VehicleInterface.consume (flash_pipeline:tspace.dataflow.pipeline.queue.P ipeline[pandas.core.frame.DataFrame], start_event:Optional[threading.Event]=None, stop_event:Optional[threading.Event]=None, interrupt_event:Optional[threading.Event]=None, exit_event:Optional[threading.Event]=None, flash_event:Optional[threading.Event]=None)
*Consume data from the pipeline
main entry to the flash thread data in pipeline is a tuple of (torque_table, flash_start_row)*
| Type | Default | Details | |
|---|---|---|---|
| flash_pipeline | Pipeline | flash pipeline | |
| start_event | Optional | None | input event start | 
| stop_event | Optional | None | input event stop | 
| interrupt_event | Optional | None | input event interrupt | 
| exit_event | Optional | None | input event exit | 
| flash_event | Optional | None | input event flash |