From 8cabb2d46bca9a1a60f2640b3bc3e7daf937e830 Mon Sep 17 00:00:00 2001
From: Alexander Mueller <alexander.mueller@hs.uni-hamburg.de>
Date: Wed, 29 Sep 2004 12:16:39 +0000
Subject: [PATCH] %[ER: 136] Some minor changes (scripting)

---
 .gitattributes                                |  8 +-
 MAC/Config/LofarPropertyTypes.pvss            | 19 ----
 MAC/GCF/_PAL/PA/pvss/config/config            | 11 ---
 MAC/GCF/_PAL/PA/pvss/config/config.level      |  6 +-
 .../_PAL/PA/pvss/scripts/libs/gcfpa-prep.ctl  | 90 +++++++++++++++++++
 MAC/GCF/_PAL/PA/src/GPA_Controller.cc         | 11 ++-
 MAC/GCF/_PAL/PA/src/Makefile.am               | 13 ++-
 MAC/GCF/_PAL/PA/src/configurePVSSProj         |  3 +
 MAC/GCF/_PAL/PA/src/initPVSSDB                |  4 -
 MAC/GCF/_PAL/PA/src/preparePVSS-DB            |  8 ++
 MAC/Test/GCF/src/Makefile.am                  |  6 +-
 .../GCF/src/customPrepPVSSDB.ctl}             |  9 +-
 12 files changed, 126 insertions(+), 62 deletions(-)
 delete mode 100644 MAC/Config/LofarPropertyTypes.pvss
 delete mode 100644 MAC/GCF/_PAL/PA/pvss/config/config
 create mode 100644 MAC/GCF/_PAL/PA/pvss/scripts/libs/gcfpa-prep.ctl
 create mode 100644 MAC/GCF/_PAL/PA/src/configurePVSSProj
 delete mode 100644 MAC/GCF/_PAL/PA/src/initPVSSDB
 create mode 100644 MAC/GCF/_PAL/PA/src/preparePVSS-DB
 rename MAC/{GCF/_PAL/PA/pvss/scripts/libs/gcfpa-cl.ctl => Test/GCF/src/customPrepPVSSDB.ctl} (73%)

diff --git a/.gitattributes b/.gitattributes
index 64db50840dd..ee057093a33 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -158,7 +158,6 @@ MAC/Config/Apc/b1.apc -text svneol=native#application/octet-stream
 MAC/Config/Apc/b2.apc -text svneol=native#application/octet-stream
 MAC/Config/Apc/d1.apc -text svneol=native#application/octet-stream
 MAC/Config/Apc/e1.apc -text svneol=native#application/octet-stream
-MAC/Config/LofarPropertyTypes.pvss -text svneol=native#application/octet-stream
 MAC/Config/mac.ns -text svneol=native#application/octet-stream
 MAC/Config/mac.top -text svneol=native#application/octet-stream
 MAC/Drivers/spid/tools/Makefile -text svneol=native#application/octet-stream
@@ -182,21 +181,21 @@ MAC/GCF/TM/test/Makefile.am -text svneol=native#application/octet-stream
 MAC/GCF/TM/test/tm-test.conf.in -text svneol=native#application/octet-stream
 MAC/GCF/_PAL/Makefile.am -text svneol=native#application/octet-stream
 MAC/GCF/_PAL/PA/Makefile.am -text svneol=native#application/octet-stream
-MAC/GCF/_PAL/PA/pvss/config/config -text svneol=native#application/octet-stream
 MAC/GCF/_PAL/PA/pvss/config/config.level -text svneol=native#application/octet-stream
 MAC/GCF/_PAL/PA/pvss/config/progs -text svneol=native#application/octet-stream
 MAC/GCF/_PAL/PA/pvss/panels/GCFPATest.pnl -text svneol=native#application/octet-stream
 MAC/GCF/_PAL/PA/pvss/panels/GCFPropSetLoader.pnl -text svneol=native#application/octet-stream
-MAC/GCF/_PAL/PA/pvss/scripts/libs/gcfpa-cl.ctl -text svneol=native#application/octet-stream
 MAC/GCF/_PAL/PA/pvss/scripts/libs/gcfpa-com.ctl -text svneol=native#application/octet-stream
 MAC/GCF/_PAL/PA/pvss/scripts/libs/gcfpa-cwd.ctl -text svneol=native#application/octet-stream
 MAC/GCF/_PAL/PA/pvss/scripts/libs/gcfpa-pml.ctl -text svneol=native#application/octet-stream
