Skip to content

Commit 900f676

Browse files
committed
opc ua client with milo1.0 ready 0.7
1 parent 83613a6 commit 900f676

File tree

120 files changed

+5292
-3452
lines changed

Some content is hidden

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

120 files changed

+5292
-3452
lines changed

core/pom.xml

Lines changed: 5 additions & 4 deletions
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.4</version>
8+
<version>1.7.5</version>
99
<relativePath>../pom.xml</relativePath>
1010
</parent>
1111

@@ -42,16 +42,16 @@
4242
<!-- https://mvnrepository.com/artifact/org.eclipse.milo/sdk-client -->
4343
<dependency>
4444
<groupId>org.eclipse.milo</groupId>
45-
<artifactId>sdk-client</artifactId>
45+
<artifactId>milo-sdk-client</artifactId>
4646

4747
</dependency>
4848

4949
<!-- https://mvnrepository.com/artifact/org.eclipse.milo/sdk-server -->
5050
<dependency>
5151
<groupId>org.eclipse.milo</groupId>
52-
<artifactId>sdk-server</artifactId>
52+
<artifactId>milo-sdk-server</artifactId>
5353
</dependency>
54-
54+
<!--
5555
<dependency>
5656
<groupId>org.eclipse.milo</groupId>
5757
<artifactId>stack-client</artifactId>
@@ -66,6 +66,7 @@
6666
<groupId>org.eclipse.milo</groupId>
6767
<artifactId>dictionary-manager</artifactId>
6868
</dependency>
69+
-->
6970
<dependency>
7071
<groupId>org.graalvm.js</groupId>
7172
<artifactId>js</artifactId>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ public void run()
632632
catch (Exception e)
633633
{
634634
log.error("connprovider name="+ConnProvider.this.name+" err",e);
635-
//e.printStackTrace();
635+
e.printStackTrace();
636636
}
637637
finally
638638
{

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import org.graalvm.polyglot.HostAccess;
1313
import org.iottree.core.alert.AlertItem;
1414
import org.iottree.core.alert.AlertManager;
15-
import org.iottree.core.basic.ValAlert;
15+
import org.iottree.core.basic.ValEvent;
1616
import org.iottree.core.cxt.JSObMap;
1717
import org.iottree.core.cxt.JsDef;
1818
import org.iottree.core.cxt.JsEnv;
@@ -667,14 +667,14 @@ public boolean CXT_renderTagsJson(Writer w, boolean bsys, long lastdt) throws IO
667667
return true;
668668
}
669669

