Another ToString function
This commit is contained in:
@@ -57,6 +57,11 @@ bool SensorData::isEmpty() const
|
|||||||
return (!isAvailable() && type == 0 && id == 0 && subid == 0 && instance == 0 && rxIdx == 0 && moduleIdx == 0 && unit == 0 && ratio == 0 && prec == 0 && offset == 0 && autoOffset == 0 && filter == 0 && onlyPositive == 0 && logs == 0);
|
return (!isAvailable() && type == 0 && id == 0 && subid == 0 && instance == 0 && rxIdx == 0 && moduleIdx == 0 && unit == 0 && ratio == 0 && prec == 0 && offset == 0 && autoOffset == 0 && filter == 0 && onlyPositive == 0 && logs == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString SensorData::idToString() const
|
||||||
|
{
|
||||||
|
return idToString(id);
|
||||||
|
}
|
||||||
|
|
||||||
QString SensorData::typeToString() const
|
QString SensorData::typeToString() const
|
||||||
{
|
{
|
||||||
return typeToString(type);
|
return typeToString(type);
|
||||||
@@ -126,16 +131,16 @@ QString SensorData::paramsToString(const ModelData * model) const
|
|||||||
int mask = getMask();
|
int mask = getMask();
|
||||||
|
|
||||||
if (type == TELEM_TYPE_CALCULATED) {
|
if (type == TELEM_TYPE_CALCULATED) {
|
||||||
str.append(QString(FMT_LABEL_VALUE).arg(tr("Formula")).arg(formulaToString(formula)));
|
str.append(QString(FMT_LABEL_VALUE).arg(tr("Formula")).arg(formulaToString()));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
str.append(QString(FMT_LABEL_VALUE).arg(tr("Id")).arg(QString::number(id, 16).toUpper()));
|
str.append(QString(FMT_LABEL_VALUE).arg(tr("Id")).arg(idToString()));
|
||||||
str.append(QString(FMT_LABEL_VALUE).arg(tr("Instance")).arg(instance));
|
str.append(QString(FMT_LABEL_VALUE).arg(tr("Instance")).arg(instance));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mask & SENSOR_HAS_CELLS) {
|
if (mask & SENSOR_HAS_CELLS) {
|
||||||
str.append(QString(FMT_LABEL_VALUE).arg(tr("Sensor")).arg(sourceToString(model, source)));
|
str.append(QString(FMT_LABEL_VALUE).arg(tr("Sensor")).arg(sourceToString(model, source)));
|
||||||
str.append(QString(FMT_VALUE).arg(cellIndexToString(index)));
|
str.append(QString(FMT_VALUE).arg(cellIndexToString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mask & SENSOR_HAS_SOURCES_12) {
|
if (mask & SENSOR_HAS_SOURCES_12) {
|
||||||
@@ -156,10 +161,10 @@ QString SensorData::paramsToString(const ModelData * model) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mask & SENSOR_ISCONFIGURABLE)
|
if (mask & SENSOR_ISCONFIGURABLE)
|
||||||
str.append(QString(FMT_LABEL_VALUE).arg(tr("Unit")).arg(unitToString(unit)));
|
str.append(QString(FMT_LABEL_VALUE).arg(tr("Unit")).arg(unitToString()));
|
||||||
|
|
||||||
if (mask & SENSOR_HAS_PRECISION)
|
if (mask & SENSOR_HAS_PRECISION)
|
||||||
str.append(QString(FMT_LABEL_VALUE).arg(tr("Precision")).arg(precToString(prec)));
|
str.append(QString(FMT_LABEL_VALUE).arg(tr("Precision")).arg(precToString()));
|
||||||
|
|
||||||
if (mask & SENSOR_HAS_RATIO) {
|
if (mask & SENSOR_HAS_RATIO) {
|
||||||
if (unit != UNIT_RPMS) {
|
if (unit != UNIT_RPMS) {
|
||||||
@@ -170,7 +175,7 @@ QString SensorData::paramsToString(const ModelData * model) const
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
str.append(QString(FMT_LABEL_VALUE).arg(tr("Blades")).arg(ratio)); // TODO refactor to dedicated RPMS field
|
str.append(QString(FMT_LABEL_VALUE).arg(tr("Blades")).arg(ratio)); // TODO refactor to dedicated RPMS field
|
||||||
str.append(QString(FMT_LABEL_VALUE).arg(tr("Multi")).arg(offset)); // TODO refactor to dedicated RPMS field
|
str.append(QString(FMT_LABEL_VALUE).arg(tr("Multiplier")).arg(offset)); // TODO refactor to dedicated RPMS field
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,6 +257,12 @@ void SensorData::unitChanged()
|
|||||||
prec = 0;
|
prec = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// static
|
||||||
|
QString SensorData::idToString(const int value)
|
||||||
|
{
|
||||||
|
return QString::number(value, 16).toUpper();
|
||||||
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
QString SensorData::typeToString(const int value)
|
QString SensorData::typeToString(const int value)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -185,6 +185,7 @@ class SensorData {
|
|||||||
QString getOrigin(const ModelData* model) const;
|
QString getOrigin(const ModelData* model) const;
|
||||||
void clear() { memset(this, 0, sizeof(SensorData)); }
|
void clear() { memset(this, 0, sizeof(SensorData)); }
|
||||||
bool isEmpty() const;
|
bool isEmpty() const;
|
||||||
|
QString idToString() const;
|
||||||
QString typeToString() const;
|
QString typeToString() const;
|
||||||
QString formulaToString() const;
|
QString formulaToString() const;
|
||||||
QString cellIndexToString() const;
|
QString cellIndexToString() const;
|
||||||
@@ -199,6 +200,7 @@ class SensorData {
|
|||||||
|
|
||||||
static QString sourceToString(const ModelData * model, const int index, const bool sign = false);
|
static QString sourceToString(const ModelData * model, const int index, const bool sign = false);
|
||||||
static bool isSourceAvailable(const ModelData * model, const int index);
|
static bool isSourceAvailable(const ModelData * model, const int index);
|
||||||
|
static QString idToString(const int value);
|
||||||
static QString typeToString(const int value);
|
static QString typeToString(const int value);
|
||||||
static QString formulaToString(const int value);
|
static QString formulaToString(const int value);
|
||||||
static QString cellIndexToString(const int value);
|
static QString cellIndexToString(const int value);
|
||||||
|
|||||||
Reference in New Issue
Block a user