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:
1 parent
edd5e3ba81
commit
473462cbdb
42 files changed
+1631
-2103
No files matched your search
+6
@@ -45,6 +45,9 @@ if(QT6_GUI_AVAILABLE)
|
||||
Qt6::Svg
|
||||
)
|
||||
endif()
|
||||
IF(BUILD_RTI)
|
||||
TARGET_LINK_LIBRARIES(LtsUtilsGuiDds PUBLIC ddscore)
|
||||
ENDIF(BUILD_RTI)
|
||||
NGL_TARGET_COMPILE_DEFINITIONS(LtsUtilsGuiDds
|
||||
PUBLIC
|
||||
REQUEST_HELPER_WITH_GUI
|
||||
@@ -77,3 +80,6 @@ NGL_TARGET_LINK_LIBRARIES(LtsUtilsDds
|
||||
PUBLIC
|
||||
Qt6::Core
|
||||
)
|
||||
IF(BUILD_RTI)
|
||||
TARGET_LINK_LIBRARIES(LtsUtilsDds PUBLIC ddscore)
|
||||
ENDIF(BUILD_RTI)
|
||||
@@ -17,7 +17,8 @@
|
||||
#include <TrainingAreaBase/training_area_telegrams.h>
|
||||
|
||||
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))
|
||||
return false;
|
||||
@@ -38,28 +39,31 @@ int main(int argc, char **argv)
|
||||
|
||||
QCoreApplication app(argc, argv);
|
||||
|
||||
// Check alle 30 Sekunden
|
||||
|
||||
NGL::NGLLoggerBootstrap::createNGLRootLogger("log4cxx_tetra.props", false);
|
||||
|
||||
NGL::INGLLogger &logger(NGL::NGLLoggerBootstrap::getNGLRootLogger());
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
QFile telegramFile(app.arguments().at(1));
|
||||
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;
|
||||
}
|
||||
bool bOk;
|
||||
int telIdToSearch = app.arguments().at(2).toUShort(&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;
|
||||
}
|
||||
s_eqIds.clear();
|
||||
@@ -68,29 +72,30 @@ int main(int argc, char **argv)
|
||||
int eqId = app.arguments().at(i).toUShort(&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;
|
||||
}
|
||||
s_eqIds += eqId;
|
||||
}
|
||||
|
||||
//fprintf(stdout, "Counter;EqID;TelID;TelTime;LogTime;Diff\n");
|
||||
|
||||
while (true)
|
||||
{
|
||||
// read the header of telegram-entry
|
||||
|
||||
N_CoPrtCnv::CoPrtCnvLogHeader lh;
|
||||
if (sizeof(lh) == telegramFile.read((char *)&lh, sizeof(lh)))
|
||||
{
|
||||
if (lh.m_Version == 3)
|
||||
{
|
||||
// read the telegram itself
|
||||
|
||||
qint64 telegramLength = lh.m_Length - sizeof(lh);
|
||||
QByteArray telegramData(telegramLength, Qt::Uninitialized);
|
||||
if (telegramLength == telegramFile.read(telegramData.data(), telegramLength))
|
||||
{
|
||||
// add the telegram to telegram-list
|
||||
N_CoPrtCnv::CoPrtCnvLogHeader::E_CoPrtCnvProtocol dest =
|
||||
(N_CoPrtCnv::CoPrtCnvLogHeader::E_CoPrtCnvProtocol)(lh.m_Protocol & N_CoPrtCnv::CoPrtCnvLogHeader::e_DestProtocolMask);
|
||||
|
||||
N_CoPrtCnv::CoPrtCnvLogHeader::E_CoPrtCnvProtocol dest = (N_CoPrtCnv::CoPrtCnvLogHeader::E_CoPrtCnvProtocol)
|
||||
(lh.m_Protocol & N_CoPrtCnv::CoPrtCnvLogHeader::e_DestProtocolMask);
|
||||
|
||||
switch (dest)
|
||||
{
|
||||
@@ -113,13 +118,22 @@ int main(int argc, char **argv)
|
||||
const CreateFunctionalArea tele(CreateFunctionalArea::fromJson(objData));
|
||||
if (!validEqId(tele))
|
||||
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;
|
||||
}
|
||||
case Constraints<DeactivateEffectSimulation>::id():
|
||||
{
|
||||
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;
|
||||
}
|
||||
case Constraints<PositionReport>::id():
|
||||
@@ -129,7 +143,11 @@ int main(int argc, char **argv)
|
||||
break;
|
||||
if (tele.opsPosition.opsId == 0)
|
||||
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;
|
||||
}
|
||||
case BESTAETIGUNG:
|
||||
@@ -138,6 +156,7 @@ int main(int argc, char **argv)
|
||||
default:
|
||||
fprintf(stderr, "Printing telegram with id %d not implemented\n", telId);
|
||||
break;
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -154,7 +173,9 @@ int main(int argc, char **argv)
|
||||
{
|
||||
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());
|
||||
bci = radioTelegram.getBroadcastIndex();
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
// **************************************************************************
|
||||
//
|
||||
// (C) Copyright 2009 Swiss SIMTEC AG
|
||||
//
|
||||
// **************************************************************************
|
||||
//
|
||||
// $HeadURL$
|
||||
// $LastChangedBy$
|
||||
// $LastChangedDate$
|
||||
// $LastChangedRevision$
|
||||
//
|
||||
// **************************************************************************
|
||||
|
||||
// manual class headers
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "IntegerCalculator.hpp"
|
||||
|
||||
#include <sstream>
|
||||
@@ -19,43 +19,43 @@
|
||||
|
||||
namespace N_SST
|
||||
{
|
||||
IntegerCalculator::IntegerCalculator()
|
||||
: m_OperationList({{"*", 6}, {"/", 6}, {"%", 6}, {"+", 5}, {"-", 5}, {"<<", 4}, {">>", 4}})
|
||||
IntegerCalculator::IntegerCalculator()
|
||||
: m_OperationList({{"*", 6},{"/", 6},{"%", 6},{"+", 5},{"-", 5},{"<<", 4},{">>", 4}})
|
||||
, m_AdditionalErrorText()
|
||||
, m_ParanthesisCount(0)
|
||||
, 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;
|
||||
// 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, ")", " ) ");
|
||||
|
||||
|
||||
// now calculate the expression
|
||||
|
||||
m_ParanthesisCount = 0;
|
||||
m_Error = e_Ok;
|
||||
m_AdditionalErrorText = "";
|
||||
size_t pos = 0;
|
||||
bool dummy;
|
||||
int64_t value = calc(calcText, pos, dummy, "", 0, "+"); // todo: use member-variable m_CalcText
|
||||
//M_INFO("calc: " << calcText << " value: " << value);
|
||||
int64_t value = calc(calcText, pos, dummy, "", 0, "+");
|
||||
|
||||
|
||||
|
||||
// check the paranthesis
|
||||
if (m_Error == e_Ok)
|
||||
{
|
||||
if (m_ParanthesisCount > 0)
|
||||
@@ -72,7 +72,7 @@ namespace N_SST
|
||||
}
|
||||
}
|
||||
|
||||
// actions if a failure happens
|
||||
|
||||
a_error = m_Error;
|
||||
if (a_error != e_Ok)
|
||||
{
|
||||
@@ -83,41 +83,38 @@ namespace N_SST
|
||||
}
|
||||
}
|
||||
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);
|
||||
if (iter != m_VariableList.end())
|
||||
removeVariable(a_name);
|
||||
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);
|
||||
if (iter != m_VariableList.end())
|
||||
m_VariableList.erase(iter);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// Calculates the expression (recursive)
|
||||
// ---------------------------------------------------------------
|
||||
int64_t IntegerCalculator::calc(const std::string &a_calcText,
|
||||
size_t &a_pos,
|
||||
bool &a_IsEndParanthesis,
|
||||
const std::string &a_prevOp,
|
||||
const int64_t a_prevValue,
|
||||
const std::string &a_initOp)
|
||||
{
|
||||
|
||||
|
||||
|
||||
int64_t IntegerCalculator::calc(const std::string& a_calcText, size_t& a_pos, bool& a_IsEndParanthesis,
|
||||
const std::string& a_prevOp, const int64_t a_prevValue,
|
||||
const std::string& a_initOp)
|
||||
{
|
||||
std::string operation = a_initOp;
|
||||
int64_t value1 = a_prevValue;
|
||||
bool isNegative = false;
|
||||
@@ -137,12 +134,12 @@ namespace N_SST
|
||||
int64_t value2 = calcSign(calc(calcText, ++a_pos, dummy), isNegative);
|
||||
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);
|
||||
if (isOperation(nextOp) && isOperation(a_prevOp) && !isOperationPriorityHigher(nextOp, a_prevOp))
|
||||
{
|
||||
// end of higher priority operation
|
||||
|
||||
return value1;
|
||||
}
|
||||
|
||||
@@ -157,40 +154,38 @@ namespace N_SST
|
||||
}
|
||||
else if (isDigit(calcText[a_pos]))
|
||||
{
|
||||
// value
|
||||
// -----
|
||||
|
||||
|
||||
int64_t value2 = calcSign(convertValue(calcText, a_pos), isNegative);
|
||||
if (calcWithPriority(calcText, a_pos, value1, operation, value2, a_prevOp))
|
||||
return value1;
|
||||
if (calcWithPriority(calcText, a_pos, value1, operation, value2, a_prevOp)) return value1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// operation or variable
|
||||
// ---------------------
|
||||
|
||||
|
||||
std::string oldOperation = operation;
|
||||
operation = getToken(calcText, a_pos);
|
||||
|
||||
// is it a variable?
|
||||
|
||||
if (!isOperation(operation))
|
||||
{
|
||||
int64_t value2 = 0;
|
||||
if (getVariableValue(operation, value2))
|
||||
{
|
||||
value2 = calcSign(value2, isNegative);
|
||||
if (calcWithPriority(calcText, a_pos, value1, oldOperation, value2, a_prevOp))
|
||||
return value1;
|
||||
if (calcWithPriority(calcText, a_pos, value1, oldOperation, value2, a_prevOp)) return value1;
|
||||
operation = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
// error
|
||||
|
||||
m_Error = e_UnknownOperationOrVariable;
|
||||
m_AdditionalErrorText = operation;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// do we have a sign?
|
||||
|
||||
if (oldOperation != "")
|
||||
{
|
||||
if (operation == "+")
|
||||
@@ -213,67 +208,62 @@ namespace N_SST
|
||||
}
|
||||
}
|
||||
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,
|
||||
size_t &a_pos,
|
||||
int64_t &a_value1,
|
||||
std::string &a_operation,
|
||||
int64_t a_value2,
|
||||
const std::string &a_prevOp)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
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);
|
||||
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_value1 = doOperation(a_value1, a_operation, a_value2);
|
||||
if (isParaEnd || (isOperation(nextOp) && isOperation(a_prevOp) && !isOperationPriorityHigher(nextOp, a_prevOp)))
|
||||
{
|
||||
// end of higher priority operation
|
||||
|
||||
return true;
|
||||
}
|
||||
a_operation = "";
|
||||
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)
|
||||
{
|
||||
a_isNegative = false;
|
||||
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);
|
||||
int base = 10;
|
||||
size_t startpos = 0;
|
||||
// hex- and binary-stuff
|
||||
|
||||
bool isHex = (0 == valueText.find("0X")) || (0 == valueText.find("0x"));
|
||||
bool isBin = (0 == valueText.find("0B")) || (0 == valueText.find("0b"));
|
||||
if (isHex)
|
||||
@@ -286,16 +276,16 @@ namespace N_SST
|
||||
base = 2;
|
||||
startpos = 2;
|
||||
}
|
||||
// search end of value
|
||||
|
||||
size_t i;
|
||||
for (i = startpos; i < valueText.length(); i++)
|
||||
for (i=startpos; i<valueText.length(); i++)
|
||||
{
|
||||
if (!isDigit(valueText[i], isHex, isBin))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
// check the next char, it must be a space
|
||||
|
||||
if (valueText.length() > i && valueText[i] != ' ')
|
||||
{
|
||||
m_Error = e_InvalidOperand;
|
||||
@@ -306,10 +296,10 @@ namespace N_SST
|
||||
|
||||
int64_t value = 0;
|
||||
std::stringstream stream;
|
||||
stream.str(valueText.substr(startpos, i - startpos));
|
||||
stream.str(valueText.substr(startpos, i-startpos));
|
||||
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();
|
||||
for (const char c : binValueAsText)
|
||||
{
|
||||
@@ -324,53 +314,50 @@ namespace N_SST
|
||||
stream >> 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)
|
||||
{
|
||||
// skip spaces at begin
|
||||
|
||||
|
||||
|
||||
|
||||
std::string IntegerCalculator::getToken(const std::string &a_calcText, size_t& a_pos)
|
||||
{
|
||||
|
||||
while (a_pos < a_calcText.length())
|
||||
{
|
||||
if (a_calcText[a_pos] == ' ')
|
||||
a_pos++;
|
||||
else
|
||||
break;
|
||||
if (a_calcText[a_pos] == ' ') a_pos++;
|
||||
else break;
|
||||
}
|
||||
|
||||
// search until next space (or end)
|
||||
|
||||
size_t startPos = a_pos;
|
||||
while (a_pos < a_calcText.length())
|
||||
{
|
||||
if (' ' == a_calcText[a_pos])
|
||||
break;
|
||||
if (' ' == a_calcText[a_pos]) break;
|
||||
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);
|
||||
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)
|
||||
{
|
||||
// M_INFO("" << a_value1 << " " << a_operation << " " << a_value2);
|
||||
|
||||
|
||||
|
||||
|
||||
int64_t IntegerCalculator::doOperation(const int64_t a_value1, const std::string& a_operation, const int64_t a_value2)
|
||||
{
|
||||
|
||||
if (("+" == a_operation) || a_operation.empty())
|
||||
{
|
||||
return a_value1 + a_value2;
|
||||
@@ -419,28 +406,28 @@ namespace N_SST
|
||||
m_AdditionalErrorText = a_operation;
|
||||
}
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// 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);
|
||||
if (iter != m_VariableList.end())
|
||||
{
|
||||
@@ -448,53 +435,53 @@ namespace N_SST
|
||||
return true;
|
||||
}
|
||||
|
||||
// error
|
||||
|
||||
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)
|
||||
{
|
||||
// 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');
|
||||
}
|
||||
else if (a_isBin)
|
||||
{
|
||||
// for binary-values only 0 and 1 are allowed
|
||||
|
||||
return (a_char >= '0' && a_char <= '1');
|
||||
}
|
||||
// normal digits
|
||||
|
||||
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);
|
||||
if (iter != m_OperationList.end())
|
||||
return iter->second;
|
||||
|
||||
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 replaceSize = a_replaceText.length();
|
||||
|
||||
@@ -505,6 +492,6 @@ namespace N_SST
|
||||
pos += replaceSize;
|
||||
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
|
||||
|
||||
@@ -18,65 +18,39 @@
|
||||
|
||||
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
|
||||
{
|
||||
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
|
||||
{
|
||||
/**
|
||||
* No error happend
|
||||
*/
|
||||
|
||||
|
||||
e_Ok,
|
||||
/**
|
||||
* The divisor is 0
|
||||
*/
|
||||
|
||||
|
||||
e_DivisionByZero,
|
||||
/**
|
||||
* The operation/variable is not known. a_addErrorText will contain the unknown
|
||||
* operation/variable.
|
||||
*/
|
||||
|
||||
|
||||
e_UnknownOperationOrVariable,
|
||||
/**
|
||||
* Between to operators no variable/operand exists. a_addErrorText contains the 2
|
||||
* operations.
|
||||
*/
|
||||
|
||||
|
||||
e_NoOperandBetweenOperators,
|
||||
/**
|
||||
* The operand contains invalid characters. a_addErrorText contains the invalid
|
||||
* operand.
|
||||
*/
|
||||
|
||||
|
||||
e_InvalidOperand,
|
||||
/**
|
||||
* There are more ) than (
|
||||
*/
|
||||
|
||||
|
||||
e_MissingLeftParanthesis,
|
||||
/**
|
||||
* There are more ) than (
|
||||
*/
|
||||
|
||||
|
||||
e_MissingRightParanthesis,
|
||||
/**
|
||||
* Something else went wrong
|
||||
*/
|
||||
|
||||
|
||||
e_UnknownError
|
||||
};
|
||||
|
||||
@@ -84,173 +58,86 @@ namespace N_SST
|
||||
IntegerCalculator();
|
||||
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);
|
||||
|
||||
/**
|
||||
* Removes a case-sensitive variable from the calculator.
|
||||
*
|
||||
* @param a_name
|
||||
*/
|
||||
void removeVariable(const std::string &a_name);
|
||||
int64_t calc(const std::string& a_calcText, E_Error& a_error, std::string* a_addErrorText = nullptr);
|
||||
|
||||
|
||||
|
||||
void addVariable(const std::string& a_name, const int64_t a_value);
|
||||
|
||||
|
||||
|
||||
void removeVariable(const std::string& a_name);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Contains all supported operations
|
||||
*/
|
||||
|
||||
|
||||
|
||||
const std::map<std::string, int> m_OperationList;
|
||||
/**
|
||||
* Contains all variables
|
||||
*/
|
||||
|
||||
|
||||
std::map<std::string, int64_t> m_VariableList;
|
||||
/**
|
||||
* The additional text for errors
|
||||
*/
|
||||
|
||||
|
||||
std::string m_AdditionalErrorText;
|
||||
/**
|
||||
* The number of open paranthesis
|
||||
*/
|
||||
|
||||
|
||||
int32_t m_ParanthesisCount;
|
||||
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);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @param a_value
|
||||
* @param a_isNegative
|
||||
*/
|
||||
static int64_t calcSign(const int64_t a_value, bool &a_isNegative);
|
||||
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());
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* returns true if a_operation is a known operation.
|
||||
*
|
||||
* @param a_operation
|
||||
*/
|
||||
bool isOperation(const std::string &a_operation) const;
|
||||
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);
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @param a_variableName
|
||||
* @param a_value
|
||||
*/
|
||||
virtual bool getVariableValue(const std::string &a_variableName, int64_t &a_value) const;
|
||||
static int64_t calcSign(const int64_t a_value, bool& a_isNegative);
|
||||
|
||||
|
||||
|
||||
int64_t convertValue(const std::string& a_valueText, size_t& a_pos);
|
||||
|
||||
|
||||
|
||||
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);
|
||||
|
||||
/**
|
||||
* 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).
|
||||
*
|
||||
* @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);
|
||||
|
||||
int16_t getPriority(const std::string& a_operation) const;
|
||||
|
||||
|
||||
|
||||
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 "LogViewField.hpp"
|
||||
@@ -13,20 +8,20 @@
|
||||
namespace N_LogView
|
||||
{
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
LogViewBooleanEdit::LogViewBooleanEdit(LogViewField *a_field, QWidget *a_parent, const bool a_readonly)
|
||||
: QCheckBox(a_parent)
|
||||
|
||||
LogViewBooleanEdit::LogViewBooleanEdit(LogViewField* a_field, QWidget* a_parent, const bool a_readonly)
|
||||
: QCheckBox (a_parent)
|
||||
, LogViewWidget(a_field, this, a_parent, a_readonly)
|
||||
{
|
||||
{
|
||||
const QString valueText = a_field->value(0);
|
||||
|
||||
setChecked(valueText.toInt() == 1);
|
||||
setEnabled(!a_readonly);
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
bool LogViewBooleanEdit::saveContent(LogViewTelegram *a_telegram)
|
||||
{
|
||||
|
||||
bool LogViewBooleanEdit::saveContent(LogViewTelegram* a_telegram)
|
||||
{
|
||||
if (m_Valid)
|
||||
{
|
||||
if (a_telegram->isJsonTelegram())
|
||||
@@ -36,6 +31,6 @@ namespace N_LogView
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace N_LogView
|
||||
}
|
||||
@@ -1,10 +1,5 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Edit boolean values
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -13,14 +8,12 @@
|
||||
|
||||
namespace N_LogView
|
||||
{
|
||||
class LogViewBooleanEdit
|
||||
: public QCheckBox
|
||||
, public LogViewWidget
|
||||
class LogViewBooleanEdit : public QCheckBox, public LogViewWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
LogViewBooleanEdit(LogViewField *a_field, QWidget *a_parent, const bool a_readonly);
|
||||
bool saveContent(LogViewTelegram *a_telegram) override;
|
||||
LogViewBooleanEdit(LogViewField* a_field, QWidget* a_parent, const bool a_readonly);
|
||||
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 <time.h>
|
||||
#include "LogViewField.hpp"
|
||||
@@ -20,18 +20,18 @@
|
||||
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)
|
||||
, LogViewWidget(a_field, this, a_parent, a_readonly)
|
||||
{
|
||||
{
|
||||
if (a_readonly)
|
||||
{
|
||||
setReadOnly(true);
|
||||
setAlignment(a_field->isRightAligned() ? Qt::AlignRight : Qt::AlignLeft);
|
||||
}
|
||||
|
||||
// date-time-field
|
||||
|
||||
qint64 unixTime = 0;
|
||||
if (a_field->hasContent())
|
||||
{
|
||||
@@ -40,45 +40,47 @@ namespace N_LogView
|
||||
else
|
||||
unixTime = a_field->value(0, true).toInt() * 1000LL;
|
||||
}
|
||||
// take actual date and time if time is 0
|
||||
|
||||
if (0 == unixTime && !a_readonly)
|
||||
unixTime = ::time(nullptr) * 1000LL;
|
||||
|
||||
//valueWidget = new QDateTimeEdit(dateTime);
|
||||
|
||||
setDateTime(QDateTime::fromMSecsSinceEpoch(unixTime));
|
||||
setDisplayFormat(QLatin1String("dd MMM yyyy hh:mm:ss"));
|
||||
setCalendarPopup(true);
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// 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())
|
||||
{
|
||||
a_telegram->setJsonValue(m_Field->jsonPath(), dateTime().toMSecsSinceEpoch());
|
||||
}
|
||||
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);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // namespace N_LogView
|
||||
@@ -1,15 +1,15 @@
|
||||
// **************************************************************************
|
||||
//
|
||||
// (C) Copyright 2009 Swiss SIMTEC AG
|
||||
//
|
||||
// **************************************************************************
|
||||
//
|
||||
// $HeadURL$
|
||||
// $LastChangedBy$
|
||||
// $LastChangedDate$
|
||||
// $LastChangedRevision$
|
||||
//
|
||||
// **************************************************************************
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -18,37 +18,23 @@
|
||||
|
||||
namespace N_LogView
|
||||
{
|
||||
/**
|
||||
* Used for date & time
|
||||
*
|
||||
* @author alois.wismer
|
||||
* @version 1.0
|
||||
* @created 20-Mai-2010 17:41:28
|
||||
*/
|
||||
class LogViewDateTimeEdit
|
||||
: public QDateTimeEdit
|
||||
, public LogViewWidget
|
||||
|
||||
|
||||
class LogViewDateTimeEdit : public QDateTimeEdit, public LogViewWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
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.
|
||||
* Returns true if successful.
|
||||
*
|
||||
* @param a_telegram
|
||||
*/
|
||||
bool saveContent(LogViewTelegram *a_telegram) override;
|
||||
|
||||
LogViewDateTimeEdit(LogViewField* a_field, QWidget* a_parent, const bool a_readonly);
|
||||
|
||||
|
||||
|
||||
bool saveContent(LogViewTelegram* a_telegram) override;
|
||||
|
||||
public slots:
|
||||
void checkAndOvertakeContent();
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
@@ -1,17 +1,17 @@
|
||||
// **************************************************************************
|
||||
//
|
||||
// (C) Copyright 2009 Swiss SIMTEC AG
|
||||
//
|
||||
// **************************************************************************
|
||||
//
|
||||
// $HeadURL$
|
||||
// $LastChangedBy$
|
||||
// $LastChangedDate$
|
||||
// $LastChangedRevision$
|
||||
//
|
||||
// **************************************************************************
|
||||
|
||||
// manual class headers
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "LogViewEnumEdit.hpp"
|
||||
#include "LogViewXdrStruct.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)
|
||||
, LogViewWidget(a_field, this, a_parent, a_readonly)
|
||||
{
|
||||
{
|
||||
QString value = a_field->value(a_index);
|
||||
|
||||
// show the tool-tip with special-case for TETRA bitfields
|
||||
|
||||
setToolTip(a_field->toolTipText());
|
||||
|
||||
// fill combobox
|
||||
|
||||
bool bCurrentIndexSet = false;
|
||||
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());
|
||||
if (!a_readonly || enumText == value)
|
||||
@@ -61,33 +61,34 @@ namespace N_LogView
|
||||
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
|
||||
{
|
||||
// todo: check ob wirklich ein struct
|
||||
const LogViewXdrStruct *xdrStruct = static_cast<const LogViewXdrStruct *>(m_Field->xdrElement());
|
||||
|
||||
uint16_t LogViewEnumEdit::getSize() const
|
||||
{
|
||||
|
||||
const LogViewXdrStruct* xdrStruct = static_cast<const LogViewXdrStruct*>(m_Field->xdrElement());
|
||||
return xdrStruct->getEnumSize();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
void LogViewEnumEdit::checkAndOvertakeContent()
|
||||
{
|
||||
|
||||
void LogViewEnumEdit::checkAndOvertakeContent()
|
||||
{
|
||||
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;
|
||||
int value = itemData(currentIndex()).toInt(&ok);
|
||||
if (ok)
|
||||
@@ -98,7 +99,7 @@ namespace N_LogView
|
||||
a_telegram->setUIntX(getSize(), value);
|
||||
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
|
||||
|
||||
@@ -18,41 +18,26 @@
|
||||
|
||||
namespace N_LogView
|
||||
{
|
||||
/**
|
||||
* Used for enums
|
||||
*
|
||||
* @author alois.wismer
|
||||
* @version 1.0
|
||||
* @created 21-Mai-2010 09:31:16
|
||||
*/
|
||||
class LogViewEnumEdit
|
||||
: public QComboBox
|
||||
, public LogViewWidget
|
||||
|
||||
|
||||
class LogViewEnumEdit : public QComboBox, public LogViewWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
/**
|
||||
*
|
||||
* @param a_field
|
||||
* @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);
|
||||
|
||||
|
||||
LogViewEnumEdit(LogViewField* a_field, QWidget* a_parent, const bool a_readonly, const int a_index);
|
||||
|
||||
|
||||
uint16_t getSize() const override;
|
||||
|
||||
/**
|
||||
* Writes the content into telegram.
|
||||
* Returns true if successful.
|
||||
*
|
||||
* @param a_telegram
|
||||
*/
|
||||
bool saveContent(LogViewTelegram *a_telegram) override;
|
||||
|
||||
|
||||
bool saveContent(LogViewTelegram* a_telegram) override;
|
||||
|
||||
protected slots:
|
||||
void checkAndOvertakeContent();
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
@@ -1,15 +1,15 @@
|
||||
// **************************************************************************
|
||||
//
|
||||
// (C) Copyright 2009 Swiss SIMTEC AG
|
||||
//
|
||||
// **************************************************************************
|
||||
//
|
||||
// $HeadURL$
|
||||
// $LastChangedBy$
|
||||
// $LastChangedDate$
|
||||
// $LastChangedRevision$
|
||||
//
|
||||
// **************************************************************************
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#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();
|
||||
|
||||
LogViewField *clone(int arrayIdx) const;
|
||||
@@ -44,7 +44,7 @@ namespace N_LogView
|
||||
void setName(const QString &newVal) { m_Name = newVal; }
|
||||
|
||||
|
||||
void addChild(LogViewField *a_child);
|
||||
void addChild(LogViewField* a_child);
|
||||
void removeLastChild();
|
||||
LogViewField *child(int arrayIdx);
|
||||
int childCount() const { return m_Child.size(); }
|
||||
@@ -57,15 +57,8 @@ namespace N_LogView
|
||||
void addValue(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;
|
||||
int valueListSize() const { return m_ValueList.size(); }
|
||||
|
||||
@@ -81,21 +74,12 @@ namespace N_LogView
|
||||
int64_t getHighestValue() const;
|
||||
int64_t getLowestValue() const;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param a_indent
|
||||
*/
|
||||
|
||||
|
||||
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);
|
||||
|
||||
|
||||
@@ -103,11 +87,10 @@ namespace N_LogView
|
||||
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 isMSecsField() const;
|
||||
|
||||
@@ -115,9 +98,8 @@ namespace N_LogView
|
||||
uint16_t maxArraySize() const { return m_MaxArraySize; }
|
||||
void setMaxArraySize(uint16_t newVal, const bool a_isDynamic);
|
||||
|
||||
/**
|
||||
* True if the array is dynamic.
|
||||
*/
|
||||
|
||||
|
||||
bool isDynamicArray() const { return m_IsDynamicArray; }
|
||||
|
||||
|
||||
@@ -130,7 +112,6 @@ namespace N_LogView
|
||||
QStringList jsonPath() const { return m_jsonPath; }
|
||||
|
||||
protected:
|
||||
NGL::INGLLogger &m_logger;
|
||||
|
||||
QString m_Name;
|
||||
QString m_type;
|
||||
@@ -141,13 +122,12 @@ namespace N_LogView
|
||||
uint16_t m_Offset;
|
||||
int m_Size;
|
||||
uint16_t m_MaxArraySize;
|
||||
/**
|
||||
* True if the array is dynamic.
|
||||
*/
|
||||
|
||||
|
||||
bool m_IsDynamicArray;
|
||||
bool m_HasContent;
|
||||
bool m_bDeleteXdr;
|
||||
QVector<LogViewField *> m_Child;
|
||||
QVector<LogViewField*> m_Child;
|
||||
|
||||
E_FieldKind m_Kind;
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
// **************************************************************************
|
||||
//
|
||||
// (C) Copyright 2009 Swiss SIMTEC AG
|
||||
//
|
||||
// **************************************************************************
|
||||
//
|
||||
// $HeadURL$
|
||||
// $LastChangedBy$
|
||||
// $LastChangedDate$
|
||||
// $LastChangedRevision$
|
||||
//
|
||||
// **************************************************************************
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -24,15 +24,13 @@ namespace N_LogView
|
||||
{
|
||||
class LogViewTelegram;
|
||||
|
||||
/**
|
||||
* @author alois.wismer
|
||||
* @version 1.0
|
||||
* @created 05-Aug-2010 16:02:15
|
||||
*/
|
||||
|
||||
|
||||
class LogViewInjectionThread : public QThread
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
LogViewInjectionThread();
|
||||
|
||||
void run();
|
||||
@@ -41,15 +39,12 @@ namespace N_LogView
|
||||
|
||||
bool isSendingPossible() const;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param a_telegram
|
||||
* @param a_doSendAsCentralTelegram
|
||||
*/
|
||||
void sendTelegram(LogViewTelegram *a_telegram, const bool a_doSendAsCentralTelegram);
|
||||
|
||||
|
||||
void sendTelegram(LogViewTelegram* a_telegram, const bool a_doSendAsCentralTelegram);
|
||||
|
||||
protected:
|
||||
NGL::INGLLogger &m_logger;
|
||||
|
||||
bool m_DoStartConnection;
|
||||
bool m_SendingPossible;
|
||||
QString m_Hostname;
|
||||
@@ -72,12 +67,10 @@ namespace N_LogView
|
||||
|
||||
public:
|
||||
signals:
|
||||
/**
|
||||
*
|
||||
* @param a_picName
|
||||
* @param a_toolTipText
|
||||
*/
|
||||
void updateStatus(const QString &a_picName, const QString &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
|
||||
|
||||
@@ -21,10 +16,10 @@
|
||||
namespace N_LogView
|
||||
{
|
||||
|
||||
class ParticipantModel final : public QAbstractTableModel
|
||||
{
|
||||
class ParticipantModel final : public QAbstractTableModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
public:
|
||||
using QAbstractTableModel::QAbstractTableModel;
|
||||
|
||||
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 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();
|
||||
bool addUpdateParticipants(const QVector<int> &eqIds, const QVector<int> &issis, const QVector<int> &numberOfTelegrams);
|
||||
|
||||
protected:
|
||||
bool addUpdateParticipants(const QVector<int> &eqIds,
|
||||
const QVector<int> &issis,
|
||||
const QVector<int> &numberOfTelegrams);
|
||||
protected:
|
||||
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;
|
||||
// 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
|
||||
public:
|
||||
public:
|
||||
using QAbstractTableModel::QAbstractTableModel;
|
||||
|
||||
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 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 appendTelegrams(const QVector<QSharedPointer<LogViewTelegram>> &telegrams);
|
||||
void appendTelegrams(const QVector<QSharedPointer<LogViewTelegram> > &telegrams);
|
||||
void appendTelegram(const QSharedPointer<LogViewTelegram> &telegram);
|
||||
QSharedPointer<LogViewTelegram> telegram(int row) const;
|
||||
protected:
|
||||
QVector<QSharedPointer<LogViewTelegram> > m_telegrams;
|
||||
};
|
||||
|
||||
protected:
|
||||
QVector<QSharedPointer<LogViewTelegram>> m_telegrams;
|
||||
};
|
||||
|
||||
class TelegramProxyModel final : public QSortFilterProxyModel
|
||||
{
|
||||
class TelegramProxyModel final : public QSortFilterProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
public:
|
||||
using QSortFilterProxyModel::QSortFilterProxyModel;
|
||||
|
||||
void setFilterByEquipmentIds(bool bFilterByEquipmentIds);
|
||||
@@ -93,12 +89,10 @@ namespace N_LogView
|
||||
void setFilterTetraFragmented(bool bFilter);
|
||||
|
||||
QSharedPointer<LogViewTelegram> telegram(int row) const;
|
||||
|
||||
protected:
|
||||
protected:
|
||||
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
|
||||
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
|
||||
|
||||
protected:
|
||||
protected:
|
||||
std::set<int> m_allowedEquipmentIds;
|
||||
std::set<int> m_filteredCentralTelegramIds;
|
||||
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_filterWlsTelegrams;
|
||||
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 <QtCore/QCoreApplication>
|
||||
@@ -28,52 +28,52 @@
|
||||
namespace N_LogView
|
||||
{
|
||||
|
||||
// static member initialization
|
||||
const QString LogViewOptionDialog::SPEC_FILES = tr("Spezifikations-Dateien (*.x)");
|
||||
const QString LogViewOptionDialog::KRLOG_FILES = tr("Log-Dateien (*.krlog)");
|
||||
const QLatin1String LogViewOptionDialog::SPEC_FILES_GROUP("SpecFiles");
|
||||
const QLatin1String LogViewOptionDialog::DIR("Dir");
|
||||
const QLatin1String LogViewOptionDialog::P0_FILENAME("Central2PrtCnv");
|
||||
const QLatin1String LogViewOptionDialog::P5_FILENAME("PrtCnv2TETRA");
|
||||
const QLatin1String LogViewOptionDialog::SERVER_GROUP("ServerPorts");
|
||||
const QLatin1String LogViewOptionDialog::CENTRAL_PORT("Central");
|
||||
const QLatin1String LogViewOptionDialog::TETRA_PORT("Tetra");
|
||||
const QLatin1String LogViewOptionDialog::LOG_FILENAME("LogFilename");
|
||||
const QLatin1String LogViewOptionDialog::INJECTION_GROUP("InjectionServer");
|
||||
const QLatin1String LogViewOptionDialog::INJECTION_HOSTNAME("InjectionHostname");
|
||||
const QLatin1String LogViewOptionDialog::INJECTION_PORT("InjectionPort");
|
||||
|
||||
const QString LogViewOptionDialog::SPEC_FILES = tr("Spezifikations-Dateien (*.x)");
|
||||
const QString LogViewOptionDialog::KRLOG_FILES = tr("Log-Dateien (*.krlog)");
|
||||
const QLatin1String LogViewOptionDialog::SPEC_FILES_GROUP("SpecFiles");
|
||||
const QLatin1String LogViewOptionDialog::DIR("Dir");
|
||||
const QLatin1String LogViewOptionDialog::P0_FILENAME("Central2PrtCnv");
|
||||
const QLatin1String LogViewOptionDialog::P5_FILENAME("PrtCnv2TETRA");
|
||||
const QLatin1String LogViewOptionDialog::SERVER_GROUP("ServerPorts");
|
||||
const QLatin1String LogViewOptionDialog::CENTRAL_PORT("Central");
|
||||
const QLatin1String LogViewOptionDialog::TETRA_PORT("Tetra");
|
||||
const QLatin1String LogViewOptionDialog::LOG_FILENAME("LogFilename");
|
||||
const QLatin1String LogViewOptionDialog::INJECTION_GROUP("InjectionServer");
|
||||
const QLatin1String LogViewOptionDialog::INJECTION_HOSTNAME("InjectionHostname");
|
||||
const QLatin1String LogViewOptionDialog::INJECTION_PORT("InjectionPort");
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
LogViewOptionDialog::LogViewOptionDialog(QWidget *a_parent)
|
||||
|
||||
LogViewOptionDialog::LogViewOptionDialog(QWidget* 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);
|
||||
QGroupBox *groupBox = new QGroupBox(tr("Telegramm-Spezifikations-Dateien"), this);
|
||||
QGroupBox* groupBox = new QGroupBox(tr("Telegramm-Spezifikations-Dateien"), this);
|
||||
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);
|
||||
QString defString = QCoreApplication::applicationDirPath() + QLatin1String("/training_area_telegrams.h");
|
||||
m_P0Edit = new QLineEdit(m_Settings.value(P0_FILENAME, defString).toString(), this);
|
||||
m_P0Edit->setMinimumWidth(400);
|
||||
groupLayout->addWidget(m_P0Edit);
|
||||
QPushButton *p0Browse = new QPushButton(tr("Browse"), this);
|
||||
QPushButton* p0Browse = new QPushButton(tr("Browse"), this);
|
||||
p0Label->setBuddy(p0Browse);
|
||||
connect(p0Browse, &QPushButton::clicked, this, &LogViewOptionDialog::browseP0File);
|
||||
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);
|
||||
defString = QCoreApplication::applicationDirPath() + QLatin1String("/zsksxd_tetraForLogView.x");
|
||||
m_P5Edit = new QLineEdit(m_Settings.value(P5_FILENAME, defString).toString(), this);
|
||||
groupLayout->addWidget(m_P5Edit);
|
||||
QPushButton *p5Browse = new QPushButton(tr("Browse"), this);
|
||||
QPushButton* p5Browse = new QPushButton(tr("Browse"), this);
|
||||
p5Label->setBuddy(p5Browse);
|
||||
connect(p5Browse, &QPushButton::clicked, this, &LogViewOptionDialog::browseP5File);
|
||||
groupLayout->addWidget(p5Browse, 3, 1);
|
||||
@@ -81,20 +81,20 @@ namespace N_LogView
|
||||
groupBox->setLayout(groupLayout);
|
||||
m_Settings.endGroup();
|
||||
|
||||
// injection
|
||||
|
||||
m_Settings.beginGroup(LogViewOptionDialog::INJECTION_GROUP);
|
||||
groupBox = new QGroupBox(tr("Telegram Injection Server"), this);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
m_InjectHostnameEdit = new QLineEdit(m_Settings.value(INJECTION_HOSTNAME).toString(), this);
|
||||
injectLayout->addWidget(m_InjectHostnameEdit, 0, 1);
|
||||
@@ -102,20 +102,20 @@ namespace N_LogView
|
||||
groupBox->setLayout(injectLayout);
|
||||
m_Settings.endGroup();
|
||||
|
||||
// buttons
|
||||
|
||||
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::rejected, this, &LogViewOptionDialog::reject);
|
||||
layout->addWidget(buttonBox);
|
||||
|
||||
//setLayout(layout);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
void LogViewOptionDialog::browseP0File()
|
||||
{
|
||||
|
||||
void LogViewOptionDialog::browseP0File()
|
||||
{
|
||||
QString newFilename = QFileDialog::getOpenFileName(this,
|
||||
tr("Zentrale - Protokollkonverter Spezifikations-Datei"),
|
||||
m_Settings.value(DIR).toString(),
|
||||
@@ -128,12 +128,12 @@ namespace N_LogView
|
||||
m_Settings.setValue(DIR, dir.filePath(newFilename));
|
||||
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);
|
||||
if (!newFilename.isEmpty())
|
||||
{
|
||||
@@ -143,18 +143,19 @@ namespace N_LogView
|
||||
m_Settings.setValue(DIR, dir.filePath(newFilename));
|
||||
m_Settings.endGroup();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
void LogViewOptionDialog::save()
|
||||
{
|
||||
|
||||
void LogViewOptionDialog::save()
|
||||
{
|
||||
uint32_t changedFlags = 0;
|
||||
|
||||
// check group wise for changes
|
||||
// specification files
|
||||
|
||||
|
||||
m_Settings.beginGroup(LogViewOptionDialog::SPEC_FILES_GROUP);
|
||||
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(P5_FILENAME, m_P5Edit->text());
|
||||
@@ -162,9 +163,10 @@ namespace N_LogView
|
||||
}
|
||||
m_Settings.endGroup();
|
||||
|
||||
// injection settings
|
||||
|
||||
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_PORT, m_InjectPortEdit->text());
|
||||
@@ -175,6 +177,6 @@ namespace N_LogView
|
||||
emit settingsChanged(changedFlags);
|
||||
|
||||
accept();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace N_LogView
|
||||
}
|
||||
@@ -1,15 +1,15 @@
|
||||
// **************************************************************************
|
||||
//
|
||||
// (C) Copyright 2009 Swiss SIMTEC AG
|
||||
//
|
||||
// **************************************************************************
|
||||
//
|
||||
// $HeadURL$
|
||||
// $LastChangedBy$
|
||||
// $LastChangedDate$
|
||||
// $LastChangedRevision$
|
||||
//
|
||||
// **************************************************************************
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -20,19 +20,14 @@ class QLineEdit;
|
||||
|
||||
namespace N_LogView
|
||||
{
|
||||
/**
|
||||
* This class lets the user view and change the settings of the application
|
||||
*
|
||||
* @author alois.wismer
|
||||
* @version 1.0
|
||||
* @created 09-Mrz-2010 14:49:40
|
||||
*/
|
||||
class LogViewOptionDialog : public QDialog
|
||||
{
|
||||
|
||||
|
||||
class LogViewOptionDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum SettingsChangedFlag
|
||||
{
|
||||
public:
|
||||
|
||||
enum SettingsChangedFlag {
|
||||
SpecFilesGroup = 0x01,
|
||||
ServerGroup = 0x02,
|
||||
InjectionGroup = 0x04
|
||||
@@ -55,16 +50,15 @@ namespace N_LogView
|
||||
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 QLatin1String DIR;
|
||||
bool m_IsServer;
|
||||
@@ -74,10 +68,10 @@ namespace N_LogView
|
||||
QLineEdit *m_InjectHostnameEdit;
|
||||
QLineEdit *m_InjectPortEdit;
|
||||
|
||||
protected slots:
|
||||
protected slots:
|
||||
void browseP0File();
|
||||
void browseP5File();
|
||||
void save();
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
@@ -1,15 +1,15 @@
|
||||
// **************************************************************************
|
||||
//
|
||||
// (C) Copyright 2009 Swiss SIMTEC AG
|
||||
//
|
||||
// **************************************************************************
|
||||
//
|
||||
// $HeadURL$
|
||||
// $LastChangedBy$
|
||||
// $LastChangedDate$
|
||||
// $LastChangedRevision$
|
||||
//
|
||||
// **************************************************************************
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "LogViewSpinBox.hpp"
|
||||
#include "LogViewField.hpp"
|
||||
@@ -17,42 +17,43 @@
|
||||
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)
|
||||
, LogViewWidget(a_field, this, a_parent, false)
|
||||
{
|
||||
// set range
|
||||
{
|
||||
|
||||
uint16_t maxArraySize = a_field->maxArraySize();
|
||||
setRange(0, maxArraySize);
|
||||
|
||||
// set the actual value
|
||||
|
||||
setValue(a_value);
|
||||
|
||||
// set tooltip-text
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// 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);
|
||||
// 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
|
||||
|
||||
@@ -18,44 +18,28 @@
|
||||
|
||||
namespace N_LogView
|
||||
{
|
||||
/**
|
||||
* Used for changing size of dyn. arrays.
|
||||
*
|
||||
* @author alois.wismer
|
||||
* @version 1.0
|
||||
* @created 25-Mai-2010 10:39:45
|
||||
*/
|
||||
class LogViewSpinBox
|
||||
: public QSpinBox
|
||||
, public LogViewWidget
|
||||
|
||||
|
||||
class LogViewSpinBox : public QSpinBox, public LogViewWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
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.
|
||||
* Returns true if successful.
|
||||
*
|
||||
* @param a_telegram
|
||||
*/
|
||||
bool saveContent(LogViewTelegram *a_telegram) override;
|
||||
|
||||
LogViewSpinBox(LogViewField* a_field, QWidget* a_parent, const int a_value);
|
||||
|
||||
|
||||
|
||||
bool saveContent(LogViewTelegram* a_telegram) override;
|
||||
|
||||
protected slots:
|
||||
void finishEditing();
|
||||
|
||||
signals:
|
||||
/**
|
||||
*
|
||||
* @param 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 <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)
|
||||
, LogViewWidget(a_field, this, a_parent, false)
|
||||
, m_TelegramDialog(a_parent)
|
||||
, m_SpinBox(a_spinBox)
|
||||
, m_logger(logger)
|
||||
{
|
||||
{
|
||||
setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
void LogViewTabWidget::changeSize(const int a_newSize)
|
||||
{
|
||||
// add new tabs
|
||||
|
||||
void LogViewTabWidget::changeSize(const int a_newSize)
|
||||
{
|
||||
|
||||
for (int i = count(); i < a_newSize; i++)
|
||||
addTab(m_Field, true, i);
|
||||
|
||||
// remove old tabs
|
||||
|
||||
while (count() > a_newSize)
|
||||
{
|
||||
QStringList path = m_Field->jsonPath();
|
||||
@@ -56,19 +55,19 @@ namespace N_LogView
|
||||
|
||||
|
||||
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())
|
||||
return true;
|
||||
// if m_SpinBox is NULL, we have a static array => no size has to be stored
|
||||
|
||||
if (m_SpinBox)
|
||||
{
|
||||
if (!isValid())
|
||||
@@ -76,12 +75,12 @@ namespace N_LogView
|
||||
a_telegram->setUIntX(LogViewTelegram::SIZE_CENTRAL_DYN_ARRAY_SIZE, count());
|
||||
}
|
||||
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)
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Invalid array index given: " << arrayIdx;
|
||||
@@ -90,7 +89,7 @@ namespace N_LogView
|
||||
|
||||
QFrame *frame = new QFrame;
|
||||
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)
|
||||
a_field->setHasContent(false);
|
||||
auto *childTree = a_field->child(arrayIdx);
|
||||
@@ -122,11 +121,11 @@ namespace N_LogView
|
||||
}
|
||||
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)
|
||||
{
|
||||
int spinValue = m_SpinBox->value();
|
||||
@@ -135,6 +134,6 @@ namespace N_LogView
|
||||
}
|
||||
|
||||
setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace N_LogView
|
||||
}
|
||||
@@ -1,21 +1,20 @@
|
||||
// **************************************************************************
|
||||
//
|
||||
// (C) Copyright 2009 Swiss SIMTEC AG
|
||||
//
|
||||
// **************************************************************************
|
||||
//
|
||||
// $HeadURL$
|
||||
// $LastChangedBy$
|
||||
// $LastChangedDate$
|
||||
// $LastChangedRevision$
|
||||
//
|
||||
// **************************************************************************
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QtWidgets/QTabWidget>
|
||||
#include "LogViewWidget.hpp"
|
||||
#include "logger.h"
|
||||
|
||||
|
||||
namespace N_LogView
|
||||
@@ -23,35 +22,28 @@ namespace N_LogView
|
||||
class LogViewTelegramDialog;
|
||||
class LogViewSpinBox;
|
||||
|
||||
/**
|
||||
* Used for arrays of structures
|
||||
*
|
||||
* @author alois.wismer
|
||||
* @version 1.0
|
||||
* @created 26-Mai-2010 17:12:30
|
||||
*/
|
||||
class LogViewTabWidget
|
||||
: public QTabWidget
|
||||
, public LogViewWidget
|
||||
|
||||
|
||||
class LogViewTabWidget : public QTabWidget, public LogViewWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
LogViewTabWidget(LogViewField *a_field, LogViewTelegramDialog *a_parent, LogViewSpinBox *a_spinBox, NGL::INGLLogger &logger);
|
||||
|
||||
bool saveContent(LogViewTelegram *a_telegram) override;
|
||||
void addTab(LogViewField *a_field, const bool a_isEmpty, int arrayIdx);
|
||||
LogViewTabWidget(LogViewField* a_field, LogViewTelegramDialog* a_parent, LogViewSpinBox* a_spinBox);
|
||||
|
||||
bool saveContent(LogViewTelegram* a_telegram) override;
|
||||
void addTab(LogViewField* a_field, const bool a_isEmpty, int arrayIdx);
|
||||
|
||||
public slots:
|
||||
/**
|
||||
*
|
||||
* @param a_newSize
|
||||
*/
|
||||
|
||||
|
||||
void changeSize(const int a_newSize);
|
||||
|
||||
protected:
|
||||
LogViewTelegramDialog *m_TelegramDialog;
|
||||
LogViewSpinBox *m_SpinBox;
|
||||
NGL::INGLLogger &m_logger;
|
||||
|
||||
LogViewTelegramDialog* m_TelegramDialog;
|
||||
LogViewSpinBox* m_SpinBox;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
@@ -1,17 +1,17 @@
|
||||
// **************************************************************************
|
||||
//
|
||||
// (C) Copyright 2009 Swiss SIMTEC AG
|
||||
//
|
||||
// **************************************************************************
|
||||
//
|
||||
// $HeadURL$
|
||||
// $LastChangedBy$
|
||||
// $LastChangedDate$
|
||||
// $LastChangedRevision$
|
||||
//
|
||||
// **************************************************************************
|
||||
|
||||
// manual class headers
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "LogViewTableWidget.hpp"
|
||||
#include "LogViewField.hpp"
|
||||
#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)
|
||||
, LogViewWidget(a_field, this, a_parent, a_readonly)
|
||||
, m_IsFloat(false)
|
||||
, m_IsEnum(false)
|
||||
, m_logger(logger)
|
||||
{
|
||||
{
|
||||
switch (m_Field->xdrElement()->getKind())
|
||||
{
|
||||
case LogViewXdrElement::e_KindEnum:
|
||||
m_IsEnum = true;
|
||||
break;
|
||||
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)
|
||||
setColumnCount(3);
|
||||
@@ -55,18 +54,18 @@ namespace N_LogView
|
||||
}
|
||||
setAlternatingRowColors(true);
|
||||
|
||||
// make pretty
|
||||
// horizontalHeader()->setResizeMode(2, QHeaderView::Stretch);
|
||||
|
||||
|
||||
|
||||
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();
|
||||
setRowCount(nbrOfRows);
|
||||
for (int i = 0; i < nbrOfRows; i++)
|
||||
@@ -74,38 +73,41 @@ namespace N_LogView
|
||||
|
||||
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);
|
||||
|
||||
disconnect(this, &LogViewTableWidget::itemChanged, this, &LogViewTableWidget::checkAndOvertakeContent);
|
||||
// check and set the new fields
|
||||
disconnect(this, &LogViewTableWidget::itemChanged,
|
||||
this, &LogViewTableWidget::checkAndOvertakeContent);
|
||||
|
||||
for (int i = 0; i < a_newSize; i++)
|
||||
changeRow(i, QLatin1String("0"));
|
||||
|
||||
connect(this, &LogViewTableWidget::itemChanged, this, &LogViewTableWidget::checkAndOvertakeContent);
|
||||
connect(this, &LogViewTableWidget::itemChanged,
|
||||
this, &LogViewTableWidget::checkAndOvertakeContent);
|
||||
|
||||
makePretty();
|
||||
|
||||
m_Valid = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
void LogViewTableWidget::changeRow(const int a_rowIndex, const QString &a_value)
|
||||
{
|
||||
// INFO_LOG(m_logger) << "a_rowIndex=" << a_rowIndex << " a_value=" << a_value.toStdString();
|
||||
|
||||
void LogViewTableWidget::changeRow(const int a_rowIndex, const QString& a_value)
|
||||
{
|
||||
|
||||
|
||||
if (m_IsEnum)
|
||||
{
|
||||
// enum
|
||||
QWidget *enumItem = cellWidget(a_rowIndex, 0);
|
||||
|
||||
QWidget* enumItem = cellWidget(a_rowIndex, 0);
|
||||
if (!enumItem)
|
||||
setCellWidget(a_rowIndex, 0, new LogViewEnumEdit(m_Field, this, m_Readonly, a_rowIndex));
|
||||
}
|
||||
@@ -114,12 +116,12 @@ namespace N_LogView
|
||||
QFont font;
|
||||
font.setStyleHint(QFont::TypeWriter);
|
||||
font.setFamily(QString());
|
||||
// decimal
|
||||
QTableWidgetItem *decItem = item(a_rowIndex, 0);
|
||||
|
||||
QTableWidgetItem* decItem = item(a_rowIndex, 0);
|
||||
if (!decItem)
|
||||
{
|
||||
decItem = new QTableWidgetItem();
|
||||
//decItem->setData(Qt::DisplayRole, 0);
|
||||
|
||||
decItem->setText(a_value);
|
||||
decItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||
if (!m_Readonly)
|
||||
@@ -131,8 +133,8 @@ namespace N_LogView
|
||||
setItem(a_rowIndex, 0, decItem);
|
||||
}
|
||||
|
||||
// hexadecimal
|
||||
QTableWidgetItem *hexItem = item(a_rowIndex, 1);
|
||||
|
||||
QTableWidgetItem* hexItem = item(a_rowIndex, 1);
|
||||
if (!hexItem)
|
||||
{
|
||||
hexItem = new QTableWidgetItem();
|
||||
@@ -142,10 +144,10 @@ namespace N_LogView
|
||||
setItem(a_rowIndex, 1, hexItem);
|
||||
}
|
||||
|
||||
// binary
|
||||
|
||||
if (!m_IsFloat)
|
||||
{
|
||||
QTableWidgetItem *binItem = item(a_rowIndex, 2);
|
||||
QTableWidgetItem* binItem = item(a_rowIndex, 2);
|
||||
if (!binItem)
|
||||
{
|
||||
binItem = new QTableWidgetItem();
|
||||
@@ -156,18 +158,17 @@ namespace N_LogView
|
||||
}
|
||||
}
|
||||
|
||||
// set the values
|
||||
|
||||
checkAndOvertakeContent(decItem);
|
||||
makePretty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
void LogViewTableWidget::checkAndOvertakeContent(QTableWidgetItem *a_changedItem)
|
||||
{
|
||||
if (a_changedItem->column() != 0)
|
||||
return;
|
||||
|
||||
void LogViewTableWidget::checkAndOvertakeContent(QTableWidgetItem* a_changedItem)
|
||||
{
|
||||
if (a_changedItem->column() != 0) return;
|
||||
|
||||
int row = a_changedItem->row();
|
||||
QString text = a_changedItem->text();
|
||||
@@ -177,70 +178,67 @@ namespace N_LogView
|
||||
int64_t intValue = 0;
|
||||
double floatValue = 0.0;
|
||||
|
||||
// get the calculated and checked value
|
||||
|
||||
if (m_IsFloat)
|
||||
floatValue = getFloat(text, (uint64_t &)intValue, ok, true);
|
||||
floatValue = getFloat(text, (uint64_t&)intValue, ok, true);
|
||||
else
|
||||
intValue = getInteger(text, ok);
|
||||
|
||||
// handle errors
|
||||
|
||||
if (!ok)
|
||||
{
|
||||
setFocus();
|
||||
// selectAll();
|
||||
setCurrentCell(row, 0); // todo: funktioniert nicht
|
||||
|
||||
setCurrentCell(row, 0);
|
||||
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 *hexField = item(row, 1);
|
||||
if (hexField)
|
||||
hexField->setText(toHex(intValue));
|
||||
QTableWidgetItem* decField = item(row, 0);
|
||||
if (decField) decField->setText(QString::number(m_IsFloat ? floatValue : intValue));
|
||||
|
||||
|
||||
QTableWidgetItem* hexField = item(row, 1);
|
||||
if (hexField) hexField->setText(toHex(intValue));
|
||||
|
||||
|
||||
// set the binary value
|
||||
if (!m_IsFloat)
|
||||
{
|
||||
QTableWidgetItem *binField = item(row, 2);
|
||||
if (binField)
|
||||
binField->setText(toBin(intValue));
|
||||
}
|
||||
QTableWidgetItem* binField = item(row, 2);
|
||||
if (binField) binField->setText(toBin(intValue));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
void LogViewTableWidget::makePretty()
|
||||
{
|
||||
//horizontalHeader()->setResizeMode(2, QHeaderView::Stretch);
|
||||
|
||||
void LogViewTableWidget::makePretty()
|
||||
{
|
||||
|
||||
resizeColumnsToContents();
|
||||
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())
|
||||
return false;
|
||||
|
||||
@@ -272,20 +270,20 @@ namespace N_LogView
|
||||
{
|
||||
arraySize = rowCount();
|
||||
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
|
||||
{
|
||||
// todo: teste mit opaque[]
|
||||
|
||||
arraySize = m_Field->maxArraySize();
|
||||
}
|
||||
// copy the data
|
||||
|
||||
INFO_LOG(m_logger) << "arraySize=" << arraySize;
|
||||
for (int i = 0; i < arraySize; i++)
|
||||
{
|
||||
if (m_IsEnum)
|
||||
{
|
||||
LogViewEnumEdit *enumEdit = dynamic_cast<LogViewEnumEdit *>(cellWidget(i, 0));
|
||||
LogViewEnumEdit *enumEdit = dynamic_cast<LogViewEnumEdit*>(cellWidget(i,0));
|
||||
enumEdit->saveContent(a_telegram);
|
||||
}
|
||||
else
|
||||
@@ -298,7 +296,7 @@ namespace N_LogView
|
||||
}
|
||||
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();
|
||||
uint64_t hex;
|
||||
getFloat(text, hex, m_Valid);
|
||||
@@ -308,6 +306,6 @@ namespace N_LogView
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace N_LogView
|
||||
}
|
||||
@@ -1,59 +1,46 @@
|
||||
// **************************************************************************
|
||||
//
|
||||
// (C) Copyright 2009 Swiss SIMTEC AG
|
||||
//
|
||||
// **************************************************************************
|
||||
//
|
||||
// $HeadURL$
|
||||
// $LastChangedBy$
|
||||
// $LastChangedDate$
|
||||
// $LastChangedRevision$
|
||||
//
|
||||
// **************************************************************************
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QTableWidget>
|
||||
#include "LogViewWidget.hpp"
|
||||
#include "logger.h"
|
||||
|
||||
namespace N_LogView
|
||||
{
|
||||
/**
|
||||
* Used for arrays of data (opaque)
|
||||
*
|
||||
* @author alois.wismer
|
||||
* @version 1.0
|
||||
* @created 25-Mai-2010 09:34:24
|
||||
*/
|
||||
class LogViewTableWidget
|
||||
: public QTableWidget
|
||||
, public LogViewWidget
|
||||
|
||||
|
||||
class LogViewTableWidget : public QTableWidget, public LogViewWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
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.
|
||||
*
|
||||
* @param a_telegram
|
||||
*/
|
||||
bool saveContent(LogViewTelegram *a_telegram) override;
|
||||
|
||||
|
||||
bool saveContent(LogViewTelegram* a_telegram) override;
|
||||
|
||||
public slots:
|
||||
void changeSize(const int a_newSize);
|
||||
|
||||
protected:
|
||||
void changeRow(const int a_rowIndex, const QString &a_value);
|
||||
void changeRow(const int a_rowIndex, const QString& a_value);
|
||||
void makePretty();
|
||||
protected slots:
|
||||
void checkAndOvertakeContent(QTableWidgetItem *a_changedItem);
|
||||
void checkAndOvertakeContent(QTableWidgetItem* a_changedItem);
|
||||
|
||||
private:
|
||||
bool m_IsFloat;
|
||||
bool m_IsEnum;
|
||||
NGL::INGLLogger &m_logger;
|
||||
};
|
||||
}
|
||||
@@ -1,15 +1,15 @@
|
||||
// **************************************************************************
|
||||
//
|
||||
// (C) Copyright 2009 Swiss SIMTEC AG
|
||||
//
|
||||
// **************************************************************************
|
||||
//
|
||||
// $HeadURL$
|
||||
// $LastChangedBy$
|
||||
// $LastChangedDate$
|
||||
// $LastChangedRevision$
|
||||
//
|
||||
// **************************************************************************
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -32,28 +32,14 @@ namespace N_LogView
|
||||
class LogViewTetraTelegramsParser;
|
||||
class LogViewXdrParser;
|
||||
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
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @author alois.wismer
|
||||
* @version 1.0
|
||||
* @created 12-Mrz-2010 11:04:14
|
||||
*/
|
||||
|
||||
|
||||
|
||||
enum E_Validity
|
||||
{
|
||||
e_NotYetEvaluated,
|
||||
@@ -61,11 +47,8 @@ namespace N_LogView
|
||||
e_Invalid
|
||||
};
|
||||
|
||||
/**
|
||||
* @author alois.wismer
|
||||
* @version 1.0
|
||||
* @created 05-Mai-2010 09:07:22
|
||||
*/
|
||||
|
||||
|
||||
enum E_Column
|
||||
{
|
||||
e_ColName,
|
||||
@@ -78,83 +61,55 @@ namespace N_LogView
|
||||
|
||||
~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;
|
||||
|
||||
|
||||
/**
|
||||
* Copy ctor
|
||||
*/
|
||||
|
||||
|
||||
LogViewTelegram(const LogViewTelegram &o);
|
||||
// no assignment (needed)
|
||||
|
||||
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);
|
||||
|
||||
/**
|
||||
* Writes a_value with size a_size at actual position of m_Data (given with
|
||||
* 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
|
||||
* @param a_value
|
||||
* @param a_byteOrder
|
||||
*/
|
||||
void setUIntX(const uint8_t a_size, quint64 a_value, const LogViewXdrStandardType::E_ByteOrder a_byteOrder = LogViewXdrStandardType::e_ByteOrderBigEndian);
|
||||
LogViewTelegram(const N_CoPrtCnv::CoPrtCnvLogHeader::E_CoPrtCnvProtocol a_destination,
|
||||
int telegramId);
|
||||
|
||||
|
||||
|
||||
LogViewTelegram(const N_CoPrtCnv::CoPrtCnvLogHeader::E_CoPrtCnvProtocol a_destination,
|
||||
const quint64 a_unixTime,
|
||||
const QByteArray &a_telegramData);
|
||||
|
||||
|
||||
|
||||
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);
|
||||
|
||||
/**
|
||||
* Returns the log-time of the telegram
|
||||
*/
|
||||
|
||||
|
||||
quint64 getLogTime() const { return m_LogTime; }
|
||||
quint64 getLogTimeMsec() const;
|
||||
|
||||
/**
|
||||
* Returns the log-time of the telegram as pretty formatted text
|
||||
*/
|
||||
|
||||
|
||||
QString getLogTimeText() const;
|
||||
|
||||
|
||||
QString getDestinationText() const;
|
||||
|
||||
/**
|
||||
* Returns the gps-time of the telegram
|
||||
*/
|
||||
|
||||
|
||||
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;
|
||||
|
||||
|
||||
@@ -163,26 +118,19 @@ namespace N_LogView
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
|
||||
void resetOffset();
|
||||
|
||||
|
||||
LogViewField *getFieldTree();
|
||||
LogViewField* getFieldTree();
|
||||
|
||||
|
||||
void dump() const;
|
||||
@@ -210,46 +158,34 @@ namespace N_LogView
|
||||
|
||||
bool isJsonTelegram() const { return N_CoPrtCnv::CoPrtCnvLogHeader::e_DestProtocolCentral == m_Protocol; }
|
||||
void clearJsonData() { m_json.remove(QStringLiteral("data")); }
|
||||
void rebuildJsonString()
|
||||
{
|
||||
if (!m_json.isEmpty())
|
||||
m_data.clear();
|
||||
}
|
||||
void rebuildJsonString() { if (!m_json.isEmpty()) m_data.clear(); }
|
||||
void setJsonValue(const QStringList &path, const QJsonValue &val);
|
||||
QJsonObject jsonData() const { return m_json; }
|
||||
void updateJsonValue(const QStringList &path, const QJsonValue &newVal, QJsonObject &obj);
|
||||
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 LogViewXdrParser *tetraParser();
|
||||
|
||||
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; }
|
||||
|
||||
/**
|
||||
* The time to wait after sending this telegram in milliseconds.
|
||||
*
|
||||
* @param newVal
|
||||
*/
|
||||
|
||||
|
||||
void setWaitTime(uint32_t newVal) { m_WaitTime = newVal; }
|
||||
|
||||
/**
|
||||
* The name of the telegram, shown in edit-list
|
||||
*/
|
||||
|
||||
|
||||
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; }
|
||||
|
||||
|
||||
@@ -261,9 +197,8 @@ namespace N_LogView
|
||||
|
||||
void actualizeGpsTime();
|
||||
|
||||
/**
|
||||
* Create the tooltip text for the column 'Name'
|
||||
*/
|
||||
|
||||
|
||||
void createToolTipTextForColName();
|
||||
|
||||
|
||||
@@ -273,40 +208,32 @@ namespace N_LogView
|
||||
static uint32_t floatToXdr(float in);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* The name of the telegram, shown in edit-list
|
||||
*/
|
||||
|
||||
|
||||
|
||||
QString m_Name;
|
||||
/**
|
||||
* The tooltip text for caching purposes
|
||||
*/
|
||||
|
||||
|
||||
std::vector<QString> m_ToolTipText;
|
||||
/**
|
||||
* The time to wait after sending this telegram in milliseconds.
|
||||
*/
|
||||
|
||||
|
||||
uint32_t m_WaitTime;
|
||||
int m_ParticipantId;
|
||||
/**
|
||||
* The ISSI of TETRA-Protocol
|
||||
*/
|
||||
|
||||
|
||||
uint32_t m_ISSI;
|
||||
/**
|
||||
* The allocated size of m_Data. (Used for optimizing of speed)
|
||||
*/
|
||||
|
||||
|
||||
int m_AllocatedSize;
|
||||
static const LogViewXdrParser *m_Parser;
|
||||
static const LogViewXdrParser* m_Parser;
|
||||
uint16_t m_ActOffset;
|
||||
QVector<uint16_t> m_GpsFieldOffset;
|
||||
int m_TelId;
|
||||
/**
|
||||
* used for dyn. array in TETRA-Protocol
|
||||
*/
|
||||
|
||||
|
||||
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;
|
||||
static const uint16_t START_OFFSET_CENTRAL;
|
||||
static const uint16_t POS_CENTRAL_COUNTER;
|
||||
@@ -335,14 +262,14 @@ namespace N_LogView
|
||||
QJsonObject m_json;
|
||||
|
||||
N_CoPrtCnv::CoPrtCnvRadioTelegram *m_TetraTelegram;
|
||||
NGL::INGLLogger &m_logger;
|
||||
|
||||
LogViewField *getFieldTree(const QString &a_type,
|
||||
const QString &a_name,
|
||||
uint16_t a_arraySize,
|
||||
const LogViewXdrType *a_parentElement = nullptr,
|
||||
LogViewField *getFieldTree(const QString& a_type, const QString& a_name,
|
||||
uint16_t a_arraySize, const LogViewXdrType* a_parentElement = nullptr,
|
||||
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,
|
||||
LogViewField *parent,
|
||||
@@ -374,108 +301,70 @@ namespace N_LogView
|
||||
static QString typeFromStructInformation(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;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param a_offset
|
||||
*/
|
||||
|
||||
|
||||
uint32_t getUInt32(const uint16_t a_offset) const;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param a_offset
|
||||
*/
|
||||
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param a_offset
|
||||
* @param a_size
|
||||
*/
|
||||
quint64 getUIntX(const uint16_t a_offset, const uint8_t a_size, const LogViewXdrStandardType::E_ByteOrder a_byteOrder = LogViewXdrStandardType::e_ByteOrderBigEndian) const;
|
||||
|
||||
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
*
|
||||
* @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;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param a_errorText
|
||||
* @param a_title
|
||||
*/
|
||||
void showMessageBox(const QString &a_errorText, const QString &a_title = QObject::tr("Invalid telegram")) const;
|
||||
LogViewField* getContent(const LogViewXdrStandardType* a_standardType, uint16_t& a_offset, const uint16_t a_arraySize);
|
||||
|
||||
/**
|
||||
*
|
||||
* @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); }
|
||||
|
||||
/**
|
||||
*
|
||||
* @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);
|
||||
bool isScalar(const LogViewXdrType* a_xdrType) const;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
|
||||
friend class LogViewTabWidget;
|
||||
|
||||
};
|
||||
}
|
||||
@@ -1,10 +1,5 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* some models for LogViewGui
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "LogViewTelegramEditModel.hpp"
|
||||
#include <algorithm>
|
||||
@@ -12,21 +7,21 @@
|
||||
namespace N_LogView
|
||||
{
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
int TelegramEditModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
|
||||
int TelegramEditModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
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 (role == Qt::DisplayRole)
|
||||
@@ -50,11 +45,13 @@ namespace N_LogView
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
switch (section)
|
||||
@@ -70,97 +67,97 @@ namespace N_LogView
|
||||
}
|
||||
}
|
||||
return QAbstractTableModel::headerData(section, orientation, role);
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
void TelegramEditModel::clearTelegrams()
|
||||
{
|
||||
|
||||
void TelegramEditModel::clearTelegrams()
|
||||
{
|
||||
beginResetModel();
|
||||
m_telegrams.clear();
|
||||
endResetModel();
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
void TelegramEditModel::appendTelegrams(const QVector<QSharedPointer<LogViewTelegram>> &telegrams)
|
||||
{
|
||||
|
||||
void TelegramEditModel::appendTelegrams(const QVector<QSharedPointer<LogViewTelegram> > &telegrams)
|
||||
{
|
||||
if (telegrams.isEmpty())
|
||||
return;
|
||||
beginInsertRows(QModelIndex(), m_telegrams.size(), m_telegrams.size() + telegrams.size() - 1);
|
||||
m_telegrams += telegrams;
|
||||
endInsertRows();
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
int TelegramEditModel::appendTelegram(const QSharedPointer<LogViewTelegram> &telegram)
|
||||
{
|
||||
|
||||
int TelegramEditModel::appendTelegram(const QSharedPointer<LogViewTelegram> &telegram)
|
||||
{
|
||||
beginInsertRows(QModelIndex(), m_telegrams.size(), m_telegrams.size());
|
||||
m_telegrams.push_back(telegram);
|
||||
telegram->rebuildJsonString();
|
||||
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())
|
||||
return m_telegrams.at(row);
|
||||
return QSharedPointer<LogViewTelegram>();
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
bool TelegramEditModel::moveUp(int row)
|
||||
{
|
||||
|
||||
bool TelegramEditModel::moveUp(int row)
|
||||
{
|
||||
if (row <= 0 || row >= m_telegrams.size())
|
||||
return false;
|
||||
beginMoveRows(QModelIndex(), row, row, QModelIndex(), row - 1);
|
||||
std::swap(m_telegrams[row], m_telegrams[row - 1]);
|
||||
endMoveRows();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
bool TelegramEditModel::moveDown(int row)
|
||||
{
|
||||
|
||||
bool TelegramEditModel::moveDown(int row)
|
||||
{
|
||||
if (row >= (m_telegrams.size() - 1))
|
||||
return false;
|
||||
beginMoveRows(QModelIndex(), row, row, QModelIndex(), row + 1);
|
||||
std::swap(m_telegrams[row], m_telegrams[row + 1]);
|
||||
endMoveRows();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
void TelegramEditModel::emitDataChanged(int row)
|
||||
{
|
||||
|
||||
void TelegramEditModel::emitDataChanged(int row)
|
||||
{
|
||||
QModelIndex top = createIndex(row, 0);
|
||||
QModelIndex bottom = createIndex(row, columnCount() - 1);
|
||||
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();
|
||||
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);
|
||||
beginRemoveRows(QModelIndex(), row, row);
|
||||
m_telegrams.remove(row);
|
||||
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())
|
||||
return;
|
||||
beginInsertRows(QModelIndex(), row, row);
|
||||
m_telegrams.insert(row, QSharedPointer<LogViewTelegram>(new LogViewTelegram(*tele.data())));
|
||||
endInsertRows();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace N_LogView
|
||||
}
|
||||
@@ -1,10 +1,5 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* some models for LogViewGui
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -15,10 +10,10 @@
|
||||
|
||||
namespace N_LogView
|
||||
{
|
||||
class TelegramEditModel final : public QAbstractTableModel
|
||||
{
|
||||
class TelegramEditModel final : public QAbstractTableModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
public:
|
||||
using QAbstractTableModel::QAbstractTableModel;
|
||||
|
||||
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 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 appendTelegrams(const QVector<QSharedPointer<LogViewTelegram>> &telegrams);
|
||||
void appendTelegrams(const QVector<QSharedPointer<LogViewTelegram> > &telegrams);
|
||||
int appendTelegram(const QSharedPointer<LogViewTelegram> &telegram);
|
||||
QSharedPointer<LogViewTelegram> telegram(int row) const;
|
||||
|
||||
@@ -41,8 +37,8 @@ namespace N_LogView
|
||||
void removeTelegrams(const QSet<int> &rows);
|
||||
|
||||
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 <QtWidgets/QLabel>
|
||||
@@ -22,19 +22,19 @@
|
||||
|
||||
namespace N_LogView
|
||||
{
|
||||
static int s_currentRow = 0;
|
||||
// ---------------------------------------------------------------
|
||||
LogViewTelegramSelectionDialog::LogViewTelegramSelectionDialog(QWidget *a_parent)
|
||||
static int s_currentRow = 0;
|
||||
|
||||
LogViewTelegramSelectionDialog::LogViewTelegramSelectionDialog(QWidget* a_parent)
|
||||
: QDialog(a_parent)
|
||||
{
|
||||
{
|
||||
setMinimumSize(QSize(600, 500));
|
||||
QVBoxLayout *layout = new QVBoxLayout;
|
||||
QVBoxLayout* layout = new QVBoxLayout;
|
||||
layout->addWidget(new QLabel(tr("Select a telegram:")));
|
||||
m_TelegramList = new QListWidget(this);
|
||||
const auto telegramMap = LogViewTelegram::jsonParser()->telegramsToCreate();
|
||||
for (auto it = telegramMap.cbegin(); it != telegramMap.cend(); ++it)
|
||||
{
|
||||
if (it.key() == 0) // ACK
|
||||
if (it.key() == 0)
|
||||
continue;
|
||||
auto lwi = new QListWidgetItem(it.value() + QStringLiteral(" (%1)").arg(it.key()));
|
||||
lwi->setData(Qt::UserRole, it.key());
|
||||
@@ -43,19 +43,20 @@ namespace N_LogView
|
||||
|
||||
m_TelegramList->sortItems();
|
||||
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);
|
||||
|
||||
setLayout(layout);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
void LogViewTelegramSelectionDialog::selectTelegram(QListWidgetItem *a_telegramItem)
|
||||
{
|
||||
|
||||
void LogViewTelegramSelectionDialog::selectTelegram(QListWidgetItem* a_telegramItem)
|
||||
{
|
||||
s_currentRow = m_TelegramList->currentRow();
|
||||
m_SelectedTelegramId = a_telegramItem->data(Qt::UserRole).toInt();
|
||||
accept();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace N_LogView
|
||||
}
|
||||
@@ -1,15 +1,15 @@
|
||||
// **************************************************************************
|
||||
//
|
||||
// (C) Copyright 2009 Swiss SIMTEC AG
|
||||
//
|
||||
// **************************************************************************
|
||||
//
|
||||
// $HeadURL$
|
||||
// $LastChangedBy$
|
||||
// $LastChangedDate$
|
||||
// $LastChangedRevision$
|
||||
//
|
||||
// **************************************************************************
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -19,34 +19,28 @@ class QListWidgetItem;
|
||||
|
||||
namespace N_LogView
|
||||
{
|
||||
/**
|
||||
* @author alois.wismer
|
||||
* @version 1.0
|
||||
* @created 05-Mai-2010 17:24:14
|
||||
*/
|
||||
|
||||
|
||||
class LogViewTelegramSelectionDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
/**
|
||||
*
|
||||
* @param a_parent
|
||||
*/
|
||||
explicit LogViewTelegramSelectionDialog(QWidget *a_parent);
|
||||
|
||||
|
||||
explicit LogViewTelegramSelectionDialog(QWidget* a_parent);
|
||||
|
||||
|
||||
int getSelectedTelegramId() const { return m_SelectedTelegramId; }
|
||||
|
||||
protected slots:
|
||||
/**
|
||||
*
|
||||
* @param a_telegramItem
|
||||
*/
|
||||
void selectTelegram(QListWidgetItem *a_telegramItem);
|
||||
|
||||
|
||||
void selectTelegram(QListWidgetItem* a_telegramItem);
|
||||
|
||||
protected:
|
||||
|
||||
QListWidget *m_TelegramList;
|
||||
int m_SelectedTelegramId;
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
@@ -1,15 +1,15 @@
|
||||
// **************************************************************************
|
||||
//
|
||||
// (C) Copyright 2009 Swiss SIMTEC AG
|
||||
//
|
||||
// **************************************************************************
|
||||
//
|
||||
// $HeadURL$
|
||||
// $LastChangedBy$
|
||||
// $LastChangedDate$
|
||||
// $LastChangedRevision$
|
||||
//
|
||||
// **************************************************************************
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "LogViewTextEdit.hpp"
|
||||
#include "LogViewField.hpp"
|
||||
@@ -18,11 +18,11 @@
|
||||
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)
|
||||
, LogViewWidget(a_field, this, a_parent, a_readonly)
|
||||
{
|
||||
{
|
||||
const QString value = a_field->value(0);
|
||||
setText(value);
|
||||
|
||||
@@ -32,12 +32,12 @@ namespace N_LogView
|
||||
setAlignment(a_field->isRightAligned() ? Qt::AlignRight : Qt::AlignLeft);
|
||||
}
|
||||
|
||||
// set a validator for number of chars
|
||||
|
||||
uint16_t maxArraySize = a_field->maxArraySize();
|
||||
setMaxLength(maxArraySize);
|
||||
updateToolTip(value);
|
||||
|
||||
// make proper width of widget
|
||||
|
||||
QFontMetrics fm(font());
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
|
||||
setMinimumWidth(fm.width(QLatin1Char(' ') + value + QLatin1Char(' ')));
|
||||
@@ -45,24 +45,25 @@ namespace N_LogView
|
||||
setMinimumWidth(fm.horizontalAdvance(QLatin1Char(' ') + value + QLatin1Char(' ')));
|
||||
#endif
|
||||
|
||||
// connect signals
|
||||
connect(this, &LogViewTextEdit::editingFinished, this, &LogViewTextEdit::checkAndOvertakeContent);
|
||||
}
|
||||
|
||||
connect(this, &LogViewTextEdit::editingFinished,
|
||||
this, &LogViewTextEdit::checkAndOvertakeContent);
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
void LogViewTextEdit::checkAndOvertakeContent()
|
||||
{
|
||||
updateToolTip(text()); // fixme nach jedem zeichen updaten
|
||||
|
||||
void LogViewTextEdit::checkAndOvertakeContent()
|
||||
{
|
||||
updateToolTip(text());
|
||||
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())
|
||||
return false;
|
||||
if (a_telegram->isJsonTelegram())
|
||||
@@ -78,18 +79,18 @@ namespace N_LogView
|
||||
{
|
||||
arraySize = content.length();
|
||||
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
|
||||
{
|
||||
arraySize = m_Field->maxArraySize();
|
||||
}
|
||||
|
||||
// copy the text
|
||||
|
||||
for (int i = 0; i < arraySize; i++)
|
||||
a_telegram->setUIntX(size, i < content.length() ? content[i].toLatin1() : 0);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace N_LogView
|
||||
}
|
||||
@@ -1,15 +1,15 @@
|
||||
// **************************************************************************
|
||||
//
|
||||
// (C) Copyright 2009 Swiss SIMTEC AG
|
||||
//
|
||||
// **************************************************************************
|
||||
//
|
||||
// $HeadURL$
|
||||
// $LastChangedBy$
|
||||
// $LastChangedDate$
|
||||
// $LastChangedRevision$
|
||||
//
|
||||
// **************************************************************************
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -18,37 +18,23 @@
|
||||
|
||||
namespace N_LogView
|
||||
{
|
||||
/**
|
||||
* Used for arrays of char and string.
|
||||
*
|
||||
* @author alois.wismer
|
||||
* @version 1.0
|
||||
* @created 21-Mai-2010 10:28:05
|
||||
*/
|
||||
class LogViewTextEdit
|
||||
: public QLineEdit
|
||||
, public LogViewWidget
|
||||
|
||||
|
||||
class LogViewTextEdit : public QLineEdit, public LogViewWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
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.
|
||||
* Returns true if successful.
|
||||
*
|
||||
* @param a_telegram
|
||||
*/
|
||||
bool saveContent(LogViewTelegram *a_telegram) override;
|
||||
|
||||
LogViewTextEdit(LogViewField* a_field, QWidget* a_parent, const bool a_readonly);
|
||||
|
||||
|
||||
|
||||
bool saveContent(LogViewTelegram* a_telegram) override;
|
||||
|
||||
protected slots:
|
||||
void checkAndOvertakeContent();
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
@@ -1,15 +1,15 @@
|
||||
// **************************************************************************
|
||||
//
|
||||
// (C) Copyright 2009 Swiss SIMTEC AG
|
||||
//
|
||||
// **************************************************************************
|
||||
//
|
||||
// $HeadURL$
|
||||
// $LastChangedBy$
|
||||
// $LastChangedDate$
|
||||
// $LastChangedRevision$
|
||||
//
|
||||
// **************************************************************************
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "LogViewValueEdit.hpp"
|
||||
#include "LogViewField.hpp"
|
||||
@@ -18,23 +18,23 @@
|
||||
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)
|
||||
, LogViewWidget(a_field, this, a_parent, a_readonly)
|
||||
, 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());
|
||||
|
||||
const QString valueText = a_field->value(0);
|
||||
|
||||
setText(valueText);
|
||||
|
||||
// checkAndOvertakeContent();
|
||||
|
||||
updateToolTip(valueText);
|
||||
|
||||
// make proper width of widget
|
||||
|
||||
QFontMetrics fm(font());
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
|
||||
setMinimumWidth(fm.width(QLatin1Char(' ') + valueText + QLatin1Char(' ')));
|
||||
@@ -49,54 +49,55 @@ namespace N_LogView
|
||||
}
|
||||
else
|
||||
{
|
||||
connect(this, &LogViewValueEdit::editingFinished, this, &LogViewValueEdit::checkAndOvertakeContent);
|
||||
}
|
||||
connect(this, &LogViewValueEdit::editingFinished,
|
||||
this, &LogViewValueEdit::checkAndOvertakeContent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
void LogViewValueEdit::checkAndOvertakeContent()
|
||||
{
|
||||
|
||||
void LogViewValueEdit::checkAndOvertakeContent()
|
||||
{
|
||||
bool ok;
|
||||
int64_t intValue = 0;
|
||||
double floatValue = 0.0;
|
||||
|
||||
// get the calculated and checked value
|
||||
|
||||
if (m_IsFloat)
|
||||
floatValue = getFloat(text(), (uint64_t &)intValue, ok);
|
||||
floatValue = getFloat(text(), (uint64_t&)intValue, ok);
|
||||
else
|
||||
intValue = getInteger(text(), ok);
|
||||
|
||||
// handle errors
|
||||
|
||||
if (!ok)
|
||||
{
|
||||
setFocus();
|
||||
selectAll();
|
||||
return; // abort
|
||||
return;
|
||||
}
|
||||
|
||||
// update
|
||||
|
||||
if (m_IsFloat)
|
||||
setText(QString::number(floatValue));
|
||||
else
|
||||
setText(QString::number(intValue));
|
||||
|
||||
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)
|
||||
{
|
||||
bool ok;
|
||||
if (m_IsFloat)
|
||||
{
|
||||
// save the float or double-value
|
||||
|
||||
uint64_t valueAsUint64;
|
||||
const double value = getFloat(text(), valueAsUint64, ok);
|
||||
if (ok)
|
||||
@@ -107,7 +108,7 @@ namespace N_LogView
|
||||
}
|
||||
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();
|
||||
a_telegram->setUIntX(getSize(), valueAsUint64, byteOrder);
|
||||
}
|
||||
@@ -116,7 +117,7 @@ namespace N_LogView
|
||||
}
|
||||
else
|
||||
{
|
||||
// save the integer-value
|
||||
|
||||
qint64 intValue = getInteger(text(), ok);
|
||||
if (ok)
|
||||
{
|
||||
@@ -129,6 +130,6 @@ namespace N_LogView
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace N_LogView
|
||||
}
|
||||
@@ -1,15 +1,15 @@
|
||||
// **************************************************************************
|
||||
//
|
||||
// (C) Copyright 2009 Swiss SIMTEC AG
|
||||
//
|
||||
// **************************************************************************
|
||||
//
|
||||
// $HeadURL$
|
||||
// $LastChangedBy$
|
||||
// $LastChangedDate$
|
||||
// $LastChangedRevision$
|
||||
//
|
||||
// **************************************************************************
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -18,40 +18,27 @@
|
||||
|
||||
namespace N_LogView
|
||||
{
|
||||
/**
|
||||
* Used for scalar signed or unsigned values
|
||||
*
|
||||
* @author alois.wismer
|
||||
* @version 1.0
|
||||
* @created 20-Mai-2010 14:47:50
|
||||
*/
|
||||
class LogViewValueEdit
|
||||
: public QLineEdit
|
||||
, public LogViewWidget
|
||||
|
||||
|
||||
class LogViewValueEdit : public QLineEdit, public LogViewWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
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.
|
||||
* Returns true if successful.
|
||||
*
|
||||
* @param a_telegram
|
||||
*/
|
||||
bool saveContent(LogViewTelegram *a_telegram) override;
|
||||
|
||||
LogViewValueEdit(LogViewField* a_field, QWidget* a_parent, const bool a_readonly);
|
||||
|
||||
|
||||
|
||||
bool saveContent(LogViewTelegram* a_telegram) override;
|
||||
|
||||
protected:
|
||||
|
||||
bool m_IsFloat;
|
||||
|
||||
protected slots:
|
||||
void checkAndOvertakeContent();
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
@@ -1,43 +1,43 @@
|
||||
// **************************************************************************
|
||||
//
|
||||
// (C) Copyright 2009 Swiss SIMTEC AG
|
||||
//
|
||||
// **************************************************************************
|
||||
//
|
||||
// $HeadURL$
|
||||
// $LastChangedBy$
|
||||
// $LastChangedDate$
|
||||
// $LastChangedRevision$
|
||||
//
|
||||
// **************************************************************************
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "LogViewXdrElement.hpp"
|
||||
|
||||
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_Kind(a_kind)
|
||||
, m_logger(getLogger(loggerName))
|
||||
{
|
||||
{
|
||||
if (a_name.indexOf(QLatin1Char('<')) >= 0 || a_name.indexOf(QLatin1Char('[')) >= 0)
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
QString LogViewXdrElement::getKindName() const
|
||||
{
|
||||
|
||||
QString LogViewXdrElement::getKindName() const
|
||||
{
|
||||
switch (getKind())
|
||||
{
|
||||
case e_KindDefine:
|
||||
@@ -56,6 +56,6 @@ namespace N_LogView
|
||||
return QLatin1String("Typedef");
|
||||
}
|
||||
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
|
||||
|
||||
@@ -18,19 +18,14 @@
|
||||
|
||||
namespace N_LogView
|
||||
{
|
||||
/**
|
||||
* @author alois.wismer
|
||||
* @version 1.0
|
||||
* @created 05-Feb-2010 11:24:56
|
||||
*/
|
||||
|
||||
|
||||
class LogViewXdrElement
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @author alois.wismer
|
||||
* @version 1.0
|
||||
* @created 10-Feb-2010 11:34:47
|
||||
*/
|
||||
|
||||
|
||||
|
||||
enum E_ElementKind
|
||||
{
|
||||
e_KindStandardType,
|
||||
@@ -45,16 +40,12 @@ namespace N_LogView
|
||||
virtual ~LogViewXdrElement() = default;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Constructor of a struct or enum
|
||||
*
|
||||
* @param a_name
|
||||
* @param a_kind
|
||||
*/
|
||||
LogViewXdrElement(const QString &a_name, const E_ElementKind a_kind, const char *loggerName);
|
||||
|
||||
|
||||
LogViewXdrElement(const QString& a_name, const E_ElementKind a_kind, const char *loggerName);
|
||||
|
||||
public:
|
||||
const QString &getName() const { return m_Name; }
|
||||
const QString& getName() const { return m_Name; }
|
||||
LogViewXdrElement::E_ElementKind getKind() const { return m_Kind; }
|
||||
|
||||
virtual void dump() const;
|
||||
@@ -62,7 +53,6 @@ namespace N_LogView
|
||||
protected:
|
||||
QString m_Name;
|
||||
E_ElementKind m_Kind;
|
||||
LOGGER_T m_logger;
|
||||
QString getKindName() const;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
|
||||
@@ -1,83 +1,84 @@
|
||||
// **************************************************************************
|
||||
//
|
||||
// (C) Copyright 2009 Swiss SIMTEC AG
|
||||
//
|
||||
// **************************************************************************
|
||||
//
|
||||
// $HeadURL$
|
||||
// $LastChangedBy$
|
||||
// $LastChangedDate$
|
||||
// $LastChangedRevision$
|
||||
//
|
||||
// **************************************************************************
|
||||
|
||||
// manual class headers
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "LogViewXdrStandardType.hpp"
|
||||
|
||||
namespace N_LogView
|
||||
{
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// (a_valueKind must be Unsigned, if a_dynArraySizeMethod is
|
||||
// e_DynArray...)
|
||||
// ---------------------------------------------------------------
|
||||
LogViewXdrStandardType::LogViewXdrStandardType(const QString &a_name,
|
||||
const int a_valueSize,
|
||||
const int a_editSize,
|
||||
const E_ValueKind a_valueKind,
|
||||
const E_DynArraySizeMethod a_dynArraySizeMethod,
|
||||
E_ByteOrder a_byteOrder)
|
||||
|
||||
|
||||
|
||||
|
||||
LogViewXdrStandardType::LogViewXdrStandardType(const QString& a_name, const int a_valueSize,
|
||||
const int a_editSize, const E_ValueKind a_valueKind,
|
||||
const E_DynArraySizeMethod a_dynArraySizeMethod, E_ByteOrder a_byteOrder)
|
||||
: LogViewXdrElement(a_name, e_KindStandardType, "LogViewXdrStandardType")
|
||||
, m_ValueSize(a_valueSize)
|
||||
, m_EditSize(a_editSize)
|
||||
, m_ValueKind(a_valueKind)
|
||||
, m_ByteOrder(a_byteOrder)
|
||||
, m_DynArraySizeMethod(a_dynArraySizeMethod)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
uint16_t LogViewXdrStandardType::getValueSize() const
|
||||
{
|
||||
|
||||
uint16_t LogViewXdrStandardType::getValueSize() const
|
||||
{
|
||||
return m_ValueSize;
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
LogViewXdrStandardType::E_ValueKind LogViewXdrStandardType::getValueKind() const
|
||||
{
|
||||
|
||||
LogViewXdrStandardType::E_ValueKind LogViewXdrStandardType::getValueKind() const
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
LogViewXdrStandardType::E_DynArraySizeMethod LogViewXdrStandardType::getDynArraySizeMethod() const
|
||||
{
|
||||
void LogViewXdrStandardType::dump() 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
LogViewXdrStandardType::E_ByteOrder LogViewXdrStandardType::getByteOrder() const
|
||||
{
|
||||
|
||||
LogViewXdrStandardType::E_ByteOrder LogViewXdrStandardType::getByteOrder() const
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace N_LogView
|
||||
}
|
||||
@@ -1,15 +1,15 @@
|
||||
// **************************************************************************
|
||||
//
|
||||
// (C) Copyright 2009 Swiss SIMTEC AG
|
||||
//
|
||||
// **************************************************************************
|
||||
//
|
||||
// $HeadURL$
|
||||
// $LastChangedBy$
|
||||
// $LastChangedDate$
|
||||
// $LastChangedRevision$
|
||||
//
|
||||
// **************************************************************************
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -17,90 +17,61 @@
|
||||
|
||||
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
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @author alois.wismer
|
||||
* @version 1.0
|
||||
* @created 16-Feb-2010 14:34:38
|
||||
*/
|
||||
|
||||
|
||||
|
||||
enum E_ValueKind
|
||||
{
|
||||
/**
|
||||
* An unsigned 32-bit integer
|
||||
*/
|
||||
|
||||
|
||||
e_Unsigned,
|
||||
/**
|
||||
* An signed 32-bit integer
|
||||
*/
|
||||
|
||||
|
||||
e_Signed,
|
||||
/**
|
||||
* A floating-point number
|
||||
*/
|
||||
|
||||
|
||||
e_Float,
|
||||
/**
|
||||
* A character or string
|
||||
*/
|
||||
|
||||
|
||||
e_Character,
|
||||
/**
|
||||
* A boolean value
|
||||
*/
|
||||
|
||||
|
||||
e_Boolean,
|
||||
/**
|
||||
* Hex-Data "0000: F7 A5 07 ..."
|
||||
*/
|
||||
|
||||
|
||||
e_Data
|
||||
};
|
||||
|
||||
/**
|
||||
* @author alois.wismer
|
||||
* @version 1.0
|
||||
* @created 31-Mrz-2010 10:27:31
|
||||
*/
|
||||
|
||||
|
||||
enum E_ByteOrder
|
||||
{
|
||||
e_ByteOrderBigEndian,
|
||||
e_ByteOrderLittleEndian
|
||||
};
|
||||
|
||||
/**
|
||||
* @author alois.wismer
|
||||
* @version 1.0
|
||||
* @created 29-Mrz-2010 13:58:44
|
||||
*/
|
||||
|
||||
|
||||
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,
|
||||
/**
|
||||
* Size of dyn array is defined by a field (StandardType must be Unsigned)
|
||||
*/
|
||||
|
||||
|
||||
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
|
||||
};
|
||||
|
||||
/**
|
||||
* (a_valueKind must be Unsigned, if a_dynArraySizeMethod is e_DynArray...)
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
LogViewXdrStandardType(const QString &a_name,
|
||||
const int a_valueSize,
|
||||
const int a_editSize,
|
||||
@@ -123,25 +94,24 @@ namespace N_LogView
|
||||
|
||||
LogViewXdrStandardType::E_ByteOrder getByteOrder() const;
|
||||
|
||||
/**
|
||||
* The 'real' size of the value, which will be allowd when editing this value
|
||||
*/
|
||||
|
||||
|
||||
uint16_t getEditSize() const;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* The size of this value as stored data. It may be bigger as the real (edit) size.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
int m_ValueSize;
|
||||
/**
|
||||
* The 'real' size of the value, which will be allowd when editing this value
|
||||
*/
|
||||
|
||||
|
||||
int m_EditSize;
|
||||
E_ValueKind m_ValueKind;
|
||||
|
||||
E_ByteOrder m_ByteOrder;
|
||||
|
||||
E_DynArraySizeMethod m_DynArraySizeMethod;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
@@ -1,15 +1,15 @@
|
||||
// **************************************************************************
|
||||
//
|
||||
// (C) Copyright 2009 Swiss SIMTEC AG
|
||||
//
|
||||
// **************************************************************************
|
||||
//
|
||||
// $HeadURL$
|
||||
// $LastChangedBy$
|
||||
// $LastChangedDate$
|
||||
// $LastChangedRevision$
|
||||
//
|
||||
// **************************************************************************
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "LogViewXdrStruct.hpp"
|
||||
#include "LogViewXdrValue.hpp"
|
||||
@@ -18,94 +18,88 @@
|
||||
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")
|
||||
, m_EnumSize(enumSize)
|
||||
{
|
||||
}
|
||||
{
|
||||
}
|
||||
|
||||
LogViewXdrStruct::~LogViewXdrStruct()
|
||||
{
|
||||
LogViewXdrStruct::~LogViewXdrStruct()
|
||||
{
|
||||
for (auto ptr : m_ChildList)
|
||||
delete ptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
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)
|
||||
{
|
||||
|
||||
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)
|
||||
{
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
LogViewXdrElement *LogViewXdrStruct::getChild(const uint32_t a_childIndex) const
|
||||
{
|
||||
|
||||
LogViewXdrElement* LogViewXdrStruct::getChild(const uint32_t a_childIndex) const
|
||||
{
|
||||
if (m_ChildList.size() > a_childIndex)
|
||||
return m_ChildList[a_childIndex];
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
LogViewXdrType *LogViewXdrStruct::getChildAsType(const uint32_t a_childIndex) const
|
||||
{
|
||||
return static_cast<LogViewXdrType *>(getChild(a_childIndex)); // fixme: check ob es wirklich ein XdrType ist
|
||||
}
|
||||
|
||||
LogViewXdrType* LogViewXdrStruct::getChildAsType(const uint32_t a_childIndex) const
|
||||
{
|
||||
return static_cast<LogViewXdrType*>(getChild(a_childIndex));
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
LogViewXdrValue *LogViewXdrStruct::getChildAsValue(const uint32_t a_childIndex) const
|
||||
{
|
||||
return static_cast<LogViewXdrValue *>(getChild(a_childIndex)); // fixme: check ob es wirklich ein XdrValue ist
|
||||
}
|
||||
|
||||
LogViewXdrValue* LogViewXdrStruct::getChildAsValue(const uint32_t a_childIndex) const
|
||||
{
|
||||
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) << "-------------- 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())
|
||||
{
|
||||
(*iter)->dump();
|
||||
++iter;
|
||||
}
|
||||
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)
|
||||
*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())
|
||||
{
|
||||
if ((*iter)->getName() == a_name)
|
||||
return static_cast<const LogViewXdrValue *>(*iter)->getValue();
|
||||
return static_cast<const LogViewXdrValue*>(*iter)->getValue();
|
||||
++iter;
|
||||
}
|
||||
if (a_error)
|
||||
*a_error = true;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // namespace N_LogView
|
||||
@@ -1,15 +1,15 @@
|
||||
// **************************************************************************
|
||||
//
|
||||
// (C) Copyright 2009 Swiss SIMTEC AG
|
||||
//
|
||||
// **************************************************************************
|
||||
//
|
||||
// $HeadURL$
|
||||
// $LastChangedBy$
|
||||
// $LastChangedDate$
|
||||
// $LastChangedRevision$
|
||||
//
|
||||
// **************************************************************************
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "LogViewXdrElement.hpp"
|
||||
#include <vector>
|
||||
|
||||
// forward declarations from stereotyped includes
|
||||
|
||||
namespace N_LogView
|
||||
{
|
||||
class LogViewXdrValue;
|
||||
@@ -29,42 +29,32 @@ 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
|
||||
{
|
||||
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();
|
||||
|
||||
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);
|
||||
void addElement(const QString &a_name, const uint32_t a_value, const E_ElementKind a_kind);
|
||||
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);
|
||||
void addElement(const QString& a_name, const uint32_t a_value, const E_ElementKind a_kind);
|
||||
|
||||
LogViewXdrElement *getChild(const uint32_t a_childIndex) const;
|
||||
LogViewXdrType *getChildAsType(const uint32_t a_childIndex) const;
|
||||
LogViewXdrValue *getChildAsValue(const uint32_t a_childIndex) const;
|
||||
LogViewXdrElement* getChild(const uint32_t a_childIndex) const;
|
||||
LogViewXdrType* getChildAsType(const uint32_t a_childIndex) const;
|
||||
LogViewXdrValue* getChildAsValue(const uint32_t a_childIndex) const;
|
||||
|
||||
|
||||
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; }
|
||||
|
||||
protected:
|
||||
|
||||
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"
|
||||
|
||||
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")
|
||||
, m_Type(a_type)
|
||||
, m_ArraySize(a_arraySize)
|
||||
@@ -25,19 +25,12 @@ namespace N_LogView
|
||||
, m_FirstBit(-1)
|
||||
, m_LastBit(-1)
|
||||
, m_IsLast(true)
|
||||
{
|
||||
}
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
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)
|
||||
|
||||
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)
|
||||
: LogViewXdrElement(a_name, a_kind, "LogViewXdrType")
|
||||
, m_Type(a_type)
|
||||
, m_ArraySize(a_arraySize)
|
||||
@@ -45,60 +38,69 @@ namespace N_LogView
|
||||
, m_FirstBit(a_firstBit)
|
||||
, m_LastBit(a_lastBit)
|
||||
, m_IsLast(a_isLast)
|
||||
{
|
||||
}
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
void LogViewXdrType::dump() const
|
||||
{
|
||||
INFO_LOG(m_logger) << "Element[" << getName() << "]: kind=" << getKindName() << " type=" << getType() << " arraySize=" << getArraySize()
|
||||
<< " maxArraySize=" << getMaxArraySize() << " firstBit=" << m_FirstBit << " lastBit=" << m_LastBit << " isLast=" << m_IsLast;
|
||||
}
|
||||
|
||||
void LogViewXdrType::dump() const
|
||||
{
|
||||
INFO_LOG(m_logger) << "Element[" << getName()
|
||||
<< "]: 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;
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// 0 => opaque
|
||||
// 1 => normal (scalar) element
|
||||
// >1 => array
|
||||
// ---------------------------------------------------------------
|
||||
uint16_t LogViewXdrType::getArraySize() const
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
uint16_t LogViewXdrType::getArraySize() const
|
||||
{
|
||||
return m_ArraySize;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
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;
|
||||
|
||||
bool LogViewXdrType::maskValue(uint32_t& a_value, const uint16_t a_size, QString& a_tooltip) const
|
||||
{
|
||||
|
||||
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;
|
||||
uint16_t bitshift = (a_size * 8) - m_LastBit - 1;
|
||||
uint32_t mask = (1 << (m_LastBit - m_FirstBit + 1)) - 1;
|
||||
// INFO_LOG(m_logger) << "value=" << a_value << " bitshift=" << bitshift << " mask=" << mask;
|
||||
uint16_t bitshift = (a_size*8)-m_LastBit-1;
|
||||
uint32_t mask = (1<<(m_LastBit-m_FirstBit+1))-1;
|
||||
|
||||
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_LastBit + 1, 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>"));
|
||||
return m_IsLast;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
uint16_t LogViewXdrType::getMaxArraySize() const
|
||||
{
|
||||
|
||||
uint16_t LogViewXdrType::getMaxArraySize() const
|
||||
{
|
||||
return m_MaxArraySize;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace N_LogView
|
||||
}
|
||||
@@ -1,15 +1,15 @@
|
||||
// **************************************************************************
|
||||
//
|
||||
// (C) Copyright 2009 Swiss SIMTEC AG
|
||||
//
|
||||
// **************************************************************************
|
||||
//
|
||||
// $HeadURL$
|
||||
// $LastChangedBy$
|
||||
// $LastChangedDate$
|
||||
// $LastChangedRevision$
|
||||
//
|
||||
// **************************************************************************
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -17,99 +17,56 @@
|
||||
|
||||
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
|
||||
{
|
||||
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
|
||||
* @param a_type
|
||||
* @param a_arraySize
|
||||
* @param a_dynArrayOffset
|
||||
* @param a_kind
|
||||
* @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);
|
||||
|
||||
|
||||
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(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;
|
||||
|
||||
|
||||
const QString &getType() const;
|
||||
const QString& getType() const;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 0 => opaque
|
||||
* 1 => normal (scalar) element
|
||||
* >1 => array
|
||||
*/
|
||||
uint16_t getArraySize() const;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param a_value
|
||||
* @param a_size
|
||||
* @param a_tooltip
|
||||
*/
|
||||
bool maskValue(uint32_t &a_value, const uint16_t a_size, QString &a_tooltip) const;
|
||||
|
||||
|
||||
bool maskValue(uint32_t& a_value, const uint16_t a_size, QString& a_tooltip) const;
|
||||
|
||||
|
||||
uint16_t getMaxArraySize() const;
|
||||
|
||||
protected:
|
||||
|
||||
QString m_Type;
|
||||
/**
|
||||
* 0 => opaque
|
||||
* 1 => normal (scalar) element
|
||||
* >1 => array
|
||||
*/
|
||||
|
||||
|
||||
uint16_t m_ArraySize;
|
||||
/**
|
||||
* The maximum size of the array. Interesting for dynamic arrays.
|
||||
*/
|
||||
|
||||
|
||||
uint16_t m_MaxArraySize;
|
||||
/**
|
||||
* The first relevant bit, if we have bitfield-enum
|
||||
*/
|
||||
|
||||
|
||||
int16_t m_FirstBit;
|
||||
/**
|
||||
* The last relevant bit, if we have bitfield-enum
|
||||
*/
|
||||
|
||||
|
||||
int16_t m_LastBit;
|
||||
/**
|
||||
* used to step to next values when reading out content-data of bit-fields
|
||||
*/
|
||||
|
||||
|
||||
bool m_IsLast;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
// **************************************************************************
|
||||
//
|
||||
// (C) Copyright 2009 Swiss SIMTEC AG
|
||||
//
|
||||
// **************************************************************************
|
||||
//
|
||||
// $HeadURL$
|
||||
// $LastChangedBy$
|
||||
// $LastChangedDate$
|
||||
// $LastChangedRevision$
|
||||
//
|
||||
// **************************************************************************
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "LogViewXdrValue.hpp"
|
||||
|
||||
@@ -17,25 +17,24 @@
|
||||
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")
|
||||
, m_Value(a_value)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
void LogViewXdrValue::dump() const
|
||||
{
|
||||
|
||||
void LogViewXdrValue::dump() const
|
||||
{
|
||||
INFO_LOG(m_logger) << "Element[" << getName() << "]: kind=" << getKindName() << " value=" << getValue();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
int64_t LogViewXdrValue::getValue() const
|
||||
{
|
||||
|
||||
int64_t LogViewXdrValue::getValue() const
|
||||
{
|
||||
return m_Value;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace N_LogView
|
||||
}
|
||||
@@ -1,15 +1,15 @@
|
||||
// **************************************************************************
|
||||
//
|
||||
// (C) Copyright 2009 Swiss SIMTEC AG
|
||||
//
|
||||
// **************************************************************************
|
||||
//
|
||||
// $HeadURL$
|
||||
// $LastChangedBy$
|
||||
// $LastChangedDate$
|
||||
// $LastChangedRevision$
|
||||
//
|
||||
// **************************************************************************
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -17,23 +17,18 @@
|
||||
|
||||
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
|
||||
{
|
||||
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;
|
||||
int64_t getValue() const;
|
||||
|
||||
protected:
|
||||
|
||||
int64_t m_Value;
|
||||
};
|
||||
}
|
||||
@@ -1,10 +1,5 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Building Config - logging facility
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "logger.h"
|
||||
|
||||
@@ -13,8 +8,8 @@
|
||||
namespace N_LogView
|
||||
{
|
||||
|
||||
LOGGER_T getLogger(const char *name)
|
||||
{
|
||||
LOGGER_T getLogger(const char *name)
|
||||
{
|
||||
static const char ns[] = "LogView.";
|
||||
std::string loggerName;
|
||||
const size_t len = strlen(name);
|
||||
@@ -24,13 +19,14 @@ namespace N_LogView
|
||||
|
||||
try
|
||||
{
|
||||
return NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger(loggerName);
|
||||
return NGL::NGLLoggerBootstrap::getNGLRootLogger().
|
||||
getNGLLogger(loggerName);
|
||||
}
|
||||
catch (const std::exception &ex)
|
||||
{
|
||||
fprintf(stderr, "Error retrieving logger: %s", ex.what());
|
||||
abort();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace LogView
|
||||
}
|
||||
@@ -1,10 +1,5 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Logging for AudioVideoManagement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -12,11 +7,11 @@
|
||||
|
||||
namespace N_LogView
|
||||
{
|
||||
typedef NGL::INGLLogger &LOGGER_T;
|
||||
typedef NGL::INGLLogger &LOGGER_T;
|
||||
|
||||
LOGGER_T getLogger(const char *name);
|
||||
inline LOGGER_T getLogger(const QString &loggerName)
|
||||
{
|
||||
LOGGER_T getLogger(const char *name);
|
||||
inline LOGGER_T getLogger(const QString &loggerName)
|
||||
{
|
||||
return getLogger(loggerName.toUtf8().constData());
|
||||
}
|
||||
} // namespace LogView
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user