// Package sensor defines the hardware seam. Everything above this interface is // pure and testable on any machine; everything below it touches the Pi. package sensor import "time" // Reading is one complete sample. A Reading only exists if every channel was // read successfully — there is no partial Reading, because a partial sample // cannot be reasoned about downstream. type Reading struct { ACPresent bool Volts float64 SOC float64 At time.Time } // Sensor reads the UPS. Read returns an error if any channel fails; callers // must treat the Reading as invalid in that case. // // Implementations may hold OS handles open across calls. A Read that returns // an error must leave the Sensor usable: the next Read reacquires whatever it // needs. type Sensor interface { Read() (Reading, error) Close() error }