| | |
| | | package com.dy.testClient.tcpClient; |
| | | |
| | | import com.dy.common.mw.protocol.p206V1_0_0.CommonV1_0_1; |
| | | import com.dy.common.mw.protocol.p206V1_0_0.ProtocolConstantV206V1_0_0; |
| | | import com.dy.common.mw.protocol.p206V1_0_0.parse.global.GlCreate; |
| | | import com.dy.common.mw.protocol.p206V1.CommonV1; |
| | | import com.dy.common.mw.protocol.p206V1.ProtocolConstantV206V1; |
| | | import com.dy.common.mw.protocol.p206V1.parse.global.GlCreate; |
| | | import com.dy.common.util.ByteUtil; |
| | | import com.dy.common.util.ByteUtilUnsigned; |
| | | |
| | | /** |
| | | * @Author: liurunyu |
| | |
| | | public class RtuUpData { |
| | | |
| | | private static byte[] creatHead(String rtuAddr, String code, byte ctrl)throws Exception { |
| | | byte[] bsHead = new byte[ProtocolConstantV206V1_0_0.lenHead2Code] ; |
| | | byte[] bsHead = new byte[ProtocolConstantV206V1.lenHead2Code] ; |
| | | byte index = 0 ; |
| | | bsHead[index] = ProtocolConstantV206V1_0_0.P_Head_Byte ; |
| | | bsHead[index] = ProtocolConstantV206V1.P_Head_Byte ; |
| | | |
| | | index++ ; |
| | | bsHead[index] = 0 ;//帧长度 |
| | | |
| | | index++ ; |
| | | bsHead[index] = ProtocolConstantV206V1_0_0.P_Head_Byte ; |
| | | bsHead[index] = ProtocolConstantV206V1.P_Head_Byte ; |
| | | |
| | | index++ ; |
| | | bsHead[index] = ctrl; //控制域功能码 |
| | |
| | | * @throws Exception 异常 |
| | | */ |
| | | public static byte[] createCdC0(String rtuAddr) throws Exception { |
| | | CommonV1_0_1 commonV1_0_1 = new CommonV1_0_1() ; |
| | | CommonV1 commonV_1 = new CommonV1() ; |
| | | byte[] bytes ; |
| | | byte[] bsHead = new byte[ProtocolConstantV206V1_0_0.lenHead2Code] ; |
| | | byte[] bsHead = new byte[ProtocolConstantV206V1.lenHead2Code] ; |
| | | byte index = 0 ; |
| | | bsHead[index] = ProtocolConstantV206V1_0_0.P_Head_Byte ; |
| | | bsHead[index] = ProtocolConstantV206V1.P_Head_Byte ; |
| | | |
| | | index++ ; |
| | | bsHead[index] = 0 ;//帧长度 |
| | | |
| | | index++ ; |
| | | bsHead[index] = ProtocolConstantV206V1_0_0.P_Head_Byte ; |
| | | bsHead[index] = ProtocolConstantV206V1.P_Head_Byte ; |
| | | |
| | | index++ ; |
| | | bsHead[index] = commonV1_0_1.createCtrl((byte)0x80, (byte)3) ;//控制域功能码3:自报帧,流量(水量)参数 |
| | | bsHead[index] = commonV_1.createCtrl((byte)0x80, (byte)3) ;//控制域功能码3:自报帧,流量(水量)参数 |
| | | |
| | | index++ ; |
| | | GlCreate.createRtuAddr(rtuAddr, bsHead, index); |