From 21989973eb90e0fbf60c60ef9343a117fa67d354 Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期日, 28 四月 2024 08:55:56 +0800
Subject: [PATCH] 靳总离职前,应元谋二期项目要求(慧图),做了通信协议修改,在他离职后,从韩月处得到最新协议,并做了部分协议软件实现修改,发现新协议中有一些协议定义有重复,也有错误的,所以这版本协议未全部实现,但实现的部分可以用来测试测控一体阀(与段志强一起测试过)。目前情况下,这版本协议实现不能应用于实际项目中,如果必须实现,还需要结合硬件协议具体实现内容再实现通信中间件的协议解析与构造部分,还需要实现上行数据处理任务树部分。
---
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/tasks/ToRtuConstantTask.java | 80 +++++++++++++++++++++++++++++++--------
1 files changed, 63 insertions(+), 17 deletions(-)
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 d042ef3..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);
+ }
}
}
--
Gitblit v1.8.0