diff --git a/MAC/APL/APLCommon/configure.in b/MAC/APL/APLCommon/configure.in index d558c3f3916fcc66c277fcda8d12318f9dbe3210..33d7586597d4ee9e1016bd59fd9fc3fbf8e88715 100644 --- a/MAC/APL/APLCommon/configure.in +++ b/MAC/APL/APLCommon/configure.in @@ -57,6 +57,7 @@ lofar_COMPILETOOLS lofar_PVSS(1) lofar_INTERNAL(LCS/Common, common, , 1, Common/LofarTypes.h,,) lofar_INTERNAL(LCS/ACC/APS, APS, , 1, APS/ParameterSet.h,,) +lofar_INTERNAL(MAC/Deployment, Deployment, , 1, Deployment/StationInfo.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,,) diff --git a/MAC/APL/APLCommon/include/APL/APLCommon/ControllerDefines.h b/MAC/APL/APLCommon/include/APL/APLCommon/ControllerDefines.h index 4808115d5a9ad4e3b9b748ff4dfb57ed5715c44a..4c2c7ebf27a709bd724d066506f9e9f80562455d 100644 --- a/MAC/APL/APLCommon/include/APL/APLCommon/ControllerDefines.h +++ b/MAC/APL/APLCommon/include/APL/APLCommon/ControllerDefines.h @@ -65,6 +65,9 @@ string controllerName (uint16 cntlrType, uint16 instanceNr, uint32 ObservationNr); +// Convert a controller type to the coresponding node in the OTDB. +string parsetNodeName (uint16 cntlrType); + // Convert the 'non-shared controllername' to the 'shared controller' name. string sharedControllerName (const string& controllerName); @@ -83,6 +86,9 @@ uint16 getInstanceNr (const string& ObservationName); // Get the controllerType from the controllername. int32 getControllerType (const string& ObservationName); +// Construct PS name solving markers line @observation@, @ring@, etc. +string createPropertySetName(const string& propSetMask, + const string& controllerName); }; // APLCommon }; // LOFAR diff --git a/MAC/APL/APLCommon/src/ChildControl.cc b/MAC/APL/APLCommon/src/ChildControl.cc index b2a7df31694980a3d0e426043a1d592b462997b0..b34acf73df77520ff7268117f705eeb4c3d113ac 100644 --- a/MAC/APL/APLCommon/src/ChildControl.cc +++ b/MAC/APL/APLCommon/src/ChildControl.cc @@ -25,7 +25,7 @@ //# Includes #include <Common/LofarLogger.h> -#include <Common/Deployment.h> +#include <Deployment/StationInfo.h> #include <APS/ParameterSet.h> #include <GCF/GCF_ServiceInfo.h> #include <GCF/Utils.h> @@ -33,8 +33,11 @@ #include <APL/APLCommon/ChildControl.h> #include <Controller_Protocol.ph> #include <StartDaemon_Protocol.ph> +#include <boost/lexical_cast.hpp> +using namespace boost; namespace LOFAR { + using namespace Deployment; using namespace GCF::TM; using namespace ACC::APS; namespace APLCommon { @@ -154,34 +157,33 @@ bool ChildControl::startChild (const string& aName, } // make sure there is a parameterSet for the program. - if (aCntlrType != CNTLRTYPE_OBSERVATIONCTRL) { - // search observation-parset for controller name and determine prefix - string baseSetName = formatString("%s/Observation_%d", - LOFAR_SHARE_LOCATION, anObsID); - LOG_DEBUG_STR ("Reading parameterfile: " << baseSetName); - ParameterSet wholeSet (baseSetName); - ParameterSet::iterator iter = wholeSet.begin(); - ParameterSet::iterator end = wholeSet.end(); - while (iter != end) { - // search a parameter that is meant for this controller - // to determine the position of the controller in the tree. - if (keyName(moduleName(iter->first)) == aName) { - string cntlrSetName = formatString("%s/%s", LOFAR_SHARE_LOCATION, - aName.c_str()); - LOG_DEBUG_STR("Creating parameterfile: " << cntlrSetName); - ParameterSet cntlrSet = wholeSet.makeSubset(moduleName(iter->first)); - cntlrSet.add("prefix", moduleName(iter->first)); - cntlrSet.writeFile (cntlrSetName); - break; - } - iter++; - } - if (iter == end) { // could not create a parameterset, report failure. - LOG_ERROR_STR("No parameter information found for controller " << aName << - " in file " << baseSetName << ". Cannot start controller!"); - return (false); - } - } + // search observation-parset for controller name and determine prefix + // NOTE: this name must be the same as in the MACScheduler. + string baseSetName = formatString("%s/Observation_%d", LOFAR_SHARE_LOCATION, anObsID); + LOG_DEBUG_STR ("Reading parameterfile: " << baseSetName); + ParameterSet wholeSet (baseSetName); + string prefix = wholeSet.getString("prefix"); + + // Create a parameterset with software related issues. + string cntlrSetName(formatString("%s/%s", LOFAR_SHARE_LOCATION, aName.c_str())); + LOG_DEBUG_STR("Creating parameterfile: " << cntlrSetName); + // first add the controller specific stuff + string nodeName(parsetNodeName(aCntlrType)); + string position(wholeSet.locateModule(nodeName)); + LOG_DEBUG_STR("Ctype=" << aCntlrType << ", name=" << nodeName << + ", position=" << position); + ParameterSet cntlrSet = wholeSet.makeSubset(position+nodeName+"."); + // always add Observation and all its children to the Parset. + cntlrSet.adoptCollection(wholeSet.makeSubset(wholeSet.locateModule("Observation"))); + // Add some comment lines and some extra fields to the file + cntlrSet.add("prefix", prefix+position+nodeName+"."); + cntlrSet.add("_instanceNr", lexical_cast<string>(instanceNr)); + cntlrSet.add("_treeID", lexical_cast<string>(anObsID)); + cntlrSet.add("# modulename", nodeName); + cntlrSet.add("# pathname", prefix+position+nodeName+"."); + cntlrSet.add("# treeID", lexical_cast<string>(anObsID)); + // Finally write to subset to the file. + cntlrSet.writeFile (cntlrSetName); // Alright, child does not exist yet. // construct structure with all information @@ -467,7 +469,7 @@ void ChildControl::_processActionList() STARTDAEMONCreateEvent startRequest; startRequest.cntlrType = action->cntlrType; startRequest.cntlrName = action->cntlrName; - startRequest.parentHost = GCF::Common::myHostname(); + startRequest.parentHost = GCF::Common::myHostname(true); startRequest.parentService = itsListener->makeServiceName(); startDaemon->second->send(startRequest); diff --git a/MAC/APL/APLCommon/src/ControllerDefines.cc b/MAC/APL/APLCommon/src/ControllerDefines.cc index 52295338befb6985c19bc4efb0f98c62b70b4445..e7018538be5f550d8de0b2de096a39ae62cb6832 100644 --- a/MAC/APL/APLCommon/src/ControllerDefines.cc +++ b/MAC/APL/APLCommon/src/ControllerDefines.cc @@ -26,29 +26,38 @@ //# Includes #include <Common/LofarLogger.h> #include <Common/StringUtil.h> // rtrim +#include <Deployment/StationInfo.h> +#include <GCF/Utils.h> // myHostname #include <APS/ParameterSet.h> // indexValue #include <APL/APLCommon/ControllerDefines.h> +#include <boost/config.hpp> +#include <boost/lexical_cast.hpp> +using namespace boost; + namespace LOFAR { + using namespace Deployment; + using namespace GCF::Common; namespace APLCommon { typedef struct cntlrDefinition { char* cntlrName; + char* parsetName; bool shared; } cntlrDefinition_t; static cntlrDefinition_t controllerTable[] = { - { "", false }, - { "MACScheduler", false }, - { "ObservationControl", false }, - { "BeamDirectionControl", true }, - { "RingControl", true }, - { "StationControl", false }, - { "DigitalBoardControl", false }, - { "BeamControl", true }, - { "CalibrationControl", true }, - { "StationInfraControl", true }, - { "", false } + { "", "", false }, + { "MACScheduler", "MACScheduler", false }, + { "ObservationControl", "ObsCtrl", false }, + { "BeamDirectionControl", "BeamDirCtrl", true }, + { "RingControl", "RingCtrl", true }, + { "StationControl", "StationCtrl", false }, + { "DigitalBoardControl", "DigBoardCtrl", false }, + { "BeamControl", "BeamCtrl", true }, + { "CalibrationControl", "CalCtrl", true }, + { "StationInfraControl", "StsInfraCtrl", true }, + { "", "", false } }; // Construct a uniq controllername from the controllerType, the instanceNr @@ -66,6 +75,15 @@ string controllerName (uint16 cntlrType, instanceNr, ObservationNr)); } +// Convert a controller type to the coresponding node in the OTDB. +string parsetNodeName (uint16 cntlrType) +{ + ASSERTSTR (cntlrType != CNTLRTYPE_NO_TYPE && cntlrType < CNTLRTYPE_NR_TYPES, + "No controller defined with type: " << cntlrType); + + return (controllerTable[cntlrType].parsetName); +} + // Convert the 'non-shared controllername' to the 'shared controller' name. string sharedControllerName (const string& controllerName) { @@ -127,6 +145,51 @@ int32 getControllerType (const string& controllerName) return (CNTLRTYPE_NO_TYPE); } +// +// createPropertySetName(propSetMask) +// +// A PropSetMask may contain the markers: +// @ring@ +// @arm@ +// @station@ +// @instance@ +// @observation@ +// +string createPropertySetName(const string& propSetMask, + const string& controllerName) +{ + string psName(propSetMask); // editable copy + uint pos; + if ((pos = psName.find("@ring@")) != string::npos) { + psName.replace(pos, 6, string("ring")+lexical_cast<string>(stationRingNr())); + } + if ((pos = psName.find("@arm@")) != string::npos) { + psName.replace(pos, 5, string("arm")+lexical_cast<string>(stationArmNr())); + } + if ((pos = psName.find("@station@")) != string::npos) { + psName.replace(pos, 9, myHostname(false)); + } + if ((pos = psName.find("@instance@")) != string::npos) { + uint16 instanceNr = getInstanceNr(controllerName); + if (instanceNr) { + psName.replace(pos, 10, lexical_cast<string>(instanceNr)); + } + else { + psName.replace(pos, 10, ""); + } + } + if ((pos = psName.find("@observation@")) != string::npos) { + psName.replace(pos, 13, string("Observation") + + lexical_cast<string>(getObservationNr(controllerName))); + } + + return (psName); +} + + + + + } // namespace APLCommon } // namespace LOFAR diff --git a/MAC/APL/APLCommon/src/Observation.cc b/MAC/APL/APLCommon/src/Observation.cc index 1b80558a6fa400a74a5abed87241846a3fbb6ed7..5be0563c8a8887f9b68dce1865cf29043afc3ede 100644 --- a/MAC/APL/APLCommon/src/Observation.cc +++ b/MAC/APL/APLCommon/src/Observation.cc @@ -51,7 +51,7 @@ Observation::Observation(ACC::APS::ParameterSet* aParSet) : sampleClock(0) { // analyse ParameterSet. - string prefix = ACC::APS::moduleName(aParSet->locateKey("Observation")); + string prefix = ACC::APS::moduleName(aParSet->locateModule("Observation")); if (aParSet->isDefined(prefix+"name")) { name = aParSet->getTime(prefix+"name"); } diff --git a/MAC/APL/APLCommon/src/ParentControl.cc b/MAC/APL/APLCommon/src/ParentControl.cc index 76e6113baf2bb2c158524ab17cf17734f87feeeb..d5551fe916005c801f4e359c62a9fda911a9a120 100644 --- a/MAC/APL/APLCommon/src/ParentControl.cc +++ b/MAC/APL/APLCommon/src/ParentControl.cc @@ -25,7 +25,7 @@ //# Includes #include <Common/LofarLogger.h> -#include <Common/Deployment.h> +#include <Deployment/StationInfo.h> #include <APS/ParameterSet.h> #include <GCF/GCF_ServiceInfo.h> #include <GCF/Utils.h> @@ -35,7 +35,9 @@ #include <StartDaemon_Protocol.ph> namespace LOFAR { + using namespace Deployment; using namespace GCF::TM; + using namespace GCF::Common; using namespace ACC::APS; namespace APLCommon {