+MAC/GCF/_PAL/PA/pvss/scripts/libs/gcfpa-prep.ctl -text svneol=native#application/octet-stream
 MAC/GCF/_PAL/PA/pvss/scripts/pvss_scripts.lst -text svneol=native#application/octet-stream
 MAC/GCF/_PAL/PA/src/Makefile.am -text svneol=native#application/octet-stream
 MAC/GCF/_PAL/PA/src/PA_Protocol.prot -text svneol=native#application/octet-stream
+MAC/GCF/_PAL/PA/src/configurePVSSProj -text svneol=native#application/octet-stream
 MAC/GCF/_PAL/PA/src/gcf-pa.conf.in -text svneol=native#application/octet-stream
-MAC/GCF/_PAL/PA/src/initPVSSDB -text svneol=native#application/octet-stream
 MAC/GCF/_PAL/PA/src/loadAPC -text svneol=native#application/octet-stream
+MAC/GCF/_PAL/PA/src/preparePVSS-DB -text svneol=native#application/octet-stream
 MAC/GCF/_PAL/PI/Makefile.am -text svneol=native#application/octet-stream
 MAC/GCF/_PAL/PI/src/Makefile.am -text svneol=native#application/octet-stream
 MAC/GCF/_PAL/PI/src/PI_Protocol.prot -text svneol=native#application/octet-stream
@@ -334,6 +333,7 @@ MAC/Test/GCF/configure.in -text svneol=native#application/octet-stream
 MAC/Test/GCF/src/Echo_Protocol.prot -text svneol=native#application/octet-stream
 MAC/Test/GCF/src/Makefile.am -text svneol=native#application/octet-stream
 MAC/Test/GCF/src/TST_Protocol.prot -text svneol=native#application/octet-stream
+MAC/Test/GCF/src/customPrepPVSSDB.ctl -text svneol=native#application/octet-stream
 MAC/Test/GCF/src/gcf-test.conf.in -text svneol=native#application/octet-stream
 MAC/Test/GCF/src/gcftesttypes.dpl -text svneol=native#application/octet-stream
 MAC/Test/PROTO/Event/MY_Protocol.prot -text svneol=native#application/octet-stream
diff --git a/MAC/Config/LofarPropertyTypes.pvss b/MAC/Config/LofarPropertyTypes.pvss
deleted file mode 100644
index 7adfcfd12f7..00000000000
--- a/MAC/Config/LofarPropertyTypes.pvss
+++ /dev/null
@@ -1,19 +0,0 @@
-TypeName
-GCFTempRef.GCFTempRef	23#1
-GCFDataType.GCFDataType	1#1
-	panelAdmin	9#2
-	permanentStatus	23#3
-LPT_BOOL.LPT_BOOL	23#1
-LPT_DOUBLE.LPT_DOUBLE	22#1
-LPT_INTEGER.LPT_INTEGER	21#1
-LPT_CHAR.LPT_CHAR	19#1
-LPT_UNSIGNED.LPT_UNSIGNED	20#1
-LPT_STRING.LPT_STRING	25#1
-LPT_BLOB.LPT_BLOB	46#1
-LPT_DYNBOOL.LPT_DYNBOOL	7#1
-LPT_DYNDOUBLE.LPT_DYNDOUBLE	6#1
-LPT_DYNINTEGER.LPT_DYNINTEGER	5#1
-LPT_DYNCHAR.LPT_DYNCHAR	3#1
-LPT_DYNUNSIGNED.LPT_DYNUNSIGNED	4#1
-LPT_DYNSTRING.LPT_DYNSTRING	9#1
-LPT_DYNBLOB.LPT_DYNBLOB	48#1
diff --git a/MAC/GCF/_PAL/PA/pvss/config/config b/MAC/GCF/_PAL/PA/pvss/config/config
deleted file mode 100644
index e7c30c17c23..00000000000
--- a/MAC/GCF/_PAL/PA/pvss/config/config
+++ /dev/null
@@ -1,11 +0,0 @@
-[general]
-pvss_path = "/usr/pvss/pvss2_v3.0"
-proj_path = "/usr/pvss/Lofar/3.0/LCU"
-proj_version = "3.0"
-userName = "root"
-password = ""
-langs = "en_US.iso88591"
-distributed = 1
-
-[dist]
-distPeer = "sun:4776" 2 
diff --git a/MAC/GCF/_PAL/PA/pvss/config/config.level b/MAC/GCF/_PAL/PA/pvss/config/config.level
index 46af9648ea0..71829fa870c 100644
--- a/MAC/GCF/_PAL/PA/pvss/config/config.level
+++ b/MAC/GCF/_PAL/PA/pvss/config/config.level
@@ -1,5 +1,6 @@
 [ctrl]
