V 10
1
LANG:1 8 (NoName)
PANEL,372 214 430 326 N "_3DFace" 0
EEE E E 1 -1 -1 0  100 130
"" 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 1
"Button1"
""
1 100 40 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 ""
98 38 332 102
T 
1
LANG:1 17 Load Alerts_old_2
"//Function Load_Alerts()
main()
{
file card, par, new;
int err, i;
string raw, path, status;

status = \"off\";
setValue(\"\",\"foreCol\",\"Red\");

  /* open Cnf_Card.txt file */
	path = getPath(PANELS_REL_PATH, \"Cnf_Card.txt\");
	card = fopen(path,\"r\");

  /* open Cnf_Para.txt file */	
	path = getPath(PANELS_REL_PATH, \"Cnf_Para.txt\");
	par = fopen(path,\"r\");
	
	err = ferror(card);

  /* open a new file */	
	new = fopen(\"new.txt\",\"w\");

  /* excluding first line of both files */
	fgets( raw, 300, card );
	fgets( raw, 300, par );

  /* setting cards alerts */
	while( fgets( raw, 300, card))
	  {
	  strreplace( raw, \"\\\"\", \"\");
	  strreplace( raw, \"\\t\", \" \");
	//  DebugN(raw);
	  cardSet( raw, status );
	  }
	
  /* setting cards alerts */
	while( fgets( raw, 300, par) )  
//	for (i=0; i <=10; i++)
	  {
//	  fgets( raw, 300, par);  
	  strreplace( raw, \"\\\"\", \"\");
	  strreplace( raw, \"x\", \"\");
	  strreplace( raw, \"\\t\", \" \");
	//  DebugN(raw);
	  channelSet( raw, status );
	  }

/* close files */
fclose(card);
fclose(par);
fclose(new);
setValue(\"\",\"foreCol\",\"\");
}


/**************************************************************************\\
|* The following function splits the string from the Cnf_Card.txt file    *|
|* giving back the setting values for every card.                         *|
\\**************************************************************************/
void cardSet(string raw, string status)
{
int ID,	Rack,	Crate,	Card, Host,	Node,	Port,	Unit;
string Para, EoN, EoA, EoO, EoS, Comment, LV_HV, dpName, module;
float FatlL_Off, WarnL_Off,	Norm_Off, WarnH_Off, FatlH_Off,
	  FatlL_Stb, WarnL_Stb, Norm_Stb, WarnH_Stb, FatlH_Stb,
	  FatlL_On,	 WarnL_On,	Norm_On,  WarnH_On,	 FatlH_On;

 sscanf(raw,
       \"%d %d %d %d %s %s %d %d %d %d %s %f %f %f %f %f %s %f %f %f %f %f %s %f %f %f %f %f %s %s\",
		ID,	Rack,	Crate,	Card,	Para,	EoN,	Host,	Node,	Port,	Unit,	EoA,
		FatlL_Off,	WarnL_Off,	Norm_Off,	WarnH_Off,	FatlH_Off,	EoO,
		FatlL_Stb,	WarnL_Stb,	Norm_Stb,	WarnH_Stb,	FatlH_Stb,	EoS,
		FatlL_On,	WarnL_On,	Norm_On,	WarnH_On,	FatlH_On,	LV_HV, Comment);

/*  DebugN(ID,	Rack,	Crate,	Card,	Para,	EoN,	Host,	Node,	Port,	Unit,	EoA,
		FatlL_Off,	WarnL_Off,	Norm_Off,	WarnH_Off,	FatlH_Off,	EoO,
		FatlL_Stb,	WarnL_Stb,	Norm_Stb,	WarnH_Stb,	FatlH_Stb,	EoS,
		FatlL_On,	WarnL_On,	Norm_On,	WarnH_On,	FatlH_On,	LV_HV, Comment);*/

  Crate = 0;  
  sprintf( module, \"Crate%02d.\" + LV_HV + \"_card%02d.\", Crate, Card );

// Scanning for Moni
  if (Comment == \"Moni\")
	{
	dpName = getSystemName() + module + Para + \".Recv\";
	if ( dpExists(dpName) )
		{
		switch(status) // setting values related to actual status
			{
			case \"on\"  :  setAlerts( dpName, FatlL_On,	WarnL_On,	WarnH_On,	FatlH_On );  break;
			case \"off\" :  setAlerts( dpName, FatlL_Off,	WarnL_Off,	WarnH_Off,	FatlH_Off ); break;
			case \"stb\" :  setAlerts( dpName, FatlL_Stb,	WarnL_Stb,	WarnH_Stb,	FatlH_Stb ); break;
			default	 :  DebugN(\"Error in reading! No status available for \",dpName,\".\");
			}
	 	}
	else DebugN(\"Error in reading!\" , dpName, \" doesn't exist.\");
	} 
// Scanning for Command	
  else if (Comment == \"Comm\") {
    dpName = getSystemName() + module + Para + \".Send\";
    if ( dpExists(dpName) )
    	{
		switch(status) // setting values related to actual status
			{
			case \"on\"  :  setAlerts( dpName, FatlL_On,	WarnL_On,	WarnH_On,	FatlH_On );  break;
			case \"off\" :  setAlerts( dpName, FatlL_Off,	WarnL_Off,	WarnH_Off,	FatlH_Off ); break;
			case \"stb\" :  setAlerts( dpName, FatlL_Stb,	WarnL_Stb,	WarnH_Stb,	FatlH_Stb ); break;
			default	 :  DebugN(\"Error in reading! No status available for \",dpName,\".\");
			}
		}	
	else DebugN(\"Error in reading!\" , dpName, \" doesn't exist.\");		
	}
  else DebugN(\"Error in reading! No type available for \", getSystemName() + module + Para);
}


/**************************************************************************\\
|* The following function splits the string from the Cnf_Para.txt file    *|
|* giving back the setting values for every channel.                      *|
\\**************************************************************************/
void channelSet(string raw, string status)
{
int i, ID,	Mod, enab, Crate; 
string Para, EoO, EoS, Comment, EoP, LV_HV, dpName, module, type;
float FatlL_Off, WarnL_Off,	Norm_Off, WarnH_Off, FatlH_Off,
	  FatlL_Stb, WarnL_Stb, Norm_Stb, WarnH_Stb, FatlH_Stb,
	  FatlL_On,	 WarnL_On,	Norm_On,  WarnH_On,	 FatlH_On;

  sscanf(raw, \"%d %d %s %s %f %f %f %f %f %s %f %f %f %f %f %s %f %f %f %f %f %d %s\",
		ID,	Mod, Para, EoP, 
		FatlL_Off,	WarnL_Off,	Norm_Off,	WarnH_Off,	FatlH_Off,	EoO,
		FatlL_Stb,	WarnL_Stb,	Norm_Stb,	WarnH_Stb,	FatlH_Stb,	EoS,
		FatlL_On,	WarnL_On,	Norm_On,	WarnH_On,	FatlH_On,	enab, Comment);
/*  DebugN(ID,	Mod, Para, EoP, 
		FatlL_Off,	WarnL_Off,	Norm_Off,	WarnH_Off,	FatlH_Off,	EoO,
		FatlL_Stb,	WarnL_Stb,	Norm_Stb,	WarnH_Stb,	FatlH_Stb,	EoS,
		FatlL_On,	WarnL_On,	Norm_On,	WarnH_On,	FatlH_On,	enab, Comment);*/
   
  Crate = 0;
  sprintf( module, \"Crate%02d.Channel%02d.\", Crate, i );
  
// Scanning for Moni
  if (Comment == \"Moni\")
  	{
    dpName = getSystemName() + module + Para + \".Recv\";
    if ( dpExists(dpName) )
    	{
		switch(status) // setting values related to actual status
			{
			case \"on\"  :  setAlerts( dpName, FatlL_On,	WarnL_On,	WarnH_On,	FatlH_On );  break;
			case \"off\" :  setAlerts( dpName, FatlL_Off,	WarnL_Off,	WarnH_Off,	FatlH_Off ); break;
			case \"stb\" :  setAlerts( dpName, FatlL_Stb,	WarnL_Stb,	WarnH_Stb,	FatlH_Stb ); break;
			default	 :  DebugN(\"Error in reading! No status available for \",dpName,\".\");
		    }
		}
	else DebugN(\"Error in reading!\" , dpName, \" doesn't exist.\");		
    }
// Scanning for Command	  
  else if (Comment == \"Comm\")
  	{
    dpName = getSystemName() + module + Para + \".Send\";
    if ( dpExists(dpName) )
    	{
		switch(status) // setting values related to actual status
			{
	  		case \"on\"  :  setAlerts( dpName, FatlL_On,	WarnL_On,	WarnH_On,	FatlH_On );  break;
  	  		case \"off\" :  setAlerts( dpName, FatlL_Off,	WarnL_Off,	WarnH_Off,	FatlH_Off ); break;
      		case \"stb\" :  setAlerts( dpName, FatlL_Stb,	WarnL_Stb,	WarnH_Stb,	FatlH_Stb ); break;
	  		default	 :  DebugN(\"Error in reading! No status available for \",dpName,\".\");	  
		  	}
		}
	else DebugN(\"Error in reading!\" , dpName, \" doesn't exist.\");		
	}
// Scanning for read&write Parameters
  else if (Comment == \"MoniComm\")
  	{
  	for(i=1; i<=2; i++)
		{
		switch(i)
			{
			case 1 : type = \".Send\"; break;
			case 2 : type = \".Recv\"; break;
			}
	    dpName = getSystemName() + module + Para + type;
	    if ( dpExists(dpName) )
	    	{
	    	switch(status) // setting values related to actual status
	    		{
				case \"on\"  :  setAlerts( dpName, FatlL_On,	WarnL_On,	WarnH_On,	FatlH_On );  break;
				case \"off\" :  setAlerts( dpName, FatlL_Off,	WarnL_Off,	WarnH_Off,	FatlH_Off ); break;
				case \"stb\" :  setAlerts( dpName, FatlL_Stb,	WarnL_Stb,	WarnH_Stb,	FatlH_Stb ); break;
				default	 :  DebugN(\"Error in reading! No status available for \",dpName,\".\");
				}
			}
		else DebugN(\"Error in reading!\" , dpName, \" doesn't exist.\");		
	    }
	}
  else DebugN(\"Error in reading! No type available for \",getSystemName() + module + Para); 
  }

/*****************************************************************************************\\
|* The following function sets alert config for the datapoint element dpeName            *|
|* with the five alert ranges neighbouring Fatal_low, Warn_low, Warn_high and Fatal_high *|
\\*****************************************************************************************/
 setAlerts(string dpeName, float Fatal_low, float Warn_low,
                                float Warn_high, float Fatal_high)
{
	string prefix = dpeName+\":_alert_hdl.\";
	dyn_errClass err;
	int rc, type;
	bool ok;
	dyn_string 	rangeTexts 		= makeDynString (\"Data is fatal Low\", \"Data is warn. Low\", \"Data is Normal\", \"Data is warn. High\", \"Data is fatal High\");
	dyn_string 	rangeClasses 	= makeDynString (\"alert.\", \"warning.\", \"\", \"warning.\", \"alert.\");

if ( !(dpeName < Fatal_low < Warn_low < Warn_high < Fatal_high)) 
	{
	DebugN(\"Error! Invalid limits for\", dpeName, \" : \", Fatal_low, Warn_low, Warn_high, Fatal_high);
	return; 
	}
//	DebugN(dpeName, \" : \", Fatal_low, Warn_low, Warn_high, Fatal_high);
	
	// check if the alarm already exists
	rc = dpGet (prefix+\"._type\", type);
	err = getLastError ();	
	if (rc | dynlen(err)) {
		DebugN(\"Failed to check whether alarm already exists for dpe: \"+dpeName+\" : \"+rc);
		throwError (err);
		return;
	}

	// if it exists, deactivate the alarm handling (so we can change it)
	if (type != DPCONFIG_NONE) {
		dpDeactivateAlert (dpeName, ok);		
		if ( ! ok) {
			DebugN(\"Failed to deactivate alarm on dpe: \"+dpeName);
			return;
		}
	}
	
	// configure the alarm
	rc = dpSetWait (prefix+\"._type\", DPCONFIG_ALERT_NONBINARYSIGNAL, // equal to 13!

					prefix+\"1._type\", DPDETAIL_RANGETYPE_MINMAX, // equal to 4!
					prefix+\"1._u_limit\", Fatal_low,
					prefix+\"1._l_incl\", TRUE,
					prefix+\"1._u_incl\", FALSE,
					prefix+\"1._text\",  rangeTexts [1],
					prefix+\"1._class\", rangeClasses [1],

					prefix+\"2._type\", DPDETAIL_RANGETYPE_MINMAX,
					prefix+\"2._l_limit\", Fatal_low,
					prefix+\"2._u_limit\", Warn_low,
					prefix+\"2._l_incl\", TRUE,
					prefix+\"2._u_incl\", FALSE,
					prefix+\"2._text\", rangeTexts [2],
					prefix+\"2._class\", rangeClasses [2],

					prefix+\"3._type\", DPDETAIL_RANGETYPE_MINMAX,
					prefix+\"3._l_limit\", Warn_low,
					prefix+\"3._u_limit\", Warn_high,
					prefix+\"3._l_incl\", TRUE,
					prefix+\"3._u_incl\", FALSE,
					prefix+\"3._text\", rangeTexts [3],
					prefix+\"3._class\", rangeClasses [3],

					prefix+\"4._type\", DPDETAIL_RANGETYPE_MINMAX,
					prefix+\"4._l_limit\", Warn_high,
					prefix+\"4._u_limit\", Fatal_high,
					prefix+\"4._l_incl\", TRUE,
					prefix+\"4._u_incl\", FALSE,
					prefix+\"4._text\", rangeTexts [4],
					prefix+\"4._class\", rangeClasses [4],

					prefix+\"5._type\", DPDETAIL_RANGETYPE_MINMAX,
					prefix+\"5._l_limit\", Fatal_high,
					prefix+\"5._l_incl\", TRUE,
					prefix+\"5._u_incl\", FALSE,
					prefix+\"5._text\", rangeTexts [5],
					prefix+\"5._class\", rangeClasses [5],

					prefix+\"._orig_hdl\", TRUE);
			
	err = getLastError ();	
	if (rc | dynlen(err)) {
		DebugN(\"Failed to set alarm on dpe: \"+dpeName+\" : \"+rc);
		throwError (err);
		return;
	}

	//activate the alarm handling
	dpActivateAlert (dpeName, ok);		
	if ( ! ok) {
		DebugN(\"Failed to activate alarm on dpe: \"+dpeName);
		return;
	}
}

//this subroutine check the existence of a given type
bool dpTypeExists(string dpType)
{
  int index;
  dyn_string dpAllTypes;
  
  //get all types
  dpAllTypes = dpTypes();
  
  //check the existence of the given type 
  for(index=1; index<=dynlen(dpAllTypes); index++)
  	{
  		if(dpAllTypes[index] == dpType) return 1;
  	}
  
  return 0;
}
" 0
 E E E
13 2
"Button2"
""
1 200 260 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 ""
98 218 332 282
T 
1
LANG:1 11 Load Alerts
"//Function Load_Alerts()
main()
{
file crate, card, par, new;
int err, i;
string raw, path, status;

status = \"off\";
setValue(\"\",\"foreCol\",\"Red\");

  /* open Cnf_Crate.txt file */
	path = getPath(PANELS_REL_PATH, \"Cnf_Crate.txt\");
	crate = fopen(path,\"r\");

  /* open Cnf_Card.txt file */
	path = getPath(PANELS_REL_PATH, \"Cnf_Card.txt\");
	card = fopen(path,\"r\");

  /* open Cnf_Para.txt file */	
	path = getPath(PANELS_REL_PATH, \"Cnf_Para.txt\");
	par = fopen(path,\"r\");
	
	err = ferror(card);

  /* open a new file */	
	new = fopen(\"new.txt\",\"w\");

  /* excluding first line of both files */
	fgets( raw, 300, crate );
	fgets( raw, 300, card );
	fgets( raw, 300, par );

  /* setting crate alerts */
	while( fgets( raw, 300, crate))
	  {
	  strreplace( raw, \"\\\"\", \"\");
	  strreplace( raw, \"\\t\", \" \");
	//  DebugN(raw);
	  crateSet( raw, status );
	  }

  /* setting cards alerts */
	while( fgets( raw, 300, card))
	  {
	  strreplace( raw, \"\\\"\", \"\");
	  strreplace( raw, \"\\t\", \" \");
	//  DebugN(raw);
	  cardSet( raw, status );
	  }
	
  /* setting cards alerts */
	while( fgets( raw, 300, par) )  
	{
	  strreplace( raw, \"\\\"\", \"\");
	  strreplace( raw, \"\\t\", \" \");
	//  DebugN(raw);
	  channelSet( raw, status );
	}

/* close files */
fclose(crate);
fclose(card);
fclose(par);
fclose(new);
setValue(\"\",\"foreCol\",\"\");
}


/**************************************************************************\\
|* The following function splits the string from the Cnf_Crate.txt file   *|
|* giving back the setting values for every crate.                        *|
\\**************************************************************************/
void crateSet(string raw, string status)
{
int ID,	Rack, Crate, Host, Node, Port, Unit;
string Para, EoN, EoA, EoO, EoS, Comment, dpName, module,
        s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13,
        s14, s15, s16, s17, s18, s19, s20, s21, s22;
float FatlL_Off, WarnL_Off,	Norm_Off, WarnH_Off, FatlH_Off,
	  FatlL_Stb, WarnL_Stb, Norm_Stb, WarnH_Stb, FatlH_Stb,
	  FatlL_On,	 WarnL_On,	Norm_On,  WarnH_On,	 FatlH_On;

sscanf(raw,
       \"%s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s\",
        s1, s2, s3, Para, EoN, s4, s5, s6, s7, EoA, s8, s9, s10, s11, s12, EoO,
        s13, s14, s15, s16, s17, EoS, s18, s19, s20, s21, s22, Comment);

sscanf(s1,  \"%d\", ID);
sscanf(s2,  \"%d\", Rack);
sscanf(s3,  \"%d\", Crate);
sscanf(s4,  \"%d\", Host);
sscanf(s5,  \"%d\", Node);
sscanf(s6,  \"%d\", Port);
sscanf(s7,  \"%d\", Unit);
sscanf(s8,  \"%f\", FatlL_Off);
sscanf(s9, \"%f\", WarnL_Off);
sscanf(s10, \"%f\", Norm_Off);
sscanf(s11, \"%f\", WarnH_Off);
sscanf(s12, \"%f\", FatlH_Off);
sscanf(s13, \"%f\", FatlL_Stb);
sscanf(s14, \"%f\", WarnL_Stb);
sscanf(s15, \"%f\", Norm_Stb);
sscanf(s16, \"%f\", WarnH_Stb);
sscanf(s17, \"%f\", FatlH_Stb);
sscanf(s18, \"%f\", FatlL_On);
sscanf(s19, \"%f\", WarnL_On);
sscanf(s20, \"%f\", Norm_On);
sscanf(s21, \"%f\", WarnH_On);
sscanf(s22, \"%f\", FatlH_On);

/*  DebugN(s1, s2, s3, Para, EoN, s4, s5, s6, s7, EoA, s8, s9, s10, s11, s12, EoO,
        s13, s14, s15, s16, s17, EoS, s18, s19, s20, s21, s22, Comment);
	DebugN(ID,	Rack,	Crate,	Para,	EoN,	Host,	Node,	Port,	Unit,	EoA,
		FatlL_Off,	WarnL_Off,	Norm_Off,	WarnH_Off,	FatlH_Off,	EoO,
		FatlL_Stb,	WarnL_Stb,	Norm_Stb,	WarnH_Stb,	FatlH_Stb,	EoS,
		FatlL_On,	WarnL_On,	Norm_On,	WarnH_On,	FatlH_On,	Comment);
	DebugN(\"----------------------------------------\");*/
  
  sprintf( module, \"Crate%02d.Controller.\", Crate);

// Scanning for Moni
  if (Comment == \"Moni\")
	{
	dpName = getSystemName() + module + Para + \".Recv\";
	if ( dpExists(dpName) )
		{
		switch(status) // setting values related to actual status
			{
			case \"on\"  :  setAlerts( dpName, FatlL_On,	WarnL_On,	WarnH_On,	FatlH_On );  break;
			case \"off\" :  setAlerts( dpName, FatlL_Off,	WarnL_Off,	WarnH_Off,	FatlH_Off ); break;
			case \"stb\" :  setAlerts( dpName, FatlL_Stb,	WarnL_Stb,	WarnH_Stb,	FatlH_Stb ); break;
			default	 :  DebugN(\"Error in reading! No status available for \",dpName,\".\");
			}
	 	}
	else DebugN(\"Error in reading!\" , dpName, \" doesn't exist.\");
	} 
// Scanning for Command	
  else if (Comment == \"Comm\") {
    dpName = getSystemName() + module + Para + \".Send\";
    if ( dpExists(dpName) )
    	{
		switch(status) // setting values related to actual status
			{
			case \"on\"  :  setAlerts( dpName, FatlL_On,	WarnL_On,	WarnH_On,	FatlH_On );  break;
			case \"off\" :  setAlerts( dpName, FatlL_Off,	WarnL_Off,	WarnH_Off,	FatlH_Off ); break;
			case \"stb\" :  setAlerts( dpName, FatlL_Stb,	WarnL_Stb,	WarnH_Stb,	FatlH_Stb ); break;
			default	 :  DebugN(\"Error in reading! No status available for \",dpName,\".\");
			}
		}	
	else DebugN(\"Error in reading!\" , dpName, \" doesn't exist.\");		
	}
  else DebugN(\"Error in reading! No type available for \", getSystemName() + module + Para);
}



/**************************************************************************\\
|* The following function splits the string from the Cnf_Card.txt file    *|
|* giving back the setting values for every card.                         *|
\\**************************************************************************/
void cardSet(string raw, string status)
{
int ID,	Rack,	Crate,	Card, Host,	Node,	Port,	Unit;
string Para, EoN, EoA, EoO, EoS, Comment, LV_HV, dpName, module,
        s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13,
        s14, s15, s16, s17, s18, s19, s20, s21, s22, s23;
float FatlL_Off, WarnL_Off,	Norm_Off, WarnH_Off, FatlH_Off,
	  FatlL_Stb, WarnL_Stb, Norm_Stb, WarnH_Stb, FatlH_Stb,
	  FatlL_On,	 WarnL_On,	Norm_On,  WarnH_On,	 FatlH_On;

sscanf(raw,
       \"%s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s\",
        s1, s2, s3, s4, Para, EoN, s5, s6, s7, s8, EoA, s9, s10, s11, s12, s13, EoO,
        s14, s15, s16, s17, s18, EoS, s19, s20, s21, s22, s23, LV_HV, Comment);

sscanf(s1,  \"%d\", ID);
sscanf(s2,  \"%d\", Rack);
sscanf(s3,  \"%d\", Crate);
sscanf(s4,  \"%d\", Card);
sscanf(s5,  \"%d\", Host);
sscanf(s6,  \"%d\", Node);
sscanf(s7,  \"%d\", Port);
sscanf(s8,  \"%d\", Unit);
sscanf(s9,  \"%f\", FatlL_Off);
sscanf(s10, \"%f\", WarnL_Off);
sscanf(s11, \"%f\", Norm_Off);
sscanf(s12, \"%f\", WarnH_Off);
sscanf(s13, \"%f\", FatlH_Off);
sscanf(s14, \"%f\", FatlL_Stb);
sscanf(s15, \"%f\", WarnL_Stb);
sscanf(s16, \"%f\", Norm_Stb);
sscanf(s17, \"%f\", WarnH_Stb);
sscanf(s18, \"%f\", FatlH_Stb);
sscanf(s19, \"%f\", FatlL_On);
sscanf(s20, \"%f\", WarnL_On);
sscanf(s21, \"%f\", Norm_On);
sscanf(s22, \"%f\", WarnH_On);
sscanf(s23, \"%f\", FatlH_On);

/*  DebugN(s1, s2, s3, s4, Para, EoN, s5, s6, s7, s8, EoA, s9, s10, s11, s12, s13, EoO,
        s14, s15, s16, s17, s18, EoS, s19, s20, s21, s22, s23, LV_HV, Comment);
	DebugN(ID,	Rack,	Crate,	Card,	Para,	EoN,	Host,	Node,	Port,	Unit,	EoA,
		FatlL_Off,	WarnL_Off,	Norm_Off,	WarnH_Off,	FatlH_Off,	EoO,
		FatlL_Stb,	WarnL_Stb,	Norm_Stb,	WarnH_Stb,	FatlH_Stb,	EoS,
		FatlL_On,	WarnL_On,	Norm_On,	WarnH_On,	FatlH_On,	LV_HV, Comment);
	DebugN(\"----------------------------------------\");*/
  
  Crate = 0;  
  sprintf( module, \"Crate%02d.\" + LV_HV + \"_card%02d.\", Crate, Card );

// Scanning for Moni
  if (Comment == \"Moni\")
	{
	dpName = getSystemName() + module + Para + \".Recv\";
	if ( dpExists(dpName) )
		{
		switch(status) // setting values related to actual status
			{
			case \"on\"  :  setAlerts( dpName, FatlL_On,	WarnL_On,	WarnH_On,	FatlH_On );  break;
			case \"off\" :  setAlerts( dpName, FatlL_Off,	WarnL_Off,	WarnH_Off,	FatlH_Off ); break;
			case \"stb\" :  setAlerts( dpName, FatlL_Stb,	WarnL_Stb,	WarnH_Stb,	FatlH_Stb ); break;
			default	 :  DebugN(\"Error in reading! No status available for \",dpName,\".\");
			}
	 	}
	else DebugN(\"Error in reading!\" , dpName, \" doesn't exist.\");
	} 
// Scanning for Command	
  else if (Comment == \"Comm\") {
    dpName = getSystemName() + module + Para + \".Send\";
    if ( dpExists(dpName) )
    	{
		switch(status) // setting values related to actual status
			{
			case \"on\"  :  setAlerts( dpName, FatlL_On,	WarnL_On,	WarnH_On,	FatlH_On );  break;
			case \"off\" :  setAlerts( dpName, FatlL_Off,	WarnL_Off,	WarnH_Off,	FatlH_Off ); break;
			case \"stb\" :  setAlerts( dpName, FatlL_Stb,	WarnL_Stb,	WarnH_Stb,	FatlH_Stb ); break;
			default	 :  DebugN(\"Error in reading! No status available for \",dpName,\".\");
			}
		}	
	else DebugN(\"Error in reading!\" , dpName, \" doesn't exist.\");		
	}
  else DebugN(\"Error in reading! No type available for \", getSystemName() + module + Para);
}


/**************************************************************************\\
|* The following function splits the string from the Cnf_Para.txt file    *|
|* giving back the setting values for every channel.                      *|
\\**************************************************************************/
void channelSet(string raw, string status)
{
int i, ID,	Mod, Crate; 
string Para, EoO, EoS, Comment, EoP, LV_HV, dpName, module, type,
		s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15, s16, s17;
float FatlL_Off, WarnL_Off,	Norm_Off, WarnH_Off, FatlH_Off,
	  FatlL_Stb, WarnL_Stb, Norm_Stb, WarnH_Stb, FatlH_Stb,
	  FatlL_On,	 WarnL_On,	Norm_On,  WarnH_On,	 FatlH_On;

  sscanf(raw, \"%s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s\",
			   s1, s2, Para, EoP, s3, s4, s5, s6, s7, EoO, s8, s9, s10, s11, s12,
			   EoS, s13, s14, s15, s16, s17, Comment);

sscanf(s1,  \"%d\", ID);
sscanf(s2,  \"%d\", Mod);
sscanf(s3,  \"%f\", FatlL_Off);
sscanf(s4,  \"%f\", WarnL_Off);
sscanf(s5,  \"%f\", Norm_Off);
sscanf(s6,  \"%f\", WarnH_Off);
sscanf(s7,  \"%f\", FatlH_Off);
sscanf(s8,  \"%f\", FatlL_Stb);
sscanf(s9,  \"%f\", WarnL_Stb);
sscanf(s10, \"%f\", Norm_Stb);
sscanf(s11, \"%f\", WarnH_Stb);
sscanf(s12, \"%f\", FatlH_Stb);
sscanf(s13, \"%f\", FatlL_On);
sscanf(s14, \"%f\", WarnL_On);
sscanf(s15, \"%f\", Norm_On);
sscanf(s16, \"%f\", WarnH_On);
sscanf(s17, \"%f\", FatlH_On);

/*  DebugN(s1, s2, Para, EoP, s3, s4, s5, s6, s7, EoO, s8, s9, s10, s11, s12,
			   EoS, s13, s14, s15, s16, s17, Comment);		
	DebugN(ID,	Mod, Para, EoP, 
		FatlL_Off,	WarnL_Off,	Norm_Off,	WarnH_Off,	FatlH_Off,	EoO,
		FatlL_Stb,	WarnL_Stb,	Norm_Stb,	WarnH_Stb,	FatlH_Stb,	EoS,
		FatlL_On,	WarnL_On,	Norm_On,	WarnH_On,	FatlH_On,	Comment);*/

  Crate = 0;
  sprintf( module, \"Crate%02d.Channel%02d.\", Crate, i );
  
// Scanning for Moni
  if (Comment == \"Moni\")
  	{
    dpName = getSystemName() + module + Para + \".Recv\";
    if ( dpExists(dpName) )
    	{
		switch(status) // setting values related to actual status
			{
			case \"on\"  :  setAlerts( dpName, FatlL_On,	WarnL_On,	WarnH_On,	FatlH_On );  break;
			case \"off\" :  setAlerts( dpName, FatlL_Off,	WarnL_Off,	WarnH_Off,	FatlH_Off ); break;
			case \"stb\" :  setAlerts( dpName, FatlL_Stb,	WarnL_Stb,	WarnH_Stb,	FatlH_Stb ); break;
			default	 :  DebugN(\"Error in reading! No status available for \",dpName,\".\");
		    }
		}
	else DebugN(\"Error in reading!\" , dpName, \" doesn't exist.\");		
    }
// Scanning for Command	  
  else if (Comment == \"Comm\")
  	{
    dpName = getSystemName() + module + Para + \".Send\";
    if ( dpExists(dpName) )
    	{
		switch(status) // setting values related to actual status
			{
	  		case \"on\"  :  setAlerts( dpName, FatlL_On,	WarnL_On,	WarnH_On,	FatlH_On );  break;
  	  		case \"off\" :  setAlerts( dpName, FatlL_Off,	WarnL_Off,	WarnH_Off,	FatlH_Off ); break;
      		case \"stb\" :  setAlerts( dpName, FatlL_Stb,	WarnL_Stb,	WarnH_Stb,	FatlH_Stb ); break;
	  		default	 :  DebugN(\"Error in reading! No status available for \",dpName,\".\");	  
		  	}
		}
	else DebugN(\"Error in reading!\" , dpName, \" doesn't exist.\");		
	}
// Scanning for read&write Parameters
  else if (Comment == \"MoniComm\")
  	{
  	for(i=1; i<=2; i++)
		{
		switch(i)
			{
			case 1 : type = \".Send\"; break;
			case 2 : type = \".Recv\"; break;
			}
	    dpName = getSystemName() + module + Para + type;
	    if ( dpExists(dpName) )
	    	{
	    	switch(status) // setting values related to actual status
	    		{
				case \"on\"  :  setAlerts( dpName, FatlL_On,	WarnL_On,	WarnH_On,	FatlH_On );  break;
				case \"off\" :  setAlerts( dpName, FatlL_Off,	WarnL_Off,	WarnH_Off,	FatlH_Off ); break;
				case \"stb\" :  setAlerts( dpName, FatlL_Stb,	WarnL_Stb,	WarnH_Stb,	FatlH_Stb ); break;
				default	 :  DebugN(\"Error in reading! No status available for \",dpName,\".\");
				}
			}
		else DebugN(\"Error in reading!\" , dpName, \" doesn't exist.\");		
	    }
	}
  else DebugN(\"Error in reading! No type available for \",getSystemName() + module + Para); 
  }

/*****************************************************************************************\\
|* The following function sets alert config for the datapoint element dpeName            *|
|* with the five alert ranges neighbouring Fatal_low, Warn_low, Warn_high and Fatal_high *|
\\*****************************************************************************************/
 setAlerts(string dpeName, float Fatal_low, float Warn_low,
                                float Warn_high, float Fatal_high)
{
	string prefix = dpeName+\":_alert_hdl.\";
	dyn_errClass err;
	int rc, type;
	bool ok;
	dyn_string 	rangeTexts 		= makeDynString (\"Data is fatal Low\", \"Data is warn. Low\", \"Data is Normal\", \"Data is warn. High\", \"Data is fatal High\");
	dyn_string 	rangeClasses 	= makeDynString (\"alert.\", \"warning.\", \"\", \"warning.\", \"alert.\");

if ( !(dpeName < Fatal_low < Warn_low < Warn_high < Fatal_high)) 
	{
	DebugN(\"Error! Invalid limits for\", dpeName, \" : \", Fatal_low, Warn_low, Warn_high, Fatal_high);
	return; 
	}
//	DebugN(dpeName, \" : \", Fatal_low, Warn_low, Warn_high, Fatal_high);
	
	// check if the alarm already exists
	rc = dpGet (prefix+\"._type\", type);
	err = getLastError ();	
	if (rc | dynlen(err)) {
		DebugN(\"Failed to check whether alarm already exists for dpe: \"+dpeName+\" : \"+rc);
		throwError (err);
		return;
	}

	// if it exists, deactivate the alarm handling (so we can change it)
	if (type != DPCONFIG_NONE) {
		dpDeactivateAlert (dpeName, ok);		
		if ( ! ok) {
			DebugN(\"Failed to deactivate alarm on dpe: \"+dpeName);
			return;
		}
	}
	
	// configure the alarm
	rc = dpSetWait (prefix+\"._type\", DPCONFIG_ALERT_NONBINARYSIGNAL, // equal to 13!

					prefix+\"1._type\", DPDETAIL_RANGETYPE_MINMAX, // equal to 4!
					prefix+\"1._u_limit\", Fatal_low,
					prefix+\"1._l_incl\", TRUE,
					prefix+\"1._u_incl\", FALSE,
					prefix+\"1._text\",  rangeTexts [1],
					prefix+\"1._class\", rangeClasses [1],

					prefix+\"2._type\", DPDETAIL_RANGETYPE_MINMAX,
					prefix+\"2._l_limit\", Fatal_low,
					prefix+\"2._u_limit\", Warn_low,
					prefix+\"2._l_incl\", TRUE,
					prefix+\"2._u_incl\", FALSE,
					prefix+\"2._text\", rangeTexts [2],
					prefix+\"2._class\", rangeClasses [2],

					prefix+\"3._type\", DPDETAIL_RANGETYPE_MINMAX,
					prefix+\"3._l_limit\", Warn_low,
					prefix+\"3._u_limit\", Warn_high,
					prefix+\"3._l_incl\", TRUE,
					prefix+\"3._u_incl\", FALSE,
					prefix+\"3._text\", rangeTexts [3],
					prefix+\"3._class\", rangeClasses [3],

					prefix+\"4._type\", DPDETAIL_RANGETYPE_MINMAX,
					prefix+\"4._l_limit\", Warn_high,
					prefix+\"4._u_limit\", Fatal_high,
					prefix+\"4._l_incl\", TRUE,
					prefix+\"4._u_incl\", FALSE,
					prefix+\"4._text\", rangeTexts [4],
					prefix+\"4._class\", rangeClasses [4],

					prefix+\"5._type\", DPDETAIL_RANGETYPE_MINMAX,
					prefix+\"5._l_limit\", Fatal_high,
					prefix+\"5._l_incl\", TRUE,
					prefix+\"5._u_incl\", FALSE,
					prefix+\"5._text\", rangeTexts [5],
					prefix+\"5._class\", rangeClasses [5],

					prefix+\"._orig_hdl\", TRUE);
			
	err = getLastError ();	
	if (rc | dynlen(err)) {
		DebugN(\"Failed to set alarm on dpe: \"+dpeName+\" : \"+rc);
		throwError (err);
		return;
	}

	//activate the alarm handling
	dpActivateAlert (dpeName, ok);		
	if ( ! ok) {
		DebugN(\"Failed to activate alarm on dpe: \"+dpeName);
		return;
	}
}

//this subroutine check the existence of a given type
bool dpTypeExists(string dpType)
{
  int index;
  dyn_string dpAllTypes;
  
  //get all types
  dpAllTypes = dpTypes();
  
  //check the existence of the given type 
  for(index=1; index<=dynlen(dpAllTypes); index++)
  	{
  		if(dpAllTypes[index] == dpType) return 1;
  	}
  
  return 0;
}
" 0
 E E E
13 3
"Button3"
""
1 100 130 E E E 1 E 1 E N "_3DText" E N {102,204,255} E E
 E E
2 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 ""
98 128 332 192
T 
1
LANG:1 17 Load Alerts_old_1
"//Function Load_Alerts()
main()
{
file card, par, new;
int err, i, j;
string raw, path;
int ID,	Rack,	Crate,	Card, Host,	Node,	Port,	Unit;
int Mod, enab; 
string Para, EoN, EoA, EoO, EoS, Comment, EoP, LV_HV;
float FatlL_Off, WarnL_Off,	Norm_Off, WarnH_Off, FatlH_Off,
	  FatlL_Stb, WarnL_Stb, Norm_Stb, WarnH_Stb, FatlH_Stb,
	  FatlL_On,	 WarnL_On,	Norm_On,  WarnH_On,	 FatlH_On;
string status, dpName, module, type;

status = \"off\";

setValue(\"\",\"foreCol\",\"Red\");
path = getPath(PANELS_REL_PATH, \"Cnf_Card.txt\");
card = fopen(path,\"r\");
path = getPath(PANELS_REL_PATH, \"Cnf_Para.txt\");
par = fopen(path,\"r\");
err = ferror(card);
new = fopen(\"new.txt\",\"w\");
fgets( raw, 300, card );
fgets( raw, 300, par );

// fgets( raw, 300, card);
while( fgets( raw, 300, card))
  {
  strreplace( raw, \"\\\"\", \"\");
  strreplace( raw, \"\\t\", \" \");
//  DebugN(raw);
  sscanf(raw,
       \"%d %d %d %d %s %s %d %d %d %d %s %f %f %f %f %f %s %f %f %f %f %f %s %f %f %f %f %f %s %s\",
		ID,	Rack,	Crate,	Card,	Para,	EoN,	Host,	Node,	Port,	Unit,	EoA,
		FatlL_Off,	WarnL_Off,	Norm_Off,	WarnH_Off,	FatlH_Off,	EoO,
		FatlL_Stb,	WarnL_Stb,	Norm_Stb,	WarnH_Stb,	FatlH_Stb,	EoS,
		FatlL_On,	WarnL_On,	Norm_On,	WarnH_On,	FatlH_On,	LV_HV, Comment);

/*  DebugN(ID,	Rack,	Crate,	Card,	Para,	EoN,	Host,	Node,	Port,	Unit,	EoA,
		FatlL_Off,	WarnL_Off,	Norm_Off,	WarnH_Off,	FatlH_Off,	EoO,
		FatlL_Stb,	WarnL_Stb,	Norm_Stb,	WarnH_Stb,	FatlH_Stb,	EoS,
		FatlL_On,	WarnL_On,	Norm_On,	WarnH_On,	FatlH_On,	LV_HV, Comment);*/

  Crate = 0;  
  sprintf( module, \"Crate%02d.\" + LV_HV + \"_card%02d.\", Crate, Card );

// Scanning for Moni
  if (Comment == \"Moni\")
	{
	dpName = getSystemName() + module + Para + \".Recv\";
	if ( dpExists(dpName) )
		{
		switch(status) // setting values related to actual status
			{
			case \"on\"  :  setAlerts( dpName, FatlL_On,	WarnL_On,	WarnH_On,	FatlH_On );  break;
			case \"off\" :  setAlerts( dpName, FatlL_Off,	WarnL_Off,	WarnH_Off,	FatlH_Off ); break;
			case \"stb\" :  setAlerts( dpName, FatlL_Stb,	WarnL_Stb,	WarnH_Stb,	FatlH_Stb ); break;
			default	 :  DebugN(\"Error in reading! No status available for \",dpName,\".\");
			}
	 	}
	else DebugN(\"Error in reading!\" , dpName, \" doesn't exist.\");
	} 
// Scanning for Command	
  else if (Comment == \"Comm\") {
    dpName = getSystemName() + module + Para + \".Send\";
    if ( dpExists(dpName) )
    	{
		switch(status) // setting values related to actual status
			{
			case \"on\"  :  setAlerts( dpName, FatlL_On,	WarnL_On,	WarnH_On,	FatlH_On );  break;
			case \"off\" :  setAlerts( dpName, FatlL_Off,	WarnL_Off,	WarnH_Off,	FatlH_Off ); break;
			case \"stb\" :  setAlerts( dpName, FatlL_Stb,	WarnL_Stb,	WarnH_Stb,	FatlH_Stb ); break;
			default	 :  DebugN(\"Error in reading! No status available for \",dpName,\".\");
			}
		}	
	else DebugN(\"Error in reading!\" , dpName, \" doesn't exist.\");		
	}
  else DebugN(\"Error in reading! No type available for \", getSystemName() + module + Para);
}
  
for (j=0; j <=10; j++) {
fgets( raw, 300, par);  
//while( fgets( raw, 300, par) ){
  strreplace( raw, \"\\\"\", \"\");
  strreplace( raw, \"x\", \"\");
  strreplace( raw, \"\\t\", \" \");
//  DebugN(raw);
  sscanf(raw, \"%d %d %s %s %f %f %f %f %f %s %f %f %f %f %f %s %f %f %f %f %f %d %s\",
		ID,	Mod, Para, EoP, 
		FatlL_Off,	WarnL_Off,	Norm_Off,	WarnH_Off,	FatlH_Off,	EoO,
		FatlL_Stb,	WarnL_Stb,	Norm_Stb,	WarnH_Stb,	FatlH_Stb,	EoS,
		FatlL_On,	WarnL_On,	Norm_On,	WarnH_On,	FatlH_On,	enab, Comment);
/*  DebugN(ID,	Mod, Para, EoP, 
		FatlL_Off,	WarnL_Off,	Norm_Off,	WarnH_Off,	FatlH_Off,	EoO,
		FatlL_Stb,	WarnL_Stb,	Norm_Stb,	WarnH_Stb,	FatlH_Stb,	EoS,
		FatlL_On,	WarnL_On,	Norm_On,	WarnH_On,	FatlH_On,	enab, Comment);*/
   
  Crate = 0;
  sprintf( module, \"Crate%02d.Channel%02d.\", Crate, i );
  
// Scanning for Moni
  if (Comment == \"Moni\")
  	{
    dpName = getSystemName() + module + Para + \".Recv\";
    if ( dpExists(dpName) )
    	{
		switch(status) // setting values related to actual status
			{
			case \"on\"  :  setAlerts( dpName, FatlL_On,	WarnL_On,	WarnH_On,	FatlH_On );  break;
			case \"off\" :  setAlerts( dpName, FatlL_Off,	WarnL_Off,	WarnH_Off,	FatlH_Off ); break;
			case \"stb\" :  setAlerts( dpName, FatlL_Stb,	WarnL_Stb,	WarnH_Stb,	FatlH_Stb ); break;
			default	 :  DebugN(\"Error in reading! No status available for \",dpName,\".\");
		    }
		}
	else DebugN(\"Error in reading!\" , dpName, \" doesn't exist.\");		
    }
// Scanning for Command	  
  else if (Comment == \"Comm\")
  	{
    dpName = getSystemName() + module + Para + \".Send\";
    if ( dpExists(dpName) )
    	{
		switch(status) // setting values related to actual status
			{
	  		case \"on\"  :  setAlerts( dpName, FatlL_On,	WarnL_On,	WarnH_On,	FatlH_On );  break;
  	  		case \"off\" :  setAlerts( dpName, FatlL_Off,	WarnL_Off,	WarnH_Off,	FatlH_Off ); break;
      		case \"stb\" :  setAlerts( dpName, FatlL_Stb,	WarnL_Stb,	WarnH_Stb,	FatlH_Stb ); break;
	  		default	 :  DebugN(\"Error in reading! No status available for \",dpName,\".\");	  
		  	}
		}
	else DebugN(\"Error in reading!\" , dpName, \" doesn't exist.\");		
	}
// Scanning for read&write Parameters
  else if (Comment == \"MoniComm\")
  	{
  	for(i=1; i<=2; i++)
		{
		switch(i)
			{
			case 1 : type = \".Send\"; break;
			case 2 : type = \".Recv\"; break;
			}
	    dpName = getSystemName() + module + Para + type;
	    if ( dpExists(dpName) )
	    	{
	    	switch(status) // setting values related to actual status
	    		{
				case \"on\"  :  setAlerts( dpName, FatlL_On,	WarnL_On,	WarnH_On,	FatlH_On );  break;
				case \"off\" :  setAlerts( dpName, FatlL_Off,	WarnL_Off,	WarnH_Off,	FatlH_Off ); break;
				case \"stb\" :  setAlerts( dpName, FatlL_Stb,	WarnL_Stb,	WarnH_Stb,	FatlH_Stb ); break;
				default	 :  DebugN(\"Error in reading! No status available for \",dpName,\".\");
				}
			}
		else DebugN(\"Error in reading!\" , dpName, \" doesn't exist.\");		
	    }
	}
  else DebugN(\"Error in reading! No type available for \",getSystemName() + module + Para); 
  }

fclose(card);
fclose(par);
fclose(new);
setValue(\"\",\"foreCol\",\"\");
}

/*****************************************************************************************\\
|* The following function sets alert config for the datapoint element dpeName            *|
|* with the five alert ranges neighbouring Fatal_low, Warn_low, Warn_high and Fatal_high *|
\\*****************************************************************************************/
 setAlerts(string dpeName, float Fatal_low, float Warn_low,
                                float Warn_high, float Fatal_high)
{
	string prefix = dpeName+\":_alert_hdl.\";
	dyn_errClass err;
	int rc, type;
	bool ok;
	dyn_string 	rangeTexts 		= makeDynString (\"Data is fatal Low\", \"Data is warn. Low\", \"Data is Normal\", \"Data is warn. High\", \"Data is fatal High\");
	dyn_string 	rangeClasses 	= makeDynString (\"alert.\", \"warning.\", \"\", \"warning.\", \"alert.\");

if ( !(dpeName < Fatal_low < Warn_low < Warn_high < Fatal_high)) 
	{
	DebugN(\"Error! Invalid limits for\", dpeName, \" : \", Fatal_low, Warn_low, Warn_high, Fatal_high);
	return; 
	}
//	DebugN(dpeName, \" : \", Fatal_low, Warn_low, Warn_high, Fatal_high);
	
	// check if the alarm already exists
	rc = dpGet (prefix+\"._type\", type);
	err = getLastError ();	
	if (rc | dynlen(err)) {
		DebugN(\"Failed to check whether alarm already exists for dpe: \"+dpeName+\" : \"+rc);
		throwError (err);
		return;
	}

	// if it exists, deactivate the alarm handling (so we can change it)
	if (type != DPCONFIG_NONE) {
		dpDeactivateAlert (dpeName, ok);		
		if ( ! ok) {
			DebugN(\"Failed to deactivate alarm on dpe: \"+dpeName);
			return;
		}
	}
	
	// configure the alarm
	rc = dpSetWait (prefix+\"._type\", DPCONFIG_ALERT_NONBINARYSIGNAL, // equal to 13!

					prefix+\"1._type\", DPDETAIL_RANGETYPE_MINMAX, // equal to 4!
					prefix+\"1._u_limit\", Fatal_low,
					prefix+\"1._l_incl\", TRUE,
					prefix+\"1._u_incl\", FALSE,
					prefix+\"1._text\",  rangeTexts [1],
					prefix+\"1._class\", rangeClasses [1],

					prefix+\"2._type\", DPDETAIL_RANGETYPE_MINMAX,
					prefix+\"2._l_limit\", Fatal_low,
					prefix+\"2._u_limit\", Warn_low,
					prefix+\"2._l_incl\", TRUE,
					prefix+\"2._u_incl\", FALSE,
					prefix+\"2._text\", rangeTexts [2],
					prefix+\"2._class\", rangeClasses [2],

					prefix+\"3._type\", DPDETAIL_RANGETYPE_MINMAX,
					prefix+\"3._l_limit\", Warn_low,
					prefix+\"3._u_limit\", Warn_high,
					prefix+\"3._l_incl\", TRUE,
					prefix+\"3._u_incl\", FALSE,
					prefix+\"3._text\", rangeTexts [3],
					prefix+\"3._class\", rangeClasses [3],

					prefix+\"4._type\", DPDETAIL_RANGETYPE_MINMAX,
					prefix+\"4._l_limit\", Warn_high,
					prefix+\"4._u_limit\", Fatal_high,
					prefix+\"4._l_incl\", TRUE,
					prefix+\"4._u_incl\", FALSE,
					prefix+\"4._text\", rangeTexts [4],
					prefix+\"4._class\", rangeClasses [4],

					prefix+\"5._type\", DPDETAIL_RANGETYPE_MINMAX,
					prefix+\"5._l_limit\", Fatal_high,
					prefix+\"5._l_incl\", TRUE,
					prefix+\"5._u_incl\", FALSE,
					prefix+\"5._text\", rangeTexts [5],
					prefix+\"5._class\", rangeClasses [5],

					prefix+\"._orig_hdl\", TRUE);
			
	err = getLastError ();	
	if (rc | dynlen(err)) {
		DebugN(\"Failed to set alarm on dpe: \"+dpeName+\" : \"+rc);
		throwError (err);
		return;
	}

	//activate the alarm handling
	dpActivateAlert (dpeName, ok);		
	if ( ! ok) {
		DebugN(\"Failed to activate alarm on dpe: \"+dpeName);
		return;
	}
}

//this subroutine check the existence of a given type
bool dpTypeExists(string dpType)
{
  int index;
  dyn_string dpAllTypes;
  
  //get all types
  dpAllTypes = dpTypes();
  
  //check the existence of the given type 
  for(index=1; index<=dynlen(dpAllTypes); index++)
  	{
  		if(dpAllTypes[index] == dpType) return 1;
  	}
  
  return 0;
}
" 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