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
cdcfd4e8
Commit
cdcfd4e8
authored
Aug 10, 2016
by
Maxime Perrotin
Browse files
Make exhaustive simulation interruptible
parent
a7245d8c
Changes
1
Hide whitespace changes
Inline
Side-by-side
asn1_value_editor/sdlHandler.py
View file @
cdcfd4e8
...
...
@@ -695,7 +695,7 @@ class sdlHandler(QObject):
for
each
in
exhaust_interface
(
name
,
asn1_ty
):
yield
each
def
breadth_first
(
self
,
max_states
=
100
):
def
breadth_first
(
self
,
max_states
=
100
0
):
''' Create and explore the state graph with breadth first '''
# Fifo contains the hash, and a tuple (PI, Param) to reach it
fifo
=
deque
([(
self
.
current_hash
,
(
None
,
None
))])
...
...
@@ -708,12 +708,15 @@ class sdlHandler(QObject):
scenario
.
append
((
trans_name
,
trans_param
))
self
.
restore_global_state
(
state
)
for
sibling
,
(
trans_name
,
trans_param
)
in
self
.
children_states
():
QApplication
.
processEvents
()
if
self
.
sim_param
[
'state'
]
!=
'exhaustive'
:
return
if
sibling
not
in
visited
:
visited
.
append
(
sibling
)
if
not
self
.
stop_conditions
:
# Cut branch if there are stop conditions
fifo
.
append
((
sibling
,
(
trans_name
,
trans_param
)))
else
:
# Cut branch if there are stop conditions
scenario
.
append
((
trans_name
,
trans_param
))
print
'Stop conditions met:'
,
self
.
stop_conditions
print
'Scenario:'
...
...
@@ -727,53 +730,10 @@ class sdlHandler(QObject):
def
exhaustive_simulation
(
self
):
''' Model checker - try all combinations of all inputs in all
possible states, and verify properties on the fly '''
# DEPRECATED FUNCTION
print
'Exhaustive simulation (Breadth first)'
self
.
sim_param
[
'state'
]
=
'exhaustive'
self
.
breadth_first
()
# next_level = []
# self.sim_param['state'] = 'exhaustive'
# total_err = 0
#
# def exhaust_interface(name, asn1_ty):
# ''' Send all combinations of an input signal and return
# a list of new states (should be doing this in a worker thread) '''
# error = 0
# new_hashes = []
# if asn1_ty:
# for arg in compute_combinations(asn1_ty, self.proc.dataview):
# QApplication.processEvents()
# if self.sim_param['state'] != 'exhaustive':
# return new_hashes, error
# self.click_tc(name, arg)
# if self.new_state_created:
# # Create new state only if no stop conditions
# if not self.stop_conditions:
# new_hashes.append((name, arg, self.current_hash))
# else:
# # TODO: generate scenario
# error += 1
# self.undo()
# else:
# self.click_tc(name)
# if self.new_state_created:
# new_hashes.append((name, None, self.current_hash))
# self.undo()
# return new_hashes, error
# for name in self.active_tc:
# ty = None
# for inp in self.proc.input_signals:
# if inp['name'].lower() == name.lower():
# sort = inp.get('type', None)
# if sort:
# typename = sort.ReferencedTypeName.replace('-', '_')
# ty = self.proc.dataview[sort.ReferencedTypeName]
# next_states, error_count = exhaust_interface(name, ty)
# total_err += error_count
# next_level.extend(next_states)
# print 'length of next level: ', len(next_level)
#
# print 'Number of stop conditions reached:', total_err
def
random_simulation
(
self
):
''' Random simulator - read the config from the checker_table and
...
...
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