Beispiel #1
0
 protected static String _privk3_getContextPath(
     final RegionAspectRegionAspectProperties _self_,
     final Region _self,
     final AbstractState _vertex) {
   String root = "currentState";
   ArrayList<Region> parentRegions = new ArrayList<Region>();
   Region currentRegion = _vertex.getOwnerRegion();
   while ((!Objects.equal(currentRegion, null))) {
     {
       parentRegions.add(currentRegion);
       State _ownerState = currentRegion.getOwnerState();
       boolean _notEquals = (!Objects.equal(_ownerState, null));
       if (_notEquals) {
         State _ownerState_1 = currentRegion.getOwnerState();
         Region _ownerRegion = _ownerState_1.getOwnerRegion();
         currentRegion = _ownerRegion;
       } else {
         currentRegion = null;
       }
     }
   }
   for (int i = (parentRegions.size() - 1); (i >= 0); i--) {
     String _root = root;
     Region _get = parentRegions.get(i);
     String _name = _get.getName();
     String _plus = ("-" + _name);
     root = (_root + _plus);
   }
   return root;
 }
Beispiel #2
0
 protected static String _privk3_getContextPathByRegion(
     final RegionAspectRegionAspectProperties _self_, final Region _self) {
   String root = "currentState";
   ArrayList<Region> parentRegions = new ArrayList<Region>();
   Region currentRegion = _self;
   while (((!Objects.equal(currentRegion.getOwnerState(), null))
       && (!Objects.equal(currentRegion.getOwnerState().getOwnerRegion(), null)))) {
     {
       State _ownerState = _self.getOwnerState();
       Region _ownerRegion = _ownerState.getOwnerRegion();
       parentRegions.add(_ownerRegion);
       State _ownerState_1 = currentRegion.getOwnerState();
       Region _ownerRegion_1 = _ownerState_1.getOwnerRegion();
       currentRegion = _ownerRegion_1;
     }
   }
   for (int i = (parentRegions.size() - 1); (i >= 0); i--) {
     String _root = root;
     Region _get = parentRegions.get(i);
     String _name = _get.getName();
     String _plus = ("-" + _name);
     root = (_root + _plus);
   }
   String _name = _self.getName();
   return ((root + "-") + _name);
 }
Beispiel #3
0
 protected static ArrayList<AbstractState> _privk3_getCurrentState(
     final RegionAspectRegionAspectProperties _self_,
     final Region _self,
     final Hashtable<String, Object> context,
     final EList<String> events) {
   final ArrayList<AbstractState> currentState = new ArrayList<AbstractState>();
   Set<String> _keySet = context.keySet();
   Iterator<String> _it = _keySet.iterator();
   while (_it.hasNext()) {
     {
       String _key = _it.next();
       Object _value = context.get(_key);
       String _name = _self.getName();
       String _plus = ("currentState-" + _name);
       boolean _startsWith = _key.startsWith(_plus);
       if (_startsWith) {
         final Consumer<AbstractState> _function =
             (AbstractState _vertex) -> {
               currentState.add(_vertex);
             };
         ((ArrayList<AbstractState>) _value).forEach(_function);
       }
     }
   }
   return currentState;
 }
Beispiel #4
0
 protected static void _privk3_initRegion(
     final RegionAspectRegionAspectProperties _self_,
     final Region _self,
     final Hashtable<String, Object> context) {
   State _history = RegionAspect.history(_self);
   boolean _equals = Objects.equal(_history, null);
   if (_equals) {
     ArrayList<AbstractState> regionCurrentState = new ArrayList<AbstractState>();
     String _contextPathByRegion = RegionAspect.getContextPathByRegion(_self);
     context.put(_contextPathByRegion, regionCurrentState);
     EList<AbstractState> _subvertex = _self.getSubvertex();
     final Function1<AbstractState, Boolean> _function =
         (AbstractState _vertex) -> {
           boolean _and = false;
           if (!(_vertex instanceof Pseudostate)) {
             _and = false;
           } else {
             _and = (_vertex instanceof InitialState);
           }
           return Boolean.valueOf(_and);
         };
     AbstractState _findFirst = IterableExtensions.<AbstractState>findFirst(_subvertex, _function);
     Pseudostate initialPseudostate = ((Pseudostate) _findFirst);
     ArrayList<AbstractState> initialCurrentState = new ArrayList<AbstractState>();
     ArrayList<Transition> initialCurrentTransitions = new ArrayList<Transition>();
     EList<Transition> _outgoing = initialPseudostate.getOutgoing();
     for (final Transition _transition : _outgoing) {
       {
         initialCurrentTransitions.add(_transition);
         AbstractState _target = _transition.getTarget();
         initialCurrentState.add(_target);
       }
     }
     ((ArrayList<AbstractState>) regionCurrentState).addAll(initialCurrentState);
     final Consumer<Transition> _function_1 =
         (Transition transition) -> {
           TransitionAspect.evalTransition(transition, context);
         };
     initialCurrentTransitions.forEach(_function_1);
   } else {
     String _name = _self.getName();
     String _plus = ("currentState-" + _name);
     Object _get = context.get(_plus);
     State _history_1 = RegionAspect.history(_self);
     ((ArrayList<AbstractState>) _get).add(_history_1);
   }
 }
