From b6833ab41416dd68a30f7cd368a802aa3a0a2e21 Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期四, 11 七月 2024 20:32:10 +0800
Subject: [PATCH] 1、完善代码; 2、生成新模块pipIrr-mwTest-rtu
---
pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/java/com/dy/pipIrrMwTestRtu/tcpClient/LocalDecoder.java | 37 ++
pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/java/com/dy/pipIrrMwTestRtu/tcpClient/LocalCodecFactory.java | 35 ++
pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/java/com/dy/pipIrrMwTestRtu/tcpClient/TcpConnect.java | 62 ++++
pipIrr-platform/pipIrr-web/pom.xml | 1
pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/java/com/dy/pipIrrMwTestRtu/tcpClient/LocalEncoder.java | 27 +
pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/rtuData/p206V1_0_0/TkDealClientAmountDay.java | 24 +
pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/java/com/dy/pipIrrMwTestRtu/tcpClient/TcpClUnitConfigVo.java | 6
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ByteUtil.java | 25 +
pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/resources/log4j2.xml | 2
pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/resources/log4j2.xml | 39 ++
pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/pom.xml | 2
pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/java/com/dy/pipIrrMwTestRtu/tcpClient/TcpClUnitAdapter.java | 7
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/parse/global/GlCreate.java | 4
pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/resources/Config.xml | 9
pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/tcpClient/MyThreadJob.java | 158 +---------
pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/java/com/dy/pipIrrMwTestRtu/tcpClient/TcpHandler.java | 77 +++++
pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/resources/application.yml | 29 +
pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/Server.java | 8
pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/java/com/dy/pipIrrMwTestRtu/AdapterImp_TcpClUnit.java | 19 +
pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/src/main/java/com/dy/pipIrrMwTestWeb/PipIrrMwTestWebApplication.java | 3
pipIrr-platform/pipIrr-global/src/main/resources/application-global.yml | 5
pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/tcpClient/RtuUpData.java | 287 +++++++++++++++++++
pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/resources/log4j2.xml | 2
23 files changed, 718 insertions(+), 150 deletions(-)
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/parse/global/GlCreate.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/parse/global/GlCreate.java
index a47ac4c..d2caefe 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/parse/global/GlCreate.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/parse/global/GlCreate.java
@@ -28,6 +28,10 @@
ByteUtil.string2BCD_LE(bs, DateTime.yyMMddhhmmss(), index) ;
}
+ public static void createTp(String yyMMddhhmmss, byte[] bs, int index) throws Exception {
+ ByteUtil.string2BCD_LE(bs, yyMMddhhmmss, index) ;
+ }
+
public static void createLen(byte[] bsNoTail) throws Exception {
int len = bsNoTail.length - ProtocolConstantV206V1_0_0.lenHead2ctrl;
bsNoTail[ProtocolConstantV206V1_0_0.dataLenIndex] = (byte)len ;
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ByteUtil.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ByteUtil.java
index f3f8dfc..d0f7034 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ByteUtil.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ByteUtil.java
@@ -1035,6 +1035,31 @@
return fromIndex ;
}
+ /**
+ * 鍗佸叚杩涘埗杞瓧鑺傛暟缁�
+ * @param hex the hex string
+ * @return 杩斿洖 byte[]
+ */
+ public static int hex2Bytes_LE(String hex, byte[] bs, int fromIndex) {
+ if (hex == null || hex.equals("")) {
+ return fromIndex;
+ }
+ hex = hex.toUpperCase(Locale.ENGLISH);
+ int length = hex.length() / 2;
+ char[] hexChars = hex.toCharArray();
+ byte[] d = new byte[length];
+ for (int i = 0; i < length; i++) {
+ int pos = i * 2;
+ d[i] = (byte) (charToByte(hexChars[pos]) << 4 | charToByte(hexChars[pos + 1]));
+ }
+ for(int i = 0 ; i < d.length; i++){
+ bs[fromIndex++] = d[(d.length - 1) - i] ;
+ }
+ return fromIndex ;
+ }
+
+
+
private static final char[] HEX_CHAR = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
// /**
// * 灏哹yte[]杞崲涓�16杩涘埗瀛楃涓�
diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/application-global.yml b/pipIrr-platform/pipIrr-global/src/main/resources/application-global.yml
index 330cfe7..88dc1c3 100644
--- a/pipIrr-platform/pipIrr-global/src/main/resources/application-global.yml
+++ b/pipIrr-platform/pipIrr-global/src/main/resources/application-global.yml
@@ -134,7 +134,10 @@
#protocol: DYJS_2023,DYJS_2024
mw:
#鍛戒护鍙戦�佸湴鍧�
- comSendUrl: "http://127.0.0.1:8070/rtuMw/com/send"
+ ym:
+ comSendUrl: "http://127.0.0.1:8070/rtuMw/com/send"
+ sp:
+ comSendUrl: "http://127.0.0.1:8071/rtuMw/com/send"
#鐩戞祴鎺у埗妯″潡鍥炶皟鍦板潃
rtuCallbackUrl_rm: "http://127.0.0.1:8081/remote/comRes/receive"
#寰俊灏忕▼搴忓洖璋冨湴鍧�
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/rtuData/p206V1_0_0/TkDealClientAmountDay.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/rtuData/p206V1_0_0/TkDealClientAmountDay.java
index 5c1abe9..1260bd9 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/rtuData/p206V1_0_0/TkDealClientAmountDay.java
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/rtuData/p206V1_0_0/TkDealClientAmountDay.java
@@ -170,8 +170,16 @@
RmClientAmountDay poHistory = new RmClientAmountDay() ;
poHistory.clientId = clientVo.getId();
if(lastPo != null){
- poHistory.amount += lastPo.amount ;
- poHistory.money += lastPo.money ;
+ if(poHistory.amount != null){
+ poHistory.amount += lastPo.amount ;
+ }else{
+ poHistory.amount = lastPo.amount ;
+ }
+ if(poHistory.money != null){
+ poHistory.money += lastPo.money ;
+ }else{
+ poHistory.money = lastPo.money ;
+ }
poHistory.dt = lastPo.dt ;
poHistory.openDtLast = lastPo.openDtLast ;
poHistory.closeDtLast = lastPo.closeDtLast ;
@@ -278,8 +286,16 @@
*/
private RmClientAmountDay updateRmClientAmountBySameDateNewData(SeClient clientVo, RmClientAmountDay poHistory, RmClientAmountDayLast lastPo, DataV1_0_1 dV1_0_1, DataCd83CloseVo cdData)throws Exception {
poHistory.clientId = clientVo.getId();
- poHistory.amount += lastPo.amount ;
- poHistory.money += lastPo.money ;
+ if(poHistory.amount != null){
+ poHistory.amount += cdData.thisAmount ;
+ }else{
+ poHistory.amount = cdData.thisAmount ;
+ }
+ if(poHistory.money != null){
+ poHistory.money += cdData.thisMoney ;
+ }else{
+ poHistory.money = cdData.thisMoney ;
+ }
poHistory.dt = lastPo.dt ;
poHistory.openDtLast = lastPo.openDtLast ;
poHistory.closeDtLast = lastPo.closeDtLast ;
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 0f58f3e..fe1eae5 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
@@ -14,6 +14,16 @@
private static final Logger log = LogManager.getLogger(MyThreadJob.class) ;
+ public static String icCardAddr = "3B7D1E1A" ;
+ public static String icCardNo = "61181622830147821" ;
+ public static String openValveDt = "240711163700" ;
+ public static String cdC0 = "C0" ;
+ public static String cd83Open = "83Open" ;
+ public static String cd83Close = "83Close" ;
+
+
+ public static String curCd = cdC0 ;//閫氳繃淇敼杩欎釜鍊硷紝鏉ユ敼鍙樹笂鎶ユ暟鎹被鍨�
+
public String rtuAddr;
public String serverIp;
public Integer serverPort;
@@ -44,7 +54,7 @@
if(sendTimes <= ServerProperties.sendTimes){
log.info("RTU" + rtuAddr + "寮�濮嬩换鍔�");
log.info("RTU" + rtuAddr + "灏嗚鎵ц" + ServerProperties.sendTimes + "杞浠诲姟锛屽綋鍓嶈疆娆℃槸" + sendTimes);
- sendDataOfP206V1_0_0() ;
+ sendDataOfP206V1_0_0(curCd) ;
}else{
if(ServerProperties.sendOverThenCloseConnect == 1){
log.info("RTU" + rtuAddr + "绛夊緟涓�浼氾紝浠ユ帴鏀堕�氫俊涓棿浠朵笅琛屾暟鎹�");
@@ -64,11 +74,20 @@
}
}
- private void sendDataOfP206V1_0_0(){
+ private void sendDataOfP206V1_0_0(String cd){
try{
if(heartbeatTimes > ServerProperties.heartbeatTimes){
heartbeatTimes = 1 ;
- this.sendReportData() ;
+ byte[] bs = null ;
+ if(cd.equals(cdC0)){
+ bs = RtuUpData.createCdC0(this.rtuAddr) ;
+ }else if(cd.equals(cd83Open)){
+ bs = RtuUpData.createCd83Open(this.rtuAddr, icCardAddr, icCardNo, openValveDt) ;
+ }else if(cd.equals(cd83Close)){
+ bs = RtuUpData.createCd83Close(this.rtuAddr, icCardAddr, icCardNo, openValveDt) ;
+ }
+ this.session.write(bs) ;
+ log.info("RTU" + rtuAddr + "鍙戦�佷簡涓婅鏁版嵁锛�" + ByteUtil.bytes2Hex(bs, false));
TcpClUnit.clientSendData();
sendTimes++ ;
}else{
@@ -82,7 +101,7 @@
}
private void sendHeartbeat(){
try{
- byte[] bs = this.createHeartbeat() ;
+ byte[] bs = RtuUpData.createHeartbeat(this.rtuAddr) ;
this.session.write(bs) ;
log.info("RTU" + rtuAddr + "鍙戦�佷簡蹇冭烦鏁版嵁锛�" + ByteUtil.bytes2Hex(bs, false));
}catch (Exception e){
@@ -90,15 +109,6 @@
}
}
- private void sendReportData(){
- try{
- byte[] bs = this.createReport() ;
- this.session.write(bs) ;
- log.info("RTU" + rtuAddr + "鍙戦�佷簡涓婃姤鏁版嵁锛�" + ByteUtil.bytes2Hex(bs, false));
- }catch (Exception e){
- e.printStackTrace();
- }
- }
private void jobOver(){
if(ServerProperties.sendOverThenCloseConnect == 1){
@@ -108,128 +118,6 @@
TcpClUnit.clientOver() ;
}
- /**
- * 鏋勯�犲績璺虫暟鎹�
- * @return 瀛楄妭鏁扮粍
- * @throws Exception 寮傚父
- */
- public byte[] createHeartbeat( ) throws Exception {
- CommonV1_0_1 commonV1_0_1 = new CommonV1_0_1() ;
- byte[] bytes ;
- byte[] bsHead = new byte[ProtocolConstantV206V1_0_0.lenHead2Code] ;
- byte index = 0 ;
- bsHead[index] = ProtocolConstantV206V1_0_0.P_Head_Byte ;
-
- index++ ;
- bsHead[index] = 0 ;//甯ч暱搴�
-
- index++ ;
- bsHead[index] = ProtocolConstantV206V1_0_0.P_Head_Byte ;
-
- index++ ;
- bsHead[index] = commonV1_0_1.createCtrl((byte)0x80, (byte)0) ;//鎺у埗鍩熷姛鑳界爜锛氱‘璁� 璁ゅ彲
-
- index++ ;
- GlCreate.createRtuAddr(this.rtuAddr, bsHead, index);
- index += 5 ;
-
- ByteUtil.hex2Bytes("02", bsHead, index) ;
-
- byte[] bs = new byte[1] ;
- bs[0] = (byte)0xF2 ;//鏁版嵁鍩燂細 1 涓瓧鑺傦紝F0 鐧诲綍锛� F1 閫�鍑虹櫥褰曪紝F2 鍦ㄧ嚎淇濇寔銆�
-
- bytes = ByteUtil.bytesMerge(bsHead, bs) ;
-
- GlCreate.createLen(bytes);//闀垮害鏀惧瓧鑺傛暟缁勪腑
-
- byte[] bsTail = GlCreate.createCrcTail(bytes) ;//CRC鍜屽熬鍙犲姞瀛楄妭鏁扮粍涓�
-
- bytes = ByteUtil.bytesMerge(bytes, bsTail) ;
-
- return bytes ;
- }
-
- /**
- * 鏋勯�犱笂鎶ユ暟鎹�
- * @return 瀛楄妭鏁扮粍
- * @throws Exception 寮傚父
- */
- public byte[] createReport( ) throws Exception {
- CommonV1_0_1 commonV1_0_1 = new CommonV1_0_1() ;
- byte[] bytes ;
- byte[] bsHead = new byte[ProtocolConstantV206V1_0_0.lenHead2Code] ;
- byte index = 0 ;
- bsHead[index] = ProtocolConstantV206V1_0_0.P_Head_Byte ;
-
- index++ ;
- bsHead[index] = 0 ;//甯ч暱搴�
-
- index++ ;
- bsHead[index] = ProtocolConstantV206V1_0_0.P_Head_Byte ;
-
- index++ ;
- bsHead[index] = commonV1_0_1.createCtrl((byte)0x80, (byte)3) ;//鎺у埗鍩熷姛鑳界爜3锛氳嚜鎶ュ抚锛屾祦閲忥紙姘撮噺锛夊弬鏁�
-
- index++ ;
- GlCreate.createRtuAddr(this.rtuAddr, bsHead, index);
- index += 5 ;
-
- ByteUtil.hex2Bytes("C0", bsHead, index) ;
-
- byte[] bs = new byte[2] ;
- bs[0] = (byte)0x04 ;//鏈夋祦閲忔暟鎹�
- bs[1] = (byte)0xE0 ;//鏈夋按鍘嬨�佺數姹犵數鍘嬨�佷俊鍙峰己搴�
-
- bytes = ByteUtil.bytesMerge(bsHead, bs) ;
-
- bs = new byte[5] ;//鐬椂娴侀噺
- bs[0] = ByteUtil.int2BCD_LE (21)[0] ;
- bs[1] = ByteUtil.int2BCD_LE (43)[0] ;
- bs[2] = ByteUtil.int2BCD_LE (65)[0] ;
- bytes = ByteUtil.bytesMerge(bytes, bs) ;
-
- bs = new byte[5] ;//绱娴侀噺
- bs[0] = ByteUtil.int2BCD_LE (21)[0] ;
- bs[1] = ByteUtil.int2BCD_LE (43)[0] ;
- bs[2] = ByteUtil.int2BCD_LE (65)[0] ;
- bs[3] = ByteUtil.int2BCD_LE (87)[0] ;
- bytes = ByteUtil.bytesMerge(bytes, bs) ;
-
- bs = new byte[5] ;//鎹熷け娴侀噺
- bs[0] = ByteUtil.int2BCD_LE (10)[0] ;
- bs[1] = ByteUtil.int2BCD_LE (32)[0] ;
- bs[2] = ByteUtil.int2BCD_LE (54)[0] ;
- bytes = ByteUtil.bytesMerge(bytes, bs) ;
-
- bs = new byte[4] ;//姘村帇
- bs[0] = ByteUtil.int2BCD_LE (10)[0] ;
- bs[1] = ByteUtil.int2BCD_LE (32)[0] ;
- bs[2] = ByteUtil.int2BCD_LE (4)[0] ;
- bytes = ByteUtil.bytesMerge(bytes, bs) ;
-
- bs = new byte[4] ;//鐢垫睜鐢靛帇
- bs[0] = ByteUtil.int2BCD_LE (10)[0] ;
- bs[1] = ByteUtil.int2BCD_LE (32)[0] ;
- bs[2] = ByteUtil.int2BCD_LE (10)[0] ;
- bs[3] = ByteUtil.int2BCD_LE (32)[0] ;
- bytes = ByteUtil.bytesMerge(bytes, bs) ;
-
- bs = new byte[1] ;//淇″彿寮哄害
- bs[0] = ByteUtil.int2BCD_LE (21)[0] ;
- bytes = ByteUtil.bytesMerge(bytes, bs) ;
-
- bs = new byte[6] ;//鏃堕挓
- GlCreate.createTp(bs, 0);
- bytes = ByteUtil.bytesMerge(bytes, bs) ;
-
- GlCreate.createLen(bytes);//闀垮害鏀惧瓧鑺傛暟缁勪腑
-
- byte[] bsTail = GlCreate.createCrcTail(bytes) ;//CRC鍜屽熬鍙犲姞瀛楄妭鏁扮粍涓�
-
- bytes = ByteUtil.bytesMerge(bytes, bsTail) ;
-
- return bytes ;
- }
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/tcpClient/RtuUpData.java b/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/tcpClient/RtuUpData.java
new file mode 100644
index 0000000..f3659c2
--- /dev/null
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/tcpClient/RtuUpData.java
@@ -0,0 +1,287 @@
+package com.dy.testClient.tcpClient;
+
+import com.dy.common.mw.protocol.p206V1_0_0.CommonV1_0_1;
+import com.dy.common.mw.protocol.p206V1_0_0.ProtocolConstantV206V1_0_0;
+import com.dy.common.mw.protocol.p206V1_0_0.parse.global.GlCreate;
+import com.dy.common.util.ByteUtil;
+import com.dy.common.util.ByteUtilUnsigned;
+
+/**
+ * @Author: liurunyu
+ * @Date: 2024/7/11 13:55
+ * @Description
+ */
+public class RtuUpData {
+
+ private static byte[] creatHead(String rtuAddr, String code, byte ctrl)throws Exception {
+ byte[] bsHead = new byte[ProtocolConstantV206V1_0_0.lenHead2Code] ;
+ byte index = 0 ;
+ bsHead[index] = ProtocolConstantV206V1_0_0.P_Head_Byte ;
+
+ index++ ;
+ bsHead[index] = 0 ;//甯ч暱搴�
+
+ index++ ;
+ bsHead[index] = ProtocolConstantV206V1_0_0.P_Head_Byte ;
+
+ index++ ;
+ bsHead[index] = ctrl; //鎺у埗鍩熷姛鑳界爜
+
+ index++ ;
+ GlCreate.createRtuAddr(rtuAddr, bsHead, index);
+ index += 5 ;
+
+ ByteUtil.hex2Bytes(code, bsHead, index) ;
+
+ return bsHead ;
+ }
+
+
+ /**
+ * 鏋勯�犲績璺虫暟鎹�
+ * @return 瀛楄妭鏁扮粍
+ * @throws Exception 寮傚父
+ */
+ public static byte[] createHeartbeat(String rtuAddr) throws Exception {
+ byte[] bytes = creatHead(rtuAddr, "02", (byte)0xB0);
+
+ byte[] bs = new byte[1] ;
+ bs[0] = (byte)0xF2 ;//鏁版嵁鍩燂細 1 涓瓧鑺傦紝F0 鐧诲綍锛� F1 閫�鍑虹櫥褰曪紝F2 鍦ㄧ嚎淇濇寔銆�
+
+ bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+ GlCreate.createLen(bytes);//闀垮害鏀惧瓧鑺傛暟缁勪腑
+
+ byte[] bsTail = GlCreate.createCrcTail(bytes) ;//CRC鍜屽熬鍙犲姞瀛楄妭鏁扮粍涓�
+
+ bytes = ByteUtil.bytesMerge(bytes, bsTail) ;
+
+ return bytes ;
+ }
+
+ /**
+ * 鏋勯�犱笂鎶ユ暟鎹�
+ * @return 瀛楄妭鏁扮粍
+ * @throws Exception 寮傚父
+ */
+ public static byte[] createCd83Open(String rtuAddr, String icCardAddr, String icCardNo, String openValveDt) throws Exception {
+ byte[] bytes = creatHead(rtuAddr, "83", (byte)0xB0);
+
+ byte[] bs = new byte[1] ;
+ bs[0] = (byte)0x01 ;//鍒峰崱寮�闃�
+
+ bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+ bs = new byte[5] ;//绱娴侀噺
+ bs[0] = ByteUtil.int2BCD_LE (21)[0] ;
+ bs[1] = ByteUtil.int2BCD_LE (43)[0] ;
+ bs[2] = ByteUtil.int2BCD_LE (0)[0] ;
+ bs[3] = ByteUtil.int2BCD_LE (0)[0] ;
+ bs[4] = ByteUtil.int2BCD_LE (0)[0] ;
+ bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+ bs = new byte[8] ;//IC鍗$紪鍙�
+ GlCreate.createIcCardNo(icCardNo, bs, 0);
+ bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+ bs = new byte[4] ;//IC鍗″湴鍧�
+ ByteUtil.hex2Bytes_LE(icCardAddr, bs, 0);
+ bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+ bs = new byte[4] ;//鐢ㄦ按鎴蜂綑棰�
+ bs[0] = ByteUtil.int2BCD_LE (21)[0] ;
+ bs[1] = ByteUtil.int2BCD_LE (43)[0] ;
+ bs[2] = ByteUtil.int2BCD_LE (0)[0] ;
+ bs[3] = ByteUtil.int2BCD_LE (0)[0] ;
+ bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+ bs = new byte[6] ;//寮�闃�鏃堕棿
+ GlCreate.createTp(openValveDt, bs, 0);
+ bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+ bs = new byte[6] ;//鎺у埗鍣ㄦ椂閽�
+ GlCreate.createTp(bs, 0);
+ bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+ GlCreate.createLen(bytes);//闀垮害鏀惧瓧鑺傛暟缁勪腑
+
+ byte[] bsTail = GlCreate.createCrcTail(bytes) ;//CRC鍜屽熬鍙犲姞瀛楄妭鏁扮粍涓�
+
+ bytes = ByteUtil.bytesMerge(bytes, bsTail) ;
+
+ return bytes ;
+ }
+
+
+ /**
+ * 鏋勯�犱笂鎶ユ暟鎹�
+ * @return 瀛楄妭鏁扮粍
+ * @throws Exception 寮傚父
+ */
+ public static byte[] createCd83Close(String rtuAddr, String icCardAddr, String icCardNo, String openValveDt) throws Exception {
+ byte[] bytes = creatHead(rtuAddr, "83", (byte)0xB0);
+
+ byte[] bs = new byte[1] ;
+ bs[0] = (byte)0x02 ;//鍒峰崱鍏抽榾
+
+ bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+ bs = new byte[5] ;//绱娴侀噺
+ bs[0] = ByteUtil.int2BCD_LE (21)[0] ;
+ bs[1] = ByteUtil.int2BCD_LE (53)[0] ;
+ bs[2] = ByteUtil.int2BCD_LE (0)[0] ;
+ bs[3] = ByteUtil.int2BCD_LE (0)[0] ;
+ bs[4] = ByteUtil.int2BCD_LE (0)[0] ;
+ bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+ bs = new byte[8] ;//IC鍗$紪鍙�
+ GlCreate.createIcCardNo(icCardNo, bs, 0);
+ bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+ bs = new byte[4] ;//IC鍗″湴鍧�
+ ByteUtil.hex2Bytes_LE(icCardAddr, bs, 0);
+ bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+ bs = new byte[4] ;//鐢ㄦ按鎴蜂綑棰�
+ bs[0] = ByteUtil.int2BCD_LE (21)[0] ;
+ bs[1] = ByteUtil.int2BCD_LE (33)[0] ;
+ bs[2] = ByteUtil.int2BCD_LE (0)[0] ;
+ bs[3] = ByteUtil.int2BCD_LE (0)[0] ;
+ bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+ bs = new byte[6] ;//寮�闃�鏃堕棿
+ GlCreate.createTp(openValveDt, bs, 0);
+ bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+ bs = new byte[6] ;//鍏抽榾鏃堕棿
+ GlCreate.createTp(bs, 0);
+ bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+ bs = new byte[5] ;//鐢ㄦ按鎴锋湰娆$敤姘撮噺
+ bs[0] = ByteUtil.int2BCD_LE (0)[0] ;
+ bs[1] = ByteUtil.int2BCD_LE (10)[0] ;
+ bs[2] = ByteUtil.int2BCD_LE (0)[0] ;
+ bs[3] = ByteUtil.int2BCD_LE (0)[0] ;
+ bs[4] = ByteUtil.int2BCD_LE (0)[0] ;
+ bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+ bs = new byte[4] ;//鐢ㄦ按鎴锋湰娆℃秷璐归噾棰�
+ bs[0] = ByteUtil.int2BCD_LE (0)[0] ;
+ bs[1] = ByteUtil.int2BCD_LE (10)[0] ;
+ bs[2] = ByteUtil.int2BCD_LE (0)[0] ;
+ bs[3] = ByteUtil.int2BCD_LE (0)[0] ;
+ bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+ bs = new byte[2] ;//鐢ㄦ按鎴锋湰娆$敤姘存椂闀�
+ bs[0] = ByteUtil.int2BCD_LE (10)[0] ;
+ bs[1] = ByteUtil.int2BCD_LE (0)[0] ;
+ bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+ bs = new byte[1] ;//姘翠环绫诲瀷
+ bs[0] = ByteUtil.int2BCD_LE (1)[0] ;
+ bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+ bs = new byte[2] ;//姘翠环
+ bs[0] = ByteUtil.int2BCD_LE (0)[0] ;
+ bs[1] = ByteUtil.int2BCD_LE (1)[0] ;
+ bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+ bs = new byte[6] ;//鎺у埗鍣ㄦ椂閽�
+ GlCreate.createTp(bs, 0);
+ bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+ bs = new byte[1] ;//鍗$被鍨�
+ bs[0] = ByteUtil.int2BCD_LE (1)[0] ;
+ bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+ GlCreate.createLen(bytes);//闀垮害鏀惧瓧鑺傛暟缁勪腑
+
+ byte[] bsTail = GlCreate.createCrcTail(bytes) ;//CRC鍜屽熬鍙犲姞瀛楄妭鏁扮粍涓�
+
+ bytes = ByteUtil.bytesMerge(bytes, bsTail) ;
+
+ return bytes ;
+ }
+
+ /**
+ * 鏋勯�犱笂鎶ユ暟鎹�
+ * @return 瀛楄妭鏁扮粍
+ * @throws Exception 寮傚父
+ */
+ public static byte[] createCdC0(String rtuAddr) throws Exception {
+ CommonV1_0_1 commonV1_0_1 = new CommonV1_0_1() ;
+ byte[] bytes ;
+ byte[] bsHead = new byte[ProtocolConstantV206V1_0_0.lenHead2Code] ;
+ byte index = 0 ;
+ bsHead[index] = ProtocolConstantV206V1_0_0.P_Head_Byte ;
+
+ index++ ;
+ bsHead[index] = 0 ;//甯ч暱搴�
+
+ index++ ;
+ bsHead[index] = ProtocolConstantV206V1_0_0.P_Head_Byte ;
+
+ index++ ;
+ bsHead[index] = commonV1_0_1.createCtrl((byte)0x80, (byte)3) ;//鎺у埗鍩熷姛鑳界爜3锛氳嚜鎶ュ抚锛屾祦閲忥紙姘撮噺锛夊弬鏁�
+
+ index++ ;
+ GlCreate.createRtuAddr(rtuAddr, bsHead, index);
+ index += 5 ;
+
+ ByteUtil.hex2Bytes("C0", bsHead, index) ;
+
+ byte[] bs = new byte[2] ;
+ bs[0] = (byte)0x04 ;//鏈夋祦閲忔暟鎹�
+ bs[1] = (byte)0xE0 ;//鏈夋按鍘嬨�佺數姹犵數鍘嬨�佷俊鍙峰己搴�
+
+ bytes = ByteUtil.bytesMerge(bsHead, bs) ;
+
+ bs = new byte[5] ;//鐬椂娴侀噺
+ bs[0] = ByteUtil.int2BCD_LE (21)[0] ;
+ bs[1] = ByteUtil.int2BCD_LE (43)[0] ;
+ bs[2] = ByteUtil.int2BCD_LE (65)[0] ;
+ bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+ bs = new byte[5] ;//绱娴侀噺
+ bs[0] = ByteUtil.int2BCD_LE (21)[0] ;
+ bs[1] = ByteUtil.int2BCD_LE (43)[0] ;
+ bs[2] = ByteUtil.int2BCD_LE (65)[0] ;
+ bs[3] = ByteUtil.int2BCD_LE (87)[0] ;
+ bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+ bs = new byte[5] ;//鎹熷け娴侀噺
+ bs[0] = ByteUtil.int2BCD_LE (10)[0] ;
+ bs[1] = ByteUtil.int2BCD_LE (32)[0] ;
+ bs[2] = ByteUtil.int2BCD_LE (54)[0] ;
+ bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+ bs = new byte[4] ;//姘村帇
+ bs[0] = ByteUtil.int2BCD_LE (10)[0] ;
+ bs[1] = ByteUtil.int2BCD_LE (32)[0] ;
+ bs[2] = ByteUtil.int2BCD_LE (4)[0] ;
+ bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+ bs = new byte[4] ;//鐢垫睜鐢靛帇
+ bs[0] = ByteUtil.int2BCD_LE (10)[0] ;
+ bs[1] = ByteUtil.int2BCD_LE (32)[0] ;
+ bs[2] = ByteUtil.int2BCD_LE (10)[0] ;
+ bs[3] = ByteUtil.int2BCD_LE (32)[0] ;
+ bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+ bs = new byte[1] ;//淇″彿寮哄害
+ bs[0] = ByteUtil.int2BCD_LE (21)[0] ;
+ bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+ bs = new byte[6] ;//鏃堕挓
+ GlCreate.createTp(bs, 0);
+ bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+ GlCreate.createLen(bytes);//闀垮害鏀惧瓧鑺傛暟缁勪腑
+
+ byte[] bsTail = GlCreate.createCrcTail(bytes) ;//CRC鍜屽熬鍙犲姞瀛楄妭鏁扮粍涓�
+
+ bytes = ByteUtil.bytesMerge(bytes, bsTail) ;
+
+ return bytes ;
+ }
+}
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/resources/log4j2.xml b/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/resources/log4j2.xml
index 104ed67..c75e1cd 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/resources/log4j2.xml
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/resources/log4j2.xml
@@ -12,7 +12,7 @@
/logs/testJgroups.log褰撳墠杞欢鎵�鍦ㄧ‖鐩樻牴鐩綍
logs/testJgroups.log褰撳墠杞欢鎵�鍦ㄧ洰褰�
-->
- <RollingFile name="File" fileName="logs/mwTestCl.log" filePattern="logs/aepTest-%d{yyyyMMdd}-%i.log">
+ <RollingFile name="File" fileName="logs/mwTestCl.log" filePattern="logs/mwTestCl-%d{yyyyMMdd}-%i.log">
<PatternLayout charset="UTF-8" pattern="%d %-5p [%t] (%class.%method:%L) - %m%n%throwable"/>
<Policies>
<TimeBasedTriggeringPolicy interval="7" />
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/Server.java b/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/Server.java
index 04d80ad..e77a63c 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/Server.java
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/Server.java
@@ -105,8 +105,8 @@
if(txt.startsWith("0")){
throw new Exception("鍏冪礌config.base鐨勫睘鎬tuAddrStart鐨勬暟鍊间笉鑳戒互0寮�澶�!");
}
- if(txt.length() != 10){
- throw new Exception("鍏冪礌config.base鐨勫睘鎬tuAddrStart鐨勬暟鍊奸暱搴﹀繀椤讳负10浣�!");
+ if(!(txt.length() == 10 || txt.length() == 12)){
+ throw new Exception("鍏冪礌config.base鐨勫睘鎬tuAddrStart鐨勬暟鍊奸暱搴﹀繀椤讳负10浣嶆垨12浣�!");
}
ServerProperties.rtuAddrStart = Long.valueOf(txt) ;
@@ -121,8 +121,8 @@
if(txt.startsWith("0")){
throw new Exception("鍏冪礌config.base鐨勫睘鎬tuAddrEnd鐨勬暟鍊间笉鑳戒互0寮�澶�!");
}
- if(txt.length() != 10){
- throw new Exception("鍏冪礌config.base鐨勫睘鎬tuAddrEnd鐨勬暟鍊奸暱搴﹀繀椤讳负10浣�!");
+ if(!(txt.length() == 10 || txt.length() == 12)){
+ throw new Exception("鍏冪礌config.base鐨勫睘鎬tuAddrEnd鐨勬暟鍊奸暱搴﹀繀椤讳负10浣嶆垨12浣�!");
}
ServerProperties.rtuAddrEnd = Long.valueOf(txt) ;
if(ServerProperties.rtuAddrEnd <= ServerProperties.rtuAddrStart){
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/resources/log4j2.xml b/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/resources/log4j2.xml
index 6dae26f..b83fd9a 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/resources/log4j2.xml
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/resources/log4j2.xml
@@ -12,7 +12,7 @@
/logs/testJgroups.log褰撳墠杞欢鎵�鍦ㄧ‖鐩樻牴鐩綍
logs/testJgroups.log褰撳墠杞欢鎵�鍦ㄧ洰褰�
-->
- <RollingFile name="File" fileName="logs/mwTestSv.log" filePattern="logs/aepTest-%d{yyyyMMdd}-%i.log">
+ <RollingFile name="File" fileName="logs/mwTestSv.log" filePattern="logs/mwTestSv-%d{yyyyMMdd}-%i.log">
<PatternLayout charset="UTF-8" pattern="%d %-5p [%t] (%class.%method:%L) - %m%n%throwable"/>
<Policies>
<TimeBasedTriggeringPolicy interval="7" />
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/java/com/dy/pipIrrMwTestRtu/AdapterImp_TcpClUnit.java b/pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/java/com/dy/pipIrrMwTestRtu/AdapterImp_TcpClUnit.java
new file mode 100644
index 0000000..e693023
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/java/com/dy/pipIrrMwTestRtu/AdapterImp_TcpClUnit.java
@@ -0,0 +1,19 @@
+package com.dy.pipIrrMwTestRtu;
+
+import com.dy.pipIrrMwTestRtu.tcpClient.TcpClUnitAdapter;
+import com.dy.pipIrrMwTestRtu.tcpClient.TcpClUnitConfigVo;
+
+
+public class AdapterImp_TcpClUnit implements TcpClUnitAdapter {
+
+ private TcpClUnitConfigVo configVo ;
+
+ public TcpClUnitConfigVo getConfig() {
+ return configVo;
+ }
+
+ public void setConfig(TcpClUnitConfigVo configVo){
+ this.configVo = configVo ;
+ }
+
+}
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/java/com/dy/pipIrrMwTestRtu/tcpClient/LocalCodecFactory.java b/pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/java/com/dy/pipIrrMwTestRtu/tcpClient/LocalCodecFactory.java
new file mode 100644
index 0000000..47af50b
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/java/com/dy/pipIrrMwTestRtu/tcpClient/LocalCodecFactory.java
@@ -0,0 +1,35 @@
+package com.dy.pipIrrMwTestRtu.tcpClient;
+
+import org.apache.mina.core.session.IoSession;
+import org.apache.mina.filter.codec.ProtocolCodecFactory;
+import org.apache.mina.filter.codec.ProtocolDecoder;
+import org.apache.mina.filter.codec.ProtocolEncoder;
+
+public class LocalCodecFactory implements ProtocolCodecFactory {
+ private ProtocolEncoder encoder;
+ private ProtocolDecoder decoder;
+
+ public LocalCodecFactory() {
+ encoder = new LocalEncoder();
+ decoder = new LocalDecoder();
+ }
+
+ /**
+ * 寰楀埌鍗忚缂栫爜鍣�
+ * @param ioSession 缃戠粶浼氳瘽
+ * @return 鍗忚缂栫爜鍣�
+ */
+ @Override
+ public ProtocolEncoder getEncoder(IoSession ioSession) {
+ return encoder;
+ }
+ /**
+ * 寰楀埌鍗忚瑙g爜鍣�
+ * @param ioSession 缃戠粶浼氳瘽
+ * @return 鍗忚瑙g爜鍣�
+ */
+ @Override
+ public ProtocolDecoder getDecoder(IoSession ioSession) {
+ return decoder;
+ }
+}
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/java/com/dy/pipIrrMwTestRtu/tcpClient/LocalDecoder.java b/pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/java/com/dy/pipIrrMwTestRtu/tcpClient/LocalDecoder.java
new file mode 100644
index 0000000..4d89c6c
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/java/com/dy/pipIrrMwTestRtu/tcpClient/LocalDecoder.java
@@ -0,0 +1,37 @@
+package com.dy.pipIrrMwTestRtu.tcpClient;
+
+import com.dy.common.util.ByteUtil;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.mina.core.buffer.IoBuffer;
+import org.apache.mina.core.session.IoSession;
+import org.apache.mina.filter.codec.CumulativeProtocolDecoder;
+import org.apache.mina.filter.codec.ProtocolDecoderOutput;
+
+import java.io.IOException;
+
+public class LocalDecoder extends CumulativeProtocolDecoder {
+
+ private static final Logger log = LogManager.getLogger(LocalDecoder.class) ;
+
+ private static final String DECODER_STATE_KEY = LocalDecoder.class.getName() + ".STATE";
+
+ public static final int MAX_SIZE = 2147483647 ;
+
+
+ /**
+ * 瀵圭綉缁滀紶杈撴潵鐨勬暟鎹繘琛岃В鐮�
+ */
+ protected boolean doDecode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) throws IOException, Exception{
+ int remain = in.remaining() ;
+ if(remain > 0){
+ byte[] preByte = new byte[remain];
+ in.get(preByte) ;
+ in.position(0) ;
+ log.info("鏀跺埌涓績涓嬭鏁版嵁锛�" + ByteUtil.bytes2Hex(preByte, true));
+ }
+ return true;
+ }
+
+
+}
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/java/com/dy/pipIrrMwTestRtu/tcpClient/LocalEncoder.java b/pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/java/com/dy/pipIrrMwTestRtu/tcpClient/LocalEncoder.java
new file mode 100644
index 0000000..a030b2d
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/java/com/dy/pipIrrMwTestRtu/tcpClient/LocalEncoder.java
@@ -0,0 +1,27 @@
+package com.dy.pipIrrMwTestRtu.tcpClient;
+
+import com.dy.common.util.ByteUtil;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.mina.core.buffer.IoBuffer;
+import org.apache.mina.core.session.IoSession;
+import org.apache.mina.filter.codec.ProtocolEncoderAdapter;
+import org.apache.mina.filter.codec.ProtocolEncoderOutput;
+
+import java.io.IOException;
+
+public class LocalEncoder extends ProtocolEncoderAdapter {
+
+ private static final Logger log = LogManager.getLogger(LocalEncoder.class) ;
+
+ /**
+ * 瀵规暟鎹繘琛岀紪鐮侊紝浠ュ缃戠粶浼犺緭
+ */
+ public void encode(IoSession session, Object message, ProtocolEncoderOutput out) throws IOException, Exception{
+ byte[] data = (byte[])message;
+ log.info("涓嬭鏁版嵁锛�" + ByteUtil.bytes2Hex(data, true));
+
+ out.write(IoBuffer.allocate((data==null?0:data.length), false).put(data).flip());
+ }
+
+}
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/java/com/dy/pipIrrMwTestRtu/tcpClient/TcpClUnitAdapter.java b/pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/java/com/dy/pipIrrMwTestRtu/tcpClient/TcpClUnitAdapter.java
new file mode 100644
index 0000000..20eaecb
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/java/com/dy/pipIrrMwTestRtu/tcpClient/TcpClUnitAdapter.java
@@ -0,0 +1,7 @@
+package com.dy.pipIrrMwTestRtu.tcpClient;
+
+import com.dy.common.mw.UnitAdapterInterface;
+
+public interface TcpClUnitAdapter extends UnitAdapterInterface {
+ public TcpClUnitConfigVo getConfig() ;
+}
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/java/com/dy/pipIrrMwTestRtu/tcpClient/TcpClUnitConfigVo.java b/pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/java/com/dy/pipIrrMwTestRtu/tcpClient/TcpClUnitConfigVo.java
new file mode 100644
index 0000000..96f34d8
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/java/com/dy/pipIrrMwTestRtu/tcpClient/TcpClUnitConfigVo.java
@@ -0,0 +1,6 @@
+package com.dy.pipIrrMwTestRtu.tcpClient;
+
+public class TcpClUnitConfigVo {
+ public String mwServerIp ;
+ public Integer mwServerPort ;
+}
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/java/com/dy/pipIrrMwTestRtu/tcpClient/TcpConnect.java b/pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/java/com/dy/pipIrrMwTestRtu/tcpClient/TcpConnect.java
new file mode 100644
index 0000000..be55666
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/java/com/dy/pipIrrMwTestRtu/tcpClient/TcpConnect.java
@@ -0,0 +1,62 @@
+package com.dy.pipIrrMwTestRtu.tcpClient;
+
+import com.dy.common.util.Callback;
+import org.apache.mina.core.future.ConnectFuture;
+import org.apache.mina.core.session.IoSession;
+import org.apache.mina.filter.codec.ProtocolCodecFilter;
+import org.apache.mina.transport.socket.SocketConnector;
+import org.apache.mina.transport.socket.nio.NioSocketConnector;
+
+import java.net.InetSocketAddress;
+
+public class TcpConnect {
+
+ /**
+ * 鍒ゆ柇浼氳瘽鏄惁鏈夋晥
+ * @param se 缃戠粶浼氳瘽
+ * @return 鏄惁杩炴帴
+ */
+ public boolean isConnected(IoSession se) {
+ return (se != null && se.isConnected());
+ }
+
+ /**
+ * 鍒涘缓鏂颁細璇�
+ * @param host 鏈嶅姟鍣║RI
+ * @param port 鏈嶅姟鍣ㄧ鍙�
+ * @param connectTimeout 杩炴帴瓒呮椂鏃堕暱
+ * @param handler 鏁版嵁澶勭悊鑰�
+ * @param callback 鍥炶皟
+ * @return 缃戠粶浼氳瘽
+ */
+ public void createSession(String host ,
+ int port ,
+ int connectTimeout ,
+ TcpHandler handler,
+ Callback callback) throws Exception{
+ SocketConnector connector = new NioSocketConnector();
+ connector.getFilterChain().addLast("codec", new ProtocolCodecFilter(new LocalCodecFactory()));
+ connector.setHandler(handler);
+ ConnectFuture connectFuture = connector.connect(new InetSocketAddress(host, port));
+ connectFuture.awaitUninterruptibly(connectTimeout);
+ IoSession se = connectFuture.getSession();
+ callback.call(se) ;
+ }
+
+
+ /**
+ * 鍏抽棴浼氳瘽鑱旀帴
+ * @param se
+ * @param connectTimeout
+ */
+ public void disconnect(IoSession se , int connectTimeout) {
+ if (se != null) {
+ try{
+ se.closeNow().awaitUninterruptibly(connectTimeout);
+ }catch(Exception e){
+ }finally{
+ se = null;
+ }
+ }
+ }
+}
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/java/com/dy/pipIrrMwTestRtu/tcpClient/TcpHandler.java b/pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/java/com/dy/pipIrrMwTestRtu/tcpClient/TcpHandler.java
new file mode 100644
index 0000000..01c4a53
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/java/com/dy/pipIrrMwTestRtu/tcpClient/TcpHandler.java
@@ -0,0 +1,77 @@
+package com.dy.pipIrrMwTestRtu.tcpClient;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.mina.core.service.IoHandlerAdapter;
+import org.apache.mina.core.session.IdleStatus;
+import org.apache.mina.core.session.IoSession;
+import org.apache.mina.filter.FilterEvent;
+
+public class TcpHandler extends IoHandlerAdapter {
+
+ private static Logger log = LogManager.getLogger(TcpHandler.class.getName()) ;
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void sessionCreated(IoSession session) throws Exception {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void sessionOpened(IoSession session) throws Exception {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void sessionClosed(IoSession session) throws Exception {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void sessionIdle(IoSession session, IdleStatus status) throws Exception {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void exceptionCaught(IoSession session, Throwable cause) throws Exception {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void messageReceived(IoSession session, Object message) throws Exception {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void messageSent(IoSession session, Object message) throws Exception {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void inputClosed(IoSession session) throws Exception {
+ session.closeNow();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void event(IoSession session, FilterEvent event) throws Exception {
+ }
+}
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/resources/Config.xml b/pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/resources/Config.xml
new file mode 100644
index 0000000..b35e39d
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/resources/Config.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<config>
+ <server name="RTU妯℃嫙" showStartInfo="true" company="http://www.dyjs.com"/>
+
+ <!--
+ enable:鏄惁鍚姩
+ -->
+ <tcpCl mwServerIp="127.0.0.1" mwServerPort="60000" />
+</config>
\ No newline at end of file
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/resources/application.yml b/pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/resources/application.yml
new file mode 100644
index 0000000..bf28011
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/resources/application.yml
@@ -0,0 +1,29 @@
+logging:
+ charset:
+ console: UTF-8
+ config:
+ classpath: log4j2.yml
+
+#web鏈嶅姟绔彛锛宼omcat榛樿鏄�8080
+server:
+ error:
+ whitelabel:
+ enabled: false
+ port: 65534
+ servlet:
+ context-path: /rtu #web璁块棶涓婁笅鏂囪矾寰�
+ encoding:
+ #鍙栨秷榛樿鐨勫瓧绗﹂泦缂栫爜
+ enabled: true
+ #璁剧疆寮哄埗浣跨敤鎸囧畾瀛楃缂栫爜闆�
+ force: true
+ #浣跨敤鐨勫瓧绗︾紪鐮�
+ charset: utf-8
+
+#绂佹鍚姩鏁版嵁搴撹繛鎺ユ睜
+spring:
+ #autoconfigure:
+ # exclude:
+ # - org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
+ # - org.springframework.boot.autoconfigure.jdbc.JdbcTemplateAutoConfiguration
+ # - org.springframework.boot.autoconfigure.jdbc.JndiDataSourceAutoConfiguration
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/resources/log4j2.xml b/pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/resources/log4j2.xml
new file mode 100644
index 0000000..8c46b0b
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/resources/log4j2.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Configuration status="OFF">
+ <Appenders>
+ <Console name="Console" target="SYSTEM_OUT">
+ <PatternLayout charset="GBK" pattern="%d %-5p [%t] (%F:%L) - %m%n%throwable"/>
+ </Console>
+ <!--
+ fileName="${sys:user.home}/logs/aepTest.log" filePattern="${sys:user.home}/logs/aepTest-%d{yyyy-MM}-%i.log.gz"
+ fileName="/logs/testJgroups.log" filePattern="/logs/testJgroups-%d{yyyyMMdd}-%i.log.gz"
+ fileName="logs/testJgroups.log" filePattern="logs/testJgroups-%d{yyyyMMdd}-%i.log.gz"
+ sys:user.home褰撳墠鐢ㄦ埛鍦ㄦ搷浣滅郴缁熶腑鐨勬枃妗g洰褰�
+ /logs/testJgroups.log褰撳墠杞欢鎵�鍦ㄧ‖鐩樻牴鐩綍
+ logs/testJgroups.log褰撳墠杞欢鎵�鍦ㄧ洰褰�
+ -->
+ <RollingFile name="File" fileName="logs/mwRtu.log" filePattern="logs/mwRtu-%d{yyyyMMdd}-%i.log">
+ <PatternLayout charset="UTF-8" pattern="%d %-5p [%t] (%class.%method:%L) - %m%n%throwable"/>
+ <Policies>
+ <TimeBasedTriggeringPolicy interval="7" />
+ <SizeBasedTriggeringPolicy size="10MB"/>
+ </Policies>
+ <DefaultRolloverStrategy max="50" />
+ </RollingFile>
+ </Appenders>
+ <Loggers>
+ <!--
+ <Logger name="com.zhzc.jgTest" level="debug">
+ <AppenderRef ref="Console"/>
+ </Logger>
+ <Logger name="org.jgroups" level="info">
+ <AppenderRef ref="File"/>
+ </Logger>
+ -->
+ <!-- Root涓庡悇涓狶ogger鍚屾椂璧蜂綔鐢� -->
+ <Root level="info">
+ <AppenderRef ref="Console"/>
+ <AppenderRef ref="File"/>
+ </Root>
+ </Loggers>
+</Configuration>
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/pom.xml b/pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/pom.xml
index be397d1..291a9ef 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/pom.xml
+++ b/pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/pom.xml
@@ -13,7 +13,7 @@
<packaging>jar</packaging>
<artifactId>pipIrr-mwTest-web</artifactId>
<version>1.0.0</version>
- <name>pipIrr-mw-rtu</name>
+ <name>pipIrr-mwTest-web</name>
<description>閫氫俊涓棿浠朵腑蹇冩湇鍔$涓嬪彂鍛戒护娴嬭瘯</description>
<dependencies>
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/src/main/java/com/dy/pipIrrMwTestWeb/PipIrrMwTestWebApplication.java b/pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/src/main/java/com/dy/pipIrrMwTestWeb/PipIrrMwTestWebApplication.java
index 7a6aef6..ad39965 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/src/main/java/com/dy/pipIrrMwTestWeb/PipIrrMwTestWebApplication.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-mwTest-web/src/main/java/com/dy/pipIrrMwTestWeb/PipIrrMwTestWebApplication.java
@@ -28,9 +28,6 @@
)
public class PipIrrMwTestWebApplication{
- @Autowired
- private CommandP206V202404Ctrl test ;
-
public static void main(String[] args) {
SpringApplication.run(PipIrrMwTestWebApplication.class, args);
}
diff --git a/pipIrr-platform/pipIrr-web/pom.xml b/pipIrr-platform/pipIrr-web/pom.xml
index ef476fa..abd60b2 100644
--- a/pipIrr-platform/pipIrr-web/pom.xml
+++ b/pipIrr-platform/pipIrr-web/pom.xml
@@ -18,6 +18,7 @@
<description>姝ゆā鍧椾负鍏朵粬web妯″潡鐨勫眬閮ㄥ叏灞�妯″潡锛屽彧瀹氫箟渚濊禆</description>
<modules>
+ <module>pipIrr-mwTest-rtu</module>
<module>pipIrr-mwTest-web</module>
<module>pipIrr-web-sso</module>
<module>pipIrr-web-base</module>
--
Gitblit v1.8.0