Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
VIGNET Pierre
cadbiom
Commits
15588892
Commit
15588892
authored
Sep 21, 2017
by
VIGNET Pierre
Browse files
Handle Start nodes in exported graph for a bcx model
parent
3307da77
Changes
1
Hide whitespace changes
Inline
Side-by-side
command_line/cadbiom_cmd/solution_repr.py
View file @
15588892
...
...
@@ -154,14 +154,19 @@ def load_solutions(file):
def
get_transitions
(
file
,
all_places
=
False
):
"""Get all transitions in a file model (bcx format).
:param: Model in bcx format.
:type: <str>
:param arg1: Model in bcx format.
:param arg2: Ask to return all the places of the model.
(useful for get_frontier_places() that compute frontier places)
:type arg1: <str>
:type arg2: <bool>
:return: A dictionnary of events as keys, and transitions as values.
Since many transitions can define an event, values are lists.
Each transition is a tuple with: origin node, final node, attributes
like label and condition.
{u'h00': [('Ax', 'n1', {u'label': u'h00[]'}),]
:rtype: <dict <list <tuple <str>, <str>, <dict <str>: <str>>>>
If all_places is True, this func returns also a list of all places in
the model.
"""
parser
=
MakeModelFromXmlFile
(
file
)
...
...
@@ -183,9 +188,15 @@ def get_transitions(file, all_places=False):
# ori/ext entities, so we have to extract them and their respective
# conditions
if
trans
.
event
==
''
:
# null event without clock...
# null event without clock => StartNodes
# These nodes are used to resolve the problem of
# Strongly Connected Components (inactivated cycles in the graph)
# The nodes
# Avoids having SigConstExpr as event type in parse_event()
continue
# I create a transition (SCC-__start__?),
# and a node (__start__?) for this case.
trans
.
event
=
'SCC-'
+
trans
.
ori
.
name
events
=
{
trans
.
event
:
trans
.
condition
}
elif
re
.
match
(
'_h_[0-9_\.]+'
,
trans
.
event
):
# 1 event (with 1 clock)
events
=
{
trans
.
event
:
trans
.
condition
}
...
...
@@ -222,7 +233,14 @@ def get_transitions(file, all_places=False):
def
get_frontier_places
(
transitions
,
all_places
):
"""Return frontier places of a model (deducted from its transitions).
"""Return frontier places of a model (deducted from its transitions and
from all places of the model).
.. note:: why we use all_places from the model instead of
(input_places - output_places) to get frontier places ?
Because some nodes are only in conditions and not in transitions.
If we don't do that, these nodes are missing when we compute
valid paths from conditions.
:param arg1: Model's transitions.
{u'h00': [('Ax', 'n1', {u'label': u'h00[]'}),]
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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