1078-查询区域或线路数据应答...

This commit is contained in:
648540858
2024-05-06 18:00:26 +08:00
parent 364d613ccb
commit 2112fffc26
12 changed files with 162 additions and 62 deletions

View File

@@ -80,6 +80,22 @@ public class JTAreaAttribute {
return byteBuf;
}
public static JTAreaAttribute decode(int attributeInt) {
JTAreaAttribute attribute = new JTAreaAttribute();
attribute.setRuleForTimeLimit((attributeInt & 1) == 1);
attribute.setRuleForSpeedLimit((attributeInt >> 1 & 1) == 1);
attribute.setRuleForAlarmToDriverWhenEnter((attributeInt >> 2 & 1) == 1);
attribute.setRuleForAlarmToPlatformWhenEnter((attributeInt >> 3 & 1) == 1);
attribute.setRuleForAlarmToDriverWhenExit((attributeInt >> 4 & 1) == 1);
attribute.setRuleForAlarmToPlatformWhenExit((attributeInt >> 5 & 1) == 1);
attribute.setSouthLatitude((attributeInt >> 6 & 1) == 1);
attribute.setWestLongitude((attributeInt >> 7 & 1) == 1);
attribute.setProhibitOpeningDoors((attributeInt >> 8 & 1) == 1);
attribute.setRuleForTurnOffCommunicationWhenEnter((attributeInt >> 9 & 1) == 1);
attribute.setRuleForGnssWhenEnter((attributeInt >> 10 & 1) == 1);
return attribute;
}
public boolean isRuleForTimeLimit() {
return ruleForTimeLimit;
}

View File

@@ -52,8 +52,8 @@ public class JTCircleArea implements JTAreaOrRoute{
byteBuf.writeInt((int) (Math.round((latitude * 1000000)) & 0xffffffffL));
byteBuf.writeInt((int) (Math.round((longitude * 1000000)) & 0xffffffffL));
byteBuf.writeInt((int) (radius & 0xffffffffL));
byteBuf.writeBytes(BCDUtil.transform(DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(startTime)));
byteBuf.writeBytes(BCDUtil.transform(DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(endTime)));
byteBuf.writeBytes(BCDUtil.strToBcd(DateUtil.yyyy_MM_dd_HH_mm_ssTo1078(startTime)));
byteBuf.writeBytes(BCDUtil.strToBcd(DateUtil.yyyy_MM_dd_HH_mm_ssTo1078(endTime)));
byteBuf.writeShort((short)(maxSpeed & 0xffff));
byteBuf.writeByte(overSpeedDuration);
byteBuf.writeShort((short)(nighttimeMaxSpeed & 0xffff));

View File

@@ -43,8 +43,8 @@ public class JTPolygonArea implements JTAreaOrRoute{
ByteBuf byteBuf = Unpooled.buffer();
byteBuf.writeInt((int) (id & 0xffffffffL));
byteBuf.writeBytes(attribute.encode());
byteBuf.writeBytes(BCDUtil.transform(DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(startTime)));
byteBuf.writeBytes(BCDUtil.transform(DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(endTime)));
byteBuf.writeBytes(BCDUtil.strToBcd(DateUtil.yyyy_MM_dd_HH_mm_ssTo1078(startTime)));
byteBuf.writeBytes(BCDUtil.strToBcd(DateUtil.yyyy_MM_dd_HH_mm_ssTo1078(endTime)));
byteBuf.writeShort((short)(maxSpeed & 0xffff));
byteBuf.writeByte(overSpeedDuration);

View File

@@ -47,16 +47,17 @@ public class JTRectangleArea implements JTAreaOrRoute{
@Schema(description = "区域的名称")
private String name;
public ByteBuf encode(){
public ByteBuf encode(){
ByteBuf byteBuf = Unpooled.buffer();
byteBuf.writeInt((int) (id & 0xffffffffL));
byteBuf.writeBytes(attribute.encode());
byteBuf.writeInt((int) (Math.round((latitudeForUpperLeft * 1000000)) & 0xffffffffL));
byteBuf.writeInt((int) (Math.round((longitudeForLowerRight * 1000000)) & 0xffffffffL));
byteBuf.writeInt((int) (Math.round((longitudeForUpperLeft * 1000000)) & 0xffffffffL));
byteBuf.writeInt((int) (Math.round((latitudeForLowerRight * 1000000)) & 0xffffffffL));
byteBuf.writeInt((int) (Math.round((longitudeForLowerRight * 1000000)) & 0xffffffffL));
byteBuf.writeBytes(BCDUtil.transform(DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(startTime)));
byteBuf.writeBytes(BCDUtil.transform(DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(endTime)));
byteBuf.writeBytes(BCDUtil.strToBcd(DateUtil.yyyy_MM_dd_HH_mm_ssTo1078(startTime)));
byteBuf.writeBytes(BCDUtil.strToBcd(DateUtil.yyyy_MM_dd_HH_mm_ssTo1078(endTime)));
byteBuf.writeShort((short)(maxSpeed & 0xffff));
byteBuf.writeByte(overSpeedDuration);
byteBuf.writeShort((short)(nighttimeMaxSpeed & 0xffff));
@@ -65,6 +66,30 @@ public class JTRectangleArea implements JTAreaOrRoute{
return byteBuf;
}
public static JTRectangleArea decode(ByteBuf buf) {
JTRectangleArea area = new JTRectangleArea();
area.setId(buf.readUnsignedInt());
int attributeInt = buf.readUnsignedShort();
JTAreaAttribute areaAttribute = JTAreaAttribute.decode(attributeInt);
area.setAttribute(areaAttribute);
area.setLatitudeForUpperLeft(buf.readUnsignedInt()/1000000D);
area.setLongitudeForUpperLeft(buf.readUnsignedInt()/1000000D);
area.setLatitudeForLowerRight(buf.readUnsignedInt()/1000000D);
area.setLongitudeForLowerRight(buf.readUnsignedInt()/1000000D);
byte[] startTimeBytes = new byte[6];
buf.readBytes(startTimeBytes);
area.setStartTime(DateUtil.jt1078Toyyyy_MM_dd_HH_mm_ss(BCDUtil.transform(startTimeBytes)));
byte[] endTimeBytes = new byte[6];
buf.readBytes(endTimeBytes);
area.setEndTime(DateUtil.jt1078Toyyyy_MM_dd_HH_mm_ss(BCDUtil.transform(endTimeBytes)));
area.setMaxSpeed(buf.readUnsignedShort());
area.setOverSpeedDuration(buf.readUnsignedByte());
area.setNighttimeMaxSpeed(buf.readUnsignedShort());
int nameLength = buf.readUnsignedShort();
area.setName(buf.readCharSequence(nameLength, Charset.forName("GBK")).toString().trim());
return area;
}
public long getId() {
return id;
}