41 #define _CRT_SECURE_NO_DEPRECATE //do not use windows secure crt 49 #define __FILE_ID__ "anbutton" 53 ,_calibratedValue(CALIBRATEDVALUE_INVALID)
54 ,_rawValue(RAWVALUE_INVALID)
55 ,_analogCalibration(ANALOGCALIBRATION_INVALID)
56 ,_calibrationMax(CALIBRATIONMAX_INVALID)
57 ,_calibrationMin(CALIBRATIONMIN_INVALID)
58 ,_sensitivity(SENSITIVITY_INVALID)
59 ,_isPressed(ISPRESSED_INVALID)
60 ,_lastTimePressed(LASTTIMEPRESSED_INVALID)
61 ,_lastTimeReleased(LASTTIMERELEASED_INVALID)
62 ,_pulseCounter(PULSECOUNTER_INVALID)
63 ,_pulseTimer(PULSETIMER_INVALID)
64 ,_valueCallbackAnButton(NULL)
80 if(json_val->
has(
"calibratedValue")) {
83 if(json_val->
has(
"rawValue")) {
86 if(json_val->
has(
"analogCalibration")) {
89 if(json_val->
has(
"calibrationMax")) {
92 if(json_val->
has(
"calibrationMin")) {
95 if(json_val->
has(
"sensitivity")) {
98 if(json_val->
has(
"isPressed")) {
101 if(json_val->
has(
"lastTimePressed")) {
104 if(json_val->
has(
"lastTimeReleased")) {
107 if(json_val->
has(
"pulseCounter")) {
110 if(json_val->
has(
"pulseTimer")) {
138 }
catch (std::exception) {
167 }
catch (std::exception) {
196 }
catch (std::exception) {
220 rest_val = (newval>0 ?
"1" :
"0");
221 res =
_setAttr(
"analogCalibration", rest_val);
222 }
catch (std::exception) {
252 }
catch (std::exception) {
279 char buf[32]; sprintf(buf,
"%d", newval); rest_val = string(buf);
280 res =
_setAttr(
"calibrationMax", rest_val);
281 }
catch (std::exception) {
311 }
catch (std::exception) {
338 char buf[32]; sprintf(buf,
"%d", newval); rest_val = string(buf);
339 res =
_setAttr(
"calibrationMin", rest_val);
340 }
catch (std::exception) {
370 }
catch (std::exception) {
399 char buf[32]; sprintf(buf,
"%d", newval); rest_val = string(buf);
400 res =
_setAttr(
"sensitivity", rest_val);
401 }
catch (std::exception) {
431 }
catch (std::exception) {
463 }
catch (std::exception) {
495 }
catch (std::exception) {
526 }
catch (std::exception) {
540 char buf[32]; sprintf(buf,
"%u", (u32)newval); rest_val = string(buf);
541 res =
_setAttr(
"pulseCounter", rest_val);
542 }
catch (std::exception) {
571 }
catch (std::exception) {
619 }
catch (std::exception) {
641 if (callback != NULL) {
648 if (callback != NULL && this->
isOnline()) {
691 vector<YFUN_DESCR> v_fundescr;
693 string serial, funcId, funcName, funcVal, errmsg;
696 v_fundescr.size() == 0 ||
yCRITICAL_SECTION _this_cs
YRETCODE _load_unsafe(int msValidity)
static int DefaultCacheValidity
void yLeaveCriticalSection(yCRITICAL_SECTION *cs)
static YRETCODE getFunctionInfo(YFUN_DESCR fundesc, YDEV_DESCR &devdescr, string &serial, string &funcId, string &funcName, string &funcVal, string &errmsg)
virtual int _parseAttr(YJSONObject *json_val)
int getInt(const string &key)
static u64 GetTickCount(void)
static void _AddToCache(const string &classname, const string &func, YFunction *obj)
static YFunction * _FindFromCache(const string &classname, const string &func)
void yEnterCriticalSection(yCRITICAL_SECTION *cs)
static yCRITICAL_SECTION _global_cs
static int getFunctionsByClass(const string &class_str, YFUN_DESCR prevfundesc, vector< YFUN_DESCR > &buffer, int maxsize, string &errmsg)
s64 getLong(const string &key)
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)