Documentation
¶
Index ¶
- func RegistersByName(device string) (registers map[int]Register, err error)
- type DatabaseConnection
- type DatabaseField
- type Reader
- func (rdr *Reader) Dump(factored bool)
- func (rdr *Reader) Get(code int, factored bool) (rValue Value, err error)
- func (rdr *Reader) Map(factored bool) map[int]Value
- func (rdr *Reader) Read() error
- func (rdr *Reader) ReadRegister(code int, factored bool) (val Value, err error)
- func (rdr *Reader) ScanHolding(start, stop uint16)
- func (rdr *Reader) Units(code int) string
- type Register
- type Value
- type Writer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DatabaseConnection ¶
type DatabaseConnection struct {
Host string
Port uint
User string
Password string
Name string
SSL bool
Query string
Fields []DatabaseField
// contains filtered or unexported fields
}
DatabaseConnection Structure that holds details of database connection and query to be executed
func (DatabaseConnection) Close ¶
func (dbC DatabaseConnection) Close()
Close Close the database connection, closing any open statements as well.
func (DatabaseConnection) Execute ¶
func (dbC DatabaseConnection) Execute(data map[int]Value) error
Execute Execute the stored query using supplied map of values
func (*DatabaseConnection) OpenDatabase ¶
func (dbC *DatabaseConnection) OpenDatabase() error
OpenDatabase Open a database connection and call Ping to verify the connection.
type DatabaseField ¶
DatabaseField Struct to allow for managing a relationship between a named field in the database and the corresponding element in the device Map() data
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader A reader structure allows us to tie a client to a device register map
func NewReader ¶
NewReader Return a configured Reader with the correct register mappings. Device names are converted to lower case for matching, so case provided is irrelevant.
func (*Reader) Map ¶
Map Return a map object of the registers. If getting a register returns a value it is simply omitted from the map.
func (*Reader) Read ¶
Read Read the registers that are required to provide data for the configured device. This attempts a single call to the device.
func (*Reader) ReadRegister ¶
ReadRegister Read the register specified by the code. This always causes the device to be queried.
func (*Reader) ScanHolding ¶
ScanHolding Given a start and stop register, scan the holding registers. Added as a convenience.
type Register ¶
type Register struct {
Description string
Units string
Register uint16
Format string
Factor float64
}
Register Structure that contains details of the register value available.
type Value ¶
type Value struct {
Unsigned16 uint16
Signed16 int16
Unsigned32 uint32
Signed32 int32
Coil bool
Ieee32 float64
}
Value As there are a number of possible return values, we simply return this structure with the appropriate member set.
func (*Value) FormatBytes ¶
FormatBytes Given a format string and some bytes, attempt to correctly format them
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Reader A reader structure allows us to tie a client to a device register map
func NewWriter ¶
NewWriter Return a configured Writer with the correct register mappings. Device names are converted to lower case for matching, so case provided is irrelevant.
func (*Writer) WriteDirect ¶
WriteDirect Write the given values to the specified register
func (*Writer) WriteRegister ¶
WriteRegister Write a given value to a register
func (*Writer) WriteSimple ¶
WriteSimple Write a given int value to a register after converting the type (if possible)