41 #define _CRT_SECURE_NO_DEPRECATE //do not use windows secure crt 49 #define __FILE_ID__ "wakeupmonitor" 53 ,_powerDuration(POWERDURATION_INVALID)
54 ,_sleepCountdown(SLEEPCOUNTDOWN_INVALID)
55 ,_nextWakeUp(NEXTWAKEUP_INVALID)
56 ,_wakeUpReason(WAKEUPREASON_INVALID)
57 ,_wakeUpState(WAKEUPSTATE_INVALID)
58 ,_rtcTime(RTCTIME_INVALID)
59 ,_endOfTime(2145960000)
60 ,_valueCallbackWakeUpMonitor(NULL)
76 if(json_val->
has(
"powerDuration")) {
79 if(json_val->
has(
"sleepCountdown")) {
82 if(json_val->
has(
"nextWakeUp")) {
85 if(json_val->
has(
"wakeUpReason")) {
88 if(json_val->
has(
"wakeUpState")) {
91 if(json_val->
has(
"rtcTime")) {
119 }
catch (std::exception) {
143 char buf[32]; sprintf(buf,
"%d", newval); rest_val = string(buf);
144 res =
_setAttr(
"powerDuration", rest_val);
145 }
catch (std::exception) {
174 }
catch (std::exception) {
197 char buf[32]; sprintf(buf,
"%d", newval); rest_val = string(buf);
198 res =
_setAttr(
"sleepCountdown", rest_val);
199 }
catch (std::exception) {
228 }
catch (std::exception) {
251 char buf[32]; sprintf(buf,
"%u", (u32)newval); rest_val = string(buf);
252 res =
_setAttr(
"nextWakeUp", rest_val);
253 }
catch (std::exception) {
284 }
catch (std::exception) {
313 }
catch (std::exception) {
327 char buf[32]; sprintf(buf,
"%d", newval); rest_val = string(buf);
328 res =
_setAttr(
"wakeUpState", rest_val);
329 }
catch (std::exception) {
351 }
catch (std::exception) {
399 }
catch (std::exception) {
421 if (callback != NULL) {
428 if (callback != NULL && this->
isOnline()) {
469 if (!(currTime != 0)) {
494 if (!(currTime != 0)) {
519 if (!(currTime != 0)) {
553 vector<YFUN_DESCR> v_fundescr;
555 string serial, funcId, funcName, funcVal, errmsg;
558 v_fundescr.size() == 0 ||
Y_WAKEUPSTATE_enum _wakeUpState
yCRITICAL_SECTION _this_cs
static YWakeUpMonitor * FindWakeUpMonitor(string func)
static const int SLEEPCOUNTDOWN_INVALID
int set_sleepCountdown(int newval)
virtual int resetSleepCountDown(void)
YRETCODE _load_unsafe(int msValidity)
static int DefaultCacheValidity
void _throw(YRETCODE errType, string errMsg)
static const Y_WAKEUPSTATE_enum WAKEUPSTATE_INVALID
void yLeaveCriticalSection(yCRITICAL_SECTION *cs)
virtual int sleepUntil(int wakeUpTime, int secBeforeSleep)
static const int POWERDURATION_INVALID
static YRETCODE getFunctionInfo(YFUN_DESCR fundesc, YDEV_DESCR &devdescr, string &serial, string &funcId, string &funcName, string &funcVal, string &errmsg)
YWakeUpMonitor * nextWakeUpMonitor(void)
virtual int _parseAttr(YJSONObject *json_val)
Y_WAKEUPSTATE_enum get_wakeUpState(void)
int getInt(const string &key)
static u64 GetTickCount(void)
static void _AddToCache(const string &classname, const string &func, YFunction *obj)
int get_powerDuration(void)
virtual int _invokeValueCallback(string value)
static YFunction * _FindFromCache(const string &classname, const string &func)
YWakeUpMonitor(const string &func)
Y_WAKEUPREASON_enum _wakeUpReason
virtual int _parseAttr(YJSONObject *json_val)
void yEnterCriticalSection(yCRITICAL_SECTION *cs)
static yCRITICAL_SECTION _global_cs
YWakeUpMonitorValueCallback _valueCallbackWakeUpMonitor
int set_nextWakeUp(s64 newval)
static int getFunctionsByClass(const string &class_str, YFUN_DESCR prevfundesc, vector< YFUN_DESCR > &buffer, int maxsize, string &errmsg)
static YWakeUpMonitor * FirstWakeUpMonitor(void)
static const s64 NEXTWAKEUP_INVALID
s64 getLong(const string &key)
Y_WAKEUPREASON_enum get_wakeUpReason(void)
static const Y_WAKEUPREASON_enum WAKEUPREASON_INVALID
static const s64 RTCTIME_INVALID
virtual int registerValueCallback(YWakeUpMonitorValueCallback callback)
virtual int sleep(int secBeforeSleep)
static bool _apiInitialized
YRETCODE _nextFunction(string &hwId)
virtual int sleepFor(int secUntilWakeUp, int secBeforeSleep)
int set_wakeUpState(Y_WAKEUPSTATE_enum newval)
static void _UpdateValueCallbackList(YFunction *func, bool add)
void(* YWakeUpMonitorValueCallback)(YWakeUpMonitor *func, const string &functionValue)
int get_sleepCountdown(void)
bool has(const string &key)
YRETCODE _setAttr(string attrname, string newvalue)
int set_powerDuration(int newval)
virtual int _invokeValueCallback(string value)