Initialize new member m_ismasTriggerStatusMessage.
This commit is contained in:
parent
530ea33460
commit
db24853062
104
worker.cpp
104
worker.cpp
@ -97,6 +97,7 @@ const QMap<UPDATE_STEP, const char*> Worker::smap (
|
||||
INSERT_ELEMENT(UPDATE_STEP::SAVE_LOGS_FAILURE),
|
||||
INSERT_ELEMENT(UPDATE_STEP::SEND_LAST_VERSION),
|
||||
INSERT_ELEMENT(UPDATE_STEP::UPDATE_SUCCEEDED),
|
||||
INSERT_ELEMENT(UPDATE_STEP::UPDATE_NOT_NECESSARY),
|
||||
INSERT_ELEMENT(UPDATE_STEP::UPDATE_FAILED),
|
||||
INSERT_ELEMENT(UPDATE_STEP::UPDATE_ACTIVATED),
|
||||
INSERT_ELEMENT(UPDATE_STEP::FINISHED),
|
||||
@ -478,11 +479,13 @@ bool Worker::updateTriggerSet() {
|
||||
// (WAIT-button) is activated even in case of initial checkout
|
||||
static const QString func = "UPDATE-TRIGGER-SET";
|
||||
|
||||
if (m_withoutIsmasDirectPort) { // useful for testing
|
||||
return true;
|
||||
}
|
||||
// if (m_withoutIsmasDirectPort) { // useful for testing
|
||||
// return true;
|
||||
//}
|
||||
|
||||
GUI() << (ISMAS() << (CONSOLE() << UPDATE_STEP::CHECK_ISMAS_TRIGGER));
|
||||
m_ismasTriggerStatusMessage.clear();
|
||||
|
||||
GUI() << (CONSOLE() << UPDATE_STEP::CHECK_ISMAS_TRIGGER);
|
||||
|
||||
QString triggerValue("NOT CHECKED YET");
|
||||
static constexpr int const repeats = 15;
|
||||
@ -492,10 +495,10 @@ bool Worker::updateTriggerSet() {
|
||||
int const startMs = QTime::currentTime().msecsSinceStartOfDay();
|
||||
int const durationMs = QTime::currentTime().msecsSinceStartOfDay() - startMs;
|
||||
QString const &s = QString("elapsed: %1.%2s").arg(durationMs / 1000).arg(durationMs % 1000);
|
||||
CONSOLE(QStringList(func) << s) << UPDATE_STEP::DEBUG;
|
||||
QStringList lst = (m_ismasTriggerStatusMessage = (QStringList(func) << s));
|
||||
CONSOLE(lst) << UPDATE_STEP::DEBUG;
|
||||
} else {
|
||||
QStringList lst = (QStringList(func) << QString("-> REPEAT=%1 (%2)").arg(repeat).arg(repeats-repeat));
|
||||
// GUI(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER;
|
||||
QStringList lst = (m_ismasTriggerStatusMessage = (QStringList(func) << QString("-> REPEAT=%1 (%2)").arg(repeat).arg(repeats-repeat)));
|
||||
CONSOLE(lst) << UPDATE_STEP::DEBUG;
|
||||
}
|
||||
|
||||
@ -504,7 +507,8 @@ bool Worker::updateTriggerSet() {
|
||||
Command c("systemctl restart apism");
|
||||
if (c.execute("/tmp")) {
|
||||
QThread::sleep(20); // give APISM some time to reconnect
|
||||
CONSOLE(QStringList(func) << "RESTART APISM DONE") << UPDATE_STEP::DEBUG;
|
||||
QStringList lst = (m_ismasTriggerStatusMessage = (QStringList(func) << "RESTART APISM DONE"));
|
||||
CONSOLE(lst) << UPDATE_STEP::DEBUG;
|
||||
}
|
||||
}
|
||||
|
||||
@ -513,30 +517,34 @@ bool Worker::updateTriggerSet() {
|
||||
IsmasClient::APISM::DIRECT_PORT, "#M=APISM#C=REQ_ISMASPARAMETER#J={}")) {
|
||||
|
||||
QString const &msg = QString("APISM RESPONSE(%1)=(").arg(repeat) + result.value() + ")";
|
||||
CONSOLE(QStringList(func) << msg) << UPDATE_STEP::DEBUG;
|
||||
QStringList lst = (m_ismasTriggerStatusMessage = (QStringList(func) << msg));
|
||||
CONSOLE(lst) << UPDATE_STEP::DEBUG;
|
||||
|
||||
QJsonParseError parseError;
|
||||
QJsonDocument document(QJsonDocument::fromJson(result.value().toUtf8(), &parseError));
|
||||
if (parseError.error != QJsonParseError::NoError) {
|
||||
QStringList lst(QString("INVALID JSON MSG: PARSING FAILED (json=<START>%1<END> error=[%2] str=[%3] offset=[%4])")
|
||||
m_ismasTriggerStatusMessage = QStringList(QString("INVALID JSON MSG: PARSING FAILED (json=<START>%1<END> error=[%2] str=[%3] offset=[%4])")
|
||||
.arg(msg)
|
||||
.arg(parseError.error)
|
||||
.arg(parseError.errorString())
|
||||
.arg(parseError.offset));
|
||||
QStringList lst = m_ismasTriggerStatusMessage;
|
||||
GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE));
|
||||
break;
|
||||
return false;
|
||||
}
|
||||
if (!document.isObject()) {
|
||||
QStringList lst(QString("not a json-object %1").arg(result.value()));
|
||||
m_ismasTriggerStatusMessage = QStringList(QString("not a json-object %1").arg(result.value()));
|
||||
QStringList lst = m_ismasTriggerStatusMessage;
|
||||
GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE));
|
||||
break;
|
||||
return false;
|
||||
}
|
||||
|
||||
QJsonObject obj = document.object();
|
||||
|
||||
// always look for an 'error' first
|
||||
if (obj.contains("error")) {
|
||||
QStringList lst(obj.value("error").toString());
|
||||
m_ismasTriggerStatusMessage = QStringList(obj.value("error").toString());
|
||||
QStringList lst = m_ismasTriggerStatusMessage;
|
||||
CONSOLE(QStringList(lst)) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE);
|
||||
QThread::sleep(6);
|
||||
continue;
|
||||
@ -552,31 +560,35 @@ bool Worker::updateTriggerSet() {
|
||||
int const customerNr = obj.value("Custom_ID").toInt(-1);
|
||||
int const machineNr = obj.value("Device_ID").toInt(-1);
|
||||
if (customerNr != m_customerNr) {
|
||||
QStringList lst(QString("CUSTOMER-NR (%1) != LOCAL CUSTOMER-NR (%2)")
|
||||
m_ismasTriggerStatusMessage = QStringList(QString("CUSTOMER-NR (%1) != LOCAL CUSTOMER-NR (%2)")
|
||||
.arg(customerNr).arg(m_customerNr));
|
||||
QStringList lst = m_ismasTriggerStatusMessage;
|
||||
GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE));
|
||||
break;
|
||||
return false;
|
||||
}
|
||||
if (machineNr != m_machineNr) {
|
||||
QStringList lst(QString("MACHINE-NR (%1) != LOCAL MACHINE-NR (%2)")
|
||||
m_ismasTriggerStatusMessage = QStringList(QString("MACHINE-NR (%1) != LOCAL MACHINE-NR (%2)")
|
||||
.arg(machineNr).arg(m_machineNr));
|
||||
QStringList lst = m_ismasTriggerStatusMessage;
|
||||
GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE));
|
||||
break;
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
QStringList lst("Dev_ID DOES NOT CONTAIN Custom_ID AND/OR Device_ID");
|
||||
QStringList lst(QString("Dev_ID DOES NOT CONTAIN Custom_ID AND/OR Device_ID (LINE=%1)").arg(__LINE__));
|
||||
GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE));
|
||||
break;
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
QStringList lst("Dev_ID KEY NOT A JSON-OBJECT");
|
||||
m_ismasTriggerStatusMessage = QStringList(QString("Dev_ID KEY NOT A JSON-OBJECT (LINE=%1)").arg(__LINE__));
|
||||
QStringList lst = m_ismasTriggerStatusMessage;
|
||||
GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE));
|
||||
break;
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
QStringList lst("Dev_ID KEY NOT AVAILABLE");
|
||||
m_ismasTriggerStatusMessage = QStringList(QString("Dev_ID KEY NOT AVAILABLE (LINE=%1)").arg(__LINE__));
|
||||
QStringList lst = m_ismasTriggerStatusMessage;
|
||||
GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE));
|
||||
break;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (obj.contains("Fileupload")) {
|
||||
@ -585,56 +597,68 @@ bool Worker::updateTriggerSet() {
|
||||
obj = v.toObject();
|
||||
if (obj.contains("TRG")) {
|
||||
if ((triggerValue = obj.value("TRG").toString()) == "WAIT") {
|
||||
m_ismasTriggerStatusMessage = QStringList("ISMAS_UPDATE-TRIGGER SET TO WAIT");
|
||||
m_ismasTriggerActive = true;
|
||||
return m_ismasTriggerActive;
|
||||
} else
|
||||
if (QRegExp("\\s*").exactMatch(triggerValue)) { // check for whitespace
|
||||
QStringList lst(QString("%1 empty update trigger (%2)").arg(repeat).arg(repeats-repeat));
|
||||
m_ismasTriggerStatusMessage = QStringList(QString("%1 EMPTY UPDATE TRIGGER (%2)").arg(repeat).arg(repeats-repeat));
|
||||
QStringList lst = m_ismasTriggerStatusMessage;
|
||||
if (m_clone) {
|
||||
GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_WRONG_VALUE);
|
||||
GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_WRONG_VALUE));
|
||||
// if the customer repository has just been cloned
|
||||
break; // it is OK the ISMAS trigger might not be 'WAIT'
|
||||
return false; // it is OK the ISMAS trigger might not be 'WAIT'
|
||||
} else {
|
||||
GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE));
|
||||
}
|
||||
QThread::sleep(6);
|
||||
continue;
|
||||
} else {
|
||||
// if the download-button once has the wrong value, it will never recover
|
||||
// if the download-button once has a wrong value, it will never recover
|
||||
if (m_clone) {
|
||||
GUI() << (CONSOLE() << UPDATE_STEP::CHECK_ISMAS_TRIGGER_WRONG_VALUE);
|
||||
m_ismasTriggerStatusMessage = QStringList(QString("TRIGGER-VALUE=<%1> NOT 'WAIT'").arg(triggerValue));
|
||||
QStringList lst = m_ismasTriggerStatusMessage;
|
||||
GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_WRONG_VALUE));
|
||||
} else {
|
||||
QStringList lst(QString("TRIGGER-VALUE=<%1> NOT 'WAIT'").arg(triggerValue));
|
||||
m_ismasTriggerStatusMessage = QStringList(QString("TRIGGER-VALUE=<%1> NOT 'WAIT'").arg(triggerValue));
|
||||
QStringList lst = m_ismasTriggerStatusMessage;
|
||||
GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE));
|
||||
}
|
||||
break;
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
QStringList lst("TRG key not available");
|
||||
m_ismasTriggerStatusMessage = QStringList(QString("TRG key not available (LINE=%1)").arg(__LINE__));
|
||||
QStringList lst = m_ismasTriggerStatusMessage;
|
||||
GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE));
|
||||
break;
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
QStringList lst("Fileupload not a json-object");
|
||||
m_ismasTriggerStatusMessage = QStringList(QString("Fileupload not a json-object (LINE=%1)").arg(__LINE__));
|
||||
QStringList lst = m_ismasTriggerStatusMessage;
|
||||
GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE));
|
||||
break;
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
QStringList lst(QString("Fileupload not available"));
|
||||
m_ismasTriggerStatusMessage = QStringList(QString("Fileupload not available (LINE=%1)").arg(__LINE__));
|
||||
QStringList lst = m_ismasTriggerStatusMessage;
|
||||
GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE));
|
||||
break;
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
QStringList lst = QStringList(QString("no ISMAS response"));
|
||||
m_ismasTriggerStatusMessage = QStringList(QString("no ISMAS response (LINE=%1)").arg(__LINE__));
|
||||
QStringList lst = m_ismasTriggerStatusMessage;
|
||||
GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE));
|
||||
QThread::sleep(6);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_initialClone == false) {
|
||||
if (!triggerValue.contains("WAIT", Qt::CaseInsensitive)) {
|
||||
QStringList lst(QString("ISMAS_UPDATE-TRIGGER-NOT-SET-OR-WRONG: VALUE=(") + triggerValue + ")");
|
||||
ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE)));
|
||||
m_ismasTriggerStatusMessage = QStringList(QString("ISMAS_UPDATE-TRIGGER-NOT-SET-OR-WRONG: VALUE=(") + triggerValue + ")");
|
||||
QStringList lst = m_ismasTriggerStatusMessage;
|
||||
GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user