diff --git a/MAC/APL/APLCommon/include/APL/APLCommon/ControllerDefines.h b/MAC/APL/APLCommon/include/APL/APLCommon/ControllerDefines.h index 19d3ff796494d768136a4b7df604b56a23cf46d3..73a08392f61014d9e23345926d9e04d51ae196fb 100644 --- a/MAC/APL/APLCommon/include/APL/APLCommon/ControllerDefines.h +++ b/MAC/APL/APLCommon/include/APL/APLCommon/ControllerDefines.h @@ -68,9 +68,10 @@ enum { // of the controller and the observationID. // Note: the returned name is always the 'non-shared' name. To get the 'shared' // name passed the result to 'sharedControllerName') -string controllerName (uint16 cntlrType, - uint16 instanceNr, - uint32 ObservationNr); +string controllerName (uint16 cntlrType, + uint16 instanceNr, + uint32 ObservationNr, + const string& hostname = ""); // Convert a controller type to the coresponding node in the OTDB. string parsetNodeName (uint16 cntlrType); diff --git a/MAC/APL/APLCommon/src/ControllerDefines.cc b/MAC/APL/APLCommon/src/ControllerDefines.cc index 2ce8d9db620ee6b655c840625e987621ed423d28..cab02c1ad71cb363c65fe9dd31ed6f15cd1208b5 100644 --- a/MAC/APL/APLCommon/src/ControllerDefines.cc +++ b/MAC/APL/APLCommon/src/ControllerDefines.cc @@ -70,19 +70,27 @@ static cntlrDefinition_t controllerTable[] = { // of the controller and the observationID. // Note: the returned name is always the 'non-shared' name. To get the 'shared' // name passed the result to 'sharedControllerName') -string controllerName (uint16 cntlrType, - uint16 instanceNr, - uint32 ObservationNr) +string controllerName (uint16 cntlrType, + uint16 instanceNr, + uint32 ObservationNr, + const string& hostname) { ASSERTSTR (cntlrType != CNTLRTYPE_NO_TYPE && cntlrType < CNTLRTYPE_NR_TYPES, "No controller defined with type: " << cntlrType); + string theHostname(hostname); + if (theHostname.empty()) { + theHostname = myHostname(false); + } + if (ObservationNr == 0) { // used when starting up shared controllers - return (controllerTable[cntlrType].cntlrName); + return (formatString("%s:%s", theHostname.c_str(), + controllerTable[cntlrType].cntlrName)); } - return (formatString("%s[%d]{%d}", controllerTable[cntlrType].cntlrName, - instanceNr, ObservationNr)); + return (formatString("%s:%s[%d]{%d}", theHostname.c_str(), + controllerTable[cntlrType].cntlrName, + instanceNr, ObservationNr)); } // Convert a controller type to the coresponding node in the OTDB. @@ -105,7 +113,9 @@ string sharedControllerName (const string& controllerName) // uint32 observationNr = getObservationNr (controllerName); // return (formatString("%s{%d}", controllerTable[cntlrType].cntlrName, // observationNr)); - return (controllerTable[cntlrType].cntlrName); + string cntlrName(controllerName); // destroyable copy. + rtrim(cntlrName, "[]{}0123456789"); + return (cntlrName); } // Return name of the executable @@ -145,6 +155,11 @@ int32 getControllerType (const string& controllerName) { string cntlrName(controllerName); // destroyable copy rtrim(cntlrName, "[]{}0123456789"); // cut down to executable name + uint pos; + if ((pos = cntlrName.find(":")) != string::npos) { // strip off hostname + cntlrName.erase(0, pos+1); + } + // first try on controllername uint32 idx = CNTLRTYPE_NO_TYPE + 1; while (idx < CNTLRTYPE_NR_TYPES) { @@ -181,10 +196,11 @@ string createPropertySetName(const string& propSetMask, { string psName(propSetMask); // editable copy uint pos; - // when name contains @station@ cut of everything before and replace it with - // stationname+: -> LOFAR_PIC_@ring@_@station@_CalCtrl_xxx --> CS010:CalCtrl_xxx - if ((pos = psName.find("@station@_")) != string::npos) { - psName.replace(0, pos+10, PVSSDatabaseName() + ":"); + // when name contains @ring@_@station@ cut out this marker and prepend hostname + // stationname+: -> LOFAR_ObsSW_@ring@_@station@_CalCtrl_xxx --> CS010:LOFAR_ObsSW_CalCtrl_xxx + if ((pos = psName.find("@ring@_@station@_")) != string::npos) { + psName.erase(pos, 17); + psName = myHostname(false) + ":" + psName; } if ((pos = psName.find("@ring@")) != string::npos) { diff --git a/MAC/APL/APLCommon/test/tControllerDefines.cc b/MAC/APL/APLCommon/test/tControllerDefines.cc index a4fdb8774d8d9c5bb34649a042473c5a27956eba..7cf008b45c72ecd912ebb28689075b3ecdb2cbc8 100644 --- a/MAC/APL/APLCommon/test/tControllerDefines.cc +++ b/MAC/APL/APLCommon/test/tControllerDefines.cc @@ -32,6 +32,7 @@ using namespace LOFAR; using namespace LOFAR::APLCommon; using namespace LOFAR::Deployment; +using namespace LOFAR::GCF::Common; int main (int argc, char* argv[]) { @@ -40,16 +41,20 @@ int main (int argc, char* argv[]) uint16 cntlrType(CNTLRTYPE_STATIONCTRL); uint16 instanceNr(8); uint32 obsNr(123); + string hostname(myHostname(false)); string cntlrName = controllerName(cntlrType, instanceNr, obsNr); LOG_INFO_STR("Controllername = " << cntlrName); - ASSERTSTR (cntlrName == "StationControl[8]{123}", - "Expecting cntlrName 'StationControl[8]{123}' in stead of " << cntlrName); + ASSERTSTR (cntlrName == hostname+":StationControl[8]{123}", + "Expecting cntlrName '" << hostname << + ":StationControl[8]{123}' in stead of " << cntlrName); + string sharedName = sharedControllerName(cntlrName); LOG_INFO_STR("SharedName = " << sharedName); - ASSERTSTR (sharedName == "StationControl", - "Expecting sharedName 'StationControl' in stead of " << sharedName); + ASSERTSTR (sharedName == hostname+":StationControl", + "Expecting sharedName '" << hostname << ":StationControl' in stead of " + << sharedName); string execName = getExecutable(cntlrType); LOG_INFO_STR("Executable = " << execName);