Commit 8fd4b2b7 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Proper tabification and setup of automatic simulation

parent 1f28a173
This diff is collapsed.
......@@ -28,7 +28,7 @@ from itertools import chain
from PySide.QtGui import (QDockWidget, QPushButton, QGridLayout, QListWidget,
QUndoStack, QUndoCommand, QToolButton, QTableWidget,
QTableWidgetItem, QComboBox)
from PySide.QtCore import QObject, Signal, Slot, Qt, QFile
from PySide.QtCore import QObject, Signal, Slot, Qt, QFile, QTimer
from PySide.QtUiTools import QUiLoader
import asn1_value_editor
......@@ -241,6 +241,10 @@ class sdlHandler(QObject):
self.prop_dll = None
# VDM handler instance, when needed for external procedures calls
self.vdm = None
# Reference to the random simulator/checker table (set with DLL)
self.checker_table = None
# Parameter when using automatic simulation (random/exhaustive)
self.sim_param = {'state': 'manual', 'periodic': [], 'random': []}
def active_tc(self):
......@@ -291,6 +295,7 @@ class sdlHandler(QObject):
self.parent.tabifyDockWidget(self.dock_state, self.dock_simu)
self.parent.tabifyDockWidget(self.dock_simu, self.dock_checker)
# Add the state list to the ASN.1 Editor (at row 0)
row = 0
statenames = [CleanName(s) for s in self.proc.mapping.viewkeys()
......@@ -308,7 +313,7 @@ class sdlHandler(QObject):
# Fill in data in the checker panel
self.checker_table = self.set_dock_checker()
# Add handler to callback functions for SDL external procedure calls
self.get_sdl_state = getattr(value,
......@@ -571,6 +576,25 @@ class sdlHandler(QObject):
return docks
def random_step(self):
''' One step of random simulation '''
print 'Simulation step'
if self.sim_param['state'] == 'random':
QTimer().singleShot(1000, self.random_step)
def random_simulation(self):
''' Random simulator - read the config from the checker_table and
call TC either randomly or periodically, until the stop button is
pressed '''
print 'Random simulation'
self.sim_param['state'] = 'random'
QTimer().singleShot(1000, self.random_step)
def stop_simulation(self):
''' Stop a random or exhaustive simulation '''
print 'End of simulation'
self.sim_param['state'] = 'manual'
def add_to_msc(self, direction, msg):
''' Create an undo command and display message on the MSC diagram '''
......@@ -716,7 +740,7 @@ class sdlHandler(QObject):
def set_checker_dock(self):
def set_dock_checker(self):
''' Once the DLL is loaded, fill in the checker tab with the list of
TCs to allow user configuring the behaviour of the random and
exhaustive simulators. Each TC trigger can be configured as periodic,
......@@ -724,16 +748,22 @@ class sdlHandler(QObject):
customised to limit the range of values used in the simulator
(this feature is not implemented yet) '''
widget = self.dock_checker.widget()
self.checker_table = widget.findChild(QTableWidget, 'tableWidget')
checker_table = widget.findChild(QTableWidget, 'tableWidget')
for idx, inp in enumerate(self.proc.input_signals):
name = inp['name']
item = QTableWidgetItem(name)
combo = QComboBox()
combo.addItems(('Manual', 'Random', 'Periodic'))
self.checker_table.setItem(idx, 0, item)
self.checker_table.setCellWidget(idx, 1, combo)
checker_table.setItem(idx, 0, item)
checker_table.setCellWidget(idx, 1, combo)
# Plug the "Random" button to the function handling random simulation
random_btn = widget.findChild(QToolButton, 'randomButton')
stop_btn = widget.findChild(QToolButton, 'stopButton')
return checker_table
def set_paramless_tc(self):
''' Once the DLL is loaded set the buttons to send paramless TC '''
......@@ -19,21 +19,21 @@
<layout class="QHBoxLayout" name="horizontalLayout">
<widget class="QToolButton" name="resetButton">
<widget class="QToolButton" name="randomButton">
<property name="text">
<widget class="QToolButton" name="undoButton">
<widget class="QToolButton" name="exhaustButton">
<property name="text">
<widget class="QToolButton" name="redoButton">
<widget class="QToolButton" name="stopButton">
<property name="text">
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