node

package
v0.16.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 3, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package node contains functionality to manage different types of nodes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init added in v0.0.30

func Init(nc *nats.Conn) error

Init is used to create initial root node and admin user

Types

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager is responsible for maintaining node state, running rules, etc

func NewManger

func NewManger(nc *nats.Conn, appVersion, osVersionField string) *Manager

NewManger creates a new Manager

func (*Manager) Start added in v0.3.0

func (m *Manager) Start() error

Start manager

func (*Manager) Stop added in v0.3.0

func (m *Manager) Stop(_ error)

Stop manager

type Modbus added in v0.0.16

type Modbus struct {
	// contains filtered or unexported fields
}

Modbus describes a modbus bus

func NewModbus added in v0.0.16

func NewModbus(nc *nats.Conn, node data.NodeEdge) (*Modbus, error)

NewModbus creates a new bus from a node

func (*Modbus) CheckIOs added in v0.0.16

func (b *Modbus) CheckIOs() error

CheckIOs goes through ios on the bus and handles any config changes

func (*Modbus) ClientIO added in v0.0.16

func (b *Modbus) ClientIO(io *ModbusIO) error

ClientIO processes an IO on a client bus

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

func (b *Modbus) ReadBusBit(io *ModbusIO) error

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

func (b *Modbus) ReadBusReg(io *ModbusIO) error

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) SendPoint added in v0.0.16

func (b *Modbus) SendPoint(nodeID, pointType string, value float64) error

SendPoint sends a point over nats

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) SetupPort added in v0.0.16

func (b *Modbus) SetupPort() error

SetupPort sets up io for the 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

func (*ModbusIO) Stop added in v0.0.16

func (io *ModbusIO) Stop()

Stop 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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL