1078-设置路线
This commit is contained in:
@@ -42,41 +42,41 @@ public class JTAreaAttribute {
|
|||||||
|
|
||||||
public ByteBuf encode(){
|
public ByteBuf encode(){
|
||||||
ByteBuf byteBuf = Unpooled.buffer();
|
ByteBuf byteBuf = Unpooled.buffer();
|
||||||
byte[] bytes = new byte[2];
|
short content = 0 ;
|
||||||
if (ruleForTimeLimit) {
|
if (ruleForTimeLimit) {
|
||||||
bytes[0] |= 1;
|
content |= 1;
|
||||||
}
|
}
|
||||||
if (ruleForSpeedLimit) {
|
if (ruleForSpeedLimit) {
|
||||||
bytes[0] |= (1 << 1);
|
content |= (1 << 1);
|
||||||
}
|
}
|
||||||
if (ruleForAlarmToDriverWhenEnter) {
|
if (ruleForAlarmToDriverWhenEnter) {
|
||||||
bytes[0] |= (1 << 2);
|
content |= (1 << 2);
|
||||||
}
|
}
|
||||||
if (ruleForAlarmToPlatformWhenEnter) {
|
if (ruleForAlarmToPlatformWhenEnter) {
|
||||||
bytes[0] |= (1 << 3);
|
content |= (1 << 3);
|
||||||
}
|
}
|
||||||
if (ruleForAlarmToDriverWhenExit) {
|
if (ruleForAlarmToDriverWhenExit) {
|
||||||
bytes[0] |= (1 << 4);
|
content |= (1 << 4);
|
||||||
}
|
}
|
||||||
if (ruleForAlarmToPlatformWhenExit) {
|
if (ruleForAlarmToPlatformWhenExit) {
|
||||||
bytes[0] |= (1 << 5);
|
content |= (1 << 5);
|
||||||
}
|
}
|
||||||
if (southLatitude) {
|
if (southLatitude) {
|
||||||
bytes[0] |= (1 << 6);
|
content |= (1 << 6);
|
||||||
}
|
}
|
||||||
if (westLongitude) {
|
if (westLongitude) {
|
||||||
bytes[0] |= (byte) (1 << 7);
|
content |= (byte) (1 << 7);
|
||||||
}
|
}
|
||||||
if (prohibitOpeningDoors) {
|
if (prohibitOpeningDoors) {
|
||||||
bytes[1] |= 1;
|
content |= (1 << (0 + 8));
|
||||||
}
|
}
|
||||||
if (ruleForTurnOffCommunicationWhenEnter) {
|
if (ruleForTurnOffCommunicationWhenEnter) {
|
||||||
bytes[1] |= (1 << 1);
|
content |= (1 << (1 + 8));
|
||||||
}
|
}
|
||||||
if (ruleForGnssWhenEnter) {
|
if (ruleForGnssWhenEnter) {
|
||||||
bytes[1] |= (1 << 2);
|
content |= (1 << (2 + 8));
|
||||||
}
|
}
|
||||||
byteBuf.writeBytes(bytes);
|
byteBuf.writeShort((short)(content & 0xffff));
|
||||||
return byteBuf;
|
return byteBuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,8 +34,8 @@ public class JTRoute implements JTAreaOrRoute{
|
|||||||
ByteBuf byteBuf = Unpooled.buffer();
|
ByteBuf byteBuf = Unpooled.buffer();
|
||||||
byteBuf.writeInt((int) (id & 0xffffffffL));
|
byteBuf.writeInt((int) (id & 0xffffffffL));
|
||||||
byteBuf.writeBytes(attribute.encode());
|
byteBuf.writeBytes(attribute.encode());
|
||||||
byteBuf.writeBytes(BCDUtil.transform(DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(startTime)));
|
byteBuf.writeBytes(BCDUtil.strToBcd(DateUtil.yyyy_MM_dd_HH_mm_ssTo1078(startTime)));
|
||||||
byteBuf.writeBytes(BCDUtil.transform(DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(endTime)));
|
byteBuf.writeBytes(BCDUtil.strToBcd(DateUtil.yyyy_MM_dd_HH_mm_ssTo1078(endTime)));
|
||||||
byteBuf.writeShort((short)(routePointList.size() & 0xffff));
|
byteBuf.writeShort((short)(routePointList.size() & 0xffff));
|
||||||
if (!routePointList.isEmpty()){
|
if (!routePointList.isEmpty()){
|
||||||
for (JTRoutePoint jtRoutePoint : routePointList) {
|
for (JTRoutePoint jtRoutePoint : routePointList) {
|
||||||
|
|||||||
@@ -24,23 +24,23 @@ public class JTRouteAttribute {
|
|||||||
|
|
||||||
public ByteBuf encode(){
|
public ByteBuf encode(){
|
||||||
ByteBuf byteBuf = Unpooled.buffer();
|
ByteBuf byteBuf = Unpooled.buffer();
|
||||||
byte[] bytes = new byte[2];
|
short content = 0;
|
||||||
if (ruleForTimeLimit) {
|
if (ruleForTimeLimit) {
|
||||||
bytes[0] |= 1;
|
content |= 1;
|
||||||
}
|
}
|
||||||
if (ruleForAlarmToDriverWhenEnter) {
|
if (ruleForAlarmToDriverWhenEnter) {
|
||||||
bytes[0] |= (1 << 2);
|
content |= (1 << 2);
|
||||||
}
|
}
|
||||||
if (ruleForAlarmToPlatformWhenEnter) {
|
if (ruleForAlarmToPlatformWhenEnter) {
|
||||||
bytes[0] |= (1 << 3);
|
content |= (1 << 3);
|
||||||
}
|
}
|
||||||
if (ruleForAlarmToDriverWhenExit) {
|
if (ruleForAlarmToDriverWhenExit) {
|
||||||
bytes[0] |= (1 << 4);
|
content |= (1 << 4);
|
||||||
}
|
}
|
||||||
if (ruleForAlarmToPlatformWhenExit) {
|
if (ruleForAlarmToPlatformWhenExit) {
|
||||||
bytes[0] |= (1 << 5);
|
content |= (1 << 5);
|
||||||
}
|
}
|
||||||
byteBuf.writeBytes(bytes);
|
byteBuf.writeShort((short)(content & 0xffff));
|
||||||
return byteBuf;
|
return byteBuf;
|
||||||
}
|
}
|
||||||
public boolean isRuleForTimeLimit() {
|
public boolean isRuleForTimeLimit() {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.jt1078.util;
|
|||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
|
import org.springframework.security.crypto.codec.Hex;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
@@ -27,6 +28,48 @@ public class BCDUtil {
|
|||||||
return stringBuffer.toString();
|
return stringBuffer.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字符串转BCD码
|
||||||
|
* 来自: https://www.cnblogs.com/ranandrun/p/BCD.html
|
||||||
|
* @param asc ASCII字符串
|
||||||
|
* @return BCD
|
||||||
|
*/
|
||||||
|
public static byte[] strToBcd(String asc) {
|
||||||
|
int len = asc.length();
|
||||||
|
int mod = len % 2;
|
||||||
|
if (mod != 0) {
|
||||||
|
asc = "0" + asc;
|
||||||
|
len = asc.length();
|
||||||
|
}
|
||||||
|
byte abt[] = new byte[len];
|
||||||
|
if (len >= 2) {
|
||||||
|
len >>= 1;
|
||||||
|
}
|
||||||
|
byte bbt[] = new byte[len];
|
||||||
|
abt = asc.getBytes();
|
||||||
|
int j, k;
|
||||||
|
for (int p = 0; p < asc.length() / 2; p++) {
|
||||||
|
if ((abt[2 * p] >= '0') && (abt[2 * p] <= '9')) {
|
||||||
|
j = abt[2 * p] - '0';
|
||||||
|
} else if ((abt[2 * p] >= 'a') && (abt[2 * p] <= 'z')) {
|
||||||
|
j = abt[2 * p] - 'a' + 0x0a;
|
||||||
|
} else {
|
||||||
|
j = abt[2 * p] - 'A' + 0x0a;
|
||||||
|
}
|
||||||
|
if ((abt[2 * p + 1] >= '0') && (abt[2 * p + 1] <= '9')) {
|
||||||
|
k = abt[2 * p + 1] - '0';
|
||||||
|
} else if ((abt[2 * p + 1] >= 'a') && (abt[2 * p + 1] <= 'z')) {
|
||||||
|
k = abt[2 * p + 1] - 'a' + 0x0a;
|
||||||
|
} else {
|
||||||
|
k = abt[2 * p + 1] - 'A' + 0x0a;
|
||||||
|
}
|
||||||
|
int a = (j << 4) + k;
|
||||||
|
byte b = (byte) a;
|
||||||
|
bbt[p] = b;
|
||||||
|
}
|
||||||
|
return bbt;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 时间使用按照YY-MM-DD-hh-mm-ss,转换为byte数据
|
* 时间使用按照YY-MM-DD-hh-mm-ss,转换为byte数据
|
||||||
*/
|
*/
|
||||||
@@ -40,6 +83,12 @@ public class BCDUtil {
|
|||||||
int hour = calendar.get(Calendar.HOUR_OF_DAY);
|
int hour = calendar.get(Calendar.HOUR_OF_DAY);
|
||||||
int minute = calendar.get(Calendar.MINUTE);
|
int minute = calendar.get(Calendar.MINUTE);
|
||||||
int second = calendar.get(Calendar.SECOND);
|
int second = calendar.get(Calendar.SECOND);
|
||||||
|
System.out.println("year== " + year);
|
||||||
|
System.out.println("month== " + month);
|
||||||
|
System.out.println("day== " + day);
|
||||||
|
System.out.println("hour== " + hour);
|
||||||
|
System.out.println("minute== " + minute);
|
||||||
|
System.out.println("second== " + second);
|
||||||
byteBuf.writeByte(year);
|
byteBuf.writeByte(year);
|
||||||
byteBuf.writeByte(month);
|
byteBuf.writeByte(month);
|
||||||
byteBuf.writeByte(day);
|
byteBuf.writeByte(day);
|
||||||
|
|||||||
Reference in New Issue
Block a user