代码拉取完成,页面将自动刷新
package FlyModbusSlaves
import (
"errors"
"gitee.com/flyiot/flylibs/FlyConfigFile"
)
type FlyModbusSlaveSettings struct {
Enable bool
ConfigType string
ConfigKey string
Debug bool
SlaveID uint
EnableTcp bool
EnableSerial bool
MirrorAddress int
TcpAddr string
Port string
BaudRate uint
DataBits uint
ParityMode string
StopBits uint
MinimumReadSize uint
InterCharacterTimeout uint
Ready bool
}
func NewFlyModbusSlaveSettings() *FlyModbusSlaveSettings {
s := FlyModbusSlaveSettings{}
s.SlaveID = 1
s.TcpAddr = "0.0.0.0:1502"
s.BaudRate = 115200
s.DataBits = 8
s.ParityMode = "none"
s.StopBits = 1
s.MinimumReadSize = 1
s.InterCharacterTimeout = 0
s.MirrorAddress = 40000
return &s
}
// 从ini加载配置信息
func (s *FlyModbusSlaveSettings) LoadIni(config *FlyConfigFile.FlyIni, key string) error {
s.Ready = false
if !config.Ready {
return errors.New("config file error")
}
s.Enable = config.GetBool(key, "enable", true)
s.ConfigType = "ini"
s.ConfigKey = key
s.Debug = config.GetBool(key, "debug", false)
s.SlaveID = config.GetUint(key, "slave_id", 1)
s.EnableTcp = config.GetBool(key, "enable_tcp", true)
s.EnableSerial = config.GetBool(key, "enable_serial", true)
s.TcpAddr = config.GetString(key, "tcp_addr", "0.0.0.0:1502")
s.Port = config.GetString(key, "port", "")
s.BaudRate = config.GetUint(key, "baudrate", 115200)
s.DataBits = config.GetUint(key, "databits", 8)
s.ParityMode = config.GetString(key, "paritymode", "none")
s.StopBits = config.GetUint(key, "stopbits", 1)
s.MinimumReadSize = config.GetUint(key, "minimumreadsize", 1)
s.InterCharacterTimeout = config.GetUint(key, "intercharactertimeout", 0)
s.MirrorAddress = config.GetInt(key, "mirror_address", 40000)
s.Ready = true
return nil
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。