|  |  | 
 |  |  | 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.util.DateTime; | 
 |  |  |  | 
 |  |  | import java.net.URI; | 
 |  |  | 
 |  |  | @AnnotationDriver(name= ProtocolConstantV206V202404.protocolName) | 
 |  |  | public class DriverV202404 extends Driver { | 
 |  |  |     | 
 |  |  |    private static String scanRootPackage = "com.dy.common.mw.protocol.p206V202404." ; | 
 |  |  |    private static String scanRootPackage = "com.dy.common.mw.protocol.p206V202404" ; | 
 |  |  |     | 
 |  |  |    //在Driver中是单例,随Driver的单例对象在单线程中运行 | 
 |  |  |    private ParseParamsForUpV202404 upCpParams ; | 
 |  |  | 
 |  |  |       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 void scanAnnotationCode() throws Exception{ | 
 |  |  |       if(!scanRootPackage.endsWith(".")){ | 
 |  |  |          scanRootPackage += "." ; | 
 |  |  |       } | 
 |  |  |       URL url = this.getClass().getResource("/" + scanRootPackage.replace('.', '/')); | 
 |  |  |       URI uri = new URI(url.toString());   | 
 |  |  |       super.doScanAnnotationCode(this, ProtocolConstantV206V202404.protocolName, uri, scanRootPackage) ; | 
 |  |  |       super.doScanAnnotationCode(this, ProtocolConstantV206V1_0_0.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{ | 
 |  |  | 
 |  |  |           | 
 |  |  |          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, 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,  |