From 10c65da3d2af7056f48d9301e83f53f102f76e18 Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期一, 30 十月 2023 14:52:11 +0800 Subject: [PATCH] fix --- model/common/common.go | 52 ++++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 40 insertions(+), 12 deletions(-) diff --git a/model/common/common.go b/model/common/common.go index 2b3e2c9..d616014 100644 --- a/model/common/common.go +++ b/model/common/common.go @@ -74,14 +74,17 @@ } PlcConfig struct { - Brand string `gorm:"type:varchar(191);comment:PLC鍝佺墝" json:"brand"` - Method constvar.PlcMethod `gorm:"type:varchar(191);comment:鎺ュ彛鏂瑰紡" json:"method"` - Address string `gorm:"type:varchar(191);comment:PLC鍦板潃" json:"address"` //plc ip鍦板潃锛� method = modbusTCP鐢� - Port int `gorm:"type:int(11);comment:绔彛" json:"port"` //plc 绔彛鍙凤紝 method = modbusTCP鐢� - BaudRate int `gorm:"type:int(11);comment:娉㈢壒鐜�" json:"baudRate"` //涓插彛娉㈢壒鐜囷紝 method = serial鏃� 鐢� - SerialName string `gorm:"type:int(11);comment:涓插彛鍚嶇О" json:"serialName"` //涓插彛鍚嶇О锛宮ethod = serial鏃� 鐢� - IsOpen bool `gorm:"type:tinyint(1);comment:鏄惁寮�鍚�" json:"isOpen"` - Detail string `gorm:"type:varchar(2048);comment:鏁版嵁璇︽儏" json:"-"` + Brand string `gorm:"type:varchar(191)" json:"brand"` //comment:PLC鍝佺墝 + 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鎴杕odbusRTU 鏃剁敤 + SerialName string `gorm:"type:int(11)" json:"serialName"` //涓插彛鍚嶇О锛宮ethod = serial鎴杕odbusRTU 鏃剁敤 + 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"` //鏍¢獙鏂瑰紡锛宮ethod = modbusRTU 鐢� + IsOpen bool `gorm:"type:tinyint(1)" json:"isOpen"` + Detail string `gorm:"type:varchar(2048)" json:"-"` Details []*PlcAddress `gorm:"-" json:"details"` } @@ -107,11 +110,8 @@ } ResponseProcessParams struct { Number string `json:"number"` //宸ヨ壓妯″瀷缂栧彿 - OrderId string `json:"orderId"` //璁㈠崟id Product string `json:"product"` //浜у搧鍚嶇О Procedure string `json:"procedure"` //宸ュ簭 - WorkOrder string `json:"workOrder"` //宸ュ崟 - Device string `json:"device"` //璁惧 Params string `json:"params"` ParamsMap map[string]interface{} `json:"paramsMap"` DeviceId string `json:"deviceId" gorm:"-"` //鐢ㄤ簬杩囨护鑾峰彇nsq娑堟伅 @@ -127,13 +127,41 @@ IsFinish bool //鏄惁瀹屾垚 } -type Device struct { +// DeviceMsg 涓嬪彂鍒扮粓绔殑璁惧淇℃伅 +type DeviceMsg struct { ID string `gorm:"comment:涓婚敭ID;primaryKey;type:varchar(191);" json:"id"` DeviceProcedureAttr []*DeviceProcedureAttr `json:"deviceProcedureAttr"` // 璁惧宸ュ簭灞炴�у垪琛� ExtChannelAmount int `gorm:"type:tinyint;comment:棰濆鐨勯�氶亾鏁伴噺;default:0;" json:"extChannelAmount"` + PlcAddressList []*PlcAddress + PlcConfig *PlcConfig } type DeviceProcedureAttr struct { ProcedureID string `gorm:"index;type:varchar(191);comment:宸ュ簭ID" json:"procedureId"` ProcedureName string `gorm:"type:varchar(191);comment:宸ュ簭鍚嶇О" json:"procedureName"` DeviceID string `gorm:"index;type:varchar(191);not null;comment:璁惧ID" json:"deviceId"` } + +type PullDataType string + +const ( + PullDataTypeProcessModel = "process_model" + PullDataTypeDevice = "device" +) + +// MsgPullDataRequest 鎷夊彇浜戠鏁版嵁 +type MsgPullDataRequest struct { + DataType PullDataType `json:"dataType"` //瑕佹媺鍙栫殑鏁版嵁绫诲瀷 +} + +type MsgPullDataResponse struct { + DataType PullDataType `json:"dataType"` //瑕佹媺鍙栫殑鏁版嵁绫诲瀷 + Data interface{} //杩斿洖鐨勬暟鎹� +} + +type RTUConfig struct { + BaudRate int `json:"baudRate"` //涓插彛娉㈢壒鐜囷紝 method = serial鏃� 鐢� + SerialName string `json:"serialName"` //涓插彛鍚嶇О锛宮ethod = serial鏃� 鐢� + 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"` //鏍¢獙鏂瑰紡锛宮ethod = modbusRTU 鐢� +} -- Gitblit v1.8.0