Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV
	
		
		20个文件已删除
	
		
		17 文件已重命名
	
		
		49个文件已修改
	
		
		13个文件已添加
	
	
 
	
	
	
	
	
	
	
	
|  |  |  | 
|---|
|  |  |  | *     org.apache.mina.filter.codec.ProtocolDecoderOutput) | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | protected boolean doDecode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) { | 
|---|
|  |  |  | String meterNo = (String)session.getAttribute(TcpIoSessionAttrIdIsRtuAddr.sessionArrIdKey) ; | 
|---|
|  |  |  | if(meterNo == null){ | 
|---|
|  |  |  | String rtuAddr = (String)session.getAttribute(TcpIoSessionAttrIdIsRtuAddr.sessionArrIdKey) ; | 
|---|
|  |  |  | if(rtuAddr == null){ | 
|---|
|  |  |  | //ä¼è¯æªè¢«ç®¡ç | 
|---|
|  |  |  | //ä¼è¯ç®¡çå¨ä¸ä¸å卿¤ä¼è¯ï¼è¯´æå建ç«ç½ç»è¿æ¥ï¼ | 
|---|
|  |  |  | return this.doDecode_onLineData(session, in, out) ; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | //ä¼è¯å·²è¢«ç®¡ç | 
|---|
|  |  |  | //ä¼è¯ç®¡çå¨ä¸å卿¤ä¼è¯ï¼è¯´æå·²ç»ä¸çº¿äºï¼ | 
|---|
|  |  |  | return this.doDecode_data(session, in, out, meterNo) ; | 
|---|
|  |  |  | return this.doDecode_data(session, in, out, rtuAddr) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | * @param session IOä¼è¯ | 
|---|
|  |  |  | * @param in è¾å
¥Buffer | 
|---|
|  |  |  | * @param out åè®®è¾åºç¼ç  | 
|---|
|  |  |  | * @param meterNo æ§å¶å¨ç¼å· | 
|---|
|  |  |  | * @param rtuAddr æ§å¶å¨å°å | 
|---|
|  |  |  | * @return æ¯å¦æ£å¥½æç²å | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @SuppressWarnings("unused") | 
|---|
|  |  |  | private boolean doDecode_data(IoSession session, IoBuffer in, ProtocolDecoderOutput out, String meterNo) { | 
|---|
|  |  |  | private boolean doDecode_data(IoSession session, IoBuffer in, ProtocolDecoderOutput out, String rtuAddr) { | 
|---|
|  |  |  | //éä¸çº¿æ°æ®ï¼å¯è½ä¼åºç°æå
æç²å
ç°è±¡ | 
|---|
|  |  |  | PrefixedDataAvailableStatus dataStatus = this.pdaHandle.forUpData(in) ; | 
|---|
|  |  |  | if(dataStatus == null){ | 
|---|
|  |  |  | //ä¸å¯è½åç | 
|---|
|  |  |  | log.error("严éé误ï¼Rtu (水表å·ä¸º" + meterNo + ")ä¸è¡æ°æ®å®æ´æ§æ£æ¥æ¶ï¼è¿åç对象为空ã") ; | 
|---|
|  |  |  | log.error("严éé误ï¼Rtu (RTU" + rtuAddr + ")ä¸è¡æ°æ®å®æ´æ§æ£æ¥æ¶ï¼è¿åç对象为空ã") ; | 
|---|
|  |  |  | this.nextDeal(in, null, out) ; | 
|---|
|  |  |  | return true; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | 
|---|
|  |  |  | this.nextDeal(in, dataStatus.getDataLen(), out) ; | 
|---|
|  |  |  | if(dataStatus.isAdjoined()){ | 
|---|
|  |  |  | //说æç²å
äºï¼è¿ææ°æ®ï¼éè¦å¯¹è¿äºæ°æ®å次æ§è¡doDecode_æ¹æ³. | 
|---|
|  |  |  | return this.doDecode_data(session, in, out, meterNo) ;//å ä¸éå½ | 
|---|
|  |  |  | return this.doDecode_data(session, in, out, rtuAddr) ;//å ä¸éå½ | 
|---|
|  |  |  | }else if(dataStatus.isCompleted()){ | 
|---|
|  |  |  | //æ°æ®ä¸æä¸ç² | 
|---|
|  |  |  | return true; | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return this ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | /* | 
|---|
|  |  |  | public static void main(String[] args){ | 
|---|
|  |  |  | String json = "{\"attachment\":null,\"code\":\"03\",\"deviceId\":\"d8c9601f214747d98d47a4736e5\",\"id\":\"999999999\",\"meterNo\":\"23040600377\",\"productId\":16873252,\"param\":\"0002\",\"protocol\":\"HAC_NBhV2_5\",\"rtuAddr\":\"863318060168996\",\"type\":\"outerCommand\"}" ; | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | Command com = jsonToObject(json) ; | 
|---|
|  |  |  | System.out.println(com.param); | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | */ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public String getId() { | 
|---|
|  |  |  | return id; | 
|---|
|  |  |  | 
|---|
|  |  |  | Data d = new Data() ; | 
|---|
|  |  |  | d.code = "01" ; | 
|---|
|  |  |  | d.rtuAddr = "123234" ; | 
|---|
|  |  |  | d.meterNo = "1234567890123456" ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | DataV1_0_1 subD = new DataV1_0_1() ; | 
|---|
|  |  |  | subD.rtuAddr = "2342345" ; | 
|---|
|  |  |  | subD.meterNo = "1234567890123456" ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | d.subData = subD ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.dy.common.util.ByteUtil; | 
|---|
|  |  |  | import com.dy.common.util.ByteUtilUnsigned; | 
|---|
|  |  |  | import com.dy.common.util.CRC8_for_2_0; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public class CommonV1_0_1 { | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * åææ°æ®åèæ° | 
|---|
|  |  |  | * åæå¸§é¿åº¦ | 
|---|
|  |  |  | * @param bs ä¸è¡åèæ°ç» | 
|---|
|  |  |  | * @return æ°æ®é¿åº¦ | 
|---|
|  |  |  | * @throws Exception å¼å¸¸ | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public int parseFrameLen(byte[] bs)throws Exception{ | 
|---|
|  |  |  | int len = ByteUtilUnsigned.byte2Byte(bs, ProtocolConstantV206V1_0_0.dataLenIndex) ; | 
|---|
|  |  |  | return len + ProtocolConstantV206V1_0_0.lenHead2ctrl + ProtocolConstantV206V1_0_0.lenTail ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * åæç¨æ·æ°æ®ååèæ° | 
|---|
|  |  |  | * @param bs ä¸è¡åèæ°ç» | 
|---|
|  |  |  | * @return æ°æ®é¿åº¦ | 
|---|
|  |  |  | * @throws Exception å¼å¸¸ | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public int parseDataLen(byte[] bs)throws Exception{ | 
|---|
|  |  |  | return ByteUtilUnsigned.bytes2Short_BE(bs, ProtocolConstantV206V1_0_0.dataLenIndex) ; | 
|---|
|  |  |  | int len = ByteUtilUnsigned.byte2Byte(bs, ProtocolConstantV206V1_0_0.dataLenIndex) ; | 
|---|
|  |  |  | return len + ProtocolConstantV206V1_0_0.lenHead2ctrl + ProtocolConstantV206V1_0_0.lenTail ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | public String parseRtuAddr(byte[] bs)throws Exception{ | 
|---|
|  |  |  | String rtuAddrBCD = "" + ByteUtil.BCD2Long_BE(bs, ProtocolConstantV206V1_0_0.rtuAddr1Index_start, ProtocolConstantV206V1_0_0.rtuAddr1Index_end) ; | 
|---|
|  |  |  | String rtuAddrStr = "" + ByteUtilUnsigned.bytes2Short_BE(bs, ProtocolConstantV206V1_0_0.rtuAddr2Index_start) ; | 
|---|
|  |  |  | while(rtuAddrStr.length() < 6){ | 
|---|
|  |  |  | while(rtuAddrStr.length() < 4){ | 
|---|
|  |  |  | rtuAddrStr = "0" + rtuAddrStr ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return rtuAddrBCD + rtuAddrStr ; | 
|---|
|  |  |  | 
|---|
|  |  |  | return ByteUtil.bytes2Hex(bs, false, ProtocolConstantV206V1_0_0.codeIndex, 1) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * æ ¡éªåæ£æ¥ | 
|---|
|  |  |  | * @param bs ä¸è¡åèæ°ç» | 
|---|
|  |  |  | * @return éè¿true,æªéè¿false | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public boolean checkCrc(byte[] bs) { | 
|---|
|  |  |  | byte he = 0 ; | 
|---|
|  |  |  | for(int i = 0 ; i <= bs.length - 3 ; i++){ | 
|---|
|  |  |  | he = (byte)(he + bs[i]) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return bs[bs.length - 2] == he ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * æ ¡éªåæ£æ¥ | 
|---|
|  |  |  | * @param bs  ä¸è¡åèæ°ç» | 
|---|
|  |  |  | 
|---|
|  |  |  | * @throws Exception å¼å¸¸ | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public String checkCrc_str(byte[] bs) throws Exception { | 
|---|
|  |  |  | byte[] he = new byte[1] ; | 
|---|
|  |  |  | for(int i = 0 ; i <= bs.length - 3 ; i++){ | 
|---|
|  |  |  | he[0] = (byte)(he[0] + bs[i]) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | short hes = ByteUtilUnsigned.byte2Byte(he, 0); | 
|---|
|  |  |  | short heOrg = ByteUtilUnsigned.byte2Byte(bs, bs.length - 2); | 
|---|
|  |  |  | if(hes == heOrg){ | 
|---|
|  |  |  | byte crcCompute = (byte)new CRC8_for_2_0().CRC8(bs, ProtocolConstantV206V1_0_0.ctrlIndex, bs.length - 3) ; | 
|---|
|  |  |  | byte crcInBs = bs[bs.length - 2] ; | 
|---|
|  |  |  | if(crcCompute == crcInBs){ | 
|---|
|  |  |  | return null ; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | return "è®¡ç®æ ¡éªåæ¯:" + hes + "ï¼ä¸ä¼ æ ¡éªåæ¯" + heOrg ; | 
|---|
|  |  |  | return "计ç®CRCæ¯:" + crcCompute + "ï¼ä¸ä¼ CRCæ¯" + crcInBs ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | D7                  D6                  D5ï½D4            D3ï½D0 | 
|---|
|  |  |  | ä¼ è¾æ¹åä½ DIR        æåæ å¿ä½ DIV       å¸§è®¡æ°ä½ FCB       åè½ç  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public byte createCtrl(byte funcCode){ | 
|---|
|  |  |  | byte b = 0 ; | 
|---|
|  |  |  | public byte createCtrl(byte dir, byte funcCode){ | 
|---|
|  |  |  | byte b = dir;//(byte)0x80//æ§å¶åï¼DIR=1ï¼è¡¨ç¤ºæ¤å¸§æ¥ææ¯ç±ç»ç«¯ååºçä¸è¡æ¥æï¼ | 
|---|
|  |  |  | b = (byte)(b | funcCode) ; | 
|---|
|  |  |  | //FCB == 3 | 
|---|
|  |  |  | b = (byte)(b | (byte)60) ; | 
|---|
|  |  |  | b = (byte)(b | (byte)0x18) ; | 
|---|
|  |  |  | //DIV = 0 | 
|---|
|  |  |  | //DIR = 0 | 
|---|
|  |  |  | return b ; | 
|---|
|  |  |  | 
|---|
|  |  |  | sb.append("      æ§å¶å¨æ¶éï¼"); | 
|---|
|  |  |  | sb.append(rtuDt==null?"":rtuDt); | 
|---|
|  |  |  | sb.append("\n"); | 
|---|
|  |  |  | sb.append(alarmVo==null?"":alarmVo.toString()); | 
|---|
|  |  |  | if(alarmVo != null){ | 
|---|
|  |  |  | sb.append(alarmVo.toString()); | 
|---|
|  |  |  | sb.append("\n"); | 
|---|
|  |  |  | sb.append(stateVo==null?"":stateVo.toString()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(stateVo != null){ | 
|---|
|  |  |  | sb.append(stateVo.toString()); | 
|---|
|  |  |  | sb.append("\n"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return sb.toString() ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | if(dataCd02Vo != null){ | 
|---|
|  |  |  | sb.append(dataCd02Vo.toString()) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(dataCdC0Vo != null){ | 
|---|
|  |  |  | sb.append(dataCdC0Vo.toString()) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(dataCd83OpenVo != null){ | 
|---|
|  |  |  | sb.append(dataCd83OpenVo.toString()) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(dataCd83CloseVo != null){ | 
|---|
|  |  |  | sb.append(dataCd83CloseVo.toString()) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(dataCd84Vo != null){ | 
|---|
|  |  |  | sb.append(dataCd84Vo.toString()) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(dataCd71Vo != null){ | 
|---|
|  |  |  | sb.append(dataCd71Vo.toString()) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return sb.toString() ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | @AnnotationDriver(name= ProtocolConstantV206V1_0_0.protocolName) | 
|---|
|  |  |  | public class DriverV1_0_1 extends Driver { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private static String scanRootPackage = "" ; | 
|---|
|  |  |  | private static String scanRootPackage = "com.dy.common.mw.protocol.p206V1_0_0." ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //å¨Driver䏿¯åä¾ï¼éDriverçåä¾å¯¹è±¡å¨å线ç¨ä¸è¿è¡ | 
|---|
|  |  |  | private ParseParamsForUpV1_0_1 upCpParams ; | 
|---|
|  |  |  | 
|---|
|  |  |  | return null ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Integer dataLen = parseCommon.parseDataLen(preByte) ; | 
|---|
|  |  |  | Integer dataLen = parseCommon.parseFrameLen(preByte) ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(dataLen == null){ | 
|---|
|  |  |  | String headHex = ByteUtil.bytes2Hex(preByte, true) ; | 
|---|
|  |  |  | 
|---|
|  |  |  | * RTUä¸çº¿æ°æ®ï¼ä¸çº¿å第ä¸å
æ°æ®ï¼æå°é¿åº¦ï¼è®¾ç½®è¯¥å±æ§ä»¥å¤è¿è¡å®æ´æ§æ£æ¥ï¼ | 
|---|
|  |  |  | * å³æå
æ£æ¥ï¼ä½¿å°½å¯è½æ¶å
¨ä¸çº¿æ°æ®ï¼åå¼èå´1-100ï¼ | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public static final int onLineDataMinLength = 30 ;//éç¨éæ§åæ§ï¼å
¶é¿åº¦æçï¼çåèæ° | 
|---|
|  |  |  | public static final int onLineDataMinLength = 13 ;//éç¨å¿è·³ä¸è¡æ°æ®é¿åº¦ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * RTU䏿¥æ°æ®ç头鍿å°é¿åº¦ï¼ä¸æ¥æ°æ®ä¸ï¼åè¿ä¸ªæå°é¿åº¦çé¨åæ°æ®ä¸ï¼ | 
|---|
|  |  |  | 
|---|
|  |  |  | public static final String P_Head_Hex = "68" ; | 
|---|
|  |  |  | public static final String P_Tail_Hex = "16" ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static final byte lenHead2Code = 10 ; //ä»å¤´å°åè½ç åèæ°ç»é¿åº¦ | 
|---|
|  |  |  | public static final byte lenHead2ctrl = 3 ; //ä»å¤´å°æ§å¶åï¼ä¸å
æ¬ï¼åèæ°ç»é¿åº¦ | 
|---|
|  |  |  | public static final byte lenHead2Code = 10 ; //ä»å¤´å°åè½ç ï¼å
æ¬ï¼åèæ°ç»é¿åº¦ | 
|---|
|  |  |  | public static final byte lenTail = 2 ; //帧尾é¨åèæ°ç»é¿åº¦ | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * æå¨åèæ°ç»çä½ç½®ï¼ä¸æ ï¼ | 
|---|
|  |  |  | 
|---|
|  |  |  | bsHead[index] = ProtocolConstantV206V1_0_0.P_Head_Byte ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | index++ ; | 
|---|
|  |  |  | bsHead[index] = commonV1_0_1.createCtrl((byte)0) ; | 
|---|
|  |  |  | bsHead[index] = commonV1_0_1.createCtrl((byte)0, (byte)0) ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | index++ ; | 
|---|
|  |  |  | GlCreate.createRtuAddr(para.rtuAddr, bsHead, index); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | GlCreate.createLen(bytes);//é¿åº¦æ¾åèæ°ç»ä¸ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | bytes = GlCreate.createCrcTail(bytes) ;//CRCåå°¾å å åèæ°ç»ä¸ | 
|---|
|  |  |  | byte[] bsTail = GlCreate.createCrcTail(bytes) ;//CRCåå°¾å å åèæ°ç»ä¸ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | bytes = ByteUtil.bytesMerge(bytes, bsTail) ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return bytes ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | bsHead[index] = ProtocolConstantV206V1_0_0.P_Head_Byte ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | index++ ; | 
|---|
|  |  |  | bsHead[index] = commonV1_0_1.createCtrl((byte)0) ; | 
|---|
|  |  |  | bsHead[index] = commonV1_0_1.createCtrl((byte)0, (byte)0) ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | index++ ; | 
|---|
|  |  |  | GlCreate.createRtuAddr(para.rtuAddr, bsHead, index); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | GlCreate.createLen(bytes);//é¿åº¦æ¾åèæ°ç»ä¸ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | bytes = GlCreate.createCrcTail(bytes) ;//CRCåå°¾å å åèæ°ç»ä¸ | 
|---|
|  |  |  | byte[] bsTail = GlCreate.createCrcTail(bytes) ;//CRCåå°¾å å åèæ°ç»ä¸ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | bytes = ByteUtil.bytesMerge(bytes, bsTail) ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return bytes ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | bsHead[index] = ProtocolConstantV206V1_0_0.P_Head_Byte ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | index++ ; | 
|---|
|  |  |  | bsHead[index] = commonV1_0_1.createCtrl((byte)0) ; | 
|---|
|  |  |  | bsHead[index] = commonV1_0_1.createCtrl((byte)0, (byte)0) ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | index++ ; | 
|---|
|  |  |  | GlCreate.createRtuAddr(para.rtuAddr, bsHead, index); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | GlCreate.createLen(bytes);//é¿åº¦æ¾åèæ°ç»ä¸ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | bytes = GlCreate.createCrcTail(bytes) ;//CRCåå°¾å å åèæ°ç»ä¸ | 
|---|
|  |  |  | byte[] bsTail = GlCreate.createCrcTail(bytes) ;//CRCåå°¾å å åèæ°ç»ä¸ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | bytes = ByteUtil.bytesMerge(bytes, bsTail) ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return bytes ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | bsHead[index] = ProtocolConstantV206V1_0_0.P_Head_Byte ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | index++ ; | 
|---|
|  |  |  | bsHead[index] = commonV1_0_1.createCtrl((byte)0) ; | 
|---|
|  |  |  | bsHead[index] = commonV1_0_1.createCtrl((byte)0, (byte)0) ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | index++ ; | 
|---|
|  |  |  | GlCreate.createRtuAddr(para.rtuAddr, bsHead, index); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | GlCreate.createLen(bytes);//é¿åº¦æ¾åèæ°ç»ä¸ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | bytes = GlCreate.createCrcTail(bytes) ;//CRCåå°¾å å åèæ°ç»ä¸ | 
|---|
|  |  |  | byte[] bsTail = GlCreate.createCrcTail(bytes) ;//CRCåå°¾å å åèæ°ç»ä¸ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | bytes = ByteUtil.bytesMerge(bytes, bsTail) ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return bytes ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | bsHead[index] = ProtocolConstantV206V1_0_0.P_Head_Byte ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | index++ ; | 
|---|
|  |  |  | bsHead[index] = commonV1_0_1.createCtrl((byte)0) ; | 
|---|
|  |  |  | bsHead[index] = commonV1_0_1.createCtrl((byte)0, (byte)0) ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | index++ ; | 
|---|
|  |  |  | GlCreate.createRtuAddr(para.rtuAddr, bsHead, index); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | GlCreate.createLen(bytes);//é¿åº¦æ¾åèæ°ç»ä¸ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | bytes = GlCreate.createCrcTail(bytes) ;//CRCåå°¾å å åèæ°ç»ä¸ | 
|---|
|  |  |  | byte[] bsTail = GlCreate.createCrcTail(bytes) ;//CRCåå°¾å å åèæ°ç»ä¸ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | bytes = ByteUtil.bytesMerge(bytes, bsTail) ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return bytes ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | String rtuAddr1 = rtuAddr.substring(0, 6) ; | 
|---|
|  |  |  | String rtuAddr2 = rtuAddr.substring(6) ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | index++ ; | 
|---|
|  |  |  | ByteUtil.string2BCD_BE(bs, rtuAddr1, index) ; | 
|---|
|  |  |  | index += 3 ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static void createTp(byte[] bs, int index) throws Exception { | 
|---|
|  |  |  | ByteUtil.string2BCD_BE(bs, DateTime.yyMMddhhmmss(), index) ; | 
|---|
|  |  |  | ByteUtil.string2BCD_LE(bs, DateTime.yyMMddhhmmss(), index) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static void createLen(byte[] bs) throws Exception { | 
|---|
|  |  |  | int len = bs.length + ProtocolConstantV206V1_0_0.lenTail; | 
|---|
|  |  |  | bs[ProtocolConstantV206V1_0_0.dataLenIndex] = (byte)len ; | 
|---|
|  |  |  | public static void createLen(byte[] bsNoTail) throws Exception { | 
|---|
|  |  |  | int len = bsNoTail.length - ProtocolConstantV206V1_0_0.lenHead2ctrl; | 
|---|
|  |  |  | bsNoTail[ProtocolConstantV206V1_0_0.dataLenIndex] = (byte)len ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static byte[] createCrcTail(byte[] bs) throws Exception { | 
|---|
|  |  |  | int crc = new CRC8_for_2_0().CRC8(bs, ProtocolConstantV206V1_0_0.ctrlIndex, bs.length -1) ; | 
|---|
|  |  |  | bs = new byte[ProtocolConstantV206V1_0_0.lenTail] ; | 
|---|
|  |  |  | bs[0] = (byte)crc ; | 
|---|
|  |  |  | bs[1] = ProtocolConstantV206V1_0_0.P_Tail_Byte ; | 
|---|
|  |  |  | return ByteUtil.bytesMerge(bs, bs) ; | 
|---|
|  |  |  | public static byte[] createCrcTail(byte[] bsNoTail) throws Exception { | 
|---|
|  |  |  | int crc = new CRC8_for_2_0().CRC8(bsNoTail, ProtocolConstantV206V1_0_0.ctrlIndex, bsNoTail.length -1) ; | 
|---|
|  |  |  | byte[] bytes = new byte[ProtocolConstantV206V1_0_0.lenTail] ; | 
|---|
|  |  |  | bytes[0] = (byte)crc ; | 
|---|
|  |  |  | bytes[1] = ProtocolConstantV206V1_0_0.P_Tail_Byte ; | 
|---|
|  |  |  | return bytes ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | index++ ; | 
|---|
|  |  |  | dt = ByteUtil.BCD2String_BE(bs, index, index) + ":" + dt ;//å | 
|---|
|  |  |  | index++ ; | 
|---|
|  |  |  | dt = ByteUtil.BCD2String_BE(bs, index, index) + " " + dt ;//æ¶ | 
|---|
|  |  |  | dt = ByteUtil.BCD2String_BE(bs, index, index) + ":" + dt ;//æ¶ | 
|---|
|  |  |  | index++ ; | 
|---|
|  |  |  | dt = ByteUtil.BCD2String_BE(bs, index, index) + "-" + dt ;//æ¥ | 
|---|
|  |  |  | dt = ByteUtil.BCD2String_BE(bs, index, index) + " " + dt ;//æ¥ | 
|---|
|  |  |  | index++ ; | 
|---|
|  |  |  | bs[index] = (byte)(bs[index] & 0x10); | 
|---|
|  |  |  | dt = ByteUtil.BCD2String_BE(bs, index, index) + "-" + dt ;//æ | 
|---|
|  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * æ¥å¿ | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private Logger log = LogManager.getLogger(MonitorThread.class.getName()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private static final Logger log = LogManager.getLogger(MonitorThread.class) ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * çº¿ç¨æ± æé æ¹æ³ | 
|---|
|  |  |  | 
|---|
|  |  |  | HELP.md | 
|---|
|  |  |  | target/ | 
|---|
|  |  |  | /pipIrr-mw.iml | 
|---|
|  |  |  | !.mvn/wrapper/maven-wrapper.jar | 
|---|
|  |  |  | !**/src/main/**/target/ | 
|---|
|  |  |  | !**/src/test/**/target/ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ### STS ### | 
|---|
|  |  |  | .apt_generated | 
|---|
|  |  |  | .classpath | 
|---|
|  |  |  | .factorypath | 
|---|
|  |  |  | .project | 
|---|
|  |  |  | .settings | 
|---|
|  |  |  | .springBeans | 
|---|
|  |  |  | .sts4-cache | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ### IntelliJ IDEA ### | 
|---|
|  |  |  | .idea | 
|---|
|  |  |  | *.iws | 
|---|
|  |  |  | *.iml | 
|---|
|  |  |  | *.ipr | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ### NetBeans ### | 
|---|
|  |  |  | /nbproject/private/ | 
|---|
|  |  |  | /nbbuild/ | 
|---|
|  |  |  | /dist/ | 
|---|
|  |  |  | /nbdist/ | 
|---|
|  |  |  | /.nb-gradle/ | 
|---|
|  |  |  | build/ | 
|---|
|  |  |  | !**/src/main/**/build/ | 
|---|
|  |  |  | !**/src/test/**/build/ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ### VS Code ### | 
|---|
|  |  |  | .vscode/ | 
|---|
|  |  |  | 
|---|
|  |  |  | <scope>test</scope> | 
|---|
|  |  |  | </dependency> | 
|---|
|  |  |  | </dependencies> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <build> | 
|---|
|  |  |  | <plugins> | 
|---|
|  |  |  | <!-- çæä¸å
å«ä¾èµjarç坿§è¡jarå | 
|---|
|  |  |  | <plugin> | 
|---|
|  |  |  | !- spring bootæä¾çmavenæå
æä»¶ - | 
|---|
|  |  |  | <groupId>org.springframework.boot</groupId> | 
|---|
|  |  |  | <artifactId>spring-boot-maven-plugin</artifactId> | 
|---|
|  |  |  | <executions> | 
|---|
|  |  |  | <execution> | 
|---|
|  |  |  | !- | 
|---|
|  |  |  | <goals> | 
|---|
|  |  |  | <goal>repackage</goal> | 
|---|
|  |  |  | </goals> | 
|---|
|  |  |  | - | 
|---|
|  |  |  | <configuration> | 
|---|
|  |  |  | !- ä¸å çè¯æç»å
å为: ${artifactId}-${version}.jar, å äºçè¯æç»å
å: ${artifactId}-${version}-${classifier}.jar  - | 
|---|
|  |  |  | <classifier>execute</classifier> | 
|---|
|  |  |  | !- ä¸æå®çæè·¯å¾çè¯, é»è®¤ä¿å娠${build.directory} ä¸ - | 
|---|
|  |  |  | <outputDirectory>${project.build.directory}/execute</outputDirectory> | 
|---|
|  |  |  | <finalName>${artifactId}-${version}</finalName> | 
|---|
|  |  |  | <layout>ZIP</layout> | 
|---|
|  |  |  | <mainClass>com.dy.pipIrrBase.PipIrrBaseApplication</mainClass> | 
|---|
|  |  |  | <includes> | 
|---|
|  |  |  | <include> | 
|---|
|  |  |  | <groupId>com.dy</groupId> | 
|---|
|  |  |  | <artifactId>pipIrr-common</artifactId> | 
|---|
|  |  |  | </include> | 
|---|
|  |  |  | <include> | 
|---|
|  |  |  | <groupId>com.dy</groupId> | 
|---|
|  |  |  | <artifactId>pipIrr-global</artifactId> | 
|---|
|  |  |  | </include> | 
|---|
|  |  |  | </includes> | 
|---|
|  |  |  | <excludes> | 
|---|
|  |  |  | <exclude> | 
|---|
|  |  |  | <groupId>org.projectlombok</groupId> | 
|---|
|  |  |  | <artifactId>lombok</artifactId> | 
|---|
|  |  |  | </exclude> | 
|---|
|  |  |  | </excludes> | 
|---|
|  |  |  | </configuration> | 
|---|
|  |  |  | </execution> | 
|---|
|  |  |  | </executions> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | </plugin> | 
|---|
|  |  |  | --> | 
|---|
|  |  |  | <!-- æ·è´ä¾èµçjarå
å°libç®å½--> | 
|---|
|  |  |  | <plugin> | 
|---|
|  |  |  | <groupId>org.springframework.boot</groupId> | 
|---|
|  |  |  | <artifactId>spring-boot-maven-plugin</artifactId> | 
|---|
|  |  |  | <executions> | 
|---|
|  |  |  | <execution> | 
|---|
|  |  |  | <configuration> | 
|---|
|  |  |  | <!-- ä¸å çè¯æç»å
å为: ${artifactId}-${version}.jar, å äºçè¯æç»å
å: ${artifactId}-${version}-${classifier}.jar | 
|---|
|  |  |  | <classifier>execute</classifier> | 
|---|
|  |  |  | --> | 
|---|
|  |  |  | <!-- ${project.build.directory}æ¯mavenåéï¼å
ç½®çï¼è¡¨ç¤ºtargetç®å½,妿ä¸åï¼å°å¨æ ¹ç®å½ä¸å建/lib --> | 
|---|
|  |  |  | <outputDirectory>${project.build.directory}/lib</outputDirectory> | 
|---|
|  |  |  | <!-- excludeTransitive:æ¯å¦ä¸å
å«é´æ¥ä¾èµå
ï¼æ¯å¦æä»¬ä¾èµAï¼ä½æ¯Aåä¾èµäºBï¼æä»¬æ¯å¦ä¹è¦æBæè¿å» é»è®¤ä¸æ--> | 
|---|
|  |  |  | <excludeTransitive>false</excludeTransitive> | 
|---|
|  |  |  | <!-- å¤å¶çjaræä»¶å»æçæ¬ä¿¡æ¯ --> | 
|---|
|  |  |  | <stripVersion>false</stripVersion> | 
|---|
|  |  |  | <finalName>${project.artifactId}-${project.version}</finalName> | 
|---|
|  |  |  | <layout>ZIP</layout> | 
|---|
|  |  |  | <mainClass>com.dy.aceMw.PipIrrMwAcceptApplication</mainClass> | 
|---|
|  |  |  | <includes> | 
|---|
|  |  |  | <include> | 
|---|
|  |  |  | <groupId>com.dy</groupId> | 
|---|
|  |  |  | <artifactId>pipIrr-common</artifactId> | 
|---|
|  |  |  | </include> | 
|---|
|  |  |  | <include> | 
|---|
|  |  |  | <groupId>com.dy</groupId> | 
|---|
|  |  |  | <artifactId>pipIrr-global</artifactId> | 
|---|
|  |  |  | </include> | 
|---|
|  |  |  | </includes> | 
|---|
|  |  |  | <excludes> | 
|---|
|  |  |  | <exclude> | 
|---|
|  |  |  | <groupId>org.projectlombok</groupId> | 
|---|
|  |  |  | <artifactId>lombok</artifactId> | 
|---|
|  |  |  | </exclude> | 
|---|
|  |  |  | </excludes> | 
|---|
|  |  |  | </configuration> | 
|---|
|  |  |  | </execution> | 
|---|
|  |  |  | </executions> | 
|---|
|  |  |  | </plugin> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <plugin> | 
|---|
|  |  |  | <!-- è®¾ç½®javaç¼è¯çæ¬ï¼è¿è¡ç¯å¢ç欠--> | 
|---|
|  |  |  | <groupId>org.apache.maven.plugins</groupId> | 
|---|
|  |  |  | <artifactId>maven-compiler-plugin</artifactId> | 
|---|
|  |  |  | <!-- sourceï¼ æºä»£ç ç¼è¯çæ¬ï¼targetï¼ ç®æ å¹³å°ç¼è¯çæ¬ï¼encodingï¼ å符éç¼ç ã --> | 
|---|
|  |  |  | <configuration> | 
|---|
|  |  |  | <source>${java.version}</source> | 
|---|
|  |  |  | <target>${java.version}</target> | 
|---|
|  |  |  | <encoding>${encoding}</encoding> | 
|---|
|  |  |  | </configuration> | 
|---|
|  |  |  | </plugin> | 
|---|
|  |  |  | <plugin> | 
|---|
|  |  |  | <!-- è§£å³èµæºæä»¶çç¼ç é®é¢ --> | 
|---|
|  |  |  | <groupId>org.apache.maven.plugins</groupId> | 
|---|
|  |  |  | <artifactId>maven-resources-plugin</artifactId> | 
|---|
|  |  |  | <configuration> | 
|---|
|  |  |  | <encoding>${encoding}</encoding> | 
|---|
|  |  |  | </configuration> | 
|---|
|  |  |  | </plugin> | 
|---|
|  |  |  | <plugin> | 
|---|
|  |  |  | <!-- mavenéæ§è¡æµè¯ç¨ä¾çæä»¶ --> | 
|---|
|  |  |  | <groupId>org.apache.maven.plugins</groupId> | 
|---|
|  |  |  | <artifactId>maven-surefire-plugin</artifactId> | 
|---|
|  |  |  | <configuration> | 
|---|
|  |  |  | <skipTests>true</skipTests> | 
|---|
|  |  |  | </configuration> | 
|---|
|  |  |  | </plugin> | 
|---|
|  |  |  | <plugin> | 
|---|
|  |  |  | <!-- ä¸é¢è§£å³ï¼å½è¿è¡Maven Lifecycle packageæ¶æ¥éï¼Could not find artifact org.apache.mina:mina-core:bundle:2.2.1 in maven (https://repo1.maven.org/maven2/)--> | 
|---|
|  |  |  | <groupId>org.apache.felix</groupId> | 
|---|
|  |  |  | <artifactId>maven-bundle-plugin</artifactId> | 
|---|
|  |  |  | <extensions>true</extensions> | 
|---|
|  |  |  | </plugin> | 
|---|
|  |  |  | </plugins> | 
|---|
|  |  |  | </build> | 
|---|
|  |  |  | </project> | 
|---|
|  |  |  | 
|---|
|  |  |  | @EnableAspectJAutoProxy | 
|---|
|  |  |  | @EnableMultiDataSource | 
|---|
|  |  |  | @ComponentScan(basePackages = {"com.dy.common", "com.dy.pipIrrGlobal", "com.dy.aceMw"}) | 
|---|
|  |  |  | @MapperScan(basePackages={"com.dy.pipIrrGlobal.daoBa"}) | 
|---|
|  |  |  | @MapperScan(basePackages={"com.dy.pipIrrGlobal.daoRm"}) | 
|---|
|  |  |  | public class PipIrrMwAcceptApplication implements CommandLineRunner { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static void main(String[] args) { | 
|---|
|  |  |  | 
|---|
|  |  |  | import java.util.ArrayList; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.dy.aceMw.server.tasks.BusiConstantTask; | 
|---|
|  |  |  | import com.dy.aceMw.server.*; | 
|---|
|  |  |  | import com.dy.aceMw.server.rtuData.RtuDataUnit; | 
|---|
|  |  |  | import com.dy.aceMw.server.rtuData.RtuDataUnitConfigVo; | 
|---|
|  |  |  | import com.dy.aceMw.server.tasks.FromRtuConstantTask; | 
|---|
|  |  |  | import com.dy.common.mw.UnitInterface; | 
|---|
|  |  |  | import com.dy.common.mw.UnitStartedCallbackInterface; | 
|---|
|  |  |  | import com.dy.common.mw.channel.rmi.RmiConfigVo; | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.dy.common.mw.protocol.ProtocolUnit; | 
|---|
|  |  |  | import com.dy.common.mw.support.SupportUnit; | 
|---|
|  |  |  | import com.dy.common.mw.support.SupportUnitConfigVo; | 
|---|
|  |  |  | import com.dy.aceMw.server.AdapterImp_CoreUnit; | 
|---|
|  |  |  | import com.dy.aceMw.server.AdapterImp_ProtocolUnit; | 
|---|
|  |  |  | import com.dy.aceMw.server.AdapterImp_RmiUnit; | 
|---|
|  |  |  | import com.dy.aceMw.server.AdapterImp_TcpUnit; | 
|---|
|  |  |  | import com.dy.aceMw.server.ServerProperties; | 
|---|
|  |  |  | import com.dy.aceMw.server.tasks.ToRtuConstantTask; | 
|---|
|  |  |  | import com.dy.aceMw.server.AdapterImp_SupportUnit; | 
|---|
|  |  |  | import com.dy.aceMw.resource.ResourceUnit; | 
|---|
|  |  |  | import com.dy.aceMw.resource.ResourceUnitConfigVo; | 
|---|
|  |  |  | import com.dy.aceMw.server.AdapterImp_ResourceUnit; | 
|---|
|  |  |  | import com.dy.common.springUtil.SpringContextUtil; | 
|---|
|  |  |  | import com.dy.common.util.ConfigXml; | 
|---|
|  |  |  | import com.dy.common.util.IDLongGenerator; | 
|---|
|  |  |  | 
|---|
|  |  |  | //TCPä¸è¡æ°æ®æ¶å»ç¼åæ¶é¿ï¼å½è¾¾å°æ¶é¿æ¶ï¼TCPä¸è¡æ°æ®æ¶å»è¢«æ¸
空ï¼éç¨TCPä¸è¡æ°æ®æ¶å»ç®çæ¯ï¼é»æ¢ä¸æ°æ®åæ¶ä¸åæ°æ®ï¼å ä¸ºRTUå¤çä¸è¿æ¥ | 
|---|
|  |  |  | ServerProperties.lastUpDataTimeLive = conf.getSetAttrPlusInt(doc, "config.base", "lastUpDataTimeLive", null, 0, 5, null) * 1000L ; | 
|---|
|  |  |  | //æ°æ®åºæ°æ®idçæå¨çidåç¼ï¼0æ¯é»è®¤çåç¼ï¼ä¸è¬webç³»ç»åºç¨ï¼æ°æ®ä¸é´ä»¶idåç¼å¤§äºçäº1 | 
|---|
|  |  |  | ServerProperties.dbDataIdSuffix = conf.getSetAttrInt(doc, "config.base", "dbDataIdSuffix", null, 1, 9, null); | 
|---|
|  |  |  | ServerProperties.dbDataIdSuffix = conf.getSetAttrInt(doc, "config.base", "dbDataIdSuffix", null, 0, 99, null); | 
|---|
|  |  |  | //ä¸ä¸è¡æ°æ®ç¼åéåä¸ç¼åæ°æ®ä¸ªæ°çæ¥è¦éï¼è¿ä¸ªä¸ç°å®é¡¹ç®ææ¥æ°´è¡¨æ°ç¸å
³ | 
|---|
|  |  |  | ServerProperties.cacheUpDownDataWarnCount = conf.getSetAttrPlusInt(doc, "config.base", "cacheUpDownDataWarnCount", null, 1, null, null) ; | 
|---|
|  |  |  | //ä¸ä¸è¡æ°æ®ç¼åéåä¸ç¼åæ°æ®ä¸ªæ°çæå¤§å¼ï¼è¿ä¸ªä¸ç°å®é¡¹ç®ææ¥æ°´è¡¨æ°ç¸å
³ | 
|---|
|  |  |  | 
|---|
|  |  |  | protoAdap.setConfig(protoVo); | 
|---|
|  |  |  | ProtocolUnit protoUnit = ProtocolUnit.getInstance(); | 
|---|
|  |  |  | protoUnit.setAdapter(protoAdap); | 
|---|
|  |  |  | protoUnit.start(new UnitStartedCallbackInterface(){ | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void call(Object obj) { | 
|---|
|  |  |  | } | 
|---|
|  |  |  | protoUnit.start(obj -> { | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | units.add(protoUnit) ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | supAdap.setConfig(supVo); | 
|---|
|  |  |  | SupportUnit supUnit = SupportUnit.getInstance() ; | 
|---|
|  |  |  | supUnit.setAdapter(supAdap); | 
|---|
|  |  |  | supUnit.start(new UnitStartedCallbackInterface(){ | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void call(Object obj) { | 
|---|
|  |  |  | } | 
|---|
|  |  |  | supUnit.start(obj -> { | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | units.add(supUnit) ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | //å½åæ¯æspring + hibernate | 
|---|
|  |  |  | resUnit.setSpringContext(SpringContextUtil.getApplicationContext()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | resUnit.start(new UnitStartedCallbackInterface(){ | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void call(Object obj) { | 
|---|
|  |  |  | } | 
|---|
|  |  |  | resUnit.start(obj -> { | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | units.add(resUnit) ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | rmiAdap.setConfig(rmiVo); | 
|---|
|  |  |  | RmiUnit rmiUnit = RmiUnit.getInstance(); | 
|---|
|  |  |  | rmiUnit.setAdapter(rmiAdap); | 
|---|
|  |  |  | rmiUnit.start(new UnitStartedCallbackInterface(){ | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void call(Object obj) { | 
|---|
|  |  |  | } | 
|---|
|  |  |  | rmiUnit.start(obj -> { | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | RmiSvUrl = "[ip]:" + rmiVo.port + "/" + rmiVo.context ; | 
|---|
|  |  |  | units.add(rmiUnit) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ///////////////// | 
|---|
|  |  |  | //RTUä¸è¡æ°æ®å¤ç模å | 
|---|
|  |  |  | RtuDataUnitConfigVo rducVo = new RtuDataUnitConfigVo(); | 
|---|
|  |  |  | AdapterImp_RtuDataUnit rducAdap = new AdapterImp_RtuDataUnit(); | 
|---|
|  |  |  | rducAdap.setConfig(rducVo); | 
|---|
|  |  |  | RtuDataUnit rducUnit = RtuDataUnit.getInstance(); | 
|---|
|  |  |  | rducUnit.setAdapter(rducAdap); | 
|---|
|  |  |  | rducUnit.start(obj -> { | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | units.add(rducUnit) ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // /////////////// | 
|---|
|  |  |  | // æ ¸å¿ | 
|---|
|  |  |  | 
|---|
|  |  |  | CoreUnit coreUnit = CoreUnit.getInstance(); | 
|---|
|  |  |  | coreUnit.setAdapter(coreAdap); | 
|---|
|  |  |  | CoreUnit.addConstantTask(new ToRtuConstantTask()); | 
|---|
|  |  |  | CoreUnit.addConstantTask(new BusiConstantTask()); | 
|---|
|  |  |  | coreUnit.start(new UnitStartedCallbackInterface(){ | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void call(Object obj) { | 
|---|
|  |  |  | } | 
|---|
|  |  |  | CoreUnit.addConstantTask(new FromRtuConstantTask()); | 
|---|
|  |  |  | coreUnit.start(obj -> { | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | units.add(coreUnit) ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | tcpAdap.setConfig(tcpVo); | 
|---|
|  |  |  | TcpUnit tcpUnit = TcpUnit.getInstance(); | 
|---|
|  |  |  | tcpUnit.setAdapter(tcpAdap); | 
|---|
|  |  |  | tcpUnit.start(new UnitStartedCallbackInterface(){ | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void call(Object obj) { | 
|---|
|  |  |  | } | 
|---|
|  |  |  | tcpUnit.start(obj -> { | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | TcpSvUrl = "[ip]:" + tcpVo.port ; | 
|---|
|  |  |  | units.add(tcpUnit) ; | 
|---|
| New file | 
|  |  |  | 
|---|
|  |  |  | package com.dy.aceMw.server; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.dy.aceMw.server.rtuData.RtuDataUnitAdapter; | 
|---|
|  |  |  | import com.dy.aceMw.server.rtuData.RtuDataUnitConfigVo; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public class AdapterImp_RtuDataUnit implements RtuDataUnitAdapter { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private RtuDataUnitConfigVo configVo ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public RtuDataUnitConfigVo getConfig() { | 
|---|
|  |  |  | return configVo; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void setConfig(RtuDataUnitConfigVo configVo){ | 
|---|
|  |  |  | this.configVo = configVo ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | package com.dy.aceMw.server.forTcp; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.dy.aceMw.server.busi.AboutRtuNode; | 
|---|
|  |  |  | import com.dy.aceMw.server.busi.TcpUpDataCache; | 
|---|
|  |  |  | import com.dy.aceMw.server.rtuData.RtuDataNode; | 
|---|
|  |  |  | import com.dy.aceMw.server.rtuData.RtuDataCache; | 
|---|
|  |  |  | import org.apache.logging.log4j.LogManager; | 
|---|
|  |  |  | import org.apache.logging.log4j.Logger; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private void nextDeal(boolean reportOrResponse_trueOrFalse, MidResultFromRtu resFromRtu){ | 
|---|
|  |  |  | try{ | 
|---|
|  |  |  | TcpUpDataCache.cacheRtuUpData(reportOrResponse_trueOrFalse, new AboutRtuNode(resFromRtu.data)); | 
|---|
|  |  |  | RtuDataCache.cacheRtuUpData(reportOrResponse_trueOrFalse, new RtuDataNode(resFromRtu.data)); | 
|---|
|  |  |  | }catch(Exception e){ | 
|---|
|  |  |  | log.error(e.getMessage(), e); | 
|---|
|  |  |  | } | 
|---|
| File was renamed from pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/busi/TcpUpDataCache.java | 
|  |  |  | 
|---|
|  |  |  | package com.dy.aceMw.server.busi; | 
|---|
|  |  |  | package com.dy.aceMw.server.rtuData; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.dy.aceMw.server.ServerProperties; | 
|---|
|  |  |  | import com.dy.common.queue.Node; | 
|---|
|  |  |  | import com.dy.common.queue.Queue; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public class TcpUpDataCache { | 
|---|
|  |  |  | public class RtuDataCache { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //TCPä¸è¡å½ä»¤ç¼åéå | 
|---|
|  |  |  | private static Queue cacheQueue = new Queue("tcpUpDataQueue") ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private static TcpUpDataCache instance = new TcpUpDataCache() ; | 
|---|
|  |  |  | private static RtuDataCache instance = new RtuDataCache() ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private TcpUpDataCache(){ | 
|---|
|  |  |  | private RtuDataCache(){ | 
|---|
|  |  |  | cacheQueue.setLimit(ServerProperties.cacheUpDownDataWarnCount, ServerProperties.cacheUpDownDataMaxCount); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static TcpUpDataCache getInstance(){ | 
|---|
|  |  |  | public static RtuDataCache getInstance(){ | 
|---|
|  |  |  | return instance ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | * @param node node | 
|---|
|  |  |  | * @throws Exception å¼å¸¸ | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public static void cacheRtuUpData(boolean reportOrResponse_trueOrFalse, AboutRtuNode node) throws Exception{ | 
|---|
|  |  |  | public static void cacheRtuUpData(boolean reportOrResponse_trueOrFalse, RtuDataNode node) throws Exception{ | 
|---|
|  |  |  | if(node != null && node.obj != null){ | 
|---|
|  |  |  | if(reportOrResponse_trueOrFalse){ | 
|---|
|  |  |  | cacheQueue.pushHead(node); | 
|---|
| File was renamed from pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/busi/AboutRtuNode.java | 
|  |  |  | 
|---|
|  |  |  | package com.dy.aceMw.server.busi; | 
|---|
|  |  |  | package com.dy.aceMw.server.rtuData; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.dy.aceMw.server.busi.deal.TaskPool; | 
|---|
|  |  |  | import com.dy.aceMw.server.busi.deal.TaskSurpport; | 
|---|
|  |  |  | import com.dy.common.queue.NodeObj; | 
|---|
|  |  |  | import com.dy.common.threadPool.ThreadPool; | 
|---|
|  |  |  | import com.dy.common.threadPool.TreadPoolFactory; | 
|---|
|  |  |  | import org.apache.logging.log4j.LogManager; | 
|---|
|  |  |  | import org.apache.logging.log4j.Logger; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public class AboutRtuNode implements NodeObj { | 
|---|
|  |  |  | public class RtuDataNode implements NodeObj { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private static final Logger log = LogManager.getLogger(AboutRtuNode.class.getName()); | 
|---|
|  |  |  | private static final Logger log = LogManager.getLogger(RtuDataNode.class.getName()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public Object obj ;//æ°æ® | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public AboutRtuNode(Object obj){ | 
|---|
|  |  |  | public RtuDataNode(Object obj){ | 
|---|
|  |  |  | this.obj = obj ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | /** | 
|---|
| New file | 
|  |  |  | 
|---|
|  |  |  | package com.dy.aceMw.server.rtuData; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.dy.common.mw.UnitAdapterInterface; | 
|---|
|  |  |  | import com.dy.common.mw.UnitInterface; | 
|---|
|  |  |  | import com.dy.common.mw.UnitStartedCallbackInterface; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public class RtuDataUnit  implements UnitInterface { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private static RtuDataUnit instance = new RtuDataUnit() ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static RtuDataUnitAdapter adapter ; | 
|---|
|  |  |  | public static RtuDataUnitConfigVo confVo ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private RtuDataUnit(){} ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static RtuDataUnit getInstance(){ | 
|---|
|  |  |  | return instance ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void setAdapter(UnitAdapterInterface adapter) throws Exception { | 
|---|
|  |  |  | if(adapter == null){ | 
|---|
|  |  |  | throw new Exception("RTUæ°æ®å¤ç模åéé
å¨å¯¹è±¡ä¸è½ä¸ºç©ºï¼") ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | RtuDataUnit.adapter = (RtuDataUnitAdapter)adapter ; | 
|---|
|  |  |  | RtuDataUnit.confVo = RtuDataUnit.adapter.getConfig() ; | 
|---|
|  |  |  | if(RtuDataUnit.confVo == null){ | 
|---|
|  |  |  | throw new Exception("RTUæ°æ®å¤ç模åé
置对象ä¸è½ä¸ºç©ºï¼") ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * åå§åä¸è¡æ°æ®å¤ç任塿± | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void start(UnitStartedCallbackInterface callback) throws Exception { | 
|---|
|  |  |  | TaskPool.setTaskTreeCofig(new TreeParse().parseConfig()); | 
|---|
|  |  |  | callback.call(null) ; | 
|---|
|  |  |  | System.out.println("RTUæ°æ®å¤ç模åæåå¯å¨"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void stop(UnitStartedCallbackInterface callback) throws Exception { | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
| New file | 
|  |  |  | 
|---|
|  |  |  | package com.dy.aceMw.server.rtuData; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.dy.common.mw.UnitAdapterInterface; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public interface RtuDataUnitAdapter extends UnitAdapterInterface { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public RtuDataUnitConfigVo getConfig() ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
| New file | 
|  |  |  | 
|---|
|  |  |  | package com.dy.aceMw.server.rtuData; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public class RtuDataUnitConfigVo { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
| File was renamed from pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/busi/deal/Task.java | 
|  |  |  | 
|---|
|  |  |  | package com.dy.aceMw.server.busi.deal; | 
|---|
|  |  |  | package com.dy.aceMw.server.rtuData; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public interface Task { | 
|---|
|  |  |  |  | 
|---|
| File was renamed from pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/busi/deal/TaskConfig.java | 
|  |  |  | 
|---|
|  |  |  | package com.dy.aceMw.server.busi.deal; | 
|---|
|  |  |  | package com.dy.aceMw.server.rtuData; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public class TaskConfig { | 
|---|
| File was renamed from pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/busi/deal/TaskPool.java | 
|  |  |  | 
|---|
|  |  |  | package com.dy.aceMw.server.busi.deal; | 
|---|
|  |  |  | package com.dy.aceMw.server.rtuData; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.ArrayList; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | 
|---|
|  |  |  | if (c == null) { | 
|---|
|  |  |  | throw new Exception("å®ä¾åä¸è¡æ°æ®å¤çä»»å¡å¯¹è±¡æ å¤±è´¥ï¼ä»»å¡ç±»ä¸º" + clazz + "ï¼"); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | return (TaskSurpport)c.newInstance(); | 
|---|
|  |  |  | return (TaskSurpport)c.getDeclaredConstructor().newInstance(); | 
|---|
|  |  |  | //return (TaskSurpport)c.newInstance(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
| File was renamed from pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/busi/deal/TaskSurpport.java | 
|  |  |  | 
|---|
|  |  |  | package com.dy.aceMw.server.busi.deal; | 
|---|
|  |  |  | package com.dy.aceMw.server.rtuData; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import org.apache.logging.log4j.LogManager; | 
|---|
|  |  |  | import org.apache.logging.log4j.Logger; | 
|---|
| File was renamed from pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/busi/deal/TkReceive.java | 
|  |  |  | 
|---|
|  |  |  | package com.dy.aceMw.server.busi.deal; | 
|---|
|  |  |  | package com.dy.aceMw.server.rtuData; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.dy.common.mw.protocol.Data; | 
|---|
|  |  |  | import org.apache.logging.log4j.LogManager; | 
|---|
| File was renamed from pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/busi/deal/TkRtuData.java | 
|  |  |  | 
|---|
|  |  |  | package com.dy.aceMw.server.busi.deal; | 
|---|
|  |  |  | package com.dy.aceMw.server.rtuData; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.dy.common.mw.protocol.Data; | 
|---|
|  |  |  | import org.apache.logging.log4j.LogManager; | 
|---|
| File was renamed from pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/busi/deal/TreeConfig.java | 
|  |  |  | 
|---|
|  |  |  | package com.dy.aceMw.server.busi.deal; | 
|---|
|  |  |  | package com.dy.aceMw.server.rtuData; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public class TreeConfig { | 
|---|
|  |  |  | public TaskConfig taskConf ; | 
|---|
| File was renamed from pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/busi/deal/TreeParse.java | 
|  |  |  | 
|---|
|  |  |  | package com.dy.aceMw.server.busi.deal; | 
|---|
|  |  |  | package com.dy.aceMw.server.rtuData; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.net.URL; | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | protected TreeConfig parseConfig() { | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | URL configFileURL = TreeParse.class.getResource("Tree.xml"); | 
|---|
|  |  |  | ClassLoader classLoader = ClassLoader.getSystemClassLoader(); | 
|---|
|  |  |  | URL configFileURL = classLoader.getResource("RtuDataDealTree.xml"); | 
|---|
|  |  |  | return this.parse(this.createDom(configFileURL)) ; | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | System.out.println("ç³»ç»å¯å¨æ¶ï¼åå§ä¸è¡æ°æ®å¤çä»»å¡é
ç½®åºé !"); | 
|---|
|  |  |  | 
|---|
|  |  |  | private TreeConfig parse(Document doc) throws Exception { | 
|---|
|  |  |  | Element root = doc.getRootElement(); | 
|---|
|  |  |  | if (root == null) { | 
|---|
|  |  |  | throw new Exception("æªå¾å°ä¸è¡æ°æ®å¤çä»»å¡é
ç½®æä»¶æ ¹å
ç´ config!"); | 
|---|
|  |  |  | throw new Exception("æªå¾å°ä¸è¡æ°æ®å¤çä»»å¡é
ç½®æä»¶æ ¹å
ç´ project!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<Element> rootTasks = root.getChildren("task") ; | 
|---|
| File was renamed from pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/busi/deal/dbSv/RtuSv.java | 
|  |  |  | 
|---|
|  |  |  | package com.dy.aceMw.server.busi.deal.dbSv; | 
|---|
|  |  |  | package com.dy.aceMw.server.rtuData.dbSv; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import org.springframework.stereotype.Service; | 
|---|
|  |  |  |  | 
|---|
| File was renamed from pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/busi/deal/p206V1_0_0/TkFindP206V1_0_0.java | 
|  |  |  | 
|---|
|  |  |  | package com.dy.aceMw.server.busi.deal.p206V1_0_0; | 
|---|
|  |  |  | package com.dy.aceMw.server.rtuData.p206V1_0_0; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.dy.aceMw.server.busi.deal.TaskSurpport; | 
|---|
|  |  |  | import com.dy.aceMw.server.rtuData.TaskSurpport; | 
|---|
|  |  |  | import com.dy.common.mw.protocol.Data; | 
|---|
|  |  |  | import com.dy.common.mw.protocol.p206V1_0_0.ProtocolConstantV206V1_0_0; | 
|---|
|  |  |  |  | 
|---|
| File was renamed from pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/busi/deal/p206V1_0_0/TkPreGenObjs.java | 
|  |  |  | 
|---|
|  |  |  | package com.dy.aceMw.server.busi.deal.p206V1_0_0; | 
|---|
|  |  |  | package com.dy.aceMw.server.rtuData.p206V1_0_0; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.dy.aceMw.server.busi.deal.TaskSurpport; | 
|---|
|  |  |  | import com.dy.aceMw.server.rtuData.TaskSurpport; | 
|---|
|  |  |  | import com.dy.common.mw.protocol.Data; | 
|---|
|  |  |  | import org.apache.logging.log4j.LogManager; | 
|---|
|  |  |  | import org.apache.logging.log4j.Logger; | 
|---|
|  |  |  | 
|---|
|  |  |  | public void execute(Object data) { | 
|---|
|  |  |  | Data d = (Data)data ; | 
|---|
|  |  |  | String rtuAddr = d.getRtuAddr() ; | 
|---|
|  |  |  | log.info("RTU" + rtuAddr + "æ°æ®å°æ¤ï¼è¿æªå®ç°å¤ç:" + data.toString()); | 
|---|
|  |  |  | //å¾å°æ¬å°RTU æ°æ®ï¼ä»¥å¤åé¢èç¹åºç¨ | 
|---|
|  |  |  | /* | 
|---|
|  |  |  | BuziInterface baseBusi = BuziGeter.getBaseBusi() ; | 
|---|
|  |  |  | 
|---|
|  |  |  | if(orgBusi == null){ | 
|---|
|  |  |  | log.error("严ééè¯¯ï¼æªè½å¾å°æ ç¾ä¸º" + nbRtu.orgTag + "ç便°´æºææ°æ®åºä¸å¡Busi"); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | BaMeter meter = DbOrgBuzi.getMeterByImeiAndNo(orgBusi, imei, meterNo) ; | 
|---|
|  |  |  | BaMeter meter = DbOrgBuzi.getMeterByImeiAndNo(orgBusi, imei, rtuAddr) ; | 
|---|
|  |  |  | //å¯è½æªæ¥è¯¢å°meterï¼å³ä»æ¯æµæµªè
RTUï¼ä½ä»è¦åç»å¤çï¼ï¼1ï¼ãä»è½è¯å«åºæµæµªè
RTUï¼ï¼2ï¼ãä»è¦è®°å½å
¶ä¸æ¥æ°æ® | 
|---|
|  |  |  | if(meter != null){ | 
|---|
|  |  |  | String protocol = d.getProtocol() ; | 
|---|
|  |  |  | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | //NB产åï¼RTUå®ä½ï¼æªåé
ç»å
·ä½ç便°´æºæ | 
|---|
|  |  |  | //æµæµªè
RTU | 
|---|
|  |  |  | rtuTramp = DbSyBuzi.getSyRtuTramp(baseBusi, imei, meterNo) ; | 
|---|
|  |  |  | rtuTramp = DbSyBuzi.getSyRtuTramp(baseBusi, imei, rtuAddr) ; | 
|---|
|  |  |  | if(rtuTramp == null){ | 
|---|
|  |  |  | rtuTramp = new SyRtuTramp(imei, meterNo) ; | 
|---|
|  |  |  | rtuTramp = new SyRtuTramp(imei, rtuAddr) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | this.taskResult = new Object[]{baseBusi, orgBusi, nbRtu, rtuTramp, null} ; | 
|---|
|  |  |  | this.toNextOneTask(data, TkDealRtuTramp.taskId); | 
|---|
|  |  |  | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | //æ°æ®åºä¸æªæ¥è¯¢å°NB产åï¼RTUå®ä½ï¼ | 
|---|
|  |  |  | //æµæµªè
RTU | 
|---|
|  |  |  | rtuTramp = DbSyBuzi.getSyRtuTramp(baseBusi, imei, meterNo) ; | 
|---|
|  |  |  | rtuTramp = DbSyBuzi.getSyRtuTramp(baseBusi, imei, rtuAddr) ; | 
|---|
|  |  |  | if(rtuTramp == null){ | 
|---|
|  |  |  | rtuTramp = new SyRtuTramp(imei, meterNo) ; | 
|---|
|  |  |  | rtuTramp = new SyRtuTramp(imei, rtuAddr) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | this.taskResult = new Object[]{baseBusi, orgBusi, nbRtu, rtuTramp, null} ; | 
|---|
|  |  |  | this.toNextOneTask(data, TkDealRtuTramp.taskId); | 
|---|
| File was renamed from pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/tasks/BusiConstantTask.java | 
|  |  |  | 
|---|
|  |  |  | package com.dy.aceMw.server.tasks; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.dy.aceMw.server.busi.AboutRtuNode; | 
|---|
|  |  |  | import com.dy.aceMw.server.busi.TcpUpDataCache; | 
|---|
|  |  |  | import com.dy.aceMw.server.rtuData.RtuDataNode; | 
|---|
|  |  |  | import com.dy.aceMw.server.rtuData.RtuDataCache; | 
|---|
|  |  |  | import com.dy.common.mw.core.CoreTask; | 
|---|
|  |  |  | import com.dy.common.queue.Node; | 
|---|
|  |  |  | import org.apache.logging.log4j.LogManager; | 
|---|
|  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * å¯¹RTUä¸è¡æ°æ®è¿è¡ä¸å¡å¤ç | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public class BusiConstantTask  extends CoreTask { | 
|---|
|  |  |  | private static final Logger log = LogManager.getLogger(BusiConstantTask.class.getName()); | 
|---|
|  |  |  | public class FromRtuConstantTask extends CoreTask { | 
|---|
|  |  |  | private static final Logger log = LogManager.getLogger(FromRtuConstantTask.class.getName()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * å¨å线ç¨ç¯å¢ä¸è¿è¡ | 
|---|
|  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Integer excute() { | 
|---|
|  |  |  | try{ | 
|---|
|  |  |  | return dealRtuUpdata() ; | 
|---|
|  |  |  | return dealRtuUpData() ; | 
|---|
|  |  |  | }catch(Exception e){ | 
|---|
|  |  |  | log.error(e); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * å¤çä¸è¡æ°æ® | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Integer dealRtuUpdata() { | 
|---|
|  |  |  | Node first = TcpUpDataCache.getFirstQueueNode() ; | 
|---|
|  |  |  | public Integer dealRtuUpData() { | 
|---|
|  |  |  | Node first = RtuDataCache.getFirstQueueNode() ; | 
|---|
|  |  |  | if(first != null){ | 
|---|
|  |  |  | Integer count = TcpUpDataCache.size() ; | 
|---|
|  |  |  | Node last = TcpUpDataCache.getLastQueueNode() ; | 
|---|
|  |  |  | this.doDealRtuUpdata(first, last); | 
|---|
|  |  |  | Integer count = RtuDataCache.size() ; | 
|---|
|  |  |  | Node last = RtuDataCache.getLastQueueNode() ; | 
|---|
|  |  |  | this.doDealRtuUpData(first, last); | 
|---|
|  |  |  | return count ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return null ; | 
|---|
|  |  |  | 
|---|
|  |  |  | * @param first ç¬¬ä¸ä¸ªèç¹ | 
|---|
|  |  |  | * @param last æåä¸ä¸ªèç¹ | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private void doDealRtuUpdata(Node first, Node last){ | 
|---|
|  |  |  | private void doDealRtuUpData(Node first, Node last){ | 
|---|
|  |  |  | if(last != null){ | 
|---|
|  |  |  | //å¨dealNodeæ¹æ³ä¸ï¼å¯è½è¦ælastä»éåä¸ç§»é¤ï¼è¿æ¶last.preä¸ºç©ºï¼æä»¥æåælast.preååºæ¥ | 
|---|
|  |  |  | Node pre = last.pre ; | 
|---|
|  |  |  | dealNode(last) ; | 
|---|
|  |  |  | if(first != null && first != last){ | 
|---|
|  |  |  | doDealRtuUpdata(first, pre) ; | 
|---|
|  |  |  | doDealRtuUpData(first, pre) ; | 
|---|
|  |  |  | }else if(first != null && first == last){ | 
|---|
|  |  |  | //忢 | 
|---|
|  |  |  | }else if(first == null){ | 
|---|
|  |  |  | //è¿ç§æ
åµä¸ä¼åå¨ | 
|---|
|  |  |  | doDealRtuUpdata(null, pre) ; | 
|---|
|  |  |  | doDealRtuUpData(null, pre) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | * @param node èç¹ | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private void dealNode(Node node){ | 
|---|
|  |  |  | AboutRtuNode obj = (AboutRtuNode)node.obj ; | 
|---|
|  |  |  | RtuDataNode obj = (RtuDataNode)node.obj ; | 
|---|
|  |  |  | obj.dealSelf() ; | 
|---|
|  |  |  | TcpUpDataCache.removeNode(node); | 
|---|
|  |  |  | RtuDataCache.removeNode(node); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
| New file | 
|  |  |  | 
|---|
|  |  |  | <?xml version="1.0" encoding="UTF-8"?> | 
|---|
|  |  |  | <!DOCTYPE project> | 
|---|
|  |  |  | <project> | 
|---|
|  |  |  | <!-- | 
|---|
|  |  |  | id:ä¸å¯¹åºç±»ä¸çéææååétaskIdä¸è´ | 
|---|
|  |  |  | enable:æ è¯æ¬èç¹æ¯å¦æ§è¡ï¼è¥æ¬èç¹ä¸æ§è¡ï¼åç´æ¥è¿å
¥å
¶åèç¹ | 
|---|
|  |  |  | --> | 
|---|
|  |  |  | <task id="TkReceive" name="æ¥æ¶æ°æ®" enable="true" class="com.dy.aceMw.server.rtuData.TkReceive"> | 
|---|
|  |  |  | <task id="TkRtuData" name="æ¥æ¶RTUæ°æ®" enable="true" class="com.dy.aceMw.server.rtuData.TkRtuData"> | 
|---|
|  |  |  | <task id="TkFindP206V1_0_0" name="è¯å«P206V1_0_0æ°æ®" enable="true" class="com.dy.aceMw.server.rtuData.p206V1_0_0.TkFindP206V1_0_0"> | 
|---|
|  |  |  | <task id="TkPreGenObjs" name="é¢å
åå¤å对象" enable="true" class="com.dy.aceMw.server.rtuData.p206V1_0_0.TkPreGenObjs"> | 
|---|
|  |  |  | </task> | 
|---|
|  |  |  | </task> | 
|---|
|  |  |  | </task> | 
|---|
|  |  |  | </task> | 
|---|
|  |  |  | </project> | 
|---|
| New file | 
|  |  |  | 
|---|
|  |  |  | <?xml version="1.0" encoding="UTF-8"?> | 
|---|
|  |  |  | <!DOCTYPE project> | 
|---|
|  |  |  | <project> | 
|---|
|  |  |  | <!-- | 
|---|
|  |  |  | id:ä¸å¯¹åºç±»ä¸çéææååétaskIdä¸è´ | 
|---|
|  |  |  | enable:æ è¯æ¬èç¹æ¯å¦æ§è¡ï¼è¥æ¬èç¹ä¸æ§è¡ï¼åç´æ¥è¿å
¥å
¶åèç¹ | 
|---|
|  |  |  | --> | 
|---|
|  |  |  | <task id="TkReceive" name="æ¥æ¶æ°æ®" enable="true" class="com.dy.aceMw.server.rtuData.TkReceive"> | 
|---|
|  |  |  | <task id="TkRtuData" name="æ¥æ¶RTUæ°æ®" enable="true" class="com.dy.aceMw.server.rtuData.TkRtuData"> | 
|---|
|  |  |  | <task id="TkFindP206V1_0_0" name="è¯å«P206V1_0_0æ°æ®" enable="true" class="com.dy.aceMw.server.rtuData.p206V1_0_0.TkFindP206V1_0_0"> | 
|---|
|  |  |  | <task id="TkPreGenObjs" name="é¢å
åå¤å对象" enable="true" class="com.dy.aceMw.server.rtuData.p206V1_0_0.TkPreGenObjs"> | 
|---|
|  |  |  | <!-- è¯å«æµæµªè
RTUï¼æ°æ®åºä¸æ²¡æææ°æ®åºåå¨ä½æªåé
ç½®ä¾æ°´æºæ --> | 
|---|
|  |  |  | <task id="TkDealRtuTramp" name="è¯å«æµæµªè
RTU" enable="true" class="com.dy.aceMw.server.rtuData.p206V1_0_0.TkDealRtuTramp" /> | 
|---|
|  |  |  | <!-- éæµæµªè
RTUï¼å¿
é¡»æ¾å¨TkDealRtuTrampå颠--> | 
|---|
|  |  |  | <task id="TkDealNoRtuTramp" name="éæµæµªè
RTU" enable="true" class="com.dy.aceMw.server.rtuData.p206V1_0_0.TkDealNoRtuTramp"> | 
|---|
|  |  |  | <!-- è¯å«ä¸»å¨ä¸æ¥æ°æ® --> | 
|---|
|  |  |  | <task id="TkFindAutoReport" name="è¯å«ä¸»å¨ä¸æ¥å触å䏿¥æ°æ®" enable="true" class="com.dy.aceMw.server.rtuData.p206V1_0_0.TkFindAutoReport"> | 
|---|
|  |  |  | <!-- æ£æ¥æ¶é´ç䏿£ç¡®ç䏿¥æ°æ® --> | 
|---|
|  |  |  | <task id="TkCheckAutoReport" name="æ£æ¥æ¶é´ç䏿£ç¡®ç䏿¥æ°æ®" enable="true" class="com.dy.aceMw.server.rtuData.p206V1_0_0.autoReport.TkCheckAutoReport"> | 
|---|
|  |  |  | <!-- æ£æ¥éå¤ä¸æ¥æ°æ® --> | 
|---|
|  |  |  | <task id="TkCheckRepeatReport" name="æ£æ¥éå¤ä¸æ¥æ°æ®" enable="true" class="com.dy.aceMw.server.rtuData.p206V1_0_0.autoReport.TkCheckRepeatReport"> | 
|---|
|  |  |  | <!-- Mnè¿ç»´ç³»ç» --> | 
|---|
|  |  |  | <task id="TkMnRtuDealAutoReportLastAlarm" name="è¿ç»´RTU䏿¥ææ°æ¥è¦" enable="true" class="com.dy.aceMw.server.rtuData.p206V1_0_0.autoReport.TkMnRtuDealAutoReportLastAlarm" /> | 
|---|
|  |  |  | <!-- RTU主å¨ä¸æ¥æ°æ®å¿
é¡»å¨RTU主å¨ä¸æ¥æ¥è¦ä»»å¡çä¸é¢ï¼ä»¥å¤ä¸»å¨ä¸æ¥æ°æ®ä¸è®°å½æ¯å¦ææ¥è¦--> | 
|---|
|  |  |  | <task id="TkMnRtuDealAutoReportLastData" name="è¿ç»´RTU主å¨ä¸æ¥ææ°æ°æ®" enable="true" class="com.dy.aceMw.server.rtuData.p206V1_0_0.autoReport.TkMnRtuDealAutoReportLastData" /> | 
|---|
|  |  |  | <!-- RTU宿¶ï¼è§¦åï¼ä¸æ¥æ°æ®å¿
é¡»å¨RTU主å¨ä¸æ¥æ¥è¦ä»»å¡çä¸é¢ï¼ä»¥å¤ä¸»å¨ä¸æ¥æ°æ®ä¸è®°å½æ¯å¦ææ¥è¦--> | 
|---|
|  |  |  | <task id="TkMnRtuDealRealReportLastData" name="è¿ç»´RTU宿¶ï¼è§¦åï¼ä¸æ¥ææ°æ°æ®" enable="true" class="com.dy.aceMw.server.rtuData.p206V1_0_0.autoReport.TkMnRtuDealRealReportLastData" /> | 
|---|
|  |  |  | <!-- Org便°´æºæç³»ç» --> | 
|---|
|  |  |  | <task id="TkOrgRtuDealAutoReportLastAlarm" name="便°´æºæRTU主å¨ä¸æ¥ææ°æ¥è¦" enable="true" class="com.dy.aceMw.server.rtuData.p206V1_0_0.autoReport.TkOrgRtuDealAutoReportLastAlarm"> | 
|---|
|  |  |  | <task id="TkOrgRtuDealAutoReportAlarm" name="便°´æºæRTU主å¨ä¸æ¥æ¥è¦" enable="true" class="com.dy.aceMw.server.rtuData.p206V1_0_0.autoReport.TkOrgRtuDealAutoReportAlarm" /> | 
|---|
|  |  |  | <task id="TkOrgRtuDealReportValveOpResult" name="便°´æºæRTU主å¨ä¸æ¥å¼å
³éç»æ" enable="true" class="com.dy.aceMw.server.rtuData.p206V1_0_0.autoReport.TkOrgRtuDealReportValveOpResult" /> | 
|---|
|  |  |  | </task> | 
|---|
|  |  |  | <!-- RTU主å¨ä¸æ¥æ°æ®å¿
é¡»å¨RTU主å¨ä¸æ¥æ¥è¦ä»»å¡çä¸é¢ï¼ä»¥å¤ä¸»å¨ä¸æ¥æ°æ®ä¸è®°å½æ¯å¦ææ¥è¦--> | 
|---|
|  |  |  | <task id="TkOrgRtuDealDayAmountAlarm" name="便°´æºæRTUæ¥ç»ç´¯è®¡æµéæ¥è¦" enable="true" class="com.dy.aceMw.server.rtuData.p206V1_0_0.autoReport.TkOrgRtuDealDayAmountAlarm" > | 
|---|
|  |  |  | <task id="TkOrgRtuDeal48HourNoAmount" name="便°´æºæRTU48å°æ¶æªç¨æ°´" enable="true" class="com.dy.aceMw.server.rtuData.p206V1_0_0.autoReport.TkOrgRtuDeal48HourNoAmount" > | 
|---|
|  |  |  | <task id="TkOrgRtuDealAutoReportLastData" name="便°´æºæRTU主å¨ä¸æ¥ææ°æ°æ®" enable="true" class="com.dy.aceMw.server.rtuData.p206V1_0_0.autoReport.TkOrgRtuDealAutoReportLastData"> | 
|---|
|  |  |  | <task id="TkOrgRtuDealAutoReportData" name="便°´æºæRTU主å¨ä¸æ¥æ°æ®" enable="true" class="com.dy.aceMw.server.rtuData.p206V1_0_0.autoReport.TkOrgRtuDealAutoReportData" /> | 
|---|
|  |  |  | <task id="TkOrgRtuDealCycleData" name="便°´æºæRTU主å¨ä¸æ¥å¨æééæ°æ®" enable="true" class="com.dy.aceMw.server.rtuData.p206V1_0_0.autoReport.TkOrgRtuDealCycleData"> | 
|---|
|  |  |  | <task id="TkOrgRtuDealCycleLongSmallAmountAlarm" name="便°´æºæRTU主å¨ä¸æ¥å¨æééæ°æ®é¿æµæ°´åæ" enable="true" class="com.dy.aceMw.server.rtuData.p206V1_0_0.autoReport.TkOrgRtuDealCycleLongSmallAmountAlarm" /> | 
|---|
|  |  |  | </task> | 
|---|
|  |  |  | <task id="TkOrgRtuDealAmountCost" name="便°´æºæRTU主å¨ä¸æ¥è®¡ç®æ¥æ°´éãææ°´éãåæ°´è´¹" enable="true" class="com.dy.aceMw.server.rtuData.p206V1_0_0.autoReport.TkOrgRtuDealAmountCost" > | 
|---|
|  |  |  | <task id="TkOrgRtuDealPayCost" name="便°´æºæç¨æ°´æ·æ°´è¡¨çµåé±å
æ¯ä»æ°´è´¹" enable="true" class="com.dy.aceMw.server.rtuData.p206V1_0_0.autoReport.TkOrgRtuDealPayCost" /> | 
|---|
|  |  |  | </task> | 
|---|
|  |  |  | </task> | 
|---|
|  |  |  | </task> | 
|---|
|  |  |  | </task> | 
|---|
|  |  |  | <!-- RTU宿¶ï¼è§¦åï¼ä¸æ¥æ°æ®å¿
é¡»å¨RTU主å¨ä¸æ¥æ¥è¦ä»»å¡çä¸é¢ï¼ä»¥å¤ä¸»å¨ä¸æ¥æ°æ®ä¸è®°å½æ¯å¦ææ¥è¦--> | 
|---|
|  |  |  | <task id="TkOrgRtuDealRealReportLastData" name="便°´æºæRTU宿¶ï¼è§¦åï¼ä¸æ¥ææ°æ°æ®" enable="true" class="com.dy.aceMw.server.rtuData.p206V1_0_0.autoReport.TkOrgRtuDealRealReportLastData"> | 
|---|
|  |  |  | <task id="TkOrgRtuDealRealReportData" name="便°´æºæRTU宿¶ï¼è§¦åï¼ä¸æ¥æ°æ®" enable="true" class="com.dy.aceMw.server.rtuData.p206V1_0_0.autoReport.TkOrgRtuDealRealReportData" /> | 
|---|
|  |  |  | </task> | 
|---|
|  |  |  | </task> | 
|---|
|  |  |  | </task> | 
|---|
|  |  |  | </task> | 
|---|
|  |  |  | <!-- è¯å«å½ä»¤ååºæ°æ® --> | 
|---|
|  |  |  | <task id="TkFindComResponse" name="è¯å«ååºå½ä»¤æ°æ®" enable="true" class="com.dy.aceMw.server.rtuData.p206V1_0_0.TkFindComResponse"> | 
|---|
|  |  |  | <task id="TkRtuDealCommandResponse" name="RTUååºå½ä»¤æ°æ®" enable="true" class="com.dy.aceMw.server.rtuData.p206V1_0_0.comResponse.TkRtuDealCommandResponse" > | 
|---|
|  |  |  | <task id="TkRtuDealSetParamComResponse" name="RTUååºè®¾ç½®åæ°å½ä»¤æ°æ®" enable="true" class="com.dy.aceMw.server.rtuData.p206V1_0_0.comResponse.TkRtuDealSetParamComResponse" /> | 
|---|
|  |  |  | </task> | 
|---|
|  |  |  | </task> | 
|---|
|  |  |  | </task> | 
|---|
|  |  |  | </task> | 
|---|
|  |  |  | </task> | 
|---|
|  |  |  | <task id="TkFindHAC_NBhV2_5" name="è¯å«HAC_NBhV2_5æ°æ®" enable="true" class="com.dy.busi.server.rtuData.HAC_NBhV2_5.TkFindHAC_NBhV2_5"> | 
|---|
|  |  |  | <task id="TkPipPreGenObjs" name="é¢å
åå¤å对象" enable="true" class="com.dy.busi.server.rtuData.HAC_NBhV2_5.TkPipPreGenObjs"> | 
|---|
|  |  |  | <!-- è¯å«æµæµªè
ç®¡ç½æ°´è¡¨ï¼æ°æ®åºä¸æ²¡æææ°æ®åºåå¨ä½æªåé
ç½®ä¾æ°´æºæ --> | 
|---|
|  |  |  | <task id="TkPipDealRtuTramp" name="è¯å«æµæµªè
ç®¡ç½æ°´è¡¨" enable="true" class="com.dy.busi.server.rtuData.HAC_NBhV2_5.TkPipDealRtuTramp" /> | 
|---|
|  |  |  | <!-- éæµæµªè
ç®¡ç½æ°´è¡¨ï¼å¿
é¡»æ¾å¨TkDealRtuTrampå颠--> | 
|---|
|  |  |  | <task id="TkPipDealNoRtuTramp" name="éæµæµªè
ç®¡ç½æ°´è¡¨" enable="true" class="com.dy.busi.server.rtuData.HAC_NBhV2_5.TkPipDealNoRtuTramp"> | 
|---|
|  |  |  | <!-- è¯å«ä¸»å¨ä¸æ¥æ°æ® --> | 
|---|
|  |  |  | <task id="TkPipFindAutoReport" name="è¯å«ä¸»å¨ä¸æ¥å触å䏿¥æ°æ®" enable="true" class="com.dy.busi.server.rtuData.HAC_NBhV2_5.TkPipFindAutoReport"> | 
|---|
|  |  |  | <!-- æ£æ¥æ¶é´ç䏿£ç¡®ç䏿¥æ°æ® --> | 
|---|
|  |  |  | <task id="TkPipCheckAutoReport" name="æ£æ¥æ¶é´ç䏿£ç¡®ç䏿¥æ°æ®" enable="true" class="com.dy.busi.server.rtuData.HAC_NBhV2_5.autoReport.TkPipCheckAutoReport"> | 
|---|
|  |  |  | <task id="TkPipCheckRepeatAutoReport" name="æ£æ¥éå¤ä¸æ¥æ°æ®" enable="true" class="com.dy.busi.server.rtuData.HAC_NBhV2_5.autoReport.TkPipCheckRepeatAutoReport"> | 
|---|
|  |  |  | <!-- Mnè¿ç»´ç³»ç» --> | 
|---|
|  |  |  | <task id="TkPipMnRtuDealAutoReportLastAlarm" name="è¿ç»´ç®¡ç½æ°´è¡¨ä¸æ¥ææ°æ¥è¦" enable="true" class="com.dy.busi.server.rtuData.HAC_NBhV2_5.autoReport.TkPipMnRtuDealAutoReportLastAlarm" /> | 
|---|
|  |  |  | <!-- RTU主å¨ä¸æ¥æ°æ®å¿
é¡»å¨RTU主å¨ä¸æ¥æ¥è¦ä»»å¡çä¸é¢ï¼ä»¥å¤ä¸»å¨ä¸æ¥æ°æ®ä¸è®°å½æ¯å¦ææ¥è¦--> | 
|---|
|  |  |  | <task id="TkPipMnRtuDealAutoReportLastData" name="è¿ç»´ç®¡ç½æ°´è¡¨ä¸»å¨ä¸æ¥ææ°æ°æ®" enable="true" class="com.dy.busi.server.rtuData.HAC_NBhV2_5.autoReport.TkPipMnRtuDealAutoReportLastData" /> | 
|---|
|  |  |  | <!-- Org便°´æºæç³»ç» --> | 
|---|
|  |  |  | <task id="TkPipOrgRtuDealAutoReportLastAlarm" name="便°´æºæç®¡ç½æ°´è¡¨ä¸»å¨ä¸æ¥ææ°æ¥è¦" enable="true" class="com.dy.busi.server.rtuData.HAC_NBhV2_5.autoReport.TkPipOrgRtuDealAutoReportLastAlarm"> | 
|---|
|  |  |  | <task id="TkPipOrgRtuDealAutoReportAlarm" name="便°´æºæç®¡ç½æ°´è¡¨ä¸»å¨ä¸æ¥æ¥è¦" enable="true" class="com.dy.busi.server.rtuData.HAC_NBhV2_5.autoReport.TkPipOrgRtuDealAutoReportAlarm" /> | 
|---|
|  |  |  | </task> | 
|---|
|  |  |  | <!-- RTU主å¨ä¸æ¥æ°æ®å¿
é¡»å¨RTU主å¨ä¸æ¥æ¥è¦ä»»å¡çä¸é¢ï¼ä»¥å¤ä¸»å¨ä¸æ¥æ°æ®ä¸è®°å½æ¯å¦ææ¥è¦--> | 
|---|
|  |  |  | <task id="TkPipOrgRtuDealAutoReportLastData" name="便°´æºæç®¡ç½æ°´è¡¨ä¸»å¨ä¸æ¥ææ°æ°æ®" enable="true" class="com.dy.busi.server.rtuData.HAC_NBhV2_5.autoReport.TkPipOrgRtuDealAutoReportLastData"> | 
|---|
|  |  |  | <task id="TkPipOrgRtuDealAutoReportData" name="便°´æºæç®¡ç½æ°´è¡¨ä¸»å¨ä¸æ¥æ°æ®" enable="true" class="com.dy.busi.server.rtuData.HAC_NBhV2_5.autoReport.TkPipOrgRtuDealAutoReportData" /> | 
|---|
|  |  |  | <task id="TkPipOrgRtuDealAmount" name="便°´æºæç®¡ç½æ°´è¡¨ææµéç»è®¡" enable="true" class="com.dy.busi.server.rtuData.HAC_NBhV2_5.autoReport.TkPipOrgRtuDealAmount" /> | 
|---|
|  |  |  | </task> | 
|---|
|  |  |  | </task> | 
|---|
|  |  |  | </task> | 
|---|
|  |  |  | </task> | 
|---|
|  |  |  | </task> | 
|---|
|  |  |  | </task> | 
|---|
|  |  |  | </task> | 
|---|
|  |  |  | </task> | 
|---|
|  |  |  | </task> | 
|---|
|  |  |  | </project> | 
|---|
|  |  |  | 
|---|
|  |  |  | </dependencies> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <build> | 
|---|
|  |  |  | <resources> | 
|---|
|  |  |  | <resource> | 
|---|
|  |  |  | <directory>src/main/java</directory> | 
|---|
|  |  |  | <includes> | 
|---|
|  |  |  | <include>**/*.xml</include> | 
|---|
|  |  |  | </includes> | 
|---|
|  |  |  | </resource> | 
|---|
|  |  |  | <resource> | 
|---|
|  |  |  | <directory>src/main/resources</directory> | 
|---|
|  |  |  | <includes> | 
|---|
|  |  |  | <include>**/*.xml</include> | 
|---|
|  |  |  | <include>**/*.yml</include> | 
|---|
|  |  |  | </includes> | 
|---|
|  |  |  | </resource> | 
|---|
|  |  |  | </resources> | 
|---|
|  |  |  | <plugins> | 
|---|
|  |  |  | <plugin> | 
|---|
|  |  |  | <!-- è¯¥æä»¶ä¸ä¼å°é¡¹ç®ä¸å¼å
¥çä¾èµæè¿æç»ç Jar æä»¶ --> | 
|---|
|  |  |  | 
|---|
|  |  |  | //æ¯ææ¨¡åï¼ springHibernateå çº¿ç¨æ± | 
|---|
|  |  |  | SupportUnitConfigVo supVo = new SupportUnitConfigVo() ; | 
|---|
|  |  |  | //ç工使¶é¿çº¿ç¨æ± ï¼çº¿ç¨è´è´£ç¨æ¶è¾ççå·¥ä½ä»»å¡ | 
|---|
|  |  |  | supVo.short_maxThread = conf.getSetAttrPlusInt(doc, "config.support", "short_maxThread", null, 1, 1000, null) ;//æ± ä¸æå¤§çº¿ç¨æ°ä¸ºææCPUæ ¸æ°+1 | 
|---|
|  |  |  | supVo.short_minThread = conf.getSetAttrPlusInt(doc, "config.support", "short_minThread", null, 1, 5, null) ;//æ± ä¸æå°çº¿ç¨æ° | 
|---|
|  |  |  | supVo.short_maxThread = conf.getSetAttrPlusInt(doc, "config.support", "short_maxThread", null, -1, 1000, null) ;//æ± ä¸æå¤§çº¿ç¨æ°ä¸ºææCPUæ ¸æ°+1 | 
|---|
|  |  |  | if(supVo.short_maxThread < 0){ | 
|---|
|  |  |  | supVo.short_maxThread = -1 ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | supVo.short_minThread = conf.getSetAttrPlusInt(doc, "config.support", "short_minThread", null, -1, 100, null) ;//æ± ä¸æå°çº¿ç¨æ° | 
|---|
|  |  |  | if(supVo.short_minThread < 0){ | 
|---|
|  |  |  | supVo.short_minThread = -1 ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | supVo.short_freeTimeout = conf.getSetAttrPlusInt(doc, "config.support", "short_freeTimeout", null, 1, 90, null) * 1000 ;//çº¿ç¨æ°ç©ºé²æ¶é¿ï¼è¥æ± ä¸çº¿ç¨æ°é大äºminThreadï¼ä¸æç线ç¨ç©ºé²æ¶é¿è¶
è¿freeTimeoutï¼åæ¸
é¤è¯¥çº¿ç¨ï¼ä¸ºäºä¸æ¸
é¤ï¼æminThreadä¸maxThread设置ç¸ç | 
|---|
|  |  |  | supVo.short_busyTimeout = conf.getSetAttrPlusInt(doc, "config.support", "short_busyTimeout", null, 1, 10, null) * 1000 ;//线ç¨ä¸é´æå·¥ä½æ¶é¿ï¼åä½ä¸ºç§)è¶
æ¶éï¼è®¤ä¸ºçº¿ç¨å·²ç»äºå´©æºï¼å°å¼ºå¶æ¸
é¤ï¼ç工使¶é¿è®¾ç½®ä¸º5ç§ | 
|---|
|  |  |  | if(supVo.short_maxThread == 0 || supVo.short_minThread == 0){ | 
|---|
|  |  |  | supVo.enableShortThreadPool = false ; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | supVo.enableShortThreadPool = true ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //é¿å·¥ä½æ¶é¿çº¿ç¨æ± ï¼çº¿ç¨è´è´£ç¨æ¶è¾é¿çå·¥ä½ä»»å¡ | 
|---|
|  |  |  | supVo.long_maxThread = conf.getSetAttrInt(doc, "config.support", "long_maxThread", null, -1, 1000, null)  ;//æ± ä¸æå¤§çº¿ç¨æ°,è¥ä¸º-1ï¼ä¸åéå¶ | 
|---|
|  |  |  | if(supVo.long_maxThread < 0){ | 
|---|
|  |  |  | supVo.long_maxThread = -1 ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | supVo.long_minThread = conf.getSetAttrPlusInt(doc, "config.support", "long_minThread", null, 0, 5, null) ;//æ± ä¸æå°çº¿ç¨æ° | 
|---|
|  |  |  | supVo.long_minThread = conf.getSetAttrPlusInt(doc, "config.support", "long_minThread", null, -1, 100, null) ;//æ± ä¸æå°çº¿ç¨æ° | 
|---|
|  |  |  | if(supVo.long_minThread < 0){ | 
|---|
|  |  |  | supVo.long_minThread = -1 ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | supVo.long_freeTimeout = conf.getSetAttrPlusInt(doc, "config.support", "long_freeTimeout", null, 1, 90, null) * 1000 ;//çº¿ç¨æ°ç©ºé²æ¶é¿ï¼è¥æ± ä¸çº¿ç¨æ°é大äºminThreadï¼ä¸æç线ç¨ç©ºé²æ¶é¿è¶
è¿freeTimeoutï¼åæ¸
é¤è¯¥çº¿ç¨ | 
|---|
|  |  |  | supVo.long_busyTimeout = conf.getSetAttrInt(doc, "config.support", "long_busyTimeout", null, -1, 10, null) ;//线ç¨ä¸é´æå·¥ä½æ¶é¿ï¼åä½ä¸ºç§)è¶
æ¶éï¼è¥ä¸º-1ï¼ä¸åéå¶ | 
|---|
|  |  |  | if(supVo.long_busyTimeout < 0){ | 
|---|
|  |  |  | supVo.long_busyTimeout = -1 ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(supVo.long_maxThread == 0 || supVo.long_minThread == 0){ | 
|---|
|  |  |  | supVo.enableLongThreadPool = false ; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | supVo.enableLongThreadPool = true ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | supVo.showStartInfo = showStartInfo ; | 
|---|
|  |  |  | 
|---|
|  |  |  | // Tcp Client æ¨¡å | 
|---|
|  |  |  | TcpClUnitConfigVo tcpClVo = new TcpClUnitConfigVo(); | 
|---|
|  |  |  | tcpClVo.enable = conf.getSetAttrBoolean(doc, "config.tcpCl", "enable", null, null) ; | 
|---|
|  |  |  | tcpClVo.heartbeatTimes = conf.getSetAttrPlusInt(doc, "config.tcpCl", "heartbeatTimes", null, 1, 10, null) ;//è¿ç»é
置次æ°å¿è·³ååé䏿¬¡æ°æ® | 
|---|
|  |  |  | tcpClVo.sendInterval = conf.getSetAttrPlusInt(doc, "config.tcpCl", "sendInterval", null, 1, 60, null) ;//åéå¿è·³ææ°æ®çæ¶é´é´é | 
|---|
|  |  |  | if(tcpClVo.enable){ | 
|---|
|  |  |  | AdapterImp_TcpClUnit httpClAdap = new AdapterImp_TcpClUnit(); | 
|---|
|  |  |  | httpClAdap.setConfig(tcpClVo); | 
|---|
|  |  |  | 
|---|
|  |  |  | //RTUæªæ¢å°å | 
|---|
|  |  |  | public static Long rtuAddrEnd = 0L ; | 
|---|
|  |  |  | //æå¡ç«¯IP | 
|---|
|  |  |  | public static String serverIp = "" ; | 
|---|
|  |  |  | public static String tcpServerIp = "" ; | 
|---|
|  |  |  | //æå¡ç«¯ä¸ä¸æ | 
|---|
|  |  |  | public static Integer serverPort = 0 ; | 
|---|
|  |  |  | public static Integer tcpServerPort = 0 ; | 
|---|
|  |  |  | //åéæ°æ®æ°æ®é´é | 
|---|
|  |  |  | public static Integer sendInterval = 0 ;//ç§ | 
|---|
|  |  |  | //æ¯ä¸è½®æ¬¡åéæ°æ®ï¼å
¶ä¸å
æ¬å¿è·³æ°æ®çæ¬¡æ° | 
|---|
|  |  |  | public static Integer heartbeatTimes = 3 ; | 
|---|
|  |  |  | //åéæ°æ®æ¬¡æ° | 
|---|
|  |  |  | public static Integer sendTimes = 0 ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static String cd4 = "004" ;//åæå¡ç«¯ä¸æ¥ä¿¡æ¯ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static String cd5 = "005" ;//åæå¡ç«¯ä¸æ¥  æ°æ®ä¸æ¥å·¥ä½å·²ç»å®æ | 
|---|
|  |  |  | public static String cd5 = "005" ;//åæå¡ç«¯ä¸æ¥  å®æä»»å¡çæ°é | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static String cd6 = "006" ;//åæå¡ç«¯ä¸æ¥  å
¨é¨ä»»å¡å®æ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | //模æå®¢æ·çIMEIå·æªæ¢å· | 
|---|
|  |  |  | public Long rtuAddrEnd = 0L ; | 
|---|
|  |  |  | //æå¡ç«¯IP | 
|---|
|  |  |  | public String serverIp = "" ; | 
|---|
|  |  |  | public String tcpServerIp = "" ; | 
|---|
|  |  |  | //æå¡ç«¯ä¸ä¸æ | 
|---|
|  |  |  | public Integer serverPort = 0 ; | 
|---|
|  |  |  | public Integer tcpServerPort = 0 ; | 
|---|
|  |  |  | //åéæ°æ®é´é | 
|---|
|  |  |  | public Integer sendInterval = 2 ;//ç§ | 
|---|
|  |  |  | //æ¯ä¸è½®æ¬¡åéæ°æ®ï¼å
¶ä¸å
æ¬å¿è·³å鿬¡æ° | 
|---|
|  |  |  | public Integer heartbeatTimes = 3 ; | 
|---|
|  |  |  | //åéæ°æ®æ¬¡æ° | 
|---|
|  |  |  | public Integer sendTimes = 0 ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | this.rtuAddrEnd = rtuAddrEnd; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public String getServerIp() { | 
|---|
|  |  |  | return serverIp; | 
|---|
|  |  |  | public String getTcpServerIp() { | 
|---|
|  |  |  | return tcpServerIp; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void setServerIp(String serverIp) { | 
|---|
|  |  |  | this.serverIp = serverIp; | 
|---|
|  |  |  | public void setTcpServerIp(String tcpServerIp) { | 
|---|
|  |  |  | this.tcpServerIp = tcpServerIp; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public Integer getServerPort() { | 
|---|
|  |  |  | return serverPort; | 
|---|
|  |  |  | public Integer getTcpServerPort() { | 
|---|
|  |  |  | return tcpServerPort; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void setServerPort(Integer serverPort) { | 
|---|
|  |  |  | this.serverPort = serverPort; | 
|---|
|  |  |  | public void setTcpServerPort(Integer tcpServerPort) { | 
|---|
|  |  |  | this.tcpServerPort = tcpServerPort; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public Integer getSendInterval() { | 
|---|
|  |  |  | return sendInterval; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void setSendInterval(Integer sendInterval) { | 
|---|
|  |  |  | this.sendInterval = sendInterval; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public Integer getHeartbeatTimes() { | 
|---|
|  |  |  | return heartbeatTimes; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void setHeartbeatTimes(Integer heartbeatTimes) { | 
|---|
|  |  |  | this.heartbeatTimes = heartbeatTimes; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public Integer getSendTimes() { | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //ææ°æ®ä¸æ¥å®ææ
åµ  ä¸æ¥ç»mwTestServer | 
|---|
|  |  |  | public void reportHadReportOver(Long seconds){ | 
|---|
|  |  |  | public void reportHadReportOver(Integer count){ | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | Thread.sleep(100L); | 
|---|
|  |  |  | RmiRequestVo rqVo = new RmiRequestVo() ; | 
|---|
|  |  |  | rqVo.id = id ; | 
|---|
|  |  |  | rqVo.token = token ; | 
|---|
|  |  |  | rqVo.code = Code.cd5 ; | 
|---|
|  |  |  | rqVo.overCount = count ; | 
|---|
|  |  |  | String json = rqVo.toJson() ; | 
|---|
|  |  |  | frmWork.syncRequest(json) ; | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | log.error("ææ°æ®ä¸æ¥å®ææ
åµ  ä¸æ¥ç»mwTestServer失败" + e.getMessage()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //ææ°æ®ä¸æ¥å®ææ
åµ  ä¸æ¥ç»mwTestServer | 
|---|
|  |  |  | public void allOver(Long seconds){ | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | Thread.sleep(100L); | 
|---|
|  |  |  | RmiRequestVo rqVo = new RmiRequestVo() ; | 
|---|
|  |  |  | rqVo.id = id ; | 
|---|
|  |  |  | rqVo.token = token ; | 
|---|
|  |  |  | rqVo.code = Code.cd6 ; | 
|---|
|  |  |  | rqVo.over = true ; | 
|---|
|  |  |  | rqVo.seconds = seconds ; | 
|---|
|  |  |  | String json = rqVo.toJson() ; | 
|---|
|  |  |  | 
|---|
|  |  |  | if(rVo != null){ | 
|---|
|  |  |  | ServerProperties.rtuAddrStart = rVo.rtuAddrStart; | 
|---|
|  |  |  | ServerProperties.rtuAddrEnd = rVo.rtuAddrEnd; | 
|---|
|  |  |  | ServerProperties.serverIp = rVo.serverIp; | 
|---|
|  |  |  | ServerProperties.serverPort = rVo.serverPort; | 
|---|
|  |  |  | ServerProperties.tcpServerIp = rVo.tcpServerIp; | 
|---|
|  |  |  | ServerProperties.tcpServerPort = rVo.tcpServerPort; | 
|---|
|  |  |  | ServerProperties.sendInterval = rVo.sendInterval ; | 
|---|
|  |  |  | ServerProperties.heartbeatTimes = rVo.heartbeatTimes ; | 
|---|
|  |  |  | ServerProperties.sendTimes = rVo.sendTimes ; | 
|---|
|  |  |  | log.info("å¾å°é
ç½®æå"); | 
|---|
|  |  |  | log.info("    å¼å§RtuAddr=" + ServerProperties.rtuAddrStart); | 
|---|
|  |  |  | log.info("    æªæ¢RtuAddr=" + ServerProperties.rtuAddrEnd); | 
|---|
|  |  |  | log.info("    mwAcceptæå¡IP=" + ServerProperties.serverIp); | 
|---|
|  |  |  | log.info("    mwAcceptæå¡ç«¯å£=" + ServerProperties.serverPort); | 
|---|
|  |  |  | log.info("    æ¯imei䏿¥æ°æ®æ¬¡æ°=" + ServerProperties.sendTimes); | 
|---|
|  |  |  | log.info("    mwAcceptæå¡IP=" + ServerProperties.tcpServerIp); | 
|---|
|  |  |  | log.info("    mwAcceptæå¡ç«¯å£=" + ServerProperties.tcpServerPort); | 
|---|
|  |  |  | log.info("    åéæ°æ®é´é=" + ServerProperties.sendTimes); | 
|---|
|  |  |  | log.info("    æ¯è½®æ¬¡åéå¿è·³æ¬¡æ°=" + ServerProperties.heartbeatTimes); | 
|---|
|  |  |  | log.info("    æ¯RTU䏿¥æ°æ®è½®æ¬¡=" + ServerProperties.sendTimes); | 
|---|
|  |  |  | break ; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | log.error("rmiå¾å°é
置失败ï¼json转ResConfigVo为null"); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public Integer count;//aepTest䏿¥æ°æ®æ°é | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public Integer overCount;//aepTestç»æä¸æ¥æ°æ®æ°é | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public Boolean over ;//aepTest䏿¥æ°æ®ç»æ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public Long seconds ;//aepTest䏿¥æ°æ®ç¨æ¶(ç§) | 
|---|
|  |  |  | 
|---|
|  |  |  | package com.dy.testClient.rmiClient; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.alibaba.fastjson2.JSON; | 
|---|
|  |  |  | import com.alibaba.fastjson2.JSONObject; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public class RmiResponseVo { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public static RmiResponseVo jsonToObject(String json, Class<?> clazz)throws Exception{ | 
|---|
|  |  |  | try{ | 
|---|
|  |  |  | return JSON.parseObject(json, RmiResponseVo.class) ; | 
|---|
|  |  |  | //JSONDeserializer<RmiResponseVo> jsonD = new JSONDeserializer<RmiResponseVo>() ; | 
|---|
|  |  |  | //jsonD.use("obj", clazz) ; | 
|---|
|  |  |  | //RmiResponseVo resp = jsonD.deserialize(json, RmiResponseVo.class) ; | 
|---|
|  |  |  | //return resp ; | 
|---|
|  |  |  | JSONObject jsonObject = JSON.parseObject(json); | 
|---|
|  |  |  | RmiResponseVo vo = jsonObject.to(RmiResponseVo.class) ; | 
|---|
|  |  |  | vo.obj = jsonObject.getObject("obj", clazz); | 
|---|
|  |  |  | return vo ; | 
|---|
|  |  |  | }catch(Exception e){ | 
|---|
|  |  |  | throw new Exception(e.getMessage() , e ) ; | 
|---|
|  |  |  | } | 
|---|
| File was renamed from pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/tcpConnect/LocalCodecFactory.java | 
|  |  |  | 
|---|
|  |  |  | package com.dy.testClient.tcpConnect; | 
|---|
|  |  |  | package com.dy.testClient.tcpClient; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import org.apache.mina.filter.codec.ProtocolCodecFactory; | 
|---|
|  |  |  | import org.apache.mina.filter.codec.ProtocolEncoder; | 
|---|
|  |  |  | import org.apache.mina.filter.codec.ProtocolDecoder; | 
|---|
|  |  |  | 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; | 
|---|
| New file | 
|  |  |  | 
|---|
|  |  |  | package com.dy.testClient.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; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
| New file | 
|  |  |  | 
|---|
|  |  |  | package com.dy.testClient.tcpClient; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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 { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * å¯¹æ°æ®è¿è¡ç¼ç ï¼ä»¥å¤ç½ç»ä¼ è¾ | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | 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()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | 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.threadPool.ThreadPool; | 
|---|
|  |  |  | import com.dy.testClient.httpCl.*; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.Base64; | 
|---|
|  |  |  | import com.dy.common.util.ByteUtil; | 
|---|
|  |  |  | import com.dy.testClient.ServerProperties; | 
|---|
|  |  |  | import org.apache.logging.log4j.LogManager; | 
|---|
|  |  |  | import org.apache.logging.log4j.Logger; | 
|---|
|  |  |  | import org.apache.mina.core.session.IoSession; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public class MyThreadJob  implements ThreadPool.Job { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private static final Logger log = LogManager.getLogger(MyThreadJob.class) ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public String rtuAddr; | 
|---|
|  |  |  | public String serverIp; | 
|---|
|  |  |  | public Integer serverPort; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public IoSession session ; | 
|---|
|  |  |  | public boolean exceptionOnConnect = false ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static final int connectTimeout = 3000 ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public int sendTimes = 0 ;//åéæ°æ®æ¬¡æ° | 
|---|
|  |  |  | public int heartbeatTimes = 0 ;//䏿¥å¿è·³æ¬¡æ° | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public boolean isOver = false ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public MyThreadJob(){ | 
|---|
|  |  |  | } | 
|---|
|  |  |  | public MyThreadJob(String rtuAddr){ | 
|---|
|  |  |  | public MyThreadJob(String rtuAddr, String serverIp, Integer serverPort){ | 
|---|
|  |  |  | this.rtuAddr = rtuAddr ; | 
|---|
|  |  |  | this.serverIp = serverIp ; | 
|---|
|  |  |  | this.serverPort = serverPort ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void execute() throws Exception { | 
|---|
|  |  |  | testP206V1_0_0() ; | 
|---|
|  |  |  | log.info("RTU" + rtuAddr + "å¼å§ä»»å¡"); | 
|---|
|  |  |  | if(session != null){ | 
|---|
|  |  |  | log.info("RTU" + rtuAddr + "å°è¦æ§è¡" + ServerProperties.sendTimes + "轮次任å¡ï¼å½å轮次æ¯" + sendTimes); | 
|---|
|  |  |  | if(sendTimes <= ServerProperties.sendTimes){ | 
|---|
|  |  |  | sendDataOfP206V1_0_0() ; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | this.jobOver() ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private void testP206V1_0_0(){ | 
|---|
|  |  |  | private void sendDataOfP206V1_0_0(){ | 
|---|
|  |  |  | try{ | 
|---|
|  |  |  | RtuData4MeterV1_0 rd = new RtuData4MeterV1_0() ; | 
|---|
|  |  |  | byte[] bs = rd.create(rtuAddr) ; | 
|---|
|  |  |  | bs = Base64.getEncoder().encode(bs) ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | UpDataPayloadVo payloadVo = new UpDataPayloadVo() ; | 
|---|
|  |  |  | payloadVo.APPdata = new String(bs, "UTF-8") ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | UpDataVo vo = new UpDataVo(rtuAddr, "8086" + rtuAddr) ; | 
|---|
|  |  |  | vo.payload = payloadVo ; | 
|---|
|  |  |  | String json = vo.toJson() ; | 
|---|
|  |  |  | byte[] bytes = json.getBytes() ; | 
|---|
|  |  |  | HttpPost.post(bytes); | 
|---|
|  |  |  | if(heartbeatTimes >= ServerProperties.heartbeatTimes){ | 
|---|
|  |  |  | heartbeatTimes = 0 ; | 
|---|
|  |  |  | this.sendReportData() ; | 
|---|
|  |  |  | TcpClUnit.clientSendData(); | 
|---|
|  |  |  | sendTimes++ ; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | this.sendHeartbeat() ; | 
|---|
|  |  |  | TcpClUnit.clientSendData(); | 
|---|
|  |  |  | heartbeatTimes++ ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }catch(Exception e){ | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | }finally{ | 
|---|
|  |  |  | HttpClUnit.clientOver() ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | private void sendHeartbeat(){ | 
|---|
|  |  |  | try{ | 
|---|
|  |  |  | byte[] bs = this.createHeartbeat() ; | 
|---|
|  |  |  | this.session.write(bs) ; | 
|---|
|  |  |  | log.info("RTU" + rtuAddr + "åéäºå¿è·³æ°æ®ï¼" + ByteUtil.bytes2Hex(bs, false)); | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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(){ | 
|---|
|  |  |  | session.closeOnFlush() ; | 
|---|
|  |  |  | this.isOver = true ; | 
|---|
|  |  |  | 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 ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.dy.common.mw.UnitStartedCallbackInterface; | 
|---|
|  |  |  | import com.dy.common.threadPool.ThreadPool; | 
|---|
|  |  |  | import com.dy.common.threadPool.TreadPoolFactory; | 
|---|
|  |  |  | import com.dy.common.util.Callback; | 
|---|
|  |  |  | import com.dy.testClient.ServerProperties; | 
|---|
|  |  |  | import com.dy.testClient.rmiClient.RmiClUnit; | 
|---|
|  |  |  | import org.apache.logging.log4j.LogManager; | 
|---|
|  |  |  | import org.apache.logging.log4j.Logger; | 
|---|
|  |  |  | import org.apache.mina.core.session.IoSession; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.Collection; | 
|---|
|  |  |  | import java.util.HashMap; | 
|---|
|  |  |  | import java.util.Map; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public class TcpClUnit  implements UnitInterface { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | public static TcpClUnitConfigVo confVo ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private static ThreadPool.Pool pool ; | 
|---|
|  |  |  | private static Map<String, MyThreadJob> jobMap = new HashMap<>() ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private static Integer totalRunedClientCount = 0; | 
|---|
|  |  |  | private static Integer totalRtuClientCount = 0; | 
|---|
|  |  |  | private static Integer totalSendDataCount = 0; | 
|---|
|  |  |  | private static Integer totalOverClientCount = 0; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private static Long startTime = 0L ; | 
|---|
|  |  |  | 
|---|
|  |  |  | if(!ServerProperties.startWork){ | 
|---|
|  |  |  | Thread.sleep(100L); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | try{ | 
|---|
|  |  |  | startTime = System.currentTimeMillis() ; | 
|---|
|  |  |  | for(Long addr = ServerProperties.rtuAddrStart; addr <= ServerProperties.rtuAddrEnd; addr++){ | 
|---|
|  |  |  | totalRunedClientCount++ ; | 
|---|
|  |  |  | startClient(addr) ; | 
|---|
|  |  |  | totalRtuClientCount++ ; | 
|---|
|  |  |  | createImitate(addr) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | log.info("å
±æ¨¡æäº" + totalRtuClientCount + "å°RTU"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Collection<MyThreadJob> collection = jobMap.values() ; | 
|---|
|  |  |  | for(MyThreadJob job : collection){ | 
|---|
|  |  |  | connectServer(job) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | log.info("å¯å¨ææRTUè¿æ¥éä¿¡ä¸é´ä»¶"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | while(true){ | 
|---|
|  |  |  | if(totalOverClientCount.longValue() >= totalRunedClientCount.longValue()){ | 
|---|
|  |  |  | int noConnectedCount = checkConnected() ; | 
|---|
|  |  |  | if(noConnectedCount > 0){ | 
|---|
|  |  |  | log.info("çå¾
" + noConnectedCount + "å°RTUè¿æ¥ç½ç»"); | 
|---|
|  |  |  | Thread.sleep(100L); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | break ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | startJob() ; | 
|---|
|  |  |  | while(true){ | 
|---|
|  |  |  | if(totalOverClientCount.longValue() >= totalRtuClientCount.longValue()){ | 
|---|
|  |  |  | Long seconds = (System.currentTimeMillis() - startTime)/1000 ; | 
|---|
|  |  |  | RmiClUnit.getInstance().reportHadReportOver(seconds) ; | 
|---|
|  |  |  | System.out.println("å
±ç¨æ¶" + seconds + "ç§"); | 
|---|
|  |  |  | RmiClUnit.getInstance().allOver(seconds) ; | 
|---|
|  |  |  | log.info("å
±ç¨æ¶" + seconds + "ç§"); | 
|---|
|  |  |  | break ; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | Thread.sleep(100L); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | }finally { | 
|---|
|  |  |  | break ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }).start(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * å建RTU模æMyThreadJob | 
|---|
|  |  |  | * @param rtuAddr rtuå°å | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private void createImitate(Long rtuAddr){ | 
|---|
|  |  |  | jobMap.put("" + rtuAddr, new MyThreadJob("" + rtuAddr, ServerProperties.tcpServerIp, ServerProperties.tcpServerPort)) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private void connectServer(MyThreadJob job){ | 
|---|
|  |  |  | if(job.session == null){ | 
|---|
|  |  |  | try{ | 
|---|
|  |  |  | new TcpConnect().createSession(job.rtuAddr, | 
|---|
|  |  |  | job, | 
|---|
|  |  |  | job.serverIp, | 
|---|
|  |  |  | job.serverPort, | 
|---|
|  |  |  | job.connectTimeout, | 
|---|
|  |  |  | new TcpHandler(), | 
|---|
|  |  |  | new Callback() { | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void call(Object obj) { | 
|---|
|  |  |  | if(obj == null){ | 
|---|
|  |  |  | log.error("å建ç½ç»ä¼è¯è¿å为null"); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | job.session = (IoSession)obj ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void call(Object... objs) { | 
|---|
|  |  |  | } | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void exception(Exception e) { | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }) ; | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  | job.exceptionOnConnect = true ; | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private int checkConnected(){ | 
|---|
|  |  |  | int noConnectedCount = 0 ; | 
|---|
|  |  |  | Collection<MyThreadJob> collection = jobMap.values() ; | 
|---|
|  |  |  | for(MyThreadJob job : collection){ | 
|---|
|  |  |  | if(job.session == null && !job.exceptionOnConnect){ | 
|---|
|  |  |  | noConnectedCount++ ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return noConnectedCount; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private void startJob(){ | 
|---|
|  |  |  | new Thread(new Runnable(){ | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void run() { | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | int notOverCount; | 
|---|
|  |  |  | while(true){ | 
|---|
|  |  |  | notOverCount = 0 ; | 
|---|
|  |  |  | Collection<MyThreadJob> collection = jobMap.values() ; | 
|---|
|  |  |  | for(MyThreadJob job : collection){ | 
|---|
|  |  |  | if(!job.isOver){ | 
|---|
|  |  |  | notOverCount++ ; | 
|---|
|  |  |  | pool.putJob(job); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(notOverCount > 0){ | 
|---|
|  |  |  | log.info("å½åè¿æ" + notOverCount + "å°RTUæªå®æä»»å¡"); | 
|---|
|  |  |  | Thread.sleep(ServerProperties.sendInterval * 1000); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | }).start(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private void startClient(Long rtuAddr){ | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | pool.putJob(new MyThreadJob("" + rtuAddr)); | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | log.error("TcpClUnit.startClient() ", e); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static synchronized void clientSendData(){ | 
|---|
|  |  |  | totalSendDataCount++; | 
|---|
|  |  |  | if(totalOverClientCount.longValue() >= totalRtuClientCount.longValue()){ | 
|---|
|  |  |  | RmiClUnit.getInstance().reportHadReportCount(totalSendDataCount); | 
|---|
|  |  |  | System.out.println("å·²ç»åé" + totalSendDataCount + "æ¡æ°æ®"); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | if(totalRtuClientCount > 100){ | 
|---|
|  |  |  | if(totalSendDataCount % 100 == 0){ | 
|---|
|  |  |  | RmiClUnit.getInstance().reportHadReportCount(totalSendDataCount); | 
|---|
|  |  |  | System.out.println("å·²ç»åé" + totalSendDataCount + "æ¡æ°æ®"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | RmiClUnit.getInstance().reportHadReportCount(totalSendDataCount); | 
|---|
|  |  |  | System.out.println("å·²ç»åé" + totalSendDataCount + "æ¡æ°æ®"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static synchronized void clientOver(){ | 
|---|
|  |  |  | totalOverClientCount++; | 
|---|
|  |  |  | if(totalOverClientCount.longValue() >= totalRtuClientCount.longValue()){ | 
|---|
|  |  |  | RmiClUnit.getInstance().reportHadReportOver(totalOverClientCount); | 
|---|
|  |  |  | System.out.println("å·²æ" + totalOverClientCount + "个RTU宿äºä»»å¡"); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | if(totalRtuClientCount > 100) { | 
|---|
|  |  |  | if(totalOverClientCount % 100 == 0){ | 
|---|
|  |  |  | RmiClUnit.getInstance().reportHadReportCount(totalOverClientCount); | 
|---|
|  |  |  | System.out.println("å·²ç»åé" + totalOverClientCount + "æ¡æ°æ®"); | 
|---|
|  |  |  | RmiClUnit.getInstance().reportHadReportOver(totalOverClientCount); | 
|---|
|  |  |  | System.out.println("å·²æ" + totalOverClientCount + "个RTU宿äºä»»å¡"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | RmiClUnit.getInstance().reportHadReportOver(totalOverClientCount); | 
|---|
|  |  |  | System.out.println("å·²æ" + totalOverClientCount + "个RTU宿äºä»»å¡"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public class TcpClUnitConfigVo { | 
|---|
|  |  |  | public boolean enable ; | 
|---|
|  |  |  | public int heartbeatTimes ; | 
|---|
|  |  |  | public int sendInterval ; | 
|---|
|  |  |  | } | 
|---|
| New file | 
|  |  |  | 
|---|
|  |  |  | package com.dy.testClient.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 { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static final String rtuAddrKey = "rtuAddr" ; | 
|---|
|  |  |  | public static final String threadJobKey = "threadJob" ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * å¤æä¼è¯æ¯å¦ææ | 
|---|
|  |  |  | * @param se ç½ç»ä¼è¯ | 
|---|
|  |  |  | * @return æ¯å¦è¿æ¥ | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public boolean isConnected(IoSession se) { | 
|---|
|  |  |  | return (se != null && se.isConnected()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * å建æ°ä¼è¯ | 
|---|
|  |  |  | * @param rtuAddr rtuå°å | 
|---|
|  |  |  | * @param job rtuå·¥ä½ç±» | 
|---|
|  |  |  | * @param host æå¡å¨URI | 
|---|
|  |  |  | * @param port æå¡å¨ç«¯å£ | 
|---|
|  |  |  | * @param connectTimeout è¿æ¥è¶
æ¶æ¶é¿ | 
|---|
|  |  |  | * @param handler æ°æ®å¤çè | 
|---|
|  |  |  | * @param callback åè° | 
|---|
|  |  |  | * @return ç½ç»ä¼è¯ | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public void createSession(String rtuAddr, | 
|---|
|  |  |  | MyThreadJob job, | 
|---|
|  |  |  | 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(); | 
|---|
|  |  |  | se.setAttribute(rtuAddrKey, rtuAddr) ; | 
|---|
|  |  |  | se.setAttribute(threadJobKey, job) ; | 
|---|
|  |  |  | 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; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
| New file | 
|  |  |  | 
|---|
|  |  |  | package com.dy.testClient.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 { | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | --> | 
|---|
|  |  |  | <rmiCl | 
|---|
|  |  |  | rmiSvUrl="127.0.0.1" | 
|---|
|  |  |  | rmiSvContext="mwTestServer" | 
|---|
|  |  |  | rmiSvPort="9898" | 
|---|
|  |  |  | rmiSvContext="mwTestSv" | 
|---|
|  |  |  | rmiSvPort="12345" | 
|---|
|  |  |  | /> | 
|---|
|  |  |  | <!-- | 
|---|
|  |  |  | enable:æ¯å¦å¯å¨ | 
|---|
|  |  |  | heartbeatTimes:è¿ç»é
置次æ°å¿è·³ååé䏿¬¡æ°æ® | 
|---|
|  |  |  | sendInterval:åéå¿è·³ææ°æ®çæ¶é´é´é | 
|---|
|  |  |  | --> | 
|---|
|  |  |  | <tcpCl | 
|---|
|  |  |  | enable="true" | 
|---|
|  |  |  | heartbeatTimes="3" | 
|---|
|  |  |  | sendInterval="3" | 
|---|
|  |  |  | /> | 
|---|
|  |  |  | </config> | 
|---|
| New file | 
|  |  |  | 
|---|
|  |  |  | <?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å½åç¨æ·å¨æä½ç³»ç»ä¸çææ¡£ç®å½ | 
|---|
|  |  |  | /logs/testJgroups.logå½å软件æå¨ç¡¬çæ ¹ç®å½ | 
|---|
|  |  |  | logs/testJgroups.logå½å软件æå¨ç®å½ | 
|---|
|  |  |  | --> | 
|---|
|  |  |  | <RollingFile name="File" fileName="logs/mwTestCl.log" filePattern="logs/aepTest-%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ä¸å个Loggeråæ¶èµ·ä½ç¨ --> | 
|---|
|  |  |  | <Root level="info"> | 
|---|
|  |  |  | <AppenderRef ref="Console"/> | 
|---|
|  |  |  | <AppenderRef ref="File"/> | 
|---|
|  |  |  | </Root> | 
|---|
|  |  |  | </Loggers> | 
|---|
|  |  |  | </Configuration> | 
|---|
|  |  |  | 
|---|
|  |  |  | </dependencies> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <build> | 
|---|
|  |  |  | <resources> | 
|---|
|  |  |  | <resource> | 
|---|
|  |  |  | <directory>src/main/java</directory> | 
|---|
|  |  |  | <includes> | 
|---|
|  |  |  | <include>**/*.xml</include> | 
|---|
|  |  |  | </includes> | 
|---|
|  |  |  | </resource> | 
|---|
|  |  |  | <resource> | 
|---|
|  |  |  | <directory>src/main/resources</directory> | 
|---|
|  |  |  | <includes> | 
|---|
|  |  |  | <include>**/*.xml</include> | 
|---|
|  |  |  | <include>**/*.yml</include> | 
|---|
|  |  |  | </includes> | 
|---|
|  |  |  | </resource> | 
|---|
|  |  |  | </resources> | 
|---|
|  |  |  | <plugins> | 
|---|
|  |  |  | <plugin> | 
|---|
|  |  |  | <!-- è¯¥æä»¶ä¸ä¼å°é¡¹ç®ä¸å¼å
¥çä¾èµæè¿æç»ç Jar æä»¶ --> | 
|---|
|  |  |  | 
|---|
|  |  |  | long start = System.currentTimeMillis() ; | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | sv.conf = new ConfigXml() ; | 
|---|
|  |  |  | sv.doc = sv.conf.createDom(sv.getClass(), "/config.xml") ; | 
|---|
|  |  |  | sv.doc = sv.conf.createDom(sv.getClass(), "config.xml") ; | 
|---|
|  |  |  | //////////////// | 
|---|
|  |  |  | //æå¡ é
ç½® | 
|---|
|  |  |  | sv.showStartInfo = sv.conf.getSetAttrBoolean(sv.doc, "config.server", "showStartInfo", null, null) ; | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | ServerProperties.tcpServerIp = conf.getSetAttrTxt(doc, "config.base", "tcpServerIp", null, false, null) ; | 
|---|
|  |  |  | ServerProperties.tcpServerPort = conf.getSetAttrPlusInt(doc, "config.base", "tcpServerPort", null, 1, 65535, null) ; | 
|---|
|  |  |  | ServerProperties.sendInterval = conf.getSetAttrPlusInt(doc, "config.base", "sendInterval", null, 1, null, null) ; | 
|---|
|  |  |  | ServerProperties.heartbeatTimes = conf.getSetAttrPlusInt(doc, "config.base", "heartbeatTimes", null, 1, null, null) ; | 
|---|
|  |  |  | ServerProperties.sendTimes = conf.getSetAttrPlusInt(doc, "config.base", "sendTimes", null, 1, null, null) ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | public static String tcpServerIp = "" ; | 
|---|
|  |  |  | //æå¡ç«¯ä¸ä¸æ | 
|---|
|  |  |  | public static Integer tcpServerPort = 60000 ; | 
|---|
|  |  |  | //åéæ°æ®é´é ç§ | 
|---|
|  |  |  | public static Integer sendInterval = 0 ; | 
|---|
|  |  |  | //æ¯ä¸è½®æ¬¡åéæ°æ®ï¼å
¶ä¸å
æ¬å¿è·³å鿬¡æ° | 
|---|
|  |  |  | public static Integer heartbeatTimes = 0 ; | 
|---|
|  |  |  | //åéæ°æ®æ¬¡æ° | 
|---|
|  |  |  | public static Integer sendTimes = 0 ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | prtWrt.println("  æ¯ä¸ªmwTeståé
çRtuAddræ°ï¼" + ServerProperties.rtuAddrPerMwTest); | 
|---|
|  |  |  | prtWrt.println("  éä¿¡ä¸é´ä»¶IPï¼" + ServerProperties.tcpServerIp); | 
|---|
|  |  |  | prtWrt.println("  éä¿¡ä¸é´ä»¶ç«¯å£ï¼" + ServerProperties.tcpServerPort); | 
|---|
|  |  |  | prtWrt.println("  mwTeståéæ°æ®é´éï¼ç§ï¼ï¼" + ServerProperties.sendInterval); | 
|---|
|  |  |  | prtWrt.println("  mwTestæ¯RtuAddrå·åéæ°æ®æ¬¡æ°ï¼" + ServerProperties.sendTimes); | 
|---|
|  |  |  | prtWrt.println("  mwTestæ¯ä¸è½®æ¬¡åéæ°æ®ï¼å
¶ä¸å
æ¬å¿è·³å鿬¡æ°ï¼" + ServerProperties.heartbeatTimes); | 
|---|
|  |  |  | prtWrt.println("æ¬æå¡RMI Serveré
ç½®"); | 
|---|
|  |  |  | String ip = null ; | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | 
|---|
|  |  |  | if(sta.count != null){ | 
|---|
|  |  |  | prtWrt.println("    å·²ç»ä¸æ¥æ°æ®ï¼" + sta.count + "æ¡"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(sta.overCount != null){ | 
|---|
|  |  |  | prtWrt.println("    å·²ç»å®æä¸æ¥æ°æ®ï¼" + sta.overCount + "å°RTU"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(sta.over != null && sta.over){ | 
|---|
|  |  |  | prtWrt.println("    ä¸æ¥æ°æ®å·²ç»å®æï¼å
±ç¨æ¶ï¼" + sta.seconds + "ç§"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static String cd4 = "004" ;//åæå¡ç«¯ä¸æ¥ä¿¡æ¯ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static String cd5 = "005" ;//åæå¡ç«¯ä¸æ¥  æ°æ®ä¸æ¥å·¥ä½å·²ç»å®æ | 
|---|
|  |  |  | public static String cd5 = "005" ;//åæå¡ç«¯ä¸æ¥  å®æä»»å¡çæ°é | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static String cd6 = "006" ;//åæå¡ç«¯ä¸æ¥  å
¨é¨ä»»å¡å®æ | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | doDealReportCount(rqVo) ; | 
|---|
|  |  |  | }else if(rqVo.code.equals(Code.cd5)){ | 
|---|
|  |  |  | doDealReportOver(rqVo) ; | 
|---|
|  |  |  | }else if(rqVo.code.equals(Code.cd6)){ | 
|---|
|  |  |  | doDealAllOver(rqVo) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return resVo ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | conVo.rtuAddrEnd = (Long)rtuAddrs[1] ; | 
|---|
|  |  |  | conVo.tcpServerIp = ServerProperties.tcpServerIp ; | 
|---|
|  |  |  | conVo.tcpServerPort = ServerProperties.tcpServerPort ; | 
|---|
|  |  |  | conVo.sendInterval = ServerProperties.sendInterval ; | 
|---|
|  |  |  | conVo.heartbeatTimes = ServerProperties.heartbeatTimes ; | 
|---|
|  |  |  | conVo.sendTimes = ServerProperties.sendTimes ; | 
|---|
|  |  |  | sta = new MwTestClientStatus() ; | 
|---|
|  |  |  | sta.confVo = conVo ; | 
|---|
|  |  |  | 
|---|
|  |  |  | MwTestClientStatus sta = token2ClientMap.get("" + token); | 
|---|
|  |  |  | if(sta == null){ | 
|---|
|  |  |  | sta = new MwTestClientStatus() ; | 
|---|
|  |  |  | sta.overCount = rqVo.overCount ; | 
|---|
|  |  |  | token2ClientMap.put("" + token, sta); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | sta.overCount = rqVo.overCount ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private static void doDealAllOver(RmiRequestVo rqVo){ | 
|---|
|  |  |  | int token = Integer.parseInt(rqVo.token) ; | 
|---|
|  |  |  | MwTestClientStatus sta = token2ClientMap.get("" + token); | 
|---|
|  |  |  | if(sta == null){ | 
|---|
|  |  |  | sta = new MwTestClientStatus() ; | 
|---|
|  |  |  | if(rqVo.over != null && rqVo.over){ | 
|---|
|  |  |  | sta.over = true ; | 
|---|
|  |  |  | sta.seconds = rqVo.seconds ; | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | public String tcpServerIp = "" ; | 
|---|
|  |  |  | //éä¿¡ä¸é´ä»¶ç«¯å£ | 
|---|
|  |  |  | public Integer tcpServerPort = 0 ; | 
|---|
|  |  |  | //åéæ°æ®æ°æ®é´é | 
|---|
|  |  |  | public Integer sendInterval = 2 ;//ç§ | 
|---|
|  |  |  | //æ¯ä¸è½®æ¬¡åéæ°æ®ï¼å
¶ä¸å
æ¬å¿è·³å鿬¡æ° | 
|---|
|  |  |  | public Integer heartbeatTimes = 3 ; | 
|---|
|  |  |  | //åéæ°æ®æ¬¡æ° | 
|---|
|  |  |  | public Integer sendTimes = 0 ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * å¯¹è±¡è½¬æjson | 
|---|
|  |  |  | * @return è¿å json | 
|---|
|  |  |  | 
|---|
|  |  |  | this.tcpServerPort = tcpServerPort; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public Integer getSendInterval() { | 
|---|
|  |  |  | return sendInterval; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void setSendInterval(Integer sendInterval) { | 
|---|
|  |  |  | this.sendInterval = sendInterval; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public Integer getHeartbeatTimes() { | 
|---|
|  |  |  | return heartbeatTimes; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void setHeartbeatTimes(Integer heartbeatTimes) { | 
|---|
|  |  |  | this.heartbeatTimes = heartbeatTimes; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public Integer getSendTimes() { | 
|---|
|  |  |  | return sendTimes; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public Integer count ;//mwTest䏿¥æ°æ®æ°é | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public Integer overCount ;//mwTest宿å
¨é¨ä¸æ¥æ°æ®RTUæ°é | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public Boolean over ;//mwTest䏿¥æ°æ®ç»æ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public Long seconds ;//mwTest䏿¥æ°æ®ç¨æ¶(ç§) | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public Integer count;//mwTest䏿¥æ°æ®æ°é | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public Integer overCount;//aepTestç»æä¸æ¥æ°æ®æ°é | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public Boolean over ;//mwTest䏿¥æ°æ®ç»æ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public Long seconds ;//mwTest䏿¥æ°æ®ç¨æ¶(ç§) | 
|---|
|  |  |  | 
|---|
|  |  |  | this.seconds = seconds; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public Integer getOverCount() { | 
|---|
|  |  |  | return overCount; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void setOverCount(Integer overCount) { | 
|---|
|  |  |  | this.overCount = overCount; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | rtuAddrsPerMwTest: æ¯ä¸ªmwTeståé
çRtuAddræ° | 
|---|
|  |  |  | tcpServerIp: éä¿¡ä¸é´ä»¶IP | 
|---|
|  |  |  | tcpServerPort: éä¿¡ä¸é´ä»¶ç«¯å£ | 
|---|
|  |  |  | sendIntervalï¼åéæ°æ®é´é ç§ | 
|---|
|  |  |  | heartbeatTimesï¼æ¯ä¸è½®æ¬¡åéæ°æ®ï¼å
¶ä¸å
æ¬å¿è·³å鿬¡æ° | 
|---|
|  |  |  | sendTimesï¼åéæ°æ®æ¬¡æ° | 
|---|
|  |  |  | --> | 
|---|
|  |  |  | <base | 
|---|
|  |  |  | 
|---|
|  |  |  | rtuAddrPerMwTest="1" | 
|---|
|  |  |  | tcpServerIp="127.0.0.1" | 
|---|
|  |  |  | tcpServerPort="60000" | 
|---|
|  |  |  | sendInterval="2" | 
|---|
|  |  |  | heartbeatTimes="3" | 
|---|
|  |  |  | sendTimes="1" | 
|---|
|  |  |  | /> | 
|---|
|  |  |  |  | 
|---|
| New file | 
|  |  |  | 
|---|
|  |  |  | <?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å½åç¨æ·å¨æä½ç³»ç»ä¸çææ¡£ç®å½ | 
|---|
|  |  |  | /logs/testJgroups.logå½å软件æå¨ç¡¬çæ ¹ç®å½ | 
|---|
|  |  |  | logs/testJgroups.logå½å软件æå¨ç®å½ | 
|---|
|  |  |  | --> | 
|---|
|  |  |  | <RollingFile name="File" fileName="logs/mwTestSv.log" filePattern="logs/aepTest-%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> | 
|---|
|  |  |  | <!-- Rootä¸å个Loggeråæ¶èµ·ä½ç¨ --> | 
|---|
|  |  |  | <Root level="info"> | 
|---|
|  |  |  | <AppenderRef ref="Console"/> | 
|---|
|  |  |  | <AppenderRef ref="File"/> | 
|---|
|  |  |  | </Root> | 
|---|
|  |  |  | </Loggers> | 
|---|
|  |  |  | </Configuration> | 
|---|
|  |  |  | 
|---|
|  |  |  | <groupId>com.dy</groupId> | 
|---|
|  |  |  | <artifactId>pipIrr-common</artifactId> | 
|---|
|  |  |  | <version>1.0.0</version> | 
|---|
|  |  |  | <scope>provided</scope> | 
|---|
|  |  |  | <!-- | 
|---|
|  |  |  | scopeä¸è½ç¨providedï¼å¦åServer.javaçè¿è¡ä¸èµ·æ¥ | 
|---|
|  |  |  | scopeä¸è½ç¨runtimeï¼å¦åä¸è½ç¼è¾ | 
|---|
|  |  |  | --> | 
|---|
|  |  |  | <scope>compile</scope> | 
|---|
|  |  |  | <optional>true</optional> | 
|---|
|  |  |  | <exclusions> | 
|---|
|  |  |  | <exclusion> | 
|---|
|  |  |  | 
|---|
|  |  |  | <groupId>com.dy</groupId> | 
|---|
|  |  |  | <artifactId>pipIrr-global</artifactId> | 
|---|
|  |  |  | <version>1.0.0</version> | 
|---|
|  |  |  | <scope>provided</scope> | 
|---|
|  |  |  | <scope>compile</scope> | 
|---|
|  |  |  | <optional>true</optional> | 
|---|
|  |  |  | <exclusions> | 
|---|
|  |  |  | <exclusion> | 
|---|
|  |  |  | 
|---|
|  |  |  | target/ | 
|---|
|  |  |  | /pipIrr-web.iml | 
|---|
|  |  |  | pipIrr-web.iml | 
|---|
|  |  |  | 
|---|
|  |  |  | HELP.md | 
|---|
|  |  |  | target/ | 
|---|
|  |  |  | /pipIrr-web-sso.iml | 
|---|
|  |  |  | mvnw | 
|---|
|  |  |  | !.mvn/wrapper/maven-wrapper.jar | 
|---|
|  |  |  | !**/src/main/**/target/ | 
|---|
|  |  |  | !**/src/test/**/target/ | 
|---|