From dd694b8a3d05e2d785413182e1c28b25a5b3f431 Mon Sep 17 00:00:00 2001
From: Administrator <zhubaomin>
Date: 星期三, 20 十二月 2023 17:24:08 +0800
Subject: [PATCH] Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV
---
pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/rmiClient/Code.java | 12
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreConstantThread.java | 95 ++---
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreUnit.java | 6
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/multiDataSource/DataSourceSingle.java | 2
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/tasks/ToRtuConstantTask.java | 80 +++-
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/multiDataSource/DataSourceSingleAspect.java | 8
pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/rmiClient/RmiClUnit.java | 95 ++++-
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreConstantManage.java | 43 ++
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/TcpSessionCacheBk.java | 41 +-
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreThread.java | 6
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/tasks/RtuDownTask.java | 6
pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/tcpClient/MyThreadJob.java | 23 +
pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/forRmi/ResStartTcpConnectVo.java | 6
pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/forRmi/MwTestClientStatus.java | 26 +
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/tasks/FromRtuConstantTask.java | 68 +++
pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/rmiClient/ResStartRtuReportVo.java | 17
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/tasks/RtuUpTask.java | 12
pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/ServerProperties.java | 6
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/rtuData/p206V1_0_0/TkPreGenObjs.java | 2
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/TcpSessionCache.java | 216 +++++++++++++
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/multiDataSource/DataSourceAspect.java | 9
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/TcpDownCommandObj.java | 4
pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/console/Command.java | 29 +
pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/forRmi/Manager.java | 36 +
pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/rmiClient/ResStartTcpConnectVo.java | 6
pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/forRmi/ResStartRtuReportVo.java | 18
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreTask.java | 2
pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/forRmi/Code.java | 18
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/multiDataSource/DataSourceContext.java | 3
pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/tcpClient/TcpClUnit.java | 17
30 files changed, 685 insertions(+), 227 deletions(-)
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/multiDataSource/DataSourceAspect.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/multiDataSource/DataSourceAspect.java
index 6af975f..2d1a8c7 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/multiDataSource/DataSourceAspect.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/multiDataSource/DataSourceAspect.java
@@ -14,7 +14,12 @@
import java.lang.reflect.Method;
import java.util.Objects;
-
+/**
+ * 澶氭暟鎹簮搴旂敤涓紝閫氳繃娉ㄨВ纭畾鏌愪釜鏁版嵁婧�
+ * 渚嬪鍦⊿ervices灞傛柟娉曚笂娉ㄨВ锛�
+ * @DataSource("test")
+ * 琛ㄧず搴旂敤鏁版嵁婧恡est
+ */
@Slf4j
@Aspect
@Order(Constant.AspectOrderDataSource)
@@ -32,7 +37,7 @@
DataSource dataSource = method.getAnnotation(DataSource.class);
if (Objects.nonNull(dataSource) && !StringUtils.isNullOrEmpty(dataSource.value())) {
- log.info("鍒囨崲鏁版嵁婧愪负" + dataSource.value());
+ //log.info("鍒囨崲鏁版嵁婧愪负" + dataSource.value());
//寮哄埗杞垚鏂规硶涓婇厤缃殑鏁版嵁婧愶紝鏇挎崲鎺塂ataSourceContext涓繚瀛樼殑鏁版嵁婧�
DataSourceContext.set(dataSource.value());
}else{
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/multiDataSource/DataSourceContext.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/multiDataSource/DataSourceContext.java
index 159c430..61ac9df 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/multiDataSource/DataSourceContext.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/multiDataSource/DataSourceContext.java
@@ -1,5 +1,8 @@
package com.dy.common.multiDataSource;
+/**
+ * 绾跨▼瀹夊叏鐨勬暟鎹簮鎸佹湁鑰咃紝鎸佹湁褰撳墠璁块棶鎵�搴旂敤鐨勬暟鎹簮鍚嶇О
+ */
public class DataSourceContext {
private final static ThreadLocal<String> LOCAL_DATASOURCE = new ThreadLocal<>();
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/multiDataSource/DataSourceSingle.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/multiDataSource/DataSourceSingle.java
index cdcf4df..524c373 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/multiDataSource/DataSourceSingle.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/multiDataSource/DataSourceSingle.java
@@ -5,7 +5,7 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
- * 閽堝涓�涓暟鎹簮锛堜腑闂翠欢搴旂敤锛夛紝澶氭暟鎹簮搴旂敤涓疄闄呭彧鐢ㄤ簡涓�涓暟鎹簮
+ * 閽堝涓�涓暟鎹簮锛堥�氫俊涓棿浠跺簲鐢級锛屽鏁版嵁婧愬簲鐢ㄤ腑瀹為檯鍙敤浜嗕竴涓暟鎹簮
* 澶氭暟鎹簮搴旂敤涓紝閫氳繃娉ㄨВ纭畾鏌愪釜鏁版嵁婧愩��
* 纭畾鏁版嵁婧愭湁涓ょ鏂规硶锛�
* 1銆佹敞瑙f槑纭簡鏁版嵁婧愶細
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/multiDataSource/DataSourceSingleAspect.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/multiDataSource/DataSourceSingleAspect.java
index 860bfcc..1f7c680 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/multiDataSource/DataSourceSingleAspect.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/multiDataSource/DataSourceSingleAspect.java
@@ -33,24 +33,24 @@
DataSourceSingle dataSource = method.getAnnotation(DataSourceSingle.class);
if (Objects.nonNull(dataSource) && !StringUtils.isNullOrEmpty(dataSource.value())) {
- log.info("鏁版嵁婧愭寚瀹氫负" + dataSource.value());
+ //log.info("鏁版嵁婧愭寚瀹氫负" + dataSource.value());
//寮哄埗杞垚鏂规硶涓婇厤缃殑鏁版嵁婧愶紝鏇挎崲鎺塂ataSourceContext涓繚瀛樼殑鏁版嵁婧�
DataSourceContext.set(dataSource.value());
}else{
String datasourceName = SpringContextUtil.getApplicationContext().getEnvironment().getProperty("spring.datasource.names") ;
if(!StringUtils.isNullOrEmpty(datasourceName)){
- log.info("鏍规嵁閰嶇疆鏁版嵁婧愪负" + datasourceName);
+ //log.info("鏍规嵁閰嶇疆鏁版嵁婧愪负" + datasourceName);
DataSourceContext.set(datasourceName);
}else{
log.error("鏁版嵁婧愭湭鎸囧畾");
}
}
try {
- log.info("鏁版嵁搴撴搷浣滃紑濮�" + dataSource.value());
+ //log.info("鏁版嵁搴撴搷浣滃紑濮�" + dataSource.value());
return point.proceed();
} finally {
// 閿�姣佹暟鎹簮 鍦ㄦ墽琛屾柟娉曚箣鍚�
- log.info("鏁版嵁婧愭搷浣滃畬姣�" + dataSource.value());
+ //log.info("鏁版嵁婧愭搷浣滃畬姣�" + dataSource.value());
DataSourceContext.remove();
}
}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreConstantManage.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreConstantManage.java
new file mode 100644
index 0000000..262df98
--- /dev/null
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreConstantManage.java
@@ -0,0 +1,43 @@
+package com.dy.common.mw.core;
+
+import java.util.List;
+
+import org.apache.logging.log4j.*;
+
+public class CoreConstantManage {
+
+ private final static Logger log = LogManager.getLogger(CoreConstantManage.class.getName()) ;
+
+ private final static CoreConstantManage instance = new CoreConstantManage() ;
+
+ private static Long sleepBigBusy = 100L ;//澶у繖鏃讹紙闄や簡鎭掍箙浠诲姟锛岃繕鏄叾浠栦换鍔★級锛屾牳蹇冪嚎绋嬫殏鍋滈棿闅�
+ private static Long sleepSmallBusy = 500L ;//灏忓繖鏃讹紙鍙湁鎭掍箙浠诲姟锛屾棤鍏朵粬浠诲姟锛夛紝鏍稿績绾跨▼鏆傚仠闂撮殧
+
+ private CoreConstantManage(){
+ }
+
+ public static CoreConstantManage getInstance(){
+ return instance ;
+ }
+
+ /**
+ * 璁剧疆鏆傚仠鏃堕暱
+ * @param sleepBigBusy 澶у繖鏃讹紙闄や簡鎭掍箙浠诲姟锛岃繕鏄叾浠栦换鍔★級锛屾牳蹇冪嚎绋嬫殏鍋滈棿闅�
+ * @param sleepSmallBusy 灏忓繖鏃讹紙鍙湁鎭掍箙浠诲姟锛屾棤鍏朵粬浠诲姟锛夛紝鏍稿績绾跨▼鏆傚仠闂撮殧
+ */
+ public void setSleep(Long sleepBigBusy, Long sleepSmallBusy){
+ CoreConstantManage.sleepBigBusy = sleepBigBusy ;
+ CoreConstantManage.sleepSmallBusy = sleepSmallBusy ;
+ }
+
+ public void start(){
+ //鎭掍箙浠诲姟
+ List<CoreTask> constantTasks = CoreUnit.getAllConstantTasks();
+ if (constantTasks != null && constantTasks.size() > 0) {
+ for (CoreTask task : constantTasks) {
+ new CoreConstantThread(sleepBigBusy, sleepSmallBusy, task).start();
+ }
+ }
+ }
+
+}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreConstantThread.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreConstantThread.java
index bb54e15..8e497f2 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreConstantThread.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreConstantThread.java
@@ -1,64 +1,45 @@
package com.dy.common.mw.core;
-import java.util.List;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.*;
+/**
+ * @Author liurunyu
+ * @Date 2023/12/19 16:41
+ * @LastEditTime 2023/12/19 16:41
+ * @Description
+ */
+public class CoreConstantThread extends Thread {
-public class CoreConstantThread extends Thread{
-
- private final static Logger log = LogManager.getLogger(CoreConstantThread.class.getName()) ;
-
- private final static CoreConstantThread instance = new CoreConstantThread() ;
+ private final static Logger log = LogManager.getLogger(CoreConstantThread.class.getName()) ;
- @SuppressWarnings("unused")
- private static Long sleepBigBusy = 100L ;//澶у繖鏃讹紙闄や簡鎭掍箙浠诲姟锛岃繕鏄叾浠栦换鍔★級锛屾牳蹇冪嚎绋嬫殏鍋滈棿闅�
- private static Long sleepSmallBusy = 500L ;//灏忓繖鏃讹紙鍙湁鎭掍箙浠诲姟锛屾棤鍏朵粬浠诲姟锛夛紝鏍稿績绾跨▼鏆傚仠闂撮殧
-
- private CoreConstantThread(){
- }
-
- public static CoreConstantThread getInstance(){
- return instance ;
- }
-
- /**
- * 璁剧疆鏆傚仠鏃堕暱
- * @param sleepBigBusy 澶у繖鏃讹紙闄や簡鎭掍箙浠诲姟锛岃繕鏄叾浠栦换鍔★級锛屾牳蹇冪嚎绋嬫殏鍋滈棿闅�
- * @param sleepSmallBusy 灏忓繖鏃讹紙鍙湁鎭掍箙浠诲姟锛屾棤鍏朵粬浠诲姟锛夛紝鏍稿績绾跨▼鏆傚仠闂撮殧
- */
- public void setSleep(Long sleepBigBusy, Long sleepSmallBusy){
- CoreConstantThread.sleepBigBusy = sleepBigBusy ;
- CoreConstantThread.sleepSmallBusy = sleepSmallBusy ;
- }
+ private long sleepBigBusy ;
+ private long sleepSmallBusy ;
+ private CoreTask task ;
- /**
- * 鏍稿績鍗曠嚎绋嬶紝鎵ц鎵�鏈夌殑鍗曠嚎绋嬩换鍔�
- */
- @Override
- @SuppressWarnings("InfiniteLoopStatement")
- public void run(){
- int count ;
- Integer temp ;
- while (true) {
- count = 0;
- try {
- //鎭掍箙浠诲姟
- List<CoreTask> constantTasks = CoreUnit.getAllConstantTasks();
- if (constantTasks != null && constantTasks.size() > 0) {
- for (CoreTask task : constantTasks) {
- temp = task.excute();
- if (temp != null) {
- count += temp;
- }
- }
- }
- if (count == 0) {
- //灏忔殏鍋滀竴涓�
- Thread.sleep(sleepSmallBusy);
- }
- } catch (Exception e) {
- log.error("鏍稿績绾跨▼鍙戠敓寮傚父" + (e.getMessage() == null ? "" : (":" + e.getMessage())), e);
- }
- }
- }
+ public CoreConstantThread(long sleepBigBusy, long sleepSmallBusy, CoreTask task){
+ this.sleepBigBusy = sleepBigBusy ;
+ this.sleepSmallBusy = sleepSmallBusy ;
+ this.task = task ;
+ }
+
+ @Override
+ public void run() {
+ if(task != null){
+ int count ;
+ while (true) {
+ try {
+ count = task.execute();
+ if (count == 0) {
+ //灏忔殏鍋滀竴涓�
+ Thread.sleep(sleepBigBusy);
+ }else{
+ Thread.sleep(sleepSmallBusy);
+ }
+ } catch (Exception e) {
+ log.error("鎭掍箙浠诲姟" + task.getClass().getName() + "鎵ц鏃跺彂鐢熷紓甯�" + (e.getMessage() == null ? "" : (":" + e.getMessage())), e);
+ }
+ }
+ }
+ }
}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreTask.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreTask.java
index fd70cd4..c592369 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreTask.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreTask.java
@@ -8,5 +8,5 @@
* 浠诲姟鑷垜鎵ц鏂规硶
* @return 鎵ц浠诲姟鐨勬暟閲忥紝濡傛灉璋冪敤鑰呬笉闇�瑕佹暟閲忔椂锛屽彲浠ヨ繑鍥瀗ull
*/
- public abstract Integer excute() ;
+ public abstract Integer execute() ;
}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreThread.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreThread.java
index 46341fe..4f706a3 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreThread.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreThread.java
@@ -22,8 +22,8 @@
/**
* 璁剧疆鏆傚仠鏃堕暱
- * @param sleepWorking
- * @param sleepIdel
+ * @param sleepBigBusy 澶у繖鏃剁潯鐪犳椂闀�
+ * @param sleepSmallBusy 灏忓繖鏃剁潯鐪犳椂闀�
*/
public void setSleep(Long sleepBigBusy, Long sleepSmallBusy){
CoreThread.sleepBigBusy = sleepBigBusy ;
@@ -52,7 +52,7 @@
while(n < count){
CoreTask task = (CoreTask)coreQueue.pop() ;
if(task != null){
- task.excute();
+ task.execute();
}
n ++ ;
}
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreUnit.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreUnit.java
index 5c5e0df..6fd31f7 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreUnit.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreUnit.java
@@ -71,9 +71,9 @@
ct.setSleep(this.adapter.getConfig().sleepBigBusy, this.adapter.getConfig().sleepSmallBusy);
ct.start();
- CoreConstantThread cct = CoreConstantThread.getInstance() ;
- cct.setSleep(this.adapter.getConfig().sleepBigBusy, this.adapter.getConfig().sleepSmallBusy);
- cct.start();
+ CoreConstantManage ccm = CoreConstantManage.getInstance() ;
+ ccm.setSleep(this.adapter.getConfig().sleepBigBusy, this.adapter.getConfig().sleepSmallBusy);
+ ccm.start();
if(adapter.getConfig().showStartInfo){
System.out.println("鏍稿績妯″潡鎴愬姛鍚姩锛�"
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/TcpDownCommandObj.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/TcpDownCommandObj.java
index ae05e4f..573b6c7 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/TcpDownCommandObj.java
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/TcpDownCommandObj.java
@@ -50,8 +50,8 @@
return removeNodeFromCach ;
}
- TcpSession tcpSe = TcpSessionCach.getTcpSession(this.result.rtuAddr) ;
- Boolean flag = TcpSessionCach.isConnect(this.result.rtuAddr) ;
+ TcpSession tcpSe = TcpSessionCache.getTcpSession(this.result.rtuAddr) ;
+ Boolean flag = TcpSessionCache.isConnect(this.result.rtuAddr) ;
if(tcpSe == null || flag == null || !flag.booleanValue()){
//鏈浘涓婄嚎鎴栦笉鍦ㄧ嚎
if(!this.result.isCachForOffLine){
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/TcpSessionCache.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/TcpSessionCache.java
new file mode 100644
index 0000000..39577db
--- /dev/null
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/TcpSessionCache.java
@@ -0,0 +1,216 @@
+package com.dy.aceMw.server.forTcp;
+
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map.Entry;
+
+import org.apache.mina.core.session.IoSession;
+
+import com.dy.aceMw.server.ServerProperties;
+
+
+public class TcpSessionCache {
+
+ /**
+ * 鐢℉ashtable鑰屼笉鐢℉ashMap鍘熷洜锛�
+ * Hashtable绾跨▼瀹夊叏鐨�
+ * HashMap绾跨▼涓嶅畨鍏ㄧ殑
+ * 澶氱嚎绋嬪sessionTable璇诲嚭鎴栧瓨鍏ワ紝鍙兘浜х敓寮傚父
+ * TcpSessionCache鏄湪澶氱嚎绋嬬幆澧冧笅杩愯
+ *
+ * 2023-12-19瀹炴祴锛屽彂鐜癏ashtable骞朵笉绾跨▼瀹夊叏锛屾墍浠ュ簲鐢ㄤ簡HashMap鍜宻ynchronized
+ */
+ private static HashMap<String, TcpSession> sessionTable = new HashMap<String, TcpSession>() ;
+
+ /**
+ * 鍔犲叆鏂扮殑IoSession
+ * @param rtuAddr
+ * @param protocolName
+ * @param ioSession
+ */
+ public static void putNewTcpSession(String rtuAddr, String protocolName, IoSession ioSession){
+ synchronized (sessionTable){
+ TcpSession tcpSe = sessionTable.get(rtuAddr) ;
+ if(tcpSe == null){
+ tcpSe = new TcpSession() ;
+ tcpSe.protocolName = protocolName ;
+ tcpSe.ioSession = ioSession ;
+ sessionTable.put(rtuAddr, tcpSe) ;
+ }else{
+ tcpSe.ioSession = ioSession ;
+ }
+ }
+ }
+
+ /**
+ * 鏇存柊IoSession瀵瑰簲鐨剅tuAddr
+ * @param oldRtuAddr
+ * @param newRtuAddr
+ * @param protocolName
+ * @param ioSession
+ */
+ public static void changeRtuAddr(String oldRtuAddr, String newRtuAddr, String protocolName, IoSession ioSession){
+ if(oldRtuAddr != null && newRtuAddr != null && !oldRtuAddr.equals(newRtuAddr)){
+ synchronized (sessionTable){
+ TcpSession tcpSe = sessionTable.get(oldRtuAddr) ;
+ if(tcpSe == null){
+ putNewTcpSession(newRtuAddr, protocolName, ioSession) ;
+ }else{
+ sessionTable.remove(oldRtuAddr) ;
+ sessionTable.put(newRtuAddr, tcpSe) ;
+ }
+ }
+ }
+ }
+
+ /**
+ * 寰楀埌TcpSession
+ * @param rtuAddr
+ * @return
+ */
+ public static TcpSession getTcpSession(String rtuAddr){
+ return sessionTable.get(rtuAddr) ;
+ }
+
+ /**
+ * 寰楀埌Tcp閫氫俊鍗忚鍚嶇О
+ * @param rtuAddr
+ * @return
+ */
+ public static String getTcpProtocolName(String rtuAddr){
+ TcpSession tcpSe = sessionTable.get(rtuAddr) ;
+ if(tcpSe != null){
+ return tcpSe.protocolName ;
+ }else{
+ return null ;
+ }
+ }
+
+ /**
+ * 寰楀埌鎵�鏈夊湪绾挎儏鍐�
+ * @return
+ */
+ public static HashMap<String, Boolean> allOnLine(){
+ synchronized (sessionTable){
+ HashMap<String, Boolean> map = new HashMap<String, Boolean>();
+ Iterator<Entry<String, TcpSession>> it = sessionTable.entrySet().iterator() ;
+ Entry<String, TcpSession> entry = null ;
+ while(it.hasNext()){
+ entry = it.next() ;
+ map.put(entry.getKey(), entry.getValue().ioSession.isConnected()) ;
+ }
+ return map ;
+ }
+ }
+ /**
+ * 寰楀埌鎵�鏈塕TU杩炴帴鐘舵�佹儏鍐�
+ * @return
+ */
+ public static List<RtuSessionStatus> allConnectStatus(){
+ synchronized (sessionTable){
+ List<RtuSessionStatus> list = new ArrayList<RtuSessionStatus>();
+ Iterator<Entry<String, TcpSession>> it = sessionTable.entrySet().iterator() ;
+ Entry<String, TcpSession> entry = null ;
+ while(it.hasNext()){
+ entry = it.next() ;
+ RtuSessionStatus vo = new RtuSessionStatus() ;
+ vo.rtuAddr = entry.getKey() ;
+ IoSession se = entry.getValue().ioSession ;
+ vo.onTrueOffLine = se.isConnected() ;
+ InetSocketAddress sa = (InetSocketAddress)se.getRemoteAddress() ;
+ if(sa != null){
+ InetAddress inetAddr = sa.getAddress() ;
+ if(inetAddr != null){
+ vo.ip = inetAddr.getHostAddress() ;
+ vo.port = sa.getPort() ;
+ }
+ }
+ list.add(vo) ;
+ }
+ return list ;
+ }
+ }
+
+
+ /**
+ * 寰楀埌IoSession
+ * @param rtuAddr
+ * @return
+ */
+// public IoSession getIoSession(String rtuAddr){
+// TcpSession tcpSe = sessionMap.get(rtuAddr) ;
+// if(tcpSe != null){
+// return tcpSe.ioSession ;
+// }
+// return null ;
+// }
+
+ /**
+ * 缃戠粶鏄惁杩炴帴
+ * @param rtuAddr
+ * @return
+ */
+ public static Boolean isConnect(String rtuAddr){
+ TcpSession tcpSe = sessionTable.get(rtuAddr) ;
+ if(tcpSe != null){
+ return tcpSe.ioSession.isConnected() ;
+ }
+ return null ;
+ }
+
+ /**
+ * 閫氳繃IoSession杈撳嚭鏁版嵁
+ * @param rtuAddr
+ * @param data
+ * @throws Exception
+ */
+ public static void write(String rtuAddr, byte[] data) throws Exception{
+ TcpSession tcpSe = sessionTable.get(rtuAddr) ;
+ if(tcpSe != null){
+ if(tcpSe.ioSession.isConnected()){
+ tcpSe.ioSession.write(data) ;
+ }else{
+ throw new Exception("Rtu杩炴帴宸茬粡鍏抽棴!") ;
+ }
+ }else{
+ throw new Exception("Rtu鏈浘涓婄嚎!") ;
+ }
+ }
+
+ /**
+ * 璁剧疆涓婅鏁版嵁鏃跺埢
+ * @param rtuAddr
+ */
+ public static void cacheUpDataTime(String rtuAddr){
+ TcpSession tcpSe = sessionTable.get(rtuAddr) ;
+ if(tcpSe != null){
+ tcpSe.lastUpDataTime = System.currentTimeMillis() ;
+ }
+ }
+
+ /**
+ * 鏇存柊涓婅鏁版嵁鏃跺埢
+ * 褰撲笂琛屾暟鎹椂鍒诲凡缁忚繃鍘讳竴瀹氭椂闀匡紝涓婅鏁版嵁鏃跺埢娓呯┖
+ */
+ public static void updateUpDataTime(Long now){
+ synchronized (sessionTable){
+ Iterator<TcpSession> it = sessionTable.values().iterator() ;
+ TcpSession tcpSe ;
+ while(it.hasNext()){
+ tcpSe = it.next() ;
+ if(tcpSe.lastUpDataTime != null){
+ if(now - tcpSe.lastUpDataTime > ServerProperties.lastUpDataTimeLive){
+ tcpSe.lastUpDataTime = null ;
+ }
+ }
+ }
+ }
+ }
+
+
+}
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/TcpSessionCach.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/TcpSessionCacheBk.java
similarity index 86%
rename from pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/TcpSessionCach.java
rename to pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/TcpSessionCacheBk.java
index 5a97810..a9905a8 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/TcpSessionCach.java
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/TcpSessionCacheBk.java
@@ -1,27 +1,24 @@
package com.dy.aceMw.server.forTcp;
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map.Entry;
-
+import com.dy.aceMw.server.ServerProperties;
import org.apache.mina.core.session.IoSession;
-import com.dy.aceMw.server.ServerProperties;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.util.*;
+import java.util.Map.Entry;
-
-public class TcpSessionCach {
+/**
+ * 鐢℉ashtable瀹炵幇锛屼絾瀹炴祴鍙戠幇Hashtable骞朵笉绾跨▼瀹夊叏
+ */
+public class TcpSessionCacheBk {
/**
* 鐢℉ashtable鑰屼笉鐢℉ashMap鍘熷洜锛�
* Hashtable绾跨▼瀹夊叏鐨�
* HashMap绾跨▼涓嶅畨鍏ㄧ殑
* 澶氱嚎绋嬪sessionTable璇诲嚭鎴栧瓨鍏ワ紝鍙兘浜х敓寮傚父
- * 铏界劧鏄崟涓富绾跨▼锛屼絾鍦↗groups web鎴愬憳鏌ヨ鍦ㄧ嚎鎯呭喌鏃讹紝Jgroups鐨勭嚎绋嬬洿鎺ヤ镜鍏ワ紝浠庤�屽舰鎴愬绾跨▼鐜锛屽绾跨▼閬嶅巻鏃讹紝Map鎴愬憳鏁伴噺鏈夊彉鍖栧氨浼氫骇鐢熷紓甯�
+ * TcpSessionCache鏄湪澶氱嚎绋嬬幆澧冧笅杩愯
*/
private static Hashtable<String, TcpSession> sessionTable = new Hashtable<String, TcpSession>() ;
@@ -51,12 +48,14 @@
* @param ioSession
*/
public static void changeRtuAddr(String oldRtuAddr, String newRtuAddr, String protocolName, IoSession ioSession){
- TcpSession tcpSe = sessionTable.get(oldRtuAddr) ;
- if(tcpSe == null){
- putNewTcpSession(newRtuAddr, protocolName, ioSession) ;
- }else{
- sessionTable.remove(oldRtuAddr) ;
- sessionTable.put(newRtuAddr, tcpSe) ;
+ if(oldRtuAddr != null && newRtuAddr != null && !oldRtuAddr.equals(newRtuAddr)){
+ TcpSession tcpSe = sessionTable.get(oldRtuAddr) ;
+ if(tcpSe == null){
+ putNewTcpSession(newRtuAddr, protocolName, ioSession) ;
+ }else{
+ sessionTable.remove(oldRtuAddr) ;
+ sessionTable.put(newRtuAddr, tcpSe) ;
+ }
}
}
@@ -101,7 +100,7 @@
* 寰楀埌鎵�鏈塕TU杩炴帴鐘舵�佹儏鍐�
* @return
*/
- public static List<RtuSessionStatus> allConnectStauts(){
+ public static List<RtuSessionStatus> allConnectStatus(){
List<RtuSessionStatus> list = new ArrayList<RtuSessionStatus>();
Iterator<Entry<String, TcpSession>> it = sessionTable.entrySet().iterator() ;
Entry<String, TcpSession> entry = null ;
@@ -174,7 +173,7 @@
* 璁剧疆涓婅鏁版嵁鏃跺埢
* @param rtuAddr
*/
- public static void cachUpDataTime(String rtuAddr){
+ public static void cacheUpDataTime(String rtuAddr){
TcpSession tcpSe = sessionTable.get(rtuAddr) ;
if(tcpSe != null){
tcpSe.lastUpDataTime = System.currentTimeMillis() ;
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/rtuData/p206V1_0_0/TkPreGenObjs.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/rtuData/p206V1_0_0/TkPreGenObjs.java
index 34b9641..66048c2 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/rtuData/p206V1_0_0/TkPreGenObjs.java
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/rtuData/p206V1_0_0/TkPreGenObjs.java
@@ -22,7 +22,7 @@
public void execute(Object data) {
Data d = (Data)data ;
String rtuAddr = d.getRtuAddr() ;
- log.info("RTU" + rtuAddr + "鏁版嵁鍒版锛岃繕鏈疄鐜板鐞�:" + data.toString());
+ log.info("RTU" + rtuAddr + "鏁版嵁鍒版锛岃繘琛屾暟鎹簱瀛樺偍娴嬭瘯");
RtuSv sv = (RtuSv)SpringContextUtil.getBean(RtuSv.class) ;
sv.save(d) ;
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/tasks/FromRtuConstantTask.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/tasks/FromRtuConstantTask.java
index 266d88f..fbf4b7c 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/tasks/FromRtuConstantTask.java
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/tasks/FromRtuConstantTask.java
@@ -17,24 +17,63 @@
* 鍦ㄥ崟绾跨▼鐜涓繍琛�
*/
@Override
- public Integer excute() {
+ public Integer execute() {
try{
- return dealRtuUpData() ;
+ dealRtuUpData() ;
}catch(Exception e){
log.error(e);
}
- return null ;
+ return RtuDataCache.size()>0?0:1 ;
}
-
/**
* 澶勭悊涓婅鏁版嵁
*/
- public Integer dealRtuUpData() {
+ public void dealRtuUpData() {
+ Node first = RtuDataCache.getFirstQueueNode() ;
+ if(first != null){
+ Node last = RtuDataCache.getLastQueueNode() ;
+ while (last != null){
+ last = this.doDealRtuUpData(first, last);
+ }
+ }
+ }
+
+ /**
+ * 澶勭悊缂撳瓨鐨勪笂琛屾暟鎹妭鐐�
+ * @param first 绗竴涓妭鐐�
+ * @param last 鏈�鍚庝竴涓妭鐐�
+ */
+ private Node doDealRtuUpData(Node first, Node last){
+ if(last != null){
+ //鍦╠ealNode鏂规硶涓紝鍙兘瑕佹妸last浠庨槦鍒椾腑绉婚櫎锛岃繖鏃秎ast.pre涓虹┖锛屾墍浠ユ彁鍓嶆妸last.pre鍙栧嚭鏉�
+ Node pre = last.pre ;
+ dealNode(last) ;
+ if(first != last){
+ return pre ;
+ }else{
+ //鍋滄
+ return null ;
+ }
+ }else{
+ return null ;
+ }
+ }
+
+
+ ////////////////////////////////////////////////
+ //
+ //浠ヤ笅瀹炵幇锛岄噰鐢ㄤ簡閫掑綊璋冪敤锛屽綋闃熷垪缂撳瓨缁撶偣寰堝鏃讹紝浼氫骇鐢熸爤婧㈠嚭寮傚父
+ //
+ ////////////////////////////////////////////////
+ /**
+ * 澶勭悊涓婅鏁版嵁
+ */
+ public Integer dealRtuUpData_() {
Node first = RtuDataCache.getFirstQueueNode() ;
if(first != null){
Integer count = RtuDataCache.size() ;
Node last = RtuDataCache.getLastQueueNode() ;
- this.doDealRtuUpData(first, last);
+ this.doDealRtuUpData_(first, last);
return count ;
}
return null ;
@@ -45,18 +84,15 @@
* @param first 绗竴涓妭鐐�
* @param last 鏈�鍚庝竴涓妭鐐�
*/
- private void doDealRtuUpData(Node first, Node last){
+ private void doDealRtuUpData_(Node first, Node last){
if(last != null){
//鍦╠ealNode鏂规硶涓紝鍙兘瑕佹妸last浠庨槦鍒椾腑绉婚櫎锛岃繖鏃秎ast.pre涓虹┖锛屾墍浠ユ彁鍓嶆妸last.pre鍙栧嚭鏉�
Node pre = last.pre ;
dealNode(last) ;
- if(first != null && first != last){
+ if(first != last){
doDealRtuUpData(first, pre) ;
- }else if(first != null && first == last){
+ }else{
//鍋滄
- }else if(first == null){
- //杩欑鎯呭喌涓嶄細瀛樺湪
- doDealRtuUpData(null, pre) ;
}
}
}
@@ -66,9 +102,11 @@
* @param node 鑺傜偣
*/
private void dealNode(Node node){
- RtuDataNode obj = (RtuDataNode)node.obj ;
- obj.dealSelf() ;
- RtuDataCache.removeNode(node);
+ if(node != null && node.obj != null){
+ RtuDataNode obj = (RtuDataNode)node.obj ;
+ obj.dealSelf() ;
+ RtuDataCache.removeNode(node);
+ }
}
}
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/tasks/RtuDownTask.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/tasks/RtuDownTask.java
index 64891d0..16a4852 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/tasks/RtuDownTask.java
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/tasks/RtuDownTask.java
@@ -9,7 +9,7 @@
import com.dy.common.mw.protocol.Driver;
import com.dy.common.mw.protocol.ProtocolCache;
import com.dy.aceMw.server.ServerProperties;
-import com.dy.aceMw.server.forTcp.TcpSessionCach;
+import com.dy.aceMw.server.forTcp.TcpSessionCache;
/**
* 浠巜eb涓氬姟绯荤粺鍙戝悜RTU鐨勫懡浠や换鍔�
@@ -21,7 +21,7 @@
private static Logger log = LogManager.getLogger(RtuDownTask.class.getName());
@Override
- public Integer excute() {
+ public Integer execute() {
Command com = (Command)this.data ;
try {
log.info("涓嬪彂杩滅▼鍛戒护" + com.getCode() + "鐨勬牳蹇冧换鍔″紑濮嬫墽琛�");
@@ -41,7 +41,7 @@
String rtuAddr = com.getRtuAddr() ;
//鍓嶉潰宸茬粡鍒ゆ柇rtuAddr涓虹┖鎯呭喌锛岃嚦姝ゅ叾涓嶄负绌�
Driver dri = null ;
- String protocolName = TcpSessionCach.getTcpProtocolName(rtuAddr) ;
+ String protocolName = TcpSessionCache.getTcpProtocolName(rtuAddr) ;
if(protocolName == null){
//RTU鏈浘涓婄嚎
int count = ProtocolCache.driverCount() ;
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/tasks/RtuUpTask.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/tasks/RtuUpTask.java
index c27241f..cce0aeb 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/tasks/RtuUpTask.java
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/tasks/RtuUpTask.java
@@ -18,7 +18,7 @@
import com.dy.aceMw.server.ServerProperties;
import com.dy.aceMw.server.forTcp.RtuLogDealer;
import com.dy.aceMw.server.forTcp.RtuStatusDealer;
-import com.dy.aceMw.server.forTcp.TcpSessionCach;
+import com.dy.aceMw.server.forTcp.TcpSessionCache;
import com.dy.common.util.ByteUtil;
public class RtuUpTask extends CoreTask {
@@ -26,7 +26,7 @@
private static final Logger log = LogManager.getLogger(RtuUpTask.class.getName());
@Override
- public Integer excute() {
+ public Integer execute() {
Object[] os = (Object[])this.data ;
IoSession session = (IoSession)os[0] ;
byte[] upBuf = (byte[])os[1] ;
@@ -72,7 +72,7 @@
//璁剧疆session鐨勫睘鎬D
TcpUnit.getInstance().setIoSessionArrId(session, rtuAddr);
//缂撳瓨session
- TcpSessionCach.putNewTcpSession(rtuAddr, protocolName, session);
+ TcpSessionCache.putNewTcpSession(rtuAddr, protocolName, session);
log.info("RTU(鍦板潃锛�" + rtuAddr + ")涓婄嚎浜嗐��") ;
}
@@ -81,11 +81,11 @@
if(rtuAddr != null){
if(protocolName == null){
- protocolName = TcpSessionCach.getTcpProtocolName(rtuAddr) ;
+ protocolName = TcpSessionCache.getTcpProtocolName(rtuAddr) ;
}
//璁剧疆鏀跺埌鏁版嵁鏃跺埢
- TcpSessionCach.cachUpDataTime(rtuAddr);
+ TcpSessionCache.cacheUpDataTime(rtuAddr);
if(protocolName != null){
//瀵逛笂琛屾暟鎹繘琛屽鐞�
@@ -154,7 +154,7 @@
//鏇存柊缁堢鐘舵��
if(rtuAddrInData != null && !rtuAddrInData.equals(rtuAddrAtHead)){
//鏁版嵁澶翠腑鐨凴TU鍦板潃涓庢暟鎹腑鐨凴TU鍦板潃涓嶄竴鑷达紝鏇存崲鎴愭暟鎹腑鐨凴TU鍦板潃
- TcpSessionCach.changeRtuAddr(rtuAddrAtHead, rtuAddrInData, protocolName, session);
+ TcpSessionCache.changeRtuAddr(rtuAddrAtHead, rtuAddrInData, protocolName, session);
session.setAttribute(TcpIoSessionAttrIdIsRtuAddr.sessionArrIdKey, rtuAddrInData) ;
}
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/tasks/ToRtuConstantTask.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/tasks/ToRtuConstantTask.java
index 291184a..3de49a2 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/tasks/ToRtuConstantTask.java
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/tasks/ToRtuConstantTask.java
@@ -7,7 +7,7 @@
import com.dy.common.mw.core.CoreTask;
import com.dy.aceMw.server.forTcp.TcpDownCommandCache;
import com.dy.aceMw.server.forTcp.TcpDownCommandObj;
-import com.dy.aceMw.server.forTcp.TcpSessionCach;
+import com.dy.aceMw.server.forTcp.TcpSessionCache;
/**
* 澶勭悊RTU涓嬭鍛戒护鏁版嵁鐨勬亽涔呬换鍔�
@@ -19,26 +19,71 @@
* 鍦ㄥ崟绾跨▼鐜涓繍琛�
*/
@Override
- public Integer excute() {
+ public Integer execute() {
try{
- Long now = System.currentTimeMillis() ;
- dealTcpSession(now) ;
- return dealDownCommand(now) ;
+ dealTcpSession() ;
+ }catch(Exception e){
+ log.error("鏇存柊RTU浼氳瘽涓婃姤鏁版嵁鏃跺埢鏃跺彂鐢熼泦鍚堟搷浣滃紓甯革紝姝ゅ紓甯稿苟涓嶅奖鍝嶇郴缁熸甯歌繍琛�", e);
+ }
+ try{
+ //log.info("褰撳墠涓嬭鍛戒护闃熷垪涓繕鏈夌粨鐐规暟閲忥細" + TcpDownCommandCache.size());
+ dealDownCom() ;
}catch(Exception e){
log.error(e);
}
- return null ;
+ return TcpDownCommandCache.size()>0?0:1 ;
}
/**
* 澶勭悊TCP缂撳瓨涓殑鍚勪釜TCP Session鐨勪笂琛屾暟鎹椂鍒�
*/
- private void dealTcpSession(Long now){
- TcpSessionCach.updateUpDataTime(now) ;
+ private void dealTcpSession(){
+ TcpSessionCache.updateUpDataTime(System.currentTimeMillis() ) ;
}
-
+
+
/**
* 澶勭悊涓嬭鍛戒护
*/
+ public void dealDownCom() {
+ Node first = TcpDownCommandCache.getFirstQueueNode() ;
+ if(first != null){
+ Node last = TcpDownCommandCache.getLastQueueNode() ;
+ while (last != null){
+ last = this.doDealDownComm(System.currentTimeMillis(), first, last);
+ }
+ }
+ }
+ /**
+ * 澶勭悊缂撳瓨鐨勪笅琛屽懡浠よ妭鐐�
+ * @param now 褰撳墠鏃跺埢
+ * @param first 绗竴涓妭鐐�
+ * @param last 鏈�鍚庝竴涓妭鐐�
+ */
+ private Node doDealDownComm(Long now, Node first, Node last){
+ if(last != null){
+ //鍦╠ealNode鏂规硶涓紝鍙兘瑕佹妸last浠庨槦鍒椾腑绉婚櫎锛岃繖鏃秎ast.pre涓虹┖锛屾墍浠ユ彁鍓嶆妸last.pre鍙栧嚭鏉�
+ Node pre = last.pre ;
+ dealNode(now, last) ;
+ if(first != last){
+ return pre ;
+ }else{
+ //鍋滄
+ return null ;
+ }
+ }else{
+ return null ;
+ }
+ }
+
+
+
+ ////////////////////////////////////////////////
+ //
+ //浠ヤ笅瀹炵幇锛岄噰鐢ㄤ簡閫掑綊璋冪敤锛屽綋闃熷垪缂撳瓨缁撶偣寰堝鏃讹紝浼氫骇鐢熸爤婧㈠嚭寮傚父
+ //
+ ////////////////////////////////////////////////
+ /**
+ * 澶勭悊涓嬭鍛戒护
public Integer dealDownCommand(Long now) {
Node first = TcpDownCommandCache.getFirstQueueNode() ;
if(first != null){
@@ -49,12 +94,12 @@
}
return null ;
}
+ */
/**
* 澶勭悊缂撳瓨鐨勪笅琛屽懡浠よ妭鐐�
* @param now 褰撳墠鏃跺埢
* @param first 绗竴涓妭鐐�
* @param last 鏈�鍚庝竴涓妭鐐�
- */
private void doDealDownCommand1(Long now, Node first, Node last){
if(first != null){
//鍦╠ealNode鏂规硶涓紝鍙兘瑕佹妸first浠庨槦鍒椾腑绉婚櫎锛岃繖鏃秄irst.next涓虹┖锛屾墍浠ユ彁鍓嶆妸first.next鍙栧嚭鏉�
@@ -70,13 +115,12 @@
}
}
}
-
+ */
/**
* 澶勭悊缂撳瓨鐨勪笅琛屽懡浠よ妭鐐�
* @param now 褰撳墠鏃跺埢
* @param first 绗竴涓妭鐐�
* @param last 鏈�鍚庝竴涓妭鐐�
- */
private void doDealDownCommand(Long now, Node first, Node last){
if(last != null){
//鍦╠ealNode鏂规硶涓紝鍙兘瑕佹妸last浠庨槦鍒椾腑绉婚櫎锛岃繖鏃秎ast.pre涓虹┖锛屾墍浠ユ彁鍓嶆妸last.pre鍙栧嚭鏉�
@@ -92,17 +136,19 @@
}
}
}
-
+ */
/**
* 澶勭悊涓�涓妭鐐�
* @param now 鐜板湪鏃跺埢
* @param node 鑺傜偣
*/
private void dealNode(Long now, Node node){
- TcpDownCommandObj obj = (TcpDownCommandObj)node.obj ;
- boolean removeNode = obj.dealSelf(now) ;
- if(removeNode){
- TcpDownCommandCache.removeNode(node);
+ if(node != null && node.obj != null){
+ TcpDownCommandObj obj = (TcpDownCommandObj)node.obj ;
+ boolean removeNode = obj.dealSelf(now) ;
+ if(removeNode){
+ TcpDownCommandCache.removeNode(node);
+ }
}
}
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/ServerProperties.java b/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/ServerProperties.java
index a5f18cf..c1462a6 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/ServerProperties.java
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/ServerProperties.java
@@ -17,6 +17,8 @@
//鍙戦�佹暟鎹鏁�
public static Integer sendTimes = 0 ;
- //mwTestServer鎺у埗鏄惁鍚姩
- public static boolean startWork = false ;
+ public static boolean startTcpConnectWork = false ;
+
+ //mwTestServer
+ public static boolean startRtuReportWork = false ;
}
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/rmiClient/Code.java b/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/rmiClient/Code.java
index 9dc631e..633c79e 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/rmiClient/Code.java
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/rmiClient/Code.java
@@ -6,12 +6,14 @@
public static String cd2 = "002" ;//璇锋眰sepTest鐨勯厤缃�
- public static String cd3 = "003" ;//璇锋眰寮�濮嬪伐浣�
-
- public static String cd4 = "004" ;//鍚戞湇鍔$涓婃姤淇℃伅
+ public static String cd3 = "003" ;//璇锋眰寮�濮嬪缓绔嬬綉缁滆繛鎺�
- public static String cd5 = "005" ;//鍚戞湇鍔$涓婃姤 瀹屾垚浠诲姟鐨勬暟閲�
+ public static String cd4 = "004" ;//璇锋眰寮�濮婻TU涓婃姤鏁版嵁
- public static String cd6 = "006" ;//鍚戞湇鍔$涓婃姤 鍏ㄩ儴浠诲姟瀹屾垚
+ public static String cd5 = "005" ;//鍚戞湇鍔$涓婃姤淇℃伅
+
+ public static String cd6 = "006" ;//鍚戞湇鍔$涓婃姤 瀹屾垚浠诲姟鐨勬暟閲�
+
+ public static String cd7 = "007" ;//鍚戞湇鍔$涓婃姤 鍏ㄩ儴浠诲姟瀹屾垚
}
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/rmiClient/ResStartVo.java b/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/rmiClient/ResStartRtuReportVo.java
similarity index 68%
copy from pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/rmiClient/ResStartVo.java
copy to pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/rmiClient/ResStartRtuReportVo.java
index 12f2ca6..911d641 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/rmiClient/ResStartVo.java
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/rmiClient/ResStartRtuReportVo.java
@@ -3,9 +3,9 @@
import com.alibaba.fastjson2.JSON;
-public class ResStartVo {
+public class ResStartRtuReportVo {
- public boolean start ;
+ public boolean report ;
/**
@@ -27,21 +27,20 @@
* @return 瀵硅薄
* @throws Exception 寮傚父
*/
- public static ResStartVo jsonToObject(String json)throws Exception{
+ public static ResStartRtuReportVo jsonToObject(String json)throws Exception{
try{
- return JSON.parseObject(json, ResStartVo.class) ;
+ return JSON.parseObject(json, ResStartRtuReportVo.class) ;
//return new JSONDeserializer<ResStartVo>().deserialize(json, ResStartVo.class) ;
}catch(Exception e){
throw new Exception(e.getMessage() , e ) ;
}
}
- public boolean isStart() {
- return start;
+ public boolean isReport() {
+ return report;
}
- public void setStart(boolean start) {
- this.start = start;
+ public void setReport(boolean report) {
+ this.report = report;
}
-
}
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/rmiClient/ResStartVo.java b/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/rmiClient/ResStartTcpConnectVo.java
similarity index 82%
rename from pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/rmiClient/ResStartVo.java
rename to pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/rmiClient/ResStartTcpConnectVo.java
index 12f2ca6..cf62857 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/rmiClient/ResStartVo.java
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/rmiClient/ResStartTcpConnectVo.java
@@ -3,7 +3,7 @@
import com.alibaba.fastjson2.JSON;
-public class ResStartVo {
+public class ResStartTcpConnectVo {
public boolean start ;
@@ -27,9 +27,9 @@
* @return 瀵硅薄
* @throws Exception 寮傚父
*/
- public static ResStartVo jsonToObject(String json)throws Exception{
+ public static ResStartTcpConnectVo jsonToObject(String json)throws Exception{
try{
- return JSON.parseObject(json, ResStartVo.class) ;
+ return JSON.parseObject(json, ResStartTcpConnectVo.class) ;
//return new JSONDeserializer<ResStartVo>().deserialize(json, ResStartVo.class) ;
}catch(Exception e){
throw new Exception(e.getMessage() , e ) ;
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/rmiClient/RmiClUnit.java b/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/rmiClient/RmiClUnit.java
index e383670..fa47cd9 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/rmiClient/RmiClUnit.java
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/rmiClient/RmiClUnit.java
@@ -86,7 +86,7 @@
RmiRequestVo rqVo = new RmiRequestVo() ;
rqVo.id = id ;
rqVo.token = token ;
- rqVo.code = Code.cd4 ;
+ rqVo.code = Code.cd5;
rqVo.count = count ;
String json = rqVo.toJson() ;
frmWork.syncRequest(json) ;
@@ -102,7 +102,7 @@
RmiRequestVo rqVo = new RmiRequestVo() ;
rqVo.id = id ;
rqVo.token = token ;
- rqVo.code = Code.cd5 ;
+ rqVo.code = Code.cd6;
rqVo.overCount = count ;
String json = rqVo.toJson() ;
frmWork.syncRequest(json) ;
@@ -119,7 +119,7 @@
RmiRequestVo rqVo = new RmiRequestVo() ;
rqVo.id = id ;
rqVo.token = token ;
- rqVo.code = Code.cd6 ;
+ rqVo.code = Code.cd7;
rqVo.over = true ;
rqVo.seconds = seconds ;
String json = rqVo.toJson() ;
@@ -238,13 +238,14 @@
}
}
if(!error){
- getStart(frmWork) ;
+ getStartTcpConnect(frmWork) ;
}
}
- //浠巑wTestServer寰楀埌寮�濮嬩笂鎶ユ暟鎹殑璇峰厑璁�
- private void getStart(RmiFrameWork frmWork){
- log.info("绛夊緟鏈嶅姟绔厑璁镐笂鎶ユ暟鎹�");
+ //浠巑wTestServer寰楀埌寮�濮婽CP杩炴帴鐨勮鍏佽
+ private void getStartTcpConnect(RmiFrameWork frmWork){
+ log.info("绛夊緟鏈嶅姟绔厑璁哥綉缁滆繛鎺�");
+ boolean error = false ;
while(true){
try {
Thread.sleep(100L);
@@ -255,37 +256,93 @@
String json = rqVo.toJson() ;
Object rObj = frmWork.syncRequest(json) ;
if(rObj != null){
- RmiResponseVo rspVo = RmiResponseVo.jsonToObject(String.valueOf(rObj), ResStartVo.class) ;
+ RmiResponseVo rspVo = RmiResponseVo.jsonToObject(String.valueOf(rObj), ResStartTcpConnectVo.class) ;
if(rspVo != null){
if(rspVo.success){
- if(rspVo.obj != null && rspVo.obj instanceof ResStartVo){
- ResStartVo rVo = (ResStartVo)rspVo.obj ;
+ if(rspVo.obj != null && rspVo.obj instanceof ResStartTcpConnectVo){
+ ResStartTcpConnectVo rVo = (ResStartTcpConnectVo)rspVo.obj ;
if(rVo != null){
if(rVo.start){
- ServerProperties.startWork = true ;
- log.info("鍏佽涓婃姤鏁版嵁宸ヤ綔浜�( ^_^ )");
+ ServerProperties.startTcpConnectWork = true ;
+ log.info("鍏佽TCP缃戠粶杩炴帴浜�( ^_^ )");
+ error = false ;
break ;
}
}else{
- log.error("rmi璇锋眰鍚姩澶辫触锛歫son杞琑esStartVo涓簄ull");
+ error = true ;
+ log.error("rmi璇锋眰TCP缃戠粶杩炴帴澶辫触锛歫son杞琑esStartTcpConnectVo涓簄ull");
}
}else{
- log.error("rmi璇锋眰鍚姩澶辫触锛氭湇鍔$杩斿洖ResStartVo涓簄ull");
+ error = true ;
+ log.error("rmi璇锋眰TCP缃戠粶杩炴帴澶辫触锛氭湇鍔$杩斿洖ResStartTcpConnectVo涓簄ull");
}
}else{
- log.error("rmi璇锋眰鍚姩澶辫触锛氭湇鍔$杩斿洖閿欒锛�" + rspVo.errorInfo);
+ error = true ;
+ log.error("rmi璇锋眰TCP缃戠粶杩炴帴澶辫触锛氭湇鍔$杩斿洖閿欒锛�" + rspVo.errorInfo);
}
}else{
- log.error("rmi璇锋眰鍚姩澶辫触锛氭湇鍔$杩斿洖鐨凴miResponseVo涓簄ull");
+ error = true ;
+ log.error("rmi璇锋眰TCP缃戠粶杩炴帴澶辫触锛氭湇鍔$杩斿洖鐨凴miResponseVo涓簄ull");
}
}else{
- log.error("rmi璇锋眰鍚姩澶辫触锛氭湇鍔$杩斿洖json涓簄ull");
+ error = true ;
+ log.error("rmi璇锋眰TCP缃戠粶杩炴帴澶辫触锛氭湇鍔$杩斿洖json涓簄ull");
}
} catch (Exception e) {
- log.error("rmi璇锋眰鍚姩澶辫触" + e.getMessage());
+ error = true ;
+ log.error("rmi璇锋眰TCP缃戠粶杩炴帴澶辫触" + e.getMessage());
+ continue ;
+ }
+ }
+ if(!error){
+ getStartRtuReport(frmWork) ;
+ }
+ }
+
+ //浠巑wTestServer寰楀埌寮�濮婻TU涓婃姤鏁版嵁鐨勮鍏佽
+ private void getStartRtuReport(RmiFrameWork frmWork){
+ log.info("绛夊緟鏈嶅姟绔厑璁镐笂鎶ユ暟鎹�");
+ while(true){
+ try {
+ Thread.sleep(100L);
+ RmiRequestVo rqVo = new RmiRequestVo() ;
+ rqVo.id = id ;
+ rqVo.token = token ;
+ rqVo.code = Code.cd4 ;
+ String json = rqVo.toJson() ;
+ Object rObj = frmWork.syncRequest(json) ;
+ if(rObj != null){
+ RmiResponseVo rspVo = RmiResponseVo.jsonToObject(String.valueOf(rObj), ResStartRtuReportVo.class) ;
+ if(rspVo != null){
+ if(rspVo.success){
+ if(rspVo.obj != null && rspVo.obj instanceof ResStartRtuReportVo){
+ ResStartRtuReportVo rVo = (ResStartRtuReportVo)rspVo.obj ;
+ if(rVo != null){
+ if(rVo.report){
+ ServerProperties.startRtuReportWork = true ;
+ log.info("鍏佽RTU涓婃姤鏁版嵁宸ヤ綔浜�( ^_^ )");
+ break ;
+ }
+ }else{
+ log.error("rmi璇锋眰Rtu涓婃姤鏁版嵁澶辫触锛歫son杞琑esStartRtuReportVo涓簄ull");
+ }
+ }else{
+ log.error("rmi璇锋眰Rtu涓婃姤鏁版嵁澶辫触锛氭湇鍔$杩斿洖ResStartRtuReportVo涓簄ull");
+ }
+ }else{
+ log.error("rmi璇锋眰Rtu涓婃姤鏁版嵁澶辫触锛氭湇鍔$杩斿洖閿欒锛�" + rspVo.errorInfo);
+ }
+ }else{
+ log.error("rmi璇锋眰Rtu涓婃姤鏁版嵁澶辫触锛氭湇鍔$杩斿洖鐨凴miResponseVo涓簄ull");
+ }
+ }else{
+ log.error("rmi璇锋眰Rtu涓婃姤鏁版嵁澶辫触锛氭湇鍔$杩斿洖json涓簄ull");
+ }
+ } catch (Exception e) {
+ log.error("rmi璇锋眰Rtu涓婃姤鏁版嵁澶辫触" + e.getMessage());
continue ;
}
}
}
-
+
}
\ No newline at end of file
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/tcpClient/MyThreadJob.java b/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/tcpClient/MyThreadJob.java
index e50537f..7575093 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/tcpClient/MyThreadJob.java
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/tcpClient/MyThreadJob.java
@@ -23,9 +23,10 @@
public static final int connectTimeout = 3000 ;
- public int sendTimes = 0 ;//鍙戦�佹暟鎹鏁�
- public int heartbeatTimes = 0 ;//涓婃姤蹇冭烦娆℃暟
+ public int sendTimes = 1 ;//鍙戦�佹暟鎹鏁�
+ public int heartbeatTimes = 1 ;//涓婃姤蹇冭烦娆℃暟
+ public long overStart = 0L;
public boolean isOver = false ;
public MyThreadJob(){
@@ -38,21 +39,29 @@
@Override
public void execute() throws Exception {
- log.info("RTU" + rtuAddr + "寮�濮嬩换鍔�");
if(session != null){
- log.info("RTU" + rtuAddr + "灏嗚鎵ц" + ServerProperties.sendTimes + "杞浠诲姟锛屽綋鍓嶈疆娆℃槸" + sendTimes);
if(sendTimes <= ServerProperties.sendTimes){
+ log.info("RTU" + rtuAddr + "寮�濮嬩换鍔�");
+ log.info("RTU" + rtuAddr + "灏嗚鎵ц" + ServerProperties.sendTimes + "杞浠诲姟锛屽綋鍓嶈疆娆℃槸" + sendTimes);
sendDataOfP206V1_0_0() ;
}else{
- this.jobOver() ;
+ log.info("RTU" + rtuAddr + "绛夊緟涓�浼氾紝浠ユ帴鏀堕�氫俊涓棿浠朵笅琛屾暟鎹�");
+ if(overStart == 0){
+ overStart = System.currentTimeMillis() ;
+ }else{
+ long now = System.currentTimeMillis() ;
+ if(now - overStart >= 30 * 1000){
+ this.jobOver() ;
+ }
+ }
}
}
}
private void sendDataOfP206V1_0_0(){
try{
- if(heartbeatTimes >= ServerProperties.heartbeatTimes){
- heartbeatTimes = 0 ;
+ if(heartbeatTimes > ServerProperties.heartbeatTimes){
+ heartbeatTimes = 1 ;
this.sendReportData() ;
TcpClUnit.clientSendData();
sendTimes++ ;
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/tcpClient/TcpClUnit.java b/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/tcpClient/TcpClUnit.java
index 8db9ab8..e2f8660 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/tcpClient/TcpClUnit.java
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/tcpClient/TcpClUnit.java
@@ -71,7 +71,7 @@
public void run() {
try {
while(true){
- if(!ServerProperties.startWork){
+ if(!ServerProperties.startTcpConnectWork){
Thread.sleep(100L);
}else{
try{
@@ -101,7 +101,14 @@
}
}
- startJob() ;
+ while (true){
+ if(!ServerProperties.startRtuReportWork){
+ Thread.sleep(100L);
+ }else{
+ startJob() ;
+ break ;
+ }
+ }
while(true){
if(totalOverClientCount.longValue() >= totalRtuClientCount.longValue()){
@@ -210,16 +217,16 @@
totalSendDataCount++;
if(totalOverClientCount.longValue() >= totalRtuClientCount.longValue()){
RmiClUnit.getInstance().reportHadReportCount(totalSendDataCount);
- System.out.println("宸茬粡鍙戦��" + totalSendDataCount + "鏉℃暟鎹�");
+ System.out.println("宸茬粡鍙戦��" + totalSendDataCount + "鏉℃暟鎹紙蹇冭烦鍜屼笂鎶ワ級");
}else{
if(totalRtuClientCount > 100){
if(totalSendDataCount % 100 == 0){
RmiClUnit.getInstance().reportHadReportCount(totalSendDataCount);
- System.out.println("宸茬粡鍙戦��" + totalSendDataCount + "鏉℃暟鎹�");
+ System.out.println("宸茬粡鍙戦��" + totalSendDataCount + "鏉℃暟鎹紙蹇冭烦鍜屼笂鎶ワ級");
}
}else{
RmiClUnit.getInstance().reportHadReportCount(totalSendDataCount);
- System.out.println("宸茬粡鍙戦��" + totalSendDataCount + "鏉℃暟鎹�");
+ System.out.println("宸茬粡鍙戦��" + totalSendDataCount + "鏉℃暟鎹紙蹇冭烦鍜屼笂鎶ワ級");
}
}
}
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/console/Command.java b/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/console/Command.java
index 263786c..cca3779 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/console/Command.java
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/console/Command.java
@@ -20,7 +20,8 @@
commands = new String[]{
"config 鏌ョ湅閰嶇疆淇℃伅",
"show 鏄剧ずmwTest鎯呭喌",
- "start 鍚姩mwTest涓婃姤鏁版嵁",
+ "start 鍚姩mwTest寤虹珛TCP杩炴帴鏁版嵁",
+ "report 鍚姩mwTest RTU涓婃姤鏁版嵁",
"exit 閫�鍑�",
};
}
@@ -35,7 +36,9 @@
} else if (command.equals("show")) {
show(prtWrt);
} else if (command.equals("start")) {
- start(prtWrt);
+ startNetConnect(prtWrt);
+ } else if (command.equals("report")) {
+ startRtuReport(prtWrt);
} else if(command.equals("exit")){
exit = true ;
} else {
@@ -101,9 +104,14 @@
prtWrt.println(" rtuAddr鑼冨洿锛�" + sta.confVo.rtuAddrStart + "--" + sta.confVo.rtuAddrEnd);
}
if(sta.startVo != null){
- prtWrt.println(" 涓婃姤鏁版嵁锛�" + (sta.startVo.start?"宸茬粡寮�濮�":"鏈紑濮�"));
+ prtWrt.println(" TCP杩炴帴锛�" + (sta.startVo.start?"宸茬粡寮�濮�":"鏈紑濮�"));
}else{
- prtWrt.println(" 涓婃姤鏁版嵁锛氭湭寮�濮�") ;
+ prtWrt.println(" TCP杩炴帴锛氭湭寮�濮�") ;
+ }
+ if(sta.reportVo != null){
+ prtWrt.println(" RTU涓婃姤鏁版嵁锛�" + (sta.reportVo.report?"宸茬粡寮�濮�":"鏈紑濮�"));
+ }else{
+ prtWrt.println(" RTU涓婃姤鏁版嵁锛氭湭寮�濮�") ;
}
if(sta.count != null){
prtWrt.println(" 宸茬粡涓婃姤鏁版嵁锛�" + sta.count + "鏉�");
@@ -120,11 +128,18 @@
prtWrt.println("");
}
- private static void start(PrintWriter prtWrt){
+ private static void startNetConnect(PrintWriter prtWrt){
prtWrt.println("");
- prtWrt.println(" 宸茬粡鍏佽mwTest涓婃姤鏁版嵁浜�");
+ prtWrt.println(" 宸茬粡鍏佽mwTest寤虹珛TCP杩炴帴");
prtWrt.println("");
- Manager.enablemwTestStart = true ;
+ Manager.enablemwTestStartTcpConnect = true ;
+ }
+
+ private static void startRtuReport(PrintWriter prtWrt){
+ prtWrt.println("");
+ prtWrt.println(" 宸茬粡鍏佽mwTest RTU涓婃姤鏁版嵁浜�");
+ prtWrt.println("");
+ Manager.enablemwTestStartRtuReport = true ;
}
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/forRmi/Code.java b/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/forRmi/Code.java
index 970c2f5..ae54ebb 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/forRmi/Code.java
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/forRmi/Code.java
@@ -3,14 +3,16 @@
public class Code {
public static String cd1 = "001" ;//娉ㄥ唽
-
- public static String cd2 = "002" ;//璇锋眰mwClient鐨勯厤缃�
-
- public static String cd3 = "003" ;//璇锋眰寮�濮嬪伐浣�
-
- public static String cd4 = "004" ;//鍚戞湇鍔$涓婃姤淇℃伅
- public static String cd5 = "005" ;//鍚戞湇鍔$涓婃姤 瀹屾垚浠诲姟鐨勬暟閲�
+ public static String cd2 = "002" ;//璇锋眰sepTest鐨勯厤缃�
- public static String cd6 = "006" ;//鍚戞湇鍔$涓婃姤 鍏ㄩ儴浠诲姟瀹屾垚
+ public static String cd3 = "003" ;//璇锋眰寮�濮嬪缓绔嬬綉缁滆繛鎺�
+
+ public static String cd4 = "004" ;//璇锋眰寮�濮婻TU涓婃姤鏁版嵁
+
+ public static String cd5 = "005" ;//鍚戞湇鍔$涓婃姤淇℃伅
+
+ public static String cd6 = "006" ;//鍚戞湇鍔$涓婃姤 瀹屾垚浠诲姟鐨勬暟閲�
+
+ public static String cd7 = "007" ;//鍚戞湇鍔$涓婃姤 鍏ㄩ儴浠诲姟瀹屾垚
}
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/forRmi/Manager.java b/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/forRmi/Manager.java
index cf45570..2bbe053 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/forRmi/Manager.java
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/forRmi/Manager.java
@@ -8,9 +8,11 @@
import com.dy.testServer.ServerProperties;
public class Manager {
-
- public static boolean enablemwTestStart = false ;
-
+
+ public static boolean enablemwTestStartTcpConnect = false ;
+
+ public static boolean enablemwTestStartRtuReport = false ;
+
public static int clientId = 1 ;
public static long maxClient = 0 ;
@@ -79,10 +81,12 @@
}else if(rqVo.code.equals(Code.cd3)){
resVo.obj = doDealGetStart(rqVo) ;
}else if(rqVo.code.equals(Code.cd4)){
- doDealReportCount(rqVo) ;
+ resVo.obj = doDealGetReport(rqVo) ;
}else if(rqVo.code.equals(Code.cd5)){
- doDealReportOver(rqVo) ;
+ doDealReportCount(rqVo) ;
}else if(rqVo.code.equals(Code.cd6)){
+ doDealReportOver(rqVo) ;
+ }else if(rqVo.code.equals(Code.cd7)){
doDealAllOver(rqVo) ;
}
return resVo ;
@@ -127,9 +131,9 @@
}
return conVo ;
}
- private static ResStartVo doDealGetStart(RmiRequestVo rqVo){
- ResStartVo rvo = new ResStartVo() ;
- rvo.start = enablemwTestStart ;
+ private static ResStartTcpConnectVo doDealGetStart(RmiRequestVo rqVo){
+ ResStartTcpConnectVo rvo = new ResStartTcpConnectVo() ;
+ rvo.start = enablemwTestStartTcpConnect ;
int token = Integer.parseInt(rqVo.token) ;
MwTestClientStatus sta = token2ClientMap.get("" + token);
if(sta == null){
@@ -141,7 +145,21 @@
}
return rvo ;
}
-
+ private static ResStartRtuReportVo doDealGetReport(RmiRequestVo rqVo){
+ ResStartRtuReportVo rvo = new ResStartRtuReportVo() ;
+ rvo.report = enablemwTestStartRtuReport ;
+ int token = Integer.parseInt(rqVo.token) ;
+ MwTestClientStatus sta = token2ClientMap.get("" + token);
+ if(sta == null){
+ sta = new MwTestClientStatus() ;
+ sta.reportVo = rvo ;
+ token2ClientMap.put("" + token, sta);
+ }else{
+ sta.reportVo = rvo ;
+ }
+ return rvo ;
+ }
+
private static void doDealReportCount(RmiRequestVo rqVo){
int token = Integer.parseInt(rqVo.token) ;
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/forRmi/MwTestClientStatus.java b/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/forRmi/MwTestClientStatus.java
index 71af287..bb4cd7d 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/forRmi/MwTestClientStatus.java
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/forRmi/MwTestClientStatus.java
@@ -4,7 +4,9 @@
public MwConfigVo confVo ;
- public ResStartVo startVo ;
+ public ResStartTcpConnectVo startVo ;
+
+ public ResStartRtuReportVo reportVo ;
public Integer count ;//mwTest涓婃姤鏁版嵁鏁伴噺
@@ -22,11 +24,11 @@
this.confVo = confVo;
}
- public ResStartVo getStartVo() {
+ public ResStartTcpConnectVo getStartVo() {
return startVo;
}
- public void setStartVo(ResStartVo startVo) {
+ public void setStartVo(ResStartTcpConnectVo startVo) {
this.startVo = startVo;
}
@@ -53,6 +55,20 @@
public void setSeconds(Long seconds) {
this.seconds = seconds;
}
-
-
+
+ public ResStartRtuReportVo getReportVo() {
+ return reportVo;
+ }
+
+ public void setReportVo(ResStartRtuReportVo reportVo) {
+ this.reportVo = reportVo;
+ }
+
+ public Integer getOverCount() {
+ return overCount;
+ }
+
+ public void setOverCount(Integer overCount) {
+ this.overCount = overCount;
+ }
}
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/forRmi/ResStartVo.java b/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/forRmi/ResStartRtuReportVo.java
similarity index 76%
copy from pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/forRmi/ResStartVo.java
copy to pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/forRmi/ResStartRtuReportVo.java
index ce87eb6..92126bb 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/forRmi/ResStartVo.java
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/forRmi/ResStartRtuReportVo.java
@@ -3,13 +3,13 @@
import com.alibaba.fastjson2.JSON;
-public class ResStartVo {
+public class ResStartRtuReportVo {
public boolean success = true ;
public String errorInfo ;
- public boolean start ;
+ public boolean report;
/**
@@ -31,9 +31,9 @@
* @return 瀵硅薄
* @throws Exception 寮傚父
*/
- public static ResStartVo jsonToObject(String json)throws Exception{
+ public static ResStartRtuReportVo jsonToObject(String json)throws Exception{
try{
- return JSON.parseObject(json, ResStartVo.class) ;
+ return JSON.parseObject(json, ResStartRtuReportVo.class) ;
//return new JSONDeserializer<ResStartVo>().deserialize(json, ResStartVo.class) ;
}catch(Exception e){
throw new Exception(e.getMessage() , e ) ;
@@ -52,12 +52,12 @@
public void setErrorInfo(String errorInfo) {
this.errorInfo = errorInfo;
}
- public boolean isStart() {
- return start;
+
+ public boolean isReport() {
+ return report;
}
- public void setStart(boolean start) {
- this.start = start;
+ public void setReport(boolean report) {
+ this.report = report;
}
-
}
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/forRmi/ResStartVo.java b/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/forRmi/ResStartTcpConnectVo.java
similarity index 86%
rename from pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/forRmi/ResStartVo.java
rename to pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/forRmi/ResStartTcpConnectVo.java
index ce87eb6..ecec448 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/forRmi/ResStartVo.java
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/forRmi/ResStartTcpConnectVo.java
@@ -3,7 +3,7 @@
import com.alibaba.fastjson2.JSON;
-public class ResStartVo {
+public class ResStartTcpConnectVo {
public boolean success = true ;
@@ -31,9 +31,9 @@
* @return 瀵硅薄
* @throws Exception 寮傚父
*/
- public static ResStartVo jsonToObject(String json)throws Exception{
+ public static ResStartTcpConnectVo jsonToObject(String json)throws Exception{
try{
- return JSON.parseObject(json, ResStartVo.class) ;
+ return JSON.parseObject(json, ResStartTcpConnectVo.class) ;
//return new JSONDeserializer<ResStartVo>().deserialize(json, ResStartVo.class) ;
}catch(Exception e){
throw new Exception(e.getMessage() , e ) ;
--
Gitblit v1.8.0