zhangqian
2023-09-14 d93d2bc56ed06b3c060ff48f49591e8c5d779230
通讯方式字段转换
2个文件已修改
21 ■■■■ 已修改文件
constvar/const.go 19 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
nsq/msg_handler.go 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
constvar/const.go
@@ -34,12 +34,23 @@
type PlcMethod string
const (
    PlcMethodModbusTCP PlcMethod = "modbusTCP"
    PlcMethodSerial    PlcMethod = "serial"
    PlcMethodModbusTCP        PlcMethod = "modbusTCP"
    PlcMethodSerial           PlcMethod = "serial"
    PlcMethodModbusTCPChinese PlcMethod = "网络"
    PlcMethodSerialChinese    PlcMethod = "串口"
)
func (slf PlcMethod) Valid() bool {
    return slf == PlcMethodModbusTCP || slf == PlcMethodSerial
func (slf *PlcMethod) ConvertToEnglish() {
    if *slf == PlcMethodModbusTCPChinese {
        *slf = PlcMethodModbusTCP
    }
    if *slf == PlcMethodSerialChinese {
        *slf = PlcMethodSerial
    }
}
func (slf *PlcMethod) Valid() bool {
    return *slf == PlcMethodModbusTCP || *slf == PlcMethodSerial
}
const (
nsq/msg_handler.go
@@ -156,6 +156,8 @@
        return nil
    }
    resp.PlcConfig.Method.ConvertToEnglish()
    var record model.DevicePlc
    err = mapstructure.Decode(resp.PlcConfig, &record)
    if err != nil {