41 #define _CRT_SECURE_NO_DEPRECATE //do not use windows secure crt 49 #define __FILE_ID__ "voltageoutput" 53 ,_currentVoltage(CURRENTVOLTAGE_INVALID)
54 ,_voltageTransition(VOLTAGETRANSITION_INVALID)
55 ,_voltageAtStartUp(VOLTAGEATSTARTUP_INVALID)
56 ,_valueCallbackVoltageOutput(NULL)
75 if(json_val->
has(
"currentVoltage")) {
78 if(json_val->
has(
"voltageTransition")) {
81 if(json_val->
has(
"voltageAtStartUp")) {
103 char buf[32]; sprintf(buf,
"%d", (
int)floor(newval * 65536.0 + 0.5)); rest_val = string(buf);
104 res =
_setAttr(
"currentVoltage", rest_val);
105 }
catch (std::exception) {
134 }
catch (std::exception) {
156 }
catch (std::exception) {
171 res =
_setAttr(
"voltageTransition", rest_val);
172 }
catch (std::exception) {
196 char buf[32]; sprintf(buf,
"%d", (
int)floor(newval * 65536.0 + 0.5)); rest_val = string(buf);
197 res =
_setAttr(
"voltageAtStartUp", rest_val);
198 }
catch (std::exception) {
227 }
catch (std::exception) {
275 }
catch (std::exception) {
297 if (callback != NULL) {
304 if (callback != NULL && this->
isOnline()) {
336 if (V_target < 0.0) {
339 if (V_target > 10.0) {
359 vector<YFUN_DESCR> v_fundescr;
361 string serial, funcId, funcName, funcVal, errmsg;
364 v_fundescr.size() == 0 ||
double get_voltageAtStartUp(void)
double getDouble(const string &key)
yCRITICAL_SECTION _this_cs
virtual int voltageMove(double V_target, int ms_duration)
double get_currentVoltage(void)
static YVoltageOutput * FindVoltageOutput(string func)
YRETCODE _load_unsafe(int msValidity)
string get_voltageTransition(void)
static int DefaultCacheValidity
string _voltageTransition
string getString(const string &key)
static const double VOLTAGEATSTARTUP_INVALID
static YVoltageOutput * FirstVoltageOutput(void)
virtual int _invokeValueCallback(string value)
void yLeaveCriticalSection(yCRITICAL_SECTION *cs)
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)
static u64 GetTickCount(void)
static void _AddToCache(const string &classname, const string &func, YFunction *obj)
#define YAPI_INVALID_DOUBLE
static YFunction * _FindFromCache(const string &classname, const string &func)
static string ysprintf(const char *fmt,...)
void yEnterCriticalSection(yCRITICAL_SECTION *cs)
static yCRITICAL_SECTION _global_cs
static const double CURRENTVOLTAGE_INVALID
int set_currentVoltage(double newval)
virtual int _parseAttr(YJSONObject *json_val)
static int getFunctionsByClass(const string &class_str, YFUN_DESCR prevfundesc, vector< YFUN_DESCR > &buffer, int maxsize, string &errmsg)
YVoltageOutput(const string &func)
int set_voltageAtStartUp(double newval)
virtual int registerValueCallback(YVoltageOutputValueCallback callback)
YVoltageOutput * nextVoltageOutput(void)
int set_voltageTransition(const string &newval)
YVoltageOutputValueCallback _valueCallbackVoltageOutput
static bool _apiInitialized
YRETCODE _nextFunction(string &hwId)
static void _UpdateValueCallbackList(YFunction *func, bool add)
void(* YVoltageOutputValueCallback)(YVoltageOutput *func, const string &functionValue)
bool has(const string &key)
YRETCODE _setAttr(string attrname, string newvalue)
static const string VOLTAGETRANSITION_INVALID
virtual int _invokeValueCallback(string value)