41 #define _CRT_SECURE_NO_DEPRECATE //do not use windows secure crt 49 #define __FILE_ID__ "compass" 53 ,_bandwidth(BANDWIDTH_INVALID)
55 ,_magneticHeading(MAGNETICHEADING_INVALID)
56 ,_valueCallbackCompass(NULL)
57 ,_timedReportCallbackCompass(NULL)
74 if(json_val->
has(
"bandwidth")) {
77 if(json_val->
has(
"axis")) {
80 if(json_val->
has(
"magneticHeading")) {
108 }
catch (std::exception) {
132 char buf[32]; sprintf(buf,
"%d", newval); rest_val = string(buf);
133 res =
_setAttr(
"bandwidth", rest_val);
134 }
catch (std::exception) {
156 }
catch (std::exception) {
185 }
catch (std::exception) {
233 }
catch (std::exception) {
255 if (callback != NULL) {
262 if (callback != NULL && this->
isOnline()) {
296 if (callback != NULL) {
327 vector<YFUN_DESCR> v_fundescr;
329 string serial, funcId, funcName, funcVal, errmsg;
332 v_fundescr.size() == 0 ||
double getDouble(const string &key)
yCRITICAL_SECTION _this_cs
static void _UpdateTimedReportCallbackList(YFunction *func, bool add)
static const Y_AXIS_enum AXIS_INVALID
YCompass * nextCompass(void)
YRETCODE _load_unsafe(int msValidity)
static YCompass * FirstCompass(void)
YCompassTimedReportCallback _timedReportCallbackCompass
void(* YCompassValueCallback)(YCompass *func, const string &functionValue)
double get_magneticHeading(void)
static YCompass * FindCompass(string func)
YCompassValueCallback _valueCallbackCompass
static int DefaultCacheValidity
static const double MAGNETICHEADING_INVALID
virtual int _invokeValueCallback(string value)
virtual int registerValueCallback(YCompassValueCallback callback)
void yLeaveCriticalSection(yCRITICAL_SECTION *cs)
YCompass(const string &func)
static YRETCODE getFunctionInfo(YFUN_DESCR fundesc, YDEV_DESCR &devdescr, string &serial, string &funcId, string &funcName, string &funcVal, string &errmsg)
int set_bandwidth(int newval)
Y_AXIS_enum get_axis(void)
virtual int registerTimedReportCallback(YCompassTimedReportCallback callback)
int getInt(const string &key)
static u64 GetTickCount(void)
static void _AddToCache(const string &classname, const string &func, YFunction *obj)
#define YAPI_INVALID_DOUBLE
virtual int _invokeTimedReportCallback(YMeasure value)
virtual int _invokeValueCallback(string value)
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)
virtual int _invokeTimedReportCallback(YMeasure value)
static const int BANDWIDTH_INVALID
static bool _apiInitialized
YRETCODE _nextFunction(string &hwId)
static void _UpdateValueCallbackList(YFunction *func, bool add)
virtual int _parseAttr(YJSONObject *json_val)
void(* YCompassTimedReportCallback)(YCompass *func, YMeasure measure)
bool has(const string &key)
YRETCODE _setAttr(string attrname, string newvalue)