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