Skip to content

Serial port sensor data processing using multithreaded C++ with Producer-Consumer-Pattern, CircularBuffer, Objectoriented Programming, Jumping Windows, Factory Patterns and Containers.

License

Notifications You must be signed in to change notification settings

s-voelkl/Multithreaded-Sensor-DataProcessing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Serial Port Sensor Data Processing

Overview

This project implements serial port sensor data processing using multithreaded C++ techniques. It incorporates the Producer-Consumer Pattern, Circular Buffer, Object-Oriented Programming, Jumping Windows, Factory Patterns, and Containers.

Documentation and Resources

  • Doxygen Documentation: Available at ./Other/Doxygen/html/index.html, providing class structures and more.
  • Sources and LLM Usage: Refer to ./Other/sources.txt.
  • Example Console Output: See ./Other/example_console_output.txt.
  • UML Diagram: Located at ./Other/UML_Diagram.png.
  • Output Files: Generated output can be found in the ./Output/ directory.
  • Project Summary: This file contains a brief description of the project.

Project Structure

The project is organized into header (.h) and source (.cpp) files. Execution begins from main.cpp, where initial tests are performed on custom classes. Subsequently, a thread is created for line-by-line processing using the Producer-Consumer Pattern, and a connection to the serial port is established. Please note that the SerialPort.cpp was initially written by Prof. Dr.-Ing. Gerald Pirkl at the Department of Electrical Engineering, Media and Computer Science of the OTH Amberg-Weiden.

Data Processing Workflow

Each incoming line from the serial port is temporarily stored in a Circular Buffer (ring buffer). The LineProcessingWorker processes these lines, waiting for notifications and ensuring at least one element is present in the buffer before proceeding.

Lines are processed with comprehensive error handling. Using the Factory Pattern, a generic string line is converted into a subclass of SensorRecord.

A map structure is used where the key is the sensor type (e.g., temperature sensor) and the value is a Sensor object. Each Sensor holds zero or more SensorRecord entries.

If a SensorRecord contains a sensor type not yet present in the map, a new entry is created. The SensorRecord is then added to the corresponding Sensor. Once the number of stored SensorRecords reaches the threshold for file output, the data is written to the appropriate file and the records are cleared from the Sensor (Jumping Window). Average calculations are performed as needed.

Error Handling

Numerous error sources are addressed in the console output.
Note: std::cerr error messages may appear prematurely or belatedly.

Additional Concepts

The project integrates various advanced programming concepts, including:

  • Containers and Iterators
  • Multithreading and Synchronization
  • Custom Exceptions
  • Polymorphism and Inheritance

About

Serial port sensor data processing using multithreaded C++ with Producer-Consumer-Pattern, CircularBuffer, Objectoriented Programming, Jumping Windows, Factory Patterns and Containers.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published