Revert "removed comments"

This reverts commit d194d9e18d.
This commit is contained in:
portnoytmy 2025-06-03 07:48:50 +02:00
parent d194d9e18d
commit f3a82ab88b
6 changed files with 167 additions and 24 deletions

View file

@ -4,11 +4,16 @@
#include <limits>
#include <thread>
// Standardkonfiguration
constexpr size_t DEFAULT_NUM_SENSORS = 3;
constexpr size_t DEFAULT_NUM_ANALYSERS = 2;
constexpr int DEFAULT_RUN_TIME = 30;
constexpr int DEFAULT_RUN_TIME = 30; // Sekunden
constexpr size_t DEFAULT_BUFFER_SIZE = 8;
/**
* Führt die Simulation mit gegebenen Parametern aus
* @tparam N Puffergröße
*/
template<size_t N>
void run_simulation(size_t num_sensors, size_t num_analysers, int run_time) {
SensorNetwork<N> network;
@ -25,13 +30,21 @@ void run_simulation(size_t num_sensors, size_t num_analysers, int run_time) {
std::cout << "\n=== Simulation beendet ===\n";
}
/**
* Liest Benutzereingabe mit Standardwert
* @param prompt Eingabeaufforderung
* @param default_value Standardwert bei leerer Eingabe
* @return Eingegebener oder Standardwert
*/
size_t get_input(const std::string& prompt, size_t default_value) {
std::cout << prompt << " [" << default_value << "]: ";
std::string input;
std::getline(std::cin, input);
// Verwende Standardwert bei leerer Eingabe
if(input.empty()) return default_value;
// Konvertiere Eingabe
try {
return std::stoul(input);
} catch(...) {
@ -45,6 +58,7 @@ int main() {
std::cout << "=== Sensornetzwerk-Simulation ===\n"
<< "(Leere Eingabe verwendet Standardwerte)\n";
// Interaktive Konfiguration
size_t num_sensors = get_input("Anzahl Sensoren", DEFAULT_NUM_SENSORS);
size_t num_analysers = get_input("Anzahl Analysemodule", DEFAULT_NUM_ANALYSERS);
int run_time = static_cast<int>(
@ -52,6 +66,7 @@ int main() {
);
size_t buffer_size = get_input("Puffergröße", DEFAULT_BUFFER_SIZE);
// Starte Simulation basierend auf Puffergröße
switch(buffer_size) {
case 8:
run_simulation<8>(num_sensors, num_analysers, run_time);
@ -72,4 +87,4 @@ int main() {
std::cout << "Simulation erfolgreich abgeschlossen.\n";
return 0;
}
}