From 3e72a10e4e596451efdfebf6b0b3105a0e6da39b Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期五, 27 十月 2023 16:05:53 +0800
Subject: [PATCH] add log
---
model/device_plc.go | 19 +++++++++++++++++--
1 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/model/device_plc.go b/model/device_plc.go
index 4136ecb..a098e81 100644
--- a/model/device_plc.go
+++ b/model/device_plc.go
@@ -13,14 +13,20 @@
// DevicePlc 璁惧鐨凱LC閰嶇疆
DevicePlc struct {
gorm.Model
+ DeviceID string `gorm:"column:device_id;type:varchar(255);not null;unique" json:"deviceID"` //璁惧缂栧彿
Brand string `gorm:"type:varchar(191)" json:"brand"`
Method constvar.PlcMethod `gorm:"type:varchar(191)" json:"method"`
Address string `gorm:"type:varchar(191)" json:"address"` //plc ip鍦板潃锛� method = modbusTCP鐢�
Port int `json:"port"` //plc 绔彛鍙凤紝 method = modbusTCP鐢�
BaudRate int `json:"baudRate"` //涓插彛娉㈢壒鐜囷紝 method = serial鏃� 鐢�
SerialName string `json:"serialName"` //涓插彛鍚嶇О锛宮ethod = 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"` //鏍¢獙鏂瑰紡锛宮ethod = modbusRTU 鐢�
+
+ IsOpen bool `json:"isOpen"`
+ Detail string `gorm:"type:varchar(2048)" json:"-"`
Details []*DevicePlcAddress `gorm:"-" json:"details"`
@@ -84,6 +90,11 @@
return slf
}
+func (slf *DevicePlcSearch) SetDeviceId(deviceId string) *DevicePlcSearch {
+ slf.DeviceID = deviceId
+ return slf
+}
+
func (slf *DevicePlcSearch) build() *gorm.DB {
var db = slf.Orm.Table(slf.TableName())
@@ -91,6 +102,10 @@
db = db.Where("id = ?", slf.ID)
}
+ if slf.DeviceID != "" {
+ db = db.Where("device_id = ?", slf.DeviceID)
+ }
+
if slf.Order != "" {
db = db.Order(slf.Order)
}
--
Gitblit v1.8.0