zhangqian
2023-12-20 1960a054785d1f81e69abe84b43073ed9df638e0
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
package constvar
 
const (
    NsqTopicScheduleTask              = "aps.%v.scheduleTask"            //排程任务下发
    NsqTopicApsProcessParams          = "aps.%v.aps.processParams"       //有了新的工艺模型
    NsqTopicTaskProcedureStatusUpdate = "aps.%v.task.procedure.status"   //工序状态更新
    NsqTopicSyncTaskProgress          = "aps.%v.task.procedure.progress" //工序生产进度
    NsqTopicDeviceUpdate              = "aps.%v.device.update"           //设备信息更改
    NsqTopicPullDataRequest           = "aps.%v.pull.data.request"       //拉取数据请求
    NsqTopicPullDataResponse          = "aps.%v.pull.data.response"      //拉取数据响应
    NsqTopicApsClientReportData       = "aps.%v.apsClient.report.data"   //apsClient上报数据
    NsqTopicSendDashboardData         = "aps.%v.apsClient.dashboard"     //下发dashboard数据
)
 
type PlcStartAddressType int
 
const (
    PlcStartAddressTypeFinishNumber     PlcStartAddressType = 1
    PlcStartAddressTypeTotalNumber      PlcStartAddressType = 2
    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 (
    PlcStartAddressValueTypeString PlcStartAddressValueType = "string"
    PlcStartAddressValueTypeInt16  PlcStartAddressValueType = "int16"
    PlcStartAddressValueTypeInt32  PlcStartAddressValueType = "int32"
)
 
const (
    PlcAddressDataPath          = "datafile/"
    PlcAddressDataKeyFileName   = "plc_address_key"
    PlcAddressDataValueFileName = "plc_address_value"
)
 
type PlcMethod string
 
const (
    PlcMethodModbusTCP        PlcMethod = "modbusTCP"
    PlcMethodModbusRTU        PlcMethod = "modbusRTU"
    PlcMethodSerial           PlcMethod = "serial"
    PlcMethodModbusTCPChinese PlcMethod = "网络"
    PlcMethodSerialChinese    PlcMethod = "串口"
)
 
func (slf *PlcMethod) ConvertToEnglish() {
    if *slf == PlcMethodModbusTCPChinese {
        *slf = PlcMethodModbusTCP
    }
    if *slf == PlcMethodSerialChinese {
        *slf = PlcMethodSerial
    }
}
 
func (slf *PlcMethod) Valid() bool {
    return *slf == PlcMethodModbusTCP || *slf == PlcMethodSerial || *slf == PlcMethodModbusRTU
}
 
const (
    PlcCacheKeyFinishNumber = "finish_number"
    PlcCacheKeyTotalNumber  = "total_number"
)
 
const (
    PlcPackageApache               = "apache"
    PlcPackageGoBurrow             = "goBurrow"
    PlcPackageApacheLongConnection = "apacheLong"
)
 
type TaskMode int
 
const (
    TaskModeUnStarted    TaskMode = 1 //未开始的
    TaskModeCurrent      TaskMode = 2 //未开始的和进行中的
    TaskModeLastFinished TaskMode = 3 //上一个结束的
)
 
type Parity int
 
const (
    ParityEven Parity = 1 //奇校验
    ParityOdd  Parity = 2 //偶校验
    ParityNull Parity = 3 //无校验
)
 
func (p Parity) ToString() string {
    switch p {
    case ParityEven:
        return "E"
    case ParityOdd:
        return "O"
    case ParityNull:
        return "N"
    }
    return ""
}
 
const (
    SerfClusterStatusNull   = ""       //未加入集群
    SerfClusterStatusMaster = "master" //集群master
    SerfClusterStatusSlave  = "slave"  //集群slave
)
 
type ProblemCode string
 
const (
    ProblemCodeService                    ProblemCode = "service"                        //服务不可用
    ProblemCodeNetwork                    ProblemCode = "network"                        //网络错误
    ProblemCodeDB                         ProblemCode = "db"                             //数据库连接错误
    ProblemCodeSerf                       ProblemCode = "serf"                           //未加入serf集群
    ProblemCodeCloud                      ProblemCode = "cloud"                          //未连接云端
    ProblemCodeDevice                     ProblemCode = "device"                         //未绑定设备
    ProblemCodeProcessModel               ProblemCode = "process_model"                  //工艺参数缺失
    ProblemCodePlcConfig                  ProblemCode = "plc_config"                     //plc配置缺失
    ProblemCodePlcAddressList             ProblemCode = "plc_address_list"               //plc地址表缺失
    ProblemCodePlcProcessModelAddressList ProblemCode = "plc_process_model_address_list" //plc地址表缺失
    ProblemCodePlcConnect                 ProblemCode = "plc_connect"                    //plc连接失败
)
 
type SystemStatusKey string
 
const (
    SystemStatusKeyNsq SystemStatusKey = "nsq"
)
 
type SystemStatusValue string
 
const (
    SystemStatusValueNormal   SystemStatusValue = "1"
    SystemStatusValueUnNormal SystemStatusValue = "2"
)
 
type ReportType int //上报类型
 
const (
    ReportTypeSystemDeviceID ReportType = 1
    ReportTypeReportWork     ReportType = 2
)
 
type SyncStatus int //同步状态
 
const (
    SyncStatusWait SyncStatus = 1 //待同步
    SyncStatusOk   SyncStatus = 2 //已完成
)