model

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 31, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventTypeSignal      = EventType("signal")
	EventTypeCommlost    = EventType("commlost")
	EventTypeCommlostEnd = EventType("commlost_end")
	EventTypeOnbatt      = EventType("onbatt")
	EventTypeOnbattEnd   = EventType("onbatt_end")
	EventTypeOffline     = EventType("offline")
	EventTypeOnline      = EventType("online")
	EventTypeLineOk      = EventType("line_ok")
	EventTypeTrim        = EventType("trim")
	EventTypeBoost       = EventType("boost")
	EventTypeOverload    = EventType("overload")
	EventTypeOverloadEnd = EventType("overload_end")
	EventTypeNobatt      = EventType("nobatt")
	EventTypeNobattEnd   = EventType("nobatt_end")
	EventTypeTurnedOn    = EventType("turned_on")
	EventTypeTurnedOff   = EventType("turned_off")
)

Event types

View Source
const (
	SignalCommfailure   = Signal("commfailure")
	SignalCommok        = Signal("commok")
	SignalStartselftest = Signal("startselftest")
	SignalEndselftest   = Signal("endselftest")
	SignalPowerout      = Signal("powerout")
	SignalMainsback     = Signal("mainsback")
	SignalOnbattery     = Signal("onbattery")
	SignalOffbattery    = Signal("offbattery")
	SignalBattattach    = Signal("battattach")
	SignalChangeme      = Signal("changeme")
	SignalFailing       = Signal("failing")
	SignalTimeout       = Signal("timeout")
	SignalLoadlimit     = Signal("loadlimit")
	SignalDoshutdown    = Signal("doshutdown")
	SignalAnnoyme       = Signal("annoyme")
	SignalRemotedown    = Signal("remotedown")
)

Signals

Variables

View Source
var AlarmModeTypes = map[string]interface{}{
	"No alarm":    AlarmModeType(1),
	"Always":      AlarmModeType(2),
	"5 Seconds":   AlarmModeType(3),
	"30 Seconds":  AlarmModeType(4),
	"Low Battery": AlarmModeType(5),
}

AlarmModeTypes type enum

View Source
var CableTypes = map[string]interface{}{
	"Custom Cable Simple":  CableType(1),
	"APC Cable 940-0119A":  CableType(2),
	"APC Cable 940-0127A":  CableType(3),
	"APC Cable 940-0128A":  CableType(4),
	"APC Cable 940-0020B":  CableType(5),
	"APC Cable 940-0020C":  CableType(6),
	"APC Cable 940-0023A":  CableType(7),
	"MAM Cable 04-02-2000": CableType(8),
	"APC Cable 940-0095A":  CableType(9),
	"APC Cable 940-0095B":  CableType(10),
	"APC Cable 940-0095C":  CableType(11),
	"Custom Cable Smart":   CableType(12),
	"APC Cable 940-0024B":  CableType(121),
	"APC Cable 940-0024C":  CableType(122),
	"APC Cable 940-1524C":  CableType(123),
	"APC Cable 940-0024G":  CableType(124),
	"APC Cable 940-0625A":  CableType(125),
	"Ethernet Link":        CableType(13),
	"USB Cable":            CableType(14),
}

CableTypes type enum

View Source
var DriverTypes = map[string]interface{}{
	"DUMB UPS Driver":     DriverType(1),
	"APC Smart UPS (any)": DriverType(2),
	"USB UPS Driver":      DriverType(3),
	"NETWORK UPS Driver":  DriverType(4),
	"TEST UPS Driver":     DriverType(5),
	"PCNET UPS Driver":    DriverType(6),
	"SNMP UPS Driver":     DriverType(7),
	"MODBUS UPS Driver":   DriverType(8),
}

DriverTypes type enum

View Source
var ModeTypes = map[string]interface{}{
	"Stand Alone":     ModeType(1),
	"ShareUPS Slave":  ModeType(2),
	"ShareUPS Master": ModeType(3),
}

ModeTypes type enum

