HAN-FUN API  1.5.3
This project provides the common implementation of ULE Alliance's HAN-FUN application protocol.
HF::Units::Unit< Profile, ITF > Class Template Reference

Helper template class to implement units. More...

#include <units.h>

+ Inheritance diagram for HF::Units::Unit< Profile, ITF >:
+ Collaboration diagram for HF::Units::Unit< Profile, ITF >:

Public Member Functions

 Unit (uint8_t id, IDevice &device)
 Constructor. More...
 
uint8_t id () const
 Get the id number of this unit on the device. More...
 
uint16_t uid () const
 Return this profile HAN-FUN UID. More...
 
Common::Result handle (Protocol::Packet &packet, Common::ByteArray &payload, uint16_t offset)
 Handle incoming messages from the network. More...
 
HF::Attributes::List attributes (Common::Interface itf, uint8_t pack_id, const HF::Attributes::UIDS &uids) const
 Return a list of all the attributes for a given interface, pack id and list of attributes UID's. More...
 
void send (const Protocol::Address &addr, Protocol::Message &message)
 Send message msg to the network address given by addr. More...
 
void notify (const HF::Attributes::IAttribute &old_value, const HF::Attributes::IAttribute &new_value) const
 Notify the attribute reporting service that the given attribute has changed value. More...
 
std::vector< Common::Interfaceinterfaces () const
 Return the list of optional interfaces implemented by this unit. More...
 
void periodic (uint32_t time)
 Handle periodic processing. More...
 
- Public Member Functions inherited from HF::Units::AbstractUnit
IDevicedevice () const
 Reference to the device this unit belongs to. More...
 
void send (const Protocol::Address &addr, Protocol::Message &message, Transport::Link *link)
 Create and send a new packet with the given message to the given address. More...
 
- Public Member Functions inherited from HF::Interfaces::Container< HF::Units::Unit< Profile, ITF... >, Proxy< ITF, HF::Units::Unit< Profile, ITF... > >... >
 Container (HF::Units::Unit< Profile, ITF... > &base)
 Constructor. More...
 
Common::Result handle (Protocol::Packet &packet, Common::ByteArray &payload, uint16_t offset)
 Handle incoming messages from the network. More...
 
void attributes (HF::Attributes::List &attr_list, Common::Interface itf, uint8_t pack_id, const HF::Attributes::UIDS &uids) const
 Return a list of all the attributes for a given interface, pack id and list of attributes UID's. More...
 
std::vector< Common::Interfaceinterfaces () const
 Return the list of interfaces present in the wrapper. More...
 
const std::tuple_element< N, interfaces_t >::type::base * get () const
 Retrieve a pointer to the N optional interface implemented by this unit. More...
 

Additional Inherited Members

- Protected Member Functions inherited from HF::Units::AbstractUnit
 AbstractUnit (IDevice &device)
 Constructor. More...
 
void notify (const HF::Attributes::IAttribute &old_value, const HF::Attributes::IAttribute &new_value) const
 Notify the attribute reporting service that the given attribute has changed value. More...
 
- Protected Member Functions inherited from HF::Interfaces::Container< HF::Units::Unit< Profile, ITF... >, Proxy< ITF, HF::Units::Unit< Profile, ITF... > >... >
void for_each (std::function< void(HF::Interface &)> func) const
 Call the given function for all the interfaces. More...
 
void for_each (std::function< void(HF::Interface &)> func)
 Call the given function for all the interfaces. More...
 
void for_each (std::function< void(HF::Interface &)> func) const
 Helper template function to implement the HF::Units::Unit::for_each functionality. More...
 
void for_each (std::function< void(HF::Interface &)> func) const
 Helper template function to implement the HF::Units::Unit::for_each functionality. More...
 
HF::Interfacefind (uint16_t itf_uid) const
 Find the interface with the given UID. More...
 
HF::Interfacefind (uint16_t itf_uid) const
 Final template instantiation that finds the wrapped interface with the given UID. More...
 
void attributes_itf (HF::Attributes::List &attrs, Common::Interface itf, uint8_t pack_id, const HF::Attributes::UIDS &uids) const
 Helper function used to provide HF::Units::Unit::attributes functionality. More...
 
void attributes_itf (HF::Attributes::List &attrs, Common::Interface itf, uint8_t pack_id, const HF::Attributes::UIDS &uids) const
 Helper function used to provide HF::Units::Unit::attributes functionality. More...
 
- Protected Attributes inherited from HF::Units::AbstractUnit
uint8_t _id
 Unit ID used to identify a given unit in a given HAN-FUN device.
 

Detailed Description

template<class Profile, typename... ITF>
class HF::Units::Unit< Profile, ITF >

Helper template class to implement units.

Definition at line 196 of file units.h.

Constructor & Destructor Documentation

◆ Unit()

template<class Profile, typename... ITF>
HF::Units::Unit< Profile, ITF >::Unit ( uint8_t  id,
IDevice device 
)
inline

Constructor.

Parameters
[in]idunit identifier.
[in]devicedevice that contains this units.

Definition at line 212 of file units.h.

212  :
213  Profile(), HF::Units::AbstractUnit(device),
214  Wrapper(*this), _id(id)
215  {}
This is the parent class for all HAN-FUN units.
Definition: units.h:95
IDevice & device() const
Reference to the device this unit belongs to.
Definition: units.h:107

