diff --git a/MAC/APL/CEPCU/src/PythonControl/PythonControl.cc b/MAC/APL/CEPCU/src/PythonControl/PythonControl.cc index 5cfd97c3be08d2049794798cfe21686f853d6659..5d523f162b0c09388fc0720f3a8a65fea1ffe7ba 100644 --- a/MAC/APL/CEPCU/src/PythonControl/PythonControl.cc +++ b/MAC/APL/CEPCU/src/PythonControl/PythonControl.cc @@ -30,7 +30,6 @@ #include <Common/Exceptions.h> #include <Common/SystemUtil.h> #include <Common/hexdump.h> -#include <MessageBus/MsgBus.h> #include <ApplCommon/LofarDirs.h> #include <ApplCommon/StationInfo.h> #include <MACIO/MACServiceInfo.h> @@ -79,7 +78,7 @@ PythonControl::PythonControl(const string& cntlrName) : itsForcedQuitTimer (0), itsListener (0), itsMsgQueue (0), - itsFeedbackResult (CT_RESULT_NO_ERROR), // QUICK FIX #3633 + itsFeedbackResult (CT_RESULT_NO_ERROR), itsPythonPort (0), itsState (CTState::NOSTATE), itsForceTimeout (3600.0) @@ -106,6 +105,8 @@ PythonControl::PythonControl(const string& cntlrName) : // need port for timers. itsTimerPort = new GCFTimerPort(*this, "TimerPort"); ASSERTSTR(itsTimerPort, "Cannot allocate the timer"); + itsQueueTimer = new GCFTimerPort(*this, "MsgQTimer"); + ASSERTSTR(itsQueueTimer, "Cannot allocate queue timer"); // for debugging purposes registerProtocol (CONTROLLER_PROTOCOL, CONTROLLER_PROTOCOL_STRINGS); @@ -124,6 +125,8 @@ PythonControl::~PythonControl() delete itsListener; } + delete itsTimerPort; + delete itsQueueTimer; delete itsMsgQueue; } @@ -349,7 +352,6 @@ GCFEvent::TResult PythonControl::initial_state(GCFEvent& event, GCFPortInterface string pythonHost (thePS->getString(myPrefix+"pythonHost", "@pythonHost@")); itsChildCanCommunicate = thePS->getBool (myPrefix+"canCommunicate", true); // START PYTHON - // QUICK FIX #3633: if-else nesting was different if (itsChildCanCommunicate) { bool startOK = _startPython(pythonProg, getObservationNr(getName()), realHostname(pythonHost), itsListener->makeServiceName()); @@ -517,30 +519,6 @@ GCFEvent::TResult PythonControl::operational_state(GCFEvent& event, GCFPortInter } } break; - // QUICK FIX #3633 -#if 0 - case F_DATAIN: { - ASSERTSTR(&port == itsFeedbackPort, "Didn't expect raw data on port " << port.getName()); - char buf[1024]; - ssize_t btsRead = port.recv((void*)&buf[0], 1023); - buf[btsRead] = '\0'; - string s; - hexdump(s, buf, btsRead); - LOG_INFO_STR("Received command on feedback port: " << s); - - if (!strcmp(buf, "ABORT")) { - itsFeedbackResult = CT_RESULT_PIPELINE_FAILED; - TRAN(PythonControl::finishing_state); - } - else if (!strcmp(buf, "FINISHED")) { - TRAN(PythonControl::finishing_state); - } - else { - LOG_ERROR_STR("Received command on feedback port unrecognized"); - } - } break; -#endif - case F_TIMER: { if (&port == itsForcedQuitTimer) { LOG_WARN("Aborting program on emergency timer!"); @@ -549,7 +527,14 @@ GCFEvent::TResult PythonControl::operational_state(GCFEvent& event, GCFPortInter if (&port == itsQueueTimer) { Message msg; if (itsMsgQueue->getMessage(msg, 0.1)) { -// itsFeedbackResult = msg.content.task.state; // @@@@ + string result = msg.getXMLvalue("message.payload.task.state"); + if (result == "ABORT") { + itsFeedbackResult = CT_RESULT_PIPELINE_FAILED; + } + else if (result != "FINISHED") { + LOG_FATAL_STR("Unknown result received from pipeline: " << result << " assuming failure!"); + itsFeedbackResult = CT_RESULT_PIPELINE_FAILED; + } LOG_INFO_STR("Received finish result on messagebus: " << itsFeedbackResult); TRAN(PythonControl::finishing_state); break; @@ -609,7 +594,6 @@ GCFEvent::TResult PythonControl::operational_state(GCFEvent& event, GCFPortInter itsPythonPort->send(msg); } else { - // QUICK FIX #3633 LOG_INFO("Trying to start the Python environment"); ParameterSet* thePS = globalParameterSet(); // shortcut to global PS. string myPrefix (thePS->locateModule("PythonControl")+"PythonControl."); @@ -626,7 +610,6 @@ GCFEvent::TResult PythonControl::operational_state(GCFEvent& event, GCFPortInter finish(CT_RESULT_PIPELINE_FAILED); break; } - // QUICK FIX #3633 END LOG_WARN("Start of Python environment looks OK, sending FAKE Resume response"); sendControlResult(*itsParentPort, event.signal, itsMyName, CT_RESULT_NO_ERROR); } diff --git a/MAC/APL/CEPCU/src/PythonControl/PythonControl.h b/MAC/APL/CEPCU/src/PythonControl/PythonControl.h index 8a73ff15c5e915197e8bf73407525cedfccf97e9..759f3a0f3b1e1ebe77c00f87ef02698ccc4a23ac 100644 --- a/MAC/APL/CEPCU/src/PythonControl/PythonControl.h +++ b/MAC/APL/CEPCU/src/PythonControl/PythonControl.h @@ -88,7 +88,6 @@ private: bool _stopPython ( int obsID, const string& pythonHost); void _databaseEventHandler(GCFEvent& event); - void _passMetadatToOTDB(); // ----- datamembers ----- RTDBPropertySet* itsPropertySet; @@ -106,7 +105,6 @@ private: GCFTCPPort* itsListener; - // QUICK FIX #3633 FromBus* itsMsgQueue; int itsFeedbackResult;