functional and commented
This commit is contained in:
parent
eb203bcf00
commit
e2f3584f47
10 changed files with 604 additions and 38 deletions
41
sensor_network.h
Normal file
41
sensor_network.h
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
#pragma once
|
||||
#include <thread>
|
||||
#include <atomic>
|
||||
#include <vector>
|
||||
#include "ring_buffer.h"
|
||||
#include "analysis_model.h"
|
||||
|
||||
/**
|
||||
* Hauptklasse des Sensornetzwerks
|
||||
* @tparam N Größe des Ringpuffers
|
||||
*
|
||||
* Verwaltet alle Komponenten:
|
||||
* - Ringpuffer für Sensordaten
|
||||
* - Analysemodell
|
||||
* - Threads für Sensoren, Analyse und Controller
|
||||
*/
|
||||
template <size_t N>
|
||||
class SensorNetwork {
|
||||
RingBuffer<N> buffer; // Gemeinsamer Datenpuffer
|
||||
AnalysisModel model; // Geteiltes Analysemodell
|
||||
std::atomic<bool> running{false}; // Steuerflag für Threads
|
||||
|
||||
// Thread-Container
|
||||
std::vector<std::thread> sensors;
|
||||
std::vector<std::thread> analysers;
|
||||
std::thread controller;
|
||||
|
||||
public:
|
||||
~SensorNetwork() {
|
||||
if (running) stop();
|
||||
}
|
||||
|
||||
void start(size_t num_sensors, size_t num_analysers);
|
||||
void stop();
|
||||
|
||||
private:
|
||||
// Thread-Funktionen
|
||||
void sensor_thread(int id);
|
||||
void analyser_thread(int id);
|
||||
void controller_thread();
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue