41 #define _CRT_SECURE_NO_DEPRECATE //do not use windows secure crt 49 #define __FILE_ID__ "motor" 53 ,_motorStatus(MOTORSTATUS_INVALID)
54 ,_drivingForce(DRIVINGFORCE_INVALID)
55 ,_brakingForce(BRAKINGFORCE_INVALID)
56 ,_cutOffVoltage(CUTOFFVOLTAGE_INVALID)
57 ,_overCurrentLimit(OVERCURRENTLIMIT_INVALID)
58 ,_frequency(FREQUENCY_INVALID)
59 ,_starterTime(STARTERTIME_INVALID)
60 ,_failSafeTimeout(FAILSAFETIMEOUT_INVALID)
61 ,_command(COMMAND_INVALID)
62 ,_valueCallbackMotor(NULL)
83 if(json_val->
has(
"motorStatus")) {
86 if(json_val->
has(
"drivingForce")) {
89 if(json_val->
has(
"brakingForce")) {
92 if(json_val->
has(
"cutOffVoltage")) {
95 if(json_val->
has(
"overCurrentLimit")) {
98 if(json_val->
has(
"frequency")) {
101 if(json_val->
has(
"starterTime")) {
104 if(json_val->
has(
"failSafeTimeout")) {
107 if(json_val->
has(
"command")) {
147 }
catch (std::exception) {
161 char buf[32]; sprintf(buf,
"%d", newval); rest_val = string(buf);
162 res =
_setAttr(
"motorStatus", rest_val);
163 }
catch (std::exception) {
190 char buf[32]; sprintf(buf,
"%d", (
int)floor(newval * 65536.0 + 0.5)); rest_val = string(buf);
191 res =
_setAttr(
"drivingForce", rest_val);
192 }
catch (std::exception) {
222 }
catch (std::exception) {
248 char buf[32]; sprintf(buf,
"%d", (
int)floor(newval * 65536.0 + 0.5)); rest_val = string(buf);
249 res =
_setAttr(
"brakingForce", rest_val);
250 }
catch (std::exception) {
280 }
catch (std::exception) {
309 char buf[32]; sprintf(buf,
"%d", (
int)floor(newval * 65536.0 + 0.5)); rest_val = string(buf);
310 res =
_setAttr(
"cutOffVoltage", rest_val);
311 }
catch (std::exception) {
344 }
catch (std::exception) {
375 }
catch (std::exception) {
403 char buf[32]; sprintf(buf,
"%d", newval); rest_val = string(buf);
404 res =
_setAttr(
"overCurrentLimit", rest_val);
405 }
catch (std::exception) {
431 char buf[32]; sprintf(buf,
"%d", (
int)floor(newval * 65536.0 + 0.5)); rest_val = string(buf);
432 res =
_setAttr(
"frequency", rest_val);
433 }
catch (std::exception) {
462 }
catch (std::exception) {
494 }
catch (std::exception) {
520 char buf[32]; sprintf(buf,
"%d", newval); rest_val = string(buf);
521 res =
_setAttr(
"starterTime", rest_val);
522 }
catch (std::exception) {
556 }
catch (std::exception) {
584 char buf[32]; sprintf(buf,
"%d", newval); rest_val = string(buf);
585 res =
_setAttr(
"failSafeTimeout", rest_val);
586 }
catch (std::exception) {
608 }
catch (std::exception) {
623 res =
_setAttr(
"command", rest_val);
624 }
catch (std::exception) {
672 }
catch (std::exception) {
694 if (callback != NULL) {
701 if (callback != NULL && this->
isOnline()) {
782 vector<YFUN_DESCR> v_fundescr;
784 string serial, funcId, funcName, funcVal, errmsg;
787 v_fundescr.size() == 0 ||
static const int FAILSAFETIMEOUT_INVALID
double getDouble(const string &key)
int get_starterTime(void)
yCRITICAL_SECTION _this_cs
int set_motorStatus(Y_MOTORSTATUS_enum newval)
int set_cutOffVoltage(double newval)
YRETCODE _load_unsafe(int msValidity)
Y_MOTORSTATUS_enum _motorStatus
int set_command(const string &newval)
static int DefaultCacheValidity
string getString(const string &key)
static const string COMMAND_INVALID
static const double CUTOFFVOLTAGE_INVALID
static const double FREQUENCY_INVALID
static const int STARTERTIME_INVALID
int set_brakingForce(double 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)
static YMotor * FindMotor(string func)
int get_failSafeTimeout(void)
static const Y_MOTORSTATUS_enum MOTORSTATUS_INVALID
#define YAPI_INVALID_STRING
double get_brakingForce(void)
virtual int _parseAttr(YJSONObject *json_val)
double get_frequency(void)
static const int OVERCURRENTLIMIT_INVALID
int set_frequency(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
int set_starterTime(int newval)
virtual int _parseAttr(YJSONObject *json_val)
YMotorValueCallback _valueCallbackMotor
static YFunction * _FindFromCache(const string &classname, const string &func)
static string ysprintf(const char *fmt,...)
virtual int keepALive(void)
void yEnterCriticalSection(yCRITICAL_SECTION *cs)
void(* YMotorValueCallback)(YMotor *func, const string &functionValue)
static yCRITICAL_SECTION _global_cs
Y_MOTORSTATUS_enum get_motorStatus(void)
virtual int registerValueCallback(YMotorValueCallback callback)
int set_drivingForce(double newval)
static int getFunctionsByClass(const string &class_str, YFUN_DESCR prevfundesc, vector< YFUN_DESCR > &buffer, int maxsize, string &errmsg)
int set_overCurrentLimit(int newval)
static const double BRAKINGFORCE_INVALID
YMotor(const string &func)
int get_overCurrentLimit(void)
int set_failSafeTimeout(int newval)
virtual int _invokeValueCallback(string value)
static bool _apiInitialized
YRETCODE _nextFunction(string &hwId)
static YMotor * FirstMotor(void)
virtual int resetStatus(void)
static const double DRIVINGFORCE_INVALID
static void _UpdateValueCallbackList(YFunction *func, bool add)
double get_cutOffVoltage(void)
double get_drivingForce(void)
virtual int drivingForceMove(double targetPower, int delay)
bool has(const string &key)
virtual int brakingForceMove(double targetPower, int delay)
YRETCODE _setAttr(string attrname, string newvalue)
virtual int _invokeValueCallback(string value)