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): ...@@ -816,6 +816,27 @@ class sdlHandler(QObject):
self.add_to_msc('in', tm_name) self.add_to_msc('in', tm_name)
self.log_area.addItem('Received event "{}"'.format(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',
QMessageBox.RejectRole)
ans = question.exec_()
if ans == QMessageBox.AcceptRole:
res[0] = 1
else:
res[0] = 0
def external_proc_handler(self, name, *args): def external_proc_handler(self, name, *args):
''' Callback function when an external procedure is invoked ''' Callback function when an external procedure is invoked
Parameters: name is the name of the external procedure, and Parameters: name is the name of the external procedure, and
...@@ -832,7 +853,7 @@ class sdlHandler(QObject): ...@@ -832,7 +853,7 @@ class sdlHandler(QObject):
# Create native ASN.1 type # Create native ASN.1 type
typename = spec['type'].ReferencedTypeName.replace('-', '_') typename = spec['type'].ReferencedTypeName.replace('-', '_')
asn1_instance = getattr(ASN1, typename)(ptr=val) 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': if spec['direction'] == 'in':
interface['in'].append((spec, asn1_instance)) interface['in'].append((spec, asn1_instance))
else: else:
...@@ -867,8 +888,7 @@ class sdlHandler(QObject): ...@@ -867,8 +888,7 @@ class sdlHandler(QObject):
for _, _, asn1_instance in interface['out']: for _, _, asn1_instance in interface['out']:
outp.append(asn1_instance.GSER()) outp.append(asn1_instance.GSER())
del(asn1_instance) del(asn1_instance)
call_str = u'{}({})'.format(name, call_str = u'{}({})'.format(name, ', '.join(chain(inp, outp)))
', '.join(chain(inp, outp)))
self.add_to_msc('procedure_call', call_str) self.add_to_msc('procedure_call', call_str)
self.log_area.addItem('Call to {}'.format(call_str)) self.log_area.addItem('Call to {}'.format(call_str))
...@@ -1010,7 +1030,11 @@ class sdlHandler(QObject): ...@@ -1010,7 +1030,11 @@ class sdlHandler(QObject):
register_func = getattr(self.dll, "register_{}" register_func = getattr(self.dll, "register_{}"
.format(each.inputString)) .format(each.inputString))
register_func(self.proc_handlers[each.inputString.lower()][0]) register_func(self.proc_handlers[each.inputString.lower()][0])
# 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)
register_func(self.check_queue_callback)
def init_timers(self): def init_timers(self):
''' When loading the DLL, initialize timers/set callbacks, etc ''' ''' When loading the DLL, initialize timers/set callbacks, etc '''
......
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