From 5e99301887e7e7e2a2218dbfa3b395a7847f7a82 Mon Sep 17 00:00:00 2001
From: zjj <zjj123456>
Date: 星期三, 25 十二月 2024 16:57:20 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/common/model/LocTypeDto.java | 52 ++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 38 insertions(+), 14 deletions(-)
diff --git a/src/main/java/com/zy/common/model/LocTypeDto.java b/src/main/java/com/zy/common/model/LocTypeDto.java
index ccd52fc..d8e3e26 100644
--- a/src/main/java/com/zy/common/model/LocTypeDto.java
+++ b/src/main/java/com/zy/common/model/LocTypeDto.java
@@ -10,7 +10,7 @@
@Data
public class LocTypeDto {
- // 楂樹綆绫诲瀷{0:鏈煡,1:浣庡簱浣�,2:楂樺簱浣峿
+ // 楂樹綆绫诲瀷{0:鏈煡,1:杈冧綆搴撲綅,2:浣庡簱浣嶏紝3:楂樺簱浣�,4: 鐗归珮搴撲綅}
private Short locType1;
// 瀹界獎绫诲瀷{0:鏈煡,1:绐勫簱浣�,2:瀹藉簱浣峿
@@ -22,14 +22,38 @@
public LocTypeDto() {
}
+ public LocTypeDto(Short locType1, Short locType2, Short locType3) {
+ this.locType1 = locType1;
+ this.locType2 = locType2;
+ this.locType3 = locType3;
+ }
+
public LocTypeDto(StaProtocol staProtocol) {
- if (staProtocol.isHigh() == staProtocol.isLow()) {
- throw new CoolException("plc楂樹綆妫�娴嬪紓甯�");
+ int trueLen = 0;
+ if (staProtocol.isHigh()) {
+ trueLen++;
+ }
+ if (staProtocol.isHigh1()) {
+ trueLen++;
}
if (staProtocol.isLow()) {
- this.locType1 = 1; // 浣庡簱浣�
- } else {
- this.locType1 = 2; // 楂樺簱浣�
+ trueLen++;
+ }
+ if (staProtocol.isLow1()) {
+ trueLen++;
+ }
+ if (trueLen != 1) {
+ throw new CoolException("plc楂樹綆妫�娴嬪紓甯�");
+ }
+
+ if (staProtocol.isLow()) {
+ this.locType1 = 1; // 杈冧綆搴撲綅
+ } else if (staProtocol.isLow1()){
+ this.locType1 = 2; // 浣庡簱浣�
+ } else if (staProtocol.isHigh()){
+ this.locType1 = 3; // 楂樺簱浣�
+ } else if (staProtocol.isHigh1()){
+ this.locType1 = 4; // 鐗归珮搴撲綅
}
}
@@ -38,14 +62,14 @@
*/
public static LocTypeDto process(StaProtocol staProtocol) {
LocTypeDto dto = new LocTypeDto();
- if (staProtocol.isHigh() == staProtocol.isLow()) {
- throw new CoolException("plc楂樹綆妫�娴嬪紓甯�");
- }
- if (staProtocol.isLow()) {
- dto.setLocType1((short) 1); // 浣庡簱浣�
- } else {
- dto.setLocType1((short) 2); // 楂樺簱浣�
- }
+// if (staProtocol.isHigh() == staProtocol.isLow()) {
+// throw new CoolException("plc楂樹綆妫�娴嬪紓甯�");
+// }
+// if (staProtocol.isLow()) {
+// dto.setLocType1((short) 1); // 浣庡簱浣�
+// } else {
+// dto.setLocType1((short) 2); // 楂樺簱浣�
+// }
return dto;
}
--
Gitblit v1.9.1