void CtrlInfo::formatDouble(double value, stdString &result) const { if (getType() != Numeric) { result = "<enumerated>"; return; } char buf[200]; if (cvtDoubleToString(value, buf, getPrecision()) >= 200) result = "<too long>"; else result = buf; }
void Exporter::printValue(FILE *f, const epicsTime &time, const ValueI *v) { // skip values which are Archiver specials size_t ai; stdString txt; char buf[100]; unsigned short precision; if (v->isInfo()) { for (ai=0; ai<v->getCount(); ++ai) fprintf(f, "\t%s", _undefined_value.c_str()); } else { const CtrlInfo *info = v->getCtrlInfo(); // Format according to precision. // Unfortuately that is usually configured wrongly // and then people complain about not seeing their data... // -> use prec. if > 0 if (v->getType() == DBR_TIME_STRING || (info && info->getType() == CtrlInfo::Enumerated)) { v->getValue(txt); fprintf(f, "\t%s", txt.c_str()); } else { if (info && info->getPrecision() > 0) precision = info->getPrecision(); else precision = 6; for (ai=0; ai<v->getCount(); ++ai) { cvtDoubleToString(v->getDouble(ai), buf, precision); fprintf(f, "\t%s", buf); } } } if (_show_status) { v->getStatus(txt); if (txt.empty()) fprintf(f, "\t "); else fprintf(f, "\t%s", txt.c_str()); } }
/* Convert Double to String */ static long cvt_d_st( epicsFloat64 *from, char *to, const dbAddr *paddr) { struct rset *prset = 0; long status = 0; long precision = 6; if(paddr) prset = dbGetRset(paddr); if (prset && prset->get_precision) status = (*prset->get_precision)(paddr, &precision); cvtDoubleToString(*from, to, (unsigned short)precision); return(status); }