1、d341/d331里判断如果超过30分钟没有收到d3f0/f2,则做状态和统计更新

2、SingleCalc对象里不做固定解告警判断,统一在d3f2和d341里做
This commit is contained in:
weidong 2024-05-12 14:34:35 +08:00
parent 3913bc1ed7
commit b60982c4f1
8 changed files with 75 additions and 52 deletions

View File

@ -244,8 +244,8 @@ public class SingleLineGNSSCalcService implements GNSSDataCalcService {
}
// 检查b562有效数如果过少产生告警
warningService.checkB562Num(deviceId, tenantId, focusCalculator.getB562Stat());
// 检查b562有效数如果过少产生告警改到d341Executor检查
//warningService.checkB562Num(deviceId, tenantId, focusCalculator.getB562Stat());
focusCalculator.reset();
}

View File

@ -7,7 +7,6 @@ import com.imdroid.sideslope.bd.Gga;
import com.imdroid.sideslope.message.D331RtcmMessage;
import com.imdroid.sideslope.sal.Device;
import com.imdroid.sideslope.sal.DeviceService;
import com.imdroid.sideslope.server.DeviceChannel;
import com.imdroid.sideslope.server.OnlineChannels;
import com.imdroid.sideslope.service.DataPersistService;
import io.netty.buffer.ByteBuf;
@ -45,7 +44,7 @@ public class D331RtcmMessageExecutor implements Executor<D331RtcmMessage, Void>
if (logger.isDebugEnabled()) {
logger.debug("receive d331 rtcm message of device: "+message.getId()+", seq:"+message.getSeq()+", len:"+message.getLen());
}
// 推送基站数据
if(device1.getOpMode() == GnssDevice.OP_MODE_USE) {
byte[] forwardBytes = message.getSrcData();
// 要求快速转发因此用缓存不要每次都查数据库
@ -67,29 +66,21 @@ public class D331RtcmMessageExecutor implements Executor<D331RtcmMessage, Void>
}
}
// trx stat
message.setTenantId(device1.getTenantId());
LocalDateTime lastTime = device1.getLastRxTime();
Device lastCycleDevice;
if(LocalDateTime.now().isAfter(lastTime.plusMinutes(1))){
// new cycle
lastCycleDevice = new Device();
lastCycleDevice.setDeviceId(device1.getDeviceId());
lastCycleDevice.setTenantId(device1.getTenantId());
lastCycleDevice.setD3xxbytes(device1.getD3xxbytes());
lastCycleDevice.setD341Count(device1.getD341Count());
lastCycleDevice.setLastRxTime(device1.getLastRxTime());
lastCycleDevice.setSatelitesInUse(device1.getSatelitesInUse());
device1.clearStat();
} else {
lastCycleDevice = null;
}
// 如果控制通道没连接则收到不到d3f0和d3f2则根据UDP最后一个报文触发状态更新和统计
// 测站的更新和统计放在解算之后进行因为要统计固定解浮点解等信息
if(lastCycleDevice != null){
DeviceChannel channel = OnlineChannels.INSTANCE.getConfigChannel(device1.getDeviceId());
if(channel == null || !channel.isOnline()){
// 如果30分钟内收到不到d3f0和d3f2则根据UDP最后一个报文触发状态更新和统计
LocalDateTime now = LocalDateTime.now();
if(device1.getLastRxTime()!=null &&
device1.getLastRxTime().isBefore(now.minusMinutes(1))){
if(device1.getLastD3f0f2Time() == null ||
device1.getLastD3f0f2Time().isBefore(now.minusMinutes(30))) {
// new cycle
Device lastCycleDevice = new Device();
lastCycleDevice.setDeviceId(device1.getDeviceId());
lastCycleDevice.setTenantId(device1.getTenantId());
lastCycleDevice.setD3xxbytes(device1.getD3xxbytes());
lastCycleDevice.setD3xxCount(device1.getD3xxCount());
lastCycleDevice.setLastRxTime(device1.getLastRxTime());
lastCycleDevice.setSatelitesInUse(device1.getSatelitesInUse());
device1.clearStat();
ThreadManager.getFixedThreadPool().submit(() -> {
// 通知上线
try {
@ -102,6 +93,7 @@ public class D331RtcmMessageExecutor implements Executor<D331RtcmMessage, Void>
}
}
// update trx
device1.updateRx(message.getHeader(),message.getLen(),message.getPacketNum());
// update gga
Gga gga = message.getGga();

View File

@ -7,14 +7,14 @@ import com.imdroid.sideslope.message.D341LocationMessage;
import com.imdroid.sideslope.sal.Device;
import com.imdroid.sideslope.sal.DeviceService;
import com.imdroid.common.util.ThreadManager;
import com.imdroid.sideslope.server.DeviceChannel;
import com.imdroid.sideslope.server.OnlineChannels;
import com.imdroid.sideslope.service.DataPersistService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.time.LocalDateTime;
/**
* @author Layton
@ -31,6 +31,8 @@ public class D341LocationMessageExecutor implements Executor<D341LocationMessage
private DeviceService deviceService;
@Autowired
private BeidouClient beidouClient;
@Autowired
private DataPersistService dataPersistService;
@Override
public Void execute(D341LocationMessage message) {
if (logger.isDebugEnabled()) {
@ -40,6 +42,37 @@ public class D341LocationMessageExecutor implements Executor<D341LocationMessage
Device device = deviceService.findByDeviceId(message.getId());
if(device == null) return null;
message.setTenantId(device.getTenantId());
// trx cycle stat
LocalDateTime now = LocalDateTime.now();
if(device.getLastRxTime()!=null &&
device.getLastRxTime().isBefore(now.minusMinutes(2))){
if(device.getLastD3f0f2Time() == null ||
device.getLastD3f0f2Time().isBefore(now.minusMinutes(30))) {
// new cycle
Device lastCycleDevice = new Device();
lastCycleDevice.setDeviceId(device.getDeviceId());
lastCycleDevice.setTenantId(device.getTenantId());
lastCycleDevice.setD341bytes(device.getD341bytes());
lastCycleDevice.setD341Count(device.getD341Count());
lastCycleDevice.setFixedNum(device.getFixedNum());
lastCycleDevice.setFloatNum(device.getFloatNum());
lastCycleDevice.setLastRxTime(device.getLastRxTime());
lastCycleDevice.setSatelitesInUse(device.getSatelitesInUse());
device.clearStat();
ThreadManager.getFixedThreadPool().submit(() -> {
// 通知上线
try {
beidouClient.onDeviceActive(device.getDeviceId(), device.getTenantId());
} catch (Exception e) {
}
dataPersistService.updateDeviceState(lastCycleDevice);
});
}
}
// update trx
device.updateRx(message.getHeader(), message.getLen(), 1);
double[] pos = message.getB562_loc();
device.updateB562Quality((int) pos[3]);
@ -54,20 +87,6 @@ public class D341LocationMessageExecutor implements Executor<D341LocationMessage
}
}
// 收到第一个数据包如果控制通道没连接也通知上线
if(device.getD341Count() == 1){
DeviceChannel channel = OnlineChannels.INSTANCE.getConfigChannel(device.getDeviceId());
if(channel == null || !channel.isOnline()){
// 通知上线
try{
beidouClient.onDeviceActive(device.getDeviceId(), device.getTenantId());
}
catch (Exception e){
}
}
}
ThreadManager.getFixedThreadPool().submit(() -> {
gnssCalcService.calcSingle(message,true);
});

View File

@ -79,6 +79,9 @@ public class D3F2StopIndicationMessageExecutor implements Executor<D3F2StopIndic
if(device.getDeviceType() == Device.DEVICE_BASE_STATION) {
warningService.checkD3xxNum(device);
}
else{
warningService.checkB562Num(device);
}
});
return null;

View File

@ -57,6 +57,7 @@ public class Device {
Double iPosd;
LocalDateTime lastRxTime;
LocalDateTime lastD3f0f2Time;
int lastRxHead = 0;
int fixedNum = 0;
@ -67,9 +68,11 @@ public class Device {
lastRxTime = LocalDateTime.now();
switch (head){
case 0xd3f0:
lastD3f0f2Time = LocalDateTime.now();
clearStat();
break;
case 0xd3f2:
lastD3f0f2Time = LocalDateTime.now();
break;
case 0xd331:
d3xxCount+=count;
@ -97,7 +100,6 @@ public class Device {
public void updateB562Quality(int quality){
if(quality == UBXUtil.FIX_RESULT) fixedNum++;
else if(quality == UBXUtil.FLOAT_RESULT) floatNum++;
else;
}
public void clearStat(){

View File

@ -161,9 +161,14 @@ public class DataPersistServiceImpl implements DataPersistService {
// 检测状态和告警
deviceState.setState(GnssStatus.STATE_ACTIVE);
warningService.checkDeviceStatus(null, deviceState);
//
if(device.getDeviceType() == Device.DEVICE_BASE_STATION){
warningService.checkD3xxNum(device);
}
else{
warningService.checkB562Num(device);
}
if(new_flag) deviceStateRepository.insert(deviceState);
else deviceStateRepository.updateById(deviceState);

View File

@ -11,7 +11,9 @@ public interface WarningService {
* 检查一个周期内的b562数量是否足够
* 返回告警级别和告警码
*/
void checkB562Num(String deviceId,Integer tenantId, int[] numB562Stat);
void checkB562Num(Device device);
void checkD3xxNum(Device device);
/***
* 检查电压RSSI等
@ -22,5 +24,4 @@ public interface WarningService {
*/
void checkTrx(GnssTrxMsg msg, GnssStatus curStatus);
void checkD3xxNum(Device device);
}

View File

@ -44,9 +44,8 @@ public class WarningServiceImpl implements WarningService {
* 检查一个周期内的b562数量是否足够
*/
@Override
public void checkB562Num(String deviceId, Integer tenantId,
int[] numB562Stat){
GnssStatus status = gnssStatusMapper.getByDeviceId(deviceId);
public void checkB562Num(Device device){
GnssStatus status = gnssStatusMapper.getByDeviceId(device.getDeviceId());
if(status == null) return;
boolean isUpdated = false;
@ -58,11 +57,13 @@ public class WarningServiceImpl implements WarningService {
// b562少
if(check(status, WarningCfg.TYPE_LESS_B562,
WarningCfg.TYPE_NAME_LESS_B562,true,
numB562Stat[0],null,
"固定解:"+numB562Stat[0]+",浮点解:"+numB562Stat[1]+",全零:"+numB562Stat[2])) isUpdated=true;
device.getFixedNum(),null,
"固定解:"+device.getFixedNum()+",浮点解:"+device.getFloatNum()+",全部:"+device.getD341Count())){
isUpdated=true;
}
//清除连续无b562
if(0 != numB562Stat[0]){
if(0 != device.getFixedNum()){
if ((status.getWarningcode() & WarningCfg.TYPE_NO_FIXED_RESULT) != 0) {
status.setWarningcode(status.getWarningcode() & ~WarningCfg.TYPE_NO_FIXED_RESULT);
isUpdated = true;