优化统计消息
This commit is contained in:
parent
97acf5442c
commit
0206d6c097
@ -33,8 +33,6 @@ public class D331RtcmMessageExecutor implements Executor<D331RtcmMessage, Void>
|
|||||||
// 补齐tenantId
|
// 补齐tenantId
|
||||||
Device device1 = deviceService.findByDeviceId(id);
|
Device device1 = deviceService.findByDeviceId(id);
|
||||||
if(device1 == null || device1.getOpMode() == GnssDevice.OP_MODE_UNUSE) return null;
|
if(device1 == null || device1.getOpMode() == GnssDevice.OP_MODE_UNUSE) return null;
|
||||||
message.setTenantId(device1.getTenantId());
|
|
||||||
device1.updateD331Bytes(message.getLen());
|
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("receive d331 rtcm message of device: "+message.getId()+", seq:"+message.getSeq()+", len:"+message.getLen());
|
logger.debug("receive d331 rtcm message of device: "+message.getId()+", seq:"+message.getSeq()+", len:"+message.getLen());
|
||||||
}
|
}
|
||||||
@ -57,6 +55,8 @@ public class D331RtcmMessageExecutor implements Executor<D331RtcmMessage, Void>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message.setTenantId(device1.getTenantId());
|
||||||
|
device1.updateD331Bytes(message.getLen(),message.getPacketNum());
|
||||||
Gga gga = message.getGga();
|
Gga gga = message.getGga();
|
||||||
if(gga != null) {
|
if(gga != null) {
|
||||||
device1.updateSatelitesNum(gga.getSatellitesInUsed());
|
device1.updateSatelitesNum(gga.getSatellitesInUsed());
|
||||||
|
|||||||
@ -49,8 +49,10 @@ public class D3F2StopIndicationMessageExecutor implements Executor<D3F2StopIndic
|
|||||||
if(device == null) return null;
|
if(device == null) return null;
|
||||||
message.setTenantId(device.getTenantId());
|
message.setTenantId(device.getTenantId());
|
||||||
GnssTrxMsg gnssTrxMsg = message.getTrxMsg();
|
GnssTrxMsg gnssTrxMsg = message.getTrxMsg();
|
||||||
|
gnssTrxMsg.setTenantid(device.getTenantId());
|
||||||
gnssTrxMsg.setD3xxbytes(device.getD3xxbytes());
|
gnssTrxMsg.setD3xxbytes(device.getD3xxbytes());
|
||||||
gnssTrxMsg.setB562bytes(device.getD341bytes());
|
gnssTrxMsg.setB562bytes(device.getD341bytes());
|
||||||
|
gnssTrxMsg.setSatelliteinuse(device.getSatelitesInUse());
|
||||||
|
|
||||||
// 储设备收发字节数统计信息
|
// 储设备收发字节数统计信息
|
||||||
ThreadManager.getFixedThreadPool().submit(() -> {
|
ThreadManager.getFixedThreadPool().submit(() -> {
|
||||||
|
|||||||
@ -26,12 +26,12 @@ public abstract class BaseMessage {
|
|||||||
this.createTime = LocalDateTime.now();
|
this.createTime = LocalDateTime.now();
|
||||||
if (shouldDecodeHeader()) {
|
if (shouldDecodeHeader()) {
|
||||||
// read操作会移动ByteBuf内部指针,除D331外,其他都用read来读
|
// read操作会移动ByteBuf内部指针,除D331外,其他都用read来读
|
||||||
int packetLen = src.readableBytes();
|
//int packetLen = src.readableBytes();
|
||||||
this.header = src.readUnsignedShort();
|
this.header = src.readUnsignedShort();
|
||||||
|
|
||||||
this.len = src.readUnsignedShort();
|
this.len = src.readUnsignedShort();
|
||||||
this.seq = this.len >> 11;
|
this.seq = this.len >> 11;
|
||||||
this.len = packetLen;//this.len & 0x7FF;
|
this.len = this.len & 0x7FF;
|
||||||
this.id = String.valueOf(src.readUnsignedInt());
|
this.id = String.valueOf(src.readUnsignedInt());
|
||||||
/*if (packetLen - 4 != this.len) {
|
/*if (packetLen - 4 != this.len) {
|
||||||
String msg = (String.format("id[%s],长度字段值[%s]与包的消息体长度[%s]不匹配", id, this.len, packetLen - 4));
|
String msg = (String.format("id[%s],长度字段值[%s]与包的消息体长度[%s]不匹配", id, this.len, packetLen - 4));
|
||||||
|
|||||||
@ -2,22 +2,38 @@ package com.imdroid.sideslope.message;
|
|||||||
|
|
||||||
import com.imdroid.sideslope.bd.Gga;
|
import com.imdroid.sideslope.bd.Gga;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Layton
|
* @author Layton
|
||||||
* @date 2023/2/2 20:47
|
* @date 2023/2/2 20:47
|
||||||
*/
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper=true)
|
||||||
public class D331RtcmMessage extends BaseMessage {
|
public class D331RtcmMessage extends BaseMessage {
|
||||||
Gga gga;
|
Gga gga;
|
||||||
|
int packetNum;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void decodeBody(ByteBuf src) {
|
public void decodeBody(ByteBuf src) {
|
||||||
// get操作不会移动指针,这样可以确保整个全转发出去
|
// get操作不会移动指针,这样可以确保整个全转发出去
|
||||||
this.header = src.getUnsignedShort(0); // flag
|
this.packetNum = 1;
|
||||||
this.len = src.getUnsignedShort(2); // length:11 bits
|
|
||||||
this.seq = this.len >> 11;
|
|
||||||
this.len = src.readableBytes();//this.len & 0x7FF;//有可能两个d331粘包
|
this.len = src.readableBytes();//this.len & 0x7FF;//有可能两个d331粘包
|
||||||
|
this.header = src.getUnsignedShort(0); // flag
|
||||||
|
int onePacketLen = src.getUnsignedShort(2); // length:11 bits
|
||||||
|
this.seq = onePacketLen >> 11;
|
||||||
|
onePacketLen = onePacketLen&0x7FF;
|
||||||
this.id = String.valueOf(src.getUnsignedInt(4)); //id
|
this.id = String.valueOf(src.getUnsignedInt(4)); //id
|
||||||
|
int pos = onePacketLen + 4;
|
||||||
|
while(pos < this.len){
|
||||||
|
if(src.getUnsignedShort(pos) == 0xd331){
|
||||||
|
onePacketLen = src.getUnsignedShort(pos+2)&0x7FF;
|
||||||
|
pos = pos+4+onePacketLen;
|
||||||
|
packetNum ++;
|
||||||
|
}
|
||||||
|
else pos++;
|
||||||
|
}
|
||||||
/*if (src.readableBytes() - 4 < this.len) {
|
/*if (src.readableBytes() - 4 < this.len) {
|
||||||
String msg = String.format("id[%s],长度字段值[%s]效益包的消息体长度[%s]", id, this.len, src.readableBytes() - 4);
|
String msg = String.format("id[%s],长度字段值[%s]效益包的消息体长度[%s]", id, this.len, src.readableBytes() - 4);
|
||||||
WrongMessageRecorder.INSTANCE.append("receive wrong message," + msg);
|
WrongMessageRecorder.INSTANCE.append("receive wrong message," + msg);
|
||||||
@ -31,6 +47,4 @@ public class D331RtcmMessage extends BaseMessage {
|
|||||||
public boolean shouldDecodeHeader() {
|
public boolean shouldDecodeHeader() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Gga getGga() {return gga;}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,12 +20,12 @@ public class D341LocationMessage extends BaseMessage {
|
|||||||
@Override
|
@Override
|
||||||
public void decodeBody(ByteBuf src) {
|
public void decodeBody(ByteBuf src) {
|
||||||
// read操作会移动ByteBuf内部指针,除D331外,其他都用read来读
|
// read操作会移动ByteBuf内部指针,除D331外,其他都用read来读
|
||||||
int packetLen = src.readableBytes();
|
//int packetLen = src.readableBytes();
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
this.header = src.getUnsignedShort(pos);pos+=2;
|
this.header = src.getUnsignedShort(pos);pos+=2;
|
||||||
this.len = src.getUnsignedShort(pos);pos+=2;
|
this.len = src.getUnsignedShort(pos);pos+=2;
|
||||||
this.seq = this.len >> 11;
|
this.seq = this.len >> 11;
|
||||||
this.len = packetLen;//this.len & 0x7FF;
|
this.len = this.len & 0x7FF;
|
||||||
this.id = String.valueOf(src.getUnsignedInt(pos));pos+=4; //id
|
this.id = String.valueOf(src.getUnsignedInt(pos));pos+=4; //id
|
||||||
/*if (packetLen - 4 != this.len) {
|
/*if (packetLen - 4 != this.len) {
|
||||||
String msg = (String.format("id[%s],长度字段值[%s]与包的消息体长度[%s]不匹配", id, this.len, packetLen - 4));
|
String msg = (String.format("id[%s],长度字段值[%s]与包的消息体长度[%s]不匹配", id, this.len, packetLen - 4));
|
||||||
|
|||||||
@ -17,6 +17,7 @@ import java.time.LocalTime;
|
|||||||
public class D3F2StopIndicationMessage extends BaseMessage {
|
public class D3F2StopIndicationMessage extends BaseMessage {
|
||||||
|
|
||||||
private GnssTrxMsg trxMsg = new GnssTrxMsg();
|
private GnssTrxMsg trxMsg = new GnssTrxMsg();
|
||||||
|
private String otherInfo;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void decodeBody(ByteBuf src) {
|
public void decodeBody(ByteBuf src) {
|
||||||
@ -39,7 +40,17 @@ public class D3F2StopIndicationMessage extends BaseMessage {
|
|||||||
trxMsg.setUart2rxbytes((int) value);
|
trxMsg.setUart2rxbytes((int) value);
|
||||||
} else if (key == 5) {
|
} else if (key == 5) {
|
||||||
trxMsg.setUart2unknown((int) value);
|
trxMsg.setUart2unknown((int) value);
|
||||||
|
}else if (key == 6) {//粘包
|
||||||
|
otherInfo = "stick num:"+value;
|
||||||
|
//trxMsg.setUart2unknown((int) value);
|
||||||
|
}else if (key == 7) {//分片
|
||||||
|
otherInfo = otherInfo + ", frag num:"+value;
|
||||||
|
//trxMsg.setUart2unknown((int) value);
|
||||||
|
}else if (key == 8) {//其他错误
|
||||||
|
otherInfo = otherInfo + ", other err:"+value;
|
||||||
|
//trxMsg.setUart2unknown((int) value);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -39,14 +39,15 @@ public class Device {
|
|||||||
int d3xxbytes = 0;
|
int d3xxbytes = 0;
|
||||||
int d341Count = 0;
|
int d341Count = 0;
|
||||||
int d341bytes = 0;
|
int d341bytes = 0;
|
||||||
int satelitesInUse = 0;
|
int satelitesInUse = 0;//平均卫星数
|
||||||
|
int sataStatCount = 0;
|
||||||
|
|
||||||
Double latitude;
|
Double latitude;
|
||||||
Double longitude;
|
Double longitude;
|
||||||
Double altitude;
|
Double altitude;
|
||||||
|
|
||||||
public void updateD331Bytes(int bytes){
|
public void updateD331Bytes(int bytes,int count){
|
||||||
d3xxCount++;
|
d3xxCount+=count;
|
||||||
d3xxbytes += bytes;
|
d3xxbytes += bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,7 +57,10 @@ public class Device {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updateSatelitesNum(int num){
|
public void updateSatelitesNum(int num){
|
||||||
satelitesInUse = num;
|
if(num>0) {
|
||||||
|
sataStatCount++;
|
||||||
|
satelitesInUse = (satelitesInUse*(sataStatCount-1) + num) / sataStatCount;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearStat(){
|
public void clearStat(){
|
||||||
@ -64,6 +68,8 @@ public class Device {
|
|||||||
d3xxbytes = 0;
|
d3xxbytes = 0;
|
||||||
d341Count = 0;
|
d341Count = 0;
|
||||||
d341bytes = 0;
|
d341bytes = 0;
|
||||||
|
sataStatCount = 0;
|
||||||
|
satelitesInUse = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -91,11 +91,14 @@ public class DataPersistServiceImpl implements DataPersistService {
|
|||||||
try {
|
try {
|
||||||
// 添加到trxmsg里
|
// 添加到trxmsg里
|
||||||
GnssTrxMsg trxMsg = message.getTrxMsg();
|
GnssTrxMsg trxMsg = message.getTrxMsg();
|
||||||
trxMsg.setTenantid(message.getTenantId());
|
|
||||||
trxMsg.setSatelliteinuse(device.getSatelitesInUse());
|
|
||||||
trxMsgMapper.insert(trxMsg);
|
trxMsgMapper.insert(trxMsg);
|
||||||
// 保存消息摘要
|
// 保存消息摘要
|
||||||
saveMsg(message,null);
|
if(device.getDeviceType() == GnssDevice.TYPE_ROVER) {
|
||||||
|
saveMsg(message, "d341 num: "+device.getD341Count()+","+message.getOtherInfo());
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
saveMsg(message, "d331 num: "+device.getD3xxCount()+","+message.getOtherInfo());
|
||||||
|
}
|
||||||
|
|
||||||
// 检测该对象是否已存在
|
// 检测该对象是否已存在
|
||||||
GnssStatus deviceState = deviceStateRepository.getByDeviceId(message.getId());
|
GnssStatus deviceState = deviceStateRepository.getByDeviceId(message.getId());
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user