HAN-FUN API  1.5.3
This project provides the common implementation of ULE Alliance's HAN-FUN application protocol.
scheduling.h
Go to the documentation of this file.
1 // =============================================================================
15 // =============================================================================
16 
17 #ifndef HF_CORE_SCHEDULING_H
18 #define HF_CORE_SCHEDULING_H
19 
20 #include "hanfun/protocol.h"
21 #include "hanfun/core.h"
22 
23 #include <string>
24 #include <map>
25 #include <forward_list>
26 #include <algorithm>
27 
37 #define HF_SCHEDULING_SETTER_HELPER(_Type, _name, _value) \
38  { \
39  _Type::value_type old = this->_name; \
40  \
41  this->_name = _value; \
42  \
43  _Type old_attr(static_cast<HF::Interface::UID>(this->uid()), old, this); \
44  _Type new_attr(static_cast<HF::Interface::UID>(this->uid()), this->_name, this); \
45  \
46  notify(old_attr, new_attr); \
47  }
48 
49 namespace HF
50 {
51  namespace Core
52  {
53  // Forward declaration.
54  namespace Scheduling
55  {
56  class IServer;
57  }
58 
74  HF::Attributes::IAttribute *create_attribute(Scheduling::IServer *server,
75  Interface::UID itf_uid, uint8_t uid);
76 
80  namespace Scheduling
81  {
90  typedef enum _CMD
92  {
96  GET_ENTRY_CMD = 0x04,
97  DELETE_CMD = 0x05,
98  DELETE_ALL_CMD = 0x06,
99  __LAST_CMD__ = DELETE_ALL_CMD
100  } CMD;
101 
103  typedef enum _Attributes
104  {
107  STATUS_ATTR = 0x03,
108  __LAST_ATTR__ = STATUS_ATTR
109  } Attributes;
110 
111  // =============================================================================
112  // Attribute Helper classes
113  // =============================================================================
114 
120  {
121  static constexpr uint8_t ID = MAXIMUM_NUMBER_OF_ENTRIES_ATTR;
122  static constexpr bool WRITABLE = false;
123 
124  MaximumNumberOfEntries(Interface::UID itf, uint8_t value = 0,
125  HF::Interface *owner = nullptr):
126  Attribute<uint8_t>(itf, ID, owner, value, WRITABLE)
127  {}
128  };
129 
134  {
135  static constexpr uint8_t ID = NUMBER_OF_ENTRIES_ATTR;
136  static constexpr bool WRITABLE = false;
137 
138  NumberOfEntries(Interface::UID itf, uint8_t value = 0, HF::Interface *owner = nullptr):
139  Attribute<uint8_t>(itf, ID, owner, value, WRITABLE)
140  {}
141  };
142 
146  struct Status: public HF::Attributes::Attribute<bool>
147  {
148  static constexpr uint8_t ID = STATUS_ATTR;
149  static constexpr bool WRITABLE = false;
150 
151  Status(Interface::UID itf, bool value = false, HF::Interface *owner = nullptr):
152  Attribute<bool>(itf, ID, owner, value, WRITABLE)
153  {}
154  };
155 
168 
174  template<typename _Type>
175  struct Entry
176  {
177  uint8_t id;
178  bool status;
179  _Type time;
180  uint8_t pid;
181 
182  // Helper attribute - Not included on the message entry!
183  uint32_t next_run;
184 
193  Entry(uint8_t _id, uint8_t _status, _Type _t, uint8_t _pid):
194  id(_id), status(_status), time(_t), pid(_pid), next_run(time.first())
195  {}
196 
197  Entry() = default;
198 
199  static constexpr uint16_t START_ID = 0x00;
200  static constexpr uint16_t MAX_ID = 0xFE;
201  static constexpr uint16_t AVAILABLE_ID = 0xFF;
202 
211  bool active(uint32_t _time) const
212  {
213  return (status == 0x01 &&
214  time.active(_time) &&
215  _time >= next_run);
216  }
217 
221  void step(void)
222  {
223  next_run += time.step();
224  }
225 
227  static constexpr uint16_t min_size = sizeof(uint8_t) // Event ID
228  + sizeof(uint8_t) // Event Status
229  + _Type::min_size // _Type min size
230  + sizeof(uint8_t); // Program ID
231 
233  uint16_t size() const
234  {
235  return min_size;
236  }
237 
239  uint16_t pack(Common::ByteArray &array, uint16_t offset = 0) const
240  {
241  HF_SERIALIZABLE_CHECK(array, offset, size());
242 
243  uint16_t start = offset;
244 
245  offset += array.write(offset, id);
246  offset += array.write(offset, static_cast<uint8_t>((status << 7) & 0x80));
247  offset += time.pack(array, offset);
248  offset += array.write(offset, pid);
249 
250  return (offset - start);
251  }
252 
254  uint16_t unpack(const Common::ByteArray &array, uint16_t offset = 0)
255  {
256  HF_SERIALIZABLE_CHECK(array, offset, min_size);
257 
258  uint16_t start = offset;
259 
260  offset += array.read(offset, id);
261 
262  uint8_t flags = 0;
263  offset += array.read(offset, flags);
264  status = (flags >> 7) & 0x01;
265 
266  uint16_t size = time.unpack(array, offset);
267  HF_ASSERT(size != 0, {return 0;});
268  offset += size;
269 
270  offset += array.read(offset, pid);
271 
272  return (offset - start);
273  }
274  };
275 
278  {
279  bool status;
280 
281  ActivateScheduler(bool _status = false): status(_status)
282  {}
283 
285  static constexpr uint16_t min_size = sizeof(uint8_t); // Status
286 
288  uint16_t size() const
289  {
290  return min_size;
291  }
292 
294  uint16_t pack(Common::ByteArray &array, uint16_t offset = 0) const;
295 
297  uint16_t unpack(const Common::ByteArray &array, uint16_t offset = 0);
298  };
299 
302 
303 #if __cplusplus >= 201103
304 
309  template<class _Type>
310  using DefineEvent = Entry<_Type>;
311 #endif
312 
315  {
316  uint8_t event_id;
317 
319  uint8_t _event_id = 0x00):
320  HF::Protocol::Response(_code), event_id(_event_id)
321  {}
322 
324  uint16_t size() const
325  {
326  if (code != Common::Result::OK)
327  {
328  return min_size;
329  }
330 
331  return min_size + sizeof(uint8_t);
332  }
333 
335  uint16_t pack(Common::ByteArray &array, uint16_t offset = 0) const;
336 
338  uint16_t unpack(const Common::ByteArray &array, uint16_t offset = 0);
339  };
340 
343  {
344  uint8_t event_id;
345  bool status;
346 
347  UpdateStatus(uint8_t _event_id = 0x00, bool _status = false):
348  event_id(_event_id), status(_status)
349  {}
350 
352  static constexpr uint16_t min_size = sizeof(uint8_t) // Event ID
353  + sizeof(uint8_t); // Status
354 
356  uint16_t size() const
357  {
358  return min_size;
359  }
360 
362  uint16_t pack(Common::ByteArray &array, uint16_t offset = 0) const;
363 
365  uint16_t unpack(const Common::ByteArray &array, uint16_t offset = 0);
366  };
367 
370 
372  struct GetEntry
373  {
374  uint8_t event_id;
375 
376  GetEntry(uint8_t _event_id = 0x00):
377  event_id(_event_id)
378  {}
379 
381  static constexpr uint16_t min_size = sizeof(uint8_t); // Event ID
382 
384  uint16_t size() const
385  {
386  return min_size;
387  }
388 
390  uint16_t pack(Common::ByteArray &array, uint16_t offset = 0) const;
391 
393  uint16_t unpack(const Common::ByteArray &array, uint16_t offset = 0);
394  };
395 
401  template<typename _Type>
403  {
405 
407  Entry<_Type> _entry):
408  HF::Protocol::Response(_code), entry(_entry)
409  {}
410 
412  HF::Protocol::Response(_code)
413  {}
414 
416  uint16_t size() const
417  {
418  if (code != Common::Result::OK)
419  {
420  return min_size;
421  }
422 
424  }
425 
427  uint16_t pack(Common::ByteArray &array, uint16_t offset = 0) const
428  {
429  HF_SERIALIZABLE_CHECK(array, offset, size());
430 
431  uint8_t start = offset;
432 
433  offset += Protocol::Response::pack(array, offset);
434 
435  if (code != Common::Result::OK)
436  {
437  goto _end;
438  }
439 
440  offset += entry.pack(array, offset);
441 
442  _end:
443  return offset - start;
444  }
445 
447  uint16_t unpack(const Common::ByteArray &array, uint16_t offset = 0)
448  {
449  HF_SERIALIZABLE_CHECK(array, offset, min_size);
450 
451  uint8_t start = offset;
452 
453  offset += Protocol::Response::unpack(array, offset);
454 
455  if (code != Common::Result::OK)
456  {
457  goto _end;
458  }
459 
460  HF_SERIALIZABLE_CHECK(array, offset, entry.size());
461  offset += entry.unpack(array, offset);
462 
463  _end:
464  return offset - start;
465  }
466  };
467 
470 
473 
476 
482  template<typename _Type>
483  struct IEntries: public Common::IEntries<Entry<_Type>>
484  {
487 
497  virtual Common::Result save(const EntryType &entry) = 0;
498 
502  virtual void clear(void) = 0;
503 
512  virtual EntryPointer find(uint8_t id) const = 0;
513 
520  virtual uint8_t next_id() const = 0;
521 
527  virtual void for_each(std::function<void(EntryType &e)> func) = 0;
528  };
529 
535  template<typename _Type>
536  struct Entries: public IEntries<_Type>
537  {
538  typedef Entry<_Type> EntryType;
540 
541  typedef typename Common::SimpleList<EntryType> Container;
542  typedef typename Container::iterator iterator;
543  typedef typename Container::const_iterator const_iterator;
544  typedef typename Container::value_type value_type;
545 
546  virtual ~Entries() {}
547 
549  uint16_t size() const
550  {
551  return std::distance(db.begin(), db.end());
552  }
553 
556  {
557  if (exists(entry.id))
558  {
560  }
561  else
562  {
563  db.push_front(entry);
564  return Common::Result::OK;
565  }
566  }
567 
579  Common::Result save(uint8_t id, uint8_t status, _Type &time, uint8_t pid)
580  {
581  EntryType entry(id, status, time, pid);
582  return save(entry);
583  }
584 
588  void clear(void)
589  {
590  db.clear();
591  }
592 
601  Common::Result destroy(const uint8_t id)
602  {
603  if (exists(id))
604  {
605  db.remove_if([id](const EntryType &e) {return e.id == id;});
606  return Common::Result::OK;
607  }
608  else
609  {
611  }
612  }
613 
621  {
622  return destroy(entry.id);
623  }
624 
626  EntryPointer find(uint8_t id) const
627  {
628  auto it = std::find_if(db.begin(), db.end(),
629  [id](const EntryType &e)
630  {return e.id == id;});
631 
632  if (it == db.end())
633  {
634  return EntryPointer();
635  }
636  else
637  {
638  return EntryPointer(const_cast<EntryType *>(&(*it)));
639  }
640  }
641 
643  void for_each(std::function<void(Entry<_Type> &)> func)
644  {
645  std::for_each(db.begin(), db.end(), func);
646  }
647 
649  uint8_t next_id() const
650  {
651  if (std::distance(db.begin(), db.end()) > EntryType::MAX_ID)
652  {
654  }
655 
656  for (uint8_t id = EntryType::START_ID; id <= EntryType::MAX_ID; ++id)
657  {
658  if (!exists(id))
659  {
660  return id;
661  }
662  }
663 
665  }
666 
672  iterator begin()
673  {
674  return db.begin();
675  }
676 
682  iterator end()
683  {
684  return db.end();
685  }
686 
692  const_iterator begin() const
693  {
694  return db.cbegin();
695  }
696 
702  const_iterator end() const
703  {
704  return db.cend();
705  }
706 
707  protected:
708 
717  bool exists(const uint8_t id) const
718  {
719  return std::any_of(db.begin(), db.end(), [id](const EntryType &e) {
720  return e.id == id;
721  });
722  }
723 
725  Container db;
726  };
727 
728 
737  template<Interface::UID _ITF, typename _Parent>
738  struct Base: public Service<_ITF, _Parent>
739  {
740  protected:
741 
743  Base(Unit0 &unit):
744  Service<_ITF, _Parent>(unit)
745  {}
746  };
747 
753  class IServer: public ServiceRole<AbstractService, HF::Interface::SERVER_ROLE>
754  {
755  protected:
756 
758  bool _status;
759 
763  _maximum_number_of_entries(std::numeric_limits<uint8_t>::max()),
764  _status(true)
765  {}
766 
767  public:
768 
770  virtual ~IServer()
771  {}
772 
773  // ======================================================================
774  // Events
775  // ======================================================================
778 
789  virtual Common::Result activate_scheduler(const Protocol::Packet &packet,
790  const ActivateScheduler &msg);
791 
793  // ======================================================================
794 
795  // ======================================================================
796  // Get/Set API.
797  // ======================================================================
798 
804  uint8_t maximum_number_of_entries() const;
805 
811  void maximum_number_of_entries(uint8_t __value);
812 
818  virtual uint8_t number_of_entries() const = 0;
819 
826  bool status() const;
827 
834  bool enabled() const
835  {
836  return status();
837  }
838 
844  void status(bool __value);
845 
851  void enable(bool __value)
852  {
853  status(__value);
854  }
855 
856  // ======================================================================
857  // Attribute API.
858  // ======================================================================
859 
861 
862  HF::Attributes::UIDS attributes(uint8_t pack_id =
864 
865  protected:
866 
868  uint16_t offset);
869  };
870 
876  class IClient: public Interfaces::InterfaceRole<Interfaces::AbstractInterface,
877  HF::Interface::CLIENT_ROLE>
878  {
879  public:
880 
881  virtual ~IClient()
882  {}
883 
884  // ======================================================================
885  // Commands
886  // ======================================================================
889 
898  void activate_scheduler(const Protocol::Address &addr,
899  const Interface::UID itf_uid, bool enabled = true);
900 
901 #ifdef HF_CORE_EVENT_SCHEDULING_UPDATE_EVENT_STATUS_CMD
902 
911  void update_event_status(const Protocol::Address &addr, const Interface::UID itf_uid,
912  uint8_t id, bool enabled);
913 #endif
914 
915 #ifdef HF_CORE_EVENT_SCHEDULING_GET_EVENT_ENTRY_CMD
916 
924  void get_event_entry(const Protocol::Address &addr, const Interface::UID itf_uid,
925  uint8_t id);
926 #endif
927 
936  void delete_event(const Protocol::Address &addr, const Interface::UID itf_uid,
937  uint8_t id);
938 
939 #ifdef HF_CORE_EVENT_SCHEDULING_DELETE_ALL_EVENTS_CMD
940 
947  void delete_all_events(const Protocol::Address &addr, const Interface::UID itf_uid);
948 #endif
949 
950  virtual void send(const Protocol::Address &addr, Protocol::Message &message) = 0;
952  // ======================================================================
953  };
954 
957  } // namespace Scheduling
958 
959  } // namespace Core
960 
961 } // namespace HF
962 
968 // =============================================================================
969 // Stream Helpers
970 // =============================================================================
979 std::ostream &operator<<(std::ostream &stream, const HF::Core::Scheduling::CMD command);
980 
989 std::ostream &operator<<(std::ostream &stream,
990  const HF::Core::Scheduling::Attributes attribute);
992 #endif /* HF_CORE_SCHEDULING_H_ */
Default implementation of the persistence API.
Definition: scheduling.h:536
static constexpr uint16_t START_ID
Lower bound for the entries ID.
Definition: scheduling.h:199
DefineEventResponse UpdateStatusResponse
Response message payload for a Scheduling::UPDATE_STATUS_CMD request.
Definition: scheduling.h:369
uint16_t size() const
Number bytes needed to serialize the message.
Definition: scheduling.h:324
bool active(uint32_t _time) const
Check if the current entry is runnable at _time.
Definition: scheduling.h:211
Entry< _Type > entry
&Entry data to return to client.
Definition: scheduling.h:404
Common::Result destroy(const uint8_t id)
Destroy the given entry in the persistent storage.
Definition: scheduling.h:601
Scheduling Service : Parent.
Definition: scheduling.h:738
UID
Interfaces Unique Identifiers (UID).
Definition: interface.h:57
Delete Event command UID.
Definition: scheduling.h:97
static constexpr bool WRITABLE
Attribute Read/Write.
Definition: scheduling.h:122
uint16_t write(uint16_t offset, uint8_t data)
Write a byte into the array at the given offset.
Number Of Entries attribute UID.
Definition: scheduling.h:106
Common::Result save(const EntryType &entry)
Store the given entry to persistent storage.
Definition: scheduling.h:555
This represent the special unit with ID/UID = 0.
Definition: core.h:67
iterator begin()
Get an iterator to the start of the entries in this container.
Definition: scheduling.h:672
uint8_t event_id
Event ID.
Definition: scheduling.h:374
virtual uint8_t number_of_entries() const =0
Get the Number Of Entries for the Scheduling server.
static constexpr uint16_t min_size
Minimum pack/unpack required data size.
Definition: scheduling.h:381
static constexpr uint16_t min_size
Minimum pack/unpack required data size.
Definition: scheduling.h:227
std::ostream & operator<<(std::ostream &stream, const HF::Core::Scheduling::CMD command)
Convert the given command into a string and write it to the given stream.
virtual Common::Result activate_scheduler(const Protocol::Packet &packet, const ActivateScheduler &msg)
Callback that is called when a Scheduling::ACTIVATE_SCHEDULER_CMD, is received.
Container db
Actual container for the entries.
Definition: scheduling.h:725
EntryPointer find(uint8_t id) const
Find the Event with the given id.
Definition: scheduling.h:626
void step(void)
Increment the next_run attribute.
Definition: scheduling.h:221
static constexpr uint8_t ID
Attribute UID.
Definition: scheduling.h:148
uint8_t id
Event ID.
Definition: scheduling.h:177
List of attributes UIDs.
Definition: attributes.h:176
Return all mandatory attributes for the interface.
Definition: attributes.h:842
Scheduling Service : Client side implementation.
Definition: scheduling.h:876
#define HF_ASSERT(_expr, _block)
Helper macro to check for correct assumptions.
This file contains the forward declarations of the core services and interfaces implementing classes...
uint16_t unpack(const Common::ByteArray &array, uint16_t offset=0)
Read a message from a ByteArray.
uint32_t next_run
Next run timestamp.
Definition: scheduling.h:183
STL namespace.
iterator end()
Get an iterator to the end of the entries in this container.
Definition: scheduling.h:682
uint16_t unpack(const Common::ByteArray &array, uint16_t offset=0)
Read a message from a ByteArray.
Definition: scheduling.h:447
Common::Result handle_command(Protocol::Packet &packet, Common::ByteArray &payload, uint16_t offset)
Handle incoming messages from the network.
virtual void clear(void)=0
Erase all the DB entries.
Response message payload for a Scheduling::DEFINE_EVENT_CMD request.
Definition: scheduling.h:314
void enable(bool __value)
Enable/Disable scheduler.
Definition: scheduling.h:851
Define Event command UID.
Definition: scheduling.h:94
This file contains the definitions for the HAN-FUN protocol messages.
const_iterator end() const
Get a constant iterator to the start of the entries in this container.
Definition: scheduling.h:702
This is the parent class for all services implementations.
Definition: core.h:137
Helper class to handle the Maximum Number Of Entries attribute for the scheduling services...
Definition: scheduling.h:119
Base class for scheduling services entries.
Definition: scheduling.h:175
Message payload for a Scheduling::ACTIVATE_SCHEDULER_CMD request.
Definition: scheduling.h:277
Base(Unit0 &unit)
Constructor.
Definition: scheduling.h:743
Status attribute UID.
Definition: scheduling.h:107
virtual void send(const Protocol::Address &addr, Protocol::Message &message)=0
Send message msg to the network address given by addr.
uint16_t unpack(const Common::ByteArray &array, uint16_t offset=0)
Read a message from a ByteArray.
Message payload for a Scheduling::GET_ENTRY_CMD request.
Definition: scheduling.h:372
static constexpr bool WRITABLE
Attribute Read/Write.
Definition: scheduling.h:136
static constexpr uint16_t MAX_ID
Upper bound for the entries ID.
Definition: scheduling.h:200
#define HF_SERIALIZABLE_CHECK(__array, __offset, __size)
Helper macro to check if the given __array has enough size so __size bytes can be written/read from t...
uint16_t size() const
Number bytes needed to serialize the message.
Definition: scheduling.h:416
virtual void for_each(std::function< void(EntryType &e)> func)=0
Call the given function with each entry in the DB as argument.
Entry< _Type > EntryType
Entry helper type.
Definition: scheduling.h:485
uint16_t size() const
Number bytes needed to serialize the message.
Definition: scheduling.h:356
Update Event Status command UID.
Definition: scheduling.h:95
void clear(void)
Erase all the DB entries.
Definition: scheduling.h:588
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.
HF::Attributes::IAttribute * create_attribute(HF::Interface::UID itf_uid, uint8_t uid)
Create an attribute object that can hold the attribute with the given uid. (HF::Core::Scheduling::ISe...
uint16_t size() const
Number bytes needed to serialize the message.
Definition: scheduling.h:384
Fail - Unknown reason.
void for_each(std::function< void(Entry< _Type > &)> func)
Call the given function with each entry in the DB as argument.
Definition: scheduling.h:643
Entry(uint8_t _id, uint8_t _status, _Type _t, uint8_t _pid)
Constructor.
Definition: scheduling.h:193
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.
Definition: scheduling.h:239
HF::Interface const * owner() const
Definition: attributes.h:414
DefineEventResponse DeleteEventResponse
Response message payload for a Scheduling::DELETE_CMD request.
Definition: scheduling.h:472
Unit0 & unit() const
The device this unit is associated with.
Definition: core.h:142
Protocol::Response ActivateSchedulerResponse
Response message payload for a Scheduling::ACTIVATE_SCHEDULER_CMD request.
Definition: scheduling.h:301
Activate Scheduler command UID.
Definition: scheduling.h:93
Helper class to handle the Status attribute for the scheduling services.
Definition: scheduling.h:146
virtual EntryPointer find(uint8_t id) const =0
Find the Event with the given id.
static constexpr uint16_t min_size
Minimum pack/unpack required data size.
Definition: scheduling.h:352
Scheduling - Persistent Storage API.
Definition: scheduling.h:483
Delete All Events command UID.
Definition: scheduling.h:98
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.
This class represents a byte array.
bool status
Event Status.
Definition: scheduling.h:178
uint16_t unpack(const Common::ByteArray &array, uint16_t offset=0)
Read a message from a ByteArray.
bool _status
Server Status
Definition: scheduling.h:758
virtual Common::Result save(const EntryType &entry)=0
Store the given entry to persistent storage.
Network Address.
Definition: protocol.h:201
_Type time
Scheduler configuration.
Definition: scheduling.h:179
Network Message.
Definition: protocol.h:60
uint8_t pid
Program ID to be invoked.
Definition: scheduling.h:180
Attributes
Attributes.
Definition: scheduling.h:103
bool exists(const uint8_t id) const
Check if entry with given id exists.
Definition: scheduling.h:717
uint8_t maximum_number_of_entries() const
Get the Maximum Number Of Entries for the Scheduling server.
uint16_t size() const
Return the number of entries in the container.
Definition: scheduling.h:549
Common::Result save(uint8_t id, uint8_t status, _Type &time, uint8_t pid)
Store the given entry to persistent storage.
Definition: scheduling.h:579
Fail - Invalid Argument.
HAN-FUN Protocol Packet.
Definition: protocol.h:298
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...
GetEntry DeleteEvent
Message payload for a Scheduling::DELETE_CMD request.
Definition: scheduling.h:469
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 Number Of Entries attribute for the scheduling services.
Definition: scheduling.h:133
Interface/Service Attribute API.
Definition: attributes.h:44
static constexpr uint8_t ID
Attribute UID.
Definition: scheduling.h:135
bool status() const
Get the Status for the Scheduling server.
static constexpr bool WRITABLE
Attribute Read/Write.
Definition: scheduling.h:149
CMD
Command IDs.
Definition: scheduling.h:91
uint16_t read(uint16_t offset, uint8_t &data) const
Read the byte at offset into data.
Scheduling Service : Server side implementation.
Definition: scheduling.h:753
Parent class for the response messages.
Definition: protocol.h:368
HF::Attributes::IAttribute * attribute(uint8_t uid)
Return a pointer to the interface attribute with the given uid.
Class template for all interfaces role implementations.
Definition: core.h:225
Simple raw pointer wrapper.
uint16_t size() const
Number bytes needed to serialize the message.
Definition: scheduling.h:233
bool enabled() const
Check if scheduler is enabled.
Definition: scheduling.h:834
Helper class template for implementing a given interface role.
Definition: interface.h:394
Message payload for a Scheduling::UPDATE_STATUS_CMD request.
Definition: scheduling.h:342
static constexpr uint8_t ID
Attribute UID.
Definition: scheduling.h:121
bool status
Scheduler status.
Definition: scheduling.h:345
Helper template class to declare an attribute with the given T type.
Definition: attributes.h:349
IServer(Unit0 &unit)
Constructor.
Definition: scheduling.h:761
virtual ~IServer()
Destructor.
Definition: scheduling.h:770
Common::Result destroy(const EntryType &entry)
Destroy the given entry in the persistent storage.
Definition: scheduling.h:620
Attribute(const uint16_t interface, const uint8_t uid, const HF::Interface *__owner, uint8_t data, bool writable=false)
Attribute template constructor.
Definition: attributes.h:360
static constexpr uint16_t min_size
Minimum number of bytes required by this message.
Definition: protocol.h:375
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.
Definition: scheduling.h:427
Common::Pointer< EntryType > EntryPointer
Entry pointer helper.
Definition: scheduling.h:486
static constexpr uint16_t min_size
Minimum pack/unpack required data size.
Definition: scheduling.h:285
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.
Common interface for all Interfaces.
Definition: interface.h:43
uint8_t _maximum_number_of_entries
Maximum Number Of Entries.
Definition: scheduling.h:757
HF::Protocol::Response DeleteAllResponse
Response Message payload for a Scheduling::DELETE_ALL_CMD request.
Definition: scheduling.h:475
virtual uint8_t next_id() const =0
Return next available id for event.
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.
Get Event Entry command UID.
Definition: scheduling.h:96
Class template for all core services implementations.
Definition: core.h:188
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.
uint16_t unpack(const Common::ByteArray &array, uint16_t offset=0)
Read a message from a ByteArray.
uint16_t unpack(const Common::ByteArray &array, uint16_t offset=0)
Read a message from a ByteArray.
Definition: scheduling.h:254
virtual uint16_t uid() const =0
This method returns the interface UID.
static constexpr uint16_t AVAILABLE_ID
Special ID for system allocated ID.
Definition: scheduling.h:201
Result
Commands result codes.
Response message payload for a Scheduling::GET_ENTRY_CMD request.
Definition: scheduling.h:402
Maximum Number Of Entries attribute UID.
Definition: scheduling.h:105
uint16_t size() const
Number bytes needed to serialize the message.
Definition: scheduling.h:288
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.
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.
uint16_t unpack(const Common::ByteArray &array, uint16_t offset=0)
Read a message from a ByteArray.
const_iterator begin() const
Get a constant iterator to the start of the entries in this container.
Definition: scheduling.h:692
uint8_t next_id() const
Return next available id for event.
Definition: scheduling.h:649
Basic API for persistent storage implementations.
Top-level namespace for the HAN-FUN library.
Definition: attributes.h:22