From ec79c696b9a595d36c941bbdc17600e4c2b47df8 Mon Sep 17 00:00:00 2001 From: blaakmeer <sdos@astron.nl> Date: Tue, 12 Sep 2006 09:49:39 +0000 Subject: [PATCH] BugID: 802 Implemented shutdown procedure --- .../CEPCU/src/OnlineControl/OnlineControl.cc | 92 ++++++++++++++----- .../CEPCU/src/OnlineControl/OnlineControl.h | 7 +- 2 files changed, 74 insertions(+), 25 deletions(-) diff --git a/MAC/APL/CEPCU/src/OnlineControl/OnlineControl.cc b/MAC/APL/CEPCU/src/OnlineControl/OnlineControl.cc index 75efe582302..0d70222252d 100644 --- a/MAC/APL/CEPCU/src/OnlineControl/OnlineControl.cc +++ b/MAC/APL/CEPCU/src/OnlineControl/OnlineControl.cc @@ -377,9 +377,9 @@ GCFEvent::TResult OnlineControl::active_state(GCFEvent& event, GCFPortInterface& case CONTROL_RELEASE: { CONTROLReleaseEvent msg(event); - LOG_DEBUG_STR("Received RELEASED(" << msg.cntlrName << ")"); + LOG_DEBUG_STR("Received RELEASE(" << msg.cntlrName << ")"); setState(CTState::RELEASE); - doRelease(event); + doRelease(); setState(CTState::RELEASED); CONTROLReleasedEvent answer; answer.cntlrName = msg.cntlrName; @@ -396,6 +396,33 @@ GCFEvent::TResult OnlineControl::active_state(GCFEvent& event, GCFPortInterface& return (status); } +// +// finished_state(event, port) +// +// Finishing state. +// +GCFEvent::TResult OnlineControl::finished_state(GCFEvent& event, GCFPortInterface& port) +{ + LOG_DEBUG_STR ("active:" << evtstr(event) << "@" << port.getName()); + + GCFEvent::TResult status = GCFEvent::HANDLED; + + switch (event.signal) { + case F_ENTRY: { + GCFTask::stop(); + break; + } + default: + LOG_DEBUG("active_state, default"); + status = GCFEvent::NOT_HANDLED; + break; + } + + return (status); +} + + + // // doPrepare(cntlrName) @@ -519,27 +546,44 @@ uint16_t OnlineControl::doPrepare(const string& cntlrName) } // -// doRelease(event) +// doRelease() // -void OnlineControl::doRelease(GCFEvent& /*event*/) +void OnlineControl::doRelease(void) { - string hostName, remoteFile, resultFile; - hostName = itsCepAppParams.getString("AC.hostname"); - resultFile = formatString("ACC-%s_result.param", getName().c_str()); - remoteFile = string(LOFAR_SHARE_LOCATION) + string("/") + resultFile; - APLCommon::APLUtilities::copyFromRemote(hostName,remoteFile,resultFile); - itsResultParams.adoptFile(resultFile); - // itsResultParams.replace(KVpair(formatString("%s.quality", getName().c_str()), (int) _qualityGuard.getQuality())); - if (!itsResultParams.isDefined(formatString("%s.faultyNodes", getName().c_str()))) + try + { + string hostName, remoteFile, resultFile; + hostName = itsCepAppParams.getString("AC.hostname"); + resultFile = formatString("ACC-%s_result.param", getName().c_str()); + remoteFile = string(LOFAR_SHARE_LOCATION) + string("/") + resultFile; + APLCommon::APLUtilities::copyFromRemote(hostName,remoteFile,resultFile); + itsResultParams.adoptFile(resultFile); + // itsResultParams.replace(KVpair(formatString("%s.quality", getName().c_str()), (int) _qualityGuard.getQuality())); + if (!itsResultParams.isDefined(formatString("%s.faultyNodes", getName().c_str()))) + { + itsResultParams.add(formatString("%s.faultyNodes", getName().c_str()), ""); + } + itsResultParams.writeFile(formatString("%s_result.param", getName().c_str())); + } + catch(...) { - itsResultParams.add(formatString("%s.faultyNodes", getName().c_str()), ""); } - itsResultParams.writeFile(formatString("%s_result.param", getName().c_str())); - itsCepApplication.quit(0); } +// +// finishController +// +void OnlineControl::finishController(uint16_t result) +{ + setState(CTState::RELEASE); + doRelease(); + setState(CTState::RELEASED); + LOG_DEBUG ("Going to finished state"); + TRAN(OnlineControl::finished_state); // go to next state. +} +// // _connectedHandler(port) // void OnlineControl::_connectedHandler(GCFPortInterface& /*port*/) @@ -567,8 +611,7 @@ void OnlineControl::appBooted(uint16 result) else if (result == 0) // Error { LOG_ERROR("Error in ACC. Stops CEP application and releases Online Control."); - itsCepApplication.quit(0); - // _doStateTransition(LOGICALDEVICE_STATE_RELEASING, LD_RESULT_LOW_QUALITY); + finishController(CT_RESULT_UNSPECIFIED); } } @@ -584,8 +627,7 @@ void OnlineControl::appDefined(uint16 result) else if (result == 0) // Error { LOG_ERROR("Error in ACC. Stops CEP application and releases VB."); - itsCepApplication.quit(0); - // _doStateTransition(LOGICALDEVICE_STATE_RELEASING, LD_RESULT_LOW_QUALITY); + finishController(CT_RESULT_UNSPECIFIED); } } @@ -602,8 +644,7 @@ void OnlineControl::appInitialized(uint16 result) else if (result == 0) // Error { LOG_ERROR("Error in ACC. Stops CEP application and releases VB."); - itsCepApplication.quit(0); - // _doStateTransition(LOGICALDEVICE_STATE_RELEASING, LD_RESULT_LOW_QUALITY); + finishController(CT_RESULT_UNSPECIFIED); } } @@ -616,8 +657,7 @@ void OnlineControl::appRunDone(uint16 result) else if (result == 0) // Error { LOG_ERROR("Error in ACC. Stops CEP application and releases VB."); - itsCepApplication.quit(0); - // _doStateTransition(LOGICALDEVICE_STATE_RELEASING, LD_RESULT_LOW_QUALITY); + finishController(CT_RESULT_UNSPECIFIED); } } @@ -627,10 +667,14 @@ void OnlineControl::appPaused(uint16 /*result*/) void OnlineControl::appQuitDone(uint16 result) { - if (result == AcCmdMaskOk) + if (result == (AcCmdMaskOk | AcCmdMaskScheduled)) { //_qualityGuard.stopMonitoring(); // not in this increment } + else + { + finishController(CT_RESULT_NO_ERROR); + } } void OnlineControl::appSnapshotDone(uint16 /*result*/) diff --git a/MAC/APL/CEPCU/src/OnlineControl/OnlineControl.h b/MAC/APL/CEPCU/src/OnlineControl/OnlineControl.h index 9328c5e29ad..54ca0367a9d 100644 --- a/MAC/APL/CEPCU/src/OnlineControl/OnlineControl.h +++ b/MAC/APL/CEPCU/src/OnlineControl/OnlineControl.h @@ -86,6 +86,10 @@ public: GCFEvent::TResult active_state (GCFEvent& e, GCFPortInterface& p); + // Finishing mode. + GCFEvent::TResult finished_state(GCFEvent& event, + GCFPortInterface& port); + protected: // implemenation of abstract CEPApplicationManagerInterface methods void appBooted(uint16 result); void appDefined(uint16 result); @@ -108,7 +112,8 @@ private: uint16_t doClaim(const string& cntlrName); uint16_t doPrepare(const string& cntlrName); - void doRelease(GCFEvent& event); + void doRelease(); + void finishController(uint16_t result); void _connectedHandler(GCFPortInterface& port); void _disconnectedHandler(GCFPortInterface& port); void setState(CTState::CTstateNr newState); -- GitLab