Commit Graph

23 Commits

Author SHA1 Message Date
Huamonarch
18a5675109 fix: 子类实现 doMonProc() + 测试 CMake 添加缺失链接文件 2026-05-15 15:51:55 +08:00
Huamonarch
4032ff92ef fix: 将测试文件中 "" include 改为 <> 风格,统一项目规范 2026-05-15 15:22:04 +08:00
Huamonarch
ae7834adaa refactor: 算法子类化 — LogicAlg/BoundAlg/BoundHoldAlg/FeedbackAlg 消除 exp_type_ 分支
将 ExpBase::mon_proc() 中的 exp_type_ 分支逻辑提取为 4 个子类,通过 doMonProc() 虚函数实现多态分发:
- LogicAlg (exp_type 1):实时逻辑判断
- BoundAlg (exp_type 2):监控变量上下限检测
- BoundHoldAlg (exp_type 5):持续超限检测(继承 BoundAlg)
- FeedbackAlg (exp_type 3/4):动作反馈处理

ExpBase 新增纯虚函数 doMonProc() 和钩子函数 doInitExtend(),
init() 和 mon_proc() 中所有类型分支替换为虚函数委托调用。
2026-05-15 14:37:15 +08:00
Huamonarch
4f8eecd828 refactor: 提取 StatCollector 统计学习组件
将 ExpBase::cron_proc() 中的 DAA::STA 统计学习逻辑提取到独立的
StatCollector 工具类,统一管理分布统计的生命周期(样本累积、分布
初始化、DB2 持久化、置信区间更新)。同时将 exec_task() 与
task_mon_pro() 中的任务相关 STA 操作也委托给 StatCollector。

新增:
- eqpalg/utility/stat_collector.h  -- StatCollector 接口
- eqpalg/utility/stat_collector.cpp -- StatCollector 实现

修改:
- eqpalg/algs/exp_base.h  -- 替换 sta_ptr_ 为 stat_collector_
- eqpalg/algs/exp_base.cpp -- cron_proc/reload_ci_dist/reset_dev_data/
                               exec_task/task_mon_pro 委托给 StatCollector
2026-05-15 14:21:36 +08:00
Huamonarch
b9cf5f4e9e refactor: 提取 BoundChecker 上下限检测组件
从 ExpBase 提取 detect_up_down() 逻辑和哨兵值处理至独立的 BoundChecker 类。
将 DetectMode 从 struct 升级为 enum class。
2026-05-15 14:09:56 +08:00
Huamonarch
c4bcb6610b refactor: 删除旧反馈状态方法和标志(已由 FbStateMachine 替代) 2026-05-15 13:57:20 +08:00
Huamonarch
0106e553a0 refactor: 集成 FbStateMachine 到 ExpBase::mon_proc() 2026-05-15 13:36:30 +08:00
Huamonarch
3f8d281596 fix: 清理 ExpBase 子类中的 exp_act_/exp_feedback_/exp_result_ 残留引用
将 exp_bound、exp_times、exp_sample2D 中对已删除成员的引用替换为
expr_engine_->evaluate()/evaluateBool() 调用。
exp_sample2D 中原来绑定 exp_feedback_ 和 exp_result_ 的 sample_X/sample_Y
表达式现在通过 expr_engine_->registerExpression() 注册。
2026-05-15 13:14:17 +08:00
Huamonarch
38d0942a6c refactor: 非 ExpBase 算法适配 ExpressionEngine API 2026-05-15 13:08:30 +08:00
Huamonarch
7c2fe7f7bb refactor: ExpBase 表达式管理迁移到 ExpressionEngine 2026-05-15 12:59:11 +08:00
Huamonarch
f80a917ab7 Async-ify ExpTimes DB persistence with global singleton worker thread
Add AsyncDbWorker: a persistent background thread with dedup queue that
executes DB2 writes asynchronously, keeping the mon 20ms cycle free of
blocking I/O.

Changes:
- async_db_worker.h/.cc: singleton worker, submit() with rule_id dedup,
  drain_and_stop() for clean shutdown
- eqp_stat.h/.cc: new update_static(ruleid, shear_times, running_time)
  overload that skips redundant DB reads for known values (reduces
  5 SELECTs to 3 per persist cycle)
- exp_times.cc: extract persist_exp_times() as a standalone function,
  update_history_times() snapshots values and submits to worker
  (returns immediately), reset_dev_data() uses direct SHM update
- eqpalg_icei.cpp: alg_mgr_.reset() → drain_and_stop() in destructor
  ensures all algorithm threads are stopped before draining the worker

Risk: re-run cmake .. to pick up the new async_db_worker.cc file.
2026-05-13 13:32:50 +08:00
Huamonarch
6ed178b367 Fix: protect update_history_times snapshot restore from DB failures
Three fixes in update_history_times():
1. Wrap DB operations in try-catch — exception no longer skips the
   snapshot restore, preventing permanent loss of accumulated counts
2. Treat get_history_times() -1 return (DB failure) as skip, not as
   "record exists" → no more silent UPDATE on non-existent rows
3. Only call update_static and advance last_load_time_ on success,
   so a failed persist retries on the next cycle instead of waiting
   another rw_time_ minutes
2026-05-13 12:59:16 +08:00
Huamonarch
0a5397345c Fix: access TaskRecord::data_record vector after TaskData refactor
Commit e21b2af changed TaskShm map value from DataRecord (flat array)
to TaskRecord (struct wrapping shm_vector_f), but three call sites in
exp_base.cpp didn't drill into the .data_record member — they called
size()/operator[]/push_back() on TaskRecord itself, which has none.
2026-05-13 09:15:20 +08:00
Huamonarch
e21b2af2a6 Replace fixed 518MB array in TaskData with dynamic shared-memory vector
DataRecord used a fixed float[129600000] consuming 5GB disk even when
collecting only a few hundred data points. Replaced with shm_vector_f
that grows on demand via push_back. Removes the need for rm -rf on
process exit — vector destructor frees memory back to the segment.
Also drops now-unnecessary task_data_size member.
2026-05-12 17:19:44 +08:00
Huamonarch
6a28112cd7 Final comment cleanup batch 2026-05-09 13:35:17 +08:00
Huamonarch
38bbdb5b34 Remove comment from roller3.cpp 2026-05-09 13:33:07 +08:00
Huamonarch
ecf02306b2 Remove final remaining comment from distribution.h 2026-05-09 13:32:24 +08:00
Huamonarch
c53b108500 Remove last remaining comments from eqpalg 2026-05-09 13:32:10 +08:00
Huamonarch
62a97cdf9d Remove remaining comments (exp_times, STA.h, gb_item_memory) 2026-05-09 13:31:22 +08:00
Huamonarch
48c9fe7f22 Remove remaining irrelevant comments from eqpalg (final batch) 2026-05-09 13:31:06 +08:00
Huamonarch
e3207fa593 Remove remaining irrelevant comments from eqpalg (glitch_detection, roller, STA) 2026-05-09 13:30:42 +08:00
Huamonarch
224c2c45c4 Remove irrelevant comments from eqpalg source files
Cleaned 66 files across all eqpalg subdirectories:
- Removed commented-out dead code
- Removed redundant Chinese inline comments that restate variable/function names
- Removed trailing ///< annotations on self-explanatory fields
- Removed namespace closing comments
- Preserved all file headers, Doxygen documentation, and logic explanations
- No code changes — only comment removal
2026-05-09 13:30:09 +08:00
Huamonarch
7e602c7bc1 Initial commit: EIS C++ project with multi-process code 2026-05-09 11:23:45 +08:00