diff --git a/src/main/java/com/qgs/dc/common/utils/CommonFunction.java b/src/main/java/com/qgs/dc/common/utils/CommonFunction.java index 56f5552..d41d71e 100644 --- a/src/main/java/com/qgs/dc/common/utils/CommonFunction.java +++ b/src/main/java/com/qgs/dc/common/utils/CommonFunction.java @@ -14,6 +14,7 @@ import java.io.File; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.Arrays; +import java.util.List; import java.util.UUID; /** @@ -115,7 +116,8 @@ public class CommonFunction { * */ public static Object var(Object object){ if(object.getClass().isArray()){ - return Arrays.asList(object); + List objects = Arrays.asList(object); + return objects.get(0); } return object.toString(); } diff --git a/src/main/java/com/qgs/dc/opcua/selfunion/UAService.java b/src/main/java/com/qgs/dc/opcua/selfunion/UAService.java index ddf1af1..adbf5ec 100644 --- a/src/main/java/com/qgs/dc/opcua/selfunion/UAService.java +++ b/src/main/java/com/qgs/dc/opcua/selfunion/UAService.java @@ -1058,7 +1058,7 @@ public class UAService { //String s = ns.get(i)+","+id.get(i)+"|"+var.toString()+"|"+varType+"|"+plcName; - CurrentSubEntity cur = new CurrentSubEntity(ns.get(i),id.get(i),var,varType,isArray,plcName); + CurrentSubEntity cur = new CurrentSubEntity(ns.get(i),id.get(i),var,varType,isArray,plcName,CommonFunction.quality(values.get(i).getStatusCode())); result.add(cur); } return result; diff --git a/src/main/java/com/qgs/dc/opcua/selfunion/entity/CurrentSubEntity.java b/src/main/java/com/qgs/dc/opcua/selfunion/entity/CurrentSubEntity.java index f17112c..ff1193a 100644 --- a/src/main/java/com/qgs/dc/opcua/selfunion/entity/CurrentSubEntity.java +++ b/src/main/java/com/qgs/dc/opcua/selfunion/entity/CurrentSubEntity.java @@ -12,14 +12,16 @@ public class CurrentSubEntity { private String valueType; private Boolean isArray; private String plcName; + private String status; - public CurrentSubEntity(Integer nameSpace, String identifier, Object value, String valueType, Boolean isArray, String plcName) { + public CurrentSubEntity(Integer nameSpace, String identifier, Object value, String valueType, Boolean isArray, String plcName,String status) { this.nameSpace = nameSpace; this.identifier = identifier; this.value = value; this.valueType = valueType; this.isArray = isArray; this.plcName = plcName; + this.status = status; } public Boolean getArray() { @@ -69,4 +71,12 @@ public class CurrentSubEntity { public void setPlcName(String plcName) { this.plcName = plcName; } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } } diff --git a/src/main/java/com/qgs/dc/s7/controller/S7Controller.java b/src/main/java/com/qgs/dc/s7/controller/S7Controller.java index 8a9772a..18254de 100644 --- a/src/main/java/com/qgs/dc/s7/controller/S7Controller.java +++ b/src/main/java/com/qgs/dc/s7/controller/S7Controller.java @@ -29,7 +29,7 @@ public class S7Controller { @PostMapping("/addThisPlc") public R addThisPlc() throws PlcConnectionException { //s7://192.168.1.51?remote-rack=0&remote-slot=3&controller-type=S7_400,如果参数不是默认的 要向这样往url 后面加。 - return R.ok().put("res",s7Service.addPlc("s7://192.168.0.200")); + return R.ok().put("res",s7Service.addPlc("s7://192.168.0.100")); } @PostMapping("/getValue") public R getValue() throws PlcConnectionException {