41 #define _CRT_SECURE_NO_DEPRECATE //do not use windows secure crt 49 #define __FILE_ID__ "accelerometer" 53 ,_bandwidth(BANDWIDTH_INVALID)
54 ,_xValue(XVALUE_INVALID)
55 ,_yValue(YVALUE_INVALID)
56 ,_zValue(ZVALUE_INVALID)
57 ,_gravityCancellation(GRAVITYCANCELLATION_INVALID)
58 ,_valueCallbackAccelerometer(NULL)
59 ,_timedReportCallbackAccelerometer(NULL)
78 if(json_val->
has(
"bandwidth")) {
81 if(json_val->
has(
"xValue")) {
82 _xValue = floor(json_val->
getDouble(
"xValue") * 1000.0 / 65536.0 + 0.5) / 1000.0;
84 if(json_val->
has(
"yValue")) {
85 _yValue = floor(json_val->
getDouble(
"yValue") * 1000.0 / 65536.0 + 0.5) / 1000.0;
87 if(json_val->
has(
"zValue")) {
88 _zValue = floor(json_val->
getDouble(
"zValue") * 1000.0 / 65536.0 + 0.5) / 1000.0;
90 if(json_val->
has(
"gravityCancellation")) {
118 }
catch (std::exception) {
142 char buf[32]; sprintf(buf,
"%d", newval); rest_val = string(buf);
143 res =
_setAttr(
"bandwidth", rest_val);
144 }
catch (std::exception) {
173 }
catch (std::exception) {
202 }
catch (std::exception) {
231 }
catch (std::exception) {
253 }
catch (std::exception) {
267 rest_val = (newval>0 ?
"1" :
"0");
268 res =
_setAttr(
"gravityCancellation", rest_val);
269 }
catch (std::exception) {
317 }
catch (std::exception) {
339 if (callback != NULL) {
346 if (callback != NULL && this->
isOnline()) {
380 if (callback != NULL) {
411 vector<YFUN_DESCR> v_fundescr;
413 string serial, funcId, funcName, funcVal, errmsg;
416 v_fundescr.size() == 0 ||
double getDouble(const string &key)
yCRITICAL_SECTION _this_cs
YAccelerometerValueCallback _valueCallbackAccelerometer
static void _UpdateTimedReportCallbackList(YFunction *func, bool add)
virtual int _parseAttr(YJSONObject *json_val)
YRETCODE _load_unsafe(int msValidity)
void(* YAccelerometerValueCallback)(YAccelerometer *func, const string &functionValue)
static const double ZVALUE_INVALID
YAccelerometer * nextAccelerometer(void)
static int DefaultCacheValidity
YAccelerometerTimedReportCallback _timedReportCallbackAccelerometer
Y_GRAVITYCANCELLATION_enum _gravityCancellation
void yLeaveCriticalSection(yCRITICAL_SECTION *cs)
static const double XVALUE_INVALID
static YRETCODE getFunctionInfo(YFUN_DESCR fundesc, YDEV_DESCR &devdescr, string &serial, string &funcId, string &funcName, string &funcVal, string &errmsg)
int set_gravityCancellation(Y_GRAVITYCANCELLATION_enum newval)
int set_bandwidth(int newval)
void(* YAccelerometerTimedReportCallback)(YAccelerometer *func, YMeasure measure)
int getInt(const string &key)
static u64 GetTickCount(void)
static void _AddToCache(const string &classname, const string &func, YFunction *obj)
virtual int registerTimedReportCallback(YAccelerometerTimedReportCallback callback)
#define YAPI_INVALID_DOUBLE
virtual int _invokeTimedReportCallback(YMeasure value)
virtual int _invokeValueCallback(string value)
static YFunction * _FindFromCache(const string &classname, const string &func)
virtual int registerValueCallback(YAccelerometerValueCallback callback)
void yEnterCriticalSection(yCRITICAL_SECTION *cs)
static yCRITICAL_SECTION _global_cs
virtual int _parseAttr(YJSONObject *json_val)
static const int BANDWIDTH_INVALID
Y_GRAVITYCANCELLATION_enum
static int getFunctionsByClass(const string &class_str, YFUN_DESCR prevfundesc, vector< YFUN_DESCR > &buffer, int maxsize, string &errmsg)
virtual int _invokeValueCallback(string value)
static YAccelerometer * FirstAccelerometer(void)
Y_GRAVITYCANCELLATION_enum get_gravityCancellation(void)
static const double YVALUE_INVALID
static bool _apiInitialized
YRETCODE _nextFunction(string &hwId)
static const Y_GRAVITYCANCELLATION_enum GRAVITYCANCELLATION_INVALID
static void _UpdateValueCallbackList(YFunction *func, bool add)
bool has(const string &key)
static YAccelerometer * FindAccelerometer(string func)
YAccelerometer(const string &func)
YRETCODE _setAttr(string attrname, string newvalue)
virtual int _invokeTimedReportCallback(YMeasure value)