HAN-FUN API  1.5.3
This project provides the common implementation of ULE Alliance's HAN-FUN application protocol.
simple_air_pressure.h
Go to the documentation of this file.
1 // =============================================================================
15 // =============================================================================
16 
17 #ifndef HF_ITF_SIMPLE_AIR_PRESSURE_H
18 #define HF_ITF_SIMPLE_AIR_PRESSURE_H
19 
20 #include "hanfun/protocol.h"
21 #include "hanfun/interface.h"
22 
23 namespace HF
24 {
25  namespace Interfaces
26  {
27  // Forward declaration.
28  namespace SimpleAirPressure
29  {
30  class Server;
31  }
32 
48 
52  namespace SimpleAirPressure
53  {
62  typedef enum _Attributes
64  {
65  VALUE_ATTR = 1,
69  __LAST_ATTR__ = TOLERANCE_ATTR
70  } Attributes;
71 
72  // =============================================================================
73  // Attribute Helper classes
74  // =============================================================================
75 
79  struct Value: public HF::Attributes::Attribute<uint16_t>
80  {
81  static constexpr uint8_t ID = VALUE_ATTR;
82  static constexpr bool WRITABLE = false;
83 
84  Value(uint16_t value = 0, HF::Interface *owner = nullptr):
85  Attribute<uint16_t>(HF::Interface::SIMPLE_AIR_PRESSURE, ID, owner, value, WRITABLE)
86  {}
87  };
88 
92  struct Maximum: public HF::Attributes::Attribute<uint16_t>
93  {
94  static constexpr uint8_t ID = MAXIMUM_ATTR;
95  static constexpr bool WRITABLE = false;
96 
97  Maximum(uint16_t value = 0, HF::Interface *owner = nullptr):
98  Attribute<uint16_t>(HF::Interface::SIMPLE_AIR_PRESSURE, ID, owner, value, WRITABLE)
99  {}
100  };
101 
105  struct Minimum: public HF::Attributes::Attribute<uint16_t>
106  {
107  static constexpr uint8_t ID = MINIMUM_ATTR;
108  static constexpr bool WRITABLE = false;
109 
110  Minimum(uint16_t value = 0, HF::Interface *owner = nullptr):
111  Attribute<uint16_t>(HF::Interface::SIMPLE_AIR_PRESSURE, ID, owner, value, WRITABLE)
112  {}
113  };
114 
118  struct Tolerance: public HF::Attributes::Attribute<uint16_t>
119  {
120  static constexpr uint8_t ID = TOLERANCE_ATTR;
121  static constexpr bool WRITABLE = false;
122 
123  Tolerance(uint16_t value = 0, HF::Interface *owner = nullptr):
124  Attribute<uint16_t>(HF::Interface::SIMPLE_AIR_PRESSURE, ID, owner, value, WRITABLE)
125  {}
126  };
127 
139 
145  struct Base: public Interface<HF::Interface::SIMPLE_AIR_PRESSURE>
146  {
147  protected:
148 
151  };
152 
158  class Server: public InterfaceRole<SimpleAirPressure::Base, HF::Interface::SERVER_ROLE>
159  {
160  protected:
161 
162  uint16_t _value;
163  uint16_t _maximum;
164  uint16_t _minimum;
165  uint16_t _tolerance;
166 
167  public:
168 
170  Server(): InterfaceRole<SimpleAirPressure::Base, HF::Interface::SERVER_ROLE>() {}
171 
173  virtual ~Server() {}
174 
175  // =============================================================================
176  // Get/Set API.
177  // =============================================================================
178 
184  uint16_t value() const;
185 
191  void value(uint16_t __value);
192 
198  uint16_t maximum() const;
199 
205  void maximum(uint16_t __value);
206 
212  uint16_t minimum() const;
213 
219  void minimum(uint16_t __value);
220 
226  uint16_t tolerance() const;
227 
233  void tolerance(uint16_t __value);
234 
235  // =============================================================================
236  // Attribute API.
237  // =============================================================================
238 
240 
241  HF::Attributes::UIDS attributes(uint8_t pack_id =
243 
244  };
245 
251  struct Client: public InterfaceRole<SimpleAirPressure::Base, HF::Interface::CLIENT_ROLE>
252  {
254 
255  virtual ~Client() {}
256  };
257 
260  } // namespace SimpleAirPressure
261 
262  } // namespace Interfaces
263 
264 } // namespace HF
265 
271 // =============================================================================
272 // Stream Helpers
273 // =============================================================================
274 
283 std::ostream &operator<<(std::ostream &stream,
287 #endif /* HF_ITF_SIMPLE_AIR_PRESSURE_H */
std::ostream & operator<<(std::ostream &stream, const HF::Interfaces::SimpleAirPressure::Attributes attribute)
Convert the given attribute into a string and write it to the given stream.
static constexpr uint8_t ID
Attribute UID.
List of attributes UIDs.
Definition: attributes.h:176
Return all mandatory attributes for the interface.
Definition: attributes.h:842
Helper class template for parent class implementation of the interfaces.
Definition: interface.h:371
static constexpr bool WRITABLE
Attribute Read/Write.
This file contains the definitions for the HAN-FUN protocol messages.
Helper class to handle the Maximum attribute for the Simple Air Pressure interface.
Simple Air Pressure Interface : Client side implementation.
Helper class to handle the Minimum attribute for the Simple Air Pressure interface.
This file contains the definitions common to all interfaces.
Simple Air Pressure Interface : Parent.
Helper class to handle the Tolerance attribute for the Simple Air Pressure interface.
HF::Interface const * owner() const
Definition: attributes.h:414
HF::Attributes::IAttribute * attribute(uint8_t uid)
Return a pointer to the interface attribute with the given uid.
HF::Attributes::IAttribute * create_attribute(uint8_t uid)
Create an attribute object that can hold the attribute with the given uid. (HF::Interfaces::SimpleAir...
uint16_t maximum() const
Get the Maximum for the Simple Air Pressure server.
static constexpr bool WRITABLE
Attribute Read/Write.
uint16_t uid() const
This method returns the interface UID.
Definition: interface.h:374
Helper class to handle the Value attribute for the Simple Air Pressure interface. ...
static constexpr uint8_t ID
Attribute UID.
HF::Attributes::IAttribute * create_attribute(HF::Interfaces::Alert::Server *server, uint8_t uid)
Create an attribute object that can hold the attribute with the given uid.
static constexpr bool WRITABLE
Attribute Read/Write.
Interface/Service Attribute API.
Definition: attributes.h:44
Simple Air Pressure interface UID.
Definition: interface.h:89
HF::Attributes::UIDS attributes(uint8_t pack_id=HF::Attributes::Pack::MANDATORY) const
Return a vector containing the attribute UIDs, for the given pack ID.
static constexpr uint8_t ID
Attribute UID.
uint16_t tolerance() const
Get the Tolerance for the Simple Air Pressure server.
static constexpr bool WRITABLE
Attribute Read/Write.
Helper class template for implementing a given interface role.
Definition: interface.h:394
static constexpr uint8_t ID
Attribute UID.
Helper template class to declare an attribute with the given T type.
Definition: attributes.h:349
Attribute(const uint16_t interface, const uint8_t uid, const HF::Interface *__owner, uint16_t data, bool writable=false)
Attribute template constructor.
Definition: attributes.h:360
Simple Air Pressure Interface : Server side implementation.
Common interface for all Interfaces.
Definition: interface.h:43
uint16_t value() const
Get the Value for the Simple Air Pressure server.
uint16_t minimum() const
Get the Minimum for the Simple Air Pressure server.
Top-level namespace for the HAN-FUN library.
Definition: attributes.h:22