package main

// Boardlink def
type Boardlink struct {
	BoardID string `json:"boardid"`
	Channel uint   `json:"channel"`
	board   *Board
}

// Board def
func (bl Boardlink) Board() *Board {
	if bl.board == nil {
		for i := range TheConfig.Boards {
			if TheConfig.Boards[i].ID == bl.BoardID {
				bl.board = TheConfig.Boards[i]
				break
			}
		}
	}
	return bl.board
}

// PowerON def
func (bl Boardlink) PowerON() error {
	b := bl.Board()
	return b.PowerON(bl.Channel)
}

// PowerOFF def
func (bl Boardlink) PowerOFF() error {
	b := bl.Board()
	return b.PowerOFF(bl.Channel)
}

// PowerToggle def
func (bl Boardlink) PowerToggle() error {
	b := bl.Board()
	return b.PowerToggle(bl.Channel)
}

// PowerStatus def
func (bl Boardlink) PowerStatus() (bool, error) {
	b := bl.Board()
	return b.PowerStatus(bl.Channel)
}
