修改使用备用基站的ID
This commit is contained in:
parent
9f5fa31bb1
commit
a580eb204a
@ -38,6 +38,8 @@ public class D331RtcmMessageExecutor implements Executor<D331RtcmMessage, Void>
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
private static final Map<String ,Boolean> deviceBackupStatus = new ConcurrentHashMap<>();
|
||||
|
||||
@Autowired
|
||||
private DeviceService deviceService;
|
||||
@Autowired
|
||||
@ -89,8 +91,26 @@ public class D331RtcmMessageExecutor implements Executor<D331RtcmMessage, Void>
|
||||
Device primaryBase = deviceService.findByDeviceId(primaryBaseId);
|
||||
// 如果主基站仍然在线,则跳过备选基站的数据
|
||||
if (primaryBase != null && isBaseStationOnline(primaryBase)) {
|
||||
if(deviceBackupStatus.remove(deviceId) != null){
|
||||
logger.info("设备 {} 从备用基站 {} 切换回主基站 {}",
|
||||
deviceId, id, primaryBaseId);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
else{
|
||||
String hexPrimaryBase = String.format("%06x",Integer.parseInt(primaryBaseId));
|
||||
if(deviceBackupStatus.putIfAbsent(deviceId,true) == null){
|
||||
logger.info("设备 {} 从主基站 {} 切换到备用基站 {}",
|
||||
deviceId, primaryBaseId, id);
|
||||
}
|
||||
|
||||
byte[] modifyData = forwardBytes.clone();
|
||||
modifyData[5] = (byte) Integer.parseInt(hexPrimaryBase.substring(0,2),16);
|
||||
modifyData[6] = (byte) Integer.parseInt(hexPrimaryBase.substring(2,4),16);
|
||||
modifyData[7] = (byte) Integer.parseInt(hexPrimaryBase.substring(4,6),16);
|
||||
|
||||
forwardBytes = modifyData;
|
||||
}
|
||||
}
|
||||
|
||||
// 获取设备通道并发送数据
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user