-LoadCtrlLibs = "std.ctl, libCTRL.ctl, hosts.ctl, va.ctl, archiv.ctl, mp.ctl, gcfpa-cwd.ctl, gcfpa-com.ctl"
+LoadCtrlLibs = "std.ctl, libCTRL.ctl, hosts.ctl, va.ctl, archiv.ctl, mp.ctl"
+LoadCtrlLibs = "gcfpa-cwd.ctl, gcfpa-com.ctl"
 
 [ui_extend]
 LoadCtrlLibs = "para.ctl, ep.ctl, csg.ctl, ngedi.ctl, ini.ctl"
@@ -10,7 +11,8 @@ LoadCtrlLibs = "login.ctl, panel.ctl, std.ctl, dist.ctl"
 LoadCtrlLibs = "hosts.ctl, va.ctl, ac.ctl, dpGroups.ctl"
 LoadCtrlLibs = "pager.ctl, archiv.ctl, Clk.ctl, tools.ctl, mp.ctl, ax.ctl"
 LoadCtrlLibs = "pmon.ctl, userMan.ctl"
-LoadCtrlLibs = "ft.ctl, pt.ctl, gcfpa-pml.ctl, gcfpa-com.ctl"
+LoadCtrlLibs = "ft.ctl, pt.ctl"
+LoadCtrlLibs = "gcfpa-pml.ctl, gcfpa-com.ctl"
 
 [event]
 LoadCtrlLibs = "STD_Symbols.ctl"
