41 #define _CRT_SECURE_NO_DEPRECATE //do not use windows secure crt 49 #define __FILE_ID__ "genericsensor" 53 ,_signalValue(SIGNALVALUE_INVALID)
54 ,_signalUnit(SIGNALUNIT_INVALID)
55 ,_signalRange(SIGNALRANGE_INVALID)
56 ,_valueRange(VALUERANGE_INVALID)
57 ,_signalBias(SIGNALBIAS_INVALID)
58 ,_signalSampling(SIGNALSAMPLING_INVALID)
59 ,_valueCallbackGenericSensor(NULL)
60 ,_timedReportCallbackGenericSensor(NULL)
81 if(json_val->
has(
"signalValue")) {
84 if(json_val->
has(
"signalUnit")) {
87 if(json_val->
has(
"signalRange")) {
90 if(json_val->
has(
"valueRange")) {
93 if(json_val->
has(
"signalBias")) {
96 if(json_val->
has(
"signalSampling")) {
122 }
catch (std::exception) {
152 }
catch (std::exception) {
181 }
catch (std::exception) {
210 }
catch (std::exception) {
234 res =
_setAttr(
"signalRange", rest_val);
235 }
catch (std::exception) {
264 }
catch (std::exception) {
289 res =
_setAttr(
"valueRange", rest_val);
290 }
catch (std::exception) {
315 char buf[32]; sprintf(buf,
"%d", (
int)floor(newval * 65536.0 + 0.5)); rest_val = string(buf);
316 res =
_setAttr(
"signalBias", rest_val);
317 }
catch (std::exception) {
348 }
catch (std::exception) {
384 }
catch (std::exception) {
414 char buf[32]; sprintf(buf,
"%d", newval); rest_val = string(buf);
415 res =
_setAttr(
"signalSampling", rest_val);
416 }
catch (std::exception) {
464 }
catch (std::exception) {
486 if (callback != NULL) {
493 if (callback != NULL && this->
isOnline()) {
527 if (callback != NULL) {
556 double currSignal = 0.0;
557 double currBias = 0.0;
575 vector<YFUN_DESCR> v_fundescr;
577 string serial, funcId, funcName, funcVal, errmsg;
580 v_fundescr.size() == 0 ||
string get_signalRange(void)
virtual int registerTimedReportCallback(YGenericSensorTimedReportCallback callback)
double getDouble(const string &key)
yCRITICAL_SECTION _this_cs
int set_signalRange(const string &newval)
static void _UpdateTimedReportCallbackList(YFunction *func, bool add)
void(* YGenericSensorValueCallback)(YGenericSensor *func, const string &functionValue)
YRETCODE _load_unsafe(int msValidity)
virtual int zeroAdjust(void)
YGenericSensor(const string &func)
int set_valueRange(const string &newval)
double get_signalBias(void)
virtual int _parseAttr(YJSONObject *json_val)
static int DefaultCacheValidity
string getString(const string &key)
void(* YGenericSensorTimedReportCallback)(YGenericSensor *func, YMeasure measure)
virtual int _invokeValueCallback(string value)
void yLeaveCriticalSection(yCRITICAL_SECTION *cs)
static YRETCODE getFunctionInfo(YFUN_DESCR fundesc, YDEV_DESCR &devdescr, string &serial, string &funcId, string &funcName, string &funcVal, string &errmsg)
#define YAPI_INVALID_STRING
virtual int registerValueCallback(YGenericSensorValueCallback callback)
int set_signalBias(double newval)
int getInt(const string &key)
static u64 GetTickCount(void)
static void _AddToCache(const string &classname, const string &func, YFunction *obj)
static YGenericSensor * FirstGenericSensor(void)
#define YAPI_INVALID_DOUBLE
virtual int _invokeTimedReportCallback(YMeasure value)
virtual int _invokeValueCallback(string value)
static YFunction * _FindFromCache(const string &classname, const string &func)
static const string SIGNALRANGE_INVALID
void yEnterCriticalSection(yCRITICAL_SECTION *cs)
static yCRITICAL_SECTION _global_cs
static const double SIGNALBIAS_INVALID
Y_SIGNALSAMPLING_enum get_signalSampling(void)
YGenericSensor * nextGenericSensor(void)
virtual int _parseAttr(YJSONObject *json_val)
static int getFunctionsByClass(const string &class_str, YFUN_DESCR prevfundesc, vector< YFUN_DESCR > &buffer, int maxsize, string &errmsg)
static const Y_SIGNALSAMPLING_enum SIGNALSAMPLING_INVALID
Y_SIGNALSAMPLING_enum _signalSampling
string get_signalUnit(void)
static const string VALUERANGE_INVALID
double get_signalValue(void)
virtual int _invokeTimedReportCallback(YMeasure value)
string get_valueRange(void)
static YGenericSensor * FindGenericSensor(string func)
YGenericSensorTimedReportCallback _timedReportCallbackGenericSensor
static const string SIGNALUNIT_INVALID
int set_signalSampling(Y_SIGNALSAMPLING_enum newval)
int set_unit(const string &newval)
static bool _apiInitialized
YRETCODE _nextFunction(string &hwId)
static void _UpdateValueCallbackList(YFunction *func, bool add)
static const double SIGNALVALUE_INVALID
YGenericSensorValueCallback _valueCallbackGenericSensor
bool has(const string &key)
YRETCODE _setAttr(string attrname, string newvalue)