generated from wessel/boilerplate
[PR] Make the delay between random grades a parameter #5
@@ -7,6 +7,10 @@ ExamResultGenerator::ExamResultGenerator()
|
|||||||
gen_(rd_()),
|
gen_(rd_()),
|
||||||
grade_dist_(10, 100)
|
grade_dist_(10, 100)
|
||||||
{
|
{
|
||||||
|
this->declare_parameter("delay_between_grades_ms", 2000);
|
||||||
|
int delay_ms = this->get_parameter("delay_between_grades_ms").as_int();
|
||||||
|
delay_between_grades_ = std::chrono::milliseconds(delay_ms);
|
||||||
|
|
||||||
db_manager_ = std::make_unique<DatabaseManager>(this->get_logger());
|
db_manager_ = std::make_unique<DatabaseManager>(this->get_logger());
|
||||||
|
|
||||||
// Load initial student/course combinations from database
|
// Load initial student/course combinations from database
|
||||||
@@ -27,7 +31,7 @@ ExamResultGenerator::ExamResultGenerator()
|
|||||||
|
|
||||||
// Create timer to generate random exam results every 2 seconds
|
// Create timer to generate random exam results every 2 seconds
|
||||||
timer_ = this->create_wall_timer(
|
timer_ = this->create_wall_timer(
|
||||||
std::chrono::seconds(2),
|
delay_between_grades_,
|
||||||
std::bind(&ExamResultGenerator::generate_random_result, this)
|
std::bind(&ExamResultGenerator::generate_random_result, this)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
* Reviewed by: <x>
|
* Reviewed by: <x>
|
||||||
* Changelog:
|
* Changelog:
|
||||||
* [23-09-2025] Wessel T: Initial Implementation
|
* [23-09-2025] Wessel T: Initial Implementation
|
||||||
|
* [05-10-2025] Wessel T: Added delay between grades parameter
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
@@ -15,6 +16,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
#include "rclcpp/rclcpp.hpp"
|
#include "rclcpp/rclcpp.hpp"
|
||||||
#include "g2_2025_interfaces/msg/exam.hpp"
|
#include "g2_2025_interfaces/msg/exam.hpp"
|
||||||
@@ -42,10 +44,12 @@ private:
|
|||||||
|
|
||||||
std::vector<StudentCourse> operations_queue_;
|
std::vector<StudentCourse> operations_queue_;
|
||||||
|
|
||||||
|
std::chrono::milliseconds delay_between_grades_ { 2000 };
|
||||||
|
|
||||||
void queue_pending_combinations();
|
void queue_pending_combinations();
|
||||||
void generate_random_result();
|
void generate_random_result();
|
||||||
void student_management_callback(const g2_2025_interfaces::msg::Student::SharedPtr msg);
|
void student_management_callback(const g2_2025_interfaces::msg::Student::SharedPtr msg);
|
||||||
void add_student_course_combination(const StudentCourse& sc);
|
void add_student_course_combination(const StudentCourse& sc);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace lessons::zero::tmp
|
} // namespace assignments::one::exam_result_generator
|
||||||
|
|||||||
Reference in New Issue
Block a user