diff --git a/MAC/GCF/_PAL/PA/pvss/scripts/libs/gcfpa-prep.ctl b/MAC/GCF/_PAL/PA/pvss/scripts/libs/gcfpa-prep.ctl
new file mode 100644
index 00000000000..30e0a679caa
--- /dev/null
+++ b/MAC/GCF/_PAL/PA/pvss/scripts/libs/gcfpa-prep.ctl
@@ -0,0 +1,90 @@
+main()
+{
+	dyn_dyn_string xxdepes;
+	dyn_dyn_int xxdepei;
+	dyn_string types;
+	types = dpTypes("LPT_*");
+	
+	handleType(types, "LPT_CHAR", DPEL_CHAR);
+	handleType(types, "LPT_STRING", DPEL_STRING);
+	handleType(types, "LPT_BOOL", DPEL_BOOL);
+	handleType(types, "LPT_BLOB", DPEL_BLOB);
+	handleType(types, "LPT_DOUBLE", DPEL_FLOAT);
+	handleType(types, "LPT_INTEGER", DPEL_INT);
+	handleType(types, "LPT_UNSIGNED", DPEL_UINT);
+	handleType(types, "LPT_DYNCHAR", DPEL_DYN_CHAR);
+	handleType(types, "LPT_DYNSTRING", DPEL_DYN_STRING);
+	handleType(types, "LPT_DYNBOOL", DPEL_DYN_BOOL);
+	handleType(types, "LPT_DYNBLOB", DPEL_DYN_BLOB);
+	handleType(types, "LPT_DYNDOUBLE", DPEL_DYN_FLOAT);
+	handleType(types, "LPT_DYNINTEGER", DPEL_DYN_INT);
+	handleType(types, "LPT_DYNUNSIGNED", DPEL_DYN_UINT);
+
+	types = dpTypes("GCF*");
+	if (!dynContains(types, "GCFTempRef"))
+	{
+		xxdepes[1] = makeDynString ("GCFTempRef");
+		xxdepei[1] = makeDynInt (DPEL_STRING);
+		dpTypeCreate(xxdepes,xxdepei);
+	}
+	else
+	{
+  	deleteDPs("GCFTempRef");
+	}
+
+	if (!dynContains(types, "GCFDataType"))
+	{
+		xxdepes[1] = makeDynString ("GCFDataType", "");
+		xxdepes[2] = makeDynString ("", "panelAdmin");
+		xxdepes[3] = makeDynString ("", "permanentStatus");
+		xxdepei[1] = makeDynInt (DPEL_STRUCT);
+		xxdepei[2] = makeDynInt (0, DPEL_DYNSTRING);
+		xxdepei[2] = makeDynInt (0, DPEL_BOOL);
+		dpTypeCreate(xxdepes,xxdepei);
+	}
+
+  deleteDPs("TTypeA");
+  deleteDPs("TTypeB");
+  deleteDPs("TTypeC");
+  deleteDPs("TTypeD");
+  deleteDPs("TTypeE");
+  deleteDPs("TTypeF");
+  deleteDPs("TTypeG");
+  dpCreate("A_K", "TTypeB");
+  dpCreate("A_L", "TTypeE");
+  dpCreate("B_A_BRD1", "TTypeF");
+}
+
+deleteDPs(string type)
+{
+  string dpName;
+  dyn_string names = dpNames("*",type);  
+  int i, len;
+  len = dynlen(names);
+  if (len > 0)
+  {
+    for (i = 1; i <= len; i++)
+    {
+      dpName = names[i];
+      dpDelete(dpName);
+      DebugN(dpName + " deleted");
+    }
+  }
+}
+
+void handleType(dyn_string types, string type, int dpelType)
+{
+	if (!dynContains(types, type))
+	{
+		dyn_dyn_string xxdepes;
+		dyn_dyn_int xxdepei;
+		xxdepes[1] = makeDynString (type);
+		xxdepei[1] = makeDynInt (dpelType);
+		dpTypeCreate(xxdepes,xxdepei);
+		DebugN("Add type " + type);
+	}
+	else
+	{
+		deleteDPs(type);
+	}
+}
\ No newline at end of file
diff --git a/MAC/GCF/_PAL/PA/src/GPA_Controller.cc b/MAC/GCF/_PAL/PA/src/GPA_Controller.cc
index b91c914c0a6..ebb93871165 100644
--- a/MAC/GCF/_PAL/PA/src/GPA_Controller.cc
+++ b/MAC/GCF/_PAL/PA/src/GPA_Controller.cc
@@ -58,6 +58,10 @@ GPAController::GPAController() :
   // the connection with the PVSS system on construction. Because it will managed
   // by a singleton the property set only needs to be temporary.
   GPAPropertySet dummy(*this, _pmlPortProvider);  
+  LOG_INFO("Prepare PVSS DB for proper use by PA");
+  system("chmod 777 preparePVSS-DB");
+  string sysCmd = "preparePVSS-DB " + GCFPVSSInfo::getProjectName();
+  system(sysCmd.c_str());
 }
 
 GPAController::~GPAController()
@@ -96,14 +100,9 @@ GCFEvent::TResult GPAController::initial(GCFEvent& e, GCFPortInterface& p)
       break;
 
     case F_EXIT:
-    {
-      LOG_INFO("Initialise PVSS DB");
-      system("chmod 777 initPVSSDB");
-      string sysCmd = "initPVSSDB " + GCFPVSSInfo::getProjectName();
-      system(sysCmd.c_str());
+      LOG_INFO("Property Agent is ready!!!");
       _garbageTimerId = _distPmlPortProvider.setTimer(2.0, 2.0);
       break;
-    }  
     default:
       status = GCFEvent::NOT_HANDLED;
       break;
diff --git a/MAC/GCF/_PAL/PA/src/Makefile.am b/MAC/GCF/_PAL/PA/src/Makefile.am
index 0ef2a229085..4f7b386cc10 100644
--- a/MAC/GCF/_PAL/PA/src/Makefile.am
+++ b/MAC/GCF/_PAL/PA/src/Makefile.am
@@ -46,14 +46,13 @@ EXTRA_DIST = \
 configfilesdir=$(bindir)
 configfiles_DATA= \
 	loadAPC \
-	initPVSSDB \
-	PropertyAgent.conf \
-	LofarPropertyTypes.pvss
+	preparePVSS-DB \
+	configurePVSSProj \
+	PropertyAgent.conf
 
