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
dc427a7e
Commit
dc427a7e
authored
Dec 23, 2016
by
Maxime Perrotin
Browse files
Fix list of active tc for random simulation
parent
12329335
Changes
3
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
dc427a7e
...
@@ -34,6 +34,7 @@ LICENSE: LGPL - see LICENSE file
...
@@ -34,6 +34,7 @@ LICENSE: LGPL - see LICENSE file
CHANGELOG:
CHANGELOG:
1.
5.5 - Bugfix for random simulation
1.
5.4 - Bugfix - needed for MSC editor
1.
5.4 - Bugfix - needed for MSC editor
1.
5.3 - Minor accomodation for the MSC editor
1.
5.3 - Minor accomodation for the MSC editor
1.
5.2 - Minor bugfix with SDL interface
1.
5.2 - Minor bugfix with SDL interface
...
...
asn1_value_editor/asn1_value_editor.py
View file @
dc427a7e
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
__author__
=
"Maxime Perrotin"
__author__
=
"Maxime Perrotin"
__license__
=
"LGPLv3"
__license__
=
"LGPLv3"
__version__
=
"1.5.
4
"
__version__
=
"1.5.
5
"
__url__
=
"http://taste.tuxfamily.org"
__url__
=
"http://taste.tuxfamily.org"
import
sys
import
sys
...
...
asn1_value_editor/sdlHandler.py
View file @
dc427a7e
...
@@ -128,8 +128,9 @@ class sdlHandler(QObject):
...
@@ -128,8 +128,9 @@ class sdlHandler(QObject):
self
.
proc
=
root_ast
.
processes
[
0
]
self
.
proc
=
root_ast
.
processes
[
0
]
except
IndexError
:
except
IndexError
:
raise
IOError
(
'SDL Handler failed to initialize'
)
raise
IOError
(
'SDL Handler failed to initialize'
)
#opengeode.Helper.flatten(self.proc)
graph
=
opengeode
.
Statechart
.
create_dot_graph
(
self
.
proc
,
basic
=
True
)
graph
=
opengeode
.
Statechart
.
create_dot_graph
(
self
.
proc
,
basic
=
True
)
# Flatten the model to have the nested states names in process.mapping
opengeode
.
Helper
.
flatten
(
self
.
proc
)
self
.
sdl_scene
=
opengeode
.
SDL_Scene
(
'statechart'
)
self
.
sdl_scene
=
opengeode
.
SDL_Scene
(
'statechart'
)
self
.
sdl_view
=
opengeode
.
SDL_View
(
self
.
sdl_scene
)
self
.
sdl_view
=
opengeode
.
SDL_View
(
self
.
sdl_scene
)
opengeode
.
Statechart
.
render_statechart
(
self
.
sdl_scene
,
graph
)
opengeode
.
Statechart
.
render_statechart
(
self
.
sdl_scene
,
graph
)
...
@@ -181,14 +182,19 @@ class sdlHandler(QObject):
...
@@ -181,14 +182,19 @@ class sdlHandler(QObject):
def
active_tc
(
self
):
def
active_tc
(
self
):
''' Yield list of TCs that can be sent (including timeouts) '''
''' Yield list of TCs that can be sent (including timeouts) '''
# Find the list of allowed TC based on the current state
# Find the list of allowed TC based on the current state
st
=
self
.
current_sdl_state
curr_state
=
self
.
current_sdl_state
.
replace
(
UNICODE_SEP
,
'_'
).
lower
()
inputs
=
self
.
proc
.
mapping
[
st
.
replace
(
UNICODE_SEP
,
'_'
).
lower
()]
try
:
allowed_tc
=
(
tc
for
each
in
inputs
for
tc
in
each
.
inputlist
)
inputs
=
self
.
proc
.
mapping
[
curr_state
]
for
each
in
allowed_tc
:
except
KeyError
:
if
each
in
self
.
timers
and
not
self
.
buttons
[
each
].
isEnabled
():
# Raised in there is a bug in the tool
# Timers: check if button is active
print
curr_state
,
'not in'
,
self
.
proc
.
mapping
.
keys
(),
'(BUG?)'
continue
else
:
yield
each
allowed_tc
=
(
tc
for
each
in
inputs
for
tc
in
each
.
inputlist
)
for
each
in
allowed_tc
:
if
each
in
self
.
timers
and
not
self
.
buttons
[
each
].
isEnabled
():
# Timers: check if button is active
continue
yield
each
@
property
@
property
def
dll
(
self
):
def
dll
(
self
):
...
@@ -541,34 +547,37 @@ class sdlHandler(QObject):
...
@@ -541,34 +547,37 @@ class sdlHandler(QObject):
''' Depending on the current SDL state, enable or disable the buttons
''' Depending on the current SDL state, enable or disable the buttons
for sending TCs '''
for sending TCs '''
# Find the list of allowed TC based on the current state
# Find the list of allowed TC based on the current state
st
=
self
.
current_sdl_state
.
split
(
UNICODE_SEP
)
# Removed all the logic below, self.active_tc is doing it already
st_iter
=
st
.
pop
(
0
)
# st = self.current_sdl_state.split(UNICODE_SEP)
context
=
self
.
proc
# st_iter = st.pop(0)
# context = self.proc
def
find_allowed_tc
(
context
,
statename
):
# statename = '_'.join(st).lower()
try
:
# def find_allowed_tc(context, statename):
inputs
=
context
.
mapping
[
statename
.
lower
()]
# try:
for
each
in
inputs
:
# inputs = context.mapping[statename.lower()]
for
inp
in
each
.
inputlist
:
# for each in inputs:
yield
inp
# for inp in each.inputlist:
except
KeyError
as
err
:
# yield inp
# FIXME: State Aggregations are not in context.mapping
# except KeyError as err:
print
(
'State {} not supported/found'
.
format
(
statename
))
# # FIXME: State Aggregations are not in context.mapping
# print('State {} not supported/found'.format(statename))
allowed_tc
=
list
(
find_allowed_tc
(
context
,
st_iter
))
#
# print '1'
while
len
(
st
):
# allowed_tc = list(find_allowed_tc(context, st_iter))
# Handle state composition
# print '2'
next_st
=
st
.
pop
(
0
)
#
for
each
in
context
.
composite_states
:
# while len(st):
if
each
.
statename
.
lower
()
==
st_iter
.
lower
():
# # Handle state composition (when model is not flattened)
context
=
each
# next_st = st.pop(0)
break
# for each in context.composite_states:
allowed_tc
.
extend
(
list
(
find_allowed_tc
(
context
,
next_st
)))
# if each.statename.lower() == st_iter.lower():
st_iter
=
next_st
# context = each
# break
# allowed_tc.extend(list(find_allowed_tc(context, next_st)))
# st_iter = next_st
# Remove timers from the list
# Remove timers from the list
allowed_tc
=
set
(
allowed
_tc
)
-
set
(
self
.
proc
.
timers
)
allowed_tc
=
set
(
self
.
active
_tc
)
-
set
(
self
.
proc
.
timers
)
# Enable/disable the parameterless TC buttons accordingly
# Enable/disable the parameterless TC buttons accordingly
for
tc
,
button
in
self
.
buttons
.
viewitems
():
for
tc
,
button
in
self
.
buttons
.
viewitems
():
if
tc
in
self
.
proc
.
timers
:
if
tc
in
self
.
proc
.
timers
:
...
@@ -738,6 +747,7 @@ class sdlHandler(QObject):
...
@@ -738,6 +747,7 @@ class sdlHandler(QObject):
nb_states
+=
1
nb_states
+=
1
print
'Visited'
,
nb_states
print
'Visited'
,
nb_states
if
nb_states
>=
max_states
:
if
nb_states
>=
max_states
:
print
'End (limit reached)'
return
return
def
exhaustive_simulation
(
self
):
def
exhaustive_simulation
(
self
):
...
@@ -747,7 +757,6 @@ class sdlHandler(QObject):
...
@@ -747,7 +757,6 @@ class sdlHandler(QObject):
self
.
sim_param
[
'state'
]
=
'exhaustive'
self
.
sim_param
[
'state'
]
=
'exhaustive'
self
.
breadth_first
()
self
.
breadth_first
()
def
random_simulation
(
self
):
def
random_simulation
(
self
):
''' Random simulator - read the config from the checker_table and
''' Random simulator - read the config from the checker_table and
call TC either randomly or periodically, until the stop button is
call TC either randomly or periodically, until the stop button is
...
...
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