Commit 528c1f25 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Register to timer callbacks

parent dce84547
......@@ -217,6 +217,18 @@ class sdlHandler(QObject):
self.msc.emit('in', tm_name)
self.log_area.addItem('Received event "{}"'.format(tm_name))
def set_timer(self, name, duration):
''' Callback function when the SDL model sets a timer '''
self.msc.emit('in', 'SET_{}({})'.format(name, duration))
self.log_area.addItem('Received event "SET_{}({})"'
.format(name, duration))
def reset_timer(self, name):
''' Callback function when the SDL model resets a timer '''
self.msc.emit('in', 'RESET_{}'.format(name))
self.log_area.addItem('Received event "RESET_{}"'
def set_paramless_tc(self):
''' Once the DLL is loaded set the buttons to send paramless TC '''
# tc_area and buttons have to be in self because of known pyside bug
......@@ -250,9 +262,17 @@ class sdlHandler(QObject):
def init_timers(self):
''' When loading the DLL, initialize timers/set callbacks, etc '''
# Define a single function to handle all timer SET functions
set_func = ctypes.CFUNCTYPE(None, ctypes.c_char_p, ctypes.c_int)
reset_func = ctypes.CFUNCTYPE(None, ctypes.c_char_p)
self.set_timer_wrap = set_func(self.set_timer)
self.reset_timer_wrap = reset_func(self.reset_timer)
for each in self.proc.timers:
self.timers[each] = 'unset'
register_set_func = getattr(self.dll, 'register_SET_{}'
register_reset_func = getattr(self.dll, 'register_RESET_{}'
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