3232 ******************************************************************************/
3333class Schedule : public TimeService {
3434 public:
35- unsigned int start, end, duration, mask ;
36- Schedule (unsigned int s, unsigned int e, unsigned int d, unsigned int m): start (s), end (e), duration (d), mask (m) {}
35+ unsigned int frm, to, len, msk ;
36+ Schedule (unsigned int s, unsigned int e, unsigned int d, unsigned int m): frm (s), to (e), len (d), msk (m) {}
3737
3838 bool isActive () {
3939
4040 unsigned int now = getTime ();
41- if (checkSchedulePeriod (now, start, end )) {
41+ if (checkSchedulePeriod (now, frm, to )) {
4242 /* We are in the schedule range */
4343
44- if (checkScheduleMask (now, mask )) {
44+ if (checkScheduleMask (now, msk )) {
4545
4646 /* We can assume now that the schedule is always repeating with fixed delta */
47- unsigned int delta = getScheduleDelta (mask );
48- if ( ( (std::max (now , start ) - std::min (now , start )) % delta ) <= duration ) {
47+ unsigned int delta = getScheduleDelta (msk );
48+ if ( ( (std::max (now , frm ) - std::min (now , frm )) % delta ) <= len ) {
4949 return true ;
5050 }
5151 }
@@ -54,87 +54,87 @@ class Schedule : public TimeService {
5454 }
5555
5656 Schedule& operator =(Schedule & aSchedule) {
57- start = aSchedule.start ;
58- end = aSchedule.end ;
59- duration = aSchedule.duration ;
60- mask = aSchedule.mask ;
57+ frm = aSchedule.frm ;
58+ to = aSchedule.to ;
59+ len = aSchedule.len ;
60+ msk = aSchedule.msk ;
6161 return *this ;
6262 }
6363
6464 bool operator ==(Schedule & aSchedule) {
65- return start == aSchedule.start && end == aSchedule.end && duration == aSchedule.duration && mask == aSchedule.mask ;
65+ return frm == aSchedule.frm && to == aSchedule.to && len == aSchedule.len && msk == aSchedule.msk ;
6666 }
6767
6868 bool operator !=(Schedule & aSchedule) {
6969 return !(operator ==(aSchedule));
7070 }
7171 private:
72- bool isScheduleOneShot (unsigned int mask ) {
73- if ((mask & 0x3C000000 ) == 0x00000000 ) {
72+ bool isScheduleOneShot (unsigned int msk ) {
73+ if ((msk & 0x3C000000 ) == 0x00000000 ) {
7474 return true ;
7575 } else {
7676 return false ;
7777 }
7878 }
7979
80- bool isScheduleFixed (unsigned int mask ) {
81- if ((mask & 0x3C000000 ) == 0x04000000 ) {
80+ bool isScheduleFixed (unsigned int msk ) {
81+ if ((msk & 0x3C000000 ) == 0x04000000 ) {
8282 return true ;
8383 } else {
8484 return false ;
8585 }
8686 }
8787
88- bool isScheduleWeekly (unsigned int mask ) {
89- if ((mask & 0x3C000000 ) == 0x08000000 ) {
88+ bool isScheduleWeekly (unsigned int msk ) {
89+ if ((msk & 0x3C000000 ) == 0x08000000 ) {
9090 return true ;
9191 } else {
9292 return false ;
9393 }
9494 }
9595
96- bool isScheduleMonthly (unsigned int mask ) {
97- if ((mask & 0x3C000000 ) == 0x0C000000 ) {
96+ bool isScheduleMonthly (unsigned int msk ) {
97+ if ((msk & 0x3C000000 ) == 0x0C000000 ) {
9898 return true ;
9999 } else {
100100 return false ;
101101 }
102102 }
103103
104- bool isScheduleYearly (unsigned int mask ) {
105- if ((mask & 0x3C000000 ) == 0x10000000 ) {
104+ bool isScheduleYearly (unsigned int msk ) {
105+ if ((msk & 0x3C000000 ) == 0x10000000 ) {
106106 return true ;
107107 } else {
108108 return false ;
109109 }
110110 }
111111
112- bool isScheduleInSeconds (unsigned int mask ) {
113- if ((mask & 0xC0000000 ) == 0x00000000 ) {
112+ bool isScheduleInSeconds (unsigned int msk ) {
113+ if ((msk & 0xC0000000 ) == 0x00000000 ) {
114114 return true ;
115115 } else {
116116 return false ;
117117 }
118118 }
119119
120- bool isScheduleInMinutes (unsigned int mask ) {
121- if ((mask & 0xC0000000 ) == 0x40000000 ) {
120+ bool isScheduleInMinutes (unsigned int msk ) {
121+ if ((msk & 0xC0000000 ) == 0x40000000 ) {
122122 return true ;
123123 } else {
124124 return false ;
125125 }
126126 }
127127
128- bool isScheduleInHours (unsigned int mask ) {
129- if ((mask & 0xC0000000 ) == 0x80000000 ) {
128+ bool isScheduleInHours (unsigned int msk ) {
129+ if ((msk & 0xC0000000 ) == 0x80000000 ) {
130130 return true ;
131131 } else {
132132 return false ;
133133 }
134134 }
135135
136- bool isScheduleInDays (unsigned int mask ) {
137- if ((mask & 0xC0000000 ) == 0xC0000000 ) {
136+ bool isScheduleInDays (unsigned int msk ) {
137+ if ((msk & 0xC0000000 ) == 0xC0000000 ) {
138138 return true ;
139139 } else {
140140 return false ;
@@ -162,38 +162,38 @@ class Schedule : public TimeService {
162162 return ptm->tm_mon ;
163163 }
164164
165- unsigned int getScheduleRawMask (unsigned int mask ) {
166- return mask & 0x03FFFFFF ;
165+ unsigned int getScheduleRawMask (unsigned int msk ) {
166+ return msk & 0x03FFFFFF ;
167167 }
168168
169- unsigned int getScheduleWeekMask (unsigned int mask ) {
170- return mask & 0x000000FF ;
169+ unsigned int getScheduleWeekMask (unsigned int msk ) {
170+ return msk & 0x000000FF ;
171171 }
172172
173- unsigned int getScheduleDay (unsigned int mask ) {
174- return mask & 0x000000FF ;
173+ unsigned int getScheduleDay (unsigned int msk ) {
174+ return msk & 0x000000FF ;
175175 }
176176
177- unsigned int getScheduleMonth (unsigned int mask ) {
178- return (mask & 0x0000FF00 ) >> 8 ;
177+ unsigned int getScheduleMonth (unsigned int msk ) {
178+ return (msk & 0x0000FF00 ) >> 8 ;
179179 }
180180
181- bool checkSchedulePeriod (unsigned int now, unsigned int start , unsigned int end ) {
182- if (now >= start && (now < end || end == 0 )) {
181+ bool checkSchedulePeriod (unsigned int now, unsigned int frm , unsigned int to ) {
182+ if (now >= frm && (now < to || to == 0 )) {
183183 return true ;
184184 } else {
185185 return false ;
186186 }
187187 }
188188
189- bool checkScheduleMask (unsigned int now, unsigned int mask ) {
190- if (isScheduleFixed (mask ) || isScheduleOneShot (mask )) {
189+ bool checkScheduleMask (unsigned int now, unsigned int msk ) {
190+ if (isScheduleFixed (msk ) || isScheduleOneShot (msk )) {
191191 return true ;
192192 }
193193
194- if (isScheduleWeekly (mask )) {
194+ if (isScheduleWeekly (msk )) {
195195 unsigned int nowMask = timeToWeekMask (now);
196- unsigned int scheduleMask = getScheduleWeekMask (mask );
196+ unsigned int scheduleMask = getScheduleWeekMask (msk );
197197
198198 if ((nowMask & scheduleMask) == 0 ) {
199199 return false ;
@@ -202,9 +202,9 @@ class Schedule : public TimeService {
202202 }
203203 }
204204
205- if (isScheduleMonthly (mask )) {
205+ if (isScheduleMonthly (msk )) {
206206 unsigned int nowDay = timeToDay (now);
207- unsigned int scheduleDay = getScheduleDay (mask );
207+ unsigned int scheduleDay = getScheduleDay (msk );
208208
209209 if (nowDay != scheduleDay) {
210210 return false ;
@@ -213,11 +213,11 @@ class Schedule : public TimeService {
213213 }
214214 }
215215
216- if (isScheduleYearly (mask )) {
216+ if (isScheduleYearly (msk )) {
217217 unsigned int nowDay = timeToDay (now);
218- unsigned int scheduleDay = getScheduleDay (mask );
218+ unsigned int scheduleDay = getScheduleDay (msk );
219219 unsigned int nowMonth = timeToMonth (now);
220- unsigned int scheduleMonth = getScheduleMonth (mask );
220+ unsigned int scheduleMonth = getScheduleMonth (msk );
221221
222222 if ((nowDay != scheduleDay) || (nowMonth != scheduleMonth)) {
223223 return false ;
@@ -229,26 +229,26 @@ class Schedule : public TimeService {
229229 return false ;
230230 }
231231
232- unsigned int getScheduleDelta (unsigned int mask ) {
233- if (isScheduleOneShot (mask )) {
232+ unsigned int getScheduleDelta (unsigned int msk ) {
233+ if (isScheduleOneShot (msk )) {
234234 return 0xFFFFFFFF ;
235235 }
236236
237- if (isScheduleFixed (mask )) {
238- if (isScheduleInSeconds (mask )) {
239- return getScheduleRawMask (mask );
237+ if (isScheduleFixed (msk )) {
238+ if (isScheduleInSeconds (msk )) {
239+ return getScheduleRawMask (msk );
240240 }
241241
242- if (isScheduleInMinutes (mask )) {
243- return 60 * getScheduleRawMask (mask );
242+ if (isScheduleInMinutes (msk )) {
243+ return 60 * getScheduleRawMask (msk );
244244 }
245245
246- if (isScheduleInHours (mask )) {
247- return 60 * 60 * getScheduleRawMask (mask );
246+ if (isScheduleInHours (msk )) {
247+ return 60 * 60 * getScheduleRawMask (msk );
248248 }
249249 }
250250
251- if (isScheduleWeekly (mask ) || isScheduleMonthly (mask ) || isScheduleYearly (mask )) {
251+ if (isScheduleWeekly (msk ) || isScheduleMonthly (msk ) || isScheduleYearly (msk )) {
252252 return 60 * 60 * 24 ;
253253 }
254254
@@ -259,21 +259,21 @@ class Schedule : public TimeService {
259259class CloudSchedule : public Property {
260260 private:
261261 Schedule _value,
262- _cloud_value;
262+ _cloud_value;
263263 public:
264264 CloudSchedule () : _value(0 , 0 , 0 , 0 ), _cloud_value(0 , 0 , 0 , 0 ) {}
265- CloudSchedule (unsigned int start , unsigned int end , unsigned int duration , unsigned int mask ) : _value(start, end, duration, mask ), _cloud_value(start, end, duration, mask ) {}
265+ CloudSchedule (unsigned int frm , unsigned int to , unsigned int len , unsigned int msk ) : _value(frm, to, len, msk ), _cloud_value(frm, to, len, msk ) {}
266266
267267 virtual bool isDifferentFromCloud () {
268268
269269 return _value != _cloud_value;
270270 }
271271
272272 CloudSchedule& operator =(Schedule aSchedule) {
273- _value.start = aSchedule.start ;
274- _value.end = aSchedule.end ;
275- _value.duration = aSchedule.duration ;
276- _value.mask = aSchedule.mask ;
273+ _value.frm = aSchedule.frm ;
274+ _value.to = aSchedule.to ;
275+ _value.len = aSchedule.len ;
276+ _value.msk = aSchedule.msk ;
277277 updateLocalTimestamp ();
278278 return *this ;
279279 }
@@ -297,17 +297,17 @@ class CloudSchedule : public Property {
297297 _cloud_value = _value;
298298 }
299299 virtual CborError appendAttributesToCloud () {
300- CHECK_CBOR (appendAttribute (_value.start ));
301- CHECK_CBOR (appendAttribute (_value.end ));
302- CHECK_CBOR (appendAttribute (_value.duration ));
303- CHECK_CBOR (appendAttribute (_value.mask ));
300+ CHECK_CBOR (appendAttribute (_value.frm ));
301+ CHECK_CBOR (appendAttribute (_value.to ));
302+ CHECK_CBOR (appendAttribute (_value.len ));
303+ CHECK_CBOR (appendAttribute (_value.msk ));
304304 return CborNoError;
305305 }
306306 virtual void setAttributesFromCloud () {
307- setAttribute (_cloud_value.start );
308- setAttribute (_cloud_value.end );
309- setAttribute (_cloud_value.duration );
310- setAttribute (_cloud_value.mask );
307+ setAttribute (_cloud_value.frm );
308+ setAttribute (_cloud_value.to );
309+ setAttribute (_cloud_value.len );
310+ setAttribute (_cloud_value.msk );
311311 }
312312};
313313
0 commit comments