add types to json get with definition
This commit is contained in:
+4
-1
@@ -7,16 +7,19 @@
|
|||||||
* fix some compiler warnings
|
* fix some compiler warnings
|
||||||
* fix non-unique message keys in HTTP JSON output with "full" query parameter
|
* fix non-unique message keys in HTTP JSON output with "full" query parameter
|
||||||
* fix for message after debian install
|
* fix for message after debian install
|
||||||
|
* fix for replacing already existing message definitions
|
||||||
|
* fix missing length in CSV dump for some data types
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
* added DTM and BDZ data types
|
* added DTM and BDZ data types
|
||||||
* added "-n" argument to "hex" and "direct" commands for automatically determining message length from input
|
* added "-n" argument to "hex" and "direct" commands for automatically determining message length from input
|
||||||
* added level/pollprio/condition to HTTP JSON output
|
* added level/pollprio/condition/field flags and field result type as well as list of types to HTTP JSON output
|
||||||
* added message dump from commandline in JSON format
|
* added message dump from commandline in JSON format
|
||||||
* added support for newer MQTT broker versions
|
* added support for newer MQTT broker versions
|
||||||
* added some PIC calibration data to "ebuspicloader" verbose output
|
* added some PIC calibration data to "ebuspicloader" verbose output
|
||||||
* added support for upcoming adapter 3 firmware enhancements
|
* added support for upcoming adapter 3 firmware enhancements
|
||||||
* added config override path
|
* added config override path
|
||||||
|
* added support for adding message definition via HTTP port
|
||||||
|
|
||||||
## Breaking Changes
|
## Breaking Changes
|
||||||
* remove support for Debian 8 Jessie in docker
|
* remove support for Debian 8 Jessie in docker
|
||||||
|
|||||||
@@ -2199,8 +2199,13 @@ result_t MainLoop::executeGet(const vector<string>& args, bool* connected, ostri
|
|||||||
*ostream << ",\n \"reconnects\": " << m_reconnectCount
|
*ostream << ",\n \"reconnects\": " << m_reconnectCount
|
||||||
<< ",\n \"masters\": " << m_busHandler->getMasterCount()
|
<< ",\n \"masters\": " << m_busHandler->getMasterCount()
|
||||||
<< ",\n \"messages\": " << m_messages->size()
|
<< ",\n \"messages\": " << m_messages->size()
|
||||||
<< ",\n \"lastup\": " << static_cast<unsigned>(maxLastUp)
|
<< ",\n \"lastup\": " << static_cast<unsigned>(maxLastUp);
|
||||||
<< "\n }"
|
if (withDefinition) {
|
||||||
|
*ostream << ",\n \"types\": [";
|
||||||
|
DataTypeList::getInstance()->dump(verbosity, true, ostream);
|
||||||
|
*ostream << "\n ]";
|
||||||
|
}
|
||||||
|
*ostream << "\n }"
|
||||||
<< "\n}";
|
<< "\n}";
|
||||||
type = 6;
|
type = 6;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1116,6 +1116,31 @@ DataTypeList* DataTypeList::getInstance() {
|
|||||||
return &s_instance;
|
return &s_instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DataTypeList::dump(OutputFormat outputFormat, bool appendDivisor, ostream* output) const {
|
||||||
|
bool json = outputFormat & OF_JSON;
|
||||||
|
string sep = "\n";
|
||||||
|
for (int withLength=0; withLength<2; withLength++) {
|
||||||
|
const map<string, const DataType*>* types = withLength==0 ? &m_typesById : &m_typesByIdLength;
|
||||||
|
for (const auto &it: *types) {
|
||||||
|
const DataType *dataType = it.second;
|
||||||
|
if (json) {
|
||||||
|
*output << sep << " {";
|
||||||
|
}
|
||||||
|
if ((dataType->getBitCount() % 8) != 0) {
|
||||||
|
dataType->dump(outputFormat, dataType->getBitCount(), appendDivisor, output);
|
||||||
|
} else {
|
||||||
|
dataType->dump(outputFormat, dataType->getBitCount() / 8, appendDivisor, output);
|
||||||
|
}
|
||||||
|
if (json) {
|
||||||
|
*output << "}";
|
||||||
|
sep = ",\n";
|
||||||
|
} else {
|
||||||
|
*output << "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void DataTypeList::clear() {
|
void DataTypeList::clear() {
|
||||||
for (auto& it : m_cleanupTypes) {
|
for (auto& it : m_cleanupTypes) {
|
||||||
delete it;
|
delete it;
|
||||||
|
|||||||
@@ -575,6 +575,14 @@ class DataTypeList {
|
|||||||
*/
|
*/
|
||||||
static DataTypeList* getInstance();
|
static DataTypeList* getInstance();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dump the type list optionally including the divisor to the output.
|
||||||
|
* @param outputFormat the @a OutputFormat options.
|
||||||
|
* @param appendDivisor whether to append the divisor (if available).
|
||||||
|
* @param output the @a ostream to dump to.
|
||||||
|
*/
|
||||||
|
void dump(OutputFormat outputFormat, bool appendDivisor, ostream* output) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes all @a DataType instances.
|
* Removes all @a DataType instances.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user