constvar/const.go | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
model/common/common.go | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
model/device_plc.go | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
nsq/msg_handler.go | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
constvar/const.go
@@ -34,6 +34,7 @@ const ( PlcMethodModbusTCP PlcMethod = "modbusTCP" PlcMethodModbusRTU PlcMethod = "modbusRTU" PlcMethodSerial PlcMethod = "serial" PlcMethodModbusTCPChinese PlcMethod = "网络" PlcMethodSerialChinese PlcMethod = "串口" @@ -70,3 +71,11 @@ TaskModeCurrent TaskMode = 2 //未开始的和进行中的 TaskModeLastFinished TaskMode = 3 //上一个结束的 ) type Parity int const ( ParityEven Parity = 1 //奇校验 ParityOdd Parity = 2 //偶校验 ParityNull Parity = 3 //无校验 ) model/common/common.go
@@ -78,8 +78,11 @@ Method constvar.PlcMethod `gorm:"type:varchar(191)" json:"method"` //comment:接口方式 Address string `gorm:"type:varchar(191)" json:"address"` //plc ip地址, method = modbusTCP用 Port int `gorm:"type:int(11)" json:"port"` //plc 端口号, method = modbusTCP用 BaudRate int `gorm:"type:int(11)" json:"baudRate"` //串口波特率, method = serial时 用 SerialName string `gorm:"type:int(11)" json:"serialName"` //串口名称,method = serial时 用 BaudRate int `gorm:"type:int(11)" json:"baudRate"` //串口波特率, method = serial或modbusRTU 时用 SerialName string `gorm:"type:int(11)" json:"serialName"` //串口名称,method = serial或modbusRTU 时用 DataBit int `gorm:"type:int(11)" json:"dataBit"` //数据位,method = modbusRTU 用 StopBit int `gorm:"type:int(11)" json:"stopBit"` //停止位,method = modbusRTU 用 Parity constvar.Parity `gorm:"type:int(11)" json:"parity"` //校验方式,method = modbusRTU 用 IsOpen bool `gorm:"type:tinyint(1)" json:"isOpen"` Detail string `gorm:"type:varchar(2048)" json:"-"` Details []*PlcAddress `gorm:"-" json:"details"` model/device_plc.go
@@ -20,8 +20,13 @@ Port int `json:"port"` //plc 端口号, method = modbusTCP用 BaudRate int `json:"baudRate"` //串口波特率, method = serial时 用 SerialName string `json:"serialName"` //串口名称,method = serial时 用 IsOpen bool `json:"isOpen"` Detail string `gorm:"type:varchar(2048)" json:"-"` DataBit int `gorm:"type:int(11)" json:"dataBit"` //数据位,method = modbusRTU 用 StopBit int `gorm:"type:int(11)" json:"stopBit"` //停止位,method = modbusRTU 用 Parity constvar.Parity `gorm:"type:int(11)" json:"parity"` //校验方式,method = modbusRTU 用 IsOpen bool `json:"isOpen"` Detail string `gorm:"type:varchar(2048)" json:"-"` Details []*DevicePlcAddress `gorm:"-" json:"details"` nsq/msg_handler.go
@@ -301,15 +301,25 @@ oldPlcRecord, err := model.NewDevicePlcSearch().SetDeviceId(msg.ID).First() if err == gorm.ErrRecordNotFound { err = model.NewDevicePlcSearch().Create(&record) } else if record.Port != oldPlcRecord.Port || record.Method != oldPlcRecord.Method || } else if record.Port != oldPlcRecord.Port || record.Method != oldPlcRecord.Method || record.Address != oldPlcRecord.Address || record.Detail != oldPlcRecord.Detail { record.Detail != oldPlcRecord.Detail || record.BaudRate != oldPlcRecord.BaudRate || record.SerialName != oldPlcRecord.SerialName || record.DataBit != oldPlcRecord.DataBit || record.StopBit != oldPlcRecord.StopBit || record.Parity != oldPlcRecord.Parity { oldPlcRecord.Port = record.Port oldPlcRecord.Method = record.Method oldPlcRecord.Address = record.Address oldPlcRecord.Port = record.Port oldPlcRecord.Detail = record.Detail oldPlcRecord.BaudRate = record.BaudRate oldPlcRecord.SerialName = record.SerialName oldPlcRecord.DataBit = record.DataBit oldPlcRecord.StopBit = record.StopBit oldPlcRecord.Parity = record.Parity err = model.NewDevicePlcSearch().Save(oldPlcRecord) } if err != nil {