| | |
| | | package com.dy.common.mw.protocol.p206V202404; |
| | | |
| | | import com.dy.common.mw.protocol.*; |
| | | import com.dy.common.mw.protocol.p206V1_0_0.ProtocolConstantV206V1_0_0; |
| | | import com.dy.common.mw.protocol.p206V1.ProtocolConstantV206V1; |
| | | import com.dy.common.util.DateTime; |
| | | |
| | | import java.net.URI; |
| | | import java.net.URL; |
| | | |
| | | @AnnotationDriver(name= ProtocolConstantV206V202404.protocolName) |
| | | public class DriverV202404 extends Driver { |
| | |
| | | private ParseParamsForDownV202404 downCpParams ; |
| | | |
| | | private Boolean reportOrResponse_trueOrFalse = null ; |
| | | private String rtuAddrInData = null ; |
| | | |
| | | public DriverV202404(){ |
| | | upCpParams = new ParseParamsForUpV202404() ; |
| | | 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 ; |
| | | } |
| | | |
| | | /** |
| | | * 扫描识别功能码注解类 |
| | | */ |
| | | @Override |
| | | public void scanAnnotationCode() throws Exception{ |
| | | super.doScanAnnotationCode(this, ProtocolConstantV206V1_0_0.protocolName, scanRootPackage) ; |
| | | super.doScanAnnotationCode(this, ProtocolConstantV206V1.protocolName, scanRootPackage) ; |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @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{ |
| | | CommonV202404 cp = new CommonV202404() ; |
| | | cp.checkHead(upBuffer) ; |
| | | cp.checkTail(upBuffer) ; |
| | | String crcStr = cp.checkCrc_str(upBuffer) ; |
| | | if(crcStr != null){ |
| | |
| | | Data upData = new Data() ; |
| | | upData.setRtuAddr(rtuAddr) ; |
| | | upData.setProtocol(ProtocolConstantV206V202404.protocolName); |
| | | upData.setProtocolVer(ProtocolConstantV206V202404.protocolVer); |
| | | upData.setCode(upCode) ; |
| | | upData.setHex(upHex) ; |
| | | |
| | | |
| | | DataV202404 dV1_0_1 = new DataV202404() ; |
| | | //dV1_0_1.version = cp.parseVersion(upBuffer) ; |
| | | dV1_0_1.rtuAddr = rtuAddr ; |
| | | dV1_0_1.dt = DateTime.yyyy_MM_dd_HH_mm_ss() ; |
| | | DataV202404 dV201 = new DataV202404() ; |
| | | //dV201.version = cp.parseVersion(upBuffer) ; |
| | | dV201.rtuAddr = rtuAddr ; |
| | | dV201.dt = DateTime.yyyy_MM_dd_HH_mm_ss() ; |
| | | |
| | | upData.setSubData(dV1_0_1) ; |
| | | upData.setSubData(dV201) ; |
| | | |
| | | this.upCpParams.clear(); |
| | | this.upCpParams.setValue(ProtocolConstantV206V202404.protocolName, |
| | | this.upCpParams.setValue(ProtocolConstantV206V202404.protocolName, |
| | | ProtocolConstantV206V202404.protocolVer, |
| | | rtuAddr, |
| | | upCode, |
| | | upHex, |
| | |
| | | @Override |
| | | public void callback(Boolean flag) { |
| | | reportOrResponse_trueOrFalse = flag ; |
| | | rtuAddrInData = dV1_0_1.getRtuAddr() ; |
| | | //rtuAddrInData = dV201.getRtuAddr() ; |
| | | } |
| | | @Override |
| | | public void notify(NotifyInfo ...infos) { |
| | | } |
| | | }); |
| | | } |
| | |
| | | isFail = true ; |
| | | return new MidResult[]{(new MidResultError(ProtocolConstantV206V202404.protocolName, rtuAddr, "严重错误,分析Rtu数据出错!数据为:" + upHex + (e.getMessage() == null?"":(",出错信息:" + e.getMessage())), e))} ; |
| | | } finally{ |
| | | callback.callback(rtuAddr, 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, |
| | | ProtocolConstantV206V202404.protocolName, |
| | | command.protocolVersion==null?ProtocolConstantV206V202404.protocolVer:command.protocolVersion, |
| | | rtuAddr, |
| | | command.getId(), |
| | | commandCode, |