41 #define _CRT_SECURE_NO_DEPRECATE //do not use windows secure crt 49 #define __FILE_ID__ "weighscale" 53 ,_excitation(EXCITATION_INVALID)
54 ,_compTempAdaptRatio(COMPTEMPADAPTRATIO_INVALID)
55 ,_compTempAvg(COMPTEMPAVG_INVALID)
56 ,_compTempChg(COMPTEMPCHG_INVALID)
57 ,_compensation(COMPENSATION_INVALID)
58 ,_zeroTracking(ZEROTRACKING_INVALID)
59 ,_command(COMMAND_INVALID)
60 ,_valueCallbackWeighScale(NULL)
61 ,_timedReportCallbackWeighScale(NULL)
83 if(json_val->
has(
"excitation")) {
86 if(json_val->
has(
"compTempAdaptRatio")) {
89 if(json_val->
has(
"compTempAvg")) {
92 if(json_val->
has(
"compTempChg")) {
95 if(json_val->
has(
"compensation")) {
98 if(json_val->
has(
"zeroTracking")) {
101 if(json_val->
has(
"command")) {
127 }
catch (std::exception) {
157 }
catch (std::exception) {
181 char buf[32]; sprintf(buf,
"%d", newval); rest_val = string(buf);
182 res =
_setAttr(
"excitation", rest_val);
183 }
catch (std::exception) {
209 char buf[32]; sprintf(buf,
"%d", (
int)floor(newval * 65536.0 + 0.5)); rest_val = string(buf);
210 res =
_setAttr(
"compTempAdaptRatio", rest_val);
211 }
catch (std::exception) {
243 }
catch (std::exception) {
272 }
catch (std::exception) {
302 }
catch (std::exception) {
331 }
catch (std::exception) {
354 char buf[32]; sprintf(buf,
"%d", (
int)floor(newval * 65536.0 + 0.5)); rest_val = string(buf);
355 res =
_setAttr(
"zeroTracking", rest_val);
356 }
catch (std::exception) {
387 }
catch (std::exception) {
409 }
catch (std::exception) {
424 res =
_setAttr(
"command", rest_val);
425 }
catch (std::exception) {
473 }
catch (std::exception) {
495 if (callback != NULL) {
502 if (callback != NULL && this->
isOnline()) {
536 if (callback != NULL) {
592 double currComp = 0.0;
593 double idxTemp = 0.0;
594 siz = (int)tempValues.size();
599 if (!(siz == (
int)compValues.size())) {
615 currComp = -999999.0;
618 idxTemp = tempValues[idx];
619 if ((idxTemp > prev) && (idxTemp < curr)) {
621 currComp = compValues[idx];
642 vector<string> paramlist;
649 id = (id).substr( 10, (
int)(id).length() - 10);
653 siz = (((int)paramlist.size()) >> (1));
658 temp = atof((paramlist[2*idx]).c_str())/1000.0;
659 comp = atof((paramlist[2*idx+1]).c_str())/1000.0;
660 tempValues.push_back(temp);
661 compValues.push_back(comp);
839 vector<YFUN_DESCR> v_fundescr;
841 string serial, funcId, funcName, funcVal, errmsg;
844 v_fundescr.size() == 0 ||
virtual int _parseAttr(YJSONObject *json_val)
YWeighScaleValueCallback _valueCallbackWeighScale
int set_unit(const string &newval)
double getDouble(const string &key)
double get_zeroTracking(void)
void(* YWeighScaleTimedReportCallback)(YWeighScale *func, YMeasure measure)
yCRITICAL_SECTION _this_cs
virtual int set_offsetChgCompensationTable(vector< double > tempValues, vector< double > compValues)
static void _UpdateTimedReportCallbackList(YFunction *func, bool add)
virtual int _invokeTimedReportCallback(YMeasure value)
static const double COMPTEMPADAPTRATIO_INVALID
YWeighScaleTimedReportCallback _timedReportCallbackWeighScale
YRETCODE _load_unsafe(int msValidity)
YWeighScale(const string &func)
static const string COMMAND_INVALID
virtual int loadOffsetChgCompensationTable(vector< double > &tempValues, vector< double > &compValues)
YWeighScale * nextWeighScale(void)
int set_command(const string &newval)
double get_compTempChg(void)
static const double ZEROTRACKING_INVALID
static int DefaultCacheValidity
string getString(const string &key)
int set_compTempAdaptRatio(double newval)
void _throw(YRETCODE errType, string errMsg)
void yLeaveCriticalSection(yCRITICAL_SECTION *cs)
static const Y_EXCITATION_enum EXCITATION_INVALID
virtual int registerValueCallback(YWeighScaleValueCallback callback)
string _download(const string &url)
static YRETCODE getFunctionInfo(YFUN_DESCR fundesc, YDEV_DESCR &devdescr, string &serial, string &funcId, string &funcName, string &funcVal, string &errmsg)
static const double COMPTEMPCHG_INVALID
virtual int loadCompensationTable(int tableIndex, vector< double > &tempValues, vector< double > &compValues)
virtual int loadOffsetAvgCompensationTable(vector< double > &tempValues, vector< double > &compValues)
#define YAPI_INVALID_STRING
string get_functionId(void)
int set_excitation(Y_EXCITATION_enum newval)
static YWeighScale * FindWeighScale(string func)
double get_compensation(void)
static YWeighScale * FirstWeighScale(void)
int getInt(const string &key)
static u64 GetTickCount(void)
virtual int loadSpanAvgCompensationTable(vector< double > &tempValues, vector< double > &compValues)
static void _AddToCache(const string &classname, const string &func, YFunction *obj)
#define YAPI_INVALID_DOUBLE
virtual int _invokeTimedReportCallback(YMeasure value)
virtual int set_spanAvgCompensationTable(vector< double > tempValues, vector< double > compValues)
virtual int _invokeValueCallback(string value)
int set_zeroTracking(double newval)
static YFunction * _FindFromCache(const string &classname, const string &func)
vector< string > _json_get_array(const string &json)
static string ysprintf(const char *fmt,...)
virtual int loadSpanChgCompensationTable(vector< double > &tempValues, vector< double > &compValues)
void yEnterCriticalSection(yCRITICAL_SECTION *cs)
static yCRITICAL_SECTION _global_cs
static const double COMPENSATION_INVALID
double get_compTempAvg(void)
virtual int set_offsetAvgCompensationTable(vector< double > tempValues, vector< double > compValues)
double _compTempAdaptRatio
virtual int _parseAttr(YJSONObject *json_val)
void(* YWeighScaleValueCallback)(YWeighScale *func, const string &functionValue)
static int getFunctionsByClass(const string &class_str, YFUN_DESCR prevfundesc, vector< YFUN_DESCR > &buffer, int maxsize, string &errmsg)
virtual int setCompensationTable(int tableIndex, vector< double > tempValues, vector< double > compValues)
virtual int set_spanChgCompensationTable(vector< double > tempValues, vector< double > compValues)
virtual int registerTimedReportCallback(YWeighScaleTimedReportCallback callback)
virtual int _invokeValueCallback(string value)
static const double COMPTEMPAVG_INVALID
static bool _apiInitialized
YRETCODE _nextFunction(string &hwId)
Y_EXCITATION_enum _excitation
static void _UpdateValueCallbackList(YFunction *func, bool add)
bool has(const string &key)
YRETCODE _setAttr(string attrname, string newvalue)
virtual int setupSpan(double currWeight, double maxWeight)
Y_EXCITATION_enum get_excitation(void)
double get_compTempAdaptRatio(void)