|  |  |  | 
|---|
|  |  |  | package com.dy.common.mw.protocol.p206V202404.parse; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.alibaba.fastjson2.JSON; | 
|---|
|  |  |  | import com.alibaba.fastjson2.JSONObject; | 
|---|
|  |  |  | import com.dy.common.mw.protocol.*; | 
|---|
|  |  |  | import com.dy.common.mw.protocol.p206V202404.CodeV202404; | 
|---|
|  |  |  | import com.dy.common.mw.protocol.p206V202404.ParseParamsForDownV202404; | 
|---|
|  |  |  | import com.dy.common.mw.protocol.p206V202404.downVos.ComCd16Vo; | 
|---|
|  |  |  | import com.dy.common.mw.protocol.p206V202404.parse.global.GlCreate; | 
|---|
|  |  |  | import com.dy.common.util.ByteUtil; | 
|---|
|  |  |  | import com.dy.common.util.ByteUtilUnsigned; | 
|---|
|  |  |  | import com.dy.common.util.NumUtil; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @AnnotationCodeDown(ifAny={ | 
|---|
|  |  |  | CodeV202404.cd_16 | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | MidResultToRtu midRs = new MidResultToRtu() ; | 
|---|
|  |  |  | midRs.protocolName = para.protocolName ;//协议名称 | 
|---|
|  |  |  | midRs.rtuResultSendWebUrl = para.rtuResultSendWebUrl ; | 
|---|
|  |  |  | midRs.rtuAddr = para.rtuAddr ;//Rtu地址 | 
|---|
|  |  |  | midRs.commandId = para.commandId ;//命令ID,发起命令的客户端(web端)生成,以匹配命令结果 | 
|---|
|  |  |  | midRs.downCode = para.commandCode ;//下行命令功能码; | 
|---|
|  |  |  | 
|---|
|  |  |  | public byte[] doParse(ParseParamsForDownV202404 para) throws Exception { | 
|---|
|  |  |  | byte[] bytes = GlCreate.createStart2Cd(para.rtuAddr, para.commandCode); | 
|---|
|  |  |  | if(para.param != null){ | 
|---|
|  |  |  | String json = (String)para.param; | 
|---|
|  |  |  | JSONObject obj = (JSONObject)para.param; | 
|---|
|  |  |  | String json = obj.toJSONString(); | 
|---|
|  |  |  | ComCd16Vo cvo = JSON.parseObject(json, ComCd16Vo.class) ; | 
|---|
|  |  |  | if(cvo == null){ | 
|---|
|  |  |  | throw new Exception("json转ComCd16Vo为null") ; | 
|---|
|  |  |  | 
|---|
|  |  |  | bs[index++] = 0 ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | index += 4 ; | 
|---|
|  |  |  | strTemp = "" + cvo.moneyAlarm ; | 
|---|
|  |  |  | bTemp = ByteUtil.string2BCD_LE(strTemp) ; | 
|---|
|  |  |  | bTempLen = bTemp.length ; | 
|---|
|  |  |  | 
|---|
|  |  |  | bs[index++] = 0 ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | index ++ ; | 
|---|
|  |  |  | GlCreate.createPw(bs, index); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | index += 2 ; | 
|---|