// NewReliefValveController returns ReliefValveController, the controller will be registered for the
// events those are used to set the coffee-maker's relief-valve state (OPEN, CLOSED) using api.
func NewReliefValveController(aggregator *events.Aggregator, api hardwareAPI.CommandAPI) *ReliefValveController {
	controller := ReliefValveController{Controller{Api: api}}

	// ReliefValveController is a subscriber for warmer-plate events
	aggregator.SubscribeFunc(controller.handleWarmerPlateEmptyEvent, machineEvent.WamerPlateEmpty)
	aggregator.SubscribeFunc(controller.handleWarmerPlateNotEmptyEvents, machineEvent.WamerPlatePotNotEmpty,
		machineEvent.WamerPlatePotEmpty)
	return &controller
}
Пример #2
0
// NewBoilerController returns BoilerController, the controller will be registered for the
// events those are used to set the coffee-maker's boiler heater state (ON, OFF) using api.
func NewBoilerController(aggregator *events.Aggregator, api hardwareAPI.CommandAPI) *BoilerController {
	controller := BoilerController{
		Controller:  Controller{Api: api},
		boilerEmpty: false,
	}

	// BoilerController is a subscriber for boiler events
	aggregator.SubscribeFunc(controller.handleBoilerEvents, machineEvent.BoilerEmpty, machineEvent.BoilerNotEmpty)
	// BoilerController is a subscriber for brew button event BrewButtonPushed
	aggregator.SubscribeFunc(controller.handleBrewButtonPushEvent, machineEvent.BrewButtonPushed)

	return &controller
}