Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
asn1-value-editor
Commits
34db2b1c
Commit
34db2b1c
authored
Mar 20, 2015
by
Maxime Perrotin
Browse files
Merge branch 'master' of gitrepos.estec.esa.int:taste/asn1-value-editor
Conflicts: asn1_value_editor/resources.py
parents
d6496c13
fc906bab
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
asn1_value_editor/resources.py
View file @
34db2b1c
This diff is collapsed.
Click to expand it.
asn1_value_editor/sdlHandler.py
View file @
34db2b1c
...
...
@@ -139,6 +139,9 @@ class sdlHandler(QObject):
reset_button
.
clicked
.
connect
(
self
.
reset_simulation
)
undo_button
.
clicked
.
connect
(
self
.
undo
)
redo_button
.
clicked
.
connect
(
self
.
redo
)
# Placeholder to keep a list of properties to be checked at runtime
self
.
properties
=
[]
self
.
prop_dll
=
None
@
property
def
dll
(
self
):
...
...
@@ -200,6 +203,47 @@ class sdlHandler(QObject):
self
.
check_state
()
self
.
init_state
=
self
.
current_hash
=
self
.
on_event
()
self
.
init_timers
()
# Try loading property file
self
.
load_properties
()
def
load_properties
(
self
):
''' Try loading a shared object with properties to verify
Properties are e.g. stop conditions, processed by the "properties.py"
module, and transformed to Ada code compiled as a dynamic library.
There may be several properties, this function tries to retrieve
them all without a priori knowledge of their content '''
try
:
self
.
prop_dll
=
ctypes
.
CDLL
(
'lib{}_stop_conditions.so'
.
format
(
self
.
proc
.
processName
))
except
OSError
as
err
:
self
.
log_area
.
addItem
(
'No properties to load'
)
else
:
self
.
log_area
.
addItem
(
'Found property file'
)
idx
=
0
while
True
:
try
:
prop
=
getattr
(
self
.
prop_dll
,
'_property_{}'
.
format
(
idx
))
prop
.
restype
=
ctypes
.
c_char
self
.
properties
.
append
(
prop
)
except
AttributeError
:
break
else
:
idx
+=
1
self
.
log_area
.
addItem
(
'Loaded {} properties'
.
format
(
idx
))
def
check_properties
(
self
):
''' Check the properties at runtime
First copy the running system state to the property system state,
then execute each property and check the return value '''
if
not
self
.
prop_dll
:
return
self
.
restore_global_state
(
self
.
current_hash
,
dll
=
self
.
prop_dll
)
for
idx
,
check
in
enumerate
(
self
.
properties
):
if
not
check
():
self
.
log_area
.
addItem
(
'Property {} was violated'
.
format
(
idx
))
@
Slot
()
def
startStop
(
self
):
...
...
@@ -244,13 +288,14 @@ class sdlHandler(QObject):
self
.
current_hash
=
self
.
on_event
()
self
.
msc_redo
.
emit
()
def
restore_global_state
(
self
,
statehash
):
def
restore_global_state
(
self
,
statehash
,
dll
=
None
):
''' From a hashcode, restore a global state in the DLL (state +
all internal variables '''
target
=
dll
or
self
.
dll
target_state
=
self
.
set_of_states
[
statehash
]
for
idx
,
(
var
,
(
sort
,
_
))
in
enumerate
(
self
.
proc
.
variables
.
viewitems
()):
# get internal variables, translate them to swig, and print them
setter_ptr
=
getattr
(
self
.
dll
,
"_set_{}"
.
format
(
var
))
setter_ptr
=
getattr
(
target
,
"_set_{}"
.
format
(
var
))
value_asn1
=
target_state
[
idx
]
try
:
value_swig_ptr
=
int
(
value_asn1
.
_ptr
)
...
...
@@ -262,9 +307,10 @@ class sdlHandler(QObject):
ctypes
.
POINTER
(
ctypes
.
c_uint32
))
setter_ptr
(
value_ptr
)
state_value
=
target_state
[
idx
+
1
]
set_state
=
getattr
(
self
.
dll
,
"_set_state"
)
set_state
=
getattr
(
target
,
"_set_state"
)
set_state
(
ctypes
.
c_char_p
(
state_value
))
self
.
check_state
()
if
target
is
self
.
dll
:
self
.
check_state
()
def
change_internal_state
(
self
):
''' When user press the "Apply" button to change the model's internal
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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