extend MQTT integration support
This commit is contained in:
@@ -209,6 +209,12 @@ class DataField : public AttributedItem {
|
||||
*/
|
||||
virtual bool isSet() const { return false; }
|
||||
|
||||
/**
|
||||
* Return whether this is a @a ValueListDataField.
|
||||
* @return true if this is a @a DataFieldSet.
|
||||
*/
|
||||
virtual bool isList() const { return false; }
|
||||
|
||||
/**
|
||||
* Factory method for creating new instances.
|
||||
* @param isWriteMessage whether the field is part of a write message (default false).
|
||||
@@ -534,6 +540,9 @@ class ValueListDataField : public SingleDataField {
|
||||
// @copydoc
|
||||
const ValueListDataField* clone() const override;
|
||||
|
||||
// @copydoc
|
||||
bool isList() const override { return true; }
|
||||
|
||||
// @copydoc
|
||||
result_t derive(const string& name, PartType partType, int divisor,
|
||||
const map<unsigned int, string>& values, map<string, string>* attributes,
|
||||
|
||||
@@ -674,6 +674,16 @@ result_t NumberDataType::derive(int divisor, size_t bitCount, const NumberDataTy
|
||||
return RESULT_OK;
|
||||
}
|
||||
|
||||
result_t NumberDataType::getMinMax(bool getMax, const OutputFormat outputFormat, ostream* output) const {
|
||||
size_t length;
|
||||
if (m_bitCount<8) {
|
||||
length = 1;
|
||||
} else {
|
||||
length = m_bitCount/8;
|
||||
}
|
||||
return readFromRawValue(length, getMax ? m_maxValue : m_minValue, outputFormat, output);
|
||||
}
|
||||
|
||||
result_t NumberDataType::readRawValue(size_t offset, size_t length, const SymbolString& input,
|
||||
unsigned int* value) const {
|
||||
size_t start = 0, count = length;
|
||||
@@ -725,12 +735,17 @@ result_t NumberDataType::readRawValue(size_t offset, size_t length, const Symbol
|
||||
result_t NumberDataType::readSymbols(size_t offset, size_t length, const SymbolString& input,
|
||||
OutputFormat outputFormat, ostream* output) const {
|
||||
unsigned int value = 0;
|
||||
int signedValue;
|
||||
|
||||
result_t result = readRawValue(offset, length, input, &value);
|
||||
if (result != RESULT_OK) {
|
||||
return result;
|
||||
}
|
||||
return readFromRawValue(length, value, outputFormat, output);
|
||||
}
|
||||
|
||||
result_t NumberDataType::readFromRawValue(size_t length, unsigned int value,
|
||||
OutputFormat outputFormat, ostream* output) const {
|
||||
int signedValue;
|
||||
*output << setw(0) << dec; // initialize output
|
||||
|
||||
if (!hasFlag(REQ) && value == m_replacement) {
|
||||
|
||||
@@ -493,6 +493,15 @@ class NumberDataType : public DataType {
|
||||
*/
|
||||
unsigned int getMaxValue() const { return m_maxValue; }
|
||||
|
||||
/**
|
||||
* Get the minimum or maximum value.
|
||||
* @param getMax true for the maximum, false for the minimum.
|
||||
* @param outputFormat the @a OutputFormat options to use.
|
||||
* @param output the ostream to append the formatted value to.
|
||||
* @return @a RESULT_OK on success, or an error code.
|
||||
*/
|
||||
result_t getMinMax(bool getMax, const OutputFormat outputFormat, ostream* output) const;
|
||||
|
||||
/**
|
||||
* @return the divisor (negative for reciprocal).
|
||||
*/
|
||||
@@ -516,6 +525,16 @@ class NumberDataType : public DataType {
|
||||
result_t readSymbols(size_t offset, size_t length, const SymbolString& input,
|
||||
const OutputFormat outputFormat, ostream* output) const override;
|
||||
|
||||
/**
|
||||
* Internal method for interpreting a numeric raw value.
|
||||
* @param value the numeric raw value.
|
||||
* @param outputFormat the @a OutputFormat options to use.
|
||||
* @param output the ostream to append the formatted value to.
|
||||
* @return @a RESULT_OK on success, or an error code.
|
||||
*/
|
||||
result_t readFromRawValue(size_t length, unsigned int value,
|
||||
OutputFormat outputFormat, ostream* output) const;
|
||||
|
||||
/**
|
||||
* Internal method for writing the numeric raw value to a @a SymbolString.
|
||||
* @param value the numeric raw value to write.
|
||||
|
||||
Reference in New Issue
Block a user