Documentation
¶
Index ¶
Constants ¶
const ( // DiFilename to check for DiFilename = "di_value" // DiTrueValue is the value considered to be true DiTrueValue = "1" // DiFolderRegex represents to regular expression used for finding the required file to read from DiFolderRegex = "di_[0-9]_[0-9]{2}" )
const ( // DoFilename to check for DoFilename = "do_value" // DoTrueValue digital output true value to write DoTrueValue = "1\n" // DoFalseValue digital output false value to write DoFalseValue = "0\n" // DoFolderRegex regular expression used for finding folders which contain digital output DoFolderRegex = "do_[0-9]_[0-9]{2}" )
const ( // SysFsRoot default root folder to search for digital inputs SysFsRoot = "/sys/devices/platform/unipi_plc" // MsgTrueValue is the MQTT true value to check for MsgTrueValue = "ON" )
Variables ¶
This section is empty.
Functions ¶
func FindDigitalOutputWriters ¶
func FindDigitalOutputWriters(root string) (writerMap map[string]DigitalOutputWriter, err error)
FindDigitalOutputWriters generates the output writes from a given path
Types ¶
type Configuration ¶
Configuration represents the topic name for the MQTT message for a given instance name
func (*Configuration) Name ¶
func (c *Configuration) Name(topic string) string
Name reverse mapping of topic for given name. In case nothing is found, just return the topic itself, hoping there's a mapped instance for it
func (*Configuration) Topic ¶
func (c *Configuration) Topic(name string) string
Topic gets a topic (value) for a given name (key). Return the name itself as fallback
type DigitalInput ¶
type DigitalInput interface { Update(chan *DigitalInput) error Poll(chan *DigitalInput, int) Close() }
DigitalInput interface for doing the polling
type DigitalInputReader ¶
type DigitalInputReader struct { Name string Value bool Path string Err error // contains filtered or unexported fields }
DigitalInputReader implements the digital input interface
func FindDigitalInputReaders ¶
func FindDigitalInputReaders(root string) (readers []DigitalInputReader, err error)
FindDigitalInputReaders crawls the root (sys) folder to find any matching digial inputs and creates corresponding DigitalInputReader instances from these.
func NewDigitalInputReader ¶
func NewDigitalInputReader(folder string, name string) (d *DigitalInputReader, err error)
NewDigitalInputReader creates a new DigitalInput and opens the file handle
func (*DigitalInputReader) Close ¶
func (d *DigitalInputReader) Close() error
Close closes the current open file handle
func (*DigitalInputReader) Poll ¶
func (d *DigitalInputReader) Poll(events chan *DigitalInputReader, interval int)
Poll continuously updates the instance
func (*DigitalInputReader) Update ¶
func (d *DigitalInputReader) Update(events chan *DigitalInputReader) (err error)
Update reads the value and sets the new value
type DigitalOutput ¶
DigitalOutput represents the digital outputs of the unipi board
type DigitalOutputWriter ¶
DigitalOutputWriter implements the digital output specifically for writing outputs to files
func NewDigitalOutputWriter ¶
func NewDigitalOutputWriter(folder string) (d *DigitalOutputWriter)
NewDigitalOutputWriter creates a new digital output writer instance from a a given matching folder
func (*DigitalOutputWriter) Update ¶
func (d *DigitalOutputWriter) Update(value bool) (err error)
Update writes the updated value to the digital output
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler implements handles all unipi to MQTT interactions