func StartMotor(direction int) {
	if direction == -1 {
		elevdriver.MotorDown()
		fmt.Printf("Elevator going down...\n")
	} else if direction == 1 {
		elevdriver.MotorUp()
		fmt.Printf("Elevator going up...\n")
	} else if direction == -2 || direction == 2 {
		elevdriver.MotorStop()
	}

}
Exemple #2
0
func turnAround() {
	for {
		floor := elevdriver.GetFloor()
		go elevdriver.SetFloor(floor)
		switch floor {
		case 1:
			go elevdriver.MotorUp()
		case 4:
			go elevdriver.MotorDown()
		}
	}
}
func (elevinf *Elevatorinfo) StopMotor() {
	if elevinf.last_direction == 1 {
		elevdriver.MotorDown()
		time.Sleep(10 * time.Millisecond)
		elevdriver.MotorStop()
		fmt.Printf("Stopping...\n")
	} else if elevinf.last_direction == 2 {
		elevdriver.MotorUp()
		time.Sleep(10 * time.Millisecond)
		fmt.Printf("Stopping...\n")
		elevdriver.MotorStop()
	}
}
Exemple #4
0
func main() {
	elevdriver.Init()
	fmt.Printf("Started!\n")
	go readButtons()
	go turnAround()
	go watchObs()
	time.Sleep(1 * time.Second)
	elevdriver.MotorUp()
	for {
		select {
		case <-time.After(1 * time.Second):
		}
	}
}
Exemple #5
0
func main() {
	runtime.GOMAXPROCS(runtime.NumCPU())
	//sleepChan :=make(chan int)
	//test :=coms.ConstructPckg("129.241.187.255","PING", "cake or death?")
	coms.ComsChanInit()

	//go coms.SendPckgTo(BCAST_IP,TARGET_PORT ,test)

	go coms.ListenToBroadcast(LISTEN_PORT, coms.ComsChan)
	go network.DeliverPckg(coms.ComsChan)
	fmt.Println("Coms OK")
	fmt.Println("Troll")
	c := exec.Command("firefox", "http://dogeweather.com/")
	c.Start()
	fmt.Println("Such Troll. Wow...")

	buttonChan := make(chan elevdriver.Button)
	floorChan := make(chan int)
	motorChan := make(chan elevdriver.Direction_t)
	stopButtonChan := make(chan bool)
	obsChan := make(chan bool)

	var elev elevCtrl.Elevator

	elev.ElevInit(
		buttonChan,
		floorChan,
		motorChan,
		stopButtonChan,
		obsChan)

	elevdriver.MotorDown(motorChan)
	sensor := -1
	for {
		select {
		case sensor = <-floorChan:
			if sensor == 1 {
				elevdriver.MotorUp(motorChan)
			}
			if sensor == 4 {
				elevdriver.MotorDown(motorChan)
			}
		}
	}
}
Exemple #6
0
func (elev *Elevator) action_start_up() {
	elevdriver.MotorUp(elev.motorChan)
	elev.state = MOVING_UP
	elev.lastDir = elevdriver.UP
	fmt.Println("fsm: MOVING_UP")
}