41 #define _CRT_SECURE_NO_DEPRECATE //do not use windows secure crt 49 #define __FILE_ID__ "currentloopoutput" 53 ,_current(CURRENT_INVALID)
54 ,_currentTransition(CURRENTTRANSITION_INVALID)
55 ,_currentAtStartUp(CURRENTATSTARTUP_INVALID)
56 ,_loopPower(LOOPPOWER_INVALID)
57 ,_valueCallbackCurrentLoopOutput(NULL)
76 if(json_val->
has(
"current")) {
77 _current = floor(json_val->
getDouble(
"current") * 1000.0 / 65536.0 + 0.5) / 1000.0;
79 if(json_val->
has(
"currentTransition")) {
82 if(json_val->
has(
"currentAtStartUp")) {
85 if(json_val->
has(
"loopPower")) {
109 char buf[32]; sprintf(buf,
"%d", (
int)floor(newval * 65536.0 + 0.5)); rest_val = string(buf);
110 res =
_setAttr(
"current", rest_val);
111 }
catch (std::exception) {
140 }
catch (std::exception) {
162 }
catch (std::exception) {
177 res =
_setAttr(
"currentTransition", rest_val);
178 }
catch (std::exception) {
202 char buf[32]; sprintf(buf,
"%d", (
int)floor(newval * 65536.0 + 0.5)); rest_val = string(buf);
203 res =
_setAttr(
"currentAtStartUp", rest_val);
204 }
catch (std::exception) {
233 }
catch (std::exception) {
265 }
catch (std::exception) {
313 }
catch (std::exception) {
335 if (callback != NULL) {
342 if (callback != NULL && this->
isOnline()) {
374 if (mA_target < 3.0) {
377 if (mA_target > 21.0) {
397 vector<YFUN_DESCR> v_fundescr;
399 string serial, funcId, funcName, funcVal, errmsg;
402 v_fundescr.size() == 0 ||
double getDouble(const string &key)
yCRITICAL_SECTION _this_cs
virtual int registerValueCallback(YCurrentLoopOutputValueCallback callback)
Y_LOOPPOWER_enum get_loopPower(void)
static const double CURRENTATSTARTUP_INVALID
double get_currentAtStartUp(void)
string _currentTransition
YCurrentLoopOutput(const string &func)
Y_LOOPPOWER_enum _loopPower
YRETCODE _load_unsafe(int msValidity)
YCurrentLoopOutput * nextCurrentLoopOutput(void)
static int DefaultCacheValidity
string getString(const string &key)
void(* YCurrentLoopOutputValueCallback)(YCurrentLoopOutput *func, const string &functionValue)
static const string CURRENTTRANSITION_INVALID
void yLeaveCriticalSection(yCRITICAL_SECTION *cs)
YCurrentLoopOutputValueCallback _valueCallbackCurrentLoopOutput
static YRETCODE getFunctionInfo(YFUN_DESCR fundesc, YDEV_DESCR &devdescr, string &serial, string &funcId, string &funcName, string &funcVal, string &errmsg)
#define YAPI_INVALID_STRING
virtual int _parseAttr(YJSONObject *json_val)
int set_currentAtStartUp(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
virtual int currentMove(double mA_target, int ms_duration)
static const double CURRENT_INVALID
virtual int _parseAttr(YJSONObject *json_val)
static YFunction * _FindFromCache(const string &classname, const string &func)
static string ysprintf(const char *fmt,...)
int set_currentTransition(const string &newval)
string get_currentTransition(void)
void yEnterCriticalSection(yCRITICAL_SECTION *cs)
static yCRITICAL_SECTION _global_cs
virtual int _invokeValueCallback(string value)
static int getFunctionsByClass(const string &class_str, YFUN_DESCR prevfundesc, vector< YFUN_DESCR > &buffer, int maxsize, string &errmsg)
static const Y_LOOPPOWER_enum LOOPPOWER_INVALID
static YCurrentLoopOutput * FindCurrentLoopOutput(string func)
int set_current(double newval)
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)
static YCurrentLoopOutput * FirstCurrentLoopOutput(void)
virtual int _invokeValueCallback(string value)