zhangzengfei
2023-08-11 bc0b7e914a378b2c40f9d2ec2470b61a19c18288
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package msg
 
type PLCDevice struct {
    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 {
    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"`
}