Beispiel #1
0
# create a Monitor and connect it to the environment
monitor = Monitor()
monitor.set_sample_time(0.48)
api.connect_monitor(sim_env, monitor, 0.5)  

# create a Result Reader that is used to export the 
# simulation results to the GUI or to a file
result_reader = ResultReader()
save_path_cp = os.path.join(os.path.dirname(__file__), "logs/checkpoints.csv")
save_path_buf = os.path.join(os.path.dirname(__file__), "logs/buffer.csv")
save_path_can = os.path.join(os.path.dirname(__file__), "logs/can_bus.csv")

# enable certain handlers to define which export has to be made
# a result reader receives the interpreter to be used and the InterpreterOptions enum
# defining how the export should be performed
result_reader.enable_handler(BufferInterpreter, [InterpreterOptions.CONNECTION, InterpreterOptions.CSV_FILE], save_path_buf) 
result_reader.enable_handler(CheckpointInterpreter, [ InterpreterOptions.TIMING_FILE], save_path_cp)
result_reader.enable_handler(EventlineInterpreter, [InterpreterOptions.CSV_FILE], save_path_cp)  # CSV Live Tracking
result_reader.enable_handler(CanBusInterpreter, [InterpreterOptions.CSV_MSG_FILE, InterpreterOptions.CSV_DR_FILE], save_path_can)

# connect the result reader to the monitor
api.connect_result_reader(sim_env, monitor, result_reader)


#===========================================================================
#     Build and run simulation
#===========================================================================

# run the simulation
api.build_simulation(sim_env)
api.run_simulation(sim_env)
Beispiel #2
0
#     Monitoring and Export of Results
#===========================================================================

# Create a Monitor and Reader
my_moni = Monitor()
my_moni.set_sample_time(0.48)
api.connect_monitor(sim_env, my_moni, 0.5)  # Connect monitor to environment
my_reader = ResultReader()

# enable handlers
save_path_cp = os.path.join(os.path.dirname(__file__), "logs/checkpoints.csv")
save_path_cp_2 = os.path.join(os.path.dirname(__file__), "logs/checkpoints2.csv")
save_path_buf = os.path.join(os.path.dirname(__file__), "logs/buffer.csv")
save_path_can = os.path.join(os.path.dirname(__file__), "logs/can_bus.csv")
 
my_reader.enable_handler(BufferInterpreter, [InterpreterOptions.CONNECTION, InterpreterOptions.CSV_FILE], save_path_buf)  # If connected to GUI this step is done automatically by GUI
my_reader.enable_handler(CheckpointInterpreter, [ InterpreterOptions.TIMING_FILE], save_path_cp)
my_reader.enable_handler(EventlineInterpreter, [InterpreterOptions.CSV_FILE], save_path_cp_2)  # CSV Live Tracking
my_reader.enable_handler(CanBusInterpreter, [InterpreterOptions.CSV_FILE], save_path_can)
api.connect_result_reader(sim_env, my_moni, my_reader)  # Connect result reader

#===============================================================================
#     Connect Reader to GUI
#===============================================================================

# Create a GUI and connect it to the monior
direct_view = gui.direct_view_window.DirectViewer()

# available Plugins: BufferViewPlugin, CanBusStateViewPlugin, CanBusViewPlugin, CheckpointViewPlugin, 
#                    ConstellationViewPlugin, ECUMessagesViewPlugin, EventlineViewPlugin, MessageCountViewPlugin
sim_env.gui_lock_sync.acquire()  # optionally ensure thread synchronization
Beispiel #3
0
    
#===========================================================================
#     Monitoring and Export of Results
#===========================================================================

# Create a Monitor and Reader
my_moni = Monitor()
my_moni.set_sample_time(0.48)
api.connect_monitor(sim_env, my_moni, 0.5)  # Connect monitor to environment
my_reader = ResultReader()

# enable handlers
save_path_cp = os.path.join(os.path.dirname(__file__), "logs/checkpoints.csv")
save_path_cp_2 = os.path.join(os.path.dirname(__file__), "logs/checkpoints2.csv")
save_path_buf = os.path.join(os.path.dirname(__file__), "logs/buffer.csv")
save_path_can = os.path.join(os.path.dirname(__file__), "logs/can_bus.csv")
 
my_reader.enable_handler(BufferInterpreter, [InterpreterOptions.CONNECTION, InterpreterOptions.CSV_FILE], save_path_buf)  # If connected to GUI this step is done automatically by GUI
my_reader.enable_handler(CheckpointInterpreter, [ InterpreterOptions.TIMING_FILE], save_path_cp)
my_reader.enable_handler(EventlineInterpreter, [InterpreterOptions.CSV_FILE], save_path_cp_2)  # CSV Live Tracking
my_reader.enable_handler(CanBusInterpreter, [InterpreterOptions.CSV_FILE], save_path_can)
api.connect_result_reader(sim_env, my_moni, my_reader)  # Connect result reader

#===============================================================================
#     Connect Reader to GUI
#===============================================================================

# Create a GUI and connect it to the monior
direct_view = gui.direct_view_window.DirectViewer()

# available Plugins: BufferViewPlugin, CanBusStateViewPlugin, CanBusViewPlugin, CheckpointViewPlugin, 
Beispiel #4
0
# create a Monitor and connect it to the environment
monitor = Monitor()
monitor.set_sample_time(0.48)
api.connect_monitor(sim_env, monitor, 0.5)  

# create a Result Reader that is used to export the 
# simulation results to the GUI or to a file
result_reader = ResultReader()
save_path_cp = os.path.join(os.path.dirname(__file__), "logs/checkpoints.csv")
save_path_buf = os.path.join(os.path.dirname(__file__), "logs/buffer.csv")
save_path_can = os.path.join(os.path.dirname(__file__), "logs/can_bus.csv")

# enable certain handlers to define which export has to be made
# a result reader receives the interpreter to be used and the InterpreterOptions enum
# defining how the export should be performed
result_reader.enable_handler(BufferInterpreter, [InterpreterOptions.CONNECTION, InterpreterOptions.CSV_FILE], save_path_buf) 
result_reader.enable_handler(CheckpointInterpreter, [ InterpreterOptions.TIMING_FILE], save_path_cp)
result_reader.enable_handler(EventlineInterpreter, [InterpreterOptions.CSV_FILE], save_path_cp)  # CSV Live Tracking
result_reader.enable_handler(CanBusInterpreter, [InterpreterOptions.CSV_MSG_FILE, InterpreterOptions.CSV_DR_FILE], save_path_can)

# connect the result reader to the monitor
api.connect_result_reader(sim_env, monitor, result_reader)


#===========================================================================
#     Build and run simulation
#===========================================================================

# run the simulation
api.build_simulation(sim_env)
api.run_simulation(sim_env)