-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUartMeasurementRecorder.hpp
104 lines (89 loc) · 3.61 KB
/
UartMeasurementRecorder.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/**
* @file UartMeasurementRecorder.hpp
* @brief Defines the UartMeasurementRecorder class responsible for sending measurement data
* to a COM port via UART over USB.
*/
#ifndef UartMeasurementRecorder_H_
#define UartMeasurementRecorder_H_
#include "Device/Interfaces/IMeasurementRecorder.hpp"
#include "Driver/Interfaces/IUartDriver.hpp"
namespace Device
{
/**
* @class UartMeasurementRecorder
* @brief Handles sending measurement data to a computer's COM port via UART over USB.
*
* The UartMeasurementRecorder class interacts with a UART driver to send measurement data
* over a COM port, typically using UART over USB. It provides methods to manage the
* initialization, transmission, and lifecycle of the data recording process.
*/
class UartMeasurementRecorder : public IMeasurementRecorder
{
public:
/**
* @brief Constructs a UartMeasurementRecorder with a reference to a UART driver.
*
* @param driver Reference to the UART driver responsible for managing UART communication.
*/
explicit UartMeasurementRecorder(Driver::IUartDriver &driver);
/**
* @brief Default destructor for UartMeasurementRecorder.
*/
~UartMeasurementRecorder() override = default;
/**
* @brief Deleted copy constructor to prevent copying.
*/
UartMeasurementRecorder(const UartMeasurementRecorder &) = delete;
/**
* @brief Deleted assignment operator to prevent assignment.
* @return UartMeasurementRecorder& The assigned object.
*/
UartMeasurementRecorder &operator=(const UartMeasurementRecorder &) = delete;
/**
* @brief Flushes any remaining data to the COM port via UART.
*
* This method ensures that any remaining buffered data is sent to the COM port via UART.
*/
bool flush() override;
/**
* @brief Notifies the recorder to process new data.
*
* This method is called to notify the recorder that new measurement data is available
* and should be sent to the COM port via UART.
*/
bool notify(Device::MeasurementType &measurement) override;
protected:
/**
* @brief Initializes the UartMeasurementRecorder.
*
* This method is responsible for initializing the recorder and preparing it for operation.
* @return True if initialization was successful, false otherwise.
*/
bool onInitialize() override;
/**
* @brief Starts the UartMeasurementRecorder.
*
* This method starts the recorder, enabling it to begin sending measurement data to the COM port via UART.
* @return True if the recorder started successfully, false otherwise.
*/
bool onStart() override;
/**
* @brief Stops the UartMeasurementRecorder.
*
* This method stops the recorder, halting any further transmission of measurement data.
* @return True if the recorder stopped successfully, false otherwise.
*/
bool onStop() override;
/**
* @brief Resets the UartMeasurementRecorder.
*
* This method resets the recorder, clearing any internal state or buffers.
* @return True if the recorder was reset successfully, false otherwise.
*/
bool onReset() override;
private:
/** @brief Reference to the UART driver used for communication with the COM port. */
Driver::IUartDriver &driver;
};
}
#endif // UartMeasurementRecorder_H_