Skip to content

Commit 26e2392

Browse files
committed
ver1.7.5
1 parent 900f676 commit 26e2392

File tree

16 files changed

+235
-57
lines changed

16 files changed

+235
-57
lines changed

core/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,10 @@
293293
<version>2.11.0</version>
294294
</dependency>
295295

296+
<dependency>
297+
<groupId>org.slf4j</groupId>
298+
<artifactId>slf4j-api</artifactId>
299+
</dependency>
296300

297301
</dependencies>
298302

core/src/main/java/org/iottree/core/UATag.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1659,7 +1659,11 @@ else if(ch.isConnMsg())
16591659
else if(ch.isConnBind())
16601660
{
16611661
ConnPtBinder cpt = (ConnPtBinder)ch.getConnPt();
1662-
cpt.RT_writeValByBind(this.getNodeCxtPathIn(ch), v.toString());
1662+
1663+
//ValTP tp = this.getValTp();
1664+
String sssv = UAVal.transObj2StrVal(v,-1) ;
1665+
//Object strv = UAVal..transStr2ObjVal(tp, strv);
1666+
cpt.RT_writeValByBind(this.getNodeCxtPathIn(ch), sssv);//v.toString());
16631667
return true;
16641668
}
16651669
else

core/src/main/java/org/iottree/core/UAVal.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,27 @@ public static Object transStr2ObjVal(ValTP tp,String strv)
244244
}
245245
}
246246

247+
public static String transObj2StrVal(Object objv,int dec_digits)
248+
{
249+
if(objv==null)
250+
return "" ;
251+
252+
if(dec_digits>0)
253+
{
254+
if(objv instanceof Float || objv instanceof Double)
255+
{
256+
return Convert.toDecimalDigitsStr(((Number)objv).doubleValue(), dec_digits,false) ;
257+
}
258+
}
259+
// //System.out.println(objVal.getClass()) ;
260+
if(objv instanceof java.util.Date)
261+
{
262+
return Convert.toFullYMDHMS((java.util.Date)objv) ;
263+
//return Convert.toShortYMD(d)
264+
}
265+
return objv.toString() ;
266+
}
267+
247268

248269
Object objVal = null ;
249270

@@ -409,6 +430,12 @@ public String getStrVal(int dec_digits)
409430
return Convert.toDecimalDigitsStr(((Number)objVal).doubleValue(), dec_digits,false) ;
410431
}
411432
}
433+
// //System.out.println(objVal.getClass()) ;
434+
if(objVal instanceof java.util.Date)
435+
{
436+
return Convert.toFullYMDHMS((java.util.Date)objVal) ;
437+
//return Convert.toShortYMD(d)
438+
}
412439
return objVal.toString() ;
413440
}
414441

core/src/main/java/org/iottree/core/conn/ConnPtOPCUA.java

