// 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 System; using NLog; using Raytheon.Common; namespace Raytheon.Instruments { /// /// A sim communication device /// public class CommDeviceSim : ICommDevice { #region PrivateClassMembers private static object _syncObj = new Object(); private readonly string _name; private SelfTestResult _selfTestResult; private State _state; private readonly ILogger _logger; private readonly IConfigurationManager _configurationManager; private readonly IConfiguration _configuration; #endregion #region PrivateFunctions /// /// The Finalizer /// ~CommDeviceSim() { Dispose(false); } /// /// Dispose of the resources contained by this object /// /// protected virtual void Dispose(bool disposing) { } #endregion #region PublicFuctions /// /// CommDevice factory constructor /// /// /// public CommDeviceSim(string deviceName, IConfigurationManager configurationManager) { _name = deviceName; _selfTestResult = SelfTestResult.Unknown; _state = State.Uninitialized; _logger = LogManager.GetLogger($"{this.GetType().Name} - {deviceName}"); _configurationManager = configurationManager; _configuration = _configurationManager.GetConfiguration(Name); } /// /// /// /// public CommDeviceSim(string deviceName) { _name = deviceName; _selfTestResult = SelfTestResult.Unknown; _state = State.Uninitialized; _logger = LogManager.GetLogger($"{this.GetType().Name} - {deviceName}"); } /// /// /// /// public bool ClearErrors() { throw new NotImplementedException(); } /// /// /// public bool DisplayEnabled { get { throw new NotImplementedException(); } set { throw new NotImplementedException(); } } /// /// /// public string DetailedStatus { get { return "This is a Comm Device Sim called " + _name; } } /// /// Dispose of the resources /// public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } /// /// /// public bool FrontPanelEnabled { get { throw new NotImplementedException(); } set { throw new NotImplementedException(); } } /// /// /// public InstrumentMetadata Info { get { throw new NotImplementedException(); } } /// /// /// public void Initialize() { lock (_syncObj) { if (_state == State.Uninitialized) { _state = State.Ready; } else { throw new Exception("expected the state to be Uninitialized, state was: " + _state.ToString() + " on device " + _name); } } } /// /// /// public string Name { get { return _name; } } /// /// /// /*public void Open() { lock (_syncObj) { } }*/ /// /// /// /// public SelfTestResult PerformSelfTest() { lock (_syncObj) { _selfTestResult = SelfTestResult.Pass; return _selfTestResult; } } /// /// Read data from the device. /// /// The buffer to put the data in /// The number of bytes read public uint Read(ref byte[] dataRead) { lock (_syncObj) { return (uint)dataRead.Length; } } /// /// /// public void Reset() { lock (_syncObj) { } } /// /// Sets the read timeout /// /// public void SetReadTimeout(uint timeout) { lock (_syncObj) { } } /// /// /// public SelfTestResult SelfTestResult { get { return _selfTestResult; } } /// /// /// public State Status { get { return _state; } } /// /// /// public void Shutdown() { lock (_syncObj) { _state = State.Uninitialized; } } /// /// Write data to the device /// /// The data to write /// The number of bytes to write /// THe number of bytes that were written public uint Write(byte[] dataToSend, uint numBytesToWrite) { lock (_syncObj) { return numBytesToWrite; } } public void Close() { throw new NotImplementedException(); } public void Open() { throw new NotImplementedException(); } #endregion } }