@@ -64,6 +64,44 @@ enum class ScheduleType : int {
6464 Yearly = 4
6565};
6666
67+ enum class ScheduleMonth : int {
68+ Jan = 0 ,
69+ Feb = 1 ,
70+ Mar = 2 ,
71+ Apr = 3 ,
72+ May = 4 ,
73+ Jun = 5 ,
74+ Jul = 6 ,
75+ Aug = 7 ,
76+ Sep = 8 ,
77+ Oct = 9 ,
78+ Nov = 10 ,
79+ Dec = 11
80+ };
81+
82+ enum class ScheduleWeekDay : int {
83+ Sun = 0 ,
84+ Mon = 1 ,
85+ Tue = 2 ,
86+ Wed = 3 ,
87+ Thu = 4 ,
88+ Fri = 5 ,
89+ Sat = 6
90+ };
91+
92+ enum class ScheduleState : int {
93+ Inactive = 0 ,
94+ Active = 1
95+ };
96+
97+ /* *****************************************************************************
98+ * TYPEDEF
99+ ******************************************************************************/
100+ typedef struct ScheduleWeeklyMask {
101+ ScheduleState& operator [](ScheduleWeekDay i) { return day[static_cast <int >(i)];}
102+ ScheduleState day[7 ];
103+ }ScheduleWeeklyMask;
104+
67105/* *****************************************************************************
68106 CLASS DECLARATION
69107 ******************************************************************************/
@@ -90,6 +128,55 @@ class Schedule : public TimeService {
90128 return false ;
91129 }
92130
131+ static unsigned int createOneShotScheduleConfiguration () {
132+ return 0 ;
133+ }
134+
135+ static unsigned int createFixedDeltaScheduleConfiguration (ScheduleUnit unit, unsigned int delta) {
136+ unsigned int temp_unit = static_cast <int >(unit);
137+ unsigned int temp_type = static_cast <int >(ScheduleType::FixedDelta);
138+ unsigned int temp_delta = delta;
139+
140+ if (temp_delta > SCHEDULE_REP_MASK) {
141+ temp_delta = SCHEDULE_REP_MASK;
142+ }
143+ return (temp_unit << SCHEDULE_UNIT_SHIFT) | (temp_type << SCHEDULE_TYPE_SHIFT) | temp_delta;
144+ }
145+
146+ static unsigned int createWeeklyScheduleConfiguration (ScheduleWeeklyMask weekMask) {
147+ unsigned int temp_week = 0 ;
148+ unsigned int temp_type = static_cast <int >(ScheduleType::Weekly);
149+
150+ for (int i = 0 ; i<7 ; i++) {
151+ if (weekMask[static_cast <ScheduleWeekDay>(i)] == ScheduleState::Active) {
152+ temp_week |= 1 << i;
153+ }
154+ }
155+ return (temp_type << SCHEDULE_TYPE_SHIFT) | temp_week;
156+ }
157+
158+ static unsigned int createMonthlyScheduleConfiguration (int dayOfTheMonth) {
159+ int temp_day = dayOfTheMonth;
160+ unsigned int temp_type = static_cast <int >(ScheduleType::Monthly);
161+
162+ if (temp_day < 1 ) {
163+ temp_day = 1 ;
164+ }
165+
166+ if (temp_day > 31 ) {
167+ temp_day = 31 ;
168+ }
169+ return (temp_type << SCHEDULE_TYPE_SHIFT) | temp_day;
170+ }
171+
172+ static unsigned int createYearlyScheduleConfiguration (ScheduleMonth month, int dayOfTheMonth) {
173+ int temp_day = createMonthlyScheduleConfiguration (dayOfTheMonth);
174+ int temp_month = static_cast <int >(month);
175+ unsigned int temp_type = static_cast <int >(ScheduleType::Yearly);
176+
177+ return (temp_type << SCHEDULE_TYPE_SHIFT) | (temp_month << SCHEDULE_MONTH_SHIFT)| temp_day;
178+ }
179+
93180 Schedule& operator =(Schedule & aSchedule) {
94181 frm = aSchedule.frm ;
95182 to = aSchedule.to ;
0 commit comments