//                           UNCLASSIFIED
/*-------------------------------------------------------------------------
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.
-------------------------------------------------------------------------*/

using NLog;
using Raytheon.Common;
using System;

namespace Raytheon.Instruments
{
	/// <summary>
	/// </summary>
	public class JtagTeradyneEDigital6020A : IJtag
	{
		#region PrivateClassMembers
		private string _logicalName;

		public string DetailedStatus => throw new NotImplementedException();

		public bool DisplayEnabled { get => false; set => throw new NotImplementedException(); }
		public bool FrontPanelEnabled { get => false; set => throw new NotImplementedException(); }

		public InstrumentMetadata Info => throw new NotImplementedException();

		public string Name { get => _logicalName; set { _logicalName = value; } }

		public SelfTestResult SelfTestResult => PerformSelfTest();

		public State Status => throw new NotImplementedException();

		/// <summary>
		/// NLog logger
		/// </summary>
		private readonly ILogger _logger;
		/// <summary>
		/// Raytheon configuration
		/// </summary>
		private readonly IConfigurationManager _configurationManager;
		private readonly IConfiguration _configuration;

		#endregion

		#region PrivateClassFunctions
		/// <summary>
		/// The finalizer.
		/// </summary>
		~JtagTeradyneEDigital6020A()
		{
			Dispose(false);
		}

		/// <summary>
		/// Dispose of this object.
		/// </summary>
		/// <param name="disposing">True = currently disposing, False = not disposing.</param>
		protected virtual void Dispose(bool disposing)
		{
			try
			{
				if (disposing)
				{
				}
			}
			catch (Exception err)
			{
				try
				{
					ErrorLogger.Instance().Write(err.Message + "\r\n" + err.StackTrace);
				}
				catch (Exception)
				{
					//Do not rethrow. Exception from error logger that has already been garbage collected
				}
			}
		}
		#endregion

		#region PublicClassFunctions

		/// <summary>
		/// JtagTeradyneEDigital6020A factory constructor
		/// </summary>
		/// <param name="deviceName"></param>
		/// <param name="configurationManager"></param>
		public JtagTeradyneEDigital6020A(string deviceName, IConfigurationManager configurationManager, ILogger logger)
		{
			Name = deviceName;

			_logger = logger;

			_configurationManager = configurationManager;
			_configuration = _configurationManager.GetConfiguration(Name);
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="logicalName"></param>
		public JtagTeradyneEDigital6020A(string logicalName)
		{
			_logicalName = logicalName;
			_logger = LogManager.GetCurrentClassLogger();
		}

		/// <summary>
		/// Dispose of this object.
		/// </summary>
		public void Dispose()
		{
			try
			{
				Dispose(true);

				GC.SuppressFinalize(this);
			}
			catch (Exception err)
			{
				try
				{
					ErrorLogger.Instance().Write(err.Message + "\r\n" + err.StackTrace);
				}
				catch (Exception)
				{
					//Do not rethrow. Exception from error logger that has already been garbage collected.
				}
			}
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="jobInfo"></param>
		/// <returns></returns>
		public int PerformJtagJob(JtagJobInfo jobInfo)
		{
			throw new NotImplementedException();
		}

		/// <summary>
		/// 
		/// </summary>
		/// <returns></returns>
		public bool ClearErrors()
		{
			return false;
		}

		/// <summary>
		/// 
		/// </summary>
		public void Initialize()
		{
		}

		/// <summary>
		/// 
		/// </summary>
		/// <returns></returns>
		public SelfTestResult PerformSelfTest()
		{
			return SelfTestResult.Unknown;
		}

		/// <summary>
		/// 
		/// </summary>
		public void Reset()
		{
			Shutdown();

			Initialize();
		}

		/// <summary>
		/// 
		/// </summary>
		public void Shutdown()
		{
			Dispose();
		}

		#endregion
	}
}