51 namespace DeviceInformation
102 static void remove_mandatory(std::vector<Common::Interface> &itfs)
104 static std::array<uint16_t, 3>
const mandatory =
113 itfs.erase(std::remove_if(itfs.begin(), itfs.end(), [](
const Common::Interface &itf)
117 return itf.id ==
uid;
149 return AbstractInterface::attribute(
uid);
154 return AbstractInterface::attributes(pack_id);
173 unit().
send(addr, message,
nullptr);
187 template<Interface::UID _u
id,
typename Parent = AbstractService>
224 template<
class Parent, Interface::Role _role>
227 static_assert(std::is_base_of<HF::Core::AbstractService, Parent>::value,
228 "Parent must be of type HF::Core::AbstractService");
263 template<
typename Base,
typename... ITF>
266 static_assert(std::is_base_of<HF::Core::Unit0, Base>::value,
267 "Base must be of type HF::Core::Unit0");
270 typedef typename std::tuple<ITF...> interfaces_t;
283 #if HF_BATCH_PROGRAM_SUPPORT 286 #if HF_EVENT_SCHEDULING_SUPPORT 289 #if HF_WEEKLY_SCHEDULING_SUPPORT 299 typedef typename std::tuple_element<DEV_INFO, interfaces_t>::type DeviceInfo;
301 typedef typename std::tuple_element<DEV_MGT, interfaces_t>::type DeviceMgt;
303 typedef typename std::tuple_element<ATTR_RPT, interfaces_t>::type AttrReporting;
305 static_assert(std::is_base_of<HF::Core::DeviceInformation::Server, DeviceInfo>::value,
306 "DeviceInfo must be of type HF::Core::DeviceInformation::Server");
308 static_assert(std::is_base_of<HF::Core::AttributeReporting::IServer, AttrReporting>::value,
309 "AttrReporting must be of type HF::Core::AttributeReporting::Server");
312 typedef typename std::tuple_element<GROUP_TABLE, interfaces_t>::type GroupTable;
314 static_assert(std::is_base_of<HF::Core::GroupTable::IServer, GroupTable>::value,
315 "GroupTable must be of type HF::Core::GroupTable::IServer");
319 typedef typename std::tuple_element<TIME, interfaces_t>::type
Time;
321 static_assert(std::is_base_of<HF::Core::Time::Server, Time>::value,
322 "Time must be of type HF::Core::Time::Server");
325 #if HF_BATCH_PROGRAM_SUPPORT 326 typedef typename std::tuple_element<BATCH_PROGRAM, interfaces_t>::type BatchProgram;
328 static_assert(std::is_base_of<HF::Core::BatchProgramManagement::IServer, BatchProgram>::value,
329 "BatchProgram must be of type HF::Core::BatchProgramManagement::IServer");
332 #if HF_EVENT_SCHEDULING_SUPPORT 333 typedef typename std::tuple_element<EVENT_SCH, interfaces_t>::type EventScheduling;
335 static_assert(std::is_base_of<HF::Core::Scheduling::Event::IServer, EventScheduling>::value,
336 "EventSch must be of type HF::Core::Scheduling::Event::IServer");
339 #if HF_WEEKLY_SCHEDULING_SUPPORT 340 typedef typename std::tuple_element<WEEKLY_SCH, interfaces_t>::type WeeklyScheduling;
342 static_assert(std::is_base_of<HF::Core::Scheduling::Weekly::IServer, WeeklyScheduling>::value,
343 "WeeklyScheduling must be of type HF::Core::Scheduling::Weekly::IServer");
364 return get<DeviceInfo, DEV_INFO>();
374 return get<DeviceInfo, DEV_INFO>();
384 return get<DeviceMgt, DEV_MGT>();
394 return get<DeviceMgt, DEV_MGT>();
404 return get<AttrReporting, ATTR_RPT>();
414 return get<AttrReporting, ATTR_RPT>();
423 GroupTable *group_table()
425 return get<GroupTable, GROUP_TABLE>();
433 GroupTable *group_table()
const 435 return get<GroupTable, GROUP_TABLE>();
447 return get<Time, TIME>();
457 return get<Time, TIME>();
461 #if HF_BATCH_PROGRAM_SUPPORT 467 BatchProgram *batch_program()
469 return get<BatchProgram, BATCH_PROGRAM>();
477 BatchProgram *batch_program()
const 479 return get<BatchProgram, BATCH_PROGRAM>();
483 #if HF_EVENT_SCHEDULING_SUPPORT 489 EventScheduling *event_scheduling()
491 return get<EventScheduling, EVENT_SCH>();
499 EventScheduling *event_scheduling()
const 501 return get<EventScheduling, EVENT_SCH>();
505 #if HF_WEEKLY_SCHEDULING_SUPPORT 511 WeeklyScheduling *weekly_scheduling()
513 return get<WeeklyScheduling, WEEKLY_SCH>();
521 WeeklyScheduling *weekly_scheduling()
const 523 return get<WeeklyScheduling, WEEKLY_SCH>();
541 result = itf.
handle(packet, payload, offset);
565 InterfacesWrapper::periodic(time);
568 std::vector<Common::Interface> interfaces()
const 572 Base::remove_mandatory(result);
580 template<
typename T, u
int8_t N>
583 return const_cast<T *
>(InterfacesWrapper::template get<N>());
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...
This class represents a HAN-FUN Concentrator.
Top-level parent class for all implemented interfaces.
ServiceRole(Unit0 &unit)
Constructor.
This represent the special unit with ID/UID = 0.
HF::Attributes::IAttribute * attribute(uint8_t uid)
Return a pointer to the interface attribute with the given uid.
This is the parent class for all HAN-FUN units.
DeviceInfo * device_info() const
Device Information service.
Service(Unit0 &unit)
Constructor.
virtual Unit0 & unit() const =0
The device this unit is associated with.
Inferface
Core Services indexs.
AbstractService(Unit0 &unit)
Constructor.
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.
Helper class to handle optional interfaces in units.
Attribute Reporting interface UID.
Return all mandatory attributes for the interface.
This file contains the common defines for the HAN-FUN library.
AttrReporting * attribute_reporting() const
Attribute Reporting service.
Helper template class used to define custom Unit 0 for devices.
This interface represents a link on the transport layer, used to send data to the remote end-point...
This class has the same behavior has a list, however the list element access methods where overwritte...
This file contains the definitions for the HAN-FUN protocol messages.
AbstractUnit(IDevice &device)
Constructor.
This is the parent class for all services implementations.
uint8_t id() const
Get the id number of this unit on the device.
std::vector< Common::Interface > interfaces() const
Return the list of interfaces present in the wrapper.
Attribute Reporting service index.
void for_each(std::function< void(HF::Interface &)> func) const
Call the given function for all the interfaces.
This class represents the interface common to all HAN-FUN devices.
uint16_t uid() const
Return this profile HAN-FUN UID.
This file contains the definitions common to all interfaces.
DeviceInfo * device_info()
Device Information service.
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.
DeviceMgt * device_management() const
Device Management service.
Common::Result handle(HF::Protocol::Packet &packet, Common::ByteArray &payload, uint16_t offset)
Handle incoming messages from the network.
Device Management interface UID.
void periodic(uint32_t time)
Handle periodic processing.
AttrReporting * attribute_reporting()
Attribute Reporting service.
Unit0(HF::IDevice &device)
Constructor.
uint16_t uid() const
This method returns the interface UID.
Unit0 & unit() const
The device this unit is associated with.
Unit0 & _unit
Reference to the unit the service belongs to.
This class represents a byte array.
void send(const Protocol::Address &addr, Protocol::Message &message)
Send message msg to the network address given by addr.
Common::Result handle(Protocol::Packet &packet, Common::ByteArray &payload, uint16_t offset)
Handle incoming messages from the network.
Device Information service index.
Device Management service index.
This file contains the definitions for the HAN-FUN unit implementation.
bool check_uid(uint16_t uid) const
Check if the given uid value matches the service's UID value.
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...
IDevice & device() const
Reference to the device this unit belongs to.
Interface::Role role() const
Return the Interface::Role this interface implements.
Interface/Service Attribute API.
DeviceMgt * device_management()
Device Management service.
This is the interface common to all Services.
Class template for all interfaces role implementations.
#define UNUSED(x)
Helper macro to remove warning about unused function/method argument.
void periodic(uint32_t time)
Handle periodic processing.
Time
This represents the type of time that is associated with a time measurement.
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.
virtual Common::Result handle(Protocol::Packet &packet, Common::ByteArray &payload, uint16_t offset)=0
Handle incoming messages from the network.
Device information interface UID.
Common interface for all Interfaces.
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...
Class template for all core services implementations.
virtual uint16_t uid() const =0
This method returns the interface UID.
Result
Commands result codes.
Protocol::Message * mandatory()
Create a message that can be used to retrieve the mandatory attributes on a remote device...
Bind Management service index.
Unit0(IDevice &device)
Constructor.
Top-level namespace for the HAN-FUN library.