diff --git a/MAC/APL/APLCommon/configure.in b/MAC/APL/APLCommon/configure.in index 70a4fe8ff9e37d44a0f9d9e9dae05e47c01dca06..7bb6640d5c99cfaad6ce1e36d4e6b62d142cd5e0 100644 --- a/MAC/APL/APLCommon/configure.in +++ b/MAC/APL/APLCommon/configure.in @@ -59,7 +59,6 @@ lofar_INTERNAL(LCS/Common, common, , 1, Common/LofarTypes.h,,) lofar_INTERNAL(LCS/ACC/APS, APS, , 1, APS/ParameterSet.h,,) lofar_INTERNAL(MAC/GCF/TM, GCFTM, , 1, GCF/TM/GCF_Control.h,,) lofar_INTERNAL(MAC/GCF/GCFCommon, GCFCommon, , 1, GCF/GCF_Defines.h,,) -lofar_INTERNAL(MAC/GCF/PAL, GCFPAL, , 1, GCF/PAL/GCF_Property.h,,) lofar_EXTERNAL(boost,1,boost/date_time/date.hpp, boost_date_time) dnl diff --git a/MAC/APL/APLCommon/src/ChildControl.cc b/MAC/APL/APLCommon/src/ChildControl.cc index bd108db957c6e8be0bc6199adf2c78bee73863b3..c01e7b8c13bd31e14cbb1add7fc52d2dc3d9b7cf 100644 --- a/MAC/APL/APLCommon/src/ChildControl.cc +++ b/MAC/APL/APLCommon/src/ChildControl.cc @@ -930,6 +930,7 @@ void ChildControl::_doGarbageCollection() CIiter iterCopy = iter; iter++; itsCntlrList->erase(iterCopy); + LOG_DEBUG_STR("Size of itsCntlrList = " << itsCntlrList->size()); } else { iter++; } @@ -948,7 +949,7 @@ void ChildControl::_doGarbageCollection() GCFEvent::TResult ChildControl::initial (GCFEvent& event, GCFPortInterface& port) { - LOG_DEBUG_STR ("initial:" << evtstr(event) << "@" << port.getName()); +// LOG_DEBUG_STR ("initial:" << evtstr(event) << "@" << port.getName()); LOG_DEBUG_STR ("initial:" << eventName(event) << "@" << port.getName()); GCFEvent::TResult status = GCFEvent::HANDLED; @@ -1053,7 +1054,9 @@ GCFEvent::TResult ChildControl::operational(GCFEvent& event, if (controller->currentState >= CTState::QUIT) {// expected disconnect? LOG_DEBUG_STR("Removing " << controller->cntlrName << " from the controllerList"); + port.close(); itsCntlrList->erase(controller); // just remove + LOG_DEBUG_STR("Size of itsCntlrList = " << itsCntlrList->size()); } else { // unexpected disconnect give child some time to reconnect(?) LOG_WARN_STR ("Lost connection with controller " << @@ -1072,15 +1075,16 @@ GCFEvent::TResult ChildControl::operational(GCFEvent& event, itsActionTimer = itsListener->setTimer(1.0); itsActionList.push_back(*controller); - // And schedule cleanup when everthing fails #endif - if (itsGarbageTimer) { - itsTimerPort.cancelTimer(itsGarbageTimer); - } - itsGarbageTimer = itsTimerPort.setTimer(1.0 * itsGarbageInterval); - LOG_DEBUG_STR("GarbageTimer = " << itsGarbageTimer); } - // controlelr was found and handled, break out of the while loop. + + // And schedule cleanup when everthing fails + if (itsGarbageTimer) { + itsTimerPort.cancelTimer(itsGarbageTimer); + } + itsGarbageTimer = itsTimerPort.setTimer(1.0 * itsGarbageInterval); + LOG_DEBUG_STR("GarbageTimer = " << itsGarbageTimer); + // controller was found and handled, break out of the while loop. break; } // while #endif diff --git a/MAC/APL/APLCommon/src/ControllerDefines.cc b/MAC/APL/APLCommon/src/ControllerDefines.cc index 41c804a7ce20fd2937e57ee5d8599e9437ec753f..9a033bdf903193e3cb9e046178634af8b8ef1a93 100644 --- a/MAC/APL/APLCommon/src/ControllerDefines.cc +++ b/MAC/APL/APLCommon/src/ControllerDefines.cc @@ -27,7 +27,6 @@ #include <Common/LofarLogger.h> #include <Common/StringUtil.h> // rtrim #include <GCF/Utils.h> // myHostname -#include <GCF/PAL/GCF_PropertyProxy.h> #include <APS/ParameterSet.h> // indexValue #include <APL/APLCommon/ControllerDefines.h> #include <APL/APLCommon/StationInfo.h> @@ -40,7 +39,6 @@ using namespace boost; namespace LOFAR { using namespace Deployment; using namespace GCF::Common; - using namespace GCF::PAL; namespace APLCommon { typedef struct cntlrDefinition { @@ -261,16 +259,16 @@ string createPropertySetName(const string& propSetMask, } if ((pos = psName.find("@cabinet@")) != string::npos) { - psName.replace(pos, 9, string("cabinet%d")); + psName.replace(pos, 9, string("Cabinet%d")); } if ((pos = psName.find("@subrack@")) != string::npos) { - psName.replace(pos, 9, string("subrack%d")); + psName.replace(pos, 9, string("Subrack%d")); } if ((pos = psName.find("@RSPBoard@")) != string::npos) { psName.replace(pos, 10, string("RSPBoard%d")); } if ((pos = psName.find("@rcu@")) != string::npos) { - psName.replace(pos, 5, string("rcu%d")); + psName.replace(pos, 5, string("RCU%d")); } return (psName); @@ -372,6 +370,7 @@ bool sendControlResult(GCF::TM::GCFPortInterface& port, // // setControllerMode(PSname, modeNr) // +// TODO MOVE TO RTDBCommon or something like that. void setControllerMode(const string& propertyName, int16 modeNr) { #if 0 diff --git a/MAC/APL/APLCommon/src/PropertySetAnswer.cc b/MAC/APL/APLCommon/src/PropertySetAnswer.cc deleted file mode 100644 index b8580d564292238dd38f0befbf1cdb93532598bd..0000000000000000000000000000000000000000 --- a/MAC/APL/APLCommon/src/PropertySetAnswer.cc +++ /dev/null @@ -1,49 +0,0 @@ -//# PropertySetAnswer.cc: Implementation of the PropertySet Answer -//# -//# Copyright (C) 2002-2004 -//# ASTRON (Netherlands Foundation for Research in Astronomy) -//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl -//# -//# This program is free software; you can redistribute it and/or modify -//# it under the terms of the GNU General Public License as published by -//# the Free Software Foundation; either version 2 of the License, or -//# (at your option) any later version. -//# -//# This program is distributed in the hope that it will be useful, -//# but WITHOUT ANY WARRANTY; without even the implied warranty of -//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//# GNU General Public License for more details. -//# -//# You should have received a copy of the GNU General Public License -//# along with this program; if not, write to the Free Software -//# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -//# -//# $Id$ -#include <lofar_config.h> -#include <Common/LofarLogger.h> - -#include <APL/APLCommon/APL_Defines.h> -#include "APL/APLCommon/PropertySetAnswer.h" -#include "APL/APLCommon/PropertySetAnswerHandlerInterface.h" - -using namespace LOFAR; -using namespace LOFAR::GCF::TM; -using namespace LOFAR::GCF::PAL; -using namespace LOFAR::APLCommon; - -PropertySetAnswer::PropertySetAnswer(PropertySetAnswerHandlerInterface& handler) : - GCFAnswer(), - m_handler(handler) -{ - LOG_DEBUG("PropertySetAnswer::PropertySetAnswer"); -} - -PropertySetAnswer::~PropertySetAnswer() -{ - LOG_DEBUG("PropertySetAnswer::~PropertySetAnswer"); -} - -void PropertySetAnswer::handleAnswer(GCFEvent& answer) -{ - m_handler.handlePropertySetAnswer(answer); -} diff --git a/MAC/APL/APLCommon/src/swlevel.conf b/MAC/APL/APLCommon/src/swlevel.conf index 4ec69055fc039816ed55512784f26693a21def70..4af49dc1daa000873ceaaf451ae7e3ccfb833cce 100644 --- a/MAC/APL/APLCommon/src/swlevel.conf +++ b/MAC/APL/APLCommon/src/swlevel.conf @@ -9,9 +9,8 @@ 2:u:d:r:EPAStub 2:u:d:r:RSPDriver 3:u:d::PVSS00pmon -3:u:d::PropertyAgent 3:u:d::CodeLoggingProcessor -4:u:d::RegisterAccess +4:u:d::HardwareMonitor 5:u:d::amcserver 5:u:d::CalServer 5:u:d::BeamServer diff --git a/MAC/APL/MainCU/configure.in b/MAC/APL/MainCU/configure.in index 3bd60923a73ecb6896b03b8d5d97d791efbf63e7..fe0406a77dba63c2a2b2aa2d2fa0ff4cbe35f98b 100644 --- a/MAC/APL/MainCU/configure.in +++ b/MAC/APL/MainCU/configure.in @@ -60,7 +60,7 @@ lofar_INTERNAL(LCS/ACC/APS, aps, , 1, APS/ParameterSet.h,,) lofar_INTERNAL(SAS/OTDB, otdb, , 1, OTDB/OTDBconnection.h,,) lofar_INTERNAL(MAC/GCF/GCFCommon, gcfcommon, , 1, GCF/GCF_Defines.h,,) lofar_INTERNAL(MAC/GCF/TM, gcftm, , 1, GCF/TM/GCF_Task.h,,) -lofar_INTERNAL(MAC/GCF/PAL, gcfpal, , 1, GCF/PAL/GCF_PVSSInfo.h,,) +lofar_INTERNAL(MAC/GCF/RTDB, rtdb, , 1, GCF/RTDB/RTDB_PropertySet.h,,) lofar_INTERNAL(MAC/APL/APLCommon, aplcommon, , 1, APL/APLCommon/APL_Defines.h,,) lofar_EXTERNAL(boost,1,boost/date_time/date.hpp, boost_date_time) lofar_EXTERNAL(pqxx,2.5.5,pqxx/pqxx, pqxx) diff --git a/MAC/APL/MainCU/src/MACScheduler/MACScheduler.cc b/MAC/APL/MainCU/src/MACScheduler/MACScheduler.cc index 14d1dac943f899a126064651eab51f89970fa71a..2062f5649a47251599815195d60da771f45cdd2d 100644 --- a/MAC/APL/MainCU/src/MACScheduler/MACScheduler.cc +++ b/MAC/APL/MainCU/src/MACScheduler/MACScheduler.cc @@ -22,19 +22,16 @@ #include <lofar_config.h> #include <Common/LofarLogger.h> -#include <boost/shared_array.hpp> #include <APS/ParameterSet.h> #include <GCF/TM/GCF_Protocols.h> #include <GCF/GCF_ServiceInfo.h> #include <GCF/GCF_PVTypes.h> -#include <GCF/Protocols/PA_Protocol.ph> -#include <GCF/PAL/GCF_PVSSInfo.h> #include <GCF/Utils.h> #include <APL/APLCommon/APL_Defines.h> #include <APL/APLCommon/ControllerDefines.h> #include <APL/APLCommon/StationInfo.h> -#include <APL/APLCommon/APLCommonExceptions.h> #include <APL/APLCommon/Controller_Protocol.ph> +#include <GCF/RTDB/DP_Protocol.ph> #include <OTDB/TreeStateConv.h> #include <signal.h> @@ -43,7 +40,7 @@ using namespace LOFAR::GCF::Common; using namespace LOFAR::GCF::TM; -using namespace LOFAR::GCF::PAL; +using namespace LOFAR::GCF::RTDB; using namespace LOFAR::OTDB; using namespace LOFAR::Deployment; using namespace std; @@ -61,9 +58,7 @@ static MACScheduler* pMacScheduler = 0; // MACScheduler::MACScheduler() : GCFTask ((State)&MACScheduler::initial_state,string(MS_TASKNAME)), - PropertySetAnswerHandlerInterface(), - itsPropertySetAnswer(*this), - itsPropertySet (), + itsPropertySet (0), itsObservations (), itsPVSSObsList (), itsTimerPort (0), @@ -98,8 +93,7 @@ MACScheduler::MACScheduler() : itsObservations.reserve(10); // already reserve memory for 10 observations. GCF::TM::registerProtocol(CONTROLLER_PROTOCOL, CONTROLLER_PROTOCOL_STRINGS); - GCF::TM::registerProtocol(PA_PROTOCOL, PA_PROTOCOL_STRINGS); - GCF::TM::registerProtocol(F_PML_PROTOCOL, F_PML_PROTOCOL_STRINGS); + GCF::TM::registerProtocol(DP_PROTOCOL, DP_PROTOCOL_STRINGS); } @@ -110,10 +104,9 @@ MACScheduler::~MACScheduler() { LOG_TRACE_OBJ ("~MACscheduler"); -// if (itsPropertySet) { - // Note: disable is not neccesary because this is always done in destructor - // of propertyset. -// } + if (itsPropertySet) { + delete itsPropertySet; + } if (itsOTDBconnection) { delete itsOTDBconnection; @@ -134,63 +127,30 @@ void MACScheduler::sigintHandler(int signum) // -// handlePropertySetAnswer(answer) +// _databaseEventHandler(event) // -void MACScheduler::handlePropertySetAnswer(GCFEvent& answer) +void MACScheduler::_databaseEventHandler(GCFEvent& event) { - LOG_DEBUG_STR ("handlePropertySetAnswer:" << eventName(answer)); - - switch(answer.signal) { - case F_MYPS_ENABLED: { - GCFPropSetAnswerEvent* pPropAnswer=static_cast<GCFPropSetAnswerEvent*>(&answer); - if(pPropAnswer->result != GCF_NO_ERROR) { - LOG_ERROR(formatString("%s : PropertySet %s NOT ENABLED", - getName().c_str(), pPropAnswer->pScope)); - } - // always let timer expire so main task will continue. - itsTimerPort->setTimer(0.0); - break; - } - - case F_PS_CONFIGURED: - { - GCFConfAnswerEvent* pConfAnswer=static_cast<GCFConfAnswerEvent*>(&answer); - if(pConfAnswer->result == GCF_NO_ERROR) { - LOG_DEBUG(formatString("%s : apc %s Loaded", - getName().c_str(), pConfAnswer->pApcName)); - //apcLoaded(); - } - else { - LOG_ERROR(formatString("%s : apc %s NOT LOADED", - getName().c_str(), pConfAnswer->pApcName)); - } - break; - } + LOG_DEBUG_STR ("_databaseEventHandler:" << eventName(event)); - case F_VGETRESP: - case F_VCHANGEMSG: { - // check which property changed - GCFPropValueEvent* pPropAnswer=static_cast<GCFPropValueEvent*>(&answer); + switch(event.signal) { + case DP_CHANGED: { + DPChangedEvent dpEvent(event); // TODO: implement something usefull. - // change of queueTime - if ((strstr(pPropAnswer->pPropName, PSN_MAC_SCHEDULER) != 0) && - (pPropAnswer->pValue->getType() == LPT_INTEGER)) { - uint32 newVal = (uint32) ((GCFPVInteger*)pPropAnswer->pValue)->getValue(); - if (strstr(pPropAnswer->pPropName, PVSSNAME_MS_QUEUEPERIOD) != 0) { - LOG_INFO_STR ("Changing QueuePeriod from " << itsQueuePeriod << - " to " << newVal); - itsQueuePeriod = newVal; - } - else if (strstr(pPropAnswer->pPropName, PVSSNAME_MS_CLAIMPERIOD) != 0) { - LOG_INFO_STR ("Changing ClaimPeriod from " << itsClaimPeriod << - " to " << newVal); - itsClaimPeriod = newVal; - } + if (strstr(dpEvent.DPname.c_str(), PVSSNAME_MS_QUEUEPERIOD) != 0) { + uint32 newVal = ((GCFPVUnsigned*) (dpEvent.value._pValue))->getValue(); + LOG_INFO_STR ("Changing QueuePeriod from " << itsQueuePeriod << " to " << newVal); + itsQueuePeriod = newVal; + } + if (strstr(dpEvent.DPname.c_str(), PVSSNAME_MS_CLAIMPERIOD) != 0) { + uint32 newVal = ((GCFPVUnsigned*) (dpEvent.value._pValue))->getValue(); + LOG_INFO_STR ("Changing ClaimPeriod from " << itsClaimPeriod << " to " << newVal); + itsClaimPeriod = newVal; } - break; } + break; default: break; @@ -216,14 +176,22 @@ GCFEvent::TResult MACScheduler::initial_state(GCFEvent& event, GCFPortInterface& case F_ENTRY: { // Get access to my own propertyset. LOG_DEBUG ("Activating PropertySet"); - itsPropertySet = GCFMyPropertySetPtr(new GCFMyPropertySet(PSN_MAC_SCHEDULER, - PST_MAC_SCHEDULER, - PS_CAT_PERM_AUTOLOAD, - &itsPropertySetAnswer)); - itsPropertySet->enable(); - // Wait for timer that is set in PropertySetAnswer on ENABLED event. + itsPropertySet = new RTDBPropertySet(PSN_MAC_SCHEDULER, + PST_MAC_SCHEDULER, + PSAT_RW, + this); } break; + + case DP_CREATED: { + // NOTE: thsi function may be called DURING the construction of the PropertySet. + // Always exit this event in a way that GCF can end the construction. + DPCreatedEvent dpEvent(event); + LOG_DEBUG_STR("Result of creating " << dpEvent.DPname << " = " << dpEvent.result); + itsTimerPort->cancelAllTimers(); + itsTimerPort->setTimer(0.0); + } + break; case F_TIMER: { // must be timer that PropSet is enabled. // update PVSS. @@ -232,7 +200,7 @@ GCFEvent::TResult MACScheduler::initial_state(GCFEvent& event, GCFPortInterface& itsPropertySet->setValue(PVSSNAME_FSM_ERROR, GCFPVString ("")); itsPropertySet->setValue(PN_MS_OTDB_CONNECTED, GCFPVBool (false)); itsPropertySet->setValue(PN_MS_OTDB_LAST_POLL, GCFPVString ("")); - itsPropertySet->setValue(PN_MS_OTDB_POLLINTERVAL, GCFPVUnsigned(itsOTDBpollInterval)); + itsPropertySet->setValue(PN_MS_OTDB_POLLINTERVAL, GCFPVInteger (itsOTDBpollInterval)); itsPropertySet->setValue(PN_MS_ACTIVE_OBSERVATIONS, GCFPVDynArr(LPT_STRING, itsPVSSObsList)); @@ -249,7 +217,7 @@ GCFEvent::TResult MACScheduler::initial_state(GCFEvent& event, GCFPortInterface& "Unable to connect to database " << DBname << " using " << username << "," << password); LOG_INFO ("Connected to the OTDB"); - itsPropertySet->setValue(string(PN_MS_OTDB_CONNECTED),GCFPVBool(true)); + itsPropertySet->setValue(PN_MS_OTDB_CONNECTED, GCFPVBool(true)); // Start ChildControl task LOG_DEBUG ("Enabling ChildControltask"); @@ -359,6 +327,10 @@ GCFEvent::TResult MACScheduler::active_state(GCFEvent& event, GCFPortInterface& _disconnectedHandler(port); break; + case DP_CHANGED: + _databaseEventHandler(event); + break; + case F_TIMER: { // secondTimer or reconnectTimer. GCFTimerEvent& timerEvent=static_cast<GCFTimerEvent&>(event); if (timerEvent.id == itsSecondTimer) { @@ -508,7 +480,8 @@ GCFEvent::TResult MACScheduler::finishing_state(GCFEvent& event, GCFPortInterfac case F_ENTRY: { // update PVSS itsPropertySet->setValue(string(PVSSNAME_FSM_CURACT),GCFPVString("finished")); - itsPropertySet->setValue(string(PVSSNAME_FSM_ERROR),GCFPVString("")); + itsPropertySet->setValue(string(PVSSNAME_FSM_ERROR), GCFPVString("")); + itsPropertySet->setValue(PN_MS_OTDB_CONNECTED, GCFPVBool (false)); itsTimerPort->setTimer(1L); break; diff --git a/MAC/APL/MainCU/src/MACScheduler/MACScheduler.h b/MAC/APL/MainCU/src/MACScheduler/MACScheduler.h index 1bfe5f862eccfac6939c3761bb205fc806f55bdc..cd2f4acb67d91450314995cc0e1c880e67cb8185 100644 --- a/MAC/APL/MainCU/src/MACScheduler/MACScheduler.h +++ b/MAC/APL/MainCU/src/MACScheduler/MACScheduler.h @@ -23,13 +23,9 @@ #ifndef MACScheduler_H #define MACScheduler_H -//# Includes -#include <boost/shared_ptr.hpp> - //# GCF Includes -#include <GCF/PAL/GCF_MyPropertySet.h> -#include <GCF/GCF_PVDynArr.h> -#include <GCF/GCF_PVString.h> +#include <GCF/RTDB/RTDB_PropertySet.h> +#include <GCF/GCF_PVTypes.h> #include <GCF/TM/GCF_Port.h> #include <GCF/TM/GCF_ITCPort.h> #include <GCF/TM/GCF_TimerPort.h> @@ -37,9 +33,6 @@ #include <GCF/TM/GCF_Event.h> //# local includes -#include <APL/APLCommon/PropertySetAnswerHandlerInterface.h> -#include <APL/APLCommon/PropertySetAnswer.h> -#include <APL/APLCommon/APLCommonExceptions.h> #include <APL/APLCommon/Controller_Protocol.ph> #include <APL/APLCommon/ChildControl.h> #include <APL/APLCommon/CTState.h> @@ -67,20 +60,17 @@ using GCF::TM::GCFPort; using GCF::TM::GCFEvent; using GCF::TM::GCFPortInterface; using GCF::TM::GCFTask; +using GCF::RTDB::RTDBPropertySet; using APLCommon::ChildControl; using APLCommon::Observation; -class MACScheduler : public GCFTask, - APLCommon::PropertySetAnswerHandlerInterface +class MACScheduler : public GCFTask { public: MACScheduler(); ~MACScheduler(); - // PropertySetAnswerHandlerInterface method - virtual void handlePropertySetAnswer(GCFEvent& answer); - // During the initial state all connections with the other programs are made. GCFEvent::TResult initial_state (GCFEvent& e, GCFPortInterface& p); @@ -114,12 +104,10 @@ private: void _removeActiveObservation(const string& name); void _connectedHandler(GCFPortInterface& port); void _disconnectedHandler(GCFPortInterface& port); + void _databaseEventHandler(GCFEvent& event); void _doOTDBcheck(); - typedef boost::shared_ptr<GCF::PAL::GCFMyPropertySet> GCFMyPropertySetPtr; - - APLCommon::PropertySetAnswer itsPropertySetAnswer; - GCFMyPropertySetPtr itsPropertySet; + RTDBPropertySet* itsPropertySet; // Information about the Observations. Not used yet. vector<Observation> itsObservations; diff --git a/MAC/APL/MainCU/src/ObservationControl/ObservationControl.cc b/MAC/APL/MainCU/src/ObservationControl/ObservationControl.cc index 2ea1c6f73864a22569f274eeb7a3a2aa04737e49..58498a39ecb85ddb55bc405dd6863f2729da82c8 100644 --- a/MAC/APL/MainCU/src/ObservationControl/ObservationControl.cc +++ b/MAC/APL/MainCU/src/ObservationControl/ObservationControl.cc @@ -22,18 +22,15 @@ #include <lofar_config.h> #include <Common/LofarLogger.h> -#include <boost/shared_array.hpp> #include <APS/ParameterSet.h> #include <GCF/GCF_PVTypes.h> -#include <GCF/PAL/GCF_PVSSInfo.h> #include <GCF/Utils.h> #include <GCF/GCF_ServiceInfo.h> -#include <GCF/Protocols/PA_Protocol.ph> #include <APL/APLCommon/APL_Defines.h> #include <APL/APLCommon/APLUtilities.h> -#include <APL/APLCommon/APLCommonExceptions.h> #include <APL/APLCommon/Controller_Protocol.ph> #include <APL/APLCommon/StationInfo.h> +#include <GCF/RTDB/DP_Protocol.ph> #include <signal.h> #include "ObservationControl.h" @@ -41,7 +38,7 @@ using namespace LOFAR::GCF::Common; using namespace LOFAR::GCF::TM; -using namespace LOFAR::GCF::PAL; +using namespace LOFAR::GCF::RTDB; using namespace std; namespace LOFAR { @@ -57,9 +54,7 @@ static ObservationControl* thisObservationControl = 0; // ObservationControl::ObservationControl(const string& cntlrName) : GCFTask ((State)&ObservationControl::initial_state,cntlrName), - PropertySetAnswerHandlerInterface(), - itsPropertySetAnswer(*this), - itsPropertySet (), + itsPropertySet (0), itsChildControl (0), itsChildPort (0), itsParentControl (0), @@ -119,8 +114,7 @@ ObservationControl::ObservationControl(const string& cntlrName) : itsTimerPort = new GCFTimerPort(*this, "TimerPort"); GCF::TM::registerProtocol (CONTROLLER_PROTOCOL, CONTROLLER_PROTOCOL_STRINGS); - GCF::TM::registerProtocol (PA_PROTOCOL, PA_PROTOCOL_STRINGS); - GCF::TM::registerProtocol (F_PML_PROTOCOL, F_PML_PROTOCOL_STRINGS); + GCF::TM::registerProtocol (DP_PROTOCOL, DP_PROTOCOL_STRINGS); // we cannot use setState right now, wait for propertysets to come online // setState(CTState::CREATED); @@ -175,120 +169,6 @@ void ObservationControl::setState(CTState::CTstateNr newState) itsParentControl->nowInState(getName(), newState); } -// -// handlePropertySetAnswer(answer) -// -void ObservationControl::handlePropertySetAnswer(GCFEvent& answer) -{ - LOG_TRACE_FLOW_STR ("handlePropertySetAnswer:" << eventName(answer)); - - switch(answer.signal) { - case F_MYPS_ENABLED: { - GCFPropSetAnswerEvent* pPropAnswer=static_cast<GCFPropSetAnswerEvent*>(&answer); - if(pPropAnswer->result != GCF_NO_ERROR) { - LOG_ERROR(formatString("%s : PropertySet %s NOT ENABLED", - getName().c_str(), pPropAnswer->pScope)); - } - // always let timer expire so main task will continue. - itsTimerPort->setTimer(0.0); - break; - } - - case F_PS_CONFIGURED: - { - GCFConfAnswerEvent* pConfAnswer=static_cast<GCFConfAnswerEvent*>(&answer); - if(pConfAnswer->result == GCF_NO_ERROR) { - LOG_DEBUG(formatString("%s : apc %s Loaded", - getName().c_str(), pConfAnswer->pApcName)); - //apcLoaded(); - } - else { - LOG_ERROR(formatString("%s : apc %s NOT LOADED", - getName().c_str(), pConfAnswer->pApcName)); - } - break; - } - - case F_VGETRESP: - case F_VCHANGEMSG: { - // check which propertySet(!) changed - GCFPropValueEvent* pPropAnswer=static_cast<GCFPropValueEvent*>(&answer); - - string PropSetName = createPropertySetName(PSN_OBS_CTRL, getName()); - if (strstr(pPropAnswer->pPropName, PropSetName.c_str()) == 0) { - break; // if not my own, exit - } - - // don't watch state and error fields. - if ((strstr(pPropAnswer->pPropName, PVSSNAME_FSM_STATE) != 0) || - (strstr(pPropAnswer->pPropName, PVSSNAME_FSM_ERROR) != 0) || - (strstr(pPropAnswer->pPropName, PVSSNAME_FSM_CURACT) != 0) || - (strstr(pPropAnswer->pPropName, PVSSNAME_FSM_LOGMSG) != 0)) { - return; - } - - // periods are of type integer. - if (pPropAnswer->pValue->getType() == LPT_INTEGER) { - uint32 newVal = (uint32) ((GCFPVInteger*)pPropAnswer->pValue)->getValue(); - - if (strstr(pPropAnswer->pPropName, PN_OC_CLAIM_PERIOD) != 0) { - LOG_INFO_STR ("Changing ClaimPeriod from " << itsClaimPeriod << - " to " << newVal); - itsClaimPeriod = newVal; - } - else if (strstr(pPropAnswer->pPropName, PN_OC_PREPARE_PERIOD) != 0) { - LOG_INFO_STR ("Changing PreparePeriod from " << itsPreparePeriod << - " to " << newVal); - itsPreparePeriod = newVal; - } - } - // times are of type string - else if (pPropAnswer->pValue->getType() == LPT_STRING) { - string newVal = (string) ((GCFPVString*)pPropAnswer->pValue)->getValue(); - ptime newTime; - try { - newTime = time_from_string(newVal); - } - catch (exception& e) { - LOG_DEBUG_STR(newVal << " is not a legal time!!!"); - return; - } - if (strstr(pPropAnswer->pPropName, PN_OC_START_TIME) != 0) { - LOG_INFO_STR ("Changing startTime from " << to_simple_string(itsStartTime) - << " to " << newVal); - itsStartTime = newTime; - } - else if (strstr(pPropAnswer->pPropName, PN_OC_STOP_TIME) != 0) { - LOG_INFO_STR ("Changing stopTime from " << to_simple_string(itsStopTime) - << " to " << newVal); - itsStopTime = newTime; - } - } - setObservationTimers(); - LOG_DEBUG("Sending all childs a RESCHEDULE event"); - itsChildControl->rescheduleChilds(to_time_t(itsStartTime), - to_time_t(itsStopTime), ""); - break; - } - -// case F_SUBSCRIBED: GCFPropAnswerEvent pPropName -// case F_UNSUBSCRIBED: GCFPropAnswerEvent pPropName -// case F_PS_CONFIGURED: GCFConfAnswerEvent pApcName -// case F_EXTPS_LOADED: GCFPropSetAnswerEvent pScope, result -// case F_EXTPS_UNLOADED: GCFPropSetAnswerEvent pScope, result -// case F_MYPS_ENABLED: GCFPropSetAnswerEvent pScope, result -// case F_MYPS_DISABLED: GCFPropSetAnswerEvent pScope, result -// case F_VGETRESP: GCFPropValueEvent pValue, pPropName -// case F_VSETRESP: GCFPropAnswerEvent pPropName -// case F_VCHANGEMSG: GCFPropValueEvent pValue, pPropName -// case F_SERVER_GONE: GCFPropSetAnswerEvent pScope, result - - default: - break; - } -} - - // // initial_state(event, port) // @@ -309,15 +189,23 @@ GCFEvent::TResult ObservationControl::initial_state(GCFEvent& event, // Create 'Observationxxx' datapoint as top of the observation tree string propSetName(createPropertySetName(PSN_OBSERVATION, getName())); LOG_DEBUG_STR ("Activating PropertySet: " << propSetName); - itsBootPS = GCFMyPropertySetPtr(new GCFMyPropertySet(propSetName.c_str(), - PST_OBSERVATION, - PS_CAT_TEMP_AUTOLOAD, - &itsPropertySetAnswer)); - itsBootPS->enable(); - // Wait for timer that is set in PropertySetAnswer on ENABLED event + itsBootPS = new RTDBPropertySet(propSetName.c_str(), + PST_OBSERVATION, + PSAT_RW, + this); } break; + case DP_CREATED: { + // NOTE: thsi function may be called DURING the construction of the PropertySet. + // Always exit this event in a way that GCF can end the construction. + DPCreatedEvent dpEvent(event); + LOG_DEBUG_STR("Result of creating " << dpEvent.DPname << " = " << dpEvent.result); + itsTimerPort->cancelAllTimers(); + itsTimerPort->setTimer(0.0); + } + break; + case F_TIMER: { // must be timer that PropSet has set. // update PVSS. LOG_TRACE_FLOW ("top DP of observation created, going to starting state"); @@ -360,15 +248,23 @@ GCFEvent::TResult ObservationControl::starting_state(GCFEvent& event, // Get access to my own propertyset. string propSetName(createPropertySetName(PSN_OBS_CTRL, getName())); LOG_DEBUG_STR ("Activating PropertySet: " << propSetName); - itsPropertySet = GCFMyPropertySetPtr(new GCFMyPropertySet(propSetName.c_str(), - PST_OBS_CTRL, - PS_CAT_TEMP_AUTOLOAD, - &itsPropertySetAnswer)); - itsPropertySet->enable(); - // Wait for timer that is set in PropertySetAnswer on ENABLED event + itsPropertySet = new RTDBPropertySet(propSetName.c_str(), + PST_OBS_CTRL, + PSAT_RW, + this); } break; + case DP_CREATED: { + // NOTE: thsi function may be called DURING the construction of the PropertySet. + // Always exit this event in a way that GCF can end the construction. + DPCreatedEvent dpEvent(event); + LOG_DEBUG_STR("Result of creating " << dpEvent.DPname << " = " << dpEvent.result); + itsTimerPort->cancelAllTimers(); + itsTimerPort->setTimer(0.0); + } + break; + case F_TIMER: { // can be timer that PropSet has set or timer from // wait period for Child and Parent Control. if (thisObservationControl == this) { // task timer @@ -387,7 +283,7 @@ GCFEvent::TResult ObservationControl::starting_state(GCFEvent& event, // update PVSS. LOG_TRACE_FLOW ("Updateing state to PVSS"); - itsPropertySet->setValue(PVSSNAME_FSM_CURACT, GCFPVString("initial")); + itsPropertySet->setValue(PVSSNAME_FSM_CURACT, GCFPVString("Initial")); itsPropertySet->setValue(PVSSNAME_FSM_ERROR, GCFPVString("")); itsPropertySet->setValue(PN_OC_CLAIM_PERIOD, GCFPVInteger(itsClaimPeriod)); itsPropertySet->setValue(PN_OC_PREPARE_PERIOD,GCFPVInteger(itsPreparePeriod)); @@ -445,6 +341,10 @@ GCFEvent::TResult ObservationControl::starting_state(GCFEvent& event, case F_DISCONNECTED: break; + case DP_CHANGED: + _databaseEventHandler(event); + break; + default: LOG_DEBUG_STR ("starting, default"); status = GCFEvent::NOT_HANDLED; @@ -489,6 +389,10 @@ GCFEvent::TResult ObservationControl::active_state(GCFEvent& event, GCFPortInter _disconnectedHandler(port); break; + case DP_CHANGED: + _databaseEventHandler(event); + break; + case F_TIMER: { GCFTimerEvent& timerEvent=static_cast<GCFTimerEvent&>(event); if (timerEvent.id == itsHeartBeatTimer) { @@ -666,7 +570,7 @@ GCFEvent::TResult ObservationControl::finishing_state(GCFEvent& event, itsParentPort->send(msg); // update PVSS - itsPropertySet->setValue(string(PVSSNAME_FSM_CURACT),GCFPVString("finished")); + itsPropertySet->setValue(string(PVSSNAME_FSM_CURACT),GCFPVString("Finished")); itsPropertySet->setValue(string(PVSSNAME_FSM_ERROR),GCFPVString("")); itsTimerPort->setTimer(1L); // give PVSS task some time to update the DB. @@ -858,6 +762,72 @@ void ObservationControl::_disconnectedHandler(GCFPortInterface& port) port.close(); } +// +// _databaseEventHandler(answer) +// +void ObservationControl::_databaseEventHandler(GCFEvent& event) +{ + LOG_TRACE_FLOW_STR ("_databaseEventHandler:" << eventName(event)); + + switch(event.signal) { + case DP_CHANGED: { + DPChangedEvent dpEvent(event); + + // don't watch state and error fields. + if ((strstr(dpEvent.DPname.c_str(), PVSSNAME_FSM_STATE) != 0) || + (strstr(dpEvent.DPname.c_str(), PVSSNAME_FSM_ERROR) != 0) || + (strstr(dpEvent.DPname.c_str(), PVSSNAME_FSM_CURACT) != 0) || + (strstr(dpEvent.DPname.c_str(), PVSSNAME_FSM_LOGMSG) != 0)) { + return; + } + + // Change of claim_period? + if (strstr(dpEvent.DPname.c_str(), PN_OC_CLAIM_PERIOD) != 0) { + uint32 newVal = ((GCFPVInteger*) (dpEvent.value._pValue))->getValue(); + LOG_INFO_STR ("Changing ClaimPeriod from " << itsClaimPeriod << " to " << newVal); + itsClaimPeriod = newVal; + } + // Change of prepare_period? + else if (strstr(dpEvent.DPname.c_str(), PN_OC_PREPARE_PERIOD) != 0) { + uint32 newVal = ((GCFPVInteger*) (dpEvent.value._pValue))->getValue(); + LOG_INFO_STR ("Changing PreparePeriod from " << itsPreparePeriod << " to " << newVal); + itsPreparePeriod = newVal; + } + + // Change of start or stop time? + if ((strstr(dpEvent.DPname.c_str(), PN_OC_START_TIME) != 0) || + (strstr(dpEvent.DPname.c_str(), PN_OC_STOP_TIME) != 0)) { + string newVal = ((GCFPVString*) (dpEvent.value._pValue))->getValue(); + ptime newTime; + try { + newTime = time_from_string(newVal); + } + catch (exception& e) { + LOG_DEBUG_STR(newVal << " is not a legal time!!!"); + return; + } + if (strstr(dpEvent.DPname.c_str(), PN_OC_START_TIME) != 0) { + LOG_INFO_STR ("Changing startTime from " << to_simple_string(itsStartTime) << " to " << newVal); + itsStartTime = newTime; + } + else { + LOG_INFO_STR ("Changing stopTime from " << to_simple_string(itsStopTime) << " to " << newVal); + itsStopTime = newTime; + } + setObservationTimers(); + LOG_DEBUG("Sending all childs a RESCHEDULE event"); + itsChildControl->rescheduleChilds(to_time_t(itsStartTime), + to_time_t(itsStopTime), ""); + } + } + break; + + default: + break; + } +} + + }; }; diff --git a/MAC/APL/MainCU/src/ObservationControl/ObservationControl.h b/MAC/APL/MainCU/src/ObservationControl/ObservationControl.h index f74c6659fa315cb9dc8d4f9d8719712a04807162..ed627f868c719c8038b97a2c523edaccadbd1b23 100644 --- a/MAC/APL/MainCU/src/ObservationControl/ObservationControl.h +++ b/MAC/APL/MainCU/src/ObservationControl/ObservationControl.h @@ -23,11 +23,8 @@ #ifndef ObservationControl_H #define ObservationControl_H -//# Includes -#include <boost/shared_ptr.hpp> - //# GCF Includes -#include <GCF/PAL/GCF_MyPropertySet.h> +#include <GCF/RTDB/RTDB_PropertySet.h> #include <GCF/TM/GCF_Port.h> #include <GCF/TM/GCF_ITCPort.h> #include <GCF/TM/GCF_TimerPort.h> @@ -35,9 +32,6 @@ #include <GCF/TM/GCF_Event.h> //# local includes -#include <APL/APLCommon/PropertySetAnswerHandlerInterface.h> -#include <APL/APLCommon/PropertySetAnswer.h> -#include <APL/APLCommon/APLCommonExceptions.h> #include <APL/APLCommon/Controller_Protocol.ph> #include <APL/APLCommon/APL_Defines.h> #include <APL/APLCommon/ChildControl.h> @@ -64,20 +58,17 @@ using GCF::TM::GCFPort; using GCF::TM::GCFEvent; using GCF::TM::GCFPortInterface; using GCF::TM::GCFTask; +using GCF::RTDB::RTDBPropertySet; using APLCommon::ChildControl; using APLCommon::ParentControl; using APLCommon::CTState; -class ObservationControl : public GCFTask, - APLCommon::PropertySetAnswerHandlerInterface +class ObservationControl : public GCFTask { public: explicit ObservationControl(const string& cntlrName); ~ObservationControl(); - // PropertySetAnswerHandlerInterface method - virtual void handlePropertySetAnswer(GCFEvent& answer); - // During this state the top DP LOFAR_ObsSW_<observation> is created GCFEvent::TResult initial_state (GCFEvent& e, GCFPortInterface& p); @@ -111,13 +102,10 @@ private: void _connectedHandler(GCFPortInterface& port); void _disconnectedHandler(GCFPortInterface& port); + void _databaseEventHandler(GCFEvent& answer); - typedef boost::shared_ptr<GCF::PAL::GCFMyPropertySet> GCFMyPropertySetPtr; -// typedef GCF::PAL::GCFMyPropertySet* GCFMyPropertySetPtr; - - APLCommon::PropertySetAnswer itsPropertySetAnswer; - GCFMyPropertySetPtr itsPropertySet; - GCFMyPropertySetPtr itsBootPS; + RTDBPropertySet* itsPropertySet; + RTDBPropertySet* itsBootPS; // pointer to child control task ChildControl* itsChildControl; diff --git a/MAC/APL/StationCU/configure.in b/MAC/APL/StationCU/configure.in index 076bf57f4feb0010f4d4c86481e75a9ef6273a66..004aa4762398ae23dc617dd6e960f76c357ea38b 100644 --- a/MAC/APL/StationCU/configure.in +++ b/MAC/APL/StationCU/configure.in @@ -61,14 +61,13 @@ lofar_INTERNAL(LCS/ACC/APS, aps,, 1, APS/ParameterSet.h,,) dnl lofar_INTERNAL(SAS/OTDB, otdb,, 1, OTDB/OTDBconnection.h,,) lofar_INTERNAL(MAC/GCF/GCFCommon, gcfcommon,, 1, GCF/GCF_Defines.h,,) lofar_INTERNAL(MAC/GCF/TM, gcftm,, 1, GCF/TM/GCF_Task.h,,) -lofar_INTERNAL(MAC/GCF/PAL, gcfpal,, 1, GCF/PAL/GCF_PVSSInfo.h,,) -lofar_INTERNAL(MAC/GCF/PAL, gcfpvss,, 1, GCF/PVSS/PVSSservice.h,,) -lofar_INTERNAL(MAC/GCF/PAL, rtdb,, 1, GCF/RTDB/RTDB_PropertySet.h,,) +lofar_INTERNAL(MAC/GCF/PVSS, gcfpvss,, 1, GCF/PVSS/PVSSservice.h,,) +lofar_INTERNAL(MAC/GCF/RTDB, rtdb,, 1, GCF/RTDB/RTDB_PropertySet.h,,) lofar_INTERNAL(MAC/APL/APLCommon, aplcommon,, 1, APL/APLCommon/APL_Defines.h,,) lofar_INTERNAL(MAC/APL/PAC/BS_Protocol, BS_Protocol,, 1, APL/BS_Protocol/BS_Protocol.ph,,) lofar_INTERNAL(MAC/APL/PAC/CAL_Protocol, CAL_Protocol,, 1, APL/CAL_Protocol/CAL_Protocol.ph,,) lofar_INTERNAL(MAC/APL/PIC/RSP_Protocol, RSP_Protocol,, 1, APL/RSP_Protocol/RSP_Protocol.ph,,) -lofar_EXTERNAL(boost,1,boost/date_time/date.hpp, boost_date_time) +lofar_EXTERNAL(boost,1.32,boost/date_time/date.hpp, boost_date_time-gcc) dnl lofar_EXTERNAL(pqxx,2.5.5,pqxx/pqxx, pqxx) dnl lofar_EXTERNAL(pq,,libpq-fe.h, pq, /usr/local/pgsql) diff --git a/MAC/APL/StationCU/src/BeamControl/BeamControl.cc b/MAC/APL/StationCU/src/BeamControl/BeamControl.cc index f7b385567fc5a052e0f8977a3938ff01fadff838..d11bfe1c6512b2453cb4da5f33432f74faa42e23 100644 --- a/MAC/APL/StationCU/src/BeamControl/BeamControl.cc +++ b/MAC/APL/StationCU/src/BeamControl/BeamControl.cc @@ -22,20 +22,17 @@ #include <lofar_config.h> #include <Common/LofarLogger.h> -#include <boost/shared_array.hpp> #include <APS/ParameterSet.h> #include <GCF/GCF_PVTypes.h> -#include <GCF/PAL/GCF_PVSSInfo.h> #include <GCF/Utils.h> #include <GCF/GCF_ServiceInfo.h> -#include <GCF/Protocols/PA_Protocol.ph> #include <APL/APLCommon/APL_Defines.h> #include <APL/APLCommon/APLUtilities.h> -#include <APL/APLCommon/APLCommonExceptions.h> #include <APL/APLCommon/Controller_Protocol.ph> #include <APL/APLCommon/StationInfo.h> #include <APL/APLCommon/Observation.h> #include <APL/BS_Protocol/BS_Protocol.ph> +#include <GCF/RTDB/DP_Protocol.ph> #include <signal.h> #include "BeamControl.h" @@ -43,7 +40,7 @@ using namespace LOFAR::GCF::Common; using namespace LOFAR::GCF::TM; -using namespace LOFAR::GCF::PAL; +using namespace LOFAR::GCF::RTDB; using namespace std; namespace LOFAR { @@ -59,9 +56,7 @@ static BeamControl* thisBeamControl = 0; // BeamControl::BeamControl(const string& cntlrName) : GCFTask ((State)&BeamControl::initial_state,cntlrName), - PropertySetAnswerHandlerInterface(), - itsPropertySetAnswer(*this), - itsPropertySet (), + itsPropertySet (0), itsPropertySetInitialized (false), itsParentControl (0), itsParentPort (0), @@ -97,9 +92,8 @@ BeamControl::BeamControl(const string& cntlrName) : // for debugging purposes GCF::TM::registerProtocol (CONTROLLER_PROTOCOL, CONTROLLER_PROTOCOL_STRINGS); - GCF::TM::registerProtocol (PA_PROTOCOL, PA_PROTOCOL_STRINGS); + GCF::TM::registerProtocol (DP_PROTOCOL, DP_PROTOCOL_STRINGS); GCF::TM::registerProtocol (BS_PROTOCOL, BS_PROTOCOL_STRINGS); - GCF::TM::registerProtocol (F_PML_PROTOCOL, F_PML_PROTOCOL_STRINGS); setState(CTState::CREATED); } @@ -160,65 +154,6 @@ int32 BeamControl::convertDirection(const string& typeName) return (2); } -// -// handlePropertySetAnswer(answer) -// -void BeamControl::handlePropertySetAnswer(GCFEvent& answer) -{ - LOG_DEBUG_STR ("handlePropertySetAnswer:" << eventName(answer)); - - switch(answer.signal) { - case F_MYPS_ENABLED: { - GCFPropSetAnswerEvent* pPropAnswer=static_cast<GCFPropSetAnswerEvent*>(&answer); - if(pPropAnswer->result != GCF_NO_ERROR) { - LOG_ERROR(formatString("%s : PropertySet %s NOT ENABLED", - getName().c_str(), pPropAnswer->pScope)); - } - // always let timer expire so main task will continue. - itsTimerPort->setTimer(1.0); - break; - } - - case F_PS_CONFIGURED: { - GCFConfAnswerEvent* pConfAnswer=static_cast<GCFConfAnswerEvent*>(&answer); - if(pConfAnswer->result == GCF_NO_ERROR) { - LOG_DEBUG(formatString("%s : apc %s Loaded", - getName().c_str(), pConfAnswer->pApcName)); - //apcLoaded(); - } - else { - LOG_ERROR(formatString("%s : apc %s NOT LOADED", - getName().c_str(), pConfAnswer->pApcName)); - } - break; - } - - case F_VGETRESP: - case F_VCHANGEMSG: { - // check which property changed - // GCFPropValueEvent* pPropAnswer=static_cast<GCFPropValueEvent*>(&answer); - - // TODO: implement something usefull. - break; - } - -// case F_SUBSCRIBED: -// case F_UNSUBSCRIBED: -// case F_PS_CONFIGURED: -// case F_EXTPS_LOADED: -// case F_EXTPS_UNLOADED: -// case F_MYPS_ENABLED: -// case F_MYPS_DISABLED: -// case F_VGETRESP: -// case F_VCHANGEMSG: -// case F_SERVER_GONE: - - default: - break; - } -} - - // // initial_state(event, port) // @@ -239,15 +174,24 @@ GCFEvent::TResult BeamControl::initial_state(GCFEvent& event, // Get access to my own propertyset. string propSetName(createPropertySetName(PSN_BEAM_CTRL, getName())); LOG_INFO_STR ("Activating PropertySet" << propSetName); - itsPropertySet = GCFMyPropertySetPtr(new GCFMyPropertySet(propSetName.c_str(), - PST_BEAM_CTRL, - PS_CAT_TEMP_AUTOLOAD, - &itsPropertySetAnswer)); - itsPropertySet->enable(); - // Wait for timer that is set in PropertySetAnswer on ENABLED event - } - break; + itsPropertySet = new RTDBPropertySet(propSetName, + PST_BEAM_CTRL, + PSAT_RW, + this); + // Wait for timer that is set on DP_CREATED event + } + break; + case DP_CREATED: { + // NOTE: thsi function may be called DURING the construction of the PropertySet. + // Always exit this event in a way that GCF can end the construction. + DPCreatedEvent dpEvent(event); + LOG_DEBUG_STR("Result of creating " << dpEvent.DPname << " = " << dpEvent.result); + itsTimerPort->cancelAllTimers(); + itsTimerPort->setTimer(0.0); + } + break; + case F_TIMER: if (!itsPropertySetInitialized) { itsPropertySetInitialized = true; @@ -836,6 +780,12 @@ GCFEvent::TResult BeamControl::_defaultEventHandler(GCFEvent& event, case CONTROL_QUITED: result = GCFEvent::HANDLED; break; + + case DP_CHANGED: { + LOG_DEBUG_STR("DP " << DPChangedEvent(event).DPname << " was changed"); + result = GCFEvent::HANDLED; + } + break; } if (result == GCFEvent::NOT_HANDLED) { diff --git a/MAC/APL/StationCU/src/BeamControl/BeamControl.h b/MAC/APL/StationCU/src/BeamControl/BeamControl.h index dd58f778c2a590f43e917e03d1ad293057e1b890..482fe277ca2a44a0621c1c83622e4425ac6a421a 100644 --- a/MAC/APL/StationCU/src/BeamControl/BeamControl.h +++ b/MAC/APL/StationCU/src/BeamControl/BeamControl.h @@ -23,34 +23,26 @@ #ifndef BEAMCONTROL_H #define BEAMCONTROL_H -//# Includes -#include <boost/shared_ptr.hpp> +//# Common Includes +#include <Common/LofarLogger.h> +#include <Common/lofar_string.h> +#include <Common/lofar_datetime.h> + +//# ACC Includes +#include <APS/ParameterSet.h> //# GCF Includes -#include <GCF/PAL/GCF_MyPropertySet.h> #include <GCF/TM/GCF_Port.h> #include <GCF/TM/GCF_ITCPort.h> #include <GCF/TM/GCF_TimerPort.h> #include <GCF/TM/GCF_Task.h> #include <GCF/TM/GCF_Event.h> +#include <GCF/RTDB/RTDB_PropertySet.h> //# local includes -#include <APL/APLCommon/PropertySetAnswerHandlerInterface.h> -#include <APL/APLCommon/PropertySetAnswer.h> -#include <APL/APLCommon/APLCommonExceptions.h> -#include <APL/APLCommon/Controller_Protocol.ph> #include <APL/APLCommon/ParentControl.h> #include <APL/APLCommon/CTState.h> -//# Common Includes -#include <Common/lofar_string.h> -#include <Common/lofar_vector.h> -#include <Common/lofar_datetime.h> -#include <Common/LofarLogger.h> - -//# ACC Includes -#include <APS/ParameterSet.h> - // forward declaration namespace LOFAR { @@ -62,11 +54,11 @@ using GCF::TM::GCFPort; using GCF::TM::GCFEvent; using GCF::TM::GCFPortInterface; using GCF::TM::GCFTask; +using GCF::RTDB::RTDBPropertySet; using APLCommon::ParentControl; -class BeamControl : public GCFTask, - APLCommon::PropertySetAnswerHandlerInterface +class BeamControl : public GCFTask { public: explicit BeamControl(const string& cntlrName); @@ -77,9 +69,6 @@ public: void finish(); private: - // PropertySetAnswerHandlerInterface method - void handlePropertySetAnswer(GCFEvent& answer); - // During the initial state all connections with the other programs are made. GCFEvent::TResult initial_state (GCFEvent& e, GCFPortInterface& p); // connected to PVSS, waiting for CLAIM event @@ -107,11 +96,8 @@ private: void setState (CTState::CTstateNr newState); GCFEvent::TResult _defaultEventHandler(GCFEvent& event, GCFPortInterface& port); - typedef boost::shared_ptr<GCF::PAL::GCFMyPropertySet> GCFMyPropertySetPtr; - - APLCommon::PropertySetAnswer itsPropertySetAnswer; - GCFMyPropertySetPtr itsPropertySet; - bool itsPropertySetInitialized; + RTDBPropertySet* itsPropertySet; + bool itsPropertySetInitialized; // pointer to parent control task ParentControl* itsParentControl; diff --git a/MAC/APL/StationCU/src/CalibrationControl/CalibrationControl.cc b/MAC/APL/StationCU/src/CalibrationControl/CalibrationControl.cc index 2d8c1905bfaadfd5de93d02a60039c7ac00db1d7..38e67613daf3a8efbf0ceabc9e733f3f19621725 100644 --- a/MAC/APL/StationCU/src/CalibrationControl/CalibrationControl.cc +++ b/MAC/APL/StationCU/src/CalibrationControl/CalibrationControl.cc @@ -25,11 +25,11 @@ #include <GCF/GCF_PVTypes.h> #include <GCF/GCF_ServiceInfo.h> -#include <GCF/Protocols/PA_Protocol.ph> #include <APL/APLCommon/APLUtilities.h> #include <APL/APLCommon/Controller_Protocol.ph> #include <APL/APLCommon/StationInfo.h> #include <APL/CAL_Protocol/CAL_Protocol.ph> +#include <GCF/RTDB/DP_Protocol.ph> #include <signal.h> #include "CalibrationControl.h" @@ -37,7 +37,7 @@ using namespace LOFAR::GCF::Common; using namespace LOFAR::GCF::TM; -using namespace LOFAR::GCF::PAL; +using namespace LOFAR::GCF::RTDB; namespace LOFAR { using namespace APLCommon; @@ -52,9 +52,7 @@ static CalibrationControl* thisCalibrationControl = 0; // CalibrationControl::CalibrationControl(const string& cntlrName) : GCFTask ((State)&CalibrationControl::initial_state,cntlrName), - PropertySetAnswerHandlerInterface(), - itsPropertySetAnswer(*this), - itsPropertySet (), + itsPropertySet (0), itsPropertySetInitialized (false), itsParentControl (0), itsParentPort (0), @@ -90,9 +88,8 @@ CalibrationControl::CalibrationControl(const string& cntlrName) : // for debugging purposes GCF::TM::registerProtocol (CONTROLLER_PROTOCOL, CONTROLLER_PROTOCOL_STRINGS); - GCF::TM::registerProtocol (PA_PROTOCOL, PA_PROTOCOL_STRINGS); + GCF::TM::registerProtocol (DP_PROTOCOL, DP_PROTOCOL_STRINGS); GCF::TM::registerProtocol (CAL_PROTOCOL, CAL_PROTOCOL_STRINGS); - GCF::TM::registerProtocol (F_PML_PROTOCOL, F_PML_PROTOCOL_STRINGS); setState(CTState::CREATED); } @@ -150,7 +147,7 @@ int32 CalibrationControl::convertFilterSelection(const string& filterselection) if (filterselection == "LBL_30_80") { return(2); } if (filterselection == "LBH_10_80") { return(3); } if (filterselection == "LBH_30_80") { return(4); } - if (filterselection == "HB_110_190") { return(5); } + if (filterselection == "HB_100_190") { return(5); } if (filterselection == "HB_170_230") { return(6); } if (filterselection == "HB_210_240") { return(7); } @@ -164,50 +161,6 @@ int32 CalibrationControl::convertFilterSelection(const string& filterselection) return (1); } -// -// handlePropertySetAnswer(answer) -// -void CalibrationControl::handlePropertySetAnswer(GCFEvent& answer) -{ - LOG_DEBUG_STR ("handlePropertySetAnswer:" << eventName(answer)); - - switch(answer.signal) { - case F_MYPS_ENABLED: { - GCFPropSetAnswerEvent* pPropAnswer=static_cast<GCFPropSetAnswerEvent*>(&answer); - if (pPropAnswer->result != GCF_NO_ERROR) { - LOG_ERROR(formatString("%s : PropertySet %s NOT ENABLED", - getName().c_str(), pPropAnswer->pScope)); - } - // always let timer expire so main task will continue. - itsTimerPort->setTimer(0.5); - break; - } - - case F_VGETRESP: - case F_VCHANGEMSG: - // check which property changed - // GCFPropValueEvent* pPropAnswer=static_cast<GCFPropValueEvent*>(&answer); - // TODO: implement something usefull. - break; - -// case F_SUBSCRIBED: GCFPropAnswerEvent pPropName -// case F_UNSUBSCRIBED: GCFPropAnswerEvent pPropName -// case F_PS_CONFIGURED: GCFConfAnswerEvent pApcName -// case F_EXTPS_LOADED: GCFPropSetAnswerEvent pScope, result -// case F_EXTPS_UNLOADED: GCFPropSetAnswerEvent pScope, result -// case F_MYPS_ENABLED: GCFPropSetAnswerEvent pScope, result -// case F_MYPS_DISABLED: GCFPropSetAnswerEvent pScope, result -// case F_VGETRESP: GCFPropValueEvent pValue, pPropName -// case F_VSETRESP: GCFPropAnswerEvent pPropName -// case F_VCHANGEMSG: GCFPropValueEvent pValue, pPropName -// case F_SERVER_GONE: GCFPropSetAnswerEvent pScope, result - - default: - break; - } -} - - // // initial_state(event, port) // @@ -228,15 +181,24 @@ GCFEvent::TResult CalibrationControl::initial_state(GCFEvent& event, // Get access to my own propertyset. string propSetName(createPropertySetName(PSN_CAL_CTRL, getName())); LOG_INFO_STR ("Activating PropertySet" << propSetName); - itsPropertySet = GCFMyPropertySetPtr(new GCFMyPropertySet(propSetName.c_str(), - PST_CAL_CTRL, - PS_CAT_TEMP_AUTOLOAD, - &itsPropertySetAnswer)); - itsPropertySet->enable(); - // Wait for timer that is set in PropertySetAnswer on ENABLED event - } - break; + itsPropertySet = new RTDBPropertySet(propSetName, + PST_CAL_CTRL, + PSAT_RW_TMP, + this); + // Wait for timer that is set on DP_CREATED event + } + break; + case DP_CREATED: { + // NOTE: thsi function may be called DURING the construction of the PropertySet. + // Always exit this event in a way that GCF can end the construction. + DPCreatedEvent dpEvent(event); + LOG_DEBUG_STR("Result of creating " << dpEvent.DPname << " = " << dpEvent.result); + itsTimerPort->cancelAllTimers(); + itsTimerPort->setTimer(0.0); + } + break; + case F_TIMER: if (!itsPropertySetInitialized) { itsPropertySetInitialized = true; @@ -631,9 +593,9 @@ bool CalibrationControl::startCalibration() calStartEvent.rcumode()(0).setMode((RSP_Protocol::RCUSettings::Control::RCUMode) convertFilterSelection(itsObsPar.filter)); // calStartEvent.nyquist_zone = itsObsPar.nyquistZone; - calStartEvent.rcumode()(0).setSpecinv(calStartEvent.rcumode()(0).getNyquistZone() == 2); +// calStartEvent.rcumode()(0).setSpecinv(calStartEvent.rcumode()(0).getNyquistZone() == 2); calStartEvent.subset = itsObsPar.RCUset; - LOG_DEBUG(formatString("Sending CALSTART(%s,%s,08X)", + LOG_DEBUG(formatString("Sending CALSTART(%s,%s,%08X)", obsName.c_str(), calStartEvent.parent.c_str(), calStartEvent.rcumode()(0).getRaw())); @@ -705,6 +667,12 @@ GCFEvent::TResult CalibrationControl::_defaultEventHandler(GCFEvent& event, case CONTROL_QUITED: result = GCFEvent::HANDLED; break; + + case DP_CHANGED: + case DP_SET: + result = GCFEvent::HANDLED; + break; + } if (result == GCFEvent::NOT_HANDLED) { diff --git a/MAC/APL/StationCU/src/CalibrationControl/CalibrationControl.h b/MAC/APL/StationCU/src/CalibrationControl/CalibrationControl.h index cc1b5ec997cc9794e05d5fd4cdfe17af6bad1bfe..b48bd97896405c18638ba7b900aa7c55b73c1381 100644 --- a/MAC/APL/StationCU/src/CalibrationControl/CalibrationControl.h +++ b/MAC/APL/StationCU/src/CalibrationControl/CalibrationControl.h @@ -23,31 +23,19 @@ #ifndef CALIBRATIONCONTROL_H #define CALIBRATIONCONTROL_H -//# Includes -#include <boost/shared_ptr.hpp> - //# GCF Includes -#include <GCF/PAL/GCF_MyPropertySet.h> -//#include <GCF/PAL/GCF_ExtPropertySet.h> #include <GCF/TM/GCF_Port.h> #include <GCF/TM/GCF_ITCPort.h> #include <GCF/TM/GCF_TimerPort.h> +#include <GCF/RTDB/RTDB_PropertySet.h> //# local includes -#include <APL/APLCommon/PropertySetAnswerHandlerInterface.h> -#include <APL/APLCommon/PropertySetAnswer.h> -//#include <APL/APLCommon/APLCommonExceptions.h> -//#include <APL/APLCommon/Controller_Protocol.ph> #include <APL/APLCommon/ParentControl.h> #include <APL/APLCommon/Observation.h> #include <APL/APLCommon/CTState.h> //# Common Includes #include <Common/lofar_string.h> -//#include <bitset> - -//# ACC Includes -//#include <APS/ParameterSet.h> // forward declaration @@ -59,11 +47,11 @@ using GCF::TM::GCFITCPort; using GCF::TM::GCFPort; using GCF::TM::GCFEvent; using GCF::TM::GCFPortInterface; +using GCF::RTDB::RTDBPropertySet; using APLCommon::ParentControl; -class CalibrationControl : public GCFTask, - APLCommon::PropertySetAnswerHandlerInterface +class CalibrationControl : public GCFTask { public: explicit CalibrationControl(const string& cntlrName); @@ -74,9 +62,6 @@ public: void finish(); private: - // PropertySetAnswerHandlerInterface method - virtual void handlePropertySetAnswer(GCFEvent& answer); - // During the initial state all connections with the other programs are made. GCFEvent::TResult initial_state (GCFEvent& e, GCFPortInterface& p); GCFEvent::TResult started_state (GCFEvent& e, GCFPortInterface& p); @@ -93,6 +78,7 @@ private: void _connectedHandler(GCFPortInterface& port); void _disconnectedHandler(GCFPortInterface& port); + GCFEvent::TResult _defaultEventHandler(GCFEvent& event, GCFPortInterface& port); void setState (CTState::CTstateNr newState); @@ -102,11 +88,8 @@ private: bool startCalibration (); bool stopCalibration (); - typedef boost::shared_ptr<GCF::PAL::GCFMyPropertySet> GCFMyPropertySetPtr; - - APLCommon::PropertySetAnswer itsPropertySetAnswer; - GCFMyPropertySetPtr itsPropertySet; - bool itsPropertySetInitialized; + RTDBPropertySet* itsPropertySet; + bool itsPropertySetInitialized; //# --- Datamembers --- ParentControl* itsParentControl; // pointer to parent control task diff --git a/MAC/APL/StationCU/src/DigitalBoardControl/DigitalBoardControl.cc b/MAC/APL/StationCU/src/DigitalBoardControl/DigitalBoardControl.cc index 9d3ce0cddcae0ee533e5aff7a8cc3aec52677f0a..b32fc21fb42a7e4cb4100cee2e712891e5cfa8ad 100644 --- a/MAC/APL/StationCU/src/DigitalBoardControl/DigitalBoardControl.cc +++ b/MAC/APL/StationCU/src/DigitalBoardControl/DigitalBoardControl.cc @@ -22,19 +22,15 @@ #include <lofar_config.h> #include <Common/LofarLogger.h> -#include <boost/shared_array.hpp> #include <APS/ParameterSet.h> -#include <GCF/GCF_PVTypes.h> -#include <GCF/PAL/GCF_PVSSInfo.h> -#include <GCF/PAL/GCF_Answer.h> #include <GCF/Utils.h> #include <GCF/GCF_ServiceInfo.h> -#include <GCF/Protocols/PA_Protocol.ph> +#include <GCF/GCF_PVTypes.h> #include <APL/APLCommon/APL_Defines.h> -#include <APL/APLCommon/APLCommonExceptions.h> #include <APL/APLCommon/Controller_Protocol.ph> -#include <APL/RSP_Protocol/RSP_Protocol.ph> #include <APL/APLCommon/StationInfo.h> +#include <APL/RSP_Protocol/RSP_Protocol.ph> +#include <GCF/RTDB/DP_Protocol.ph> #include <signal.h> #include "DigitalBoardControl.h" @@ -42,7 +38,7 @@ using namespace LOFAR::GCF::Common; using namespace LOFAR::GCF::TM; -using namespace LOFAR::GCF::PAL; +using namespace LOFAR::GCF::RTDB; using namespace std; namespace LOFAR { @@ -58,10 +54,8 @@ static DigitalBoardControl* thisDigitalBoardControl = 0; // DigitalBoardControl::DigitalBoardControl(const string& cntlrName) : GCFTask ((State)&DigitalBoardControl::initial_state,cntlrName), - PropertySetAnswerHandlerInterface(), - itsPropertySetAnswer(*this), - itsOwnPropertySet (), - itsExtPropertySet (), + itsOwnPropertySet (0), + itsExtPropertySet (0), itsOwnPSinitialized (false), itsExtPSinitialized (false), itsParentPort (0), @@ -97,9 +91,8 @@ itsClock = globalParameterSet()->getUint32(itsTreePrefix + "sampleClock"); // for debugging purposes GCF::TM::registerProtocol (CONTROLLER_PROTOCOL, CONTROLLER_PROTOCOL_STRINGS); - GCF::TM::registerProtocol (PA_PROTOCOL, PA_PROTOCOL_STRINGS); + GCF::TM::registerProtocol (DP_PROTOCOL, DP_PROTOCOL_STRINGS); GCF::TM::registerProtocol (RSP_PROTOCOL, RSP_PROTOCOL_STRINGS); - GCF::TM::registerProtocol (F_PML_PROTOCOL, F_PML_PROTOCOL_STRINGS); } @@ -142,90 +135,41 @@ void DigitalBoardControl::finish() // -// handlePropertySetAnswer(answer) +// _databaseEventHandler(event) // -void DigitalBoardControl::handlePropertySetAnswer(GCFEvent& answer) +void DigitalBoardControl::_databaseEventHandler(GCFEvent& event) { - LOG_TRACE_FLOW_STR ("handlePropertySetAnswer:" << eventName(answer)); - - switch(answer.signal) { - case F_MYPS_ENABLED: - case F_EXTPS_LOADED: { - GCFPropSetAnswerEvent* pPropAnswer=static_cast<GCFPropSetAnswerEvent*>(&answer); - if(pPropAnswer->result != GCF_NO_ERROR) { - LOG_ERROR(formatString("%s : PropertySet %s NOT ENABLED", - getName().c_str(), pPropAnswer->pScope)); - } - else { - LOG_DEBUG_STR("Property set " << pPropAnswer->pScope << - " enabled, continuing main task"); - } - // always let timer expire so main task will continue. - itsTimerPort->setTimer(0.5); - break; - } - - case F_VGETRESP: { // initial get of required clock - GCFPropValueEvent* pPropAnswer=static_cast<GCFPropValueEvent*>(&answer); - if (strstr(pPropAnswer->pPropName, PN_SC_CLOCK) != 0) { - itsClock =(static_cast<const GCFPVInteger*>(pPropAnswer->pValue))->getValue(); - - // signal main task we have the value. - LOG_DEBUG_STR("Clock in PVSS has value: " << itsClock); - itsTimerPort->setTimer(0.5); - break; - } - LOG_WARN_STR("Got VGETRESP signal from unknown property " << - pPropAnswer->pPropName); - } + LOG_DEBUG_STR ("_databaseEventHandler:" << eventName(event)); + + switch(event.signal) { - case F_VCHANGEMSG: { - // check which property changed - GCFPropValueEvent* pPropAnswer=static_cast<GCFPropValueEvent*>(&answer); + case DP_CHANGED: { + DPChangedEvent dpEvent(event); + LOG_DEBUG_STR("_databaseEventHandler:DP_CHANGED(" << dpEvent.DPname << ")"); // don't watch state and error fields. - if ((strstr(pPropAnswer->pPropName, PVSSNAME_FSM_STATE) != 0) || - (strstr(pPropAnswer->pPropName, PVSSNAME_FSM_ERROR) != 0) || - (strstr(pPropAnswer->pPropName, PVSSNAME_FSM_CURACT) != 0) || - (strstr(pPropAnswer->pPropName, PVSSNAME_FSM_LOGMSG) != 0)) { + if ((strstr(dpEvent.DPname.c_str(), PVSSNAME_FSM_STATE) != 0) || + (strstr(dpEvent.DPname.c_str(), PVSSNAME_FSM_ERROR) != 0) || + (strstr(dpEvent.DPname.c_str(), PVSSNAME_FSM_CURACT) != 0) || + (strstr(dpEvent.DPname.c_str(), PVSSNAME_FSM_LOGMSG) != 0)) { return; } - if (strstr(pPropAnswer->pPropName, PN_SC_CLOCK) != 0) { - int newClock = (static_cast<const GCFPVInteger*>(pPropAnswer->pValue))->getValue(); + if (strstr(dpEvent.DPname.c_str(), PN_SC_CLOCK) != 0) { + GCFPVInteger* clockObj = (GCFPVInteger*)dpEvent.value._pValue; + int32 newClock = clockObj->getValue(); if (newClock != itsClock) { itsClock = newClock; LOG_DEBUG_STR("Received clock change from PVSS, clock is now " << itsClock); - sendClockSetting(); + TRAN(DigitalBoardControl::setClock_state); + // sendClockSetting(); } break; } LOG_WARN_STR("Got VCHANGEMSG signal from unknown property " << - pPropAnswer->pPropName); + dpEvent.DPname); } - case F_SUBSCRIBED: { - GCFPropAnswerEvent* pPropAnswer=static_cast<GCFPropAnswerEvent*>(&answer); - LOG_DEBUG_STR("Got SUBSCRIBE signal from property " << pPropAnswer->pPropName); - if (strstr(pPropAnswer->pPropName, PN_SC_CLOCK) != 0) { - // signal main task we have a subscription - itsTimerPort->setTimer(0.5); - } - break; - } - -// case F_SUBSCRIBED: GCFPropAnswerEvent pPropName -// case F_UNSUBSCRIBED: GCFPropAnswerEvent pPropName -// case F_PS_CONFIGURED: GCFConfAnswerEvent pApcName -// case F_EXTPS_LOADED: GCFPropSetAnswerEvent pScope, result -// case F_EXTPS_UNLOADED: GCFPropSetAnswerEvent pScope, result -// case F_MYPS_ENABLED: GCFPropSetAnswerEvent pScope, result -// case F_MYPS_DISABLED: GCFPropSetAnswerEvent pScope, result -// case F_VGETRESP: GCFPropValueEvent pValue, pPropName -// case F_VSETRESP: GCFPropAnswerEvent pPropName -// case F_VCHANGEMSG: GCFPropValueEvent pValue, pPropName -// case F_SERVER_GONE: GCFPropSetAnswerEvent pScope, result - default: break; } @@ -251,23 +195,26 @@ GCFEvent::TResult DigitalBoardControl::initial_state(GCFEvent& event, case F_ENTRY: { // Get access to my own propertyset. string myPropSetName(createPropertySetName(PSN_DIG_BOARD_CTRL, getName())); -myPropSetName=myPropSetName.substr(8); LOG_DEBUG_STR ("Activating PropertySet " << myPropSetName); - itsOwnPropertySet = GCFMyPropertySetPtr( - new GCFMyPropertySet(myPropSetName.c_str(), - PST_DIG_BOARD_CTRL, - PS_CAT_PERM_AUTOLOAD, - &itsPropertySetAnswer)); - itsOwnPropertySet->enable(); // will result in F_MYPS_ENABLED - - // When myPropSet is enabled we will connect to the external PropertySet - // that dictates the systemClock setting. - - // Wait for timer that is set in PropertySetAnswer on ENABLED event - } - break; - - case F_TIMER: + itsOwnPropertySet = new RTDBPropertySet(myPropSetName, + PST_DIG_BOARD_CTRL, + PSAT_RW, + this); + // Wait for timer that is set on DP_CREATED event + } + break; + + case DP_CREATED: { + // NOTE: thsi function may be called DURING the construction of the PropertySet. + // Always exit this event in a way that GCF can end the construction. + DPCreatedEvent dpEvent(event); + LOG_DEBUG_STR("Result of creating " << dpEvent.DPname << " = " << dpEvent.result); + itsTimerPort->cancelAllTimers(); + itsTimerPort->setTimer(0.0); + } + break; + + case F_TIMER: { // first timer event is from own propertyset if (!itsOwnPSinitialized) { itsOwnPSinitialized = true; @@ -280,19 +227,18 @@ myPropSetName=myPropSetName.substr(8); // update PVSS. LOG_TRACE_FLOW ("Updateing state to PVSS"); - itsOwnPropertySet->setValue(PVSSNAME_FSM_CURACT,GCFPVString("initial")); - itsOwnPropertySet->setValue(PVSSNAME_FSM_ERROR,GCFPVString("")); - itsOwnPropertySet->setValue(PN_DBC_CONNECTED, GCFPVBool(false)); + itsOwnPropertySet->setValue(PVSSNAME_FSM_CURACT,GCFPVString("Initial")); + itsOwnPropertySet->setValue(PVSSNAME_FSM_ERROR, GCFPVString("")); + itsOwnPropertySet->setValue(PN_DBC_CONNECTED, GCFPVBool(false)); // Now connect to propertyset that dictates the clocksetting string extPropSetName(createPropertySetName(PSN_STATION_CLOCK, getName())); //extPropSetName= extPropSetName.substr(8); LOG_DEBUG_STR ("Connecting to PropertySet " << extPropSetName); - itsExtPropertySet = GCFExtPropertySetPtr( - new GCFExtPropertySet(extPropSetName.c_str(), - PST_STATION_CLOCK, - &itsPropertySetAnswer)); - itsExtPropertySet->load(); // will result in F_EXTPS_LOADED + itsExtPropertySet = new RTDBPropertySet(extPropSetName, + PST_STATION_CLOCK, + PSAT_RO, + this); break; } @@ -301,36 +247,38 @@ myPropSetName=myPropSetName.substr(8); itsExtPSinitialized = true; // take subscription - LOG_DEBUG_STR("Taking subscription in property " << PN_SC_CLOCK); - itsExtPropertySet->subscribeProp(PN_SC_CLOCK); - break; - } - - // third timer event is from subscription - if (itsClock == 0) { - // get current value - LOG_DEBUG_STR("Getting current value of property " << PN_SC_CLOCK); - GCFProperty* requiredClockProp = - itsExtPropertySet->getProperty(PN_SC_CLOCK); - ASSERTSTR(requiredClockProp, "Property " << PN_SC_CLOCK << - " not in propertyset " << PSN_STATION_CLOCK); - requiredClockProp->requestValue(); + LOG_DEBUG("Taking subscription on clock datapoint"); + itsExtPropertySet->setSubscription(true); break; } + } + break; + + case DP_SUBSCRIBED: { + DPSubscribedEvent dpEvent(event); + string propSetName(createPropertySetName(PSN_STATION_CLOCK, getName())); + propSetName += "." PN_SC_CLOCK; + if (dpEvent.DPname.find(propSetName) != string::npos) { + GCFPVInteger clockVal; + itsExtPropertySet->getValue(PN_SC_CLOCK, clockVal); + itsClock = clockVal.getValue(); + LOG_DEBUG_STR("ClockSetting is " << itsClock); - // fourth timer event is from retrieving the required clock. - if (itsClock) { - LOG_DEBUG ("Attached to external propertySet, going to connect state"); itsOwnPropertySet->setValue(PN_DBC_CLOCK,GCFPVInteger(itsClock)); itsParentPort = itsParentControl->registerTask(this); + LOG_DEBUG ("Going to connect state"); TRAN(DigitalBoardControl::connect_state); // go to next state. } - break; + } + break; case F_CONNECTED: + case F_DISCONNECTED: + case F_EXIT: break; - case F_DISCONNECTED: + case DP_CHANGED: + _databaseEventHandler(event); break; default: @@ -355,12 +303,12 @@ GCFEvent::TResult DigitalBoardControl::connect_state(GCFEvent& event, GCFEvent::TResult status = GCFEvent::HANDLED; switch (event.signal) { - case F_INIT: + case F_EXIT: break; case F_ENTRY: case F_TIMER: - itsOwnPropertySet->setValue(PVSSNAME_FSM_CURACT, GCFPVString("connecting")); + itsOwnPropertySet->setValue(PVSSNAME_FSM_CURACT, GCFPVString("Connecting")); itsOwnPropertySet->setValue(PN_DBC_CONNECTED, GCFPVBool(false)); itsSubscription = 0; itsRSPDriver->open(); // will result in F_CONN or F_DISCONN @@ -384,6 +332,10 @@ GCFEvent::TResult DigitalBoardControl::connect_state(GCFEvent& event, itsTimerPort->setTimer(2.0); break; + case DP_CHANGED: + _databaseEventHandler(event); + break; + default: LOG_DEBUG_STR ("connect, default"); status = defaultMessageHandling(event, port); @@ -406,12 +358,12 @@ GCFEvent::TResult DigitalBoardControl::subscribe_state(GCFEvent& event, GCFEvent::TResult status = GCFEvent::HANDLED; switch (event.signal) { - case F_INIT: + case F_EXIT: break; case F_ENTRY: case F_TIMER: - itsOwnPropertySet->setValue(PVSSNAME_FSM_CURACT,GCFPVString("subscribe on clock")); + itsOwnPropertySet->setValue(PVSSNAME_FSM_CURACT,GCFPVString("Subscribe to clock")); requestSubscription(); // will result in RSP_SUBCLOCKACK; break; @@ -436,6 +388,10 @@ GCFEvent::TResult DigitalBoardControl::subscribe_state(GCFEvent& event, } break; + case DP_CHANGED: + _databaseEventHandler(event); + break; + default: LOG_DEBUG_STR ("subscribe, default"); status = defaultMessageHandling(event, port); @@ -459,12 +415,12 @@ GCFEvent::TResult DigitalBoardControl::retrieve_state(GCFEvent& event, GCFEvent::TResult status = GCFEvent::HANDLED; switch (event.signal) { - case F_INIT: + case F_EXIT: break; case F_ENTRY: case F_TIMER: - itsOwnPropertySet->setValue(PVSSNAME_FSM_CURACT,GCFPVString("retrieve clock")); + itsOwnPropertySet->setValue(PVSSNAME_FSM_CURACT,GCFPVString("Retrieve clock")); requestClockSetting(); // will result in RSP_GETCLOCKACK; break; @@ -496,6 +452,10 @@ GCFEvent::TResult DigitalBoardControl::retrieve_state(GCFEvent& event, break; } + case DP_CHANGED: + _databaseEventHandler(event); + break; + default: LOG_DEBUG_STR ("retrieve, default"); status = defaultMessageHandling(event, port); @@ -524,7 +484,7 @@ GCFEvent::TResult DigitalBoardControl::setClock_state(GCFEvent& event, case F_ENTRY: case F_TIMER: - itsOwnPropertySet->setValue(PVSSNAME_FSM_CURACT,GCFPVString("set clock")); + itsOwnPropertySet->setValue(PVSSNAME_FSM_CURACT,GCFPVString("Set clock")); sendClockSetting(); // will result in RSP_SETCLOCKACK; break; @@ -548,6 +508,10 @@ GCFEvent::TResult DigitalBoardControl::setClock_state(GCFEvent& event, break; } + case DP_CHANGED: + _databaseEventHandler(event); + break; + default: LOG_DEBUG_STR ("setClock, default"); status = defaultMessageHandling(event, port); @@ -575,8 +539,8 @@ GCFEvent::TResult DigitalBoardControl::active_state(GCFEvent& event, GCFPortInte case F_ENTRY: { // update PVSS - itsOwnPropertySet->setValue(PVSSNAME_FSM_CURACT,GCFPVString("active")); - itsOwnPropertySet->setValue(PVSSNAME_FSM_ERROR,GCFPVString("")); + itsOwnPropertySet->setValue(PVSSNAME_FSM_CURACT,GCFPVString("Active")); + itsOwnPropertySet->setValue(PVSSNAME_FSM_ERROR, GCFPVString("")); break; } @@ -610,11 +574,16 @@ GCFEvent::TResult DigitalBoardControl::active_state(GCFEvent& event, GCFPortInte } // when update.clock==itsClock ignore it, we probable caused it ourselves. - break; + LOG_DEBUG_STR("Event.clock = " << updateEvent.clock << ", myClock = " << itsClock); } + break; + case DP_CHANGED: + _databaseEventHandler(event); + break; + default: - LOG_DEBUG("active_state, default"); +// LOG_DEBUG("active_state, default"); status = defaultMessageHandling(event, port); break; } @@ -645,7 +614,7 @@ void DigitalBoardControl::requestSubscription() RSPSubclockEvent msg; - msg.timestamp.setNow(); +// msg.timestamp = 0; msg.period = 1; // let RSPdriver check every second itsRSPDriver->send(msg); @@ -675,7 +644,7 @@ void DigitalBoardControl::requestClockSetting() RSPGetclockEvent msg; - msg.timestamp.setNow(); +// msg.timestamp = 0; msg.cache = 1; itsRSPDriver->send(msg); @@ -691,7 +660,7 @@ void DigitalBoardControl::sendClockSetting() RSPSetclockEvent msg; - msg.timestamp.setNow(); +// msg.timestamp = 0; msg.clock = itsClock; itsRSPDriver->send(msg); @@ -776,10 +745,18 @@ GCFEvent::TResult DigitalBoardControl::defaultMessageHandling(GCFEvent& event, break; case CONTROL_RESYNC: { + } + break; + case DP_CHANGED: { + DPChangedEvent dpEvent(event); + LOG_DEBUG_STR("DP " << dpEvent.DPname << " changed"); } break; + case DP_SET: + break; + default: { LOG_WARN_STR ("no action defined for event:" << eventName(event)); } @@ -810,8 +787,9 @@ GCFEvent::TResult DigitalBoardControl::finishing_state(GCFEvent& event, GCFPortI itsParentControl->nowInState(getName(), CTState::QUIT); // update PVSS - itsOwnPropertySet->setValue(string(PVSSNAME_FSM_CURACT),GCFPVString("finished")); - itsOwnPropertySet->setValue(string(PVSSNAME_FSM_ERROR),GCFPVString("")); + itsOwnPropertySet->setValue(PVSSNAME_FSM_CURACT,GCFPVString("Finished")); + itsOwnPropertySet->setValue(PVSSNAME_FSM_ERROR, GCFPVString("")); + itsOwnPropertySet->setValue(PN_DBC_CONNECTED, GCFPVBool (false)); itsTimerPort->setTimer(1L); break; diff --git a/MAC/APL/StationCU/src/DigitalBoardControl/DigitalBoardControl.h b/MAC/APL/StationCU/src/DigitalBoardControl/DigitalBoardControl.h index 524bcc7d62302acfe28694e1c937473024d79bee..638e6c88b831361789674a8a75ca3b954545fced 100644 --- a/MAC/APL/StationCU/src/DigitalBoardControl/DigitalBoardControl.h +++ b/MAC/APL/StationCU/src/DigitalBoardControl/DigitalBoardControl.h @@ -23,34 +23,25 @@ #ifndef DIGITALBOARDCONTROL_H #define DIGITALBOARDCONTROL_H -//# Includes -#include <boost/shared_ptr.hpp> +//# Common Includes +#include <Common/LofarLogger.h> +#include <Common/lofar_string.h> + +//# ACC Includes +#include <APS/ParameterSet.h> //# GCF Includes -#include <GCF/PAL/GCF_MyPropertySet.h> -#include <GCF/PAL/GCF_ExtPropertySet.h> #include <GCF/TM/GCF_Port.h> #include <GCF/TM/GCF_ITCPort.h> #include <GCF/TM/GCF_TimerPort.h> #include <GCF/TM/GCF_Task.h> #include <GCF/TM/GCF_Event.h> +#include <GCF/RTDB/RTDB_PropertySet.h> //# local includes -#include <APL/APLCommon/PropertySetAnswerHandlerInterface.h> -#include <APL/APLCommon/PropertySetAnswer.h> -#include <APL/APLCommon/APLCommonExceptions.h> -#include <APL/APLCommon/Controller_Protocol.ph> #include <APL/APLCommon/ParentControl.h> #include <APL/APLCommon/CTState.h> -//# Common Includes -#include <Common/lofar_string.h> -#include <Common/lofar_vector.h> -#include <Common/LofarLogger.h> - -//# ACC Includes -#include <APS/ParameterSet.h> - // forward declaration namespace LOFAR { @@ -62,11 +53,11 @@ using GCF::TM::GCFPort; using GCF::TM::GCFEvent; using GCF::TM::GCFPortInterface; using GCF::TM::GCFTask; +using GCF::RTDB::RTDBPropertySet; using APLCommon::ParentControl; -class DigitalBoardControl : public GCFTask, - APLCommon::PropertySetAnswerHandlerInterface +class DigitalBoardControl : public GCFTask { public: explicit DigitalBoardControl(const string& cntlrName); @@ -77,9 +68,6 @@ public: void finish(); private: - // PropertySetAnswerHandlerInterface method - virtual void handlePropertySetAnswer(GCFEvent& answer); - // During the initial state all connections with the other programs are made. GCFEvent::TResult initial_state (GCFEvent& e, GCFPortInterface& p); GCFEvent::TResult connect_state (GCFEvent& e, GCFPortInterface& p); @@ -96,20 +84,17 @@ private: DigitalBoardControl& operator=(const DigitalBoardControl&); void _disconnectedHandler(GCFPortInterface& port); + void _databaseEventHandler(GCFEvent& answer); void requestSubscription(); void cancelSubscription(); void requestClockSetting(); void sendClockSetting(); // Data members - typedef boost::shared_ptr<GCF::PAL::GCFMyPropertySet> GCFMyPropertySetPtr; - typedef boost::shared_ptr<GCF::PAL::GCFExtPropertySet> GCFExtPropertySetPtr; - - APLCommon::PropertySetAnswer itsPropertySetAnswer; - GCFMyPropertySetPtr itsOwnPropertySet; - GCFExtPropertySetPtr itsExtPropertySet; - bool itsOwnPSinitialized; - bool itsExtPSinitialized; + RTDBPropertySet* itsOwnPropertySet; + RTDBPropertySet* itsExtPropertySet; + bool itsOwnPSinitialized; + bool itsExtPSinitialized; // pointer to parent control task ParentControl* itsParentControl; diff --git a/MAC/APL/StationCU/src/DigitalBoardControl/DigitalBoardControlDefines.h b/MAC/APL/StationCU/src/DigitalBoardControl/DigitalBoardControlDefines.h index 16276dc5179c5f9e6249da496e0de22dd2967986..b43572644c69530bdbd1f08a9b6aa7ef7eb5d8a6 100644 --- a/MAC/APL/StationCU/src/DigitalBoardControl/DigitalBoardControlDefines.h +++ b/MAC/APL/StationCU/src/DigitalBoardControl/DigitalBoardControlDefines.h @@ -26,7 +26,7 @@ namespace LOFAR { namespace StationCU { -#define PSN_DIG_BOARD_CTRL "lofar28:LOFAR_PermSW_DigBoardCtrl@instance@" +#define PSN_DIG_BOARD_CTRL "LOFAR_PermSW_DigBoardCtrl@instance@" #define PST_DIG_BOARD_CTRL "DigBoardCtrl" #define PN_DBC_CONNECTED "connected" #define PN_DBC_CLOCK "clock" diff --git a/MAC/APL/StationCU/src/HardwareMonitor/HardwareMonitor.cc b/MAC/APL/StationCU/src/HardwareMonitor/HardwareMonitor.cc index b00085b83ef15e4b68d72cbff90be6b4f65c367f..743f71841a9f80431c93d4b8901f4b1488f06386 100644 --- a/MAC/APL/StationCU/src/HardwareMonitor/HardwareMonitor.cc +++ b/MAC/APL/StationCU/src/HardwareMonitor/HardwareMonitor.cc @@ -261,14 +261,19 @@ GCFEvent::TResult HardwareMonitor::askConfiguration(GCFEvent& event, // calc size of the propertyset vectors itsNrRCUs = ack.n_rcus; itsNrRSPboards = ack.n_rspboards; - itsNrSubracks = itsNrRSPboards/NR_RSPBOARDS_PER_SUBRACK + (itsNrRSPboards%NR_RSPBOARDS_PER_SUBRACK) ? 1 : 0; - itsNrCabinets = itsNrSubracks /NR_SUBRACKS_PER_CABINET + (itsNrSubracks%NR_SUBRACKS_PER_CABINET) ? 1 : 0; + itsNrSubracks = (itsNrRSPboards/NR_RSPBOARDS_PER_SUBRACK) + + ((itsNrRSPboards%NR_RSPBOARDS_PER_SUBRACK) ? 1 : 0); + itsNrCabinets = (itsNrSubracks /NR_SUBRACKS_PER_CABINET) + + ((itsNrSubracks%NR_SUBRACKS_PER_CABINET) ? 1 : 0); // inform user LOG_DEBUG(formatString("nr RCUs = %d",ack.n_rcus)); LOG_DEBUG(formatString("nr RSPboards = %d",ack.max_rspboards)); LOG_DEBUG(formatString("nr Subracks = %d", itsNrSubracks)); LOG_DEBUG(formatString("nr Cabinets = %d", itsNrCabinets)); + LOG_DEBUG_STR("("<<itsNrRSPboards<<"/"<<NR_RSPBOARDS_PER_SUBRACK<<") + (("<<itsNrRSPboards<<"%"<<NR_RSPBOARDS_PER_SUBRACK<<") ? 1 : 0)"); + LOG_DEBUG_STR("("<<itsNrRSPboards<<"/"<<NR_RSPBOARDS_PER_SUBRACK<<") = " << itsNrRSPboards/NR_RSPBOARDS_PER_SUBRACK); + LOG_DEBUG_STR("("<<itsNrRSPboards<<"%"<<NR_RSPBOARDS_PER_SUBRACK<<") = " << itsNrRSPboards%NR_RSPBOARDS_PER_SUBRACK); // do some checks if (itsNrRSPboards != (uint32)ack.max_rspboards) { @@ -373,7 +378,7 @@ GCFEvent::TResult HardwareMonitor::createPropertySets(GCFEvent& event, } LOG_DEBUG_STR("Allocation of all propertySets successfull, going to operational mode"); itsOwnPropertySet->setValue(PVSSNAME_FSM_ERROR,GCFPVString("")); - TRAN(HardwareMonitor::askRSPinfo); + TRAN(HardwareMonitor::askVersion); } break; @@ -501,7 +506,12 @@ GCFEvent::TResult HardwareMonitor::askRSPinfo(GCFEvent& event, if (ack.status != SUCCESS) { LOG_ERROR_STR ("Failed to get the status information, trying other information"); itsOwnPropertySet->setValue(PVSSNAME_FSM_ERROR,GCFPVString("getStatus error")); +#if 0 TRAN(HardwareMonitor::askRCUinfo); // go to next state. +#else + LOG_WARN ("SKIPPING RCU INFO FOR A MOMENT"); + TRAN(HardwareMonitor::waitForNextCycle); // go to next state. +#endif break; } @@ -578,7 +588,12 @@ GCFEvent::TResult HardwareMonitor::askRSPinfo(GCFEvent& event, LOG_DEBUG_STR ("RSPboard information updated, going to RCU information"); itsOwnPropertySet->setValue(PVSSNAME_FSM_ERROR,GCFPVString("")); +#if 0 TRAN(HardwareMonitor::askRCUinfo); // go to next state. +#else + LOG_WARN ("SKIPPING RCU INFO FOR A MOMENT"); + TRAN(HardwareMonitor::waitForNextCycle); // go to next state. +#endif break; } diff --git a/MAC/APL/StationCU/src/HardwareMonitor/Makefile.am b/MAC/APL/StationCU/src/HardwareMonitor/Makefile.am index 2b9fda4fedbbe44d4df07b88e138dacaea36eb7a..321e45f925e6d1aaf6657cb25186b2ad6a655c79 100644 --- a/MAC/APL/StationCU/src/HardwareMonitor/Makefile.am +++ b/MAC/APL/StationCU/src/HardwareMonitor/Makefile.am @@ -22,7 +22,6 @@ DOCHDRS = $(pkginclude_HEADERS) $(BUILT_SOURCES) EXTRA_DIST = $(configfiles_DATA) $(sysconf_DATA) -sysconf_DATA = HardwareMonitor.conf \ - HardwareMonitor.log_prop +sysconf_DATA = HardwareMonitor.log_prop include $(top_srcdir)/Makefile.common diff --git a/MAC/APL/StationCU/src/StationControl/ActiveObs.cc b/MAC/APL/StationCU/src/StationControl/ActiveObs.cc index 537198adc74bb51cbb708eb7e97da185949cbc5a..acea611a78873231cb133e540b203c54a338167f 100644 --- a/MAC/APL/StationCU/src/StationControl/ActiveObs.cc +++ b/MAC/APL/StationCU/src/StationControl/ActiveObs.cc @@ -35,6 +35,7 @@ #include <APL/APLCommon/ChildControl.h> #include <APL/APLCommon/ControllerDefines.h> #include <APL/APLCommon/Controller_Protocol.ph> +#include <GCF/RTDB/DP_Protocol.ph> #include "StationControlDefines.h" #include "ActiveObs.h" @@ -47,7 +48,7 @@ namespace LOFAR { using namespace APLCommon; using namespace GCF::TM; using namespace GCF::Common; - using namespace GCF::PAL; + using namespace GCF::RTDB; namespace StationCU { // @@ -58,11 +59,10 @@ ActiveObs::ActiveObs(const string& name, ParameterSet* thePS, GCFTask& task) : GCFFsm (initial), - PropertySetAnswerHandlerInterface(), itsStopTimerID (0), - itsPropertySetAnswer(*this), itsPropSetTimer (new GCFTimerPort(task, name)), itsName (name), + itsTask (&task), itsInstanceNr (getInstanceNr(name)), itsObsPar (APLCommon::Observation(thePS)), itsBeamCntlrReady (false), @@ -83,84 +83,10 @@ ActiveObs::ActiveObs(const string& name, ActiveObs::~ActiveObs() { if (itsPropertySet) { - itsPropertySet->disable(); delete itsPropertySet; } } -// -// handlePropertySetAnswer(answer) -// -void ActiveObs::handlePropertySetAnswer(GCFEvent& answer) -{ - LOG_DEBUG_STR ("ActiveObs::handlePropertySetAnswer"); - - switch(answer.signal) { - case F_MYPS_ENABLED: - case F_EXTPS_LOADED: { - GCFPropSetAnswerEvent* pPropAnswer=static_cast<GCFPropSetAnswerEvent*>(&answer); - if(pPropAnswer->result != GCF_NO_ERROR) { - LOG_ERROR(formatString("PropertySet %s NOT ENABLED", pPropAnswer->pScope)); - } - // always let timer expire so main task will continue. - LOG_DEBUG_STR("Property set " << pPropAnswer->pScope << - " enabled, continuing main task"); - itsPropSetTimer->setTimer(0.5); - break; - } - - case F_VGETRESP: { // initial get of required clock - GCFPropValueEvent* pPropAnswer=static_cast<GCFPropValueEvent*>(&answer); -// if (strstr(pPropAnswer->pPropName, PN_SC_CLOCK) != 0) { -// itsClock =(static_cast<const GCFPVInteger*>(pPropAnswer->pValue))->getValue(); -// -// // signal main task we have the value. -// LOG_DEBUG_STR("Clock in PVSS has value: " << itsClock); -// itsTimerPort->setTimer(0.5); -// break; -// } - LOG_WARN_STR("Got VGETRESP signal from unknown property " << - pPropAnswer->pPropName); - } - - case F_VCHANGEMSG: { - // check which property changed - GCFPropValueEvent* pPropAnswer=static_cast<GCFPropValueEvent*>(&answer); -// if (strstr(pPropAnswer->pPropName, PN_SC_CLOCK) != 0) { -// itsClock =(static_cast<const GCFPVInteger*>(pPropAnswer->pValue))->getValue(); -// LOG_DEBUG_STR("Received clock change from PVSS, clock is now " << itsClock); -// break; -// } - - // don't watch state and error fields. - if ((strstr(pPropAnswer->pPropName, PVSSNAME_FSM_STATE) != 0) || - (strstr(pPropAnswer->pPropName, PVSSNAME_FSM_ERROR) != 0) || - (strstr(pPropAnswer->pPropName, PVSSNAME_FSM_CURACT) != 0) || - (strstr(pPropAnswer->pPropName, PVSSNAME_FSM_LOGMSG) != 0)) { - return; - } - - LOG_WARN_STR("Got VCHANGEMSG signal from unknown property " << - pPropAnswer->pPropName); - } - -// case F_SUBSCRIBED: GCFPropAnswerEvent pPropName -// case F_UNSUBSCRIBED: GCFPropAnswerEvent pPropName -// case F_PS_CONFIGURED: GCFConfAnswerEvent pApcName -// case F_EXTPS_LOADED: GCFPropSetAnswerEvent pScope, result -// case F_EXTPS_UNLOADED: GCFPropSetAnswerEvent pScope, result -// case F_MYPS_ENABLED: GCFPropSetAnswerEvent pScope, result -// case F_MYPS_DISABLED: GCFPropSetAnswerEvent pScope, result -// case F_VGETRESP: GCFPropValueEvent pValue, pPropName -// case F_VSETRESP: GCFPropAnswerEvent pPropName -// case F_VCHANGEMSG: GCFPropValueEvent pValue, pPropName -// case F_SERVER_GONE: GCFPropSetAnswerEvent pScope, result - - default: - break; - } -} - // // initial(event, port) // @@ -174,25 +100,25 @@ GCFEvent::TResult ActiveObs::initial(GCFEvent& event, GCFEvent::TResult status = GCFEvent::HANDLED; switch (event.signal) { - case F_INIT: + case F_ENTRY: itsReqState = CTState::CREATED; LOG_DEBUG_STR("Starting statemachine for observation " << itsName); break; - case F_ENTRY: { + case F_INIT: { // Get access to my own propertyset. string propSetName(createPropertySetName(PSN_OBSERVATION, itsName)); LOG_DEBUG_STR ("Activating PropertySet: " << propSetName); - itsPropertySet = new GCFMyPropertySet(propSetName.c_str(), + itsPropertySet = new RTDBPropertySet(propSetName, PST_OBSERVATION, - PS_CAT_TEMP_AUTOLOAD, - &itsPropertySetAnswer); - itsPropertySet->enable(); - // Wait for timer that is set in PropertySetAnswer on ENABLED event + PSAT_WO, + itsTask); +#if 0 } break; case F_TIMER: { // must be timer that PropSet has set. +#endif // update PVSS. LOG_TRACE_FLOW ("top DP of observation created, going to starting state"); itsCurState = CTState::CREATED; @@ -200,6 +126,16 @@ GCFEvent::TResult ActiveObs::initial(GCFEvent& event, } break; + case DP_CREATED: { + // NOTE: thsi function may be called DURING the construction of the PropertySet. + // Always exit this event in a way that GCF can end the construction. + DPCreatedEvent dpEvent(event); + LOG_DEBUG_STR("Result of creating " << dpEvent.DPname << " = " << dpEvent.result); +// itsPropSetTimer->setTimer(0.1); +// TODO: Find out why this timer is not running. + } + break; + case F_CONNECTED: break; diff --git a/MAC/APL/StationCU/src/StationControl/ActiveObs.h b/MAC/APL/StationCU/src/StationControl/ActiveObs.h index c713f3855c3bb9ec74f0a5f34747ef7becda97bd..97141118831507d92b837d52ac3c650e8a37e49d 100644 --- a/MAC/APL/StationCU/src/StationControl/ActiveObs.h +++ b/MAC/APL/StationCU/src/StationControl/ActiveObs.h @@ -34,10 +34,7 @@ #include <GCF/TM/GCF_TimerPort.h> #include <APL/APLCommon/Observation.h> #include <APL/APLCommon/CTState.h> -#include <APL/APLCommon/PropertySetAnswerHandlerInterface.h> -#include <APL/APLCommon/PropertySetAnswer.h> -#include <GCF/PAL/GCF_MyPropertySet.h> -#include <GCF/PAL/GCF_Answer.h> +#include <GCF/RTDB/RTDB_PropertySet.h> // Avoid 'using namespace' in headerfiles @@ -48,7 +45,7 @@ namespace LOFAR { using GCF::TM::GCFPortInterface; using GCF::TM::GCFTask; using GCF::TM::GCFTimerPort; - using GCF::PAL::GCFMyPropertySet; + using GCF::RTDB::RTDBPropertySet; using APLCommon::CTState; namespace StationCU { @@ -63,8 +60,7 @@ namespace LOFAR { // The ActiveObs class can instruct the ChildControl task directly, the responses // are captured in the StationController task that will forward them. // -class ActiveObs : public GCFFsm, - APLCommon::PropertySetAnswerHandlerInterface +class ActiveObs : public GCFFsm { public: ActiveObs (const string& name, @@ -72,7 +68,6 @@ public: ACC::APS::ParameterSet* aPS, GCFTask& task); virtual ~ActiveObs(); - virtual void handlePropertySetAnswer(GCFEvent& answer); void start() { initFsm(); } bool isReady() const { return (itsReadyFlag); } @@ -99,11 +94,11 @@ private: ActiveObs& operator=(const ActiveObs& that); //# --- Datamembers --- - APLCommon::PropertySetAnswer itsPropertySetAnswer; - GCFMyPropertySet* itsPropertySet; - GCFTimerPort* itsPropSetTimer; + RTDBPropertySet* itsPropertySet; + GCFTimerPort* itsPropSetTimer; string itsName; + GCFTask* itsTask; int32 itsInstanceNr; APLCommon::Observation itsObsPar; bool itsBeamCntlrReady; diff --git a/MAC/APL/StationCU/src/StationControl/StationControl.cc b/MAC/APL/StationCU/src/StationControl/StationControl.cc index 3b40c07d2d5745171d68780dd27486c61d8be341..8cdf3a73be757648cb454d7afc72aee5f26955b6 100644 --- a/MAC/APL/StationCU/src/StationControl/StationControl.cc +++ b/MAC/APL/StationCU/src/StationControl/StationControl.cc @@ -26,19 +26,15 @@ #include <lofar_config.h> #include <Common/LofarLogger.h> -#include <boost/shared_array.hpp> #include <APS/ParameterSet.h> #include <GCF/GCF_PVTypes.h> -#include <GCF/PAL/GCF_PVSSInfo.h> -#include <GCF/PAL/GCF_Answer.h> #include <GCF/Utils.h> #include <GCF/GCF_ServiceInfo.h> -#include <GCF/Protocols/PA_Protocol.ph> #include <APL/APLCommon/APL_Defines.h> -#include <APL/APLCommon/APLCommonExceptions.h> #include <APL/APLCommon/ControllerDefines.h> #include <APL/APLCommon/Controller_Protocol.ph> #include <APL/RSP_Protocol/RSP_Protocol.ph> +#include <GCF/RTDB/DP_Protocol.ph> #include <APL/APLCommon/StationInfo.h> #include <signal.h> @@ -48,7 +44,7 @@ using namespace LOFAR::GCF::Common; using namespace LOFAR::GCF::TM; -using namespace LOFAR::GCF::PAL; +using namespace LOFAR::GCF::RTDB; using namespace std; namespace LOFAR { @@ -64,10 +60,8 @@ static StationControl* thisStationControl = 0; // StationControl::StationControl(const string& cntlrName) : GCFTask ((State)&StationControl::initial_state,cntlrName), - PropertySetAnswerHandlerInterface(), - itsPropertySetAnswer(*this), - itsClockPropSet (), - itsOwnPropSet (), + itsClockPropSet (0), + itsOwnPropSet (0), itsClockPSinitialized(false), itsOwnPSinitialized (false), itsChildControl (0), @@ -104,8 +98,7 @@ StationControl::StationControl(const string& cntlrName) : // for debugging purposes GCF::TM::registerProtocol (CONTROLLER_PROTOCOL, CONTROLLER_PROTOCOL_STRINGS); - GCF::TM::registerProtocol (PA_PROTOCOL, PA_PROTOCOL_STRINGS); - GCF::TM::registerProtocol (F_PML_PROTOCOL, F_PML_PROTOCOL_STRINGS); + GCF::TM::registerProtocol (DP_PROTOCOL, DP_PROTOCOL_STRINGS); } @@ -141,74 +134,32 @@ void StationControl::finish() // -// handlePropertySetAnswer(answer) +// _databaseEventHandler(event) // -void StationControl::handlePropertySetAnswer(GCFEvent& answer) +void StationControl::_databaseEventHandler(GCFEvent& event) { - LOG_TRACE_FLOW_STR ("handlePropertySetAnswer:" << eventstr(answer)); - - switch(answer.signal) { - case F_MYPS_ENABLED: - case F_EXTPS_LOADED: { - GCFPropSetAnswerEvent* pPropAnswer=static_cast<GCFPropSetAnswerEvent*>(&answer); - if(pPropAnswer->result != GCF_NO_ERROR) { - LOG_ERROR(formatString("%s : PropertySet %s NOT ENABLED", - getName().c_str(), pPropAnswer->pScope)); - } - // always let timer expire so main task will continue. - LOG_DEBUG_STR("Property set " << pPropAnswer->pScope << - " enabled, continuing main task"); - itsTimerPort->setTimer(0.5); - break; - } - - case F_VGETRESP: { // initial get of required clock - GCFPropValueEvent* pPropAnswer=static_cast<GCFPropValueEvent*>(&answer); - if (strstr(pPropAnswer->pPropName, PN_SC_CLOCK) != 0) { - itsClock =(static_cast<const GCFPVInteger*>(pPropAnswer->pValue))->getValue(); + LOG_TRACE_FLOW_STR ("_databaseEventHandler:" << eventName(event)); - // signal main task we have the value. - LOG_DEBUG_STR("Clock in PVSS has value: " << itsClock); - itsTimerPort->setTimer(0.5); - break; - } - LOG_WARN_STR("Got VGETRESP signal from unknown property " << - pPropAnswer->pPropName); - } - - case F_VCHANGEMSG: { - // check which property changed - GCFPropValueEvent* pPropAnswer=static_cast<GCFPropValueEvent*>(&answer); - - if (strstr(pPropAnswer->pPropName, PN_SC_CLOCK) != 0) { - itsClock =(static_cast<const GCFPVInteger*>(pPropAnswer->pValue))->getValue(); + switch(event.signal) { + case DP_CHANGED: { + DPChangedEvent dpEvent(event); + if (strstr(dpEvent.DPname.c_str(), PN_SC_CLOCK) != 0) { + itsClock = ((GCFPVInteger*)(dpEvent.value._pValue))->getValue(); LOG_DEBUG_STR("Received clock change from PVSS, clock is now " << itsClock); break; } // don't watch state and error fields. - if ((strstr(pPropAnswer->pPropName, PVSSNAME_FSM_STATE) != 0) || - (strstr(pPropAnswer->pPropName, PVSSNAME_FSM_ERROR) != 0) || - (strstr(pPropAnswer->pPropName, PVSSNAME_FSM_CURACT) != 0) || - (strstr(pPropAnswer->pPropName, PVSSNAME_FSM_LOGMSG) != 0)) { + if ((strstr(dpEvent.DPname.c_str(), PVSSNAME_FSM_STATE) != 0) || + (strstr(dpEvent.DPname.c_str(), PVSSNAME_FSM_ERROR) != 0) || + (strstr(dpEvent.DPname.c_str(), PVSSNAME_FSM_CURACT) != 0) || + (strstr(dpEvent.DPname.c_str(), PVSSNAME_FSM_LOGMSG) != 0)) { return; } - LOG_WARN_STR("Got VCHANGEMSG signal from unknown property " << - pPropAnswer->pPropName); + LOG_WARN_STR("Got VCHANGEMSG signal from unknown property " << dpEvent.DPname); } - -// case F_SUBSCRIBED: GCFPropAnswerEvent pPropName -// case F_UNSUBSCRIBED: GCFPropAnswerEvent pPropName -// case F_PS_CONFIGURED: GCFConfAnswerEvent pApcName -// case F_EXTPS_LOADED: GCFPropSetAnswerEvent pScope, result -// case F_EXTPS_UNLOADED: GCFPropSetAnswerEvent pScope, result -// case F_MYPS_ENABLED: GCFPropSetAnswerEvent pScope, result -// case F_MYPS_DISABLED: GCFPropSetAnswerEvent pScope, result -// case F_VGETRESP: GCFPropValueEvent pValue, pPropName -// case F_VSETRESP: GCFPropAnswerEvent pPropName -// case F_VCHANGEMSG: GCFPropValueEvent pValue, pPropName -// case F_SERVER_GONE: GCFPropSetAnswerEvent pScope, result + break; default: break; @@ -224,7 +175,7 @@ void StationControl::handlePropertySetAnswer(GCFEvent& answer) GCFEvent::TResult StationControl::initial_state(GCFEvent& event, GCFPortInterface& port) { - LOG_DEBUG_STR ("initial:" << eventstr(event) << "@" << port.getName()); + LOG_DEBUG_STR ("initial:" << eventName(event) << "@" << port.getName()); GCFEvent::TResult status = GCFEvent::HANDLED; @@ -236,24 +187,34 @@ GCFEvent::TResult StationControl::initial_state(GCFEvent& event, // Get access to my own propertyset. string myPropSetName(createPropertySetName(PSN_STATION_CTRL, getName())); LOG_DEBUG_STR ("Activating PropertySet " << myPropSetName); - itsOwnPropSet = new GCFMyPropertySet(PSN_STATION_CTRL, - PST_STATION_CTRL, - PS_CAT_PERM_AUTOLOAD, - &itsPropertySetAnswer); - itsOwnPropSet->enable(); // will result in F_MYPS_ENABLED - - // When myPropSet is enabled we will connect to the external PropertySet - // that dictates the systemClock setting. - + itsOwnPropSet = new RTDBPropertySet(myPropSetName, + PST_STATION_CTRL, + PSAT_RW, + this); // Wait for timer that is set in PropertySetAnswer on ENABLED event } break; + case DP_CREATED: { + // NOTE: thsi function may be called DURING the construction of the PropertySet. + // Always exit this event in a way that GCF can end the construction. + DPCreatedEvent dpEvent(event); + LOG_DEBUG_STR("Result of creating " << dpEvent.DPname << " = " << dpEvent.result); + itsTimerPort->cancelAllTimers(); + itsTimerPort->setTimer(0.0); + } + break; + case F_TIMER: // first timer event is from own propertyset if (!itsOwnPSinitialized) { itsOwnPSinitialized = true; + // Enable Child task on time so we have some time to resolve the name + LOG_DEBUG ("Enabling ChildControl task"); + itsChildControl->openService(MAC_SVCMASK_STATIONCTRL, itsInstanceNr); + itsChildControl->registerCompletionPort(itsChildPort); + // first redirect signalHandler to our finishing state to leave PVSS // in the right state when we are going down thisStationControl = this; @@ -262,26 +223,25 @@ GCFEvent::TResult StationControl::initial_state(GCFEvent& event, // update PVSS. LOG_TRACE_FLOW ("Updateing state to PVSS"); - itsOwnPropSet->setValue(PVSSNAME_FSM_CURACT,GCFPVString("initial")); + itsOwnPropSet->setValue(PVSSNAME_FSM_CURACT,GCFPVString("Initial")); itsOwnPropSet->setValue(PVSSNAME_FSM_ERROR,GCFPVString("")); // enable clock propertyset. string clkPropSetName(createPropertySetName(PSN_STATION_CLOCK, getName())); LOG_DEBUG_STR ("Activating PropertySet " << clkPropSetName); - itsClockPropSet = new GCFMyPropertySet(PSN_STATION_CLOCK, - PST_STATION_CLOCK, - PS_CAT_PERM_AUTOLOAD, - &itsPropertySetAnswer); - itsClockPropSet->enable(); // will result in F_MYPS_ENABLED + itsClockPropSet = new RTDBPropertySet(clkPropSetName, + PST_STATION_CLOCK, + PSAT_WO, + this); } else { itsClockPSinitialized = true; - LOG_DEBUG ("Attached to external propertySets"); - LOG_DEBUG ("Enabling ChildControl task"); - itsChildControl->openService(MAC_SVCMASK_STATIONCTRL, itsInstanceNr); - itsChildControl->registerCompletionPort(itsChildPort); + GCFPVInteger clockVal; + itsClockPropSet->getValue(PN_SC_CLOCK, clockVal); + itsClock = clockVal.getValue(); + LOG_DEBUG_STR("Clock in PVSS has value: " << itsClock); LOG_DEBUG ("Going to connect state to attach to DigitalBoardController"); TRAN(StationControl::connect_state); // go to next state. @@ -294,6 +254,10 @@ GCFEvent::TResult StationControl::initial_state(GCFEvent& event, case F_DISCONNECTED: break; + case DP_CHANGED: + _databaseEventHandler(event); + break; + default: LOG_DEBUG_STR ("initial, default"); status = GCFEvent::NOT_HANDLED; @@ -310,7 +274,7 @@ GCFEvent::TResult StationControl::initial_state(GCFEvent& event, GCFEvent::TResult StationControl::connect_state(GCFEvent& event, GCFPortInterface& port) { - LOG_DEBUG_STR ("connect:" << eventstr(event) << "@" << port.getName()); + LOG_DEBUG_STR ("connect:" << eventName(event) << "@" << port.getName()); GCFEvent::TResult status = GCFEvent::HANDLED; @@ -319,7 +283,7 @@ GCFEvent::TResult StationControl::connect_state(GCFEvent& event, break; case F_ENTRY: { - itsOwnPropSet->setValue(PVSSNAME_FSM_CURACT,GCFPVString("connected")); + itsOwnPropSet->setValue(PVSSNAME_FSM_CURACT,GCFPVString("Connected")); // start DigitalBoardController LOG_DEBUG_STR("Starting DigitalBoardController"); @@ -378,6 +342,10 @@ GCFEvent::TResult StationControl::connect_state(GCFEvent& event, port.close(); break; + case DP_CHANGED: + _databaseEventHandler(event); + break; + default: LOG_DEBUG_STR ("connect, default"); status = GCFEvent::NOT_HANDLED; @@ -394,7 +362,7 @@ GCFEvent::TResult StationControl::connect_state(GCFEvent& event, // GCFEvent::TResult StationControl::operational_state(GCFEvent& event, GCFPortInterface& port) { - LOG_DEBUG_STR ("operational:" << eventstr(event) << "@" << port.getName()); + LOG_DEBUG_STR ("operational:" << eventName(event) << "@" << port.getName()); GCFEvent::TResult status = GCFEvent::HANDLED; @@ -404,7 +372,7 @@ GCFEvent::TResult StationControl::operational_state(GCFEvent& event, GCFPortInte case F_ENTRY: { // update PVSS - itsOwnPropSet->setValue(PVSSNAME_FSM_CURACT,GCFPVString("active")); + itsOwnPropSet->setValue(PVSSNAME_FSM_CURACT,GCFPVString("Active")); itsOwnPropSet->setValue(PVSSNAME_FSM_ERROR,GCFPVString("")); } break; @@ -414,6 +382,10 @@ GCFEvent::TResult StationControl::operational_state(GCFEvent& event, GCFPortInte case F_DISCONNECTED: break; + case DP_CHANGED: + _databaseEventHandler(event); + break; + case F_TIMER: { // try to map the timer on portname to an Observation ObsIter theObs = itsObsMap.find(port.getName()); @@ -601,7 +573,7 @@ GCFEvent::TResult StationControl::finishing_state(GCFEvent& event, GCFPortInterf itsParentPort->send(msg); // update PVSS - itsOwnPropSet->setValue(string(PVSSNAME_FSM_CURACT),GCFPVString("finished")); + itsOwnPropSet->setValue(string(PVSSNAME_FSM_CURACT),GCFPVString("Finished")); itsOwnPropSet->setValue(string(PVSSNAME_FSM_ERROR),GCFPVString("")); itsTimerPort->setTimer(1L); diff --git a/MAC/APL/StationCU/src/StationControl/StationControl.h b/MAC/APL/StationCU/src/StationControl/StationControl.h index 182e14c473e5f40fcd9e9be9d0a7dcb440cf3144..d5eed60fb5d3df969ae245b277a97b9cbedc26f7 100644 --- a/MAC/APL/StationCU/src/StationControl/StationControl.h +++ b/MAC/APL/StationCU/src/StationControl/StationControl.h @@ -32,8 +32,7 @@ #include <APS/ParameterSet.h> //# GCF Includes -#include <GCF/PAL/GCF_MyPropertySet.h> -#include <GCF/PAL/GCF_ExtPropertySet.h> +#include <GCF/RTDB/RTDB_PropertySet.h> #include <GCF/TM/GCF_Port.h> #include <GCF/TM/GCF_ITCPort.h> #include <GCF/TM/GCF_TimerPort.h> @@ -41,9 +40,6 @@ #include <GCF/TM/GCF_Event.h> //# Application includes -#include <APL/APLCommon/PropertySetAnswerHandlerInterface.h> -#include <APL/APLCommon/PropertySetAnswer.h> -#include <APL/APLCommon/APLCommonExceptions.h> #include <APL/APLCommon/Controller_Protocol.ph> #include <APL/APLCommon/ChildControl.h> #include <APL/APLCommon/ParentControl.h> @@ -68,8 +64,7 @@ namespace LOFAR { using GCF::TM::GCFTask; -class StationControl : public GCFTask, - APLCommon::PropertySetAnswerHandlerInterface +class StationControl : public GCFTask { public: explicit StationControl(const string& cntlrName); @@ -80,9 +75,6 @@ public: void finish(); private: - // PropertySetAnswerHandlerInterface method - virtual void handlePropertySetAnswer(GCFEvent& answer); - // During the initial state all connections with the other programs are made. GCFEvent::TResult initial_state (GCFEvent& e, GCFPortInterface& p); GCFEvent::TResult connect_state (GCFEvent& e, GCFPortInterface& p); @@ -98,14 +90,14 @@ private: uint16 _addObservation (const string& name); void _disconnectedHandler(GCFPortInterface& port); + void _databaseEventHandler(GCFEvent& event); ObsIter _searchObsByTimerID (uint32 aTimerID); // Data members - APLCommon::PropertySetAnswer itsPropertySetAnswer; - GCF::PAL::GCFMyPropertySet* itsClockPropSet; - GCF::PAL::GCFMyPropertySet* itsOwnPropSet; - bool itsClockPSinitialized; - bool itsOwnPSinitialized; + RTDBPropertySet* itsClockPropSet; + RTDBPropertySet* itsOwnPropSet; + bool itsClockPSinitialized; + bool itsOwnPSinitialized; // pointer to child control task ChildControl* itsChildControl; diff --git a/MAC/APL/TestCtlr/src/TestController.cc b/MAC/APL/TestCtlr/src/TestController.cc index bccb52eed0097775653a429599a50feeac0da7aa..78f81752579f9d62dc56d256659388a67e16ebfc 100644 --- a/MAC/APL/TestCtlr/src/TestController.cc +++ b/MAC/APL/TestCtlr/src/TestController.cc @@ -24,15 +24,10 @@ #include <Common/LofarLogger.h> #include <Common/LofarLocators.h> -#include <boost/shared_array.hpp> #include <APS/ParameterSet.h> -#include <GCF/GCF_PVTypes.h> -#include <GCF/PAL/GCF_PVSSInfo.h> #include <GCF/Utils.h> #include <GCF/GCF_ServiceInfo.h> -#include <GCF/Protocols/PA_Protocol.ph> #include <APL/APLCommon/APL_Defines.h> -#include <APL/APLCommon/APLCommonExceptions.h> #include <APL/APLCommon/Controller_Protocol.ph> #include <APL/APLCommon/ControllerDefines.h> #include <APL/APLCommon/StationInfo.h> @@ -41,7 +36,6 @@ using namespace LOFAR::GCF::Common; using namespace LOFAR::GCF::TM; -using namespace LOFAR::GCF::PAL; namespace LOFAR { using namespace APLCommon; @@ -53,7 +47,6 @@ namespace LOFAR { // TestController::TestController(const string& cntlrName) : GCFTask ((State)&TestController::initial_state,cntlrName), - PropertySetAnswerHandlerInterface(), itsParentControl (0), itsParentPort (0), itsTimerPort (0) @@ -84,15 +77,6 @@ TestController::~TestController() } -// -// handlePropertySetAnswer(answer) -// -void TestController::handlePropertySetAnswer(GCFEvent& answer) -{ - LOG_DEBUG_STR ("handlePropertySetAnswer:" << evtstr(answer)); -} - - // // initial_state(event, port) // diff --git a/MAC/APL/TestCtlr/src/TestController.h b/MAC/APL/TestCtlr/src/TestController.h index 9e2f5d26fd7e5d6372c55c9e58929d5793d40c68..c61cc19535fae8aec29ccca494e506020e214887 100644 --- a/MAC/APL/TestCtlr/src/TestController.h +++ b/MAC/APL/TestCtlr/src/TestController.h @@ -23,9 +23,10 @@ #ifndef PARENTONLY_H #define PARENTONLY_H +//# Common Includes +#include <Common/LofarLogger.h> + //# GCF Includes -#include <GCF/PAL/GCF_MyPropertySet.h> -#include <GCF/PAL/GCF_ExtPropertySet.h> #include <GCF/TM/GCF_Port.h> #include <GCF/TM/GCF_ITCPort.h> #include <GCF/TM/GCF_TimerPort.h> @@ -33,19 +34,10 @@ #include <GCF/TM/GCF_Event.h> //# local includes -#include <APL/APLCommon/PropertySetAnswerHandlerInterface.h> -#include <APL/APLCommon/PropertySetAnswer.h> -#include <APL/APLCommon/APLCommonExceptions.h> #include <APL/APLCommon/Controller_Protocol.ph> #include <APL/APLCommon/ParentControl.h> #include <APL/APLCommon/CTState.h> -//# Common Includes -#include <Common/LofarLogger.h> - -//# ACC Includes -#include <APS/ParameterSet.h> - // forward declaration namespace LOFAR { @@ -59,16 +51,12 @@ using GCF::TM::GCFPortInterface; using APLCommon::ParentControl; -class TestController : public GCFTask, - APLCommon::PropertySetAnswerHandlerInterface +class TestController : public GCFTask { public: explicit TestController(const string& cntlrName); ~TestController(); - // PropertySetAnswerHandlerInterface method - virtual void handlePropertySetAnswer(GCFEvent& answer); - // During the initial state all connections with the other programs are made. GCFEvent::TResult initial_state (GCFEvent& e, GCFPortInterface& p); diff --git a/MAC/Deployment/data/PVSS/ObsCtrl.dpdef b/MAC/Deployment/data/PVSS/ObsCtrl.dpdef index 8f280ba09c31fc5c392b62a7e90bb799387194b8..060978dfca4c124080f2c953785a1b6be9cb0879 100644 --- a/MAC/Deployment/data/PVSS/ObsCtrl.dpdef +++ b/MAC/Deployment/data/PVSS/ObsCtrl.dpdef @@ -7,7 +7,7 @@ subbandList string beamletList string bandFilter string nyquistzone int -antenneArray string +antennaArray string receiverList string sampleClock int diff --git a/MAC/GCF/RTDB/src/DP_Protocol.prot b/MAC/GCF/RTDB/src/DP_Protocol.prot index 2cfab647da9f9640e84745684a2108298bbe70e1..79b1ee9c0a598ac687ca9cbec9a4644b6319b4a0 100644 --- a/MAC/GCF/RTDB/src/DP_Protocol.prot +++ b/MAC/GCF/RTDB/src/DP_Protocol.prot @@ -25,7 +25,7 @@ autogen definitions protocol; description = "Protocol for passing PVSSresponses to GCF-tasks"; prefix = "DP"; // for the signal names -id = "(LOFAR::GCF::TM::F_APL_PROTOCOL+3)"; +id = "(LOFAR::GCF::TM::F_APL_PROTOCOL+1)"; // specify extra include files // e.g. diff --git a/MAC/GCF/RTDB/src/RTDB_PropertySet.cc b/MAC/GCF/RTDB/src/RTDB_PropertySet.cc index 3ed4eb5a19dbde2c7f73dca080b3efac9dab118e..569fc63f32383f483cca9e79c124088a2fd0d03c 100644 --- a/MAC/GCF/RTDB/src/RTDB_PropertySet.cc +++ b/MAC/GCF/RTDB/src/RTDB_PropertySet.cc @@ -441,6 +441,8 @@ LOG_DEBUG_STR("RTDBPropertySet::dpeValueGet(" << propName << ")"); // void RTDBPropertySet::dpeValueChanged(const string& propName, PVSSresult result, const GCFPValue& value) { + LOG_DEBUG_STR("RTDBPropertySet::dpeValueChanged(" << propName << ")"); + // find property string shortName(propName); _cutScope(shortName); @@ -448,24 +450,31 @@ void RTDBPropertySet::dpeValueChanged(const string& propName, PVSSresult result shortName = "value"; } Property* propPtr = _getProperty(shortName); + // if property is not yet initialized than this call is from our initial dpeGet. + bool informClient(false); if (!propPtr->initialized) { propPtr->value->copy(value); propPtr->initialized = true; - return; - } - - // if property is changed adopt the value if it all went ok. - if (*(propPtr->value) != value) { - if (result == SA_NO_ERROR) { - propPtr->value->copy(value); - } - // notify user when he is interested in it. - if (itsAccessType & PSAT_RD_MASK) { - itsExtResponse->dpeValueChanged(propName, result, value); + LOG_DEBUG("RTDBPropertySet::dpeValueChanged:internal event"); + informClient = true; +// return; + } + else { + // if property is changed adopt the value if it all went ok. + if (*(propPtr->value) != value) { + if (result == SA_NO_ERROR) { + propPtr->value->copy(value); + informClient = true; + } } } + // notify user when he is interested in it. + if (informClient && (itsAccessType & PSAT_RD_MASK)) { + LOG_DEBUG("RTDBPropertySet::dpeValueChanged:propagate"); + itsExtResponse->dpeValueChanged(propName, result, value); + } } } // namespace RTDB diff --git a/MAC/MACCommon/ProtID_numbers.txt b/MAC/MACCommon/ProtID_numbers.txt index 13f55a477f21f533b34999c154947ad258e1906f..5482c60834fede02cbad9e7bb9663aa5d4658bfa 100644 --- a/MAC/MACCommon/ProtID_numbers.txt +++ b/MAC/MACCommon/ProtID_numbers.txt @@ -25,7 +25,7 @@ PA F_GCF_PROTOCOL + 2 5 SB F_GCF_PROTOCOL + 3 6 KVL F_GCF_PROTOCOL + 4 7 -LogicalDevice F_APL_PROTOCOL + 1 11 // almost obsolete +RTDB F_APL_PROTOCOL + 1 11 // was LogicalDevice StartDaemon F_APL_PROTOCOL + 2 12 Control F_APL_PROTOCOL + 3 13 // used to be SAS THPVSSBridge F_APL_PROTOCOL + 4 14