V 10
1
LANG:1 22 ElementCrateStatMedium
PANEL,276 776 186 46 N "_3DFace" 3
"$dpCrate"
"$dpSystem"
"$userCrate"
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
10 0
"ElementCrateStatMediumState"
""
1 10 36 E E E 1 E 1 E N {0,0,0} E N {0,255,0} E E
 E E
1 0 0 0 0 0
EE E
0
1
LANG:1 14 Crate mm State
1
"dashclr"N "_Transparent"
"main()
{
//*******0*********0*********0*********0*********0*********0*********0*********0*********0*
//  SCT Power Supply Crate State Function
//*******0*********0*********0*********0*********0*********0*********0*********0*********0*
//  John Macallister,  30-JUN-2003
//*******0*********0*********0*********0*********0*********0*********0*********0*********0*
//
//  Stat register is 8 bits as follows:  | rr | ww | st | es |
//    where  rr = read only, ww = write enable, st = state, es = error status 
//    All are 2-bit values ie 0,1,2 or 3
//
//  Set the background colour of the channel triangle object
//   according to the value of the State flag: 0,1,2 or 3   
//        0 - OUT of system  (Off)          Grey
//        1 - IN system      (Configured)   Yellow
//        2 - READY          (Standby)      Cyan
//        3 - RUNNING        (Busy)         Green
//
//*******0*********0*********0*********0*********0*********0*********0*********0*********0*

dyn_errClass err;
bool startnow;

//
// Set the tool tip value according to user crate number
//
  setValue(\"\",\"toolTipText\",
            \"Crate \"+$userCrate+\" State\");
//
//*******0*********0*********0*********0*********0*********0*********0*********0*********0*
//  Set background according to the initial value of the datapoint
//   Indicate if datapoint has not been defined - Transparent
//   Indicate if (lower structure of) datapoint does not exist - Purple 
//*******0*********0*********0*********0*********0*********0*********0*********0*********0*
  if (dpExists($dpSystem+\":Crate\"+$dpCrate+\".:_common\"))
    {
//
//    Data point for crate is defined
//
     startnow = true;
     dpConnect(\"SCTps_setBackColour\",
      startnow,
      $dpSystem+\":Crate\"+$dpCrate+\".Stat:_original.._value\");
     err = getLastError();
//
//    If data point is defined but lower structure DP does not exist, something is wrong!
//
     if (dynlen(err) > 0) 
      setValue(\"\",\"backCol\",\"_dpdoesnotexist\");  /* Warning colour if DP does not exist */
     }
     else
     {
//
//    Data point for crate is not defined
//
     setValue(\"\",\"backCol\",\"_Transparent\");  /* Reminder colour to indicate that DP */
                                             /*  for the crate has not been defined */
     }
  
}

//*******0*********0*********0*********0*********0*********0*********0*********0*********0*
//  Function to set the background colour according to the state value
//*******0*********0*********0*********0*********0*********0*********0*********0*********0*
SCTps_setBackColour( string dp1 , int stat )
{
  switch ( stat & 0x0C )
  {

    case 0:  
      setValue(\"\",\"backCol\",\"{204,204,204}\"); break;   // State: Off              -  Grey
    case 4:  
      setValue(\"\",\"backCol\",\"{255,255,0}\");   break;   // State: Configured       -  Yellow
    case 8:  
      setValue(\"\",\"backCol\",\"{0,255,255}\");   break;   // State: Standby          -  Cyan
    case 12: 
      setValue(\"\",\"backCol\",\"{0,255,0}\");     break;   // State: Running          -  Red
    default: 
      setValue(\"\",\"backCol\",\"{204,204,204}\");          // Undefined = State: Off  -  Grey

  }
  
}" 0
 E 0 1 1 0 1 E U  1 E 3 10 36
10 10
176 10
1
10 1
"ElementCrateStatMediumErrorStatus"
""
1 132 -82 E E E 1 E 1 E N {0,0,0} E N {0,255,0} E E
 E E
2 0 0 0 0 0
EE E
0
1
LANG:1 21 Crate mm Error Status
1
"dashclr"N "_Transparent"
"main()
{
//*******0*********0*********0*********0*********0*********0*********0*********0*********0*
//  SCT Power Supply Crate Error Status Function
//*******0*********0*********0*********0*********0*********0*********0*********0*********0*
//  John Macallister,  30-JUN-2003
//*******0*********0*********0*********0*********0*********0*********0*********0*********0*
//
//  Stat register is 8 bits as follows:  | rr | ww | st | es |
//    where  rr = read only, ww = write enable, se = state, ss = error status 
//    All are 2-bit values ie 0,1,2 or 3
//
//  Set the background colour of the channel triangle object
//   according to the value of the Status flag: 0,1,2 or 3   
//        0 - Normal      Green
//        1 - Fatal       Red
//        2 - Warning     Yellow
//        3 - Disabled    Grey
//
//*******0*********0*********0*********0*********0*********0*********0*********0*********0*

dyn_errClass err;
bool startnow;

//
// Set the tool tip value according to user crate number and channel number
//
  setValue(\"\",\"toolTipText\",
            \"Crate \"+$userCrate+\" Error Status\");
//
//*******0*********0*********0*********0*********0*********0*********0*********0*********0*
//  Set background according to the initial value of the datapoint
//   Indicate if datapoint has not been defined - Transparent
//   Indicate if (lower structure of) datapoint does not exist - Purple 
//*******0*********0*********0*********0*********0*********0*********0*********0*********0*
  if (dpExists($dpSystem+\":Crate\"+$dpCrate+\".:_common\"))
    {
//
//    Data point for crate is defined
//
    startnow = true;
    dpConnect(\"SCTps_setBackColour\",
     startnow,
     $dpSystem+\":Crate\"+$dpCrate+\".Stat:_original.._value\");
    err = getLastError();
//
//    If data point is defined but lower structure DP does not exist, something is wrong!
//
    if (dynlen(err) > 0) 
     setValue(\"\",\"backCol\",\"_dpdoesnotexist\");  /* Warning colour if DP does not exist */
    }
    else
    {
//
//    Data point for crate is not defined
//
    setValue(\"\",\"backCol\",\"_Transparent\");  /* Reminder colour to indicate that DP */
                                            /*  for the crate has not been defined */
    }
  
}

//*******0*********0*********0*********0*********0*********0*********0*********0*********0*
//  Function to set the background colour according to the error status value
//*******0*********0*********0*********0*********0*********0*********0*********0*********0*
SCTps_setBackColour( string dp1 , int stat )
{
  if ( ( stat & 0x0c) != 0 )
//
//  Error status only has meaning when State is not OFF
//
   switch ( stat & 0x03 )
    {
    case 0:  
      setValue(\"\",\"backCol\",\"{0,255,0}\");     break; // Error status: Normal       - Green
    case 1:  
      setValue(\"\",\"backCol\",\"{255,0,0}\");     break; // Error status: Fatal        - Red
    case 2:  
      setValue(\"\",\"backCol\",\"{255,255,0}\");   break; // Error status: Warning      - Yellow
    case 3:  
      setValue(\"\",\"backCol\",\"{204,204,204}\"); break; // Error status: Disabled     - Grey
    default: 
      setValue(\"\",\"backCol\",\"{204,204,204}\"); // Undefined = Error status: disabled - Grey
    }  
   else
// 
//  If State is OFF the Error Status has no meaning
//   
   setValue(\"\",\"backCol\",\"{204,204,204}\");    // Undefined = Error status: disabled - Grey
}" 0
 E 0 1 1 0 1 E -1 1.224606353822377e-016 -1.224606353822377e-016 -1  186 45.99999999999999  1 E 3 10 36
10 10
176 10
1
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