41 #define _CRT_SECURE_NO_DEPRECATE //do not use windows secure crt 49 #define __FILE_ID__ "dualpower" 53 ,_powerState(POWERSTATE_INVALID)
54 ,_powerControl(POWERCONTROL_INVALID)
55 ,_extVoltage(EXTVOLTAGE_INVALID)
56 ,_valueCallbackDualPower(NULL)
72 if(json_val->
has(
"powerState")) {
75 if(json_val->
has(
"powerControl")) {
78 if(json_val->
has(
"extVoltage")) {
107 }
catch (std::exception) {
137 }
catch (std::exception) {
162 char buf[32]; sprintf(buf,
"%d", newval); rest_val = string(buf);
163 res =
_setAttr(
"powerControl", rest_val);
164 }
catch (std::exception) {
193 }
catch (std::exception) {
241 }
catch (std::exception) {
263 if (callback != NULL) {
270 if (callback != NULL && this->
isOnline()) {
301 vector<YFUN_DESCR> v_fundescr;
303 string serial, funcId, funcName, funcVal, errmsg;
306 v_fundescr.size() == 0 ||
yCRITICAL_SECTION _this_cs
static const Y_POWERSTATE_enum POWERSTATE_INVALID
Y_POWERSTATE_enum _powerState
YRETCODE _load_unsafe(int msValidity)
int set_powerControl(Y_POWERCONTROL_enum newval)
static int DefaultCacheValidity
void yLeaveCriticalSection(yCRITICAL_SECTION *cs)
Y_POWERCONTROL_enum _powerControl
virtual int registerValueCallback(YDualPowerValueCallback callback)
static YRETCODE getFunctionInfo(YFUN_DESCR fundesc, YDEV_DESCR &devdescr, string &serial, string &funcId, string &funcName, string &funcVal, string &errmsg)
YDualPower * nextDualPower(void)
void(* YDualPowerValueCallback)(YDualPower *func, const string &functionValue)
virtual int _parseAttr(YJSONObject *json_val)
virtual int _invokeValueCallback(string value)
int getInt(const string &key)
static u64 GetTickCount(void)
static void _AddToCache(const string &classname, const string &func, YFunction *obj)
Y_POWERCONTROL_enum get_powerControl(void)
static YFunction * _FindFromCache(const string &classname, const string &func)
static const Y_POWERCONTROL_enum POWERCONTROL_INVALID
static const int EXTVOLTAGE_INVALID
YDualPowerValueCallback _valueCallbackDualPower
void yEnterCriticalSection(yCRITICAL_SECTION *cs)
static yCRITICAL_SECTION _global_cs
static YDualPower * FindDualPower(string func)
Y_POWERSTATE_enum get_powerState(void)
static int getFunctionsByClass(const string &class_str, YFUN_DESCR prevfundesc, vector< YFUN_DESCR > &buffer, int maxsize, string &errmsg)
virtual int _parseAttr(YJSONObject *json_val)
YDualPower(const string &func)
static YDualPower * FirstDualPower(void)
static bool _apiInitialized
YRETCODE _nextFunction(string &hwId)
static void _UpdateValueCallbackList(YFunction *func, bool add)
bool has(const string &key)
YRETCODE _setAttr(string attrname, string newvalue)
virtual int _invokeValueCallback(string value)