1、修改协议驱动RTU上行数据解析出错时,RTU上下行数据日志中的RTU地址不正确的bug;
2、83功能码上行数据测试main方法实现。
| | |
| | | protected HashMap<String, CodeParse> downCode2ClassInstance = new HashMap<>() ; |
| | | |
| | | /** |
| | | * 清空自己 |
| | | */ |
| | | public abstract void clear() ; |
| | | /** |
| | | * 单线程单例Driver模式下运行 |
| | | * 扫描识别功能码注解类 |
| | | * @throws Exception 异常 |
| | |
| | | * 扫描识别功能码注解类 |
| | | * @param driver 驱动 |
| | | * @param protocolName 协议名称 |
| | | * @param uri URI |
| | | * @param scanRootPackage 扫描包 |
| | | * @throws Exception 异常 |
| | | */ |
| | |
| | | downCpParams = new ParseParamsForDownV1_0_1() ; |
| | | } |
| | | |
| | | /** |
| | | * 清空自己 |
| | | */ |
| | | @Override |
| | | public void clear() { |
| | | if(this.upCpParams != null){ |
| | | this.upCpParams.clear(); |
| | | } |
| | | if(this.downCpParams != null){ |
| | | this.downCpParams.clear(); |
| | | } |
| | | this.reportOrResponse_trueOrFalse = null ; |
| | | this.rtuAddrInData = null ; |
| | | } |
| | | |
| | | /** |
| | | * 扫描识别功能码注解类 |
| | |
| | | */ |
| | | @Override |
| | | public MidResult[] parseData(Boolean isLowPower, String rtuAddr, byte[] upBuffer, String upHex, DriverParserDataCallback callback, Object... params) { |
| | | reportOrResponse_trueOrFalse = null ; |
| | | this.clear(); |
| | | boolean isFail = false ; |
| | | String upCode = null ; |
| | | try{ |
| | |
| | | |
| | | upData.setSubData(dV1_0_1) ; |
| | | |
| | | this.upCpParams.clear(); |
| | | this.upCpParams.setValue(ProtocolConstantV206V1_0_0.protocolName, |
| | | this.upCpParams.setValue(ProtocolConstantV206V1_0_0.protocolName, |
| | | rtuAddr, |
| | | upCode, |
| | | upHex, |
| | |
| | | isFail = true ; |
| | | return new MidResult[]{(new MidResultError(ProtocolConstantV206V1_0_0.protocolName, rtuAddr, "严重错误,分析Rtu数据出错!数据为:" + upHex + (e.getMessage() == null?"":(",出错信息:" + e.getMessage())), e))} ; |
| | | } finally{ |
| | | callback.callback(rtuAddr, upCode, CodeV1_0_1.getCodeName(upCode), upHex, reportOrResponse_trueOrFalse, isFail, rtuAddrInData); |
| | | callback.callback(rtuAddr, upCode, CodeV1_0_1.getCodeName(upCode), upHex, reportOrResponse_trueOrFalse, isFail, rtuAddr); |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public MidResult[] createCommand(Boolean isLowPower, Command command, Object... params) { |
| | | this.clear(); |
| | | String RtuResultSendWebUrl = command.getRtuResultSendWebUrl() ; |
| | | if(RtuResultSendWebUrl == null || RtuResultSendWebUrl.trim().equals("")){ |
| | | return new MidResult[]{(new MidResultError(ProtocolConstantV206V1_0_0.protocolName, null, "严重错误,命令中rtu返回命令结果发向目的地web URL为空,不能构建任何命令!", null))} ; |
| | |
| | | try { |
| | | String commandCode = command.getCode() ; |
| | | |
| | | this.downCpParams.clear(); |
| | | this.downCpParams.setValue( |
| | | RtuResultSendWebUrl, |
| | | ProtocolConstantV206V1_0_0.protocolName, |
| | |
| | | cdData.rtuDt = GlParse.parseTp(bs, index) ; |
| | | //index += 6 ; |
| | | } |
| | | |
| | | public static void main(String[] args) throws Exception { |
| | | Cd_83_Up obj = new Cd_83_Up() ; |
| | | String hex = "683C68B08485353448830200000000001000282353FE739444000001000313000101211615000101210000000000000000000200019000011518000101210A7B16"; |
| | | byte[] bs = ByteUtil.hex2Bytes(hex) ; |
| | | |
| | | Data data = new Data() ; |
| | | data.setSubData(new DataV1_0_1()) ; |
| | | |
| | | int bsLen = new CommonV1_0_1().parseDataLen(bs) ; |
| | | if(bsLen > 0){ |
| | | try { |
| | | obj.doParse(bs, |
| | | bsLen, |
| | | "83", |
| | | data) ; |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | System.out.println("data = " + data); |
| | | } |
| | | } |
| | |
| | | downCpParams = new ParseParamsForDownV202404() ; |
| | | } |
| | | |
| | | /** |
| | | * 清空自己 |
| | | */ |
| | | @Override |
| | | public void clear() { |
| | | if(this.upCpParams != null){ |
| | | this.upCpParams.clear(); |
| | | } |
| | | if(this.downCpParams != null){ |
| | | this.downCpParams.clear(); |
| | | } |
| | | this.reportOrResponse_trueOrFalse = null ; |
| | | this.rtuAddrInData = null ; |
| | | } |
| | | |
| | | /** |
| | | * 扫描识别功能码注解类 |
| | |
| | | */ |
| | | @Override |
| | | public MidResult[] parseData(Boolean isLowPower, String rtuAddr, byte[] upBuffer, String upHex, DriverParserDataCallback callback, Object... params) { |
| | | reportOrResponse_trueOrFalse = null ; |
| | | this.clear(); |
| | | boolean isFail = false ; |
| | | String upCode = null ; |
| | | try{ |
| | |
| | | |
| | | upData.setSubData(dV1_0_1) ; |
| | | |
| | | this.upCpParams.clear(); |
| | | this.upCpParams.setValue(ProtocolConstantV206V202404.protocolName, |
| | | this.upCpParams.setValue(ProtocolConstantV206V202404.protocolName, |
| | | rtuAddr, |
| | | upCode, |
| | | upHex, |
| | |
| | | isFail = true ; |
| | | return new MidResult[]{(new MidResultError(ProtocolConstantV206V202404.protocolName, rtuAddr, "严重错误,分析Rtu数据出错!数据为:" + upHex + (e.getMessage() == null?"":(",出错信息:" + e.getMessage())), e))} ; |
| | | } finally{ |
| | | callback.callback(rtuAddr, upCode, CodeV202404.getCodeName(upCode), upHex, reportOrResponse_trueOrFalse, isFail, rtuAddrInData); |
| | | callback.callback(rtuAddr, upCode, CodeV202404.getCodeName(upCode), upHex, reportOrResponse_trueOrFalse, isFail, rtuAddr); |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public MidResult[] createCommand(Boolean isLowPower, Command command, Object... params) { |
| | | this.clear(); |
| | | String RtuResultSendWebUrl = command.getRtuResultSendWebUrl() ; |
| | | if(RtuResultSendWebUrl == null || RtuResultSendWebUrl.trim().equals("")){ |
| | | return new MidResult[]{(new MidResultError(ProtocolConstantV206V202404.protocolName, null, "严重错误,命令中rtu返回命令结果发向目的地web URL为空,不能构建任何命令!", null))} ; |
| | |
| | | try { |
| | | String commandCode = command.getCode() ; |
| | | |
| | | this.downCpParams.clear(); |
| | | this.downCpParams.setValue( |
| | | RtuResultSendWebUrl, |
| | | ProtocolConstantV206V202404.protocolName, |