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
6bd655a7
Commit
6bd655a7
authored
Mar 21, 2015
by
Maxime Perrotin
Browse files
Specify property file with the cli
parent
34271366
Changes
3
Hide whitespace changes
Inline
Side-by-side
asn1_value_editor/gui.py
View file @
6bd655a7
...
...
@@ -16,7 +16,7 @@ import sys
import
platform
import
re
import
logging
import
opt
parse
import
arg
parse
import
time
from
functools
import
partial
from
ctypes
import
CDLL
...
...
@@ -130,7 +130,7 @@ def gui():
# Exit app on Ctrl-C
signal
.
signal
(
signal
.
SIGINT
,
signal
.
SIG_DFL
)
usage
=
'usage: gui.py [--udp=IP_Address:in_Port:out_Port]'
#
usage = 'usage: gui.py [--udp=IP_Address:in_Port:out_Port]'
version
=
'taste auto-gui %s'
%
(
__version__
)
# Set up the logging facilities
...
...
@@ -143,19 +143,22 @@ def gui():
sys
.
stdout
=
myPrint
# Parse the command line
parser
=
opt
parse
.
OptionParser
(
usage
=
usage
,
version
=
version
)
parser
.
add_
option
(
'-
v
'
,
'--verbose'
,
action
=
'store_true'
,
default
=
False
,
parser
=
arg
parse
.
ArgumentParser
(
version
=
version
)
parser
.
add_
argument
(
'-
g
'
,
'--verbose'
,
action
=
'store_true'
,
default
=
False
,
help
=
'Display debug information'
)
parser
.
add_
option
(
'--udp'
,
dest
=
'udp'
,
metavar
=
'RemoteIP:inPort:outPort'
,
parser
.
add_
argument
(
'--udp'
,
dest
=
'udp'
,
metavar
=
'RemoteIP:inPort:outPort'
,
help
=
'Use UDP sockets instead of message queues'
)
parser
.
add_option
(
'-l'
,
'--shared_lib'
,
action
=
'store_true'
,
default
=
False
,
help
=
'Use a shared library instead of msgQ or UDP'
)
parser
.
add_option
(
'-r'
,
'--reset'
,
action
=
'store_true'
,
default
=
False
,
parser
.
add_argument
(
'-l'
,
'--shared_lib'
,
action
=
'store_true'
,
default
=
False
,
help
=
'Simulate SDL system, '
'using a shared library'
)
parser
.
add_argument
(
'-r'
,
'--reset'
,
action
=
'store_true'
,
default
=
False
,
help
=
'Do not try to restore windows layout'
)
parser
.
add_option
(
'-i'
,
'--ivpath'
,
dest
=
'ivpath'
,
parser
.
add_argument
(
'-p'
,
'--properties'
,
dest
=
'properties'
,
help
=
'Specify a file containing stop conditions'
)
parser
.
add_argument
(
'-i'
,
'--ivpath'
,
dest
=
'ivpath'
,
default
=
'./InterfaceView.aadl'
,
help
=
'Path and filename of the system interface view'
)
options
,
args
=
parser
.
parse_args
()
options
=
parser
.
parse_args
()
if
options
.
verbose
:
log
.
setLevel
(
logging
.
DEBUG
)
else
:
...
...
@@ -334,6 +337,8 @@ def gui():
else
:
sdlButton
=
toolbar
.
addAction
(
'SDL'
)
sdlButton
.
triggered
.
connect
(
sdl
.
startStop
)
if
options
.
properties
:
sdl
.
load_properties
(
options
.
properties
)
# Set the ASN.1 data type of each TC editor
...
...
asn1_value_editor/resources.py
View file @
6bd655a7
...
...
@@ -2,7 +2,7 @@
# Resource object code
#
# Created:
Fri
Mar 2
0 20:00:31
2015
# Created:
Sat
Mar 2
1 16:33:04
2015
# by: The Resource Compiler for PySide (Qt v4.8.6)
#
# WARNING! All changes made in this file will be lost!
...
...
asn1_value_editor/sdlHandler.py
View file @
6bd655a7
...
...
@@ -140,7 +140,7 @@ class sdlHandler(QObject):
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
.
properties
=
{}
self
.
prop_dll
=
None
@
property
...
...
@@ -203,33 +203,50 @@ 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
):
def
load_properties
(
self
,
prop_file
=
None
):
''' 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 '''
if
not
prop_file
:
return
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_uint
self
.
properties
.
append
(
prop
)
except
AttributeError
:
break
else
:
idx
+=
1
self
.
log_area
.
addItem
(
'Loaded {} properties'
.
format
(
idx
))
self
.
log_area
.
addItem
(
'lib{}_stop_conditions.so not found'
.
format
(
self
.
proc
.
processName
))
return
properties
=
[]
idx
=
0
while
True
:
try
:
prop
=
getattr
(
self
.
prop_dll
,
'_property_{}'
.
format
(
idx
))
prop
.
restype
=
ctypes
.
c_uint
properties
.
append
(
prop
)
except
AttributeError
:
break
else
:
idx
+=
1
self
.
log_area
.
addItem
(
'Loaded {} properties'
.
format
(
idx
))
self
.
log_area
.
addItem
(
'Property file: {}'
.
format
(
prop_file
))
try
:
with
open
(
prop_file
,
'r'
)
as
pt
:
props
,
syntax
,
semantic
,
warnings
,
term
=
\
opengeode
.
ogParser
.
parseSingleElement
(
'stop_if'
,
pt
.
read
(),
self
.
proc
)
if
syntax
or
semantic
:
raise
IOError
(
'Properties parsing error'
)
except
IOError
as
err
:
self
.
log_area
.
addItem
(
'Could not open property file!'
)
return
if
idx
!=
len
(
props
):
self
.
log_area
.
addItem
(
'Wrong number of properties found!'
)
return
self
.
properties
=
{
ppty
.
inputString
:
ptr
for
ppty
,
ptr
in
zip
(
props
,
properties
)}
def
check_properties
(
self
,
statehash
):
''' Check the properties at runtime
...
...
@@ -238,9 +255,9 @@ class sdlHandler(QObject):
if
not
self
.
prop_dll
:
return
self
.
restore_global_state
(
statehash
,
dll
=
self
.
prop_dll
)
for
idx
,
check
in
enumerate
(
self
.
properties
):
for
text
,
check
in
self
.
properties
.
viewitems
(
):
if
check
():
self
.
log_area
.
addItem
(
'Property {}
was violated
'
.
format
(
idx
))
self
.
log_area
.
addItem
(
'Property
"
{}
" is true
'
.
format
(
text
))
@
Slot
()
def
startStop
(
self
):
...
...
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