26个文件已修改
20个文件已删除
24个文件已添加
4 文件已重命名
| | |
| | | <orderEntry type="library" name="Maven: org.jdom:jdom2:2.0.6.1" level="project" /> |
| | | <orderEntry type="library" name="Maven: cn.hutool:hutool-all:5.8.21" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.apache.mina:mina-core:2.2.1" level="project" /> |
| | | <orderEntry type="library" name="Maven: org.quartz-scheduler:quartz-weblogic:2.1.7" level="project" /> |
| | | </component> |
| | | </module> |
| | |
| | | |
| | | private static CoreThread instance = new CoreThread() ; |
| | | |
| | | private static Long sleepBigBusy = 100L ;//å¤§å¿æ¶ï¼é¤äºæä¹
ä»»å¡ï¼è¿æ¯å
¶ä»ä»»å¡ï¼ï¼æ ¸å¿çº¿ç¨æåé´é |
| | | private static Long sleepBigBusy = 100L ;//å¤§å¿æ¶ï¼é¤äºæä¹
ä»»å¡ï¼è¿æå
¶ä»ä»»å¡ï¼ï¼æ ¸å¿çº¿ç¨æåé´é |
| | | private static Long sleepSmallBusy = 500L ;//å°å¿æ¶ï¼åªææä¹
ä»»å¡ï¼æ å
¶ä»ä»»å¡ï¼ï¼æ ¸å¿çº¿ç¨æåé´é |
| | | |
| | | private CoreThread(){ |
| | |
| | | |
| | | /** |
| | | * 设置æåæ¶é¿ |
| | | * @param sleepWorking |
| | | * @param sleepIdel |
| | | * @param sleepBigBusy å¤§å¿æ¶ï¼é¤äºæä¹
ä»»å¡ï¼è¿æå
¶ä»ä»»å¡ï¼ï¼æ ¸å¿çº¿ç¨æåé´é |
| | | * @param sleepSmallBusy å°å¿æ¶ï¼åªææä¹
ä»»å¡ï¼æ å
¶ä»ä»»å¡ï¼ï¼æ ¸å¿çº¿ç¨æåé´é |
| | | */ |
| | | public void setSleep(Long sleepBigBusy, Long sleepSmallBusy){ |
| | | CoreThread.sleepBigBusy = sleepBigBusy ; |
| | |
| | | * RTU å°å |
| | | */ |
| | | public String rtuAddr ; |
| | | |
| | | /** |
| | | * æ°´è¡¨å· |
| | | * åºç¨çµä¿¡å¹³å°æ¶ææ |
| | | */ |
| | | public String meterNo ; |
| | | |
| | | /** |
| | | * çµä¿¡å¹³å°ä¸ç产åIDï¼å½ä¸å¨çµä¿¡å¹³å°ä¸è¿è¡æ¶ï¼ä¸ºnull |
| | | * åºç¨çµä¿¡å¹³å°æ¶ææ |
| | | */ |
| | | public Integer productId ; |
| | | |
| | | /** |
| | | * çµä¿¡å¹³å°ä¸ç设å¤IDï¼å½ä¸å¨çµä¿¡å¹³å°ä¸è¿è¡æ¶ï¼ä¸ºnull |
| | | * åºç¨çµä¿¡å¹³å°æ¶ææ |
| | | */ |
| | | public String deviceId ; |
| | | |
| | | |
| | | /** |
| | | * å½ä»¤ç±»å:Rtuå½ä»¤ãéå¯¹çæ§ä¸é´ä»¶çå½ä»¤ |
| | | * ç±com.dy.common.mw.protocol.CommandTypeç±»å®ä¹ |
| | |
| | | String s = "å½ä»¤id=" + id + "\n" ; |
| | | s += (protocol == null ? "" : ("åè®®=" + protocol + "\n")); |
| | | s += (rtuAddr == null ? "" : ("IMEIå·=" + rtuAddr + "\n")); |
| | | s += (meterNo == null ? "" : ("水表å·=" + meterNo + "\n")); |
| | | if(productId != null){ |
| | | s += "çµä¿¡å¹³å°äº§åID=" + productId + "\n" ; |
| | | } |
| | | if(deviceId != null && !deviceId.trim().equals("")){ |
| | | s += "çµä¿¡å¹³å°è®¾å¤ID=" + deviceId + "\n" ; |
| | | } |
| | | s += "å½ä»¤ç±»å=" + (type.equals(CommandType.innerCommand)?"å
é¨å½ä»¤":"ç»ç«¯å½ä»¤") + "\n" ; |
| | | s += (code == null ? "" : ("åè½ç =" + code + "\n")) ; |
| | | s += "è¿åä¸é´ä»¶å¯¹å½ä»¤å¤çç»æ=" + (noRtMwDealRes == null?"è¿å":(noRtMwDealRes?"ä¸è¿å":"è¿å") + "\n") ; |
| | |
| | | } |
| | | public void setProtocol(String protocol) { |
| | | this.protocol = protocol; |
| | | } |
| | | public String getMeterNo() { |
| | | return meterNo; |
| | | } |
| | | public void setMeterNo(String meterNo) { |
| | | this.meterNo = meterNo; |
| | | } |
| | | public Integer getProductId() { |
| | | return productId; |
| | | } |
| | | public void setProductId(Integer productId) { |
| | | this.productId = productId; |
| | | } |
| | | public String getDeviceId() { |
| | | return deviceId; |
| | | } |
| | | public void setDeviceId(String deviceId) { |
| | | this.deviceId = deviceId; |
| | | } |
| | | public String getType() { |
| | | return type; |
| | |
| | | |
| | | /** |
| | | * æ°æ®æ ¹ |
| | | * @author Administrator |
| | | * |
| | | */ |
| | | public class Data implements java.io.Serializable{ |
| | |
| | | |
| | | private String commandId ;//å½ä»¤IDï¼å¯è½ä¸ºnull |
| | | private String rtuAddr ;//ç»ç«¯å°å |
| | | private String meterNo ;//æ°´è¡¨å· |
| | | private String protocol ;//æ°æ®æå¯¹åºçåè®®åç§° |
| | | private String code ;//æ°æ®æå¯¹åºçåè½ç : |
| | | private Object subData ;//对åºå个åè½ç çå
·ä½æ°æ® |
| | |
| | | StringBuilder sb = new StringBuilder() ; |
| | | sb.append("ä¸è¡æ¥æ(åå
è¿å¶): ").append((hex == null?"":hex)).append("\n") ; // |
| | | sb.append("IMEIå· : ").append((rtuAddr==null?"":rtuAddr)).append("\n") ; |
| | | sb.append("æ°´è¡¨å· : ").append((meterNo==null?"":meterNo)).append("\n") ; |
| | | if(commandId != null){ |
| | | sb.append("å½ä»¤ID : ").append(commandId).append("\n") ; //å½ä»¤ID |
| | | } |
| | |
| | | this.rtuAddr = rtuAddr; |
| | | } |
| | | |
| | | public String getMeterNo() { |
| | | return meterNo; |
| | | } |
| | | public void setMeterNo(String meterNo) { |
| | | this.meterNo = meterNo; |
| | | } |
| | | public String getCode() { |
| | | return code; |
| | | } |
| | |
| | | return codeParse ; |
| | | } |
| | | /** |
| | | * è§£æä¸è¡æ°æ® |
| | | * è§£æçµä¿¡å¹³å°ä¸è¡æ°æ® |
| | | * @param isLowPower æ¯å¦å¨ä½åèç¯å¢ä¸è¿è¡ |
| | | * @param rtuAddr æ§å¶å¨å°å |
| | | * @param upBuffer åèæ°ç» |
| | |
| | | * @return MidResult[] |
| | | */ |
| | | public abstract MidResult[] parseData(Boolean isLowPower, String rtuAddr, byte[] upBuffer, String upHex, DriverParserDataCallback callback, Object... params) ; |
| | | /** |
| | | * è§£æçµä¿¡å¹³å°ä¸è¡æ°æ® |
| | | * @param isLowPower æ¯å¦å¨ä½åèç¯å¢ä¸è¿è¡ |
| | | * @param rtuAddr æ§å¶å¨å°å |
| | | * @param productId çµä¿¡å¹³å°äº§åIDï¼å½ä¸å¨çµä¿¡å¹³å°ä¸è¿è¡æ¶ï¼ä¸ºnull |
| | | * @param deviceId çµä¿¡å¹³å°è®¾å¤IDï¼å½ä¸å¨çµä¿¡å¹³å°ä¸è¿è¡æ¶ï¼ä¸ºnull |
| | | * @param upBuffer åèæ°ç» |
| | | * @param upHex åèæ°ç»16è¿å¶å½¢å¼ |
| | | * @param callback åè° |
| | | * @return MidResult[] |
| | | */ |
| | | public abstract MidResult[] parseData(Boolean isLowPower, String rtuAddr, Integer productId, String deviceId, byte[] upBuffer, String upHex, DriverParserDataCallback callback, Object... params) ; |
| | | |
| | | /** |
| | | * æé ä¸è¡æ°æ®ï¼å½ä»¤ï¼ |
| | |
| | | |
| | | /** |
| | | * è§£æä¸è¡æ°æ®ååè° |
| | | * @param rtuAddr ä¸è¡æ°æ®å议头ä¸çIMEIå· |
| | | * @param meterNo ä¸è¡æ°æ®å议头ä¸çæ°´è¡¨å· |
| | | * @param rtuAddr ä¸è¡æ°æ®å议头ä¸RtuAddr |
| | | * @param code ä¸è¡æ°æ® åè½ç |
| | | * @param upHex ä¸è¡æ°æ® |
| | | * @param reportOrResponse_trueOrFalse ä¸è¡æ°æ®æ¯ä¸»å¨ä¸æ¥è¿æ¯å½ä»¤ç»æ |
| | | * @param parseFail ä¸è¡æ°æ®è§£ææ¯å¦å¤±è´¥ |
| | | * @param rtuAddrInData ä¸è¡æ°æ®ä¸å¨åè®®æ°æ®ä¸çIMEIå·ï¼ |
| | | * @param meterNoInData ä¸è¡æ°æ®ä¸å¨åè®®æ°æ®ä¸ç水表å·ï¼ |
| | | * âä¿®æ¹RTUç»ç«¯ç®¡çé
ç½®åæ°âå½ä»¤çè¿åæ°æ®ï¼å
¶å议头ä¸çIMEIå·ä¸æ°æ®ä¸çIMEIå·ä¸ä¸æ ·ï¼ |
| | | * 妿RTUä¸è½å
³éç½ç»ï¼é£ä¹sessionCachä¸çIMEIå·æ»æ¯ç¨ä¿®æ¹åçIMEIå·ï¼ä½¿å¾ä»¥åä¸è¡æ°æ®çä¸è½æ¾å°ç¼åä¸çSession |
| | | */ |
| | | void callback(String rtuAddr, |
| | | String meterNo, |
| | | String code, |
| | | String code, |
| | | String upHex, |
| | | Boolean reportOrResponse_trueOrFalse, |
| | | boolean parseFail, |
| | | String rtuAddrInData, |
| | | String meterNoInData) ; |
| | | String rtuAddrInData) ; |
| | | } |
| | |
| | | |
| | | public String protocolName ;//åè®®åç§° |
| | | public String rtuAddr ;//IMEIå·ï¼æ³¨ærtuAddrå¯è½ä¸ºnull |
| | | public String meterNo ;//水表å·ï¼æ³¨æmeterNoå¯è½ä¸ºnull |
| | | public String message ;//åºéæ¶æ¯ |
| | | public Exception e ;//å¼å¸¸ |
| | | |
| | | public MidResultError(String protocolName, String rtuAddr, String meterNo, String message, Exception e){ |
| | | public MidResultError(String protocolName, String rtuAddr, String message, Exception e){ |
| | | this.protocolName = protocolName ; |
| | | this.rtuAddr = rtuAddr ; |
| | | this.meterNo = meterNo ; |
| | | this.message = message ; |
| | | this.e = e ; |
| | | } |
| | |
| | | |
| | | public String protocolName ;//åè®®åç§° |
| | | public String rtuAddr ;//IMEIå· |
| | | public String meterNo ;//æ°´è¡¨å· |
| | | public Integer productId ;//çµä¿¡å¹³å°äº§åIDï¼å½ä¸å¨çµä¿¡å¹³å°è¿è¡æ¶ï¼ä¸ºnull |
| | | public String deviceId ;//çµä¿¡å¹³å°è®¾å¤IDï¼å½ä¸å¨çµä¿¡å¹³å°è¿è¡æ¶ï¼ä¸ºnull |
| | | public String upCode ;//ä¸è¡æ°æ®ä¸çåè½ç |
| | | public String upHex ;//ä¸è¡æ°æ®åå
è¿å¶å½¢å¼ |
| | | public byte[] upBuffer ;//ä¸è¡æ°æ®åèæ°ç» |
| | |
| | | |
| | | public String protocolName ;//åè®®åç§° |
| | | public String rtuAddr ;//IMEIå·(çµä¿¡å¹³å°IMEI) |
| | | public String meterNo ;//æ°´è¡¨å· |
| | | public Integer productId ;//çµä¿¡å¹³å°äº§åID |
| | | public String deviceId ;//çµä¿¡å¹³å°è®¾å¤ID |
| | | public String commandId ;//å½ä»¤IDï¼åèµ·å½ä»¤ç客æ·ç«¯(web端)çæï¼ä»¥å¹é
å½ä»¤ç»æ |
| | | public String downCode ;//ä¸è¡å½ä»¤åè½ç ; |
| | | public byte[] downBuffer ;//ä¸è¡å½ä»¤æ°æ® |
| | |
| | | public int result ;//åæç»æ |
| | | public String protocolName ;//åè®®åç§° |
| | | public String rtuAddr ;//IMEIå· |
| | | public String meterNo ;//æ°´è¡¨å· |
| | | public byte[] remoteData;//éè¦åRtuååçæ°æ® |
| | | public OnLineResult(){ |
| | | result = OnLineAction_fail ; |
| | | rtuAddr = null ; |
| | | meterNo = null ; |
| | | remoteData = null ; |
| | | } |
| | | } |
| | |
| | | public class OnLineHandle { |
| | | |
| | | /** |
| | | * è§£æä¸çº¿æ°æ®ï¼å¾å°IMEIå· |
| | | * è§£æä¸çº¿æ°æ®ï¼å¾å°RtuAddr |
| | | * @param bs åèæ°ç» |
| | | * @return OnLine.OnLineResult |
| | | */ |
| | |
| | | if(set.size() == 0){ |
| | | throw new Exception("ä¸çº¿æ°æ®å®æ´æ§æ£æ¥æ¶ï¼å¾å°çåè®®å®æ´æ§æ£æ¥ç±»éå为空ã") ; |
| | | } |
| | | int prority = ProtocolConstant.firstPriority ; |
| | | int priority = ProtocolConstant.firstPriority ; |
| | | |
| | | while(true){ |
| | | Object[] objs = this.getClassObjAndAnnotationVo(prority, set) ; |
| | | Object[] objs = this.getClassObjAndAnnotationVo(priority, set) ; |
| | | PrefixedDataAvailable pda = (PrefixedDataAvailable)objs[0] ; |
| | | if(pda == null && prority == ProtocolConstant.firstPriority){ |
| | | throw new Exception("ä¸çº¿æ°æ®å®æ´æ§æ£æ¥æ¶ï¼æªå¾å°ä¼å
级为" + prority + "ä¸çº¿æ°æ®å®æ´æ§æ£æ¥ç±»ï¼") ; |
| | | if(pda == null && priority == ProtocolConstant.firstPriority){ |
| | | throw new Exception("ä¸çº¿æ°æ®å®æ´æ§æ£æ¥æ¶ï¼æªå¾å°ä¼å
级为" + priority + "ä¸çº¿æ°æ®å®æ´æ§æ£æ¥ç±»ï¼") ; |
| | | }else if(pda == null){ |
| | | //说æä¸çº¿æ°æ®å®æ´æ§æ£æ¥ç±»éåå·²ç»éåå®äºã |
| | | break ; |
| | |
| | | if(pds == null){ |
| | | //说æä¸æ¯å¯¹åºçåè®®æ°æ®ï¼éè¦å¦å¤çåè®®æ¥å¤çä¸çº¿ |
| | | //循ç¯ç»§ç» |
| | | prority++ ; |
| | | priority++ ; |
| | | }else{ |
| | | //åæ¢å¾ªç¯ï¼è¿åç»æ |
| | | break ; |
| File was renamed from pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/CodeV1_0_1.java |
| | |
| | | package com.dy.common.mw.protocol.pMeterV1_0_1; |
| | | package com.dy.common.mw.protocol.p206V1_0_0; |
| | | |
| | | public class CodeV1_0_1 { |
| | | //åè½ç 为å符串ï¼åå
è¿å¶æ°æ® |
| | | public static final String cd_01 = "01" ;//宿¶ï¼å¨æï¼ä¸æ¥ |
| | | public static final String cd_02 = "02" ;//宿¶(触å)䏿¥ |
| | | public static final String cd_02 = "02" ;//é¾è·¯æ£æµ |
| | | public static final String cd_03 = "03" ;//äºä»¶ä¸æ¥ |
| | | public static final String cd_04 = "04" ;//å¼é |
| | | public static final String cd_05 = "05" ;//å
³é |
| | | public static final String cd_06 = "06" ;//éé¨å¨ä½ç»æ |
| | | |
| | | public static String getCodeName(String code) { |
| | | String name = (code.equals(cd_01) ? "宿¶ä¸æ¥ " : |
| | | (code.equals(cd_02) ? "触å䏿¥" : |
| | | (code.equals(cd_03) ? "äºä»¶ä¸æ¥" : |
| | | String name = (code.equals(cd_02) ? "é¾è·¯æ£æµ" : |
| | | (code.equals(cd_03) ? "äºä»¶ä¸æ¥" : |
| | | (code.equals(cd_04) ? "å¼é" : |
| | | (code.equals(cd_05) ? "å
³é" : |
| | | (code.equals(cd_06) ? "éé¨å¨ä½ç»æ" : |
| | | "")))))) ; |
| | | ""))))) ; |
| | | return name ; |
| | | } |
| | | |
| | | /** |
| | | * æ¯å¦ä¸ºææåè½ç |
| | | * @param code |
| | | * @return |
| | | * @param code åè½ç |
| | | * @return æætrueï¼æ æfalse |
| | | */ |
| | | public static boolean isValid(String code){ |
| | | String name = getCodeName(code) ; |
| New file |
| | |
| | | package com.dy.common.mw.protocol.p206V1_0_0; |
| | | |
| | | import com.dy.common.util.ByteUtil; |
| | | import com.dy.common.util.ByteUtilUnsigned; |
| | | |
| | | |
| | | public class CommonV1_0_1 { |
| | | /** |
| | | * æ£æ¥å¤´ |
| | | * @param bs ä¸è¡åèæ°ç» |
| | | * @return trueæ¯,falseå¦ |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public Boolean isThisProtocolHead(byte[] bs) throws Exception{ |
| | | if(bs == null){ |
| | | return null ; |
| | | }else if(bs.length >= (ProtocolConstantV206V1_0_0.ctrlIndex - 1) |
| | | && bs[0] == ProtocolConstantV206V1_0_0.P_Head_Byte |
| | | && bs[2] == ProtocolConstantV206V1_0_0.P_Head_Byte){ |
| | | //String vs = this.parseVersion(bs) ; |
| | | //return vs.equals(ProtocolConstantV206V1_0_0.version); |
| | | return true ; |
| | | }else{ |
| | | return false ; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æ£æ¥å¤´ |
| | | * @param bs ä¸è¡åèæ°ç» |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public void checkHead(byte[] bs) throws Exception{ |
| | | if(bs.length < 13 || bs[0] != ProtocolConstantV206V1_0_0.P_Head_Byte || bs[2] != ProtocolConstantV206V1_0_0.P_Head_Byte){ |
| | | throw new Exception("ä¸è¡æ°æ®å¸§å¤´ä¸æ£ç¡®ï¼") ; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æ£æ¥å°¾ |
| | | * @param bs ä¸è¡åèæ°ç» |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public void checkTail(byte[] bs) throws Exception{ |
| | | if(bs.length < 1 || bs[bs.length - 1] != ProtocolConstantV206V1_0_0.P_Tail_Byte){ |
| | | throw new Exception("ä¸è¡æ°æ®å°¾ä¸æ£ç¡®ï¼") ; |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * åææ°æ®åèæ° |
| | | * @param bs ä¸è¡åèæ°ç» |
| | | * @return æ°æ®é¿åº¦ |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public int parseDataLen(byte[] bs)throws Exception{ |
| | | return ByteUtilUnsigned.bytes2Short_BE(bs, ProtocolConstantV206V1_0_0.dataLenIndex) ; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * åæIMEIå· |
| | | * @param bs ä¸è¡åèæ°ç» |
| | | * @return æ§å¶å¨å°å |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | 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){ |
| | | rtuAddrStr = "0" + rtuAddrStr ; |
| | | } |
| | | return rtuAddrBCD + rtuAddrStr ; |
| | | } |
| | | |
| | | /** |
| | | * åæåè½ç |
| | | * @param bs ä¸è¡åèæ°ç» |
| | | * @return åè½ç |
| | | */ |
| | | public String parseCode(byte[] bs){ |
| | | 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 ä¸è¡åèæ°ç» |
| | | * @return éè¿nullï¼æªéè¿è¿ååå |
| | | * @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){ |
| | | return null ; |
| | | }else{ |
| | | return "è®¡ç®æ ¡éªåæ¯:" + hes + "ï¼ä¸ä¼ æ ¡éªåæ¯" + heOrg ; |
| | | } |
| | | } |
| | | |
| | | |
| | | /* |
| | | æé æ§å¶å |
| | | D7 D6 D5ï½D4 D3ï½D0 |
| | | ä¼ è¾æ¹åä½ DIR æåæ å¿ä½ DIV 帧计æ°ä½ FCB åè½ç |
| | | */ |
| | | public byte createCtrl(byte funcCode){ |
| | | byte b = 0 ; |
| | | b = (byte)(b | funcCode) ; |
| | | //FCB == 3 |
| | | b = (byte)(b | (byte)60) ; |
| | | //DIV = 0 |
| | | //DIR = 0 |
| | | return b ; |
| | | } |
| | | |
| | | /* |
| | | * åæçæ¬å· |
| | | * @param bs ä¸è¡åèæ°ç» |
| | | * @return çæ¬å· |
| | | * @throws Exception å¼å¸¸ |
| | | public String parseVersion(byte[] bs)throws Exception{ |
| | | short ver = ByteUtilUnsigned.byte2Byte(bs, ProtocolConstantV206V1_0_0.versionIndex) ; |
| | | char[] cs = ("" + ver).toCharArray() ; |
| | | StringBuilder vs = new StringBuilder() ; |
| | | for(byte i = 0 ; i < cs.length; i++){ |
| | | if(i == 0){ |
| | | vs.append(cs[i]) ; |
| | | }else{ |
| | | vs.append(".").append(cs[i]) ; |
| | | } |
| | | } |
| | | return vs.toString() ; |
| | | } |
| | | */ |
| | | |
| | | } |
| New file |
| | |
| | | package com.dy.common.mw.protocol.p206V1_0_0; |
| | | |
| | | import lombok.Data; |
| | | |
| | | //é¾è·¯æ£æµ |
| | | @Data |
| | | public class DataCd02Vo { |
| | | |
| | | public String status ;//F0 ç»å½ï¼F1 éåºç»å½ï¼F2 å¨çº¿ä¿æ |
| | | |
| | | public String toString(){ |
| | | StringBuffer sb = new StringBuffer() ; |
| | | sb.append(" é¾è·¯æ£æµ : \n") ; |
| | | sb.append(" 请æ±ç¶æ : ") ; |
| | | sb.append(status == null?"":(status.equals("F0")?"ç»å½":(status.equals("F1")?"éåºç»å½":(status.equals("F2")?"å¨çº¿ä¿æ":status)))) ; |
| | | sb.append("\n") ; |
| | | return sb.toString() ; |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | package com.dy.common.mw.protocol.p206V1_0_0; |
| | | |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class DataCdC0Vo { |
| | | } |
| New file |
| | |
| | | package com.dy.common.mw.protocol.p206V1_0_0; |
| | | |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class DataV1_0_1 implements java.io.Serializable{ |
| | | |
| | | private static final long serialVersionUID = 202211271110001L; |
| | | |
| | | public String rtuAddr ;//RtuAddr |
| | | |
| | | public DataCd02Vo dataCd02Vo;//é¾è·¯æ£æµ |
| | | public DataCdC0Vo dataCdC0Vo;//ç»ç«¯èªæ¥å®æ¶æ°æ® |
| | | |
| | | public String dt ;//éä¿¡ä¸é´ä»¶äº§ç忥æ¶é´(yyyy-MM-dd hh:mm:ss) |
| | | |
| | | public String toString(){ |
| | | StringBuffer sb = new StringBuffer() ; |
| | | sb.append(" æ§å¶å¨å°å : " + (rtuAddr==null?"":rtuAddr) + "\n") ; |
| | | sb.append(" ç»ç«¯æ°æ®:\n") ; |
| | | if(dataCd02Vo != null){ |
| | | sb.append(dataCd02Vo.toString()) ; |
| | | } |
| | | return sb.toString() ; |
| | | } |
| | | } |
| New file |
| | |
| | | package com.dy.common.mw.protocol.p206V1_0_0; |
| | | |
| | | import com.dy.common.mw.protocol.*; |
| | | import com.dy.common.util.DateTime; |
| | | |
| | | import java.net.URI; |
| | | import java.net.URL; |
| | | |
| | | @AnnotationDriver(name= ProtocolConstantV206V1_0_0.protocolName) |
| | | public class DriverV1_0_1 extends Driver { |
| | | |
| | | private static String scanRootPackage = "" ; |
| | | |
| | | //å¨Driver䏿¯åä¾ï¼éDriverçåä¾å¯¹è±¡å¨å线ç¨ä¸è¿è¡ |
| | | private ParseParamsForUpV1_0_1 upCpParams ; |
| | | private ParseParamsForDownV1_0_1 downCpParams ; |
| | | |
| | | private Boolean reportOrResponse_trueOrFalse = null ; |
| | | private String rtuAddrInData = null ; |
| | | |
| | | public DriverV1_0_1(){ |
| | | upCpParams = new ParseParamsForUpV1_0_1() ; |
| | | downCpParams = new ParseParamsForDownV1_0_1() ; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * æ«æè¯å«åè½ç 注解类 |
| | | */ |
| | | @Override |
| | | public void scanAnnotationCode() throws Exception{ |
| | | if(!scanRootPackage.endsWith(".")){ |
| | | scanRootPackage += "." ; |
| | | } |
| | | URL url = this.getClass().getResource("/" + scanRootPackage.replace('.', '/')); |
| | | URI uri = new URI(url.toString()); |
| | | super.doScanAnnotationCode(this, ProtocolConstantV206V1_0_0.protocolName, uri, scanRootPackage) ; |
| | | } |
| | | |
| | | /** |
| | | * è§£æä¸è¡æ°æ® |
| | | * @param isLowPower æ¯å¦å¨ä½åèç¯å¢ä¸è¿è¡ |
| | | * @param rtuAddr |
| | | * @param upBuffer |
| | | * @param callback |
| | | * @param upHex |
| | | * @return |
| | | */ |
| | | @Override |
| | | public MidResult[] parseData(Boolean isLowPower, String rtuAddr, byte[] upBuffer, String upHex, DriverParserDataCallback callback, Object... params) { |
| | | reportOrResponse_trueOrFalse = null ; |
| | | boolean isFail = false ; |
| | | String upCode = null ; |
| | | try{ |
| | | CommonV1_0_1 cp = new CommonV1_0_1() ; |
| | | cp.checkHead(upBuffer) ; |
| | | cp.checkTail(upBuffer) ; |
| | | String crcStr = cp.checkCrc_str(upBuffer) ; |
| | | if(crcStr != null){ |
| | | return new MidResult[]{(new MidResultError(ProtocolConstantV206V1_0_0.protocolName, rtuAddr, "严éé误ï¼ä¸è¡æ°æ®CRCæ£æ¥å¤±è´¥ï¼" + crcStr, null))} ; |
| | | } |
| | | rtuAddr = cp.parseRtuAddr(upBuffer) ; |
| | | upCode = cp.parseCode(upBuffer) ; |
| | | if(upCode == null){ |
| | | return new MidResult[]{(new MidResultError(ProtocolConstantV206V1_0_0.protocolName, rtuAddr, "严ééè¯¯ï¼æªè½ä»ä¸è¡æ°æ®ä¸è§£æåºåè½ç ï¼", null))} ; |
| | | } |
| | | //Integer dataLen = cp.parseFrameLen(upBuffer) ; |
| | | Data upData = new Data() ; |
| | | upData.setRtuAddr(rtuAddr) ; |
| | | upData.setProtocol(ProtocolConstantV206V1_0_0.protocolName); |
| | | upData.setCode(upCode) ; |
| | | upData.setHex(upHex) ; |
| | | |
| | | |
| | | DataV1_0_1 dV1_0_1 = new DataV1_0_1() ; |
| | | //dV1_0_1.version = cp.parseVersion(upBuffer) ; |
| | | dV1_0_1.rtuAddr = rtuAddr ; |
| | | dV1_0_1.dt = DateTime.yyyy_MM_dd_HH_mm_ss() ; |
| | | |
| | | upData.setSubData(dV1_0_1) ; |
| | | |
| | | this.upCpParams.clear(); |
| | | this.upCpParams.setValue(ProtocolConstantV206V1_0_0.protocolName, |
| | | rtuAddr, |
| | | upCode, |
| | | upHex, |
| | | upBuffer, |
| | | upData); |
| | | CodeParse codeParse = this.getUpCodeParser(upCode) ; |
| | | if(codeParse == null){ |
| | | return new MidResult[]{(new MidResultError(ProtocolConstantV206V1_0_0.protocolName, rtuAddr, "严ééè¯¯ï¼æªè½å¾å°ä¸è¡æ°æ®åè½ç " + upCode + "å¤çç±»!", null))} ; |
| | | }else{ |
| | | return codeParse.parse(isLowPower, this.upCpParams, new CodeParseCallback(){ |
| | | @Override |
| | | public void callback(Boolean flag) { |
| | | reportOrResponse_trueOrFalse = flag ; |
| | | rtuAddrInData = dV1_0_1.getRtuAddr() ; |
| | | } |
| | | }); |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | isFail = true ; |
| | | return new MidResult[]{(new MidResultError(ProtocolConstantV206V1_0_0.protocolName, rtuAddr, "严éé误ï¼åæRtuæ°æ®åºéï¼æ°æ®ä¸ºï¼" + upHex + (e.getMessage() == null?"":("ï¼åºéä¿¡æ¯ï¼" + e.getMessage())), e))} ; |
| | | } finally{ |
| | | callback.callback(rtuAddr, upCode, upHex, reportOrResponse_trueOrFalse, isFail, rtuAddrInData); |
| | | } |
| | | } |
| | | /** |
| | | * æé ä¸è¡æ°æ®ï¼å½ä»¤ï¼ |
| | | * @param isLowPower æ¯å¦å¨ä½åèç¯å¢ä¸è¿è¡ |
| | | * @param command å½ä»¤ |
| | | * @return |
| | | */ |
| | | @Override |
| | | public MidResult[] createCommand(Boolean isLowPower, Command command, Object... params) { |
| | | String rtuAddr = command.getRtuAddr() ; |
| | | if(rtuAddr == null){ |
| | | return new MidResult[]{(new MidResultError(ProtocolConstantV206V1_0_0.protocolName, null, "严éé误ï¼å½ä»¤ä¸IMEIå·ä¸ºç©ºï¼ä¸è½æå»ºä»»ä½å½ä»¤ï¼", null))} ; |
| | | } |
| | | try { |
| | | String commandCode = command.getCode() ; |
| | | |
| | | this.downCpParams.clear(); |
| | | this.downCpParams.setValue( |
| | | ProtocolConstantV206V1_0_0.protocolName, |
| | | rtuAddr, |
| | | command.getId(), |
| | | commandCode, |
| | | command.getParam(), |
| | | command.getAttachment()); |
| | | |
| | | if(commandCode == null){ |
| | | return new MidResult[]{(new MidResultError(ProtocolConstantV206V1_0_0.protocolName, rtuAddr, "严éé误ï¼å½ä»¤ä¸åè½ç 为空ï¼ä¸è½æå»ºä»»ä½å½ä»¤ï¼", null))} ; |
| | | }else{ |
| | | CodeParse codeParse = this.getDownCodeParser(commandCode) ; |
| | | if(codeParse == null){ |
| | | return new MidResult[]{(new MidResultError(ProtocolConstantV206V1_0_0.protocolName, rtuAddr, "严ééè¯¯ï¼æªè½å¾å°ä¸è¡æ°æ®åè½ç " + commandCode + "å¤çç±»!", null))} ; |
| | | }else{ |
| | | return codeParse.parse(isLowPower, this.downCpParams, null); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | return new MidResult[]{(new MidResultError(ProtocolConstantV206V1_0_0.protocolName, rtuAddr, "严ééè¯¯ï¼æé ä¸è¡æ°æ®åºéï¼å½ä»¤ä¸ºï¼" + command.toString(), e))} ; |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| File was renamed from pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/OnLineV1_0_1.java |
| | |
| | | package com.dy.common.mw.protocol.pMeterV1_0_1; |
| | | package com.dy.common.mw.protocol.p206V1_0_0; |
| | | |
| | | import com.dy.common.mw.protocol.AnnotationOnLine; |
| | | import com.dy.common.mw.protocol.OnLine; |
| | | |
| | | @AnnotationOnLine( |
| | | protocolName = ProtocolConstantV1_0_1.protocolName, |
| | | priority = ProtocolConstantV1_0_1.priority) |
| | | protocolName = ProtocolConstantV206V1_0_0.protocolName, |
| | | priority = ProtocolConstantV206V1_0_0.priority) |
| | | @SuppressWarnings("unused") |
| | | public class OnLineV1_0_1 implements OnLine{ |
| | | |
| | | /** |
| | |
| | | //åºé |
| | | olr.result = OnLine.OnLineAction_fail ; |
| | | olr.rtuAddr = null ; |
| | | olr.meterNo = null ; |
| | | }else if(!flag.booleanValue()){ |
| | | //䏿¯æ¬åè®®æ°æ® |
| | | olr.result = OnLine.OnLineAction_success_noMe ; |
| | | olr.rtuAddr = null ; |
| | | olr.meterNo = null ; |
| | | }else{ |
| | | //æ¯æ¬åè®®æ°æ® |
| | | olr.result = OnLine.OnLineAction_success ; |
| | | olr.rtuAddr = cp.parseRtuAddr(upBuf) ; |
| | | olr.meterNo = cp.parseMeterNo(upBuf) ; |
| | | olr.protocolName = ProtocolConstantV1_0_1.protocolName ; |
| | | olr.protocolName = ProtocolConstantV206V1_0_0.protocolName ; |
| | | } |
| | | return olr; |
| | | } |
| New file |
| | |
| | | package com.dy.common.mw.protocol.p206V1_0_0; |
| | | |
| | | import com.dy.common.mw.protocol.CodeParseParams; |
| | | |
| | | public class ParseParamsForDownV1_0_1 implements CodeParseParams{ |
| | | |
| | | public String protocolName ; |
| | | public String rtuAddr ;//æ§å¶å¨å°å |
| | | public String commandId ; |
| | | public String commandCode ; |
| | | public Object param ; |
| | | public Object attachment ; |
| | | |
| | | public ParseParamsForDownV1_0_1(){} |
| | | |
| | | public void clear(){ |
| | | this.protocolName = null ; |
| | | this.rtuAddr = null ; |
| | | this.commandId = null ; |
| | | this.commandCode = null ; |
| | | this.param = null ; |
| | | this.attachment = null ; |
| | | } |
| | | |
| | | public void setValue( |
| | | String protocolName, |
| | | String rtuAddr, |
| | | String commandId, |
| | | String commandCode, |
| | | Object param, |
| | | Object attachment ){ |
| | | this.protocolName = protocolName ; |
| | | this.rtuAddr = rtuAddr ; |
| | | this.commandId = commandId ; |
| | | this.commandCode = commandCode ; |
| | | this.param = param ; |
| | | this.attachment = attachment ; |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | package com.dy.common.mw.protocol.p206V1_0_0; |
| | | |
| | | import com.dy.common.mw.protocol.CodeParseParams; |
| | | import com.dy.common.mw.protocol.Data; |
| | | |
| | | public class ParseParamsForUpV1_0_1 implements CodeParseParams{ |
| | | |
| | | public String protocolName ;//åè®®åç§° |
| | | public String rtuAddr ;//æ§å¶å¨å |
| | | public String upCode ;//ä¸è¡æ¥ææ°æ®ä¸çåè½ç |
| | | public String upHex ;//è¡æ¥ææ°æ®åå
è¿å¶å½¢å¼ |
| | | public byte[] upBuffer ;//è¡æ¥ææ°æ®åèæ°ç» |
| | | public Data data ;//è§£æåçæ°æ® |
| | | |
| | | public ParseParamsForUpV1_0_1(){} |
| | | |
| | | public void clear(){ |
| | | this.protocolName = null ; |
| | | this.rtuAddr = null ; |
| | | this.upCode = null ; |
| | | this.upHex = null ; |
| | | this.upBuffer = null ; |
| | | this.data = null ; |
| | | } |
| | | |
| | | public void setValue(String protocolName, |
| | | String rtuAddr, |
| | | String upCode, |
| | | String upHex, |
| | | byte[] upBuffer, |
| | | Data data){ |
| | | this.protocolName = protocolName ; |
| | | this.rtuAddr = rtuAddr ; |
| | | this.upCode = upCode ; |
| | | this.upHex = upHex ; |
| | | this.upBuffer = upBuffer ; |
| | | this.data = data ; |
| | | } |
| | | } |
| File was renamed from pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/pMeterV1_0_1/PrefixedDataAvailableV1_0_1.java |
| | |
| | | package com.dy.common.mw.protocol.pMeterV1_0_1; |
| | | |
| | | import org.apache.logging.log4j.LogManager; |
| | | import org.apache.logging.log4j.Logger; |
| | | import org.apache.mina.core.buffer.BufferDataException; |
| | | import org.apache.mina.core.buffer.IoBuffer; |
| | | package com.dy.common.mw.protocol.p206V1_0_0; |
| | | |
| | | import com.dy.common.mw.channel.tcp.PrefixedDataAvailableStatus; |
| | | import com.dy.common.mw.protocol.AnnotationPrefixedDataAvailable; |
| | | import com.dy.common.mw.protocol.PrefixedDataAvailable; |
| | | import com.dy.common.util.ByteUtil; |
| | | import org.apache.logging.log4j.LogManager; |
| | | import org.apache.logging.log4j.Logger; |
| | | import org.apache.mina.core.buffer.BufferDataException; |
| | | import org.apache.mina.core.buffer.IoBuffer; |
| | | |
| | | |
| | | @AnnotationPrefixedDataAvailable( |
| | | protocolName = ProtocolConstantV1_0_1.protocolName, |
| | | priority = ProtocolConstantV1_0_1.priority, |
| | | onLineDataMinLength = ProtocolConstantV1_0_1.onLineDataMinLength, |
| | | headMinLength = ProtocolConstantV1_0_1.headMinLength) |
| | | public class PrefixedDataAvailableV1_0_1 implements PrefixedDataAvailable { |
| | | protocolName = ProtocolConstantV206V1_0_0.protocolName, |
| | | priority = ProtocolConstantV206V1_0_0.priority, |
| | | onLineDataMinLength = ProtocolConstantV206V1_0_0.onLineDataMinLength, |
| | | headMinLength = ProtocolConstantV206V1_0_0.headMinLength) |
| | | @SuppressWarnings("unused") |
| | | public class PrefixedDataAvailableV1_0_1 implements PrefixedDataAvailable { |
| | | |
| | | private static Logger log = LogManager.getLogger(PrefixedDataAvailableV1_0_1.class) ; |
| | | private static final Logger log = LogManager.getLogger(PrefixedDataAvailableV1_0_1.class) ; |
| | | |
| | | private static String protocolName = ProtocolConstantV1_0_1.protocolName ; |
| | | private static final String protocolName = ProtocolConstantV206V1_0_0.protocolName ; |
| | | |
| | | |
| | | /** |
| | | * åæä¸çº¿æ°æ®(ç½ç»è¿æ¥å第ä¸å
æ°æ®)æ¯å¦å¯è·å¾ |
| | | * @param in |
| | | * @param in IoBuffer |
| | | * @param remain ä¸å®æ¶å¤§äº0çæ°æ® |
| | | * @param minDataLength æå°æ°æ®é¿åº¦ |
| | | * @param maxDataLength æå¤§æ°æ®é¿åº¦ï¼è¾¾å°æè¶
è¿æ¤é¿åº¦ï¼è®¤ä¸ºæ¯å徿°æ®ãä¾å¦ï¼æ°æ®å¤´é¨æ¯æ£ç¡®çï¼ä½åæ³æ°æ®ç»å°¾æ»ä¸åºç°ï¼è®¤ä¸ºæ¤æ°æ®å徿°æ® |
| | | * @return 䏿¯æ¬åè®®æ°æ®æ¶è¿å空 |
| | | * @throws Exception |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public PrefixedDataAvailableStatus forOnLine(IoBuffer in, |
| | | int remain, |
| | |
| | | |
| | | /** |
| | | * åæä¸çº¿å(ç½ç»è¿æ¥åé第ä¸å
æ°æ®)æ¯å¦å¯è·å¾ |
| | | * @param in |
| | | * @param protocolConf Rtué
ç½® |
| | | * @param maxDataLength |
| | | * @return |
| | | * @throws Exception |
| | | * @param in IoBuffer |
| | | * @param remain å©ä½ |
| | | * @param minDataLength æå°æ°æ®é¿åº¦ |
| | | * @param maxDataLength æå¤§æ°æ®é¿åº¦ |
| | | * @return PrefixedDataAvailableStatus |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | @Override |
| | | public PrefixedDataAvailableStatus forUpData(IoBuffer in, |
| | |
| | | } |
| | | /** |
| | | * è¿è¡å¤æ |
| | | * @param preByte |
| | | * @param maxDataLength |
| | | * @return |
| | | * @param preByte byte[] |
| | | * @param minDataLength æå°æ°æ®é¿åº¦ |
| | | * @param maxDataLength æå¤§æ°æ®é¿åº¦ |
| | | * @return PrefixedDataAvailableStatus |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | private PrefixedDataAvailableStatus doForData(byte[] preByte, int minDataLength, int maxDataLength) throws Exception{ |
| | | int remain = preByte.length ; |
| | |
| | | } |
| | | |
| | | Integer dataLen = parseCommon.parseDataLen(preByte) ; |
| | | |
| | | String headHex = ByteUtil.bytes2Hex(preByte, true) ; |
| | | |
| | | |
| | | if(dataLen == null){ |
| | | String headHex = ByteUtil.bytes2Hex(preByte, true) ; |
| | | throw new BufferDataException("æ¶å°æ°æ®ä¹å¸§åé¨ï¼" + headHex + "ï¼ä½ä¸¥éé误ï¼å¨è¿è¡æå
ä¸ç²å
æ£æ¥æ¶ï¼æªè½å¾å°æ°æ®å¸§çé¿åº¦ã"); |
| | | } |
| | | |
| | | if (dataLen <= 0 || dataLen > maxDataLength) { |
| | | String headHex = ByteUtil.bytes2Hex(preByte, true) ; |
| | | throw new BufferDataException("æ¶å°æ°æ®ä¹å¸§åé¨ï¼" + headHex + "ï¼ä½ä¸¥éé误ï¼å¨è¿è¡æå
ä¸ç²å
æ£æ¥æ¶ï¼æ°æ®å¸§çé¿åº¦(" + dataLen + ")è¶
åºåæ³èå´ã"); |
| | | } |
| | | |
| | |
| | | //䏿ä¸ç² |
| | | return new PrefixedDataAvailableStatus().completed(dataLen) ; |
| | | }else if(remain > dataLen){ |
| | | String headHex = ByteUtil.bytes2Hex(preByte, true) ; |
| | | log.warn("æ¶å°æ°æ®ä¹å¸§åé¨ï¼" + headHex + "ï¼ä½åçç²å
ç°è±¡ã") ; |
| | | return new PrefixedDataAvailableStatus().adjoined(dataLen) ; |
| | | }else{ |
| | | // remain < dataLen |
| | | String headHex = ByteUtil.bytes2Hex(preByte, true) ; |
| | | log.warn("æ¶å°æ°æ®ä¹å¸§åé¨ï¼" + headHex + "ï¼ä½åçæå
ç°è±¡ã") ; |
| | | return new PrefixedDataAvailableStatus().breaked() ; |
| | | } |
| New file |
| | |
| | | package com.dy.common.mw.protocol.p206V1_0_0; |
| | | |
| | | public class ProtocolConstantV206V1_0_0 { |
| | | |
| | | public static final String version = "1.0.1" ; |
| | | public static final Byte versionByte = 101 ; |
| | | |
| | | /** |
| | | * 注解ç¸å
³ |
| | | */ |
| | | public static final String protocolName = "p206V1_0_1" ; |
| | | public static final int priority = 1 ;//ä¼å
级 |
| | | /** |
| | | * RTUä¸çº¿æ°æ®ï¼ä¸çº¿å第ä¸å
æ°æ®ï¼æå°é¿åº¦ï¼è®¾ç½®è¯¥å±æ§ä»¥å¤è¿è¡å®æ´æ§æ£æ¥ï¼ |
| | | * 峿å
æ£æ¥ï¼ä½¿å°½å¯è½æ¶å
¨ä¸çº¿æ°æ®ï¼åå¼èå´1-100ï¼ |
| | | */ |
| | | public static final int onLineDataMinLength = 30 ;//éç¨éæ§åæ§ï¼å
¶é¿åº¦æçï¼çåèæ° |
| | | |
| | | /** |
| | | * RTU䏿¥æ°æ®ç头鍿å°é¿åº¦ï¼ä¸æ¥æ°æ®ä¸ï¼åè¿ä¸ªæå°é¿åº¦çé¨åæ°æ®ä¸ï¼ |
| | | * è¦ä¸å®å
嫿°æ®å¸§é¿åº¦ï¼ä»¥å¤ååºæ°æ®å¸§é¿åº¦æ¥ï¼è¿è¡å®æ´æ§æ£æ¥ï¼ |
| | | * 峿å
ä¸ç²å
æ£æ¥(åå¼èå´0-100ï¼å
¶ä¸åå¼ä¸º0æ¶ï¼è¡¨ç¤ºheadMinLengthæ°æ®æ ä½ç¨ï¼ç±åè®®å®ç°æ¥æ§å¶) |
| | | */ |
| | | public static final int headMinLength = 3 ; |
| | | |
| | | |
| | | //å¸§èµ·å§ |
| | | public static final byte P_Head_Byte = (byte)0x68 ; |
| | | public static final byte P_Tail_Byte = (byte)0x16 ; |
| | | |
| | | 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 lenTail = 2 ; //帧尾é¨åèæ°ç»é¿åº¦ |
| | | /** |
| | | * æå¨åèæ°ç»çä½ç½®ï¼ä¸æ ï¼ |
| | | */ |
| | | public static final int dataLenIndex = 1 ;//帧é¿åº¦æå¨ åèæ°ç»èµ·å§ä¸æ |
| | | public static final int ctrlIndex = 3 ;//æ§å¶åæå¨ åèæ°ç»èµ·å§ä¸æ |
| | | public static final int rtuAddr1Index_start = 4 ;//æ§å¶å¨å°å åèæ°ç»å¼å§ä¸æ |
| | | public static final int rtuAddr1Index_end = 6 ;//æ§å¶å¨å°å åèæ°ç»å¼å§ä¸æ |
| | | public static final int rtuAddr2Index_start = 7 ;//æ§å¶å¨å°å åèæ°ç»æªæ¢ä¸æ |
| | | public static final int rtuAddr2Index_end = 8 ;//æ§å¶å¨å°å åèæ°ç»æªæ¢ä¸æ |
| | | public static final int codeIndex = 9 ;//åè½ç åèæ°ç»ä¸æ |
| | | public static final int dataIndex = 10 ;//å
·ä½æ°æ®åèæ°ç»ä¸æ |
| | | |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | package com.dy.common.mw.protocol.p206V1_0_0.parse; |
| | | |
| | | import com.dy.common.mw.protocol.*; |
| | | import com.dy.common.mw.protocol.p206V1_0_0.*; |
| | | import com.dy.common.util.ByteUtil; |
| | | import com.dy.common.util.ByteUtilUnsigned; |
| | | import com.dy.common.util.CRC8_for_2_0; |
| | | import com.dy.common.util.DateTime; |
| | | |
| | | @AnnotationCodeDown(ifAny={ |
| | | CodeV1_0_1.cd_06 |
| | | }) |
| | | public class Cd_02_Down implements CodeParse { |
| | | |
| | | //private static Logger log = LogManager.getLogger(Cd_XY_Down.class); |
| | | |
| | | @Override |
| | | public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback) throws Exception { |
| | | ParseParamsForDownV1_0_1 para = (ParseParamsForDownV1_0_1) params ; |
| | | byte[] bs = this.doParse(para) ; |
| | | |
| | | MidResultToRtu midRs = new MidResultToRtu() ; |
| | | midRs.protocolName = para.protocolName ;//åè®®åç§° |
| | | midRs.rtuAddr = para.rtuAddr ;//IMEIå·ï¼çµä¿¡å¹³å°è®¾å¤IMEIï¼ |
| | | midRs.commandId = para.commandId ;//å½ä»¤IDï¼åèµ·å½ä»¤ç客æ·ç«¯(web端)çæï¼ä»¥å¹é
å½ä»¤ç»æ |
| | | midRs.downCode = para.commandCode ;//ä¸è¡å½ä»¤åè½ç ; |
| | | midRs.downBuffer = bs ;//ä¸è¡å½ä»¤æ°æ® |
| | | midRs.downBufHex = ByteUtil.bytes2Hex(bs, true) ;//ä¸è¡å½ä»¤æ°æ®åå
è¿å¶å½¢å¼ |
| | | midRs.hasResponse = true ;//æ¯å¦æåºç |
| | | midRs.maxSendTimes = null ;//å½ä»¤æå¤§å鿬¡æ°(彿¶ä¸å°åºçæ¶ï¼å°éå)ï¼å¦æä¸è®¾ç½®ï¼å½ä»¤ç¼åå¨è¿è¡è¡¥å
设置 |
| | | midRs.isCachForOffLine = true ;//RTUä¸å¨çº¿ï¼å½ä»¤æ¯å¦ç¼åï¼ä½åèæ¶ä¸ºtrue |
| | | |
| | | //对RTUä¸è¡æ°æ®çåºç |
| | | midRs.hasResponse = false ;//æ¯å¦æåºç |
| | | midRs.maxSendTimes = 1 ;//对RTUä¸è¡æ°æ®åºçï¼æä»¥åªéå䏿¬¡ |
| | | if(isLowPower != null && isLowPower.booleanValue()){ |
| | | //ä½åèæ¶ |
| | | midRs.isQuickSend = true ; |
| | | } |
| | | |
| | | return new MidResult[]{midRs} ; |
| | | } |
| | | /** |
| | | * æé ä¸è¡æ°æ® |
| | | * @param para |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public byte[] doParse(ParseParamsForDownV1_0_1 para) 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)0) ; |
| | | |
| | | String rtuAddr = para.rtuAddr ; |
| | | String rtuAddr1 = rtuAddr.substring(0, 6) ; |
| | | String rtuAddr2 = rtuAddr.substring(6) ; |
| | | |
| | | index++ ; |
| | | ByteUtil.string2BCD_BE(bsHead, rtuAddr1, index) ; |
| | | index += 3 ; |
| | | |
| | | Integer rtuAddr2Int = Integer.parseInt(rtuAddr2) ; |
| | | ByteUtilUnsigned.short2Bytes_BE(bsHead, rtuAddr2Int.shortValue(), index); |
| | | index += 2 ; |
| | | |
| | | ByteUtil.hex2Bytes(para.commandCode, bsHead, index) ; |
| | | |
| | | byte[] bs = new byte[7] ; |
| | | bs[0] = (byte)0xF2 ; |
| | | ByteUtil.string2BCD_BE(bs, DateTime.yyMMddhhmmss(), 1) ; |
| | | |
| | | bytes = ByteUtil.bytesMerge(bsHead, bs) ; |
| | | |
| | | int len = bytes.length + ProtocolConstantV206V1_0_0.lenTail; |
| | | bytes[ProtocolConstantV206V1_0_0.dataLenIndex] = (byte)len ; |
| | | |
| | | int crc = new CRC8_for_2_0().CRC8(bytes, ProtocolConstantV206V1_0_0.ctrlIndex, bytes.length -1) ; |
| | | bs = new byte[ProtocolConstantV206V1_0_0.lenTail] ; |
| | | bs[0] = (byte)crc ; |
| | | bs[1] = ProtocolConstantV206V1_0_0.P_Tail_Byte ; |
| | | bytes = ByteUtil.bytesMerge(bytes, bs) ; |
| | | |
| | | return bytes ; |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | package com.dy.common.mw.protocol.p206V1_0_0.parse; |
| | | |
| | | |
| | | import com.dy.common.mw.protocol.*; |
| | | import com.dy.common.util.ByteUtil; |
| | | import org.apache.logging.log4j.LogManager; |
| | | import org.apache.logging.log4j.Logger; |
| | | |
| | | import com.dy.common.mw.protocol.p206V1_0_0.*; |
| | | |
| | | @AnnotationCodeUp(ifAny={ |
| | | CodeV1_0_1.cd_02 |
| | | }) |
| | | @SuppressWarnings("unused") |
| | | public class Cd_02_Up implements CodeParse{ |
| | | |
| | | private static Logger log = LogManager.getLogger(Cd_02_Up.class); |
| | | |
| | | /** |
| | | * åæä¸è¡æ°æ® |
| | | */ |
| | | @Override |
| | | public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback)throws Exception { |
| | | ParseParamsForUpV1_0_1 para = (ParseParamsForUpV1_0_1)params ; |
| | | int bsLen = new CommonV1_0_1().parseDataLen(para.upBuffer) ; |
| | | if(bsLen > 0){ |
| | | this.doParse(para.upBuffer, |
| | | bsLen, |
| | | para.upCode, |
| | | para.data) ; |
| | | } |
| | | log.info("åæä¸è¡æ°æ®<" + CodeV1_0_1.getCodeName(para.upCode) + " RTUå°å=" + para.rtuAddr + ">:\n" + para.data.toString()); |
| | | |
| | | MidResultFromRtu midRs = new MidResultFromRtu() ; |
| | | midRs.protocolName = para.protocolName ;//åè®®åç§° |
| | | midRs.rtuAddr = para.rtuAddr ;//IMEIå· |
| | | midRs.upCode = para.upCode ;//ä¸è¡æ°æ®ä¸çåè½ç |
| | | midRs.upHex = para.upHex ;//ä¸è¡æ°æ®åå
è¿å¶å½¢å¼ |
| | | midRs.upBuffer = para.upBuffer ;//ä¸è¡æ°æ®åèæ°ç» |
| | | midRs.data = para.data ;//è§£æåçæ°æ® |
| | | |
| | | midRs.reportOrResponse_trueOrFalse = true ;//主å¨ä¸æ¥ |
| | | |
| | | String confirmComCode = CodeV1_0_1.cd_02 ; |
| | | ParseParamsForDownV1_0_1 downCpParams = new ParseParamsForDownV1_0_1() ; |
| | | downCpParams.setValue( |
| | | ProtocolConstantV206V1_0_0.protocolName, |
| | | para.rtuAddr, |
| | | Command.defaultId, |
| | | confirmComCode, |
| | | null, |
| | | null); |
| | | //æé åºç |
| | | byte[] data = new Cd_02_Down().doParse(downCpParams) ; |
| | | |
| | | MidResultToRtu confirmCommand = new MidResultToRtu() ; |
| | | confirmCommand.protocolName = para.protocolName ;//åè®®åç§° |
| | | confirmCommand.rtuAddr = para.rtuAddr ;//IMEIå· |
| | | confirmCommand.commandId = Command.defaultId ;//å½ä»¤IDï¼åèµ·å½ä»¤ç客æ·ç«¯(web端)çæï¼ä»¥å¹é
å½ä»¤ç»æ |
| | | confirmCommand.downCode = confirmComCode ;//ä¸è¡å½ä»¤åè½ç ; |
| | | confirmCommand.downBuffer = data ;//ä¸è¡å½ä»¤æ°æ® |
| | | confirmCommand.downBufHex = ByteUtil.bytes2Hex(data, true) ;//ä¸è¡å½ä»¤æ°æ®åå
è¿å¶å½¢å¼ |
| | | confirmCommand.hasResponse = false ;//æ¯å¦æåºç |
| | | confirmCommand.maxSendTimes = 1 ;//å½ä»¤æå¤§å鿬¡æ°(彿¶ä¸å°åºçæ¶ï¼å°éå2次)ï¼å¦æä¸è®¾ç½®ï¼å½ä»¤ç¼åå¨è¿è¡è¡¥å
设置 |
| | | confirmCommand.isSendFirst = true ;//确认å½ä»¤ï¼ä¼å
åé |
| | | confirmCommand.isCachForOffLine = false ;//RTUä¸å¨çº¿ï¼å½ä»¤æ¯å¦ç¼å |
| | | |
| | | callback.callback(midRs.reportOrResponse_trueOrFalse); |
| | | return new MidResult[]{midRs, confirmCommand} ; |
| | | } |
| | | /** |
| | | * æ§è¡åæ |
| | | * @param bs |
| | | * @param bsLen åèé¿åº¦ï¼æ»å
é¿ï¼å
æ¬å
头åå
å°¾ï¼ |
| | | * @param dataCode åè½ç |
| | | * @param data æ°æ® |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | protected void doParse(byte[] bs, int bsLen, String dataCode, Data data) throws Exception { |
| | | DataV1_0_1 dV1 = (DataV1_0_1)data.getSubData() ; |
| | | DataCd02Vo cdData = new DataCd02Vo() ; |
| | | dV1.dataCd02Vo = cdData ; |
| | | cdData.status = ByteUtil.bytes2Hex(bs, false, ProtocolConstantV206V1_0_0.dataIndex, 1) ; |
| | | } |
| | | } |
| | |
| | | public void start(UnitStartedCallbackInterface callback) throws Exception { |
| | | if(!started){ |
| | | started = true ; |
| | | if(confVo.enableThreadPool){ |
| | | TreadPoolFactory.initThreadPoolShort("çä»»å¡å·¥ä½çº¿ç¨æ± ", |
| | | this.confVo.short_maxThread, |
| | | this.confVo.short_minThread, |
| | | this.confVo.short_freeTimeout, |
| | | if(confVo.enableShortThreadPool) { |
| | | TreadPoolFactory.initThreadPoolShort("çä»»å¡å·¥ä½çº¿ç¨æ± ", |
| | | this.confVo.short_maxThread, |
| | | this.confVo.short_minThread, |
| | | this.confVo.short_freeTimeout, |
| | | this.confVo.short_busyTimeout); |
| | | TreadPoolFactory.initThreadPoolLong("é¿ä»»å¡å·¥ä½çº¿ç¨æ± ", |
| | | this.confVo.long_maxThread, |
| | | this.confVo.long_minThread, |
| | | this.confVo.long_freeTimeout, |
| | | this.confVo.long_busyTimeout); |
| | | |
| | | if(this.confVo.showStartInfo){ |
| | | System.out.println("çº¿ç¨æ± 模åæåå¯å¨"); |
| | | } |
| | | }else{ |
| | | System.out.println("ççº¿ç¨æ± é
ç½®ä¸å¯å¨"); |
| | | } |
| | | callback.call(null); |
| | | if(confVo.enableLongThreadPool) { |
| | | TreadPoolFactory.initThreadPoolLong("é¿ä»»å¡å·¥ä½çº¿ç¨æ± ", |
| | | this.confVo.long_maxThread, |
| | | this.confVo.long_minThread, |
| | | this.confVo.long_freeTimeout, |
| | | this.confVo.long_busyTimeout); |
| | | }else{ |
| | | System.out.println("é¿çº¿ç¨æ± é
ç½®ä¸å¯å¨"); |
| | | } |
| | | if(this.confVo.showStartInfo){ |
| | | System.out.println("çº¿ç¨æ± 模åæåå¯å¨"); |
| | | } |
| | | } |
| | | callback.call(null); |
| | | } |
| | | |
| | | @Override |
| | | public void stop(UnitStartedCallbackInterface callback) throws Exception { |
| | | public void stop(UnitStartedCallbackInterface callback) { |
| | | } |
| | | |
| | | |
| | | /* |
| | | public static void main(String[] args) throws Exception{ |
| | | SupportUnitConfigVo supVo = new SupportUnitConfigVo() ; |
| | | //ç工使¶é¿çº¿ç¨æ± ï¼çº¿ç¨è´è´£ç¨æ¶è¾ççå·¥ä½ä»»å¡ |
| | |
| | | supVo.long_busyTimeout = -1 ; |
| | | } |
| | | |
| | | supVo.enableThreadPool = true ; |
| | | |
| | | supVo.enableShortThreadPool = true ; |
| | | supVo.enableLongThreadPool = true ; |
| | | |
| | | supVo.showStartInfo = true ; |
| | | |
| | | SupportUnit supUnit = SupportUnit.getInstance() ; |
| | |
| | | supUnit.start(obj -> { |
| | | }); |
| | | } |
| | | |
| | | private static class AdapterImp_SupportUnit implements SupportUnitAdapter { |
| | | |
| | | private SupportUnitConfigVo configVo = null ; |
| | |
| | | public void setConfig(SupportUnitConfigVo configVo) { |
| | | this.configVo = configVo; |
| | | } |
| | | |
| | | |
| | | } |
| | | */ |
| | | } |
| | |
| | | package com.dy.common.mw.support; |
| | | |
| | | public class SupportUnitConfigVo { |
| | | |
| | | public boolean enableThreadPool ; |
| | | |
| | | public boolean enableShortThreadPool ; |
| | | |
| | | public boolean enableLongThreadPool ; |
| | | |
| | | //çä»»å¡çº¿ç¨æ± |
| | | public int short_maxThread ; |
| | |
| | | import org.apache.logging.log4j.Logger; |
| | | |
| | | /** |
| | | * éåï¼å
è¿å
åº |
| | | * éåï¼å
è¿å
åºï¼é线ç¨å®å
¨ |
| | | */ |
| | | public class Queue { |
| | | @SuppressWarnings("unfinal") |
| | |
| | | */ |
| | | @SuppressWarnings("unused") |
| | | public void pushHead(NodeObj obj)throws Exception{ |
| | | //两个线ç¨ç¯å¢ï¼éè¦åæ¥é |
| | | synchronized(synObj){ |
| | | if(obj == null){ |
| | | return ; |
| | |
| | | * @param obj å
¥åç对象 |
| | | */ |
| | | public void pushTail(NodeObj obj)throws Exception{ |
| | | //两个线ç¨ç¯å¢ï¼éè¦åæ¥é |
| | | synchronized(synObj){ |
| | | if(obj == null){ |
| | | return ; |
| | |
| | | * @return åºå对象 |
| | | */ |
| | | public NodeObj pop(){ |
| | | //两个线ç¨ç¯å¢ï¼éè¦åæ¥é |
| | | synchronized(synObj){ |
| | | NodeObj obj = null ; |
| | | if(this.size > 0){ |
| | |
| | | */ |
| | | @SuppressWarnings("unused") |
| | | public Node getFirstNode(){ |
| | | Node node = this.head.next ; |
| | | if(node != this.tail){ |
| | | return node ; |
| | | //两个线ç¨ç¯å¢ï¼éè¦åæ¥é |
| | | synchronized(synObj) { |
| | | Node node = this.head.next; |
| | | if (node != this.tail) { |
| | | return node; |
| | | } |
| | | return null; |
| | | } |
| | | return null ; |
| | | } |
| | | /** |
| | | * å¾å°æåä¸ä¸ªèç¹ï¼ä½ä¸æèç¹ä»éå䏿¸
é¤ |
| | |
| | | */ |
| | | @SuppressWarnings("unused") |
| | | public Node getLastNode(){ |
| | | Node node = this.tail.pre ; |
| | | if(node != this.head){ |
| | | return node ; |
| | | //两个线ç¨ç¯å¢ï¼éè¦åæ¥é |
| | | synchronized(synObj) { |
| | | Node node = this.tail.pre; |
| | | if (node != this.head) { |
| | | return node; |
| | | } |
| | | return null; |
| | | } |
| | | return null ; |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | private Logger log = LogManager.getLogger(MonitorThread.class.getName()); |
| | | |
| | | /** |
| | | * å¾å°é»è®¤å¯ä¸å®ä¾ |
| | | * @return |
| | | */ |
| | | // public MyThreadPool getDefaultInstance(){ |
| | | // if(myPool == null){ |
| | | // myPool = new MyThreadPool(null, null, null, null, null) ; |
| | | // } |
| | | // return myPool ; |
| | | // } |
| | | /** |
| | | * å¾å°å¯ä¸å®ä¾ |
| | | * @param poolName |
| | | * @param maxNum |
| | | * @param minNum |
| | | * @param freeTimeout |
| | | * @param busyTimeout |
| | | * @return |
| | | */ |
| | | // public MyThreadPool getInstance( |
| | | // String poolName , |
| | | // Integer maxNum , |
| | | // Integer minNum , |
| | | // Long freeTimeout , |
| | | // Long busyTimeout){ |
| | | // if(myPool == null){ |
| | | // myPool = new MyThreadPool(poolName, maxNum, minNum, freeTimeout, busyTimeout) ; |
| | | // } |
| | | // return myPool ; |
| | | // } |
| | | |
| | | /** |
| | | * çº¿ç¨æ± æé æ¹æ³ |
| | |
| | | } |
| | | this.poolName = poolName ; |
| | | |
| | | if(maxNum == null || maxNum.intValue() <= 0){ |
| | | maxNum = -1 ; |
| | | if(maxNum == null || maxNum.intValue() < 0){ |
| | | maxNum = 65535 ; |
| | | } |
| | | if(minNum == null || minNum.intValue() < 0){ |
| | | minNum = 0 ; |
| | |
| | | }else{ |
| | | this.busyTimeout = busyTimeout ; |
| | | } |
| | | |
| | | this.busiThreads = new ArrayList<MyThread>(); |
| | | this.freeThreads = new ArrayList<MyThread>(); |
| | | |
| | | //æå°åçº¿ç¨æ± |
| | | for (int i = 0; i < this.minNum ; i++) { |
| | | MyThread t = new MyThread(this); |
| | | t.start(); |
| | | this.freeThreads.add(t); |
| | | this.currNum++; |
| | | if(maxNum != 0){ |
| | | this.busiThreads = new ArrayList<>(); |
| | | this.freeThreads = new ArrayList<>(); |
| | | //æå°åçº¿ç¨æ± |
| | | for (int i = 0; i < this.minNum ; i++) { |
| | | MyThread t = new MyThread(this); |
| | | t.start(); |
| | | this.freeThreads.add(t); |
| | | this.currNum++; |
| | | } |
| | | this.monitorThread = new MonitorThread(this) ; |
| | | this.monitorThread.start() ; |
| | | } |
| | | |
| | | this.monitorThread = new MonitorThread(this) ; |
| | | this.monitorThread.start() ; |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public void putJob(Job job) throws Exception { |
| | | if(this.busiThreads == null || this.freeThreads == null){ |
| | | throw new Exception("çº¿ç¨æ± æªå¯å¨") ; |
| | | } |
| | | synchronized(this.synObj) { |
| | | //log.debug("å·¥ä½ä»»å¡åé
å°çº¿ç¨æ± ä¸ã") ; |
| | | MyThread t = null ; |
| | |
| | | /** |
| | | * 线ç¨å·¥ä½å®æï¼ä»busiThreadsåå½freeThreads |
| | | */ |
| | | protected void freeThread(MyThread t) { |
| | | protected void freeThread(MyThread t) throws Exception { |
| | | if(this.busiThreads == null || this.freeThreads == null){ |
| | | throw new Exception("çº¿ç¨æ± æªå¯å¨") ; |
| | | } |
| | | synchronized (synObj) { |
| | | busiThreads.remove(t); |
| | | freeThreads.add(t); |
| | |
| | | |
| | | /** |
| | | * |
| | | * @param pool |
| | | * @param pool æ± |
| | | */ |
| | | public MonitorThread(MyThreadPool pool){ |
| | | this.pool = pool ; |
| | |
| | | } |
| | | }//end synchronized (pool.synObj) |
| | | }catch(Exception e){ |
| | | e.printStackTrace(); |
| | | }finally{ |
| | | continue ; |
| | | } |
| | |
| | | |
| | | /** |
| | | * 设置线ç¨å·¥ä½å¯¹è±¡ |
| | | * @param job |
| | | * @param job å·¥ä½ |
| | | */ |
| | | protected void putJob(Job job) throws Exception { |
| | | if(job == null){ |
| | |
| | | } |
| | | |
| | | public void free(){ |
| | | //使æ¬çº¿ç¨åå½ç©ºé²çº¿ç¨æ± |
| | | pool.freeThread(this); |
| | | //空é²å¼å§è®°æ¶ |
| | | this.time = System.currentTimeMillis() ; |
| | | // 没æå¯åçäº |
| | | this.canJob = false; |
| | | log.debug("çº¿ç¨æ± (" + this.pool.poolName + ")ä¸ç线ç¨åå½ç©ºé²éåã"); |
| | | try{ |
| | | //使æ¬çº¿ç¨åå½ç©ºé²çº¿ç¨æ± |
| | | pool.freeThread(this); |
| | | //空é²å¼å§è®°æ¶ |
| | | this.time = System.currentTimeMillis() ; |
| | | // 没æå¯åçäº |
| | | this.canJob = false; |
| | | log.debug("çº¿ç¨æ± (" + this.pool.poolName + ")ä¸ç线ç¨åå½ç©ºé²éåã"); |
| | | }catch (Exception e){ |
| | | log.error("çº¿ç¨æ± (" + pool.poolName + ")çå·¥ä½çº¿ç¨éæ¾å彿¶åçå¼å¸¸:\n" + e.getMessage(), e); |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | /** |
| | | * åå§åçº¿ç¨æ± |
| | | * @param threadPoolName çº¿ç¨æ± å线ç¨åç§° |
| | | * @param maxThreadNum çº¿ç¨æ± æå¤§çº¿ç¨æ° ï¼è¥ä¸º-1ï¼ä¸åéå¶ |
| | | * @param minThreadNum çº¿ç¨æ± æå°çº¿ç¨æ°ï¼æåå§çº¿ç¨æ° |
| | | * @param poolName çº¿ç¨æ± å线ç¨åç§° |
| | | * @param maxNum çº¿ç¨æ± æå¤§çº¿ç¨æ° ï¼è¥ä¸º-1ï¼ä¸åéå¶ |
| | | * @param minNum çº¿ç¨æ± æå°çº¿ç¨æ°ï¼æåå§çº¿ç¨æ° |
| | | * @param freeTimeout 空é²çº¿ç¨è¶
æ¶æ¶é¿(ç§) |
| | | * @param busyTimeout å¿ç¢çº¿ç¨è¶
æ¶æ¶é¿(ç§)ï¼è¥ä¸º-1ï¼ä¸åéå¶ |
| | | * @return çº¿ç¨æ± å®ä¾ |
| | |
| | | |
| | | /** |
| | | * åå§åçº¿ç¨æ± |
| | | * @param threadPoolName çº¿ç¨æ± å线ç¨åç§° |
| | | * @param maxThreadNum çº¿ç¨æ± æå¤§çº¿ç¨æ°ï¼è¥ä¸º-1ï¼ä¸åéå¶ |
| | | * @param minThreadNum çº¿ç¨æ± æå°çº¿ç¨æ°ï¼æåå§çº¿ç¨æ° |
| | | * @param poolName çº¿ç¨æ± å线ç¨åç§° |
| | | * @param maxNum çº¿ç¨æ± æå¤§çº¿ç¨æ°ï¼è¥ä¸º-1ï¼ä¸åéå¶ |
| | | * @param minNum çº¿ç¨æ± æå°çº¿ç¨æ°ï¼æåå§çº¿ç¨æ° |
| | | * @param freeTimeout 空é²çº¿ç¨è¶
æ¶æ¶é¿(ç§) |
| | | * @param busyTimeout å¿ç¢çº¿ç¨è¶
æ¶æ¶é¿(ç§)ï¼è¥ä¸º-1ï¼ä¸åéå¶ |
| | | * @return çº¿ç¨æ± å®ä¾ |
| | |
| | | } |
| | | /** |
| | | * å¾å°å¯ä¸çº¿ç¨æ± å®ä¾ |
| | | * @param dataSourceName |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public final static ThreadPool.Pool getThreadPoolShort() |
| | |
| | | } |
| | | /** |
| | | * å¾å°å¯ä¸çº¿ç¨æ± å®ä¾ |
| | | * @param dataSourceName |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public final static ThreadPool.Pool getThreadPoolLong() |
| | | throws Exception { |
| | |
| | | * å°åèæ°ç»åå¹¶å°åèæ°ç»ä¸ |
| | | * @param bGroup1 被åå¹¶æ°ç» |
| | | * @param bGroup2 åå¹¶æ°ç» |
| | | * @return åå¹¶åæ°ç» |
| | | * @return è¿å åå¹¶åæ°ç» |
| | | */ |
| | | public static byte[] bytesMerge(byte[] bGroup1, byte[] bGroup2){ |
| | | if(bGroup1 == null && bGroup2 == null){ |
| | |
| | | |
| | | /** |
| | | * 夿ææåèæ¯å¦ä¸º0xFF |
| | | * @param bs |
| | | * @param index |
| | | * @param len |
| | | * @return |
| | | * @throws Exception |
| | | * @param bs åèæ°ç» |
| | | * @param index 䏿 ä½ |
| | | * @param len é¿åº¦ |
| | | * @return è¿å è¿å |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public static boolean bytesIsAll0xFF(byte[] bs, int index, int len)throws Exception { |
| | | int count = 0 ; |
| | |
| | | count++ ; |
| | | } |
| | | } |
| | | return count==len?true:false ; |
| | | return count == len; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * äºè¿å¶è½¬åè¿å¶æ° |
| | | * @param str |
| | | * @return |
| | | * @throws Exception |
| | | * @return è¿å |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public static int binary2Int(String str) throws Exception { |
| | | int cnt=0; |
| | |
| | | return sum; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * åè转åäºè¿å¶ |
| | | * |
| | | * |
| | | * @param b byte |
| | | * @throws Exception |
| | | * @return String |
| | | * @throws Exception å¼å¸¸ |
| | | * @return è¿å String |
| | | */ |
| | | public static String byte2Binary(byte b) throws Exception { |
| | | int n = (b + 256) % 256 + 256; |
| | |
| | | } |
| | | /** |
| | | * åè转å8ä½äºè¿å¶ |
| | | * |
| | | * |
| | | * @param b |
| | | * byte |
| | | * @throws Exception |
| | | * @return String |
| | | * @throws Exception å¼å¸¸ |
| | | * @return è¿å String |
| | | */ |
| | | public static String byte2bit8Binary(byte b) throws Exception { |
| | | String s = byte2Binary(b); |
| | |
| | | } |
| | | return s; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * åèåbit |
| | | * @param b |
| | | * @param index |
| | | * @throws Exception |
| | | * @return String |
| | | * @param b |
| | | * @throws Exception å¼å¸¸ |
| | | * @return è¿å String |
| | | */ |
| | | public static byte[] getBit(byte b) throws Exception { |
| | | byte[] bs = new byte[8] ; |
| | |
| | | /** |
| | | * åèåbit |
| | | * @param b |
| | | * @param index |
| | | * @throws Exception |
| | | * @return String |
| | | * @param index 䏿 ä½ |
| | | * @throws Exception å¼å¸¸ |
| | | * @return è¿å String |
| | | */ |
| | | public static byte getBit(byte b, byte index) throws Exception { |
| | | if(index == 0){ |
| | |
| | | |
| | | /** |
| | | * ä¸ä¸ªåèè½¬æ£æ´æ° |
| | | * |
| | | * |
| | | * @param b |
| | | * byte |
| | | * @throws Exception |
| | | * @return String |
| | | * @throws Exception å¼å¸¸ |
| | | * @return è¿å String |
| | | */ |
| | | public static Short byte2PlusInt(byte b) throws Exception { |
| | | short v = b ; |
| | |
| | | return v ; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 大端模å¼ãæ°æ®ä½ä½å¨æ°ç»é«åèã |
| | | * double转æ¢byte |
| | | * @param bs byte[] |
| | | * @param bs åèæ°ç» byte[] |
| | | * @param value double doubleç±»åçåæ° |
| | | * @param from int |
| | | * @param from å¼å§ä½ int |
| | | */ |
| | | public static void double2Bytes_BE(byte[] bs, double value, int from)throws Exception { |
| | | boolean b = isOutOfArrLength(bs.length, (from - 1) + 8); |
| | |
| | | /** |
| | | * å°ç«¯æ¨¡å¼ãæ°æ®ä½ä½å¨æ°ç»ä½åèã |
| | | * double转æ¢byteï¼åèé¡ºåºæ¯åç |
| | | * @param bs byte[] |
| | | * @param bs åèæ°ç» byte[] |
| | | * @param value double doubleç±»åçåæ° |
| | | * @param from int |
| | | * @param from å¼å§ä½ int |
| | | */ |
| | | public static void double2Bytes_LE(byte[] bs, double value, int from)throws Exception { |
| | | boolean b = isOutOfArrLength(bs.length, (from - 1) + 8); |
| | |
| | | /** |
| | | * 大端模å¼ãæ°æ®ä½ä½å¨æ°ç»é«åèã |
| | | * byte转æ¢double |
| | | * @param bs byte[] |
| | | * @param from int |
| | | * @param bs åèæ°ç» byte[] |
| | | * @param from å¼å§ä½ int |
| | | */ |
| | | public static double bytes2Double_BE(byte[] bs, int from) throws Exception { |
| | | long l = bytes2Long_BE(bs, from); |
| | |
| | | /** |
| | | * å°ç«¯æ¨¡å¼ãæ°æ®ä½ä½å¨æ°ç»ä½åèã |
| | | * byte转æ¢doubleï¼åèé¡ºåºæ¯åç |
| | | * @param bs byte[] |
| | | * @param from int |
| | | * @param bs åèæ°ç» byte[] |
| | | * @param from å¼å§ä½ int |
| | | */ |
| | | public static double bytes2Double_LE(byte[] bs, int from) throws Exception { |
| | | long l = bytes2Long_LE(bs, from); |
| | |
| | | |
| | | /** |
| | | * å°ç«¯æ¨¡å¼ãæ°æ®ä½ä½å¨æ°ç»ä½åèã |
| | | * 转æ¢longå为byteæ°ç» |
| | | * 转æ¢longå为byteæ°ç» |
| | | * @value bs byte[] |
| | | * @value value long |
| | | * @value from int |
| | |
| | | boolean b = isOutOfArrLength(bs.length, (from - 1) + 8); |
| | | if (b) { |
| | | for (int i = 0; i < 8; i++) { |
| | | bs[from + i] = Long.valueOf(value & 0xff).byteValue(); |
| | | value = value >> 8; |
| | | bs[from + i] = Long.valueOf(value & 0xff).byteValue(); |
| | | value = value >> 8; |
| | | if(value == 0){ |
| | | break ; |
| | | } |
| | |
| | | throw new Exception("long2Bytesæ¶æ°ç»è¶ç"); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 大端模å¼ãæ°æ®ä½ä½å¨æ°ç»é«åèã |
| | | * 8ä½åèæ°ç»è½¬æ¢ä¸ºé¿æ´å |
| | | * @param bs byte[] |
| | | * @return |
| | | * @param bs åèæ°ç» byte[] |
| | | * @return è¿å |
| | | */ |
| | | public static long bytes2Long_BE(byte[] bs) { |
| | | int len = bs.length ; |
| | |
| | | l = l | ls[i] ; |
| | | } |
| | | return l; |
| | | } |
| | | } |
| | | return 0L ; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 大端模å¼ãæ°æ®ä½ä½å¨æ°ç»é«åèã |
| | | * 8ä½åèæ°ç»è½¬æ¢ä¸ºé¿æ´å |
| | | * @param bs byte[] |
| | | * @param from int |
| | | * @return |
| | | * @param bs åèæ°ç» byte[] |
| | | * @param from å¼å§ä½ int |
| | | * @return è¿å |
| | | */ |
| | | public static long bytes2Long_BE(byte[] bs, int from) throws Exception { |
| | | boolean b = isOutOfArrLength(bs.length, (from - 1) + 8); |
| | |
| | | /** |
| | | * 大端模å¼ãæ°æ®ä½ä½å¨æ°ç»é«åèã |
| | | * 8ä½åèæ°ç»è½¬æ¢ä¸ºé¿æ´å |
| | | * @param bs byte[] |
| | | * @param from int |
| | | * @param bs åèæ°ç» byte[] |
| | | * @param from å¼å§ä½ int |
| | | * @param end int |
| | | * @return |
| | | * @return è¿å |
| | | */ |
| | | public static long bytes2Long_BE(byte[] bs, int from, int end) throws Exception { |
| | | boolean b = isOutOfArrLength(bs.length, end); |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * å°ç«¯æ¨¡å¼ãæ°æ®ä½ä½å¨æ°ç»ä½åèã |
| | | * 8ä½åèæ°ç»è½¬æ¢ä¸ºé¿æ´å |
| | | * @param bs byte[] |
| | | * @return |
| | | * @param bs åèæ°ç» byte[] |
| | | * @return è¿å |
| | | */ |
| | | public static long bytes2Long_LE(byte[] bs) { |
| | | int len = bs.length ; |
| | |
| | | l = l | ls[i] ; |
| | | } |
| | | return l; |
| | | } |
| | | } |
| | | return 0L ; |
| | | } |
| | | |
| | | /** |
| | | * å°ç«¯æ¨¡å¼ãæ°æ®ä½ä½å¨æ°ç»ä½åèã |
| | | * 8ä½åèæ°ç»è½¬æ¢ä¸ºé¿æ´å |
| | | * @param bs byte[] |
| | | * @param from int |
| | | * @return |
| | | * 8ä½åèæ°ç»è½¬æ¢ä¸ºé¿æ´å |
| | | * @param bs åèæ°ç» byte[] |
| | | * @param from å¼å§ä½ int |
| | | * @return è¿å |
| | | */ |
| | | public static long bytes2Long_LE(byte[] bs, int from) throws Exception { |
| | | boolean b = isOutOfArrLength(bs.length, (from - 1) + 8); |
| | |
| | | /** |
| | | * å°ç«¯æ¨¡å¼ãæ°æ®ä½ä½å¨æ°ç»ä½åèã |
| | | * 8ä½åèæ°ç»è½¬æ¢ä¸ºé¿æ´å |
| | | * @param bs byte[] |
| | | * @param from int |
| | | * @param bs åèæ°ç» byte[] |
| | | * @param from å¼å§ä½ int |
| | | * @param end int |
| | | * @return |
| | | * @return è¿å |
| | | */ |
| | | public static long bytes2Long_LE(byte[] bs, int from, int end) throws Exception { |
| | | boolean b = isOutOfArrLength(bs.length, end); |
| | |
| | | /** |
| | | * 大端模å¼ãæ°æ®ä½ä½å¨æ°ç»é«åèã |
| | | * 4ä½åèæ°ç»è½¬æ¢ä¸ºæ´å |
| | | * @param b |
| | | * @return |
| | | * @param bs åèæ°ç» |
| | | * @param from å¼å§ä½ |
| | | * @return è¿å |
| | | */ |
| | | public static int bytes2Int_BE(byte[] bs, int from) throws Exception { |
| | | boolean b = isOutOfArrLength(bs.length, (from - 1) + 4); |
| | |
| | | throw new Exception("byte2Intæ¶æ°ç»è¶ç"); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * å°ç«¯æ¨¡å¼ãæ°æ®ä½ä½å¨æ°ç»ä½åèã |
| | | * 4ä½åèæ°ç»è½¬æ¢ä¸ºæ´åï¼åèé¡ºåºæ¯åç |
| | | * @param b |
| | | * @return |
| | | * @param bs åèæ°ç» åèæ°ç» |
| | | * @return è¿å |
| | | */ |
| | | public static int bytes2Int_LE(byte[] bs, int from) throws Exception { |
| | | boolean b = isOutOfArrLength(bs.length, (from - 1) + 4); |
| | |
| | | throw new Exception("byte2Intæ¶æ°ç»è¶ç"); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 大端模å¼ãæ°æ®ä½ä½å¨æ°ç»é«åèã |
| | |
| | | /** |
| | | * 大端模å¼ãæ°æ®ä½ä½å¨æ°ç»é«åèã |
| | | * 2ä½åèæ°ç»è½¬æ¢ä¸ºçæ´å |
| | | * @param b |
| | | * @return |
| | | * @param bs åèæ°ç» åèæ°ç» |
| | | * @return è¿å |
| | | */ |
| | | public static short bytes2Short_BE(byte[] bs, int from) throws Exception { |
| | | boolean b = isOutOfArrLength(bs.length, (from - 1) + 2); |
| | | if (b) { |
| | | int s = 0; |
| | | int s0 = bs[from + 0] ; |
| | | int s0 = bs[from + 0] ; |
| | | int s1 = bs[from + 1] ; |
| | | |
| | | // s1ä¸å |
| | |
| | | /** |
| | | * å°ç«¯æ¨¡å¼ãæ°æ®ä½ä½å¨æ°ç»ä½åèã |
| | | * 2ä½åèæ°ç»è½¬æ¢ä¸ºçæ´åï¼åèé¡ºåºæ¯åç |
| | | * @param b |
| | | * @return |
| | | * @param bs åèæ°ç» åèæ°ç» |
| | | * @return è¿å |
| | | */ |
| | | public static short bytes2Short_LE(byte[] bs, int from) throws Exception { |
| | | boolean b = isOutOfArrLength(bs.length, (from - 1) + 2); |
| | | if (b) { |
| | | int s = 0; |
| | | int s0 = bs[from + 0] ; |
| | | int s0 = bs[from + 0] ; |
| | | int s1 = bs[from + 1] ; |
| | | |
| | | // s0ä¸å |
| | |
| | | } |
| | | /** |
| | | * å符å°ä¸åèè½¬æ¢ |
| | | * |
| | | * |
| | | * @value bs byte[] |
| | | * @value ch char charç±»åçåæ° |
| | | * @value index int |
| | | * @return |
| | | * @return è¿å |
| | | */ |
| | | public static void char2Bytes(byte[] bs, char ch, int index)throws Exception { |
| | | boolean b = isOutOfArrLength(bs.length, index); |
| | |
| | | |
| | | /** |
| | | * ä¸åè转æ¢ä¸ºå符 |
| | | * |
| | | * @param b |
| | | * @param bs åèæ°ç» åèæ°ç» |
| | | * @value index int |
| | | * @return |
| | | * @return è¿å |
| | | */ |
| | | public static char bytes2Char(byte[] bs, int index) throws Exception { |
| | | boolean b = isOutOfArrLength(bs.length, index); |
| | |
| | | |
| | | /** |
| | | * åç¬¦ä¸²åæ°å转æbyte |
| | | * |
| | | * |
| | | * @param s |
| | | * @return |
| | | * @throws Exception |
| | | * @return è¿å |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public static byte string2byte(String s) throws Exception { |
| | | int n = 0; |
| | | int n ; |
| | | try { |
| | | n = Integer.parseInt(s); |
| | | } catch (Exception e) { |
| | |
| | | * @value bs byte[] |
| | | * @value str String |
| | | * @value from int |
| | | * @return |
| | | * @return è¿å |
| | | * @throws java.io.UnsupportedEncodingException |
| | | */ |
| | | public static int string2Bytes_BE(byte[] bs, String str, int from, int end)throws Exception { |
| | |
| | | * @value bs byte[] |
| | | * @value str String |
| | | * @value from int |
| | | * @return |
| | | * @return è¿å |
| | | * @throws java.io.UnsupportedEncodingException |
| | | */ |
| | | public static int string2Bytes_LE(byte[] bs, String str, int from, int end)throws Exception { |
| | |
| | | * @value bs byte[] |
| | | * @value str String |
| | | * @value from int |
| | | * @return |
| | | * @return è¿å |
| | | * @throws java.io.UnsupportedEncodingException |
| | | */ |
| | | public static int string2Bytes_BE(byte[] bs, String str, int from)throws Exception { |
| | |
| | | * @value bs byte[] |
| | | * @value str String |
| | | * @value from int |
| | | * @return |
| | | * @return è¿å |
| | | * @throws java.io.UnsupportedEncodingException |
| | | */ |
| | | public static int string2Bytes_LE(byte[] bs, String str, int from)throws Exception { |
| | |
| | | |
| | | /** |
| | | * 夿æ°ç»ä¸æ æ¯å¦è¶ç |
| | | * |
| | | * |
| | | * @value bsLength æ°ç»æ»é¿åº¦ |
| | | * @value toSite æ°ç»åç§»é |
| | | * @return |
| | | * @return è¿å |
| | | */ |
| | | private static boolean isOutOfArrLength(int bsLength, int toSite) { |
| | | if (bsLength > toSite) { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * åèæ°ç»è½¬æ¢æåå
è¿å¶çå符串 |
| | | * |
| | | * @param b byte[] |
| | | * åèæ°ç»è½¬æ¢æåå
è¿å¶çå符串 |
| | | * |
| | | * @param src byte[] |
| | | * @param hasBlank 16è¿å¶æ¯å¦ç¨ç©ºæ ¼åé |
| | | * @return String |
| | | * @return è¿å String |
| | | */ |
| | | public static String bytes2Hex(byte[] src, boolean hasBlank){ |
| | | StringBuilder stringBuilder = new StringBuilder(""); |
| | | if (src == null || src.length <= 0) { |
| | | return null; |
| | | } |
| | | for (int i = 0; i < src.length; i++) { |
| | | int v = src[i] & 0xFF; |
| | | String str = Integer.toHexString(v); |
| | | if (str.length() < 2) { |
| | | public static String bytes2Hex(byte[] src, boolean hasBlank){ |
| | | StringBuilder stringBuilder = new StringBuilder(""); |
| | | if (src == null || src.length <= 0) { |
| | | return null; |
| | | } |
| | | for (int i = 0; i < src.length; i++) { |
| | | int v = src[i] & 0xFF; |
| | | String str = Integer.toHexString(v); |
| | | if (str.length() < 2) { |
| | | str = "0" + str; |
| | | } |
| | | } |
| | | if (hasBlank) { |
| | | if (i == 0) { |
| | | stringBuilder.append(str); |
| | | stringBuilder.append(str); |
| | | } else { |
| | | stringBuilder.append(" " + str); |
| | | stringBuilder.append(" " + str); |
| | | } |
| | | } else { |
| | | stringBuilder.append(str); |
| | | stringBuilder.append(str); |
| | | } |
| | | } |
| | | } |
| | | return stringBuilder.toString().toUpperCase(Locale.US); |
| | | } |
| | | } |
| | | /** |
| | | * åèæ°ç»è½¬æ¢æåå
è¿å¶çå符串 |
| | | * |
| | | * @param b byte[] |
| | | * åèæ°ç»è½¬æ¢æåå
è¿å¶çå符串 |
| | | * |
| | | * @param src byte[] |
| | | * @param hasBlank 16è¿å¶æ¯å¦ç¨ç©ºæ ¼åé |
| | | * @param from |
| | | * @param len |
| | | * @return String |
| | | * @param from å¼å§ä½ |
| | | * @param len é¿åº¦ |
| | | * @return è¿å String |
| | | */ |
| | | public static String bytes2Hex(byte[] src, boolean hasBlank, int from, int len){ |
| | | if (src == null || src.length <= 0 || src.length < from + len) { |
| | | return null; |
| | | } |
| | | public static String bytes2Hex(byte[] src, boolean hasBlank, int from, int len){ |
| | | if (src == null || src.length <= 0 || src.length < from + len) { |
| | | return null; |
| | | } |
| | | byte[] bb = new byte[len]; |
| | | for (int i = 0 ; i < len; i++) { |
| | | bb[i] = src[from + i]; |
| | | } |
| | | return bytes2Hex(bb, hasBlank) ; |
| | | } |
| | | /** |
| | | } |
| | | /** |
| | | * åå
è¿å¶è½¬åèæ°ç» |
| | | * @param hexString the hex string |
| | | * @return byte[] |
| | | */ |
| | | public static byte[] hex2Bytes(String hex) { |
| | | if (hex == null || hex.equals("")) { |
| | | return null; |
| | | } |
| | | hex = hex.toUpperCase(Locale.ENGLISH); |
| | | int length = hex.length() / 2; |
| | | char[] hexChars = hex.toCharArray(); |
| | | byte[] d = new byte[length]; |
| | | for (int i = 0; i < length; i++) { |
| | | int pos = i * 2; |
| | | d[i] = (byte) (charToByte(hexChars[pos]) << 4 | charToByte(hexChars[pos + 1])); |
| | | } |
| | | return d; |
| | | } |
| | | /** |
| | | * @param hex the hex string |
| | | * @return è¿å byte[] |
| | | */ |
| | | public static byte[] hex2Bytes(String hex) { |
| | | if (hex == null || hex.equals("")) { |
| | | return null; |
| | | } |
| | | hex = hex.toUpperCase(Locale.ENGLISH); |
| | | int length = hex.length() / 2; |
| | | char[] hexChars = hex.toCharArray(); |
| | | byte[] d = new byte[length]; |
| | | for (int i = 0; i < length; i++) { |
| | | int pos = i * 2; |
| | | d[i] = (byte) (charToByte(hexChars[pos]) << 4 | charToByte(hexChars[pos + 1])); |
| | | } |
| | | return d; |
| | | } |
| | | /** |
| | | * åå
è¿å¶è½¬åèæ°ç» |
| | | * @param hexString the hex string |
| | | * @return byte[] |
| | | */ |
| | | public static int hex2Bytes(String hex, byte[] bs, int fromIndex) { |
| | | if (hex == null || hex.equals("")) { |
| | | return fromIndex; |
| | | } |
| | | hex = hex.toUpperCase(Locale.ENGLISH); |
| | | int length = hex.length() / 2; |
| | | char[] hexChars = hex.toCharArray(); |
| | | byte[] d = new byte[length]; |
| | | for (int i = 0; i < length; i++) { |
| | | int pos = i * 2; |
| | | d[i] = (byte) (charToByte(hexChars[pos]) << 4 | charToByte(hexChars[pos + 1])); |
| | | * @param hex the hex string |
| | | * @return è¿å byte[] |
| | | */ |
| | | public static int hex2Bytes(String hex, byte[] bs, int fromIndex) { |
| | | if (hex == null || hex.equals("")) { |
| | | return fromIndex; |
| | | } |
| | | hex = hex.toUpperCase(Locale.ENGLISH); |
| | | int length = hex.length() / 2; |
| | | char[] hexChars = hex.toCharArray(); |
| | | byte[] d = new byte[length]; |
| | | for (int i = 0; i < length; i++) { |
| | | int pos = i * 2; |
| | | d[i] = (byte) (charToByte(hexChars[pos]) << 4 | charToByte(hexChars[pos + 1])); |
| | | } |
| | | for(int i = 0 ; i < d.length; i++){ |
| | | bs[fromIndex++] = d[i] ; |
| | | } |
| | | return fromIndex ; |
| | | } |
| | | return fromIndex ; |
| | | } |
| | | |
| | | private static final char[] HEX_CHAR = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; |
| | | /** |
| | | * å°byte[]转æ¢ä¸º16è¿å¶å符串 |
| | | * |
| | | * @param bytes å¾
转æ¢byte[] |
| | | * @return 转æ¢åçå符串 |
| | | * @return è¿å 转æ¢åçå符串 |
| | | */ |
| | | public static String bytesToHex(byte[] bytes) { |
| | | //ä¸ä¸ªbyte为8ä½ï¼å¯ç¨ä¸¤ä¸ªåå
è¿å¶ä½æ è¯ |
| | |
| | | * å°16è¿å¶å符串转æ¢ä¸ºbyte[] |
| | | * |
| | | * @param str å¾
转æ¢å符串 |
| | | * @return 转æ¢åçbyte[] |
| | | * @return è¿å 转æ¢åçbyte[] |
| | | */ |
| | | public static byte[] hexToBytes(String str) { |
| | | if (str == null || "".equals(str.trim())) { |
| | |
| | | /** |
| | | * Convert char to byte |
| | | * @param c char |
| | | * @return byte |
| | | * @return è¿å byte |
| | | */ |
| | | private static byte charToByte(char c) { |
| | | return (byte) "0123456789ABCDEF".indexOf(c); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 大端模å¼ãæ°æ®ä½ä½å¨æ°ç»é«åèã |
| | | * æ´å½¢è½¬æBCDç¼ç |
| | | * @param l |
| | | * @return |
| | | * @param i |
| | | * @return è¿å |
| | | */ |
| | | public static byte[] int2BCD_BE(int i)throws Exception { |
| | | String str = "" + i; |
| | |
| | | /** |
| | | * å°ç«¯æ¨¡å¼ãæ°æ®ä½ä½å¨æ°ç»ä½åèã |
| | | * æ´å½¢è½¬æBCDç¼ç ï¼åèé¡ºåºæ¯åç |
| | | * @param l |
| | | * @return |
| | | * @param i |
| | | * @return è¿å |
| | | */ |
| | | public static byte[] int2BCD_LE(int i)throws Exception { |
| | | String str = "" + i; |
| | |
| | | * 大端模å¼ãæ°æ®ä½ä½å¨æ°ç»é«åèã |
| | | * é¿æ´å½¢è½¬æBCDç¼ç |
| | | * @param l |
| | | * @return |
| | | * @return è¿å |
| | | */ |
| | | public static byte[] long2BCD_BE(long l)throws Exception { |
| | | String str = "" + l; |
| | |
| | | * å°ç«¯æ¨¡å¼ãæ°æ®ä½ä½å¨æ°ç»ä½åèã |
| | | * é¿æ´å½¢è½¬æBCDç¼ç ï¼åèé¡ºåºæ¯åç |
| | | * @param l |
| | | * @return |
| | | * @return è¿å |
| | | */ |
| | | public static byte[] long2BCD_LE(long l) throws Exception { |
| | | String str = "" + l; |
| | |
| | | * 大端模å¼ãæ°æ®ä½ä½å¨æ°ç»é«åèã |
| | | * åç¬¦ä¸²åæ°å转æBCDç¼ç |
| | | * @param s |
| | | * @return |
| | | * @throws Exception |
| | | * @return è¿å |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public static byte[] string2BCD_BE(String s) throws Exception { |
| | | byte[] b = null; |
| | | byte[] b ; |
| | | if (s.length() % 2 == 0) { |
| | | b = new byte[s.length() / 2]; |
| | | } else { |
| | | b = new byte[(s.length() / 2) + 1]; |
| | | } |
| | | |
| | | |
| | | encodeBCD_BE(s, b, 0, b.length); |
| | | |
| | | return b ; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 大端模å¼ãæ°æ®ä½ä½å¨æ°ç»é«åèã |
| | | * åç¬¦ä¸²è½¬æ¢æbyteæ°ç» |
| | | * @value bs byte[] |
| | | * @value str String |
| | | * @value fromIndex int |
| | | * @return |
| | | * @throws java.io.Exception |
| | | * @return è¿å |
| | | * @throws Exception å¼å¸¸ å¼å¸¸ |
| | | */ |
| | | public static int string2BCD_BE(byte[] bs, String str, int fromIndex)throws Exception { |
| | | byte[] bb = string2BCD_BE(str); |
| | |
| | | * å°ç«¯æ¨¡å¼ãæ°æ®ä½ä½å¨æ°ç»ä½åèã |
| | | * åç¬¦ä¸²åæ°å转æBCDç¼ç ï¼åèé¡ºåºæ¯åç |
| | | * @param s |
| | | * @return |
| | | * @throws Exception |
| | | * @return è¿å |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public static byte[] string2BCD_LE(String s) throws Exception { |
| | | byte[] b = null; |
| | |
| | | |
| | | return b; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 大端模å¼ãæ°æ®ä½ä½å¨æ°ç»é«åèã |
| | | * åç¬¦ä¸²è½¬æ¢æbyteæ°ç» |
| | | * @value bs byte[] |
| | | * @value str String |
| | | * @value fromIndex int |
| | | * @return |
| | | * @throws java.io.Exception |
| | | * @return è¿å |
| | | * @throws Exception å¼å¸¸ å¼å¸¸ |
| | | */ |
| | | public static int string2BCD_LE(byte[] bs, String str, int fromIndex)throws Exception { |
| | | byte[] bb = string2BCD_LE(str); |
| | |
| | | * 大端模å¼ãæ°æ®ä½ä½å¨æ°ç»é«åèã |
| | | * BCDç¼ç è½¬ææ´å |
| | | * @param b |
| | | * @param startIndex |
| | | * @param endIndex |
| | | * @return |
| | | * @throws Exception |
| | | * @return è¿å |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public static int BCD2Int_BE(byte b) throws Exception { |
| | | String str = ""; |
| | |
| | | * å°ç«¯æ¨¡å¼ãæ°æ®ä½ä½å¨æ°ç»ä½åèã |
| | | * BCDç¼ç è½¬ææ´åï¼åèé¡ºåºæ¯åç |
| | | * @param b |
| | | * @param startIndex |
| | | * @param endIndex |
| | | * @return |
| | | * @throws Exception |
| | | * @return è¿å |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public static int BCD2Int_LE(byte b) throws Exception { |
| | | String str = ""; |
| | |
| | | * @param b |
| | | * @param startIndex |
| | | * @param endIndex |
| | | * @return |
| | | * @throws Exception |
| | | * @return è¿å |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public static int BCD2Int_BE(byte[] b, int startIndex, int endIndex)throws Exception { |
| | | String str = ""; |
| | |
| | | * @param b |
| | | * @param startIndex |
| | | * @param endIndex |
| | | * @return |
| | | * @throws Exception |
| | | * @return è¿å |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public static int BCD2Int_LE(byte[] b, int startIndex, int endIndex)throws Exception { |
| | | String str = ""; |
| | |
| | | * @param b |
| | | * @param startIndex |
| | | * @param endIndex |
| | | * @return |
| | | * @throws Exception |
| | | * @return è¿å |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public static long BCD2Long_BE(byte[] b, int startIndex, int endIndex)throws Exception { |
| | | String str = ""; |
| | |
| | | * @param b |
| | | * @param startIndex |
| | | * @param endIndex |
| | | * @return |
| | | * @throws Exception |
| | | * @return è¿å |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public static long BCD2Long_LE(byte[] b, int startIndex, int endIndex)throws Exception { |
| | | String str = ""; |
| | |
| | | * @param b |
| | | * @param startIndex |
| | | * @param endIndex |
| | | * @return |
| | | * @throws Exception |
| | | * @return è¿å |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public static String BCD2String_BE(byte[] b, int startIndex, int endIndex) throws Exception { |
| | | return decodeBCD_BE(b, startIndex, endIndex - startIndex + 1); |
| | |
| | | * @param b |
| | | * @param startIndex |
| | | * @param endIndex |
| | | * @return |
| | | * @throws Exception |
| | | * @return è¿å |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public static String BCD2String_LE(byte[] b, int startIndex, int endIndex) throws Exception { |
| | | return decodeBCD_LE(b, startIndex, endIndex - startIndex + 1); |
| | |
| | | |
| | | /** |
| | | * 大端模å¼ãæ°æ®ä½ä½å¨æ°ç»é«åèã |
| | | * ç¼ç BCDï¼ä¾å¦1387ç¼ç æ 13 87ï¼é¡ºåºæ¯æ£ç |
| | | * ç¼ç BCDï¼ä¾å¦1387ç¼ç æ 13 87ï¼é¡ºåºæ¯æ£ç |
| | | * @param value |
| | | * @param dest |
| | | * @param startIndex |
| | | * @param length |
| | | * @param length é¿åº¦ |
| | | */ |
| | | private static void encodeBCD_BE(String value, byte[] dest, int startIndex, int length)throws Exception { |
| | | if (value == null || !value.matches("\\d*")) { |
| | | throw new Exception("æ°å转æBCDç¼ç æ¶åºéï¼ä¸æ¯åæ³æ°å:" + value, null); |
| | | } |
| | | |
| | | |
| | | int[] tmpInts = new int[2 * length]; |
| | | int index = value.length() - 1; |
| | | for (int i = tmpInts.length - 1; i >= 0 && index >= 0; i--, index--) { |
| | |
| | | dest[i] = (byte) (tmpInts[2 * j] * 16 + tmpInts[2 * j + 1]); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * å°ç«¯æ¨¡å¼ãæ°æ®ä½ä½å¨æ°ç»ä½åèã |
| | | * ç¼ç BCDï¼ä¾å¦1387ç¼ç æ 87 13ï¼é¡ºåºæ¯åç |
| | | * ç¼ç BCDï¼ä¾å¦1387ç¼ç æ 87 13ï¼é¡ºåºæ¯åç |
| | | * @param value |
| | | * @param dest |
| | | * @param startIndex |
| | | * @param length |
| | | * @param length é¿åº¦ |
| | | */ |
| | | private static void encodeBCD_LE(String value, byte[] dest, int startIndex, int length)throws Exception { |
| | | if (value == null || !value.matches("\\d*")) { |
| | | throw new Exception("æ°å转æBCDç¼ç æ¶åºéï¼ä¸æ¯åæ³æ°å:" + value, null); |
| | | } |
| | | |
| | | |
| | | int[] tmpInts = new int[2 * length]; |
| | | int index = value.length() - 1; |
| | | for (int i = 0; i <= tmpInts.length - 1 && index >= 0; i++, index--) { |
| | |
| | | * è§£ç BCDï¼é¡ºåºæ¯æ£ç |
| | | * @param src |
| | | * @param startIndex |
| | | * @param length |
| | | * @return |
| | | * @param length é¿åº¦ |
| | | * @return è¿å |
| | | */ |
| | | private static String decodeBCD_BE(byte[] src, int startIndex, int length)throws Exception { |
| | | StringBuilder sb = new StringBuilder(); |
| | |
| | | * ç¼ç BCDï¼é¡ºåºæ¯åç |
| | | * @param src |
| | | * @param startIndex |
| | | * @param length |
| | | * @return |
| | | * @param length é¿åº¦ |
| | | * @return è¿å |
| | | */ |
| | | private static String decodeBCD_LE(byte[] src, int startIndex, int length)throws Exception { |
| | | StringBuilder sb = new StringBuilder(); |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import com.dy.aceMw.server.tasks.BusiConstantTask; |
| | | import com.dy.common.mw.UnitInterface; |
| | | import com.dy.common.mw.UnitStartedCallbackInterface; |
| | | import com.dy.common.mw.channel.rmi.RmiConfigVo; |
| | |
| | | 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.cacheUpDownDataWarnCount = conf.getSetAttrPlusInt(doc, "config.base", "cacheUpDownDataWarnCount", null, 1, null, null) ; |
| | | //ä¸ä¸è¡æ°æ®ç¼åéåä¸ç¼åæ°æ®ä¸ªæ°çæå¤§å¼ï¼è¿ä¸ªä¸ç°å®é¡¹ç®ææ¥æ°´è¡¨æ°ç¸å
³ |
| | | ServerProperties.cacheUpDownDataMaxCount = conf.getSetAttrPlusInt(doc, "config.base", "cacheUpDownDataMaxCount", null, 1, null, null) ; |
| | | if(ServerProperties.cacheUpDownDataMaxCount <= ServerProperties.cacheUpDownDataWarnCount){ |
| | | throw new Exception("cacheUpDownDataMaxCountå¿
须大äºcacheUpDownDataWarnCount") ; |
| | | } |
| | | |
| | | //设置IDçæå¨çåç¼ |
| | | IDLongGenerator.setSuffix(ServerProperties.dbDataIdSuffix.intValue()); |
| | | |
| | |
| | | //æ¯ææ¨¡åï¼ 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 ; |
| | | } |
| | | |
| | | supVo.enableThreadPool = conf.getSetAttrBoolean(doc, "config.support", "enableThreadPool", null, null) ; |
| | | |
| | | // supVo.enableSpringHibernate = conf.getSetAttrBoolean(doc, "config.support", "enableSpringHibernate", null, null) ; |
| | | // if(supVo.enableSpringHibernate){ |
| | | // supVo.springXmlFile = conf.getSetAttrTxt(doc, "config.support", "springXmlFile", null, false, null) ; |
| | | // } |
| | | |
| | | if(supVo.long_maxThread == 0 || supVo.long_minThread == 0){ |
| | | supVo.enableLongThreadPool = false ; |
| | | }else{ |
| | | supVo.enableLongThreadPool = true ; |
| | | } |
| | | |
| | | supVo.showStartInfo = showStartInfo ; |
| | | |
| | | AdapterImp_SupportUnit supAdap = new AdapterImp_SupportUnit() ; |
| | |
| | | CoreUnitConfigVo coreConfVo = new CoreUnitConfigVo(); |
| | | coreConfVo.sleepBigBusy = conf.getSetAttrPlusInt(doc, "config.core", "sleepBigBusy", null, 1, 200, null).longValue() ; |
| | | coreConfVo.sleepSmallBusy = conf.getSetAttrPlusInt(doc, "config.core", "sleepSmallBusy", null, 2, 1000, null).longValue(); |
| | | coreConfVo.queueWarnSize = conf.getSetAttrPlusInt(doc, "config.core", "queueWarnSize", null, 500, 1000000, null) ; |
| | | coreConfVo.queueMaxSize = conf.getSetAttrPlusInt(doc, "config.core", "queueMaxSize", null, 5000, 3000000, null) ; |
| | | coreConfVo.queueWarnSize = ServerProperties.cacheUpDownDataWarnCount ; |
| | | coreConfVo.queueMaxSize = ServerProperties.cacheUpDownDataMaxCount ; |
| | | coreConfVo.showStartInfo = showStartInfo ; |
| | | AdapterImp_CoreUnit coreAdap = new AdapterImp_CoreUnit(); |
| | | coreAdap.setConfig(coreConfVo); |
| | | 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) { |
| | |
| | | public static Long lastUpDataTimeLive = 1000L ; |
| | | |
| | | //æ°æ®åºæ°æ®idçæå¨çidåç¼ï¼0æ¯é»è®¤çåç¼ï¼ä¸è¬webç³»ç»åºç¨ï¼æ°æ®ä¸é´ä»¶idåç¼å¤§äºçäº1 |
| | | public static Integer dbDataIdSuffix = 1 ; |
| | | public static Integer dbDataIdSuffix = 1 ; |
| | | |
| | | //ä¸ä¸è¡æ°æ®ç¼åéåä¸ç¼åæ°æ®ä¸ªæ°çæ¥è¦éï¼è¿ä¸ªä¸å®ä½é¡¹ç®ææ¥æ°´è¡¨æ°ç¸å
³ |
| | | public static Integer cacheUpDownDataWarnCount = 1000000 ; |
| | | |
| | | //ä¸ä¸è¡æ°æ®ç¼åéåä¸ç¼åæ°æ®ä¸ªæ°çæå¤§å¼ï¼è¿ä¸ªä¸å®ä½é¡¹ç®ææ¥æ°´è¡¨æ°ç¸å
³ |
| | | public static Integer cacheUpDownDataMaxCount = 1100000 ; |
| | | |
| | | } |
| New file |
| | |
| | | package com.dy.aceMw.server.busi; |
| | | |
| | | 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 { |
| | | |
| | | private static final Logger log = LogManager.getLogger(AboutRtuNode.class.getName()); |
| | | |
| | | public Object obj ;//æ°æ® |
| | | |
| | | public AboutRtuNode(Object obj){ |
| | | this.obj = obj ; |
| | | } |
| | | /** |
| | | * èªå·±å¤çèªå·± |
| | | * @return |
| | | */ |
| | | public boolean dealSelf(){ |
| | | try { |
| | | ThreadPool.Pool pool = TreadPoolFactory.getThreadPoolLong() ; |
| | | pool.putJob(new ThreadPool.Job() { |
| | | public void execute() { |
| | | if(obj != null){ |
| | | TaskSurpport t = null ; |
| | | try{ |
| | | t = TaskPool.popTask() ; |
| | | if(t != null){ |
| | | t.execute(obj); |
| | | }else{ |
| | | log.error("æªå¾å°RTU主å¨ä¸æ¥æ°æ®å¤çä»»å¡ï¼"); |
| | | } |
| | | }catch(Exception e){ |
| | | if(t != null){ |
| | | //彿å¼å¸¸æ¶ï¼try catchä¸ç代ç 坿²¡ææ§è¡freeAndCleanTask |
| | | TaskPool.freeAndCleanTask(t); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | @Override |
| | | public void destroy(){ |
| | | } |
| | | @Override |
| | | public boolean isDestroy(){ |
| | | return false ; |
| | | } |
| | | |
| | | }); |
| | | } catch (Exception e) { |
| | | log.error("å¨RtuDataNodeå
åçå¼å¸¸", e); |
| | | } |
| | | return true ; |
| | | } |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | package com.dy.aceMw.server.busi; |
| | | |
| | | import com.dy.aceMw.server.ServerProperties; |
| | | import com.dy.common.queue.Node; |
| | | import com.dy.common.queue.Queue; |
| | | |
| | | public class TcpUpDataCache { |
| | | |
| | | //TCPä¸è¡å½ä»¤ç¼åéå |
| | | private static Queue cacheQueue = new Queue("tcpUpDataQueue") ; |
| | | |
| | | private static TcpUpDataCache instance = new TcpUpDataCache() ; |
| | | |
| | | private TcpUpDataCache(){ |
| | | cacheQueue.setLimit(ServerProperties.cacheUpDownDataWarnCount, ServerProperties.cacheUpDownDataMaxCount); |
| | | } |
| | | |
| | | public static TcpUpDataCache getInstance(){ |
| | | return instance ; |
| | | } |
| | | |
| | | /** |
| | | * ç¼åèç¹ |
| | | * @param reportOrResponse_trueOrFalse reportOrResponse_trueOrFalse |
| | | * @param node node |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | public static void cacheRtuUpData(boolean reportOrResponse_trueOrFalse, AboutRtuNode node) throws Exception{ |
| | | if(node != null && node.data != null){ |
| | | if(reportOrResponse_trueOrFalse){ |
| | | cacheQueue.pushHead(node); |
| | | }else{ |
| | | cacheQueue.pushTail(node); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * å¾å°ç¬¬ä¸ä¸ªèç¹ |
| | | * @return Node |
| | | */ |
| | | public static Node getFirstQueueNode(){ |
| | | return cacheQueue.getFirstNode() ; |
| | | } |
| | | |
| | | /** |
| | | * å¾å°æåä¸ä¸ªèç¹ |
| | | * @return Node |
| | | */ |
| | | public static Node getLastQueueNode(){ |
| | | return cacheQueue.getLastNode() ; |
| | | } |
| | | |
| | | /** |
| | | * ç§»é¤èç¹ |
| | | * @param node |
| | | */ |
| | | public static void removeNode(Node node){ |
| | | cacheQueue.remove(node); |
| | | } |
| | | |
| | | /** |
| | | * ç¼åçèç¹æ° |
| | | * @Return ç¼åèç¹æ° |
| | | */ |
| | | public static Integer size(){ |
| | | return cacheQueue.size() ; |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | package com.dy.aceMw.server.busi.deal; |
| | | |
| | | public interface Task { |
| | | |
| | | |
| | | /** |
| | | * ä»»å¡éç¨å¯¹è±¡æ± ï¼ä»¥ä¾¿éç¨ä»»å¡å¯¹è±¡ï¼ |
| | | * éç¨åè¦è¿è¡å¯¹è±¡åå§åï¼æ¸
é¤ä¸æ¬¡æ§è¡ä»»å¡æ¶éççå¯¹è±¡å±æ§æ°æ® |
| | | * åå§åæ¬ä»»å¡åææåä»»å¡ |
| | | */ |
| | | public void cleanMeAndSubs() ; |
| | | |
| | | /** |
| | | * æ§è¡èç¹ä»»å¡ |
| | | * @param data éè¦å¤ççæ°æ® |
| | | */ |
| | | public void execute(Object data) ; |
| | | |
| | | /** |
| | | * å¾å°æ¬ä»»å¡èç¹å¤ç产ççä¸é´ç»æï¼ä»¥ä¾æ¬èç¹æå¨æ æçä¸çº§ä»»å¡èç¹åæ¬æ æçå·¦ä¾§ï¼æ ¹å¨ä¸ï¼æææ æçèç¹åºç¨æ¬ç»æ |
| | | * @return |
| | | */ |
| | | public Object[] getMyResults() ; |
| | | |
| | | /** |
| | | * å¾å°æå®ä»»å¡èç¹å¤ç产ççä¸é´ç»æï¼ä»¥ä¾æ¬èç¹æå¨æ æçä¸çº§ä»»å¡èç¹åæ¬æ æçå·¦ä¾§ï¼æ ¹å¨ä¸ï¼æææ æçèç¹åºç¨æ¬ç»æ |
| | | * @param id æå®ä»»å¡ID |
| | | * @return |
| | | */ |
| | | public Object[] getTaskResults(String id); |
| | | |
| | | /** |
| | | * 转ä¸çº§ä»»å¡èç¹å¤çï¼é¦å
è¦å®ä½åææåèç¹ã |
| | | * @param data éè¦å¤ççæ°æ® |
| | | */ |
| | | public void toNextTasks(Object data) ; |
| | | |
| | | |
| | | /** |
| | | * 转ä¸çº§æä¸ªä»»å¡èç¹å¤ç |
| | | * @param data éè¦å¤ççæ°æ® |
| | | * @param id æå®ä»»å¡ID |
| | | */ |
| | | public void toNextOneTask(Object data, String id); |
| | | |
| | | } |
| New file |
| | |
| | | package com.dy.aceMw.server.busi.deal; |
| | | |
| | | |
| | | public class TaskConfig { |
| | | public String id ; |
| | | public String name ; |
| | | public Boolean enable ;//æ¯å¦æ§è¡èç¹çæ°æ®å¤çä»»å¡ä»»å¡ |
| | | public String clazz ; |
| | | } |
| New file |
| | |
| | | package com.dy.aceMw.server.busi.deal; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import org.apache.logging.log4j.LogManager; |
| | | import org.apache.logging.log4j.Logger; |
| | | |
| | | |
| | | public class TaskPool { |
| | | |
| | | private static Logger log = LogManager.getLogger(TaskPool.class.getName()) ; |
| | | |
| | | private static List<TaskSurpport> tasks = new ArrayList<TaskSurpport>() ; |
| | | |
| | | private static TreeConfig taskTreeConf ; |
| | | |
| | | |
| | | public static void setTaskTreeCofig(TreeConfig conf){ |
| | | taskTreeConf = conf ; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * å¾å°ä»»å¡ |
| | | * å¤çº¿ç¨ç¯å¢ä¸è¿è¡ |
| | | * @return |
| | | */ |
| | | public static synchronized TaskSurpport popTask(){ |
| | | TaskSurpport t = (tasks.size() > 0)?tasks.get(0):null ; |
| | | if(t != null){ |
| | | tasks.remove(0) ; |
| | | }else{ |
| | | try { |
| | | t = newTaskTree() ; |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage() == null?"å®ä¾åä¸è¡æ°æ®å¤çä»»å¡å¯¹è±¡æ 失败ï¼" : e.getMessage(), e); |
| | | } finally { |
| | | if(t == null){ |
| | | log.error("å®ä¾åä¸è¡æ°æ®å¤çä»»å¡å¯¹è±¡å¤±è´¥ï¼" ); |
| | | } |
| | | } |
| | | } |
| | | |
| | | return t ; |
| | | } |
| | | |
| | | /** |
| | | * æ¾åä»»å¡ |
| | | * å¤çº¿ç¨ç¯å¢ä¸è¿è¡ |
| | | * è¿ééè¦åæ¥éï¼å 为ä¸é¢æ¹æ³ä¸æ§è¡å®tasks.get(0)䏿ªæ§è¡tasks.remove(0)æé´ï¼æ¬æ¹æ³æ§è¡å¹¶ä¸æ§è¡å®ï¼é£ä¹åæå°±ä¼åºä¹±å |
| | | * @param t |
| | | */ |
| | | public static synchronized void freeAndCleanTask(TaskSurpport t){ |
| | | if(t != null){ |
| | | boolean find = false ; |
| | | for(TaskSurpport tin : tasks){ |
| | | if(tin == t){ |
| | | find = true ; |
| | | break ; |
| | | } |
| | | } |
| | | if(!find){ |
| | | t.cleanMeAndSubs(); |
| | | tasks.add(0, t) ; |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * å®ä¾åä»»å¡å¯¹è±¡æ |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | private static TaskSurpport newTaskTree() throws Exception{ |
| | | TaskSurpport t = null ; |
| | | if(taskTreeConf != null){ |
| | | t = newTask(null, taskTreeConf.taskConf, taskTreeConf.subTreeConfs) ; |
| | | } |
| | | return t ; |
| | | } |
| | | |
| | | private static TaskSurpport newTask(TaskSurpport root, TaskConfig taskConf, TreeConfig[] subTreeConfs) throws Exception{ |
| | | TaskSurpport t = null ; |
| | | if(taskConf != null){ |
| | | t = instanceTask(taskConf.clazz) ; |
| | | if(t != null){ |
| | | t.conf = taskConf ; |
| | | t.root = root ; |
| | | if(root == null){ |
| | | root = t ; |
| | | } |
| | | newSubTask(root, t, subTreeConfs); |
| | | } |
| | | } |
| | | return t ; |
| | | } |
| | | private static void newSubTask(TaskSurpport root, TaskSurpport parent, TreeConfig[] treeConfs)throws Exception{ |
| | | if(parent != null && treeConfs != null && treeConfs.length > 0){ |
| | | parent.subTasks = new TaskSurpport[treeConfs.length] ; |
| | | for(int i = 0 ; i < treeConfs.length; i++){ |
| | | parent.subTasks[i] = newTask(root, treeConfs[i].taskConf, treeConfs[i].subTreeConfs) ; |
| | | } |
| | | } |
| | | } |
| | | private static TaskSurpport instanceTask(String clazz)throws Exception{ |
| | | Class<?> c = Class.forName(clazz); |
| | | if (c == null) { |
| | | throw new Exception("å®ä¾åä¸è¡æ°æ®å¤çä»»å¡å¯¹è±¡æ 失败ï¼ä»»å¡ç±»ä¸º" + clazz + "ï¼"); |
| | | }else{ |
| | | return (TaskSurpport)c.newInstance(); |
| | | } |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | package com.dy.aceMw.server.busi.deal; |
| | | |
| | | import org.apache.logging.log4j.LogManager; |
| | | import org.apache.logging.log4j.Logger; |
| | | |
| | | /** |
| | | * é¨åå®ç°Task |
| | | */ |
| | | public abstract class TaskSurpport implements Task { |
| | | |
| | | private static final Logger log = LogManager.getLogger(TaskSurpport.class.getName()) ; |
| | | |
| | | //å½åæå¤ççä¸è¡æ°æ®æå±RTUçå°å |
| | | public String rtuAddr_inRootTk ;//åªå¨æ ¹rootä»»å¡å¯¹è±¡ä¸ä¼ä»æ¤å¼ |
| | | //æ¬èç¹é
ç½® |
| | | protected TaskConfig conf ; |
| | | //æ ¹ä»»å¡ |
| | | protected TaskSurpport root ; |
| | | //æ¬ä»»å¡çåä»»å¡ |
| | | protected TaskSurpport[] subTasks ; |
| | | //æ¬ä»»å¡çå¤çç»æ |
| | | protected Object[] taskResult ; |
| | | |
| | | /** |
| | | * æ§è¡èç¹ä»»å¡ |
| | | * @param data éè¦å¤ççæ°æ® |
| | | */ |
| | | @Override |
| | | public abstract void execute(Object data) ; |
| | | |
| | | /** |
| | | * ä»»å¡éç¨å¯¹è±¡æ± ï¼ä»¥ä¾¿éç¨ä»»å¡å¯¹è±¡ï¼ |
| | | * éç¨åè¦è¿è¡å¯¹è±¡åå§åï¼æ¸
é¤ä¸æ¬¡æ§è¡ä»»å¡æ¶éççå¯¹è±¡å±æ§æ°æ® |
| | | * åå§åæ¬ä»»å¡åææåä»»å¡ |
| | | */ |
| | | @Override |
| | | public void cleanMeAndSubs() { |
| | | rtuAddr_inRootTk = null ; |
| | | taskResult = null ; |
| | | if(this.subTasks != null && this.subTasks.length > 0){ |
| | | for(int i = 0 ; i < this.subTasks.length; i++){ |
| | | this.subTasks[i].cleanMeAndSubs() ; |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * å¾å°æ¬ä»»å¡èç¹å¤ç产ççä¸é´ç»æï¼ä»¥ä¾æ¬èç¹æå¨æ æçä¸çº§ä»»å¡èç¹åæ¬æ æçå·¦ä¾§ï¼æ ¹å¨ä¸ï¼æææ æçèç¹åºç¨æ¬ç»æ |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Object[] getMyResults(){ |
| | | return taskResult ; |
| | | } |
| | | |
| | | /** |
| | | * å¾å°æå®ä»»å¡èç¹å¤ç产ççä¸é´ç»æï¼ä»¥ä¾æ¬èç¹æå¨æ æçä¸çº§ä»»å¡èç¹åæ¬æ æçå·¦ä¾§ï¼æ ¹å¨ä¸ï¼æææ æçèç¹åºç¨æ¬ç»æ |
| | | * @param id æå®ä»»å¡ID |
| | | * @return |
| | | */ |
| | | public Object[] getTaskResults(String id){ |
| | | if(root != null){ |
| | | return this.getTaskResults(root, id) ; |
| | | } |
| | | return null ; |
| | | } |
| | | private Object[] getTaskResults(TaskSurpport task, String id){ |
| | | if(task != null && task.conf != null && task.conf.id != null && task.conf.id.equals(id)){ |
| | | return task.getMyResults() ; |
| | | }else{ |
| | | if(task.subTasks != null && task.subTasks.length > 0){ |
| | | Object[] rs = null ; |
| | | for(int i = 0 ; i < task.subTasks.length; i++){ |
| | | rs = getTaskResults(task.subTasks[i], id) ; |
| | | if(rs != null){ |
| | | return rs ; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return null ; |
| | | } |
| | | |
| | | /** |
| | | * 转ä¸çº§ä»»å¡èç¹å¤çï¼é¦å
è¦å®ä½åææåèç¹ã |
| | | * @param data éè¦å¤ççæ°æ® |
| | | */ |
| | | @Override |
| | | public void toNextTasks(Object data) { |
| | | try { |
| | | if(subTasks != null && subTasks.length > 0){ |
| | | for(int i = 0 ; i < subTasks.length ; i++){ |
| | | if(subTasks[i].conf.enable){ |
| | | subTasks[i].execute(data) ; |
| | | }else{ |
| | | //æ¬èç¹ä¸èµ·ä½ç¨ï¼ç´æ¥è¿å
¥æ¬èçåèç¹ |
| | | subTasks[i].toNextTasks(data) ; |
| | | } |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("åä¸çº§ä»»å¡ä¼ é工使¶åºéï¼" , e); |
| | | }finally{ |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 转ä¸çº§æä¸ªä»»å¡èç¹å¤ç |
| | | * @param data éè¦å¤ççæ°æ® |
| | | * @param id æå®ä»»å¡ID |
| | | */ |
| | | public void toNextOneTask(Object data, String id){ |
| | | try { |
| | | if(subTasks != null && subTasks.length > 0){ |
| | | for(int i = 0 ; i < subTasks.length ; i++){ |
| | | if(subTasks[i].conf.id.equals(id)){ |
| | | if(subTasks[i].conf.enable){ |
| | | subTasks[i].execute(data) ; |
| | | }else{ |
| | | //æ¬èç¹ä¸èµ·ä½ç¨ï¼ç´æ¥è¿å
¥æ¬èçåèç¹ |
| | | subTasks[i].toNextTasks(data) ; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("åæå®åä»»å¡ï¼" + id + "ï¼ä¼ é任塿¶åºéï¼" , e); |
| | | }finally{ |
| | | } |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | package com.dy.aceMw.server.busi.deal; |
| | | |
| | | import com.dy.common.mw.protocol.Data; |
| | | import org.apache.logging.log4j.LogManager; |
| | | import org.apache.logging.log4j.Logger; |
| | | |
| | | public class TkReceive extends TaskSurpport { |
| | | |
| | | private static final Logger log = LogManager.getLogger(TkReceive.class.getName()) ; |
| | | |
| | | //ç±»IDï¼ä¸å®ä¸Tree.xmlé
ç½®æä»¶ä¸é
ç½®ä¸è´ |
| | | public static final String taskId = "TkReceive" ; |
| | | |
| | | /** |
| | | * æ§è¡èç¹ä»»å¡ |
| | | * @param data éè¦å¤ççæ°æ® |
| | | */ |
| | | @Override |
| | | public void execute(Object data) { |
| | | if(data == null){ |
| | | log.error("严éé误ï¼RTUä¸è¡æ°æ®ä¸ºç©ºï¼" ); |
| | | }else{ |
| | | if(data instanceof Data){ |
| | | this.toNextTasks(data); |
| | | }else{ |
| | | log.error("严éé误ï¼è¯¥æ°æ®ç±»åï¼" + data.getClass().getName() + "ï¼ï¼æ¥æ¶æ°æ®ä»»å¡è¿æªå®ç°ï¼" ); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | package com.dy.aceMw.server.busi.deal; |
| | | |
| | | import com.dy.common.mw.protocol.Data; |
| | | import org.apache.logging.log4j.LogManager; |
| | | import org.apache.logging.log4j.Logger; |
| | | |
| | | public class TkRtuData extends TaskSurpport { |
| | | |
| | | private static Logger log = LogManager.getLogger(TkRtuData.class.getName()) ; |
| | | |
| | | //ç±»IDï¼ä¸å®ä¸Tree.xmlé
ç½®æä»¶ä¸é
ç½®ä¸è´ |
| | | public static final String taskId = "TkRtuData" ; |
| | | |
| | | /** |
| | | * æ§è¡èç¹ä»»å¡ |
| | | * @param data éè¦å¤ççæ°æ® |
| | | */ |
| | | @Override |
| | | public void execute(Object data) { |
| | | Data d = (Data)data ; |
| | | String rtuAddr = d.getRtuAddr() ; |
| | | if(rtuAddr == null){ |
| | | log.error("严éé误ï¼RTUä¸è¡æ°æ®ä¸æ RTUå°åï¼" ); |
| | | }else{ |
| | | this.toNextTasks(data); |
| | | } |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE project> |
| | | <config> |
| | | <!-- |
| | | id:ä¸å¯¹åºç±»ä¸çéææååétaskIdä¸è´ |
| | | enable:æ è¯æ¬èç¹æ¯å¦æ§è¡ï¼è¥æ¬èç¹ä¸æ§è¡ï¼åç´æ¥è¿å
¥å
¶åèç¹ |
| | | --> |
| | | <task id="TkReceive" name="æ¥æ¶æ°æ®" enable="true" class="com.dy.aceMw.server.busi.deal.TkReceive"> |
| | | <task id="TkRtuData" name="æ¥æ¶RTUæ°æ®" enable="true" class="com.dy.aceMw.server.busi.deal.TkRtuData"> |
| | | <task id="TkFindP206V1_0_0" name="è¯å«P206V1_0_0æ°æ®" enable="true" class="com.dy.aceMw.server.busi.deal.p206V1_0_0.TkFindP206V1_0_0"> |
| | | <task id="TkPreGenObjs" name="é¢å
åå¤å对象" enable="true" class="com.dy.aceMw.server.busi.deal.p206V1_0_0.TkPreGenObjs"> |
| | | <!-- è¯å«æµæµªè
RTUï¼æ°æ®åºä¸æ²¡æææ°æ®åºåå¨ä½æªåé
ç½®ä¾æ°´æºæ --> |
| | | <task id="TkDealRtuTramp" name="è¯å«æµæµªè
RTU" enable="true" class="com.dy.busi.server.rtuData.meterV1_0.TkDealRtuTramp" /> |
| | | <!-- éæµæµªè
RTUï¼å¿
é¡»æ¾å¨TkDealRtuTrampåé¢ --> |
| | | <task id="TkDealNoRtuTramp" name="éæµæµªè
RTU" enable="true" class="com.dy.busi.server.rtuData.meterV1_0.TkDealNoRtuTramp"> |
| | | <!-- è¯å«ä¸»å¨ä¸æ¥æ°æ® --> |
| | | <task id="TkFindAutoReport" name="è¯å«ä¸»å¨ä¸æ¥å触å䏿¥æ°æ®" enable="true" class="com.dy.busi.server.rtuData.meterV1_0.TkFindAutoReport"> |
| | | <!-- æ£æ¥æ¶é´ç䏿£ç¡®ç䏿¥æ°æ® --> |
| | | <task id="TkCheckAutoReport" name="æ£æ¥æ¶é´ç䏿£ç¡®ç䏿¥æ°æ®" enable="true" class="com.dy.busi.server.rtuData.meterV1_0.autoReport.TkCheckAutoReport"> |
| | | <!-- æ£æ¥éå¤ä¸æ¥æ°æ® --> |
| | | <task id="TkCheckRepeatReport" name="æ£æ¥éå¤ä¸æ¥æ°æ®" enable="true" class="com.dy.busi.server.rtuData.meterV1_0.autoReport.TkCheckRepeatReport"> |
| | | <!-- Mnè¿ç»´ç³»ç» --> |
| | | <task id="TkMnRtuDealAutoReportLastAlarm" name="è¿ç»´RTU䏿¥ææ°æ¥è¦" enable="true" class="com.dy.busi.server.rtuData.meterV1_0.autoReport.TkMnRtuDealAutoReportLastAlarm" /> |
| | | <!-- RTU主å¨ä¸æ¥æ°æ®å¿
é¡»å¨RTU主å¨ä¸æ¥æ¥è¦ä»»å¡çä¸é¢ï¼ä»¥å¤ä¸»å¨ä¸æ¥æ°æ®ä¸è®°å½æ¯å¦ææ¥è¦--> |
| | | <task id="TkMnRtuDealAutoReportLastData" name="è¿ç»´RTU主å¨ä¸æ¥ææ°æ°æ®" enable="true" class="com.dy.busi.server.rtuData.meterV1_0.autoReport.TkMnRtuDealAutoReportLastData" /> |
| | | <!-- RTU宿¶ï¼è§¦åï¼ä¸æ¥æ°æ®å¿
é¡»å¨RTU主å¨ä¸æ¥æ¥è¦ä»»å¡çä¸é¢ï¼ä»¥å¤ä¸»å¨ä¸æ¥æ°æ®ä¸è®°å½æ¯å¦ææ¥è¦--> |
| | | <task id="TkMnRtuDealRealReportLastData" name="è¿ç»´RTU宿¶ï¼è§¦åï¼ä¸æ¥ææ°æ°æ®" enable="true" class="com.dy.busi.server.rtuData.meterV1_0.autoReport.TkMnRtuDealRealReportLastData" /> |
| | | <!-- Org便°´æºæç³»ç» --> |
| | | <task id="TkOrgRtuDealAutoReportLastAlarm" name="便°´æºæRTU主å¨ä¸æ¥ææ°æ¥è¦" enable="true" class="com.dy.busi.server.rtuData.meterV1_0.autoReport.TkOrgRtuDealAutoReportLastAlarm"> |
| | | <task id="TkOrgRtuDealAutoReportAlarm" name="便°´æºæRTU主å¨ä¸æ¥æ¥è¦" enable="true" class="com.dy.busi.server.rtuData.meterV1_0.autoReport.TkOrgRtuDealAutoReportAlarm" /> |
| | | <task id="TkOrgRtuDealReportValveOpResult" name="便°´æºæRTU主å¨ä¸æ¥å¼å
³éç»æ" enable="true" class="com.dy.busi.server.rtuData.meterV1_0.autoReport.TkOrgRtuDealReportValveOpResult" /> |
| | | </task> |
| | | <!-- RTU主å¨ä¸æ¥æ°æ®å¿
é¡»å¨RTU主å¨ä¸æ¥æ¥è¦ä»»å¡çä¸é¢ï¼ä»¥å¤ä¸»å¨ä¸æ¥æ°æ®ä¸è®°å½æ¯å¦ææ¥è¦--> |
| | | <task id="TkOrgRtuDealDayAmountAlarm" name="便°´æºæRTUæ¥ç»ç´¯è®¡æµéæ¥è¦" enable="true" class="com.dy.busi.server.rtuData.meterV1_0.autoReport.TkOrgRtuDealDayAmountAlarm" > |
| | | <task id="TkOrgRtuDeal48HourNoAmount" name="便°´æºæRTU48å°æ¶æªç¨æ°´" enable="true" class="com.dy.busi.server.rtuData.meterV1_0.autoReport.TkOrgRtuDeal48HourNoAmount" > |
| | | <task id="TkOrgRtuDealAutoReportLastData" name="便°´æºæRTU主å¨ä¸æ¥ææ°æ°æ®" enable="true" class="com.dy.busi.server.rtuData.meterV1_0.autoReport.TkOrgRtuDealAutoReportLastData"> |
| | | <task id="TkOrgRtuDealAutoReportData" name="便°´æºæRTU主å¨ä¸æ¥æ°æ®" enable="true" class="com.dy.busi.server.rtuData.meterV1_0.autoReport.TkOrgRtuDealAutoReportData" /> |
| | | <task id="TkOrgRtuDealCycleData" name="便°´æºæRTU主å¨ä¸æ¥å¨æééæ°æ®" enable="true" class="com.dy.busi.server.rtuData.meterV1_0.autoReport.TkOrgRtuDealCycleData"> |
| | | <task id="TkOrgRtuDealCycleLongSmallAmountAlarm" name="便°´æºæRTU主å¨ä¸æ¥å¨æééæ°æ®é¿æµæ°´åæ" enable="true" class="com.dy.busi.server.rtuData.meterV1_0.autoReport.TkOrgRtuDealCycleLongSmallAmountAlarm" /> |
| | | </task> |
| | | <task id="TkOrgRtuDealAmountCost" name="便°´æºæRTU主å¨ä¸æ¥è®¡ç®æ¥æ°´éãææ°´éãåæ°´è´¹" enable="true" class="com.dy.busi.server.rtuData.meterV1_0.autoReport.TkOrgRtuDealAmountCost" > |
| | | <task id="TkOrgRtuDealPayCost" name="便°´æºæç¨æ°´æ·æ°´è¡¨çµåé±å
æ¯ä»æ°´è´¹" enable="true" class="com.dy.busi.server.rtuData.meterV1_0.autoReport.TkOrgRtuDealPayCost" /> |
| | | </task> |
| | | </task> |
| | | </task> |
| | | </task> |
| | | <!-- RTU宿¶ï¼è§¦åï¼ä¸æ¥æ°æ®å¿
é¡»å¨RTU主å¨ä¸æ¥æ¥è¦ä»»å¡çä¸é¢ï¼ä»¥å¤ä¸»å¨ä¸æ¥æ°æ®ä¸è®°å½æ¯å¦ææ¥è¦--> |
| | | <task id="TkOrgRtuDealRealReportLastData" name="便°´æºæRTU宿¶ï¼è§¦åï¼ä¸æ¥ææ°æ°æ®" enable="true" class="com.dy.busi.server.rtuData.meterV1_0.autoReport.TkOrgRtuDealRealReportLastData"> |
| | | <task id="TkOrgRtuDealRealReportData" name="便°´æºæRTU宿¶ï¼è§¦åï¼ä¸æ¥æ°æ®" enable="true" class="com.dy.busi.server.rtuData.meterV1_0.autoReport.TkOrgRtuDealRealReportData" /> |
| | | </task> |
| | | </task> |
| | | </task> |
| | | </task> |
| | | <!-- è¯å«å½ä»¤ååºæ°æ® --> |
| | | <task id="TkFindComResponse" name="è¯å«ååºå½ä»¤æ°æ®" enable="true" class="com.dy.busi.server.rtuData.meterV1_0.TkFindComResponse"> |
| | | <task id="TkRtuDealCommandResponse" name="RTUååºå½ä»¤æ°æ®" enable="true" class="com.dy.busi.server.rtuData.meterV1_0.comResponse.TkRtuDealCommandResponse" > |
| | | <task id="TkRtuDealSetParamComResponse" name="RTUååºè®¾ç½®åæ°å½ä»¤æ°æ®" enable="true" class="com.dy.busi.server.rtuData.meterV1_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> |
| | | </config> |
| New file |
| | |
| | | package com.dy.aceMw.server.busi.deal; |
| | | |
| | | public class TreeConfig { |
| | | public TaskConfig taskConf ; |
| | | public TreeConfig[] subTreeConfs ;//ææåèç¹ |
| | | } |
| New file |
| | |
| | | package com.dy.aceMw.server.busi.deal; |
| | | |
| | | |
| | | import java.net.URL; |
| | | import java.util.*; |
| | | |
| | | import org.jdom2.Document; |
| | | import org.jdom2.Element; |
| | | import org.jdom2.input.SAXBuilder; |
| | | |
| | | |
| | | public class TreeParse { |
| | | public List<String> ids ; |
| | | public List<String> classes ; |
| | | |
| | | // public static void main(String args[]) { |
| | | // TreeParse o = new TreeParse(); |
| | | // TreeConfig conf = o.parseConfig(); |
| | | // } |
| | | |
| | | public TreeParse(){ |
| | | ids = new ArrayList<String>() ; |
| | | classes = new ArrayList<String>() ; |
| | | } |
| | | |
| | | /** |
| | | * è§£æå¤çå¨é
ç½® |
| | | * @return |
| | | */ |
| | | protected TreeConfig parseConfig() { |
| | | try { |
| | | URL configFileURL = TreeParse.class.getResource("Tree.xml"); |
| | | return this.parse(this.createDom(configFileURL)) ; |
| | | } catch (Exception e) { |
| | | System.out.println("ç³»ç»å¯å¨æ¶ï¼åå§ä¸è¡æ°æ®å¤çä»»å¡é
ç½®åºé !"); |
| | | System.out.println(e.getMessage()); |
| | | e.printStackTrace(); |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * @return |
| | | */ |
| | | private Document createDom(URL configFileURL) throws Exception { |
| | | if (configFileURL == null) { |
| | | throw new Exception("æªå¾å°ä¸è¡æ°æ®å¤çä»»å¡é
ç½®æä»¶!", null); |
| | | } |
| | | Document doc = null; |
| | | try { |
| | | SAXBuilder sb = new SAXBuilder(); |
| | | doc = sb.build(configFileURL); |
| | | if (doc == null) { |
| | | throw new Exception("æªçæä¸è¡æ°æ®å¤çä»»å¡é
ç½®æä»¶çDOM对象!", null); |
| | | } |
| | | } catch (Exception e) { |
| | | throw new Exception("çæä¸è¡æ°æ®å¤çä»»å¡é
ç½®æä»¶çDOM对象失败!", e); |
| | | } |
| | | return doc; |
| | | } |
| | | |
| | | /** |
| | | * åæ |
| | | * @return ArrayList<String> |
| | | * @throws Exception |
| | | */ |
| | | private TreeConfig parse(Document doc) throws Exception { |
| | | Element root = doc.getRootElement(); |
| | | if (root == null) { |
| | | throw new Exception("æªå¾å°ä¸è¡æ°æ®å¤çä»»å¡é
ç½®æä»¶æ ¹å
ç´ config!"); |
| | | } |
| | | |
| | | List<Element> rootTasks = root.getChildren("task") ; |
| | | if(rootTasks == null || rootTasks.size() == 0){ |
| | | throw new Exception("æªå¾å°ä¸è¡æ°æ®å¤çä»»å¡é
ç½®æä»¶æ ¹ä»»å¡task!"); |
| | | } |
| | | if(rootTasks.size() > 1){ |
| | | throw new Exception("æªå¾å°ä¸è¡æ°æ®å¤çä»»å¡é
ç½®æä»¶æ ¹ä»»å¡taskå¿
é¡»åªæä¸ä¸ª!"); |
| | | } |
| | | |
| | | TreeConfig tree = new TreeConfig() ; |
| | | tree.taskConf = new TaskConfig() ; |
| | | |
| | | this.parseNode(rootTasks.get(0), tree, tree.taskConf) ; |
| | | return tree ; |
| | | } |
| | | |
| | | private void parseNode(Element taskEle, TreeConfig me, TaskConfig taskConf)throws Exception { |
| | | // <task id="task2.1" name="æé æ°æ®" enable="true" class="" /> |
| | | if(taskEle == null){ |
| | | throw new Exception("åæä¸è¡æ°æ®å¤çä»»å¡é
ç½®æä»¶åºéï¼"); |
| | | } |
| | | |
| | | String id = taskEle.getAttributeValue("id") ; |
| | | if(id == null || id.trim().equals("")){ |
| | | throw new Exception("ä¸è¡æ°æ®å¤çä»»å¡é
ç½®æä»¶ä¸idå¿
é¡»é
ç½®ï¼"); |
| | | } |
| | | id = id.trim() ; |
| | | if(ids.contains(id)){ |
| | | throw new Exception("ä¸è¡æ°æ®å¤çä»»å¡é
ç½®æä»¶ä¸id=" + id + "éå¤é
ç½®ï¼"); |
| | | } |
| | | taskConf.id = id ; |
| | | ids.add(id) ; |
| | | |
| | | String name = taskEle.getAttributeValue("name") ; |
| | | if(name == null || name.trim().equals("")){ |
| | | throw new Exception("ä¸è¡æ°æ®å¤çä»»å¡é
ç½®æä»¶ä¸nameå¿
é¡»é
ç½®ï¼"); |
| | | } |
| | | name = name.trim() ; |
| | | taskConf.name = name ; |
| | | |
| | | String enable = taskEle.getAttributeValue("enable") ; |
| | | if(enable == null || !(enable.trim().equals("true") || enable.trim().equals("false"))){ |
| | | throw new Exception("ä¸è¡æ°æ®å¤çä»»å¡é
ç½®æä»¶ä¸enableå¿
é¡»é
ç½®ï¼å¹¶ä¸å¼åªè½ä¸ºtrueæfalseï¼"); |
| | | } |
| | | if(enable.trim().equals("true")){ |
| | | taskConf.enable = true ; |
| | | } |
| | | if(enable.trim().equals("false")){ |
| | | taskConf.enable = false ; |
| | | } |
| | | |
| | | String clazz = taskEle.getAttributeValue("class") ; |
| | | if(clazz == null || clazz.trim().equals("")){ |
| | | throw new Exception("ä¸è¡æ°æ®å¤çä»»å¡é
ç½®æä»¶ä¸classå¿
é¡»é
ç½®ï¼"); |
| | | } |
| | | clazz = clazz.trim() ; |
| | | if(classes.contains(clazz)){ |
| | | throw new Exception("ä¸è¡æ°æ®å¤çä»»å¡é
ç½®æä»¶ä¸class=" + clazz + "éå¤é
ç½®ï¼"); |
| | | } |
| | | taskConf.clazz = clazz ; |
| | | classes.add(clazz) ; |
| | | this.checkClass(taskConf.clazz) ; |
| | | |
| | | this.parseSubNode(taskEle, me) ; |
| | | |
| | | } |
| | | |
| | | private void parseSubNode(Element ele, TreeConfig parent)throws Exception { |
| | | List<?> list = ele.getChildren("task") ; |
| | | if(list != null && list.size() > 0){ |
| | | parent.subTreeConfs = new TreeConfig[list.size()] ; |
| | | Iterator<?> it = list.iterator(); |
| | | Element e = null; |
| | | int count = 0 ; |
| | | TreeConfig me ; |
| | | while(it.hasNext()){ |
| | | e = (Element) it.next(); |
| | | me = new TreeConfig() ; |
| | | me.taskConf = new TaskConfig() ; |
| | | parent.subTreeConfs[count++] = me ; |
| | | parseNode(e, me, me.taskConf) ; |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void checkClass(String clazz)throws Exception { |
| | | Class<?> c = Class.forName(clazz); |
| | | if (c == null) { |
| | | throw new Exception("ä¸è¡æ°æ®å¤çä»»å¡é
ç½®æä»¶ä¸ä¸è½å®ä¾åclass=" + clazz + "ï¼"); |
| | | }else{ |
| | | Object o = c.newInstance(); |
| | | if(o instanceof Task){ |
| | | }else{ |
| | | throw new Exception("ä¸è¡æ°æ®å¤çä»»å¡é
ç½®æä»¶ä¸class=" + clazz + "å¿
é¡»å®ç°Taskæ¥å£ï¼"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| New file |
| | |
| | | package com.dy.aceMw.server.busi.deal.p206V1_0_0; |
| | | |
| | | |
| | | import com.dy.aceMw.server.busi.deal.TaskSurpport; |
| | | import com.dy.common.mw.protocol.Data; |
| | | import com.dy.common.mw.protocol.p206V1_0_0.ProtocolConstantV206V1_0_0; |
| | | |
| | | public class TkFindP206V1_0_0 extends TaskSurpport { |
| | | |
| | | //ç±»IDï¼ä¸å®ä¸Tree.xmlé
ç½®æä»¶ä¸é
ç½®ä¸è´ |
| | | public static final String taskId = "TkFindP206V1_0_0" ; |
| | | |
| | | /** |
| | | * æ§è¡èç¹ä»»å¡ |
| | | * @param data éè¦å¤ççæ°æ® |
| | | */ |
| | | @Override |
| | | public void execute(Object data) { |
| | | Data d = (Data)data ; |
| | | if(d.getProtocol() != null && d.getProtocol().equals(ProtocolConstantV206V1_0_0.protocolName)){ |
| | | this.toNextTasks(data); |
| | | }else{ |
| | | //䏿¯æ¬åè®®çæ°æ® |
| | | } |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | package com.dy.aceMw.server.busi.deal.p206V1_0_0; |
| | | |
| | | import com.dy.aceMw.server.busi.deal.TaskSurpport; |
| | | import com.dy.common.mw.protocol.Data; |
| | | import org.apache.logging.log4j.LogManager; |
| | | import org.apache.logging.log4j.Logger; |
| | | |
| | | public class TkPreGenObjs extends TaskSurpport { |
| | | |
| | | private static final Logger log = LogManager.getLogger(TkPreGenObjs.class.getName()) ; |
| | | |
| | | //ç±»IDï¼ä¸å®ä¸Tree.xmlé
ç½®æä»¶ä¸é
ç½®ä¸è´ |
| | | public static final String taskId = "TkPreGenObjs" ; |
| | | |
| | | /** |
| | | * æ§è¡èç¹ä»»å¡ |
| | | * @param data éè¦å¤ççæ°æ® |
| | | */ |
| | | @Override |
| | | public void execute(Object data) { |
| | | Data d = (Data)data ; |
| | | String rtuAddr = d.getRtuAddr() ; |
| | | //å¾å°æ¬å°RTU æ°æ®ï¼ä»¥å¤åé¢èç¹åºç¨ |
| | | /* |
| | | BuziInterface baseBusi = BuziGeter.getBaseBusi() ; |
| | | BuziInterface orgBusi = null ; |
| | | SyRtu nbRtu = null ; |
| | | SyRtuTramp rtuTramp = null ; |
| | | if(baseBusi != null){ |
| | | nbRtu = DbSyBuzi.getRtu(baseBusi, imei) ; |
| | | if(nbRtu != null){ |
| | | //æ°æ®åºä¸æ¥è¯¢å°NB产åï¼RTUå®ä½ï¼ |
| | | if(nbRtu.orgTag != null && !nbRtu.orgTag.trim().equals("")){ |
| | | orgBusi = BuziGeter.getBusi(nbRtu.orgTag) ; |
| | | if(orgBusi == null){ |
| | | log.error("严ééè¯¯ï¼æªè½å¾å°æ ç¾ä¸º" + nbRtu.orgTag + "ç便°´æºææ°æ®åºä¸å¡Busi"); |
| | | }else{ |
| | | BaMeter meter = DbOrgBuzi.getMeterByImeiAndNo(orgBusi, imei, meterNo) ; |
| | | //å¯è½æªæ¥è¯¢å°meterï¼å³ä»æ¯æµæµªè
RTUï¼ä½ä»è¦åç»å¤çï¼ï¼1ï¼ãä»è½è¯å«åºæµæµªè
RTUï¼ï¼2ï¼ãä»è¦è®°å½å
¶ä¸æ¥æ°æ® |
| | | if(meter != null){ |
| | | String protocol = d.getProtocol() ; |
| | | if(protocol != null){ |
| | | protocol = protocol.trim(); |
| | | if(!protocol.equals("")){ |
| | | if(meter.protocol == null |
| | | || meter.protocol.trim().equals("") |
| | | || !meter.protocol.trim().equals(protocol)){ |
| | | //éè¦æ´æ°åè®®åç§° |
| | | DbOrgBuzi.updateMeter4Protocol(orgBusi, meter.id, protocol); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | this.taskResult = new Object[]{baseBusi, orgBusi, nbRtu, null, meter} ; |
| | | this.toNextTasks(data); |
| | | } |
| | | }else{ |
| | | //NB产åï¼RTUå®ä½ï¼æªåé
ç»å
·ä½ç便°´æºæ |
| | | //æµæµªè
RTU |
| | | rtuTramp = DbSyBuzi.getSyRtuTramp(baseBusi, imei, meterNo) ; |
| | | if(rtuTramp == null){ |
| | | rtuTramp = new SyRtuTramp(imei, meterNo) ; |
| | | } |
| | | this.taskResult = new Object[]{baseBusi, orgBusi, nbRtu, rtuTramp, null} ; |
| | | this.toNextOneTask(data, TkDealRtuTramp.taskId); |
| | | } |
| | | }else{ |
| | | //æ°æ®åºä¸æªæ¥è¯¢å°NB产åï¼RTUå®ä½ï¼ |
| | | //æµæµªè
RTU |
| | | rtuTramp = DbSyBuzi.getSyRtuTramp(baseBusi, imei, meterNo) ; |
| | | if(rtuTramp == null){ |
| | | rtuTramp = new SyRtuTramp(imei, meterNo) ; |
| | | } |
| | | this.taskResult = new Object[]{baseBusi, orgBusi, nbRtu, rtuTramp, null} ; |
| | | this.toNextOneTask(data, TkDealRtuTramp.taskId); |
| | | } |
| | | }else{ |
| | | log.error("严ééè¯¯ï¼æªè½å¾å°BaseBusi对象"); |
| | | } |
| | | */ |
| | | } |
| | | } |
| | |
| | | package com.dy.aceMw.server.forTcp; |
| | | |
| | | import com.dy.aceMw.server.busi.AboutRtuNode; |
| | | import com.dy.aceMw.server.busi.TcpUpDataCache; |
| | | import org.apache.logging.log4j.LogManager; |
| | | import org.apache.logging.log4j.Logger; |
| | | |
| | |
| | | //æ¤å¤å®ç°ï¼ä¸ä»¥åä¸ä¸æ ·ï¼ |
| | | //以åå®ç°ï¼å¹é
å½ä»¤æ¯ä»åååå¹é
ï¼ |
| | | //å½åå®ç°ï¼å¹é
å½ä»¤æ¯ä»åååå¹é
ï¼åå ï¼ä¸¾ä¾ï¼å½æ¹éä¸åè¡¥å¬å½ä»¤ï¼å¦æä»åå¹é
ï¼ååé¢å½ä»¤ä¼ä¸å夿¬¡ï¼å³ä¸ä¸ªä¸æ¥æ¬¡æ°æ®ä¼è¡¥å¬å¤æ¬¡ |
| | | MidResultToRtu resToRtu = TcpDownCommandCach.matchFromHead(resFromRtu) ; |
| | | MidResultToRtu resToRtu = TcpDownCommandCache.matchFromHead(resFromRtu) ; |
| | | if(resToRtu != null){ |
| | | //å¹é
å°ä¸åçå½ä»¤ |
| | | resFromRtu.setCommandId(resToRtu.commandId) ; |
| | | this.sendResult(false, resFromRtu); |
| | | this.nextDeal(false, resFromRtu); |
| | | }else{ |
| | | this.sendResult(false, resFromRtu); |
| | | this.nextDeal(false, resFromRtu); |
| | | //æªå¹é
å°ä¸åçå½ä»¤ï¼å½ä»¤å¨ç¼åå è¶
æ¶è¢«æ¸
é¤äº |
| | | RtuStatusDealer.commandFail2Success(resFromRtu.rtuAddr) ; |
| | | } |
| | | }else{ |
| | | //主å¨ä¸æ¥æ°æ® |
| | | this.sendResult(true, resFromRtu); |
| | | this.nextDeal(true, resFromRtu); |
| | | } |
| | | } |
| | | } |
| | | private void sendResult(boolean reportOrResponse_trueOrFalse, MidResultFromRtu resFromRtu){ |
| | | |
| | | /** |
| | | * è¿å
¥å¤çº¿ç¨ç¯å¢ä¸è¿è¡ |
| | | * @param reportOrResponse_trueOrFalse |
| | | * @param resFromRtu |
| | | */ |
| | | private void nextDeal(boolean reportOrResponse_trueOrFalse, MidResultFromRtu resFromRtu){ |
| | | try{ |
| | | String json = resFromRtu.data.toJson() ; |
| | | // if(reportOrResponse_trueOrFalse){ |
| | | // ToMqMessageCach.cachObj(MessageType.RtuAutoReport, json); |
| | | // }else{ |
| | | // ToMqMessageCach.cachObj(MessageType.RtuCmdResponse, json); |
| | | // } |
| | | TcpUpDataCache.cacheRtuUpData(reportOrResponse_trueOrFalse, new AboutRtuNode(resFromRtu.data)); |
| | | }catch(Exception e){ |
| | | log.error(e.getMessage(), e); |
| | | } |
| | | |
| | | } |
| | | } |
| | |
| | | if(result != null && result instanceof MidResultToRtu){ |
| | | try { |
| | | MidResultToRtu resToRtu = (MidResultToRtu)result ; |
| | | TcpDownCommandCach.cachCommand(resToRtu); |
| | | TcpDownCommandCache.cacheCommand(resToRtu); |
| | | log.info("ä¸è¡å½ä»¤(toRtu)" + resToRtu.downCode + "ä¸é´ç»æå·²ç»æ¾å
¥ä¸è¡å½ä»¤ç¼åä¸"); |
| | | } catch (Exception e) { |
| | | log.error(e); |
| File was renamed from pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/TcpDownCommandCach.java |
| | |
| | | /** |
| | | * é线ç¨å®å
¨çï¼åªè½å¨å线ç¨ä¸è¿è¡ |
| | | */ |
| | | public class TcpDownCommandCach { |
| | | public class TcpDownCommandCache { |
| | | |
| | | //TCPä¸è¡å½ä»¤ç¼åéå |
| | | private static Queue cachQueue = new Queue("tcpDownComandQueue") ; |
| | | private static Queue cacheQueue = new Queue("tcpDownCommandQueue") ; |
| | | |
| | | private static TcpDownCommandCach instance = new TcpDownCommandCach() ; |
| | | private static TcpDownCommandCache instance = new TcpDownCommandCache() ; |
| | | |
| | | private TcpDownCommandCach(){ |
| | | cachQueue.setLimit(990000, 1000000); |
| | | private TcpDownCommandCache(){ |
| | | cacheQueue.setLimit(ServerProperties.cacheUpDownDataWarnCount, ServerProperties.cacheUpDownDataMaxCount); |
| | | } |
| | | |
| | | public static TcpDownCommandCach getInstance(){ |
| | | public static TcpDownCommandCache getInstance(){ |
| | | return instance ; |
| | | } |
| | | |
| | |
| | | * @param result |
| | | * @throws Exception |
| | | */ |
| | | public static void cachCommand(MidResultToRtu result) throws Exception{ |
| | | public static void cacheCommand(MidResultToRtu result) throws Exception{ |
| | | if(result != null){ |
| | | if(result.maxSendTimes == null){ |
| | | //设置æå¤§å鿬¡æ° |
| | | result.maxSendTimes = ServerProperties.downComandMaxResendTimes ; |
| | | } |
| | | if(result.isSendFirst){ |
| | | cachQueue.pushHead(new TcpDownCommandObj(result)); |
| | | cacheQueue.pushHead(new TcpDownCommandObj(result)); |
| | | }else{ |
| | | cachQueue.pushTail(new TcpDownCommandObj(result)); |
| | | cacheQueue.pushTail(new TcpDownCommandObj(result)); |
| | | } |
| | | } |
| | | } |
| | |
| | | public static MidResultToRtu matchFromHead(MidResultFromRtu rsFromRtu){ |
| | | MidResultToRtu res = null ; |
| | | TcpDownCommandObj obj = null ; |
| | | Node node = cachQueue.getFirstNode() ; |
| | | Node node = cacheQueue.getFirstNode() ; |
| | | while(node != null && node.obj != null){ |
| | | obj = (TcpDownCommandObj)node.obj; |
| | | res = obj.result ; |
| | |
| | | public static MidResultToRtu matchFromTail(MidResultFromRtu rsFromRtu){ |
| | | MidResultToRtu res = null ; |
| | | TcpDownCommandObj obj = null ; |
| | | Node node = cachQueue.getLastNode() ; |
| | | Node node = cacheQueue.getLastNode() ; |
| | | while(node != null && node.obj != null){ |
| | | obj = (TcpDownCommandObj)node.obj; |
| | | res = obj.result ; |
| | |
| | | * @return |
| | | */ |
| | | public static Node getFirstQueueNode(){ |
| | | return cachQueue.getFirstNode() ; |
| | | return cacheQueue.getFirstNode() ; |
| | | } |
| | | |
| | | /** |
| | |
| | | * @return |
| | | */ |
| | | public static Node getLastQueueNode(){ |
| | | return cachQueue.getLastNode() ; |
| | | return cacheQueue.getLastNode() ; |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param node |
| | | */ |
| | | public static void removeNode(Node node){ |
| | | cachQueue.remove(node); |
| | | cacheQueue.remove(node); |
| | | } |
| | | |
| | | /** |
| | | * ç¼åçèç¹æ° |
| | | * @param node |
| | | * @Return ç¼åèç¹æ° |
| | | */ |
| | | public static Integer size(){ |
| | | return cachQueue.size() ; |
| | | return cacheQueue.size() ; |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | package com.dy.aceMw.server.tasks; |
| | | |
| | | import com.dy.aceMw.server.busi.AboutRtuNode; |
| | | import com.dy.aceMw.server.busi.TcpUpDataCache; |
| | | import com.dy.common.mw.core.CoreTask; |
| | | import com.dy.common.queue.Node; |
| | | import org.apache.logging.log4j.LogManager; |
| | | import org.apache.logging.log4j.Logger; |
| | | |
| | | /** |
| | | * 对RTUä¸è¡æ°æ®è¿è¡ä¸å¡å¤ç |
| | | */ |
| | | public class BusiConstantTask extends CoreTask { |
| | | private static final Logger log = LogManager.getLogger(BusiConstantTask.class.getName()); |
| | | |
| | | /** |
| | | * å¨å线ç¨ç¯å¢ä¸è¿è¡ |
| | | */ |
| | | @Override |
| | | public Integer excute() { |
| | | try{ |
| | | return dealRtuUpdata() ; |
| | | }catch(Exception e){ |
| | | log.error(e); |
| | | } |
| | | return null ; |
| | | } |
| | | |
| | | /** |
| | | * å¤çä¸è¡æ°æ® |
| | | */ |
| | | public Integer dealRtuUpdata() { |
| | | Node first = TcpUpDataCache.getFirstQueueNode() ; |
| | | if(first != null){ |
| | | Integer count = TcpUpDataCache.size() ; |
| | | Node last = TcpUpDataCache.getLastQueueNode() ; |
| | | this.doDealRtuUpdata(first, last); |
| | | return count ; |
| | | } |
| | | return null ; |
| | | } |
| | | |
| | | /** |
| | | * å¤çç¼åçä¸è¡æ°æ®èç¹ |
| | | * @param first 第ä¸ä¸ªèç¹ |
| | | * @param 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) ; |
| | | }else if(first != null && first == last){ |
| | | //忢 |
| | | }else if(first == null){ |
| | | //è¿ç§æ
åµä¸ä¼åå¨ |
| | | doDealRtuUpdata(null, pre) ; |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * å¤çä¸ä¸ªèç¹ |
| | | * @param node èç¹ |
| | | */ |
| | | private void dealNode(Node node){ |
| | | AboutRtuNode obj = (AboutRtuNode)node.obj ; |
| | | obj.dealSelf() ; |
| | | TcpUpDataCache.removeNode(node); |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | /** |
| | | * å¤çå½ä»¤ |
| | | * @param webJgroupName |
| | | * @param com |
| | | * @param com å½ä»¤ |
| | | * @throws Exception |
| | | */ |
| | | private void deal(Command com) throws Exception{ |
| | |
| | | }else{ |
| | | MidResult[] midRs = dri.parseData(ServerProperties.isLowPower, rtuAddrAtHead, upBuf, upHex, new DriverParserDataCallback(){ |
| | | @Override |
| | | public void callback(String rtuAddrAtHead, String meterNoAtHead, String code, String upHex, Boolean reportOrResponse_trueOrFalse, boolean parseFail, String rtuAddrInData, String meterNoInData) { |
| | | public void callback(String rtuAddrAtHead, String code, String upHex, Boolean reportOrResponse_trueOrFalse, boolean parseFail, String rtuAddrInData) { |
| | | //æ´æ°ç»ç«¯ç¶æ |
| | | if(rtuAddrInData != null && !rtuAddrInData.equals(rtuAddrAtHead)){ |
| | | //æ°æ®å¤´ä¸çRTUå°å䏿°æ®ä¸çRTUå°åä¸ä¸è´ï¼æ´æ¢ææ°æ®ä¸çRTUå°å |
| | |
| | | |
| | | import com.dy.common.queue.Node; |
| | | import com.dy.common.mw.core.CoreTask; |
| | | import com.dy.aceMw.server.forTcp.TcpDownCommandCach; |
| | | import com.dy.aceMw.server.forTcp.TcpDownCommandCache; |
| | | import com.dy.aceMw.server.forTcp.TcpDownCommandObj; |
| | | import com.dy.aceMw.server.forTcp.TcpSessionCach; |
| | | |
| | |
| | | * å¤çä¸è¡å½ä»¤ |
| | | */ |
| | | public Integer dealDownCommand(Long now) { |
| | | try{ |
| | | Node first = TcpDownCommandCach.getFirstQueueNode() ; |
| | | if(first != null){ |
| | | Integer count = TcpDownCommandCach.size() ; |
| | | Node last = TcpDownCommandCach.getLastQueueNode() ; |
| | | this.doDealDownCommand(now, first, last); |
| | | return count ; |
| | | } |
| | | }catch(Exception e){ |
| | | log.error(e); |
| | | Node first = TcpDownCommandCache.getFirstQueueNode() ; |
| | | if(first != null){ |
| | | Integer count = TcpDownCommandCache.size() ; |
| | | Node last = TcpDownCommandCache.getLastQueueNode() ; |
| | | this.doDealDownCommand(now, first, last); |
| | | return count ; |
| | | } |
| | | return null ; |
| | | } |
| | |
| | | * å¤çç¼åçä¸è¡å½ä»¤èç¹ |
| | | * @param now å½åæ¶å» |
| | | * @param first 第ä¸ä¸ªèç¹ |
| | | * @param last æ¯åä¸ä¸ªèç¹ |
| | | * @param last æåä¸ä¸ªèç¹ |
| | | */ |
| | | private void doDealDownCommand(Long now, Node first, Node last){ |
| | | private void doDealDownCommand1(Long now, Node first, Node last){ |
| | | if(first != null){ |
| | | //å¨dealNodeæ¹æ³ä¸ï¼å¯è½è¦æfirstä»éåä¸ç§»é¤ï¼è¿æ¶first.nextä¸ºç©ºï¼æä»¥æåæfirst.nextååºæ¥ |
| | | Node next = first.next ; |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * å¤çç¼åçä¸è¡å½ä»¤èç¹ |
| | | * @param now å½åæ¶å» |
| | | * @param first 第ä¸ä¸ªèç¹ |
| | | * @param last æåä¸ä¸ªèç¹ |
| | | */ |
| | | private void doDealDownCommand(Long now, Node first, Node last){ |
| | | if(last != null){ |
| | | //å¨dealNodeæ¹æ³ä¸ï¼å¯è½è¦ælastä»éåä¸ç§»é¤ï¼è¿æ¶last.preä¸ºç©ºï¼æä»¥æåælast.preååºæ¥ |
| | | Node pre = last.pre ; |
| | | dealNode(now, last) ; |
| | | if(first != null && first != last){ |
| | | doDealDownCommand(now, first, pre) ; |
| | | }else if(first != null && first == last){ |
| | | //忢 |
| | | }else if(first == null){ |
| | | //è¿ç§æ
åµä¸ä¼åå¨ |
| | | doDealDownCommand(now, null, pre) ; |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * å¤çä¸ä¸ªèç¹ |
| | |
| | | TcpDownCommandObj obj = (TcpDownCommandObj)node.obj ; |
| | | boolean removeNode = obj.dealSelf(now) ; |
| | | if(removeNode){ |
| | | TcpDownCommandCach.removeNode(node); |
| | | TcpDownCommandCache.removeNode(node); |
| | | } |
| | | } |
| | | |
| | |
| | | offLineCachTimeout: ä¸å¨çº¿ç¼åçå½ä»¤æå¤§ç¼åæ¶é¿(ç§) |
| | | lastUpDataTimeLive: TCPä¸è¡æ°æ®æ¶å»ç¼åæ¶é¿(ç§)ï¼å½è¾¾å°æ¶é¿æ¶ï¼TCPä¸è¡æ°æ®æ¶å»è¢«æ¸
空ï¼éç¨TCPä¸è¡æ°æ®æ¶å»ç®çæ¯ï¼é»æ¢ä¸è¡æ°æ®åæ¶ä¸åæ°æ®ï¼å 为RTUå¤çä¸è¿æ¥(ç»å次å®éªï¼1ç§è¿æ¯æé®é¢ï¼2ç§æ é®é¢) |
| | | dbDataIdSuffixï¼æ°æ®åºæ°æ®idçæå¨çidåç¼ï¼0æ¯é»è®¤çåç¼ï¼ä¸è¬webç³»ç»åºç¨ï¼æ°æ®ä¸é´ä»¶idåç¼å¤§äºçäº1 |
| | | cacheUpDownDataWarnCountï¼ä¸ä¸è¡æ°æ®ç¼åéåä¸ç¼åæ°æ®ä¸ªæ°çæ¥è¦éï¼è¿ä¸ªä¸ç°å®é¡¹ç®ææ¥æ°´è¡¨æ°ç¸å
³ |
| | | cacheUpDownDataMaxCountï¼ä¸ä¸è¡æ°æ®ç¼åéåä¸ç¼åæ°æ®ä¸ªæ°çæå¤§å¼ï¼è¿ä¸ªä¸ç°å®é¡¹ç®ææ¥æ°´è¡¨æ°ç¸å
³ |
| | | --> |
| | | <base |
| | | isLowPower="false" |
| | |
| | | offLineCachTimeout="86400" |
| | | lastUpDataTimeLive="1" |
| | | dbDataIdSuffix="1" |
| | | cacheUpDownDataWarnCount="100000" |
| | | cacheUpDownDataMaxCount="110000" |
| | | /> |
| | | |
| | | <!-- |
| | |
| | | <!-- |
| | | æ¯ææ¨¡å |
| | | ç工使¶é¿çº¿ç¨æ± ï¼çº¿ç¨è´è´£ç¨æ¶è¾ççå·¥ä½ä»»å¡ |
| | | short_maxThreadï¼ æ± ä¸æå¤§çº¿ç¨æ°ä¸ºææCPUæ ¸æ°+1 |
| | | short_minThreadï¼ æ± ä¸æå°çº¿ç¨æ° |
| | | short_maxThreadï¼ æ± ä¸æå¤§çº¿ç¨æ°ä¸ºææCPUæ ¸æ°+1ï¼shortæ± ä¸longæ± ååä¸åï¼ï¼è¥ä¸º-1ï¼ä¸åéå¶ ï¼è®¾ç½®ä¸º0ï¼è¡¨ç¤ºä¸å¯å¨çº¿ç¨æ± |
| | | short_minThreadï¼ æ± ä¸æå°çº¿ç¨æ°ï¼è¥ä¸º-1ï¼ä¸åéå¶ï¼è®¾ç½®ä¸º0ï¼è¡¨ç¤ºä¸å¯å¨çº¿ç¨æ± |
| | | short_freeTimeoutï¼ çº¿ç¨æ°ç©ºé²æ¶é¿ï¼è¥æ± ä¸çº¿ç¨æ°é大äºminThreadï¼ä¸æç线ç¨ç©ºé²æ¶é¿è¶
è¿freeTimeoutï¼åæ¸
é¤è¯¥çº¿ç¨ï¼ä¸ºäºä¸æ¸
é¤ï¼æminThreadä¸maxThread设置ç¸ç |
| | | short_busyTimeoutï¼çº¿ç¨ä¸é´æå·¥ä½æ¶é¿ï¼åä½ä¸ºç§)è¶
æ¶éï¼è®¤ä¸ºçº¿ç¨å·²ç»äºå´©æºï¼å°å¼ºå¶æ¸
é¤ï¼ç工使¶é¿è®¾ç½®ä¸º5ç§ |
| | | é¿å·¥ä½æ¶é¿çº¿ç¨æ± ï¼çº¿ç¨è´è´£ç¨æ¶è¾é¿çå·¥ä½ä»»å¡ï¼ä¾å¦ä»Redisä¸åç¼åçRTUä¸è¡æ°æ® |
| | | long_maxThreadï¼ æ± ä¸æå¤§çº¿ç¨æ°,è¥ä¸º-1ï¼ä¸åéå¶ |
| | | long_minThreadï¼ æ± ä¸æå°çº¿ç¨æ° |
| | | é¿å·¥ä½æ¶é¿çº¿ç¨æ± ï¼çº¿ç¨è´è´£ç¨æ¶è¾é¿çå·¥ä½ä»»å¡ï¼ä¾å¦æ°æ®åºååæä½ |
| | | long_maxThreadï¼ æ± ä¸æå¤§çº¿ç¨æ°ä¸ºææCPUæ ¸æ°+1ï¼shortæ± ä¸longæ± ååä¸åï¼ï¼è¥ä¸º-1ï¼ä¸åéå¶ï¼è®¾ç½®ä¸º0ï¼è¡¨ç¤ºä¸å¯å¨çº¿ç¨æ± |
| | | long_minThreadï¼ æ± ä¸æå°çº¿ç¨æ°ï¼è¥ä¸º-1ï¼ä¸åéå¶ï¼è®¾ç½®ä¸º0ï¼è¡¨ç¤ºä¸å¯å¨çº¿ç¨æ± |
| | | long_freeTimeoutï¼ çº¿ç¨æ°ç©ºé²æ¶é¿ï¼è¥æ± ä¸çº¿ç¨æ°é大äºminThreadï¼ä¸æç线ç¨ç©ºé²æ¶é¿è¶
è¿freeTimeoutï¼åæ¸
é¤è¯¥çº¿ç¨ |
| | | long_busyTimeoutï¼çº¿ç¨ä¸é´æå·¥ä½æ¶é¿ï¼åä½ä¸ºç§)è¶
æ¶éï¼è¥ä¸º-1ï¼ä¸åéå¶ |
| | | enableThreadPoolï¼æ¯å¦å¯ç¨çº¿ç¨æ± |
| | | --> |
| | | <!-- å½åå®ç°ï¼årtuæ¥å¿ãRMIæ°æ®å¤çç¨å°äºççº¿ç¨æ± --> |
| | | <!-- å½åå®ç°ï¼rtuä¸è¡æ°æ®å¤çï¼è¯»åæ°æ®ï¼ç¨å°äºç¬¬çº¿ç¨æ± --> |
| | | <support |
| | | short_maxThread="100" |
| | | short_minThread="5" |
| | | short_maxThread="6" |
| | | short_minThread="6" |
| | | short_freeTimeout="60" |
| | | short_busyTimeout="5" |
| | | long_maxThread="200" |
| | | long_minThread="0" |
| | | long_maxThread="6" |
| | | long_minThread="6" |
| | | long_freeTimeout="60" |
| | | long_busyTimeout="-1" |
| | | enableThreadPool="true" |
| | | /> |
| | | |
| | | <!-- |
| | |
| | | <!-- |
| | | sleepBigBusyï¼ä¸»çº¿ç¨å¤§å¿æ¶æ¯æ¬¡æ§è¡é´éæ¶é¿ï¼æ¯«ç§ï¼ |
| | | sleepSmallBusyï¼ä¸»çº¿ç¨å°å¿æ¶æ¯æ¬¡æ§è¡é´éæ¶é¿ï¼æ¯«ç§ï¼ |
| | | queueWarnSize: ç¼åéåèç¹æ°è¦åæ°é |
| | | queueMaxSize: ç¼åéåèç¹æ°æå¤§æ°é |
| | | --> |
| | | <core |
| | | sleepBigBusy="100" |
| | | sleepSmallBusy="500" |
| | | queueWarnSize="100000" |
| | | queueMaxSize="300000" |
| | | /> |
| | | |
| | | <!-- |