// Ignore Spelling: FRONTPANEL WATCHDOGDELAY WATCHDOGON WATCHDOGOFF OCP OVP SELFTEST

using Raytheon.Common;

namespace Raytheon.Instruments
{
   public class PowerScpiCommands
   {
      // module current commands
      public string _SET_OCP_INRUSH_DELAY_CMD;
      public string _SET_OCP_CMD;
      public string _SET_OCP_ON_CMD;
      public string _READ_CURRENT_CMD;
      public string _READ_OCP_CMD;
      public string _READ_INRUSH_DELAY_CMD;
      //public string _READ_OCP_CMD = "CURR:LIM" ?;

      // module voltage commands
      public string _SET_OVP_CMD;
      public string _SET_VOLTAGE_SLEW_CMD;
      public string _SET_VOLTAGE_SETPOINT_CMD;
      public string _SET_CONSTANT_VOLTAGE_CMD;
      public string _READ_VOLTAGE_CMD;
      public string _READ_VOLTAGE_SETPOINT_CMD;
      public string _READ_OVP_CMD;
      public string _READ_VOLTAGE_SLEW_CMD;

      // module set output commands
      public string _SET_OUTPUT_DISABLE_CMD;
      public string _SET_OUTPUT_ENABLE_CMD;

      // module query status
      public string _READ_OUTPUT_STATUS_CMD;
      public string _READ_ERROR_STATUS_CMD;
      public string _READ_PROTECTION_STATUS_CMD;

      // system commands
      public string _CLEAR_CMD;
      public string _RESET_CMD;
      public string _SELFTEST_CMD;
      public string _REBOOT_CMD;
      public string _READ_ERROR_CODE_CMD;

      // system disable/enable commands
      public string _SET_FRONTPANEL_DISABLE_CMD;
      public string _SET_FRONTPANEL_ENABLE_CMD;

      // system watchdog commands
      public string _SET_WATCHDOGDELAY_CMD;
      public string _SET_WATCHDOGON_CMD;
      public string _SET_WATCHDOGOFF_CMD;

      // system coupling commands
      public string _SET_COUPLE_CHANNELS_CMD;
      public string _SET_COUPLE_ON_CMD;
      public string _SET_COUPLE_OUTPUT_PROTECT_ON_CMD;
      public string _QUERY_COUPLE_CHANNELS_CMD;
      public string _QUERY_COUPLE_STATE_CMD;

      // system grouping Commands
      public string _SET_GROUP_DEFINE_CMD;
      public string _UNGROUP_ALL_CHANNELS_CMD;
      public string _QUERY_GROUP_CHANNELS_CMD;

      private void ReadModuleCommands(string defFile)
      {
         IniFile ini = new IniFile(defFile);
         _SET_OCP_INRUSH_DELAY_CMD = ini.ReadValue("MODULE", "SET_INRUSH_DELAY_CMD");
         _SET_OCP_CMD = ini.ReadValue("MODULE", "SET_OCP_CMD");
         _SET_OCP_ON_CMD = ini.ReadValue("MODULE", "SET_OCP_ON_CMD");
         _READ_CURRENT_CMD = ini.ReadValue("MODULE", "READ_CURRENT_CMD");
         _READ_OCP_CMD = ini.ReadValue("MODULE", "READ_OCP_CMD");
         _READ_INRUSH_DELAY_CMD = ini.ReadValue("MODULE", "READ_INRUSH_DELAY_CMD");

         _SET_OVP_CMD = ini.ReadValue("MODULE", "SET_OVP_CMD");
         _SET_VOLTAGE_SLEW_CMD = ini.ReadValue("MODULE", "SET_VOLTAGE_SLEW_CMD");
         _SET_VOLTAGE_SETPOINT_CMD = ini.ReadValue("MODULE", "SET_VOLTAGE_SETPOINT_CMD");
         _SET_CONSTANT_VOLTAGE_CMD = ini.ReadValue("MODULE", "SET_CONSTANT_VOLTAGE_CMD");
         _READ_VOLTAGE_CMD = ini.ReadValue("MODULE", "READ_VOLTAGE_CMD");
         _READ_VOLTAGE_SETPOINT_CMD = ini.ReadValue("MODULE", "READ_VOLTAGE_SETPOINT_CMD");
         _READ_OVP_CMD = ini.ReadValue("MODULE", "READ_OVP_CMD");
         _READ_VOLTAGE_SLEW_CMD = ini.ReadValue("MODULE", "READ_VOLTAGE_SLEW_CMD");

         _SET_OUTPUT_DISABLE_CMD = ini.ReadValue("MODULE", "SET_OUTPUT_DISABLE_CMD");
         _SET_OUTPUT_ENABLE_CMD = ini.ReadValue("MODULE", "SET_OUTPUT_ENABLE_CMD");
         _READ_OUTPUT_STATUS_CMD = ini.ReadValue("MODULE", "READ_OUTPUT_STATUS_CMD");
         _READ_ERROR_STATUS_CMD = ini.ReadValue("MODULE", "READ_ERROR_STATUS_CMD");
         _READ_PROTECTION_STATUS_CMD = ini.ReadValue("MODULE", "READ_PROTECTION_STATUS_CMD");
      }

