Skip to content

Commit a7dbf88

Browse files
fix(rtbot): debug mode to all runtime functions
1 parent 0d54f3f commit a7dbf88

24 files changed

+42
-35
lines changed

libs/core/include/rtbot/Buffer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ class Buffer : public Operator {
183183
}
184184

185185
protected:
186-
void process_data() override {
186+
void process_data(bool debug=false) override {
187187
auto& input_queue = get_data_queue(0);
188188

189189
while (!input_queue.empty()) {

libs/core/include/rtbot/Demultiplexer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class Demultiplexer : public Operator {
5151

5252
protected:
5353

54-
void process_data() override {
54+
void process_data(bool debug=false) override {
5555
while(true) {
5656

5757
bool is_any_control_empty;

libs/core/include/rtbot/FilterByValue.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class FilterByValue : public Operator {
2626
}
2727

2828
protected:
29-
void process_data() override {
29+
void process_data(bool debug=false) override {
3030
auto& input_queue = get_data_queue(0);
3131
auto& output_queue = get_output_queue(0);
3232

libs/core/include/rtbot/Input.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class Input : public Operator {
5353
}
5454

5555
protected:
56-
void process_data() override {
56+
void process_data(bool debug=false) override {
5757
// Process each port independently to allow concurrent timestamps
5858
for (int port_index = 0; port_index < num_data_ports(); port_index++) {
5959
const auto& input_queue = get_data_queue(port_index);

libs/core/include/rtbot/Join.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class Join : public Operator {
9393
protected:
9494
// Performs synchronization of input messages
9595

96-
void process_data() override {
96+
void process_data(bool debug=false) override {
9797

9898
while(true) {
9999

libs/core/include/rtbot/Multiplexer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class Multiplexer : public Operator {
7777

7878
protected:
7979

80-
void process_data() override {
80+
void process_data(bool debug=false) override {
8181
while (true) {
8282

8383
int num_empty_data_ports = 0;

libs/core/include/rtbot/Operator.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,13 @@ class Operator {
202202
// Process control messages first
203203
if (num_control_ports() > 0) {
204204
SpanScope control_scope{"process_control"};
205-
process_control();
205+
process_control(debug);
206206
}
207207

208208
// Then process data
209209
if (num_data_ports() > 0) {
210210
SpanScope data_scope{"process_data"};
211-
process_data();
211+
process_data(debug);
212212
}
213213

214214
#ifdef RTBOT_INSTRUMENTATION
@@ -410,8 +410,8 @@ class Operator {
410410
}
411411

412412
protected:
413-
virtual void process_data() = 0;
414-
virtual void process_control() {}
413+
virtual void process_data(bool debug) = 0;
414+
virtual void process_control(bool debug=false) {};
415415

416416
bool sync_data_inputs() {
417417

libs/core/include/rtbot/Output.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class Output : public Operator {
4848
}
4949

5050
protected:
51-
void process_data() override {
51+
void process_data(bool debug=false) override {
5252
// Forward all messages from inputs to corresponding outputs
5353
for (size_t i = 0; i < num_data_ports(); ++i) {
5454
auto& input_queue = get_data_queue(i);

libs/core/include/rtbot/Pipeline.h

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,17 @@ class Pipeline : public Operator {
6060
// API for configuring the pipeline
6161
void register_operator(std::shared_ptr<Operator> op) { operators_[op->id()] = std::move(op); }
6262

63-
void set_entry(const std::string& op_id, size_t port = 0) {
63+
void set_entry(const std::string& op_id) {
6464
auto it = operators_.find(op_id);
6565
if (it == operators_.end()) {
6666
throw std::runtime_error("Entry operator not found: " + op_id);
6767
}
68-
entry_operator_ = it->second;
69-
entry_port_ = port;
70-
RTBOT_LOG_DEBUG("Setting entry operator: ", op_id, " -> ", port);
68+
if (it->second->num_data_ports() >= num_data_ports()) {
69+
entry_operator_ = it->second;
70+
RTBOT_LOG_DEBUG("Setting entry operator: ", op_id);
71+
} else {
72+
throw std::runtime_error("Entry operator has less data ports that the pipeline: " + op_id);
73+
}
7174
}
7275

7376
void add_output_mapping(const std::string& op_id, size_t op_port, size_t pipeline_port) {
@@ -117,8 +120,11 @@ class Pipeline : public Operator {
117120
if (input_port_types_ != other.input_port_types_) return false;
118121
if (output_port_types_!= other.output_port_types_) return false;
119122
if (output_mappings_ != other.output_mappings_) return false;
120-
if (entry_operator_ != other.entry_operator_) return false;
121-
if (entry_port_ != other.entry_port_) return false;
123+
if ((bool)entry_operator_ != (bool)other.entry_operator_) return false;
124+
if (entry_operator_ && other.entry_operator_) {
125+
if (*entry_operator_ != *other.entry_operator_)
126+
return false;
127+
}
122128
if (operators_.size() != other.operators_.size()) return false;
123129

124130
for (const auto& [key, op1] : operators_) {
@@ -141,7 +147,7 @@ class Pipeline : public Operator {
141147
}
142148

143149
protected:
144-
void process_data() override {
150+
void process_data(bool debug=false) override {
145151
// Check if we have an entry point configured
146152
if (!entry_operator_) {
147153
throw std::runtime_error("Pipeline entry point not configured");
@@ -153,7 +159,7 @@ class Pipeline : public Operator {
153159
while (!input_queue.empty()) {
154160
auto& msg = input_queue.front();
155161
entry_operator_->receive_data(msg->clone(), i);
156-
entry_operator_->execute();
162+
entry_operator_->execute(debug);
157163
input_queue.pop_front();
158164
// Process output mappings
159165
bool was_reset = false;
@@ -195,7 +201,6 @@ class Pipeline : public Operator {
195201
std::vector<PipelineConnection> pipeline_connections_;
196202
std::map<std::string, std::shared_ptr<Operator>> operators_;
197203
std::shared_ptr<Operator> entry_operator_;
198-
size_t entry_port_;
199204
std::map<std::string, std::vector<std::pair<size_t, size_t>>> output_mappings_;
200205
};
201206

libs/core/include/rtbot/ReduceJoin.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class ReduceJoin : public Join {
4141
}
4242

4343
protected:
44-
void process_data() override {
44+
void process_data(bool debug=false) override {
4545

4646
while(true) {
4747

0 commit comments

Comments
 (0)