liurunyu
2023-12-07 60bd6a383b3f7c0d4922517974da9525a0166b68
文件误删除后,本地重新找回后提交
25个文件已修改
27个文件已添加
2288 ■■■■ 已修改文件
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/tcp/TcpIoSessionAttrIdIsRtuAddr.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/AnnotationScan.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/Command.java 47 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/Data.java 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/Driver.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/DriverParserDataCallback.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/MidResultError.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/MidResultFromRtu.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/MidResultToRtu.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/OnLine.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/OnLineHandle.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/PrefixedDataAvailableHandleImp.java 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/ProtocolCache.java 91 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/ProtocolUnit.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/CodeV1_0_1.java 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/DataAlarmVo.java 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/DataCd02Vo.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/DataCd71Vo.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/DataCd83CloseVo.java 61 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/DataCd83OpenVo.java 46 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/DataCd84Vo.java 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/DataStateVo.java 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/DriverV1_0_1.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/OnLineV1_0_1.java 39 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/ParseParamsForDownV1_0_1.java 40 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/ParseParamsForUpV1_0_1.java 39 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/parse/Cd_02_Up.java 89 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/parse/Cd_71_Up.java 65 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/parse/Cd_83_Up.java 253 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/parse/Cd_84_Up.java 149 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/parse/Cd_C0_Up.java 224 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/support/SupportUnit.java 42 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/support/SupportUnitConfigVo.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ByteUtil.java 446 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/Server.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/ServerProperties.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/MidResultActionToRtu.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/TcpDownCommandCache.java 129 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/TcpDownCommandObj.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/rtuData/TreeParse.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/tasks/RtuDownTask.java 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/tasks/RtuUpTask.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/tasks/ToRtuConstantTask.java 48 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/AdapterImp_RmiUnit.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/forRmi/ResRegisterVo.java 46 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/forRmi/ResStartVo.java 63 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/forRmi/RmiRequestedCallback.java 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/文档/Git操作.txt 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/文档/Maven 打包插件 maven-jar-plugin.docx 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/文档/Maven打包.docx 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/文档/Maven的maven-compiler-plugin插件.docx 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/文档/编码设计.docx 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/channel/tcp/TcpIoSessionAttrIdIsRtuAddr.java
@@ -7,5 +7,5 @@
 */
public class TcpIoSessionAttrIdIsRtuAddr {
    public static final String sessionArrIdKey = "key_rtuAddr" ; //这个key存储的是IMEI号
    public static final String sessionArrIdKey = "key_rtuAddr" ; //这个key存储的是Rtu地址
}
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/AnnotationScan.java
@@ -65,9 +65,9 @@
                    int onLineDataMinLength;
                    int headMinLength ;
                    HashMap<String, AnnotationDriverVo> driverMap = ProtocolCach.getDriverMap() ;
                    HashMap<String, AnnotationPrefixedDataAvailableVo> prefixedDataAvailableMap = ProtocolCach.getPrefixedDataAvailableMap() ;
                    HashMap<String, AnnotationOnLineVo> onLineMap = ProtocolCach.getOnLineMap() ;
                    HashMap<String, AnnotationDriverVo> driverMap = ProtocolCache.getDriverMap() ;
                    HashMap<String, AnnotationPrefixedDataAvailableVo> prefixedDataAvailableMap = ProtocolCache.getPrefixedDataAvailableMap() ;
                    HashMap<String, AnnotationOnLineVo> onLineMap = ProtocolCache.getOnLineMap() ;
                    for(String cName : classNames){
                        String className = cName.substring(0,  cName.lastIndexOf('.')) ;
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/Command.java
@@ -32,25 +32,7 @@
     * RTU åœ°å€
     */
    public String rtuAddr ;
    /**
     * æ°´è¡¨å·
     * åº”用电信平台时有效
     */
    public String meterNo ;
    /**
     * ç”µä¿¡å¹³å°ä¸Šçš„产品ID,当不在电信平台上运行时,为null
     * åº”用电信平台时有效
     */
    public Integer productId ;
    /**
     * ç”µä¿¡å¹³å°ä¸Šçš„设备ID,当不在电信平台上运行时,为null
     * åº”用电信平台时有效
     */
    public String deviceId ;
    /**
     * å‘½ä»¤ç±»åž‹:Rtu命令、针对监控中间件的命令
     * ç”±com.dy.common.mw.protocol.CommandType类定义
@@ -80,14 +62,7 @@
    public String toString(){
        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 += (rtuAddr == null ? "" : ("Rtu地址=" + rtuAddr + "\n"));
        s += "命令类型=" + (type.equals(CommandType.innerCommand)?"内部命令":"终端命令") + "\n" ;
        s += (code == null ? "" : ("功能码=" + code + "\n")) ;
        s += "返回中间件对命令处理结果=" + (noRtMwDealRes == null?"返回":(noRtMwDealRes?"不返回":"返回") + "\n") ;
@@ -198,24 +173,6 @@
    }
    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;
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/Data.java
@@ -6,7 +6,6 @@
/**
 * æ•°æ®æ ¹
 * @author Administrator
 *
 */
public class Data  implements java.io.Serializable{
@@ -15,7 +14,6 @@
    private String commandId ;//命令ID,可能为null
    private String rtuAddr ;//终端地址
    private String meterNo ;//水表号
    private String protocol ;//数据所对应的协议名称
    private String code ;//数据所对应的功能码:
    private Object subData ;//对应各个功能码的具体数据
@@ -24,8 +22,7 @@
    public String toString() {
        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") ;
        sb.append("Rtu地址 : ").append((rtuAddr==null?"":rtuAddr)).append("\n") ;
        if(commandId != null){
            sb.append("命令ID : ").append(commandId).append("\n") ; //命令ID
        }
@@ -85,13 +82,7 @@
    public void setRtuAddr(String rtuAddr) {
        this.rtuAddr = rtuAddr;
    }
    public String getMeterNo() {
        return meterNo;
    }
    public void setMeterNo(String meterNo) {
        this.meterNo = meterNo;
    }
    public String getCode() {
        return code;
    }
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/Driver.java
@@ -142,7 +142,7 @@
        return codeParse ;
    }
    /**
     * è§£æžä¸Šè¡Œæ•°æ®
     * è§£æžRTU上行数据
     * @param isLowPower æ˜¯å¦åœ¨ä½ŽåŠŸè€—çŽ¯å¢ƒä¸‹è¿è¡Œ
     * @param rtuAddr æŽ§åˆ¶å™¨åœ°å€
     * @param upBuffer å­—节数组
@@ -151,18 +151,6 @@
     * @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) ;
    
    /**
     * æž„造下行数据(命令)
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/DriverParserDataCallback.java
@@ -4,23 +4,19 @@
    /**
     * è§£æžä¸Šè¡Œæ•°æ®åŽå›žè°ƒ
     * @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
     * @param rtuAddrInData ä¸Šè¡Œæ•°æ®ä¸­åœ¨åè®®æ•°æ®ä¸­çš„Rtu地址,
     *     â€œä¿®æ”¹RTU终端管理配置参数”命令的返回数据,其协议头中的Rtu地址与数据中的Rtu地址不一样,
     *  å¦‚æžœRTU不能关闭网络,那么sessionCach中的Rtu地址总是用修改前的Rtu地址,使得以后上行数据的不能找到缓存中的Session
     */
    void callback(String rtuAddr,
            String meterNo,
            String code,
            String code,
            String upHex, 
            Boolean reportOrResponse_trueOrFalse, 
            boolean parseFail,
            String rtuAddrInData,
            String meterNoInData) ;
            String rtuAddrInData) ;
}
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/MidResultError.java
@@ -11,15 +11,13 @@
    }
    public String protocolName ;//协议名称
    public String rtuAddr ;//IMEI号,注意rtuAddr可能为null
    public String meterNo ;//水表号,注意meterNo可能为null
    public String rtuAddr ;//Rtu地址,注意rtuAddr可能为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 ;
    }
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/MidResultFromRtu.java
@@ -13,10 +13,7 @@
    public String commandId ;//发送命令的ID,如果是命令结果,并且匹配了下发命令,此值不为空
    
    public String protocolName ;//协议名称
    public String rtuAddr ;//IMEI号
    public String meterNo ;//水表号
    public Integer productId ;//电信平台产品ID,当不在电信平台运行时,为null
    public String deviceId ;//电信平台设备ID,当不在电信平台运行时,为null
    public String rtuAddr ;//Rtu地址
    public String upCode ;//上行数据中的功能码
    public String upHex ;//上行数据十六进制形式
    public byte[] upBuffer ;//上行数据字节数组
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/MidResultToRtu.java
@@ -11,10 +11,7 @@
    }
    public String protocolName ;//协议名称
    public String rtuAddr ;//IMEI号(电信平台IMEI)
    public String meterNo ;//水表号
    public Integer productId ;//电信平台产品ID
    public String deviceId ;//电信平台设备ID
    public String rtuAddr ;//Rtu地址
    public String commandId ;//命令ID,发起命令的客户端(web端)生成,以匹配命令结果
    public String downCode ;//下行命令功能码;
    public byte[] downBuffer ;//下行命令数据
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/OnLine.java
@@ -16,19 +16,17 @@
    class OnLineResult{
        public int result ;//分析结果
        public String protocolName ;//协议名称
        public String rtuAddr ;//IMEI号
        public String meterNo ;//水表号
        public String rtuAddr ;//Rtu地址
        public byte[] remoteData;//需要向Rtu回写的数据
        public OnLineResult(){
            result = OnLineAction_fail ;
            rtuAddr = null ;
            meterNo = null ;
            remoteData = null ;
        }
    }
    
    int OnLineAction_fail = 0; //分析上线数据失败,如提供的数据为null等原因
    int OnLineAction_success = 1; //分析上线数据成功,并能得到IMEI号
    int OnLineAction_success = 1; //分析上线数据成功,并能得到Rtu地址
    int OnLineAction_success_noMe = 2; //分析上线数据成功,识别出不是本协议数据
    int OnLineAction_success_response = 3; //分析上线数据成功,并需要向Rtu回写数据
    
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/OnLineHandle.java
@@ -6,13 +6,13 @@
public class OnLineHandle {
    
