Commit c1e96e33 authored by Maxime Perrotin's avatar Maxime Perrotin

Fixes with handling of timers in SDL simulation

parent 39117447
......@@ -30,6 +30,7 @@ LICENSE: LGPL - see LICENSE file
CHANGELOG:
1.8.2 - Proper handling of timers in SDL simulation
1.8.1 - Fixed minor regression in sdl simulation
1.8.0 - Refactor the UserWidgets, allowing easier customisation of TM/TC handling
1.7.8 - Minor fix in Scenario.py
......
......@@ -16,7 +16,7 @@
__author__ = "Maxime Perrotin"
__license__ = "LGPLv3"
__version__ = "1.8.1"
__version__ = "1.8.2"
__url__ = "https://taste.tools"
import sys
......
......@@ -186,12 +186,13 @@ class sdlHandler(QObject):
try:
inputs = self.proc.mapping[curr_state]
except KeyError:
# Raised in there is a bug in the tool
# Raised if there is a bug in the tool
print curr_state, 'not in', self.proc.mapping.keys(), '(BUG?)'
else:
allowed_tc = (tc for each in inputs for tc in each.inputlist)
for each in allowed_tc:
if each in self.timers and not self.buttons[each].isEnabled():
if each in self.timers and not \
self.buttons[each.lower()].isEnabled():
# Timers: check if button is active
continue
yield each
......@@ -550,36 +551,6 @@ class sdlHandler(QObject):
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
# Removed all the logic below, self.active_tc is doing it already
# st = self.current_sdl_state.split(UNICODE_SEP)
# st_iter = st.pop(0)
# context = self.proc
# statename = '_'.join(st).lower()
# def find_allowed_tc(context, statename):
# try:
# inputs = context.mapping[statename.lower()]
# for each in inputs:
# for inp in each.inputlist:
# yield inp
# except KeyError as err:
# # FIXME: State Aggregations are not in context.mapping
# print('State {} not supported/found'.format(statename))
#
# print '1'
# allowed_tc = list(find_allowed_tc(context, st_iter))
# print '2'
#
# while len(st):
# # Handle state composition (when model is not flattened)
# next_st = st.pop(0)
# for each in context.composite_states:
# if each.statename.lower() == st_iter.lower():
# context = each
# break
# allowed_tc.extend(list(find_allowed_tc(context, next_st)))
# st_iter = next_st
# Remove timers from the list
allowed_tc = set(self.active_tc) - set(self.proc.timers)
# Enable/disable the parameterless TC buttons accordingly
......@@ -588,8 +559,13 @@ class sdlHandler(QObject):
# Ignore timers, they are handled differently, below
continue
button.setEnabled(tc in allowed_tc)
if tc_name in self.timers:
self.buttons[tc_name].setEnabled(False)
# Don't disable timer buttons here, because this function is called
# AFTER the transition, and during the transition there may be
# another SET timer which would need the button to remain enable
# Diabling of the button has to be done immediately after the click,
# i.e. in the send_tc function
#if tc_name in self.timers:
# self.buttons[tc_name.lower()].setEnabled(False)
# Emit the list of allowed TC for the GUI to update other buttons
self.allowed_messages.emit(allowed_tc)
......@@ -629,9 +605,9 @@ class sdlHandler(QObject):
Doing so enables Undo/Redo, MSC Trace, etc. '''
if name not in self.active_tc:
return
if name in self.buttons:
if name.lower() in self.buttons:
# paramless TC
self.buttons[name].click()
self.buttons[name.lower()].click()
else:
# tc with a param, use the Send button
for vals in self.param_tc_editors:
......@@ -796,6 +772,9 @@ class sdlHandler(QObject):
self.msc_macro_start.emit()
with undo.UndoMacro(self.undo_stack, 'Send TC'):
if name in self.timers:
# immediately disable the button, but it may be re-enabled
# by the callback during the execution of the transition
self.buttons[name.lower()].setEnabled(False)
self.add_to_msc('timeout', name)
else:
msg = '{tc}{arg}'.format(tc=name,
......@@ -915,14 +894,14 @@ class sdlHandler(QObject):
self.add_to_msc('set', 'SET_{}_{}'.format(name, duration))
self.log_area.addItem('Received event "SET_{}({})"'
.format(name, duration))
self.buttons[name].setEnabled(True)
self.buttons[name.lower()].setEnabled(True)
def reset_timer(self, name):
''' Callback function when the SDL model resets a timer '''
self.add_to_msc('reset', 'RESET_{}'.format(name))
self.log_area.addItem('Received event "RESET_{}"'
.format(name))
self.buttons[name].setEnabled(False)
self.buttons[name.lower()].setEnabled(False)
def set_dock_checker(self):
''' Once the DLL is loaded, fill in the checker tab with the list of
......@@ -967,9 +946,9 @@ class sdlHandler(QObject):
# Find parameterless input signals and create buttons
for each in self.proc.input_signals:
if 'type' not in each:
self.buttons[each['name']] = QPushButton(each['name'])
self.buttons[each['name'].lower()] = QPushButton(each['name'])
for each in self.proc.timers:
self.buttons[each] = QPushButton(each+' timeout')
self.buttons[each.lower()] = QPushButton(each+' timeout')
col, row = 0, 0
for name, button in self.buttons.viewitems():
self.tc_area.addWidget(button, row, col)
......@@ -1065,7 +1044,7 @@ class sdlHandler(QObject):
self.reset_timer_wrap = reset_func(self.reset_timer)
for each in self.proc.timers:
self.timers[each] = 'unset'
self.buttons[each].setEnabled(False)
self.buttons[each.lower()].setEnabled(False)
register_set_func = getattr(self.dll, 'register_SET_{}'
.format(each))
register_set_func(self.set_timer_wrap)
......
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