      private void ReadSystemCommands(string defFile)
      {
         IniFile ini = new IniFile(defFile);

         _CLEAR_CMD = ini.ReadValue("SYSTEM", "CLEAR_CMD");
         _RESET_CMD = ini.ReadValue("SYSTEM", "RESET_CMD");
         _SELFTEST_CMD = ini.ReadValue("SYSTEM", "SELFTEST_CMD");
         _REBOOT_CMD = ini.ReadValue("SYSTEM", "REBOOT_CMD");
         _READ_ERROR_CODE_CMD = ini.ReadValue("SYSTEM", "READ_ERROR_CODE_CMD");

         _SET_FRONTPANEL_DISABLE_CMD = ini.ReadValue("SYSTEM", "SET_FRONTPANEL_DISABLE_CMD");
         _SET_FRONTPANEL_ENABLE_CMD = ini.ReadValue("SYSTEM", "SET_FRONTPANEL_ENABLE_CMD");

         _SET_WATCHDOGDELAY_CMD = ini.ReadValue("SYSTEM", "SET_WATCHDOGDELAY_CMD");
         _SET_WATCHDOGON_CMD = ini.ReadValue("SYSTEM", "SET_WATCHDOGON_CMD");
         _SET_WATCHDOGOFF_CMD = ini.ReadValue("SYSTEM", "SET_WATCHDOGOFF_CMD");

         _SET_COUPLE_CHANNELS_CMD = ini.ReadValue("SYSTEM", "SET_COUPLE_CHANNELS_CMD");
         _SET_COUPLE_ON_CMD = ini.ReadValue("SYSTEM", "SET_COUPLE_ON_CMD");
         _SET_COUPLE_OUTPUT_PROTECT_ON_CMD = ini.ReadValue("SYSTEM", "SET_COUPLE_OUTPUT_PROTECT_ON_CMD");
         _QUERY_COUPLE_CHANNELS_CMD = ini.ReadValue("SYSTEM", "QUERY_COUPLE_CHANNELS");
         _QUERY_COUPLE_STATE_CMD = ini.ReadValue("SYSTEM", "QUERY_COUPLE_STATE");

         _SET_GROUP_DEFINE_CMD = ini.ReadValue("SYSTEM", "SET_GROUP_DEFINE_CMD");
         _UNGROUP_ALL_CHANNELS_CMD = ini.ReadValue("SYSTEM", "UNGROUP_ALL_CHANNELS_CMD");
         _QUERY_GROUP_CHANNELS_CMD = ini.ReadValue("SYSTEM", "QUERY_GROUP_CHANNELS");
      }

      public PowerScpiCommands(string scpiDefFile)
      {
         IniFile ini = new IniFile(scpiDefFile);

         ReadModuleCommands(scpiDefFile);
         ReadSystemCommands(scpiDefFile);
      }
   }
}
