32
32
******************************************************************************/
33
33
class Schedule : public TimeService {
34
34
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) {}
37
37
38
38
bool isActive () {
39
39
40
40
unsigned int now = getTime ();
41
- if (checkSchedulePeriod (now, start, end )) {
41
+ if (checkSchedulePeriod (now, frm, to )) {
42
42
/* We are in the schedule range */
43
43
44
- if (checkScheduleMask (now, mask )) {
44
+ if (checkScheduleMask (now, msk )) {
45
45
46
46
/* 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 ) {
49
49
return true ;
50
50
}
51
51
}
@@ -54,87 +54,87 @@ class Schedule : public TimeService {
54
54
}
55
55
56
56
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 ;
61
61
return *this ;
62
62
}
63
63
64
64
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 ;
66
66
}
67
67
68
68
bool operator !=(Schedule & aSchedule) {
69
69
return !(operator ==(aSchedule));
70
70
}
71
71
private:
72
- bool isScheduleOneShot (unsigned int mask ) {
73
- if ((mask & 0x3C000000 ) == 0x00000000 ) {
72
+ bool isScheduleOneShot (unsigned int msk ) {
73
+ if ((msk & 0x3C000000 ) == 0x00000000 ) {
74
74
return true ;
75
75
} else {
76
76
return false ;
77
77
}
78
78
}
79
79
80
- bool isScheduleFixed (unsigned int mask ) {
81
- if ((mask & 0x3C000000 ) == 0x04000000 ) {
80
+ bool isScheduleFixed (unsigned int msk ) {
81
+ if ((msk & 0x3C000000 ) == 0x04000000 ) {
82
82
return true ;
83
83
} else {
84
84
return false ;
85
85
}
86
86
}
87
87
88
- bool isScheduleWeekly (unsigned int mask ) {
89
- if ((mask & 0x3C000000 ) == 0x08000000 ) {
88
+ bool isScheduleWeekly (unsigned int msk ) {
89
+ if ((msk & 0x3C000000 ) == 0x08000000 ) {
90
90
return true ;
91
91
} else {
92
92
return false ;
93
93
}
94
94
}
95
95
96
- bool isScheduleMonthly (unsigned int mask ) {
97
- if ((mask & 0x3C000000 ) == 0x0C000000 ) {
96
+ bool isScheduleMonthly (unsigned int msk ) {
97
+ if ((msk & 0x3C000000 ) == 0x0C000000 ) {
98
98
return true ;
99
99
} else {
100
100
return false ;
101
101
}
102
102
}
103
103
104
- bool isScheduleYearly (unsigned int mask ) {
105
- if ((mask & 0x3C000000 ) == 0x10000000 ) {
104
+ bool isScheduleYearly (unsigned int msk ) {
105
+ if ((msk & 0x3C000000 ) == 0x10000000 ) {
106
106
return true ;
107
107
} else {
108
108
return false ;
109
109
}
110
110
}
111
111
112
- bool isScheduleInSeconds (unsigned int mask ) {
113
- if ((mask & 0xC0000000 ) == 0x00000000 ) {
112
+ bool isScheduleInSeconds (unsigned int msk ) {
113
+ if ((msk & 0xC0000000 ) == 0x00000000 ) {
114
114
return true ;
115
115
} else {
116
116
return false ;
117
117
}
118
118
}
119
119
120
- bool isScheduleInMinutes (unsigned int mask ) {
121
- if ((mask & 0xC0000000 ) == 0x40000000 ) {
120
+ bool isScheduleInMinutes (unsigned int msk ) {
121
+ if ((msk & 0xC0000000 ) == 0x40000000 ) {
122
122
return true ;
123
123
} else {
124
124
return false ;
125
125
}
126
126
}
127
127
128
- bool isScheduleInHours (unsigned int mask ) {
129
- if ((mask & 0xC0000000 ) == 0x80000000 ) {
128
+ bool isScheduleInHours (unsigned int msk ) {
129
+ if ((msk & 0xC0000000 ) == 0x80000000 ) {
130
130
return true ;
131
131
} else {
132
132
return false ;
133
133
}
134
134
}
135
135
136
- bool isScheduleInDays (unsigned int mask ) {
137
- if ((mask & 0xC0000000 ) == 0xC0000000 ) {
136
+ bool isScheduleInDays (unsigned int msk ) {
137
+ if ((msk & 0xC0000000 ) == 0xC0000000 ) {
138
138
return true ;
139
139
} else {
140
140
return false ;
@@ -162,38 +162,38 @@ class Schedule : public TimeService {
162
162
return ptm->tm_mon ;
163
163
}
164
164
165
- unsigned int getScheduleRawMask (unsigned int mask ) {
166
- return mask & 0x03FFFFFF ;
165
+ unsigned int getScheduleRawMask (unsigned int msk ) {
166
+ return msk & 0x03FFFFFF ;
167
167
}
168
168
169
- unsigned int getScheduleWeekMask (unsigned int mask ) {
170
- return mask & 0x000000FF ;
169
+ unsigned int getScheduleWeekMask (unsigned int msk ) {
170
+ return msk & 0x000000FF ;
171
171
}
172
172
173
- unsigned int getScheduleDay (unsigned int mask ) {
174
- return mask & 0x000000FF ;
173
+ unsigned int getScheduleDay (unsigned int msk ) {
174
+ return msk & 0x000000FF ;
175
175
}
176
176
177
- unsigned int getScheduleMonth (unsigned int mask ) {
178
- return (mask & 0x0000FF00 ) >> 8 ;
177
+ unsigned int getScheduleMonth (unsigned int msk ) {
178
+ return (msk & 0x0000FF00 ) >> 8 ;
179
179
}
180
180
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 )) {
183
183
return true ;
184
184
} else {
185
185
return false ;
186
186
}
187
187
}
188
188
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 )) {
191
191
return true ;
192
192
}
193
193
194
- if (isScheduleWeekly (mask )) {
194
+ if (isScheduleWeekly (msk )) {
195
195
unsigned int nowMask = timeToWeekMask (now);
196
- unsigned int scheduleMask = getScheduleWeekMask (mask );
196
+ unsigned int scheduleMask = getScheduleWeekMask (msk );
197
197
198
198
if ((nowMask & scheduleMask) == 0 ) {
199
199
return false ;
@@ -202,9 +202,9 @@ class Schedule : public TimeService {
202
202
}
203
203
}
204
204
205
- if (isScheduleMonthly (mask )) {
205
+ if (isScheduleMonthly (msk )) {
206
206
unsigned int nowDay = timeToDay (now);
207
- unsigned int scheduleDay = getScheduleDay (mask );
207
+ unsigned int scheduleDay = getScheduleDay (msk );
208
208
209
209
if (nowDay != scheduleDay) {
210
210
return false ;
@@ -213,11 +213,11 @@ class Schedule : public TimeService {
213
213
}
214
214
}
215
215
216
- if (isScheduleYearly (mask )) {
216
+ if (isScheduleYearly (msk )) {
217
217
unsigned int nowDay = timeToDay (now);
218
- unsigned int scheduleDay = getScheduleDay (mask );
218
+ unsigned int scheduleDay = getScheduleDay (msk );
219
219
unsigned int nowMonth = timeToMonth (now);
220
- unsigned int scheduleMonth = getScheduleMonth (mask );
220
+ unsigned int scheduleMonth = getScheduleMonth (msk );
221
221
222
222
if ((nowDay != scheduleDay) || (nowMonth != scheduleMonth)) {
223
223
return false ;
@@ -229,26 +229,26 @@ class Schedule : public TimeService {
229
229
return false ;
230
230
}
231
231
232
- unsigned int getScheduleDelta (unsigned int mask ) {
233
- if (isScheduleOneShot (mask )) {
232
+ unsigned int getScheduleDelta (unsigned int msk ) {
233
+ if (isScheduleOneShot (msk )) {
234
234
return 0xFFFFFFFF ;
235
235
}
236
236
237
- if (isScheduleFixed (mask )) {
238
- if (isScheduleInSeconds (mask )) {
239
- return getScheduleRawMask (mask );
237
+ if (isScheduleFixed (msk )) {
238
+ if (isScheduleInSeconds (msk )) {
239
+ return getScheduleRawMask (msk );
240
240
}
241
241
242
- if (isScheduleInMinutes (mask )) {
243
- return 60 * getScheduleRawMask (mask );
242
+ if (isScheduleInMinutes (msk )) {
243
+ return 60 * getScheduleRawMask (msk );
244
244
}
245
245
246
- if (isScheduleInHours (mask )) {
247
- return 60 * 60 * getScheduleRawMask (mask );
246
+ if (isScheduleInHours (msk )) {
247
+ return 60 * 60 * getScheduleRawMask (msk );
248
248
}
249
249
}
250
250
251
- if (isScheduleWeekly (mask ) || isScheduleMonthly (mask ) || isScheduleYearly (mask )) {
251
+ if (isScheduleWeekly (msk ) || isScheduleMonthly (msk ) || isScheduleYearly (msk )) {
252
252
return 60 * 60 * 24 ;
253
253
}
254
254
@@ -259,21 +259,21 @@ class Schedule : public TimeService {
259
259
class CloudSchedule : public Property {
260
260
private:
261
261
Schedule _value,
262
- _cloud_value;
262
+ _cloud_value;
263
263
public:
264
264
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 ) {}
266
266
267
267
virtual bool isDifferentFromCloud () {
268
268
269
269
return _value != _cloud_value;
270
270
}
271
271
272
272
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 ;
277
277
updateLocalTimestamp ();
278
278
return *this ;
279
279
}
@@ -297,17 +297,17 @@ class CloudSchedule : public Property {
297
297
_cloud_value = _value;
298
298
}
299
299
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 ));
304
304
return CborNoError;
305
305
}
306
306
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 );
311
311
}
312
312
};
313
313
0 commit comments