41 #define _CRT_SECURE_NO_DEPRECATE //do not use windows secure crt 49 #define __FILE_ID__ "quadraturedecoder" 53 ,_speed(SPEED_INVALID)
54 ,_decoding(DECODING_INVALID)
55 ,_valueCallbackQuadratureDecoder(NULL)
56 ,_timedReportCallbackQuadratureDecoder(NULL)
73 if(json_val->
has(
"speed")) {
74 _speed = floor(json_val->
getDouble(
"speed") * 1000.0 / 65536.0 + 0.5) / 1000.0;
76 if(json_val->
has(
"decoding")) {
99 char buf[32]; sprintf(buf,
"%d", (
int)floor(newval * 65536.0 + 0.5)); rest_val = string(buf);
100 res =
_setAttr(
"currentValue", rest_val);
101 }
catch (std::exception) {
130 }
catch (std::exception) {
160 }
catch (std::exception) {
184 rest_val = (newval>0 ?
"1" :
"0");
185 res =
_setAttr(
"decoding", rest_val);
186 }
catch (std::exception) {
234 }
catch (std::exception) {
256 if (callback != NULL) {
263 if (callback != NULL && this->
isOnline()) {
297 if (callback != NULL) {
328 vector<YFUN_DESCR> v_fundescr;
330 string serial, funcId, funcName, funcVal, errmsg;
333 v_fundescr.size() == 0 ||
double getDouble(const string &key)
yCRITICAL_SECTION _this_cs
virtual int registerTimedReportCallback(YQuadratureDecoderTimedReportCallback callback)
static void _UpdateTimedReportCallbackList(YFunction *func, bool add)
YRETCODE _load_unsafe(int msValidity)
static YQuadratureDecoder * FirstQuadratureDecoder(void)
virtual int _parseAttr(YJSONObject *json_val)
static int DefaultCacheValidity
int set_decoding(Y_DECODING_enum newval)
void yLeaveCriticalSection(yCRITICAL_SECTION *cs)
static YRETCODE getFunctionInfo(YFUN_DESCR fundesc, YDEV_DESCR &devdescr, string &serial, string &funcId, string &funcName, string &funcVal, string &errmsg)
YQuadratureDecoder(const string &func)
virtual int _invokeValueCallback(string value)
int set_currentValue(double newval)
int getInt(const string &key)
static u64 GetTickCount(void)
static void _AddToCache(const string &classname, const string &func, YFunction *obj)
#define YAPI_INVALID_DOUBLE
Y_DECODING_enum _decoding
virtual int _invokeTimedReportCallback(YMeasure value)
virtual int _invokeValueCallback(string value)
void(* YQuadratureDecoderValueCallback)(YQuadratureDecoder *func, const string &functionValue)
static YFunction * _FindFromCache(const string &classname, const string &func)
static const Y_DECODING_enum DECODING_INVALID
void yEnterCriticalSection(yCRITICAL_SECTION *cs)
static yCRITICAL_SECTION _global_cs
YQuadratureDecoderValueCallback _valueCallbackQuadratureDecoder
virtual int _parseAttr(YJSONObject *json_val)
virtual int registerValueCallback(YQuadratureDecoderValueCallback callback)
static int getFunctionsByClass(const string &class_str, YFUN_DESCR prevfundesc, vector< YFUN_DESCR > &buffer, int maxsize, string &errmsg)
void(* YQuadratureDecoderTimedReportCallback)(YQuadratureDecoder *func, YMeasure measure)
static const double SPEED_INVALID
static YQuadratureDecoder * FindQuadratureDecoder(string func)
static bool _apiInitialized
YRETCODE _nextFunction(string &hwId)
static void _UpdateValueCallbackList(YFunction *func, bool add)
Y_DECODING_enum get_decoding(void)
virtual int _invokeTimedReportCallback(YMeasure value)
bool has(const string &key)
YRETCODE _setAttr(string attrname, string newvalue)
YQuadratureDecoder * nextQuadratureDecoder(void)
YQuadratureDecoderTimedReportCallback _timedReportCallbackQuadratureDecoder