Skip to content

Commit f29d450

Browse files
committed
1.8.0
1 parent 35c0ffd commit f29d450

File tree

41 files changed

+764
-231
lines changed

Some content is hidden

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

41 files changed

+764
-231
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.9</version>
8+
<version>1.8.0</version>
99
<relativePath>../pom.xml</relativePath>
1010
</parent>
1111

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

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import javax.xml.parsers.DocumentBuilder;
1717
import javax.xml.parsers.DocumentBuilderFactory;
1818

19+
import org.iottree.core.util.CompressUUID;
1920
import org.iottree.core.util.Convert;
2021
import org.iottree.core.util.xmldata.XmlHelper;
2122
import org.w3c.dom.Document;
@@ -69,6 +70,8 @@ public boolean isDefault()
6970
static String dataDynDirBase = null;
7071

7172
static String libDirBase = null;
73+
74+
static String insUid = null ;
7275

7376
static
7477
{
@@ -375,6 +378,42 @@ public static String getDataDirBase()
375378

376379
return dataFileBase + "/data/";
377380
}
381+
382+
public static String getInsUID()
383+
{
384+
if(Convert.isNotNullEmpty(insUid))
385+
return insUid ;
386+
387+
synchronized(Config.class)
388+
{
389+
if(Convert.isNotNullEmpty(insUid))
390+
return insUid ;
391+
392+
File ins_uidf = new File(getDataDirBase()+"_ins_uid.txt") ;
393+
if(!ins_uidf.exists())
394+
{
395+
try
396+
{
397+
String insuid = CompressUUID.createNewId();
398+
Convert.writeFileTxt(ins_uidf, insuid);
399+
return insUid = insuid ;
400+
}
401+
catch(Exception ee)
402+
{
403+
throw new RuntimeException(ee) ;
404+
}
405+
}
406+
407+
try
408+
{
409+
return insUid = Convert.readFileTxt(ins_uidf) ;
410+
}
411+
catch(Exception ee)
412+
{
413+
throw new RuntimeException(ee) ;
414+
}
415+
}
416+
}
378417

379418
public static String getDataDynDirBase()
380419
{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ private static boolean registerProvider(JSONObject jo)
5252
{
5353
//e.printStackTrace();
5454
if(log.isWarnEnabled())
55-
log.warn(e.getMessage());//, "");
55+
log.warn("load conn provider err:"+e.getMessage());//, "");
5656
return false;
5757
}
5858
}

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,7 +1461,7 @@ private void startStopConn(boolean b) // throws Exception
14611461
else
14621462
cp.stop();
14631463
}
1464-
catch ( Exception e)
1464+
catch (Throwable e)
14651465
{
14661466
e.printStackTrace();
14671467
}
@@ -1646,11 +1646,9 @@ public void run()
16461646

