diff --git a/MAC/APL/CURTDBDaemons/src/SASGateway/SASGateway.cc b/MAC/APL/CURTDBDaemons/src/SASGateway/SASGateway.cc index b6f36b6ca53b6334942d3aa1a293be1313e386b2..00565381d7498b5b9847ef205877fe4930080a6e 100644 --- a/MAC/APL/CURTDBDaemons/src/SASGateway/SASGateway.cc +++ b/MAC/APL/CURTDBDaemons/src/SASGateway/SASGateway.cc @@ -59,8 +59,10 @@ SASGateway::SASGateway(const string& myName) : itsDPservice (0), itsSASservice(0), itsTimerPort (0), + dbPort(0U), itsPICtreeID (0), itsQueryID (0) + { LOG_DEBUG_STR("SASGateway(" << myName << ")"); LOG_INFO(Version::getInfo<CURTDBDaemonsVersion>("SASGateway")); @@ -74,7 +76,14 @@ SASGateway::SASGateway(const string& myName) : itsSASdbname = globalParameterSet()->getString("SASGateway.OTDBdatabase"); itsSAShostname= globalParameterSet()->getString("SASGateway.OTDBhostname"); - itsSASservice = new OTDBconnection("paulus", "boskabouter", itsSASdbname, itsSAShostname); + const std::string dbUsername( + globalParameterSet()->getString("SASGateway.OTDBusername")); + const std::string dbPassword( + globalParameterSet()->getString("SASGateway.OTDBpassword")); + const std::string dbPort( + globalParameterSet()->getString("SASGateway.OTDBport")); + itsSASservice = new OTDBconnection(dbUsername, dbPassword, itsSASdbname, + itsSAShostname, dbPort); ASSERTSTR(itsSASservice, "Can't allocate connection to SAS"); itsTimerPort = new GCFTimerPort(*this, "timerPort"); @@ -87,8 +96,8 @@ SASGateway::SASGateway(const string& myName) : SASGateway::~SASGateway() { LOG_DEBUG_STR("~SASGateway()"); - - if (itsTimerPort) { + + if (itsTimerPort) { delete itsTimerPort; } if (itsDPservice) { @@ -120,7 +129,7 @@ GCFEvent::TResult SASGateway::connect2SAS(GCFEvent& event, GCFPortInterface& por case F_INIT: case F_TIMER: { // Connect to the SAS database - LOG_INFO(formatString("Trying to connect to SAS database %s@%s", + LOG_INFO(formatString("Trying to connect to SAS database %s@%s", itsSASdbname.c_str(), itsSAShostname.c_str())); itsSASservice->connect(); if (!itsSASservice->isConnected()) { @@ -133,12 +142,12 @@ GCFEvent::TResult SASGateway::connect2SAS(GCFEvent& event, GCFPortInterface& por LOG_INFO("Connection to SAS database succesfull, getting info about instrument"); ClassifConv CTconv(itsSASservice); TreeTypeConv TTconv(itsSASservice); - vector<OTDBtree> treeList = + vector<OTDBtree> treeList = itsSASservice->getTreeList(TTconv.get("hardware"), CTconv.get("operational")); - ASSERTSTR(treeList.size() == 1, "Expected 1 hardware tree in SAS, database error=" + ASSERTSTR(treeList.size() == 1, "Expected 1 hardware tree in SAS, database error=" << itsSASservice->errorMsg()); itsPICtreeID = treeList[0].treeID(); - LOG_INFO(formatString("Using PICtree %d (%s)", + LOG_INFO(formatString("Using PICtree %d (%s)", itsPICtreeID, to_simple_string(treeList[0].starttime).c_str())); // SAS part seems OK, continue with PVSS part. @@ -217,7 +226,7 @@ GCFEvent::TResult SASGateway::connect2PVSS(GCFEvent& event, GCFPortInterface& po // // operational(event, port) // -GCFEvent::TResult SASGateway::operational(GCFEvent& event, +GCFEvent::TResult SASGateway::operational(GCFEvent& event, GCFPortInterface& port) { LOG_DEBUG_STR("operational:" << eventName(event) << "@" << port.getName()); @@ -255,7 +264,7 @@ void SASGateway::_handleQueryEvent(GCFEvent& event) if (!itsQueryID) { itsQueryID = DPevent.QryID; } - + if (DPevent.result != PVSS::SA_NO_ERROR) { LOG_ERROR_STR("PVSS reported error " << DPevent.result << " for query " << itsQueryID); return;