V 10
1
LANG:1 8 (NoName)
PANEL,268 69 929 410 N "_3DFace" 0
EEE E E 1 -1 -1 0  -1 -1
"" 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
"Button1"
""
1 20 50 E E E 1 E 1 E N "_3DText" E N {204,204,153} E E
 E E
1 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 117 -microsoft windows-Courier New-bold-r-normal-*-*-200-100-100-*-*-iso8859-1|-24,0,0,0,700,0,0,0,0,3,2,1,49,Courier New
0 ""
18 48 282 112
T 
1
LANG:1 10 set Alerts
"main()
{
   setAlert(\"Crate00.Channel00.LVch_Vcc.Recv\", -200., -100., 100., 200.);
}

setAlert(string dpeName, float alarm_low, float warn_low, float warn_high, float alarm_high)
{
  int alert_exist, status;
  unsigned num_ranges = 0;

  //test if the alert exist already
  status = dpGet(dpeName + \":_alert_hdl.._type\", alert_exist);

  if(!status && !alert_exist)
    {
  	   //set analog alert (13 means analag alerts and 12 binary alerts)
	   dpSet(dpeName + \":_alert_hdl.._type\", 13,
	
 	   //set three ranges
	   dpeName + \":_alert_hdl.1._type\", 4,  //alarm low range
	   dpeName + \":_alert_hdl.2._type\", 4,  //warning low range
	   dpeName + \":_alert_hdl.3._type\", 4,  //normal range
	   dpeName + \":_alert_hdl.4._type\", 4,  //waring high range
	   dpeName + \":_alert_hdl.5._type\", 4,  //alarm high range
 
       //set each range: each range consists of two values (borders)
	   dpeName + \":_alert_hdl.1._u_limit\", alarm_low, 
	   dpeName + \":_alert_hdl.2._l_limit\", alarm_low, 
	   dpeName + \":_alert_hdl.2._u_limit\", warn_low, 
	   dpeName + \":_alert_hdl.3._l_limit\", warn_low,
	   dpeName + \":_alert_hdl.3._u_limit\", warn_high,
	   dpeName + \":_alert_hdl.4._l_limit\", warn_high,
	   dpeName + \":_alert_hdl.4._u_limit\", alarm_high,
	   dpeName + \":_alert_hdl.5._l_limit\", alarm_high,
			 
 	   //set the limit of each range, look for consistency!	
	   dpeName + \":_alert_hdl.1._u_incl\", TRUE,  
	   dpeName + \":_alert_hdl.2._l_incl\", FALSE, 
	   dpeName + \":_alert_hdl.2._u_incl\", TRUE, 
	   dpeName + \":_alert_hdl.3._l_incl\", FALSE, 
	   dpeName + \":_alert_hdl.3._u_incl\", FALSE, 
	   dpeName + \":_alert_hdl.4._l_incl\", TRUE, 
	   dpeName + \":_alert_hdl.4._u_incl\", FALSE, 
	   dpeName + \":_alert_hdl.5._l_incl\", TRUE, 

	   //set alert texts
	   dpeName + \":_alert_hdl.1._text\", \"alarm: Too Low Value\",  
	   dpeName + \":_alert_hdl.2._text\", \"Warning: Low Value\", 
	   dpeName + \":_alert_hdl.3._text\", \"Normal Value\",
	   dpeName + \":_alert_hdl.4._text\", \"Warning: High Value\",
	   dpeName + \":_alert_hdl.5._text\", \"alarm: Too High Value\",
 
       //set alert class
	   dpeName + \":_alert_hdl.1._class\", \"alert.\", 
	   dpeName + \":_alert_hdl.2._class\", \"warning.\",
	   dpeName + \":_alert_hdl.4._class\", \"warning.\",
	   dpeName + \":_alert_hdl.5._class\", \"alert.\",
	
	   //working with the original value
	   dpeName + \":_alert_hdl.._orig_hdl\", TRUE, 
 
 	   //activates the alert handling
	   dpeName + \":_alert_hdl.._active\", TRUE); 
    }
  else
    {
  	   //get the number of  alert ranges
	   dpGet(dpeName + \":_alert_hdl.._num_ranges\", num_ranges);
	
	  //make sure there are 5 ranges (the case of script)
	  if(num_ranges == 5)
	    {
	  	   //acknoledge the alert if any, otherwise the parameters cann't be changed
	       dpSet(dpeName + \":_alert_hdl.._ack\", 1);

		   //desactivates the alert handling
	   	   dpSet(dpeName + \":_alert_hdl.._active\", FALSE, 
	
    	   //set each range: each range consists of two values (borders)
	 	   dpeName + \":_alert_hdl.1._u_limit\", alarm_low, 
		   dpeName + \":_alert_hdl.2._l_limit\", alarm_low, 
		   dpeName + \":_alert_hdl.2._u_limit\", warn_low, 
		   dpeName + \":_alert_hdl.3._l_limit\", warn_low,
		   dpeName + \":_alert_hdl.3._u_limit\", warn_high,
		   dpeName + \":_alert_hdl.4._l_limit\", warn_high,
		   dpeName + \":_alert_hdl.4._u_limit\", alarm_high,
		   dpeName + \":_alert_hdl.5._l_limit\", alarm_high);
 
		   //re-activates the alert handling
		   dpSet(dpeName + \":_alert_hdl.._active\", TRUE);
	    }
	  else
	    {
	 	   Debug(\"ERROR in alert script, there are not 5 ranges as assumed\");
	    }
    }//end of else
}" 0
 E E E
13 1
"Button2"
""
1 300 50 E E E 1 E 1 E N "_3DText" E N {204,204,153} E E
 E E
2 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 117 -microsoft windows-Courier New-bold-r-normal-*-*-200-100-100-*-*-iso8859-1|-24,0,0,0,700,0,0,0,0,3,2,1,49,Courier New
0 ""
298 48 572 112
T 
1
LANG:1 13 Active Alerts
"main()
{
   activateAlert(\"Crate00.Channel00.LVch_Vcc.Recv\");
}

activateAlert(string dpeName)
{
  int alert_exist, status;


  //find out if the alert exist
  status = dpGet(dpeName + \":_alert_hdl.._type\", alert_exist);

  if(!status && alert_exist)
    {
	   //activates the alert handling
	   dpSet(dpeName + \":_alert_hdl.._active\", TRUE); 
    }
}" 0
 E E E
13 3
"Button4"
""
1 20 290 E E E 1 E 1 E N "_3DText" E N {204,204,153} E E
 E E
4 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 117 -microsoft windows-Courier New-bold-r-normal-*-*-200-100-100-*-*-iso8859-1|-24,0,0,0,700,0,0,0,0,3,2,1,49,Courier New
0 ""
18 288 282 352
T 
1
LANG:1 15 set OPC Address
"main()
{
	setOPCAddress(\"Crate00.Channel00.LVch_Vcc.Send\", \"opcItem\", \"VT_UI2\", \"OUT\", \"CANopen\", 2, \"Para\");
}

setOPCAddress(string dpeName, string OPCItemName, string dpeType, string direction, string opcServerName, 
			  int driverNum, string OPCGroup) 
{ 

	int intDirection, intDpeType;
	string reference, opc, group; 
	dyn_errClass err; 
	
	//check if OPC OPC server exist
	opc = getSystemName() + \"_\" + opcServerName;
    if(!dpExists(opc))
	{ 
		Debug(\"setOPCAddress(): OPC Server: \" + opcServerName + \" does not exist\"); 
		return;
	} 

	//check if OPC group exist
	group = getSystemName() + \"_\" + OPCGroup; 
	if (!dpExists(group))
	{
		Debug(\"setOPCAddress(): OPC group \" + OPCGroup + \" does not exist\");
		return;
	} 
	
    //the full OPC item address  
	reference = opcServerName + \"$\" + OPCGroup + \"$\" + OPCItemName; 

	//the direction (read or write):
	if(direction == \"OUT\" || direction == \"out\" || direction == \"Out\")
		{
			intDirection = DPATTR_ADDR_MODE_OUTPUT_SINGLE;
		}
	else if(direction == \"IN\" || direction == \"in\" || direction == \"In\")
	{
        intDirection = DPATTR_ADDR_MODE_INPUT_SPONT;
	}

	switch(intDirection) 
	{
		case DPATTR_ADDR_MODE_OUTPUT_SINGLE:
		case DPATTR_ADDR_MODE_INPUT_SPONT:
		case DPATTR_ADDR_MODE_INPUT_SPONT + 64:
		case DPATTR_ADDR_MODE_OUTPUT_SINGLE + 64:
			dpSetWait(	dpeName + \":_distrib.._type\", DPCONFIG_DISTRIBUTION_INFO,
						dpeName + \":_distrib.._driver\", driverNum);
			err = getLastError();
			if(dynlen(err) > 0) 
			{
				throwError(err);
				DebugN(\"setOPCAddress(): Error while creating the address config\");
			}

			//find the PVSS OPC client data type:
			switch(dpeType)
				{
					case   \"VT_UI1\":
						//uint8
				        intDpeType = 0; 
						break;
	
					case   \"VT_UI2\":
				        //uint16
				        intDpeType = 488;
						break;

					case   \"VT_UI4\":
				        //uint32
				        intDpeType = 489;
						break;

					case   \"VT_BOOL\":
				        //Bool
				        intDpeType = 486;
						break;

					case   \"VT_FLOAT8\":
				        //float64
				        intDpeType = 485;
						break;

					case   \"VT_FLOAT4\":

				        //float32
				        intDpeType = 484;
						break;

					case   \"VT_I1\":
				        //int8
 				       intDpeType = 0;
						break;

					case   \"VT_I2\":
				        //int16
				        intDpeType = 481;
						break;

					case   \"VT_I4\":
				        //int32
				        intDpeType = 482;
						break;

					case   \"VT_STRING\":
				        //string
		 		       	intDpeType = 487;
						break;
	
					case   \"default\":
				        //default
						intDpeType = 0;
						break;

					default:
		 		       	//unknown
		 		     	intDpeType = 480;
						break;
				}
				
			//set the address config parameters
			dpSetWait(	dpeName + \":_address.._type\", DPCONFIG_PERIPH_ADDR_MAIN,
						dpeName + \":_address.._reference\", reference,
						dpeName + \":_address.._datatype\", intDpeType,
						dpeName + \":_address.._mode\", intDirection,
						dpeName + \":_address.._drv_ident\", \"OPCCLIENT\");
						
			err = getLastError();
			if(dynlen(err) > 0) 
			{ 
            	throwError(err);
            	DebugN(\"setOPCAddress(): Error while configuring the peripheral address\");
            } 
			break;
		default:
			DebugN(\"setOPCAddress(): the selected mode \" + intDirection + \" is unknown\");
			return;
	} 
}" 0
 E E E
13 4
"Button5"
""
1 300 290 E E E 1 E 1 E N "_3DText" E N {204,204,153} E E
 E E
5 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 117 -microsoft windows-Courier New-bold-r-normal-*-*-200-100-100-*-*-iso8859-1|-24,0,0,0,700,0,0,0,0,3,2,1,49,Courier New
0 ""
298 288 572 352
T 
1
LANG:1 18 Active OPC Address
"main()
{
	activateOPCAddress(\"Crate00.Channel00.LVch_Vcc.Send\");
}

activateOPCAddress(string dpeName) 
{
  int address_exist, status;


  //find out if the address exist
  status = dpGet(dpeName + \":_address.._type\", address_exist);

  if(!status && address_exist)
    {
       dpSetWait(	dpeName + \":_address.._active\", TRUE);
    }
}" 0
 E E E
13 5
"Button6"
""
1 590 50 E E E 1 E 1 E N "_3DText" E N {204,204,153} E E
 E E
6 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 117 -microsoft windows-Courier New-bold-r-normal-*-*-200-100-100-*-*-iso8859-1|-24,0,0,0,700,0,0,0,0,3,2,1,49,Courier New
0 ""
588 48 902 112
T 
1
LANG:1 16 Disactive Alerts
"main()
{
   disactivateAlert(\"Crate00.Channel00.LVch_Vcc.Recv\");
}

disactivateAlert(string dpeName)
{
  int alert_exist, status;


  //find out if the alert exist
  status = dpGet(dpeName + \":_alert_hdl.._type\", alert_exist);

  if(!status && alert_exist)
    {
	   //acknoledge the alert if any, otherwise it cann't be disactiveted
	   dpSet(dpeName + \":_alert_hdl.._ack\", 1);

	   //desactivate the alert handling
	   dpSet(dpeName + \":_alert_hdl.._active\", FALSE); 
    }
}" 0
 E E E
13 6
"Button7"
""
1 590 290 E E E 1 E 1 E N "_3DText" E N {204,204,153} E E
 E E
7 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 117 -microsoft windows-Courier New-bold-r-normal-*-*-200-100-100-*-*-iso8859-1|-24,0,0,0,700,0,0,0,0,3,2,1,49,Courier New
0 ""
588 288 902 352
T 
1
LANG:1 21 Disactive OPC Address
"main()
{
	disactivateOPCAddress(\"Crate00.Channel00.LVch_Vcc.Send\");
}

disactivateOPCAddress(string dpeName) 
{
  int address_exist, status;


  //find out if the address exist
  status = dpGet(dpeName + \":_address.._type\", address_exist);

  if(!status && address_exist)
    {
       dpSetWait(	dpeName + \":_address.._active\", FALSE);
    }
}" 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