diff --git a/doc/wave_filter.jsonc b/doc/wave_filter.jsonc new file mode 100644 index 0000000..4e2913d --- /dev/null +++ b/doc/wave_filter.jsonc @@ -0,0 +1,69 @@ +下面信息对于特征值与波形保持一致,只在命令号上做区别 +// 更新全部配置的内容 +{ + "partial": false, // 如果提交全部的话,此项为false,提交部分的话,此项为true + "global": [1, 1, 1], + "3259": [0, 1, 0], + "4123": [1, 1, 0], + "4326": [1, 1, 0] +} + +// 更新部分配置的内容 +{ + "partial": true, // 如果提交全部的话,此项为false,提交部分的话,此项为true + "4326": [1, 1, 0] +} + +// 获取特征值配置内容 +// 请求 +{ + "cmd": "63", + "sub_cmd": 0 // 0:获取,1:设置 +} + +// 响应 +{ + "cmd": "63", + "success": true, + "sub_cmd": 0, // 0:获取,1:设置 + "cmdBody": { + "global": [1, 1, 1], + "3259": [0, 1, 0], + "4123": [1, 1, 0], + "4326": [1, 1, 0] + } +} + +// 请求 + +// 设置特征值配置内容-全部 +{ + "cmd": "63", + "sub_cmd": 1, // 0:获取,1:设置 + "cmdBody": { + "partial": false, + "global": [1, 1, 1], + "3259": [0, 1, 0], + "4123": [1, 1, 0], + "4326": [1, 1, 0] + } +} + +// 设置部分 +{ + "cmd": "63", + "sub_cmd": 1, // 0:获取,1:设置 + "cmdBody": { + "partial": true, // 当设置部分时,只能提交一条记录 + "4326": [1, 1, 0] + } +} + +// 响应 +{ + "cmd": "63", + "sub_cmd": 1, // 0:获取,1:设置 + "success": true +} + +波形的设置使用命令号:"64",其它格式与特征值保持一致 \ No newline at end of file diff --git a/scheduler/schedule.cpp b/scheduler/schedule.cpp index de485be..79c3bb9 100644 --- a/scheduler/schedule.cpp +++ b/scheduler/schedule.cpp @@ -10,10 +10,13 @@ #include #include "short_addr_cfg.hpp" #include "update_cfg.hpp" +#include "wave_feature_set.hpp" extern zlog_category_t *zct; extern zlog_category_t *zbt; +uint8_t g_x, g_y, g_z; + int SensorScheduler::StartSchedule(int short_addr, int &next_duration) { int id = 0; auto iter = short_addr_map_.find(short_addr); @@ -52,10 +55,17 @@ int SensorScheduler::StartSchedule(int short_addr, int &next_duration) { current_request_ = kScheduleConfigSensor; return kScheduleConfigSensor; } else { - // 执行上送特征值任务 - zlog_warn(zct, "[%d:%x] send eigen value in eigen slice", id, short_addr); - current_request_ = kScheduleEigenValue; - return kScheduleEigenValue; + wave_feature_set_inst::instance().GetFeatureCfg(short_addr, g_x, g_y, g_z); + if (g_x || g_y || g_z) { + // 执行上送特征值任务 + zlog_warn(zct, "[%d:%x] send eigen value in eigen slice", id, short_addr); + current_request_ = kScheduleEigenValue; + return kScheduleEigenValue; + } else { + next_duration = GetNextDuration(short_addr); + zlog_warn(zct, "[%d:%x] no need for eigen", id, short_addr); + return kScheduleWrongTime; + } } } else { zlog_warn(zct, "[%d:%x] Invalid request, revive in %d eigen slice", id, short_addr, nth_eigen_slice_ + 1); @@ -99,9 +109,16 @@ int SensorScheduler::StartSchedule(int short_addr, int &next_duration) { current_request_ = kScheduleConfigSensor; return kScheduleConfigSensor; } - zlog_warn(zct, "[%d:%x] it is wave time", id, short_addr); - current_request_ = kScheduleWaveForm; - return kScheduleWaveForm; + 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); + current_request_ = kScheduleWaveForm; + return kScheduleWaveForm; + } else { + next_duration = GetNextDuration(short_addr); + zlog_warn(zct, "[%d:%x] no need for wave", id, short_addr); + return kScheduleWrongTime; + } } else { if (slice_sensor_id_[nth_wave_slice-1] == 0) { zlog_warn(zct, "[%d:%x] in idle time", id, short_addr); @@ -147,14 +164,17 @@ long SensorScheduler::CalcNextTimestamp(int id, uint16_t short_addr) { } int wave_slice = wave_slice_iter->second; // 从1开始 long send_wave_ts = 0; - if (wave_slice > forward_wave_slice_num && - wave_slice <= forward_wave_slice_num + wave_slice_num_per_eigen_interval_) { - // 发送波的时间窗也在本次特征值发送间隔中 - for (int i = forward_wave_slice_num; i <= forward_wave_slice_num + wave_slice_num_per_eigen_interval_; ++i) { - if (wave_slice - 1 == i) { - send_wave_ts = current_wave_start_ts_ + nth_eigen_value_slice_ * eigen_value_send_interval_ + eigen_value_slice_total_seconds_ + (i - forward_wave_slice_num) * seconds_per_wave_slice_; - zlog_warn(zct, "[Nxt] [%d:%x] send wave time:[%s]", id, short_addr, GetUTCTime(send_wave_ts).c_str()); - break; + wave_feature_set_inst::instance().GetWaveCfg(short_addr, g_x, g_y, g_z); + if (g_x || g_y || g_z) { + if (wave_slice > forward_wave_slice_num && + wave_slice <= forward_wave_slice_num + wave_slice_num_per_eigen_interval_) { + // 发送波的时间窗也在本次特征值发送间隔中 + for (int i = forward_wave_slice_num; i <= forward_wave_slice_num + wave_slice_num_per_eigen_interval_; ++i) { + if (wave_slice - 1 == i) { + send_wave_ts = current_wave_start_ts_ + nth_eigen_value_slice_ * eigen_value_send_interval_ + eigen_value_slice_total_seconds_ + (i - forward_wave_slice_num) * seconds_per_wave_slice_; + zlog_warn(zct, "[Nxt] [%d:%x] send wave time:[%s]", id, short_addr, GetUTCTime(send_wave_ts).c_str()); + break; + } } } } @@ -650,11 +670,15 @@ void SensorScheduler::ClearScheduleCfg(int short_addr) { ShortAddrCfg::ClearCfg(); UpdateCfg::ClearCfg(); UpgradeCfg::ClearCfg(); + wave_feature_set_inst::instance().RemoveAllFeatureCfg(); + wave_feature_set_inst::instance().RemoveAllWaveCfg(); } else { UpdateConfigResult(short_addr, 0); UpgradeResult(short_addr, kUpgradeSuccess); short_addr_map_.erase(short_addr); ShortAddrCfg::WriteCfg(short_addr_map_); + wave_feature_set_inst::instance().RemoveFeatureCfg(short_addr); + wave_feature_set_inst::instance().RemoveWaveCfg(short_addr); } }