| New file | 
 |  |  | 
 |  |  | package com.dy.common.mw.protocol.p206V202404.parse; | 
 |  |  |  | 
 |  |  |  | 
 |  |  | import com.dy.common.mw.protocol.*; | 
 |  |  | import com.dy.common.mw.protocol.p206V202404.*; | 
 |  |  | import com.dy.common.mw.protocol.p206V202404.upVos.DataCd8AVo; | 
 |  |  | import com.dy.common.util.ByteUtil; | 
 |  |  | import org.apache.logging.log4j.LogManager; | 
 |  |  | import org.apache.logging.log4j.Logger; | 
 |  |  |  | 
 |  |  | @AnnotationCodeUp(ifAny={ | 
 |  |  |         CodeV202404.cd_8A | 
 |  |  | }) | 
 |  |  | @SuppressWarnings("unused") | 
 |  |  | public class Cd_8A_Up implements CodeParse{ | 
 |  |  |  | 
 |  |  |     private static final Logger log = LogManager.getLogger(Cd_8A_Up.class); | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 分析上行数据 | 
 |  |  |      */ | 
 |  |  |     @Override | 
 |  |  |     public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback)throws Exception { | 
 |  |  |         ParseParamsForUpV202404 para = (ParseParamsForUpV202404)params ; | 
 |  |  |         int bsLen = new CommonV202404().parseDataLen4P202404(para.upBuffer) ; | 
 |  |  |         if(bsLen > 0){ | 
 |  |  |             this.doParse(para.upBuffer, | 
 |  |  |                     bsLen, | 
 |  |  |                     para.upCode, | 
 |  |  |                     para.data) ; | 
 |  |  |         } | 
 |  |  |         log.info("\n分析命令应答数据<" + CodeV202404.getCodeName(para.upCode) + " RTU地址=" + para.rtuAddr + ">:\n" + para.data.toString()); | 
 |  |  |  | 
 |  |  |         MidResultFromRtu midRs = new MidResultFromRtu() ; | 
 |  |  |         midRs.protocolName = para.protocolName ;//协议名称 | 
 |  |  |         midRs.protocolVersion = para.protocolVersion ;//协议版本号 | 
 |  |  |         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 ; | 
 |  |  |         ParseParamsForDownV202404 downCpParams  = new ParseParamsForDownV202404() ; | 
 |  |  |         downCpParams.setValue( | 
 |  |  |                 null, | 
 |  |  |                 ProtocolConstantV206V202404.protocolName, | 
 |  |  |                 para.protocolVersion, | 
 |  |  |                 para.rtuAddr, | 
 |  |  |                 Command.defaultId, | 
 |  |  |                 confirmComCode, | 
 |  |  |                 para.data.subData==null?null:(((DataV202404)para.data.subData).subData), | 
 |  |  |                 null); | 
 |  |  |         //构造应答 | 
 |  |  |         byte[] data = new Cd_8A_Down().doParse(downCpParams) ; | 
 |  |  |  | 
 |  |  |         MidResultToRtu confirmCommand = new MidResultToRtu() ; | 
 |  |  |         confirmCommand.protocolName = para.protocolName ;//协议名称 | 
 |  |  |         confirmCommand.protocolVersion = para.protocolVersion ;//协议版本号 | 
 |  |  |         confirmCommand.rtuAddr = para.rtuAddr ;//Rtu地址 | 
 |  |  |         confirmCommand.commandId = Command.defaultId ;//命令ID,发起命令的客户端(web端)生成,以匹配命令结果 | 
 |  |  |         confirmCommand.downCode = confirmComCode ;//下行命令功能码; | 
 |  |  |         confirmCommand.downCodeName = CodeV202404.getCodeName(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, para.data.subData==null?null:((DataV202404)(para.data.subData)).subData); | 
 |  |  |         return new MidResult[]{confirmCommand, midRs} ; | 
 |  |  |     } | 
 |  |  |     /** | 
 |  |  |      * 执行分析 | 
 |  |  |      * @param bs 字节数组 | 
 |  |  |      * @param bsLen 字节长度(总包长,包括包头和包尾) | 
 |  |  |      * @param dataCode 功能码 | 
 |  |  |      * @param data 数据 | 
 |  |  |      * @throws Exception 异常 | 
 |  |  |      */ | 
 |  |  |     protected void doParse(byte[] bs, int bsLen, String dataCode, Data data) throws Exception { | 
 |  |  |         DataV202404 dV202404 = (DataV202404)data.getSubData() ; | 
 |  |  |         DataCd8AVo cdData = new DataCd8AVo(CodeV202404.getCodeName(dataCode)) ; | 
 |  |  |         dV202404.subData = cdData ; | 
 |  |  |         int index = ProtocolConstantV206V202404.dataIndex ; | 
 |  |  |         cdData.controllerType = ByteUtil.bytes2Hex(bs, false, index, 1) ; | 
 |  |  |  | 
 |  |  |         index++ ; | 
 |  |  |         cdData.projectNo = (int)bs[index]; | 
 |  |  |  | 
 |  |  |         index++ ; | 
 |  |  |         Long lng = ByteUtil.BCD2Long_BE(bs, index, index + 4) ; | 
 |  |  |         cdData.lng = lng/1000000.0D; | 
 |  |  |  | 
 |  |  |         index += 5 ; | 
 |  |  |         Long lat = ByteUtil.BCD2Long_BE(bs, index, index + 4) ; | 
 |  |  |         cdData.lat = lat/1000000.0D; | 
 |  |  |  | 
 |  |  |         index += 5 ; | 
 |  |  |         int softVersion = ByteUtil.BCD2Int_BE(bs, index, index + 1) ; | 
 |  |  |         cdData.softVersion = softVersion/100.0F; | 
 |  |  |  | 
 |  |  |         index += 2 ; | 
 |  |  |         int hardVersion = ByteUtil.BCD2Int_BE(bs, index, index + 1) ; | 
 |  |  |         cdData.hardVersion = hardVersion/100.0F; | 
 |  |  |  | 
 |  |  |         index += 2 ; | 
 |  |  |         int protocolVersion = ByteUtil.BCD2Int_BE(bs, index, index + 1) ; | 
 |  |  |         cdData.protocolVersion = protocolVersion/100.0F; | 
 |  |  |  | 
 |  |  |     } | 
 |  |  | } |