forked from OpenPDU/openpdu
go on
This commit is contained in:
49
t/outlet.go
Normal file
49
t/outlet.go
Normal file
@@ -0,0 +1,49 @@
|
||||
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()
|
||||
}
|
||||
Reference in New Issue
Block a user