From d8fcc8e4bd7b80b55cdab6fa6cfedd009fa00e3b Mon Sep 17 00:00:00 2001
From: Arthur Coolen <coolen@astron.nl>
Date: Thu, 10 Mar 2011 13:55:47 +0000
Subject: [PATCH] Bug1365: ran into init issues, so implemented a better way to
 force the right initialization sequence

---
 .gitattributes                                |   1 +
 .../panels/Reports/LOFAR_Reports_main.pnl     |  73 +++++
 .../panels/Reports/LOFAR_System.pnl           |  18 +-
 .../panels/objects/navigator_progressBar.pnl  |  54 ++--
 MAC/Navigator2/scripts/libs/GCFAlarm.ctl      |   5 +
 MAC/Navigator2/scripts/libs/GCFCWD.ctl        | 280 ++++++++---------
 MAC/Navigator2/scripts/libs/claimManager.ctl  |  19 +-
 MAC/Navigator2/scripts/libs/navConfig.ctl     | 282 +++++++++---------
 MAC/Navigator2/scripts/libs/navFunct.ctl      |   9 +-
 MAC/Navigator2/scripts/libs/navigator.ctl     |  51 +++-
 10 files changed, 471 insertions(+), 321 deletions(-)
 create mode 100644 MAC/Navigator2/panels/Reports/LOFAR_Reports_main.pnl

diff --git a/.gitattributes b/.gitattributes
index 60e88cb4cfd..068a1598964 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1740,6 +1740,7 @@ MAC/Navigator2/panels/Processes/Station_Processes.pnl -text
 MAC/Navigator2/panels/Processes/StorageAppl.pnl -text
 MAC/Navigator2/panels/Processes/TBBControl.pnl -text
 MAC/Navigator2/panels/Processes/TBBDriver.pnl -text
+MAC/Navigator2/panels/Reports/LOFAR_Reports_main.pnl -text
 MAC/Navigator2/panels/Reports/LOFAR_System.pnl -text
 MAC/Navigator2/panels/Test/Event_Viewer.pnl -text
 MAC/Navigator2/panels/Test/stringTest.pnl -text
diff --git a/MAC/Navigator2/panels/Reports/LOFAR_Reports_main.pnl b/MAC/Navigator2/panels/Reports/LOFAR_Reports_main.pnl
new file mode 100644
index 00000000000..e7a5c6bb178
--- /dev/null
+++ b/MAC/Navigator2/panels/Reports/LOFAR_Reports_main.pnl
@@ -0,0 +1,73 @@
+V 10
+1
+LANG:1 0 
+PANEL,-1 -1 1097 709 N "_3DFace" 0
+E E E E E 1 -1 -1 0  30 40
+""0  1
+E E 2
+"CBRef" "1"
+"EClose" E
+""
+DISPLAY_LAYER, 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0
+LAYER, 0 
+1
+LANG:1 0 
+28 0
+"TAB1"
+""
+1 0 0 E E E 1 E 1 E N "_3DText" E N "_3DFace" E E
+ E E
+0 0 0 0 0 0
+E E E
+0
+1
+LANG:1 0 
+
+0
+1
+LANG:1 98 -*-MS Shell Dlg-*-r-normal-*-11-*-100-100-*-*-iso8859-1|-11,0,0,0,505,0,0,0,0,0,0,0,0,MS Shell Dlg
+0 ""
+ -2 -2 1082 692
+E2 "Systems" 1
+LANG:1 7 Systems
+1 "Reports/LOFAR_System.pnl" 1
+LANG:1 0 
+0
+
+"Query" 1
+LANG:1 5 Query
+1 "Reports/LOFAR_Query.pnl" 1
+LANG:1 0 
+0
+
+
+0
+LAYER, 1 
+1
+LANG:1 0 
+0
+LAYER, 2 
+1
+LANG:1 0 
+0
+LAYER, 3 
+1
+LANG:1 0 
+0
+LAYER, 4 
+1
+LANG:1 0 
+0
+LAYER, 5 
+1
+LANG:1 0 
+0
+LAYER, 6 
+1
+LANG:1 0 
+0
+LAYER, 7 
+1
+LANG:1 0 
+0
+0
\ No newline at end of file
diff --git a/MAC/Navigator2/panels/Reports/LOFAR_System.pnl b/MAC/Navigator2/panels/Reports/LOFAR_System.pnl
index 831d80ee2c3..af9c63af3c4 100644
--- a/MAC/Navigator2/panels/Reports/LOFAR_System.pnl
+++ b/MAC/Navigator2/panels/Reports/LOFAR_System.pnl
@@ -2,15 +2,8 @@ V 10
 2
 LANG:1 15 System overview
 LANG:0 15 Systemübersicht
