Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
asn1-value-editor
Commits
de8aedd0
Commit
de8aedd0
authored
Jul 07, 2015
by
Maxime Perrotin
Browse files
Register to callback function for external proc
parent
1a77c12a
Changes
1
Hide whitespace changes
Inline
Side-by-side
asn1_value_editor/sdlHandler.py
View file @
de8aedd0
...
...
@@ -287,6 +287,8 @@ class sdlHandler(QObject):
# In the simulation panel, set the buttons to send paramless TC/timers
self
.
set_paramless_tc
()
self
.
set_paramless_tm
()
# Add handler to callback functions for SDL external procedure calls
self
.
register_external_procedures
()
self
.
get_sdl_state
=
getattr
(
value
,
'{}_state'
.
format
(
self
.
proc
.
processName
))
self
.
get_sdl_state
.
restype
=
ctypes
.
c_char_p
...
...
@@ -599,6 +601,11 @@ class sdlHandler(QObject):
self
.
add_to_msc
(
'in'
,
tm_name
)
self
.
log_area
.
addItem
(
'Received event "{}"'
.
format
(
tm_name
))
def
external_proc_handler
(
self
,
name
,
*
args
):
''' Callback function when an external procedure is called '''
self
.
log_area
.
addItem
(
'Call to external procedure {}'
.
format
(
name
))
def
set_timer
(
self
,
name
,
duration
):
''' Callback function when the SDL model sets a timer '''
self
.
add_to_msc
(
'set'
,
'SET_{}_{}'
.
format
(
name
,
duration
))
...
...
@@ -648,6 +655,21 @@ class sdlHandler(QObject):
.
format
(
each
[
'name'
]))
register_func
(
self
.
tm_func
)
def
register_external_procedures
(
self
):
''' Once the DLL is loaded, register the external procedures
specified in the SDL model and connect them to handling function '''
# External procedures have a non-fixed number of parameters
# but the first one is always a char string (name of procedure)
func
=
ctypes
.
CFUNCTYPE
(
None
,
ctypes
.
c_char_p
)
self
.
proc_handler
=
func
(
self
.
external_proc_handler
)
for
each
in
self
.
proc
.
procedures
:
if
not
each
.
external
:
continue
register_func
=
getattr
(
self
.
dll
,
"register_{}"
.
format
(
each
.
inputString
))
register_func
(
self
.
proc_handler
)
def
init_timers
(
self
):
''' When loading the DLL, initialize timers/set callbacks, etc '''
# Define a single function to handle all timer SET functions
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment