/*@!Encoding:1252*/
variables
{
  // ------------------------------------------------
  // File information
  // Copyright         : 2017, Vector Informatik GmbH
  // ------------------------------------------------
  
  // Definition of debugging constants
  const int kDbgInfo    = 10;
  const int kDbgWarning = 5;
  const int kDbgError   = 1;
  const int kDbgQuiet   = 0;
  char gNodeLabel[256] = "Control";
}

on sysvar CANopen::CANopen::ControlPanel_ID10::Control::CommunicationState
{
  switch(@this)
  {
    case 0: // Not active
      writeDbgLevel(kDbgInfo, "<%s>: Changed state to 'Not active'", gNodeLabel);
      @sysvar::GUIControls::ControlPanel_CommState = 3;
      break;
    case 4: // Stopped
      writeDbgLevel(kDbgInfo, "<%s>: Changed state to 'Stopped'", gNodeLabel);
      @sysvar::GUIControls::ControlPanel_CommState = 3;
      break;
    case 5: // Operational
      writeDbgLevel(kDbgInfo, "<%s>: Changed state to 'Operational'", gNodeLabel);
      @sysvar::GUIControls::ControlPanel_CommState = 1;
      break;
    case 6: // Reset Node
      writeDbgLevel(kDbgInfo, "<%s>: 'Reset Node' command received", gNodeLabel);
      @sysvar::GUIControls::ControlPanel_CommState = 3;
      break;
    case 7: // Reset Communication
      writeDbgLevel(kDbgInfo, "<%s>: 'Reset Communication' command received", gNodeLabel);
      @sysvar::GUIControls::ControlPanel_CommState = 3;
      break;
    case 127: // Preoperational
      writeDbgLevel(kDbgInfo, "<%s>: Changed state to 'Preoperational'", gNodeLabel);
      @sysvar::GUIControls::ControlPanel_CommState = 2;
      break;
    default:
      writeDbgLevel(kDbgInfo, "<%s>: Changed state (?)", gNodeLabel);
      break;
  }
  // TODO: Implement additional handling here
}





