zhangqian
2023-12-19 c688f083caf965cd13f640098ad204d8fd8c9e69
接收字节序参数
3个文件已修改
26 ■■■■ 已修改文件
constvar/const.go 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/common/common.go 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/device_plc.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
constvar/const.go
@@ -20,6 +20,18 @@
    PlcStartAddressTypeTotalNumberWrite PlcStartAddressType = 3
)
type EndianType string
const (
    EndianTypeBig    EndianType = "big"
    EndianTypeLittle EndianType = "little"
    EndianTypeMix    EndianType = "mix"
)
func (t EndianType) Valid() bool {
    return t == EndianTypeBig || t == EndianTypeLittle || t == EndianTypeMix
}
type PlcStartAddressValueType string
const (
model/common/common.go
@@ -90,12 +90,13 @@
    }
    PlcAddress struct {
        DeviceID     string                       `json:"deviceID"`     // 设备id
        Channel      int                          `json:"channel"`      // 生产通道on,一个机器可能有多个机位,需要分别配置plc地址
        StartAddress int                          `json:"startAddress"` // 数据起始地址
        Length       int                          `json:"length"`       // 数据长度
        Type         string                       `json:"type"`         // 数据类型
        FieldName    constvar.PlcStartAddressType `json:"fieldName"`    // 对应系统字段,完成量或总量
        DeviceID     string                       `json:"deviceID"`                        // 设备id
        Channel      int                          `json:"channel"`                         // 生产通道on,一个机器可能有多个机位,需要分别配置plc地址
        StartAddress int                          `json:"startAddress"`                    // 数据起始地址
        Length       int                          `json:"length"`                          // 数据长度
        Type         string                       `json:"type"`                            // 数据类型
        FieldName    constvar.PlcStartAddressType `json:"fieldName"`                       // 对应系统字段,完成量或总量
        Endian       constvar.EndianType          `json:"endian" gorm:"type:varchar(255)"` // 字节存储顺序,big(ABCD)/little(CDBA)/mix(CDAB)
    }
)
model/device_plc.go
@@ -41,6 +41,7 @@
        Length       int                               `json:"length"`       // 数据长度
        Type         constvar.PlcStartAddressValueType `json:"type"`         // 数据类型
        FieldName    constvar.PlcStartAddressType      `json:"fieldName"`    // 对应系统字段
        Endian       constvar.EndianType               `json:"endian"`       // 字节存储顺序,big(ABCD)/little(CDBA)/mix(CDAB)
    }
    DevicePlcSearch struct {