V 10
1
LANG:1 0 
PANEL,258 100 643 544 N "_3DFace" 0
EEE E E 1 -1 -1 0  140 340
"" 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 36
"Button4"
""
1 170 90 E E E 1 E 1 E N "_3DText" E N {204,204,102} E E
 E E
37 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 88 572 272
T 
1
LANG:1 41 Press this button to simulate an IV Curve
"main()
{
	string systemName = getSystemName();
	dpConnect(\"startIVCurve\", FALSE, systemName+\"requestIVCurve.trigger:_online.._value\");
}

startIVCurve(string dpePath, int dpeValue)
{
	int crate, channel;
	string channelAddress, IVCurveParameters, allChannels, systemName;
	dyn_string para_split;



	if(dpeValue == TRUE)
	   {
	   		systemName = getSystemName();
			//get the actual value of Rack, Crate and channel
			dpGet(\"requestIVCurve.parameters:_online.._value\", IVCurveParameters);
			para_split=strsplit(IVCurveParameters,\"|\");
			
			//sscanf(para_split[1],\"%f\", mod_ID);
			sscanf(para_split[1],\"%d\", crate);
			sscanf(para_split[2],\"%s\", allChannels);
 	
			if(allChannels == \"ALL\")
	  	  	   {
					//IV curve for all channels
	 				channel = 255;
	  	  	   }
		 	  else
	  	       {
	   				sscanf(allChannels,\"%d\", channel);
	      	   }
	      	//make a 2 digit label for crates
		 	sprintf(channelAddress, \"Crate%02d.Channel%02d\", crate, channel);
		 	
		 	//connect the StartIVCurve of the IV curve of the given channel
		 	//dpConnect(\"IVCurveSimulation\", FALSE, systemName+channelAddress+\".IVCurve.StartIVCurve.Send:_online.._value\");
		 	dpConnect(\"IVCurveSimulation\", FALSE, \"Crate00.Controller.StartIVCurve.Send:_online.._value\");

		}
}

IVCurveSimulation(string dpePath, int dpeValue)
{
	int istep;
	int crate, channel, start,stop,step,end,Imax,Iwarn,Twait;
	float voltage, current, Vstart, Vstop, Vstep;
	string channelAddress, IVCurveParameters, allChannels;
	dyn_string para_split;



	string systemName = getSystemName();

	if(dpeValue == 1)
	   {
			//get the actual value of Rack, Crate and channel
			dpGet(\"requestIVCurve.parameters:_online.._value\", IVCurveParameters);
			para_split=strsplit(IVCurveParameters,\"|\");

			sscanf(para_split[1],\"%d\", crate);
			sscanf(para_split[2],\"%s\", allChannels);
 	
			if(allChannels == \"ALL\")
	  	  	   {
					//IV curve for all channels
	 				channel = 255;
	  	  	   }
		 	  else
	  	       {
	   				sscanf(allChannels,\"%d\", channel);
	      	   }
	      	//make a 2 digit label for crates
		 	sprintf(channelAddress, \"Crate%02d.Channel%02d\", crate, channel);

			dpGet(systemName+channelAddress+\".IVCurve.HV_Start.Send:_online.._value\", Vstart);
			dpGet(systemName+channelAddress+\".IVCurve.HV_Stop.Send:_online.._value\",   Vstop);
			dpGet(systemName+channelAddress+\".IVCurve.HV_Step.Send:_online.._value\",  Vstep);
	
			voltage = 0;
			current = 0;
			istep = 0;
	
			dpSet(systemName+channelAddress+\".IVCurve.Status.Recv:_original.._value\", 255);
	
			for(voltage=Vstart; voltage<=Vstop; voltage=voltage+Vstep)
				{
					DebugN(\"====================== voltage = \", voltage);
					dpSet(systemName+channelAddress+\".HVchVolt.Recv:_original.._value\", voltage);
					current = exp(voltage/40);
					dpSet(systemName+channelAddress+\".HVchCurr.Recv:_original.._value\", current);
					istep = istep +1;
					dpSet(systemName+channelAddress+\".IVCurve.Status.Recv:_original.._value\", istep);
					//break;
					delay(2);
			    }
 			//tell that IV Curve is finished
 			dpSet(systemName+channelAddress+\".IVCurve.Status.Recv:_original.._value\", 251);
			
			//discconnect the IV curve connection done above
        	dpDisconnect(\"IVCurveSimulation\", \"Crate00.Controller.StartIVCurve.Send:_online.._value\");
 	   }//end of if(dpeValue == 1)
}" 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