zhangzengfei
2023-08-11 742923a5512707bdfd4c0e2e9adfcb86b453be28
msg/msg.go
@@ -1,17 +1,46 @@
package msg
type PLCDevice struct {
   Id       string
   Name     string
   Ip       string
   Address  []int // 数据地址
   Interval int   // 采集的时间间隔. 秒
   DeviceID   string        `json:"deviceId"`
   DeviceName string        `json:"deviceName"`
   DeviceIP   string        `json:"deviceIp"`
   Brand      string        `json:"brand"`
   Method     string        `json:"method"`
   PortName   string        `json:"portName"`
   Frequency  int           `json:"frequency"` // 数据更新频率 0-实时更新 1-1次/秒"
   Status     int           `json:"status"`
   Details    []*PLCAddress `gorm:"-" json:"Details"`
}
type PLCAddress struct {
   StartAddress int    `json:"startAddress"` // 数据起始地址
   Length       int    `json:"length"`       // 数据长度
   Type         string `json:"type"`         // 数据类型
   FieldName    string `json:"fieldName"`    // 对应系统字段
}
type PLCResponse struct {
   Id     string
   Name   string
   Ip     string
   Online bool
   Data   map[int][]byte
   DeviceID   string    `json:"deviceId"`
   DeviceName string    `json:"deviceName"`
   DeviceIP   string    `json:"deviceIp"`
   Online     bool      `json:"online"`
   PLCData    []PLCData `json:"plcData"`
}
type PLCData struct {
   StartAddress int    `json:"startAddress"` // 数据起始地址
   Length       int    `json:"length"`       // 数据长度
   Type         string `json:"type"`         // 数据类型
   FieldName    string `json:"fieldName"`    // 对应系统字段
   RawData      []byte `json:"rawData"`      // 从plc读取的原始数据
   Message      string `json:"message"`
}
type ApsDeviceApiResponse struct {
   Code     int         `json:"code"`
   Data     []PLCDevice `json:"data"`
   Msg      string      `json:"msg"`
   Page     int         `json:"page"`
   PageSize int         `json:"pageSize"`
   Total    int         `json:"total"`
}