Major upgrade

This commit is contained in:
Duc
2025-10-24 15:18:11 -07:00
parent fd85735c93
commit ce583d1664
478 changed files with 237518 additions and 47610 deletions

View File

@@ -22,177 +22,141 @@ using Raytheon.Common;
namespace Raytheon.Instruments
{
/// <summary>
/// Flow Meter Sim Class
/// </summary>
public class FlowMeterSim : IFlowMeter
{
#region PrivateMembers
private static object _sync = new object();
/// <summary>
/// Flow Meter Sim Class
/// </summary>
public class FlowMeterSim : IFlowMeter
{
#region PrivateMembers
private static object _sync = new object();
public string DetailedStatus => throw new NotImplementedException();
public string DetailedStatus => throw new NotImplementedException();
public bool DisplayEnabled { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public bool FrontPanelEnabled { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public bool DisplayEnabled { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public bool FrontPanelEnabled { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public InstrumentMetadata Info => throw new NotImplementedException();
public InstrumentMetadata Info => throw new NotImplementedException();
public string Name { get; set; }
public string Name { get; set; }
public SelfTestResult SelfTestResult => throw new NotImplementedException();
public SelfTestResult SelfTestResult => throw new NotImplementedException();
public State Status => throw new NotImplementedException();
public State Status => throw new NotImplementedException();
/// <summary>
/// Destructor
/// </summary>
~FlowMeterSim()
{
Dispose(false);
}
/// <summary>
/// Destructor
/// </summary>
~FlowMeterSim()
{
Dispose(false);
}
/// <summary>
/// NLog logger
/// </summary>
private readonly ILogger _logger;
/// <summary>
/// Raytheon configuration
/// </summary>
private readonly IConfigurationManager _configurationManager;
private readonly IConfiguration _configuration;
private readonly ILogger _logger;
#endregion
private readonly IConfigurationManager _configurationManager;
private readonly IConfiguration _configuration;
#region PrivateFunctions
#endregion
/// <summary>
/// Dispose of this object's resources
/// </summary>
/// <param name="disposing">Currently disposing</param>
protected virtual void Dispose(bool disposing)
{
try
{
if (disposing)
{
}
}
catch (Exception)
{
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 PrivateFunctions
#region PublicFunctions
/// <summary>
/// Dispose of this object's resources
/// </summary>
/// <param name="disposing">Currently disposing</param>
protected virtual void Dispose(bool disposing)
{
}
#endregion
/// <summary>
/// FlowMeterOmegaDPF20 factory constructor
/// </summary>
/// <param name="deviceName"></param>
/// <param name="configurationManager"></param>
public FlowMeterSim(string deviceName, IConfigurationManager configurationManager, ILogger logger)
{
Name = deviceName;
#region PublicFunctions
_logger = logger;
/// <summary>
/// FlowMeterOmegaDPF20 factory constructor
/// </summary>
/// <param name="deviceName"></param>
/// <param name="configurationManager"></param>
public FlowMeterSim(string deviceName, IConfigurationManager configurationManager)
{
Name = deviceName;
_configurationManager = configurationManager;
_configuration = _configurationManager.GetConfiguration(Name);
}
_logger = LogManager.GetLogger($"{this.GetType().Name} - {deviceName}");
/// <summary>
///
/// </summary>
/// <param name="name"></param>
public FlowMeterSim(string name)
{
Name = name;
_logger = LogManager.GetCurrentClassLogger();
}
_configurationManager = configurationManager;
_configuration = _configurationManager.GetConfiguration(Name);
}
// This code added to correctly implement the disposable pattern.
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1063:ImplementIDisposableCorrectly")]
public void Dispose()
{
try
{
lock (_sync)
{
Dispose(true);
/// <summary>
///
/// </summary>
/// <param name="name"></param>
public FlowMeterSim(string name)
{
Name = name;
_logger = LogManager.GetCurrentClassLogger();
}
GC.SuppressFinalize(this);
}
}
catch (Exception)
{
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
}
}
}
// This code added to correctly implement the disposable pattern.
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1063:ImplementIDisposableCorrectly")]
public void Dispose()
{
lock (_sync)
{
Dispose(true);
/// <summary>
/// Query the flow rate from the flow meter
/// </summary>
/// <returns>the flow rate.</returns>
public double ReadFlow()
{
lock (_sync)
{
double max = 0.15;
GC.SuppressFinalize(this);
}
}
double min = .35;
/// <summary>
/// Query the flow rate from the flow meter
/// </summary>
/// <returns>the flow rate.</returns>
public double ReadFlow()
{
lock (_sync)
{
double max = 0.15;
Random rnd = new Random();
double min = .35;
double seed = rnd.NextDouble();
Random rnd = new Random();
double dataToReturn = (seed * (max - min)) + min;
double seed = rnd.NextDouble();
Thread.Sleep(100);
double dataToReturn = (seed * (max - min)) + min;
return dataToReturn;
}
}
Thread.Sleep(100);
public bool ClearErrors()
{
throw new NotImplementedException();
}
return dataToReturn;
}
}
public void Initialize()
{
throw new NotImplementedException();
}
public bool ClearErrors()
{
throw new NotImplementedException();
}
public SelfTestResult PerformSelfTest()
{
throw new NotImplementedException();
}
public void Initialize()
{
throw new NotImplementedException();
}
public void Reset()
{
throw new NotImplementedException();
}
public SelfTestResult PerformSelfTest()
{
throw new NotImplementedException();
}
public void Shutdown()
{
throw new NotImplementedException();
}
public void Reset()
{
throw new NotImplementedException();
}
#endregion
}
public void Shutdown()
{
throw new NotImplementedException();
}
#endregion
}
}

View File

@@ -30,71 +30,64 @@
// DISTRIBUTION/DISSEMINATION CONTROL: F
// POC: Alex Kravchenko (1118268)
// **********************************************************************************************************
using NLog;
using Raytheon.Common;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.IO;
using System.Reflection;
using NLog;
using Raytheon.Common;
namespace Raytheon.Instruments
{
[ExportInstrumentFactory(ModelNumber = "FlowMeterSimFactory")]
public class FlowMeterSimFactory : IInstrumentFactory
{
/// <summary>
/// The supported interfaces
/// </summary>
private readonly List<Type> _supportedInterfaces = new List<Type>();
private ILogger _logger;
private readonly IConfigurationManager _configurationManager;
private const string DefaultConfigPath = @"C:\ProgramData\Raytheon\InstrumentManagerService";
private static string DefaultPath;
[ExportInstrumentFactory(ModelNumber = "FlowMeterSimFactory")]
public class FlowMeterSimFactory : IInstrumentFactory
{
private readonly List<Type> _supportedInterfaces = new List<Type>();
public FlowMeterSimFactory(string defaultConfigPath = DefaultConfigPath)
: this(null, defaultConfigPath)
{
}
private readonly IConfigurationManager _configurationManager;
private const string DefaultConfigPath = @"C:\ProgramData\Raytheon\InstrumentManagerService";
private static string DefaultPath;
/// <summary>
/// COECommDeviceInstrumentFactory injection constructor
/// </summary>
/// <param name="configManager"></param>
/// <param name="simEngine"></param>
/// <param name="logger"></param>
[ImportingConstructor]
public FlowMeterSimFactory([Import(AllowDefault = false)] IConfigurationManager configManager,
[Import(AllowDefault = true)] string defaultConfigPath = null)
{
DefaultPath = defaultConfigPath;
public FlowMeterSimFactory(string defaultConfigPath = DefaultConfigPath)
: this(null, defaultConfigPath)
{
}
if (LogManager.Configuration == null)
{
var assemblyFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
LogManager.Configuration = new NLog.Config.XmlLoggingConfiguration(assemblyFolder + "\\nlog.config");
}
/// <summary>
/// FlowMeterSimFactory injection constructor
/// </summary>
[ImportingConstructor]
public FlowMeterSimFactory([Import(AllowDefault = false)] IConfigurationManager configManager,
[Import(AllowDefault = true)] string defaultConfigPath = null)
{
DefaultPath = defaultConfigPath;
_configurationManager = configManager ?? GetConfigurationManager();
_supportedInterfaces.Add(typeof(IFlowMeter));
}
/// <summary>
/// Gets the instrument
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
public IInstrument GetInstrument(string name)
{
try
{
_logger = LogManager.GetLogger(name);
return new FlowMeterSim(name, _configurationManager, _logger);
}
catch (Exception)
{
throw;
}
}
if (LogManager.Configuration == null)
{
var assemblyFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
LogManager.Configuration = new NLog.Config.XmlLoggingConfiguration(assemblyFolder + "\\nlog.config");
}
_configurationManager = configManager ?? GetConfigurationManager();
_supportedInterfaces.Add(typeof(IFlowMeter));
}
/// <summary>
/// Gets the instrument
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
public IInstrument GetInstrument(string name)
{
try
{
return new FlowMeterSim(name, _configurationManager);
}
catch (Exception)
{
throw;
}
}
/// <summary>
/// Gets the instrument
@@ -105,9 +98,7 @@ namespace Raytheon.Instruments
{
try
{
_logger = LogManager.GetLogger(name);
return new FlowMeterSim(name, _configurationManager, _logger);
return new FlowMeterSim(name, _configurationManager);
}
catch (Exception)
{
@@ -120,17 +111,17 @@ namespace Raytheon.Instruments
/// </summary>
/// <returns></returns>
public ICollection<Type> GetSupportedInterfaces()
{
return _supportedInterfaces.ToArray();
}
{
return _supportedInterfaces.ToArray();
}
/// <summary>
/// returns configuration based on the predefined path or default path c:/ProgramData/Raytheon/InstrumentManagerService
/// </summary>
/// <returns></returns>
private static IConfigurationManager GetConfigurationManager()
{
return string.IsNullOrEmpty(DefaultPath) ? new RaytheonConfigurationManager() : new RaytheonConfigurationManager(DefaultPath);
}
}
/// <summary>
/// returns configuration based on the predefined path or default path c:/ProgramData/Raytheon/InstrumentManagerService
/// </summary>
/// <returns></returns>
private static IConfigurationManager GetConfigurationManager()
{
return string.IsNullOrEmpty(DefaultPath) ? new RaytheonConfigurationManager() : new RaytheonConfigurationManager(DefaultPath);
}
}
}