Esempio n. 1
0
def get_transition_map(TM, StateIndex, DropOutCatcher=None):
    global dial_db
    if DropOutCatcher is None:
        DropOutCatcher = FSM_State(sm_index.get(), TransitionMap(), dial_db=dial_db)

    def get_door_id(Target):
        return DoorID(Target, 0, dial_db)
    tm = TransitionMap.from_iterable(TM, get_door_id)
    return tm.relate_to_TargetByStateKeys(StateIndex, DropOutCatcher)
Esempio n. 2
0
def get_transition_map(TM, StateIndex, DropOutCatcher=None):
    if DropOutCatcher is None:
        DropOutCatcher = AnalyzerState(sm_index.get(), TransitionMap())

    def get_door_id(Target):
        return DoorID(Target, 0)

    tm = TransitionMap.from_iterable(TM, get_door_id)
    return tm.relate_to_TargetByStateKeys(StateIndex, DropOutCatcher)
def test(TM, Target="X"):
    tm = TransitionMap([ (Interval(x[0], x[1]), y) for x, y in TM ])
    print "____________________________________________________________________"
    print "BEFORE:"
    show(tm)
    tm.fill_gaps(Target, Setup.buffer_codec.source_set.minimum(), Setup.buffer_codec.source_set.supremum())
    tm.assert_adjacency(ChangeF=True)
    print "AFTER:"
    show(tm)
        (Interval(200, 230), 7L),
        (Interval(231, 240), 7L),
        (Interval(250, 260), 8L),
        (Interval(71, 80), 8L),
    ])

    interval_end = 300

elif choice == "B":

    def make(start):
        size = int(random.random() * 4) + 1
        target_state_index = long(random.random() * 10)
        return (Interval(start, start + size), target_state_index)

    tm0 = TransitionMap()
    interval_begin = 0
    for i in range(4000):
        tm0.append(make(interval_begin))
        interval_begin = tm0[-1][0].end

    interval_end = interval_begin

elif choice == "C":

    def make(start, size=None):
        if size is None:
            size = int(random.random() * 3) + 1
        target_state_index = long(random.random() * 5)
        return (Interval(start, start + size), target_state_index)