-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #177 from RobertGawron/feature/storage_implementation
add dev and ut for measurement data handling
- Loading branch information
Showing
34 changed files
with
1,015 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
@startuml | ||
state "Idle" as IDLE | ||
state "Initialize" as INIT | ||
state "Run" as RUN | ||
state "Sleep" as SLEEP | ||
state "Fault" as FAULT | ||
state "Power Off" as POWER_OFF | ||
|
||
[*] --> IDLE : Power On | ||
IDLE --> INIT : onInitialize() | ||
INIT --> RUN : Initialization Complete | ||
|
||
RUN --> SLEEP : onStop() | ||
SLEEP --> RUN : onStart() | ||
|
||
RUN --> FAULT : Fault Detected | ||
FAULT --> INIT : Recover and Reinitialize | ||
|
||
RUN --> POWER_OFF : onPowerOff() | ||
SLEEP --> POWER_OFF : onPowerOff() | ||
FAULT --> POWER_OFF : Emergency Shutdown | ||
|
||
POWER_OFF --> [*] : Power Down Complete | ||
@enduml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
Software/STM32F103RBTx/Application/BusinessLogic/Interfaces/IMeasurementDataStore.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/** | ||
* @file IMeasurementDataStore.hpp | ||
* @brief Defines the IMeasurementDataStore class which manages the storage of measurement data | ||
* using the observer pattern. | ||
*/ | ||
|
||
#ifndef IMeasurementDataStore_H_ | ||
#define IMeasurementDataStore_H_ | ||
|
||
#include "BusinessLogic/Inc/SaferArray.hpp" | ||
#include "Device/Interfaces/IMeasurementRecorder.hpp" | ||
#include "Device/Interfaces/IMeasurementSource.hpp" | ||
#include <cstdint> | ||
|
||
namespace BusinessLogic | ||
{ | ||
/** | ||
* @class IMeasurementDataStore | ||
* @brief Implements the observer pattern to manage a collection of measurement recorders. | ||
* | ||
* This class allows clients to add or remove observers that store measurement data. | ||
* Observers can represent different storage methods such as SD card, Wi-Fi, UART, etc. | ||
* It is responsible for initializing and notifying all registered observers when new | ||
* measurement data is ready. | ||
*/ | ||
class IMeasurementDataStore | ||
{ | ||
public: | ||
/** | ||
* @brief Default constructor for IMeasurementDataStore. | ||
*/ | ||
explicit IMeasurementDataStore() = default; | ||
|
||
/** | ||
* @brief Destructor for IMeasurementDataStore. | ||
*/ | ||
virtual ~IMeasurementDataStore() = default; | ||
|
||
/** | ||
* @brief Deleted copy constructor to prevent copying. | ||
*/ | ||
IMeasurementDataStore(const IMeasurementDataStore &) = delete; | ||
|
||
/** | ||
* @brief Deleted assignment operator to prevent assignment. | ||
* @return IMeasurementDataStore& The assigned object. | ||
*/ | ||
IMeasurementDataStore &operator=(const IMeasurementDataStore &) = delete; | ||
|
||
/** | ||
* @brief Adds an observer that records measurement data. | ||
* | ||
* The observer should implement the IMeasurementRecorder interface, and this method will | ||
* add it to the list of observers managed by the IMeasurementDataStore. | ||
* | ||
* @param observer Reference to an object that implements IMeasurementRecorder. | ||
* @return True if the observer was successfully added; false otherwise. | ||
*/ | ||
virtual bool addObserver(Device::IMeasurementRecorder &observer) = 0; | ||
|
||
/** | ||
* @brief Removes an observer that records measurement data. | ||
* | ||
* This method removes an observer from the list of registered observers, stopping it | ||
* from receiving updates about new measurement data. | ||
* | ||
* @param observer Reference to an object that implements IMeasurementRecorder. | ||
* @return True if the observer was successfully removed; false otherwise. | ||
* @note Removing the observer does not automatically deinitialize it. | ||
*/ | ||
virtual bool removeObserver(Device::IMeasurementRecorder &observer) = 0; | ||
|
||
/** | ||
* @brief Initializes the IMeasurementDataStore and all registered observers. | ||
* | ||
* This function initializes the IMeasurementDataStore and all the objects | ||
* registered via addObserver(). | ||
* | ||
* @return True if initialization was successful; false otherwise. | ||
* @note Observers should not be initialized manually in other classes such as ApplicationBuilder. | ||
*/ | ||
virtual bool initialize() = 0; | ||
|
||
/** | ||
* @brief Starts the IMeasurementDataStore and all registered observers. | ||
* | ||
* This function starts the IMeasurementDataStore and prepares all registered observers to start | ||
* recording measurement data. | ||
* | ||
* @return True if start was successful; false otherwise. | ||
*/ | ||
virtual bool start() = 0; | ||
|
||
/** | ||
* @brief Notifies all registered observers that new measurement data is ready to be stored. | ||
* | ||
* This function iterates through the list of registered observers and notifies each one | ||
* that new measurement data is available for storage. | ||
*/ | ||
virtual bool notifyObservers(Device::MeasurementType measurement) = 0; | ||
}; | ||
} | ||
|
||
#endif // IMeasurementDataStore_H_ |
Oops, something went wrong.