diff options
author | Daniel Friesel <derf@finalrewind.org> | 2018-04-26 15:33:01 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2018-04-26 15:33:01 +0200 |
commit | 17fbe0380bf08a771b0044be23102485182c9466 (patch) | |
tree | fbc898c25c9cd77b3cd463df05c291a0edc5c9e4 /lib | |
parent | 3992ec39ee64460e3555e9ba157932dffb74042b (diff) |
Support compact PTA json with multiple origin states per transition
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/automata.py | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/lib/automata.py b/lib/automata.py index e59c1ed..5779fe1 100755 --- a/lib/automata.py +++ b/lib/automata.py @@ -67,13 +67,6 @@ class State: self.power_function = power_function self.outgoing_transitions = {} - """@classmethod - def from_json(cls, serialized_state): - if 'power' in serialized_state: - cls.power = serialized_state['power']['static'] - if 'function' in serialized_state: - cls.power_function = """ - def add_outgoing_transition(self, new_transition): self.outgoing_transitions[new_transition.name] = new_transition @@ -148,16 +141,20 @@ class PTA: arg_to_param_map = None if 'arg_to_param_map' in transition: arg_to_param_map = transition['arg_to_param_map'] - pta.add_transition(transition['origin'], transition['destination'], - transition['name'], - duration = _json_get_static(transition, 'duration'), - duration_function = duration_function, - energy = _json_get_static(transition, 'energy'), - energy_function = energy_function, - timeout = _json_get_static(transition, 'timeout'), - timeout_function = timeout_function, - arg_to_param_map = arg_to_param_map - ) + origins = transition['origin'] + if type(origins) != list: + origins = [origins] + for origin in origins: + pta.add_transition(origin, transition['destination'], + transition['name'], + duration = _json_get_static(transition, 'duration'), + duration_function = duration_function, + energy = _json_get_static(transition, 'energy'), + energy_function = energy_function, + timeout = _json_get_static(transition, 'timeout'), + timeout_function = timeout_function, + arg_to_param_map = arg_to_param_map + ) return pta |