func (elevinf *Elevatorinfo) CheckLights() { // Updates lights according to the order_arrays! // for { for i := 1; i < 4; i++ { if elevinf.external_orders[i-1][0] == 1 || elevinf.external_orders[i-1][0] == -1 { elevdriver.SetLight(i, 1) } else if elevinf.external_orders[i-1][0] == 0 { elevdriver.ClearLight(i, 1) } } for i := 2; i < 5; i++ { if elevinf.external_orders[i-1][1] == 1 || elevinf.external_orders[i-1][1] == -1 { elevdriver.SetLight(i, 2) } else if elevinf.external_orders[i-1][1] == 0 { elevdriver.ClearLight(i, 2) } } for i := 0; i < 4; i++ { if elevinf.internal_orders[i][2] == 1 { elevdriver.SetLight(i+1, 0) } else if elevinf.internal_orders[i][2] == 0 { elevdriver.ClearLight(i+1, 0) } } fmt.Printf("checkedlights\n") // time.Sleep(100*time.Millisecond) // } }
func (elev *Elevator) action_exec() { elevdriver.OpenDoor() //start_timer() //order_executed() elev.state = DOORS_OPEN elevdriver.SetLight(elev.lastFloor, elev.lastDir) fmt.Println("fsm: DOORS_OPEN") }
func readButtons() { var current [FLOORS][3]bool for { floor, dir := elevdriver.GetButton() current[floor-1][dir] = !current[floor-1][dir] if current[floor-1][dir] { elevdriver.SetLight(floor, dir) } else { elevdriver.ClearLight(floor, dir) } } }
func (elevinf *Elevatorinfo) CheckLights() { // Updates lights according to the order_arrays! for i := 1; i < 4; i++ { if elevinf.external_orders[i-1][0] == 1 || elevinf.external_orders[i-1][0] == -1 { elevdriver.SetLight(i, 1) } else if elevinf.external_orders[i-1][0] == 0 { elevdriver.ClearLight(i, 1) } } for i := 2; i < 5; i++ { if elevinf.external_orders[i-1][1] == 1 || elevinf.external_orders[i-1][1] == -1 { elevdriver.SetLight(i, 2) } else if elevinf.external_orders[i-1][1] == 0 { elevdriver.ClearLight(i, 2) } } for i := 0; i < 4; i++ { if elevinf.internal_orders[i][2] == 1 { elevdriver.SetLight(i+1, 0) } else if elevinf.internal_orders[i][2] == 0 { elevdriver.ClearLight(i+1, 0) } } }