-PANEL,-1 -1 1006 645 N "_3DFace" 0
-"dyn_string  dsRegisterdPanels;
-bool bShowOnlyOneSystem;
-time tRemoveDouble;
-dyn_int diShownSystems;
-dyn_int diAllredyAddedSystems ;
-
-
-main()
+PANEL,-1 -1 1060 699 N "_3DFace" 0
+"main()
 {
   // Initialise the Panel
   navPanel_initPanel(\"fw_viewBox\");
@@ -316,6 +309,13 @@ string baseDP=\"\";
 dyn_int gdiRegisterdSystems;
 dyn_string gdiSystemIds;
 bool bBlock;
+
+dyn_string  dsRegisterdPanels;
+bool bShowOnlyOneSystem;
+time tRemoveDouble;
+dyn_int diShownSystems;
+dyn_int diAllredyAddedSystems ;
+
 " 0
  3
 "CBRef" "0"
diff --git a/MAC/Navigator2/panels/objects/navigator_progressBar.pnl b/MAC/Navigator2/panels/objects/navigator_progressBar.pnl
index f40445e2d6e..ba2e7523ff2 100644
--- a/MAC/Navigator2/panels/objects/navigator_progressBar.pnl
+++ b/MAC/Navigator2/panels/objects/navigator_progressBar.pnl
@@ -1,9 +1,8 @@
 V 10
 1
 LANG:1 8 (NoName)
-PANEL,-1 -1 638 97 N "_3DFace" 2
+PANEL,-1 -1 638 97 N "_3DFace" 1
 "$name"
-"$progressBarDPE"
 "main()
 {
     //delay while navigator instance is being prepared, shouldn't be needed, but this way we at least have a trigger when something goes wrong
@@ -18,10 +17,12 @@ PANEL,-1 -1 638 97 N "_3DFace" 2
   }
   // Check if Action point exists and connect to it if
   // it does. The action Point is the call back for this object
-  itsActionDp    = DPNAME_NAVIGATOR + g_navigatorID + \".\"+$name+\".action\";
-  itsEventDp     = DPNAME_NAVIGATOR + g_navigatorID + \".\"+$name+\".event\";
-  itsSelectionDp = DPNAME_NAVIGATOR + g_navigatorID + \".\"+$name+\".selection\";
+  itsActionDp      = DPNAME_NAVIGATOR + g_navigatorID + \".\"+$name+\".action\";
+  itsEventDp       = DPNAME_NAVIGATOR + g_navigatorID + \".\"+$name+\".event\";
+  itsSelectionDp   = DPNAME_NAVIGATOR + g_navigatorID + \".\"+$name+\".selection\";
 	
+  itsProgressBarDp = DPNAME_NAVIGATOR + g_navigatorID + \".progress\";
+
   if ( dpExists(itsActionDp) ) {
     dpConnect(\"doAction\",false,itsActionDp);
     PROGRESSBARACTIONDP=itsActionDp;
@@ -32,24 +33,20 @@ PANEL,-1 -1 638 97 N "_3DFace" 2
 void initialize() {      
   LOG_TRACE(\"navigator_progressBar.pnl:initialize|entered\");
   
+  setProgressBarDPE();
 
-
-  //check if a dpe to connect to is allready available
-  if ($progressBarDPE != \"\") {
-  	setProgressBarDPE($progressBarDPE);
-  }  
   LOG_TRACE(\"navigator_progressBar.pnl:initialize|end\");
 }
 
 // connect progressbar to value to act on
-setProgressBarDPE(string dp) {
-  if (dpExists(dp+\".progressBarValue\")) {
+setProgressBarDPE() {
+  if (dpExists(itsProgressBarDp)) {
     if (connected) {
       dpDisconnect(display,dpe);
       connected=false;
     }
-    dpe = dp+\".progressBarValue:_online.._value\";
-    dpConnect(display,true,dpe);
+    dpe = itsProgressBarDp+\":_online.._value\";
+    dpConnect(\"display\",true,dpe);
     connected=true;
   }
 }
@@ -60,7 +57,7 @@ display(string dp1, int progress)
 	        \"avail32\",\"scale\",progress/100.0,1,
   		\"used31\",\"scale\",1-progress/100.0,1,
   		\"used32\",\"scale\",1-progress/100.0,1,
-  		\"RAMavail.progress\",\"text\",progress+\"%\");
+  		\"progressValue\",\"text\",progress+\"%\");
 }
 
 
@@ -85,9 +82,10 @@ void doAction(string aDP, string anAction) {
  E E E E 1 0 0 0  210 10
 ""0  1
 E "//Global mainpoint holders
-string 			itsActionDp    = \"\";
-string 			itsEventDp     = \"\";
-dyn_string 	        itsSelectionDp = \"\";
+string 	       itsActionDp    = \"\";
+string         itsEventDp     = \"\";
+dyn_string     itsSelectionDp = \"\";
+string         itsProgressBarDp = \"\";
 
 bool connected=false;
 string dpe;
@@ -204,6 +202,26 @@ LANG:0 0
 210 30
 210 10
  0
+2 5
+"PRIMITIVE_TEXT2"
+""
+1 190 13 E E E 1 E 1 E N "_WindowText" E N "_Transparent" E E
+ E E
+6 0 0 0 0 0
+E E E
+0
+1
+LANG:1 0 
+
+1
+"dashclr"N "_Transparent"
+E E 0 1 1 2 1 E U  1 E 190 13 199 27
+0 2 2 "0s" 0 0 0 192 0 0  190 13 1
+1
+LANG:1 101 -*-MS Shell Dlg-bold-r-normal-*-*-80-100-100-*-*-iso8859-1|-11,0,0,0,758,0,0,0,0,0,0,0,0,MS Shell Dlg
+0 ""
+1
+LANG:1 1 %
 0
 LAYER, 1 
 1
diff --git a/MAC/Navigator2/scripts/libs/GCFAlarm.ctl b/MAC/Navigator2/scripts/libs/GCFAlarm.ctl
index 97e7788c935..49d7b45c38b 100644
--- a/MAC/Navigator2/scripts/libs/GCFAlarm.ctl
+++ b/MAC/Navigator2/scripts/libs/GCFAlarm.ctl
@@ -36,6 +36,7 @@
 
 #uses "GCFLogging.ctl"
 #uses "GCFCommon.ctl"
+#uses "navigator.ctl"
 
 // Mapping where we try to keep all alarms to be able to access them faster from the panels
 global mapping    g_alarms;
@@ -103,6 +104,10 @@ void alarmSystemTriggered(string dp1, dyn_time times) {
   }  
   LOG_DEBUG("GCFAlarm.ctl:alarmSystemTriggered|Nr alarms in global after update: ", dynlen(g_alarms["TIME"]));      
   showMapping(g_alarms,"g_alarms");
+  
+  if (g_initializing) {
+    navigator_writeInitProcess("initNavigatorAlarmsFinished");
+  }
 
   
 }
diff --git a/MAC/Navigator2/scripts/libs/GCFCWD.ctl b/MAC/Navigator2/scripts/libs/GCFCWD.ctl
index 5699ff5e09a..1193c647ca0 100644
--- a/MAC/Navigator2/scripts/libs/GCFCWD.ctl
+++ b/MAC/Navigator2/scripts/libs/GCFCWD.ctl
@@ -1,138 +1,142 @@
-//# GCFWatchDog
-//#
-//#  Copyright (C) 2002-2004
-//#  ASTRON (Netherlands Foundation for Research in Astronomy)
-//#  P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl
-//#
-//#  This program is free software; you can redistribute it and/or modify
-//#  it under the terms of the GNU General Public License as published by
-//#  the Free Software Foundation; either version 2 of the License, or
-//#  (at your option) any later version.
-//#
-//#  This program is distributed in the hope that it will be useful,
-//#  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//#  GNU General Public License for more details.
-//#
-//#  You should have received a copy of the GNU General Public License
-//#  along with this program; if not, write to the Free Software
-//#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-//#
-//#  $Id:$
-
-//#
-//# Connection watchdog
-//# 
-
-// Functions:
-// Main                        - starts the watchdog and connects to the distmanager DP
-// distSystemChanged 	       - Eventhandle when a system goes on or offline
-// fillWatchDog                - helper function to fill the lists into the watchdog point  
-
-
-#uses "GCFCommon.ctl"
-
-const string CWD_DP = "__gcf_cwd";
-global mapping g_connections;
-
-
-////////////////////////////////////////////////////////////////////////////////
-//
-// Function main
-//
-// Starts the ConnectionWatchDog that monitor the (dis)connecting of systems.
-// in __gcf_cwd, 5 dynamic lists are maintained that keep track of each system
-// that is on or off line. The systemID is kept, a boolean that indicates if
-// a system is on or offline, and the last time up and last time down is kept
-// to be able to do time based restoration later.
-//
-////////////////////////////////////////////////////////////////////////////////
-GCFCWD_Init() {
-  LOG_DEBUG("GCFCWD.ctl:main|Starting GCF connection watch-dog");
-        
-  // init the mapping
-  g_connections[ "SYSTEM"   ] = makeDynInt();
-  g_connections[ "NAME"     ] = makeDynString();
-  g_connections[ "UP"       ] = makeDynBool();
-  g_connections[ "DOWNTIME" ] = makeDynTime();
-  g_connections[ "UPTIME"   ] = makeDynTime();
-  
-  // retrieve old settings
-  
-  if (dpExists(CWD_DP+".systemID")) {
-    dpConnect("GCFCWD_connectWD", TRUE, CWD_DP+".systemID",
-                                        CWD_DP+".name",
-                                        CWD_DP+".online",
-                                        CWD_DP+".lastUpTime",
-                                        CWD_DP+".lastDownTime");
-    LOG_DEBUG("GCFCWD.ctl:GCFCWD_Init|Watch-dog started");
-  } else {
-    LOG_DEBUG("GCFCWD.ctl:GCFCWD_Init|Couldn't connect to "+CWD_DP+".systemID.  Watch-dog NOT started");
-  } 
-} 
-
-////////////////////////////////////////////////////////////////////////////////
-//
-// EventHandler GCFCWD_connectWD
-//
-////////////////////////////////////////////////////////////////////////////////
-void GCFCWD_connectWD(string dp1, dyn_int systemID,
-                      string dp2, dyn_string name,
-                      string dp3, dyn_bool up,
-                      string dp4, dyn_time upTime,
-                      string dp5, dyn_time downTime) {
-  LOG_DEBUG("GCFCWD.ctl:GCFCWD_connectWD|watchdog triggered systemchange");
-  LOG_DEBUG("GCFCWD.ctl:GCFCWD_connectWD|systemID: ",systemID);	
-  LOG_DEBUG("GCFCWD.ctl:GCFCWD_connectWD|name: ",name);	
-  LOG_DEBUG("GCFCWD.ctl:GCFCWD_connectWD|up: ",up);	
-  LOG_DEBUG("GCFCWD.ctl:GCFCWD_connectWD|upTime: ",upTime);	
-  LOG_DEBUG("GCFCWD.ctl:GCFCWD_connectWD|downTime: ",downTime);	
-       
-  int  iPos;
-  // check all current systems and update mapping
-  for (int i = 1; i <= dynlen(systemID); i++) {
-    bool changed=false;
-    iPos=dynContains ( g_connections[ "SYSTEM" ],systemID[i]);
-
-    // if the system was not yet available just add
-    if (iPos < 1) {
-      dynAppend( g_connections[ "SYSTEM" ],systemID[i]);
-      iPos=dynlen(g_connections[ "SYSTEM" ]);
-    }  
-    // now store the values    
-    g_connections[ "NAME" ][iPos]     = name[i];
-    if (dynlen(g_connections["UP"])>= iPos ) {
-      if (g_connections[ "UP" ][iPos] != up[i]){
-        g_connections[ "UP" ][iPos]       = up[i];
-        changed=true;
-      }
-    } else {
-        g_connections[ "UP" ][iPos]       = up[i];
-        changed=true;
-    }
-    g_connections[ "UPTIME" ][iPos]   = upTime[i];
-    g_connections[ "DOWNTIME" ][iPos] = downTime[i];
-    
-    // we need to reflect the status of the stations up/down also in the "MainDBName+LOFAR_PIC_[Ring].status.childState
-    if (changed) {
-      // changed to up, childstate is highest childstate of all stations.state and .childStates
-      // else 
-      // changed to down, childstate will be set to dpOffline
-      if (up[i] && name[i] != "CCU001:") {
-        if (dpExists(MainDBName+"__navObjectState.DPName")) {
-            dpSet(MainDBName+"__navObjectState.DPName",MainDBName+"LOFAR_PIC_"+navFunct_getRingFromStation(name[i])+"_"+navFunct_bareDBName(name[i])+".status.state",
-                  MainDBName+"__navObjectState.stateNr",OPERATIONAL,
-                  MainDBName+"__navObjectState.message","System came online",
-                  MainDBName+"__navObjectState.force",true);
-        }        
-      } else if (name[i] != "CCU001:") {
-        if (dpExists(MainDBName+"__navObjectState.DPName")) {
-            dpSet(MainDBName+"__navObjectState.DPName",MainDBName+"LOFAR_PIC_"+navFunct_getRingFromStation(name[i])+"_"+navFunct_bareDBName(name[i])+".status.state",
-                  MainDBName+"__navObjectState.stateNr",DPOFFLINE,
-                  MainDBName+"__navObjectState.message","System went offline",
-                  MainDBName+"__navObjectState.force",false);
-        }
-      }    
-    }
-  }
-}
+//# GCFWatchDog
+//#
+//#  Copyright (C) 2002-2004
+//#  ASTRON (Netherlands Foundation for Research in Astronomy)
+//#  P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl
+//#
+//#  This program is free software; you can redistribute it and/or modify
+//#  it under the terms of the GNU General Public License as published by
+//#  the Free Software Foundation; either version 2 of the License, or
+//#  (at your option) any later version.
+//#
+//#  This program is distributed in the hope that it will be useful,
+//#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//#  GNU General Public License for more details.
+//#
+//#  You should have received a copy of the GNU General Public License
+//#  along with this program; if not, write to the Free Software
+//#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+//#
+//#  $Id:$
+
+//#
+//# Connection watchdog
+//# 
+
+// Functions:
+// Main                        - starts the watchdog and connects to the distmanager DP
+// distSystemChanged 	       - Eventhandle when a system goes on or offline
+// fillWatchDog                - helper function to fill the lists into the watchdog point  
+
+
+#uses "GCFCommon.ctl"
+#uses "navigator.ctl"
+
+const string CWD_DP = "__gcf_cwd";
+global mapping g_connections;
+
+
+////////////////////////////////////////////////////////////////////////////////
+//
+// Function main
+//
+// Starts the ConnectionWatchDog that monitor the (dis)connecting of systems.
+// in __gcf_cwd, 5 dynamic lists are maintained that keep track of each system
+// that is on or off line. The systemID is kept, a boolean that indicates if
+// a system is on or offline, and the last time up and last time down is kept
+// to be able to do time based restoration later.
+//
+////////////////////////////////////////////////////////////////////////////////
+GCFCWD_Init() {
+  LOG_DEBUG("GCFCWD.ctl:main|Starting GCF connection watch-dog");
+        
+  // init the mapping
+  g_connections[ "SYSTEM"   ] = makeDynInt();
+  g_connections[ "NAME"     ] = makeDynString();
+  g_connections[ "UP"       ] = makeDynBool();
+  g_connections[ "DOWNTIME" ] = makeDynTime();
+  g_connections[ "UPTIME"   ] = makeDynTime();
+  
+  // retrieve old settings
+  
+  if (dpExists(CWD_DP+".systemID")) {
+    dpConnect("GCFCWD_connectWD", TRUE, CWD_DP+".systemID",
+                                        CWD_DP+".name",
+                                        CWD_DP+".online",
+                                        CWD_DP+".lastUpTime",
+                                        CWD_DP+".lastDownTime");
+    LOG_DEBUG("GCFCWD.ctl:GCFCWD_Init|Watch-dog started");
+  } else {
+    LOG_DEBUG("GCFCWD.ctl:GCFCWD_Init|Couldn't connect to "+CWD_DP+".systemID.  Watch-dog NOT started");
+  } 
+} 
+
+////////////////////////////////////////////////////////////////////////////////
+//
+// EventHandler GCFCWD_connectWD
+//
+////////////////////////////////////////////////////////////////////////////////
+void GCFCWD_connectWD(string dp1, dyn_int systemID,
+                      string dp2, dyn_string name,
+                      string dp3, dyn_bool up,
+                      string dp4, dyn_time upTime,
+                      string dp5, dyn_time downTime) {
+  LOG_DEBUG("GCFCWD.ctl:GCFCWD_connectWD|watchdog triggered systemchange");
+  LOG_DEBUG("GCFCWD.ctl:GCFCWD_connectWD|systemID: ",systemID);	
+  LOG_DEBUG("GCFCWD.ctl:GCFCWD_connectWD|name: ",name);	
+  LOG_DEBUG("GCFCWD.ctl:GCFCWD_connectWD|up: ",up);	
+  LOG_DEBUG("GCFCWD.ctl:GCFCWD_connectWD|upTime: ",upTime);	
+  LOG_DEBUG("GCFCWD.ctl:GCFCWD_connectWD|downTime: ",downTime);	
+       
+  int  iPos;
+  // check all current systems and update mapping
+  for (int i = 1; i <= dynlen(systemID); i++) {
+    bool changed=false;
+    iPos=dynContains ( g_connections[ "SYSTEM" ],systemID[i]);
+
+    // if the system was not yet available just add
+    if (iPos < 1) {
+      dynAppend( g_connections[ "SYSTEM" ],systemID[i]);
+      iPos=dynlen(g_connections[ "SYSTEM" ]);
+    }  
+    // now store the values    
+    g_connections[ "NAME" ][iPos]     = name[i];
+    if (dynlen(g_connections["UP"])>= iPos ) {
+      if (g_connections[ "UP" ][iPos] != up[i]){
+        g_connections[ "UP" ][iPos]       = up[i];
+        changed=true;
+      }
+    } else {
+        g_connections[ "UP" ][iPos]       = up[i];
+        changed=true;
+    }
+    g_connections[ "UPTIME" ][iPos]   = upTime[i];
+    g_connections[ "DOWNTIME" ][iPos] = downTime[i];
+    
+    // we need to reflect the status of the stations up/down also in the "MainDBName+LOFAR_PIC_[Ring].status.childState
+    if (changed) {
+      // changed to up, childstate is highest childstate of all stations.state and .childStates
+      // else 
+      // changed to down, childstate will be set to dpOffline
+      if (up[i] && name[i] != "CCU001:") {
+        if (dpExists(MainDBName+"__navObjectState.DPName")) {
+            dpSet(MainDBName+"__navObjectState.DPName",MainDBName+"LOFAR_PIC_"+navFunct_getRingFromStation(name[i])+"_"+navFunct_bareDBName(name[i])+".status.state",
+                  MainDBName+"__navObjectState.stateNr",OPERATIONAL,
+                  MainDBName+"__navObjectState.message","System came online",
+                  MainDBName+"__navObjectState.force",true);
+        }        
+      } else if (name[i] != "CCU001:") {
+        if (dpExists(MainDBName+"__navObjectState.DPName")) {
+            dpSet(MainDBName+"__navObjectState.DPName",MainDBName+"LOFAR_PIC_"+navFunct_getRingFromStation(name[i])+"_"+navFunct_bareDBName(name[i])+".status.state",
+                  MainDBName+"__navObjectState.stateNr",DPOFFLINE,
+                  MainDBName+"__navObjectState.message","System went offline",
+                  MainDBName+"__navObjectState.force",false);
+        }
+      }    
+    }
+  }
+  if (g_initializing) {
+    navigator_writeInitProcess("GCFCWDFinished");
+  }
+}
diff --git a/MAC/Navigator2/scripts/libs/claimManager.ctl b/MAC/Navigator2/scripts/libs/claimManager.ctl
index 3769802001f..4edbd214e65 100644
--- a/MAC/Navigator2/scripts/libs/claimManager.ctl
+++ b/MAC/Navigator2/scripts/libs/claimManager.ctl
@@ -130,12 +130,9 @@ void claimManager_queryConnectClaims()
   }
 }
 
-void claimManager_queryConnectClaim_Callback(
-  string strIdent,
-  dyn_dyn_anytype aResult    
-)
+void claimManager_queryConnectClaim_Callback(string strIdent,  dyn_dyn_anytype aResult) 
 {
-  // Locla data
+  // Local data
   int iPos;
   string aDP;
   string strDP;
@@ -145,9 +142,11 @@ void claimManager_queryConnectClaim_Callback(
   
   LOG_DEBUG( "claimManager.ctl:claimManager_queryConnectClaim_Callback| has " + dynlen( aResult ) + " results" );
   LOG_DEBUG( "claimManager.ctl:claimManager_queryConnectClaim_Callback| "+aResult);
-  if( dynlen( aResult ) < 2 )
+  if( dynlen( aResult ) < 2 ) {
+      navigator_writeInitProcess("connectClaimsFinished");
       return;
-  
+    }
+
   // Iterate through the results
   for( int t = 2; t <= dynlen( aResult ); t++)
   {
@@ -189,5 +188,9 @@ void claimManager_queryConnectClaim_Callback(
       // then we have to alter the 
       strClaimObjectName[iPos] = strName;
     }
-  }  
+  }
+  LOG_DEBUG("writing connectClaimsFinished");
+  if ( g_initializing ) {
+    navigator_writeInitProcess("connectClaimsFinished"); 
+  }
 }
diff --git a/MAC/Navigator2/scripts/libs/navConfig.ctl b/MAC/Navigator2/scripts/libs/navConfig.ctl
index ad50c9ccab2..bc7b26bb7df 100644
--- a/MAC/Navigator2/scripts/libs/navConfig.ctl
+++ b/MAC/Navigator2/scripts/libs/navConfig.ctl
@@ -1,142 +1,140 @@
-// navConfig.ctl
-//
-//  Copyright (C) 2002-2004
-//  ASTRON (Netherlands Foundation for Research in Astronomy)
-//  P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl
-//
-//  This program is free software; you can redistribute it and/or modify
-//  it under the terms of the GNU General Public License as published by
-//  the Free Software Foundation; either version 2 of the License, or
-//  (at your option) any later version.
-//
-//  This program is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//  GNU General Public License for more details.
-//
-//  You should have received a copy of the GNU General Public License
-//  along with this program; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-//
-//  $Id$
-//
-///////////////////////////////////////////////////////////////////
-// configuration storage functions for the Navigator.
-///////////////////////////////////////////////////////////////////
-//
-// Functions and procedures
-//
-// navConfig_getNavigatorID		: returns the navigator ID
-// navConfig_setNavigatorID		: sets the navigator ID
-// navConfig_resetDP          :
-
-
-#uses "GCFLogging.ctl"
-#uses "navigator.ctl"
-
-
-global string   DPTYPENAME_NAVIGATOR_INSTANCE   = "NavigatorInstance";
-global int      g_navigatorID 			= 0;
-
-
-//========================== Navigator ID and useCount ===========================
-
-///////////////////////////////////////////////////////////////////////////
-//
-// Function navConfig_getNavigatorID() : ID
-//  
-// returns the navigator ID
-//
-///////////////////////////////////////////////////////////////////////////
-int navConfig_getNavigatorID()
-{
-  return g_navigatorID;
-}
-
-///////////////////////////////////////////////////////////////////////////
-//
-// Function navConfig_setNavigatorID(ID)
-//  
-// sets the navigator ID
-//
-///////////////////////////////////////////////////////////////////////////
-void navConfig_setNavigatorID(int newID)
-{
-  LOG_TRACE("navConfig.ctl:navConfig_setNavigatorID|entered with ID: "+newID);
-
-  // We need an unique ID for this instance of the user interface
-  // We can use the myManId() which will give:
-  // <manager type> + <manager ID>
-  if (newID < 0) {
-    g_navigatorID = myManId();
-  } else {
-    g_navigatorID = newID;
-  }   
-    
-  // if there is no DP yet available, create one.
-  if (! dpExists(DPNAME_NAVIGATOR + g_navigatorID)) {
-    LOG_DEBUG("navConfig.ctl:navConfig_setNavigatorID|Creating new navigator configuration");
-    dpCreate(DPNAME_NAVIGATOR + g_navigatorID, DPTYPENAME_NAVIGATOR_INSTANCE);
-  }
-
-  // We need to reset the fields in our datapoint
-  // so that we don't have any old stuff ( from a previous session )
-  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".fw_viewBox.event");
-  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".fw_viewBox.action");
-  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".fw_viewBox.selection");
-  
-  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".fw_viewSelection.event");
-  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".fw_viewSelection.action");
-  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".fw_viewSelection.selection");
-  
-  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".fw_topDetailSelection.event");
-  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".fw_topDetailSelection.action");
-  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".fw_topDetailSelection.selection");
-
-  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".fw_bottomDetailSelection.event");
-  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".fw_bottomDetailSelection.action");
-  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".fw_bottomDetailSelection.selection");
-  
-  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".fw_locator.event");
-  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".fw_locator.action");
-  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".fw_locator.selection");
-  
-  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".fw_progressBar.event");
-  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".fw_progressBar.action");
-  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".fw_progressBar.selection");
-  
-  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".fw_headLines.event");
-  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".fw_headLines.action");
-  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".fw_headLines.selection");
-  
-  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".fw_alerts.event");
-  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".fw_alerts.action");
-  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".fw_alerts.selection");
-  
-  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".fw_fastJumper.event");
-  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".fw_fastJumper.action");
-  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".fw_fastJumper.selection");
-
-  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".navigator.event");
-  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".navigator.initiator");
-  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".navigator.selection");
-  
-  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".user");
-
-  LOG_DEBUG("navConfig.ctl:navConfig_setNavigatorID|Navigator ID:", g_navigatorID);
-}
-  
-///////////////////////////////////////////////////////////////////////////
-//
-// Function navConfig_resetDP
-//  
-// resets a datapoint
-//
-///////////////////////////////////////////////////////////////////////////
-void navConfig_resetDP(string aDP) {
-  if (dpSet(aDP,"") == -1) {
-    LOG_DEBUG("navConfig.ctl:navConfig_resetDP|Error during dpSet : " + aDP + " Error: " + getLastError());
-  }
-}
-
-
+// navConfig.ctl
+//
+//  Copyright (C) 2002-2004
+//  ASTRON (Netherlands Foundation for Research in Astronomy)
+//  P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl
+//
+//  This program is free software; you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation; either version 2 of the License, or
+//  (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with this program; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+//
+//  $Id$
+//
+///////////////////////////////////////////////////////////////////
+// configuration storage functions for the Navigator.
+///////////////////////////////////////////////////////////////////
+//
+// Functions and procedures
+//
+// navConfig_getNavigatorID		: returns the navigator ID
+// navConfig_setNavigatorID		: sets the navigator ID
+// navConfig_resetDP          :
+
+
+#uses "GCFLogging.ctl"
+#uses "navigator.ctl"
+
+
+global string   DPTYPENAME_NAVIGATOR_INSTANCE   = "NavigatorInstance";
+global int      g_navigatorID 			= 0;
+
+
+//========================== Navigator ID and useCount ===========================
+
+///////////////////////////////////////////////////////////////////////////
+//
+// Function navConfig_getNavigatorID() : ID
+//  
+// returns the navigator ID
+//
+///////////////////////////////////////////////////////////////////////////
+int navConfig_getNavigatorID()
+{
+  return g_navigatorID;
+}
+
+///////////////////////////////////////////////////////////////////////////
+//
+// Function navConfig_setNavigatorID(ID)
+//  
+// sets the navigator ID
+//
+///////////////////////////////////////////////////////////////////////////
+void navConfig_setNavigatorID(int newID)
+{
+  LOG_TRACE("navConfig.ctl:navConfig_setNavigatorID|entered with ID: "+newID);
+
+  // We need an unique ID for this instance of the user interface
+  // We can use the myManId() which will give:
+  // <manager type> + <manager ID>
+  if (newID < 0) {
+    g_navigatorID = myManId();
+  } else {
+    g_navigatorID = newID;
+  }   
+    
+  // if there is no DP yet available, create one.
+  if (! dpExists(DPNAME_NAVIGATOR + g_navigatorID)) {
+    LOG_DEBUG("navConfig.ctl:navConfig_setNavigatorID|Creating new navigator configuration");
+    dpCreate(DPNAME_NAVIGATOR + g_navigatorID, DPTYPENAME_NAVIGATOR_INSTANCE);
+  }
+
+  // We need to reset the fields in our datapoint
+  // so that we don't have any old stuff ( from a previous session )
+  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".fw_viewBox.event");
+  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".fw_viewBox.action");
+  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".fw_viewBox.selection");
+  
+  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".fw_viewSelection.event");
+  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".fw_viewSelection.action");
+  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".fw_viewSelection.selection");
+  
+  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".fw_topDetailSelection.event");
+  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".fw_topDetailSelection.action");
+  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".fw_topDetailSelection.selection");
+
+  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".fw_bottomDetailSelection.event");
+  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".fw_bottomDetailSelection.action");
+  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".fw_bottomDetailSelection.selection");
+  
+  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".fw_locator.event");
+  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".fw_locator.action");
+  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".fw_locator.selection");
+  
+  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".fw_progressBar.event");
+  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".fw_progressBar.action");
+  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".fw_progressBar.selection");
+  
+  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".fw_headLines.event");
+  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".fw_headLines.action");
+  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".fw_headLines.selection");
+  
+  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".fw_alerts.event");
+  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".fw_alerts.action");
+  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".fw_alerts.selection");
+  
+  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".fw_fastJumper.event");
+  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".fw_fastJumper.action");
+  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".fw_fastJumper.selection");
+
+  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".navigator.event");
+  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".navigator.initiator");
+  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".navigator.selection");
+  
+  navConfig_resetDP(DPNAME_NAVIGATOR + g_navigatorID+".user");
+}
+  
+///////////////////////////////////////////////////////////////////////////
+//
+// Function navConfig_resetDP
+//  
+// resets a datapoint
+//
+///////////////////////////////////////////////////////////////////////////
+void navConfig_resetDP(string aDP) {
+  if (dpSet(aDP,"") == -1) {
+    LOG_DEBUG("navConfig.ctl:navConfig_resetDP|Error during dpSet : " + aDP + " Error: " + getLastError());
+  }
+}
+
+
diff --git a/MAC/Navigator2/scripts/libs/navFunct.ctl b/MAC/Navigator2/scripts/libs/navFunct.ctl
index 6949d1b0a84..3c4bd3da5b9 100644
--- a/MAC/Navigator2/scripts/libs/navFunct.ctl
+++ b/MAC/Navigator2/scripts/libs/navFunct.ctl
@@ -81,7 +81,7 @@
 
 #uses "GCFLogging.ctl"
 #uses "GCFCommon.ctl"
