Skip to content
Snippets Groups Projects
Commit 4fb52c51 authored by Ruud Overeem's avatar Ruud Overeem
Browse files

BugID: 679

Added hostname to controllername.
parent 66621b9b
Branches
Tags
No related merge requests found
...@@ -68,9 +68,10 @@ enum { ...@@ -68,9 +68,10 @@ enum {
// of the controller and the observationID. // of the controller and the observationID.
// Note: the returned name is always the 'non-shared' name. To get the 'shared' // Note: the returned name is always the 'non-shared' name. To get the 'shared'
// name passed the result to 'sharedControllerName') // name passed the result to 'sharedControllerName')
string controllerName (uint16 cntlrType, string controllerName (uint16 cntlrType,
uint16 instanceNr, uint16 instanceNr,
uint32 ObservationNr); uint32 ObservationNr,
const string& hostname = "");
// Convert a controller type to the coresponding node in the OTDB. // Convert a controller type to the coresponding node in the OTDB.
string parsetNodeName (uint16 cntlrType); string parsetNodeName (uint16 cntlrType);
......
...@@ -70,19 +70,27 @@ static cntlrDefinition_t controllerTable[] = { ...@@ -70,19 +70,27 @@ static cntlrDefinition_t controllerTable[] = {
// of the controller and the observationID. // of the controller and the observationID.
// Note: the returned name is always the 'non-shared' name. To get the 'shared' // Note: the returned name is always the 'non-shared' name. To get the 'shared'
// name passed the result to 'sharedControllerName') // name passed the result to 'sharedControllerName')
string controllerName (uint16 cntlrType, string controllerName (uint16 cntlrType,
uint16 instanceNr, uint16 instanceNr,
uint32 ObservationNr) uint32 ObservationNr,
const string& hostname)
{ {
ASSERTSTR (cntlrType != CNTLRTYPE_NO_TYPE && cntlrType < CNTLRTYPE_NR_TYPES, ASSERTSTR (cntlrType != CNTLRTYPE_NO_TYPE && cntlrType < CNTLRTYPE_NR_TYPES,
"No controller defined with type: " << cntlrType); "No controller defined with type: " << cntlrType);
string theHostname(hostname);
if (theHostname.empty()) {
theHostname = myHostname(false);
}
if (ObservationNr == 0) { // used when starting up shared controllers 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, return (formatString("%s:%s[%d]{%d}", theHostname.c_str(),
instanceNr, ObservationNr)); controllerTable[cntlrType].cntlrName,
instanceNr, ObservationNr));
} }
// Convert a controller type to the coresponding node in the OTDB. // Convert a controller type to the coresponding node in the OTDB.
...@@ -105,7 +113,9 @@ string sharedControllerName (const string& controllerName) ...@@ -105,7 +113,9 @@ string sharedControllerName (const string& controllerName)
// uint32 observationNr = getObservationNr (controllerName); // uint32 observationNr = getObservationNr (controllerName);
// return (formatString("%s{%d}", controllerTable[cntlrType].cntlrName, // return (formatString("%s{%d}", controllerTable[cntlrType].cntlrName,
// observationNr)); // observationNr));
return (controllerTable[cntlrType].cntlrName); string cntlrName(controllerName); // destroyable copy.
rtrim(cntlrName, "[]{}0123456789");
return (cntlrName);
} }
// Return name of the executable // Return name of the executable
...@@ -145,6 +155,11 @@ int32 getControllerType (const string& controllerName) ...@@ -145,6 +155,11 @@ int32 getControllerType (const string& controllerName)
{ {
string cntlrName(controllerName); // destroyable copy string cntlrName(controllerName); // destroyable copy
rtrim(cntlrName, "[]{}0123456789"); // cut down to executable name 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 // first try on controllername
uint32 idx = CNTLRTYPE_NO_TYPE + 1; uint32 idx = CNTLRTYPE_NO_TYPE + 1;
while (idx < CNTLRTYPE_NR_TYPES) { while (idx < CNTLRTYPE_NR_TYPES) {
...@@ -181,10 +196,11 @@ string createPropertySetName(const string& propSetMask, ...@@ -181,10 +196,11 @@ string createPropertySetName(const string& propSetMask,
{ {
string psName(propSetMask); // editable copy string psName(propSetMask); // editable copy
uint pos; uint pos;
// when name contains @station@ cut of everything before and replace it with // when name contains @ring@_@station@ cut out this marker and prepend hostname
// stationname+: -> LOFAR_PIC_@ring@_@station@_CalCtrl_xxx --> CS010:CalCtrl_xxx // stationname+: -> LOFAR_ObsSW_@ring@_@station@_CalCtrl_xxx --> CS010:LOFAR_ObsSW_CalCtrl_xxx
if ((pos = psName.find("@station@_")) != string::npos) { if ((pos = psName.find("@ring@_@station@_")) != string::npos) {
psName.replace(0, pos+10, PVSSDatabaseName() + ":"); psName.erase(pos, 17);
psName = myHostname(false) + ":" + psName;
} }
if ((pos = psName.find("@ring@")) != string::npos) { if ((pos = psName.find("@ring@")) != string::npos) {
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
using namespace LOFAR; using namespace LOFAR;
using namespace LOFAR::APLCommon; using namespace LOFAR::APLCommon;
using namespace LOFAR::Deployment; using namespace LOFAR::Deployment;
using namespace LOFAR::GCF::Common;
int main (int argc, char* argv[]) int main (int argc, char* argv[])
{ {
...@@ -40,16 +41,20 @@ int main (int argc, char* argv[]) ...@@ -40,16 +41,20 @@ int main (int argc, char* argv[])
uint16 cntlrType(CNTLRTYPE_STATIONCTRL); uint16 cntlrType(CNTLRTYPE_STATIONCTRL);
uint16 instanceNr(8); uint16 instanceNr(8);
uint32 obsNr(123); uint32 obsNr(123);
string hostname(myHostname(false));
string cntlrName = controllerName(cntlrType, instanceNr, obsNr); string cntlrName = controllerName(cntlrType, instanceNr, obsNr);
LOG_INFO_STR("Controllername = " << cntlrName); LOG_INFO_STR("Controllername = " << cntlrName);
ASSERTSTR (cntlrName == "StationControl[8]{123}", ASSERTSTR (cntlrName == hostname+":StationControl[8]{123}",
"Expecting cntlrName 'StationControl[8]{123}' in stead of " << cntlrName); "Expecting cntlrName '" << hostname <<
":StationControl[8]{123}' in stead of " << cntlrName);
string sharedName = sharedControllerName(cntlrName); string sharedName = sharedControllerName(cntlrName);
LOG_INFO_STR("SharedName = " << sharedName); LOG_INFO_STR("SharedName = " << sharedName);
ASSERTSTR (sharedName == "StationControl", ASSERTSTR (sharedName == hostname+":StationControl",
"Expecting sharedName 'StationControl' in stead of " << sharedName); "Expecting sharedName '" << hostname << ":StationControl' in stead of "
<< sharedName);
string execName = getExecutable(cntlrType); string execName = getExecutable(cntlrType);
LOG_INFO_STR("Executable = " << execName); LOG_INFO_STR("Executable = " << execName);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment