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

SDL simulator: handle continuous signals

parent 15cac722
......@@ -816,6 +816,27 @@ class sdlHandler(QObject):
self.add_to_msc('in', tm_name)
self.log_area.addItem('Received event "{}"'.format(tm_name))
def check_queue(self, res):
''' Callback function invoked by OG-generated code to check if there
is a pending message in the input queue of the state machine. Used
to let the user decide if continuous signals shall be processed '''
# res is of type ctypes.POINTER(c_int) -> res[0]=0 to set False,
# meaning that there is no message pending in the queue
question = QMessageBox(self.parent,
'Evaluate Continuous States', '')
question.setText('Do you want to send a new message'
' or evaluate continuous signals (default)?')
question.addButton('Send message', QMessageBox.AcceptRole)
question.addButton('Evaluate continuous signals',
ans = question.exec_()
if ans == QMessageBox.AcceptRole:
res[0] = 1
res[0] = 0
def external_proc_handler(self, name, *args):
''' Callback function when an external procedure is invoked
Parameters: name is the name of the external procedure, and
......@@ -832,7 +853,7 @@ class sdlHandler(QObject):
# Create native ASN.1 type
typename = spec['type'].ReferencedTypeName.replace('-', '_')
asn1_instance = getattr(ASN1, typename)(ptr=val)
# Input parameters: copy the content in the ASN.1 Swig type
# Input parameters: copy the content in the ASN.1 instance
if spec['direction'] == 'in':
interface['in'].append((spec, asn1_instance))
......@@ -867,8 +888,7 @@ class sdlHandler(QObject):
for _, _, asn1_instance in interface['out']:
call_str = u'{}({})'.format(name,
', '.join(chain(inp, outp)))
call_str = u'{}({})'.format(name, ', '.join(chain(inp, outp)))
self.add_to_msc('procedure_call', call_str)
self.log_area.addItem('Call to {}'.format(call_str))
......@@ -1010,7 +1030,11 @@ class sdlHandler(QObject):
register_func = getattr(self.dll, "register_{}"
# Register the Check_Queue function
func = ctypes.CFUNCTYPE(None, ctypes.POINTER(ctypes.c_int))
register_func = getattr(self.dll, "register_check_queue")
self.check_queue_callback = func(self.check_queue)
def init_timers(self):
''' When loading the DLL, initialize timers/set callbacks, etc '''
Supports Markdown
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