View Source
var SelftestResultTypes = map[string]interface{}{
	"NO": SelftestResultType(1),
	"OK": SelftestResultType(2),
	"BT": SelftestResultType(3),
	"NG": SelftestResultType(4),
	"IP": SelftestResultType(5),
	"WN": SelftestResultType(6),
	"??": SelftestResultType(7),
}

SelftestResultTypes type enum

View Source
var SensivityTypes = map[string]interface{}{
	"Low":         SensivityType(1),
	"Medium":      SensivityType(2),
	"High":        SensivityType(3),
	"Auto Adjust": SensivityType(4),
	"Unknown":     SensivityType(5),
}

SensivityTypes type enum

View Source
var StatusFlags = map[string]uint64{

	"calibration": 0x00000001,
	"trim":        0x00000002,
	"boost":       0x00000004,
	"online":      0x00000008,
	"onbatt":      0x00000010,
	"overload":    0x00000020,
	"battlow":     0x00000040,
	"replacebatt": 0x00000080,

	"commlost":    0x00000100,
	"shutdown":    0x00000200,
	"slave":       0x00000400,
	"slavedown":   0x00000800,
	"onbatt_msg":  0x00020000,
	"fastpoll":    0x00040000,
	"shut_load":   0x00080000,
	"shut_btime":  0x00100000,
	"shut_ltime":  0x00200000,
	"shut_emerg":  0x00400000,
	"shut_remote": 0x00800000,
	"plugged":     0x01000000,
	"battpresent": 0x04000000,
}

StatusFlags ..

View Source
var TransferOnbatteryReasonTypes = map[string]interface{}{
	"No transfers since turnon":         TransferOnbatteryReasonType(1),
	"Automatic or explicit self test":   TransferOnbatteryReasonType(2),
	"Forced by software":                TransferOnbatteryReasonType(3),
	"Low line voltage":                  TransferOnbatteryReasonType(4),
	"High line voltage":                 TransferOnbatteryReasonType(5),
	"Unacceptable line voltage changes": TransferOnbatteryReasonType(6),
	"Line voltage notch or spike":       TransferOnbatteryReasonType(7),
	"Input frequency out of range":      TransferOnbatteryReasonType(8),
	"UNKNOWN EVENT":                     TransferOnbatteryReasonType(9),
}

TransferOnbatteryReasonTypes enum

Functions

This section is empty.

Types

type AlarmMode

type AlarmMode struct {
	Type AlarmModeType
	Text string
}

AlarmMode ..

type AlarmModeType

type AlarmModeType uint8

AlarmModeType type

type Cable

type Cable struct {
	Type CableType
	Text string
}

Cable ..

type CableType

type CableType uint8

CableType type

type Driver

type Driver struct {
	Type DriverType
	Text string
}

Driver ..

type DriverType

type DriverType uint8

DriverType type

type Event

type Event struct {
	Ts   time.Time
	Type EventType
	Data map[string]interface{}
}

Event ..

type EventType

type EventType string

EventType ..

type Mode

type Mode struct {
	Type ModeType
	Text string
}

Mode ..

type ModeType

type ModeType uint8

ModeType type

type Model

type Model struct {
	State     State
	PrevState State

	NewEvents     []Event
	EventLimit    int
	ChangedFields map[string][]interface{}
	// contains filtered or unexported fields
}

Model data

func NewModel

func NewModel() *Model

NewModel ..

func (*Model) AddEvent

func (m *Model) AddEvent(e Event)

AddEvent ..

func (*Model) AddOnChange

func (m *Model) AddOnChange(handler func(*Model))

AddOnChange ..

func (*Model) GetEvents

func (m *Model) GetEvents() []Event

GetEvents ..

func (*Model) Update

func (m *Model) Update(newState State)

Update method

type SelftestResult

type SelftestResult struct {
	Type SelftestResultType
	Text string
}

SelftestResult ..

type SelftestResultType

type SelftestResultType uint8

SelftestResultType type