Beispiel #5
0
 protected static void _privk3_history(
     final RegionAspectRegionAspectProperties _self_, final Region _self, final State history) {
   _self_.history = history;
   try {
     for (java.lang.reflect.Method m : _self.getClass().getMethods()) {
       if (m.getName().equals("setHistory") && m.getParameterTypes().length == 1) {
         m.invoke(_self, history);
       }
     }
   } catch (Exception e) {
     // Chut !
   }
 }
Beispiel #6
0
 protected static void _privk3_saveHistoryState(
     final RegionAspectRegionAspectProperties _self_,
     final Region _self,
     final Hashtable<String, Object> context) {
   InputOutput.<String>println("saving the history state");
   EList<AbstractState> _subvertex = _self.getSubvertex();
   final Function1<AbstractState, Boolean> _function =
       (AbstractState _vertex) -> {
         boolean _and = false;
         if (!(_vertex instanceof Pseudostate)) {
           _and = false;
         } else {
           _and = (_vertex instanceof ShallowHistory);
         }
         return Boolean.valueOf(_and);
       };
   boolean _exists = IterableExtensions.<AbstractState>exists(_subvertex, _function);
   if (_exists) {
     String _name = _self.getName();
     String _plus = ("currentState-" + _name);
     Object _get = context.get(_plus);
     final Function1<AbstractState, Boolean> _function_1 =
         (AbstractState _state) -> {
           boolean _and = false;
           if (!(_state instanceof State)) {
             _and = false;
           } else {
             Region _ownerRegion = ((State) _state).getOwnerRegion();
             boolean _equals = Objects.equal(_ownerRegion, _self);
             _and = _equals;
           }
           return Boolean.valueOf(_and);
         };
     AbstractState _findFirst =
         IterableExtensions.<AbstractState>findFirst(
             ((ArrayList<AbstractState>) _get), _function_1);
     RegionAspect.history(_self, ((State) _findFirst));
   }
 }
Beispiel #7
0
 protected static void _privk3_getAllParents(
     final RegionAspectRegionAspectProperties _self_,
     final Region _self,
     final AbstractState vertex,
     final ArrayList<AbstractState> parents) {
   if ((vertex instanceof State)) {
     Region _ownerRegion = ((State) vertex).getOwnerRegion();
     State superState = _ownerRegion.getOwnerState();
     while ((!Objects.equal(superState, null))) {
       {
         boolean _contains = parents.contains(superState);
         boolean _not = (!_contains);
         if (_not) {
           parents.add(superState);
         }
         Region _ownerRegion_1 = superState.getOwnerRegion();
         State _ownerState = _ownerRegion_1.getOwnerState();
         superState = _ownerState;
       }
     }
   }
 }
Beispiel #8
0
 protected static State _privk3_history(
     final RegionAspectRegionAspectProperties _self_, final Region _self) {
   try {
     for (java.lang.reflect.Method m : _self.getClass().getMethods()) {
       if (m.getName().equals("getHistory") && m.getParameterTypes().length == 0) {
         Object ret = m.invoke(_self);
         if (ret != null) {
           return (fsm.State) ret;
         }
       }
     }
   } catch (Exception e) {
     // Chut !
   }
   return _self_.history;
 }
