add wave missed schedule.
This commit is contained in:
parent
e4ad47e0e2
commit
890fcb6736
@ -139,17 +139,15 @@ int SensorScheduler::StartSchedule(int short_addr, int &next_duration) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RetransferWave(short_addr)) {
|
if (RetransferWave(short_addr)) {
|
||||||
wave_feature_set_inst::instance().GetWaveCfg(short_addr, g_x, g_y, g_z);
|
zlog_warn(zct, "[%d:%x] it is retransfer wave time", id, short_addr);
|
||||||
if (g_x || g_y || g_z) {
|
current_request_ = kScheduleWaveForm;
|
||||||
zlog_warn(zct, "[%d:%x] it is retransfer wave time", id, short_addr);
|
return kScheduleWaveForm;
|
||||||
current_request_ = kScheduleWaveForm;
|
} else if (MissedWave(short_addr)) {
|
||||||
return kScheduleWaveForm;
|
zlog_warn(zct, "[%d:%x] it is patch wave time", id, short_addr);
|
||||||
} else {
|
current_request_ = kScheduleWaveForm;
|
||||||
next_duration = GetNextDuration(short_addr);
|
patch_set_.erase(short_addr);
|
||||||
zlog_warn(zct, "[%d:%x] no need for wave", id, short_addr);
|
return kScheduleWaveForm;
|
||||||
return kScheduleWrongTime;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// if (update_.count(id)) {
|
// if (update_.count(id)) {
|
||||||
// // execute config
|
// // execute config
|
||||||
@ -169,6 +167,17 @@ int SensorScheduler::StartSchedule(int short_addr, int &next_duration) {
|
|||||||
|
|
||||||
long SensorScheduler::CalcNextTimestamp(int id, uint16_t short_addr) {
|
long SensorScheduler::CalcNextTimestamp(int id, uint16_t short_addr) {
|
||||||
// current_ts_ = GetLocalTs();
|
// current_ts_ = GetLocalTs();
|
||||||
|
// nth_wave_start_slice_ = (current_ts_ - start_timestamp_) / wave_form_send_interval_;
|
||||||
|
// current_wave_start_ts_ = nth_wave_start_slice_ * wave_form_send_interval_ + start_timestamp_;
|
||||||
|
// seconds_in_current_wave_slice_ = current_ts_ - current_wave_start_ts_;
|
||||||
|
// nth_eigen_value_slice_ = seconds_in_current_wave_slice_ / eigen_value_send_interval_;
|
||||||
|
// seconds_in_current_eigen_slice_ = seconds_in_current_wave_slice_ % eigen_value_send_interval_;
|
||||||
|
// ts_in_eigen_slice_ = false;
|
||||||
|
|
||||||
|
// if (seconds_in_current_eigen_slice_ < eigen_value_slice_total_seconds_ - 3) {
|
||||||
|
// ts_in_eigen_slice_ = true;
|
||||||
|
// }
|
||||||
|
|
||||||
if (ts_in_eigen_slice_) {
|
if (ts_in_eigen_slice_) {
|
||||||
int forward_wave_slice_num = nth_eigen_value_slice_ * wave_slice_num_per_eigen_interval_;
|
int forward_wave_slice_num = nth_eigen_value_slice_ * wave_slice_num_per_eigen_interval_;
|
||||||
auto wave_slice_iter = sensor_id_nth_slice_.find(id);
|
auto wave_slice_iter = sensor_id_nth_slice_.find(id);
|
||||||
@ -193,6 +202,19 @@ long SensorScheduler::CalcNextTimestamp(int id, uint16_t short_addr) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (send_wave_ts == 0) {
|
||||||
|
// add for patch wave
|
||||||
|
int nth_wave_slice = nth_eigen_value_slice_ * wave_slice_num_per_eigen_interval_ + nth_wave_slice_ + 1;
|
||||||
|
auto wave_slice_iter = sensor_id_nth_slice_.find(id);
|
||||||
|
if (wave_slice_iter != sensor_id_nth_slice_.end()) {
|
||||||
|
if (nth_wave_slice > wave_slice_iter->second) {
|
||||||
|
if (success_set_.count(short_addr) == 0 && !RetransferWave(short_addr)) {
|
||||||
|
patch_set_.insert(short_addr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
long available_ts = 0;
|
long available_ts = 0;
|
||||||
@ -227,6 +249,19 @@ long SensorScheduler::CalcNextTimestamp(int id, uint16_t short_addr) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (MissedWave(short_addr)) {
|
||||||
|
for (int i = 0; i < wave_slice_num_per_eigen_interval_; ++i) {
|
||||||
|
if (slice_sensor_id_[i+forward_wave_slice_num] == 0) {
|
||||||
|
// 判断此空闲位置是否被占用
|
||||||
|
long current_wave_slice_ts = current_wave_start_ts_ + nth_eigen_value_slice_ * eigen_value_send_interval_ + eigen_value_slice_total_seconds_ + i * seconds_per_wave_slice_;
|
||||||
|
if (free_slice_ocuppied_.count(current_wave_slice_ts) == 0) {
|
||||||
|
available_ts = current_wave_slice_ts;
|
||||||
|
free_slice_ocuppied_.insert(available_ts);
|
||||||
|
zlog_warn(zct, "[Nxt][%d:%x] %d nth free wave slice will be used to patch wave, utc time:[%s]", id, short_addr, i+forward_wave_slice_num, GetUTCTime(available_ts).c_str());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -366,7 +401,7 @@ void SensorScheduler::WaveError(int short_addr) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (iter->second == 0) {
|
if (iter->second == 0) {
|
||||||
zlog_warn(zct, "[WaveError][%x] no try times");
|
zlog_warn(zct, "[WaveError][%x] no try times", short_addr);
|
||||||
failure_map_.erase(short_addr);
|
failure_map_.erase(short_addr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -383,8 +418,16 @@ bool SensorScheduler::RetransferWave(uint16_t short_addr) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SensorScheduler::MissedWave(uint16_t short_addr) {
|
||||||
|
if (patch_set_.count(short_addr) > 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void SensorScheduler::WaveSuccess(int short_addr) {
|
void SensorScheduler::WaveSuccess(int short_addr) {
|
||||||
success_map_[short_addr] = 1;
|
success_set_.insert(short_addr);
|
||||||
auto iter = failure_map_.find(short_addr);
|
auto iter = failure_map_.find(short_addr);
|
||||||
if (iter != failure_map_.end()) {
|
if (iter != failure_map_.end()) {
|
||||||
zlog_warn(zct, "[WaveSuccess][%x] try %d times success", short_addr, 4 - iter->second);
|
zlog_warn(zct, "[WaveSuccess][%x] try %d times success", short_addr, 4 - iter->second);
|
||||||
@ -396,7 +439,8 @@ void SensorScheduler::WaveSuccess(int short_addr) {
|
|||||||
|
|
||||||
void SensorScheduler::ClearFailureSuccessMap() {
|
void SensorScheduler::ClearFailureSuccessMap() {
|
||||||
failure_map_.clear();
|
failure_map_.clear();
|
||||||
success_map_.clear();
|
success_set_.clear();
|
||||||
|
patch_set_.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
long SensorScheduler::GetBaseTimestamp(int short_addr) {
|
long SensorScheduler::GetBaseTimestamp(int short_addr) {
|
||||||
|
|||||||
@ -128,9 +128,11 @@ private:
|
|||||||
|
|
||||||
// 存储当前2小时内失败与成功的传感器
|
// 存储当前2小时内失败与成功的传感器
|
||||||
std::map<uint16_t, int> failure_map_;
|
std::map<uint16_t, int> failure_map_;
|
||||||
std::map<uint16_t, int> success_map_;
|
std::unordered_set<uint16_t> success_set_;
|
||||||
|
std::unordered_set<uint16_t> patch_set_; // 漏传的补传
|
||||||
void ClearFailureSuccessMap();
|
void ClearFailureSuccessMap();
|
||||||
bool RetransferWave(uint16_t short_addr);
|
bool RetransferWave(uint16_t short_addr);
|
||||||
|
bool MissedWave(uint16_t short_addr);
|
||||||
|
|
||||||
// 空闲时间戳被占用
|
// 空闲时间戳被占用
|
||||||
std::unordered_set<long> free_slice_ocuppied_;
|
std::unordered_set<long> free_slice_ocuppied_;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user