Documentation
¶
Index ¶
- type ConnectionManager
- func (cm *ConnectionManager) GetDevice(unitID uint8) (*Device, bool)
- func (cm *ConnectionManager) HandleReadCoils(unitID uint8, addr uint16, quantity uint16) ([]bool, error)
- func (cm *ConnectionManager) HandleReadDiscreteInputs(unitID uint8, addr uint16, quantity uint16) ([]bool, error)
- func (cm *ConnectionManager) HandleReadHoldingRegisters(unitID uint8, addr uint16, quantity uint16) ([]uint16, error)
- func (cm *ConnectionManager) HandleReadInputRegisters(unitID uint8, addr uint16, quantity uint16) ([]uint16, error)
- func (cm *ConnectionManager) HandleWriteCoils(unitID uint8, addr uint16, values []bool) error
- func (cm *ConnectionManager) HandleWriteRegisters(unitID uint8, addr uint16, values []uint16) error
- func (cm *ConnectionManager) Start() error
- func (cm *ConnectionManager) Stop() error
- type Device
- func (d *Device) AddEventListener(cb EventCallback)
- func (d *Device) GetParameterValue(paramName string) (interface{}, error)
- func (d *Device) ReadCoil(addr uint16) (bool, error)
- func (d *Device) ReadDiscreteInput(addr uint16) (bool, error)
- func (d *Device) ReadRegister(fc int, addr uint16) (uint16, error)
- func (d *Device) UpdateLoop(stopChan <-chan struct{})
- func (d *Device) WriteCoil(addr uint16, val bool) error
- func (d *Device) WriteRegister(fc int, addr uint16, val uint16) error
- type EventCallback
- type EventType
- type Generator
- type LogLevel
- type Logger
- func (l *Logger) Debug(format string, args ...interface{})
- func (l *Logger) Error(format string, args ...interface{})
- func (l *Logger) Info(format string, args ...interface{})
- func (l *Logger) Log(level LogLevel, format string, args ...interface{})
- func (l *Logger) Subscribe(handler func(level LogLevel, msg string))
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConnectionManager ¶
type ConnectionManager struct {
Config *config.ConnectionConfig
Devices map[uint8]*Device // SlaveID -> Device
Listener net.Listener
// contains filtered or unexported fields
}
ConnectionManager manages a Modbus connection (Server or Client-Dialer).
func NewConnectionManager ¶
func NewConnectionManager(cfg *config.ConnectionConfig, devices []*Device) *ConnectionManager
NewConnectionManager creates a new manager.
func (*ConnectionManager) GetDevice ¶
func (cm *ConnectionManager) GetDevice(unitID uint8) (*Device, bool)
Error types for internal use if needed, or just use modbus package constants
func (*ConnectionManager) HandleReadCoils ¶
func (*ConnectionManager) HandleReadDiscreteInputs ¶
func (*ConnectionManager) HandleReadHoldingRegisters ¶
func (*ConnectionManager) HandleReadInputRegisters ¶
func (*ConnectionManager) HandleWriteCoils ¶
func (cm *ConnectionManager) HandleWriteCoils(unitID uint8, addr uint16, values []bool) error
func (*ConnectionManager) HandleWriteRegisters ¶
func (cm *ConnectionManager) HandleWriteRegisters(unitID uint8, addr uint16, values []uint16) error
func (*ConnectionManager) Start ¶
func (cm *ConnectionManager) Start() error
Start starts the connection (Listen or Dial).
func (*ConnectionManager) Stop ¶
func (cm *ConnectionManager) Stop() error
Stop stops the connection.
type Device ¶
type Device struct {
Config *config.DeviceConfig
Type *config.DeviceType
// contains filtered or unexported fields
}
Device represents a simulated Modbus device.
func NewDevice ¶
func NewDevice(cfg *config.DeviceConfig, devType *config.DeviceType) *Device
NewDevice creates a new Device instance.
func (*Device) AddEventListener ¶
func (d *Device) AddEventListener(cb EventCallback)
AddEventListener adds a callback for device events.
func (*Device) GetParameterValue ¶
GetParameterValue reads and parses the current value of a parameter
func (*Device) ReadRegister ¶
ReadRegister handles external read requests.
func (*Device) UpdateLoop ¶
func (d *Device) UpdateLoop(stopChan <-chan struct{})
UpdateLoop runs the script generation loop.
type EventCallback ¶
EventCallback is a function called when an event occurs.
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Generator handles dynamic value generation.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger handles application logging.