V 10
1
LANG:1 8 HistPlot
PANEL,258 70 960 660 N "_3DFace" 1
"$Tab_Numb"
"/* Histogram Panel for MoPS
123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456*/
/*===================================-======================================*/
/*                        HISTOGRAM PANEL FOR SCT_DCS                       */
/*-----------------------------------=--------------------------------------*/
/* AUTHORs:        Abdel Abessalam, S.Basiladze (some additions)

   DESIGN ISSUEs:  This Panel contains 8 Histograms, every histogram has a
                   selector for any Rack/Crate/Channel/Parameter taking.
                   The number of bins in every histogram may be predefined.
                   Histograming starts on 'Go' button and is building for
                   Archive Data only for predefined number of hours.

   MODIF_HISTORY:  27.06.2003 - first version
  ===================================-======================================*/
main()
{
	int index;
	string dpeName;
	int rack, crate, bins, hours, ch_hv_lv_num;
	dyn_string dpeName_split, chan_para_list;
	

//=========================== initialise Histograms from 01 to 08 =============================
	for(index=1; index<= 4; index++)
	  {
	  	//initialisations
	  	rack = 0; crate = 0; bins =0; hours = 0; ch_hv_lv_num =0;
	  	dpeName = \"\";
		//set channel defaults
 		setValue(\"Ch_HV_LV_Num0\"+index, \"sbMaximum\", 48);				
		chan_para_list = makeDynString(\"LVch_Vcc\", \"LVps_Vcc\", \"LVretVcc\", \"LVch_Icc\", 
				\"LVch_Vdd\", \"LVps_Vdd\", \"LVretVdd\", \"LVch_Idd\", \"LVchVCSV\", \"LVchVCSI\", 
				\"LVchPINV\", \"LVchPINI\", \"MOch_Tm0\", \"MOch_Tm1\", \"HVchVolt\", \"HVchCurr\");
		setValue(\"Parameter0\"+index, \"items\", chan_para_list);
		setValue(\"Parameter0\"+index, \"selectedPos\", 0);	
	
		//set a default value for the number of hours
		setValue(\"Hours0\"+index, \"text\", 5);
		//set a default value for the number of bins
		setValue(\"Bins0\"+index, \"text\", 50);
	
		//take the old configuration if it exist
		dpGet(\"SCTmops1:Hist0\"+$Tab_Numb+\".Name0\"+index+\":_online.._value\", dpeName);
		dpGet(\"SCTmops1:Hist0\"+$Tab_Numb+\".Bins0\"+index+\":_online.._value\", bins);
		dpGet(\"SCTmops1:Hist0\"+$Tab_Numb+\".Hour0\"+index+\":_online.._value\", hours);
	
 		if(dpeName != \"\")
 	  	  {
			dpeName_split = strsplit(dpeName, \".\");

			//set a default value for the Rack number
			sscanf(strltrim(dpeName_split[1], \"SCTmops1:Crate\"), \"%d\", crate);
			rack = crate / 4; // because numbering in the pannels is from 0
			crate = crate - (rack * 4); // because numbering in the pannels is from 0
//			rack = crate/4 + 1; // +1 because numbering in the pannels is from 1
//			crate = crate - (rack-1)*4 + 1; // +1 because numbering in the pannels is from 1
	
			setValue(\"Rack0\"+index, \"text\", rack);
			//set a default value for the Crate number		
			setValue(\"Crate0\"+index, \"text\", crate);
		
			if(patternMatch(\"Channel*\", dpeName_split[2]))
			  {
				//set a default value for the Ch_HV_LV combobox number: in this case it channel
				setValue(\"Ch_HV_LV0\"+index, \"selectedPos\", 1);
				setValue(\"Ch_HV_LV_Num0\"+index, \"sbMaximum\", 48);
				setValue(\"Parameter0\"+index, \"items\", chan_para_list);
				//set a default value for the Channel number
				sscanf(strltrim(dpeName_split[2], \"Channel\"),\"%d\", ch_hv_lv_num);
				setValue(\"Ch_HV_LV_Num0\"+index, \"text\", ch_hv_lv_num);
//				setValue(\"Ch_HV_LV_Num0\"+index, \"text\", ch_hv_lv_num+1);
			  }		
		 	 else if(patternMatch(\"HV_card*\", dpeName_split[2]))
		      {
				//set a default value for the Ch_HV_LV combobox number: in this case it HVcard
				setValue(\"Ch_HV_LV0\"+index, \"selectedPos\", 2);			
				setValue(\"Ch_HV_LV_Num0\"+index, \"sbMaximum\", 6);
				setValue(\"Parameter0\"+index, \"items\", makeDynString(\"no para\"));
				//set a default value for the HVcard number
				sscanf(strltrim(dpeName_split[2], \"HV_card\"),\"%d\", ch_hv_lv_num);
				setValue(\"Ch_HV_LV_Num0\"+index, \"text\", ch_hv_lv_num);
//				setValue(\"Ch_HV_LV_Num0\"+index, \"text\", ch_hv_lv_num+1);
			  }
			else if(patternMatch(\"LV_card*\", dpeName_split[2]))
			  {
				//set a default value for the Ch_HV_LV combobox number: in this case it LVcard
				setValue(\"Ch_HV_LV0\"+index, \"selectedPos\", 3);			
				setValue(\"Ch_HV_LV_Num0\"+index, \"sbMaximum\", 12);
				setValue(\"Parameter0\"+index, \"items\", makeDynString(\"LVcaTemp\", \"LVcaPowr\"));
				//set a default value for the HVcard number
				sscanf(strltrim(dpeName_split[2], \"LV_card\"),\"%d\", ch_hv_lv_num);
				setValue(\"Ch_HV_LV_Num0\"+index, \"text\", ch_hv_lv_num);
//				setValue(\"Ch_HV_LV_Num0\"+index, \"text\", ch_hv_lv_num+1);
 		  	  }

			//set a default value for the parameter number
			setValue(\"Parameter0\"+index, \"text\", dpeName_split[3]);
			//set a default value for the number of bins
			setValue(\"Bins0\"+index, \"text\", bins);
			//set a default value for the number of hours
			setValue(\"Hours0\"+index, \"text\", hours);
		  }
		else
	  	  {
	  		DebugN(\"INFO: Histograms \"+index+\" of Monitor_\"+$Tab_Numb+\", no previous configuration stored.\");
	   	  }
      }//enf of for(...)
}" 0
EE E E 1 -1 -1 0  60 50
"" 0 1
EE 2
"CBRef""0"
"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
6 213
"Border1"
""
1 0 455 E E E 1 E 1 E N {0,0,0} E N {51,102,153} E E
 E E
103 0 0 0 0 0
EE E
0
1
LANG:1 21 Vers.01.1, 27-06-2003
1
"dashclr"N "_Transparent"
E E 0 1 1 0 1 E U  1 E 0 0 960 660
2 580
"Text4"
""
1 755 621 E E E 1 E 1 E N {0,0,0} E N {204,204,204} E E
 E E
466 0 0 0 0 0
EE E
0
1
LANG:1 0 
1
"dashclr"N "_Transparent"
E E 0 1 1 0 1 E U  1 E 757 623 843 641
1 2 0 "s" 0 0 0 64 0 0  757 623
 1
1
LANG:1 105 -microsoft windows-Arial-bold-r-normal-*-*-120-100-100-*-*-iso8859-1|-13,0,0,0,700,0,0,0,0,3,2,1,34,Arial
0 ""
1
LANG:1 12  Ca/Ch Para:
2 590
"Text9"
""
1 20 621 E E E 1 E 1 E N {0,0,0} E N {204,204,204} E E
 E E
476 0 0 0 0 0
EE E
0
1
LANG:1 0 
1
"dashclr"N "_Transparent"
E E 0 1 1 0 1 E U  1 E 22 623 68 641
1 2 0 "s" 0 0 0 64 0 0  22 623
 1
1
LANG:1 105 -microsoft windows-Arial-bold-r-normal-*-*-120-100-100-*-*-iso8859-1|-13,0,0,0,700,0,0,0,0,3,2,1,34,Arial
0 ""
1
LANG:1 4 Rack
2 591
"Text10"
""
1 100 620 E E E 1 E 1 E N {0,0,0} E N {204,204,204} E E
 E E
477 0 0 0 0 0
EE E
0
1
LANG:1 0 
1
"dashclr"N "_Transparent"
E E 0 1 1 0 1 E U  1 E 102 622 158 640
1 2 0 "s" 0 0 0 64 0 0  102 622
 1
1
LANG:1 105 -microsoft windows-Arial-bold-r-normal-*-*-120-100-100-*-*-iso8859-1|-13,0,0,0,700,0,0,0,0,3,2,1,34,Arial
0 ""
1
LANG:1 5 Crate
2 593
"Text12"
""
1 280 621 E E E 1 E 1 E N {0,0,0} E N {204,204,204} E E
 E E
479 0 0 0 0 0
EE E
0
1
LANG:1 0 
1
"dashclr"N "_Transparent"
E E 0 1 1 0 1 E U  1 E 282 623 368 641
1 2 0 "s" 0 0 0 64 0 0  282 623
 1
1
LANG:1 105 -microsoft windows-Arial-bold-r-normal-*-*-120-100-100-*-*-iso8859-1|-13,0,0,0,700,0,0,0,0,3,2,1,34,Arial
0 ""
1
LANG:1 12  Ca/Ch Para:
2 599
"Text13"
""
1 495 301 E E E 1 E 1 E N {0,0,0} E N {204,204,204} E E
 E E
485 0 0 0 0 0
EE E
0
1
LANG:1 0 
1
"dashclr"N "_Transparent"
E E 0 1 1 0 1 E U  1 E 497 303 543 321
1 2 0 "s" 0 0 0 64 0 0  497 303
 1
1
LANG:1 105 -microsoft windows-Arial-bold-r-normal-*-*-120-100-100-*-*-iso8859-1|-13,0,0,0,700,0,0,0,0,3,2,1,34,Arial
0 ""
1
LANG:1 4 Rack
2 600
"Text14"
""
1 575 301 E E E 1 E 1 E N {0,0,0} E N {204,204,204} E E
 E E
486 0 0 0 0 0
EE E
0
1
LANG:1 0 
1
"dashclr"N "_Transparent"
E E 0 1 1 0 1 E U  1 E 577 303 623 321
1 2 0 "s" 0 0 0 64 0 0  577 303
 1
1
LANG:1 105 -microsoft windows-Arial-bold-r-normal-*-*-120-100-100-*-*-iso8859-1|-13,0,0,0,700,0,0,0,0,3,2,1,34,Arial
0 ""
1
LANG:1 5 Crate
2 602
"Text16"
""
1 755 301 E E E 1 E 1 E N {0,0,0} E N {204,204,204} E E
 E E
488 0 0 0 0 0
EE E
0
1
LANG:1 0 
1
"dashclr"N "_Transparent"
E E 0 1 1 0 1 E U  1 E 757 303 843 321
1 2 0 "s" 0 0 0 64 0 0  757 303
 1
1
LANG:1 105 -microsoft windows-Arial-bold-r-normal-*-*-120-100-100-*-*-iso8859-1|-13,0,0,0,700,0,0,0,0,3,2,1,34,Arial
0 ""
1
LANG:1 12  Ca/Ch Para:
2 611
"text000"
""
1 280 301 E E E 1 E 1 E N {0,0,0} E N {204,204,204} E E
 E E
497 0 0 0 0 0
EE E
0
1
LANG:1 0 
1
"dashclr"N "_Transparent"
E E 0 1 1 0 1 E U  1 E 282 303 368 321
1 2 0 "s" 0 0 0 64 0 0  282 303
 1
1
LANG:1 105 -microsoft windows-Arial-bold-r-normal-*-*-120-100-100-*-*-iso8859-1|-13,0,0,0,700,0,0,0,0,3,2,1,34,Arial
0 ""
1
LANG:1 12  Ca/Ch Para:
2 578
"Text2"
""
1 575 621 E E E 1 E 1 E N {0,0,0} E N {204,204,204} E E
 E E
464 0 0 0 0 0
EE E
0
1
LANG:1 0 
1
"dashclr"N "_Transparent"
E E 0 1 1 0 1 E U  1 E 577 623 633 641
1 2 0 "s" 0 0 0 64 0 0  577 623
 1
1
LANG:1 105 -microsoft windows-Arial-bold-r-normal-*-*-120-100-100-*-*-iso8859-1|-13,0,0,0,700,0,0,0,0,3,2,1,34,Arial
0 ""
1
LANG:1 5 Crate
2 608
"Text17"
""
1 20 301 E E E 1 E 1 E N {0,0,0} E N {204,204,204} E E
 E E
494 0 0 0 0 0
EE E
0
1
LANG:1 0 
1
"dashclr"N "_Transparent"
E E 0 1 1 0 1 E U  1 E 22 303 68 321
1 2 0 "s" 0 0 0 64 0 0  22 303
 1
1
LANG:1 105 -microsoft windows-Arial-bold-r-normal-*-*-120-100-100-*-*-iso8859-1|-13,0,0,0,700,0,0,0,0,3,2,1,34,Arial
0 ""
1
LANG:1 4 Rack
2 609
"Text18"
""
1 100 301 E E E 1 E 1 E N {0,0,0} E N {204,204,204} E E
 E E
495 0 0 0 0 0
EE E
0
1
LANG:1 0 
1
"dashclr"N "_Transparent"
E E 0 1 1 0 1 E U  1 E 102 303 148 321
1 2 0 "s" 0 0 0 64 0 0  102 303
 1
1
LANG:1 105 -microsoft windows-Arial-bold-r-normal-*-*-120-100-100-*-*-iso8859-1|-13,0,0,0,700,0,0,0,0,3,2,1,34,Arial
0 ""
1
LANG:1 5 Crate
2 577
"Text1"
""
1 495 621 E E E 1 E 1 E N {0,0,0} E N {204,204,204} E E
 E E
463 0 0 0 0 0
EE E
0
1
LANG:1 0 
1
"dashclr"N "_Transparent"
E E 0 1 1 0 1 E U  1 E 497 623 543 641
1 2 0 "s" 0 0 0 64 0 0  497 623
 1
1
LANG:1 105 -microsoft windows-Arial-bold-r-normal-*-*-120-100-100-*-*-iso8859-1|-13,0,0,0,700,0,0,0,0,3,2,1,34,Arial
0 ""
1
LANG:1 4 Rack
13 850
"Button10"
""
1 20 336 E E E 1 E 1 E N "_3DText" E N {153,153,153} E E
 E E
729 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 119 -microsoft windows-Courier New-normal-r-normal-*-*-110-100-100-*-*-iso8859-1|-12,0,0,0,400,0,0,0,0,3,2,1,49,Courier New
0 ""
18 334 464 368
T 
1
LANG:1 7 Button1
E E E E
13 849
"Button9"
""
1 19 5 E E E 1 E 1 E N "_3DText" E N {153,153,153} E E
 E E
728 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 119 -microsoft windows-Courier New-normal-r-normal-*-*-110-100-100-*-*-iso8859-1|-12,0,0,0,400,0,0,0,0,3,2,1,49,Courier New
0 ""
17 3 462 37
T 
1
LANG:1 7 Button1
E E E E
13 848
"Button8"
""
1 495 5 E E E 1 E 1 E N "_3DText" E N {153,153,153} E E
 E E
727 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 119 -microsoft windows-Courier New-normal-r-normal-*-*-110-100-100-*-*-iso8859-1|-12,0,0,0,400,0,0,0,0,3,2,1,49,Courier New
0 ""
493 3 938 37
T 
1
LANG:1 7 Button1
E E E E
13 847
"Button4"
""
1 495 335 E E E 1 E 1 E N "_3DText" E N {153,153,153} E E
 E E
726 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 119 -microsoft windows-Courier New-normal-r-normal-*-*-110-100-100-*-*-iso8859-1|-12,0,0,0,400,0,0,0,0,3,2,1,49,Courier New
0 ""
493 333 938 367
T 
1
LANG:1 7 Button1
E E E E
27 825
"Hist04"
""
1 1365 -985 E E E 1 E 1 E N {0,255,255} E N {0,0,0} E E
 E E
706 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 119 -microsoft windows-Courier New-normal-r-normal-*-*-110-100-100-*-*-iso8859-1|-12,0,0,0,400,0,0,0,0,3,2,1,49,Courier New
0 ""
493 358 937 622
2 0 50 10 0 "%H:%M" 1 1
LANG:1 118 -microsoft windows-Courier New-normal-r-normal-*-*-110-100-100-*-*-iso8859-1|-12,0,0,0,400,0,0,0,0,0,0,0,0,Courier New
0 ""
0 2 1 1 0 1 N {153,153,153}
0 0 50 10 0 "%H:%M" 1 1
LANG:1 118 -microsoft windows-Courier New-normal-r-normal-*-*-110-100-100-*-*-iso8859-1|-12,0,0,0,400,0,0,0,0,0,0,0,0,Courier New
0 ""
0 2 1 1 0 1 N {153,153,153}
1 1 1 0 1
LANG:1 118 -microsoft windows-Courier New-normal-r-normal-*-*-110-100-100-*-*-iso8859-1|-12,0,0,0,400,0,0,0,0,0,0,0,0,Courier New
0 ""
2 1 1 0 1 N {153,153,153}
0 1 1 0 1 N {153,153,153}
5 0 0 100 0 N {0,0,0} N {0,0,0} N {255,0,0} 1
1 0 1 1 0 1 N {255,255,0} 1 E
27 824
"Hist03"
""
1 901 -985 E E E 1 E 1 E N {0,255,255} E N {0,0,0} E E
 E E
705 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 119 -microsoft windows-Courier New-normal-r-normal-*-*-110-100-100-*-*-iso8859-1|-12,0,0,0,400,0,0,0,0,3,2,1,49,Courier New
0 ""
8 358 462 622
2 0 50 10 0 "%H:%M" 1 1
LANG:1 118 -microsoft windows-Courier New-normal-r-normal-*-*-110-100-100-*-*-iso8859-1|-12,0,0,0,400,0,0,0,0,0,0,0,0,Courier New
0 ""
0 2 1 1 0 1 N {153,153,153}
0 0 50 10 0 "%H:%M" 1 1
LANG:1 118 -microsoft windows-Courier New-normal-r-normal-*-*-110-100-100-*-*-iso8859-1|-12,0,0,0,400,0,0,0,0,0,0,0,0,Courier New
0 ""
0 2 1 1 0 1 N {153,153,153}
1 1 1 0 1
LANG:1 118 -microsoft windows-Courier New-normal-r-normal-*-*-110-100-100-*-*-iso8859-1|-12,0,0,0,400,0,0,0,0,0,0,0,0,Courier New
0 ""
2 1 1 0 1 N {153,153,153}
0 1 1 0 1 N {153,153,153}
5 0 0 100 0 N {0,0,0} N {0,0,0} N {255,0,0} 1
1 0 1 1 0 1 N {255,255,0} 1 E
27 488
"Hist02"
""
1 1821 -1324 E E E 1 E 1 E N {0,255,255} E N {0,0,0} E E
 E E
376 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 119 -microsoft windows-Courier New-normal-r-normal-*-*-110-100-100-*-*-iso8859-1|-12,0,0,0,400,0,0,0,0,3,2,1,49,Courier New
0 ""
493 28 937 302
2 0 50 10 0 "%H:%M" 1 1
LANG:1 118 -microsoft windows-Courier New-normal-r-normal-*-*-110-100-100-*-*-iso8859-1|-12,0,0,0,400,0,0,0,0,0,0,0,0,Courier New
0 ""
0 2 1 1 0 1 N {153,153,153}
0 0 50 10 0 "%H:%M" 1 1
LANG:1 118 -microsoft windows-Courier New-normal-r-normal-*-*-110-100-100-*-*-iso8859-1|-12,0,0,0,400,0,0,0,0,0,0,0,0,Courier New
0 ""
0 2 1 1 0 1 N {153,153,153}
1 1 1 0 1
LANG:1 118 -microsoft windows-Courier New-normal-r-normal-*-*-110-100-100-*-*-iso8859-1|-12,0,0,0,400,0,0,0,0,0,0,0,0,Courier New
0 ""
2 1 1 0 1 N {153,153,153}
0 1 1 0 1 N {153,153,153}
5 0 0 100 0 N {0,0,0} N {0,0,0} N {255,0,0} 1
1 0 1 1 0 1 N {255,255,0} 1 E
27 823
"Hist01"
""
1 902 -1366 E E E 1 E 1 E N {0,255,255} E N {0,0,0} E E
 E E
704 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 119 -microsoft windows-Courier New-normal-r-normal-*-*-110-100-100-*-*-iso8859-1|-12,0,0,0,400,0,0,0,0,3,2,1,49,Courier New
0 ""
8 28 462 302
2 0 50 10 0 "%H:%M" 1 1
LANG:1 118 -microsoft windows-Courier New-normal-r-normal-*-*-110-100-100-*-*-iso8859-1|-12,0,0,0,400,0,0,0,0,0,0,0,0,Courier New
0 ""
0 2 1 1 0 1 N {153,153,153}
0 0 50 10 0 "%H:%M" 1 1
LANG:1 118 -microsoft windows-Courier New-normal-r-normal-*-*-110-100-100-*-*-iso8859-1|-12,0,0,0,400,0,0,0,0,0,0,0,0,Courier New
0 ""
0 2 1 1 0 1 N {153,153,153}
1 1 1 0 1
LANG:1 118 -microsoft windows-Courier New-normal-r-normal-*-*-110-100-100-*-*-iso8859-1|-12,0,0,0,400,0,0,0,0,0,0,0,0,Courier New
0 ""
2 1 1 0 1 N {153,153,153}
0 1 1 0 1 N {153,153,153}
5 0 0 100 0 N {0,0,0} N {0,0,0} N {255,0,0} 1
1 0 1 1 0 1 N {255,255,0} 1 E
21 594
"Rack03"
""
1 60 620 E E E 1 E 1 E N "_WindowText" E N "_Window" E E
 E E
480 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 117 -microsoft windows-Courier New-bold-r-normal-*-*-120-100-100-*-*-iso8859-1|-12,0,0,0,700,0,0,0,0,3,2,1,49,Courier New
0 ""
58 618 102 645
0
E
E
E

N 0 21 1 0 0 1
21 595
"Crate03"
""
1 140 620 E E E 1 E 1 E N "_WindowText" E N "_Window" E E
 E E
481 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 117 -microsoft windows-Courier New-bold-r-normal-*-*-120-100-100-*-*-iso8859-1|-12,0,0,0,700,0,0,0,0,3,2,1,49,Courier New
0 ""
138 618 182 645
0
E
E
E

N 0 3 1 0 0 1
21 603
"Rack02"
""
1 535 300 E E E 1 E 1 E N "_WindowText" E N "_Window" E E
 E E
489 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 117 -microsoft windows-Courier New-bold-r-normal-*-*-120-100-100-*-*-iso8859-1|-12,0,0,0,700,0,0,0,0,3,2,1,49,Courier New
0 ""
533 298 577 325
0
E
E
E

N 0 21 1 0 0 1
21 604
"Crate02"
""
1 615 300 E E E 1 E 1 E N "_WindowText" E N "_Window" E E
 E E
490 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 117 -microsoft windows-Courier New-bold-r-normal-*-*-120-100-100-*-*-iso8859-1|-12,0,0,0,700,0,0,0,0,3,2,1,49,Courier New
0 ""
613 298 657 325
0
E
E
E

N 0 3 1 0 0 1
21 612
"Rack01"
""
1 60 300 E E E 1 E 1 E N "_WindowText" E N "_Window" E E
 E E
498 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 117 -microsoft windows-Courier New-bold-r-normal-*-*-120-100-100-*-*-iso8859-1|-12,0,0,0,700,0,0,0,0,3,2,1,49,Courier New
0 ""
58 298 102 325
0
E
E
E

N 0 21 1 0 0 1
21 613
"Crate01"
""
1 140 300 E E E 1 E 1 E N "_WindowText" E N "_Window" E E
 E E
499 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 117 -microsoft windows-Courier New-bold-r-normal-*-*-120-100-100-*-*-iso8859-1|-12,0,0,0,700,0,0,0,0,3,2,1,49,Courier New
0 ""
138 298 182 325
0
E
E
E

N 0 3 1 0 0 1
21 743
"Bins04"
""
1 641 337 E E E 1 E 1 E N "_WindowText" E N "_Window" E E
 E E
629 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 117 -microsoft windows-Courier New-bold-r-normal-*-*-120-100-100-*-*-iso8859-1|-12,0,0,0,700,0,0,0,0,3,2,1,49,Courier New
0 ""
639 335 683 362
0
E
E
E

N 5 100 5 5 0 1
21 745
"Hours04"
""
1 727 336 E E E 1 E 1 E N "_WindowText" E N "_Window" E E
 E E
631 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 117 -microsoft windows-Courier New-bold-r-normal-*-*-120-100-100-*-*-iso8859-1|-12,0,0,0,700,0,0,0,0,3,2,1,49,Courier New
0 ""
725 334 769 361
0
E
E
E

N 1 100 2 1 0 1
21 747
"Bins03"
""
1 160 336 E E E 1 E 1 E N "_WindowText" E N "_Window" E E
 E E
633 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 117 -microsoft windows-Courier New-bold-r-normal-*-*-120-100-100-*-*-iso8859-1|-12,0,0,0,700,0,0,0,0,3,2,1,49,Courier New
0 ""
158 334 202 361
0
E
E
E

N 5 100 5 5 0 1
21 749
"Hours03"
""
1 246 337 E E E 1 E 1 E N "_WindowText" E N "_Window" E E
 E E
635 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 117 -microsoft windows-Courier New-bold-r-normal-*-*-120-100-100-*-*-iso8859-1|-12,0,0,0,700,0,0,0,0,3,2,1,49,Courier New
0 ""
244 335 288 362
0
E
E
E

N 1 100 2 1 0 1
21 751
"Bins02"
""
1 645 6 E E E 1 E 1 E N "_WindowText" E N "_Window" E E
 E E
637 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 117 -microsoft windows-Courier New-bold-r-normal-*-*-120-100-100-*-*-iso8859-1|-12,0,0,0,700,0,0,0,0,3,2,1,49,Courier New
0 ""
643 4 687 31
0
E
E
E

N 5 100 5 5 0 1
21 753
"Hours02"
""
1 730 6 E E E 1 E 1 E N "_WindowText" E N "_Window" E E
 E E
639 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 117 -microsoft windows-Courier New-bold-r-normal-*-*-120-100-100-*-*-iso8859-1|-12,0,0,0,700,0,0,0,0,3,2,1,49,Courier New
0 ""
728 4 772 31
0
E
E
E

N 1 100 2 1 0 1
21 755
"Bins01"
""
1 160 6 E E E 1 E 1 E N "_WindowText" E N "_Window" E E
 E E
641 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 117 -microsoft windows-Courier New-bold-r-normal-*-*-120-100-100-*-*-iso8859-1|-12,0,0,0,700,0,0,0,0,3,2,1,49,Courier New
0 ""
158 4 202 31
0
E
E
E

N 5 100 5 5 0 1
21 757
"Hours01"
""
1 245 6 E E E 1 E 1 E N "_WindowText" E N "_Window" E E
 E E
643 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 117 -microsoft windows-Courier New-bold-r-normal-*-*-120-100-100-*-*-iso8859-1|-12,0,0,0,700,0,0,0,0,3,2,1,49,Courier New
0 ""
243 4 287 31
0
E
E
E

N 1 100 2 1 0 1
21 568
"Rack04"
""
1 535 620 E E E 1 E 1 E N "_WindowText" E N "_Window" E E
 E E
455 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 117 -microsoft windows-Courier New-bold-r-normal-*-*-120-100-100-*-*-iso8859-1|-12,0,0,0,700,0,0,0,0,3,2,1,49,Courier New
0 ""
533 618 577 645
0
E
E
E

N 0 21 1 0 0 1
21 569
"Crate04"
""
1 615 620 E E E 1 E 1 E N "_WindowText" E N "_Window" E E
 E E
456 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 117 -microsoft windows-Courier New-bold-r-normal-*-*-120-100-100-*-*-iso8859-1|-12,0,0,0,700,0,0,0,0,3,2,1,49,Courier New
0 ""
613 618 657 645
0
E
E
E

N 0 3 1 0 0 1
13 574
"Button2"
""
1 -20 0 E E E 1 E 1 E N "_Window" E N {51,102,153} E E
 E E
461 0 0 0 0 0
EE E
1
1
LANG:1 0 
0
1
LANG:1 119 -microsoft windows-Courier New-normal-r-normal-*-*-110-100-100-*-*-iso8859-1|-12,0,0,0,400,0,0,0,0,3,2,1,49,Courier New
0 ""
-22 -2 2 652
T 
1
LANG:1 0 
E E E E
13 790
"Stat04"
""
1 768 336 E E E 1 E 1 E N {0,51,255} E N "_3DFace" E E
 E E
673 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 117 -microsoft windows-Courier New-bold-r-normal-*-*-120-100-100-*-*-iso8859-1|-13,0,0,0,700,0,0,0,0,3,2,1,49,Courier New
0 ""
766 334 857 361
T 
1
LANG:1 10 Statistics
"main()
{
	bool visible;
	getValue(\"StatBox04\", \"visible\", visible);

	if(visible)
		setValue(\"StatBox04\", \"visible\", FALSE);
	else
		setValue(\"StatBox04\", \"visible\", TRUE);
}" 0
 E E E
13 791
"Stat03"
""
1 287 337 E E E 1 E 1 E N {0,51,255} E N "_3DFace" E E
 E E
674 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 117 -microsoft windows-Courier New-bold-r-normal-*-*-120-100-100-*-*-iso8859-1|-13,0,0,0,700,0,0,0,0,3,2,1,49,Courier New
0 ""
285 335 380 362
T 
1
LANG:1 10 Statistics
"main()
{
	bool visible;
	getValue(\"StatBox03\", \"visible\", visible);

	if(visible)
		setValue(\"StatBox03\", \"visible\", FALSE);
	else
		setValue(\"StatBox03\", \"visible\", TRUE);
}" 0
 E E E
13 792
"Stat02"
""
1 771 6 E E E 1 E 1 E N {0,51,255} E N "_3DFace" E E
 E E
675 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 117 -microsoft windows-Courier New-bold-r-normal-*-*-120-100-100-*-*-iso8859-1|-13,0,0,0,700,0,0,0,0,3,2,1,49,Courier New
0 ""
769 4 866 31
T 
1
LANG:1 10 Statistics
"main()
{
	bool visible;
	getValue(\"StatBox02\", \"visible\", visible);

	if(visible)
		setValue(\"StatBox02\", \"visible\", FALSE);
	else
		setValue(\"StatBox02\", \"visible\", TRUE);
}" 0
 E E E
13 793
"Stat01"
""
1 286 5 E E E 1 E 1 E N {0,51,255} E N "_3DFace" E E
 E E
676 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 117 -microsoft windows-Courier New-bold-r-normal-*-*-120-100-100-*-*-iso8859-1|-13,0,0,0,700,0,0,0,0,3,2,1,49,Courier New
0 ""
284 3 382 31
T 
1
LANG:1 10 Statistics
"main()
{
	bool visible;
	getValue(\"StatBox01\", \"visible\", visible);

	if(visible)
		setValue(\"StatBox01\", \"visible\", FALSE);
	else
		setValue(\"StatBox01\", \"visible\", TRUE);
}" 0
 E E E
17 814
"StatBox01"
""
1 310 30 E E E 1 E 0 E N {0,255,255} E N {102,102,102} E E
 E E
696 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 109 -microsoft windows-Courier-bold-r-normal-*-*-100-100-100-*-*-iso8859-1|-13,0,0,0,700,0,0,0,0,1,2,1,49,Courier
0 ""
308 28 460 155
1
1
LANG:1 17 press Go first !!
 0
E
E
E

3 1
17 815
"StatBox02"
""
1 785 30 E E E 1 E 0 E N {0,255,255} E N {102,102,102} E E
 E E
697 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 109 -microsoft windows-Courier-bold-r-normal-*-*-100-100-100-*-*-iso8859-1|-13,0,0,0,700,0,0,0,0,1,2,1,49,Courier
0 ""
783 28 937 155
1
1
LANG:1 17 press Go first !!
 0
E
E
E

3 1
17 817
"StatBox03"
""
1 310 360 E E E 1 E 0 E N {0,255,255} E N {102,102,102} E E
 E E
699 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 109 -microsoft windows-Courier-bold-r-normal-*-*-100-100-100-*-*-iso8859-1|-13,0,0,0,700,0,0,0,0,1,2,1,49,Courier
0 ""
308 358 461 485
1
1
LANG:1 17 press Go first !!
 0
E
E
E

3 1
17 818
"StatBox04"
""
1 785 360 E E E 1 E 0 E N {0,255,255} E N {102,102,102} E E
 E E
700 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 109 -microsoft windows-Courier-bold-r-normal-*-*-100-100-100-*-*-iso8859-1|-13,0,0,0,700,0,0,0,0,1,2,1,49,Courier
0 ""
783 358 936 485
1
1
LANG:1 17 press Go first !!
 0
E
E
E

3 1
13 830
"Button3"
""
1 0 10 E E E 1 E 1 E N {51,102,153} E N {51,102,153} E E
 E E
711 0 0 0 0 0
EE E
1
1
LANG:1 0 
0
1
LANG:1 119 -microsoft windows-Courier New-normal-r-normal-*-*-110-100-100-*-*-iso8859-1|-12,0,0,0,400,0,0,0,0,3,2,1,49,Courier New
0 ""
-2 8 20 662
T 
1
LANG:1 0 
E E E E
13 769
"Button16"
""
1 465 0 E E E 1 E 1 E N {51,102,153} E N {51,102,153} E E
 E E
653 0 0 0 0 0
EE E
1
1
LANG:1 0 
0
1
LANG:1 119 -microsoft windows-Courier New-normal-r-normal-*-*-110-100-100-*-*-iso8859-1|-12,0,0,0,400,0,0,0,0,3,2,1,49,Courier New
0 ""
463 -2 497 652
T 
1
LANG:1 0 
E E E E
13 754
"Button55"
""
1 119 6 E E E 1 E 1 E N "_3DText" E N "_3DFace" E E
 E E
640 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 117 -microsoft windows-Courier New-bold-r-normal-*-*-120-100-100-*-*-iso8859-1|-12,0,0,0,700,0,0,0,0,3,2,1,49,Courier New
0 ""
118 4 162 32
T 
1
LANG:1 4 Bins
E E E E
13 756
"Button56"
""
1 201 6 E E E 1 E 1 E N "_3DText" E N "_3DFace" E E
 E E
642 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 117 -microsoft windows-Courier New-bold-r-normal-*-*-120-100-100-*-*-iso8859-1|-12,0,0,0,700,0,0,0,0,3,2,1,49,Courier New
0 ""
199 4 248 31
T 
1
LANG:1 5 Hours
E E E E
13 750
"Button53"
""
1 605 6 E E E 1 E 1 E N "_3DText" E N "_3DFace" E E
 E E
636 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 117 -microsoft windows-Courier New-bold-r-normal-*-*-120-100-100-*-*-iso8859-1|-12,0,0,0,700,0,0,0,0,3,2,1,49,Courier New
0 ""
603 4 647 32
T 
1
LANG:1 4 Bins
E E E E
13 752
"Button54"
""
1 685 6 E E E 1 E 1 E N "_3DText" E N "_3DFace" E E
 E E
638 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 117 -microsoft windows-Courier New-bold-r-normal-*-*-120-100-100-*-*-iso8859-1|-12,0,0,0,700,0,0,0,0,3,2,1,49,Courier New
0 ""
683 4 732 31
T 
1
LANG:1 5 Hours
E E E E
13 746
"Button51"
""
1 119 336 E E E 1 E 1 E N "_3DText" E N "_3DFace" E E
 E E
632 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 117 -microsoft windows-Courier New-bold-r-normal-*-*-120-100-100-*-*-iso8859-1|-12,0,0,0,700,0,0,0,0,3,2,1,49,Courier New
0 ""
118 334 162 362
T 
1
LANG:1 4 Bins
E E E E
13 748
"Button52"
""
1 201 337 E E E 1 E 1 E N "_3DText" E N "_3DFace" E E
 E E
634 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 117 -microsoft windows-Courier New-bold-r-normal-*-*-120-100-100-*-*-iso8859-1|-12,0,0,0,700,0,0,0,0,3,2,1,49,Courier New
0 ""
199 335 248 362
T 
1
LANG:1 5 Hours
E E E E
13 742
"toototo"
""
1 605 336 E E E 1 E 1 E N "_3DText" E N "_3DFace" E E
 E E
628 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 117 -microsoft windows-Courier New-bold-r-normal-*-*-120-100-100-*-*-iso8859-1|-12,0,0,0,700,0,0,0,0,3,2,1,49,Courier New
0 ""
603 334 645 362
T 
1
LANG:1 4 Bins
E E E E
13 744
"Button50"
""
1 682 336 E E E 1 E 1 E N "_3DText" E N "_3DFace" E E
 E E
630 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 117 -microsoft windows-Courier New-bold-r-normal-*-*-120-100-100-*-*-iso8859-1|-12,0,0,0,700,0,0,0,0,3,2,1,49,Courier New
0 ""
680 334 729 361
T 
1
LANG:1 5 Hours
E E E E
22 851
"Ch_HV_LV01"
""
1 180 300 E E E 1 E 1 E N "Schwarz" E N {204,204,204} E E
 E E
730 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 105 -microsoft windows-Arial-bold-r-normal-*-*-110-100-100-*-*-iso8859-1|-12,0,0,0,700,0,0,0,0,3,2,1,34,Arial
0 ""
178 298 244 324
2
1
LANG:1 4 Chan
 1
1
LANG:1 4 Card
 0
E
"/* Hist_1 'Card/Chan' for MoPS
123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456*/
main()
{
	string ch_hv_lv;
	dyn_string para_list;

	// set the max number...etc. depending on the item used
	getValue(\"Ch_HV_LV01\", \"text\", ch_hv_lv);
	switch(ch_hv_lv)
		{
			case \"Card\":
				setValue(\"Ch_HV_LV_Num01\", \"sbMaximum\", 18);
				setValue(\"Ch_HV_LV01\", \"text\", \"LVca\");
				setValue(\"Ch_HV_LV_Num01\", \"text\", 1);
				setValue(\"Parameter01\", \"items\", makeDynString(\"LVcaTemp\", \"LVcaPowr\"));
				setValue(\"Parameter01\", \"selectedPos\", 0);
			break;
			
			default: //it is channel
				setValue(\"Ch_HV_LV_Num01\", \"sbMaximum\", 48);
				
				para_list = makeDynString(\"LVch_Vcc\", \"LVps_Vcc\", \"LVretVcc\", \"LVch_Icc\", 
				\"LVch_Vdd\", \"LVps_Vdd\", \"LVretVdd\", \"LVch_Idd\", \"LVchVCSV\", \"LVchVCSI\", 
				\"LVchPINV\", \"LVchPINI\", \"MOch_Tm0\", \"MOch_Tm1\", \"HVchVolt\", \"HVchCurr\");
				
				setValue(\"Parameter01\", \"items\", para_list);
				setValue(\"Parameter01\", \"selectedPos\", 0);				
			break;						
		}
}" 0

E
 0 0
21 852
"Ch_HV_LV_Num01"
""
1 240 300 E E E 1 E 1 E N "_WindowText" E N "_Window" E E
 E E
731 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 117 -microsoft windows-Courier New-bold-r-normal-*-*-120-100-100-*-*-iso8859-1|-12,0,0,0,700,0,0,0,0,3,2,1,49,Courier New
0 ""
238 298 282 325
0
E
"/* Hist_1 'Numb' for MoPS
123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456*/
main()
{
	string ch_hv_lv;
	int ch_hv_lv_num;

	// set the HV-LV card label (and parametres) depending on the number of slot used
	getValue(\"Ch_HV_LV01\", \"text\", ch_hv_lv);
	switch(ch_hv_lv)
		{
			case \"Card\":
			case \"HVca\":
			case \"LVca\":
					getValue(\"Ch_HV_LV_Num01\", \"text\", ch_hv_lv_num);
					switch(ch_hv_lv_num)
					  {
					  	case 1:
					  	case 3:
					  	case 4:
					  	case 6:
					  	case 7:
					  	case 9:
					  	case 10:
					  	case 12:
					  	case 13:
					  	case 15:
					  	case 16:
					  	case 18:
							setValue(\"Ch_HV_LV01\", \"text\", \"LVca\");
							setValue(\"Parameter01\", \"items\", makeDynString(\"LVcaTemp\", \"LVcaPowr\"));
							setValue(\"Parameter01\", \"selectedPos\", 0);
						break;
					  	case 2:
					  	case 5:
					  	case 8:
					  	case 11:
					  	case 14:
					  	case 17:
					  		setValue(\"Ch_HV_LV01\", \"text\", \"HVca\");
					  		setValue(\"Parameter01\", \"items\", makeDynString(\"no para\"));
							setValue(\"Parameter01\", \"selectedPos\", 0);
					  	break;
			break;
					  }
		}

}" 0

E

N 0 47 1 0 0 1
13 853
"Button7"
""
1 460 282 E E E 1 E 1 E N {0,51,102} E N {204,204,102} E E
 E E
732 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 117 -microsoft windows-Courier New-bold-r-normal-*-*-120-100-100-*-*-iso8859-1|-13,0,0,0,700,0,0,0,0,3,2,1,49,Courier New
0 ""
458 280 483 324
T 
1
LANG:1 2 Go
"/* Histogram_1 'Go' for MoPS
123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456*/

main()
{
	int rack, crate, ch_hv_lv_num, parameter_pos, ch_hv_lv_pos;
	int hours, bins;
	string dpeName, parameter, ch_hv_lv, used_para;

	 //get the BarTrend object
	shape histo = getShape(\"Hist01\");

	//get the number of hours to go back in the past and define a default value (differentsfrom zero)
	getValue(\"Hours01\", \"text\", hours);

	//get the number of bin and do some protection
	getValue(\"Bins01\", \"text\", bins);
	if(bins == 0) bins = 50;
	
	//get the actual value of Rack, Crate, Ch_HV_LV, Ch_HV_LV_Num and Parameter
	getValue(\"Rack01\", \"text\", rack);
	getValue(\"Crate01\", \"text\", crate);
	getValue(\"Ch_HV_LV_Num01\", \"text\", ch_hv_lv_num);
	getValue(\"Parameter01\", \"text\", parameter);
	getValue(\"Parameter01\", \"selectedPos\", parameter_pos);//position of the para in the combobox
	getValue(\"Ch_HV_LV01\", \"text\", ch_hv_lv);
	getValue(\"Ch_HV_LV01\", \"selectedPos\", ch_hv_lv_pos);
	
	//strore the used parameters
	//sprintf(used_para, \"%d_%d_%d_%d_%d_%d_%d\", rack, crate, ch_hv_lv_pos, ch_hv_lv_num,
	//  											    parameter_pos, bins, hours);
	//dpSet(\"SCTmops1:Hist01.Name00:_original.._value\", used_para);

	crate = (rack * 4) + crate; //because we start from 0 (in the data point numbering)
//	crate = (rack-1)*4 + crate -1; //-1 because we start from 0 (in the data point numbering)
//	ch_hv_lv_num = ch_hv_lv_num -1; // start counting from zero (in the data point numbering)
	
	//make a 2 digit label for crates
	if(crate<10)
		dpeName = \"SCTmops1:Crate0\"+crate;
	else
		dpeName = \"SCTmops1:Crate\"+crate;

	//find out which HVca, LVca and Ch is used
	switch(ch_hv_lv)
	  {
		case \"HVca\":
			//dpeName = \"\";
            dpSet(\"SCTmops1:Eror.Name:_original.._value\", 
\" Histogram - there is no HV card parameter to be plot,\\n             choose an other card\");
            dpSet(\"SCTmops1:Eror.Stat:_original.._value\", 0x2);
			dpeName = dpeName+\".HV_card0\"+ch_hv_lv_num+\".\"+parameter+\".Recv\";
		break;
		
		case \"LVca\":
			//make a 2 digit label for LV card
			if(ch_hv_lv_num<10)
				dpeName = dpeName+\".LV_card0\"+ch_hv_lv_num+\".\"+parameter+\".Recv\";
			else
				dpeName = dpeName+\".LV_card\"+ch_hv_lv_num+\".\"+parameter+\".Recv\";
				
		break;
		
		default://it is channel
			
				//make a 2 digit label for channel
				if(ch_hv_lv_num<10)
					dpeName = dpeName+\".Channel0\"+ch_hv_lv_num+\".\"+parameter+\".Recv\";
				else
					dpeName = dpeName+\".Channel\"+ch_hv_lv_num+\".\"+parameter+\".Recv\";
		break;
	  }
	  
	//save the configuration used here for a evntual next use
	dpSet(\"SCTmops1:Hist0\"+$Tab_Numb+\".Name01:_original.._value\", dpeName);
	dpSet(\"SCTmops1:Hist0\"+$Tab_Numb+\".Bins01:_original.._value\", bins);
	dpSet(\"SCTmops1:Hist0\"+$Tab_Numb+\".Hour01:_original.._value\", hours);
	setHistogram(histo, dpeName, bins, hours);
}

 setHistogram(shape histo, string dpeName, int bins, int hours)
 {
	int seconds, x_bin;
	int index;
	float data_min, data_max, x_step, y_step, x_max, x_min, y_max, data_mean, data_RMS;
	string Entries, Mean, RMS, Xmin, Xmax, Ymax, Ymin;
	time timeNow, timePast;
	
	dyn_int evt;
	dyn_float statistique, x_coordinate, X, Y, data_array, data_square_array;
	dyn_time time_array;
 	dyn_string statBox;
 		
 	//some intitialisation
 	x_step = 0;
 	y_step = 0;
 	x_max = 0;
 	y_max = 0;
 	
	//calculate the correspondant time to hours in the past (use tranformation to seconds)
	setPeriod(timePast, period(getCurrentTime()) - hours*3600);

	//time now
	timeNow = getCurrentTime();

	//get the data correspondant to the required period
	dpGetPeriod(timePast, timeNow, -1, dpeName+\":_offline.._value\", data_array, time_array, evt);
	
	//return if no data
	if(dynlen(data_array) == 0)
        { dpSet(\"SCTmops1:Eror.Name:_original.._value\", 
\" Hist1_Go script of mainTab_\"+$Tab_Numb+\": \\n             the DaPo \"+dpeName+\"\\n             has no archived data\\n             Try to start archive if it is not started yet\\n\"); 
          dpSet(\"SCTmops1:Eror.Stat:_original.._value\", 0x2);
		  return;
		}
		
	//take the square for later RMS calculation
	for(index=1; index<=dynlen(data_array); index++)
		{
			data_square_array[index] = data_array[index]*data_array[index];
		}
		
	//find the maximum and minimum and calculate the bin width (x_step)
	data_max = dynMax(data_array);
	data_min = dynMin(data_array);
	x_step = (data_max - data_min)/(bins-1);
	
	//initialise the statistique to zero and the X coordinate to the defined binning
	for(index=1; index<=bins+3; index++) // add 2 bins (1 underflow bins and 2 overflow)
		{
			dynAppend(statistique, 0);
			dynAppend(x_coordinate, data_min + (index-2)*x_step);
		}
		
	//fill the statistique
	for(index=1; index<=dynlen(data_array); index++)
		{
			//caluculate in which bin the actual value goes
			x_bin = (data_array[index]-data_min)/x_step + 2;
			
			//increment the statistique of the correspondant bin
			statistique[x_bin] = statistique[x_bin] + 1;
		}
		
	//statistique box attributes
	sprintf(Entries, \"Entries  %d\", dynlen(data_array));
	data_mean = dynAvg(data_array);
	sprintf(Mean,    \"Mean     %f\", data_mean);
	//RMS
	data_RMS = dynAvg(data_square_array);
    data_RMS = sqrt(data_RMS - data_mean*data_mean);
    sprintf(RMS,     \"RMS      %f\", data_RMS);
    sprintf(Xmin,    \"Xmin     %f\", data_min);
    sprintf(Xmax,    \"Xmax     %f\", data_max);
    sprintf(Ymax,    \"Ymax     %d\", dynMax(statistique));
    sprintf(Ymin,    \"Ymin     %d\", dynMin(statistique));
	statBox = makeDynString(Entries, Mean, RMS, Xmin, Xmax, Ymax, Ymin); 
	setValue(\"StatBox01\", \"items\", statBox);
	
	//clear the data array. may be huge!!
	dynClear(data_array);

	//calculate the Y spep
	y_max = dynMax(statistique);
	y_step = 1;
	//if(y_max>5) y_step = y_max/5;
	
	// Y-axis coordinates stuff
	setValue(histo, \"yOrigin\", BAR_BOTTOM);
	setValue(histo, \"yCenter\", 0);
	setValue(histo, \"yRange\",  y_max+y_step);
	setValue(histo, \"yStep\",   y_step);
	setValue(histo, \"yPrec\",   0);
	setValue(histo, \"yGrid\",   FALSE);

	x_max = dynMax(x_coordinate);
	x_min = dynMin(x_coordinate);

	// X-axis coordiantes stuff
	setValue(histo, \"xOrigin\", BAR_LEFT);
	setValue(histo, \"xStep\",   x_step);
	//setValue(histo, \"xCenter\", x_min-x_step);
	setValue(histo, \"xCenter\", x_min);
	setValue(histo, \"xRange\",  x_max);
	setValue(histo, \"xPrec\",   0);
	setValue(histo, \"xGrid\",   FALSE);
	
	// set the value to the barTrend object
	setValue(histo, \"data\", x_coordinate, statistique);
 
	// step curve
	setValue(histo, \"connection\", BAR_STEPS);
 	// Fill the area
	setValue(histo, \"fill\", FALSE);
 	// Update bar trend
	histo.flush();
 }" 0
 E E E
22 854
"Parameter01"
""
1 370 300 E E E 1 E 1 E N "_WindowText" E N {204,204,204} E E
 E E
733 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
2
LANG:1 105 -microsoft windows-Arial-bold-r-normal-*-*-110-100-100-*-*-iso8859-1|-12,0,0,0,700,0,0,0,0,3,2,1,34,Arial
LANG:5 119 -microsoft windows-Courier New-normal-r-normal-*-*-110-100-100-*-*-iso8859-1|-12,0,0,0,400,0,0,0,0,3,2,1,49,Courier New
0 ""
368 298 462 324
30
1
LANG:1 8 ChanStat
 1
1
LANG:1 8 Vcc_Modl
 0
1
LANG:1 8 Vcc_onPS
 0
1
LANG:1 8 Vcc_Retn
 0
1
LANG:1 8 Icc_Curr
 0
1
LANG:1 8 Vdd_Modl
 0
1
LANG:1 8 Vdd_onPS
 0
1
LANG:1 8 Vdd_Retn
 0
1
LANG:1 8 Idd_Curr
 0
1
LANG:1 8 VCSELvol
 0
1
LANG:1 8 VCSELcur
 0
1
LANG:1 8 PIN_Volt
 0
1
LANG:1 8 PIN_Curr
 0
1
LANG:1 8 Mo0_Temp
 0
1
LANG:1 8 Mo1_Temp
 0
1
LANG:1 8 Idd_Trip
 0
1
LANG:1 8 Icc_Trip
 0
1
LANG:1 8 TempLimi
 0
1
LANG:1 8 TripLimi
 0
1
LANG:1 8 ClockSel
 0
1
LANG:1 8 ClockRes
 0
1
LANG:1 8 ChOutpON
 0
1
LANG:1 7 Reserve
 0
1
LANG:1 8 HVchStat
 0
1
LANG:1 8 HVchVolt
 0
1
LANG:1 8 HVchCurr
 0
1
LANG:1 8 HVnomVal
 0
1
LANG:1 8 HVcrTrip
 0
1
LANG:1 8 HVrampRt
 0
1
LANG:1 4 No01
 0
E
E
E
 0 0
22 855
"Ch_HV_LV02"
""
1 655 300 E E E 1 E 1 E N "Schwarz" E N {204,204,204} E E
 E E
734 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 105 -microsoft windows-Arial-bold-r-normal-*-*-110-100-100-*-*-iso8859-1|-12,0,0,0,700,0,0,0,0,3,2,1,34,Arial
0 ""
653 298 719 324
2
1
LANG:1 4 Chan
 1
1
LANG:1 4 Card
 0
E
"/* Hist_2 'Card/Chan' for MoPS
123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456*/
main()
{
	string ch_hv_lv;
	dyn_string para_list;

	// set the max number...etc. depending on the item used
	getValue(\"Ch_HV_LV02\", \"text\", ch_hv_lv);
	switch(ch_hv_lv)
		{
			case \"Card\":
				setValue(\"Ch_HV_LV_Num02\", \"sbMaximum\", 18);
				setValue(\"Ch_HV_LV02\", \"text\", \"LVca\");
				setValue(\"Ch_HV_LV_Num02\", \"text\", 1);
				setValue(\"Parameter02\", \"items\", makeDynString(\"LVcaTemp\", \"LVcaPowr\"));
				setValue(\"Parameter02\", \"selectedPos\", 0);
			break;
			
			default: //it is channel
				setValue(\"Ch_HV_LV_Num02\", \"sbMaximum\", 48);
				
				para_list = makeDynString(\"LVch_Vcc\", \"LVps_Vcc\", \"LVretVcc\", \"LVch_Icc\", 
				\"LVch_Vdd\", \"LVps_Vdd\", \"LVretVdd\", \"LVch_Idd\", \"LVchVCSV\", \"LVchVCSI\", 
				\"LVchPINV\", \"LVchPINI\", \"MOch_Tm0\", \"MOch_Tm1\", \"HVchVolt\", \"HVchCurr\");
				
				setValue(\"Parameter02\", \"items\", para_list);
				setValue(\"Parameter02\", \"selectedPos\", 0);				
			break;						
		}
}" 0

E
 0 0
21 856
"Ch_HV_LV_Num02"
""
1 715 300 E E E 1 E 1 E N "_WindowText" E N "_Window" E E
 E E
735 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 117 -microsoft windows-Courier New-bold-r-normal-*-*-120-100-100-*-*-iso8859-1|-12,0,0,0,700,0,0,0,0,3,2,1,49,Courier New
0 ""
713 298 757 325
0
E
"/* Hist_2 'Numb' for MoPS
123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456*/
main()
{
	string ch_hv_lv;
	int ch_hv_lv_num;

	// set the HV-LV card label (and parametres) depending on the number of slot used
	getValue(\"Ch_HV_LV02\", \"text\", ch_hv_lv);
	switch(ch_hv_lv)
		{
			case \"Card\":
			case \"HVca\":
			case \"LVca\":
					getValue(\"Ch_HV_LV_Num02\", \"text\", ch_hv_lv_num);
					switch(ch_hv_lv_num)
					  {
					  	case 1:
					  	case 3:
					  	case 4:
					  	case 6:
					  	case 7:
					  	case 9:
					  	case 10:
					  	case 12:
					  	case 13:
					  	case 15:
					  	case 16:
					  	case 18:
							setValue(\"Ch_HV_LV02\", \"text\", \"LVca\");
							setValue(\"Parameter02\", \"items\", makeDynString(\"LVcaTemp\", \"LVcaPowr\"));
							setValue(\"Parameter02\", \"selectedPos\", 0);
						break;
					  	case 2:
					  	case 5:
					  	case 8:
					  	case 11:
					  	case 14:
					  	case 17:
					  		setValue(\"Ch_HV_LV02\", \"text\", \"HVca\");
					  		setValue(\"Parameter02\", \"items\", makeDynString(\"no para\"));
							setValue(\"Parameter02\", \"selectedPos\", 0);
					  	break;
			break;
					  }
		}

}" 0

E

N 0 47 1 0 0 1
22 857
"Parameter02"
""
1 845 300 E E E 1 E 1 E N "_WindowText" E N {204,204,204} E E
 E E
736 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
2
LANG:1 105 -microsoft windows-Arial-bold-r-normal-*-*-110-100-100-*-*-iso8859-1|-12,0,0,0,700,0,0,0,0,3,2,1,34,Arial
LANG:5 119 -microsoft windows-Courier New-normal-r-normal-*-*-110-100-100-*-*-iso8859-1|-12,0,0,0,400,0,0,0,0,3,2,1,49,Courier New
0 ""
843 298 937 324
30
1
LANG:1 8 ChanStat
 1
1
LANG:1 8 Vcc_Modl
 0
1
LANG:1 8 Vcc_onPS
 0
1
LANG:1 8 Vcc_Retn
 0
1
LANG:1 8 Icc_Curr
 0
1
LANG:1 8 Vdd_Modl
 0
1
LANG:1 8 Vdd_onPS
 0
1
LANG:1 8 Vdd_Retn
 0
1
LANG:1 8 Idd_Curr
 0
1
LANG:1 8 VCSELvol
 0
1
LANG:1 8 VCSELcur
 0
1
LANG:1 8 PIN_Volt
 0
1
LANG:1 8 PIN_Curr
 0
1
LANG:1 8 Mo0_Temp
 0
1
LANG:1 8 Mo1_Temp
 0
1
LANG:1 8 Idd_Trip
 0
1
LANG:1 8 Icc_Trip
 0
1
LANG:1 8 TempLimi
 0
1
LANG:1 8 TripLimi
 0
1
LANG:1 8 ClockSel
 0
1
LANG:1 8 ClockRes
 0
1
LANG:1 8 ChOutpON
 0
1
LANG:1 7 Reserve
 0
1
LANG:1 8 HVchStat
 0
1
LANG:1 8 HVchVolt
 0
1
LANG:1 8 HVchCurr
 0
1
LANG:1 8 HVnomVal
 0
1
LANG:1 8 HVcrTrip
 0
1
LANG:1 8 HVrampRt
 0
1
LANG:1 4 No01
 0
E
E
E
 0 0
13 858
"Button6"
""
1 935 282 E E E 1 E 1 E N {0,51,102} E N {204,204,102} E E
 E E
737 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 117 -microsoft windows-Courier New-bold-r-normal-*-*-120-100-100-*-*-iso8859-1|-13,0,0,0,700,0,0,0,0,3,2,1,49,Courier New
0 ""
933 280 958 324
T 
1
LANG:1 2 Go
"/* Histogram_2 'Go' for MoPS
123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456*/

main()
{
	int rack, crate, ch_hv_lv_num, parameter_pos, ch_hv_lv_pos;
	int hours, bins;
	string dpeName, parameter, ch_hv_lv, used_para;

	 //get the BarTrend object
	shape histo = getShape(\"Hist02\");

	//get the number of hours to go back in the past and define a default value (differentsfrom zero)
	getValue(\"Hours02\", \"text\", hours);

	//get the number of bin and do some protection
	getValue(\"Bins02\", \"text\", bins);
	if(bins == 0) bins = 50;
	
	//get the actual value of Rack, Crate, Ch_HV_LV, Ch_HV_LV_Num and Parameter
	getValue(\"Rack02\", \"text\", rack);
	getValue(\"Crate02\", \"text\", crate);
	getValue(\"Ch_HV_LV_Num02\", \"text\", ch_hv_lv_num);
	getValue(\"Parameter02\", \"text\", parameter);
	getValue(\"Parameter02\", \"selectedPos\", parameter_pos);//position of the para in the combobox
	getValue(\"Ch_HV_LV02\", \"text\", ch_hv_lv);
	getValue(\"Ch_HV_LV02\", \"selectedPos\", ch_hv_lv_pos);
	
	//strore the used parameters
	//sprintf(used_para, \"%d_%d_%d_%d_%d_%d_%d\", rack, crate, ch_hv_lv_pos, ch_hv_lv_num,
	//  											    parameter_pos, bins, hours);
	//dpSet(\"SCTmops1:Hist02.Name00:_original.._value\", used_para);

	crate = (rack * 4) + crate; //because we start from 0 (in the data point numbering)
//	crate = (rack-1)*4 + crate -1; //-1 because we start from 0 (in the data point numbering)
//	ch_hv_lv_num = ch_hv_lv_num -1; // start counting from zero (in the data point numbering)
	
	//make a 2 digit label for crates
	if(crate<10)
		dpeName = \"SCTmops1:Crate0\"+crate;
	else
		dpeName = \"SCTmops1:Crate\"+crate;

	//find out which HVca, LVca and Ch is used
	switch(ch_hv_lv)
	  {
		case \"HVca\":
			//dpeName = \"\";
            dpSet(\"SCTmops1:Eror.Name:_original.._value\", 
\" Histogram - there is no HV card parameter to be plot,\\n             choose an other card\");
            dpSet(\"SCTmops1:Eror.Stat:_original.._value\", 0x2);
			dpeName = dpeName+\".HV_card0\"+ch_hv_lv_num+\".\"+parameter+\".Recv\";
		break;
		
		case \"LVca\":
			//make a 2 digit label for LV card
			if(ch_hv_lv_num<10)
				dpeName = dpeName+\".LV_card0\"+ch_hv_lv_num+\".\"+parameter+\".Recv\";
			else
				dpeName = dpeName+\".LV_card\"+ch_hv_lv_num+\".\"+parameter+\".Recv\";
				
		break;
		
		default://it is channel
			
				//make a 2 digit label for channel
				if(ch_hv_lv_num<10)
					dpeName = dpeName+\".Channel0\"+ch_hv_lv_num+\".\"+parameter+\".Recv\";
				else
					dpeName = dpeName+\".Channel\"+ch_hv_lv_num+\".\"+parameter+\".Recv\";
		break;
	  }

	//save the configuration used here for a evntual next use
	dpSet(\"SCTmops1:Hist0\"+$Tab_Numb+\".Name02:_original.._value\", dpeName);
	dpSet(\"SCTmops1:Hist0\"+$Tab_Numb+\".Bins02:_original.._value\", bins);
	dpSet(\"SCTmops1:Hist0\"+$Tab_Numb+\".Hour02:_original.._value\", hours);
	setHistogram(histo, dpeName, bins, hours);
}

setHistogram(shape histo, string dpeName, int bins, int hours)
{
	int seconds, x_bin;
	int index;
	float data_min, data_max, x_step, y_step, x_max, x_min, y_max, data_mean, data_RMS;
	string Entries, Mean, RMS, Xmin, Xmax, Ymax, Ymin;
	time timeNow, timePast;
	
	dyn_int evt;
	dyn_float statistique, x_coordinate, X, Y, data_array, data_square_array;
	dyn_time time_array;
 	dyn_string statBox;
 		
 	//some intitialisation
 	x_step = 0;
 	y_step = 0;
 	x_max = 0;
 	y_max = 0;
 	
	//calculate the correspondant time to hours in the past (use tranformation to seconds)
	setPeriod(timePast, period(getCurrentTime()) - hours*3600);

	//time now
	timeNow = getCurrentTime();

	//get the data correspondant to the required period
	dpGetPeriod(timePast, timeNow, -1, dpeName+\":_offline.._value\", data_array, time_array, evt);
		
	//return if no data
	if(dynlen(data_array) == 0)
        { dpSet(\"SCTmops1:Eror.Name:_original.._value\", 
\" Hist2_Go script of mainTab_\"+$Tab_Numb+\": \\n             the DaPo \"+dpeName+\"\\n             has no archived data\\n             Try to start archive if it is not started yet\\n\"); 
          dpSet(\"SCTmops1:Eror.Stat:_original.._value\", 0x2);
		  return;
		}
		
	//take the square for later RMS calculation
	for(index=1; index<=dynlen(data_array); index++)
		{
			data_square_array[index] = data_array[index]*data_array[index];
		}

	//find the maximum and minimum and calculate the bin width (x_step)
	data_max = dynMax(data_array);
	data_min = dynMin(data_array);
	x_step = (data_max - data_min)/(bins-1);
	
	//initialise the statistique to zero and the X coordinate to the defined binning
	for(index=1; index<=bins+3; index++) // add 2 bins (1 underflow bins and 2 overflow)
		{
			dynAppend(statistique, 0);
			dynAppend(x_coordinate, data_min + (index-2)*x_step);
		}
		
	//fill the statistique
	for(index=1; index<=dynlen(data_array); index++)
		{
			//caluculate in which bin the actual value goes
			x_bin = (data_array[index]-data_min)/x_step + 2;
			
			//increment the statistique of the correspondant bin
			statistique[x_bin] = statistique[x_bin] + 1;
		}
		
	//statistique box attributes
	sprintf(Entries, \"Entries  %d\", dynlen(data_array));
	data_mean = dynAvg(data_array);
	sprintf(Mean,    \"Mean     %f\", data_mean);
	//RMS
	data_RMS = dynAvg(data_square_array);
    data_RMS = sqrt(data_RMS - data_mean*data_mean);
    sprintf(RMS,     \"RMS      %f\", data_RMS);
    sprintf(Xmin,    \"Xmin     %f\", data_min);
    sprintf(Xmax,    \"Xmax     %f\", data_max);
    sprintf(Ymax,    \"Ymax     %d\", dynMax(statistique));
    sprintf(Ymin,    \"Ymin     %d\", dynMin(statistique));
	statBox = makeDynString(Entries, Mean, RMS, Xmin, Xmax, Ymax, Ymin); 
	setValue(\"StatBox02\", \"items\", statBox);
	
	//clear the data array. may be huge!!
	dynClear(data_array);

	//calculate the Y spep
	y_max = dynMax(statistique);
	y_step = 1;
	//if(y_max>5) y_step = y_max/5;
	
	// Y-axis coordinates stuff
	setValue(histo, \"yOrigin\", BAR_BOTTOM);
	setValue(histo, \"yCenter\", 0);
	setValue(histo, \"yRange\",  y_max+y_step);
	setValue(histo, \"yStep\",   y_step);
	setValue(histo, \"yPrec\",   0);
	setValue(histo, \"yGrid\",   FALSE);

	x_max = dynMax(x_coordinate);
	x_min = dynMin(x_coordinate);

	// X-axis coordiantes stuff
	setValue(histo, \"xOrigin\", BAR_LEFT);
	setValue(histo, \"xStep\",   x_step);
	//setValue(histo, \"xCenter\", x_min-x_step);
	setValue(histo, \"xCenter\", x_min);
	setValue(histo, \"xRange\",  x_max);
	setValue(histo, \"xPrec\",   0);
	setValue(histo, \"xGrid\",   FALSE);
	
	// set the value to the barTrend object
	setValue(histo, \"data\", x_coordinate, statistique);
 
	// step curve
	setValue(histo, \"connection\", BAR_STEPS);
 	// Fill the area
	setValue(histo, \"fill\", FALSE);
 	// Update bar trend
	histo.flush();
}" 0
 E E E
22 859
"Ch_HV_LV03"
""
1 180 620 E E E 1 E 1 E N "Schwarz" E N {204,204,204} E E
 E E
738 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 105 -microsoft windows-Arial-bold-r-normal-*-*-110-100-100-*-*-iso8859-1|-12,0,0,0,700,0,0,0,0,3,2,1,34,Arial
0 ""
178 618 244 644
2
1
LANG:1 4 Chan
 1
1
LANG:1 4 Card
 0
E
"/* Hist_3 'Card/Chan' for MoPS
123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456*/
main()
{
	string ch_hv_lv;
	dyn_string para_list;

	// set the max number...etc. depending on the item used
	getValue(\"Ch_HV_LV03\", \"text\", ch_hv_lv);
	switch(ch_hv_lv)
		{
			case \"Card\":
				setValue(\"Ch_HV_LV_Num03\", \"sbMaximum\", 18);
				setValue(\"Ch_HV_LV03\", \"text\", \"LVca\");
				setValue(\"Ch_HV_LV_Num03\", \"text\", 1);
				setValue(\"Parameter03\", \"items\", makeDynString(\"LVcaTemp\", \"LVcaPowr\"));
				setValue(\"Parameter03\", \"selectedPos\", 0);
			break;
			
			default: //it is channel
				setValue(\"Ch_HV_LV_Num03\", \"sbMaximum\", 48);
				
				para_list = makeDynString(\"LVch_Vcc\", \"LVps_Vcc\", \"LVretVcc\", \"LVch_Icc\", 
				\"LVch_Vdd\", \"LVps_Vdd\", \"LVretVdd\", \"LVch_Idd\", \"LVchVCSV\", \"LVchVCSI\", 
				\"LVchPINV\", \"LVchPINI\", \"MOch_Tm0\", \"MOch_Tm1\", \"HVchVolt\", \"HVchCurr\");
				
				setValue(\"Parameter03\", \"items\", para_list);
				setValue(\"Parameter03\", \"selectedPos\", 0);				
			break;						
		}
}" 0

E
 0 0
21 860
"Ch_HV_LV_Num03"
""
1 240 620 E E E 1 E 1 E N "_WindowText" E N "_Window" E E
 E E
739 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 117 -microsoft windows-Courier New-bold-r-normal-*-*-120-100-100-*-*-iso8859-1|-12,0,0,0,700,0,0,0,0,3,2,1,49,Courier New
0 ""
238 618 282 645
0
E
"/* Hist_3 'Numb' for MoPS
123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456*/
main()
{
	string ch_hv_lv;
	int ch_hv_lv_num;

	// set the HV-LV card label (and parametres) depending on the number of slot used
	getValue(\"Ch_HV_LV03\", \"text\", ch_hv_lv);
	switch(ch_hv_lv)
		{
			case \"Card\":
			case \"HVca\":
			case \"LVca\":
					getValue(\"Ch_HV_LV_Num03\", \"text\", ch_hv_lv_num);
					switch(ch_hv_lv_num)
					  {
					  	case 1:
					  	case 3:
					  	case 4:
					  	case 6:
					  	case 7:
					  	case 9:
					  	case 10:
					  	case 12:
					  	case 13:
					  	case 15:
					  	case 16:
					  	case 18:
							setValue(\"Ch_HV_LV03\", \"text\", \"LVca\");
							setValue(\"Parameter03\", \"items\", makeDynString(\"LVcaTemp\", \"LVcaPowr\"));
							setValue(\"Parameter03\", \"selectedPos\", 0);
						break;
					  	case 2:
					  	case 5:
					  	case 8:
					  	case 11:
					  	case 14:
					  	case 17:
					  		setValue(\"Ch_HV_LV03\", \"text\", \"HVca\");
					  		setValue(\"Parameter03\", \"items\", makeDynString(\"no para\"));
							setValue(\"Parameter03\", \"selectedPos\", 0);
					  	break;
			break;
					  }
		}

}" 0

E

N 0 47 1 0 0 1
22 861
"Parameter03"
""
1 370 620 E E E 1 E 1 E N "_WindowText" E N {204,204,204} E E
 E E
740 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
2
LANG:1 105 -microsoft windows-Arial-bold-r-normal-*-*-110-100-100-*-*-iso8859-1|-12,0,0,0,700,0,0,0,0,3,2,1,34,Arial
LANG:5 119 -microsoft windows-Courier New-normal-r-normal-*-*-110-100-100-*-*-iso8859-1|-12,0,0,0,400,0,0,0,0,3,2,1,49,Courier New
0 ""
368 618 462 644
30
1
LANG:1 8 ChanStat
 1
1
LANG:1 8 Vcc_Modl
 0
1
LANG:1 8 Vcc_onPS
 0
1
LANG:1 8 Vcc_Retn
 0
1
LANG:1 8 Icc_Curr
 0
1
LANG:1 8 Vdd_Modl
 0
1
LANG:1 8 Vdd_onPS
 0
1
LANG:1 8 Vdd_Retn
 0
1
LANG:1 8 Idd_Curr
 0
1
LANG:1 8 VCSELvol
 0
1
LANG:1 8 VCSELcur
 0
1
LANG:1 8 PIN_Volt
 0
1
LANG:1 8 PIN_Curr
 0
1
LANG:1 8 Mo0_Temp
 0
1
LANG:1 8 Mo1_Temp
 0
1
LANG:1 8 Idd_Trip
 0
1
LANG:1 8 Icc_Trip
 0
1
LANG:1 8 TempLimi
 0
1
LANG:1 8 TripLimi
 0
1
LANG:1 8 ClockSel
 0
1
LANG:1 8 ClockRes
 0
1
LANG:1 8 ChOutpON
 0
1
LANG:1 7 Reserve
 0
1
LANG:1 8 HVchStat
 0
1
LANG:1 8 HVchVolt
 0
1
LANG:1 8 HVchCurr
 0
1
LANG:1 8 HVnomVal
 0
1
LANG:1 8 HVcrTrip
 0
1
LANG:1 8 HVrampRt
 0
1
LANG:1 4 No01
 0
E
E
E
 0 0
13 862
"Button5"
""
1 460 602 E E E 1 E 1 E N {0,51,102} E N {204,204,102} E E
 E E
741 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 117 -microsoft windows-Courier New-bold-r-normal-*-*-120-100-100-*-*-iso8859-1|-13,0,0,0,700,0,0,0,0,3,2,1,49,Courier New
0 ""
458 600 483 644
T 
1
LANG:1 2 Go
"/* Histogram_3 'Go' for MoPS
123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456*/

main()
{
	int rack, crate, ch_hv_lv_num, parameter_pos, ch_hv_lv_pos;
	int hours, bins;
	string dpeName, parameter, ch_hv_lv, used_para;

	 //get the BarTrend object
	shape histo = getShape(\"Hist03\");

	//get the number of hours to go back in the past and define a default value (differentsfrom zero)
	getValue(\"Hours03\", \"text\", hours);

	//get the number of bin and do some protection
	getValue(\"Bins03\", \"text\", bins);
	if(bins == 0) bins = 50;
	
	//get the actual value of Rack, Crate, Ch_HV_LV, Ch_HV_LV_Num and Parameter
	getValue(\"Rack03\", \"text\", rack);
	getValue(\"Crate03\", \"text\", crate);
	getValue(\"Ch_HV_LV_Num03\", \"text\", ch_hv_lv_num);
	getValue(\"Parameter03\", \"text\", parameter);
	getValue(\"Parameter03\", \"selectedPos\", parameter_pos);//position of the para in the combobox
	getValue(\"Ch_HV_LV03\", \"text\", ch_hv_lv);
	getValue(\"Ch_HV_LV03\", \"selectedPos\", ch_hv_lv_pos);
	
	//strore the used parameters
	//sprintf(used_para, \"%d_%d_%d_%d_%d_%d_%d\", rack, crate, ch_hv_lv_pos, ch_hv_lv_num,
	//  											    parameter_pos, bins, hours);
	//dpSet(\"SCTmops1:Hist03.Name00:_original.._value\", used_para);

	crate = (rack * 4) + crate; //because we start from 0 (in the data point numbering)
//	crate = (rack-1)*4 + crate -1; //-1 because we start from 0 (in the data point numbering)
//	ch_hv_lv_num = ch_hv_lv_num -1; // start counting from zero (in the data point numbering)
	
	//make a 2 digit label for crates
	if(crate<10)
		dpeName = \"SCTmops1:Crate0\"+crate;
	else
		dpeName = \"SCTmops1:Crate\"+crate;

	//find out which HVca, LVca and Ch is used
	switch(ch_hv_lv)
	  {
		case \"HVca\":
			//dpeName = \"\";
            dpSet(\"SCTmops1:Eror.Name:_original.._value\", 
\" Histogram - there is no HV card parameter to be plot,\\n             choose an other card\");
            dpSet(\"SCTmops1:Eror.Stat:_original.._value\", 0x2);
			dpeName = dpeName+\".HV_card0\"+ch_hv_lv_num+\".\"+parameter+\".Recv\";
		break;
		
		case \"LVca\":
			//make a 2 digit label for LV card
			if(ch_hv_lv_num<10)
				dpeName = dpeName+\".LV_card0\"+ch_hv_lv_num+\".\"+parameter+\".Recv\";
			else
				dpeName = dpeName+\".LV_card\"+ch_hv_lv_num+\".\"+parameter+\".Recv\";
				
		break;
		
		default://it is channel
			
				//make a 2 digit label for channel
				if(ch_hv_lv_num<10)
					dpeName = dpeName+\".Channel0\"+ch_hv_lv_num+\".\"+parameter+\".Recv\";
				else
					dpeName = dpeName+\".Channel\"+ch_hv_lv_num+\".\"+parameter+\".Recv\";
		break;
	  }

	//save the configuration used here for a evntual next use	  
	dpSet(\"SCTmops1:Hist0\"+$Tab_Numb+\".Name03:_original.._value\", dpeName);
	dpSet(\"SCTmops1:Hist0\"+$Tab_Numb+\".Bins03:_original.._value\", bins);
	dpSet(\"SCTmops1:Hist0\"+$Tab_Numb+\".Hour03:_original.._value\", hours);
	setHistogram(histo, dpeName, bins, hours);
}

setHistogram(shape histo, string dpeName, int bins, int hours)
{
	int seconds, x_bin;
	int index;
	float data_min, data_max, x_step, y_step, x_max, x_min, y_max, data_mean, data_RMS;
	string Entries, Mean, RMS, Xmin, Xmax, Ymax, Ymin;
	time timeNow, timePast;
	
	dyn_int evt;
	dyn_float statistique, x_coordinate, X, Y, data_array, data_square_array;
	dyn_time time_array;
 	dyn_string statBox;
 		
 	//some intitialisation
 	x_step = 0;
 	y_step = 0;
 	x_max = 0;
 	y_max = 0;
 	
	//calculate the correspondant time to hours in the past (use tranformation to seconds)
	setPeriod(timePast, period(getCurrentTime()) - hours*3600);

	//time now
	timeNow = getCurrentTime();

	//get the data correspondant to the required period
	dpGetPeriod(timePast, timeNow, -1, dpeName+\":_offline.._value\", data_array, time_array, evt);
		
	//return if no data
	if(dynlen(data_array) == 0)
        { dpSet(\"SCTmops1:Eror.Name:_original.._value\", 
\" Hist3_Go script of mainTab_\"+$Tab_Numb+\": \\n             the DaPo \"+dpeName+\"\\n             has no archived data\\n             Try to start archive if it is not started yet\\n\"); 
          dpSet(\"SCTmops1:Eror.Stat:_original.._value\", 0x2);
		  return;
		}
		
	//take the square for later RMS calculation
	for(index=1; index<=dynlen(data_array); index++)
		{
			data_square_array[index] = data_array[index]*data_array[index];
		}
		
	//find the maximum and minimum and calculate the bin width (x_step)
	data_max = dynMax(data_array);
	data_min = dynMin(data_array);
	x_step = (data_max - data_min)/(bins-1);
	
	//initialise the statistique to zero and the X coordinate to the defined binning
	for(index=1; index<=bins+3; index++) // add 2 bins (1 underflow bins and 2 overflow)
		{
			dynAppend(statistique, 0);
			dynAppend(x_coordinate, data_min + (index-2)*x_step);
		}
		
	//fill the statistique
	for(index=1; index<=dynlen(data_array); index++)
		{
			//caluculate in which bin the actual value goes
			x_bin = (data_array[index]-data_min)/x_step + 2;
			
			//increment the statistique of the correspondant bin
			statistique[x_bin] = statistique[x_bin] + 1;
		}
		
	//statistique box attributes
	sprintf(Entries, \"Entries  %d\", dynlen(data_array));
	data_mean = dynAvg(data_array);
	sprintf(Mean,    \"Mean     %f\", data_mean);
	//RMS
	data_RMS = dynAvg(data_square_array);
    data_RMS = sqrt(data_RMS - data_mean*data_mean);
    sprintf(RMS,     \"RMS      %f\", data_RMS);
    sprintf(Xmin,    \"Xmin     %f\", data_min);
    sprintf(Xmax,    \"Xmax     %f\", data_max);
    sprintf(Ymax,    \"Ymax     %d\", dynMax(statistique));
    sprintf(Ymin,    \"Ymin     %d\", dynMin(statistique));
	statBox = makeDynString(Entries, Mean, RMS, Xmin, Xmax, Ymax, Ymin); 
	setValue(\"StatBox03\", \"items\", statBox);
	
	//clear the data array. may be huge!!
	dynClear(data_array);

	//calculate the Y spep
	y_max = dynMax(statistique);
	y_step = 1;
	//if(y_max>5) y_step = y_max/5;
	
	// Y-axis coordinates stuff
	setValue(histo, \"yOrigin\", BAR_BOTTOM);
	setValue(histo, \"yCenter\", 0);
	setValue(histo, \"yRange\",  y_max+y_step);
	setValue(histo, \"yStep\",   y_step);
	setValue(histo, \"yPrec\",   0);
	setValue(histo, \"yGrid\",   FALSE);

	x_max = dynMax(x_coordinate);
	x_min = dynMin(x_coordinate);

	// X-axis coordiantes stuff
	setValue(histo, \"xOrigin\", BAR_LEFT);
	setValue(histo, \"xStep\",   x_step);
	//setValue(histo, \"xCenter\", x_min-x_step);
	setValue(histo, \"xCenter\", x_min);
	setValue(histo, \"xRange\",  x_max);
	setValue(histo, \"xPrec\",   0);
	setValue(histo, \"xGrid\",   FALSE);
	
	// set the value to the barTrend object
	setValue(histo, \"data\", x_coordinate, statistique);
 
	// step curve
	setValue(histo, \"connection\", BAR_STEPS);
 	// Fill the area
	setValue(histo, \"fill\", FALSE);
 	// Update bar trend
	histo.flush();
}" 0
 E E E
22 863
"Ch_HV_LV04"
""
1 655 620 E E E 1 E 1 E N "Schwarz" E N {204,204,204} E E
 E E
742 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 105 -microsoft windows-Arial-bold-r-normal-*-*-110-100-100-*-*-iso8859-1|-12,0,0,0,700,0,0,0,0,3,2,1,34,Arial
0 ""
653 618 719 644
2
1
LANG:1 4 Chan
 1
1
LANG:1 4 Card
 0
E
"/* Hist_4 'Card/Chan' for MoPS
123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456*/
main()
{
	string ch_hv_lv;
	dyn_string para_list;

	// set the max number...etc. depending on the item used
	getValue(\"Ch_HV_LV04\", \"text\", ch_hv_lv);
	switch(ch_hv_lv)
		{
			case \"Card\":
				setValue(\"Ch_HV_LV_Num04\", \"sbMaximum\", 18);
				setValue(\"Ch_HV_LV04\", \"text\", \"LVca\");
				setValue(\"Ch_HV_LV_Num04\", \"text\", 1);
				setValue(\"Parameter04\", \"items\", makeDynString(\"LVcaTemp\", \"LVcaPowr\"));
				setValue(\"Parameter04\", \"selectedPos\", 0);
			break;
			
			default: //it is channel
				setValue(\"Ch_HV_LV_Num04\", \"sbMaximum\", 48);
				
				para_list = makeDynString(\"LVch_Vcc\", \"LVps_Vcc\", \"LVretVcc\", \"LVch_Icc\", 
				\"LVch_Vdd\", \"LVps_Vdd\", \"LVretVdd\", \"LVch_Idd\", \"LVchVCSV\", \"LVchVCSI\", 
				\"LVchPINV\", \"LVchPINI\", \"MOch_Tm0\", \"MOch_Tm1\", \"HVchVolt\", \"HVchCurr\");
				
				setValue(\"Parameter04\", \"items\", para_list);
				setValue(\"Parameter04\", \"selectedPos\", 0);				
			break;						
		}
}" 0

E
 0 0
21 864
"Ch_HV_LV_Num04"
""
1 715 620 E E E 1 E 1 E N "_WindowText" E N "_Window" E E
 E E
743 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 117 -microsoft windows-Courier New-bold-r-normal-*-*-120-100-100-*-*-iso8859-1|-12,0,0,0,700,0,0,0,0,3,2,1,49,Courier New
0 ""
713 618 757 645
0
E
"/* Hist_4 'Numb' for MoPS
123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456*/
main()
{
	string ch_hv_lv;
	int ch_hv_lv_num;

	// set the HV-LV card label (and parametres) depending on the number of slot used
	getValue(\"Ch_HV_LV04\", \"text\", ch_hv_lv);
	switch(ch_hv_lv)
		{
			case \"Card\":
			case \"HVca\":
			case \"LVca\":
					getValue(\"Ch_HV_LV_Num04\", \"text\", ch_hv_lv_num);
					switch(ch_hv_lv_num)
					  {
					  	case 1:
					  	case 3:
					  	case 4:
					  	case 6:
					  	case 7:
					  	case 9:
					  	case 10:
					  	case 12:
					  	case 13:
					  	case 15:
					  	case 16:
					  	case 18:
							setValue(\"Ch_HV_LV04\", \"text\", \"LVca\");
							setValue(\"Parameter04\", \"items\", makeDynString(\"LVcaTemp\", \"LVcaPowr\"));
							setValue(\"Parameter04\", \"selectedPos\", 0);
						break;
					  	case 2:
					  	case 5:
					  	case 8:
					  	case 11:
					  	case 14:
					  	case 17:
					  		setValue(\"Ch_HV_LV04\", \"text\", \"HVca\");
					  		setValue(\"Parameter04\", \"items\", makeDynString(\"no para\"));
							setValue(\"Parameter04\", \"selectedPos\", 0);
					  	break;
			break;
					  }
		}

}" 0

E

N 0 47 1 0 0 1
22 865
"Parameter04"
""
1 845 620 E E E 1 E 1 E N "_WindowText" E N {204,204,204} E E
 E E
744 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
2
LANG:1 105 -microsoft windows-Arial-bold-r-normal-*-*-110-100-100-*-*-iso8859-1|-12,0,0,0,700,0,0,0,0,3,2,1,34,Arial
LANG:5 119 -microsoft windows-Courier New-normal-r-normal-*-*-110-100-100-*-*-iso8859-1|-12,0,0,0,400,0,0,0,0,3,2,1,49,Courier New
0 ""
843 618 937 644
30
1
LANG:1 8 ChanStat
 1
1
LANG:1 8 Vcc_Modl
 0
1
LANG:1 8 Vcc_onPS
 0
1
LANG:1 8 Vcc_Retn
 0
1
LANG:1 8 Icc_Curr
 0
1
LANG:1 8 Vdd_Modl
 0
1
LANG:1 8 Vdd_onPS
 0
1
LANG:1 8 Vdd_Retn
 0
1
LANG:1 8 Idd_Curr
 0
1
LANG:1 8 VCSELvol
 0
1
LANG:1 8 VCSELcur
 0
1
LANG:1 8 PIN_Volt
 0
1
LANG:1 8 PIN_Curr
 0
1
LANG:1 8 Mo0_Temp
 0
1
LANG:1 8 Mo1_Temp
 0
1
LANG:1 8 Idd_Trip
 0
1
LANG:1 8 Icc_Trip
 0
1
LANG:1 8 TempLimi
 0
1
LANG:1 8 TripLimi
 0
1
LANG:1 8 ClockSel
 0
1
LANG:1 8 ClockRes
 0
1
LANG:1 8 ChOutpON
 0
1
LANG:1 7 Reserve
 0
1
LANG:1 8 HVchStat
 0
1
LANG:1 8 HVchVolt
 0
1
LANG:1 8 HVchCurr
 0
1
LANG:1 8 HVnomVal
 0
1
LANG:1 8 HVcrTrip
 0
1
LANG:1 8 HVrampRt
 0
1
LANG:1 4 No01
 0
E
E
E
 0 0
13 866
"Button1"
""
1 935 602 E E E 1 E 1 E N {0,51,102} E N {204,204,102} E E
 E E
745 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 117 -microsoft windows-Courier New-bold-r-normal-*-*-120-100-100-*-*-iso8859-1|-13,0,0,0,700,0,0,0,0,3,2,1,49,Courier New
0 ""
933 600 957 644
T 
1
LANG:1 2 Go
"/* Histogram_4 'Go' for MoPS
123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456*/

main()
{
	int rack, crate, ch_hv_lv_num, parameter_pos, ch_hv_lv_pos;
	int hours, bins;
	string dpeName, parameter, ch_hv_lv, used_para;

	 //get the BarTrend object
	shape histo = getShape(\"Hist04\");

	//get the number of hours to go back in the past and define a default value (differentsfrom zero)
	getValue(\"Hours04\", \"text\", hours);

	//get the number of bin and do some protection
	getValue(\"Bins04\", \"text\", bins);
	if(bins == 0) bins = 50;
	
	//get the actual value of Rack, Crate, Ch_HV_LV, Ch_HV_LV_Num and Parameter
	getValue(\"Rack04\", \"text\", rack);
	getValue(\"Crate04\", \"text\", crate);
	getValue(\"Ch_HV_LV_Num04\", \"text\", ch_hv_lv_num);
	getValue(\"Parameter04\", \"text\", parameter);
	getValue(\"Parameter04\", \"selectedPos\", parameter_pos);//position of the para in the combobox
	getValue(\"Ch_HV_LV04\", \"text\", ch_hv_lv);
	getValue(\"Ch_HV_LV04\", \"selectedPos\", ch_hv_lv_pos);
	
	//strore the used parameters
	//sprintf(used_para, \"%d_%d_%d_%d_%d_%d_%d\", rack, crate, ch_hv_lv_pos, ch_hv_lv_num,
	//  											    parameter_pos, bins, hours);
	//dpSet(\"SCTmops1:Hist04.Name00:_original.._value\", used_para);

	crate = (rack * 4) + crate; //because we start from 0 (in the data point numbering)
//	crate = (rack-1)*4 + crate -1; //-1 because we start from 0 (in the data point numbering)
//	ch_hv_lv_num = ch_hv_lv_num -1; // start counting from zero (in the data point numbering)
	
	//make a 2 digit label for crates
	if(crate<10)
		dpeName = \"SCTmops1:Crate0\"+crate;
	else
		dpeName = \"SCTmops1:Crate\"+crate;

	//find out which HVca, LVca and Ch is used
	switch(ch_hv_lv)
	  {
		case \"HVca\":
			//dpeName = \"\";
            dpSet(\"SCTmops1:Eror.Name:_original.._value\", 
\" Histogram - there is no HV card parameter to be plot,\\n             choose an other card\");
            dpSet(\"SCTmops1:Eror.Stat:_original.._value\", 0x2);
			dpeName = dpeName+\".HV_card0\"+ch_hv_lv_num+\".\"+parameter+\".Recv\";
		break;
		
		case \"LVca\":
			//make a 2 digit label for LV card
			if(ch_hv_lv_num<10)
				dpeName = dpeName+\".LV_card0\"+ch_hv_lv_num+\".\"+parameter+\".Recv\";
			else
				dpeName = dpeName+\".LV_card\"+ch_hv_lv_num+\".\"+parameter+\".Recv\";
				
		break;
		
		default://it is channel
			
				//make a 2 digit label for channel
				if(ch_hv_lv_num<10)
					dpeName = dpeName+\".Channel0\"+ch_hv_lv_num+\".\"+parameter+\".Recv\";
				else
					dpeName = dpeName+\".Channel\"+ch_hv_lv_num+\".\"+parameter+\".Recv\";
		break;
	  }

	//save the configuration used here for a evntual next use
	dpSet(\"SCTmops1:Hist0\"+$Tab_Numb+\".Name04:_original.._value\", dpeName);
	dpSet(\"SCTmops1:Hist0\"+$Tab_Numb+\".Bins04:_original.._value\", bins);
	dpSet(\"SCTmops1:Hist0\"+$Tab_Numb+\".Hour04:_original.._value\", hours);
	setHistogram(histo, dpeName, bins, hours);
}

setHistogram(shape histo, string dpeName, int bins, int hours)
{
	int seconds, x_bin;
	int index;
	float data_min, data_max, x_step, y_step, x_max, x_min, y_max, data_mean, data_RMS;
	string Entries, Mean, RMS, Xmin, Xmax, Ymax, Ymin;
	time timeNow, timePast;
	
	dyn_int evt;
	dyn_float statistique, x_coordinate, X, Y, data_array, data_square_array;
	dyn_time time_array;
 	dyn_string statBox;
 		
 	//some intitialisation
 	x_step = 0;
 	y_step = 0;
 	x_max = 0;
 	y_max = 0;
 	
	//calculate the correspondant time to hours in the past (use tranformation to seconds)
	setPeriod(timePast, period(getCurrentTime()) - hours*3600);

	//time now
	timeNow = getCurrentTime();

	//get the data correspondant to the required period
	dpGetPeriod(timePast, timeNow, -1, dpeName+\":_offline.._value\", data_array, time_array, evt);
		
	//return if no data
	if(dynlen(data_array) == 0)
        { dpSet(\"SCTmops1:Eror.Name:_original.._value\", 
\" Hist4_Go script of mainTab_\"+$Tab_Numb+\": \\n             the DaPo \"+dpeName+\"\\n             has no archived data\\n             Try to start archive if it is not started yet\\n\"); 
          dpSet(\"SCTmops1:Eror.Stat:_original.._value\", 0x2);
		  return;
		}
		
	//take the square for later RMS calculation
	for(index=1; index<=dynlen(data_array); index++)
		{
			data_square_array[index] = data_array[index]*data_array[index];
		}
		
	//find the maximum and minimum and calculate the bin width (x_step)
	data_max = dynMax(data_array);
	data_min = dynMin(data_array);
	x_step = (data_max - data_min)/(bins-1);
	
	//initialise the statistique to zero and the X coordinate to the defined binning
	for(index=1; index<=bins+3; index++) // add 2 bins (1 underflow bins and 2 overflow)
		{
			dynAppend(statistique, 0);
			dynAppend(x_coordinate, data_min + (index-2)*x_step);
		}
		
	//fill the statistique
	for(index=1; index<=dynlen(data_array); index++)
		{
			//caluculate in which bin the actual value goes
			x_bin = (data_array[index]-data_min)/x_step + 2;
			
			//increment the statistique of the correspondant bin
			statistique[x_bin] = statistique[x_bin] + 1;
		}
		
	//statistique box attributes
	sprintf(Entries, \"Entries  %d\", dynlen(data_array));
	data_mean = dynAvg(data_array);
	sprintf(Mean,    \"Mean     %f\", data_mean);
	//RMS
	data_RMS = dynAvg(data_square_array);
    data_RMS = sqrt(data_RMS - data_mean*data_mean);
    sprintf(RMS,     \"RMS      %f\", data_RMS);
    sprintf(Xmin,    \"Xmin     %f\", data_min);
    sprintf(Xmax,    \"Xmax     %f\", data_max);
    sprintf(Ymax,    \"Ymax     %d\", dynMax(statistique));
    sprintf(Ymin,    \"Ymin     %d\", dynMin(statistique));
	statBox = makeDynString(Entries, Mean, RMS, Xmin, Xmax, Ymax, Ymin); 
	setValue(\"StatBox04\", \"items\", statBox);
	
	//clear the data array. may be huge!!
	dynClear(data_array);

	//calculate the Y spep
	y_max = dynMax(statistique);
	y_step = 1;
	//if(y_max>5) y_step = y_max/5;
	
	// Y-axis coordinates stuff
	setValue(histo, \"yOrigin\", BAR_BOTTOM);
	setValue(histo, \"yCenter\", 0);
	setValue(histo, \"yRange\",  y_max+y_step);
	setValue(histo, \"yStep\",   y_step);
	setValue(histo, \"yPrec\",   0);
	setValue(histo, \"yGrid\",   FALSE);

	x_max = dynMax(x_coordinate);
	x_min = dynMin(x_coordinate);

	// X-axis coordiantes stuff
	setValue(histo, \"xOrigin\", BAR_LEFT);
	setValue(histo, \"xStep\",   x_step);
	//setValue(histo, \"xCenter\", x_min-x_step);
	setValue(histo, \"xCenter\", x_min);
	setValue(histo, \"xRange\",  x_max);
	setValue(histo, \"xPrec\",   0);
	setValue(histo, \"xGrid\",   FALSE);
	
	// set the value to the barTrend object
	setValue(histo, \"data\", x_coordinate, statistique);
 
	// step curve
	setValue(histo, \"connection\", BAR_STEPS);
 	// Fill the area
	setValue(histo, \"fill\", FALSE);
 	// Update bar trend
	histo.flush();
}" 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