From c688f083caf965cd13f640098ad204d8fd8c9e69 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期二, 19 十二月 2023 17:21:01 +0800
Subject: [PATCH] 接收字节序参数
---
constvar/const.go | 12 ++++++++++++
model/common/common.go | 13 +++++++------
model/device_plc.go | 1 +
3 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/constvar/const.go b/constvar/const.go
index 152d582..d92819b 100644
--- a/constvar/const.go
+++ b/constvar/const.go
@@ -20,6 +20,18 @@
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 (
diff --git a/model/common/common.go b/model/common/common.go
index b0a9b22..d918026 100644
--- a/model/common/common.go
+++ b/model/common/common.go
@@ -90,12 +90,13 @@
}
PlcAddress struct {
- DeviceID string `json:"deviceID"` // 璁惧id
- Channel int `json:"channel"` // 鐢熶骇閫氶亾on锛屼竴涓満鍣ㄥ彲鑳芥湁澶氫釜鏈轰綅锛岄渶瑕佸垎鍒厤缃畃lc鍦板潃
- StartAddress int `json:"startAddress"` // 鏁版嵁璧峰鍦板潃
- Length int `json:"length"` // 鏁版嵁闀垮害
- Type string `json:"type"` // 鏁版嵁绫诲瀷
- FieldName constvar.PlcStartAddressType `json:"fieldName"` // 瀵瑰簲绯荤粺瀛楁锛屽畬鎴愰噺鎴栨�婚噺
+ DeviceID string `json:"deviceID"` // 璁惧id
+ Channel int `json:"channel"` // 鐢熶骇閫氶亾on锛屼竴涓満鍣ㄥ彲鑳芥湁澶氫釜鏈轰綅锛岄渶瑕佸垎鍒厤缃畃lc鍦板潃
+ StartAddress int `json:"startAddress"` // 鏁版嵁璧峰鍦板潃
+ Length int `json:"length"` // 鏁版嵁闀垮害
+ Type string `json:"type"` // 鏁版嵁绫诲瀷
+ FieldName constvar.PlcStartAddressType `json:"fieldName"` // 瀵瑰簲绯荤粺瀛楁锛屽畬鎴愰噺鎴栨�婚噺
+ Endian constvar.EndianType `json:"endian" gorm:"type:varchar(255)"` // 瀛楄妭瀛樺偍椤哄簭锛宐ig(ABCD)/little(CDBA)/mix(CDAB)
}
)
diff --git a/model/device_plc.go b/model/device_plc.go
index 4f5f687..2d40004 100644
--- a/model/device_plc.go
+++ b/model/device_plc.go
@@ -41,6 +41,7 @@
Length int `json:"length"` // 鏁版嵁闀垮害
Type constvar.PlcStartAddressValueType `json:"type"` // 鏁版嵁绫诲瀷
FieldName constvar.PlcStartAddressType `json:"fieldName"` // 瀵瑰簲绯荤粺瀛楁
+ Endian constvar.EndianType `json:"endian"` // 瀛楄妭瀛樺偍椤哄簭锛宐ig(ABCD)/little(CDBA)/mix(CDAB)
}
DevicePlcSearch struct {
--
Gitblit v1.8.0