add codes.
This commit is contained in:
parent
0b256f350a
commit
c7118a7e8c
@ -69,164 +69,166 @@ int SensorScheduler::StartSchedule(uint16_t short_addr, int &next_duration, bool
|
|||||||
// current_request_ = kScheduleEigenValue;
|
// current_request_ = kScheduleEigenValue;
|
||||||
// return kScheduleEigenValue;
|
// return kScheduleEigenValue;
|
||||||
// } else {
|
// } else {
|
||||||
next_duration = GetNextDuration(short_addr, z, next_task_id);
|
// next_duration = GetNextDuration(short_addr, z, next_task_id);
|
||||||
zlog_warn(zbt, "[%d:%x] no need for eigen", id, short_addr);
|
// zlog_warn(zbt, "[%d:%x] no need for eigen", id, short_addr);
|
||||||
return kScheduleResultNone;
|
return kScheduleResultNone;
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
if (current_schedule_status_ == kScheduleStatusDebug) {
|
return kScheduleResultNone;
|
||||||
if (debug_list_.count(short_addr) == 0) {
|
// else {
|
||||||
next_duration = GetDebugUpgradeNextDuration(short_addr);
|
// if (current_schedule_status_ == kScheduleStatusDebug) {
|
||||||
next_task_id = kScheduleEigenValue;
|
// if (debug_list_.count(short_addr) == 0) {
|
||||||
zlog_debug(zbt, "[%d:%x] not in debug list", id, short_addr);
|
// next_duration = GetDebugUpgradeNextDuration(short_addr);
|
||||||
return kScheduleWrongTime;
|
// next_task_id = kScheduleEigenValue;
|
||||||
} else {
|
// zlog_debug(zbt, "[%d:%x] not in debug list", id, short_addr);
|
||||||
// z wave
|
// return kScheduleWrongTime;
|
||||||
int nth_wave_slice = nth_eigen_value_slice_ * wave_slice_num_per_eigen_interval_ + nth_wave_slice_ + 1;
|
// } else {
|
||||||
if (debug_slice_sensor_id_[nth_wave_slice] == short_addr) {
|
// // z wave
|
||||||
current_request_ = kScheduleWaveForm;
|
// int nth_wave_slice = nth_eigen_value_slice_ * wave_slice_num_per_eigen_interval_ + nth_wave_slice_ + 1;
|
||||||
z = true;
|
// if (debug_slice_sensor_id_[nth_wave_slice] == short_addr) {
|
||||||
return kScheduleWaveForm;
|
// current_request_ = kScheduleWaveForm;
|
||||||
} else {
|
// z = true;
|
||||||
// 当前特征值间隔内是否存在此传感器的波形区间
|
// return kScheduleWaveForm;
|
||||||
for (int i = nth_wave_slice + 1; i <= (nth_eigen_value_slice_+1) * wave_slice_num_per_eigen_interval_; ++i) {
|
// } else {
|
||||||
if (debug_slice_sensor_id_[i] == short_addr) {
|
// // 当前特征值间隔内是否存在此传感器的波形区间
|
||||||
long nxt_ts = current_wave_start_ts_ + nth_eigen_value_slice_ * eigen_value_send_interval_ + 60 + (i-nth_wave_slice)*60;
|
// for (int i = nth_wave_slice + 1; i <= (nth_eigen_value_slice_+1) * wave_slice_num_per_eigen_interval_; ++i) {
|
||||||
next_duration = nxt_ts - current_ts_;
|
// if (debug_slice_sensor_id_[i] == short_addr) {
|
||||||
if (next_duration < 10) {
|
// long nxt_ts = current_wave_start_ts_ + nth_eigen_value_slice_ * eigen_value_send_interval_ + 60 + (i-nth_wave_slice)*60;
|
||||||
zlog_debug(zbt, "[%d:%x] [Nxt] debug exception duration:%d, adjust to 25", id, short_addr,next_duration);
|
// next_duration = nxt_ts - current_ts_;
|
||||||
next_duration = 25;
|
// if (next_duration < 10) {
|
||||||
} else if (next_duration > eigen_value_send_interval_) {
|
// zlog_debug(zbt, "[%d:%x] [Nxt] debug exception duration:%d, adjust to 25", id, short_addr,next_duration);
|
||||||
zlog_debug(zbt, "[%d:%x] [Nxt] debug exception duration:%d, adjust to 120", id, short_addr,next_duration);
|
// next_duration = 25;
|
||||||
next_duration = 120;
|
// } else if (next_duration > eigen_value_send_interval_) {
|
||||||
}
|
// zlog_debug(zbt, "[%d:%x] [Nxt] debug exception duration:%d, adjust to 120", id, short_addr,next_duration);
|
||||||
z = true;
|
// next_duration = 120;
|
||||||
next_task_id = kScheduleWaveForm;
|
// }
|
||||||
return kScheduleWrongTime;
|
// z = true;
|
||||||
}
|
// next_task_id = kScheduleWaveForm;
|
||||||
}
|
// return kScheduleWrongTime;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
next_duration = GetDebugUpgradeNextDuration(short_addr);
|
// next_duration = GetDebugUpgradeNextDuration(short_addr);
|
||||||
next_task_id = kScheduleEigenValue;
|
// next_task_id = kScheduleEigenValue;
|
||||||
zlog_debug(zbt, "[%d:%x] debug wrong time", id, short_addr);
|
// zlog_debug(zbt, "[%d:%x] debug wrong time", id, short_addr);
|
||||||
return kScheduleWrongTime;
|
// return kScheduleWrongTime;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return 0;
|
// return 0;
|
||||||
} else if (current_schedule_status_ == kScheduleStatusUpgrade) {
|
// } else if (current_schedule_status_ == kScheduleStatusUpgrade) {
|
||||||
if (upgrade_list_.count(short_addr) == 0) {
|
// if (upgrade_list_.count(short_addr) == 0) {
|
||||||
next_duration = GetDebugUpgradeNextDuration(short_addr);
|
// next_duration = GetDebugUpgradeNextDuration(short_addr);
|
||||||
next_task_id = kScheduleEigenValue;
|
// next_task_id = kScheduleEigenValue;
|
||||||
zlog_debug(zbt, "[%d:%x] not in upgrade list", id, short_addr);
|
// zlog_debug(zbt, "[%d:%x] not in upgrade list", id, short_addr);
|
||||||
return kScheduleWrongTime;
|
// return kScheduleWrongTime;
|
||||||
} else {
|
// } else {
|
||||||
int nth_wave_slice = nth_eigen_value_slice_ * wave_slice_num_per_eigen_interval_ + nth_wave_slice_ + 1;
|
// int nth_wave_slice = nth_eigen_value_slice_ * wave_slice_num_per_eigen_interval_ + nth_wave_slice_ + 1;
|
||||||
if (upgrade_slice_sensor_id_[nth_wave_slice] == short_addr) {
|
// if (upgrade_slice_sensor_id_[nth_wave_slice] == short_addr) {
|
||||||
current_request_ = kScheduleUpgrade;
|
// current_request_ = kScheduleUpgrade;
|
||||||
// upgrade_list_.erase(short_addr);
|
// // upgrade_list_.erase(short_addr);
|
||||||
return kScheduleUpgrade;
|
// return kScheduleUpgrade;
|
||||||
} else {
|
// } else {
|
||||||
next_duration = GetDebugUpgradeNextDuration(short_addr);
|
// next_duration = GetDebugUpgradeNextDuration(short_addr);
|
||||||
next_task_id = kScheduleEigenValue;
|
// next_task_id = kScheduleEigenValue;
|
||||||
zlog_debug(zbt, "[%d:%x] in wrong time", id, short_addr);
|
// zlog_debug(zbt, "[%d:%x] in wrong time", id, short_addr);
|
||||||
return kScheduleWrongTime;
|
// return kScheduleWrongTime;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
int nth_wave_slice = nth_eigen_value_slice_ * wave_slice_num_per_eigen_interval_ + nth_wave_slice_ + 1; // 从1开始编号
|
// int nth_wave_slice = nth_eigen_value_slice_ * wave_slice_num_per_eigen_interval_ + nth_wave_slice_ + 1; // 从1开始编号
|
||||||
auto wave_slice_iter = sensor_id_nth_slice_.find(id);
|
// auto wave_slice_iter = sensor_id_nth_slice_.find(id);
|
||||||
if (wave_slice_iter == sensor_id_nth_slice_.end()) {
|
// if (wave_slice_iter == sensor_id_nth_slice_.end()) {
|
||||||
zlog_error(zbt, "[%d:%x] invaild id, not find wave slice id, need to check further", id, short_addr);
|
// zlog_error(zbt, "[%d:%x] invaild id, not find wave slice id, need to check further", id, short_addr);
|
||||||
return kScheduleUnknownSensor;
|
// return kScheduleUnknownSensor;
|
||||||
}
|
// }
|
||||||
|
|
||||||
wave_feature_set_inst::instance().GetWaveCfg(short_addr, g_x, g_y, g_z);
|
// wave_feature_set_inst::instance().GetWaveCfg(short_addr, g_x, g_y, g_z);
|
||||||
if (nth_wave_slice == wave_slice_iter->second.first) { // Z轴
|
// if (nth_wave_slice == wave_slice_iter->second.first) { // Z轴
|
||||||
if (g_z) {
|
// if (g_z) {
|
||||||
zlog_debug(zbt, "[%d:%x] it is wave z time", id, short_addr);
|
// zlog_debug(zbt, "[%d:%x] it is wave z time", id, short_addr);
|
||||||
current_request_ = kScheduleWaveForm;
|
// current_request_ = kScheduleWaveForm;
|
||||||
z = true;
|
// z = true;
|
||||||
return kScheduleWaveForm;
|
// return kScheduleWaveForm;
|
||||||
} else {
|
// } else {
|
||||||
next_duration = GetNextDuration(short_addr, z, next_task_id);
|
// next_duration = GetNextDuration(short_addr, z, next_task_id);
|
||||||
zlog_debug(zbt, "[%d:%x] no need for wave", id, short_addr);
|
// zlog_debug(zbt, "[%d:%x] no need for wave", id, short_addr);
|
||||||
return kScheduleWrongTime;
|
// return kScheduleWrongTime;
|
||||||
}
|
// }
|
||||||
} else if (nth_wave_slice == wave_slice_iter->second.second) { // XY轴
|
// } else if (nth_wave_slice == wave_slice_iter->second.second) { // XY轴
|
||||||
if (g_x || g_y) {
|
// if (g_x || g_y) {
|
||||||
zlog_debug(zbt, "[%d:%x] it is wave xy time", id, short_addr);
|
// zlog_debug(zbt, "[%d:%x] it is wave xy time", id, short_addr);
|
||||||
current_request_ = kScheduleWaveForm;
|
// current_request_ = kScheduleWaveForm;
|
||||||
z = false;
|
// z = false;
|
||||||
return kScheduleWaveForm;
|
// return kScheduleWaveForm;
|
||||||
} else {
|
// } else {
|
||||||
next_duration = GetNextDuration(short_addr, z, next_task_id);
|
// next_duration = GetNextDuration(short_addr, z, next_task_id);
|
||||||
zlog_debug(zbt, "[%d:%x] no need for wave", id, short_addr);
|
// zlog_debug(zbt, "[%d:%x] no need for wave", id, short_addr);
|
||||||
return kScheduleWrongTime;
|
// return kScheduleWrongTime;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
else {
|
// else {
|
||||||
if (slice_sensor_id_[nth_wave_slice] == 0) { // idle time
|
// if (slice_sensor_id_[nth_wave_slice] == 0) { // idle time
|
||||||
zlog_debug(zbt, "[%d:%x] in idle time", id, short_addr);
|
// zlog_debug(zbt, "[%d:%x] in idle time", id, short_addr);
|
||||||
if (trigger_wave_record_.find(short_addr) != trigger_wave_record_.end()) {
|
// if (trigger_wave_record_.find(short_addr) != trigger_wave_record_.end()) {
|
||||||
auto iter = trigger_wave_record_.find(short_addr);
|
// auto iter = trigger_wave_record_.find(short_addr);
|
||||||
if (iter->second.first != 0) {
|
// if (iter->second.first != 0) {
|
||||||
current_request_ = kScheduleWaveForm;
|
// current_request_ = kScheduleWaveForm;
|
||||||
z = true;
|
// z = true;
|
||||||
zlog_debug(zbt, "[%d:%x] trigger z wave time", id, short_addr);
|
// zlog_debug(zbt, "[%d:%x] trigger z wave time", id, short_addr);
|
||||||
iter->second.first = 0;
|
// iter->second.first = 0;
|
||||||
WriteTriggerWaveRecord();
|
// WriteTriggerWaveRecord();
|
||||||
return kScheduleWaveForm;
|
// return kScheduleWaveForm;
|
||||||
} else if (iter->second.second != 0) {
|
// } else if (iter->second.second != 0) {
|
||||||
current_request_ = kScheduleWaveForm;
|
// current_request_ = kScheduleWaveForm;
|
||||||
z = false;
|
// z = false;
|
||||||
iter->second.second = 0;
|
// iter->second.second = 0;
|
||||||
WriteTriggerWaveRecord();
|
// WriteTriggerWaveRecord();
|
||||||
zlog_debug(zbt, "[%d:%x] trigger xy wave time", id, short_addr);
|
// zlog_debug(zbt, "[%d:%x] trigger xy wave time", id, short_addr);
|
||||||
return kScheduleWaveForm;
|
// return kScheduleWaveForm;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (ZRetransferWave(short_addr)) {
|
// if (ZRetransferWave(short_addr)) {
|
||||||
zlog_debug(zbt, "[%d:%x] z retransfer wave time", id, short_addr);
|
// zlog_debug(zbt, "[%d:%x] z retransfer wave time", id, short_addr);
|
||||||
current_request_ = kScheduleWaveForm;
|
// current_request_ = kScheduleWaveForm;
|
||||||
z = true;
|
// z = true;
|
||||||
return kScheduleWaveForm;
|
// return kScheduleWaveForm;
|
||||||
} else if (ZMissedWave(short_addr)) {
|
// } else if (ZMissedWave(short_addr)) {
|
||||||
zlog_debug(zbt, "[%d:%x] z patch wave time", id, short_addr);
|
// zlog_debug(zbt, "[%d:%x] z patch wave time", id, short_addr);
|
||||||
current_request_ = kScheduleWaveForm;
|
// current_request_ = kScheduleWaveForm;
|
||||||
z = true;
|
// z = true;
|
||||||
z_patch_set_.erase(short_addr);
|
// z_patch_set_.erase(short_addr);
|
||||||
return kScheduleWaveForm;
|
// return kScheduleWaveForm;
|
||||||
} else if (XYRetransferWave(short_addr)) {
|
// } else if (XYRetransferWave(short_addr)) {
|
||||||
zlog_debug(zbt, "[%d:%x] xy retransfer wave time", id, short_addr);
|
// zlog_debug(zbt, "[%d:%x] xy retransfer wave time", id, short_addr);
|
||||||
current_request_ = kScheduleWaveForm;
|
// current_request_ = kScheduleWaveForm;
|
||||||
z = false;
|
// z = false;
|
||||||
return kScheduleWaveForm;
|
// return kScheduleWaveForm;
|
||||||
} else if (XYMissedWave(short_addr)) {
|
// } else if (XYMissedWave(short_addr)) {
|
||||||
zlog_debug(zbt, "[%d:%x] xy patch wave time", id, short_addr);
|
// zlog_debug(zbt, "[%d:%x] xy patch wave time", id, short_addr);
|
||||||
current_request_ = kScheduleWaveForm;
|
// current_request_ = kScheduleWaveForm;
|
||||||
xy_patch_set_.erase(short_addr);
|
// xy_patch_set_.erase(short_addr);
|
||||||
z = false;
|
// z = false;
|
||||||
return kScheduleWaveForm;
|
// return kScheduleWaveForm;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
// wrong time to come
|
// // wrong time to come
|
||||||
int eigen_send_ts = (id - 1) * 2;
|
// int eigen_send_ts = (id - 1) * 2;
|
||||||
if (eigen_send_ts > 57) {
|
// if (eigen_send_ts > 57) {
|
||||||
eigen_send_ts = eigen_send_ts % 57;
|
// eigen_send_ts = eigen_send_ts % 57;
|
||||||
}
|
// }
|
||||||
long available_ts = current_wave_start_ts_ + (nth_eigen_value_slice_ + 1) * eigen_value_send_interval_ + eigen_send_ts;
|
// long available_ts = current_wave_start_ts_ + (nth_eigen_value_slice_ + 1) * eigen_value_send_interval_ + eigen_send_ts;
|
||||||
next_duration = available_ts - current_ts_;
|
// next_duration = available_ts - current_ts_;
|
||||||
if (next_duration < 10 || next_duration > eigen_value_send_interval_) {
|
// if (next_duration < 10 || next_duration > eigen_value_send_interval_) {
|
||||||
zlog_debug(zbt, "[%d:%x] invalid next duration:%d, adjust to 120", id, short_addr, next_duration);
|
// zlog_debug(zbt, "[%d:%x] invalid next duration:%d, adjust to 120", id, short_addr, next_duration);
|
||||||
next_duration = 120;
|
// next_duration = 120;
|
||||||
}
|
// }
|
||||||
next_task_id = kScheduleEigenValue;
|
// next_task_id = kScheduleEigenValue;
|
||||||
zlog_debug(zbt, "[%d:%x] wrong time in wave slice, next feature send utc time:[%s], duration:%d", id, short_addr, GetUTCTime(available_ts).c_str(), next_duration);
|
// zlog_debug(zbt, "[%d:%x] wrong time in wave slice, next feature send utc time:[%s], duration:%d", id, short_addr, GetUTCTime(available_ts).c_str(), next_duration);
|
||||||
return kScheduleWrongTime;
|
// return kScheduleWrongTime;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
long SensorScheduler::CalcNextTimestamp(int id, uint16_t short_addr, bool &z, int& next_task_id) {
|
long SensorScheduler::CalcNextTimestamp(int id, uint16_t short_addr, bool &z, int& next_task_id) {
|
||||||
@ -519,12 +521,12 @@ int SensorScheduler::GetNextDuration(uint16_t short_addr, bool &z, int &next_tas
|
|||||||
ts_in_eigen_slice_ = true;
|
ts_in_eigen_slice_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ts_in_eigen_slice_) {
|
// if (ts_in_eigen_slice_) {
|
||||||
// nth_eigen_slice_ = (seconds_in_current_eigen_slice_ + 2) / eigen_value_send_duration_;
|
// // nth_eigen_slice_ = (seconds_in_current_eigen_slice_ + 2) / eigen_value_send_duration_;
|
||||||
if (nth_eigen_value_slice_ == 0) {
|
// if (nth_eigen_value_slice_ == 0) {
|
||||||
ClearFailureSuccessMap();
|
// ClearFailureSuccessMap();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
zlog_debug(zbt, "[%d:%x] ts:%ld, current utc:%s, nth eigen_value slice:%d, seconds in eigen slice:%d, eigen slice:%d",
|
zlog_debug(zbt, "[%d:%x] ts:%ld, current utc:%s, nth eigen_value slice:%d, seconds in eigen slice:%d, eigen slice:%d",
|
||||||
id, short_addr, current_ts_, GetUTCTime(current_ts_).c_str(), nth_eigen_value_slice_+1, seconds_in_current_eigen_slice_, ts_in_eigen_slice_);
|
id, short_addr, current_ts_, GetUTCTime(current_ts_).c_str(), nth_eigen_value_slice_+1, seconds_in_current_eigen_slice_, ts_in_eigen_slice_);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user