-//#uses "navigator.ctl"
+#uses "navigator.ctl"
 
 
 global dyn_string oldActiveObservations;                        
@@ -234,6 +234,9 @@ void navFunct_updateObservations(string dp1, dyn_string active,
     }
   }
   if (!update) {
+    if (g_initializing) {
+      navigator_writeInitProcess("queryConnectObservationsFinished");
+    }
     return;
   }
   oldPlannedObservations = planned;
@@ -302,6 +305,10 @@ void navFunct_updateObservations(string dp1, dyn_string active,
       LOG_ERROR("navPanel.ctl:navPanel_setEvent| "+eventDp +" or " +selectionDp + " Does not exist yet");     
     }
   }
+  
+  if (g_initializing) {
+      navigator_writeInitProcess("queryConnectObservationsFinished");
+  }
 
 }
 
diff --git a/MAC/Navigator2/scripts/libs/navigator.ctl b/MAC/Navigator2/scripts/libs/navigator.ctl
index 4475bb52a49..b0b7c483bb7 100644
--- a/MAC/Navigator2/scripts/libs/navigator.ctl
+++ b/MAC/Navigator2/scripts/libs/navigator.ctl
@@ -45,6 +45,7 @@
 
 global bool       g_initializing          = true;     // to show if initialise is ready
 global bool       g_objectReady           = true;     // Can be used for timing by objects
