forked from OpenPDU/openpdu
50 lines
1.0 KiB
Go
50 lines
1.0 KiB
Go
package main
|
|
|
|
// Outlet Initial Status
|
|
const (
|
|
OutletInitialStatusOFF uint = 0
|
|
OutletInitialStatusON uint = 1
|
|
OutletInitialStatusLAST uint = 2 // if hardware supported
|
|
)
|
|
|
|
// Outlet def
|
|
type Outlet struct {
|
|
Name string `json:"name"`
|
|
Location string `json:"location"`
|
|
HasPowerMeter bool `json:"haspowermeter"`
|
|
InitialStatus uint `json:"initialstatus"`
|
|
Command Boardlink `json:"command"`
|
|
PowerMeter Boardlink `json:"powermeter"`
|
|
}
|
|
|
|
// PowerON def
|
|
func (o Outlet) PowerON() error {
|
|
return o.Command.PowerON()
|
|
}
|
|
|
|
// PowerOFF def
|
|
func (o Outlet) PowerOFF() error {
|
|
return o.Command.PowerOFF()
|
|
}
|
|
|
|
// PowerToggle def
|
|
func (o Outlet) PowerToggle() error {
|
|
return o.Command.PowerToggle()
|
|
}
|
|
|
|
// PowerInitial def
|
|
func (o Outlet) PowerInitial() error {
|
|
switch o.InitialStatus {
|
|
case OutletInitialStatusOFF:
|
|
return o.Command.PowerOFF()
|
|
case OutletInitialStatusON:
|
|
return o.Command.PowerON()
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// PowerStatus def
|
|
func (o Outlet) PowerStatus() (bool, error) {
|
|
return o.Command.PowerStatus()
|
|
}
|