remove EbusSender

This commit is contained in:
Guido Schreuder 2024-02-25 14:30:37 +01:00
parent 42d62c3124
commit 8cd7a78786
2 changed files with 6 additions and 18 deletions

View file

@ -45,12 +45,6 @@ void EbusComponent::set_command_queue_size(uint8_t command_queue_size) {
this->command_queue_size_ = command_queue_size;
}
void EbusComponent::add_sender(EbusSender *sender) {
if (this->primary_address_ == SYN) {
return;
}
this->senders_.push_back(sender);
}
void EbusComponent::add_receiver(EbusReceiver *receiver) { this->receivers_.push_back(receiver); }
void EbusComponent::setup_queues_() {
@ -172,8 +166,8 @@ void EbusComponent::update() {
if (this->primary_address_ == SYN) {
return;
}
for (auto const &sender : this->senders_) {
optional<SendCommand> command = sender->prepare_command();
for (auto const &item : this->items_) {
optional<SendCommand> command = item->prepare_command();
if (command.has_value()) {
xQueueSendToBack(this->command_queue_, &command.value(), portMAX_DELAY);
}

View file

@ -29,12 +29,7 @@ class EbusReceiver {
};
};
class EbusSender {
public:
virtual optional<SendCommand> prepare_command() = 0;
};
class EbusItem : public EbusReceiver, public EbusSender, public Component {
class EbusItem : public EbusReceiver, public Component {
public:
void dump_config() override;
@ -45,7 +40,7 @@ class EbusItem : public EbusReceiver, public EbusSender, public Component {
void set_payload(const std::vector<uint8_t> &payload) { this->payload_ = payload; }
void set_response_read_position(uint8_t response_position) { this->response_position_ = response_position; }
optional<SendCommand> prepare_command() override;
virtual optional<SendCommand> prepare_command();
// TODO: refactor these
uint32_t get_response_bytes(Telegram &telegram, uint8_t start, uint8_t length);
@ -77,10 +72,9 @@ class EbusComponent : public PollingComponent {
void set_history_queue_size(uint8_t /*history_queue_size*/);
void set_command_queue_size(uint8_t /*command_queue_size*/);
void add_sender(EbusSender * /*sender*/);
void add_receiver(EbusReceiver * /*receiver*/);
void add_item(EbusItem *item) {
this->add_sender(item);
this->items_.push_back(item);
this->add_receiver(item);
};
@ -101,7 +95,7 @@ class EbusComponent : public PollingComponent {
QueueHandle_t command_queue_;
#endif
std::list<EbusSender *> senders_;
std::list<EbusItem *> items_;
std::list<EbusReceiver *> receivers_;
std::unique_ptr<Ebus> ebus_;