41 #define _CRT_SECURE_NO_DEPRECATE //do not use windows secure crt 49 #define __FILE_ID__ "pwminput" 53 ,_dutyCycle(DUTYCYCLE_INVALID)
54 ,_pulseDuration(PULSEDURATION_INVALID)
55 ,_frequency(FREQUENCY_INVALID)
56 ,_period(PERIOD_INVALID)
57 ,_pulseCounter(PULSECOUNTER_INVALID)
58 ,_pulseTimer(PULSETIMER_INVALID)
59 ,_pwmReportMode(PWMREPORTMODE_INVALID)
60 ,_debouncePeriod(DEBOUNCEPERIOD_INVALID)
61 ,_valueCallbackPwmInput(NULL)
62 ,_timedReportCallbackPwmInput(NULL)
82 if(json_val->
has(
"dutyCycle")) {
85 if(json_val->
has(
"pulseDuration")) {
88 if(json_val->
has(
"frequency")) {
91 if(json_val->
has(
"period")) {
92 _period = floor(json_val->
getDouble(
"period") * 1000.0 / 65536.0 + 0.5) / 1000.0;
94 if(json_val->
has(
"pulseCounter")) {
97 if(json_val->
has(
"pulseTimer")) {
100 if(json_val->
has(
"pwmReportMode")) {
103 if(json_val->
has(
"debouncePeriod")) {
131 }
catch (std::exception) {
161 }
catch (std::exception) {
190 }
catch (std::exception) {
219 }
catch (std::exception) {
250 }
catch (std::exception) {
264 char buf[32]; sprintf(buf,
"%u", (u32)newval); rest_val = string(buf);
265 res =
_setAttr(
"pulseCounter", rest_val);
266 }
catch (std::exception) {
295 }
catch (std::exception) {
329 }
catch (std::exception) {
359 char buf[32]; sprintf(buf,
"%d", newval); rest_val = string(buf);
360 res =
_setAttr(
"pwmReportMode", rest_val);
361 }
catch (std::exception) {
390 }
catch (std::exception) {
413 char buf[32]; sprintf(buf,
"%d", newval); rest_val = string(buf);
414 res =
_setAttr(
"debouncePeriod", rest_val);
415 }
catch (std::exception) {
463 }
catch (std::exception) {
485 if (callback != NULL) {
492 if (callback != NULL && this->
isOnline()) {
526 if (callback != NULL) {
569 vector<YFUN_DESCR> v_fundescr;
571 string serial, funcId, funcName, funcVal, errmsg;
574 v_fundescr.size() == 0 ||
double getDouble(const string &key)
yCRITICAL_SECTION _this_cs
static void _UpdateTimedReportCallbackList(YFunction *func, bool add)
YRETCODE _load_unsafe(int msValidity)
static int DefaultCacheValidity
void yLeaveCriticalSection(yCRITICAL_SECTION *cs)
static YRETCODE getFunctionInfo(YFUN_DESCR fundesc, YDEV_DESCR &devdescr, string &serial, string &funcId, string &funcName, string &funcVal, string &errmsg)
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)
s64 getLong(const string &key)
static bool _apiInitialized
YRETCODE _nextFunction(string &hwId)
static void _UpdateValueCallbackList(YFunction *func, bool add)
bool has(const string &key)
YRETCODE _setAttr(string attrname, string newvalue)