Documentation
¶
Overview ¶
Package node contains functionality to manage different types of nodes.
Index ¶
- 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 ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager is responsible for maintaining node state, running rules, etc
type Modbus ¶
type Modbus struct {
// contains filtered or unexported fields
}
Modbus describes a modbus bus
func (*Modbus) ClosePort ¶
func (b *Modbus) ClosePort()
ClosePort closes both the server and client ports
func (*Modbus) InitRegs ¶
func (b *Modbus) InitRegs(io *ModbusIONode)
InitRegs is used in server mode to initilize the internal modbus regs when a IO changes
func (*Modbus) ReadBusBit ¶
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 ¶
ReadBusReg reads an io value from a reg from bus this function modifies io.value
func (*Modbus) ReadReg ¶
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 ¶
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 ¶
func (b *Modbus) ServerIO(io *ModbusIONode) error
ServerIO processes an IO on a server bus
func (*Modbus) WriteBusHoldingReg ¶
func (b *Modbus) WriteBusHoldingReg(io *ModbusIONode) error
WriteBusHoldingReg used to write register values to bus should only be used by client
func (*Modbus) WriteReg ¶
func (b *Modbus) WriteReg(io *ModbusIONode) error
WriteReg writes an io value to a reg This should only be used on server
type ModbusIO ¶
type ModbusIO struct {
// contains filtered or unexported fields
}
ModbusIO represents the state of a managed modbus io
func NewModbusIO ¶
func NewModbusIO(nc *nats.Conn, node *ModbusIONode, chPoint chan<- pointWID) (*ModbusIO, error)
NewModbusIO creates a new modbus IO
type ModbusIONode ¶
type ModbusIONode struct {
// contains filtered or unexported fields
}
ModbusIONode describes a modbus IO db node
func NewModbusIONode ¶
func NewModbusIONode(busType string, node *data.NodeEdge) (*ModbusIONode, error)
NewModbusIONode Convert node to modbus IO node
func (*ModbusIONode) Changed ¶
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 ¶
type ModbusManager struct {
// contains filtered or unexported fields
}
ModbusManager manages state of modbus
func NewModbusManager ¶
func NewModbusManager(nc *nats.Conn, rootNodeID string) *ModbusManager
NewModbusManager creates a new modbus manager
func (*ModbusManager) Update ¶
func (mm *ModbusManager) Update() error
Update queries DB for modbus nodes and synchronizes with internal structures and updates data
type ModbusNode ¶
type ModbusNode struct {
// contains filtered or unexported fields
}
ModbusNode is the node data from the database
func NewModbusNode ¶
func NewModbusNode(node data.NodeEdge) (*ModbusNode, error)
NewModbusNode converts a node to ModbusNode data structure