diff options
author | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
commit | e0c6872cf40896c7be36b11dcc744620f10adf1d (patch) | |
tree | 60335e10d2f4354b0674ec22d7b53f0f8abee672 /support/dktools/DkClockData.cpp |
Initial commit
Diffstat (limited to 'support/dktools/DkClockData.cpp')
-rw-r--r-- | support/dktools/DkClockData.cpp | 210 |
1 files changed, 210 insertions, 0 deletions
diff --git a/support/dktools/DkClockData.cpp b/support/dktools/DkClockData.cpp new file mode 100644 index 0000000000..e9c407dd42 --- /dev/null +++ b/support/dktools/DkClockData.cpp @@ -0,0 +1,210 @@ +/* + WARNING: This file was generated by dkct. + Changes you make here will be lost if dkct is run again! + You should modify the original source and run dkct on it. + Original source: DkClockData.cpt +*/ + +/** @file DkClockData.cpp The DkClockData module. +*/ + + +#line 85 "DkClockData.cpt" + +#include "wxdkclock.h" + + + + +#line 90 "DkClockData.cpt" + + +DkClockData::DkClockData() +{ + + +#line 95 "DkClockData.cpt" + clvd.h = 0; + clvd.m = 0; + clvd.s = 0; + clvd.a = 0; + iAlertHour = 0; + iAlertMinute = 0; + iAlertEnabled = 0; + iAlertState = 0; + tmCurrent.Y = 0; + tmCurrent.M = 0; + tmCurrent.D = 0; + tmCurrent.h = 0; + tmCurrent.m = 0; + tmCurrent.s = 0; + + +#line 110 "DkClockData.cpt" +} + + + +void +DkClockData::getData(clockview_data_t *dptr) +{ + + +#line 118 "DkClockData.cpt" + if(dptr) { + wxMutexLocker lock(mxProtectData); + dk3mem_cpy((void *)dptr, (void *)(&clvd), sizeof(clockview_data_t)); + } + + +#line 123 "DkClockData.cpt" +} + + + +int +DkClockData::setTime(dk3_time_t *ct) +{ + dk3_tm_t lct; + int back = 0; + + +#line 133 "DkClockData.cpt" + if(dk3sf_localtime_app(&lct, ct, NULL)) { + wxMutexLocker lock(mxProtectData); + /* + Check date change. + */ + if(2 == iAlertState) { + if(lct.Y != tmCurrent.Y) { + iAlertState = 0; + } else { + if(lct.M != tmCurrent.M) { + iAlertState = 0; + } else { + if(lct.D != tmCurrent.D) { + iAlertState = 0; + } + } + } + } + /* + Check alert state change. + */ + if((0 != iAlertEnabled) && (0 == iAlertState)) { + if(lct.h > iAlertHour) { + iAlertState = 1; back = 1; + } else { + if(lct.h == iAlertHour) { + if(lct.m >= iAlertMinute) { + iAlertState = 1; back = 1; + } + } + } + } + /* + Copy current time. + */ + dk3mem_cpy((void *)(&tmCurrent), (void *)(&lct), sizeof(dk3_tm_t)); + /* + Copy to output structure. + */ + clvd.h = lct.h; + clvd.m = lct.m; + clvd.s = lct.s; + clvd.a = ((1 == iAlertState) ? 1 : 0); + } + +#line 177 "DkClockData.cpt" + return back; +} + + + +void +DkClockData::setAlert(bool flag, int hour, int min) +{ + + +#line 186 "DkClockData.cpt" + iAlertState = 0; + { + wxMutexLocker lock(mxProtectData); + if(flag) { + +#line 190 "DkClockData.cpt" + if((0 <= hour) && (23 >= hour) && (0 <= min) && (59 >= min)) { + iAlertEnabled = 1; + +#line 192 "DkClockData.cpt" + iAlertHour = hour; + iAlertMinute = min; + if(tmCurrent.h > hour) { + iAlertState = 2; + } else { + if(tmCurrent.h == hour) { + if(tmCurrent.m >= min) { + iAlertState = 2; + } + } + } + } else { + +#line 204 "DkClockData.cpt" + iAlertEnabled = 0; + iAlertHour = 0; + iAlertMinute = 0; + } + } else { + +#line 209 "DkClockData.cpt" + iAlertEnabled = 0; + iAlertHour = 0; + iAlertMinute = 0; + } + } + +#line 214 "DkClockData.cpt" +} + + + +void +DkClockData::endAlert(void) +{ + + +#line 222 "DkClockData.cpt" + { + wxMutexLocker lock(mxProtectData); + if(1 == iAlertState) { + iAlertState = 2; + } + } + +#line 228 "DkClockData.cpt" +} + + + +void +DkClockData::getAlertData(int *en, int *h, int *m) +{ + + +#line 236 "DkClockData.cpt" + if((en) && (h) && (m)) { + wxMutexLocker lock(mxProtectData); + *en = iAlertEnabled; + +#line 239 "DkClockData.cpt" + *h = iAlertHour; + +#line 240 "DkClockData.cpt" + *m = iAlertMinute; + +#line 241 "DkClockData.cpt" + } + +#line 242 "DkClockData.cpt" +} |