Beispiel #9
0
 protected static void _privk3_step(
     final RegionAspectRegionAspectProperties _self_,
     final Region _self,
     final Hashtable<String, Object> context,
     final EList<String> events) {
   boolean allJunctionsAttended = false;
   while ((!allJunctionsAttended)) {
     {
       ArrayList<AbstractState> currentState =
           RegionAspect.getCurrentState(_self, context, events);
       ArrayList<Transition> currentTransitions = new ArrayList<Transition>();
       ArrayList<AbstractState> attendedStates = new ArrayList<AbstractState>();
       ArrayList<AbstractState> newStates = new ArrayList<AbstractState>();
       EList<Transition> activeTransitions = new BasicEList<Transition>();
       for (final AbstractState _state : currentState) {
         EList<Transition> _activeTransitions =
             RegionAspect.getActiveTransitions(_self, _state, events);
         activeTransitions.addAll(_activeTransitions);
       }
       for (final Transition transition : activeTransitions) {
         {
           RegionAspect.findOldActiveStates(_self, attendedStates, transition, context);
           RegionAspect.findNewActiveTransitions(_self, currentTransitions, transition, context);
           RegionAspect.findNewActiveStates(
               _self, newStates, transition, currentTransitions, context);
         }
       }
       for (final AbstractState _attendedState : attendedStates) {
         if ((_attendedState instanceof State)) {
           StateAspect.exitState(((State) _attendedState), context);
         }
       }
       RegionAspect.removeStatesFromContext(_self, context, attendedStates);
       RegionAspect.addStatesToContext(_self, context, newStates);
       final Consumer<Transition> _function =
           (Transition transition_1) -> {
             TransitionAspect.evalTransition(transition_1, context);
           };
       activeTransitions.forEach(_function);
       final Consumer<Transition> _function_1 =
           (Transition transition_1) -> {
             boolean _alreadyFired = TransitionAspect.alreadyFired(transition_1, context);
             boolean _not = (!_alreadyFired);
             if (_not) {
               TransitionAspect.evalTransition(transition_1, context);
             }
           };
       currentTransitions.forEach(_function_1);
       final Consumer<AbstractState> _function_2 =
           (AbstractState state) -> {
             EList<Transition> _outgoing = state.getOutgoing();
             final Consumer<Transition> _function_3 =
                 (Transition transition_1) -> {
                   TransitionAspect.resetFired(transition_1);
                 };
             _outgoing.forEach(_function_3);
           };
       newStates.forEach(_function_2);
       final ArrayList<AbstractState> currentConditionalState = new ArrayList<AbstractState>();
       Set<String> _keySet = context.keySet();
       Iterator<String> _it = _keySet.iterator();
       while (_it.hasNext()) {
         {
           String _key = _it.next();
           Object _value = context.get(_key);
           boolean _startsWith = _key.startsWith("currentState");
           if (_startsWith) {
             final Consumer<AbstractState> _function_3 =
                 (AbstractState _vertex) -> {
                   currentConditionalState.add(_vertex);
                 };
             ((ArrayList<AbstractState>) _value).forEach(_function_3);
           }
         }
       }
       String _name = _self.getName();
       String _plus = ("currentState-" + _name);
       Object _get = context.get(_plus);
       currentState = ((ArrayList<AbstractState>) _get);
       final Function1<AbstractState, Boolean> _function_3 =
           (AbstractState _vertex) -> {
             EList<Transition> _outgoing = _vertex.getOutgoing();
             final Function1<Transition, Boolean> _function_4 =
                 (Transition _outgoing_1) -> {
                   boolean _and = false;
                   AbstractState _target = _outgoing_1.getTarget();
                   if (!(_target instanceof Pseudostate)) {
                     _and = false;
                   } else {
                     AbstractState _target_1 = _outgoing_1.getTarget();
                     _and = (_target_1 instanceof Junction);
                   }
                   return Boolean.valueOf(_and);
                 };
             return Boolean.valueOf(IterableExtensions.<Transition>exists(_outgoing, _function_4));
           };
       boolean _exists = IterableExtensions.<AbstractState>exists(currentState, _function_3);
       boolean _not = (!_exists);
       allJunctionsAttended = _not;
     }
   }
 }