Member Function Documentation

◆ attributes()

template<class Profile, typename... ITF>
HF::Attributes::List HF::Units::Unit< Profile, ITF >::attributes ( Common::Interface  itf,
uint8_t  pack_id,
const HF::Attributes::UIDS uids 
) const
inlinevirtual

Return a list of all the attributes for a given interface, pack id and list of attributes UID's.

Parameters
[in]itfinterface UID.
[in]pack_idattribute pack id.
[in]uidslist of attributes UID's.
Returns
attribute list.

Implements HF::Profiles::IProfile.

Definition at line 245 of file units.h.

247  {
248  auto result = Profile::attributes(itf, pack_id, uids);
249 
250  Wrapper::attributes(result, itf, pack_id, uids);
251 
252  return result;
253  }
void attributes(HF::Attributes::List &attr_list, Common::Interface itf, uint8_t pack_id, const HF::Attributes::UIDS &uids) const
Return a list of all the attributes for a given interface, pack id and list of attributes UID&#39;s...
Definition: interface.h:483

◆ handle()

template<class Profile, typename... ITF>
Common::Result HF::Units::Unit< Profile, ITF >::handle ( Protocol::Packet packet,
Common::ByteArray payload,
uint16_t  offset 
)
inlinevirtual

Handle incoming messages from the network.

Parameters
[in]packetthe packet receive from the network.
[in]payloadthe byte array containing the data received from the network.
[in]offsetthe offset the payload start at in the byte array.
Returns
the result of the message processing.

Implements HF::Units::IUnit.

Definition at line 230 of file units.h.

232  {
233  Common::Result result = Profile::handle(packet, payload, offset);
234 
235  // Message not handled by base profile, then try extra interfaces.
236  if (result == Common::Result::FAIL_ARG)
237  {
238  return Wrapper::handle(packet, payload, offset);
239  }
240 
241  return result;
242  }
Common::Result handle(Protocol::Packet &packet, Common::ByteArray &payload, uint16_t offset)
Handle incoming messages from the network.
Definition: interface.h:463
Fail - Invalid Argument.
Result
Commands result codes.

◆ id()

template<class Profile, typename... ITF>
uint8_t HF::Units::Unit< Profile, ITF >::id ( ) const
inlinevirtual

Get the id number of this unit on the device.

Returns
id number of this unit on the device.

Implements HF::Units::IUnit.

Definition at line 218 of file units.h.

219  {
220  return _id;
221  }

◆ interfaces()

template<class Profile, typename... ITF>
std::vector<Common::Interface> HF::Units::Unit< Profile, ITF >::interfaces ( ) const
inlinevirtual

Return the list of optional interfaces implemented by this unit.

Returns
a vector containing the UIDs for the optional interfaces implemented by this unit.

Reimplemented from HF::Units::AbstractUnit.

Definition at line 276 of file units.h.

277  {
278  return Wrapper::interfaces();
279  }
std::vector< Common::Interface > interfaces() const
Return the list of interfaces present in the wrapper.
Definition: interface.h:495

◆ notify()

template<class Profile, typename... ITF>
void HF::Units::Unit< Profile, ITF >::notify ( const HF::Attributes::IAttribute old_value,
const HF::Attributes::IAttribute new_value 
) const
inline

Notify the attribute reporting service that the given attribute has changed value.

Parameters
[in]old_valuereference to the previous value of the attribute.
[in]new_valuereference to the current value of the attribute.

Definition at line 264 of file units.h.

266  {
267  AbstractUnit::notify(old_value, new_value);
268  }
void notify(const HF::Attributes::IAttribute &old_value, const HF::Attributes::IAttribute &new_value) const
Notify the attribute reporting service that the given attribute has changed value.

◆ periodic()

template<class Profile, typename... ITF>
void HF::Units::Unit< Profile, ITF >::periodic ( uint32_t  time)
inlinevirtual

Handle periodic processing.

Parameters
[in]timecurrent system clock value in seconds.

Reimplemented from HF::Units::AbstractUnit.

Definition at line 281 of file units.h.

282  {
283  Profile::periodic(time);
284  Wrapper::periodic(time);
285  }

◆ send()

template<class Profile, typename... ITF>
void HF::Units::Unit< Profile, ITF >::send ( const Protocol::Address addr,
Protocol::Message message 
)
inline

Send message msg to the network address given by addr.

Parameters
[in]addrHF network address.
[in]messagepointer to the message to be sent to the network.

Definition at line 258 of file units.h.

259  {
260  AbstractUnit::send(addr, message, nullptr);
261  }
void send(const Protocol::Address &addr, Protocol::Message &message, Transport::Link *link)
Create and send a new packet with the given message to the given address.

◆ uid()

template<class Profile, typename... ITF>
uint16_t HF::Units::Unit< Profile, ITF >::uid ( ) const
inlinevirtual

Return this profile HAN-FUN UID.

Returns
the UID associated with this profile.
See also
IProfile::UID.

Implements HF::Profiles::IProfile.

Definition at line 224 of file units.h.

225  {
226  return Profile::uid();
227  }

The documentation for this class was generated from the following file: