V 10
1
LANG:1 8 (NoName)
PANEL,258 100 554 421 N "_3DFace" 0
EEE E E 1 -1 -1 0  170 140
"" 0 1
EE 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 6 Layer1
13 0
"LoadDB"
""
1 170 140 E E E 1 E 1 E N "_3DText" E N {102,204,255} E E
 E E
1 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 105 -microsoft windows-Arial-bold-r-normal-*-*-140-100-100-*-*-iso8859-1|-16,0,0,0,700,0,0,0,0,3,2,1,34,Arial
0 ""
168 138 322 192
T 
1
LANG:1 7 Load DB
"main()
{
  setValue(\"\",\"foreCol\",\"Red\");
	loadFile();
  setValue(\"\",\"foreCol\",\"\");
}

loadFile()
{
	file cfg;
	string raw, path, dpName, alias, systemName=getSystemName();
	int serial, group, err;
	
	path=getPath (PANELS_REL_PATH, \"Cnf_Map.txt\");
	cfg = fopen(path, \"r\");
	err = ferror(cfg);
	if (err)
		{ 
		DebugN(\"Error no. \",err,\" occurred: not able to open file:\",path);
		return;
		}
	
	fgets(raw, 300, cfg);
	
	while(fgets(raw, 300, cfg))
		{
		strreplace( raw, \"\\t\", \" \");
		sscanf(raw, \"%s %d %d %s\", dpName, serial, group, alias);
		dpSetAlias(systemName+dpName, alias);
		}
	fclose(cfg);
}" 0
 E E E
13 1
"Button1"
""
1 170 220 E E E 1 E 1 E N "_3DText" E N {102,204,255} E E
 E E
1 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 105 -microsoft windows-Arial-bold-r-normal-*-*-140-100-100-*-*-iso8859-1|-16,0,0,0,700,0,0,0,0,3,2,1,34,Arial
0 ""
168 218 322 272
T 
1
LANG:1 10 Re-Load DB
"//load aliases
/******************************************************************************\\
123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
|*=====================================-======================================*|
|*                 SCT COOLING SYSTEM CONTROL AND MONITORING                  *|
|*=====================================-======================================*|
|*   AUTHORs:        G.Codispoti - codispoti@cs.infn.it			    		  *|
|*								   Giuseppe.Codispoti@cern.ch			      *|
|*																		      *|
|*   DESIGN ISSUEs:  This Script loads aliases for each DPe from the file     *|
|*					 \"Cooling.cfg\" providing a dynaming mapping of the system.*|
|*																		      *|
|*   MODIF_HISTORY:  17.03.2003  - first release						      *|
|*																		      *|
\\******************************************************************************/

main()
{
  setValue(\"\",\"foreCol\",\"Red\");
	loadFile();
  setValue(\"\",\"foreCol\",\"\");
}

loadFile()
{
	file cfg;
	string raw, path;
	int err;
	
	path=getPath (PANELS_REL_PATH, \"Cooling.cfg\");
	cfg = fopen(path, \"r\");
	err = ferror(cfg);
	if (err)
		{ 
		DebugN(\"Error no. \",err,\" occurred: not able to open file:\",path);
		return;
		}
	
	fgets(raw, 300, cfg);
	
	while(fgets(raw, 300, cfg))
		{
		strreplace( raw, \"\\\"\", \"\");
		strreplace( raw, \"\\t\", \" \");
		setLoop(raw);
		}
	
	fclose(cfg);
}


setLoop(string raw)
{
	int layer, nrack, inf, sup, k, i, pos;
	string section, rack, unit, alias;
	dyn_string dps, aliases;
	
	sscanf(raw, \"%s %d %s %d\", section, layer, unit, nrack);
 	sprintf(rack, \"Rack%d.\", nrack);
//	DebugN(section, layer, unit, nrack);

	if (section == \"Barrel\") {
	 	sscanf(unit, \"%d-%d\", inf, sup);
	 	if ( inf<0 || sup>inf+3 || layer<3 || layer>6) {
	 		DebugN(\"Error in reading file: \"+raw);
	 		return;
	 	}
	 	for (k=inf; k<= sup; k++)	{
			sprintf(alias, \"Barrel%02d.Row%02d\", layer, k);
//			DebugN(alias);
			dpGetAllAliases(dps, aliases, \"*\"+alias+\"*\", \"SCTmops1:Crate*.Channel*\");
			for (i=1; i<=dynlen(dps); i++) {
				setAlias(dps[i], aliases[i], rack);
			}
		}
	}
	
	else if (strpos( strtolower(section), \"endcap\") != -1){
	 	sscanf (unit, \"%d\", k);
	 	if ( k<0 || k>3 || layer<1 || layer>9) {
	 		DebugN(\"Error in reading file: \"+raw);
	 	}
		sprintf(alias, section+\"%d.Quadrant%d\", layer, k);
//		DebugN(alias);
		dpGetAllAliases(dps, aliases, \"*\"+alias+\"*\", \"SCTmops1:Crate*.Channel*\");
		for (i=1; i<=dynlen(dps); i++) {
			setAlias(dps[i], aliases[i], rack);
		}
	}
	
	else DebugN(\"Error! In reading:\", section, \"?\");
}

setAlias(string dpName, string alias, string rack)
{
	int pos;

	pos = strpos( alias, \"rack\");
	DebugN(dpName, alias);
	if ( pos == -1) alias = rack + alias;
	else alias =  rack + substr( alias, pos, 5);
//	dpSetAlias(dpName, \"\"); // Delete alias if exists
	dpSetAlias(dpName, alias);
}" 0
 E E E
0
LAYER, 1 
1
LANG:1 6 Layer2
0
LAYER, 2 
1
LANG:1 6 Layer3
0
LAYER, 3 
1
LANG:1 6 Layer4
0
LAYER, 4 
1
LANG:1 6 Layer5
0
LAYER, 5 
1
LANG:1 6 Layer6
0
LAYER, 6 
1
LANG:1 6 Layer7
0
LAYER, 7 
1
LANG:1 6 Layer8
0
0