+global string     g_initProcess           = "";       // holds last finished init process
 
 global string     g_currentDatapoint      = MainDBName+"LOFAR_PIC_Europe";
 global string     g_lastHardwareDatapoint = MainDBName+"LOFAR_PIC_Europe";
@@ -93,11 +94,14 @@ void navigator_handleEventInitialize()
 {
   LOG_TRACE("navigator.ctl:navigator_handleEventInitialize|entered");
   g_initializing = true;
+  
 
-  // Set the global statecolors/colornames.
+  // Set the global statecolors/colornames, we need to do this before we 
+  //start the rest of the framework, because the other processes need these
   initLofarColors();
   
-  // first thing to do: get a new navigator ID
+  // first thing to do: get a new navigator ID,
+  // this also clears all navigator_instance points from previous runs
   // check the commandline parameter:
   int navID = 0;
   if (isDollarDefined("$ID")) {
@@ -117,16 +121,25 @@ void navigator_handleEventInitialize()
   // Do a dpQueryConnectSingle() so that we get a permanent list of claims
   // we can use this to translate a claimed name into a real datapoint name
   claimManager_queryConnectClaims();
+  
 
-  delay(0,100);  // wait query ready
+  // we need to wait until the claim system was able to finish all connections and callbacks
+  if (!navigator_waitInitProcess("connectClaimsFinished")) {
+    LOG_FATAL("navigator.ctl:navigator_handleEventInitialize|Couldn't finish claimManager_queryConnectClaims() , leaving");
+  }
   
   // fill global stations lists
   navFunct_fillStationLists();
+  
  
   // Init the connection Watchdog
   GCFCWD_Init();
 
-  delay(0,100); // wait init ready
+  // we need to wait until the connection watchdog has been initialised
+  if (!navigator_waitInitProcess("GCFCWDFinished")) {
+    LOG_FATAL("navigator.ctl:navigator_handleEventInitialize|Couldn't finish GCFCWD_Init() , leaving");
+  }
+
   
 
   // set user to root for now, has to be taken from PVSS login later
@@ -140,12 +153,22 @@ void navigator_handleEventInitialize()
         
   // Initilaize the alarm system
   initNavigatorAlarms();
+
+  // we need to wait until the alarmSystem has been initialised
+  if (!navigator_waitInitProcess("initNavigatorAlarmsFinished")) {
+    LOG_FATAL("navigator.ctl:navigator_handleEventInitialize|Couldn't finish initNavigatorAlarmsFinished() , leaving");
+  }
  
   // Do a dpQueryConnectSingle() so that we get a list of observations
   // so that we can easily populate our tables with 'Planned', 'Running' and 'Finished' observations
   navFunct_queryConnectObservations();
   
-  // set initialized ready
+  // we need to wait until all known observations have been initialized
+  if (!navigator_waitInitProcess("queryConnectObservationsFinished")) {
+    LOG_FATAL("navigator.ctl:navigator_handleEventInitialize|Couldn't finish queryConnectObservationsFinished() , leaving");
+  }
+
+    // set initialized ready
   g_initializing = false;
 
   LOG_TRACE("navigator.ctl:navigator_handleEventInitialize|end");
@@ -242,3 +265,21 @@ void navigator_clearWorkDPs() {
   }
 
 }
+
+bool navigator_waitInitProcess(string procName) {
+  //delay while procName != g_initProcess
+  int retry=0;
+  while (procName != g_initProcess & retry < 60) {
+    delay(0,100);
+    retry++;
+    if (retry >= 60) {
+      LOG_FATAL("navigator.ctl.pnl:waitInitProcess|initProcess waiting for "+procName+" retry longer then 2 minutes, can't continue?");
+      return false;
+    }
+  }
+  return true;
+}
+
+void navigator_writeInitProcess(string process) {
+  g_initProcess = process;
+}
-- 
GitLab