Compare commits

..

No commits in common. "6fc62863c1341b75e3ea62230c168f729f93de5d" and "739010ba59d5c5e9c869e9da6eab55b8428efdde" have entirely different histories.

3 changed files with 30 additions and 53 deletions

View File

@ -16,7 +16,6 @@
#include <QFile> #include <QFile>
#include <QTextStream> #include <QTextStream>
#include <QDateTime> #include <QDateTime>
#include <QThread>
#include <optional> #include <optional>
@ -57,50 +56,37 @@ int main(int argc, char **argv) {
QString updateRequestStatus{internal::UPDATE_NOT_REQUESTED}; QString updateRequestStatus{internal::UPDATE_NOT_REQUESTED};
QDebug debug = qCritical(); QDebug debug = qCritical();
int tries = 10; if (std::optional<QString> result
= IsmasClient::sendRequestReceiveResponse(
while (--tries > 0) { IsmasClient::APISM::DIRECT_PORT,
if (std::optional<QString> result "#M=APISM#C=REQ_SELF#J={}")) {
= IsmasClient::sendRequestReceiveResponse( QJsonDocument d = QJsonDocument::fromJson(result.value().toUtf8());
IsmasClient::APISM::DIRECT_PORT, for (QString const &k : d.object().keys()) {
"#M=APISM#C=REQ_SELF#J={}")) { if (k.contains("CMD_GET_APISMSTATUS_RESPONSE")) {
QJsonDocument d = QJsonDocument::fromJson(result.value().toUtf8()); QJsonObject o = d.object()[k].toObject();
for (QString const &k : d.object().keys()) { QJsonObject::const_iterator it = o.find("Broker");
if (k.contains("CMD_GET_APISMSTATUS_RESPONSE")) { if (it != o.constEnd()) {
QJsonObject o = d.object()[k].toObject(); // value for "Broker"
QJsonObject::const_iterator bit = o.find("Broker"); QString const &v = it->toString();
QJsonObject::const_iterator ismit = o.find("ISMAS"); if (v.contains(internal::ISMAS_CONNECTED, Qt::CaseInsensitive)) {
if (bit != o.constEnd() && ismit != o.constEnd()) { connectionStatus = internal::ISMAS_CONNECTED;
// value for "Broker" } else
QString const &v = bit->toString(); if (v.contains(internal::ISMAS_NOT_CONNECTED, Qt::CaseInsensitive)) {
bool ismas = ismit->toBool(); connectionStatus = internal::ISMAS_NOT_CONNECTED;
if (ismas && v.contains(internal::BROKER_CONNECTED, Qt::CaseInsensitive)) { } else
connectionStatus = internal::ISMAS_CONNECTED; if (v.contains(internal::ISMAS_DISCONNECTED, Qt::CaseInsensitive)) {
break; connectionStatus = internal::ISMAS_NOT_CONNECTED;
} else } else
if (v.contains(internal::BROKER_NOT_CONNECTED, Qt::CaseInsensitive)) { if (v.contains(internal::ISMAS_CONNECTION_IN_PROGRESS, Qt::CaseInsensitive)) {
connectionStatus = internal::ISMAS_NOT_CONNECTED; connectionStatus = internal::ISMAS_NOT_CONNECTED;
} else } else
if (v.contains(internal::BROKER_DISCONNECTED, Qt::CaseInsensitive)) { if (v.contains(internal::ISMAS_DISCONNECTING, Qt::CaseInsensitive)) {
connectionStatus = internal::ISMAS_NOT_CONNECTED; connectionStatus = internal::ISMAS_NOT_CONNECTED;
} else
if (v.contains(internal::BROKER_CONNECTION_IN_PROGRESS, Qt::CaseInsensitive)) {
connectionStatus = internal::ISMAS_NOT_CONNECTED;
} else
if (v.contains(internal::BROKER_DISCONNECTING, Qt::CaseInsensitive)) {
connectionStatus = internal::ISMAS_NOT_CONNECTED;
}
break;
} }
break;
} }
} }
} }
if (connectionStatus == internal::ISMAS_CONNECTED) {
break;
}
QThread::sleep(5);
} }
if (connectionStatus != internal::ISMAS_CONNECTED) { if (connectionStatus != internal::ISMAS_CONNECTED) {

View File

@ -24,12 +24,6 @@ namespace internal {
static constexpr const char *ISMAS_NOT_CONNECTED{"not connected"}; static constexpr const char *ISMAS_NOT_CONNECTED{"not connected"};
static constexpr const char *ISMAS_CONNECTION_IN_PROGRESS{"connecting"}; static constexpr const char *ISMAS_CONNECTION_IN_PROGRESS{"connecting"};
static constexpr const char *BROKER_CONNECTED{"connected"};
static constexpr const char *BROKER_DISCONNECTED{"disconnected"};
static constexpr const char *BROKER_DISCONNECTING{"disconnecting"};
static constexpr const char *BROKER_NOT_CONNECTED{"not connected"};
static constexpr const char *BROKER_CONNECTION_IN_PROGRESS{"connecting"};
static constexpr const int GIT_CHECKOUT_ERROR_CODE{-2}; static constexpr const int GIT_CHECKOUT_ERROR_CODE{-2};
static constexpr const int GIT_PULL_ERROR_CODE{-4}; static constexpr const int GIT_PULL_ERROR_CODE{-4};
static constexpr const int GIT_NOT_NECESSARY_CODE{1}; static constexpr const int GIT_NOT_NECESSARY_CODE{1};

View File

@ -47,7 +47,7 @@ innertopmargin=20,innerbottommargin=20
\newglossaryentry{ATBUpdateCheck}{% \newglossaryentry{ATBUpdateCheck}{%
name=ATBUpdateCheck, name=ATBUpdateCheck,
description={Tool for checking ISMAS connectivity and for checking description={Tool for checking ISMAS connectivity and for checking
if an update-request has been scheduled.}% the customer repository}%
}% }%
\newglossaryentry{ATBUpdateGit}{% \newglossaryentry{ATBUpdateGit}{%
@ -105,11 +105,8 @@ innertopmargin=20,innerbottommargin=20
\section{Introduction} \section{Introduction}
\section{ATBUpdateCheck} \section{ATBUpdateCheck}
\gls{ATBUpdateCheck} is used for two purposes: \gls{ATBUpdateCheck}
\begin{enumerate} \gls{ISMAS}
\item Check \gls{ISMAS} can be reached (network).
\item Check if an update has been scheduled.
\end{enumerate}
\section{ATBUpdateGit} \section{ATBUpdateGit}
\gls{ATBUpdateGit} \gls{ATBUpdateGit}