From 60f25915ba6b72dbe062082e782d09ce260dc76f Mon Sep 17 00:00:00 2001
From: Arthur Coolen <coolen@astron.nl>
Date: Fri, 22 May 2009 11:48:52 +0000
Subject: [PATCH] Bug756: check directory for conffiles. solved bug in
 claimManager.ctl: new name wasn't filled in strObjectNames

---
 MAC/Navigator2/panels/Test/Event_Viewer.pnl   | 26 +++++++++----------
 MAC/Navigator2/scripts/libs/claimManager.ctl  | 11 ++++++++
 .../scripts/readStationBGPconnections.ctl     | 13 ++++++++--
 MAC/Navigator2/scripts/readStationConfigs.ctl | 13 ++++++++--
 4 files changed, 46 insertions(+), 17 deletions(-)

diff --git a/MAC/Navigator2/panels/Test/Event_Viewer.pnl b/MAC/Navigator2/panels/Test/Event_Viewer.pnl
index 805b2c92dfc..c3ed8e399a5 100644
--- a/MAC/Navigator2/panels/Test/Event_Viewer.pnl
+++ b/MAC/Navigator2/panels/Test/Event_Viewer.pnl
@@ -1277,40 +1277,40 @@ LANG:1 5 claim
   int status = dpWaitForValue( dpNamesWait, conditions, dpNamesReturn, returnValues, 25 );
   
   if ( status == -1 ) {
-		LOG_DEBUG( \"Error in dpWaitFor Value\" );
+		LOG_DEBUG( \"Event_Viewer.pnl:Error in dpWaitFor Value\" );
 
-		LOG_DEBUG( \"dpNamesWait : \" + dpNamesWait );
+		LOG_DEBUG( \"Event_Viewer.pnl:dpNamesWait : \" + dpNamesWait );
 
-		LOG_DEBUG( \"conditions : \" + conditions );
+		LOG_DEBUG( \"Event_Viewer.pnl:conditions : \" + conditions );
 
-		LOG_DEBUG( \"dpNamesReturn : \" + dpNamesReturn );
+		LOG_DEBUG( \"Event_Viewer.pnl:dpNamesReturn : \" + dpNamesReturn );
 
 		LOG_DEBUG( \"returnValues : \" + returnValues );
 	} else if ( dynlen(getLastError()) != 0 ) {
 
-		LOG_DEBUG( \"Error returned in message dpWaitForValue\" );
+		LOG_DEBUG( \"Event_Viewer.pnl:Error returned in message dpWaitForValue\" );
 
 		// Reaction: e.g. output
 
 		LOG_DEBUG( getLastError() );
 
-		LOG_DEBUG( \"dpNamesWait : \" + dpNamesWait );
+		LOG_DEBUG( \"Event_Viewer.pnl:dpNamesWait : \" + dpNamesWait );
 
-		LOG_DEBUG( \"conditions : \" + conditions );
+		LOG_DEBUG( \"Event_Viewer.pnl:conditions : \" + conditions );
 
 		LOG_DEBUG( \"dpNamesReturn : \" + dpNamesReturn );
 
-		LOG_DEBUG( \"returnValues : \" + returnValues );
+		LOG_DEBUG( \"Event_Viewer.pnl:returnValues : \" + returnValues );
 	} else {
-		LOG_DEBUG( \"dpWaitForValue : everything ok\" );
+		LOG_DEBUG( \"Event_Viewer.pnl:dpWaitForValue : everything ok\" );
 
-		LOG_DEBUG( \"dpNamesWait : \" + dpNamesWait );
+		LOG_DEBUG( \"Event_Viewer.pnl:dpNamesWait : \" + dpNamesWait );
 
-		LOG_DEBUG( \"conditions : \" + conditions );
+		LOG_DEBUG( \"Event_Viewer.pnl:conditions : \" + conditions );
 
-		LOG_DEBUG( \"dpNamesReturn : \" + dpNamesReturn );
+		LOG_DEBUG( \"Event_Viewer.pnl:dpNamesReturn : \" + dpNamesReturn );
 
-		LOG_DEBUG( \"returnValues : \" + returnValues );
+		LOG_DEBUG( \"Event_Viewer.pnl:returnValues : \" + returnValues );
        
     LOG_DEBUG(\"Set txt_response to: \"+ returnValues[3]);
     setValue(\"txt_response\",\"text\",returnValues[3]);
diff --git a/MAC/Navigator2/scripts/libs/claimManager.ctl b/MAC/Navigator2/scripts/libs/claimManager.ctl
index 9d4e4dac8e2..de97b5dd57e 100644
--- a/MAC/Navigator2/scripts/libs/claimManager.ctl
+++ b/MAC/Navigator2/scripts/libs/claimManager.ctl
@@ -154,12 +154,19 @@ void claimManager_queryConnectClaim_Callback(
     strName    = aResult[t][2];
     tClaimDate = aResult[t][3];
     
+    LOG_DEBUG("claimManager.ctl:claimManager_queryConnectClaim_Callback| strDP     : "+ strDP);
+    LOG_DEBUG("claimManager.ctl:claimManager_queryConnectClaim_Callback| strName   : "+strName);
+    LOG_DEBUG("claimManager.ctl:claimManager_queryConnectClaim_Callback| tClaimDate: "+tClaimDate);
+    
     // We are claimed when the date is not 1970
     bClaimed = year( tClaimDate ) != 1970;
   
     // Do we already have this name 
     iPos = dynContains( strClaimDPName, strDP );  
     
+    LOG_DEBUG("claimManager.ctl:claimManager_queryConnectClaim_Callback| found old claim at postion: "+ iPos);
+
+    
     // When we have the claim, and the datapoint is now 'not claimed'
     // then 
     if( !bClaimed && (iPos > 0))
@@ -174,6 +181,10 @@ void claimManager_queryConnectClaim_Callback(
     {
       dynAppend(  strClaimDPName     , strDP   );
       dynAppend(  strClaimObjectName , strName );
+    } else if( bClaimed && (iPos > 0 )) {
+      // When we do have the item and it gets 'Claimed'
+      // then we have to alter the 
+      strClaimObjectName[iPos] = strName;
     }
   }  
 }
diff --git a/MAC/Navigator2/scripts/readStationBGPconnections.ctl b/MAC/Navigator2/scripts/readStationBGPconnections.ctl
index f53f93766ee..ac7b89a2fab 100644
--- a/MAC/Navigator2/scripts/readStationBGPconnections.ctl
+++ b/MAC/Navigator2/scripts/readStationBGPconnections.ctl
@@ -50,8 +50,17 @@ main()
   bool showDebug = true;
        
   string strCurConfig;
-//  string strDataDir             = "/opt/lofar/etc/";
-  string strDataDir               = "c:/data/CS20_CCU001/data/configs/";
+  string strDataDir     = "";
+  string strDataDir             = ""; 
+  if (isDir("/opt/lofar/etc/") ) {
+    strDataDir = "/opt/lofar/etc/";
+  } else if ( isDir ("c:/data/CS20_CS010/data/configs/") ) {
+    strDataDir = "c:/data/CS20_CS010/data/configs/";
+  } else {
+    DebugN("Could not find datadair to work with, leaving and no antenne data read.");
+    return;
+  }
+  
   string strConfFile    = strDataDir+"StationBGPconnections.conf";
 
   dyn_string dynStr_fileContent;
diff --git a/MAC/Navigator2/scripts/readStationConfigs.ctl b/MAC/Navigator2/scripts/readStationConfigs.ctl
index 79a43083f2f..34acf17680d 100644
--- a/MAC/Navigator2/scripts/readStationConfigs.ctl
+++ b/MAC/Navigator2/scripts/readStationConfigs.ctl
@@ -55,8 +55,17 @@ main()
       H          = 3;                // ArrayIndexnumber of dda_splittedLinesAntConfFile;
        
   string strCurConfig;
-//  string strDataDir             = "/opt/lofar/etc/";
-  string strDataDir               = "c:/data/CS20_CS010/data/configs/";
+  
+  string strDataDir             = ""; 
+  if (isDir("/opt/lofar/etc/") ) {
+    strDataDir = "/opt/lofar/etc/";
+  } else if ( isDir ("c:/data/CS20_CS010/data/configs/") ) {
+    strDataDir = "c:/data/CS20_CS010/data/configs/";
+  } else {
+    DebugN("Could not find datadair to work with, leaving and no antenne data read.");
+    return;
+  }
+    
   string strAntArrayConfFile      = strDataDir+"AntennaArrays.conf";
   string strRemoteStationConfFile = strDataDir+"RemoteStation.conf";
 
-- 
GitLab