670-
public List<ValAlert> CXT_listAlerts()
670+
public List<ValEvent> CXT_listAlerts()
671671
{
672-
ArrayList<ValAlert> rets = new ArrayList<>() ;
672+
ArrayList<ValEvent> rets = new ArrayList<>() ;
673673
this.iteratorAllTags((tg)->{
674-
List<ValAlert> vas = tg.getValAlerts() ;
674+
List<ValEvent> vas = tg.getValAlerts() ;
675675
if(vas==null)
676676
return ;
677-
for(ValAlert va:vas)
677+
for(ValEvent va:vas)
678678
{
679679
if(va.RT_is_triggered())
680680
rets.add(va) ;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2036,7 +2036,7 @@ public String JS_get_rt_json() throws IOException
20362036

20372037
public String JS_get_rt_json(boolean ignore_sys_tag) throws IOException
20382038
{
2039-
return JS_get_rt_json_lastdt(-1L, ignore_sys_tag) ;
2039+
return JS_get_rt_json_lastdt(-1L, ignore_sys_tag) ;
20402040
}
20412041

20422042
@HostAccess.Export

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

Lines changed: 41 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import org.iottree.core.basic.PropGroup;
1919
import org.iottree.core.basic.PropItem;
2020
import org.iottree.core.basic.PropItem.PValTP;
21-
import org.iottree.core.basic.ValAlert;
21+
import org.iottree.core.basic.ValEvent;
2222
import org.iottree.core.basic.ValIndicator;
2323
import org.iottree.core.basic.ValTranser;
2424
import org.iottree.core.basic.ValUnit;
@@ -171,8 +171,8 @@ private String getValTpTitle()
171171
// @data_val(param_name="alert_high")
172172
// String alertHighVal = null ;
173173

174-
@data_obj(param_name = "alert",obj_c = ValAlert.class)
175-
List<ValAlert> valAlerts = null ;
174+
@data_obj(param_name = "alert",obj_c = ValEvent.class)
175+
List<ValEvent> valAlerts = null ;
176176
/**
177177
* save val his, to support
178178
*/
@@ -240,8 +240,8 @@ public UATag(String name,String title,String desc,String addr,UAVal.ValTP vt,int
240240

241241
if(t.valAlerts!=null)
242242
{
243-
ArrayList<ValAlert> vas = new ArrayList<>() ;
244-
for(ValAlert va:t.valAlerts)
243+
ArrayList<ValEvent> vas = new ArrayList<>() ;
244+
for(ValEvent va:t.valAlerts)
245245
{
246246
vas.add(va.copyMe(this, false)) ;
247247
}
@@ -253,7 +253,7 @@ void constructNodeTree()
253253
{
254254
if(this.valAlerts!=null)
255255
{
256-
for(ValAlert va:this.valAlerts)
256+
for(ValEvent va:this.valAlerts)
257257
{
258258
va.setBelongTo(this);
259259
}
@@ -472,7 +472,7 @@ protected void copyTreeWithNewSelf(IRoot root,UANode new_self,String ownerid,
472472
if(this.valAlerts!=null&&this.valAlerts.size()>0)
473473
{
474474
nt.valAlerts = new ArrayList<>();
475-
for(ValAlert va : this.valAlerts)
475+
for(ValEvent va : this.valAlerts)
476476
nt.valAlerts.add(va.copyMe(nt,false)) ;
477477
}
478478
}
@@ -692,6 +692,9 @@ public String getValTranser()
692692

693693
public void setValTranser(String valtstr)
694694
{
695+
if("null".equals(valtstr))
696+
valtstr = null ;
697+
695698
this.valTranser = valtstr ;
696699
valTransObj = null ;
697700
}
@@ -730,11 +733,11 @@ public boolean setValAlerts(String jstr) throws Exception
730733
this.valAlerts = null;
731734
return true;
732735
}
733-
ArrayList<ValAlert> vas = new ArrayList<>(len) ;
736+
ArrayList<ValEvent> vas = new ArrayList<>(len) ;
734737
for(int i = 0 ; i < len ; i ++)
735738
{
736739
JSONObject jo = jarr.getJSONObject(i) ;
737-
ValAlert va = ValAlert.parseValAlert(this, jo) ;
740+
ValEvent va = ValEvent.parseValAlert(this, jo) ;
738741
if(va==null)
739742
return false;
740743
String n = va.getName() ;
@@ -744,7 +747,7 @@ public boolean setValAlerts(String jstr) throws Exception
744747
if(!Convert.checkVarName(n, true, invr))
745748
throw new Exception(invr.toString()) ;
746749

747-
for(ValAlert tmpva:vas)
750+
for(ValEvent tmpva:vas)
748751
{
749752
if(n.equals(tmpva.getName()))
750753
throw new Exception("alert name="+n+" is repleated") ;
@@ -756,17 +759,17 @@ public boolean setValAlerts(String jstr) throws Exception
756759
return true;
757760
}
758761

759-
public List<ValAlert> getValAlerts()
762+
public List<ValEvent> getValAlerts()
760763
{
761764
return this.valAlerts ;
762765
}
763766

764-
void setValAlerts(List<ValAlert> vas)
767+
void setValAlerts(List<ValEvent> vas)
765768
{
766769
this.valAlerts = vas ;
767770
if(vas!=null)
768771
{
769-
for(ValAlert va:vas)
772+
for(ValEvent va:vas)
770773
va.setBelongTo(this);
771774
}
772775
}
@@ -776,7 +779,7 @@ public JSONArray getValAlertsJArr() throws Exception
776779
JSONArray rets = new JSONArray() ;
777780
if(this.valAlerts!=null)
778781
{
779-
for(ValAlert va : this.valAlerts)
782+
for(ValEvent va : this.valAlerts)
780783
{
781784
rets.put(va.toJO());
782785
}
@@ -789,23 +792,23 @@ public boolean hasAlerts()
789792
return this.valAlerts!=null && this.valAlerts.size()>0 ;
790793
}
791794

792-
public ValAlert getValAlertByName(String name)
795+
public ValEvent getValAlertByName(String name)
793796
{
794797
if(this.valAlerts==null)
795798
return null ;
796-
for(ValAlert va:this.valAlerts)
799+
for(ValEvent va:this.valAlerts)
797800
{
798801
if(name.equals(va.getName()))
799802
return va ;
800803
}
801804
return null ;
802805
}
803806

804-
public ValAlert getValAlertById(String id)
807+
public ValEvent getValAlertById(String id)
805808
{
806809
if(this.valAlerts==null)
807810
return null ;
808-
for(ValAlert va:this.valAlerts)
811+
for(ValEvent va:this.valAlerts)
809812
{
810813
if(id.equals(va.getId()))
811814
return va ;
@@ -1406,7 +1409,7 @@ public synchronized UAVal RT_setValRaw(Object v,boolean ignore_nochg,Long updt,L
14061409
this.curVal.setValUpDT(updt);//.setVal(true,v,cdt);
14071410
if(this.curVal.isValid()) // && bval_chg)
14081411
{
1409-
RT_chkAlerts() ;
1412+
RT_chkEvent(true) ;
14101413
}
14111414
return curVal;
14121415
}
@@ -1425,15 +1428,25 @@ public synchronized UAVal RT_setValRaw(Object v,boolean ignore_nochg,Long updt,L
14251428
return uav ;
14261429
}
14271430

1428-
private void RT_chkAlerts()
1431+
private void RT_chkEvent(boolean b_val_chg)
14291432
{
14301433
if(this.valAlerts==null)
14311434
return ;
14321435
Object objv = this.curVal.getObjVal() ;
14331436

1434-
for(ValAlert va:this.valAlerts)
1437+
if(b_val_chg)
1438+
{
1439+
for(ValEvent va:this.valAlerts)
1440+
{
1441+
va.RT_fireValChged(objv);
1442+
}
1443+
}
1444+
else
14351445
{
1436-
va.RT_fireValChged(objv);
1446+
for(ValEvent va:this.valAlerts)
1447+
{
1448+
va.RT_fireValUpdated(objv);
1449+
}
14371450
}
14381451
}
14391452

@@ -1480,7 +1493,7 @@ public void RT_setUAVal(UAVal uav)
14801493

14811494
if(uav.isValid()) // && bval_chg)
14821495
{
1483-
RT_chkAlerts() ;
1496+
RT_chkEvent(true) ;
14841497
}
14851498

14861499
if(bNetMon)
@@ -1504,7 +1517,7 @@ public void RT_setUAValOnlyAlert(UAVal uav)
15041517
boolean bvalid = uav.isValid() ;
15051518
if(bvalid) // && bval_chg)
15061519
{
1507-
RT_chkAlerts() ;
1520+
RT_chkEvent(true) ;
15081521
}
15091522

15101523
if(bNetMon)
@@ -1736,7 +1749,7 @@ public boolean RT_hasAlertTriggered()
17361749
{
17371750
if(this.valAlerts==null)
17381751
return false;
1739-
for(ValAlert va:this.valAlerts)
1752+
for(ValEvent va:this.valAlerts)
17401753
{
17411754
if(va.RT_is_triggered())
17421755
return true ;
@@ -1799,12 +1812,12 @@ public List<JsProp> JS_props()
17991812
rets.add(new JsProp("_value",null,vt,false,"Tag Value","Tag Value,get value is same as _pv,bug set this prop will not trigger device write(only set in memory)"));
18001813
if(this.valAlerts!=null)
18011814
{
1802-
for(ValAlert va:this.valAlerts)
1815+
for(ValEvent va:this.valAlerts)
18031816
{
18041817
String n = va.getName() ;
18051818
if(Convert.isNullOrEmpty(n))
18061819
continue ;
1807-
rets.add(new JsProp("_alert_"+n,null,ValAlert.class,true,"Val Alert",""));
1820+
rets.add(new JsProp("_alert_"+n,null,ValEvent.class,true,"Val Alert",""));
18081821
}
18091822
}
18101823
return rets ;
@@ -1925,7 +1938,7 @@ public void CXT_renderTagJson(Writer w) throws IOException
19251938
boolean bfirst = true;
19261939
if(this.valAlerts!=null)
19271940
{
1928-
for(ValAlert va:this.valAlerts)
1941+
for(ValEvent va:this.valAlerts)
19291942
{
19301943
if(va.RT_is_triggered())
19311944
{

core/src/main/java/org/iottree/core/alert/AlertHandler.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import java.util.HashMap;
1010
import java.util.List;
1111
import org.iottree.core.UAPrj;
12-
import org.iottree.core.basic.ValAlert;
12+
import org.iottree.core.basic.ValEvent;
1313
import org.iottree.core.cxt.JSObMap;
1414
import org.iottree.core.cxt.JsProp;
1515
import org.iottree.core.store.SourceJDBC;
@@ -220,7 +220,7 @@ public boolean checkAlertUid(String alert_uid)
220220
return this.alertUids.contains(alert_uid);
221221
}
222222

223-
public boolean checkValAlertRelated(ValAlert va)
223+
public boolean checkValAlertRelated(ValEvent va)
224224
{
225225
return this.checkAlertUid(va.getUid()) ;
226226
}
@@ -304,7 +304,7 @@ public List<AlertItem> RT_getAlertItems()
304304

305305
synchronized void RT_processSelfSyn(AlertItem ai)
306306
{
307-
ValAlert va = ai.getValAlert() ;
307+
ValEvent va = ai.getValAlert() ;
308308
String vaid = va.getId() ;
309309
if(ai.bReleased)
310310
rt_vaId2ai.remove(vaid) ;
@@ -388,7 +388,7 @@ private void RT_recordAlertItem(AlertItem ai,DBConnPool cp,DataTable dt,int keep
388388
throws Exception
389389
{
390390
DataRow dr = dt.createNewRow() ;
391-
ValAlert va = ai.getValAlert() ;
391+
ValEvent va = ai.getValAlert() ;
392392
//AlertHandler ah = ai.getHandler() ;
393393
String row_id = va.RT_get_trigger_uid();//.getId() ;
394394
if(ai.bTriggerd)
@@ -397,10 +397,10 @@ private void RT_recordAlertItem(AlertItem ai,DBConnPool cp,DataTable dt,int keep
397397
dr.putValue("Tag", ai.getTag().getNodePathCxt());
398398
dr.putValue("TriggerDT", new Date(ai.getTriggerDT()));
399399
dr.putValue("Handler", this.getName());
400-
dr.putValue("Type", va.getAlertTitle());
400+
dr.putValue("Type", va.getEventTitle());
401401
dr.putValue("Value", ai.getCurVal());
402402
dr.putValue("Level", this.getLevel());
403-
dr.putValue("Prompt",va.getAlertPrompt());
403+
dr.putValue("Prompt",va.getEventPrompt());
404404

405405
Connection conn =null;
406406
try

0 commit comments

Comments
 (0)