def _get_state_machine_vs_terminal_list(CloserSequence, OpenerSequence, CounterDb, DoorIdAfter): """Additionally to all characters, the loop shall walk along the 'closer'. If the closer matches, the range skipping exits. Characters need to be counted properly. RETURNS: list(state machine, terminal) The list contains only one single element. """ # Opener Sequence Reaction opener_op_list = [Op.Increment(E_R.Counter)] # 'Goto loop entry' is added later (loop id unknown, yet). # Closer Sequence Reaction closer_op_list = [ Op.Decrement(E_R.Counter), Op.GotoDoorIdIfCounterEqualZero(DoorIdAfter) ] # 'Goto loop entry' is added later (loop id unknown, yet). return [ _get_state_machine_and_terminal(OpenerSequence, "<SKIP NESTED RANGE OPENER>", opener_op_list), _get_state_machine_and_terminal(CloserSequence, "<SKIP NESTED RANGE OPENER>", closer_op_list) ]
def _get_state_machine_vs_terminal_list(CloserPattern, OpenerPattern, DoorIdExit, dial_db): """Additionally to all characters, the loop shall walk along the 'closer'. If the closer matches, the range skipping exits. Characters need to be counted properly. RETURNS: [0] list(state machine, terminal) [1] incidence id of auxiliary terminal that goto-s to the loop entry. The auxiliary terminal is necessary since the DoorID of the loop entry cannot be known beforehand. """ # DoorID of loop entry cannot be known beforehand. # => generate an intermediate door_id from where the loop is entered. iid_aux_reentry = dial.new_incidence_id() door_id_aux_reentry = dial.DoorID.incidence(iid_aux_reentry, dial_db) # Opener Pattern Reaction opener_op_list = [ Op.Increment(E_R.Counter), Op.GotoDoorId(door_id_aux_reentry) ] # Closer Pattern Reaction closer_op_list = [ Op.Decrement(E_R.Counter), Op.GotoDoorIdIfCounterEqualZero(DoorIdExit), Op.GotoDoorId(door_id_aux_reentry) ] def sm_terminal_pair(Pattern, Name, OpList, dial_db): sm = Pattern.get_cloned_sm(StateMachineId=dial.new_incidence_id()) terminal = loop.MiniTerminal(Lng.COMMAND_LIST(OpList, dial_db), Name, sm.get_id()) return sm, terminal smt_list = [ sm_terminal_pair(OpenerPattern, "<SKIP NESTED RANGE OPENER>", opener_op_list, dial_db), sm_terminal_pair(CloserPattern, "<SKIP NESTED RANGE CLOSER>", closer_op_list, dial_db) ] return smt_list, iid_aux_reentry