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

@@ -15,210 +15,175 @@ GOVERNMENT.
UNPUBLISHED WORK - COPYRIGHT RAYTHEON COMPANY.
-------------------------------------------------------------------------*/
using NLog;
using Raytheon.Common;
using System;
using System.Threading;
using NLog;
using Raytheon.Common;
namespace Raytheon.Instruments
{
/// <summary>
/// A simulated chiller
/// </summary>
public class ChillerSim : IChiller, IDisposable
{
#region PrivateMembers
private double _setPoint;
private static object _sync = new object();
/// <summary>
/// A simulated chiller
/// </summary>
public class ChillerSim : IChiller, IDisposable
{
#region PrivateMembers
private double _setPoint;
private static object _sync = new object();
public string DetailedStatus { get; protected set; }
public string DetailedStatus { get; protected set; }
public bool DisplayEnabled { get; set; }
public bool FrontPanelEnabled { get; set; }
public bool DisplayEnabled { get; set; }
public bool FrontPanelEnabled { get; set; }
public InstrumentMetadata Info { get; set; }
public InstrumentMetadata Info { get; set; }
public string Name { get; protected set; }
public string Name { get; protected set; }
public SelfTestResult SelfTestResult => PerformSelfTest();
public SelfTestResult SelfTestResult => PerformSelfTest();
public State Status { get; set; }
public State Status { get; set; }
/// <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
~ChillerSim()
{
Dispose(false);
}
/// <summary>
/// Dispose of the 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
#endregion
#region PublicFunctions
#region PrivateFunctions
~ChillerSim()
{
Dispose(false);
}
/// <summary>
/// Dispose of the object's resources.
/// </summary>
/// <param name="disposing">Currently disposing.</param>
protected virtual void Dispose(bool disposing)
{
/// <summary>
/// ChillerFTS factory constructor
/// </summary>
/// <param name="deviceName"></param>
/// <param name="configurationManager"></param>
public ChillerSim(string deviceName, IConfigurationManager configurationManager, ILogger logger)
{
Name = deviceName;
}
#endregion
_logger = logger;
#region PublicFunctions
_configurationManager = configurationManager;
_configuration = _configurationManager.GetConfiguration(Name);
}
/// <summary>
/// ChillerFTS factory constructor
/// </summary>
/// <param name="deviceName"></param>
/// <param name="configurationManager"></param>
public ChillerSim(string deviceName, IConfigurationManager configurationManager)
{
Name = deviceName;
/// <summary>
/// The constructor
/// </summary>
/// <param name="name"></param>
public ChillerSim(string name)
{
Name = name;
_setPoint = 20.0;
_logger = LogManager.GetCurrentClassLogger();
}
_logger = LogManager.GetLogger($"{this.GetType().Name} - {deviceName}");
_configurationManager = configurationManager;
_configuration = _configurationManager.GetConfiguration(Name);
}
/// <summary>
/// The constructor
/// </summary>
/// <param name="deviceName"></param>
public ChillerSim(string deviceName)
{
Name = deviceName;
_setPoint = 20.0;
_logger = LogManager.GetLogger($"{this.GetType().Name} - {deviceName}");
}
/// <summary>
/// Stop the chiller pump.
/// </summary>
public void DisableFlow()
{
}
/// <summary>
/// Stop the chiller pump.
/// </summary>
public void DisableFlow()
{
}
/// <summary>
/// Dispose of this objects resources
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1063:ImplementIDisposableCorrectly")]
public void Dispose()
{
try
{
Dispose(true);
/// <summary>
/// Dispose of this objects resources
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1063:ImplementIDisposableCorrectly")]
public void Dispose()
{
Dispose(true);
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
}
}
}
GC.SuppressFinalize(this);
}
/// <summary>
/// Start the chiller pump.
/// </summary>
public void EnableFlow()
{
}
/// <summary>
/// Start the chiller pump.
/// </summary>
public void EnableFlow()
{
}
/// <summary>
/// Query the current setting for the coolant.
/// </summary>
/// <returns>The current coolant setting.</returns>
public double GetCoolantSetpoint()
{
return _setPoint;
}
/// <summary>
/// Query the current setting for the coolant.
/// </summary>
/// <returns>The current coolant setting.</returns>
public double GetCoolantSetpoint()
{
return _setPoint;
}
/// <summary>
/// Query the temperature of the coolant reservoir.
/// </summary>
/// <returns>The temperature of the coolant.</returns>
public double GetCoolantTemperature()
{
double max = _setPoint + 5;
/// <summary>
/// Query the temperature of the coolant reservoir.
/// </summary>
/// <returns>The temperature of the coolant.</returns>
public double GetCoolantTemperature()
{
double max = _setPoint + 5;
double min = _setPoint - 5;
double min = _setPoint - 5;
Random rnd = new Random();
Random rnd = new Random();
double seed = rnd.NextDouble();
double seed = rnd.NextDouble();
double dataToReturn = (seed * (max - min)) + min;
double dataToReturn = (seed * (max - min)) + min;
Thread.Sleep(100);
Thread.Sleep(100);
return dataToReturn;
}
return dataToReturn;
}
/// <summary>
/// Set the coolant temperature to a desired setpoint.
/// </summary>
/// <param name="temp">The desired coolant temperature.</param>
public void SetCoolantTemperature(double temp)
{
_setPoint = temp;
}
/// <summary>
/// Set the coolant temperature to a desired setpoint.
/// </summary>
/// <param name="temp">The desired coolant temperature.</param>
public void SetCoolantTemperature(double temp)
{
_setPoint = temp;
}
public bool ClearErrors()
{
throw new NotImplementedException();
}
public bool ClearErrors()
{
throw new NotImplementedException();
}
public void Initialize()
{
throw new NotImplementedException();
}
public void Initialize()
{
throw new NotImplementedException();
}
public SelfTestResult PerformSelfTest()
{
throw new NotImplementedException();
}
public SelfTestResult PerformSelfTest()
{
throw new NotImplementedException();
}
public void Reset()
{
throw new NotImplementedException();
}
public void Reset()
{
throw new NotImplementedException();
}
public void Shutdown()
{
throw new NotImplementedException();
}
public void Shutdown()
{
throw new NotImplementedException();
}
#endregion
}
#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 = "ChillerSimFactory")]
public class ChillerSimFactory : 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 = "ChillerSimFactory")]
public class ChillerSimFactory : IInstrumentFactory
{
private readonly List<Type> _supportedInterfaces = new List<Type>();
public ChillerSimFactory(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 ChillerSimFactory([Import(AllowDefault = false)] IConfigurationManager configManager,
[Import(AllowDefault = true)] string defaultConfigPath = null)
{
DefaultPath = defaultConfigPath;
public ChillerSimFactory(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>
/// ChillerSimFactory injection constructor
/// </summary>
[ImportingConstructor]
public ChillerSimFactory([Import(AllowDefault = false)] IConfigurationManager configManager,
[Import(AllowDefault = true)] string defaultConfigPath = null)
{
DefaultPath = defaultConfigPath;
_configurationManager = configManager ?? GetConfigurationManager();
_supportedInterfaces.Add(typeof(IChiller));
}
/// <summary>
/// Gets the instrument
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
public IInstrument GetInstrument(string name)
{
try
{
_logger = LogManager.GetLogger(name);
return new ChillerSim(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(IChiller));
}
/// <summary>
/// Gets the instrument
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
public IInstrument GetInstrument(string name)
{
try
{
return new ChillerSim(name, _configurationManager);
}
catch (Exception)
{
throw;
}
}
/// <summary>
/// Gets the instrument
@@ -105,9 +98,7 @@ namespace Raytheon.Instruments
{
try
{
_logger = LogManager.GetLogger(name);
return new ChillerSim(name, _configurationManager, _logger);
return new ChillerSim(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);
}
}
}