Skip to content

Development Log

Murat Toğunçhan Düzgün edited this page Sep 27, 2025 · 2 revisions

Development Log

This page tracks the day-to-day progress of the SecureEdgePlatform / SensorSimulator project.
Each entry documents what was done and what was learned.


2025-09-26

✅ Achievements

  • Refactored CMake project structure:
    • Introduced sensor_impl library to share code between executables and tests.
    • Moved main() out of EdgeShell.cpp into a new src/main_shell.cpp file.
  • Fixed critical ownership issue:
    • Sensors are now stored once in sensors_ (as std::unique_ptr<ISensor>).
    • Scheduler receives only a raw pointer (ISensor*) to avoid double ownership.
    • Resolved segmentation fault during real-time simulation (run command).
  • Added template helper getScheduledSensorAs<T> in SensorScheduler for safe downcasting.
  • Implemented case-insensitive handling for sensor IDs (TEMP, PRES, etc.).
  • Wrote new Catch2 unit tests (tests/test_cli.cpp):
    • Adding TEMP sensor
    • Adding PRES sensor
    • Rejecting unsupported sensor types
    • Case-insensitive ID handling
      → All tests are now passing ✅

🔍 Lessons Learned

  • Importance of single ownership with unique_ptr and raw pointer handover.
  • How splitting logic into libraries (sensor_impl) prevents duplicate main() issues in tests.
  • Practical usage of dynamic_cast and templates for polymorphic access.

2025-09-27

✅ Achievements

  • Implemented stop() API in EdgeShell with std::condition_variable and std::mutex to safely halt the real-time loop.
  • Updated RunCommand to use cv_.wait_for for cooperative waiting.
  • Simplified StopCommand to directly invoke EdgeShell::stop().
  • Extended CLI output: stepSensor and tick loop now print sensor IDs alongside values.
  • Wrote integration tests (tests/test_cli.cpp) simulating REPL input via std::istringstream and redirected std::cin/std::cout to validate run/stop flows without blocking.
  • Removed deprecated EdgeCLI menu-based interface.
  • Added a comprehensive README.md for the SensorSimulator module.
  • Cleaned up repo (removed accidental .DS_Store from version control).

🔍 Lessons Learned

  • Testing REPL applications requires simulating std::cin / std::cout streams; otherwise tests block indefinitely.
  • condition_variable is the right way to cooperatively control background threads (run / stop) in a CLI-driven simulation.
  • Documentation (README) not only improves onboarding but also serves as a checkpoint for architectural clarity.
  • Removing obsolete code (EdgeCLI) helps keep the project lean and focused.

(End of entry — new logs will be appended below with dates.)

Clone this wiki locally