Wizard.hpp
Go to the documentation of this file.
1 // Copyright (C) 2022 COGIP Robotics association <cogip35@gmail.com>
2 // This file is subject to the terms and conditions of the GNU Lesser
3 // General Public License v2.1. See the file LICENSE in the top level
4 // directory for more details.
5 
23 
24 #pragma once
25 
26 // Riot includes
27 #include "event.h"
28 
29 // Project includes
30 #include "uartpb/UartProtobuf.hpp"
31 
32 // Protobuf message
33 #include "PB_Wizard.hpp"
34 
35 #ifndef WIZARD_NAME_MAX_LENGTH
36 # define WIZARD_NAME_MAX_LENGTH 256
37 #endif
38 #ifndef WIZARD_REP_MAX
39 # define WIZARD_REP_MAX 8
40 #endif
41 
42 namespace cogip {
43 
44 namespace wizard {
45 
47 class Wizard {
48 public:
50  using PB_Message = PB_Wizard<
68  >;
69 
71  explicit Wizard(
72  cogip::uartpb::UartProtobuf & uartpb
73  );
74 
76  void handle_response(
77  cogip::uartpb::ReadBuffer & buffer
78  );
79 
82  const PB_Message &request(
83  const PB_Message &request
84  );
85 
86 private:
88  typedef struct {
89  event_t super;
90  PB_Message pb_message;
91  } wizard_event_t;
92 
93  cogip::uartpb::UartProtobuf & uartpb_;
94  wizard_event_t event_;
95  event_queue_t queue_;
96  bool queue_claimed_ = false;
97 };
98 
99 } // namespace wizard
100 
101 } // namespace cogip
102 
WIZARD_REP_MAX
#define WIZARD_REP_MAX
Maximum count of repeated fields.
Definition: Wizard.hpp:39
cogip::wizard::Wizard::PB_Message
PB_Wizard< WIZARD_NAME_MAX_LENGTH, WIZARD_NAME_MAX_LENGTH, WIZARD_NAME_MAX_LENGTH, WIZARD_REP_MAX, WIZARD_REP_MAX, WIZARD_REP_MAX, WIZARD_NAME_MAX_LENGTH, WIZARD_NAME_MAX_LENGTH, WIZARD_REP_MAX, WIZARD_REP_MAX, WIZARD_REP_MAX, WIZARD_REP_MAX, WIZARD_REP_MAX, WIZARD_NAME_MAX_LENGTH, WIZARD_REP_MAX, WIZARD_NAME_MAX_LENGTH, WIZARD_NAME_MAX_LENGTH > PB_Message
Protobuf message type. Shortcut for original template type.
Definition: Wizard.hpp:68
cogip::wizard::Wizard::request
const PB_Message & request(const PB_Message &request)
Send a request and wait for the response.
cogip
Differential drive controller.
Definition: Coords.hpp:16
WIZARD_NAME_MAX_LENGTH
#define WIZARD_NAME_MAX_LENGTH
Maximum length of the message strings.
Definition: Wizard.hpp:36
cogip::wizard::Wizard
Wizard class.
Definition: Wizard.hpp:47
cogip::wizard::Wizard::handle_response
void handle_response(cogip::uartpb::ReadBuffer &buffer)
Message handler for responses.
cogip::wizard::Wizard::Wizard
Wizard(cogip::uartpb::UartProtobuf &uartpb)
Constructor.