コード例 #1
0
ファイル: Elevator.go プロジェクト: rubenrav/ttk4145
func NewElevator(id, speed, direction, currentFloor, location int) *Elevator {
	e := new(Elevator)
	e.id = id
	e.stopList = list.New()
	e.speed = speed
	e.direction = direction
	e.currentFloor = currentFloor
	e.location = location
	e.out = make(chan string, 5)

	return e
}
コード例 #2
0
ファイル: Elevator.go プロジェクト: rubenrav/ttk4145
func InitElevator() *Elevator {
	// initializes elevator object
	if ElevInit() == 0 {
		Println("I am Error")
	}

	ElevSetStopLamp(1)

	e := new(Elevator)
	e.stopList = list.New()
	e.direction = 0
	//go e.PrintStatus()
	if ElevGetFloorSensorSignal() == -1 {
		// goes down to nearest floor if between two floors
		e.speed = ElevSetSpeed(-300, 0)
		for ElevGetFloorSensorSignal() == -1 {
		}
	}

	e.speed = ElevSetSpeed(0, -300)
	e.currentFloor = ElevGetFloorSensorSignal()
	e.out = make(chan string, 10)
	return e
}