41 #define _CRT_SECURE_NO_DEPRECATE //do not use windows secure crt 49 #define __FILE_ID__ "magnetometer" 53 ,_bandwidth(BANDWIDTH_INVALID)
54 ,_xValue(XVALUE_INVALID)
55 ,_yValue(YVALUE_INVALID)
56 ,_zValue(ZVALUE_INVALID)
57 ,_valueCallbackMagnetometer(NULL)
58 ,_timedReportCallbackMagnetometer(NULL)
77 if(json_val->
has(
"bandwidth")) {
80 if(json_val->
has(
"xValue")) {
81 _xValue = floor(json_val->
getDouble(
"xValue") * 1000.0 / 65536.0 + 0.5) / 1000.0;
83 if(json_val->
has(
"yValue")) {
84 _yValue = floor(json_val->
getDouble(
"yValue") * 1000.0 / 65536.0 + 0.5) / 1000.0;
86 if(json_val->
has(
"zValue")) {
87 _zValue = floor(json_val->
getDouble(
"zValue") * 1000.0 / 65536.0 + 0.5) / 1000.0;
114 }
catch (std::exception) {
138 char buf[32]; sprintf(buf,
"%d", newval); rest_val = string(buf);
139 res =
_setAttr(
"bandwidth", rest_val);
140 }
catch (std::exception) {
170 }
catch (std::exception) {
200 }
catch (std::exception) {
230 }
catch (std::exception) {
278 }
catch (std::exception) {
300 if (callback != NULL) {
307 if (callback != NULL && this->
isOnline()) {
341 if (callback != NULL) {
372 vector<YFUN_DESCR> v_fundescr;
374 string serial, funcId, funcName, funcVal, errmsg;
377 v_fundescr.size() == 0 ||
double getDouble(const string &key)
yCRITICAL_SECTION _this_cs
static void _UpdateTimedReportCallbackList(YFunction *func, bool add)
YRETCODE _load_unsafe(int msValidity)
static const double XVALUE_INVALID
virtual int _invokeTimedReportCallback(YMeasure value)
virtual int registerTimedReportCallback(YMagnetometerTimedReportCallback callback)
static int DefaultCacheValidity
virtual int registerValueCallback(YMagnetometerValueCallback callback)
virtual int _invokeValueCallback(string value)
void yLeaveCriticalSection(yCRITICAL_SECTION *cs)
static const double YVALUE_INVALID
static YRETCODE getFunctionInfo(YFUN_DESCR fundesc, YDEV_DESCR &devdescr, string &serial, string &funcId, string &funcName, string &funcVal, string &errmsg)
YMagnetometer(const string &func)
void(* YMagnetometerTimedReportCallback)(YMagnetometer *func, YMeasure measure)
static const double ZVALUE_INVALID
void(* YMagnetometerValueCallback)(YMagnetometer *func, const string &functionValue)
YMagnetometer * nextMagnetometer(void)
int getInt(const string &key)
static u64 GetTickCount(void)
static void _AddToCache(const string &classname, const string &func, YFunction *obj)
YMagnetometerTimedReportCallback _timedReportCallbackMagnetometer
#define YAPI_INVALID_DOUBLE
virtual int _invokeTimedReportCallback(YMeasure value)
virtual int _invokeValueCallback(string value)
virtual int _parseAttr(YJSONObject *json_val)
static YMagnetometer * FindMagnetometer(string func)
static YFunction * _FindFromCache(const string &classname, const string &func)
void yEnterCriticalSection(yCRITICAL_SECTION *cs)
static yCRITICAL_SECTION _global_cs
virtual int _parseAttr(YJSONObject *json_val)
static int getFunctionsByClass(const string &class_str, YFUN_DESCR prevfundesc, vector< YFUN_DESCR > &buffer, int maxsize, string &errmsg)
YMagnetometerValueCallback _valueCallbackMagnetometer
static bool _apiInitialized
YRETCODE _nextFunction(string &hwId)
static YMagnetometer * FirstMagnetometer(void)
static void _UpdateValueCallbackList(YFunction *func, bool add)
int set_bandwidth(int newval)
bool has(const string &key)
YRETCODE _setAttr(string attrname, string newvalue)
static const int BANDWIDTH_INVALID