Documentation ¶
Overview ¶
Package node contains functionality to manage different types of nodes.
Index ¶
- func Init(nc *nats.Conn) error
- type Manager
- type Modbus
- func (b *Modbus) CheckIOs() error
- func (b *Modbus) ClientIO(io *ModbusIO) error
- func (b *Modbus) ClosePort()
- func (b *Modbus) InitRegs(io *ModbusIONode)
- func (b *Modbus) LogError(io *ModbusIONode, err error) error
- func (b *Modbus) ReadBusBit(io *ModbusIO) error
- func (b *Modbus) ReadBusReg(io *ModbusIO) error
- func (b *Modbus) ReadReg(io *ModbusIONode) (float64, error)
- func (b *Modbus) Run()
- func (b *Modbus) SendPoint(nodeID, pointType string, value float64) error
- func (b *Modbus) ServerIO(io *ModbusIONode) error
- func (b *Modbus) SetupPort() error
- func (b *Modbus) Stop()
- func (b *Modbus) WriteBusHoldingReg(io *ModbusIONode) error
- func (b *Modbus) WriteReg(io *ModbusIONode) error
- type ModbusIO
- type ModbusIONode
- type ModbusManager
- type ModbusNode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager is responsible for maintaining node state, running rules, etc
type Modbus ¶ added in v0.0.16
type Modbus struct {
// contains filtered or unexported fields
}
Modbus describes a modbus bus
func (*Modbus) CheckIOs ¶ added in v0.0.16
CheckIOs goes through ios on the bus and handles any config changes
func (*Modbus) ClosePort ¶ added in v0.0.20
func (b *Modbus) ClosePort()
ClosePort closes both the server and client ports
func (*Modbus) InitRegs ¶ added in v0.0.16
func (b *Modbus) InitRegs(io *ModbusIONode)
InitRegs is used in server mode to initilize the internal modbus regs when a IO changes
func (*Modbus) LogError ¶ added in v0.0.16
func (b *Modbus) LogError(io *ModbusIONode, err error) error
LogError ...
func (*Modbus) ReadBusBit ¶ added in v0.0.16
ReadBusBit is used to read coil of discrete input values from bus this function modifies io.value. This should only be called from client.
func (*Modbus) ReadBusReg ¶ added in v0.0.16
ReadBusReg reads an io value from a reg from bus this function modifies io.value
func (*Modbus) ReadReg ¶ added in v0.0.16
func (b *Modbus) ReadReg(io *ModbusIONode) (float64, error)
ReadReg reads an value from a reg (internal, not bus) This should only be used on server
func (*Modbus) Run ¶ added in v0.0.16
func (b *Modbus) Run()
Run is routine that runs the logic for a bus. Intended to be run as a goroutine It assumes an initial dataset is obtained from the database and all updates come from NATs this routine may need to run fast scan times, so it should be doing slow things like reading the database.
func (*Modbus) ServerIO ¶ added in v0.0.16
func (b *Modbus) ServerIO(io *ModbusIONode) error
ServerIO processes an IO on a server bus
func (*Modbus) Stop ¶ added in v0.0.16
func (b *Modbus) Stop()
Stop stops the bus and resets various fields
func (*Modbus) WriteBusHoldingReg ¶ added in v0.0.16
func (b *Modbus) WriteBusHoldingReg(io *ModbusIONode) error
WriteBusHoldingReg used to write register values to bus should only be used by client
func (*Modbus) WriteReg ¶ added in v0.0.16
func (b *Modbus) WriteReg(io *ModbusIONode) error
WriteReg writes an io value to a reg This should only be used on server
type ModbusIO ¶ added in v0.0.16
type ModbusIO struct {
// contains filtered or unexported fields
}
ModbusIO represents the state of a managed modbus io
func NewModbusIO ¶ added in v0.0.16
func NewModbusIO(nc *nats.Conn, node *ModbusIONode, chPoint chan<- pointWID) (*ModbusIO, error)
NewModbusIO creates a new modbus IO
type ModbusIONode ¶ added in v0.0.16
type ModbusIONode struct {
// contains filtered or unexported fields
}
ModbusIONode describes a modbus IO db node
func NewModbusIONode ¶ added in v0.0.16
func NewModbusIONode(busType string, node *data.NodeEdge) (*ModbusIONode, error)
NewModbusIONode Convert node to modbus IO node
func (*ModbusIONode) Changed ¶ added in v0.0.16
func (io *ModbusIONode) Changed(newIO *ModbusIONode) bool
Changed returns true if the config of the IO has changed FIXME, we should not need this once we get NATS wired
type ModbusManager ¶ added in v0.0.16
type ModbusManager struct {
// contains filtered or unexported fields
}
ModbusManager manages state of modbus
func NewModbusManager ¶ added in v0.0.16
func NewModbusManager(nc *nats.Conn, rootNodeID string) *ModbusManager
NewModbusManager creates a new modbus manager
func (*ModbusManager) Update ¶ added in v0.0.16
func (mm *ModbusManager) Update() error
Update queries DB for modbus nodes and synchronizes with internal structures and updates data
type ModbusNode ¶ added in v0.0.16
type ModbusNode struct {
// contains filtered or unexported fields
}
ModbusNode is the node data from the database
func NewModbusNode ¶ added in v0.0.16
func NewModbusNode(node data.NodeEdge) (*ModbusNode, error)
NewModbusNode converts a node to ModbusNode data structure