add interface.

This commit is contained in:
pandx 2025-04-01 10:48:05 +08:00
parent fb313da3b0
commit 86da196047
2 changed files with 36 additions and 27 deletions

View File

@ -47,7 +47,7 @@ int SensorScheduler::StartSchedule(int short_addr, int &next_duration) {
zlog_warn(zct, "[%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_);
if (ts_in_eigen_slice_) {
if (id == nth_eigen_slice_ + 1) {
// if (id == nth_eigen_slice_ + 1) {
// 传感器需要执行上送特征值任务, 如果有配置需要下发的话,下发配置
if (update_.count(id)) {
// execute config
@ -67,20 +67,20 @@ int SensorScheduler::StartSchedule(int short_addr, int &next_duration) {
return kScheduleWrongTime;
}
}
} else {
zlog_warn(zct, "[%d:%x] Invalid request, revive in %d eigen slice", id, short_addr, nth_eigen_slice_ + 1);
if (id < nth_eigen_slice_ + 1) {
// 不正确的请求
long available_ts = current_wave_start_ts_ + (nth_eigen_value_slice_ + 1) * eigen_value_send_interval_ + (id - 1) * eigen_value_send_duration_;
next_duration = available_ts - current_ts_;
zlog_warn(zct, "[%d:%x] wrong time in eigen slice, next feature in next interval send utc time:[%s], duration:%d", id, short_addr, GetUTCTime(available_ts).c_str(), next_duration);
} else {
long available_ts = current_wave_start_ts_ + nth_eigen_value_slice_ * eigen_value_send_interval_ + (id - 1) * eigen_value_send_duration_;
next_duration = available_ts - current_ts_;
zlog_warn(zct, "[%d:%x] wrong time in eigen slice, next feature in current interval send utc time:[%s], duration:%d", id, short_addr, GetUTCTime(available_ts).c_str(), next_duration);
}
return kScheduleWrongTime;
}
// } else {
// zlog_warn(zct, "[%d:%x] Invalid request, revive in %d eigen slice", id, short_addr, nth_eigen_slice_ + 1);
// if (id < nth_eigen_slice_ + 1) {
// // 不正确的请求
// long available_ts = current_wave_start_ts_ + (nth_eigen_value_slice_ + 1) * eigen_value_send_interval_ + (id - 1) * eigen_value_send_duration_;
// next_duration = available_ts - current_ts_;
// zlog_warn(zct, "[%d:%x] wrong time in eigen slice, next feature in next interval send utc time:[%s], duration:%d", id, short_addr, GetUTCTime(available_ts).c_str(), next_duration);
// } else {
// long available_ts = current_wave_start_ts_ + nth_eigen_value_slice_ * eigen_value_send_interval_ + (id - 1) * eigen_value_send_duration_;
// next_duration = available_ts - current_ts_;
// zlog_warn(zct, "[%d:%x] wrong time in eigen slice, next feature in current interval send utc time:[%s], duration:%d", id, short_addr, GetUTCTime(available_ts).c_str(), next_duration);
// }
// return kScheduleWrongTime;
// }
} else {
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);
@ -103,12 +103,12 @@ int SensorScheduler::StartSchedule(int short_addr, int &next_duration) {
}
}
if (update_.count(id)) {
// execute config
zlog_warn(zct, "[%d:%x] in wave slice to update config", id, short_addr);
current_request_ = kScheduleConfigSensor;
return kScheduleConfigSensor;
}
// if (update_.count(id)) {
// // execute config
// zlog_warn(zct, "[%d:%x] in wave slice to update config", id, short_addr);
// current_request_ = kScheduleConfigSensor;
// return kScheduleConfigSensor;
// }
wave_feature_set_inst::instance().GetWaveCfg(short_addr, g_x, g_y, g_z);
if (g_x || g_y || g_z) {
zlog_warn(zct, "[%d:%x] it is wave time", id, short_addr);
@ -135,12 +135,15 @@ int SensorScheduler::StartSchedule(int short_addr, int &next_duration) {
}
}
if (update_.count(id)) {
// execute config
zlog_warn(zct, "[%d:%x] in idle time to update config", id, short_addr);
current_request_ = kScheduleConfigSensor;
return kScheduleConfigSensor;
}
// if (retransfer_wave) {
// }
// if (update_.count(id)) {
// // execute config
// zlog_warn(zct, "[%d:%x] in idle time to update config", id, short_addr);
// current_request_ = kScheduleConfigSensor;
// return kScheduleConfigSensor;
// }
}
// wrong time to come
long available_ts = current_wave_start_ts_ + (nth_eigen_value_slice_ + 1) * eigen_value_send_interval_ + (id - 1) * eigen_value_send_duration_;
@ -326,6 +329,11 @@ SensorScheduler::SensorScheduler() {
}
void SensorScheduler::WaveError(int short_addr) {
return;
}
void SensorScheduler::WaveSuccess(int short_addr) {
return;
}

View File

@ -42,6 +42,7 @@ public:
int GetNextDuration(int short_addr);
void WaveError(int short_addr);
void WaveSuccess(int short_addr);
long GetBaseTimestamp(int id);
long CalcNextTimestamp(int id, uint16_t short_addr);