41 #define _CRT_SECURE_NO_DEPRECATE //do not use windows secure crt 49 #define __FILE_ID__ "lightsensor" 53 ,_measureType(MEASURETYPE_INVALID)
54 ,_valueCallbackLightSensor(NULL)
55 ,_timedReportCallbackLightSensor(NULL)
71 if(json_val->
has(
"measureType")) {
84 char buf[32]; sprintf(buf,
"%d", (
int)floor(newval * 65536.0 + 0.5)); rest_val = string(buf);
85 res =
_setAttr(
"currentValue", rest_val);
86 }
catch (std::exception) {
110 char buf[32]; sprintf(buf,
"%d", (
int)floor(calibratedVal * 65536.0 + 0.5)); rest_val = string(buf);
111 return _setAttr(
"currentValue", rest_val);
136 }
catch (std::exception) {
165 char buf[32]; sprintf(buf,
"%d", newval); rest_val = string(buf);
166 res =
_setAttr(
"measureType", rest_val);
167 }
catch (std::exception) {
215 }
catch (std::exception) {
237 if (callback != NULL) {
244 if (callback != NULL && this->
isOnline()) {
278 if (callback != NULL) {
309 vector<YFUN_DESCR> v_fundescr;
311 string serial, funcId, funcName, funcVal, errmsg;
314 v_fundescr.size() == 0 ||
int set_measureType(Y_MEASURETYPE_enum newval)
yCRITICAL_SECTION _this_cs
Y_MEASURETYPE_enum _measureType
static void _UpdateTimedReportCallbackList(YFunction *func, bool add)
virtual int _invokeTimedReportCallback(YMeasure value)
Y_MEASURETYPE_enum get_measureType(void)
YRETCODE _load_unsafe(int msValidity)
static const Y_MEASURETYPE_enum MEASURETYPE_INVALID
void(* YLightSensorValueCallback)(YLightSensor *func, const string &functionValue)
YLightSensorTimedReportCallback _timedReportCallbackLightSensor
static int DefaultCacheValidity
virtual int _parseAttr(YJSONObject *json_val)
void yLeaveCriticalSection(yCRITICAL_SECTION *cs)
virtual int registerValueCallback(YLightSensorValueCallback callback)
static YRETCODE getFunctionInfo(YFUN_DESCR fundesc, YDEV_DESCR &devdescr, string &serial, string &funcId, string &funcName, string &funcVal, string &errmsg)
virtual int _invokeValueCallback(string value)
static YLightSensor * FindLightSensor(string func)
YLightSensorValueCallback _valueCallbackLightSensor
int getInt(const string &key)
static u64 GetTickCount(void)
static void _AddToCache(const string &classname, const string &func, YFunction *obj)
int set_currentValue(double newval)
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 registerTimedReportCallback(YLightSensorTimedReportCallback callback)
virtual int _parseAttr(YJSONObject *json_val)
static int getFunctionsByClass(const string &class_str, YFUN_DESCR prevfundesc, vector< YFUN_DESCR > &buffer, int maxsize, string &errmsg)
int calibrate(double calibratedVal)
static bool _apiInitialized
YRETCODE _nextFunction(string &hwId)
YLightSensor * nextLightSensor(void)
static void _UpdateValueCallbackList(YFunction *func, bool add)
static YLightSensor * FirstLightSensor(void)
void(* YLightSensorTimedReportCallback)(YLightSensor *func, YMeasure measure)
bool has(const string &key)
YRETCODE _setAttr(string attrname, string newvalue)
YLightSensor(const string &func)