Compare commits
3 Commits
739010ba59
...
6fc62863c1
Author | SHA1 | Date | |
---|---|---|---|
6fc62863c1 | |||
0dd731ff50 | |||
19445ec4f5 |
@ -16,6 +16,7 @@
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
#include <QDateTime>
|
||||
#include <QThread>
|
||||
|
||||
#include <optional>
|
||||
|
||||
@ -56,37 +57,50 @@ int main(int argc, char **argv) {
|
||||
QString updateRequestStatus{internal::UPDATE_NOT_REQUESTED};
|
||||
QDebug debug = qCritical();
|
||||
|
||||
if (std::optional<QString> result
|
||||
= IsmasClient::sendRequestReceiveResponse(
|
||||
IsmasClient::APISM::DIRECT_PORT,
|
||||
"#M=APISM#C=REQ_SELF#J={}")) {
|
||||
QJsonDocument d = QJsonDocument::fromJson(result.value().toUtf8());
|
||||
for (QString const &k : d.object().keys()) {
|
||||
if (k.contains("CMD_GET_APISMSTATUS_RESPONSE")) {
|
||||
QJsonObject o = d.object()[k].toObject();
|
||||
QJsonObject::const_iterator it = o.find("Broker");
|
||||
if (it != o.constEnd()) {
|
||||
// value for "Broker"
|
||||
QString const &v = it->toString();
|
||||
if (v.contains(internal::ISMAS_CONNECTED, Qt::CaseInsensitive)) {
|
||||
connectionStatus = internal::ISMAS_CONNECTED;
|
||||
} else
|
||||
if (v.contains(internal::ISMAS_NOT_CONNECTED, Qt::CaseInsensitive)) {
|
||||
connectionStatus = internal::ISMAS_NOT_CONNECTED;
|
||||
} else
|
||||
if (v.contains(internal::ISMAS_DISCONNECTED, Qt::CaseInsensitive)) {
|
||||
connectionStatus = internal::ISMAS_NOT_CONNECTED;
|
||||
} else
|
||||
if (v.contains(internal::ISMAS_CONNECTION_IN_PROGRESS, Qt::CaseInsensitive)) {
|
||||
connectionStatus = internal::ISMAS_NOT_CONNECTED;
|
||||
} else
|
||||
if (v.contains(internal::ISMAS_DISCONNECTING, Qt::CaseInsensitive)) {
|
||||
connectionStatus = internal::ISMAS_NOT_CONNECTED;
|
||||
int tries = 10;
|
||||
|
||||
while (--tries > 0) {
|
||||
if (std::optional<QString> result
|
||||
= IsmasClient::sendRequestReceiveResponse(
|
||||
IsmasClient::APISM::DIRECT_PORT,
|
||||
"#M=APISM#C=REQ_SELF#J={}")) {
|
||||
QJsonDocument d = QJsonDocument::fromJson(result.value().toUtf8());
|
||||
for (QString const &k : d.object().keys()) {
|
||||
if (k.contains("CMD_GET_APISMSTATUS_RESPONSE")) {
|
||||
QJsonObject o = d.object()[k].toObject();
|
||||
QJsonObject::const_iterator bit = o.find("Broker");
|
||||
QJsonObject::const_iterator ismit = o.find("ISMAS");
|
||||
if (bit != o.constEnd() && ismit != o.constEnd()) {
|
||||
// value for "Broker"
|
||||
QString const &v = bit->toString();
|
||||
bool ismas = ismit->toBool();
|
||||
if (ismas && v.contains(internal::BROKER_CONNECTED, Qt::CaseInsensitive)) {
|
||||
connectionStatus = internal::ISMAS_CONNECTED;
|
||||
break;
|
||||
} else
|
||||
if (v.contains(internal::BROKER_NOT_CONNECTED, Qt::CaseInsensitive)) {
|
||||
connectionStatus = internal::ISMAS_NOT_CONNECTED;
|
||||
} else
|
||||
if (v.contains(internal::BROKER_DISCONNECTED, Qt::CaseInsensitive)) {
|
||||
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) {
|
||||
|
@ -24,6 +24,12 @@ namespace internal {
|
||||
static constexpr const char *ISMAS_NOT_CONNECTED{"not connected"};
|
||||
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_PULL_ERROR_CODE{-4};
|
||||
static constexpr const int GIT_NOT_NECESSARY_CODE{1};
|
||||
|
@ -47,7 +47,7 @@ innertopmargin=20,innerbottommargin=20
|
||||
\newglossaryentry{ATBUpdateCheck}{%
|
||||
name=ATBUpdateCheck,
|
||||
description={Tool for checking ISMAS connectivity and for checking
|
||||
the customer repository}%
|
||||
if an update-request has been scheduled.}%
|
||||
}%
|
||||
|
||||
\newglossaryentry{ATBUpdateGit}{%
|
||||
@ -105,8 +105,11 @@ innertopmargin=20,innerbottommargin=20
|
||||
\section{Introduction}
|
||||
|
||||
\section{ATBUpdateCheck}
|
||||
\gls{ATBUpdateCheck}
|
||||
\gls{ISMAS}
|
||||
\gls{ATBUpdateCheck} is used for two purposes:
|
||||
\begin{enumerate}
|
||||
\item Check \gls{ISMAS} can be reached (network).
|
||||
\item Check if an update has been scheduled.
|
||||
\end{enumerate}
|
||||
|
||||
\section{ATBUpdateGit}
|
||||
\gls{ATBUpdateGit}
|
||||
|
Loading…
x
Reference in New Issue
Block a user