CrossGuard
|
Manages and operates the monitoring system for both pedestrian and vehicle detection. More...
#include <CheckingSystem.h>
Public Member Functions | |
CheckingSystem () | |
Constructor to initialize the system with default states and sensor configurations. | |
~CheckingSystem () | |
Destructor to clean up resources, ensuring all threads are joined if necessary. | |
void | initialize () |
Initialize sensors and system components. | |
void | run () |
Start the system's main operation loop. | |
void | deactivate () |
Safely deactivate and shutdown all system operations. | |
void | onPedestriansButtonPress () |
Handler for pedestrian button presses. | |
void | registerCarsMotionCallback (const std::function< void()> &callback) |
Registers a callback function for car motion detection. | |
void | registerPedestriansMotionCallback (const std::function< void()> &callback) |
Registers a callback function for pedestrian motion detection. | |
void | registerPedestriansButtonCallback (const std::function< void()> &callback) |
Registers a callback function for pedestrian button press. | |
void | enablePedestriansMotionDetection () |
Enables the motion detection for pedestrians. | |
void | disablePedestriansMotionDetection () |
Disables the motion detection for pedestrians. | |
void | enableCarsMotionDetection () |
Enables the motion detection for cars. | |
void | disableCarsMotionDetection () |
Disables the motion detection for cars. | |
void | enablePedestriansButton () |
Enables the use of the pedestrian button. | |
void | disablePedestriansButton () |
Disables the pedestrian button to prevent its use. | |
void | enableSensing () |
Enable all sensors and detection mechanisms. | |
void | disableSensing () |
Disable all sensors and detection mechanisms. | |
Manages and operates the monitoring system for both pedestrian and vehicle detection.
Integrates multiple sensors and provides functionalities to register callbacks, activate or deactivate detection, and manage system states through an interface designed for real-time traffic monitoring.
CheckingSystem::CheckingSystem | ( | ) |
Constructor to initialize the system with default states and sensor configurations.
Constructor for the CheckingSystem class. Initializes all member variables and configures sensors with the appropriate pins.
CheckingSystem::~CheckingSystem | ( | ) |
Destructor to clean up resources, ensuring all threads are joined if necessary.
Destructor for the CheckingSystem class. Ensures all components are properly deactivated and threads are joined before destruction.
void CheckingSystem::deactivate | ( | ) |
Safely deactivate and shutdown all system operations.
Deactivates the system and ensures a clean shutdown. Sets isActive to false and waits for a brief period to allow threads to finish gracefully.
void CheckingSystem::disableSensing | ( | ) |
Disable all sensors and detection mechanisms.
Deactivates all sensors and detection mechanisms in the system. Calls individual disable methods for pedestrian and vehicle detection and button usage.
void CheckingSystem::enableSensing | ( | ) |
Enable all sensors and detection mechanisms.
Activates all sensors and detection mechanisms in the system. Calls individual enable methods for pedestrian and vehicle detection and button usage.
void CheckingSystem::initialize | ( | ) |
Initialize sensors and system components.
Initializes sensors and registers button press callbacks. Configures and initializes all associated sensors and registers callback for the pedestrian button.
void CheckingSystem::onPedestriansButtonPress | ( | ) |
Handler for pedestrian button presses.
Handles actions to be performed when the pedestrian button is pressed. If the button is enabled and the callback is set, it triggers the registered callback.
void CheckingSystem::registerCarsMotionCallback | ( | const std::function< void()> & | callback | ) |
Registers a callback function for car motion detection.
callback | Function to call when car motion is detected. |
void CheckingSystem::registerPedestriansButtonCallback | ( | const std::function< void()> & | callback | ) |
Registers a callback function for pedestrian button press.
callback | Function to call when the pedestrian button is pressed. |
void CheckingSystem::registerPedestriansMotionCallback | ( | const std::function< void()> & | callback | ) |
Registers a callback function for pedestrian motion detection.
callback | Function to call when pedestrian motion is detected. |
void CheckingSystem::run | ( | ) |
Start the system's main operation loop.
Main operation function which activates all systems and starts monitoring. Launches threads for pedestrian and road monitoring and waits for them to complete.
This method initializes the active monitoring process for both pedestrians and vehicles. It starts two threads: one for pedestrian monitoring and another for road monitoring. Both threads are joined to ensure that the system continues running until both monitoring processes complete.
std::system_error | if thread creation fails. |