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" Int16 = "int16" UInt16 = "uint16" Int32 = "int32" UInt32 = "uint32" Int64 = "int64" UInt64 = "uint64" Float32 = "float32" Float64 = "float64" )
Variables ¶
View Source
var SysName = map[string]struct{}{ SysTime: {}, SlaveId: {}, }
Functions ¶
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"` // Encoding whether collect data and send binary stream or collect and parse data send JSON data Encoding string `yaml:"encoding" json:"encoding" validate:"regexp=^(binary|json)?$" default:"json"` // Time time format Time Time `yaml:"time" json:"time" default:"{\"name\":\"time\", \"type\":\"integer\"}"` // Maps definition of data points Maps []MapConfig `yaml:"maps" json:"maps"` // Publish publish topic of collected data Publish Publish `yaml:"publish" json:"publish" validate:"nonnil"` }
func (*Job) SetDefaults ¶
func (job *Job) SetDefaults()
type MapConfig ¶
type MapConfig struct { // 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"` // parsed attributes Field Field `yaml:"field" json:"field"` }
MapConfig map point configuration
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(cfg SlaveConfig, client *MbClient) *Slave
type SlaveConfig ¶
type SlaveConfig struct { // 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)?$"` // RS485 Configuration related to RS485 RS485 struct { // Enabled Enable RS485 support Enabled bool `yaml:"enabled" json:"enabled"` // DelayRtsBeforeSend Delay RTS prior to send DelayRtsBeforeSend time.Duration `yaml:"delay_rts_before_send" json:"delay_rts_before_send"` // DelayRtsAfterSend Delay RTS after send DelayRtsAfterSend time.Duration `yaml:"delay_rts_after_send" json:"delay_rts_after_send"` // RtsHighDuringSend Set RTS high during send RtsHighDuringSend bool `yaml:"rts_high_during_send" json:"rts_high_during_send"` // RtsHighAfterSend Set RTS high after send RtsHighAfterSend bool `yaml:"rts_high_after_send" json:"rts_high_after_send"` // RxDuringTx Rx during Tx RxDuringTx bool `yaml:"rx_during_tx" json:"rx_during_tx"` } `yaml:"rs485" json:"rs485"` }
SlaveConfig modbus slave device configuration
Source Files ¶
Click to show internal directories.
Click to hide internal directories.