aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorToni Uhlig <Toni.Uhlig@tq-group.com>2017-12-12 08:50:45 +0100
committerToni Uhlig <Toni.Uhlig@tq-group.com>2017-12-12 08:50:45 +0100
commita803aaa40ce61f994c3eddc94f9cab609abc4a10 (patch)
treec8554c10300c0078b5269caa7df223dc33555cd7 /src
parent10ce4daac4236316dffeff9e38d01f9f346198bc (diff)
JobQueue documentation, autoconf documentation, autoconf C/C++/Win header checks
Diffstat (limited to 'src')
-rw-r--r--src/JobQueue.cpp17
-rw-r--r--src/UpdateFactory.cpp1
2 files changed, 15 insertions, 3 deletions
diff --git a/src/JobQueue.cpp b/src/JobQueue.cpp
index 4f85619..792e795 100644
--- a/src/JobQueue.cpp
+++ b/src/JobQueue.cpp
@@ -60,7 +60,7 @@ void WorkerThread::doJob()
jobStart = std::time(nullptr);
/* process the job which was started by the GUI */
- switch(job.cmdEvent)
+ switch (job.cmdEvent)
{
case Job::eID_THREAD_EXIT:
m_pQueue->decBusyWorker();
@@ -68,19 +68,23 @@ void WorkerThread::doJob()
case Job::eID_THREAD_JOB:
Sleep(1000); /* give the UI some time to handle a lot of new Jobs */
+ /* try to CONNECT to an EnergyManager */
m_pQueue->Report(Job::eID_THREAD_MSG,
wxString::Format(wxT("Job #%d: Connecting to %s:%i"),
job.cmdArgs.jobid, job.cmdArgs.hostname, job.cmdArgs.port), m_ID);
uf.setDest(job.cmdArgs.hostname, job.cmdArgs.port);
uf.setPass(job.cmdArgs.password);
+ /* try to AUTHENTICATE against an EnergyManager */
rv = uf.doAuth();
+ /* print REMOTE EnergyManager firmware version (if valid) */
if (uf.getEmcVersion() != EMC_UNKNOWN) {
m_pQueue->Report(Job::eID_THREAD_MSG,
wxString::Format(wxT("Job #%d: Current EnergyManager version: %s"),
job.cmdArgs.jobid, mapEmcVersion(uf.getEmcVersion())), m_ID);
}
+ /* check if AUTHENTICATE failed */
if (rv != UPDATE_OK) {
mapEmcError(rv, err);
m_pQueue->Report(Job::eID_THREAD_MSGERR,
@@ -89,12 +93,14 @@ void WorkerThread::doJob()
break;
}
+ /* load UPDATE IMAGE into memory */
m_pQueue->Report(Job::eID_THREAD_MSG,
wxString::Format(wxT("Job #%d: Loading file \"%s\""),
job.cmdArgs.jobid, job.cmdArgs.update_file), m_ID);
uf.setUpdateFile(job.cmdArgs.update_file.c_str());
rv = uf.loadUpdateFile();
+ /* validate and check for UPDATE IMAGE firmware version */
if (uf.getFwVersion() == EMC_UNKNOWN) {
m_pQueue->Report(Job::eID_THREAD_MSG,
wxString::Format(wxT("Job #%d: Invalid firmware update file"),
@@ -104,6 +110,8 @@ void WorkerThread::doJob()
m_pQueue->Report(Job::eID_THREAD_MSG,
wxString::Format(wxT("Job #%d: Firmware image version: %s"),
job.cmdArgs.jobid, mapEmcVersion(uf.getFwVersion())), m_ID);
+
+ /* compare REMOTE with UPDATE IMAGE firmware version */
if (!isEmcVersionLowerThen(uf.getEmcVersion(), uf.getFwVersion())) {
m_pQueue->Report(Job::eID_THREAD_MSGERR,
wxString::Format(wxT("Job #%d: Version mismatch (%s >= %s)"),
@@ -112,6 +120,7 @@ void WorkerThread::doJob()
break;
}
+ /* compare succeeded */
if (rv != UPDATE_OK) {
mapEmcError(rv, err);
m_pQueue->Report(Job::eID_THREAD_MSGERR,
@@ -120,10 +129,12 @@ void WorkerThread::doJob()
break;
}
+ /* upload UPDATE IMAGE to the REMOTE EnergyManager */
m_pQueue->Report(Job::eID_THREAD_MSG,
wxString::Format(wxT("Job #%d: Uploading file \"%s\""),
job.cmdArgs.jobid, job.cmdArgs.update_file), m_ID);
rv = uf.doUpdate();
+ /* report any errors during upload */
mapEmcError(rv, err);
if (rv != UPDATE_OK) {
m_pQueue->Report(Job::eID_THREAD_MSGERR,
@@ -132,6 +143,7 @@ void WorkerThread::doJob()
break;
}
+ /* done */
m_pQueue->Report(Job::eID_THREAD_MSGOK,
wxString::Format(wxT("Job #%d: %s."),
job.cmdArgs.jobid, err), m_ID);
@@ -141,11 +153,12 @@ void WorkerThread::doJob()
break;
}
+ /* report consumed time */
jobEnd = std::time(nullptr);
diffTime = std::difftime(jobEnd, jobStart);
-
m_pQueue->ReportDone(JobReport(diffTime),
wxString::Format(wxT("Job #%d: finished. Time consumed: %umin %usec"),
job.cmdArgs.jobid, (diffTime / 60), (diffTime % 60)), m_ID);
+
m_pQueue->decBusyWorker();
}
diff --git a/src/UpdateFactory.cpp b/src/UpdateFactory.cpp
index 3b01107..909f8ea 100644
--- a/src/UpdateFactory.cpp
+++ b/src/UpdateFactory.cpp
@@ -2,7 +2,6 @@
#include <fstream>
#include <string>
#include <sstream>
-#include <unordered_map>
#include <iomanip>
#include "UpdateFactory.hpp"