41 #define _CRT_SECURE_NO_DEPRECATE //do not use windows secure crt 49 #define __FILE_ID__ "rangefinder" 53 ,_rangeFinderMode(RANGEFINDERMODE_INVALID)
54 ,_hardwareCalibration(HARDWARECALIBRATION_INVALID)
55 ,_currentTemperature(CURRENTTEMPERATURE_INVALID)
56 ,_command(COMMAND_INVALID)
57 ,_valueCallbackRangeFinder(NULL)
58 ,_timedReportCallbackRangeFinder(NULL)
77 if(json_val->
has(
"rangeFinderMode")) {
80 if(json_val->
has(
"hardwareCalibration")) {
83 if(json_val->
has(
"currentTemperature")) {
86 if(json_val->
has(
"command")) {
114 }
catch (std::exception) {
145 }
catch (std::exception) {
172 char buf[32]; sprintf(buf,
"%d", newval); rest_val = string(buf);
173 res =
_setAttr(
"rangeFinderMode", rest_val);
174 }
catch (std::exception) {
196 }
catch (std::exception) {
211 res =
_setAttr(
"hardwareCalibration", rest_val);
212 }
catch (std::exception) {
241 }
catch (std::exception) {
263 }
catch (std::exception) {
278 res =
_setAttr(
"command", rest_val);
279 }
catch (std::exception) {
327 }
catch (std::exception) {
349 if (callback != NULL) {
356 if (callback != NULL && this->
isOnline()) {
390 if (callback != NULL) {
421 if (!((hwcal).substr(0, 1) ==
"@")) {
424 return atoi(((hwcal).substr(1, (
int)(hwcal).length())).c_str());
471 distmm = (int) floor(targetDist * 25.4+0.5);
473 distmm = (int) floor(targetDist+0.5);
494 distmm = (int) floor(targetDist * 25.4+0.5);
496 distmm = (int) floor(targetDist+0.5);
526 vector<YFUN_DESCR> v_fundescr;
528 string serial, funcId, funcName, funcVal, errmsg;
531 v_fundescr.size() == 0 ||
virtual double get_hardwareCalibrationTemperature(void)
double getDouble(const string &key)
yCRITICAL_SECTION _this_cs
static void _UpdateTimedReportCallbackList(YFunction *func, bool add)
virtual int _invokeTimedReportCallback(YMeasure value)
Y_RANGEFINDERMODE_enum get_rangeFinderMode(void)
string _hardwareCalibration
YRETCODE _load_unsafe(int msValidity)
virtual int registerValueCallback(YRangeFinderValueCallback callback)
virtual int triggerOffsetCalibration(double targetDist)
YRangeFinderTimedReportCallback _timedReportCallbackRangeFinder
static const string HARDWARECALIBRATION_INVALID
YRangeFinderValueCallback _valueCallbackRangeFinder
virtual int cancelCoverGlassCalibrations(void)
static int DefaultCacheValidity
string getString(const string &key)
string get_hardwareCalibration(void)
virtual int triggerTemperatureCalibration(void)
int set_rangeFinderMode(Y_RANGEFINDERMODE_enum newval)
void yLeaveCriticalSection(yCRITICAL_SECTION *cs)
virtual int _invokeValueCallback(string value)
static YRETCODE getFunctionInfo(YFUN_DESCR fundesc, YDEV_DESCR &devdescr, string &serial, string &funcId, string &funcName, string &funcVal, string &errmsg)
virtual int registerTimedReportCallback(YRangeFinderTimedReportCallback callback)
void(* YRangeFinderTimedReportCallback)(YRangeFinder *func, YMeasure measure)
#define YAPI_INVALID_STRING
YRangeFinder * nextRangeFinder(void)
static YRangeFinder * FindRangeFinder(string func)
int getInt(const string &key)
static u64 GetTickCount(void)
static void _AddToCache(const string &classname, const string &func, YFunction *obj)
Y_RANGEFINDERMODE_enum _rangeFinderMode
static const double CURRENTTEMPERATURE_INVALID
#define YAPI_INVALID_DOUBLE
virtual int _invokeTimedReportCallback(YMeasure value)
virtual int _invokeValueCallback(string value)
static YRangeFinder * FirstRangeFinder(void)
virtual int _parseAttr(YJSONObject *json_val)
static YFunction * _FindFromCache(const string &classname, const string &func)
static string ysprintf(const char *fmt,...)
double get_currentTemperature(void)
static const string COMMAND_INVALID
void yEnterCriticalSection(yCRITICAL_SECTION *cs)
static yCRITICAL_SECTION _global_cs
static const Y_RANGEFINDERMODE_enum RANGEFINDERMODE_INVALID
virtual int _parseAttr(YJSONObject *json_val)
int set_command(const string &newval)
int set_hardwareCalibration(const string &newval)
static int getFunctionsByClass(const string &class_str, YFUN_DESCR prevfundesc, vector< YFUN_DESCR > &buffer, int maxsize, string &errmsg)
int set_unit(const string &newval)
static bool _apiInitialized
YRETCODE _nextFunction(string &hwId)
virtual int triggerSpadCalibration(void)
static void _UpdateValueCallbackList(YFunction *func, bool add)
double _currentTemperature
YRangeFinder(const string &func)
bool has(const string &key)
YRETCODE _setAttr(string attrname, string newvalue)
void(* YRangeFinderValueCallback)(YRangeFinder *func, const string &functionValue)
virtual int triggerXTalkCalibration(double targetDist)