17 #ifndef HF_CORE_WEEKLY_SCHEDULING_H 18 #define HF_CORE_WEEKLY_SCHEDULING_H 89 Day(uint8_t _day, uint8_t _hour, uint8_t _minute):
95 static constexpr
int MINUTE = 60;
96 static constexpr
int HOUR = 60 * MINUTE;
97 static constexpr
int DAY = 24 * HOUR;
98 static constexpr uint32_t WEEK = 7 * DAY;
101 static constexpr uint8_t DAY_OF_WEEK_BASE = SATURDAY;
103 static Day convert(
const uint32_t ×tamp)
107 std::div_t temp = std::div(timestamp, DAY);
110 result.
day = temp.quot % 7
113 result.
day = result.
day % 7;
115 temp = std::div(temp.rem, HOUR);
116 result.
hour = temp.quot;
117 temp = std::div(temp.rem, MINUTE);
118 result.
minute = temp.quot;
130 uint32_t
first(uint32_t timestamp = 0)
const 132 uint32_t result = timestamp;
134 Day current(convert(timestamp));
136 result += (this->hour - current.
hour) * 60 * 60;
137 result += (this->minute - current.
minute) * 60;
139 result += (this->day - current.
day) * 24 * 60 * 60;
141 if (timestamp > result)
171 static constexpr uint16_t
min_size =
sizeof(uint8_t)
286 Day &time, uint8_t pid);
288 #ifdef HF_CORE_WEEKLY_SCHEDULING_UPDATE_EVENT_STATUS_CMD 297 uint8_t
id,
bool enabled)
299 Scheduling::IClient::update_event_status(addr, ITF,
id, enabled);
303 #ifdef HF_CORE_WEEKLY_SCHEDULING_GET_EVENT_ENTRY_CMD 312 Scheduling::IClient::get_event_entry(addr, ITF,
id);
326 #ifdef HF_CORE_WEEKLY_SCHEDULING_DELETE_ALL_EVENTS_CMD 334 Scheduling::IClient::delete_all_events(addr, ITF);
338 using IClientBase::send;
375 uint8_t number_of_entries()
const;
441 void periodic(uint32_t time);
483 using IServerBase::notify;
501 template<
typename _Entries>
505 "_Entries must be of type HF::Core::Scheduling::IEntries<Day>");
527 return const_cast<_Entries &
>(_entries);
virtual ~IClient()
Destructor.
uint16_t size() const
Number bytes needed to serialize the message.
Scheduling Service : Parent.
UID
Interfaces Unique Identifiers (UID).
virtual Common::Result update_event_status(const Protocol::Packet &packet, const UpdateStatus &msg)
Callback that is called when a Scheduling::UPDATE_STATUS_CMD, is received.
This represent the special unit with ID/UID = 0.
uint8_t next_id() const
Return next available id for event.
virtual ~IServer()
Destructor.
Scheduling::GetEntryResponse< Day > GetEntryResponse
Specific part for the Weekly Scheduler of the HF::Scheduling::GetEntryResonse.
This file contains the definitions for the Time service.
Server< Entries< Day > > DefaultServer
Weekly Scheduling Service : Server side with default persistence implementation.
virtual Common::Result delete_all_events(const Protocol::Packet &packet)
Callback that is called when a Scheduling::DELETE_ALL_CMD, is received.
Weekly Scheduling Service : Client side implementation.
Weekly Scheduling interface UID.
uint16_t unpack(const Common::ByteArray &array, uint16_t offset=0)
Read a message from a ByteArray.
Return all mandatory attributes for the interface.
Scheduling Service : Client side implementation.
This file contains the forward declarations of the core services and interfaces implementing classes...
Helper class template for parent class implementation of the interfaces.
Helper class to handle the Status attribute for the Weekly Scheduling service.
Helper class to handle the Maximum Number Of Entries attribute for the Weekly Scheduling service...
Server(Unit0 &unit)
Constructor.
This file contains the definitions for the HAN-FUN protocol messages.
virtual Common::Result get_event_entry(const Protocol::Packet &packet, const GetEntry &msg)
Callback that is called when a Scheduling::GET_ENTRY_CMD, is received.
Helper class to handle the Maximum Number Of Entries attribute for the scheduling services...
Base class for scheduling services entries.
This file contains the common definitions for the scheduling services.
uint8_t minute
Minute of Hour.
Message payload for a Scheduling::GET_ENTRY_CMD request.
Scheduling Service : Client side implementation.
uint16_t uid() const
This method returns the interface UID.
Scheduling Service : Server side implementation.
HF::Interface const * owner() const
uint16_t pack(Common::ByteArray &array, uint16_t offset=0) const
Write the object on to a ByteArray so it can be sent over the network.
Helper class to handle the Status attribute for the scheduling services.
Scheduling - Persistent Storage API.
This class represents a byte array.
virtual void activate_scheduler(const Protocol::Address &addr, bool enabled)
Send a HAN-FUN message containing a Scheduling::ACTIVATE_SCHEDULER_CMD, to the given network address...
virtual void delete_event(const Protocol::Address &addr, uint8_t id)
Send a HAN-FUN message containing a Scheduling::DELETE_CMD, to the given network address.
_Entries & entries() const
Get a reference to the current object implementing the persistence API, for the device information...
static constexpr uint16_t min_size
Minimum pack/unpack required data size.
void activate_scheduler(const Protocol::Address &addr, const Interface::UID itf_uid, bool enabled=true)
Send a HAN-FUN message containing a Scheduling::ACTIVATE_SCHEDULER_CMD, to the given network address...
Helper class to handle the Number Of Entries attribute for the Weekly Scheduling service.
Helper class to handle the Number Of Entries attribute for the scheduling services.
Interface/Service Attribute API.
virtual IEntries< Day > & entries() const =0
Get a reference to the current object implementing the persistence API, for the device information...
virtual Common::Result define_event(const Protocol::Packet &packet, Scheduling::Entry< Day > &msg)
Callback that is called when a Scheduling::DEFINE_EVENT_CMD, is received.
uint32_t step() const
Get the step between executions.
HF::Attributes::IAttribute * create_attribute(uint8_t uid)
Create an attribute object that can hold the attribute with the given uid. (HF::Core::Scheduling::Wee...
Scheduling Service : Server side implementation.
bool active(uint32_t _time) const
Simple raw pointer wrapper.
#define UNUSED(x)
Helper macro to remove warning about unused function/method argument.
Message payload for a Scheduling::UPDATE_STATUS_CMD request.
uint32_t first(uint32_t timestamp=0) const
Get the initial value for the next_run entry attribute.
Common interface for all Interfaces.
virtual Common::Result delete_event(const Protocol::Packet &packet, const DeleteEvent &msg)
Callback that is called when a Scheduling::DELETE_CMD, is received.
Days
Day of the Week enumeration.
virtual void define_event(const Protocol::Address &addr, uint8_t id, uint8_t status, Day &time, uint8_t pid)
Send a HAN-FUN message containing a Scheduling::DEFINE_CMD, to the given network address.
Common::Pointer< Entry > entry(const uint8_t id) const
Get the Weekly Scheduling entry given by id.
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.
void delete_event(const Protocol::Address &addr, const Interface::UID itf_uid, uint8_t id)
Send a HAN-FUN message containing a Scheduling::DELETE_CMD, to the given network address.
Scheduling::Entry< Day > Entry
Specific part for the Weekly Scheduler of the HF::Scheduling::Entry.
Result
Commands result codes.
Response message payload for a Scheduling::GET_ENTRY_CMD request.
Scheduling Service : Server side implementation.
IServer(Unit0 &unit)
Constructor.
HF::Attributes::IAttribute * create_attribute(HF::Core::AttributeReporting::IServer *server, uint8_t uid)
Create an attribute object that can hold the attribute with the given uid.
Specific part for the Weekly Scheduler of the HF::Scheduling::Entry.
Top-level namespace for the HAN-FUN library.