    /**
     * è§£æžä¸Šçº¿æ•°æ®ï¼Œå¾—到IMEI号
     * è§£æžä¸Šçº¿æ•°æ®ï¼Œå¾—到RtuAddr
     * @param bs å­—节数组
     * @return OnLine.OnLineResult
     */
    public OnLine.OnLineResult parse(byte[] bs)throws Exception{
        OnLine.OnLineResult rs = null ;
        HashMap<String, AnnotationOnLineVo> onLineMap = ProtocolCach.getOnLineMap() ;
        HashMap<String, AnnotationOnLineVo> onLineMap = ProtocolCache.getOnLineMap() ;
        Collection<AnnotationOnLineVo> set = onLineMap.values() ;
        if(set.size() == 0){
            throw new Exception("处理上线时,得到的协议集合为空。") ;
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/PrefixedDataAvailableHandleImp.java
@@ -30,18 +30,18 @@
            try{
                PrefixedDataAvailableStatus pds = null ;
                
                HashMap<String, AnnotationPrefixedDataAvailableVo> prefixedDataAvailableMap = ProtocolCach.getPrefixedDataAvailableMap() ;
                HashMap<String, AnnotationPrefixedDataAvailableVo> prefixedDataAvailableMap = ProtocolCache.getPrefixedDataAvailableMap() ;
                Collection<AnnotationPrefixedDataAvailableVo> set = prefixedDataAvailableMap.values() ;
                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 ;
@@ -53,7 +53,7 @@
                    if(pds == null){
                        //说明不是对应的协议数据,需要另外的协议来处理上线
                        //循环继续
                        prority++ ;
                        priority++ ;
                    }else{
                        //停止循环,返回结果
                        break ;
@@ -90,7 +90,7 @@
            try{
               PrefixedDataAvailableStatus pds = null ;
                
                HashMap<String, AnnotationPrefixedDataAvailableVo> prefixedDataAvailableMap = ProtocolCach.getPrefixedDataAvailableMap() ;
                HashMap<String, AnnotationPrefixedDataAvailableVo> prefixedDataAvailableMap = ProtocolCache.getPrefixedDataAvailableMap() ;
                Collection<AnnotationPrefixedDataAvailableVo> set = prefixedDataAvailableMap.values() ;
                if(set.size() == 0){
                    throw new Exception("上线数据完整性检查时,得到的协议集合为空。") ;
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/ProtocolCache.java
New file
@@ -0,0 +1,91 @@
package com.dy.common.mw.protocol;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class ProtocolCache {
    //本系统中,Driver在单线程中运行,所以只用一个实例
    private static final HashMap<String, Driver> drivers = new HashMap<>() ;
    //注解与处理类的映射
    private static final HashMap<String, AnnotationDriverVo> driverMap = new HashMap<>() ;
    private static final HashMap<String, AnnotationPrefixedDataAvailableVo> prefixedDataAvailableMap = new HashMap<>() ;
    private static final HashMap<String, AnnotationOnLineVo> onLineMap = new HashMap<>() ;
    /**
     * åœ¨å•线程环境中运行
     * é€šè¿‡åè®®é©±åŠ¨çš„ç±»åï¼Œå¾—åˆ°ç±»å•ä¾‹
     * @param protocolName åè®®åç§°
     * @return é©±åЍ
     * @throws Exception å¼‚常
     */
    public static Driver getDriver(String protocolName) throws Exception{
        Driver dri = drivers.get(protocolName);
        if(dri == null){
            AnnotationDriverVo vo = driverMap.get(protocolName) ;
            if(vo != null && vo.clazz != null){
                dri = (Driver)vo.clazz.getDeclaredConstructor().newInstance();
                //dri = (Driver)vo.clazz.newInstance() ;
                drivers.put(protocolName, dri) ;
            }
        }
        return dri ;
    }
    /**
     * å¾—到驱动的数量,即中间件支持的协议数量
     * @return é©±åŠ¨æ€»æ•°
     */
    public static int driverCount(){
        if(drivers.size() == 0){
            return 0 ;
        }else{
            return drivers.size() ;
        }
    }
    /**
     * å¾—到第一个驱动
     * @return é©±åЍ
     */
    public static Driver getFirstDriver(){
        Driver dri = null ;
        if(drivers.size() > 0){
            Map.Entry<String, Driver> ent = drivers.entrySet().iterator().next() ;
            dri = ent.getValue();
        }
        return dri ;
    }
    /**
     * å¾—到所有协议名称
     * @return åè®®åç§°é›†åˆ
     */
    @SuppressWarnings("unused")
    public static List<String> getProtocolList() {
        return new ArrayList<>(driverMap.keySet()) ;
    }
    protected static HashMap<String, AnnotationDriverVo> getDriverMap() {
        return driverMap;
    }
    protected static HashMap<String, AnnotationPrefixedDataAvailableVo> getPrefixedDataAvailableMap() {
        return prefixedDataAvailableMap;
    }
    protected static HashMap<String, AnnotationOnLineVo> getOnLineMap() {
        return onLineMap;
    }
    /*
    public static void main(String[] args){
        HashMap<String, Integer> mp = new HashMap<>() ;
        mp.put("a1", 1) ;
        mp.put("a2", 2) ;
        List<String> list = new ArrayList<>(mp.keySet()) ;
        System.out.println(list);
    }
    */
}
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/ProtocolUnit.java
@@ -44,7 +44,7 @@
        AnnotationScan.getIntance() ;
        
        //各个协议驱动类扫描自己的功能码注解
        HashMap<String, AnnotationDriverVo> drivers =  ProtocolCach.getDriverMap() ;
        HashMap<String, AnnotationDriverVo> drivers =  ProtocolCache.getDriverMap() ;
        Collection<String> colDrivers = drivers.keySet() ;
        StringBuilder totalProtocols = new StringBuilder() ;
        for(String protocolName : colDrivers){
@@ -52,7 +52,7 @@
                totalProtocols.append(",") ;
            }
            totalProtocols.append(protocolName) ;
            Driver dri = ProtocolCach.getDriver(protocolName) ;
            Driver dri = ProtocolCache.getDriver(protocolName) ;
            if(dri != null){
                dri.scanAnnotationCode();
            }
@@ -70,7 +70,7 @@
     */
    @SuppressWarnings("unused")
    public boolean isOnlyOneProtocol(){
        HashMap<String, AnnotationDriverVo> drivers =  ProtocolCach.getDriverMap() ;
        HashMap<String, AnnotationDriverVo> drivers =  ProtocolCache.getDriverMap() ;
        return drivers.size() == 1 ;
    }
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/CodeV1_0_1.java
New file
@@ -0,0 +1,33 @@
package com.dy.common.mw.protocol.p206V1_0_0;
public class CodeV1_0_1 {
    //功能码为字符串,十六进制数据
    public static final String cd_02 = "02" ;//遥测站链路检测
    public static final String cd_C0 = "C0" ;//遥测站自报实时数据
    public static final String cd_83 = "83" ;//遥测站开关阀自报
    public static final String cd_84 = "84" ;//开阀工作报
    public static final String cd_71 = "71" ;//查询阀门状态
    public static String getCodeName(String code) {
        String name = (code.equals(cd_02) ? "链路检测" :
            (code.equals(cd_C0) ? "自报实时数据" :
            (code.equals(cd_83) ? "开关阀自报" :
            (code.equals(cd_84) ? "开阀工作报" :
            (code.equals(cd_71) ? "查询阀门状态" :
            ""))))) ;
        return name ;
    }
    /**
     * æ˜¯å¦ä¸ºæœ‰æ•ˆåŠŸèƒ½ç 
     * @param code åŠŸèƒ½ç 
     * @return æœ‰æ•ˆtrue,无效false
     */
    public static boolean isValid(String code){
        String name = getCodeName(code) ;
        if(name != null && !name.equals("")){
            return true ;
        }
        return false ;
    }
}
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/DataAlarmVo.java
New file
@@ -0,0 +1,28 @@
package com.dy.common.mw.protocol.p206V1_0_0;
import lombok.Data;
@Data
public class DataAlarmVo {
    public Byte batteryVolt ;// è“„电池电压
    public Byte loss ;//漏损
    public Byte meter ;//仪表
    public Byte valve ;//阀门
    public String toString(){
        StringBuilder str = new StringBuilder() ;
        str.append("      æŠ¥è­¦:\n");
        str.append("         è“„电池电压:");
        str.append(batteryVolt==null?"":(batteryVolt==1?"报警":"正常"));
        str.append("\n");
        str.append("         æ¼æŸï¼š");
        str.append(loss==null?"":(loss==1?"报警":"正常"));
        str.append("\n");
        str.append("         ä»ªè¡¨ï¼š");
        str.append(meter==null?"":(meter==1?"报警":"正常"));
        str.append("\n");
        str.append("         é˜€é—¨ï¼š");
        str.append(valve==null?"":(valve==1?"报警":"正常"));
        return str.toString() ;
    }
}
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/DataCd02Vo.java
New file
@@ -0,0 +1,20 @@
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() ;
    }
}
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/DataCd71Vo.java
New file
@@ -0,0 +1,21 @@
package com.dy.common.mw.protocol.p206V1_0_0;
import lombok.Data;
@Data
public class DataCd71Vo {
    public Byte state ;//阀门状态码(0:阀门关闭状态;1:阀门打开状态)
    public String stateName ;
    public String toString(){
        StringBuilder sb = new StringBuilder() ;
        sb.append("   æŸ¥è¯¢è®¾å¤‡é˜€é—¨çŠ¶æ€åº”ç­”:\n");
        sb.append("      é˜€é—¨çŠ¶æ€ï¼š");
        sb.append(state==null?"":state);
        sb.append(stateName==null?"":("(" + stateName + ")"));
        sb.append("\n");
        return sb.toString() ;
    }
}
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/DataCd83CloseVo.java
New file
@@ -0,0 +1,61 @@
package com.dy.common.mw.protocol.p206V1_0_0;
import lombok.Data;
@Data
public class DataCd83CloseVo {
    // å¼€å…³é˜€ç±»åž‹ï¼š
    // 1、刷卡开阀;2刷卡关阀;3、中心站开阀;4、中心站关阀;5、欠费关阀;
    // 6、流量计故障关阀;7、紧急关阀;8、用户远程开阀;9、用户远程关阀;
    public Byte type ;
    public Double totalAmount; //累计流量:5字节BCD码,取值范围0~9999999999,单位为m3。
    public String clientNum ;//农户编号
    public String icAddr ;//ic卡地址
    public Double remainMoney ;//剩余金额:用户余额4字节BCD码,取值范围0.00~999999.99,单位为元
    public String openDt ;//用水户用水开始时间:6字节BCD码,顺序是年月日时分秒,其中公元年=2000+年。
    public String closeDt ;//用水户用水结束时间:6字节BCD码,顺序是年月日时分秒,其中公元年=2000+年。
    public Double thisAmount ;//用水户本次用水量:累计流量5字节BCD码,取值范围0~9999999999,单位为m3。
    public Double thisMoney ;//用水户本次消费金额:用户余额4字节BCD码,取值范围0.00~999999.99,单位为元。
    public Integer thisTime ;//用水户本次用水时长:用水时长2字节BCD码,取值范围0~9999,单位为分钟。
    public String rtuDt ;//控制器时钟
    public String toString(){
        StringBuilder sb = new StringBuilder() ;
        sb.append("   ç»ˆç«¯å…³é˜€è‡ªæŠ¥:\n");
        sb.append("      å…³é˜€ç±»åž‹ï¼š");
        sb.append(CommonV1_0_1.openCloseValveType(type)) ;
        sb.append("\n");
        sb.append("      ç´¯è®¡æµé‡ï¼š");
        sb.append(totalAmount==null?"":totalAmount);
        sb.append("\n");
        sb.append("      å†œæˆ·ç¼–号:");
        sb.append(clientNum);
        sb.append("\n");
        sb.append("      ic卡地址:");
        sb.append(icAddr);
        sb.append("\n");
        sb.append("      å‰©ä½™é‡‘额(元):");
        sb.append(remainMoney ==null?"": remainMoney);
        sb.append("\n");
        sb.append("      å¼€é˜€æ—¶é—´ï¼š");
        sb.append(openDt);
        sb.append("\n");
        sb.append("      å…³é˜€æ—¶é—´ï¼š");
        sb.append(closeDt);
        sb.append("\n");
        sb.append("      æœ¬æ¬¡ç”¨æ°´é‡ï¼š");
        sb.append(thisAmount==null?"":thisAmount);
        sb.append("\n");
        sb.append("      æœ¬æ¬¡èŠ±è´¹é‡‘é¢ï¼ˆå…ƒï¼‰ï¼š");
        sb.append(thisMoney==null?"":thisMoney);
        sb.append("\n");
        sb.append("      æœ¬æ¬¡ç”¨æ°´æ—¶é•¿ï¼ˆåˆ†é’Ÿï¼‰ï¼š");
        sb.append(thisTime==null?"":thisTime);
        sb.append("\n");
        sb.append("      æŽ§åˆ¶å™¨æ—¶é’Ÿï¼š");
        sb.append(rtuDt==null?"":rtuDt);
        sb.append("\n");
        return sb.toString() ;
    }
}
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/DataCd83OpenVo.java
New file
@@ -0,0 +1,46 @@
package com.dy.common.mw.protocol.p206V1_0_0;
import lombok.Data;
@Data
public class DataCd83OpenVo {
    // å¼€å…³é˜€ç±»åž‹ï¼š
    // 1、刷卡开阀;2刷卡关阀;3、中心站开阀;4、中心站关阀;5、欠费关阀;
    // 6、流量计故障关阀;7、紧急关阀;8、用户远程开阀;9、用户远程关阀;
    public Byte type ;
    public Double totalAmount; //累计流量:5字节BCD码,取值范围0~9999999999,单位为m3。
    public String clientNum ;//农户编号
    public String icAddr ;//ic卡地址
    public Double remainMoney;//剩余金额:用户余额4字节BCD码,取值范围0.00~999999.99,单位为元
    public String openDt ;//用水户开阀时间:6字节BCD码,顺序是年月日时分秒,其中公元年=2000+年。
    public String rtuDt ;//控制器时钟
    public String toString(){
        StringBuilder sb = new StringBuilder() ;
        sb.append("   ç»ˆç«¯å¼€é˜€è‡ªæŠ¥:\n");
        sb.append("      å¼€é˜€ç±»åž‹ï¼š");
        sb.append(CommonV1_0_1.openCloseValveType(type)) ;
        sb.append("\n");
        sb.append("      ç´¯è®¡æµé‡ï¼š");
        sb.append(totalAmount==null?"":totalAmount);
        sb.append("\n");
        sb.append("      å†œæˆ·ç¼–号:");
        sb.append(clientNum);
        sb.append("\n");
        sb.append("      ic卡地址:");
        sb.append(icAddr);
        sb.append("\n");
        sb.append("      å‰©ä½™é‡‘额(元):");
        sb.append(remainMoney ==null?"": remainMoney);
        sb.append("\n");
        sb.append("      å¼€é˜€æ—¶é—´ï¼š");
        sb.append(openDt);
        sb.append("\n");
        sb.append("      æŽ§åˆ¶å™¨æ—¶é’Ÿï¼š");
        sb.append(rtuDt==null?"":rtuDt);
        sb.append("\n");
        return sb.toString() ;
    }
}
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/DataCd84Vo.java
New file
@@ -0,0 +1,33 @@
package com.dy.common.mw.protocol.p206V1_0_0;
import lombok.Data;
@Data
public class DataCd84Vo {
    public String clientNum ;//农户编号
    public Double remainMoney ;//剩余金额:用户余额4字节BCD码,取值范围0.00~999999.99,单位为元
    public Double totalAmount; //累计流量:5字节BCD码,取值范围0~9999999999,单位为m3。
    public Double instantAmount; //瞬时流量:5字节BCD码,取值范围0~9999999.999,单位为m3/h。
    public String rtuDt ;//控制器时钟
    public String toString(){
        StringBuilder sb = new StringBuilder() ;
        sb.append("   ç»ˆç«¯å¼€é˜€å·¥ä½œæŠ¥:\n");
        sb.append("      å†œæˆ·ç¼–号:");
        sb.append(clientNum);
        sb.append("\n");
        sb.append("      å‰©ä½™é‡‘额(元):");
        sb.append(remainMoney==null?"":remainMoney);
        sb.append("\n");
        sb.append("      ç´¯è®¡æµé‡ï¼š");
        sb.append(totalAmount==null?"":totalAmount);
        sb.append("\n");
        sb.append("      çž¬æ—¶æµé‡ï¼š");
        sb.append(instantAmount==null?"":instantAmount);
        sb.append("\n");
        sb.append("      æŽ§åˆ¶å™¨æ—¶é’Ÿï¼š");
        sb.append(rtuDt==null?"":rtuDt);
        sb.append("\n");
        return sb.toString() ;
    }
}
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/DataStateVo.java
New file
@@ -0,0 +1,24 @@
package com.dy.common.mw.protocol.p206V1_0_0;
import lombok.Data;
@Data
public class DataStateVo  {
    public Byte idCard ;// è“„电池电压
    public Byte work;//工作状态
    public Byte valve ;//阀门
    public String toString(){
        StringBuilder str = new StringBuilder() ;
        str.append("      çŠ¶æ€:\n");
        str.append("         IC å¡åŠŸèƒ½ï¼š");
        str.append(idCard==null?"":(idCard==1?"有效":"无效"));
        str.append("\n");
        str.append("         å·¥ä½œçŠ¶æ€ï¼š");
        str.append(work ==null?"":(work==1?"启动":"停止"));
        str.append("\n");
        str.append("         é˜€é—¨ï¼š");
        str.append(valve==null?"":(valve==1?"打开":"关闭"));
        return str.toString() ;
    }
}
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/DriverV1_0_1.java
@@ -106,6 +106,7 @@
            callback.callback(rtuAddr, upCode, upHex, reportOrResponse_trueOrFalse, isFail, rtuAddrInData);
        }
    }
    /**
     * æž„造下行数据(命令)
     * @param isLowPower æ˜¯å¦åœ¨ä½ŽåŠŸè€—çŽ¯å¢ƒä¸‹è¿è¡Œ
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/OnLineV1_0_1.java
New file
@@ -0,0 +1,39 @@
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 = ProtocolConstantV206V1_0_0.protocolName,
        priority = ProtocolConstantV206V1_0_0.priority)
@SuppressWarnings("unused")
public class OnLineV1_0_1 implements OnLine{
    /**
     * å¯¹ä¸Šçº¿æ•°æ®è¿›è¡Œåˆ†æž
     * @param upBuf ä¸Šè¡Œæ•°æ®
     * @return
     */
    @Override
    public OnLineResult parse(byte[] upBuf)throws Exception {
        OnLineResult olr = new OnLineResult() ;
        CommonV1_0_1 cp = new CommonV1_0_1() ;
        Boolean flag = cp.isThisProtocolHead(upBuf) ;
        if(flag == null){
            //出错
            olr.result = OnLine.OnLineAction_fail ;
            olr.rtuAddr = null ;
        }else if(!flag.booleanValue()){
            //不是本协议数据
            olr.result = OnLine.OnLineAction_success_noMe ;
            olr.rtuAddr = null ;
        }else{
            //是本协议数据
            olr.result = OnLine.OnLineAction_success ;
            olr.rtuAddr = cp.parseRtuAddr(upBuf) ;
            olr.protocolName = ProtocolConstantV206V1_0_0.protocolName ;
        }
        return olr;
    }
}
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/ParseParamsForDownV1_0_1.java
New file
@@ -0,0 +1,40 @@
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 ;
    }
}
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/ParseParamsForUpV1_0_1.java
New file
@@ -0,0 +1,39 @@
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 ;
    }
}
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/parse/Cd_02_Up.java
New file
@@ -0,0 +1,89 @@
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 final 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 ;//Rtu地址
        midRs.upCode = para.upCode ;//上行数据中的功能码
        midRs.upHex = para.upHex ;//上行数据十六进制形式
        midRs.upBuffer = para.upBuffer ;//上行数据字节数组
        midRs.data = para.data ;//解析后的数据
        midRs.reportOrResponse_trueOrFalse = true ;//主动上报
        String confirmComCode = para.upCode ;
        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 ;//Rtu地址
        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.isCachForOffLine = false ;//RTU不在线,命令是否缓存
        confirmCommand.isSendFirst = true ;//确认命令,优先发送
        if(isLowPower != null && isLowPower.booleanValue()){
            //低功耗时,尽快发送
            confirmCommand.isQuickSend = true ;
        }
        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) ;
    }
}
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/parse/Cd_71_Up.java
New file
@@ -0,0 +1,65 @@
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 org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@AnnotationCodeUp(ifAny={
        CodeV1_0_1.cd_71
})
@SuppressWarnings("unused")
public class Cd_71_Up implements CodeParse {
    private static final Logger log = LogManager.getLogger(Cd_71_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 ;//Rtu地址
        midRs.upCode = para.upCode ;//上行数据中的功能码
        midRs.upHex = para.upHex ;//上行数据十六进制形式
        midRs.upBuffer = para.upBuffer ;//上行数据字节数组
        midRs.data = para.data ;//解析后的数据
        midRs.reportOrResponse_trueOrFalse = false ;//主动上报
        callback.callback(midRs.reportOrResponse_trueOrFalse);
        return new MidResult[]{midRs} ;
    }
    /**
     * æ‰§è¡Œåˆ†æž
     * @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() ;
        DataCd71Vo cdData = new DataCd71Vo() ;
        dV1.dataCd71Vo = cdData ;
        cdData.state = bs[ProtocolConstantV206V1_0_0.dataIndex] ;
        if(cdData.state == 0){
            cdData.stateName = "阀门关闭" ;
        }else if(cdData.state == 1){
            cdData.stateName = "阀门打开" ;
        }else{
            cdData.stateName = "未知" ;
        }
    }
}
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/parse/Cd_83_Up.java
New file
@@ -0,0 +1,253 @@
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.mw.protocol.p206V1_0_0.parse.global.GlParse;
import com.dy.common.util.ByteUtil;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@AnnotationCodeUp(ifAny={
        CodeV1_0_1.cd_83
})
@SuppressWarnings("unused")
public class Cd_83_Up implements CodeParse {
    private static final Logger log = LogManager.getLogger(Cd_83_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 ;//Rtu地址
        midRs.upCode = para.upCode ;//上行数据中的功能码
        midRs.upHex = para.upHex ;//上行数据十六进制形式
        midRs.upBuffer = para.upBuffer ;//上行数据字节数组
        midRs.data = para.data ;//解析后的数据
        midRs.reportOrResponse_trueOrFalse = true ;//主动上报
        String confirmComCode = para.upCode ;
        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_83_Down().doParse(downCpParams) ;
        MidResultToRtu confirmCommand = new MidResultToRtu() ;
        confirmCommand.protocolName = para.protocolName ;//协议名称
        confirmCommand.rtuAddr = para.rtuAddr ;//Rtu地址
        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.isCachForOffLine = false ;//RTU不在线,命令是否缓存
        confirmCommand.isSendFirst = true ;//确认命令,优先发送
        if(isLowPower != null && isLowPower.booleanValue()){
            //低功耗时,尽快发送
            confirmCommand.isQuickSend = true ;
        }
        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 {
        short index = ProtocolConstantV206V1_0_0.dataIndex ;
        byte opType = bs[ProtocolConstantV206V1_0_0.dataIndex];
        if(opType == 1 || opType == 3 || opType == 8){
            this.doParseOpen(opType, bs, bsLen, dataCode, data);
        }else{
            this.doParseClose(opType, bs, bsLen, dataCode, data);
        }
    }
    private void doParseOpen(byte opType, byte[] bs, int bsLen, String dataCode, Data data) throws Exception {
        DataV1_0_1 dV1 = (DataV1_0_1)data.getSubData() ;
        DataCd83OpenVo cdData = new DataCd83OpenVo() ;
        dV1.dataCd83OpenVo = cdData ;
        cdData.type = opType ;
        short index = ProtocolConstantV206V1_0_0.dataIndex + 1 ;
        //累计流量:5字节BCD码,取值范围0~9999999999,单位为m3。
        cdData.totalAmount = 0.0D ;
        int tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
        index++ ;
        cdData.totalAmount += tpInt;
        tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
        index++ ;
        cdData.totalAmount += tpInt * 100.0 ;
        tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
        index++ ;
        cdData.totalAmount += tpInt * 10000.0 ;
        tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
        index++ ;
        cdData.totalAmount += tpInt * 1000000.0 ;
        tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
        index++ ;
        cdData.totalAmount += tpInt * 100000000.0 ;
        //用水户号数据格式:5字节BCD码低位在前高位在后。
        cdData.clientNum = ByteUtil.BCD2String_LE(bs, index, index + 4) ;
        index += 5 ;
        //IC卡号格式:4字节HEX码低位在前高位在后。
        cdData.clientNum = ByteUtil.bytesToHex(bs, index, index + 3) ;
        index += 4 ;
        //用水户余额:用户余额4字节BCD码,取值范围0.00~999999.99,单位为元。
        cdData.remainMoney = 0.0D ;
        tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
        index++ ;
        cdData.remainMoney += tpInt/100.0 ;
        tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
        index++ ;
        cdData.remainMoney += tpInt;
        tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
        index++ ;
        cdData.remainMoney += tpInt * 100.0 ;
        tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
        index++ ;
        cdData.remainMoney += tpInt * 10000.0 ;
        //用水户用水开始时间:6字节BCD码,顺序是年月日时分秒,其中公元年=2000+年。
        cdData.openDt = GlParse.parseTp(bs, index) ;
        index += 6 ;
        //控制器时钟
        cdData.rtuDt = GlParse.parseTp(bs, index) ;
        //index += 6 ;
    }
    private void doParseClose(byte opType, byte[] bs, int bsLen, String dataCode, Data data) throws Exception {
        DataV1_0_1 dV1 = (DataV1_0_1)data.getSubData() ;
        DataCd83CloseVo cdData = new DataCd83CloseVo() ;
        dV1.dataCd83CloseVo = cdData ;
        cdData.type = opType ;
        short index = ProtocolConstantV206V1_0_0.dataIndex + 1 ;
        //累计流量:5字节BCD码,取值范围0~9999999999,单位为m3。
        cdData.totalAmount = 0.0D ;
        int tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
        index++ ;
        cdData.totalAmount += tpInt;
        tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
        index++ ;
        cdData.totalAmount += tpInt * 100.0 ;
        tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
        index++ ;
        cdData.totalAmount += tpInt * 10000.0 ;
        tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
        index++ ;
        cdData.totalAmount += tpInt * 1000000.0 ;
        tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
        index++ ;
        cdData.totalAmount += tpInt * 100000000.0 ;
        //用水户号数据格式:5字节BCD码低位在前高位在后。
        cdData.clientNum = ByteUtil.BCD2String_LE(bs, index, index + 4) ;
        index += 5 ;
        //IC卡号格式:4字节HEX码低位在前高位在后。
        cdData.clientNum = ByteUtil.bytesToHex(bs, index, index + 3) ;
        index += 4 ;
        //用水户余额:用户余额4字节BCD码,取值范围0.00~999999.99,单位为元。
        cdData.remainMoney = 0.0D ;
        tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
        index++ ;
        cdData.remainMoney += tpInt/100.0 ;
        tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
        index++ ;
        cdData.remainMoney += tpInt;
        tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
        index++ ;
        cdData.remainMoney += tpInt * 100.0 ;
        tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
        index++ ;
        cdData.remainMoney += tpInt * 10000.0 ;
        //用水户用水开始时间:6字节BCD码,顺序是年月日时分秒,其中公元年=2000+年。
        cdData.openDt = GlParse.parseTp(bs, index) ;
        index += 6 ;
        //用水户用水结束时间:6字节BCD码,顺序是年月日时分秒,其中公元年=2000+年。
        cdData.closeDt = GlParse.parseTp(bs, index) ;
        index += 6 ;
        //用水户本次用水量:累计流量5字节BCD码,取值范围0~9999999999,单位为m3。
        cdData.thisAmount = 0.0D ;
        tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
        index++ ;
        cdData.thisAmount += tpInt/100.0 ;
        tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
        index++ ;
        cdData.thisAmount += tpInt ;
        tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
        index++ ;
        cdData.thisAmount += tpInt * 100.0 ;
        tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
        index++ ;
        cdData.thisAmount += tpInt * 10000.0 ;
        tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
        index++ ;
        cdData.thisAmount += tpInt * 1000000.0 ;
        //用水户本次消费金额:用户余额4字节BCD码,取值范围0.00~999999.99,单位为元。
        cdData.thisMoney = 0.0D ;
        tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
        index++ ;
        cdData.thisMoney += tpInt/100.0 ;
        tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
        index++ ;
        cdData.thisMoney += tpInt;
        tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
        index++ ;
        cdData.thisMoney += tpInt * 100.0 ;
        tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
        index++ ;
        cdData.thisMoney += tpInt * 10000.0 ;
        //用水户本次用水时长:用水时长2字节BCD码,取值范围0~9999,单位为分钟。
        cdData.thisTime = 0 ;
        tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
        index++ ;
        cdData.thisTime += tpInt;
        tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
        index++ ;
        cdData.thisTime += tpInt * 100 ;
        //控制器时钟
        cdData.rtuDt = GlParse.parseTp(bs, index) ;
        //index += 6 ;
    }
}
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/parse/Cd_84_Up.java
New file
@@ -0,0 +1,149 @@
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.mw.protocol.p206V1_0_0.parse.global.GlParse;
import com.dy.common.util.ByteUtil;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@AnnotationCodeUp(ifAny={
        CodeV1_0_1.cd_84
})
@SuppressWarnings("unused")
public class Cd_84_Up implements CodeParse {
    private static final Logger log = LogManager.getLogger(Cd_84_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 ;//Rtu地址
        midRs.upCode = para.upCode ;//上行数据中的功能码
        midRs.upHex = para.upHex ;//上行数据十六进制形式
        midRs.upBuffer = para.upBuffer ;//上行数据字节数组
        midRs.data = para.data ;//解析后的数据
        midRs.reportOrResponse_trueOrFalse = true ;//主动上报
        String confirmComCode = para.upCode ;
        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_84_Down().doParse(downCpParams) ;
        MidResultToRtu confirmCommand = new MidResultToRtu() ;
        confirmCommand.protocolName = para.protocolName ;//协议名称
        confirmCommand.rtuAddr = para.rtuAddr ;//Rtu地址
        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.isCachForOffLine = false ;//RTU不在线,命令是否缓存
        confirmCommand.isSendFirst = true ;//确认命令,优先发送
        if(isLowPower != null && isLowPower.booleanValue()){
            //低功耗时,尽快发送
            confirmCommand.isQuickSend = true ;
        }
        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() ;
        DataCd84Vo cdData = new DataCd84Vo() ;
        dV1.dataCd84Vo = cdData ;
        short index = ProtocolConstantV206V1_0_0.dataIndex ;
        //用水户号数据格式:5字节BCD码低位在前高位在后。
        cdData.clientNum = ByteUtil.BCD2String_LE(bs, index, index + 4) ;
        index += 5 ;
        //用水户余额:用户余额4字节BCD码,取值范围0.00~999999.99,单位为元。
        cdData.remainMoney = 0.0D ;
        int tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
        index++ ;
        cdData.remainMoney += tpInt/100.0 ;
        tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
        index++ ;
        cdData.remainMoney += tpInt;
        tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
        index++ ;
        cdData.remainMoney += tpInt * 100.0 ;
        tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
        index++ ;
        cdData.remainMoney += tpInt * 10000.0 ;
        //累计流量:5字节BCD码,取值范围0~9999999999,单位为m3。
        cdData.totalAmount = 0.0D ;
        tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
        index++ ;
        cdData.totalAmount += tpInt;
        tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
        index++ ;
        cdData.totalAmount += tpInt * 100.0 ;
        tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
        index++ ;
        cdData.totalAmount += tpInt * 10000.0 ;
        tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
        index++ ;
        cdData.totalAmount += tpInt * 1000000.0 ;
        tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
        index++ ;
        cdData.totalAmount += tpInt * 100000000.0 ;
        //瞬时流量:5字节BCD码,取值范围0~9999999.999,单位为m3/h。
        cdData.instantAmount = 0.0D ;
        tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
        index++ ;
        cdData.instantAmount += tpInt/1000.0 ;
        tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
        index++ ;
        cdData.instantAmount += tpInt/10.0 ;
        tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
        index++ ;
        cdData.instantAmount += tpInt * 10.0 ;
        tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
        index++ ;
        cdData.instantAmount += tpInt * 1000.0 ;
        tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
        index++ ;
        cdData.instantAmount += tpInt * 100000.0 ;
        //控制器时钟
        cdData.rtuDt = GlParse.parseTp(bs, index) ;
        //index += 6 ;
    }
}
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/parse/Cd_C0_Up.java
New file
@@ -0,0 +1,224 @@
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.mw.protocol.p206V1_0_0.parse.global.GlParse;
import com.dy.common.util.ByteUtil;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@AnnotationCodeUp(ifAny={
        CodeV1_0_1.cd_C0
})
@SuppressWarnings("unused")
public class Cd_C0_Up implements CodeParse {
    private static final Logger log = LogManager.getLogger(Cd_C0_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 ;//Rtu地址
        midRs.upCode = para.upCode ;//上行数据中的功能码
        midRs.upHex = para.upHex ;//上行数据十六进制形式
        midRs.upBuffer = para.upBuffer ;//上行数据字节数组
        midRs.data = para.data ;//解析后的数据
        midRs.reportOrResponse_trueOrFalse = true ;//主动上报
        String confirmComCode = para.upCode ;
        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 ;//Rtu地址
        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.isCachForOffLine = false ;//RTU不在线,命令是否缓存
        confirmCommand.isSendFirst = true ;//确认命令,优先发送
        if(isLowPower != null && isLowPower.booleanValue()){
            //低功耗时,尽快发送
            confirmCommand.isQuickSend = true ;
        }
        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() ;
        DataCdC0Vo cdData = new DataCdC0Vo() ;
        dV1.dataCdC0Vo = cdData ;
        boolean hasWaterAmount = false ;//是否有流量数据
        boolean hasWaterPress = false ;//是否有水压数据
        boolean hasEleVolt = false ;//是否有电压数据
        boolean hasSignal = false ;//是否有信号强度数据
        boolean hasAlarmStatus = false ;//是否有数据
        short index = ProtocolConstantV206V1_0_0.dataIndex ;
        byte tmpBt1 = bs[index] ;
        index++ ;
        if(((tmpBt1 & 4) >> 2) == 1){
            hasWaterAmount = true ;
        }
        byte tmpBt2 = bs[index] ;
        index++ ;
        if(((tmpBt2 & 0x10) >> 4) == 1){
            hasAlarmStatus = true ;
        }
        if(((tmpBt2 & 0x20) >> 5) == 1){
            hasWaterPress = true ;
        }
        if(((tmpBt2 & 0x40) >> 6) == 1){
            hasEleVolt = true ;
        }
        if(((tmpBt2 & 0x80) >> 7) == 1){
            hasSignal = true ;
        }
        if(hasWaterAmount){
            //瞬时流量:5字节BCD码,取值范围0~9999999.999,单位为m3/h。
            cdData.instantAmount = 0.0D ;
            int tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
            index++ ;
            cdData.instantAmount += tpInt/1000.0 ;
            tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
            index++ ;
            cdData.instantAmount += tpInt/10.0 ;
            tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
            index++ ;
            cdData.instantAmount += tpInt * 10.0 ;
            tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
            index++ ;
            cdData.instantAmount += tpInt * 1000.0 ;
            tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
            index++ ;
            cdData.instantAmount += tpInt * 100000.0 ;
            //累计流量:5字节BCD码,取值范围0~9999999999,单位为m3。
            cdData.totalAmount = 0.0D ;
            tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
            index++ ;
            cdData.totalAmount += tpInt;
            tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
            index++ ;
            cdData.totalAmount += tpInt * 100.0 ;
            tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
            index++ ;
            cdData.totalAmount += tpInt * 10000.0 ;
            tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
            index++ ;
            cdData.totalAmount += tpInt * 1000000.0 ;
            tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
            index++ ;
            cdData.totalAmount += tpInt * 100000000.0 ;
            //损失流量:5字节BCD码,取值范围0~9999999999,单位为m3。
            cdData.lossAmount = 0.0D ;
            tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
            index++ ;
            cdData.lossAmount += tpInt;
            tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
            index++ ;
            cdData.lossAmount += tpInt * 100.0 ;
            tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
            index++ ;
            cdData.lossAmount += tpInt * 10000.0 ;
            tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
            index++ ;
            cdData.lossAmount += tpInt * 1000000.0 ;
            tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
            index++ ;
            cdData.lossAmount += tpInt * 100000000.0 ;
        }
        if(hasWaterPress){
            //水压:4字节BCD码,取值范围0~999999.99,单位为KPa。
            cdData.waterPress = 0.0D ;
            int tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
            index++ ;
            cdData.waterPress += tpInt/100.0 ;
            tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
            index++ ;
            cdData.waterPress += tpInt;
            tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
            index++ ;
            cdData.waterPress += tpInt * 100.0 ;
            tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
            index++ ;
            cdData.waterPress += tpInt * 10000.0 ;
        }
        if(hasEleVolt){
            //电池电压:4字节BCD码,取值范围0~99.99,单位为V。
            cdData.batteryVolt = 0.0D ;//蓄电池电压
            cdData.sunVolt = 0.0D ;//太阳能电压
            int tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
            index++ ;
            cdData.batteryVolt += tpInt/100.0 ;
            tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
            index++ ;
            cdData.batteryVolt += tpInt;
            //太阳能电压:4字节BCD码,取值范围0~99.99,单位为V。
            tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
            index++ ;
            cdData.sunVolt += tpInt/100.0 ;
            tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
            index++ ;
            cdData.sunVolt += tpInt;
        }
        if(hasSignal){
            //信号强度:1字节BCD码,取值范围0~99。
            cdData.signal = 0 ;
            int tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
            index++ ;
            cdData.signal += tpInt  ;
        }
        if(hasAlarmStatus){
            //报警数据
            cdData.alarmVo = GlParse.parseAlarm(bs, index) ;
            index += 2 ;
            //状态数据
            cdData.stateVo = GlParse.parseState(bs, index) ;
            index += 2 ;
        }
        cdData.rtuDt = GlParse.parseTp(bs, index) ;
    }
}
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/support/SupportUnit.java
@@ -39,31 +39,36 @@
    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() ;
        //短工作时长线程池,线程负责用时较短的工作任务
@@ -106,7 +111,6 @@
        public void setConfig(SupportUnitConfigVo configVo) {
            this.configVo = configVo;
        }
    }
    */
}
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/support/SupportUnitConfigVo.java
@@ -1,8 +1,10 @@
package com.dy.common.mw.support;
public class SupportUnitConfigVo {
    public boolean enableThreadPool ;
    public boolean enableShortThreadPool ;
    public boolean enableLongThreadPool ;
    //短任务线程池
    public int short_maxThread ;
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/ByteUtil.java
@@ -9,7 +9,7 @@
     * å°†å­—节数组合并到字节数组上
     * @param bGroup1 è¢«åˆå¹¶æ•°ç»„
     * @param bGroup2 åˆå¹¶æ•°ç»„
     * @return åˆå¹¶åŽæ•°ç»„
     * @return è¿”回 åˆå¹¶åŽæ•°ç»„
     */
    public static byte[] bytesMerge(byte[] bGroup1, byte[] bGroup2){
        if(bGroup1 == null && bGroup2 == null){
@@ -29,11 +29,11 @@
    /**
     * åˆ¤æ–­æ‰€æœ‰å­—节是否为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 ;
@@ -42,14 +42,14 @@
                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;
@@ -69,13 +69,13 @@
        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;
@@ -87,11 +87,11 @@
    }
    /**
     * å­—节转存8位二进制
     *
     *
     * @param b
     *            byte
     * @throws Exception
     * @return String
     * @throws Exception å¼‚常
     * @return è¿”回 String
     */
    public static String byte2bit8Binary(byte b) throws Exception {
        String s = byte2Binary(b);
@@ -101,13 +101,13 @@
        }
        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] ;
@@ -125,9 +125,9 @@
    /**
     * å­—节取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){
@@ -153,11 +153,11 @@
    /**
     * ä¸€ä¸ªå­—节转正整数
     *
     *
     * @param b
     *            byte
     * @throws Exception
     * @return String
     * @throws Exception å¼‚常
     * @return è¿”回 String
     */
    public static Short byte2PlusInt(byte b) throws Exception {
        short v = b ;
@@ -167,13 +167,13 @@
        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);
@@ -188,9 +188,9 @@
    /**
     * å°ç«¯æ¨¡å¼ã€Šæ•°æ®ä½Žä½åœ¨æ•°ç»„低字节》
     * 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);
@@ -205,8 +205,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);
@@ -216,8 +216,8 @@
    /**
     * å°ç«¯æ¨¡å¼ã€Šæ•°æ®ä½Žä½åœ¨æ•°ç»„低字节》
     * 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);
@@ -306,7 +306,7 @@
    /**
     * å°ç«¯æ¨¡å¼ã€Šæ•°æ®ä½Žä½åœ¨æ•°ç»„低字节》
     * è½¬æ¢long型为byte数组
     * è½¬æ¢long型为byte数组
     * @value bs byte[]
     * @value value long
     * @value from int
@@ -315,8 +315,8 @@
        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 ;
            }
@@ -325,12 +325,12 @@
            throw new Exception("long2Bytes时数组越界");
        }
    }
    /**
     * å¤§ç«¯æ¨¡å¼ã€Šæ•°æ®ä½Žä½åœ¨æ•°ç»„高字节》
     * 8位字节数组转换为长整型
     * @param bs byte[]
     * @return
     * @param bs å­—节数组 byte[]
     * @return è¿”回
     */
    public static long bytes2Long_BE(byte[] bs) {
        int len = bs.length ;
@@ -347,16 +347,16 @@
                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);
@@ -388,10 +388,10 @@
    /**
     * å¤§ç«¯æ¨¡å¼ã€Šæ•°æ®ä½Žä½åœ¨æ•°ç»„高字节》
     * 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);
@@ -414,13 +414,13 @@
        }
    }
    /**
     * å°ç«¯æ¨¡å¼ã€Šæ•°æ®ä½Žä½åœ¨æ•°ç»„低字节》
     * 8位字节数组转换为长整型
     * @param bs byte[]
     * @return
     * @param bs å­—节数组 byte[]
     * @return è¿”回
     */
    public static long bytes2Long_LE(byte[] bs) {
        int len = bs.length ;
@@ -437,16 +437,16 @@
                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);
@@ -479,10 +479,10 @@
    /**
     * å°ç«¯æ¨¡å¼ã€Šæ•°æ®ä½Žä½åœ¨æ•°ç»„低字节》
     * 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);
@@ -551,8 +551,9 @@
    /**
     * å¤§ç«¯æ¨¡å¼ã€Šæ•°æ®ä½Žä½åœ¨æ•°ç»„高字节》
     * 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);
@@ -573,13 +574,13 @@
            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);
@@ -600,7 +601,7 @@
            throw new Exception("byte2Int时数组越界");
        }
    }
    /**
     * å¤§ç«¯æ¨¡å¼ã€Šæ•°æ®ä½Žä½åœ¨æ•°ç»„高字节》
@@ -674,14 +675,14 @@
    /**
     * å¤§ç«¯æ¨¡å¼ã€Šæ•°æ®ä½Žä½åœ¨æ•°ç»„高字节》
     * 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不变
@@ -697,14 +698,14 @@
    /**
     * å°ç«¯æ¨¡å¼ã€Šæ•°æ®ä½Žä½åœ¨æ•°ç»„低字节》
     * 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不变
@@ -718,11 +719,11 @@
    }
    /**
     * å­—符到一字节转换
     *
     *
     * @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);
@@ -735,10 +736,9 @@
    /**
     * ä¸€å­—节转换为字符
     *
     * @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);
@@ -751,13 +751,13 @@
    /**
     * å­—符串型数字转成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) {
@@ -772,7 +772,7 @@
     * @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 {
@@ -798,7 +798,7 @@
     * @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 {
@@ -824,7 +824,7 @@
     * @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 {
@@ -846,7 +846,7 @@
     * @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 {
@@ -898,10 +898,10 @@
    /**
     * åˆ¤æ–­æ•°ç»„下标是否越界
     *
     *
     * @value bsLength æ•°ç»„总长度
     * @value toSite æ•°ç»„偏移量
     * @return
     * @return è¿”回
     */
    private static boolean isOutOfArrLength(int bsLength, int toSite) {
        if (bsLength > toSite) {
@@ -911,104 +911,104 @@
        }
    }
    /**
     * å­—节数组转换成十六进制的字符串
     *
     * @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位,可用两个十六进制位标识
@@ -1027,12 +1027,40 @@
        }
        return new String(buf);
    }
    /**
     * å°†byte[]转换为16进制字符串
     *
     * @param bytes å¾…转换byte[]
     * @return è¿”回 è½¬æ¢åŽçš„字符串
     */
    public static String bytesToHex(byte[] bytes, int startIndex, int endIndex) {
        byte[] bs = new byte[endIndex - startIndex + 1] ;
        byte j = 0 ;
        for(int i = startIndex; i <= endIndex; i++){
            bs[j++] = bytes[i] ;
        }
        //一个byte为8位,可用两个十六进制位标识
        char[] buf = new char[bs.length * 2];
        int a = 0;
        int index = 0;
        for (byte b : bs) { // ä½¿ç”¨é™¤ä¸Žå–余进行转换
            if (b < 0) {
                a = 256 + b;
            } else {
                a = b;
            }
            buf[index++] = HEX_CHAR[a / 16];
            buf[index++] = HEX_CHAR[a % 16];
        }
        return new String(buf);
    }
    /**
     * å°†16进制字符串转换为byte[]
     *
     * @param str å¾…转换字符串
     * @return è½¬æ¢åŽçš„byte[]
     * @return è¿”回 è½¬æ¢åŽçš„byte[]
     */
    public static byte[] hexToBytes(String str) {
        if (str == null || "".equals(str.trim())) {
@@ -1051,18 +1079,18 @@
    /**
     * 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;
@@ -1079,8 +1107,8 @@
    /**
     * å°ç«¯æ¨¡å¼ã€Šæ•°æ®ä½Žä½åœ¨æ•°ç»„低字节》
     * æ•´å½¢è½¬æˆBCD编码,字节顺序是倒的
     * @param l
     * @return
     * @param i
     * @return è¿”回
     */
    public static byte[] int2BCD_LE(int i)throws Exception {
        String str = "" + i;
@@ -1099,7 +1127,7 @@
     * å¤§ç«¯æ¨¡å¼ã€Šæ•°æ®ä½Žä½åœ¨æ•°ç»„高字节》
     * é•¿æ•´å½¢è½¬æˆBCD编码
     * @param l
     * @return
     * @return è¿”回
     */
    public static byte[] long2BCD_BE(long l)throws Exception {
        String str = "" + l;
@@ -1118,7 +1146,7 @@
     * å°ç«¯æ¨¡å¼ã€Šæ•°æ®ä½Žä½åœ¨æ•°ç»„低字节》
     * é•¿æ•´å½¢è½¬æˆBCD编码,字节顺序是倒的
     * @param l
     * @return
     * @return è¿”回
     */
    public static byte[] long2BCD_LE(long l) throws Exception {
        String str = "" + l;
@@ -1137,30 +1165,30 @@
     * å¤§ç«¯æ¨¡å¼ã€Šæ•°æ®ä½Žä½åœ¨æ•°ç»„高字节》
     * å­—符串型数字转成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);
@@ -1179,8 +1207,8 @@
     * å°ç«¯æ¨¡å¼ã€Šæ•°æ®ä½Žä½åœ¨æ•°ç»„低字节》
     * å­—符串型数字转成BCD编码,字节顺序是倒的
     * @param s
     * @return
     * @throws Exception
     * @return è¿”回
     * @throws Exception å¼‚常
     */
    public static byte[] string2BCD_LE(String s) throws Exception {
        byte[] b = null;
@@ -1193,15 +1221,15 @@
        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);
@@ -1221,10 +1249,8 @@
     * å¤§ç«¯æ¨¡å¼ã€Šæ•°æ®ä½Žä½åœ¨æ•°ç»„高字节》
     * BCD编码转成整型
     * @param b
     * @param startIndex
     * @param endIndex
     * @return
     * @throws Exception
     * @return è¿”回
     * @throws Exception å¼‚常
     */
    public static int BCD2Int_BE(byte b) throws Exception {
        String str = "";
@@ -1237,10 +1263,8 @@
     * å°ç«¯æ¨¡å¼ã€Šæ•°æ®ä½Žä½åœ¨æ•°ç»„低字节》
     * BCD编码转成整型,字节顺序是倒的
     * @param b
     * @param startIndex
     * @param endIndex
     * @return
     * @throws Exception
     * @return è¿”回
     * @throws Exception å¼‚常
     */
    public static int BCD2Int_LE(byte b) throws Exception {
        String str = "";
@@ -1255,8 +1279,8 @@
     * @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 = "";
@@ -1271,8 +1295,8 @@
     * @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 = "";
@@ -1287,8 +1311,8 @@
     * @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 = "";
@@ -1304,8 +1328,8 @@
     * @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 = "";
@@ -1320,8 +1344,8 @@
     * @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);
@@ -1333,8 +1357,8 @@
     * @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);
@@ -1342,17 +1366,17 @@
    /**
     * å¤§ç«¯æ¨¡å¼ã€Šæ•°æ®ä½Žä½åœ¨æ•°ç»„高字节》
     * ç¼–码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--) {
@@ -1362,20 +1386,20 @@
            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--) {
@@ -1393,8 +1417,8 @@
     * è§£ç 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();
@@ -1415,8 +1439,8 @@
      * ç¼–码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();
@@ -1462,6 +1486,7 @@
//        System.out.println(v5);
//
//    }
    /*
    public static void main(String[] args) throws Exception {
        byte[] bs = new byte[]{0x38, 0x36, 0x39, 0x31} ; 
        String s = bytes2String_BE(bs, 0, 3) ;
@@ -1475,5 +1500,6 @@
        }
        System.out.println(v);
    }
    */
}
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/Server.java
@@ -144,13 +144,6 @@
            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, 0, 99, 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());
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/ServerProperties.java
@@ -25,6 +25,12 @@
    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 ;
}
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/MidResultActionToRtu.java
@@ -15,7 +15,7 @@
        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);
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/TcpDownCommandCache.java
New file
@@ -0,0 +1,129 @@
package com.dy.aceMw.server.forTcp;
import com.dy.common.queue.Node;
import com.dy.common.queue.Queue;
import com.dy.common.mw.protocol.MidResultFromRtu;
import com.dy.common.mw.protocol.MidResultToRtu;
import com.dy.aceMw.server.ServerProperties;
/**
 * éžçº¿ç¨‹å®‰å…¨çš„,只能在单线程中运行
 */
public class TcpDownCommandCache {
    //TCP下行命令缓存队列
    private static Queue cacheQueue = new Queue("tcpDownCommandQueue") ;
    private static TcpDownCommandCache instance = new TcpDownCommandCache() ;
    private TcpDownCommandCache(){
        cacheQueue.setLimit(ServerProperties.cacheUpDownDataWarnCount, ServerProperties.cacheUpDownDataMaxCount);
    }
    public static TcpDownCommandCache getInstance(){
        return instance ;
    }
    /**
     * ç¼“存命令
     * @param 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){
                cacheQueue.pushHead(new TcpDownCommandObj(result));
            }else{
                cacheQueue.pushTail(new TcpDownCommandObj(result));
            }
        }
    }
    /**
     * åŒ¹é…å‘½ä»¤ç»“æžœ
     * @param rsFromRtu
     * @return
     */
    public static MidResultToRtu matchFromHead(MidResultFromRtu rsFromRtu){
        MidResultToRtu res = null ;
        TcpDownCommandObj obj = null ;
        Node node = cacheQueue.getFirstNode() ;
        while(node != null && node.obj != null){
            obj = (TcpDownCommandObj)node.obj;
            res = obj.result ;
            if(res != null
                    && res.rtuAddr.equals(rsFromRtu.rtuAddr)
                    && res.downCode.equals(rsFromRtu.upCode)){
                obj.onceReceivedResult = true ;//标识已经收到命令结果
                return res ;
            }else{
                node = node.pre ;
            }
        }
        return null ;
    }
    /**
     * åŒ¹é…å‘½ä»¤ç»“æžœ
     * @param rsFromRtu
     * @return
     */
    public static MidResultToRtu matchFromTail(MidResultFromRtu rsFromRtu){
        MidResultToRtu res = null ;
        TcpDownCommandObj obj = null ;
        Node node = cacheQueue.getLastNode() ;
        while(node != null && node.obj != null){
            obj = (TcpDownCommandObj)node.obj;
            res = obj.result ;
            if(res != null
                    && res.rtuAddr.equals(rsFromRtu.rtuAddr)
                    && res.downCode.equals(rsFromRtu.upCode)){
                obj.onceReceivedResult = true ;//标识已经收到命令结果
                return res ;
            }else{
                node = node.pre ;
            }
        }
        return null ;
    }
    /**
     * å¾—到第一个节点
     * @return
     */
    public static Node getFirstQueueNode(){
        return cacheQueue.getFirstNode() ;
    }
    /**
     * å¾—到最后一个节点
     * @return
     */
    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() ;
    }
}
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/forTcp/TcpDownCommandObj.java
@@ -73,8 +73,8 @@
        }
        Long lastSendStamp = tcpSe.lastDownComTime ;
        if(lastSendStamp == null || (now - lastSendStamp >= ServerProperties.commandSendInterval)){
            //未收到命令结果,未达到最大发送次数,RTU在线,超过命令间下发间隔,以上满足发送命令条件,执行发送命令
        if(this.result.isQuickSend || lastSendStamp == null || (now - lastSendStamp >= ServerProperties.commandSendInterval)){
            //未收到命令结果,未达到最大发送次数,RTU在线,速发命令或超过命令下发间隔,以上满足发送命令条件,执行发送命令
            tcpSe.ioSession.write(this.result.downBuffer) ;
            tcpSe.lastDownComTime = now ;
            if(!this.result.hasResponse){
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/rtuData/TreeParse.java
@@ -161,9 +161,9 @@
        if (c == null) {
            throw new Exception("上行数据处理任务配置文件中不能实例化class=" + clazz + "!");
        }else{
            Object o = c.newInstance();
            if(o instanceof Task){
            }else{
            Object o = c.getDeclaredConstructor().newInstance();
            //Object o = c.newInstance();
            if(!(o instanceof Task)){
                throw new Exception("上行数据处理任务配置文件中class=" + clazz + "必须实现Task接口!");
            }
        }
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/tasks/RtuDownTask.java
@@ -7,7 +7,7 @@
import com.dy.common.mw.protocol.MidResult;
import com.dy.common.mw.protocol.Command;
import com.dy.common.mw.protocol.Driver;
import com.dy.common.mw.protocol.ProtocolCach;
import com.dy.common.mw.protocol.ProtocolCache;
import com.dy.aceMw.server.ServerProperties;
import com.dy.aceMw.server.forTcp.TcpSessionCach;
@@ -34,8 +34,7 @@
    
    /**
     * å¤„理命令
     * @param webJgroupName
     * @param com
     * @param com å‘½ä»¤
     * @throws Exception
     */
    private void deal(Command com) throws Exception{
@@ -45,13 +44,13 @@
        String protocolName = TcpSessionCach.getTcpProtocolName(rtuAddr) ;
        if(protocolName == null){
            //RTU未曾上线
            int count = ProtocolCach.driverCount() ;
            int count = ProtocolCache.driverCount() ;
            if(count == 1){
                //只有一个协议
                dri = ProtocolCach.getFirstDriver() ;
                dri = ProtocolCache.getFirstDriver() ;
            }
        }else{
            dri = ProtocolCach.getDriver(protocolName) ;
            dri = ProtocolCache.getDriver(protocolName) ;
        }    
        if(dri == null){
            log.error("严重错误,未能得到协议" + protocolName + "驱动类实例!");
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/tasks/RtuUpTask.java
@@ -14,7 +14,7 @@
import com.dy.common.mw.protocol.Driver;
import com.dy.common.mw.protocol.OnLine;
import com.dy.common.mw.protocol.OnLineHandle;
import com.dy.common.mw.protocol.ProtocolCach;
import com.dy.common.mw.protocol.ProtocolCache;
import com.dy.aceMw.server.ServerProperties;
import com.dy.aceMw.server.forTcp.RtuLogDealer;
import com.dy.aceMw.server.forTcp.RtuStatusDealer;
@@ -144,13 +144,13 @@
     * @throws Exception å¼‚常
     */
    private void dealUpData(IoSession session, String rtuAddrAtHead, String protocolName, boolean isOnLine, byte[] upBuf, String upHex) throws Exception{
        Driver dri = ProtocolCach.getDriver(protocolName) ;
        Driver dri = ProtocolCache.getDriver(protocolName) ;
        if(dri == null){
            log.error("严重错误,未能得到协议" + protocolName + "驱动类实例!");
        }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地址
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/server/tasks/ToRtuConstantTask.java
@@ -5,7 +5,7 @@
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;
@@ -40,16 +40,12 @@
     * å¤„理下行命令
     */
    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 ;
    }
@@ -57,9 +53,9 @@
     * å¤„理缓存的下行命令节点
     * @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 ;
@@ -74,7 +70,29 @@
            }
        }
    }
    /**
     * å¤„理缓存的下行命令节点
     * @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) ;
            }
        }
    }
    /**
     * å¤„理一个节点
     * @param now çŽ°åœ¨æ—¶åˆ»
@@ -84,7 +102,7 @@
        TcpDownCommandObj obj = (TcpDownCommandObj)node.obj ;
        boolean removeNode = obj.dealSelf(now) ;
        if(removeNode){
            TcpDownCommandCach.removeNode(node);
            TcpDownCommandCache.removeNode(node);
        }
    }
pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/AdapterImp_RmiUnit.java
New file
@@ -0,0 +1,26 @@
package com.dy.testServer;
import com.dy.common.mw.channel.rmi.RmiConfigVo;
import com.dy.common.mw.channel.rmi.RmiRequestCallback;
import com.dy.common.mw.channel.rmi.RmiUnitAdapter;
import com.dy.testServer.forRmi.RmiRequestedCallback;
public class AdapterImp_RmiUnit implements RmiUnitAdapter {
    private RmiConfigVo configVo ;
    @Override
    public RmiConfigVo getConfig() {
        return configVo;
    }
    public void setConfig(RmiConfigVo configVo){
        this.configVo = configVo ;
    }
    @Override
    public RmiRequestCallback newRequestCallback() {
        return new RmiRequestedCallback();
    }
}
pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/forRmi/ResRegisterVo.java
New file
@@ -0,0 +1,46 @@
package com.dy.testServer.forRmi;
import com.alibaba.fastjson2.JSON;
public class ResRegisterVo {
    public String token ;
    /**
     * å¯¹è±¡è½¬æˆjson
     * @return json
     * @throws Exception å¼‚常
     */
    public String toJson()throws Exception{
        try{
            return JSON.toJSONString(this) ;
            //return new JSONSerializer().exclude(new String[]{"class", "*.class"}).deepSerialize(this);
        }catch(Exception e){
            throw new Exception(e.getMessage() , e ) ;
        }
    }
    /**
     * json转成对象
     * @param json å‚æ•°
     * @return å¯¹è±¡
     * @throws Exception å¼‚常
     */
    public static ResRegisterVo jsonToObject(String json)throws Exception{
        try{
            return JSON.parseObject(json, ResRegisterVo.class) ;
            //return new JSONDeserializer<ResRegisterVo>().deserialize(json, ResRegisterVo.class) ;
        }catch(Exception e){
            throw new Exception(e.getMessage() , e ) ;
        }
    }
    public String getToken() {
        return token;
    }
    public void setToken(String id) {
        this.token = id;
    }
}
pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/forRmi/ResStartVo.java
New file
@@ -0,0 +1,63 @@
package com.dy.testServer.forRmi;
import com.alibaba.fastjson2.JSON;
public class ResStartVo {
    public boolean success = true ;
    public String errorInfo ;
    public boolean start ;
    /**
     * å¯¹è±¡è½¬æˆjson
     * @return json
     * @throws Exception å¼‚常
     */
    public String toJson()throws Exception{
        try{
            return JSON.toJSONString(this) ;
            //return new JSONSerializer().exclude(new String[]{"class", "*.class"}).deepSerialize(this);
        }catch(Exception e){
            throw new Exception(e.getMessage() , e ) ;
        }
    }
    /**
     * json转成对象
     * @param json å‚æ•°
     * @return å¯¹è±¡
     * @throws Exception å¼‚常
     */
    public static ResStartVo jsonToObject(String json)throws Exception{
        try{
            return JSON.parseObject(json, ResStartVo.class) ;
            //return new JSONDeserializer<ResStartVo>().deserialize(json, ResStartVo.class) ;
        }catch(Exception e){
            throw new Exception(e.getMessage() , e ) ;
        }
    }
    public boolean isSuccess() {
        return success;
    }
    public void setSuccess(boolean success) {
        this.success = success;
    }
    public String getErrorInfo() {
        return errorInfo;
    }
    public void setErrorInfo(String errorInfo) {
        this.errorInfo = errorInfo;
    }
    public boolean isStart() {
        return start;
    }
    public void setStart(boolean start) {
        this.start = start;
    }
}
pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/forRmi/RmiRequestedCallback.java
New file
@@ -0,0 +1,36 @@
package com.dy.testServer.forRmi;
import java.rmi.RemoteException;
import com.dy.common.mw.channel.rmi.RmiRequestCallback;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class RmiRequestedCallback implements RmiRequestCallback {
    @SuppressWarnings("unused")
    private static Logger log = LogManager.getLogger(RmiRequestedCallback.class.getName()) ;
    @Override
    public Object syncRequest(Object obj) throws RemoteException {
        String json ;
        try {
            json = Manager.dealRequest(obj);
        } catch (Exception e) {
            throw new RemoteException("服务端异常" , e) ;
        }
        return json ;
    }
    @Override
    public String asyncRequest(Object obj) throws RemoteException {
        String json ;
        try {
            json = Manager.dealRequest(obj);
        } catch (Exception e) {
            throw new RemoteException("服务端异常" , e) ;
        }
        return json ;
    }
}
pipIrr-platform/Îĵµ/Git²Ù×÷.txt
New file
@@ -0,0 +1,2 @@
push之前先pull
pull前要先commit
pipIrr-platform/Îĵµ/Maven ´ò°ü²å¼þ maven-jar-plugin.docx
Binary files differ
pipIrr-platform/Îĵµ/Maven´ò°ü.docx
Binary files differ
pipIrr-platform/Îĵµ/MavenµÄmaven-compiler-plugin²å¼þ.docx
Binary files differ
pipIrr-platform/Îĵµ/±àÂëÉè¼Æ.docx
Binary files differ