Lines changed: 84 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import java.io.File;
66
import java.io.IOException;
77
import java.io.Writer;
8-
import java.nio.file.Files;
98
import java.nio.file.Path;
109
import java.nio.file.Paths;
1110
import java.security.cert.X509Certificate;
@@ -28,25 +27,25 @@
2827
import org.eclipse.milo.opcua.sdk.client.nodes.UaNode;
2928
import org.eclipse.milo.opcua.sdk.client.nodes.UaVariableNode;
3029
import org.eclipse.milo.opcua.sdk.client.nodes.UaVariableTypeNode;
31-
import org.eclipse.milo.opcua.stack.core.Identifiers;
3230
import org.eclipse.milo.opcua.stack.core.NodeIds;
3331
import org.eclipse.milo.opcua.stack.core.OpcUaDataType;
3432
import org.eclipse.milo.opcua.stack.core.UaException;
35-
import org.eclipse.milo.opcua.stack.core.security.FileBasedTrustListManager;
3633
import org.eclipse.milo.opcua.stack.core.security.SecurityPolicy;
37-
import org.eclipse.milo.opcua.stack.core.security.TrustListManager;
34+
import org.eclipse.milo.opcua.stack.core.types.builtin.ByteString;
3835
import org.eclipse.milo.opcua.stack.core.types.builtin.DataValue;
36+
import org.eclipse.milo.opcua.stack.core.types.builtin.DateTime;
3937
import org.eclipse.milo.opcua.stack.core.types.builtin.LocalizedText;
4038
import org.eclipse.milo.opcua.stack.core.types.builtin.NodeId;
4139
import org.eclipse.milo.opcua.stack.core.types.builtin.StatusCode;
4240
import org.eclipse.milo.opcua.stack.core.types.builtin.Variant;
41+
import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UByte;
4342
import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger;
43+
import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.ULong;
4444
import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UShort;
4545
import org.eclipse.milo.opcua.stack.core.types.enumerated.MessageSecurityMode;
4646
import org.eclipse.milo.opcua.stack.core.types.enumerated.TimestampsToReturn;
4747
import org.eclipse.milo.opcua.stack.core.types.structured.ApplicationDescription;
4848
import org.eclipse.milo.opcua.stack.core.types.structured.EndpointDescription;
49-
import org.eclipse.milo.opcua.stack.core.types.structured.WriteValue;
5049
import org.iottree.core.Config;
5150
import org.iottree.core.UACh;
5251
import org.iottree.core.UANode;
@@ -804,7 +803,7 @@ public void writeBindBeSelectTreeSub(Writer w, String pnode_id) throws Exception
804803
{
805804
NodeId pnid = null;
806805
if (Convert.isNullOrEmpty(pnode_id))
807-
pnid = Identifiers.RootFolder;
806+
pnid = NodeIds.RootFolder;
808807
else
809808
pnid = NodeId.parse(pnode_id);
810809
if (pnid == null)
@@ -963,7 +962,7 @@ public void writeUaNodeTreeJson(Writer w, boolean b_var, boolean force_refresh)
963962

964963
public static UaNode findUaNodeByPath(OpcUaClient client, String[] path) throws UaException
965964
{
966-
NodeId nid = Identifiers.RootFolder;
965+
NodeId nid = NodeIds.RootFolder;
967966

968967
UaNode pn = client.getAddressSpace().getNode(nid);
969968
if (pn == null)
@@ -995,7 +994,7 @@ public static void writeUaNodeTreeJson(Writer w, OpcUaClient client, String node
995994
{
996995
NodeId nid = null;
997996
if (Convert.isNullOrEmpty(nodeid))
998-
nid = Identifiers.RootFolder;
997+
nid = NodeIds.RootFolder;
999998
else
1000999
nid = NodeId.parse(nodeid);
10011000
if (nid == null)
@@ -1019,7 +1018,7 @@ public static void writeUaNodeTreeJson(Writer w, OpcUaClient client, UaNode n, b
10191018

10201019
boolean bvar = n instanceof UaVariableNode;
10211020

1022-
System.out.println(nid.toParseableString()) ;
1021+
//System.out.println(nid.toParseableString()) ;
10231022
w.write("{\"id\":\"" + nid.toParseableString() + "\"");
10241023
w.write(",\"nc\":" + n.getNodeClass().getValue());
10251024
if (bvar)
@@ -1381,8 +1380,7 @@ private void readDataInLoop()
13811380
UShort us = nodeid.getNamespaceIndex();
13821381
Object id = nodeid.getIdentifier();
13831382
//DataValue v = uaClient.readValue(maxAge, timestampsToReturn, nodeId)
1384-
DataValue v = uaClient.readValue(0.0, TimestampsToReturn.Both, nodeid);//.get();
1385-
1383+
DataValue v = uaClient.readValue(0.0, TimestampsToReturn.Both, nodeid);//.get()
13861384
updateTagVal(ch, tag2n.getKey(), v);
13871385
}
13881386
}
@@ -1395,6 +1393,8 @@ private void readDataInLoop()
13951393
lastReadData = System.currentTimeMillis();
13961394
}
13971395
}
1396+
1397+
private transient HashMap<String,DataValue> lastTagP2GoodDV = new HashMap<>() ;
13981398

13991399
private void updateTagVal(UACh ch, String tagpath, DataValue v) throws Exception
14001400
{
@@ -1415,22 +1415,22 @@ private void updateTagVal(UACh ch, String tagpath, DataValue v) throws Exception
14151415
// itemval.getValue().
14161416
if (sc.isGood())
14171417
{
1418+
lastTagP2GoodDV.put(tagpath,v) ;
14181419
long chgdt = v.getServerTime().getJavaTime();
14191420
// itemval.
14201421
// UAVal uav =
14211422
// UAVal.createByStrVal(tag.getValTp(),itemval.getLastValueStr(),chgdt,chgdt);
14221423
// tag.RT_setUAVal(uav);
1423-
// if(objv instanceof DateTime)
1424-
// {
1425-
//
1426-
// }
1424+
if(objv instanceof DateTime)
1425+
{
1426+
1427+
}
14271428
String strv = objv.toString() ;
14281429
OpcUaDataType dtp = vvt.getDataType().get() ;
14291430
if("DateTime".equals(dtp.name()))
14301431
{
1431-
return;
1432-
//DateTime dt = (DateTime) vvt.getValue();
1433-
//dt.getJavaDate() ;
1432+
DateTime dt = (DateTime) vvt.getValue();
1433+
strv = Convert.toFullYMDHMS(dt.getJavaDate()) ;
14341434
}
14351435

14361436
tag.RT_setValRawStr(strv, true, chgdt);
@@ -1495,6 +1495,46 @@ synchronized void disconnect() // throws IOException
14951495
uaClient = null;
14961496
}
14971497
}
1498+
1499+
private static Object transStr2Obj(OpcUaDataType dt,String strv)
1500+
{
1501+
switch(dt)
1502+
{
1503+
case Boolean://(1, Boolean.class),
1504+
return "true".equalsIgnoreCase(strv) || "1".equals(strv) ;
1505+
case SByte://(2, Byte.class),
1506+
return Byte.parseByte(strv) ;
1507+
case Byte://(3, UByte.class),
1508+
return UByte.valueOf(strv) ;
1509+
case Int16://(4, Short.class),
1510+
return Short.parseShort(strv) ;
1511+
case UInt16://(5, UShort.class),
1512+
return UShort.valueOf(strv) ;
1513+
case Int32://(6, Integer.class),
1514+
return Integer.parseInt(strv) ;
1515+
case UInt32://(7, UInteger.class),
1516+
return UInteger.valueOf(strv) ;
1517+
case Int64://(8, Long.class),
1518+
return Long.parseLong(strv) ;
1519+
case UInt64://(9, ULong.class),
1520+
return ULong.valueOf(strv) ;
1521+
case Float://(10, Float.class),
1522+
return Float.parseFloat(strv) ;
1523+
case Double://(11, Double.class),
1524+
return Double.parseDouble(strv) ;
1525+
case String://(12, String.class),
1526+
return strv ;
1527+
case DateTime://(13, ),
1528+
return new DateTime(Convert.toCalendar(strv).toInstant()) ;
1529+
case Guid://(14, UUID.class),
1530+
return UUID.fromString(strv) ;
1531+
case ByteString://(15, ByteString.class),
1532+
byte[] bs = Convert.hexStr2ByteArray(strv) ;
1533+
return ByteString.of(bs) ;
1534+
default:
1535+
return null ;
1536+
}
1537+
}
14981538

14991539
public void RT_writeValByBind(String tagpath, String strv)
15001540
{
@@ -1506,16 +1546,35 @@ public void RT_writeValByBind(String tagpath, String strv)
15061546
NodeId nid = tag2nodeid.get(tagpath);
15071547
if (nid == null)
15081548
return;
1509-
1510-
Variant v = new Variant(Integer.parseInt(strv));
1511-
DataValue dataValue = new DataValue(v, null, null);
1512-
WriteValue wv = new WriteValue(nid,null,"",dataValue);
1549+
DataValue lastdv = lastTagP2GoodDV.get(tagpath) ;
1550+
if(lastdv==null)
1551+
return ;
1552+
1553+
OpcUaDataType dt = lastdv.getValue().getDataType().get() ;
1554+
if(dt==null)
1555+
return ;
1556+
Object objv = transStr2Obj(dt,strv) ;
1557+
if(objv==null)
1558+
return ;
1559+
1560+
Variant v = new Variant(objv);
1561+
DataValue dataValue = new DataValue(v,StatusCode.GOOD,null); //timestamp may not allowed
1562+
//WriteValue wv = new WriteValue(nid,null,"",dataValue);
15131563
try
15141564
{
15151565
//StatusCode statusCode = uaClient.write(Arrays.asList(wv)).getResults()[0] ;
1516-
StatusCode statusCode = uaClient.writeValues(Arrays.asList(nid), Arrays.asList(dataValue)).get(0);
1517-
boolean r = statusCode.isGood();
1518-
System.out.println("w result=" + r);
1566+
List<StatusCode> scs = uaClient.writeValues(Arrays.asList(nid), Arrays.asList(dataValue)) ;
1567+
if(scs!=null && scs.size()>0)
1568+
{
1569+
StatusCode statusCode = scs.get(0);
1570+
boolean r = statusCode.isGood();
1571+
if(log.isDebugEnabled())
1572+
{
1573+
log.debug("w result=" + r+" status value="+statusCode.getValue()+" wstr="+strv+" objv="+objv+" objvt="+objv.getClass().getCanonicalName());
1574+
if(!r)
1575+
log.debug(" status code="+statusCode.toString());
1576+
}
1577+
}
15191578
}
15201579
catch ( Exception e)
15211580
{

core/src/main/java/org/iottree/core/conn/opcua/KeyStoreLoader.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ public KeyStoreLoader load(Path baseDir) throws Exception
5656
.setApplicationUri(ConnPtOPCUA.CLIENT_APP_URI)
5757
.addDnsName(hostn).setValidityPeriod(Period.ofYears(10));
5858
// .addIpAddress("127.0.0.1")
59-
6059

6160
// Get as many hostnames and IP addresses as we can listed in the
6261
// certificate.

driver-parent/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
</properties>
2525

2626
<modules>
27-
<module>driver-opc</module>
27+
<!-- <module>driver-opc</module> -->
2828
<module>driver-common</module>
2929
</modules>
3030

pom.xml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<spring.version>5.2.9.RELEASE</spring.version>
3232
<!-- 3.8.1 -->
3333
<junit.version>4.12</junit.version>
34-
<slf4j.version>1.7.12</slf4j.version>
34+
<slf4j.version>2.0.9</slf4j.version>
3535
<logback.version>1.1.11</logback.version>
3636

3737

@@ -139,6 +139,13 @@
139139
<artifactId>wrapper</artifactId>
140140
<version>3.2.3</version>
141141
</dependency>
142+
143+
<dependency>
144+
<groupId>org.slf4j</groupId>
145+
<artifactId>slf4j-api</artifactId>
146+
<version>${slf4j.version}</version>
147+
</dependency>
148+
142149
<!-- https://mvnrepository.com/artifact/javax.servlet/servlet-api -->
143150

144151
<!-- https://mvnrepository.com/artifact/org.apache.tomcat/jasper -->

server/pom.xml

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@
317317
<delete file="../_output/lib/iottree-ext-pro-${project.version}.jar" />
318318

319319
<echo message="package zip file" />
320-
<!--
320+
321321
<zip destfile="../_output/iot-tree-${project.version}-winjre8x86.zip" >
322322
<fileset dir="../_output/">
323323
<exclude name="jre/"/>
@@ -348,18 +348,7 @@
348348
<exclude name="iot-tree-${project.version}-winjre8x86.zip"/>
349349
</fileset>
350350
</zip>
351-
-->
352-
<delete file="../_output/lib/iottree-ext-opcda.jar" />
353-
354-
<zip destfile="../_output/iot-tree-${project.version}.zip" >
355-
<fileset dir="../_output/">
356-
<exclude name="jre8_x86/"/>
357-
<exclude name="jre/"/>
358-
<exclude name="iot-tree-${project.version}.zip"/>
359-
<exclude name="iot-tree-${project.version}-winjre.zip"/>
360-
<exclude name="iot-tree-${project.version}-winjre8x86.zip"/>
361-
</fileset>
362-
</zip>
351+
363352
</tasks>
364353
</configuration>
365354
</execution>

web/admin/ua_cxt/cxt_tags.jsp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,15 +217,15 @@ if(b_tags)
217217
<th sort_by="name"><wbt:g>tag</wbt:g></th>
218218
<th sort_by="title"><wbt:g>title</wbt:g></th>
219219
<th sort_by="addr"><wbt:g>addr</wbt:g></th>
220-
<th sort_by="valtp"><wbt:g>val,type</wbt:g></th>
220+
<th sort_by="valtp" style="width:80px;"><wbt:g>val,type</wbt:g></th>
221221
<th ><wbt:g>indicator</wbt:g></th>
222-
<th><wbt:g>val</wbt:g></th>
222+
<th style="min-width:120px;"><wbt:g>val</wbt:g></th>
223223
<th><wbt:g>unit</wbt:g></th>
224224
<th ><wbt:g>alert</wbt:g></th>
225225
<th><wbt:g>update,time</wbt:g></th>
226226
<th><wbt:g>change,time</wbt:g></th>
227227
<th><wbt:g>valid</wbt:g></th>
228-
<th><wbt:g>write</wbt:g></th>
228+
<th style="width:110px;"><wbt:g>write</wbt:g></th>
229229
<th><wbt:g>oper</wbt:g></th>
230230
<%
231231
if(prj!=null)

web/admin/ua_cxt/cxt_tags_tb_ajax.jsp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ if(bloc&&!tag.isSysTag())
228228
<td><%=addr%></td>
229229
<td><%=valtp_str %></td>
230230
<td><%=indicator_t %></td>
231-
<td style="width:80px;text-align:right;" id="ctag_v_<%=cxtpath%>" filter="<%=anti%>"></td>
231+
<td style="text-align:right;" id="ctag_v_<%=cxtpath%>" filter="<%=anti%>"></td>
232232
<td title="<%=unit_tt%>"><%=unit_t %></td>
233233
<td><span id="ctag_alert_<%=cxtpath%>"><%=alert_str %></span></td>
234234
<td id="ctag_dt_<%=cxtpath%>"></td>
@@ -239,7 +239,7 @@ if(bloc&&!tag.isSysTag())
239239
if(tag.isCanWrite())
240240
{
241241
%>
242-
<input type="text" id="ctag_w_<%=tag.getId()%>" value="" size="8" style="color:#999999"/><a href="javascript:w_tag('<%=tag.getId()%>')"><i class="fa fa-pencil-square" aria-hidden="true"></i></a>
242+
<input type="text" id="ctag_w_<%=tag.getId()%>" value="" style="color:#999999;width:90px"/><a href="javascript:w_tag('<%=tag.getId()%>')"><i class="fa fa-pencil-square" aria-hidden="true"></i></a>
243243
<%
244244
}
245245
%>

0 commit comments

Comments
 (0)