// ******************************************************************************************
// **                                                                                       **
// **      RAYTHEON PROPRIETARY: THIS DOCUMENT CONTAINS DATA OR INFORMATION                 **
// **      PROPRIETARY TO RAYTHEON COMPANY AND IS RESTRICTED TO USE ONLY BY PERSONS         **
// **      AUTHORIZED BY RAYTHEON COMPANY IN WRITING TO USE IT.DISCLOSURE TO                **
// **      UNAUTHORIZED PERSONS WOULD LIKELY CAUSE SUBSTANTIAL COMPETITIVE HARM TO          **
// **      RAYTHEON COMPANY'S BUSINESS POSITION. NEITHER SAID DOCUMENT NOR ITS              **
// **      CONTENTS SHALL BE FURNISHED OR DISCLOSED TO OR COPIED OR USED BY PERSONS         **
// **      OUTSIDE RAYTHEON COMPANY WITHOUT THE EXPRESS WRITTEN APPROVAL OF RAYTHEON        **
// **      COMPANY.                                                                         **
// **                                                                                       **
// **      THIS PROPRIETARY NOTICE IS NOT APPLICABLE IF DELIVERED TO THE U.S.               **
// **      GOVERNMENT.                                                                      **
// **                                                                                       **
// **      UNPUBLISHED WORK - COPYRIGHT RAYTHEON COMPANY.                                   **
// **                                                                                       **
// **      WARNING: THIS DOCUMENT CONTAINS TECHNICAL DATA AND / OR TECHNOLOGY WHOSE         **
// **      EXPORT OR DISCLOSURE TO NON-U.S.PERSONS, WHEREVER LOCATED, IS RESTRICTED         **
// **      BY THE INTERNATIONAL TRAFFIC IN ARMS REGULATIONS (ITAR) (22 C.F.R.SECTION        **
// **      120-130) OR THE EXPORT ADMINISTRATION REGULATIONS(EAR) (15 C.F.R.SECTION         **
// **      730-774). THIS DOCUMENT CANNOT BE EXPORTED(E.G., PROVIDED TO A SUPPLIER          **
// **      OUTSIDE OF THE UNITED STATES) OR DISCLOSED TO A NON-U.S.PERSON, WHEREVER         **
// **      LOCATED, UNTIL A FINAL JURISDICTION AND CLASSIFICATION DETERMINATION HAS         **
// **      BEEN COMPLETED AND APPROVED BY RAYTHEON, AND ANY REQUIRED U.S.GOVERNMENT         **
// **      APPROVALS HAVE BEEN OBTAINED. VIOLATIONS ARE SUBJECT TO SEVERE CRIMINAL          **
// **      PENALTIES.                                                                       **
// **                                                                                       **
// **      CAPITAL EQUIPMENT/SOFTWARE: THIS TECHNICAL DATA WAS DEVELOPED OR ACQUIRED        **
// **      EXCLUSIVELY AT CONTRACTOR EXPENSE AND IS INTENDED FOR USE ON MULTIPLE            **
// **      PROJECTS/PROGRAMS.                                                               **
// **                                                                                       **
// *******************************************************************************************

using Raytheon.Communication;
using Raytheon.Instruments.PowerSupply;
using System.Collections.Generic;

namespace Raytheon.Instruments
{
   /// <summary>
   /// An interface for power systems to implement.
   /// </summary>
   [UmsContract]
   public interface IPowerSupplySystem : IInstrument
   {
      /// <summary>
      /// Get the power system error register
      /// </summary>
      /// <param name="errorCode">The register value</param>
      /// <returns></returns>
      [UmsCommand( "IPowerSupplySystem.GetErrorCode" )]
      string GetErrorCode( out int errorCode );

      /// <summary>
      /// Get a list of modules that belong to this power system
      /// </summary>
      /// <returns>A list of modules belonging to this system</returns>
      [UmsCommand( "IPowerSupplySystem.GetModuleNames" )]
      List<string> GetModuleNames( );

      /// <summary>
      /// Get the dictionary that contains configuration information for each module
      /// </summary>
      /// <returns></returns>
      Dictionary<string, PowerSupplyModuleInfo> GetPowerSupplyModuleInfoDict(string powerSystem);

      /// <summary>
      /// Retrieve the programmed OCP value of a module
      /// </summary>
      /// <param name="moduleName">The module to query</param>
      /// <returns>The programmed setting</returns>
      [UmsCommand( "IPowerSupplySystem.GetOverCurrentSetting" )]
      double GetOverCurrentSetting( string moduleName );

      /// <summary>
      /// Retrieve the programmed OVP value of a module
      /// </summary>
      /// <param name="moduleName">The module to query</param>
      /// <returns>The programmed setting</returns>
      [UmsCommand( "IPowerSupplySystem.GetOverVoltageSetting" )]
      double GetOverVoltageSetting( string moduleName );

      /// <summary>
      /// Retrieve the programmed slew value of a module
      /// </summary>
      /// <param name="moduleName">The module to query</param>
      /// <returns>The programmed setting</returns>
      [UmsCommand( "IPowerSupplySystem.GetSlewRate" )]
      double GetSlewRate( string name );

      /// <summary>
      /// returns back system name
      /// </summary>
      /// <returns></returns>
      [UmsCommand( "IPowerSupplySystem.GetSystemName" )]
      string GetSystemName( );

      /// <summary>
      /// Retrieve the programmed voltage setpoint value of a module
      /// </summary>
      /// <param name="moduleName">The module to query</param>
      /// <returns>The programmed setting</returns>
      [UmsCommand( "IPowerSupplySystem.GetVoltageSetting" )]
      double GetVoltageSetting( string moduleName );

