From e77e66d681cd2676675d194211f171744e23b479 Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期四, 14 九月 2023 19:05:54 +0800 Subject: [PATCH] 从云端获取plc配置和plc地址 --- model/common/common.go | 34 ++++++++++++++++++++++++++++++---- 1 files changed, 30 insertions(+), 4 deletions(-) diff --git a/model/common/common.go b/model/common/common.go index 8a8783a..5eafc0d 100644 --- a/model/common/common.go +++ b/model/common/common.go @@ -1,6 +1,9 @@ package common -import "github.com/shopspring/decimal" +import ( + "apsClient/constvar" + "github.com/shopspring/decimal" +) // 鎺掔▼浠诲姟涓嬪彂 type ( @@ -62,9 +65,32 @@ DeviceId string } ResponsePlcAddress struct { - KeyData []byte - AddressData []byte - DeviceId string + KeyData []byte + AddressData []byte + DeviceId string + PlcAddressList []*PlcAddress + PlcConfig PlcConfig + } + + 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:"-"` + Details []*PlcAddress `gorm:"-" json:"details"` + } + + PlcAddress struct { + DeviceID string `json:"deviceID"` // 璁惧id + Position int `json:"position"` // 鐢熶骇浣嶇疆锛屼竴涓満鍣ㄥ彲鑳芥湁澶氫釜鏈轰綅锛岄渶瑕佸垎鍒厤缃畃lc鍦板潃 + StartAddress int `json:"startAddress"` // 鏁版嵁璧峰鍦板潃 + Length int `json:"length"` // 鏁版嵁闀垮害 + Type string `json:"type"` // 鏁版嵁绫诲瀷 + FieldName constvar.PlcStartAddressType `json:"fieldName"` // 瀵瑰簲绯荤粺瀛楁锛屽畬鎴愰噺鎴栨�婚噺 } ) -- Gitblit v1.8.0