Documentation ¶
Index ¶
Constants ¶
View Source
const ( BinaryEncoding = "binary" JsonEncoding = "json" SecondPrecision = "s" NanoPrecision = "ns" IntegerTime = "integer" StringTime = "string" Coil = 1 DiscreteInput = 2 HoldingRegister = 3 InputRegister = 4 SlaveId = "slaveid" SysTime = "time" Bool = "bool" String = "string" Int16 = "int16" UInt16 = "uint16" Int32 = "int32" UInt32 = "uint32" Int64 = "int64" UInt64 = "uint64" Float32 = "float32" Float64 = "float64" )
Variables ¶
View Source
var (
ErrClientInvalid = errors.New("device client is invalid")
)
View Source
var (
ErrWorkerNotExist = errors.New("worker not exist")
)
View Source
var SysName = map[string]struct{}{ SysTime: {}, SlaveId: {}, }
Functions ¶
func PopulateQuantityIfNeeds ¶
func PopulateQuantityIfNeeds(cfg *MapConfig)
Types ¶
type Config ¶
type Config struct { // Slaves slave list Slaves []SlaveConfig `yaml:"slaves" json:"slaves"` // Jobs job list Jobs []Job `yaml:"jobs" json:"jobs" validate:"validjobs"` }
Config custom configuration of the timer module
type Job ¶
type Job struct { // SlaveID slave id defined in slaves SlaveID byte `yaml:"slaveid" json:"slaveid"` // Interval the interval between task execution Interval time.Duration `yaml:"interval" json:"interval" default:"5s"` // Maps definition of data points Maps []MapConfig `yaml:"maps" json:"maps"` }
func (*Job) SetDefaults ¶
func (job *Job) SetDefaults()
type MapConfig ¶
type MapConfig struct { // Name name of map config Name string `yaml:"name" json:"name"` // Type type of map type Type string `yaml:"type" json:"type"` // Function Function byte `yaml:"function" json:"function" validate:"min=1, max=4" validate:"nonzero"` // Address Address uint16 `yaml:"address" json:"address"` // Quantity Quantity uint16 `yaml:"quantity" json:"quantity"` // SwapByte whether swap byte, meaning using big endian or little endian SwapByte bool `yaml:"swapByte" json:"swapByte"` // SwapRegister whether swap high and low register SwapRegister bool `yaml:"swapRegister" json:"swapRegister"` }
MapConfig map point configuration
type Modbus ¶
type Modbus struct {
// contains filtered or unexported fields
}
func (*Modbus) DeltaCallback ¶
func (*Modbus) EventCallback ¶
type Publish ¶
type Publish struct { QOS uint32 `yaml:"qos" json:"qos" validate:"min=0, max=1"` Topic string `yaml:"topic" json:"topic" default:"timer" validate:"nonzero"` }
Publish publish topic
type Slave ¶
type Slave struct {
// contains filtered or unexported fields
}
func NewSlave ¶
func NewSlave(dev *dm.DeviceInfo, cfg SlaveConfig, client *MbClient) *Slave
type SlaveConfig ¶
type SlaveConfig struct { Device string `yaml:"device" json:"device"` // ID slave id Id byte `yaml:"id" json:"id"` // Mode mode of connecting Mode string `yaml:"mode" json:"mode" default:"rtu" validate:"regexp=^(tcp|rtu)?$"` // Address Device path (/dev/ttyS0) Address string `yaml:"address" json:"address" default:"/dev/ttyS0"` // Timeout Read (Write) timeout. Timeout time.Duration `yaml:"timeout" json:"timeout" default:"10s"` // IdleTimeout Idle timeout to close the connection IdleTimeout time.Duration `yaml:"idletimeout" json:"idletimeout" default:"1m"` //// RTU only // BaudRate (default 19200) BaudRate int `yaml:"baudrate" json:"baudrate" default:"19200"` // DataBits: 5, 6, 7 or 8 (default 8) DataBits int `yaml:"databits" json:"databits" default:"8" validate:"min=5, max=8"` // StopBits: 1 or 2 (default 1) StopBits int `yaml:"stopbits" json:"stopbits" default:"1" validate:"min=1, max=2"` // Parity: N - None, E - Even, O - Odd (default E) // (The use of no parity requires 2 stop bits.) Parity string `yaml:"parity" json:"parity" default:"E" validate:"regexp=^(E|N|O)?$"` }
SlaveConfig modbus slave device configuration
Source Files ¶
Click to show internal directories.
Click to hide internal directories.