Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed parsing of cond in parallel states for compatibility with smach #20

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 23 additions & 8 deletions src/scxml_interpreter/scxml_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,41 @@
from scxml_interpreter.interfaces import SimpleStateInterface, CompoundStateInterface, \
SCXMLInterface, ParallelStateInterface


def convert_to_concurence_map(cond):
# split mapping
cond_ = cond.strip()
map_list = []
if(cond_.find(' AND ') == -1): # There is no "and" condition
if(cond_.find(' OR ') == -1): # There is no "or" condition
if(cond_.find(' AND ') == -1): # there are no "and" conditions
if(cond_.find(' OR ') == -1): # there are no "or" conditions
list_ = cond_.split('.')
map_list.append({list_[0]: list_[1]})
else:
else: # there are only "or" conditions

# State1.succeeded OR State2.succeeded
# succeeded: [{State1: succeeded} , {State2: succeeded }]
for cond_or in cond_.split(' OR '):
list_ = cond_or.split('.')
map_list.append({list_[0]: list_[1]})
else:
for cond_and in cond_.split(' AND '):
list_and = cond_and.split('.')
map_list.append({list_and[0]: list_and[1]})
if(cond_.find(' OR ') == -1): # there are only "and" conditions

# State1.succeeded AND State2.succeeded
# succeeded: [{State1: succeeded, State2: succeeded }]
cond_and_dict = {}
for cond_and_parcel in cond_.split(' AND '):
list_and = cond_and_parcel.split('.')
cond_and_dict[list_and[0]] = list_and[1]
map_list.append(cond_and_dict)

else: # there are both "or" and "and" conditions
for cond_or in cond_.split(' OR '):
cond_and_dict = {}
for cond_and_parcel in cond_or.split(' AND '):
list_and = cond_and_parcel.split('.')
cond_and_dict[list_and[0]] = list_and[1]
map_list.append(cond_and_dict)
return map_list


class Converter(object):

def convert_to_interface(self, root):
Expand Down