zhubaomin
2025-04-03 4c01b8d838c464f2246447120835ba189438aa43
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package com.dy.common.mw.protocol.p206V2;
 
public class ProtocolConstantV206V2 {
    /**
     * 注解相关
     */
    public static final String protocolName = "p206V2" ;
    public static final short protocolVer = 2 ;
    public static final int priority = 3 ;//优先级
    /**
     * RTU上线数据(上线后第一包数据)最小长度,设置该属性以备进行完整性检查,
     * 即断包检查,使尽可能收全上线数据(取值范围1-100)
     */
    public static final int onLineDataMinLength = 18 ;//采用心跳上行数据长度, 13 + 1 + 4
 
    /**
     * RTU上报数据的头部最小长度,上报数据中,取这个最小长度的部分数据中,
     * 要一定包含数据帧长度,以备取出数据帧长度来,进行完整性检查,
     * 即断包与粘包检查(取值范围0-100,其中取值为0时,表示headMinLength数据无作用,由协议实现来控制)
     */
    public static final int headMinLength = 4 ;
 
 
    //帧起始
    public static final byte P_Head_Byte = (byte)0x68 ;
    public static final byte P_Tail_Byte = (byte)0x16 ;
 
    //00H时遥测终端在兼容工作状态;01H时遥测终端在自报工作状态;02H时遥测终端在查询/应答工作状态;03H时遥测终端在调试/维修状态。
    public static final byte P_Default_mode = (byte)0x00 ;//默认工作模式
 
    public static final String P_Head_Hex = "68" ;
    public static final String P_Tail_Hex = "16" ;
 
    public static final byte lenHead2ctrl = 4 ; //从头到控制域(不包括)字节数组长度
    public static final byte lenHead2Code = 11 ; //从头到功能码(包括)字节数组长度
    public static final byte lenTail = 2 ; //帧尾部字节数组长度
    public static final byte lenCtrl = 1 ; //控制域字节数组长度
    public static final byte lenRtuAddr = 5 ; //控制器地址字节数组长度
    /**
     * 所在字节数组的位置(下标)
     */
    public static final int headFlag1Index = 0 ;//帧头68H所在 字节数组起始下标
    public static final int headFlag2Index = 3 ;//帧头68H所在 字节数组起始下标
    public static final int dataLenIndex = 1 ;//帧长度所在 字节数组起始下标
    public static final int versionIndex = 2 ;//版本号所在 字节数组起始下标
    public static final int ctrlIndex = 4 ;//控制域所在 字节数组起始下标
    public static final int rtuAddr1Index_start = 5 ;//控制器地址 字节数组开始下标
    public static final int rtuAddr1Index_end = 7 ;//控制器地址 字节数组开始下标
    public static final int rtuAddr2Index_start = 8 ;//控制器地址 字节数组截止下标
    public static final int rtuAddr2Index_end = 9 ;//控制器地址 字节数组截止下标
    public static final int codeIndex = 10 ;//功能码字节数组下标
    public static final int dataIndex = 11 ;//具体数据字节数组下标
 
    public static final String vsCardAddr = "00000000";//本系统应用的虚拟卡,卡物理地址采用8个0作为模拟
 
    ////////////////////////////////////////////////
    //
    //远程升级相关
    //
    ////////////////////////////////////////////////
    public static final byte UG_P_Head_Byte = (byte)0xAA ;
    public static final byte UG_P_Tail_Byte = (byte)0x16 ;
    public static final int UG_codeIndex = 4 ;//功能码字节数组下标
    public static final int UG_dataIndex = 12 ;//具体数据字节数组下标
 
    public static final int UG_dataLenIndex_start = 1 ;//帧长度开始所在 字节数组起始下标
    public static final int UG_dataLenIndex_end = 2 ;//帧长度结束所在 字节数组起始下标
 
    public static final int UG_rtuAddrIndex_start = 6 ;//控制器地址 字节数组开始下标
    public static final int UG_rtuAddrIndex_end = 11 ;//控制器地址 字节数组开始下标
 
    public static final byte UG_lenCmd = 2 ; //功能码字节数组长度
    public static final byte UG_lenRtuAddr = 6 ; //功能码字节数组长度
    public static final byte UG_lenHead2Cmd = 4 ; //从头到功能码(不包括)字节数组长度
    public static final byte UG_lenTail = 3 ; //帧尾部字节数组长度
    public static final byte UG_lenHead2RtuAddr = 12 ; //从头到RTU地址(包括)字节数组长度
 
}