-MAC_CONFIG = $(top_srcdir)/../../Config
-
-%.pvss: $(MAC_CONFIG)/%.pvss
-	cp $< $@
+install-data-local:
+	cp -Rf $(top_srcdir)/PA/pvss $(bindir)
+	chmod 777 $(bindir)/configurePVSSProj
 	
 %.conf: gcf-pa.conf.in
 	cp $< $@
diff --git a/MAC/GCF/_PAL/PA/src/configurePVSSProj b/MAC/GCF/_PAL/PA/src/configurePVSSProj
new file mode 100644
index 00000000000..a7f442f9e67
--- /dev/null
+++ b/MAC/GCF/_PAL/PA/src/configurePVSSProj
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+cp -Rf pvss/* $LOFARHOME/3.0/$1/
\ No newline at end of file
diff --git a/MAC/GCF/_PAL/PA/src/initPVSSDB b/MAC/GCF/_PAL/PA/src/initPVSSDB
deleted file mode 100644
index 83dc563cd4a..00000000000
--- a/MAC/GCF/_PAL/PA/src/initPVSSDB
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/sh
-
-PVSS00ctrl -script libs/gcfpa-cl.ctl -proj $1
-PVSS00ascii -in LofarPropertyTypes.pvss -proj $1
diff --git a/MAC/GCF/_PAL/PA/src/preparePVSS-DB b/MAC/GCF/_PAL/PA/src/preparePVSS-DB
new file mode 100644
index 00000000000..75973279d95
--- /dev/null
+++ b/MAC/GCF/_PAL/PA/src/preparePVSS-DB
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+PVSS00ctrl -script libs/gcfpa-prep.ctl -proj $1
+if [ -r customPrepPVSSDB.ctl ]; then
+	cp *.ctl $LOFARHOME/3.0/$1/scripts
+	PVSS00ctrl -script customPrepPVSSDB.ctl -proj $1
+	rm -f $LOFARHOME/3.0/$1/scripts/customPrepPVSSDB.ctl
+fi
\ No newline at end of file
diff --git a/MAC/Test/GCF/src/Makefile.am b/MAC/Test/GCF/src/Makefile.am
index a17d465a347..2cb26b50776 100644
--- a/MAC/Test/GCF/src/Makefile.am
+++ b/MAC/Test/GCF/src/Makefile.am
@@ -61,7 +61,8 @@ configfiles_DATA= \
 	RTPing.conf \
 	Application1.conf \
 	Application2.conf \
-	log4cplus.properties
+	log4cplus.properties \
+	customPrepPVSSDB.ctl
 	
 MAC_CONFIG = $(top_srcdir)/../../Config
 %.properties: $(MAC_CONFIG)/%.properties
@@ -70,5 +71,8 @@ MAC_CONFIG = $(top_srcdir)/../../Config
 %.conf: gcf-test.conf.in
 	cp $< $@
 
+%.ctl: *.ctl
+	cp $< $@
+
 include $(lofar_sharedir)/Makefile.common
 
diff --git a/MAC/GCF/_PAL/PA/pvss/scripts/libs/gcfpa-cl.ctl b/MAC/Test/GCF/src/customPrepPVSSDB.ctl
similarity index 73%
rename from MAC/GCF/_PAL/PA/pvss/scripts/libs/gcfpa-cl.ctl
rename to MAC/Test/GCF/src/customPrepPVSSDB.ctl
index 8e46a2a968b..18059a50cf4 100644
--- a/MAC/GCF/_PAL/PA/pvss/scripts/libs/gcfpa-cl.ctl
+++ b/MAC/Test/GCF/src/customPrepPVSSDB.ctl
@@ -1,12 +1,5 @@
 main()
 {
-  deleteDPs("LPT_CHAR");
-  deleteDPs("LPT_BOOL");
-  deleteDPs("LPT_STRING");
-  deleteDPs("LPT_DOUBLE");
-  deleteDPs("LPT_INTEGER");
-  deleteDPs("LPT_UNSIGNED");
-  deleteDPs("GCFTempRef");
   deleteDPs("TTypeA");
   deleteDPs("TTypeB");
   deleteDPs("TTypeC");
@@ -34,4 +27,4 @@ deleteDPs(string type)
       DebugN(dpName + " deleted");
     }
   }
-}
+}
\ No newline at end of file
-- 
GitLab