41 #define _CRT_SECURE_NO_DEPRECATE //do not use windows secure crt 49 #define __FILE_ID__ "powersupply" 53 ,_voltageSetPoint(VOLTAGESETPOINT_INVALID)
54 ,_currentLimit(CURRENTLIMIT_INVALID)
55 ,_powerOutput(POWEROUTPUT_INVALID)
56 ,_voltageSense(VOLTAGESENSE_INVALID)
57 ,_measuredVoltage(MEASUREDVOLTAGE_INVALID)
58 ,_measuredCurrent(MEASUREDCURRENT_INVALID)
59 ,_inputVoltage(INPUTVOLTAGE_INVALID)
61 ,_ldoTemperature(LDOTEMPERATURE_INVALID)
62 ,_voltageTransition(VOLTAGETRANSITION_INVALID)
63 ,_voltageAtStartUp(VOLTAGEATSTARTUP_INVALID)
64 ,_currentAtStartUp(CURRENTATSTARTUP_INVALID)
65 ,_command(COMMAND_INVALID)
66 ,_valueCallbackPowerSupply(NULL)
93 if(json_val->
has(
"voltageSetPoint")) {
96 if(json_val->
has(
"currentLimit")) {
99 if(json_val->
has(
"powerOutput")) {
102 if(json_val->
has(
"voltageSense")) {
105 if(json_val->
has(
"measuredVoltage")) {
108 if(json_val->
has(
"measuredCurrent")) {
111 if(json_val->
has(
"inputVoltage")) {
114 if(json_val->
has(
"vInt")) {
115 _vInt = floor(json_val->
getDouble(
"vInt") * 1000.0 / 65536.0 + 0.5) / 1000.0;
117 if(json_val->
has(
"ldoTemperature")) {
120 if(json_val->
has(
"voltageTransition")) {
123 if(json_val->
has(
"voltageAtStartUp")) {
126 if(json_val->
has(
"currentAtStartUp")) {
129 if(json_val->
has(
"command")) {
151 char buf[32]; sprintf(buf,
"%d", (
int)floor(newval * 65536.0 + 0.5)); rest_val = string(buf);
152 res =
_setAttr(
"voltageSetPoint", rest_val);
153 }
catch (std::exception) {
182 }
catch (std::exception) {
205 char buf[32]; sprintf(buf,
"%d", (
int)floor(newval * 65536.0 + 0.5)); rest_val = string(buf);
206 res =
_setAttr(
"currentLimit", rest_val);
207 }
catch (std::exception) {
236 }
catch (std::exception) {
265 }
catch (std::exception) {
288 rest_val = (newval>0 ?
"1" :
"0");
289 res =
_setAttr(
"powerOutput", rest_val);
290 }
catch (std::exception) {
319 }
catch (std::exception) {
342 char buf[32]; sprintf(buf,
"%d", newval); rest_val = string(buf);
343 res =
_setAttr(
"voltageSense", rest_val);
344 }
catch (std::exception) {
373 }
catch (std::exception) {
402 }
catch (std::exception) {
431 }
catch (std::exception) {
460 }
catch (std::exception) {
489 }
catch (std::exception) {
511 }
catch (std::exception) {
526 res =
_setAttr(
"voltageTransition", rest_val);
527 }
catch (std::exception) {
551 char buf[32]; sprintf(buf,
"%d", (
int)floor(newval * 65536.0 + 0.5)); rest_val = string(buf);
552 res =
_setAttr(
"voltageAtStartUp", rest_val);
553 }
catch (std::exception) {
582 }
catch (std::exception) {
606 char buf[32]; sprintf(buf,
"%d", (
int)floor(newval * 65536.0 + 0.5)); rest_val = string(buf);
607 res =
_setAttr(
"currentAtStartUp", rest_val);
608 }
catch (std::exception) {
637 }
catch (std::exception) {
659 }
catch (std::exception) {
674 res =
_setAttr(
"command", rest_val);
675 }
catch (std::exception) {
723 }
catch (std::exception) {
745 if (callback != NULL) {
752 if (callback != NULL && this->
isOnline()) {
784 if (V_target < 0.0) {
804 vector<YFUN_DESCR> v_fundescr;
806 string serial, funcId, funcName, funcVal, errmsg;
809 v_fundescr.size() == 0 ||
YPowerSupplyValueCallback _valueCallbackPowerSupply
static const double CURRENTLIMIT_INVALID
double getDouble(const string &key)
static const double CURRENTATSTARTUP_INVALID
void(* YPowerSupplyValueCallback)(YPowerSupply *func, const string &functionValue)
yCRITICAL_SECTION _this_cs
int set_voltageAtStartUp(double newval)
static const Y_POWEROUTPUT_enum POWEROUTPUT_INVALID
YRETCODE _load_unsafe(int msValidity)
static const double INPUTVOLTAGE_INVALID
static const string VOLTAGETRANSITION_INVALID
static const double LDOTEMPERATURE_INVALID
virtual int registerValueCallback(YPowerSupplyValueCallback callback)
static const double VINT_INVALID
static YPowerSupply * FirstPowerSupply(void)
int set_currentAtStartUp(double newval)
static int DefaultCacheValidity
string getString(const string &key)
void yLeaveCriticalSection(yCRITICAL_SECTION *cs)
static const double MEASUREDVOLTAGE_INVALID
static YRETCODE getFunctionInfo(YFUN_DESCR fundesc, YDEV_DESCR &devdescr, string &serial, string &funcId, string &funcName, string &funcVal, string &errmsg)
double get_measuredVoltage(void)
int set_voltageTransition(const string &newval)
#define YAPI_INVALID_STRING
virtual int _parseAttr(YJSONObject *json_val)
double get_currentAtStartUp(void)
double get_currentLimit(void)
int set_voltageSetPoint(double newval)
int getInt(const string &key)
static u64 GetTickCount(void)
static const double VOLTAGESETPOINT_INVALID
static void _AddToCache(const string &classname, const string &func, YFunction *obj)
#define YAPI_INVALID_DOUBLE
double get_ldoTemperature(void)
virtual int _parseAttr(YJSONObject *json_val)
int set_command(const string &newval)
int set_powerOutput(Y_POWEROUTPUT_enum newval)
static YFunction * _FindFromCache(const string &classname, const string &func)
string get_voltageTransition(void)
string _voltageTransition
static string ysprintf(const char *fmt,...)
int set_currentLimit(double newval)
void yEnterCriticalSection(yCRITICAL_SECTION *cs)
static yCRITICAL_SECTION _global_cs
Y_POWEROUTPUT_enum _powerOutput
static const string COMMAND_INVALID
static YPowerSupply * FindPowerSupply(string func)
static const double MEASUREDCURRENT_INVALID
double get_voltageSetPoint(void)
static int getFunctionsByClass(const string &class_str, YFUN_DESCR prevfundesc, vector< YFUN_DESCR > &buffer, int maxsize, string &errmsg)
int set_voltageSense(Y_VOLTAGESENSE_enum newval)
Y_VOLTAGESENSE_enum get_voltageSense(void)
double get_inputVoltage(void)
Y_VOLTAGESENSE_enum _voltageSense
double get_voltageAtStartUp(void)
YPowerSupply(const string &func)
static bool _apiInitialized
YRETCODE _nextFunction(string &hwId)
virtual int _invokeValueCallback(string value)
static void _UpdateValueCallbackList(YFunction *func, bool add)
virtual int voltageMove(double V_target, int ms_duration)
bool has(const string &key)
Y_POWEROUTPUT_enum get_powerOutput(void)
YPowerSupply * nextPowerSupply(void)
YRETCODE _setAttr(string attrname, string newvalue)
static const Y_VOLTAGESENSE_enum VOLTAGESENSE_INVALID
double get_measuredCurrent(void)
static const double VOLTAGEATSTARTUP_INVALID
virtual int _invokeValueCallback(string value)