type Sensivity

type Sensivity struct {
	Type SensivityType
	Text string
}

Sensivity ..

type SensivityType

type SensivityType uint8

SensivityType type

type Signal

type Signal string

Signal ..

type State

type State struct {

	// input
	InputSensivity           Sensivity
	InputFrequency           float64
	InputVoltage             float64
	InputVoltageMin          float64
	InputVoltageMax          float64
	InputVoltageNominal      float64
	InputVoltageTransferLow  float64
	InputVoltageTransferHigh float64

	// output
	OutputLoad                 float64
	OutputAmps                 float64
	OutputPowerNominal         float64
	OutputPowerApparentNominal float64
	OutputVoltage              float64
	OutputVoltageNominal       float64

	// battery
	BatteryCharge         float64
	BatteryVoltage        float64
	BatteryVoltageNominal float64
	BatteryExternalCount  uint16
	BatteryBadCount       uint16
	BatteryReplacedDate   time.Time

	// ups
	UpsManafacturedDate           time.Time
	UpsModel                      string
	UpsSerial                     string
	UpsFirmware                   string
	UpsName                       string
	UpsStatus                     Status
	UpsDipSwitchFlag              uint64
	UpsReg1                       uint64
	UpsReg2                       uint64
	UpsReg3                       uint64
	UpsTimeleftSeconds            int64
	UpsTimeleftSecondsLowBattery  int64
	UpsTransferOnBatteryCount     uint64
	UpsTransferOnBatteryReason    TransferOnbatteryReason
	UpsTransferOnBatteryDate      time.Time
	UpsTransferOffBatteryDate     time.Time
	UpsOnBatterySeconds           int64
	UpsOnBatterySecondsCumulative int64
	UpsTurnOffDelaySeconds        int64
	UpsTurnOnDelaySeconds         int64
	UpsTurnOnBatteryMin           float64
	UpsTempInternal               float64
	UpsTempAmbient                float64
	UpsHumidity                   float64
	UpsAlarmMode                  AlarmMode
	UpsSelftestResult             SelftestResult
	UpsSelftestIntervalSeconds    int64
	UpsCable                      Cable
	UpsDriver                     Driver
	UpsMode                       Mode

	// shutdown
	ShutdownBatteryMin          float64
	ShutdownTimeleftSecondsMin  int64
	ShutdownOnBatterySecondsMax int64

	// apcupsd
	ApcupsdHost      string
	ApcupsdVersion   string
	ApcupsdStartTime time.Time
}

State - parsed 'apcaccess status' result

func NewState

func NewState() State

NewState cotructor

func NewStateFromOutput

func NewStateFromOutput(o *apcupsd.Output, def *State) State

NewStateFromOutput ..

func (State) Compare

func (s State) Compare(b State) (equal bool, diff map[string][]interface{})

Compare method

func (State) GetLastUpsOnBatteryDuration

func (s State) GetLastUpsOnBatteryDuration() time.Duration

GetLastUpsOnBatteryDuration - last or current (if on battery)

type Status

type Status struct {
	Text             string
	Flag             uint64
	FlagChangeCounts map[string]uint64
}

Status ..

func NewStatus

func NewStatus(flag uint64, text string) Status

NewStatus func

func (Status) CloneFlagChangeCounts

func (s Status) CloneFlagChangeCounts() map[string]uint64

CloneFlagChangeCounts method

func (Status) Equal

func (s Status) Equal(b Status) bool

Equal method

func (Status) GetFlags

func (s Status) GetFlags() map[string]uint64

GetFlags method

func (Status) GetNormedFlags

func (s Status) GetNormedFlags(invert bool) map[string]uint8

GetNormedFlags method

type TransferOnbatteryReason

type TransferOnbatteryReason struct {
	Type TransferOnbatteryReasonType
	Text string
}

TransferOnbatteryReason ..

type TransferOnbatteryReasonType

type TransferOnbatteryReasonType uint8

TransferOnbatteryReasonType type

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL