V 10
1
LANG:1 8 (NoName)
PANEL,438 340 229 466 N "_3DFace" 0
EEE E E 1 -1 -1 0  30 70
"" 0 1
E"EP_childPanelOn()
{
   ChildPanelOnCentralModal(\"subpanels/ErrorMask.pnl\",\"\",makeDynString(\"\"));
}


Set_State(int iState, int crate, int cardtype) 
{
   dyn_errClass err;
   int i,j;
   int channel, ack, ackE;
   int ChannelNo;
   string cardname, datapoint, datapoint2, datapoint3, datapoint4, datapoint5;
   int terval = 5;
   int n_good =0;
   int fatal, expectedE;
   int start, stop;
   string systemName,cooling_state,cooling_status, FWA_param;
   int old_crate_state;
   

   // Must not ramp up if environmental alarm in progress
   // (ramp down is still allowed)
   if (iState>0) {
      dpGet(\"Fatl.Numb:_original.._value\",fatal);
      if(fatal!=0){
         dpSet(\"Info.Name:_original.._value\", \"Set_State: Request Denied due to Environment Alarm (code \"+fatal+\")\");
         DebugN(\"Set_State: Request Denied due to Environment Alarm (code \"+fatal+\")\");
         return;     
      }
   }
// same for SR cooling, commented out for Oxford
/*   if (iState>0) {
     systemName=getSystemName(40);
     dpGet(systemName +\"Cooling.State:_original.._value\",cooling_state);  
     dpGet(systemName +\"Cooling.Status:_original.._value\",cooling_status);        
     if(cooling_state!=\"Ready\"||cooling_status!=\"OK\"){
         dpSet(\"Info.Name:_original.._value\", \"Set_State: Request Denied due to Cooling Alarm (code \"+fatal+\")\");
         DebugN(\"Set_State: Request Denied due to Cooling Alarm (code \"+fatal+\")\");
         return;     
      }
   }
*/
   if (cardtype == 255) {
     // state transition for both LV and HV 
     // - can send single command
     start = 0;
     stop = 0;
     terval = 100;
     expectedE = 1;
     sprintf(cardname,\"LV and HV\"); 
   }else{
     // state transition for LV only or HV only
     // - must send 47 commands
     start = 0;
     stop = 47;
     terval = 5;
     expectedE = 0;
     if (cardtype == 64){
        sprintf(cardname,\"HV\");
     }else{
        sprintf(cardname,\"LV\");
     }
   }

   dpSet(\"Info.Name:_original.._value\", \"Set_State: Crate \"+crate+\" \"+cardname+\" to state \"+iState);

   sprintf(datapoint,\"Crate%02d.Controller.CCch_Set.Send:_original.._value\",crate);
   sprintf(datapoint2,\"Crate%02d.Controller.CCcf_Ack.Recv:_online.._value\",crate);
   sprintf(datapoint3,\"Crate%02d.Controller.CCcf_AckE.Recv:_online.._value\",crate);
     
   for (i=start;i<=stop;i++) {

      // Set channel
      channel = i+cardtype | (( iState & 0x00ff )<<8);
      dpSetWait(datapoint,channel);
 
      //Get Acknowledgement
      ack=-1;
      j=0;
      while ((ack!=channel)&&(j<200)) {
         delay(0,terval);
         dpGet(datapoint2,ack);
         j++;
      }
      dpGet(datapoint3,ackE);           
			
			DebugN(\"Channel : \",channel);
			
      // Report errors
      if (ack!=channel)  {
         dpSet(\"Info.Name:_original.._value\", \"Set_State: Timeout (channel \"+channel+\" ack \"+ack+\" ackE \"+ackE+\" after \"+(j*terval)+\"mS)\");
         DebugN(\"Set_State: Timeout (channel \"+channel+\" ack \"+ack+\" ackE \"+ackE+\" after\"+(j*terval)+\"mS)\");
      }else if (ackE!=expectedE) {
         dpSet(\"Info.Name:_original.._value\", \"Set_State: Error (channel \"+channel+\" ack \"+ack+\" ackE \"+ackE+\" after \"+(j*terval)+\"mS)\");
         DebugN(\"Set_State: Error (channel \"+channel+\" ack \"+ack+\" ackE \"+ackE+\" after\"+(j*terval)+\"mS)\");     
      } else {
         n_good++;
         
         //set State for the crate when LV and HV are changed
         if (cardtype == 255) {
         	sprintf(datapoint4,\"Crate%02d.State:_original.._value\",crate);
         	dpGet(datapoint4, old_crate_state);
         	if(old_crate_state!=iState){
         		dpSet(datapoint4,iState);
         		sprintf(FWA_param, crate + \"|\" + iState + \"|all\");
         	
         		//set State for all channels
         		ChannelNo = 0;
         		sprintf(datapoint5, \"Crate%02d.Channel%02d\", crate, ChannelNo);
         		while(dpExists(datapoint5)){
         			dpSet(datapoint5+\".State:_original.._value\",iState);
         			DebugN(\"State set\", datapoint5, ChannelNo);
         			ChannelNo++;
         			sprintf(datapoint5, \"Crate%02d.Channel%02d\", crate, ChannelNo);
         		}
         	
         	//fill Warn and Alarms for the corresponding state
         		dpSet(systemName+\"fill_Warn_Alarm.parameters:_original.._value\", FWA_param);
						dpSetWait(systemName+\"fill_Warn_Alarm.trigger:_original.._value\", TRUE);
						DebugN(FWA_param);
					}
         }
         DebugN(n_good);
      }
   }
   
   if (cardtype==0) {
      DebugN(\"Set_State: \"+n_good+\" LV channels changed to state \"+iState);
   } else if (cardtype==64) {
      DebugN(\"Set_State: \"+n_good+\" HV channels changed to state \"+iState);
   }

   err = getLastError();
   if (dynlen(err) > 0)
      errorDialog(err);
}
" 0
 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
6 38
"Border1"
""
1 10 340 E E E 1 E 1 E N {0,0,0} E N {204,204,255} E E
 E E
33 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 10 10 210 340
2 39
"Text3"
""
1 10 10 E E E 1 E 1 E N {0,0,0} E N {153,153,204} E E
 E E
34 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 12 12 208 33
1 2 0 "s" 0 0 0 65 0 0  12 12
 1
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 ""
1
LANG:1 18 One Crate Controll
2 40
"Text4"
""
1 10 271 E E E 1 E 1 E N {0,0,0} E N {153,153,204} E E
 E E
35 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 12 273 208 294
1 2 0 "s" 0 0 0 65 0 0  12 273
 1
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 ""
1
LANG:1 14 One Crate Mask
13 24
"Button5"
""
1 20 40 E E E 1 E 1 E N {0,0,0} E N {204,204,255} E E
 E E
21 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 ""
18 38 112 72
T 
1
LANG:1 9 ON ALL HV
"// SimpleCtrlScriptStart {invalid}
main()
{
   int iState, crate, cardtype;
 
   setValue(\"\", \"backCol\", \"Red\");
   iState=1;
   cardtype=64;
   
   dpGet(\"Crate.Numb:_original.._value\", crate);  
   Set_State(iState, crate, cardtype); 
 
   setValue(\"\", \"backCol\", \"{204,204,255}\");
}


// SimpleCtrlScript {EP_setDP}
// DP1 {Crate1.HVchRamp}
// Config1 {:_original.._value}
// Type1 {int}
// Value1 {1}
// SimpleCtrlScriptEnd {EP_setDP}
" 0
 E E E
13 14
"ReadCard"
""
1 968 160 E E E 1 E 1 E N {0,0,0} E N {153,153,204} E E
 E E
15 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 ""
18 128 202 162
T 
1
LANG:1 4 READ
"// SimpleCtrlScriptStart {invalid}

main()
{
  EP_setDP();
}

EP_setDP()
{
dyn_errClass err;
int crate,channel, i;
string datapoint;

dpGet(\"Crate.Numb:_original.._value\",crate);
sprintf(datapoint,\"Crate%02d.Controller.CCchRead.Send:_original.._value\", crate);
for (i=0;i<=47;i++){
channel=i+64;
dpSetWait(datapoint, channel);
dpSetWait(datapoint,i);
delay(0,10);
  err = getLastError();
  if (dynlen(err) > 0)
    errorDialog(err);
 }
}

// SimpleCtrlScript {EP_setDP}
// DP1 {Crate00.Controller.CCco_Set}
// Config1 {:_original.._value}
// Type1 {int}
// Value1 {1}
// SimpleCtrlScriptEnd {EP_setDP}
" 0
 E E E
13 21
"Button1"
""
1 74 510 E E E 1 E 1 E N {0,0,0} E N {204,204,255} E E
 E E
20 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 ""
18 298 112 332
T 
1
LANG:1 12 ALL MASKS ON
"// SimpleCtrlScriptStart {invalid}
main()
{
  EP_setDP();
}

EP_setDP()
{
dyn_errClass err;
int i;
string datapoint;
int crate;


dpGet(\"Crate.Numb:original.._value\",crate);
 for (i=0;i<=5;i++)
  {
  sprintf(datapoint, \"Crate%02d.HV_card%02d.HVcaMask.Send:_original.._value\",crate,i);

  dpSetWait(datapoint, 255);
  }
 for (i=0;i<=11;i++)
  {
  sprintf(datapoint, \"Crate%02d.LV_card%02d.LVcaMask.Send:_original.._value\",crate,i);

  dpSetWait(datapoint, 15);
  }

err = getLastError();
if (dynlen(err) > 0)
errorDialog(err);  

//DebugN(\"Mask on...\");
dpSet(\"Info.Name:_original.._value\", \"Mask on...\");     
  
}

// SimpleCtrlScript {EP_setDP}
// DP1 {Crate1.HVchRamp}
// Config1 {:_original.._value}
// Type1 {int}
// Value1 {1}
// SimpleCtrlScriptEnd {EP_setDP}
" 0
 E E E
13 22
"AllMasksOff"
""
1 183 830 E E E 1 E 1 E N {0,0,0} E N {204,204,255} E E
 E E
20 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 ""
108 298 202 332
T 
1
LANG:1 12 ALL MSKS OFF
"// SimpleCtrlScriptStart {invalid}
main()
{
  EP_setDP();
}

EP_setDP()
{
dyn_errClass err;
int i;
string datapoint;
int crate,volt ;
int flag;

flag=0;
dpGet(\"Crate.Numb:original.._value\",crate);
 for (i=0;i<=47;i++)
   {
   sprintf(datapoint,\"Crate%02d.Channel%02d.HVchVolt.Recv:_online.._value\",crate,i);
   dpGet(datapoint,volt);
   if(volt>10) flag=1;
   }
  if(flag==0)
  {
    for (i=0;i<=5;i++)
      {
      sprintf(datapoint, \"Crate%02d.HV_card%02d.HVcaMask.Send:_original.._value\",crate,i);
      //DebugN(datapoint,i);
      dpSetWait(datapoint, 0);
      }
    for (i=0;i<=11;i++)
      {
      sprintf(datapoint, \"Crate%02d.LV_card%02d.LVcaMask.Send:_original.._value\",crate,i);
      //DebugN(datapoint,i);
      dpSetWait(datapoint, 0);
      }
  }
  else 
  {
   ChildPanelOnCentral(\"realmask.pnl\", \"realmask\", \"\");
  } 

err = getLastError();
if (dynlen(err) > 0)
errorDialog(err); 

dpSet(\"Info.Name:_original.._value\", \"Mask off...\");        
  
}




// SimpleCtrlScript {EP_setDP}
// DP1 {Crate1.HVchRamp}
// Config1 {:_original.._value}
// Type1 {int}
// Value1 {1}
// SimpleCtrlScriptEnd {EP_setDP}
" 0
 E E E
13 45
"Button9"
""
1 20 70 E E E 1 E 1 E N {0,0,0} E N {204,204,255} E E
 E E
40 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 ""
18 68 112 102
T 
1
LANG:1 12 STNBY ALL HV
"// SimpleCtrlScriptStart {invalid}
main()
{
   int iState, crate, cardtype;
 
   setValue(\"\", \"backCol\", \"Red\");
   iState=2;
   cardtype=64;
   
   dpGet(\"Crate.Numb:_original.._value\", crate);  
   Set_State(iState, crate, cardtype); 
 
   setValue(\"\", \"backCol\", \"{204,204,255}\");
}

// SimpleCtrlScript {EP_setDP}
// DP1 {Crate1.HVchRamp}
// Config1 {:_original.._value}
// Type1 {int}
// Value1 {1}
// SimpleCtrlScriptEnd {EP_setDP}
" 0
 E E E
13 46
"Button12"
""
1 20 100 E E E 1 E 1 E N {0,0,0} E N {204,204,255} E E
 E E
41 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 ""
18 98 112 132
T 
1
LANG:1 10 OFF ALL HV
"// SimpleCtrlScriptStart {invalid}
main()
{
   int iState, crate, cardtype;
 
   setValue(\"\", \"backCol\", \"Red\");
   iState=0;
   cardtype=64;
   
   dpGet(\"Crate.Numb:_original.._value\", crate);  
   Set_State(iState, crate, cardtype); 
 
   setValue(\"\", \"backCol\", \"{204,204,255}\");
}

// SimpleCtrlScript {EP_setDP}
// DP1 {Crate1.HVchRamp}
// Config1 {:_original.._value}
// Type1 {int}
// Value1 {1}
// SimpleCtrlScriptEnd {EP_setDP}
" 0
 E E E
13 47
"Button2"
""
1 110 40 E E E 1 E 1 E N {0,0,0} E N {204,204,255} E E
 E E
42 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 ""
108 38 202 72
T 
1
LANG:1 9 ON ALL LV
"// SimpleCtrlScriptStart {invalid}
main()
{
   int iState, crate, cardtype;
 
   setValue(\"\", \"backCol\", \"Red\");
   iState=1;
   cardtype=0;
   
   dpGet(\"Crate.Numb:_original.._value\", crate);  
   Set_State(iState, crate, cardtype); 
 
   setValue(\"\", \"backCol\", \"{204,204,255}\");
}
// SimpleCtrlScript {EP_setDP}
// DP1 {Crate1.HVchRamp}
// Config1 {:_original.._value}
// Type1 {int}
// Value1 {1}
// SimpleCtrlScriptEnd {EP_setDP}
" 0
 E E E
13 48
"Button3"
""
1 110 70 E E E 1 E 1 E N {0,0,0} E N {204,204,255} E E
 E E
43 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 ""
108 68 202 102
T 
1
LANG:1 12 STNBY ALL LV
"// SimpleCtrlScriptStart {invalid}
main()
{
   int iState, crate, cardtype;
 
   setValue(\"\", \"backCol\", \"Red\");
   iState=2;
   cardtype=0;
   
   dpGet(\"Crate.Numb:_original.._value\", crate);  
   Set_State(iState, crate, cardtype); 
 
   setValue(\"\", \"backCol\", \"{204,204,255}\");
}
// SimpleCtrlScript {EP_setDP}
// DP1 {Crate1.HVchRamp}
// Config1 {:_original.._value}
// Type1 {int}
// Value1 {1}
// SimpleCtrlScriptEnd {EP_setDP}
" 0
 E E E
13 49
"Button4"
""
1 110 100 E E E 1 E 1 E N {0,0,0} E N {204,204,255} E E
 E E
44 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 ""
108 98 202 132
T 
1
LANG:1 10 OFF ALL LV
"// SimpleCtrlScriptStart {invalid}
main()
{
   int iState, crate, cardtype;
 
   setValue(\"\", \"backCol\", \"Red\");
   iState=0;
   cardtype=0;
   
   dpGet(\"Crate.Numb:_original.._value\", crate);  
   Set_State(iState, crate, cardtype); 
 
   setValue(\"\", \"backCol\", \"{204,204,255}\");
}
// SimpleCtrlScript {EP_setDP}
// DP1 {Crate1.HVchRamp}
// Config1 {:_original.._value}
// Type1 {int}
// Value1 {1}
// SimpleCtrlScriptEnd {EP_setDP}
" 0
 E E E
13 50
"Button6"
""
1 60 170 E E E 1 E 1 E N {0,0,0} E N {204,204,255} E E
 E E
44 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 ""
58 168 172 202
T 
1
LANG:1 12 ON LV and HV
"// SimpleCtrlScriptStart {invalid}
main()
{
   int iState, crate, cardtype;
 
   setValue(\"\", \"backCol\", \"Red\");
   iState=1;
   cardtype=255; // special code for all cards, all channels
   
   dpGet(\"Crate.Numb:_original.._value\", crate);  
   Set_State(iState, crate, cardtype); 
 
   setValue(\"\", \"backCol\", \"{204,204,255}\");
}

// SimpleCtrlScript {EP_setDP}
// DP1 {Crate1.HVchRamp}
// Config1 {:_original.._value}
// Type1 {int}
// Value1 {1}
// SimpleCtrlScriptEnd {EP_setDP}
" 0
 E E E
13 51
"Button7"
""
1 60 200 E E E 1 E 1 E N {0,0,0} E N {204,204,255} E E
 E E
45 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 ""
58 198 172 232
T 
1
LANG:1 16 STNBY  LV and HV
"// SimpleCtrlScriptStart {invalid}
main()
{
   int iState, crate, cardtype;
 
   setValue(\"\", \"backCol\", \"Red\");
   iState=2;
   cardtype=255; // special code for all cards, all channels
   
   dpGet(\"Crate.Numb:_original.._value\", crate);  
   Set_State(iState, crate, cardtype); 
 
   setValue(\"\", \"backCol\", \"{204,204,255}\");
}

// SimpleCtrlScript {EP_setDP}
// DP1 {Crate1.HVchRamp}
// Config1 {:_original.._value}
// Type1 {int}
// Value1 {1}
// SimpleCtrlScriptEnd {EP_setDP}
" 0
 E E E
13 53
"Button8"
""
1 60 230 E E E 1 E 1 E N {0,0,0} E N {204,204,255} E E
 E E
47 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 ""
58 228 172 262
T 
1
LANG:1 13 OFF LV and HV
"// SimpleCtrlScriptStart {invalid}
main()
{
   int iState, crate, cardtype;
 
   setValue(\"\", \"backCol\", \"Red\");
   iState=0;
   cardtype=255; // special code for all cards, all channels
   
   dpGet(\"Crate.Numb:_original.._value\", crate);  
   Set_State(iState, crate, cardtype); 
 
   setValue(\"\", \"backCol\", \"{204,204,255}\");
}

// SimpleCtrlScript {EP_setDP}
// DP1 {Crate1.HVchRamp}
// Config1 {:_original.._value}
// Type1 {int}
// Value1 {1}
// SimpleCtrlScriptEnd {EP_setDP}
" 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