Beispiel #1
0
def main():
    try:
        state = "StateInit"
        stateCurr = machine.mainStateMachine(state)
        while (1):
            stateCurr = machine.mainStateMachine(stateCurr)
    except KeyboardInterrupt:
        sys.exit()
Beispiel #2
0
def ambulanceInterrupt(stateCurrent):
    stateCur = ambulance.ambulanceStateMachine('H', stateCurrent)
    stateCur = machine.mainStateMachine(stateCurrent)
    print("Ambulance Interrupted")
    file = open("trigger.txt", "w")
    file.write("4")
    file.close()
    return stateCur
Beispiel #3
0
def main():
    #Start the Normal State Machine
    stateCurr = "StateInit"
    stateCurr = machine.mainStateMachine(stateCurr)
    print("Dont come here")
    #Infinite While loop that constantly runs state machine
    while (1):
        with open('trigger.txt', 'r') as f:
            fline = f.readline()
            print(fline)
        #Normal State Machine
        if fline == '4':
            stateCurr = normalTrafficLight(stateCurr)
        #Ambulance Interrupt
        elif fline == '2':
            print('Ambulance interrupt accepted!')
            stateCurr = ambulanceInterrupt(stateCurr)
        #Error State: SHOULD NOT GO HERE!!
        else:
            print('Problem occured')
Beispiel #4
0
def main2():
    stateCurr = ambulance.ambulanceStateMachine('H', stateCurr)
    stateCurr = machine.mainStateMachine(stateCurr)
    print("Ambulance interfiered")
    count = 0
Beispiel #5
0
def main():
    stateCurr = machine.mainStateMachine(state)
    count = 0
    stateCurr = machine.mainStateMachine(stateCurr)
    count = count + 1
    print("Normal states")
Beispiel #6
0
def normalTrafficLight(stateCurrent):
    stateCur = machine.mainStateMachine(stateCurrent)
    print("Normal states")
    return stateCur