1、修改f9p重启指令发送的时机,如果连续6个周期无固定解则重启
2、增加ping指令,用于终端测试服务器是否正常
This commit is contained in:
parent
8cfdbb89f3
commit
5a1fc85cd6
@ -1,7 +1,5 @@
|
|||||||
import com.imdroid.beidou_fwd.entity.KingMaData;
|
import com.imdroid.beidou_fwd.entity.KingMaData;
|
||||||
import com.imdroid.common.util.GsonUtil;
|
import com.imdroid.common.util.GsonUtil;
|
||||||
import com.imdroid.secapi.dto.GnssCalcData;
|
|
||||||
import com.imdroid.secapi.utils.HexUtil;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
|
|||||||
@ -0,0 +1,34 @@
|
|||||||
|
package com.imdroid.sideslope.executor;
|
||||||
|
|
||||||
|
import com.imdroid.sideslope.message.D314PingMessage;
|
||||||
|
import com.imdroid.sideslope.server.OnlineChannels;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import io.netty.buffer.Unpooled;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Layton
|
||||||
|
* @date 2023/2/2 20:49
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class D314PingMessageExecutor implements Executor<D314PingMessage, Void> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Void execute(D314PingMessage message) {
|
||||||
|
String deviceId = message.getId();
|
||||||
|
byte[] forwardBytes = message.getSrcData();
|
||||||
|
OnlineChannels.INSTANCE.get(deviceId).ifPresent(deviceChannel -> {
|
||||||
|
forwardBytes[12] = (byte) 1;//ping ack
|
||||||
|
ByteBuf buf = Unpooled.buffer();
|
||||||
|
buf.writeBytes(forwardBytes);
|
||||||
|
deviceChannel.writeAndFlush(buf);
|
||||||
|
});
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<?> getMessageType() {
|
||||||
|
return D314PingMessage.class;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -2,13 +2,13 @@ package com.imdroid.sideslope.executor;
|
|||||||
|
|
||||||
import com.imdroid.common.util.HexUtil;
|
import com.imdroid.common.util.HexUtil;
|
||||||
import com.imdroid.secapi.client.BeidouClient;
|
import com.imdroid.secapi.client.BeidouClient;
|
||||||
import com.imdroid.secapi.client.RtcmClient;
|
|
||||||
import com.imdroid.secapi.dto.*;
|
import com.imdroid.secapi.dto.*;
|
||||||
import com.imdroid.sideslope.message.D3F0SelfCheckMessage;
|
import com.imdroid.sideslope.message.D3F0SelfCheckMessage;
|
||||||
import com.imdroid.sideslope.sal.DeviceService;
|
import com.imdroid.sideslope.sal.DeviceService;
|
||||||
import com.imdroid.sideslope.sal.Device;
|
import com.imdroid.sideslope.sal.Device;
|
||||||
import com.imdroid.sideslope.service.DataPersistService;
|
import com.imdroid.sideslope.service.DataPersistService;
|
||||||
import com.imdroid.common.util.ThreadManager;
|
import com.imdroid.common.util.ThreadManager;
|
||||||
|
import com.imdroid.sideslope.web.ApiController;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -37,7 +37,7 @@ public class D3F0SelfCheckMessageExecutor implements Executor<D3F0SelfCheckMessa
|
|||||||
@Resource(name = "local")
|
@Resource(name = "local")
|
||||||
private DeviceService deviceService;
|
private DeviceService deviceService;
|
||||||
@Autowired
|
@Autowired
|
||||||
RtcmClient rtcmClient;
|
ApiController rtcmClient;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Void execute(D3F0SelfCheckMessage message) {
|
public Void execute(D3F0SelfCheckMessage message) {
|
||||||
@ -74,33 +74,18 @@ public class D3F0SelfCheckMessageExecutor implements Executor<D3F0SelfCheckMessa
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<?> getMessageType() {
|
public Class<?> getMessageType() {
|
||||||
return D3F0SelfCheckMessage.class;
|
return D3F0SelfCheckMessage.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkAndSendF9PPowerOffCommand(Device device){
|
private void checkAndSendF9PPowerOffCommand(Device device){
|
||||||
LocalDateTime now = LocalDateTime.now();
|
if(device.getDeviceId().startsWith("2419") && device.getDeviceType() == Device.DEVICE_ROVER){
|
||||||
// 针对 2419 编号开头的测站设备,检查其 F9P 运行的时间,每隔48小时需要使其断电
|
// 连续6个周期无解,则立即发送F9P断电指令
|
||||||
// 断电时间记录保存于缓存之中,不必查询数据库
|
if(device.getNoFixedAndFloatResult() >= 6){
|
||||||
// 平台重启会清除缓存,所以每次重启后收到该设备的第一条D3F0自检消息后,让其 F9P 断电,以保证F9P断电时间小于等于 48 小时
|
|
||||||
if(device.getDeviceId().startsWith("2419") && device.getDeviceType() == 0){
|
|
||||||
// 缓存中若没有 F9P 最近一次断电时间的记录,则立即发送F9P断电指令
|
|
||||||
if(device.getLastF9PPowerOffTime() == null){
|
|
||||||
sendF9PPowerOffCommand(device);
|
sendF9PPowerOffCommand(device);
|
||||||
// 初始化 F9P 断电时间
|
logger.debug("{}: 连续{}次无固定解和浮点解,重启F9P",device.getDeviceId(), device.getNoFixedAndFloatResult());
|
||||||
device.setLastF9PPowerOffTime(now);
|
device.clearNoResultStat();
|
||||||
logger.debug("设备" + device.getDeviceId() + ": F9P 最近一次断电时间初始化为 " + device.getLastF9PPowerOffTime());
|
|
||||||
}
|
|
||||||
// 检查 F9P 最近一次断电时间是否超过 48 小时 ,若是,则发送断电指令
|
|
||||||
else if(device.getLastF9PPowerOffTime().isBefore(now.minusHours(24))){
|
|
||||||
logger.debug("设备 "+device.getDeviceId()+" 的 F9P 距离上一次断电已超过48小时,发送F9P断电指令");
|
|
||||||
sendF9PPowerOffCommand(device);
|
|
||||||
// 更新F9P断电时间,用于下一个48小时周期后的判断
|
|
||||||
device.setLastF9PPowerOffTime(now);
|
|
||||||
}else{
|
|
||||||
logger.debug("设备 "+device.getDeviceId()+" 的 F9P 距离上一次断电时间为:"+device.getLastF9PPowerOffTime());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,6 +37,7 @@ public class MessageParser {
|
|||||||
types.put((short)0xd31B, D31xConfigAckMessage.class);//LORA配置应答
|
types.put((short)0xd31B, D31xConfigAckMessage.class);//LORA配置应答
|
||||||
types.put((short)0xd320, D31xConfigAckMessage.class);//v3.2 DTU配置应答
|
types.put((short)0xd320, D31xConfigAckMessage.class);//v3.2 DTU配置应答
|
||||||
types.put((short)0xd350, D350TestMessage.class);//ACC上报
|
types.put((short)0xd350, D350TestMessage.class);//ACC上报
|
||||||
|
types.put((short)0xd314, D314PingMessage.class);//ping
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,27 @@
|
|||||||
|
package com.imdroid.sideslope.message;
|
||||||
|
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Layton
|
||||||
|
* @date 2023/2/2 20:47
|
||||||
|
*/
|
||||||
|
public class D314PingMessage extends BaseMessage {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void decodeBody(ByteBuf src) {
|
||||||
|
//srcData需要完整的消息,所以解析头用get方法
|
||||||
|
this.header = src.getUnsignedShort(0); // flag
|
||||||
|
this.len = src.getUnsignedShort(2); // length:11bit
|
||||||
|
this.seq = 0;
|
||||||
|
this.id = String.valueOf(src.getUnsignedInt(4)); //id
|
||||||
|
|
||||||
|
this.srcData = new byte[src.readableBytes()];
|
||||||
|
src.readBytes(this.srcData);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldDecodeHeader() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -61,7 +61,7 @@ public class Device {
|
|||||||
|
|
||||||
LocalDateTime lastRxTime;
|
LocalDateTime lastRxTime;
|
||||||
LocalDateTime lastD3f0f2Time;
|
LocalDateTime lastD3f0f2Time;
|
||||||
LocalDateTime lastF9PPowerOffTime;
|
short noFixedAndFloatResult=0;
|
||||||
|
|
||||||
int lastRxHead = 0;
|
int lastRxHead = 0;
|
||||||
|
|
||||||
@ -108,6 +108,9 @@ public class Device {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void clearStat(){
|
public void clearStat(){
|
||||||
|
if(fixedNum+floatNum == 0) noFixedAndFloatResult++;
|
||||||
|
else noFixedAndFloatResult = 0;
|
||||||
|
|
||||||
d3xxCount = 0;
|
d3xxCount = 0;
|
||||||
d3xxbytes = 0;
|
d3xxbytes = 0;
|
||||||
d341Count = 0;
|
d341Count = 0;
|
||||||
@ -123,4 +126,9 @@ public class Device {
|
|||||||
d342Bytes = 0;
|
d342Bytes = 0;
|
||||||
d341In42Count = 0;
|
d341In42Count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void clearNoResultStat(){
|
||||||
|
noFixedAndFloatResult = 0;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -112,7 +112,7 @@ public class DeviceStatusChecker {
|
|||||||
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime now = LocalDateTime.now();
|
||||||
LocalDateTime beginTime = now.minusHours(warningCfg.getValue());
|
LocalDateTime beginTime = now.minusHours(warningCfg.getValue());
|
||||||
QueryWrapper<GnssCalcData> calcDataQueryWrapper = new QueryWrapper<>();
|
QueryWrapper<GnssCalcData> calcDataQueryWrapper = new QueryWrapper<>();
|
||||||
calcDataQueryWrapper.ge("createtime",beginTime.format(formatter));
|
calcDataQueryWrapper.ge("createtime",beginTime);
|
||||||
List<GnssCalcData> calcDataList = dataMapper.selectList(calcDataQueryWrapper);
|
List<GnssCalcData> calcDataList = dataMapper.selectList(calcDataQueryWrapper);
|
||||||
|
|
||||||
MPJQueryWrapper<GnssStatus> queryWrapper =
|
MPJQueryWrapper<GnssStatus> queryWrapper =
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user