示例#1
0
 def __init__(self, *args, **kwargs):
     QtGui.QMainWindow.__init__(self, *args, **kwargs)
     
     ''' 1. members '''
     self.builder = GBuilder()
     self.monitor = Monitor()
     self.setWindowTitle('TUMCreate - Automotive Simulator')
     self.setWindowIcon(QtGui.QIcon(os.path.join(os.path.dirname(__file__), r'../icons/tumcreatelogo2.png')))
     
     ''' 2. initialize the gui factories '''
     ViewerPluginFactory().load_classes()
     SettingsPluginFactory().load_classes()
     
     ''' 3. actions '''
     self.init_actions()
     self.create_widgets()
示例#2
0
bus_spec = SimpleBusSpec(['CAN_0', 'CAN_1', 'CAN_2'])
bus_group = api.set_busses(sim_env, 3, 'StdCANBus', bus_spec)
 
# Connect ECUs and Gateways to the busses
# Connect CAN 0 via GW1 to CAN 1 // Connect CAN 1 via GW 2 to CAN 2
api.connect_bus_by_obj(sim_env, 'CAN_0', ecu_group_1  + gateway_group_1) 
api.connect_bus_by_obj(sim_env, 'CAN_1', gateway_group_1 + ecu_group_3 + gateway_group_2)
api.connect_bus_by_obj(sim_env, 'CAN_2', ecu_group_4 + gateway_group_2)


#===========================================================================
#     Monitoring and Export of Results
#===========================================================================

# 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)
示例#3
0
    api.apply_timing_functions_set(sim_env, ecu.ecu_id, t_set2)
     
# Define streams: Attention this definition of MessageStream objects has to be conform with the 
#                 definition of the sending_actions of the ecus. See above
# Note:  the disclosure delay defines the delay with which the message can be verified. Defined in 
#        sending intervals
stream_1 = MessageStream('RegularSecureECU_15', ['TEST ECU 9', 'TEST ECU 10'], can_registration.CAN_TEST_MSG, start_time=160, sending_interval=0.1, disclosure_delay=1)
stream_2 = MessageStream('TEST ECU 11', ['TEST ECU 9'], can_registration.CAN_TEST_MSG_2, start_time=150, sending_interval=0.2, disclosure_delay=1)

api.set_stream(sim_env, stream_1)
api.set_stream(sim_env, stream_2)
    
#===========================================================================
#     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
示例#4
0
文件: main_tls.py 项目: xding/IVNS
    t_set2.set_mapping_from_function_set(ecu.ecu_id, ecu_func_set) 
    api.apply_timing_functions_set(sim_env, ecu.ecu_id, t_set2)
     
# define streams
stream_1 = MessageStream('RegularSecureECU_15', ['TEST ECU 9', 'TEST ECU 10'], can_registration.CAN_TEST_MSG)
stream_2 = MessageStream('TEST ECU 11', ['TEST ECU 10'], can_registration.CAN_TEST_MSG_2)

api.set_stream(sim_env, stream_1)
api.set_stream(sim_env, stream_2)
    
#===========================================================================
#     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
示例#5
0
api.connect_bus_by_obj(sim_env, 'CAN_0', ecu_group_1  + gateway_group_1) 
api.connect_bus_by_obj(sim_env, 'CAN_1', gateway_group_1 + ecu_group_3 + gateway_group_2)
api.connect_bus_by_obj(sim_env, 'CAN_2', ecu_group_4 + gateway_group_2)
 
#===========================================================================
#     Monitoring and Export of Results
#
#    Structure:
#    environment connected to monitor object
#    monitor object connected to ResultReader object
#    ResultReader publishes data to the Interpreters
#    Interpreters pass the data to connected GUI and/or to Files
#===========================================================================

# 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)
示例#6
0
文件: main.py 项目: xding/IVNS
t_set = TimingFunctionSet()
ecu_func_set = StdSecurLwSecModTimingFunctions(main_library_tag='CyaSSL')
ecu_func_set.library_tags['t_ecu_auth_reg_msg_validate_cert'] = 'Crypto_Lib_SW'

t_set.set_mapping_from_function_set('SEC 1', ecu_func_set)
api.apply_timing_functions_set(my_env, 'SEC 1', t_set)

t_set2 = TimingFunctionSet()
ecu_func_set = StdSecurECUTimingFunctions(main_library_tag='CyaSSL')
ecu_func_set.library_tags['t_adv_msg_secmodcert_enc'] = 'Crypto_Lib_SW'

# SET ALL GATEWAY FILTERS, Bus dependent from the streams
api.autoset_gateway_filters(my_env, 'SEC 1')

for ecu in APICore()._ecu_list_from_groups(
    [[ecu_group_1 + ecu_group_3 + ecu_group_4]]):  # UNINTENDED HACK
    t_set2.set_mapping_from_function_set(ecu.ecu_id, ecu_func_set)
    api.apply_timing_functions_set(my_env, ecu.ecu_id, t_set2)

# Save environment
# filepath = os.path.join(os.path.dirname(__file__), "environments/1.env")
# api.save_env_spec(my_env, filepath)
# my_env = api.load_env_spec(filepath)

# Monitor Test (optional)
my_moni = Monitor()
api.connect_monitor(my_env, my_moni, 5)  # Connect monitor to environment

api.build_simulation(my_env)
api.run_simulation(my_env)