|  |  |  | 
|---|
|  |  |  | package com.dy.common.mw.protocol.p206V1; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.dy.common.mw.channel.tcp.TcpIoSessionAttrIdIsRtuAddr; | 
|---|
|  |  |  | import com.dy.common.util.ByteUtil; | 
|---|
|  |  |  | import com.dy.common.util.ByteUtilUnsigned; | 
|---|
|  |  |  | import com.dy.common.util.CRC16; | 
|---|
|  |  |  | import com.dy.common.util.CRC8_for_2_0; | 
|---|
|  |  |  | import org.apache.mina.core.session.IoSession; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public class CommonV1 { | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 检查头 | 
|---|
|  |  |  | * @param bs 上行字节数组 | 
|---|
|  |  |  | * @return [rt1->true:是本协议P206,false:不是本协议;  rt2->true:是水资源协议,false:是升级协议] | 
|---|
|  |  |  | * @return [【0】->true:是本协议P206,false:不是本协议;  【1】->true:是水资源协议,false:是升级协议] | 
|---|
|  |  |  | * @throws Exception  异常 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public Boolean[] isThisProtocolHead(byte[] bs) throws Exception{ | 
|---|
|  |  |  | 
|---|
|  |  |  | return "计算CRC是:" + crcCompute + ",上传CRC是" + crcInBs ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | int crcCompute = (byte)new CRC16().CRC(bs, ProtocolConstantV206V1.ctrlIndex, bs.length - 3) ; | 
|---|
|  |  |  | int crcInBs = ByteUtilUnsigned.bytes2Short_BE(bs, bs.length - 3) ; | 
|---|
|  |  |  | short crcCompute = new CRC16().CRC(bs, 0, bs.length - 4) ; | 
|---|
|  |  |  | short crcInBs = ByteUtil.bytes2Short_BE(bs,bs.length - 3) ; | 
|---|
|  |  |  | //int crcInBs = ByteUtilUnsigned.bytes2Short_BE(bs, bs.length - 3) ; | 
|---|
|  |  |  | if(crcCompute == crcInBs){ | 
|---|
|  |  |  | return null ; | 
|---|
|  |  |  | }else{ | 
|---|