Пример #1
0
func main() {
	var communicator network.CommChannels
	communicator.CommChanInit()
	network.NetworkInit(communicator)

	time.Sleep(time.Second)

	go receiveTESTmail(communicator)

	for {
		sendTESTmail(communicator)
		time.Sleep(400 * time.Millisecond)
	}
}
Пример #2
0
func (elevinf *Elevatorinfo) HandleElevator() {

	sendToAll = make(chan string)
	sendToOne = make(chan network.DecodedMessage)
	receivedCostchan = make(chan receivedCost)
	receivedGochan = make(chan bool)
	receivedNoGochan = make(chan bool)
	receiveDeletion = make(chan string)
	gochan = make(chan string)
	noGochan = make(chan string)

	var communicator network.CommChannels
	communicator.CommChanInit()

	elevinf.state = IDLE
	elevinf.event = NO_EVENT

	// Initializing order arrays
	elevinf.internal_orders = make([][]int, N_FLOORS)
	for i := range elevinf.internal_orders {
		elevinf.internal_orders[i] = make([]int, N_BUTTONS)
	}
	elevinf.external_orders = make([][]int, N_FLOORS)
	for i := range elevinf.internal_orders {
		elevinf.external_orders[i] = make([]int, N_BUTTONS-1)
	}

	network.NetworkInit(communicator)
	go elevinf.ExternalOrderMaster(communicator)
	go elevinf.ExternalOrderSlave()
	go elevinf.ExternalOrderTimer()
	go elevinf.ExternalRecvDelete()
	go ExternalOrderSend(communicator)
	go ExternalOrderReceive(communicator)

	elevinf.BootStatemachine()

	elevinf.RunStatemachine()

}