Fix LogView consistency and LtsUtilsGuiDds link after the merge

- LogView: take the complete XmlPatterns (d327c66c4) file set - the
  auto-merged mix (XmlPatterns .cpp + validation .hpp) left duplicated
  m_logger members and constructor signature mismatches, because the
  two lineages reworked the module differently.
- LogView CMakeLists: the cleanup version (separate LogViewLogger
  static library, required by tabPluginTetraJson and present in the
  Release 2 target list).
- LtsUtilsGuiDds: link ddscore (BUILD_RTI) for the Core::FunctionReply
  symbols, as in story/release-2-cleanup.

Full-scope ninja all is green; ctest 20/22 (the two failures,
GrantleeParserSmoke and utils_test, are out of the driver's 46-target
scope and 'Not Run' in the official baseline).
This commit is contained in:
berrux-dev committed 2026-11-16 20:24:04 +01:00
1 parent edd5e3ba81
commit 473462cbdb
42 files changed
+1631 -2103

No files matched your search

@@ -45,6 +45,9 @@ if(QT6_GUI_AVAILABLE)
Qt6::Svg Qt6::Svg
) )
endif() endif()
IF(BUILD_RTI)
TARGET_LINK_LIBRARIES(LtsUtilsGuiDds PUBLIC ddscore)
ENDIF(BUILD_RTI)
NGL_TARGET_COMPILE_DEFINITIONS(LtsUtilsGuiDds NGL_TARGET_COMPILE_DEFINITIONS(LtsUtilsGuiDds
PUBLIC PUBLIC
REQUEST_HELPER_WITH_GUI REQUEST_HELPER_WITH_GUI
@@ -77,3 +80,6 @@ NGL_TARGET_LINK_LIBRARIES(LtsUtilsDds
PUBLIC PUBLIC
Qt6::Core Qt6::Core
) )
IF(BUILD_RTI)
TARGET_LINK_LIBRARIES(LtsUtilsDds PUBLIC ddscore)
ENDIF(BUILD_RTI)
@@ -17,7 +17,8 @@
#include <TrainingAreaBase/training_area_telegrams.h> #include <TrainingAreaBase/training_area_telegrams.h>
static QSet<int> s_eqIds; static QSet<int> s_eqIds;
template <typename T> bool validEqId(const T &tele) template <typename T>
bool validEqId(const T &tele)
{ {
if (!s_eqIds.isEmpty() && !s_eqIds.contains(tele.header.equipmentNumber)) if (!s_eqIds.isEmpty() && !s_eqIds.contains(tele.header.equipmentNumber))
return false; return false;
@@ -38,28 +39,31 @@ int main(int argc, char **argv)
QCoreApplication app(argc, argv); QCoreApplication app(argc, argv);
// Check alle 30 Sekunden
NGL::NGLLoggerBootstrap::createNGLRootLogger("log4cxx_tetra.props", false); NGL::NGLLoggerBootstrap::createNGLRootLogger("log4cxx_tetra.props", false);
NGL::INGLLogger &logger(NGL::NGLLoggerBootstrap::getNGLRootLogger()); NGL::INGLLogger &logger(NGL::NGLLoggerBootstrap::getNGLRootLogger());
if (app.arguments().count() < 3) if (app.arguments().count() < 3)
{ {
ERROR_LOG(logger) << "Usage: " << app.arguments().at(0) << " <logfile> <telId> <equipId>"; ERROR_LOG(logger) << "Usage: " << app.arguments().at(0)
<< " <logfile> <telId> <equipId>";
return 1; return 1;
} }
QFile telegramFile(app.arguments().at(1)); QFile telegramFile(app.arguments().at(1));
if (!telegramFile.open(QIODevice::ReadOnly)) if (!telegramFile.open(QIODevice::ReadOnly))
{ {
ERROR_LOG(logger) << "Error opening " << telegramFile.fileName() << " for reading: " << telegramFile.errorString(); ERROR_LOG(logger) << "Error opening " << telegramFile.fileName()
<< " for reading: " << telegramFile.errorString();
return 2; return 2;
} }
bool bOk; bool bOk;
int telIdToSearch = app.arguments().at(2).toUShort(&bOk); int telIdToSearch = app.arguments().at(2).toUShort(&bOk);
if (!bOk) if (!bOk)
{ {
ERROR_LOG(logger) << "Error reading telId - not a (valid) number: " << app.arguments().at(2); ERROR_LOG(logger) << "Error reading telId - not a (valid) number: "
<< app.arguments().at(2);
return 3; return 3;
} }
s_eqIds.clear(); s_eqIds.clear();
@@ -68,29 +72,30 @@ int main(int argc, char **argv)
int eqId = app.arguments().at(i).toUShort(&bOk); int eqId = app.arguments().at(i).toUShort(&bOk);
if (!bOk) if (!bOk)
{ {
ERROR_LOG(logger) << "Error reading equipId - not a (valid) number: " << app.arguments().at(i); ERROR_LOG(logger) << "Error reading equipId - not a (valid) number: "
<< app.arguments().at(i);
return 4; return 4;
} }
s_eqIds += eqId; s_eqIds += eqId;
} }
//fprintf(stdout, "Counter;EqID;TelID;TelTime;LogTime;Diff\n");
while (true) while (true)
{ {
// read the header of telegram-entry
N_CoPrtCnv::CoPrtCnvLogHeader lh; N_CoPrtCnv::CoPrtCnvLogHeader lh;
if (sizeof(lh) == telegramFile.read((char *)&lh, sizeof(lh))) if (sizeof(lh) == telegramFile.read((char *)&lh, sizeof(lh)))
{ {
if (lh.m_Version == 3) if (lh.m_Version == 3)
{ {
// read the telegram itself
qint64 telegramLength = lh.m_Length - sizeof(lh); qint64 telegramLength = lh.m_Length - sizeof(lh);
QByteArray telegramData(telegramLength, Qt::Uninitialized); QByteArray telegramData(telegramLength, Qt::Uninitialized);
if (telegramLength == telegramFile.read(telegramData.data(), telegramLength)) if (telegramLength == telegramFile.read(telegramData.data(), telegramLength))
{ {
// add the telegram to telegram-list
N_CoPrtCnv::CoPrtCnvLogHeader::E_CoPrtCnvProtocol dest = N_CoPrtCnv::CoPrtCnvLogHeader::E_CoPrtCnvProtocol dest = (N_CoPrtCnv::CoPrtCnvLogHeader::E_CoPrtCnvProtocol)
(N_CoPrtCnv::CoPrtCnvLogHeader::E_CoPrtCnvProtocol)(lh.m_Protocol & N_CoPrtCnv::CoPrtCnvLogHeader::e_DestProtocolMask); (lh.m_Protocol & N_CoPrtCnv::CoPrtCnvLogHeader::e_DestProtocolMask);
switch (dest) switch (dest)
{ {
@@ -113,13 +118,22 @@ int main(int argc, char **argv)
const CreateFunctionalArea tele(CreateFunctionalArea::fromJson(objData)); const CreateFunctionalArea tele(CreateFunctionalArea::fromJson(objData));
if (!validEqId(tele)) if (!validEqId(tele))
break; break;
fprintf(stdout, "%s, FUNKTIONSRAUM: '%s', %d, %d\n", timeStr, tele.name.c_str(), tele.aesDdsId, tele.header.equipmentNumber); fprintf(stdout, "%s, FUNKTIONSRAUM: '%s', %d, %d\n",
timeStr,
tele.name.c_str(),
tele.aesDdsId,
tele.header.equipmentNumber
);
break; break;
} }
case Constraints<DeactivateEffectSimulation>::id(): case Constraints<DeactivateEffectSimulation>::id():
{ {
const DeactivateEffectSimulation tele(DeactivateEffectSimulation::fromJson(objData)); const DeactivateEffectSimulation tele(DeactivateEffectSimulation::fromJson(objData));
fprintf(stdout, "%s, DEAKTIVIERUNG_WIRKFELD: typ: %d - kennung: %d\n", timeStr, int(tele.aesType), tele.aesDdsId); fprintf(stdout, "%s, DEAKTIVIERUNG_WIRKFELD: typ: %d - kennung: %d\n",
timeStr,
int(tele.aesType),
tele.aesDdsId
);
break; break;
} }
case Constraints<PositionReport>::id(): case Constraints<PositionReport>::id():
@@ -129,7 +143,11 @@ int main(int argc, char **argv)
break; break;
if (tele.opsPosition.opsId == 0) if (tele.opsPosition.opsId == 0)
break; break;
fprintf(stdout, "%s, IPS_POSITIONSDATEN: %d - OPS: %d\n", timeStr, tele.header.equipmentNumber, tele.opsPosition.opsId); fprintf(stdout, "%s, IPS_POSITIONSDATEN: %d - OPS: %d\n",
timeStr,
tele.header.equipmentNumber,
tele.opsPosition.opsId
);
break; break;
} }
case BESTAETIGUNG: case BESTAETIGUNG:
@@ -138,6 +156,7 @@ int main(int argc, char **argv)
default: default:
fprintf(stderr, "Printing telegram with id %d not implemented\n", telId); fprintf(stderr, "Printing telegram with id %d not implemented\n", telId);
break; break;
} }
break; break;
} }
@@ -154,7 +173,9 @@ int main(int argc, char **argv)
{ {
if (bci > radioTelegram.getBroadcastIndex() && bci != 0xFFFF) if (bci > radioTelegram.getBroadcastIndex() && bci != 0xFFFF)
{ {
fprintf(stdout, "BCI reset in %s at %s!\n", qPrintable(telegramFile.fileName()), timeStr); fprintf(stdout, "BCI reset in %s at %s!\n",
qPrintable(telegramFile.fileName()),
timeStr);
} }
fprintf(stdout, "BCI: %d\n", radioTelegram.getBroadcastIndex()); fprintf(stdout, "BCI: %d\n", radioTelegram.getBroadcastIndex());
bci = radioTelegram.getBroadcastIndex(); bci = radioTelegram.getBroadcastIndex();
@@ -1,17 +1,17 @@
// **************************************************************************
//
// (C) Copyright 2009 Swiss SIMTEC AG
//
// **************************************************************************
//
// $HeadURL$
// $LastChangedBy$
// $LastChangedDate$
// $LastChangedRevision$
//
// **************************************************************************
// manual class headers
#include "IntegerCalculator.hpp" #include "IntegerCalculator.hpp"
#include <sstream> #include <sstream>
@@ -19,43 +19,43 @@
namespace N_SST namespace N_SST
{ {
IntegerCalculator::IntegerCalculator() IntegerCalculator::IntegerCalculator()
: m_OperationList({{"*", 6}, {"/", 6}, {"%", 6}, {"+", 5}, {"-", 5}, {"<<", 4}, {">>", 4}}) : m_OperationList({{"*", 6},{"/", 6},{"%", 6},{"+", 5},{"-", 5},{"<<", 4},{">>", 4}})
, m_AdditionalErrorText() , m_AdditionalErrorText()
, m_ParanthesisCount(0) , m_ParanthesisCount(0)
, m_Error(IntegerCalculator::e_Ok) , m_Error(IntegerCalculator::e_Ok)
{ {
} }
// ---------------------------------------------------------------
// Converts the expressen in a_calcText into a signed value.
// Returns whether an error happend in the variable a_error.
// If an error happend, the variable a_addErrorText can
// contain more informaition about the error (see E_Error for
// more information about errors).
// ---------------------------------------------------------------
int64_t IntegerCalculator::calc(const std::string &a_calcText, E_Error &a_error, std::string *a_addErrorText) int64_t IntegerCalculator::calc(const std::string& a_calcText, E_Error& a_error, std::string* a_addErrorText)
{ {
std::string calcText = a_calcText; std::string calcText = a_calcText;
// separate operations from variables
for (auto iter = m_OperationList.begin(); iter != m_OperationList.end(); ++iter)
replace(calcText, iter->first, " " + iter->first + " ");
// separate paranthesis from variables for (auto iter = m_OperationList.begin(); iter != m_OperationList.end(); ++iter)
replace(calcText, iter->first, " "+iter->first+" ");
replace(calcText, "(", " ( "); replace(calcText, "(", " ( ");
replace(calcText, ")", " ) "); replace(calcText, ")", " ) ");
// now calculate the expression
m_ParanthesisCount = 0; m_ParanthesisCount = 0;
m_Error = e_Ok; m_Error = e_Ok;
m_AdditionalErrorText = ""; m_AdditionalErrorText = "";
size_t pos = 0; size_t pos = 0;
bool dummy; bool dummy;
int64_t value = calc(calcText, pos, dummy, "", 0, "+"); // todo: use member-variable m_CalcText int64_t value = calc(calcText, pos, dummy, "", 0, "+");
//M_INFO("calc: " << calcText << " value: " << value);
// check the paranthesis
if (m_Error == e_Ok) if (m_Error == e_Ok)
{ {
if (m_ParanthesisCount > 0) if (m_ParanthesisCount > 0)
@@ -72,7 +72,7 @@ namespace N_SST
} }
} }
// actions if a failure happens
a_error = m_Error; a_error = m_Error;
if (a_error != e_Ok) if (a_error != e_Ok)
{ {
@@ -83,41 +83,38 @@ namespace N_SST
} }
} }
return value; return value;
} }
// ---------------------------------------------------------------
// Adds or changes a case-sensitive variable to the calculator.
// ---------------------------------------------------------------
void IntegerCalculator::addVariable(const std::string &a_name, const int64_t a_value) void IntegerCalculator::addVariable(const std::string& a_name, const int64_t a_value)
{ {
std::map<std::string, int64_t>::iterator iter = m_VariableList.find(a_name); std::map<std::string, int64_t>::iterator iter = m_VariableList.find(a_name);
if (iter != m_VariableList.end()) if (iter != m_VariableList.end())
removeVariable(a_name); removeVariable(a_name);
m_VariableList.insert(std::make_pair(a_name, a_value)); m_VariableList.insert(std::make_pair(a_name, a_value));
} }
// ---------------------------------------------------------------
// Removes a case-sensitive variable from the calculator.
// ---------------------------------------------------------------
void IntegerCalculator::removeVariable(const std::string &a_name) void IntegerCalculator::removeVariable(const std::string& a_name)
{ {
std::map<std::string, int64_t>::iterator iter = m_VariableList.find(a_name); std::map<std::string, int64_t>::iterator iter = m_VariableList.find(a_name);
if (iter != m_VariableList.end()) if (iter != m_VariableList.end())
m_VariableList.erase(iter); m_VariableList.erase(iter);
} }
// ---------------------------------------------------------------
// Calculates the expression (recursive)
// ---------------------------------------------------------------
int64_t IntegerCalculator::calc(const std::string &a_calcText, int64_t IntegerCalculator::calc(const std::string& a_calcText, size_t& a_pos, bool& a_IsEndParanthesis,
size_t &a_pos, const std::string& a_prevOp, const int64_t a_prevValue,
bool &a_IsEndParanthesis, const std::string& a_initOp)
const std::string &a_prevOp, {
const int64_t a_prevValue,
const std::string &a_initOp)
{
std::string operation = a_initOp; std::string operation = a_initOp;
int64_t value1 = a_prevValue; int64_t value1 = a_prevValue;
bool isNegative = false; bool isNegative = false;
@@ -137,12 +134,12 @@ namespace N_SST
int64_t value2 = calcSign(calc(calcText, ++a_pos, dummy), isNegative); int64_t value2 = calcSign(calc(calcText, ++a_pos, dummy), isNegative);
value1 = doOperation(value1, operation, value2); value1 = doOperation(value1, operation, value2);
// get next operation to check priority of operation
size_t tmpPos = a_pos; // do not change the position, we only pre-read size_t tmpPos = a_pos;
std::string nextOp = getToken(a_calcText, tmpPos); std::string nextOp = getToken(a_calcText, tmpPos);
if (isOperation(nextOp) && isOperation(a_prevOp) && !isOperationPriorityHigher(nextOp, a_prevOp)) if (isOperation(nextOp) && isOperation(a_prevOp) && !isOperationPriorityHigher(nextOp, a_prevOp))
{ {
// end of higher priority operation
return value1; return value1;
} }
@@ -157,40 +154,38 @@ namespace N_SST
} }
else if (isDigit(calcText[a_pos])) else if (isDigit(calcText[a_pos]))
{ {
// value
// -----
int64_t value2 = calcSign(convertValue(calcText, a_pos), isNegative); int64_t value2 = calcSign(convertValue(calcText, a_pos), isNegative);
if (calcWithPriority(calcText, a_pos, value1, operation, value2, a_prevOp)) if (calcWithPriority(calcText, a_pos, value1, operation, value2, a_prevOp)) return value1;
return value1;
} }
else else
{ {
// operation or variable
// ---------------------
std::string oldOperation = operation; std::string oldOperation = operation;
operation = getToken(calcText, a_pos); operation = getToken(calcText, a_pos);
// is it a variable?
if (!isOperation(operation)) if (!isOperation(operation))
{ {
int64_t value2 = 0; int64_t value2 = 0;
if (getVariableValue(operation, value2)) if (getVariableValue(operation, value2))
{ {
value2 = calcSign(value2, isNegative); value2 = calcSign(value2, isNegative);
if (calcWithPriority(calcText, a_pos, value1, oldOperation, value2, a_prevOp)) if (calcWithPriority(calcText, a_pos, value1, oldOperation, value2, a_prevOp)) return value1;
return value1;
operation = ""; operation = "";
} }
else else
{ {
// error
m_Error = e_UnknownOperationOrVariable; m_Error = e_UnknownOperationOrVariable;
m_AdditionalErrorText = operation; m_AdditionalErrorText = operation;
} }
} }
else else
{ {
// do we have a sign?
if (oldOperation != "") if (oldOperation != "")
{ {
if (operation == "+") if (operation == "+")
@@ -213,67 +208,62 @@ namespace N_SST
} }
} }
return value1; return value1;
} }
// ---------------------------------------------------------------
// Calculates an operation with respecting the priority of
// operations. This will be done with recursion.
// ---------------------------------------------------------------
bool IntegerCalculator::calcWithPriority(const std::string &a_calcText, bool IntegerCalculator::calcWithPriority(const std::string& a_calcText, size_t& a_pos, int64_t& a_value1, std::string& a_operation, int64_t a_value2, const std::string& a_prevOp)
size_t &a_pos, {
int64_t &a_value1,
std::string &a_operation,
int64_t a_value2,
const std::string &a_prevOp)
{
bool isParaEnd = false; bool isParaEnd = false;
// get next operation to check priority of operation
size_t tmpPos = a_pos; // only pre-read size_t tmpPos = a_pos;
std::string nextOp = getToken(a_calcText, tmpPos); std::string nextOp = getToken(a_calcText, tmpPos);
if (isOperation(a_operation) && isOperation(nextOp) && isOperationPriorityHigher(nextOp, a_operation)) if (isOperation(a_operation) && isOperation(nextOp) && isOperationPriorityHigher(nextOp, a_operation))
{ {
// next operation has higher priority => calc the next operation first
a_value2 = calc(a_calcText, a_pos, isParaEnd, a_operation, a_value2); a_value2 = calc(a_calcText, a_pos, isParaEnd, a_operation, a_value2);
} }
a_value1 = doOperation(a_value1, a_operation, a_value2); a_value1 = doOperation(a_value1, a_operation, a_value2);
if (isParaEnd || (isOperation(nextOp) && isOperation(a_prevOp) && !isOperationPriorityHigher(nextOp, a_prevOp))) if (isParaEnd || (isOperation(nextOp) && isOperation(a_prevOp) && !isOperationPriorityHigher(nextOp, a_prevOp)))
{ {
// end of higher priority operation
return true; return true;
} }
a_operation = ""; a_operation = "";
return false; return false;
} }
// ---------------------------------------------------------------
// Returns the inverted a_value if a_isNegative is true.
// a_isNegative will be false after calling this function.
// If a_isNegative is true, the NOT inverted a_value will be
// returned.
// ---------------------------------------------------------------
int64_t IntegerCalculator::calcSign(const int64_t a_value, bool &a_isNegative) int64_t IntegerCalculator::calcSign(const int64_t a_value, bool& a_isNegative)
{ {
if (a_isNegative) if (a_isNegative)
{ {
a_isNegative = false; a_isNegative = false;
return -a_value; return -a_value;
} }
return a_value; return a_value;
} }
// ---------------------------------------------------------------
// Converts the value in form of text to a number. The Text
// can be decimal, hex (0x) or binary (0b).
// ---------------------------------------------------------------
int64_t IntegerCalculator::convertValue(const std::string &a_valueText, size_t &a_pos) int64_t IntegerCalculator::convertValue(const std::string &a_valueText, size_t& a_pos)
{ {
std::string valueText = a_valueText.substr(a_pos); std::string valueText = a_valueText.substr(a_pos);
int base = 10; int base = 10;
size_t startpos = 0; size_t startpos = 0;
// hex- and binary-stuff
bool isHex = (0 == valueText.find("0X")) || (0 == valueText.find("0x")); bool isHex = (0 == valueText.find("0X")) || (0 == valueText.find("0x"));
bool isBin = (0 == valueText.find("0B")) || (0 == valueText.find("0b")); bool isBin = (0 == valueText.find("0B")) || (0 == valueText.find("0b"));
if (isHex) if (isHex)
@@ -286,16 +276,16 @@ namespace N_SST
base = 2; base = 2;
startpos = 2; startpos = 2;
} }
// search end of value
size_t i; size_t i;
for (i = startpos; i < valueText.length(); i++) for (i=startpos; i<valueText.length(); i++)
{ {
if (!isDigit(valueText[i], isHex, isBin)) if (!isDigit(valueText[i], isHex, isBin))
{ {
break; break;
} }
} }
// check the next char, it must be a space
if (valueText.length() > i && valueText[i] != ' ') if (valueText.length() > i && valueText[i] != ' ')
{ {
m_Error = e_InvalidOperand; m_Error = e_InvalidOperand;
@@ -306,10 +296,10 @@ namespace N_SST
int64_t value = 0; int64_t value = 0;
std::stringstream stream; std::stringstream stream;
stream.str(valueText.substr(startpos, i - startpos)); stream.str(valueText.substr(startpos, i-startpos));
if (2 == base) if (2 == base)
{ {
// our stl is not able to read in binary-values, therefore we have to implement it ourself
const std::string binValueAsText = stream.str(); const std::string binValueAsText = stream.str();
for (const char c : binValueAsText) for (const char c : binValueAsText)
{ {
@@ -324,53 +314,50 @@ namespace N_SST
stream >> value; stream >> value;
} }
return value; return value;
} }
// ---------------------------------------------------------------
// Returns the next token (with space as separator). Heading
// spaces will be ignored.
// ---------------------------------------------------------------
std::string IntegerCalculator::getToken(const std::string &a_calcText, size_t &a_pos) std::string IntegerCalculator::getToken(const std::string &a_calcText, size_t& a_pos)
{ {
// skip spaces at begin
while (a_pos < a_calcText.length()) while (a_pos < a_calcText.length())
{ {
if (a_calcText[a_pos] == ' ') if (a_calcText[a_pos] == ' ') a_pos++;
a_pos++; else break;
else
break;
} }
// search until next space (or end)
size_t startPos = a_pos; size_t startPos = a_pos;
while (a_pos < a_calcText.length()) while (a_pos < a_calcText.length())
{ {
if (' ' == a_calcText[a_pos]) if (' ' == a_calcText[a_pos]) break;
break;
a_pos++; a_pos++;
} }
return a_calcText.substr(startPos, a_pos - startPos); return a_calcText.substr(startPos, a_pos-startPos);
} }
// ---------------------------------------------------------------
// returns true if a_operation is a known operation.
// ---------------------------------------------------------------
bool IntegerCalculator::isOperation(const std::string &a_operation) const bool IntegerCalculator::isOperation(const std::string& a_operation) const
{ {
std::map<std::string, int>::const_iterator iter = m_OperationList.find(a_operation); std::map<std::string, int>::const_iterator iter = m_OperationList.find(a_operation);
return (iter != m_OperationList.end()); return (iter != m_OperationList.end());
} }
// ---------------------------------------------------------------
// Calculates the opeation a_operations with a_value1 as first
// and a_value2 as second operand.
// ---------------------------------------------------------------
int64_t IntegerCalculator::doOperation(const int64_t a_value1, const std::string &a_operation, const int64_t a_value2) int64_t IntegerCalculator::doOperation(const int64_t a_value1, const std::string& a_operation, const int64_t a_value2)
{ {
// M_INFO("" << a_value1 << " " << a_operation << " " << a_value2);
if (("+" == a_operation) || a_operation.empty()) if (("+" == a_operation) || a_operation.empty())
{ {
return a_value1 + a_value2; return a_value1 + a_value2;
@@ -419,28 +406,28 @@ namespace N_SST
m_AdditionalErrorText = a_operation; m_AdditionalErrorText = a_operation;
} }
return 0; return 0;
} }
// ---------------------------------------------------------------
// returns true if priority of a_opeation1 is higher than
// priority of a_operation2.
// ---------------------------------------------------------------
bool IntegerCalculator::isOperationPriorityHigher(const std::string &a_operation1, const std::string &a_operation2) const bool IntegerCalculator::isOperationPriorityHigher(const std::string& a_operation1, const std::string& a_operation2) const
{ {
return (getPriority(a_operation1) > getPriority(a_operation2)); return (getPriority(a_operation1) > getPriority(a_operation2));
} }
// ---------------------------------------------------------------
// Returns true if the variable named a_variableName is known
// and a_value will be filled with its value. If the variable
// is not found false will be returned.
// Overload this virtual function if you want to implement
// your own variable-list.
// ---------------------------------------------------------------
bool IntegerCalculator::getVariableValue(const std::string &a_variableName, int64_t &a_value) const bool IntegerCalculator::getVariableValue(const std::string& a_variableName, int64_t& a_value) const
{ {
auto iter = m_VariableList.find(a_variableName); auto iter = m_VariableList.find(a_variableName);
if (iter != m_VariableList.end()) if (iter != m_VariableList.end())
{ {
@@ -448,53 +435,53 @@ namespace N_SST
return true; return true;
} }
// error
return false; return false;
} }
// ---------------------------------------------------------------
// Returns true if a_char is a digit. When a_isHex is true,
// also the charactes a-f will be accepted as digits. When
// a_isBin is true, only 0 and 1 will be treated as digit.
// ---------------------------------------------------------------
bool IntegerCalculator::isDigit(const char a_char, const bool a_isHex, const bool a_isBin) bool IntegerCalculator::isDigit(const char a_char, const bool a_isHex, const bool a_isBin)
{ {
if (a_isHex) if (a_isHex)
{ {
// for hex-values also A..F are 'digits'
return (a_char >= '0' && a_char <= '9') || (a_char >= 'A' && a_char <= 'F') || (a_char >= 'a' && a_char <= 'f'); return (a_char >= '0' && a_char <= '9') || (a_char >= 'A' && a_char <= 'F') || (a_char >= 'a' && a_char <= 'f');
} }
else if (a_isBin) else if (a_isBin)
{ {
// for binary-values only 0 and 1 are allowed
return (a_char >= '0' && a_char <= '1'); return (a_char >= '0' && a_char <= '1');
} }
// normal digits
return (a_char >= '0' && a_char <= '9'); return (a_char >= '0' && a_char <= '9');
} }
// ---------------------------------------------------------------
// Returns the priority of the operation. A higher value means
// more priority.
// ---------------------------------------------------------------
int16_t IntegerCalculator::getPriority(const std::string &a_operation) const int16_t IntegerCalculator::getPriority(const std::string& a_operation) const
{ {
std::map<std::string, int>::const_iterator iter = m_OperationList.find(a_operation); std::map<std::string, int>::const_iterator iter = m_OperationList.find(a_operation);
if (iter != m_OperationList.end()) if (iter != m_OperationList.end())
return iter->second; return iter->second;
return -1; return -1;
} }
// ---------------------------------------------------------------
// replaces in a_haystack all a_searchText with a_replaceText
// (not greedy).
// ---------------------------------------------------------------
void IntegerCalculator::replace(std::string &a_haystack, const std::string &a_searchText, const std::string &a_replaceText) void IntegerCalculator::replace(std::string& a_haystack, const std::string &a_searchText, const std::string &a_replaceText)
{ {
std::string::size_type searchSize = a_searchText.length(); std::string::size_type searchSize = a_searchText.length();
std::string::size_type replaceSize = a_replaceText.length(); std::string::size_type replaceSize = a_replaceText.length();
@@ -505,6 +492,6 @@ namespace N_SST
pos += replaceSize; pos += replaceSize;
pos = a_haystack.find(a_searchText, pos); pos = a_haystack.find(a_searchText, pos);
} }
} }
} // namespace N_SST }
@@ -1,15 +1,15 @@
// **************************************************************************
//
// (C) Copyright 2009 Swiss SIMTEC AG
//
// **************************************************************************
//
// $HeadURL$
// $LastChangedBy$
// $LastChangedDate$
// $LastChangedRevision$
//
// **************************************************************************
#pragma once #pragma once
@@ -18,65 +18,39 @@
namespace N_SST namespace N_SST
{ {
/**
* This class calculates algebraic texts with integer values and returns its
* result as a signed value. It handles the operations - +, -, *, /, %, <<, >>. It
* understands the paranthesis and priorities of operations, like * before -. It
* also computes with variables, which names are case-sensitive. The values can be
* decimal, hexadecimal (0x) or binary (0b). The variable-system implemented
* virtual, so you can implement your own variable system (see getVariableValue()).
*
*
* @author alois.wismer
* @version 1.0
* @created 12-Mai-2010 16:26:43
*/
class IntegerCalculator class IntegerCalculator
{ {
public: public:
/**
* Describes the error happend while calculation of an expression
*
* @author alois.wismer
* @version 1.0
* @created 17-Mai-2010 16:38:24
*/
enum E_Error enum E_Error
{ {
/**
* No error happend
*/
e_Ok, e_Ok,
/**
* The divisor is 0
*/
e_DivisionByZero, e_DivisionByZero,
/**
* The operation/variable is not known. a_addErrorText will contain the unknown
* operation/variable.
*/
e_UnknownOperationOrVariable, e_UnknownOperationOrVariable,
/**
* Between to operators no variable/operand exists. a_addErrorText contains the 2
* operations.
*/
e_NoOperandBetweenOperators, e_NoOperandBetweenOperators,
/**
* The operand contains invalid characters. a_addErrorText contains the invalid
* operand.
*/
e_InvalidOperand, e_InvalidOperand,
/**
* There are more ) than (
*/
e_MissingLeftParanthesis, e_MissingLeftParanthesis,
/**
* There are more ) than (
*/
e_MissingRightParanthesis, e_MissingRightParanthesis,
/**
* Something else went wrong
*/
e_UnknownError e_UnknownError
}; };
@@ -84,173 +58,86 @@ namespace N_SST
IntegerCalculator(); IntegerCalculator();
virtual ~IntegerCalculator() = default; virtual ~IntegerCalculator() = default;
/**
* Converts the expressen in a_calcText into a signed value. Returns whether an
* error happend in the variable a_error. If an error happend, the variable
* a_addErrorText can contain more informaition about the error (see E_Error for
* more information about errors).
*
* @param a_calcText
* @param a_error
* @param a_addErrorText
*/
int64_t calc(const std::string &a_calcText, E_Error &a_error, std::string *a_addErrorText = nullptr);
/**
* Adds or changes a case-sensitive variable to the calculator.
*
* @param a_name
* @param a_value
*/
void addVariable(const std::string &a_name, const int64_t a_value);
/** int64_t calc(const std::string& a_calcText, E_Error& a_error, std::string* a_addErrorText = nullptr);
* Removes a case-sensitive variable from the calculator.
*
* @param a_name
*/ void addVariable(const std::string& a_name, const int64_t a_value);
void removeVariable(const std::string &a_name);
void removeVariable(const std::string& a_name);
protected: protected:
/**
* Contains all supported operations
*/
const std::map<std::string, int> m_OperationList; const std::map<std::string, int> m_OperationList;
/**
* Contains all variables
*/
std::map<std::string, int64_t> m_VariableList; std::map<std::string, int64_t> m_VariableList;
/**
* The additional text for errors
*/
std::string m_AdditionalErrorText; std::string m_AdditionalErrorText;
/**
* The number of open paranthesis
*/
int32_t m_ParanthesisCount; int32_t m_ParanthesisCount;
E_Error m_Error; E_Error m_Error;
/**
* Calculates the expression (recursive)
*
* @param a_calcText
* @param a_pos
* @param a_IsEndParanthesis
* @param a_prevOp
* @param a_prevValue
* @param a_initOp
*/
int64_t calc(const std::string &a_calcText,
size_t &a_pos,
bool &a_IsEndParanthesis,
const std::string &a_prevOp = std::string(),
const int64_t a_prevValue = 0,
const std::string &a_initOp = std::string());
/**
* Calculates an operation with respecting the priority of operations. This will
* be done with recursion.
*
* @param a_calcText
* @param a_pos
* @param a_value1
* @param a_operation
* @param a_value2
* @param a_prevOp
*/
bool calcWithPriority(const std::string &a_calcText, size_t &a_pos, int64_t &a_value1, std::string &a_operation, int64_t a_value2, const std::string &a_prevOp);
/** int64_t calc(const std::string& a_calcText, size_t& a_pos, bool& a_IsEndParanthesis,
* Returns the inverted a_value if a_isNegative is true. a_isNegative will be const std::string& a_prevOp = std::string(), const int64_t a_prevValue = 0,
* false after calling this function. const std::string& a_initOp = std::string());
* If a_isNegative is true, the NOT inverted a_value will be returned.
*
* @param a_value
* @param a_isNegative
*/
static int64_t calcSign(const int64_t a_value, bool &a_isNegative);
/**
* Converts the value in form of text to a number. The Text can be decimal, hex
* (0x) or binary (0b).
*
* @param a_valueText
* @param a_pos
*/
int64_t convertValue(const std::string &a_valueText, size_t &a_pos);
/**
* Returns the next token (with space as separator). Heading spaces will be
* ignored.
*
* @param a_calcText
* @param a_pos
*/
static std::string getToken(const std::string &a_calcText, size_t &a_pos);
/** bool calcWithPriority(const std::string& a_calcText, size_t& a_pos, int64_t& a_value1,
* returns true if a_operation is a known operation. std::string& a_operation, int64_t a_value2, const std::string& a_prevOp);
*
* @param a_operation
*/
bool isOperation(const std::string &a_operation) const;
/**
* Calculates the opeation a_operations with a_value1 as first and a_value2 as
* second operand.
*
* @param a_value1
* @param a_operation
* @param a_value2
*/
int64_t doOperation(const int64_t a_value1, const std::string &a_operation, const int64_t a_value2);
/**
* returns true if priority of a_opeation1 is higher than priority of a_operation2.
*
*
* @param a_operation1
* @param a_operation2
*/
bool isOperationPriorityHigher(const std::string &a_operation1, const std::string &a_operation2) const;
/** static int64_t calcSign(const int64_t a_value, bool& a_isNegative);
* Returns true if the variable named a_variableName is known and a_value will be
* filled with its value. If the variable is not found false will be returned.
* Overload this virtual function if you want to implement your own variable-list.
* int64_t convertValue(const std::string& a_valueText, size_t& a_pos);
* @param a_variableName
* @param a_value
*/
virtual bool getVariableValue(const std::string &a_variableName, int64_t &a_value) const; static std::string getToken(const std::string& a_calcText, size_t& a_pos);
bool isOperation(const std::string& a_operation) const;
int64_t doOperation(const int64_t a_value1, const std::string& a_operation, const int64_t a_value2);
bool isOperationPriorityHigher(const std::string& a_operation1, const std::string& a_operation2) const;
virtual bool getVariableValue(const std::string& a_variableName, int64_t& a_value) const;
/**
* Returns true if a_char is a digit. When a_isHex is true, also the charactes a-f
* will be accepted as digits. When a_isBin is true, only 0 and 1 will be treated
* as digit.
*
* @param a_char
* @param a_isHex
* @param a_isBin
*/
static bool isDigit(const char a_char, const bool a_isHex = false, const bool a_isBin = false); static bool isDigit(const char a_char, const bool a_isHex = false, const bool a_isBin = false);
/**
* Returns the priority of the operation. A higher value means more priority.
*
* @param a_operation
*/
int16_t getPriority(const std::string &a_operation) const;
/**
* replaces in a_haystack all a_searchText with a_replaceText (not greedy). int16_t getPriority(const std::string& a_operation) const;
*
* @param a_haystack
* @param a_searchText
* @param a_replaceText static void replace(std::string& a_haystack, const std::string& a_searchText, const std::string& a_replaceText);
*/
static void replace(std::string &a_haystack, const std::string &a_searchText, const std::string &a_replaceText);
}; };
} }
@@ -1,10 +1,5 @@
/**
* @RDE_HEADER@
* Edit boolean values
* $Id$
* $HeadURL$
* $Author$
*/
#include "LogViewBooleanEdit.hpp" #include "LogViewBooleanEdit.hpp"
#include "LogViewField.hpp" #include "LogViewField.hpp"
@@ -13,20 +8,20 @@
namespace N_LogView namespace N_LogView
{ {
// ---------------------------------------------------------------
LogViewBooleanEdit::LogViewBooleanEdit(LogViewField *a_field, QWidget *a_parent, const bool a_readonly) LogViewBooleanEdit::LogViewBooleanEdit(LogViewField* a_field, QWidget* a_parent, const bool a_readonly)
: QCheckBox(a_parent) : QCheckBox (a_parent)
, LogViewWidget(a_field, this, a_parent, a_readonly) , LogViewWidget(a_field, this, a_parent, a_readonly)
{ {
const QString valueText = a_field->value(0); const QString valueText = a_field->value(0);
setChecked(valueText.toInt() == 1); setChecked(valueText.toInt() == 1);
setEnabled(!a_readonly); setEnabled(!a_readonly);
} }
// ---------------------------------------------------------------
bool LogViewBooleanEdit::saveContent(LogViewTelegram *a_telegram) bool LogViewBooleanEdit::saveContent(LogViewTelegram* a_telegram)
{ {
if (m_Valid) if (m_Valid)
{ {
if (a_telegram->isJsonTelegram()) if (a_telegram->isJsonTelegram())
@@ -36,6 +31,6 @@ namespace N_LogView
return true; return true;
} }
return false; return false;
} }
} // namespace N_LogView }
@@ -1,10 +1,5 @@
/**
* @RDE_HEADER@
* Edit boolean values
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once #pragma once
@@ -13,14 +8,12 @@
namespace N_LogView namespace N_LogView
{ {
class LogViewBooleanEdit class LogViewBooleanEdit : public QCheckBox, public LogViewWidget
: public QCheckBox
, public LogViewWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
LogViewBooleanEdit(LogViewField *a_field, QWidget *a_parent, const bool a_readonly); LogViewBooleanEdit(LogViewField* a_field, QWidget* a_parent, const bool a_readonly);
bool saveContent(LogViewTelegram *a_telegram) override; bool saveContent(LogViewTelegram* a_telegram) override;
}; };
} }
@@ -1,17 +1,17 @@
// **************************************************************************
//
// (C) Copyright 2009 Swiss SIMTEC AG
//
// **************************************************************************
//
// $HeadURL$
// $LastChangedBy$
// $LastChangedDate$
// $LastChangedRevision$
//
// **************************************************************************
// manual class headers
#include "LogViewDateTimeEdit.hpp" #include "LogViewDateTimeEdit.hpp"
#include <time.h> #include <time.h>
#include "LogViewField.hpp" #include "LogViewField.hpp"
@@ -20,18 +20,18 @@
namespace N_LogView namespace N_LogView
{ {
// ---------------------------------------------------------------
LogViewDateTimeEdit::LogViewDateTimeEdit(LogViewField *a_field, QWidget *a_parent, const bool a_readonly) LogViewDateTimeEdit::LogViewDateTimeEdit(LogViewField* a_field, QWidget* a_parent, const bool a_readonly)
: QDateTimeEdit(a_parent) : QDateTimeEdit(a_parent)
, LogViewWidget(a_field, this, a_parent, a_readonly) , LogViewWidget(a_field, this, a_parent, a_readonly)
{ {
if (a_readonly) if (a_readonly)
{ {
setReadOnly(true); setReadOnly(true);
setAlignment(a_field->isRightAligned() ? Qt::AlignRight : Qt::AlignLeft); setAlignment(a_field->isRightAligned() ? Qt::AlignRight : Qt::AlignLeft);
} }
// date-time-field
qint64 unixTime = 0; qint64 unixTime = 0;
if (a_field->hasContent()) if (a_field->hasContent())
{ {
@@ -40,45 +40,47 @@ namespace N_LogView
else else
unixTime = a_field->value(0, true).toInt() * 1000LL; unixTime = a_field->value(0, true).toInt() * 1000LL;
} }
// take actual date and time if time is 0
if (0 == unixTime && !a_readonly) if (0 == unixTime && !a_readonly)
unixTime = ::time(nullptr) * 1000LL; unixTime = ::time(nullptr) * 1000LL;
//valueWidget = new QDateTimeEdit(dateTime);
setDateTime(QDateTime::fromMSecsSinceEpoch(unixTime)); setDateTime(QDateTime::fromMSecsSinceEpoch(unixTime));
setDisplayFormat(QLatin1String("dd MMM yyyy hh:mm:ss")); setDisplayFormat(QLatin1String("dd MMM yyyy hh:mm:ss"));
setCalendarPopup(true); setCalendarPopup(true);
updateToolTip(QString::number(unixTime)); updateToolTip(QString::number(unixTime));
//setToolTip(a_field->getToolTipText());
// checkAndOvertakeContent();
connect(this, &LogViewDateTimeEdit::editingFinished, this, &LogViewDateTimeEdit::checkAndOvertakeContent);
}
// ---------------------------------------------------------------
void LogViewDateTimeEdit::checkAndOvertakeContent() connect(this, &LogViewDateTimeEdit::editingFinished,
{ this, &LogViewDateTimeEdit::checkAndOvertakeContent);
}
void LogViewDateTimeEdit::checkAndOvertakeContent()
{
updateToolTip(QString::number(dateTime().toMSecsSinceEpoch() / 1000)); updateToolTip(QString::number(dateTime().toMSecsSinceEpoch() / 1000));
} }
// ---------------------------------------------------------------
// Writes the content into telegram.
// Returns true if successful.
// ---------------------------------------------------------------
bool LogViewDateTimeEdit::saveContent(LogViewTelegram *a_telegram) bool LogViewDateTimeEdit::saveContent(LogViewTelegram* a_telegram)
{ {
if (a_telegram->isJsonTelegram()) if (a_telegram->isJsonTelegram())
{ {
a_telegram->setJsonValue(m_Field->jsonPath(), dateTime().toMSecsSinceEpoch()); a_telegram->setJsonValue(m_Field->jsonPath(), dateTime().toMSecsSinceEpoch());
} }
else else
{ {
a_telegram->setNextFieldAsGpsTimeField(); // fixme: muss noch der feldname auf GPS Zeit geprüft werden? a_telegram->setNextFieldAsGpsTimeField();
a_telegram->setUIntX(getSize(), dateTime().toMSecsSinceEpoch() / 1000); a_telegram->setUIntX(getSize(), dateTime().toMSecsSinceEpoch() / 1000);
} }
return true; return true;
} }
}
} // namespace N_LogView
@@ -1,15 +1,15 @@
// **************************************************************************
//
// (C) Copyright 2009 Swiss SIMTEC AG
//
// **************************************************************************
//
// $HeadURL$
// $LastChangedBy$
// $LastChangedDate$
// $LastChangedRevision$
//
// **************************************************************************
#pragma once #pragma once
@@ -18,37 +18,23 @@
namespace N_LogView namespace N_LogView
{ {
/**
* Used for date & time
* class LogViewDateTimeEdit : public QDateTimeEdit, public LogViewWidget
* @author alois.wismer
* @version 1.0
* @created 20-Mai-2010 17:41:28
*/
class LogViewDateTimeEdit
: public QDateTimeEdit
, public LogViewWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
/**
*
* @param a_field
* @param a_parent
* @param a_readonly
*/
LogViewDateTimeEdit(LogViewField *a_field, QWidget *a_parent, const bool a_readonly);
/**
* Writes the content into telegram. LogViewDateTimeEdit(LogViewField* a_field, QWidget* a_parent, const bool a_readonly);
* Returns true if successful.
*
* @param a_telegram
*/ bool saveContent(LogViewTelegram* a_telegram) override;
bool saveContent(LogViewTelegram *a_telegram) override;
public slots: public slots:
void checkAndOvertakeContent(); void checkAndOvertakeContent();
}; };
} }
@@ -1,17 +1,17 @@
// **************************************************************************
//
// (C) Copyright 2009 Swiss SIMTEC AG
//
// **************************************************************************
//
// $HeadURL$
// $LastChangedBy$
// $LastChangedDate$
// $LastChangedRevision$
//
// **************************************************************************
// manual class headers
#include "LogViewEnumEdit.hpp" #include "LogViewEnumEdit.hpp"
#include "LogViewXdrStruct.hpp" #include "LogViewXdrStruct.hpp"
#include "LogViewXdrValue.hpp" #include "LogViewXdrValue.hpp"
@@ -23,20 +23,20 @@ namespace N_LogView
{ {
// ---------------------------------------------------------------
LogViewEnumEdit::LogViewEnumEdit(LogViewField *a_field, QWidget *a_parent, const bool a_readonly, const int a_index) LogViewEnumEdit::LogViewEnumEdit(LogViewField* a_field, QWidget* a_parent, const bool a_readonly, const int a_index)
: QComboBox(a_parent) : QComboBox(a_parent)
, LogViewWidget(a_field, this, a_parent, a_readonly) , LogViewWidget(a_field, this, a_parent, a_readonly)
{ {
QString value = a_field->value(a_index); QString value = a_field->value(a_index);
// show the tool-tip with special-case for TETRA bitfields
setToolTip(a_field->toolTipText()); setToolTip(a_field->toolTipText());
// fill combobox
bool bCurrentIndexSet = false; bool bCurrentIndexSet = false;
int i = 0; int i = 0;
while (LogViewXdrValue *child = (static_cast<const LogViewXdrStruct *>(a_field->xdrElement()))->getChildAsValue(i++)) while (LogViewXdrValue* child = (static_cast<const LogViewXdrStruct*>(a_field->xdrElement()))->getChildAsValue(i++))
{ {
QString enumText = LogViewField::makeClean(child->getName()); QString enumText = LogViewField::makeClean(child->getName());
if (!a_readonly || enumText == value) if (!a_readonly || enumText == value)
@@ -61,33 +61,34 @@ namespace N_LogView
setCurrentIndex(findText(value)); setCurrentIndex(findText(value));
} }
// connect signals
connect(this, QOverload<int>::of(&LogViewEnumEdit::currentIndexChanged), this, &LogViewEnumEdit::checkAndOvertakeContent); connect(this, QOverload<int>::of(&LogViewEnumEdit::currentIndexChanged),
} this, &LogViewEnumEdit::checkAndOvertakeContent);
}
// ---------------------------------------------------------------
uint16_t LogViewEnumEdit::getSize() const uint16_t LogViewEnumEdit::getSize() const
{ {
// todo: check ob wirklich ein struct
const LogViewXdrStruct *xdrStruct = static_cast<const LogViewXdrStruct *>(m_Field->xdrElement()); const LogViewXdrStruct* xdrStruct = static_cast<const LogViewXdrStruct*>(m_Field->xdrElement());
return xdrStruct->getEnumSize(); return xdrStruct->getEnumSize();
} }
// ---------------------------------------------------------------
void LogViewEnumEdit::checkAndOvertakeContent() void LogViewEnumEdit::checkAndOvertakeContent()
{ {
updateToolTip(itemData(currentIndex()).toString()); updateToolTip(itemData(currentIndex()).toString());
} }
// ---------------------------------------------------------------
// Writes the content into telegram.
// Returns true if successful.
// ---------------------------------------------------------------
bool LogViewEnumEdit::saveContent(LogViewTelegram *a_telegram) bool LogViewEnumEdit::saveContent(LogViewTelegram* a_telegram)
{ {
bool ok; bool ok;
int value = itemData(currentIndex()).toInt(&ok); int value = itemData(currentIndex()).toInt(&ok);
if (ok) if (ok)
@@ -98,7 +99,7 @@ namespace N_LogView
a_telegram->setUIntX(getSize(), value); a_telegram->setUIntX(getSize(), value);
return true; return true;
} }
return false; // failure while conversion return false;
} }
} // namespace N_LogView }
@@ -1,15 +1,15 @@
// **************************************************************************
//
// (C) Copyright 2009 Swiss SIMTEC AG
//
// **************************************************************************
//
// $HeadURL$
// $LastChangedBy$
// $LastChangedDate$
// $LastChangedRevision$
//
// **************************************************************************
#pragma once #pragma once
@@ -18,41 +18,26 @@
namespace N_LogView namespace N_LogView
{ {
/**
* Used for enums
* class LogViewEnumEdit : public QComboBox, public LogViewWidget
* @author alois.wismer
* @version 1.0
* @created 21-Mai-2010 09:31:16
*/
class LogViewEnumEdit
: public QComboBox
, public LogViewWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
/**
*
* @param a_field LogViewEnumEdit(LogViewField* a_field, QWidget* a_parent, const bool a_readonly, const int a_index);
* @param a_parent
* @param a_readonly
* @param a_index the array-index
*/
LogViewEnumEdit(LogViewField *a_field, QWidget *a_parent, const bool a_readonly, const int a_index);
uint16_t getSize() const override; uint16_t getSize() const override;
/**
* Writes the content into telegram.
* Returns true if successful. bool saveContent(LogViewTelegram* a_telegram) override;
*
* @param a_telegram
*/
bool saveContent(LogViewTelegram *a_telegram) override;
protected slots: protected slots:
void checkAndOvertakeContent(); void checkAndOvertakeContent();
}; };
} }
@@ -1,15 +1,15 @@
// **************************************************************************
//
// (C) Copyright 2009 Swiss SIMTEC AG
//
// **************************************************************************
//
// $HeadURL$
// $LastChangedBy$
// $LastChangedDate$
// $LastChangedRevision$
//
// **************************************************************************
#pragma once #pragma once
@@ -34,7 +34,7 @@ namespace N_LogView
}; };
LogViewField(const QString &a_name, const E_FieldKind a_kind, const LogViewXdrElement *a_xdrElement); LogViewField(const QString& a_name, const E_FieldKind a_kind, const LogViewXdrElement* a_xdrElement);
virtual ~LogViewField(); virtual ~LogViewField();
LogViewField *clone(int arrayIdx) const; LogViewField *clone(int arrayIdx) const;
@@ -44,7 +44,7 @@ namespace N_LogView
void setName(const QString &newVal) { m_Name = newVal; } void setName(const QString &newVal) { m_Name = newVal; }
void addChild(LogViewField *a_child); void addChild(LogViewField* a_child);
void removeLastChild(); void removeLastChild();
LogViewField *child(int arrayIdx); LogViewField *child(int arrayIdx);
int childCount() const { return m_Child.size(); } int childCount() const { return m_Child.size(); }
@@ -57,15 +57,8 @@ namespace N_LogView
void addValue(const QString &value); void addValue(const QString &value);
void addValueBinaryHex(const QString &value); void addValueBinaryHex(const QString &value);
/**
* Returns the value at position a_index converted to a string. If the field is a
* date-time-field, the returned value is converted to a string containing date
* and time, execpt when a_doNotMakeSpecialConversions is set to true, the unix-
* time will be returned as value.
*
* @param a_index
* @param a_doNotMakeSpecialConversions
*/
QString value(int arrayIdx, const bool a_doNotMakeSpecialConversions = false) const; QString value(int arrayIdx, const bool a_doNotMakeSpecialConversions = false) const;
int valueListSize() const { return m_ValueList.size(); } int valueListSize() const { return m_ValueList.size(); }
@@ -81,21 +74,12 @@ namespace N_LogView
int64_t getHighestValue() const; int64_t getHighestValue() const;
int64_t getLowestValue() const; int64_t getLowestValue() const;
/**
*
* @param a_indent
*/
void dump(const QString &a_indent = QString()) const; void dump(const QString &a_indent = QString()) const;
/**
* Makes the text <a_uncleanText> pretty for human readable. It does following:
* - generates umlaute (ä, ö, ü)
* - removes _rt at end
* - replaces _ with space
* - uppercase of every word
*
* @param a_uncleanText
*/
static QString makeClean(const QString &text); static QString makeClean(const QString &text);
@@ -103,11 +87,10 @@ namespace N_LogView
void setSize(int newVal) { m_Size = newVal; } void setSize(int newVal) { m_Size = newVal; }
const LogViewXdrElement *xdrElement() const { return m_XdrElement; } const LogViewXdrElement* xdrElement() const { return m_XdrElement; }
/**
* returns true if the field is a date-time
*/
bool isDateTimeField() const; bool isDateTimeField() const;
bool isMSecsField() const; bool isMSecsField() const;
@@ -115,9 +98,8 @@ namespace N_LogView
uint16_t maxArraySize() const { return m_MaxArraySize; } uint16_t maxArraySize() const { return m_MaxArraySize; }
void setMaxArraySize(uint16_t newVal, const bool a_isDynamic); void setMaxArraySize(uint16_t newVal, const bool a_isDynamic);
/**
* True if the array is dynamic.
*/
bool isDynamicArray() const { return m_IsDynamicArray; } bool isDynamicArray() const { return m_IsDynamicArray; }
@@ -130,7 +112,6 @@ namespace N_LogView
QStringList jsonPath() const { return m_jsonPath; } QStringList jsonPath() const { return m_jsonPath; }
protected: protected:
NGL::INGLLogger &m_logger;
QString m_Name; QString m_Name;
QString m_type; QString m_type;
@@ -141,13 +122,12 @@ namespace N_LogView
uint16_t m_Offset; uint16_t m_Offset;
int m_Size; int m_Size;
uint16_t m_MaxArraySize; uint16_t m_MaxArraySize;
/**
* True if the array is dynamic.
*/
bool m_IsDynamicArray; bool m_IsDynamicArray;
bool m_HasContent; bool m_HasContent;
bool m_bDeleteXdr; bool m_bDeleteXdr;
QVector<LogViewField *> m_Child; QVector<LogViewField*> m_Child;
E_FieldKind m_Kind; E_FieldKind m_Kind;
@@ -1,15 +1,15 @@
// **************************************************************************
//
// (C) Copyright 2009 Swiss SIMTEC AG
//
// **************************************************************************
//
// $HeadURL$
// $LastChangedBy$
// $LastChangedDate$
// $LastChangedRevision$
//
// **************************************************************************
#pragma once #pragma once
@@ -24,15 +24,13 @@ namespace N_LogView
{ {
class LogViewTelegram; class LogViewTelegram;
/**
* @author alois.wismer
* @version 1.0
* @created 05-Aug-2010 16:02:15
*/
class LogViewInjectionThread : public QThread class LogViewInjectionThread : public QThread
{ {
Q_OBJECT Q_OBJECT
public: public:
LogViewInjectionThread(); LogViewInjectionThread();
void run(); void run();
@@ -41,15 +39,12 @@ namespace N_LogView
bool isSendingPossible() const; bool isSendingPossible() const;
/**
*
* @param a_telegram void sendTelegram(LogViewTelegram* a_telegram, const bool a_doSendAsCentralTelegram);
* @param a_doSendAsCentralTelegram
*/
void sendTelegram(LogViewTelegram *a_telegram, const bool a_doSendAsCentralTelegram);
protected: protected:
NGL::INGLLogger &m_logger;
bool m_DoStartConnection; bool m_DoStartConnection;
bool m_SendingPossible; bool m_SendingPossible;
QString m_Hostname; QString m_Hostname;
@@ -72,12 +67,10 @@ namespace N_LogView
public: public:
signals: signals:
/**
*
* @param a_picName void updateStatus(const QString& a_picName, const QString& a_toolTipText);
* @param a_toolTipText
*/
void updateStatus(const QString &a_picName, const QString &a_toolTipText);
}; };
} }
@@ -1,10 +1,5 @@
/**
* @RDE_HEADER@
* some models for LogViewGui
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once #pragma once
@@ -21,10 +16,10 @@
namespace N_LogView namespace N_LogView
{ {
class ParticipantModel final : public QAbstractTableModel class ParticipantModel final : public QAbstractTableModel
{ {
Q_OBJECT Q_OBJECT
public: public:
using QAbstractTableModel::QAbstractTableModel; using QAbstractTableModel::QAbstractTableModel;
int rowCount(const QModelIndex &parent = QModelIndex()) const override; int rowCount(const QModelIndex &parent = QModelIndex()) const override;
@@ -32,27 +27,28 @@ namespace N_LogView
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const override;
void clearParticipants(); void clearParticipants();
bool addUpdateParticipants(const QVector<int> &eqIds, const QVector<int> &issis, const QVector<int> &numberOfTelegrams); bool addUpdateParticipants(const QVector<int> &eqIds,
const QVector<int> &issis,
protected: const QVector<int> &numberOfTelegrams);
protected:
void updateHeatMap() const; void updateHeatMap() const;
protected:
QVector<QPair<int, int> > m_particpants;
protected:
// eqId , issi
QVector<QPair<int, int>> m_particpants;
// eqid, count telegrams
QHash<int, int> m_particpantMap; QHash<int, int> m_particpantMap;
// eqId, QColor for heatmap
mutable QHash<int, QColor> m_participantHeatmap;
};
class TelegramModel final : public QAbstractTableModel mutable QHash<int, QColor> m_participantHeatmap;
{ };
class TelegramModel final : public QAbstractTableModel
{
Q_OBJECT Q_OBJECT
public: public:
using QAbstractTableModel::QAbstractTableModel; using QAbstractTableModel::QAbstractTableModel;
int rowCount(const QModelIndex &parent = QModelIndex()) const override; int rowCount(const QModelIndex &parent = QModelIndex()) const override;
@@ -60,21 +56,21 @@ namespace N_LogView
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const override;
void clearTelegrams(); void clearTelegrams();
void appendTelegrams(const QVector<QSharedPointer<LogViewTelegram>> &telegrams); void appendTelegrams(const QVector<QSharedPointer<LogViewTelegram> > &telegrams);
void appendTelegram(const QSharedPointer<LogViewTelegram> &telegram); void appendTelegram(const QSharedPointer<LogViewTelegram> &telegram);
QSharedPointer<LogViewTelegram> telegram(int row) const; QSharedPointer<LogViewTelegram> telegram(int row) const;
protected:
QVector<QSharedPointer<LogViewTelegram> > m_telegrams;
};
protected: class TelegramProxyModel final : public QSortFilterProxyModel
QVector<QSharedPointer<LogViewTelegram>> m_telegrams; {
};
class TelegramProxyModel final : public QSortFilterProxyModel
{
Q_OBJECT Q_OBJECT
public: public:
using QSortFilterProxyModel::QSortFilterProxyModel; using QSortFilterProxyModel::QSortFilterProxyModel;
void setFilterByEquipmentIds(bool bFilterByEquipmentIds); void setFilterByEquipmentIds(bool bFilterByEquipmentIds);
@@ -93,12 +89,10 @@ namespace N_LogView
void setFilterTetraFragmented(bool bFilter); void setFilterTetraFragmented(bool bFilter);
QSharedPointer<LogViewTelegram> telegram(int row) const; QSharedPointer<LogViewTelegram> telegram(int row) const;
protected:
protected:
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override; bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override; bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
protected:
protected:
std::set<int> m_allowedEquipmentIds; std::set<int> m_allowedEquipmentIds;
std::set<int> m_filteredCentralTelegramIds; std::set<int> m_filteredCentralTelegramIds;
std::set<int> m_filteredTetraTelegramIds; std::set<int> m_filteredTetraTelegramIds;
@@ -110,6 +104,6 @@ namespace N_LogView
std::set<N_CoPrtCnv::CoPrtCnvLogHeader::E_CoPrtCnvProtocol> m_filterTetraTelegrams; std::set<N_CoPrtCnv::CoPrtCnvLogHeader::E_CoPrtCnvProtocol> m_filterTetraTelegrams;
std::set<N_CoPrtCnv::CoPrtCnvLogHeader::E_CoPrtCnvProtocol> m_filterWlsTelegrams; std::set<N_CoPrtCnv::CoPrtCnvLogHeader::E_CoPrtCnvProtocol> m_filterWlsTelegrams;
std::set<N_CoPrtCnv::CoPrtCnvRadioTelegram::E_PDU_Type> m_filterTetraPDU; std::set<N_CoPrtCnv::CoPrtCnvRadioTelegram::E_PDU_Type> m_filterTetraPDU;
}; };
} // namespace N_LogView }
@@ -1,15 +1,15 @@
// **************************************************************************
//
// (C) Copyright 2009 Swiss SIMTEC AG
//
// **************************************************************************
//
// $HeadURL$
// $LastChangedBy$
// $LastChangedDate$
// $LastChangedRevision$
//
// **************************************************************************
#include "LogViewOptionDialog.hpp" #include "LogViewOptionDialog.hpp"
#include <QtCore/QCoreApplication> #include <QtCore/QCoreApplication>
@@ -28,52 +28,52 @@
namespace N_LogView namespace N_LogView
{ {
// static member initialization
const QString LogViewOptionDialog::SPEC_FILES = tr("Spezifikations-Dateien (*.x)"); const QString LogViewOptionDialog::SPEC_FILES = tr("Spezifikations-Dateien (*.x)");
const QString LogViewOptionDialog::KRLOG_FILES = tr("Log-Dateien (*.krlog)"); const QString LogViewOptionDialog::KRLOG_FILES = tr("Log-Dateien (*.krlog)");
const QLatin1String LogViewOptionDialog::SPEC_FILES_GROUP("SpecFiles"); const QLatin1String LogViewOptionDialog::SPEC_FILES_GROUP("SpecFiles");
const QLatin1String LogViewOptionDialog::DIR("Dir"); const QLatin1String LogViewOptionDialog::DIR("Dir");
const QLatin1String LogViewOptionDialog::P0_FILENAME("Central2PrtCnv"); const QLatin1String LogViewOptionDialog::P0_FILENAME("Central2PrtCnv");
const QLatin1String LogViewOptionDialog::P5_FILENAME("PrtCnv2TETRA"); const QLatin1String LogViewOptionDialog::P5_FILENAME("PrtCnv2TETRA");
const QLatin1String LogViewOptionDialog::SERVER_GROUP("ServerPorts"); const QLatin1String LogViewOptionDialog::SERVER_GROUP("ServerPorts");
const QLatin1String LogViewOptionDialog::CENTRAL_PORT("Central"); const QLatin1String LogViewOptionDialog::CENTRAL_PORT("Central");
const QLatin1String LogViewOptionDialog::TETRA_PORT("Tetra"); const QLatin1String LogViewOptionDialog::TETRA_PORT("Tetra");
const QLatin1String LogViewOptionDialog::LOG_FILENAME("LogFilename"); const QLatin1String LogViewOptionDialog::LOG_FILENAME("LogFilename");
const QLatin1String LogViewOptionDialog::INJECTION_GROUP("InjectionServer"); const QLatin1String LogViewOptionDialog::INJECTION_GROUP("InjectionServer");
const QLatin1String LogViewOptionDialog::INJECTION_HOSTNAME("InjectionHostname"); const QLatin1String LogViewOptionDialog::INJECTION_HOSTNAME("InjectionHostname");
const QLatin1String LogViewOptionDialog::INJECTION_PORT("InjectionPort"); const QLatin1String LogViewOptionDialog::INJECTION_PORT("InjectionPort");
// ---------------------------------------------------------------
LogViewOptionDialog::LogViewOptionDialog(QWidget *a_parent) LogViewOptionDialog::LogViewOptionDialog(QWidget* a_parent)
: QDialog(a_parent) : QDialog(a_parent)
{ {
QVBoxLayout *layout = new QVBoxLayout(this); QVBoxLayout* layout = new QVBoxLayout(this);
// telegram specification files
m_Settings.beginGroup(LogViewOptionDialog::SPEC_FILES_GROUP); m_Settings.beginGroup(LogViewOptionDialog::SPEC_FILES_GROUP);
QGroupBox *groupBox = new QGroupBox(tr("Telegramm-Spezifikations-Dateien"), this); QGroupBox* groupBox = new QGroupBox(tr("Telegramm-Spezifikations-Dateien"), this);
layout->addWidget(groupBox); layout->addWidget(groupBox);
QGridLayout *groupLayout = new QGridLayout(); QGridLayout* groupLayout = new QGridLayout();
QLabel *p0Label = new QLabel(tr("&Zentrale - Protokollkonverter"), this); QLabel* p0Label = new QLabel(tr("&Zentrale - Protokollkonverter"), this);
groupLayout->addWidget(p0Label, 0, 0, 1, 2); groupLayout->addWidget(p0Label, 0, 0, 1, 2);
QString defString = QCoreApplication::applicationDirPath() + QLatin1String("/training_area_telegrams.h"); QString defString = QCoreApplication::applicationDirPath() + QLatin1String("/training_area_telegrams.h");
m_P0Edit = new QLineEdit(m_Settings.value(P0_FILENAME, defString).toString(), this); m_P0Edit = new QLineEdit(m_Settings.value(P0_FILENAME, defString).toString(), this);
m_P0Edit->setMinimumWidth(400); m_P0Edit->setMinimumWidth(400);
groupLayout->addWidget(m_P0Edit); groupLayout->addWidget(m_P0Edit);
QPushButton *p0Browse = new QPushButton(tr("Browse"), this); QPushButton* p0Browse = new QPushButton(tr("Browse"), this);
p0Label->setBuddy(p0Browse); p0Label->setBuddy(p0Browse);
connect(p0Browse, &QPushButton::clicked, this, &LogViewOptionDialog::browseP0File); connect(p0Browse, &QPushButton::clicked, this, &LogViewOptionDialog::browseP0File);
groupLayout->addWidget(p0Browse, 1, 1); groupLayout->addWidget(p0Browse, 1, 1);
QLabel *p5Label = new QLabel(tr("Protokollkonverter - &TETRA"), this); QLabel* p5Label = new QLabel(tr("Protokollkonverter - &TETRA"), this);
groupLayout->addWidget(p5Label, 2, 0, 1, 2); groupLayout->addWidget(p5Label, 2, 0, 1, 2);
defString = QCoreApplication::applicationDirPath() + QLatin1String("/zsksxd_tetraForLogView.x"); defString = QCoreApplication::applicationDirPath() + QLatin1String("/zsksxd_tetraForLogView.x");
m_P5Edit = new QLineEdit(m_Settings.value(P5_FILENAME, defString).toString(), this); m_P5Edit = new QLineEdit(m_Settings.value(P5_FILENAME, defString).toString(), this);
groupLayout->addWidget(m_P5Edit); groupLayout->addWidget(m_P5Edit);
QPushButton *p5Browse = new QPushButton(tr("Browse"), this); QPushButton* p5Browse = new QPushButton(tr("Browse"), this);
p5Label->setBuddy(p5Browse); p5Label->setBuddy(p5Browse);
connect(p5Browse, &QPushButton::clicked, this, &LogViewOptionDialog::browseP5File); connect(p5Browse, &QPushButton::clicked, this, &LogViewOptionDialog::browseP5File);
groupLayout->addWidget(p5Browse, 3, 1); groupLayout->addWidget(p5Browse, 3, 1);
@@ -81,20 +81,20 @@ namespace N_LogView
groupBox->setLayout(groupLayout); groupBox->setLayout(groupLayout);
m_Settings.endGroup(); m_Settings.endGroup();
// injection
m_Settings.beginGroup(LogViewOptionDialog::INJECTION_GROUP); m_Settings.beginGroup(LogViewOptionDialog::INJECTION_GROUP);
groupBox = new QGroupBox(tr("Telegram Injection Server"), this); groupBox = new QGroupBox(tr("Telegram Injection Server"), this);
layout->addWidget(groupBox); layout->addWidget(groupBox);
QGridLayout *injectLayout = new QGridLayout(); QGridLayout* injectLayout = new QGridLayout();
QLabel *injectPortLabel = new QLabel(tr("Port"), this); QLabel* injectPortLabel = new QLabel(tr("Port"), this);
injectLayout->addWidget(injectPortLabel, 1, 0); injectLayout->addWidget(injectPortLabel, 1, 0);
m_InjectPortEdit = new QLineEdit(m_Settings.value(INJECTION_PORT).toString(), this); m_InjectPortEdit = new QLineEdit(m_Settings.value(INJECTION_PORT).toString(), this);
QIntValidator *validator = new QIntValidator(1024, 65535, this); QIntValidator* validator = new QIntValidator(1024, 65535, this);
m_InjectPortEdit->setValidator(validator); m_InjectPortEdit->setValidator(validator);
injectLayout->addWidget(m_InjectPortEdit, 1, 1); injectLayout->addWidget(m_InjectPortEdit, 1, 1);
QLabel *injectHostnameLabel = new QLabel(tr("Hostname"), this); QLabel* injectHostnameLabel = new QLabel(tr("Hostname"), this);
injectLayout->addWidget(injectHostnameLabel, 0, 0); injectLayout->addWidget(injectHostnameLabel, 0, 0);
m_InjectHostnameEdit = new QLineEdit(m_Settings.value(INJECTION_HOSTNAME).toString(), this); m_InjectHostnameEdit = new QLineEdit(m_Settings.value(INJECTION_HOSTNAME).toString(), this);
injectLayout->addWidget(m_InjectHostnameEdit, 0, 1); injectLayout->addWidget(m_InjectHostnameEdit, 0, 1);
@@ -102,20 +102,20 @@ namespace N_LogView
groupBox->setLayout(injectLayout); groupBox->setLayout(injectLayout);
m_Settings.endGroup(); m_Settings.endGroup();
// buttons
layout->addStretch(); layout->addStretch();
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
connect(buttonBox, &QDialogButtonBox::accepted, this, &LogViewOptionDialog::save); connect(buttonBox, &QDialogButtonBox::accepted, this, &LogViewOptionDialog::save);
connect(buttonBox, &QDialogButtonBox::rejected, this, &LogViewOptionDialog::reject); connect(buttonBox, &QDialogButtonBox::rejected, this, &LogViewOptionDialog::reject);
layout->addWidget(buttonBox); layout->addWidget(buttonBox);
//setLayout(layout);
} }
// ---------------------------------------------------------------
void LogViewOptionDialog::browseP0File() void LogViewOptionDialog::browseP0File()
{ {
QString newFilename = QFileDialog::getOpenFileName(this, QString newFilename = QFileDialog::getOpenFileName(this,
tr("Zentrale - Protokollkonverter Spezifikations-Datei"), tr("Zentrale - Protokollkonverter Spezifikations-Datei"),
m_Settings.value(DIR).toString(), m_Settings.value(DIR).toString(),
@@ -128,12 +128,12 @@ namespace N_LogView
m_Settings.setValue(DIR, dir.filePath(newFilename)); m_Settings.setValue(DIR, dir.filePath(newFilename));
m_Settings.endGroup(); m_Settings.endGroup();
} }
} }
// ---------------------------------------------------------------
void LogViewOptionDialog::browseP5File() void LogViewOptionDialog::browseP5File()
{ {
QString newFilename = QFileDialog::getOpenFileName(this, tr("Protokollkonverter - TETRA Spezifikations-Datei"), m_Settings.value(DIR).toString(), SPEC_FILES); QString newFilename = QFileDialog::getOpenFileName(this, tr("Protokollkonverter - TETRA Spezifikations-Datei"), m_Settings.value(DIR).toString(), SPEC_FILES);
if (!newFilename.isEmpty()) if (!newFilename.isEmpty())
{ {
@@ -143,18 +143,19 @@ namespace N_LogView
m_Settings.setValue(DIR, dir.filePath(newFilename)); m_Settings.setValue(DIR, dir.filePath(newFilename));
m_Settings.endGroup(); m_Settings.endGroup();
} }
} }
// ---------------------------------------------------------------
void LogViewOptionDialog::save() void LogViewOptionDialog::save()
{ {
uint32_t changedFlags = 0; uint32_t changedFlags = 0;
// check group wise for changes
// specification files
m_Settings.beginGroup(LogViewOptionDialog::SPEC_FILES_GROUP); m_Settings.beginGroup(LogViewOptionDialog::SPEC_FILES_GROUP);
QString string = m_Settings.value(P0_FILENAME).toString(); QString string = m_Settings.value(P0_FILENAME).toString();
if ((string != m_P0Edit->text()) || (m_Settings.value(P5_FILENAME).toString() != m_P5Edit->text())) if ((string != m_P0Edit->text()) ||
(m_Settings.value(P5_FILENAME).toString() != m_P5Edit->text()))
{ {
m_Settings.setValue(P0_FILENAME, m_P0Edit->text()); m_Settings.setValue(P0_FILENAME, m_P0Edit->text());
m_Settings.setValue(P5_FILENAME, m_P5Edit->text()); m_Settings.setValue(P5_FILENAME, m_P5Edit->text());
@@ -162,9 +163,10 @@ namespace N_LogView
} }
m_Settings.endGroup(); m_Settings.endGroup();
// injection settings
m_Settings.beginGroup(LogViewOptionDialog::INJECTION_GROUP); m_Settings.beginGroup(LogViewOptionDialog::INJECTION_GROUP);
if ((m_Settings.value(INJECTION_HOSTNAME).toString() != m_InjectHostnameEdit->text()) || (m_Settings.value(INJECTION_PORT).toString() != m_InjectPortEdit->text())) if ((m_Settings.value(INJECTION_HOSTNAME).toString() != m_InjectHostnameEdit->text()) ||
(m_Settings.value(INJECTION_PORT).toString() != m_InjectPortEdit->text()))
{ {
m_Settings.setValue(INJECTION_HOSTNAME, m_InjectHostnameEdit->text()); m_Settings.setValue(INJECTION_HOSTNAME, m_InjectHostnameEdit->text());
m_Settings.setValue(INJECTION_PORT, m_InjectPortEdit->text()); m_Settings.setValue(INJECTION_PORT, m_InjectPortEdit->text());
@@ -175,6 +177,6 @@ namespace N_LogView
emit settingsChanged(changedFlags); emit settingsChanged(changedFlags);
accept(); accept();
} }
} // namespace N_LogView }
@@ -1,15 +1,15 @@
// **************************************************************************
//
// (C) Copyright 2009 Swiss SIMTEC AG
//
// **************************************************************************
//
// $HeadURL$
// $LastChangedBy$
// $LastChangedDate$
// $LastChangedRevision$
//
// **************************************************************************
#pragma once #pragma once
@@ -20,19 +20,14 @@ class QLineEdit;
namespace N_LogView namespace N_LogView
{ {
/**
* This class lets the user view and change the settings of the application
* class LogViewOptionDialog : public QDialog
* @author alois.wismer {
* @version 1.0
* @created 09-Mrz-2010 14:49:40
*/
class LogViewOptionDialog : public QDialog
{
Q_OBJECT Q_OBJECT
public: public:
enum SettingsChangedFlag
{ enum SettingsChangedFlag {
SpecFilesGroup = 0x01, SpecFilesGroup = 0x01,
ServerGroup = 0x02, ServerGroup = 0x02,
InjectionGroup = 0x04 InjectionGroup = 0x04
@@ -55,16 +50,15 @@ namespace N_LogView
static const QLatin1String INJECTION_PORT; static const QLatin1String INJECTION_PORT;
/**
*
* @param a_parent a_parent
*/
explicit LogViewOptionDialog(QWidget *a_parent);
signals:
void settingsChanged(uint32_t changed); // bitfield of SettingsChangedFlag enum
protected: explicit LogViewOptionDialog(QWidget* a_parent);
signals:
void settingsChanged(uint32_t changed);
protected:
static const QString SPEC_FILES; static const QString SPEC_FILES;
static const QLatin1String DIR; static const QLatin1String DIR;
bool m_IsServer; bool m_IsServer;
@@ -74,10 +68,10 @@ namespace N_LogView
QLineEdit *m_InjectHostnameEdit; QLineEdit *m_InjectHostnameEdit;
QLineEdit *m_InjectPortEdit; QLineEdit *m_InjectPortEdit;
protected slots: protected slots:
void browseP0File(); void browseP0File();
void browseP5File(); void browseP5File();
void save(); void save();
}; };
} }
@@ -1,15 +1,15 @@
// **************************************************************************
//
// (C) Copyright 2009 Swiss SIMTEC AG
//
// **************************************************************************
//
// $HeadURL$
// $LastChangedBy$
// $LastChangedDate$
// $LastChangedRevision$
//
// **************************************************************************
#include "LogViewSpinBox.hpp" #include "LogViewSpinBox.hpp"
#include "LogViewField.hpp" #include "LogViewField.hpp"
@@ -17,42 +17,43 @@
namespace N_LogView namespace N_LogView
{ {
// ---------------------------------------------------------------
LogViewSpinBox::LogViewSpinBox(LogViewField *a_field, QWidget *a_parent, const int a_value) LogViewSpinBox::LogViewSpinBox(LogViewField* a_field, QWidget* a_parent, const int a_value)
: QSpinBox(a_parent) : QSpinBox(a_parent)
, LogViewWidget(a_field, this, a_parent, false) , LogViewWidget(a_field, this, a_parent, false)
{ {
// set range
uint16_t maxArraySize = a_field->maxArraySize(); uint16_t maxArraySize = a_field->maxArraySize();
setRange(0, maxArraySize); setRange(0, maxArraySize);
// set the actual value
setValue(a_value); setValue(a_value);
// set tooltip-text
setToolTip(tr("<nobr>Wertebereich: 0..%1</nobr>").arg(maxArraySize)); setToolTip(tr("<nobr>Wertebereich: 0..%1</nobr>").arg(maxArraySize));
// connect
connect(this, &LogViewSpinBox::editingFinished, this, &LogViewSpinBox::finishEditing); connect(this, &LogViewSpinBox::editingFinished,
} this, &LogViewSpinBox::finishEditing);
}
// ---------------------------------------------------------------
void LogViewSpinBox::finishEditing() void LogViewSpinBox::finishEditing()
{ {
emit valueEditingFinished(text().toInt()); emit valueEditingFinished(text().toInt());
} }
// ---------------------------------------------------------------
// Writes the content into telegram.
// Returns true if successful.
// ---------------------------------------------------------------
bool LogViewSpinBox::saveContent(LogViewTelegram *a_telegram) bool LogViewSpinBox::saveContent(LogViewTelegram* a_telegram)
{ {
Q_UNUSED(a_telegram); Q_UNUSED(a_telegram);
// not yet implemented
return false;
}
} // namespace N_LogView return false;
}
}
@@ -1,15 +1,15 @@
// **************************************************************************
//
// (C) Copyright 2009 Swiss SIMTEC AG
//
// **************************************************************************
//
// $HeadURL$
// $LastChangedBy$
// $LastChangedDate$
// $LastChangedRevision$
//
// **************************************************************************
#pragma once #pragma once
@@ -18,44 +18,28 @@
namespace N_LogView namespace N_LogView
{ {
/**
* Used for changing size of dyn. arrays.
* class LogViewSpinBox : public QSpinBox, public LogViewWidget
* @author alois.wismer
* @version 1.0
* @created 25-Mai-2010 10:39:45
*/
class LogViewSpinBox
: public QSpinBox
, public LogViewWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
/**
*
* @param a_field
* @param a_parent
* @param a_value
*/
LogViewSpinBox(LogViewField *a_field, QWidget *a_parent, const int a_value);
/**
* Writes the content into telegram. LogViewSpinBox(LogViewField* a_field, QWidget* a_parent, const int a_value);
* Returns true if successful.
*
* @param a_telegram
*/ bool saveContent(LogViewTelegram* a_telegram) override;
bool saveContent(LogViewTelegram *a_telegram) override;
protected slots: protected slots:
void finishEditing(); void finishEditing();
signals: signals:
/**
*
* @param a_newValue
*/
void valueEditingFinished(int a_newValue); void valueEditingFinished(int a_newValue);
}; };
} }
@@ -1,15 +1,15 @@
// **************************************************************************
//
// (C) Copyright 2009 Swiss SIMTEC AG
//
// **************************************************************************
//
// $HeadURL$
// $LastChangedBy$
// $LastChangedDate$
// $LastChangedRevision$
//
// **************************************************************************
#include "LogViewTabWidget.hpp" #include "LogViewTabWidget.hpp"
#include <QtWidgets/QFrame> #include <QtWidgets/QFrame>
@@ -25,25 +25,24 @@ namespace N_LogView
{ {
LogViewTabWidget::LogViewTabWidget(LogViewField *a_field, LogViewTelegramDialog *a_parent, LogViewSpinBox *a_spinBox, NGL::INGLLogger &logger) LogViewTabWidget::LogViewTabWidget(LogViewField* a_field, LogViewTelegramDialog* a_parent, LogViewSpinBox* a_spinBox)
: QTabWidget(a_parent) : QTabWidget(a_parent)
, LogViewWidget(a_field, this, a_parent, false) , LogViewWidget(a_field, this, a_parent, false)
, m_TelegramDialog(a_parent) , m_TelegramDialog(a_parent)
, m_SpinBox(a_spinBox) , m_SpinBox(a_spinBox)
, m_logger(logger) {
{
setVisible(false); setVisible(false);
} }
// ---------------------------------------------------------------
void LogViewTabWidget::changeSize(const int a_newSize) void LogViewTabWidget::changeSize(const int a_newSize)
{ {
// add new tabs
for (int i = count(); i < a_newSize; i++) for (int i = count(); i < a_newSize; i++)
addTab(m_Field, true, i); addTab(m_Field, true, i);
// remove old tabs
while (count() > a_newSize) while (count() > a_newSize)
{ {
QStringList path = m_Field->jsonPath(); QStringList path = m_Field->jsonPath();
@@ -56,19 +55,19 @@ namespace N_LogView
setVisible(a_newSize > 0); setVisible(a_newSize > 0);
m_TelegramDialog->makePretty(); // fixme: funktioniert so nicht, muss als signal realisiert werden m_TelegramDialog->makePretty();
} }
// ---------------------------------------------------------------
// Writes the content into telegram.
// Returns true if successful.
// ---------------------------------------------------------------
bool LogViewTabWidget::saveContent(LogViewTelegram *a_telegram) bool LogViewTabWidget::saveContent(LogViewTelegram* a_telegram)
{ {
if (a_telegram->isJsonTelegram()) if (a_telegram->isJsonTelegram())
return true; return true;
// if m_SpinBox is NULL, we have a static array => no size has to be stored
if (m_SpinBox) if (m_SpinBox)
{ {
if (!isValid()) if (!isValid())
@@ -76,12 +75,12 @@ namespace N_LogView
a_telegram->setUIntX(LogViewTelegram::SIZE_CENTRAL_DYN_ARRAY_SIZE, count()); a_telegram->setUIntX(LogViewTelegram::SIZE_CENTRAL_DYN_ARRAY_SIZE, count());
} }
return true; return true;
} }
// ---------------------------------------------------------------
void LogViewTabWidget::addTab(LogViewField *a_field, const bool a_isEmpty, int arrayIdx) void LogViewTabWidget::addTab(LogViewField* a_field, const bool a_isEmpty, int arrayIdx)
{ {
if (arrayIdx < 0) if (arrayIdx < 0)
{ {
WARNING_LOG(m_logger) << "Invalid array index given: " << arrayIdx; WARNING_LOG(m_logger) << "Invalid array index given: " << arrayIdx;
@@ -90,7 +89,7 @@ namespace N_LogView
QFrame *frame = new QFrame; QFrame *frame = new QFrame;
QGridLayout *box = new QGridLayout(frame); QGridLayout *box = new QGridLayout(frame);
QTabWidget::addTab(frame, QStringLiteral("%1 %2").arg(a_field->cleanName()).arg(count() + 1)); QTabWidget::addTab(frame, QStringLiteral("%1 %2").arg(a_field->cleanName()).arg(count()+1));
if (a_isEmpty) if (a_isEmpty)
a_field->setHasContent(false); a_field->setHasContent(false);
auto *childTree = a_field->child(arrayIdx); auto *childTree = a_field->child(arrayIdx);
@@ -122,11 +121,11 @@ namespace N_LogView
} }
m_TelegramDialog->showTree(childTree, box); m_TelegramDialog->showTree(childTree, box);
// todo: sind nach dem dyn. array noch weitere Felder, so wird addTab nicht richtig funktionieren, weil die
// neuen Felder des Tabs am Ende von m_EditInfoList hinzugefügt werden => diese müssen mittendrin (an der richtigen
// position) eingefügt werden.
// update spinbox
if (m_SpinBox) if (m_SpinBox)
{ {
int spinValue = m_SpinBox->value(); int spinValue = m_SpinBox->value();
@@ -135,6 +134,6 @@ namespace N_LogView
} }
setVisible(true); setVisible(true);
} }
} // namespace N_LogView }
@@ -1,21 +1,20 @@
// **************************************************************************
//
// (C) Copyright 2009 Swiss SIMTEC AG
//
// **************************************************************************
//
// $HeadURL$
// $LastChangedBy$
// $LastChangedDate$
// $LastChangedRevision$
//
// **************************************************************************
#pragma once #pragma once
#include <QtWidgets/QTabWidget> #include <QtWidgets/QTabWidget>
#include "LogViewWidget.hpp" #include "LogViewWidget.hpp"
#include "logger.h"
namespace N_LogView namespace N_LogView
@@ -23,35 +22,28 @@ namespace N_LogView
class LogViewTelegramDialog; class LogViewTelegramDialog;
class LogViewSpinBox; class LogViewSpinBox;
/**
* Used for arrays of structures
* class LogViewTabWidget : public QTabWidget, public LogViewWidget
* @author alois.wismer
* @version 1.0
* @created 26-Mai-2010 17:12:30
*/
class LogViewTabWidget
: public QTabWidget
, public LogViewWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
LogViewTabWidget(LogViewField *a_field, LogViewTelegramDialog *a_parent, LogViewSpinBox *a_spinBox, NGL::INGLLogger &logger);
bool saveContent(LogViewTelegram *a_telegram) override; LogViewTabWidget(LogViewField* a_field, LogViewTelegramDialog* a_parent, LogViewSpinBox* a_spinBox);
void addTab(LogViewField *a_field, const bool a_isEmpty, int arrayIdx);
bool saveContent(LogViewTelegram* a_telegram) override;
void addTab(LogViewField* a_field, const bool a_isEmpty, int arrayIdx);
public slots: public slots:
/**
*
* @param a_newSize
*/
void changeSize(const int a_newSize); void changeSize(const int a_newSize);
protected: protected:
LogViewTelegramDialog *m_TelegramDialog;
LogViewSpinBox *m_SpinBox; LogViewTelegramDialog* m_TelegramDialog;
NGL::INGLLogger &m_logger; LogViewSpinBox* m_SpinBox;
}; };
} }
@@ -1,17 +1,17 @@
// **************************************************************************
//
// (C) Copyright 2009 Swiss SIMTEC AG
//
// **************************************************************************
//
// $HeadURL$
// $LastChangedBy$
// $LastChangedDate$
// $LastChangedRevision$
//
// **************************************************************************
// manual class headers
#include "LogViewTableWidget.hpp" #include "LogViewTableWidget.hpp"
#include "LogViewField.hpp" #include "LogViewField.hpp"
#include <QtWidgets/QHeaderView> #include <QtWidgets/QHeaderView>
@@ -24,20 +24,19 @@ namespace N_LogView
{ {
LogViewTableWidget::LogViewTableWidget(LogViewField *a_field, QWidget *a_parent, const bool a_readonly, NGL::INGLLogger &logger) LogViewTableWidget::LogViewTableWidget(LogViewField* a_field, QWidget* a_parent, const bool a_readonly)
: QTableWidget(0, 2, a_parent) : QTableWidget(0, 2, a_parent)
, LogViewWidget(a_field, this, a_parent, a_readonly) , LogViewWidget(a_field, this, a_parent, a_readonly)
, m_IsFloat(false) , m_IsFloat(false)
, m_IsEnum(false) , m_IsEnum(false)
, m_logger(logger) {
{
switch (m_Field->xdrElement()->getKind()) switch (m_Field->xdrElement()->getKind())
{ {
case LogViewXdrElement::e_KindEnum: case LogViewXdrElement::e_KindEnum:
m_IsEnum = true; m_IsEnum = true;
break; break;
default: default:
m_IsFloat = LogViewXdrStandardType::e_Float == static_cast<const LogViewXdrStandardType *>(m_Field->xdrElement())->getValueKind(); m_IsFloat = LogViewXdrStandardType::e_Float == static_cast<const LogViewXdrStandardType*>(m_Field->xdrElement())->getValueKind();
} }
if (!m_IsFloat) if (!m_IsFloat)
setColumnCount(3); setColumnCount(3);
@@ -55,18 +54,18 @@ namespace N_LogView
} }
setAlternatingRowColors(true); setAlternatingRowColors(true);
// make pretty
// horizontalHeader()->setResizeMode(2, QHeaderView::Stretch);
updateToolTip(); updateToolTip();
// for debugging only
// INFO_LOG(m_logger) << "type=" << static_cast<const LogViewXdrStandardType*>(a_field->getXdrElement())->getValueKind();
// INFO_LOG(m_logger) << "name=" << static_cast<const LogViewXdrStandardType*>(a_field->getXdrElement())->getName().toStdString();
// a_field->getXdrElement()->dump();
// fill in the values
// fixme: implementiere den Fall isHasContent() false
int nbrOfRows = a_field->valueListSize(); int nbrOfRows = a_field->valueListSize();
setRowCount(nbrOfRows); setRowCount(nbrOfRows);
for (int i = 0; i < nbrOfRows; i++) for (int i = 0; i < nbrOfRows; i++)
@@ -74,38 +73,41 @@ namespace N_LogView
makePretty(); makePretty();
// connect signals
connect(this, &LogViewTableWidget::itemChanged, this, &LogViewTableWidget::checkAndOvertakeContent); connect(this, &LogViewTableWidget::itemChanged,
} this, &LogViewTableWidget::checkAndOvertakeContent);
}
// ---------------------------------------------------------------
void LogViewTableWidget::changeSize(const int a_newSize) void LogViewTableWidget::changeSize(const int a_newSize)
{ {
setRowCount(a_newSize); setRowCount(a_newSize);
disconnect(this, &LogViewTableWidget::itemChanged, this, &LogViewTableWidget::checkAndOvertakeContent); disconnect(this, &LogViewTableWidget::itemChanged,
// check and set the new fields this, &LogViewTableWidget::checkAndOvertakeContent);
for (int i = 0; i < a_newSize; i++) for (int i = 0; i < a_newSize; i++)
changeRow(i, QLatin1String("0")); changeRow(i, QLatin1String("0"));
connect(this, &LogViewTableWidget::itemChanged, this, &LogViewTableWidget::checkAndOvertakeContent); connect(this, &LogViewTableWidget::itemChanged,
this, &LogViewTableWidget::checkAndOvertakeContent);
makePretty(); makePretty();
m_Valid = true; m_Valid = true;
} }
// ---------------------------------------------------------------
void LogViewTableWidget::changeRow(const int a_rowIndex, const QString &a_value) void LogViewTableWidget::changeRow(const int a_rowIndex, const QString& a_value)
{ {
// INFO_LOG(m_logger) << "a_rowIndex=" << a_rowIndex << " a_value=" << a_value.toStdString();
if (m_IsEnum) if (m_IsEnum)
{ {
// enum
QWidget *enumItem = cellWidget(a_rowIndex, 0); QWidget* enumItem = cellWidget(a_rowIndex, 0);
if (!enumItem) if (!enumItem)
setCellWidget(a_rowIndex, 0, new LogViewEnumEdit(m_Field, this, m_Readonly, a_rowIndex)); setCellWidget(a_rowIndex, 0, new LogViewEnumEdit(m_Field, this, m_Readonly, a_rowIndex));
} }
@@ -114,12 +116,12 @@ namespace N_LogView
QFont font; QFont font;
font.setStyleHint(QFont::TypeWriter); font.setStyleHint(QFont::TypeWriter);
font.setFamily(QString()); font.setFamily(QString());
// decimal
QTableWidgetItem *decItem = item(a_rowIndex, 0); QTableWidgetItem* decItem = item(a_rowIndex, 0);
if (!decItem) if (!decItem)
{ {
decItem = new QTableWidgetItem(); decItem = new QTableWidgetItem();
//decItem->setData(Qt::DisplayRole, 0);
decItem->setText(a_value); decItem->setText(a_value);
decItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); decItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
if (!m_Readonly) if (!m_Readonly)
@@ -131,8 +133,8 @@ namespace N_LogView
setItem(a_rowIndex, 0, decItem); setItem(a_rowIndex, 0, decItem);
} }
// hexadecimal
QTableWidgetItem *hexItem = item(a_rowIndex, 1); QTableWidgetItem* hexItem = item(a_rowIndex, 1);
if (!hexItem) if (!hexItem)
{ {
hexItem = new QTableWidgetItem(); hexItem = new QTableWidgetItem();
@@ -142,10 +144,10 @@ namespace N_LogView
setItem(a_rowIndex, 1, hexItem); setItem(a_rowIndex, 1, hexItem);
} }
// binary
if (!m_IsFloat) if (!m_IsFloat)
{ {
QTableWidgetItem *binItem = item(a_rowIndex, 2); QTableWidgetItem* binItem = item(a_rowIndex, 2);
if (!binItem) if (!binItem)
{ {
binItem = new QTableWidgetItem(); binItem = new QTableWidgetItem();
@@ -156,18 +158,17 @@ namespace N_LogView
} }
} }
// set the values
checkAndOvertakeContent(decItem); checkAndOvertakeContent(decItem);
makePretty(); makePretty();
} }
} }
// ---------------------------------------------------------------
void LogViewTableWidget::checkAndOvertakeContent(QTableWidgetItem *a_changedItem) void LogViewTableWidget::checkAndOvertakeContent(QTableWidgetItem* a_changedItem)
{ {
if (a_changedItem->column() != 0) if (a_changedItem->column() != 0) return;
return;
int row = a_changedItem->row(); int row = a_changedItem->row();
QString text = a_changedItem->text(); QString text = a_changedItem->text();
@@ -177,70 +178,67 @@ namespace N_LogView
int64_t intValue = 0; int64_t intValue = 0;
double floatValue = 0.0; double floatValue = 0.0;
// get the calculated and checked value
if (m_IsFloat) if (m_IsFloat)
floatValue = getFloat(text, (uint64_t &)intValue, ok, true); floatValue = getFloat(text, (uint64_t&)intValue, ok, true);
else else
intValue = getInteger(text, ok); intValue = getInteger(text, ok);
// handle errors
if (!ok) if (!ok)
{ {
setFocus(); setFocus();
// selectAll();
setCurrentCell(row, 0); // todo: funktioniert nicht setCurrentCell(row, 0);
return; return;
} }
// set the decimal value
QTableWidgetItem *decField = item(row, 0);
if (decField)
decField->setText(QString::number(m_IsFloat ? floatValue : intValue));
// set the hex value QTableWidgetItem* decField = item(row, 0);
QTableWidgetItem *hexField = item(row, 1); if (decField) decField->setText(QString::number(m_IsFloat ? floatValue : intValue));
if (hexField)
hexField->setText(toHex(intValue));
QTableWidgetItem* hexField = item(row, 1);
if (hexField) hexField->setText(toHex(intValue));
// set the binary value
if (!m_IsFloat) if (!m_IsFloat)
{ {
QTableWidgetItem *binField = item(row, 2); QTableWidgetItem* binField = item(row, 2);
if (binField) if (binField) binField->setText(toBin(intValue));
binField->setText(toBin(intValue));
}
} }
}
// ---------------------------------------------------------------
void LogViewTableWidget::makePretty() void LogViewTableWidget::makePretty()
{ {
//horizontalHeader()->setResizeMode(2, QHeaderView::Stretch);
resizeColumnsToContents(); resizeColumnsToContents();
resizeRowsToContents(); resizeRowsToContents();
// set the height of table-widget
//// QWidget* cellWdg = tableWidget->cellWidget(0, 0);
// int showRows = 7;
// if (m_Field->getValueListSize() < (showRows-1))
// {
// showRows = m_Field->getValueListSize()+1;
// setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
// }
// else
// {
// setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
// }
// setFixedHeight(showRows*tableWidget->rowHeight(0));
}
// ---------------------------------------------------------------
// Writes the content into telegram.
// Returns true if successful.
// ---------------------------------------------------------------
bool LogViewTableWidget::saveContent(LogViewTelegram *a_telegram)
{
}
bool LogViewTableWidget::saveContent(LogViewTelegram* a_telegram)
{
if (!isValid()) if (!isValid())
return false; return false;
@@ -272,20 +270,20 @@ namespace N_LogView
{ {
arraySize = rowCount(); arraySize = rowCount();
a_telegram->setUIntX(LogViewTelegram::SIZE_CENTRAL_DYN_ARRAY_SIZE, arraySize); a_telegram->setUIntX(LogViewTelegram::SIZE_CENTRAL_DYN_ARRAY_SIZE, arraySize);
// fixme: bei vielen Telegrammen muss Länge auf die Länge des Textes gesetzt werden. Dies kann nicht automatisch gemacht werden. Aber vielleicht kann man schauen, ob vor dem dyn. Array ein Feld Länge vorkommt, oder hartcodieren, oder konfigurierbaren
} }
else else
{ {
// todo: teste mit opaque[]
arraySize = m_Field->maxArraySize(); arraySize = m_Field->maxArraySize();
} }
// copy the data
INFO_LOG(m_logger) << "arraySize=" << arraySize; INFO_LOG(m_logger) << "arraySize=" << arraySize;
for (int i = 0; i < arraySize; i++) for (int i = 0; i < arraySize; i++)
{ {
if (m_IsEnum) if (m_IsEnum)
{ {
LogViewEnumEdit *enumEdit = dynamic_cast<LogViewEnumEdit *>(cellWidget(i, 0)); LogViewEnumEdit *enumEdit = dynamic_cast<LogViewEnumEdit*>(cellWidget(i,0));
enumEdit->saveContent(a_telegram); enumEdit->saveContent(a_telegram);
} }
else else
@@ -298,7 +296,7 @@ namespace N_LogView
} }
else else
{ {
const LogViewXdrStandardType *stdType = static_cast<const LogViewXdrStandardType *>(m_Field->xdrElement()); const LogViewXdrStandardType *stdType = static_cast<const LogViewXdrStandardType*>(m_Field->xdrElement());
LogViewXdrStandardType::E_ByteOrder byteOrder = stdType->getByteOrder(); LogViewXdrStandardType::E_ByteOrder byteOrder = stdType->getByteOrder();
uint64_t hex; uint64_t hex;
getFloat(text, hex, m_Valid); getFloat(text, hex, m_Valid);
@@ -308,6 +306,6 @@ namespace N_LogView
} }
return true; return true;
} }
} // namespace N_LogView }
@@ -1,59 +1,46 @@
// **************************************************************************
//
// (C) Copyright 2009 Swiss SIMTEC AG
//
// **************************************************************************
//
// $HeadURL$
// $LastChangedBy$
// $LastChangedDate$
// $LastChangedRevision$
//
// **************************************************************************
#pragma once #pragma once
#include <QTableWidget> #include <QTableWidget>
#include "LogViewWidget.hpp" #include "LogViewWidget.hpp"
#include "logger.h"
namespace N_LogView namespace N_LogView
{ {
/**
* Used for arrays of data (opaque)
* class LogViewTableWidget : public QTableWidget, public LogViewWidget
* @author alois.wismer
* @version 1.0
* @created 25-Mai-2010 09:34:24
*/
class LogViewTableWidget
: public QTableWidget
, public LogViewWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
LogViewTableWidget(LogViewField *a_field, QWidget *a_parent, const bool a_readonly, NGL::INGLLogger &logger); LogViewTableWidget(LogViewField* a_field, QWidget* a_parent, const bool a_readonly);
/**
* Writes the content into telegram.
* Returns true if successful. bool saveContent(LogViewTelegram* a_telegram) override;
*
* @param a_telegram
*/
bool saveContent(LogViewTelegram *a_telegram) override;
public slots: public slots:
void changeSize(const int a_newSize); void changeSize(const int a_newSize);
protected: protected:
void changeRow(const int a_rowIndex, const QString &a_value); void changeRow(const int a_rowIndex, const QString& a_value);
void makePretty(); void makePretty();
protected slots: protected slots:
void checkAndOvertakeContent(QTableWidgetItem *a_changedItem); void checkAndOvertakeContent(QTableWidgetItem* a_changedItem);
private: private:
bool m_IsFloat; bool m_IsFloat;
bool m_IsEnum; bool m_IsEnum;
NGL::INGLLogger &m_logger;
}; };
} }
@@ -1,15 +1,15 @@
// **************************************************************************
//
// (C) Copyright 2009 Swiss SIMTEC AG
//
// **************************************************************************
//
// $HeadURL$
// $LastChangedBy$
// $LastChangedDate$
// $LastChangedRevision$
//
// **************************************************************************
#pragma once #pragma once
@@ -32,28 +32,14 @@ namespace N_LogView
class LogViewTetraTelegramsParser; class LogViewTetraTelegramsParser;
class LogViewXdrParser; class LogViewXdrParser;
class LogViewXdrType; class LogViewXdrType;
/**
* The header and the data of a logged or a edited telegram.
*
* Writing telegrams:
* 1. allocate a telegram with the constructor LogViewTelegram(N_CoPrtCnv::
* CoPrtCnvLogHeader::e_DestProtocolCentral, telegramId)
* 2. prepare with resetOffset()
* 3. write data with setUIntX()
* 4. finish with setNewSize();
*
* @author alois.wismer
* @version 1.0
* @created 04-Feb-2010 13:15:43
*/
class LogViewTelegram final class LogViewTelegram final
{ {
public: public:
/**
* @author alois.wismer
* @version 1.0
* @created 12-Mrz-2010 11:04:14
*/
enum E_Validity enum E_Validity
{ {
e_NotYetEvaluated, e_NotYetEvaluated,
@@ -61,11 +47,8 @@ namespace N_LogView
e_Invalid e_Invalid
}; };
/**
* @author alois.wismer
* @version 1.0
* @created 05-Mai-2010 09:07:22
*/
enum E_Column enum E_Column
{ {
e_ColName, e_ColName,
@@ -78,83 +61,55 @@ namespace N_LogView
~LogViewTelegram(); ~LogViewTelegram();
/**
* The size of the field which defines the size of the dyn. array for central-
* telegrams
*/
static const uint16_t SIZE_CENTRAL_DYN_ARRAY_SIZE; static const uint16_t SIZE_CENTRAL_DYN_ARRAY_SIZE;
/**
* Copy ctor
*/
LogViewTelegram(const LogViewTelegram &o); LogViewTelegram(const LogViewTelegram &o);
// no assignment (needed)
LogViewTelegram &operator=(const LogViewTelegram &o) = delete; LogViewTelegram &operator=(const LogViewTelegram &o) = delete;
/**
* Constructor for new telegrams (only receive central-telegrams are allowd),
* which will be edited
*
* @param a_destination
* @param a_telId
*/
LogViewTelegram(const N_CoPrtCnv::CoPrtCnvLogHeader::E_CoPrtCnvProtocol a_destination, int telegramId);
/**
* Constructor for existing telegrams
*
* @param a_destination
* @param a_unixTime
* @param a_telegramData
* @param a_telegramSize
*/
LogViewTelegram(const N_CoPrtCnv::CoPrtCnvLogHeader::E_CoPrtCnvProtocol a_destination, const quint64 a_unixTime, const QByteArray &a_telegramData);
/** LogViewTelegram(const N_CoPrtCnv::CoPrtCnvLogHeader::E_CoPrtCnvProtocol a_destination,
* Writes a_value with size a_size at actual position of m_Data (given with int telegramId);
* m_ActOffset). m_ActOffset will be updated after writing data.
* If the size of m_Data is not big enough, it will be made bigger.
*
* @param a_size LogViewTelegram(const N_CoPrtCnv::CoPrtCnvLogHeader::E_CoPrtCnvProtocol a_destination,
* @param a_value const quint64 a_unixTime,
* @param a_byteOrder const QByteArray &a_telegramData);
*/
void setUIntX(const uint8_t a_size, quint64 a_value, const LogViewXdrStandardType::E_ByteOrder a_byteOrder = LogViewXdrStandardType::e_ByteOrderBigEndian);
void setUIntX(const uint8_t a_size,
quint64 a_value,
const LogViewXdrStandardType::E_ByteOrder a_byteOrder = LogViewXdrStandardType::e_ByteOrderBigEndian);
/**
* Returns true if a_data could be written.
* Returns false if a_offset is outside of range and therefore a_data could not be
* written.
*
* @param a_offset
* @param a_data
*/
bool setData(const uint16_t a_offset, const uint8_t a_data); bool setData(const uint16_t a_offset, const uint8_t a_data);
/**
* Returns the log-time of the telegram
*/
quint64 getLogTime() const { return m_LogTime; } quint64 getLogTime() const { return m_LogTime; }
quint64 getLogTimeMsec() const; quint64 getLogTimeMsec() const;
/**
* Returns the log-time of the telegram as pretty formatted text
*/
QString getLogTimeText() const; QString getLogTimeText() const;
QString getDestinationText() const; QString getDestinationText() const;
/**
* Returns the gps-time of the telegram
*/
quint64 getGpsTime() const { return m_GpsTime; } quint64 getGpsTime() const { return m_GpsTime; }
/**
* Returns the GPS-time of the telegram as pretty formatted text. Only telegrams
* from TETRA to central have a GPS-time, for all other telegrams an empty string
* will be returned.
*/
QString getGpsTimeText() const; QString getGpsTimeText() const;
@@ -163,26 +118,19 @@ namespace N_LogView
int getParticipantId() const { return m_ParticipantId; } int getParticipantId() const { return m_ParticipantId; }
/**
* Returns the difference between GPS-time and log-time in seconds. Only telegrams
* from TETRA to central have a GPS-time (and therefore only for this telegrams a
* time-difference can be calculated), for all other telegrams 0 will be returned.
*/
int32_t getDelay() const; int32_t getDelay() const;
/**
* Returns the tool-tip text for the with a_col defined column for this telegram.
* Its content depends on the type and subtype of telegram.
*
* @param a_col
*/
QString getToolTipText(const E_Column a_col); QString getToolTipText(const E_Column a_col);
void resetOffset(); void resetOffset();
LogViewField *getFieldTree(); LogViewField* getFieldTree();
void dump() const; void dump() const;
@@ -210,46 +158,34 @@ namespace N_LogView
bool isJsonTelegram() const { return N_CoPrtCnv::CoPrtCnvLogHeader::e_DestProtocolCentral == m_Protocol; } bool isJsonTelegram() const { return N_CoPrtCnv::CoPrtCnvLogHeader::e_DestProtocolCentral == m_Protocol; }
void clearJsonData() { m_json.remove(QStringLiteral("data")); } void clearJsonData() { m_json.remove(QStringLiteral("data")); }
void rebuildJsonString() void rebuildJsonString() { if (!m_json.isEmpty()) m_data.clear(); }
{
if (!m_json.isEmpty())
m_data.clear();
}
void setJsonValue(const QStringList &path, const QJsonValue &val); void setJsonValue(const QStringList &path, const QJsonValue &val);
QJsonObject jsonData() const { return m_json; } QJsonObject jsonData() const { return m_json; }
void updateJsonValue(const QStringList &path, const QJsonValue &newVal, QJsonObject &obj); void updateJsonValue(const QStringList &path, const QJsonValue &newVal, QJsonObject &obj);
void updateJsonValue(const QStringList &path, const QJsonValue &newVal, QJsonArray &arr); void updateJsonValue(const QStringList &path, const QJsonValue &newVal, QJsonArray &arr);
const N_CoPrtCnv::CoPrtCnvRadioTelegram *getTetraTelegram() const; const N_CoPrtCnv::CoPrtCnvRadioTelegram* getTetraTelegram() const;
static LogViewTetraTelegramsParser *jsonParser(); static LogViewTetraTelegramsParser *jsonParser();
static LogViewXdrParser *tetraParser(); static LogViewXdrParser *tetraParser();
QByteArray getData(QJsonDocument::JsonFormat format = QJsonDocument::JsonFormat::Compact) const; QByteArray getData(QJsonDocument::JsonFormat format = QJsonDocument::JsonFormat::Compact) const;
/**
* The time to wait after sending this telegram in milliseconds.
*/
uint32_t getWaitTime() const { return m_WaitTime; } uint32_t getWaitTime() const { return m_WaitTime; }
/**
* The time to wait after sending this telegram in milliseconds.
*
* @param newVal
*/
void setWaitTime(uint32_t newVal) { m_WaitTime = newVal; } void setWaitTime(uint32_t newVal) { m_WaitTime = newVal; }
/**
* The name of the telegram, shown in edit-list
*/
QString getName() const { return m_Name; } QString getName() const { return m_Name; }
/**
* The name of the telegram, shown in edit-list
*
* @param newVal
*/
void setName(const QString &newVal) { m_Name = newVal; } void setName(const QString &newVal) { m_Name = newVal; }
@@ -261,9 +197,8 @@ namespace N_LogView
void actualizeGpsTime(); void actualizeGpsTime();
/**
* Create the tooltip text for the column 'Name'
*/
void createToolTipTextForColName(); void createToolTipTextForColName();
@@ -273,40 +208,32 @@ namespace N_LogView
static uint32_t floatToXdr(float in); static uint32_t floatToXdr(float in);
protected: protected:
/**
* The name of the telegram, shown in edit-list
*/
QString m_Name; QString m_Name;
/**
* The tooltip text for caching purposes
*/
std::vector<QString> m_ToolTipText; std::vector<QString> m_ToolTipText;
/**
* The time to wait after sending this telegram in milliseconds.
*/
uint32_t m_WaitTime; uint32_t m_WaitTime;
int m_ParticipantId; int m_ParticipantId;
/**
* The ISSI of TETRA-Protocol
*/
uint32_t m_ISSI; uint32_t m_ISSI;
/**
* The allocated size of m_Data. (Used for optimizing of speed)
*/
int m_AllocatedSize; int m_AllocatedSize;
static const LogViewXdrParser *m_Parser; static const LogViewXdrParser* m_Parser;
uint16_t m_ActOffset; uint16_t m_ActOffset;
QVector<uint16_t> m_GpsFieldOffset; QVector<uint16_t> m_GpsFieldOffset;
int m_TelId; int m_TelId;
/**
* used for dyn. array in TETRA-Protocol
*/
uint32_t m_LastUnsignedValue; uint32_t m_LastUnsignedValue;
/**
* This value will be used for the dyn-array-method e_DynArrayMsgLength. This
* value will be subtracted from the message-length to get the size of the dynamic
* array.
*/
uint16_t m_MaxArraySize; uint16_t m_MaxArraySize;
static const uint16_t START_OFFSET_CENTRAL; static const uint16_t START_OFFSET_CENTRAL;
static const uint16_t POS_CENTRAL_COUNTER; static const uint16_t POS_CENTRAL_COUNTER;
@@ -335,14 +262,14 @@ namespace N_LogView
QJsonObject m_json; QJsonObject m_json;
N_CoPrtCnv::CoPrtCnvRadioTelegram *m_TetraTelegram; N_CoPrtCnv::CoPrtCnvRadioTelegram *m_TetraTelegram;
NGL::INGLLogger &m_logger;
LogViewField *getFieldTree(const QString &a_type, LogViewField *getFieldTree(const QString& a_type, const QString& a_name,
const QString &a_name, uint16_t a_arraySize, const LogViewXdrType* a_parentElement = nullptr,
uint16_t a_arraySize,
const LogViewXdrType *a_parentElement = nullptr,
const bool a_hasContent = true); const bool a_hasContent = true);
LogViewField *getFieldTreeJson(const QJsonValue &data, const QString &name, const StructInformation &si, const QStringList &objectPathBase); LogViewField *getFieldTreeJson(const QJsonValue &data,
const QString &name,
const StructInformation &si,
const QStringList &objectPathBase);
static void addFieldTreeStruct(const QJsonObject &parentObject, static void addFieldTreeStruct(const QJsonObject &parentObject,
LogViewField *parent, LogViewField *parent,
@@ -374,108 +301,70 @@ namespace N_LogView
static QString typeFromStructInformation(const StructInformation &si, const QString &name); static QString typeFromStructInformation(const StructInformation &si, const QString &name);
static MemberInformation memberFromStructInformation(const StructInformation &si, const QString &name); static MemberInformation memberFromStructInformation(const StructInformation &si, const QString &name);
/**
*
* @param a_offset
*/
uint16_t getUInt16(const uint16_t a_offset) const; uint16_t getUInt16(const uint16_t a_offset) const;
/**
*
* @param a_offset
*/
uint32_t getUInt32(const uint16_t a_offset) const; uint32_t getUInt32(const uint16_t a_offset) const;
/**
*
* @param a_offset
*/
int32_t getInt32(const uint16_t a_offset) const; int32_t getInt32(const uint16_t a_offset) const;
/**
*
* @param a_offset
* @param a_size
* @param a_byteOrder
*/
quint64 getUIntX(const uint16_t a_offset,
const uint8_t a_size,
const LogViewXdrStandardType::E_ByteOrder a_byteOrder = LogViewXdrStandardType::e_ByteOrderBigEndian) const;
/**
*
* @param a_offset
* @param a_size
* @param a_byteOrder
*/
int32_t getSIntX(const uint16_t a_offset,
const uint8_t a_size,
const LogViewXdrStandardType::E_ByteOrder a_byteOrder = LogViewXdrStandardType::e_ByteOrderBigEndian) const;
/** quint64 getUIntX(const uint16_t a_offset, const uint8_t a_size, const LogViewXdrStandardType::E_ByteOrder a_byteOrder = LogViewXdrStandardType::e_ByteOrderBigEndian) const;
*
* @param a_offset
* @param a_size
*/ int32_t getSIntX(const uint16_t a_offset, const uint8_t a_size, const LogViewXdrStandardType::E_ByteOrder a_byteOrder = LogViewXdrStandardType::e_ByteOrderBigEndian) const;
char getChar(const uint16_t a_offset, const uint8_t a_size) const; char getChar(const uint16_t a_offset, const uint8_t a_size) const;
/**
*
* @param a_standardType
* @param a_offset
* @param a_arraySize
*/
LogViewField *getContent(const LogViewXdrStandardType *a_standardType, uint16_t &a_offset, const uint16_t a_arraySize);
/**
*
* @param a_xdrType
*/
bool isScalar(const LogViewXdrType *a_xdrType) const;
/** LogViewField* getContent(const LogViewXdrStandardType* a_standardType, uint16_t& a_offset, const uint16_t a_arraySize);
*
* @param a_errorText
* @param a_title
*/
void showMessageBox(const QString &a_errorText, const QString &a_title = QObject::tr("Invalid telegram")) const;
/**
*
* @param a_offset
*/
uint16_t getDynArraySize(uint16_t &a_offset) const;
/**
*
* @param a_name
* @param a_value
*/
static QString formatToolTipLine(const QString &a_name, const uint32_t a_value) { return formatToolTipLine(a_name, QString::number(a_value), a_value); }
/** bool isScalar(const LogViewXdrType* a_xdrType) const;
*
* @param a_name
* @param a_text
* @param a_value
*/
static QString formatToolTipLine(const QString &a_name, const QString &a_text, const uint32_t a_value);
static QString formatToolTipLine(const QString &a_name, const std::string &a_text, const uint32_t a_value)
void showMessageBox(const QString& a_errorText, const QString& a_title = QObject::tr("Invalid telegram")) const;
uint16_t getDynArraySize(uint16_t& a_offset) const;
static QString formatToolTipLine(const QString& a_name, const uint32_t a_value)
{
return formatToolTipLine(a_name, QString::number(a_value), a_value);
}
static QString formatToolTipLine(const QString& a_name, const QString& a_text, const uint32_t a_value);
static QString formatToolTipLine(const QString& a_name, const std::string& a_text, const uint32_t a_value)
{ {
return formatToolTipLine(a_name, QString::fromStdString(a_text), a_value); return formatToolTipLine(a_name, QString::fromStdString(a_text), a_value);
} }
/**
* returns the data-byte at a_offset. Returns 0 if a_offset is outside of range.
*
* @param a_offset
*/
uint8_t getData(const uint16_t a_offset) const; uint8_t getData(const uint16_t a_offset) const;
private: private:
NGL::INGLLogger &m_logger; NGL::INGLLogger &m_logger;
friend class LogViewTabWidget; friend class LogViewTabWidget;
}; };
} }
@@ -1,10 +1,5 @@
/**
* @RDE_HEADER@
* some models for LogViewGui
* $Id$
* $HeadURL$
* $Author$
*/
#include "LogViewTelegramEditModel.hpp" #include "LogViewTelegramEditModel.hpp"
#include <algorithm> #include <algorithm>
@@ -12,21 +7,21 @@
namespace N_LogView namespace N_LogView
{ {
// ---------------------------------------------------------------
int TelegramEditModel::rowCount(const QModelIndex &parent) const int TelegramEditModel::rowCount(const QModelIndex &parent) const
{ {
return parent.isValid() ? 0 : m_telegrams.size(); return parent.isValid() ? 0 : m_telegrams.size();
} }
// ---------------------------------------------------------------
int TelegramEditModel::columnCount(const QModelIndex &parent) const int TelegramEditModel::columnCount(const QModelIndex &parent) const
{ {
return parent.isValid() ? 0 : 3; return parent.isValid() ? 0 : 3;
} }
// ---------------------------------------------------------------
QVariant TelegramEditModel::data(const QModelIndex &index, int role) const QVariant TelegramEditModel::data(const QModelIndex &index, int role) const
{ {
if (index.isValid() && index.row() < m_telegrams.size()) if (index.isValid() && index.row() < m_telegrams.size())
{ {
if (role == Qt::DisplayRole) if (role == Qt::DisplayRole)
@@ -50,11 +45,13 @@ namespace N_LogView
} }
} }
return QVariant(); return QVariant();
} }
// ---------------------------------------------------------------
QVariant TelegramEditModel::headerData(int section, Qt::Orientation orientation, int role) const QVariant TelegramEditModel::headerData(int section,
{ Qt::Orientation orientation,
int role) const
{
if (orientation == Qt::Horizontal && role == Qt::DisplayRole) if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
{ {
switch (section) switch (section)
@@ -70,97 +67,97 @@ namespace N_LogView
} }
} }
return QAbstractTableModel::headerData(section, orientation, role); return QAbstractTableModel::headerData(section, orientation, role);
} }
// ---------------------------------------------------------------
void TelegramEditModel::clearTelegrams() void TelegramEditModel::clearTelegrams()
{ {
beginResetModel(); beginResetModel();
m_telegrams.clear(); m_telegrams.clear();
endResetModel(); endResetModel();
} }
// ---------------------------------------------------------------
void TelegramEditModel::appendTelegrams(const QVector<QSharedPointer<LogViewTelegram>> &telegrams) void TelegramEditModel::appendTelegrams(const QVector<QSharedPointer<LogViewTelegram> > &telegrams)
{ {
if (telegrams.isEmpty()) if (telegrams.isEmpty())
return; return;
beginInsertRows(QModelIndex(), m_telegrams.size(), m_telegrams.size() + telegrams.size() - 1); beginInsertRows(QModelIndex(), m_telegrams.size(), m_telegrams.size() + telegrams.size() - 1);
m_telegrams += telegrams; m_telegrams += telegrams;
endInsertRows(); endInsertRows();
} }
// ---------------------------------------------------------------
int TelegramEditModel::appendTelegram(const QSharedPointer<LogViewTelegram> &telegram) int TelegramEditModel::appendTelegram(const QSharedPointer<LogViewTelegram> &telegram)
{ {
beginInsertRows(QModelIndex(), m_telegrams.size(), m_telegrams.size()); beginInsertRows(QModelIndex(), m_telegrams.size(), m_telegrams.size());
m_telegrams.push_back(telegram); m_telegrams.push_back(telegram);
telegram->rebuildJsonString(); telegram->rebuildJsonString();
endInsertRows(); endInsertRows();
return m_telegrams.size() - 1; // row return m_telegrams.size() - 1;
} }
// ---------------------------------------------------------------
QSharedPointer<LogViewTelegram> TelegramEditModel::telegram(int row) const QSharedPointer<LogViewTelegram> TelegramEditModel::telegram(int row) const
{ {
if (row >= 0 && row < m_telegrams.size()) if (row >= 0 && row < m_telegrams.size())
return m_telegrams.at(row); return m_telegrams.at(row);
return QSharedPointer<LogViewTelegram>(); return QSharedPointer<LogViewTelegram>();
} }
// ---------------------------------------------------------------
bool TelegramEditModel::moveUp(int row) bool TelegramEditModel::moveUp(int row)
{ {
if (row <= 0 || row >= m_telegrams.size()) if (row <= 0 || row >= m_telegrams.size())
return false; return false;
beginMoveRows(QModelIndex(), row, row, QModelIndex(), row - 1); beginMoveRows(QModelIndex(), row, row, QModelIndex(), row - 1);
std::swap(m_telegrams[row], m_telegrams[row - 1]); std::swap(m_telegrams[row], m_telegrams[row - 1]);
endMoveRows(); endMoveRows();
return true; return true;
} }
// ---------------------------------------------------------------
bool TelegramEditModel::moveDown(int row) bool TelegramEditModel::moveDown(int row)
{ {
if (row >= (m_telegrams.size() - 1)) if (row >= (m_telegrams.size() - 1))
return false; return false;
beginMoveRows(QModelIndex(), row, row, QModelIndex(), row + 1); beginMoveRows(QModelIndex(), row, row, QModelIndex(), row + 1);
std::swap(m_telegrams[row], m_telegrams[row + 1]); std::swap(m_telegrams[row], m_telegrams[row + 1]);
endMoveRows(); endMoveRows();
return true; return true;
} }
// ---------------------------------------------------------------
void TelegramEditModel::emitDataChanged(int row) void TelegramEditModel::emitDataChanged(int row)
{ {
QModelIndex top = createIndex(row, 0); QModelIndex top = createIndex(row, 0);
QModelIndex bottom = createIndex(row, columnCount() - 1); QModelIndex bottom = createIndex(row, columnCount() - 1);
emit dataChanged(top, bottom, {Qt::DisplayRole, Qt::ToolTipRole}); emit dataChanged(top, bottom, {Qt::DisplayRole, Qt::ToolTipRole});
} }
// ---------------------------------------------------------------
void TelegramEditModel::removeTelegrams(const QSet<int> &rows) void TelegramEditModel::removeTelegrams(const QSet<int> &rows)
{ {
QList<int> rowList = rows.values(); QList<int> rowList = rows.values();
std::sort(rowList.begin(), rowList.end()); std::sort(rowList.begin(), rowList.end());
// von oben her löschen um ein Verschieben der Indizes zu vermeiden
for (int i = rowList.size() - 1; i >= 0; --i) for (int i = rowList.size() - 1 ; i >= 0; --i)
{ {
int row = rowList.at(i); int row = rowList.at(i);
beginRemoveRows(QModelIndex(), row, row); beginRemoveRows(QModelIndex(), row, row);
m_telegrams.remove(row); m_telegrams.remove(row);
endRemoveRows(); endRemoveRows();
} }
} }
// ---------------------------------------------------------------
void TelegramEditModel::pasteRows(int row, const QSharedPointer<LogViewTelegram> &tele) void TelegramEditModel::pasteRows(int row, const QSharedPointer<LogViewTelegram> &tele)
{ {
if (row < 0 || row > m_telegrams.size()) if (row < 0 || row > m_telegrams.size())
return; return;
beginInsertRows(QModelIndex(), row, row); beginInsertRows(QModelIndex(), row, row);
m_telegrams.insert(row, QSharedPointer<LogViewTelegram>(new LogViewTelegram(*tele.data()))); m_telegrams.insert(row, QSharedPointer<LogViewTelegram>(new LogViewTelegram(*tele.data())));
endInsertRows(); endInsertRows();
} }
} // namespace N_LogView }
@@ -1,10 +1,5 @@
/**
* @RDE_HEADER@
* some models for LogViewGui
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once #pragma once
@@ -15,10 +10,10 @@
namespace N_LogView namespace N_LogView
{ {
class TelegramEditModel final : public QAbstractTableModel class TelegramEditModel final : public QAbstractTableModel
{ {
Q_OBJECT Q_OBJECT
public: public:
using QAbstractTableModel::QAbstractTableModel; using QAbstractTableModel::QAbstractTableModel;
int rowCount(const QModelIndex &parent = QModelIndex()) const override; int rowCount(const QModelIndex &parent = QModelIndex()) const override;
@@ -26,10 +21,11 @@ namespace N_LogView
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const override;
void clearTelegrams(); void clearTelegrams();
void appendTelegrams(const QVector<QSharedPointer<LogViewTelegram>> &telegrams); void appendTelegrams(const QVector<QSharedPointer<LogViewTelegram> > &telegrams);
int appendTelegram(const QSharedPointer<LogViewTelegram> &telegram); int appendTelegram(const QSharedPointer<LogViewTelegram> &telegram);
QSharedPointer<LogViewTelegram> telegram(int row) const; QSharedPointer<LogViewTelegram> telegram(int row) const;
@@ -41,8 +37,8 @@ namespace N_LogView
void removeTelegrams(const QSet<int> &rows); void removeTelegrams(const QSet<int> &rows);
void pasteRows(int row, const QSharedPointer<LogViewTelegram> &tele); void pasteRows(int row, const QSharedPointer<LogViewTelegram> &tele);
protected:
QVector<QSharedPointer<LogViewTelegram> > m_telegrams;
protected: };
QVector<QSharedPointer<LogViewTelegram>> m_telegrams;
};
} }
@@ -1,15 +1,15 @@
// **************************************************************************
//
// (C) Copyright 2009 Swiss SIMTEC AG
//
// **************************************************************************
//
// $HeadURL$
// $LastChangedBy$
// $LastChangedDate$
// $LastChangedRevision$
//
// **************************************************************************
#include "LogViewTelegramSelectionDialog.hpp" #include "LogViewTelegramSelectionDialog.hpp"
#include <QtWidgets/QLabel> #include <QtWidgets/QLabel>
@@ -22,19 +22,19 @@
namespace N_LogView namespace N_LogView
{ {
static int s_currentRow = 0; static int s_currentRow = 0;
// ---------------------------------------------------------------
LogViewTelegramSelectionDialog::LogViewTelegramSelectionDialog(QWidget *a_parent) LogViewTelegramSelectionDialog::LogViewTelegramSelectionDialog(QWidget* a_parent)
: QDialog(a_parent) : QDialog(a_parent)
{ {
setMinimumSize(QSize(600, 500)); setMinimumSize(QSize(600, 500));
QVBoxLayout *layout = new QVBoxLayout; QVBoxLayout* layout = new QVBoxLayout;
layout->addWidget(new QLabel(tr("Select a telegram:"))); layout->addWidget(new QLabel(tr("Select a telegram:")));
m_TelegramList = new QListWidget(this); m_TelegramList = new QListWidget(this);
const auto telegramMap = LogViewTelegram::jsonParser()->telegramsToCreate(); const auto telegramMap = LogViewTelegram::jsonParser()->telegramsToCreate();
for (auto it = telegramMap.cbegin(); it != telegramMap.cend(); ++it) for (auto it = telegramMap.cbegin(); it != telegramMap.cend(); ++it)
{ {
if (it.key() == 0) // ACK if (it.key() == 0)
continue; continue;
auto lwi = new QListWidgetItem(it.value() + QStringLiteral(" (%1)").arg(it.key())); auto lwi = new QListWidgetItem(it.value() + QStringLiteral(" (%1)").arg(it.key()));
lwi->setData(Qt::UserRole, it.key()); lwi->setData(Qt::UserRole, it.key());
@@ -43,19 +43,20 @@ namespace N_LogView
m_TelegramList->sortItems(); m_TelegramList->sortItems();
m_TelegramList->setCurrentRow(s_currentRow); m_TelegramList->setCurrentRow(s_currentRow);
connect(m_TelegramList, &QListWidget::itemActivated, this, &LogViewTelegramSelectionDialog::selectTelegram); connect(m_TelegramList, &QListWidget::itemActivated,
this, &LogViewTelegramSelectionDialog::selectTelegram);
layout->addWidget(m_TelegramList); layout->addWidget(m_TelegramList);
setLayout(layout); setLayout(layout);
} }
// ---------------------------------------------------------------
void LogViewTelegramSelectionDialog::selectTelegram(QListWidgetItem *a_telegramItem) void LogViewTelegramSelectionDialog::selectTelegram(QListWidgetItem* a_telegramItem)
{ {
s_currentRow = m_TelegramList->currentRow(); s_currentRow = m_TelegramList->currentRow();
m_SelectedTelegramId = a_telegramItem->data(Qt::UserRole).toInt(); m_SelectedTelegramId = a_telegramItem->data(Qt::UserRole).toInt();
accept(); accept();
} }
} // namespace N_LogView }
@@ -1,15 +1,15 @@
// **************************************************************************
//
// (C) Copyright 2009 Swiss SIMTEC AG
//
// **************************************************************************
//
// $HeadURL$
// $LastChangedBy$
// $LastChangedDate$
// $LastChangedRevision$
//
// **************************************************************************
#pragma once #pragma once
@@ -19,34 +19,28 @@ class QListWidgetItem;
namespace N_LogView namespace N_LogView
{ {
/**
* @author alois.wismer
* @version 1.0
* @created 05-Mai-2010 17:24:14
*/
class LogViewTelegramSelectionDialog : public QDialog class LogViewTelegramSelectionDialog : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
/**
*
* @param a_parent explicit LogViewTelegramSelectionDialog(QWidget* a_parent);
*/
explicit LogViewTelegramSelectionDialog(QWidget *a_parent);
int getSelectedTelegramId() const { return m_SelectedTelegramId; } int getSelectedTelegramId() const { return m_SelectedTelegramId; }
protected slots: protected slots:
/**
*
* @param a_telegramItem void selectTelegram(QListWidgetItem* a_telegramItem);
*/
void selectTelegram(QListWidgetItem *a_telegramItem);
protected: protected:
QListWidget *m_TelegramList; QListWidget *m_TelegramList;
int m_SelectedTelegramId; int m_SelectedTelegramId;
}; };
} }
@@ -1,15 +1,15 @@
// **************************************************************************
//
// (C) Copyright 2009 Swiss SIMTEC AG
//
// **************************************************************************
//
// $HeadURL$
// $LastChangedBy$
// $LastChangedDate$
// $LastChangedRevision$
//
// **************************************************************************
#include "LogViewTextEdit.hpp" #include "LogViewTextEdit.hpp"
#include "LogViewField.hpp" #include "LogViewField.hpp"
@@ -18,11 +18,11 @@
namespace N_LogView namespace N_LogView
{ {
// ---------------------------------------------------------------
LogViewTextEdit::LogViewTextEdit(LogViewField *a_field, QWidget *a_parent, const bool a_readonly) LogViewTextEdit::LogViewTextEdit(LogViewField* a_field, QWidget* a_parent, const bool a_readonly)
: QLineEdit(a_parent) : QLineEdit(a_parent)
, LogViewWidget(a_field, this, a_parent, a_readonly) , LogViewWidget(a_field, this, a_parent, a_readonly)
{ {
const QString value = a_field->value(0); const QString value = a_field->value(0);
setText(value); setText(value);
@@ -32,12 +32,12 @@ namespace N_LogView
setAlignment(a_field->isRightAligned() ? Qt::AlignRight : Qt::AlignLeft); setAlignment(a_field->isRightAligned() ? Qt::AlignRight : Qt::AlignLeft);
} }
// set a validator for number of chars
uint16_t maxArraySize = a_field->maxArraySize(); uint16_t maxArraySize = a_field->maxArraySize();
setMaxLength(maxArraySize); setMaxLength(maxArraySize);
updateToolTip(value); updateToolTip(value);
// make proper width of widget
QFontMetrics fm(font()); QFontMetrics fm(font());
#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0) #if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
setMinimumWidth(fm.width(QLatin1Char(' ') + value + QLatin1Char(' '))); setMinimumWidth(fm.width(QLatin1Char(' ') + value + QLatin1Char(' ')));
@@ -45,24 +45,25 @@ namespace N_LogView
setMinimumWidth(fm.horizontalAdvance(QLatin1Char(' ') + value + QLatin1Char(' '))); setMinimumWidth(fm.horizontalAdvance(QLatin1Char(' ') + value + QLatin1Char(' ')));
#endif #endif
// connect signals
connect(this, &LogViewTextEdit::editingFinished, this, &LogViewTextEdit::checkAndOvertakeContent); connect(this, &LogViewTextEdit::editingFinished,
} this, &LogViewTextEdit::checkAndOvertakeContent);
}
// ---------------------------------------------------------------
void LogViewTextEdit::checkAndOvertakeContent() void LogViewTextEdit::checkAndOvertakeContent()
{ {
updateToolTip(text()); // fixme nach jedem zeichen updaten updateToolTip(text());
m_Valid = true; m_Valid = true;
} }
// ---------------------------------------------------------------
// Writes the content into telegram.
// Returns true if successful.
// ---------------------------------------------------------------
bool LogViewTextEdit::saveContent(LogViewTelegram *a_telegram) bool LogViewTextEdit::saveContent(LogViewTelegram* a_telegram)
{ {
if (!isValid()) if (!isValid())
return false; return false;
if (a_telegram->isJsonTelegram()) if (a_telegram->isJsonTelegram())
@@ -78,18 +79,18 @@ namespace N_LogView
{ {
arraySize = content.length(); arraySize = content.length();
a_telegram->setUIntX(LogViewTelegram::SIZE_CENTRAL_DYN_ARRAY_SIZE, arraySize); a_telegram->setUIntX(LogViewTelegram::SIZE_CENTRAL_DYN_ARRAY_SIZE, arraySize);
// fixme: bei vielen Telegrammen muss Länge auf die Länge des Textes gesetzt werden. Dies kann nicht automatisch gemacht werden. Aber vielleicht kann man schauen, ob vor dem dyn. Array ein Feld Länge vorkommt, oder hartcodieren, oder konfigurierbaren
} }
else else
{ {
arraySize = m_Field->maxArraySize(); arraySize = m_Field->maxArraySize();
} }
// copy the text
for (int i = 0; i < arraySize; i++) for (int i = 0; i < arraySize; i++)
a_telegram->setUIntX(size, i < content.length() ? content[i].toLatin1() : 0); a_telegram->setUIntX(size, i < content.length() ? content[i].toLatin1() : 0);
} }
return true; return true;
} }
} // namespace N_LogView }
@@ -1,15 +1,15 @@
// **************************************************************************
//
// (C) Copyright 2009 Swiss SIMTEC AG
//
// **************************************************************************
//
// $HeadURL$
// $LastChangedBy$
// $LastChangedDate$
// $LastChangedRevision$
//
// **************************************************************************
#pragma once #pragma once
@@ -18,37 +18,23 @@
namespace N_LogView namespace N_LogView
{ {
/**
* Used for arrays of char and string.
* class LogViewTextEdit : public QLineEdit, public LogViewWidget
* @author alois.wismer
* @version 1.0
* @created 21-Mai-2010 10:28:05
*/
class LogViewTextEdit
: public QLineEdit
, public LogViewWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
/**
*
* @param a_field
* @param a_parent
* @param a_readonly
*/
LogViewTextEdit(LogViewField *a_field, QWidget *a_parent, const bool a_readonly);
/**
* Writes the content into telegram. LogViewTextEdit(LogViewField* a_field, QWidget* a_parent, const bool a_readonly);
* Returns true if successful.
*
* @param a_telegram
*/ bool saveContent(LogViewTelegram* a_telegram) override;
bool saveContent(LogViewTelegram *a_telegram) override;
protected slots: protected slots:
void checkAndOvertakeContent(); void checkAndOvertakeContent();
}; };
} }
@@ -1,15 +1,15 @@
// **************************************************************************
//
// (C) Copyright 2009 Swiss SIMTEC AG
//
// **************************************************************************
//
// $HeadURL$
// $LastChangedBy$
// $LastChangedDate$
// $LastChangedRevision$
//
// **************************************************************************
#include "LogViewValueEdit.hpp" #include "LogViewValueEdit.hpp"
#include "LogViewField.hpp" #include "LogViewField.hpp"
@@ -18,23 +18,23 @@
namespace N_LogView namespace N_LogView
{ {
// ---------------------------------------------------------------
LogViewValueEdit::LogViewValueEdit(LogViewField *a_field, QWidget *a_parent, const bool a_readonly) LogViewValueEdit::LogViewValueEdit(LogViewField* a_field, QWidget* a_parent, const bool a_readonly)
: QLineEdit(a_parent) : QLineEdit(a_parent)
, LogViewWidget(a_field, this, a_parent, a_readonly) , LogViewWidget(a_field, this, a_parent, a_readonly)
, m_IsFloat(false) , m_IsFloat(false)
{ {
const LogViewXdrStandardType *stdType = static_cast<const LogViewXdrStandardType *>(m_Field->xdrElement()); const LogViewXdrStandardType *stdType = static_cast<const LogViewXdrStandardType*>(m_Field->xdrElement());
m_IsFloat = (LogViewXdrStandardType::e_Float == stdType->getValueKind()); m_IsFloat = (LogViewXdrStandardType::e_Float == stdType->getValueKind());
const QString valueText = a_field->value(0); const QString valueText = a_field->value(0);
setText(valueText); setText(valueText);
// checkAndOvertakeContent();
updateToolTip(valueText); updateToolTip(valueText);
// make proper width of widget
QFontMetrics fm(font()); QFontMetrics fm(font());
#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0) #if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
setMinimumWidth(fm.width(QLatin1Char(' ') + valueText + QLatin1Char(' '))); setMinimumWidth(fm.width(QLatin1Char(' ') + valueText + QLatin1Char(' ')));
@@ -49,54 +49,55 @@ namespace N_LogView
} }
else else
{ {
connect(this, &LogViewValueEdit::editingFinished, this, &LogViewValueEdit::checkAndOvertakeContent); connect(this, &LogViewValueEdit::editingFinished,
} this, &LogViewValueEdit::checkAndOvertakeContent);
} }
}
// ---------------------------------------------------------------
void LogViewValueEdit::checkAndOvertakeContent() void LogViewValueEdit::checkAndOvertakeContent()
{ {
bool ok; bool ok;
int64_t intValue = 0; int64_t intValue = 0;
double floatValue = 0.0; double floatValue = 0.0;
// get the calculated and checked value
if (m_IsFloat) if (m_IsFloat)
floatValue = getFloat(text(), (uint64_t &)intValue, ok); floatValue = getFloat(text(), (uint64_t&)intValue, ok);
else else
intValue = getInteger(text(), ok); intValue = getInteger(text(), ok);
// handle errors
if (!ok) if (!ok)
{ {
setFocus(); setFocus();
selectAll(); selectAll();
return; // abort return;
} }
// update
if (m_IsFloat) if (m_IsFloat)
setText(QString::number(floatValue)); setText(QString::number(floatValue));
else else
setText(QString::number(intValue)); setText(QString::number(intValue));
updateToolTip(text()); updateToolTip(text());
} }
// ---------------------------------------------------------------
// Writes the content into telegram.
// Returns true if successful.
// ---------------------------------------------------------------
bool LogViewValueEdit::saveContent(LogViewTelegram *a_telegram) bool LogViewValueEdit::saveContent(LogViewTelegram* a_telegram)
{ {
if (m_Valid) if (m_Valid)
{ {
bool ok; bool ok;
if (m_IsFloat) if (m_IsFloat)
{ {
// save the float or double-value
uint64_t valueAsUint64; uint64_t valueAsUint64;
const double value = getFloat(text(), valueAsUint64, ok); const double value = getFloat(text(), valueAsUint64, ok);
if (ok) if (ok)
@@ -107,7 +108,7 @@ namespace N_LogView
} }
else else
{ {
const LogViewXdrStandardType *stdType = static_cast<const LogViewXdrStandardType *>(m_Field->xdrElement()); const LogViewXdrStandardType *stdType = static_cast<const LogViewXdrStandardType*>(m_Field->xdrElement());
LogViewXdrStandardType::E_ByteOrder byteOrder = stdType->getByteOrder(); LogViewXdrStandardType::E_ByteOrder byteOrder = stdType->getByteOrder();
a_telegram->setUIntX(getSize(), valueAsUint64, byteOrder); a_telegram->setUIntX(getSize(), valueAsUint64, byteOrder);
} }
@@ -116,7 +117,7 @@ namespace N_LogView
} }
else else
{ {
// save the integer-value
qint64 intValue = getInteger(text(), ok); qint64 intValue = getInteger(text(), ok);
if (ok) if (ok)
{ {
@@ -129,6 +130,6 @@ namespace N_LogView
} }
} }
return false; return false;
} }
} // namespace N_LogView }
@@ -1,15 +1,15 @@
// **************************************************************************
//
// (C) Copyright 2009 Swiss SIMTEC AG
//
// **************************************************************************
//
// $HeadURL$
// $LastChangedBy$
// $LastChangedDate$
// $LastChangedRevision$
//
// **************************************************************************
#pragma once #pragma once
@@ -18,40 +18,27 @@
namespace N_LogView namespace N_LogView
{ {
/**
* Used for scalar signed or unsigned values
* class LogViewValueEdit : public QLineEdit, public LogViewWidget
* @author alois.wismer
* @version 1.0
* @created 20-Mai-2010 14:47:50
*/
class LogViewValueEdit
: public QLineEdit
, public LogViewWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
/**
*
* @param a_field
* @param a_parent
* @param a_readonly
*/
LogViewValueEdit(LogViewField *a_field, QWidget *a_parent, const bool a_readonly);
/**
* Writes the content into telegram. LogViewValueEdit(LogViewField* a_field, QWidget* a_parent, const bool a_readonly);
* Returns true if successful.
*
* @param a_telegram
*/ bool saveContent(LogViewTelegram* a_telegram) override;
bool saveContent(LogViewTelegram *a_telegram) override;
protected: protected:
bool m_IsFloat; bool m_IsFloat;
protected slots: protected slots:
void checkAndOvertakeContent(); void checkAndOvertakeContent();
}; };
} }
@@ -1,43 +1,43 @@
// **************************************************************************
//
// (C) Copyright 2009 Swiss SIMTEC AG
//
// **************************************************************************
//
// $HeadURL$
// $LastChangedBy$
// $LastChangedDate$
// $LastChangedRevision$
//
// **************************************************************************
#include "LogViewXdrElement.hpp" #include "LogViewXdrElement.hpp"
namespace N_LogView namespace N_LogView
{ {
// ---------------------------------------------------------------
// Constructor of a struct or enum
// ---------------------------------------------------------------
LogViewXdrElement::LogViewXdrElement(const QString &a_name, const E_ElementKind a_kind, const char *loggerName) LogViewXdrElement::LogViewXdrElement(const QString& a_name, const E_ElementKind a_kind, const char *loggerName)
: m_Name(a_name) : m_Name(a_name)
, m_Kind(a_kind) , m_Kind(a_kind)
, m_logger(getLogger(loggerName)) , m_logger(getLogger(loggerName))
{ {
if (a_name.indexOf(QLatin1Char('<')) >= 0 || a_name.indexOf(QLatin1Char('[')) >= 0) if (a_name.indexOf(QLatin1Char('<')) >= 0 || a_name.indexOf(QLatin1Char('[')) >= 0)
ERROR_LOG(m_logger) << "Element \'" << a_name.toStdString() << "\' has a problem"; ERROR_LOG(m_logger) << "Element \'" << a_name.toStdString() << "\' has a problem";
} }
// ---------------------------------------------------------------
void LogViewXdrElement::dump() const void LogViewXdrElement::dump() const
{ {
INFO_LOG(m_logger) << "Element[" << getName() << "]: kind=" << getKindName(); INFO_LOG(m_logger) << "Element[" << getName() << "]: kind=" << getKindName();
} }
// ---------------------------------------------------------------
QString LogViewXdrElement::getKindName() const QString LogViewXdrElement::getKindName() const
{ {
switch (getKind()) switch (getKind())
{ {
case e_KindDefine: case e_KindDefine:
@@ -56,6 +56,6 @@ namespace N_LogView
return QLatin1String("Typedef"); return QLatin1String("Typedef");
} }
return QStringLiteral("Unknown (%1)").arg(getKind()); return QStringLiteral("Unknown (%1)").arg(getKind());
} }
} // namespace N_LogView }
@@ -1,15 +1,15 @@
// **************************************************************************
//
// (C) Copyright 2009 Swiss SIMTEC AG
//
// **************************************************************************
//
// $HeadURL$
// $LastChangedBy$
// $LastChangedDate$
// $LastChangedRevision$
//
// **************************************************************************
#pragma once #pragma once
@@ -18,19 +18,14 @@
namespace N_LogView namespace N_LogView
{ {
/**
* @author alois.wismer
* @version 1.0
* @created 05-Feb-2010 11:24:56
*/
class LogViewXdrElement class LogViewXdrElement
{ {
public: public:
/**
* @author alois.wismer
* @version 1.0
* @created 10-Feb-2010 11:34:47
*/
enum E_ElementKind enum E_ElementKind
{ {
e_KindStandardType, e_KindStandardType,
@@ -45,16 +40,12 @@ namespace N_LogView
virtual ~LogViewXdrElement() = default; virtual ~LogViewXdrElement() = default;
protected: protected:
/**
* Constructor of a struct or enum
* LogViewXdrElement(const QString& a_name, const E_ElementKind a_kind, const char *loggerName);
* @param a_name
* @param a_kind
*/
LogViewXdrElement(const QString &a_name, const E_ElementKind a_kind, const char *loggerName);
public: public:
const QString &getName() const { return m_Name; } const QString& getName() const { return m_Name; }
LogViewXdrElement::E_ElementKind getKind() const { return m_Kind; } LogViewXdrElement::E_ElementKind getKind() const { return m_Kind; }
virtual void dump() const; virtual void dump() const;
@@ -62,7 +53,6 @@ namespace N_LogView
protected: protected:
QString m_Name; QString m_Name;
E_ElementKind m_Kind; E_ElementKind m_Kind;
LOGGER_T m_logger;
QString getKindName() const; QString getKindName() const;
NGL::INGLLogger &m_logger; NGL::INGLLogger &m_logger;
@@ -1,83 +1,84 @@
// **************************************************************************
//
// (C) Copyright 2009 Swiss SIMTEC AG
//
// **************************************************************************
//
// $HeadURL$
// $LastChangedBy$
// $LastChangedDate$
// $LastChangedRevision$
//
// **************************************************************************
// manual class headers
#include "LogViewXdrStandardType.hpp" #include "LogViewXdrStandardType.hpp"
namespace N_LogView namespace N_LogView
{ {
// ---------------------------------------------------------------
// (a_valueKind must be Unsigned, if a_dynArraySizeMethod is
// e_DynArray...)
// ---------------------------------------------------------------
LogViewXdrStandardType::LogViewXdrStandardType(const QString &a_name, LogViewXdrStandardType::LogViewXdrStandardType(const QString& a_name, const int a_valueSize,
const int a_valueSize, const int a_editSize, const E_ValueKind a_valueKind,
const int a_editSize, const E_DynArraySizeMethod a_dynArraySizeMethod, E_ByteOrder a_byteOrder)
const E_ValueKind a_valueKind,
const E_DynArraySizeMethod a_dynArraySizeMethod,
E_ByteOrder a_byteOrder)
: LogViewXdrElement(a_name, e_KindStandardType, "LogViewXdrStandardType") : LogViewXdrElement(a_name, e_KindStandardType, "LogViewXdrStandardType")
, m_ValueSize(a_valueSize) , m_ValueSize(a_valueSize)
, m_EditSize(a_editSize) , m_EditSize(a_editSize)
, m_ValueKind(a_valueKind) , m_ValueKind(a_valueKind)
, m_ByteOrder(a_byteOrder) , m_ByteOrder(a_byteOrder)
, m_DynArraySizeMethod(a_dynArraySizeMethod) , m_DynArraySizeMethod(a_dynArraySizeMethod)
{ {}
}
// ---------------------------------------------------------------
uint16_t LogViewXdrStandardType::getValueSize() const uint16_t LogViewXdrStandardType::getValueSize() const
{ {
return m_ValueSize; return m_ValueSize;
} }
// ---------------------------------------------------------------
LogViewXdrStandardType::E_ValueKind LogViewXdrStandardType::getValueKind() const LogViewXdrStandardType::E_ValueKind LogViewXdrStandardType::getValueKind() const
{ {
return m_ValueKind; return m_ValueKind;
} }
// ---------------------------------------------------------------
void LogViewXdrStandardType::dump() const
{
INFO_LOG(m_logger) << "Element[" << getName() << "]: kind=" << getKindName() << " valueKind=" << getValueKind() << " valueSize=" << getValueSize()
<< " editSize=" << getEditSize() << " dynArrSizeMethod=" << getDynArraySizeMethod() << " byteOrder=" << getByteOrder();
}
// --------------------------------------------------------------- void LogViewXdrStandardType::dump() const
LogViewXdrStandardType::E_DynArraySizeMethod LogViewXdrStandardType::getDynArraySizeMethod() const {
{ INFO_LOG(m_logger) << "Element[" << getName()
<< "]: kind=" << getKindName()
<< " valueKind=" << getValueKind()
<< " valueSize=" << getValueSize()
<< " editSize=" << getEditSize()
<< " dynArrSizeMethod=" << getDynArraySizeMethod()
<< " byteOrder=" << getByteOrder();
}
LogViewXdrStandardType::E_DynArraySizeMethod LogViewXdrStandardType::getDynArraySizeMethod() const
{
return m_DynArraySizeMethod; return m_DynArraySizeMethod;
} }
// ---------------------------------------------------------------
LogViewXdrStandardType::E_ByteOrder LogViewXdrStandardType::getByteOrder() const LogViewXdrStandardType::E_ByteOrder LogViewXdrStandardType::getByteOrder() const
{ {
return m_ByteOrder; return m_ByteOrder;
} }
// ---------------------------------------------------------------
// The 'real' size of the value, which will be allowd when
// editing this value
// ---------------------------------------------------------------
uint16_t LogViewXdrStandardType::getEditSize() const uint16_t LogViewXdrStandardType::getEditSize() const
{ {
return m_EditSize; return m_EditSize;
} }
} // namespace N_LogView }
@@ -1,15 +1,15 @@
// **************************************************************************
//
// (C) Copyright 2009 Swiss SIMTEC AG
//
// **************************************************************************
//
// $HeadURL$
// $LastChangedBy$
// $LastChangedDate$
// $LastChangedRevision$
//
// **************************************************************************
#pragma once #pragma once
@@ -17,90 +17,61 @@
namespace N_LogView namespace N_LogView
{ {
/**
* This class represents the standardtypes like int, char, ...
* It holds the the size of this type and its representation to user
* (signed/unsigned value or character)
*
* @author alois.wismer
* @version 1.0
* @created 16-Feb-2010 14:22:20
*/
class LogViewXdrStandardType final : public LogViewXdrElement class LogViewXdrStandardType final : public LogViewXdrElement
{ {
public: public:
/**
* @author alois.wismer
* @version 1.0
* @created 16-Feb-2010 14:34:38
*/
enum E_ValueKind enum E_ValueKind
{ {
/**
* An unsigned 32-bit integer
*/
e_Unsigned, e_Unsigned,
/**
* An signed 32-bit integer
*/
e_Signed, e_Signed,
/**
* A floating-point number
*/
e_Float, e_Float,
/**
* A character or string
*/
e_Character, e_Character,
/**
* A boolean value
*/
e_Boolean, e_Boolean,
/**
* Hex-Data "0000: F7 A5 07 ..."
*/
e_Data e_Data
}; };
/**
* @author alois.wismer
* @version 1.0
* @created 31-Mrz-2010 10:27:31
*/
enum E_ByteOrder enum E_ByteOrder
{ {
e_ByteOrderBigEndian, e_ByteOrderBigEndian,
e_ByteOrderLittleEndian e_ByteOrderLittleEndian
}; };
/**
* @author alois.wismer
* @version 1.0
* @created 29-Mrz-2010 13:58:44
*/
enum E_DynArraySizeMethod enum E_DynArraySizeMethod
{ {
/**
* Size of dyn array depends on message-size (size - m_DynArrayOffset) (or no dyn
* array)
* The value within <> in struct-element will be used for m_DynArrayOffset.
*/
e_DynArrayMsgLength, e_DynArrayMsgLength,
/**
* Size of dyn array is defined by a field (StandardType must be Unsigned)
*/
e_DynArrayIndex, e_DynArrayIndex,
/**
* Size of dyn array is defined by a field, which will be divided by 8 (used for
* bitfields) (StandardType must be Unsigned)
*/
e_DynArrayIndexDiv8 e_DynArrayIndexDiv8
}; };
/**
* (a_valueKind must be Unsigned, if a_dynArraySizeMethod is e_DynArray...)
*
*/
LogViewXdrStandardType(const QString &a_name, LogViewXdrStandardType(const QString &a_name,
const int a_valueSize, const int a_valueSize,
const int a_editSize, const int a_editSize,
@@ -123,25 +94,24 @@ namespace N_LogView
LogViewXdrStandardType::E_ByteOrder getByteOrder() const; LogViewXdrStandardType::E_ByteOrder getByteOrder() const;
/**
* The 'real' size of the value, which will be allowd when editing this value
*/
uint16_t getEditSize() const; uint16_t getEditSize() const;
protected: protected:
/**
* The size of this value as stored data. It may be bigger as the real (edit) size.
*/
int m_ValueSize; int m_ValueSize;
/**
* The 'real' size of the value, which will be allowd when editing this value
*/
int m_EditSize; int m_EditSize;
E_ValueKind m_ValueKind; E_ValueKind m_ValueKind;
E_ByteOrder m_ByteOrder; E_ByteOrder m_ByteOrder;
E_DynArraySizeMethod m_DynArraySizeMethod; E_DynArraySizeMethod m_DynArraySizeMethod;
}; };
} }
@@ -1,15 +1,15 @@
// **************************************************************************
//
// (C) Copyright 2009 Swiss SIMTEC AG
//
// **************************************************************************
//
// $HeadURL$
// $LastChangedBy$
// $LastChangedDate$
// $LastChangedRevision$
//
// **************************************************************************
#include "LogViewXdrStruct.hpp" #include "LogViewXdrStruct.hpp"
#include "LogViewXdrValue.hpp" #include "LogViewXdrValue.hpp"
@@ -18,94 +18,88 @@
namespace N_LogView namespace N_LogView
{ {
// ---------------------------------------------------------------
LogViewXdrStruct::LogViewXdrStruct(const QString &a_name, const LogViewXdrElement::E_ElementKind a_kind, uint16_t enumSize) LogViewXdrStruct::LogViewXdrStruct(const QString& a_name, const LogViewXdrElement::E_ElementKind a_kind, uint16_t enumSize)
: LogViewXdrElement(a_name, a_kind, "LogViewXdrStruct") : LogViewXdrElement(a_name, a_kind, "LogViewXdrStruct")
, m_EnumSize(enumSize) , m_EnumSize(enumSize)
{ {
} }
LogViewXdrStruct::~LogViewXdrStruct() LogViewXdrStruct::~LogViewXdrStruct()
{ {
for (auto ptr : m_ChildList) for (auto ptr : m_ChildList)
delete ptr; delete ptr;
} }
// ---------------------------------------------------------------
void LogViewXdrStruct::addElement(const QString &a_name, void LogViewXdrStruct::addElement(const QString& a_name, const QString& a_type, const uint16_t a_arraySize, const uint16_t a_dynArrayOffset, const E_ElementKind a_kind, const int16_t a_firstBit, const int16_t a_lastBit, const bool a_isLast)
const QString &a_type, {
const uint16_t a_arraySize,
const uint16_t a_dynArrayOffset,
const E_ElementKind a_kind,
const int16_t a_firstBit,
const int16_t a_lastBit,
const bool a_isLast)
{
m_ChildList.push_back(new LogViewXdrType(a_name, a_type, a_arraySize, a_dynArrayOffset, a_kind, a_firstBit, a_lastBit, a_isLast)); m_ChildList.push_back(new LogViewXdrType(a_name, a_type, a_arraySize, a_dynArrayOffset, a_kind, a_firstBit, a_lastBit, a_isLast));
} }
// ---------------------------------------------------------------
void LogViewXdrStruct::addElement(const QString &a_name, const uint32_t a_value, const E_ElementKind a_kind) void LogViewXdrStruct::addElement(const QString& a_name, const uint32_t a_value, const E_ElementKind a_kind)
{ {
m_ChildList.push_back(new LogViewXdrValue(a_name, a_value, a_kind)); m_ChildList.push_back(new LogViewXdrValue(a_name, a_value, a_kind));
} }
// ---------------------------------------------------------------
LogViewXdrElement *LogViewXdrStruct::getChild(const uint32_t a_childIndex) const LogViewXdrElement* LogViewXdrStruct::getChild(const uint32_t a_childIndex) const
{ {
if (m_ChildList.size() > a_childIndex) if (m_ChildList.size() > a_childIndex)
return m_ChildList[a_childIndex]; return m_ChildList[a_childIndex];
return nullptr; return nullptr;
} }
// ---------------------------------------------------------------
LogViewXdrType *LogViewXdrStruct::getChildAsType(const uint32_t a_childIndex) const LogViewXdrType* LogViewXdrStruct::getChildAsType(const uint32_t a_childIndex) const
{ {
return static_cast<LogViewXdrType *>(getChild(a_childIndex)); // fixme: check ob es wirklich ein XdrType ist return static_cast<LogViewXdrType*>(getChild(a_childIndex));
} }
// ---------------------------------------------------------------
LogViewXdrValue *LogViewXdrStruct::getChildAsValue(const uint32_t a_childIndex) const LogViewXdrValue* LogViewXdrStruct::getChildAsValue(const uint32_t a_childIndex) const
{ {
return static_cast<LogViewXdrValue *>(getChild(a_childIndex)); // fixme: check ob es wirklich ein XdrValue ist return static_cast<LogViewXdrValue*>(getChild(a_childIndex));
} }
// ---------------------------------------------------------------
void LogViewXdrStruct::dump() const void LogViewXdrStruct::dump() const
{ {
INFO_LOG(m_logger) << "Element[" << getName().toStdString() << "]: kind=" << getKindName().toStdString() << " enumSize=" << getEnumSize(); INFO_LOG(m_logger) << "Element[" << getName().toStdString() << "]: kind=" << getKindName().toStdString() << " enumSize=" << getEnumSize();
INFO_LOG(m_logger) << "-------------- childs start -----------------"; INFO_LOG(m_logger) << "-------------- childs start -----------------";
std::vector<LogViewXdrElement *>::const_iterator iter = m_ChildList.begin(); std::vector<LogViewXdrElement*>::const_iterator iter = m_ChildList.begin();
while (iter != m_ChildList.end()) while (iter != m_ChildList.end())
{ {
(*iter)->dump(); (*iter)->dump();
++iter; ++iter;
} }
INFO_LOG(m_logger) << "-------------- childs end -----------------"; INFO_LOG(m_logger) << "-------------- childs end -----------------";
} }
// ---------------------------------------------------------------
uint32_t LogViewXdrStruct::getChildValue(const QString &a_name, bool *a_error) const uint32_t LogViewXdrStruct::getChildValue(const QString& a_name, bool* a_error) const
{ {
if (a_error) if (a_error)
*a_error = false; *a_error = false;
std::vector<LogViewXdrElement *>::const_iterator iter = m_ChildList.begin(); std::vector<LogViewXdrElement*>::const_iterator iter = m_ChildList.begin();
while (iter != m_ChildList.end()) while (iter != m_ChildList.end())
{ {
if ((*iter)->getName() == a_name) if ((*iter)->getName() == a_name)
return static_cast<const LogViewXdrValue *>(*iter)->getValue(); return static_cast<const LogViewXdrValue*>(*iter)->getValue();
++iter; ++iter;
} }
if (a_error) if (a_error)
*a_error = true; *a_error = true;
return 0; return 0;
} }
}
} // namespace N_LogView
@@ -1,15 +1,15 @@
// **************************************************************************
//
// (C) Copyright 2009 Swiss SIMTEC AG
//
// **************************************************************************
//
// $HeadURL$
// $LastChangedBy$
// $LastChangedDate$
// $LastChangedRevision$
//
// **************************************************************************
#pragma once #pragma once
@@ -17,7 +17,7 @@
#include "LogViewXdrElement.hpp" #include "LogViewXdrElement.hpp"
#include <vector> #include <vector>
// forward declarations from stereotyped includes
namespace N_LogView namespace N_LogView
{ {
class LogViewXdrValue; class LogViewXdrValue;
@@ -29,42 +29,32 @@ namespace N_LogView
namespace N_LogView namespace N_LogView
{ {
/**
* This class represents elements which have childs.
* This are enum and struct.
* @author alois.wismer
* @version 1.0
* @created 31-Mrz-2010 11:59:19
*/
class LogViewXdrStruct final : public LogViewXdrElement class LogViewXdrStruct final : public LogViewXdrElement
{ {
public: public:
LogViewXdrStruct(const QString &a_name, const LogViewXdrElement::E_ElementKind a_kind, uint16_t enumSize = 0); LogViewXdrStruct(const QString& a_name, const LogViewXdrElement::E_ElementKind a_kind, uint16_t enumSize = 0);
~LogViewXdrStruct(); ~LogViewXdrStruct();
void addElement(const QString &a_name, void addElement(const QString& a_name, const QString& a_type, const uint16_t a_arraySize, const uint16_t a_dynArrayOffset, const E_ElementKind a_kind, const int16_t a_firstBit = -1, const int16_t a_lastBit = -1, const bool a_isLast = true);
const QString &a_type, void addElement(const QString& a_name, const uint32_t a_value, const E_ElementKind a_kind);
const uint16_t a_arraySize,
const uint16_t a_dynArrayOffset,
const E_ElementKind a_kind,
const int16_t a_firstBit = -1,
const int16_t a_lastBit = -1,
const bool a_isLast = true);
void addElement(const QString &a_name, const uint32_t a_value, const E_ElementKind a_kind);
LogViewXdrElement *getChild(const uint32_t a_childIndex) const; LogViewXdrElement* getChild(const uint32_t a_childIndex) const;
LogViewXdrType *getChildAsType(const uint32_t a_childIndex) const; LogViewXdrType* getChildAsType(const uint32_t a_childIndex) const;
LogViewXdrValue *getChildAsValue(const uint32_t a_childIndex) const; LogViewXdrValue* getChildAsValue(const uint32_t a_childIndex) const;
void dump() const override; void dump() const override;
uint32_t getChildValue(const QString &a_name, bool *a_error = nullptr) const; uint32_t getChildValue(const QString& a_name, bool* a_error = nullptr) const;
uint16_t getEnumSize() const { return m_EnumSize; } uint16_t getEnumSize() const { return m_EnumSize; }
protected: protected:
uint16_t m_EnumSize; uint16_t m_EnumSize;
std::vector<LogViewXdrElement *> m_ChildList; std::vector<LogViewXdrElement*> m_ChildList;
}; };
} }
@@ -1,23 +1,23 @@
// **************************************************************************
//
// (C) Copyright 2009 Swiss SIMTEC AG
//
// **************************************************************************
//
// $HeadURL$
// $LastChangedBy$
// $LastChangedDate$
// $LastChangedRevision$
//
// **************************************************************************
#include "LogViewXdrType.hpp" #include "LogViewXdrType.hpp"
namespace N_LogView namespace N_LogView
{ {
// ---------------------------------------------------------------
LogViewXdrType::LogViewXdrType(const QString &a_name, const QString &a_type, const uint16_t a_arraySize, const uint16_t a_dynArrayOffset, const E_ElementKind a_kind) LogViewXdrType::LogViewXdrType(const QString& a_name, const QString& a_type, const uint16_t a_arraySize, const uint16_t a_dynArrayOffset, const E_ElementKind a_kind)
: LogViewXdrElement(a_name, a_kind, "LogViewXdrElement") : LogViewXdrElement(a_name, a_kind, "LogViewXdrElement")
, m_Type(a_type) , m_Type(a_type)
, m_ArraySize(a_arraySize) , m_ArraySize(a_arraySize)
@@ -25,19 +25,12 @@ namespace N_LogView
, m_FirstBit(-1) , m_FirstBit(-1)
, m_LastBit(-1) , m_LastBit(-1)
, m_IsLast(true) , m_IsLast(true)
{ {
} }
// ---------------------------------------------------------------
LogViewXdrType::LogViewXdrType(const QString &a_name, LogViewXdrType::LogViewXdrType(const QString& a_name, const QString& a_type, const uint16_t a_arraySize, const uint16_t a_dynArrayOffset, const E_ElementKind a_kind, const int16_t a_firstBit, const int16_t a_lastBit, const bool a_isLast)
const QString &a_type,
const uint16_t a_arraySize,
const uint16_t a_dynArrayOffset,
const E_ElementKind a_kind,
const int16_t a_firstBit,
const int16_t a_lastBit,
const bool a_isLast)
: LogViewXdrElement(a_name, a_kind, "LogViewXdrType") : LogViewXdrElement(a_name, a_kind, "LogViewXdrType")
, m_Type(a_type) , m_Type(a_type)
, m_ArraySize(a_arraySize) , m_ArraySize(a_arraySize)
@@ -45,60 +38,69 @@ namespace N_LogView
, m_FirstBit(a_firstBit) , m_FirstBit(a_firstBit)
, m_LastBit(a_lastBit) , m_LastBit(a_lastBit)
, m_IsLast(a_isLast) , m_IsLast(a_isLast)
{ {
} }
// ---------------------------------------------------------------
void LogViewXdrType::dump() const void LogViewXdrType::dump() const
{ {
INFO_LOG(m_logger) << "Element[" << getName() << "]: kind=" << getKindName() << " type=" << getType() << " arraySize=" << getArraySize() INFO_LOG(m_logger) << "Element[" << getName()
<< " maxArraySize=" << getMaxArraySize() << " firstBit=" << m_FirstBit << " lastBit=" << m_LastBit << " isLast=" << m_IsLast; << "]: kind=" << getKindName()
} << " type=" << getType()
<< " arraySize=" << getArraySize()
<< " maxArraySize=" << getMaxArraySize()
<< " firstBit=" << m_FirstBit
<< " lastBit=" << m_LastBit
<< " isLast=" << m_IsLast;
}
// ---------------------------------------------------------------
const QString &LogViewXdrType::getType() const const QString& LogViewXdrType::getType() const
{ {
return m_Type; return m_Type;
} }
// ---------------------------------------------------------------
// 0 => opaque
// 1 => normal (scalar) element
// >1 => array
// ---------------------------------------------------------------
uint16_t LogViewXdrType::getArraySize() const uint16_t LogViewXdrType::getArraySize() const
{ {
return m_ArraySize; return m_ArraySize;
} }
// ---------------------------------------------------------------
bool LogViewXdrType::maskValue(uint32_t &a_value, const uint16_t a_size, QString &a_tooltip) const bool LogViewXdrType::maskValue(uint32_t& a_value, const uint16_t a_size, QString& a_tooltip) const
{ {
// INFO_LOG(m_logger) << "firstBit=" << m_FirstBit << " lastBit=" << m_LastBit << " isLast=" << m_IsLast;
if (m_FirstBit != -1 && m_LastBit != -1) if (m_FirstBit != -1 && m_LastBit != -1)
{ {
DEBUG_LOG(m_logger) << "MaskValue for Element " << m_Name << " type: " << m_Type << " size: " << m_ArraySize << " first:last " << m_FirstBit << ":" << m_LastBit DEBUG_LOG(m_logger) << "MaskValue for Element " << m_Name
<< " type: " << m_Type
<< " size: " << m_ArraySize
<< " first:last " << m_FirstBit << ":" << m_LastBit
<< " isLast: " << m_IsLast; << " isLast: " << m_IsLast;
uint16_t bitshift = (a_size * 8) - m_LastBit - 1; uint16_t bitshift = (a_size*8)-m_LastBit-1;
uint32_t mask = (1 << (m_LastBit - m_FirstBit + 1)) - 1; uint32_t mask = (1<<(m_LastBit-m_FirstBit+1))-1;
// INFO_LOG(m_logger) << "value=" << a_value << " bitshift=" << bitshift << " mask=" << mask;
a_value = (a_value >> bitshift) & mask; a_value = (a_value >> bitshift) & mask;
// make bold the corresponding bits in the bitfield
a_tooltip.insert(a_tooltip.length() - (a_size * 8) + m_FirstBit, QLatin1String("<b>")); a_tooltip.insert(a_tooltip.length()-(a_size*8)+m_FirstBit, QLatin1String("<b>"));
a_tooltip.insert(a_tooltip.length() - (a_size * 8) + m_LastBit + 1, QLatin1String("</b>")); a_tooltip.insert(a_tooltip.length()-(a_size*8)+m_LastBit+1, QLatin1String("</b>"));
return m_IsLast; return m_IsLast;
} }
return true; return true;
} }
// ---------------------------------------------------------------
uint16_t LogViewXdrType::getMaxArraySize() const uint16_t LogViewXdrType::getMaxArraySize() const
{ {
return m_MaxArraySize; return m_MaxArraySize;
} }
} // namespace N_LogView }
@@ -1,15 +1,15 @@
// **************************************************************************
//
// (C) Copyright 2009 Swiss SIMTEC AG
//
// **************************************************************************
//
// $HeadURL$
// $LastChangedBy$
// $LastChangedDate$
// $LastChangedRevision$
//
// **************************************************************************
#pragma once #pragma once
@@ -17,99 +17,56 @@
namespace N_LogView namespace N_LogView
{ {
/**
* This class represents XDR-elements which have a type and an arraySize. This are
* typedefs and struct-elements.
* The arraySize has following possibilities:
* 0 => opaque
* 1 => scalar
* >1 => array
*
* @author alois.wismer
* @version 1.0
* @created 16-Feb-2010 15:48:24
*/
class LogViewXdrType final : public LogViewXdrElement class LogViewXdrType final : public LogViewXdrElement
{ {
public: public:
/**
*
* @param a_name
* @param a_type
* @param a_arraySize
* @param a_dynArrayOffset
* @param a_kind
*/
LogViewXdrType(const QString &a_name, const QString &a_type, const uint16_t a_arraySize, const uint16_t a_dynArrayOffset, const E_ElementKind a_kind);
/**
*
* @param a_name LogViewXdrType(const QString& a_name, const QString& a_type, const uint16_t a_arraySize, const uint16_t a_dynArrayOffset, const E_ElementKind a_kind);
* @param a_type
* @param a_arraySize
* @param a_dynArrayOffset
* @param a_kind LogViewXdrType(const QString& a_name, const QString& a_type, const uint16_t a_arraySize, const uint16_t a_dynArrayOffset, const E_ElementKind a_kind, const int16_t a_firstBit, const int16_t a_lastBit, const bool a_isLast);
* @param a_firstBit
* @param a_lastBit
* @param a_isLast
*/
LogViewXdrType(const QString &a_name,
const QString &a_type,
const uint16_t a_arraySize,
const uint16_t a_dynArrayOffset,
const E_ElementKind a_kind,
const int16_t a_firstBit,
const int16_t a_lastBit,
const bool a_isLast);
void dump() const override; void dump() const override;
const QString &getType() const; const QString& getType() const;
/**
* 0 => opaque
* 1 => normal (scalar) element
* >1 => array
*/
uint16_t getArraySize() const; uint16_t getArraySize() const;
/**
*
* @param a_value bool maskValue(uint32_t& a_value, const uint16_t a_size, QString& a_tooltip) const;
* @param a_size
* @param a_tooltip
*/
bool maskValue(uint32_t &a_value, const uint16_t a_size, QString &a_tooltip) const;
uint16_t getMaxArraySize() const; uint16_t getMaxArraySize() const;
protected: protected:
QString m_Type; QString m_Type;
/**
* 0 => opaque
* 1 => normal (scalar) element
* >1 => array
*/
uint16_t m_ArraySize; uint16_t m_ArraySize;
/**
* The maximum size of the array. Interesting for dynamic arrays.
*/
uint16_t m_MaxArraySize; uint16_t m_MaxArraySize;
/**
* The first relevant bit, if we have bitfield-enum
*/
int16_t m_FirstBit; int16_t m_FirstBit;
/**
* The last relevant bit, if we have bitfield-enum
*/
int16_t m_LastBit; int16_t m_LastBit;
/**
* used to step to next values when reading out content-data of bit-fields
*/
bool m_IsLast; bool m_IsLast;
}; };
} }
@@ -1,15 +1,15 @@
// **************************************************************************
//
// (C) Copyright 2009 Swiss SIMTEC AG
//
// **************************************************************************
//
// $HeadURL$
// $LastChangedBy$
// $LastChangedDate$
// $LastChangedRevision$
//
// **************************************************************************
#include "LogViewXdrValue.hpp" #include "LogViewXdrValue.hpp"
@@ -17,25 +17,24 @@
namespace N_LogView namespace N_LogView
{ {
// ---------------------------------------------------------------
LogViewXdrValue::LogViewXdrValue(const QString &a_name, const int64_t a_value, const LogViewXdrElement::E_ElementKind a_kind) LogViewXdrValue::LogViewXdrValue(const QString& a_name, const int64_t a_value, const LogViewXdrElement::E_ElementKind a_kind)
: LogViewXdrElement(a_name, a_kind, "LogViewXdrValue") : LogViewXdrElement(a_name, a_kind, "LogViewXdrValue")
, m_Value(a_value) , m_Value(a_value)
{ {}
}
// ---------------------------------------------------------------
void LogViewXdrValue::dump() const void LogViewXdrValue::dump() const
{ {
INFO_LOG(m_logger) << "Element[" << getName() << "]: kind=" << getKindName() << " value=" << getValue(); INFO_LOG(m_logger) << "Element[" << getName() << "]: kind=" << getKindName() << " value=" << getValue();
} }
// ---------------------------------------------------------------
int64_t LogViewXdrValue::getValue() const int64_t LogViewXdrValue::getValue() const
{ {
return m_Value; return m_Value;
} }
} // namespace N_LogView }
@@ -1,15 +1,15 @@
// **************************************************************************
//
// (C) Copyright 2009 Swiss SIMTEC AG
//
// **************************************************************************
//
// $HeadURL$
// $LastChangedBy$
// $LastChangedDate$
// $LastChangedRevision$
//
// **************************************************************************
#pragma once #pragma once
@@ -17,23 +17,18 @@
namespace N_LogView namespace N_LogView
{ {
/**
* This class represents XDR-elements which have a value. This are #defines and
* enum-elements.
*
* @author alois.wismer
* @version 1.0
* @created 17-Feb-2010 11:17:53
*/
class LogViewXdrValue final : public LogViewXdrElement class LogViewXdrValue final : public LogViewXdrElement
{ {
public: public:
LogViewXdrValue(const QString &a_name, const int64_t a_value, const LogViewXdrElement::E_ElementKind a_kind); LogViewXdrValue(const QString& a_name, const int64_t a_value, const LogViewXdrElement::E_ElementKind a_kind);
void dump() const override; void dump() const override;
int64_t getValue() const; int64_t getValue() const;
protected: protected:
int64_t m_Value; int64_t m_Value;
}; };
} }
@@ -1,10 +1,5 @@
/**
* @RDE_HEADER@
* Building Config - logging facility
* $Id$
* $HeadURL$
* $Author$
*/
#include "logger.h" #include "logger.h"
@@ -13,8 +8,8 @@
namespace N_LogView namespace N_LogView
{ {
LOGGER_T getLogger(const char *name) LOGGER_T getLogger(const char *name)
{ {
static const char ns[] = "LogView."; static const char ns[] = "LogView.";
std::string loggerName; std::string loggerName;
const size_t len = strlen(name); const size_t len = strlen(name);
@@ -24,13 +19,14 @@ namespace N_LogView
try try
{ {
return NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger(loggerName); return NGL::NGLLoggerBootstrap::getNGLRootLogger().
getNGLLogger(loggerName);
} }
catch (const std::exception &ex) catch (const std::exception &ex)
{ {
fprintf(stderr, "Error retrieving logger: %s", ex.what()); fprintf(stderr, "Error retrieving logger: %s", ex.what());
abort(); abort();
} }
} }
} // namespace LogView }
@@ -1,10 +1,5 @@
/**
* @RDE_HEADER@
* Logging for AudioVideoManagement
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once #pragma once
@@ -12,11 +7,11 @@
namespace N_LogView namespace N_LogView
{ {
typedef NGL::INGLLogger &LOGGER_T; typedef NGL::INGLLogger &LOGGER_T;
LOGGER_T getLogger(const char *name); LOGGER_T getLogger(const char *name);
inline LOGGER_T getLogger(const QString &loggerName) inline LOGGER_T getLogger(const QString &loggerName)
{ {
return getLogger(loggerName.toUtf8().constData()); return getLogger(loggerName.toUtf8().constData());
} }
} // namespace LogView }