      /// <summary>
      /// Query a supple to see if output is enabled
      /// </summary>
      /// <param name="moduleName">The module to query</param>
      /// <returns>true if output is on, false if it is off</returns>
      [UmsCommand( "IPowerSupplySystem.IsOutputOn" )]
      bool IsOutputOn( string moduleName );

      /// <summary>
      /// Measure the current of a module
      /// </summary>
      /// <param name="moduleName">The module to query</param>
      /// <returns>The measured current</returns>
      [UmsCommand( "IPowerSupplySystem.MeasureCurrent" )]
      double MeasureCurrent( string moduleName );

      /// <summary>
      /// Measure the voltage of a module
      /// </summary>
      /// <param name="moduleName">The module to query</param>
      /// <returns>The measured current</returns>
      [UmsCommand( "IPowerSupplySystem.MeasureVoltage" )]
      double MeasureVoltage( string moduleName );

      /// <summary>
      /// Turn off a module output
      /// </summary>
      /// <param name="moduleName">The module to turn off</param>
      [UmsCommand( "IPowerSupplySystem.Off" )]
      void Off( string moduleName );

      /// <summary>
      /// Turn on a module output
      /// </summary>
      /// <param name="moduleName">The module to turn on</param>
      [UmsCommand( "IPowerSupplySystem.On" )]
      void On( string moduleName );

      /// <summary>
      /// Read the protection status register
      /// </summary>
      /// <param name="moduleName">The module to read</param>
      /// <returns>The register value</returns>
      [UmsCommand( "IPowerSupplySystem.ReadProtectionStatus" )]
      int ReadProtectionStatus( string moduleName );

      /// <summary>
      /// Read the power data for a module
      /// </summary>
      /// <param name="moduleName">The module to read</param>
      /// <returns>THe Power Data</returns>
      [UmsCommand( "IPowerSupplySystem.ReadPowerData" )]
      void ReadPowerData( string moduleName, out double voltage, out double voltageSetpoint, out double current, out bool isOutputOn, out int faultStatus );

      /// <summary>
      /// Set the slew rate
      /// </summary>
      /// <param name="moduleName">The module to set</param>
      /// <param name="commandedSlew">The slew rate</param>
      [UmsCommand( "IPowerSupplySystem.SetSlewRate" )]
      void SetSlewRate( string moduleName, double commandedSlew );

      /// <summary>
      /// Resets the setpoint voltage to that which was passed into the constructor
      /// </summary>
      /// <param name="moduleName">The module to reset</param>
      [UmsCommand( "IPowerSupplySystem.SetInitialVoltage" )]
      void SetInitialVoltage( string moduleName );

      /// <summary>
      /// Set the voltage setpoint. Use this if you want to change the setpoint to a value that is different than what the module was initialized with
      /// </summary>
      /// <param name="moduleName">The module to set</param>
      /// <param name="ocpValue">The value to set it to</param>
      [UmsCommand( "IPowerSupplySystem.SetVoltageSetpoint" )]
      void SetVoltageSetpoint( string moduleName, double volts );

      /// <summary>
      /// Disable the system watchdog
      /// </summary>
      [UmsCommand( "IPowerSupplySystem.WatchdogDisable" )]
      void WatchdogDisable( );

      /// <summary>
      /// Enable the system watchdog
      /// </summary>
      /// <param name="timeInSeconds">The time in seconds which the app must communicate with the power system before the system get inhibited</param>
      [UmsCommand( "IPowerSupplySystem.WatchdogEnable" )]
      void WatchdogEnable( uint time );

      /// <summary>
      /// Set the OCP. Use this if you want to change OCP to a value that is different than what the module was initialized with
      /// </summary>
      /// <param name="moduleName">The module to set</param>
      /// <param name="ocpValue">The value to set it to</param>
      [UmsCommand( "IPowerSupplySystem.SetOverCurrentProtection" )]
      void SetOverCurrentProtection( string moduleName, double ocpValue );

      /// <summary>
      /// Set the OVP. Use this if you want to change OVP to a value that is different than what the module was initialized with
      /// </summary>
      /// <param name="moduleName">The module to set</param>
      /// <param name="ocpValue">The value to set it to</param>
      [UmsCommand( "IPowerSupplySystem.SetOverVoltageProtection" )]
      void SetOverVoltageProtection( string moduleName, double ovpValue );

      /// <summary>
      /// Send a command and return the response
      /// </summary>
      /// <param name="commandString"></param>
      /// <returns></returns>
      [UmsCommand( "IPowerSupplySystem.IOQuery" )]
      string IOQuery( string command );

      /// <summary>
      /// Send a command
      /// </summary>
      /// <param name="commandString"></param>
      [UmsCommand( "IPowerSupplySystem.IOWrite" )]
      void IOWrite( string command );

      /// <summary>
      /// Read the power data for a module
      /// </summary>
      /// <param name="moduleName">The module to read</param>
      /// <returns>THe Power Data</returns>
      [UmsCommand( "IPowerSupplySystem.ReadPowerData" )]
      PowerData ReadPowerData( string moduleName );

      /// <summary>
      /// Control the power supply internal mechanical relay state
      /// </summary>
      /// <param name="moduleName">The module to act on</param>
      /// <param name="shallWeConnect">True to connect, false to disconnect</param>
      [UmsCommand( "IPowerSupplySystem.MechanicalRelayOutputControl" )]
      void MechanicalRelayOutputControl( string moduleName, bool shallWeConnect );
   }
}
