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
CHANGELOG:
1.
5.5 - Bugfix for random simulation
1.
5.4 - Bugfix - needed for MSC editor
1.
5.3 - Minor accomodation for the MSC editor
1.
5.2 - Minor bugfix with SDL interface
...
...
asn1_value_editor/asn1_value_editor.py
View file @
dc427a7e
...
...
@@ -16,7 +16,7 @@
__author__
=
"Maxime Perrotin"
__license__
=
"LGPLv3"
__version__
=
"1.5.
4
"
__version__
=
"1.5.
5
"
__url__
=
"http://taste.tuxfamily.org"
import
sys
...
...
asn1_value_editor/sdlHandler.py
View file @
dc427a7e
...
...
@@ -128,8 +128,9 @@ class sdlHandler(QObject):
self
.
proc
=
root_ast
.
processes
[
0
]
except
IndexError
:
raise
IOError
(
'SDL Handler failed to initialize'
)
#opengeode.Helper.flatten(self.proc)
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_view
=
opengeode
.
SDL_View
(
self
.
sdl_scene
)
opengeode
.
Statechart
.
render_statechart
(
self
.
sdl_scene
,
graph
)
...
...
@@ -181,14 +182,19 @@ class sdlHandler(QObject):
def
active_tc
(
self
):
''' Yield list of TCs that can be sent (including timeouts) '''
# Find the list of allowed TC based on the current state
st
=
self
.
current_sdl_state
inputs
=
self
.
proc
.
mapping
[
st
.
replace
(
UNICODE_SEP
,
'_'
).
lower
()]
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
curr_state
=
self
.
current_sdl_state
.
replace
(
UNICODE_SEP
,
'_'
).
lower
()
try
:
inputs
=
self
.
proc
.
mapping
[
curr_state
]
except
KeyError
:
# Raised in there is a bug in the tool
print
curr_state
,
'not in'
,
self
.
proc
.
mapping
.
keys
(),
'(BUG?)'
else
:
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
def
dll
(
self
):
...
...
@@ -541,34 +547,37 @@ class sdlHandler(QObject):
''' Depending on the current SDL state, enable or disable the buttons
for sending TCs '''
# Find the list of allowed TC based on the current state
st
=
self
.
current_sdl_state
.
split
(
UNICODE_SEP
)
st_iter
=
st
.
pop
(
0
)
context
=
self
.
proc
def
find_allowed_tc
(
context
,
statename
):
try
:
inputs
=
context
.
mapping
[
statename
.
lower
()]
for
each
in
inputs
:
for
inp
in
each
.
inputlist
:
yield
inp
except
KeyError
as
err
:
# FIXME: State Aggregations are not in context.mapping
print
(
'State {} not supported/found'
.
format
(
statename
))
allowed_tc
=
list
(
find_allowed_tc
(
context
,
st_iter
))
while
len
(
st
):
# Handle state composition
next_st
=
st
.
pop
(
0
)
for
each
in
context
.
composite_states
:
if
each
.
statename
.
lower
()
==
st_iter
.
lower
():
context
=
each
break
allowed_tc
.
extend
(
list
(
find_allowed_tc
(
context
,
next_st
)))
st_iter
=
next_st
# Removed all the logic below, self.active_tc is doing it already
# st = self.current_sdl_state.split(UNICODE_SEP)
# st_iter = st.pop(0)
# context = self.proc
# statename = '_'.join(st).lower()
# def find_allowed_tc(context, statename):
# try:
# inputs = context.mapping[statename.lower()]
# for each in inputs:
# for inp in each.inputlist:
# yield inp
# except KeyError as err:
# # FIXME: State Aggregations are not in context.mapping
# print('State {} not supported/found'.format(statename))
#
# print '1'
# allowed_tc = list(find_allowed_tc(context, st_iter))
# print '2'
#
# while len(st):
# # Handle state composition (when model is not flattened)
# next_st = st.pop(0)
# for each in context.composite_states:
# if each.statename.lower() == st_iter.lower():
# context = each
# break
# allowed_tc.extend(list(find_allowed_tc(context, next_st)))
# st_iter = next_st
# 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
for
tc
,
button
in
self
.
buttons
.
viewitems
():
if
tc
in
self
.
proc
.
timers
:
...
...
@@ -738,6 +747,7 @@ class sdlHandler(QObject):
nb_states
+=
1
print
'Visited'
,
nb_states
if
nb_states
>=
max_states
:
print
'End (limit reached)'
return
def
exhaustive_simulation
(
self
):
...
...
@@ -747,7 +757,6 @@ class sdlHandler(QObject):
self
.
sim_param
[
'state'
]
=
'exhaustive'
self
.
breadth_first
()
def
random_simulation
(
self
):
''' Random simulator - read the config from the checker_table and
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