Commit 9bb9706c authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Prepare the simulator for state compositions

parent 1e91337b
......@@ -317,7 +317,7 @@ class sdlHandler(QObject):
def active_tc(self):
''' Yield list of TCs that can be sent (including timeouts) '''
# Find the list of allowed TC based on the current state
st = unicode(self.current_sdl_state.decode('latin1'))
st = self.current_sdl_state
inputs = self.proc.mapping[st.replace(UNICODE_SEP, '_').lower()]
allowed_tc = (tc for each in inputs for tc in each.inputlist)
for each in allowed_tc:
......@@ -387,7 +387,7 @@ class sdlHandler(QObject):
'{}_state'.format(self.proc.processName))
self.get_sdl_state.restype = ctypes.c_char_p
# Initialization: set current state and internal variables
self.current_sdl_state = ''
self.current_sdl_state = u''
self.check_state()
self.init_timers()
self.init_state = self.current_hash = self.on_event()
......@@ -472,13 +472,14 @@ class sdlHandler(QObject):
def check_state(self):
''' Highlight the current state on the statechart diagram
Return True if the state has changed '''
state = self.get_sdl_state()
state = self.get_sdl_state().decode('latin1')
if state != self.current_sdl_state:
self.current_sdl_state = state
self.sdl_scene.clear_highlight()
state = state.decode('latin1') # Recover the unicode chars
for each in self.sdl_scene.find_text(u'\\b{}\\b'.format(state)):
self.sdl_scene.highlight(each)
composition = state.split(UNICODE_SEP)
for each in composition:
for symb in self.sdl_scene.find_text(u'\\b{}\\b'.format(each)):
self.sdl_scene.highlight(symb)
self.log_area.addItem('New state: {}'.format(CleanName(state)))
return True
return False
......@@ -591,8 +592,12 @@ class sdlHandler(QObject):
# Add the SDL state to the new global state
complete_state.append(self.current_sdl_state)
# Update the SDL state in the global state panel
# state_as_pyside = vn.fromValueNotationToPySide('Current SDL state',
# '{}'.format(self.current_sdl_state.lower().replace('_', '-')
# .replace(UNICODE_SEP, '--')))
readable_state = self.current_sdl_state.replace(UNICODE_SEP, '--')
state_as_pyside = vn.fromValueNotationToPySide('Current SDL state',
'{}'.format(self.current_sdl_state.lower().replace('_', '-')))
readable_state.lower().replace('_', '-'))
self.asn1_editor.updateVariable(state_as_pyside,
root=self.tree_items['_states'])
# And save this new state in the graph, if it was not there yet
......@@ -610,21 +615,15 @@ class sdlHandler(QObject):
self.log_area.addItem('Sent {}({})'.format(tc_name,
param or ''))
self.check_properties(new_hash)
# TEMP TO TEST
# for name, typedef in self.proc.dataview.viewitems():
# if name != 'MySeq': continue
# print 'All combinations of ', name
# for combi in compute_combinations(typedef, self.proc.dataview):
# print combi
# END TEMP
return new_hash
def update_button_state(self, tc_name=None):
''' Depending on the current SDL state, enable or disable the buttons
for sending TCs '''
# Find the list of allowed TC based on the current state
st = unicode(self.current_sdl_state.decode('latin1'))
inputs = self.proc.mapping[st.replace(UNICODE_SEP, '_').lower()]
st = self.current_sdl_state.split(UNICODE_SEP)
st = st[0] # TODO: Replace with proper support of composite states
inputs = self.proc.mapping[st.lower()]
allowed_tc = []
for each in inputs:
allowed_tc.extend(each.inputlist)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment