Esempio n. 1
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)
			}
		}
	}
}
Esempio n. 2
0
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()
	}

}
Esempio n. 3
0
func turnAround() {
	for {
		floor := elevdriver.GetFloor()
		go elevdriver.SetFloor(floor)
		switch floor {
		case 1:
			go elevdriver.MotorUp()
		case 4:
			go elevdriver.MotorDown()
		}
	}
}
Esempio n. 4
0
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()
	}
}
Esempio n. 5
0
/* 	FSM Actions */
func (elev *Elevator) action_start_down() {
	elevdriver.MotorDown(elev.motorChan)
	elev.state = MOVING_DOWN
	elev.lastDir = elevdriver.DOWN
	fmt.Println("fsm: MOVING_DOWN")
}