16471647
private void stopPrj()
16481648
{
1649-
1650-
16511649
startStopTask(false);
1650+
startStopCh(false);//must before ch,or it will cost more time
16521651
startStopConn(false);
1653-
startStopCh(false);
16541652

16551653
PrjSharer ps = getSharer();
16561654
if (ps != null)

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ public static enum ValTP
3737
vt_str(9,-1,String.class),
3838
vt_date(10,8,java.util.Date.class);
3939

40-
4140
private final int val ;
4241
private final int byteLen;
4342
private final Class<?> valC;

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,17 @@
1212
import org.iottree.core.ConnProvider;
1313
import org.iottree.core.util.CompressUUID;
1414
import org.iottree.core.util.Convert;
15+
import org.iottree.core.util.logger.ILogger;
16+
import org.iottree.core.util.logger.LoggerManager;
1517
import org.iottree.core.util.xmldata.IXmlDataValidator;
1618
import org.iottree.core.util.xmldata.IXmlDataable;
1719
import org.iottree.core.util.xmldata.XmlData;
1820

1921

2022
public class ConnProTcpClient extends ConnProvider
2123
{
24+
static ILogger log = LoggerManager.getLogger(ConnProTcpClient.class) ;
25+
2226
public ConnProTcpClient()
2327
{
2428

@@ -107,10 +111,13 @@ private void disconnAll() //throws IOException
107111
try
108112
{
109113
ConnPtTcpClient conn = (ConnPtTcpClient)ci ;
110-
// long st = System.currentTimeMillis() ;
114+
long st = System.currentTimeMillis() ;
111115
conn.disconnect();
112-
// long et = System.currentTimeMillis() ;
113-
// System.out.println(" conn="+conn.getName()+" cost="+(et-st));
116+
if(log.isDebugEnabled())
117+
{
118+
long et = System.currentTimeMillis() ;
119+
log.debug(" disconnAll.conn="+conn.getName()+" cost="+(et-st));
120+
}
114121
}
115122
catch(Exception e)
116123
{

core/src/main/java/org/iottree/core/msgnet/nodes.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@
7878
{"cat":"_net","nodes":[
7979
"org.iottree.core.msgnet.nodes.NM_HttpClient",
8080
"org.iottree.core.msgnet.nodes.NM_TcpClientRR",
81-
"org.iottree.core.msgnet.nodes.NM_RESTfulApi"
81+
"org.iottree.core.msgnet.nodes.NM_RESTfulApi",
82+
"org.iottree.ext.msg_net.MailSender_NM"
8283
],"modules":[
8384
{"cn":"org.iottree.ext.msg_net.Kafka_M","nodes":[
8485
"org.iottree.ext.msg_net.KafkaIn_NS",

core/src/main/java/org/iottree/core/msgnet/nodes/NS_TagChgTrigger.java

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class NS_TagChgTrigger extends MNNodeStart
3030
// String tagId = null ;
3131
public static enum ChgTP
3232
{
33-
all_chg(0), all_valid_chg(1), up_down(2), up(3), down(4);
33+
all_chg(0), all_valid_chg(1),up_down(2), up(3), down(4);
3434

3535
final int val;
3636

@@ -119,22 +119,29 @@ public boolean checkChgTrigger(UAVal last_v, boolean cur_valid, Object curval)
119119
Object lastv = null;
120120
if (last_v != null && last_v.isValid())
121121
lastv = last_v.getObjVal();
122-
if (lastv == null || !lastv.equals(curval))
122+
if (lastv == null)
123123
{
124-
switch (this)
124+
if(curval!=null)
125125
{
126-
case all_chg:
127-
case all_valid_chg:
128-
return true;
129-
default:
130-
return false;
126+
switch (this)
127+
{
128+
case all_chg:
129+
case all_valid_chg:
130+
return true;
131+
default:
132+
return false;
133+
}
131134
}
135+
return false;
132136
}
133137

134138
int comp_res = compareCurLastUpDown(curval, lastv);
135139
// valid = true
136140
switch (this)
137141
{
142+
case all_chg:
143+
case all_valid_chg:
144+
return comp_res != 0;
138145
case up:
139146
return comp_res > 0;
140147
case down:

core/src/main/java/org/iottree/core/msgnet/store/influxdb/InfluxDB_Writer.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,9 @@ private Point calPointFmt(MNMsg msg)
270270
if(v==null)
271271
continue ;
272272

273+
String vt = tmpjo.optString("vt") ;
274+
v = transValByVT(vt,v) ;
275+
273276
if(v instanceof Number)
274277
point.addField(fn,(Number)v) ;
275278
else if(v instanceof String)
@@ -304,6 +307,24 @@ else if(v instanceof Boolean)
304307
return point ;
305308
}
306309

310+
private Object transValByVT(String vt,Object v)
311+
{
312+
if(Convert.isNullOrEmpty(vt))
313+
return v ;
314+
315+
switch(vt)
316+
{
317+
case "float":
318+
if(v instanceof Number)
319+
return ((Number)v).floatValue() ;
320+
break ;
321+
case "double":
322+
if(v instanceof Number)
323+
return ((Number)v).doubleValue() ;
324+
}
325+
return v ;
326+
}
327+
307328
private transient long lastPtIn = -1 ;
308329

309330
private transient ArrayList<Point> ptBuf = new ArrayList<>() ;

core/src/main/java/org/iottree/core/station/PlatInsWSServer.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,12 @@ public void onOpen(Session session,
277277

278278
PStation pss = PlatInsManager.getInstance().getStationById(stationid) ;
279279

280+
280281
if (pss == null)
281282
{
283+
if(log.isTraceEnabled())
284+
log.trace("onOpen stationid="+stationid+"clientip="+clientip+" PStation is unknown");
285+
282286
PlatInsManager.getInstance().fireUnknownStation(stationid) ;
283287
session.close();
284288
return;
@@ -309,6 +313,9 @@ public void onOpen(Session session,
309313
}
310314
}
311315

316+
if(log.isTraceEnabled())
317+
log.trace("onOpen stationid="+stationid+"clientip="+clientip+" title="+pss.getTitle());
318+
312319
SessionItem si = new SessionItem(session, pss,clientip);
313320
addSessionItem(si);
314321

0 commit comments

Comments
 (0)