Skip to content

Commit dcca536

Browse files
committed
BACnet Server Serivice ready,Improve OPC UA Client Connector
1 parent cdec3dd commit dcca536

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+3494
-701
lines changed

core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>org.iottree</groupId>
77
<artifactId>iottree-parent</artifactId>
8-
<version>1.7.8</version>
8+
<version>1.7.9</version>
99
<relativePath>../pom.xml</relativePath>
1010
</parent>
1111

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
package org.iottree.core;
22

3+
import org.iottree.core.util.IdIId;
4+
35
public interface IRoot
46
{
57
public String getRootIdPrefix() ;
68

79
public int getRootNextIdVal() ;
810

9-
public default String getRootNextId()
11+
public default IdIId getRootNextId()
1012
{
1113
synchronized(this)
1214
{
13-
return getRootIdPrefix() + getRootNextIdVal();
15+
int iid = getRootNextIdVal() ;
16+
return new IdIId(getRootIdPrefix() +iid,iid) ;
1417
}
1518
}
1619
}

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import java.util.*;
66

77
import org.iottree.core.util.Convert;
8+
import org.iottree.core.util.IdIId;
89
import org.iottree.core.util.Lan;
910
import org.iottree.core.util.xmldata.*;
1011
import org.iottree.core.util.xmldata.XmlDataFilesMem.FileItem;
@@ -107,10 +108,12 @@ protected void copyTreeWithNewSelf(IRoot root,UANode new_self,String ownerid,
107108
UADev ndev = new UADev() ;
108109
if(root_subnode_id)
109110
{
111+
IdIId iiid = null ;
110112
if(root!=null)
111-
ndev.id = root.getRootNextId() ;
113+
iiid = root.getRootNextId() ;
112114
else
113-
ndev.id = this.getNextIdByRoot();
115+
iiid = this.getNextIdByRoot();
116+
ndev.setIdIId(iiid);
114117
}
115118
dev.copyTreeWithNewSelf(root,ndev,ownerid,copy_id,root_subnode_id,rf2new);
116119
self.devs.add(ndev) ;
@@ -445,8 +448,8 @@ public UADev addDev(String name,String title,String desc,String libid,String dev
445448
throw new Exception("no device definition found") ;
446449
//d = dd.createNewUADev(this.getNextIdByRoot() ,name, title, desc) ;
447450
UADev dev = new UADev() ;
448-
dev.id = this.getNextIdByRoot() ;
449-
451+
//dev.id = this.getNextIdByRoot() ;
452+
dev.setIdIId(this.getNextIdByRoot());
450453

451454
d = dd.deepCopyUADev(this.getBelongTo(),dev,name, title, desc,rf2new) ;
452455
d.setDevRef(libid,devdef_id);
@@ -455,7 +458,8 @@ public UADev addDev(String name,String title,String desc,String libid,String dev
455458
else
456459
{
457460
d = new UADev();
458-
d.id = this.getNextIdByRoot() ;
461+
//d.id = this.getNextIdByRoot() ;
462+
d.setIdIId(this.getNextIdByRoot());
459463
d.setNameTitle(name, title, desc);
460464
d.setDevRef(null,null);
461465
d.setDevModel(dev_model);

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ UADev deepCopyMe(IRoot root,boolean b_newid) throws Exception
148148

149149
private void deepNewId(UANode n,IRoot root)
150150
{
151-
n.id = root.getRootNextId() ;
151+
//n.id = root.getRootNextId() ;
152+
n.setIdIId(root.getRootNextId());
152153
List<UANode> subns = n.getSubNodes() ;
153154
if(subns==null)
154155
return ;

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

Lines changed: 47 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
import org.iottree.core.util.CompressUUID;
1212
import org.iottree.core.util.Convert;
13+
import org.iottree.core.util.IdCreator;
14+
import org.iottree.core.util.IdIId;
1315
import org.iottree.core.util.Lan;
1416
import org.iottree.core.util.logger.ILogger;
1517
import org.iottree.core.util.logger.LoggerManager;
@@ -36,6 +38,9 @@ public static enum State
3638
@data_val
3739
String id = null ;
3840

41+
@data_val
42+
int iid = -1 ;
43+
3944
@data_val
4045
private String name = "" ;
4146

@@ -66,6 +71,45 @@ public UANode(String name,String title,String desc)
6671
setNameTitle(name,title,desc);
6772
}
6873

74+
75+
public final String getId()
76+
{
77+
return id ;
78+
}
79+
80+
public final IdIId getNextIdByRoot()
81+
{
82+
IRoot r = getRoot() ;
83+
if(r==null)
84+
throw new RuntimeException("no root found") ;
85+
return r.getRootNextId() ;
86+
}
87+
88+
public int getIID()
89+
{
90+
if(this.iid>=0)
91+
return this.iid ;
92+
if(this.id.charAt(0)=='r')
93+
{
94+
try
95+
{
96+
int rv = Integer.parseInt(this.id.substring(1)) ;
97+
return rv ;
98+
}
99+
catch(Exception ee)
100+
{
101+
return -1 ;
102+
}
103+
}
104+
return -1 ;
105+
}
106+
107+
protected final void setIdIId(IdIId iiid)
108+
{
109+
this.id = iiid.id;
110+
this.iid = iiid.iid ;
111+
}
112+
69113
public abstract String getNodeTp() ;
70114
// protected boolean setNameTitle(String name,String title)
71115
// {
@@ -147,19 +191,6 @@ protected void copyTreeWithNewSelf(IRoot root,UANode new_self,String ownerid,boo
147191
new_self.desc = this.desc ;
148192
}
149193

150-
public String getId()
151-
{
152-
return id ;
153-
}
154-
155-
public String getNextIdByRoot()
156-
{
157-
IRoot r = getRoot() ;
158-
if(r==null)
159-
throw new RuntimeException("no root found") ;
160-
return r.getRootNextId() ;
161-
}
162-
163194
public int getRelatedFiles(List<File> fs)
164195
{
165196
//ArrayList<File> rets = new ArrayList<>() ;
@@ -644,6 +675,7 @@ protected void onNodeChanged()
644675
PropGroup pg = new PropGroup("basic",lan) ;
645676

646677
pg.addPropItem(new PropItem("id",lan,PValTP.vt_str,true,null,null,"")); //"Id","Object's id"
678+
pg.addPropItem(new PropItem("iid",lan,PValTP.vt_int,true,null,null,-1));
647679
pg.addPropItem(new PropItem("name",lan,PValTP.vt_str,false,null,null,"")); //"Name","Object's name"
648680
pg.addPropItem(new PropItem("title",lan,PValTP.vt_str,false,null,null,"")); //"Title","Object's title"
649681
pg.addPropItem(new PropItem("desc",lan,PValTP.vt_str,false,null,null,"")); // "Description","Object's Description"
@@ -665,6 +697,8 @@ public Object getPropValue(String groupn,String itemn)
665697
{
666698
case "id":
667699
return this.getId();
700+
case "iid":
701+
return this.getIID();
668702
case "name":
669703
return this.getName();
670704
case "title":

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

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.iottree.core.basic.ValUnit;
1212
import org.iottree.core.cxt.JsDef;
1313
import org.iottree.core.util.Convert;
14+
import org.iottree.core.util.IdIId;
1415
import org.iottree.core.util.Lan;
1516
import org.iottree.core.util.xmldata.data_class;
1617
import org.iottree.core.util.xmldata.data_obj;
@@ -99,10 +100,13 @@ protected void copyTreeWithNewSelf(IRoot root,UANode new_self, String ownerid,
99100
UATag nt = new UATag();
100101
if (root_subnode_id)
101102
{
103+
IdIId iiid = null;
102104
if(root!=null)
103-
nt.id = root.getRootNextId();
105+
iiid = root.getRootNextId();
104106
else
105-
nt.id = this.getNextIdByRoot();
107+
iiid = this.getNextIdByRoot();
108+
109+
nt.setIdIId(iiid);
106110
}
107111

108112
t.copyTreeWithNewSelf(root,nt, ownerid, copy_id, root_subnode_id,rf2new);
@@ -305,7 +309,7 @@ else if(!p_addr.canWrite())
305309
d = new UATag(name, title, desc, addr, vt, dec_digits,mid_w_js);
306310
else
307311
d = new UATag(name, title, desc, addr, vt, dec_digits, canw, srate);
308-
d.id = this.getNextIdByRoot();
312+
d.setIdIId(this.getNextIdByRoot());
309313
tags.add(d);
310314
constructNodeTree();
311315
}
@@ -469,7 +473,8 @@ public UATag addTagByCopy(UATag cp_tag,boolean b_chg_title,boolean b_chg_addr) t
469473
new_addr = n_addr.toString("") ;
470474
}
471475
UATag newtag = new UATag(cp_tag, name,newtt,new_addr);
472-
newtag.id = this.getNextIdByRoot();
476+
//newtag.id = this.getNextIdByRoot();
477+
newtag.setIdIId(this.getNextIdByRoot());
473478
tags.add(newtag);
474479
constructNodeTree();
475480

@@ -527,7 +532,8 @@ UATag addOrUpdateTagSys(String tagid, boolean bmid, String name, String title, S
527532
d = new UATag();
528533
d.setTagSys(name, title, desc, addr, vt, dec_digits, canw, srate);
529534
}
530-
d.id = this.getNextIdByRoot();
535+
//d.id = this.getNextIdByRoot();
536+
d.setIdIId(this.getNextIdByRoot()) ;
531537
if (d.isSysTag())
532538
sysTags.add(d);
533539
else
@@ -559,7 +565,8 @@ public UATag addTag(DevItem item) throws Exception
559565
throw new IllegalArgumentException("tag with name=" + name + " existed");
560566
}
561567
UATag d = new UATag(item);
562-
d.id = this.getNextIdByRoot();
568+
//d.id = this.getNextIdByRoot();
569+
d.setIdIId(this.getNextIdByRoot());
563570
tags.add(d);
564571
constructNodeTree();
565572
this.bDirty = true ;
@@ -585,7 +592,8 @@ public UATag addTag(String name,String title,String desc,UAVal.ValTP vt,boolean
585592
}
586593

587594
UATag d = new UATag(name,title,desc,null,vt,0,false,200);
588-
d.id = this.getNextIdByRoot();
595+
//d.id = this.getNextIdByRoot();
596+
d.setIdIId(this.getNextIdByRoot()) ;
589597
d.bCanWrite = canwrite;
590598
tags.add(d);
591599
constructNodeTree();

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.iottree.core.plugin.PlugJsApi;
2525
import org.iottree.core.plugin.PlugManager;
2626
import org.iottree.core.util.Convert;
27+
import org.iottree.core.util.IdIId;
2728
import org.iottree.core.util.xmldata.data_class;
2829
import org.iottree.core.util.xmldata.data_obj;
2930
import org.json.JSONArray;
@@ -74,10 +75,12 @@ protected void copyTreeWithNewSelf(IRoot root,UANode new_self, String ownerid,
7475

7576
if (root_subnode_id)
7677
{
78+
IdIId iiid = null ;
7779
if(root!=null)
78-
nt.id = root.getRootNextId();
80+
iiid = root.getRootNextId();
7981
else
80-
nt.id = this.getNextIdByRoot();
82+
iiid = this.getNextIdByRoot();
83+
nt.setIdIId(iiid);
8184
}
8285
// nt.id = this.getNextIdByRoot();
8386
hmi.copyTreeWithNewSelf(root,nt, ownerid, copy_id, root_subnode_id,rf2new);
@@ -163,7 +166,8 @@ public UAHmi addHmi(String tp, String name, String title, String desc, HashMap<S
163166
}
164167
}
165168
// ch.belongTo = this;
166-
ch.id = this.getNextIdByRoot();
169+
//ch.id = this.getNextIdByRoot();
170+
ch.setIdIId(this.getNextIdByRoot());
167171
hmis.add(ch);
168172
this.constructNodeTree();
169173

@@ -210,7 +214,8 @@ public UAHmi pasteHmi(UAHmi hmi) throws Exception
210214
UAHmi nt = new UAHmi();
211215

212216
HashMap<IRelatedFile,IRelatedFile> rf2new = new HashMap<>();
213-
nt.id = this.getNextIdByRoot() ;
217+
//nt.id = this.getNextIdByRoot() ;
218+
nt.setIdIId(this.getNextIdByRoot());
214219
hmi.copyTreeWithNewSelf((IRoot)this.getTopNode(),nt, null, false, true, rf2new);
215220
String oldn = nt.getName() ;
216221
UAHmi oldhmi = this.getHmiByName(oldn) ;
@@ -500,7 +505,7 @@ public boolean CXT_renderJson(Writer w, HashMap<UATag,Long> tag2lastdt, long g_l
500505
boolean bchg=false;
501506
//long maxdt=-1 ;
502507

503-
w.write("{\"id\":\"" + this.id + "\",\"n\":\"" + this.getName() + "\",\"t\":\""+this.getTitle()+"\",\"tp\":\""+this.getNodeTp()+"\"");
508+
w.write("{\"id\":\"" + this.id + "\",\"iid\":"+this.getIID()+",\"n\":\"" + this.getName() + "\",\"t\":\""+this.getTitle()+"\",\"tp\":\""+this.getNodeTp()+"\"");
504509
if (extpms != null)
505510
{
506511
for (Map.Entry<String, Object> n2v : extpms.entrySet())

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import org.iottree.core.basic.PropItem;
1010
import org.iottree.core.basic.PropItem.PValTP;
1111
import org.iottree.core.util.Convert;
12+
import org.iottree.core.util.IdIId;
1213
import org.iottree.core.util.Lan;
1314
import org.iottree.core.util.xmldata.data_class;
1415
import org.iottree.core.util.xmldata.data_obj;
@@ -60,10 +61,12 @@ protected void copyTreeWithNewSelf(IRoot root,UANode new_self,String ownerid,
6061
UATagG ntg = new UATagG() ;
6162
if(root_subnode_id)
6263
{
64+
IdIId iiid = null ;
6365
if(root!=null)
64-
ntg.id = root.getRootNextId();
66+
iiid = root.getRootNextId();
6567
else
66-
ntg.id = this.getNextIdByRoot();
68+
iiid = this.getNextIdByRoot();
69+
ntg.setIdIId(iiid);
6770
}
6871
tagg.copyTreeWithNewSelf(root,ntg,ownerid, copy_id, root_subnode_id,rf2new);
6972
self.taggs.add(ntg) ;
@@ -255,7 +258,8 @@ public UATagG addTagG(String name,String title,String desc,boolean bsave)
255258
if(d!=null||tg!=null)
256259
throw new IllegalArgumentException("tag with name="+name+" existed") ;
257260
d = new UATagG(name,title,desc) ;
258-
d.id = this.getNextIdByRoot() ;
261+
//d.id = this.getNextIdByRoot() ;
262+
d.setIdIId(this.getNextIdByRoot());
259263
taggs.add(d);
260264
constructNodeTree();
261265
if(bsave)
@@ -380,7 +384,8 @@ public UATagG deepPasteTagG(UATagG tgg, String newname, String newtitle) throws
380384

381385
HashMap<IRelatedFile,IRelatedFile> rf2new = new HashMap<>();
382386
tgg.copyTreeWithNewSelf(null,newtgg, null, false, true,rf2new);
383-
newtgg.id = this.getNextIdByRoot();
387+
//newtgg.id = this.getNextIdByRoot();
388+
newtgg.setIdIId(this.getNextIdByRoot());
384389
// newch.name = newname;
385390
newtgg.setNameTitle(newname, null, null);
386391
// UACh newch = new UACh ch.deepCopyMe();

0 commit comments

Comments
 (0)