41 #define _CRT_SECURE_NO_DEPRECATE //do not use windows secure crt 49 #define __FILE_ID__ "temperature" 53 ,_sensorType(SENSORTYPE_INVALID)
54 ,_signalValue(SIGNALVALUE_INVALID)
55 ,_signalUnit(SIGNALUNIT_INVALID)
56 ,_command(COMMAND_INVALID)
57 ,_valueCallbackTemperature(NULL)
58 ,_timedReportCallbackTemperature(NULL)
77 if(json_val->
has(
"sensorType")) {
80 if(json_val->
has(
"signalValue")) {
83 if(json_val->
has(
"signalUnit")) {
86 if(json_val->
has(
"command")) {
118 }
catch (std::exception) {
151 }
catch (std::exception) {
182 char buf[32]; sprintf(buf,
"%d", newval); rest_val = string(buf);
183 res =
_setAttr(
"sensorType", rest_val);
184 }
catch (std::exception) {
214 }
catch (std::exception) {
243 }
catch (std::exception) {
265 }
catch (std::exception) {
280 res =
_setAttr(
"command", rest_val);
281 }
catch (std::exception) {
329 }
catch (std::exception) {
351 if (callback != NULL) {
358 if (callback != NULL && this->
isOnline()) {
392 if (callback != NULL) {
429 vector<double> tempValues;
430 vector<double> resValues;
433 res100 = res25 * exp(beta*(1.0/t1 - 1.0/t0));
436 tempValues.push_back(25.0);
437 resValues.push_back(res25);
438 tempValues.push_back(100.0);
439 resValues.push_back(res100);
467 double currTemp = 0.0;
469 siz = (int)tempValues.size();
474 if (!(siz == (
int)resValues.size())) {
490 currTemp = -999999.0;
493 idxres = resValues[idx];
494 if ((idxres > prev) && (idxres < curr)) {
496 currTemp = tempValues[idx];
533 vector<string> paramlist;
534 vector<double> templist;
541 double currRes = 0.0;
546 id = (id).substr( 11, (
int)(id).length() - 11);
550 siz = (((int)paramlist.size()) >> (1));
554 temp = atof((paramlist[2*idx+1]).c_str())/1000.0;
555 templist.push_back(temp);
569 temp = templist[idx];
570 if ((temp > prev) && (temp < curr)) {
572 currRes = atof((paramlist[2*idx]).c_str())/1000.0;
578 tempValues.push_back(curr);
579 resValues.push_back(currRes);
598 vector<YFUN_DESCR> v_fundescr;
600 string serial, funcId, funcName, funcVal, errmsg;
603 v_fundescr.size() == 0 ||
double getDouble(const string &key)
yCRITICAL_SECTION _this_cs
static void _UpdateTimedReportCallbackList(YFunction *func, bool add)
YRETCODE _load_unsafe(int msValidity)
virtual int _invokeTimedReportCallback(YMeasure value)
virtual int set_thermistorResponseTable(vector< double > tempValues, vector< double > resValues)
virtual int registerTimedReportCallback(YTemperatureTimedReportCallback callback)
string get_signalUnit(void)
static int DefaultCacheValidity
string getString(const string &key)
void _throw(YRETCODE errType, string errMsg)
int set_sensorType(Y_SENSORTYPE_enum newval)
void yLeaveCriticalSection(yCRITICAL_SECTION *cs)
virtual int loadThermistorResponseTable(vector< double > &tempValues, vector< double > &resValues)
string _download(const string &url)
static YRETCODE getFunctionInfo(YFUN_DESCR fundesc, YDEV_DESCR &devdescr, string &serial, string &funcId, string &funcName, string &funcVal, string &errmsg)
virtual int _parseAttr(YJSONObject *json_val)
YTemperature(const string &func)
YTemperatureTimedReportCallback _timedReportCallbackTemperature
int set_command(const string &newval)
#define YAPI_INVALID_STRING
string get_functionId(void)
int getInt(const string &key)
YTemperatureValueCallback _valueCallbackTemperature
static u64 GetTickCount(void)
static void _AddToCache(const string &classname, const string &func, YFunction *obj)
#define YAPI_INVALID_DOUBLE
virtual int _invokeTimedReportCallback(YMeasure value)
YTemperature * nextTemperature(void)
double get_signalValue(void)
virtual int _invokeValueCallback(string value)
static const double SIGNALVALUE_INVALID
static YTemperature * FindTemperature(string func)
static YFunction * _FindFromCache(const string &classname, const string &func)
void(* YTemperatureValueCallback)(YTemperature *func, const string &functionValue)
vector< string > _json_get_array(const string &json)
Y_SENSORTYPE_enum _sensorType
static string ysprintf(const char *fmt,...)
int set_unit(const string &newval)
virtual int _invokeValueCallback(string value)
void yEnterCriticalSection(yCRITICAL_SECTION *cs)
static yCRITICAL_SECTION _global_cs
virtual int _parseAttr(YJSONObject *json_val)
static int getFunctionsByClass(const string &class_str, YFUN_DESCR prevfundesc, vector< YFUN_DESCR > &buffer, int maxsize, string &errmsg)
virtual int set_ntcParameters(double res25, double beta)
virtual int registerValueCallback(YTemperatureValueCallback callback)
Y_SENSORTYPE_enum get_sensorType(void)
static const string SIGNALUNIT_INVALID
static YTemperature * FirstTemperature(void)
static bool _apiInitialized
YRETCODE _nextFunction(string &hwId)
static void _UpdateValueCallbackList(YFunction *func, bool add)
static const Y_SENSORTYPE_enum SENSORTYPE_INVALID
bool has(const string &key)
void(* YTemperatureTimedReportCallback)(YTemperature *func, YMeasure measure)
YRETCODE _setAttr(string attrname, string newvalue)
static const string COMMAND_INVALID