Major upgrade
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -31,71 +31,64 @@
|
||||
// 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 = "DMMKeysightM9183Factory")]
|
||||
public class DMMKeysightM9183Factory : 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 = "DMMKeysightM9183Factory")]
|
||||
public class DMMKeysightM9183Factory : IInstrumentFactory
|
||||
{
|
||||
private readonly List<Type> _supportedInterfaces = new List<Type>();
|
||||
|
||||
public DMMKeysightM9183Factory(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 DMMKeysightM9183Factory([Import(AllowDefault = false)] IConfigurationManager configManager,
|
||||
[Import(AllowDefault = true)] string defaultConfigPath = null)
|
||||
{
|
||||
DefaultPath = defaultConfigPath;
|
||||
public DMMKeysightM9183Factory(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>
|
||||
/// DMMKeysightM9183Factory injection constructor
|
||||
/// </summary>
|
||||
[ImportingConstructor]
|
||||
public DMMKeysightM9183Factory([Import(AllowDefault = false)] IConfigurationManager configManager,
|
||||
[Import(AllowDefault = true)] string defaultConfigPath = null)
|
||||
{
|
||||
DefaultPath = defaultConfigPath;
|
||||
|
||||
_configurationManager = configManager ?? GetConfigurationManager();
|
||||
_supportedInterfaces.Add(typeof(IDmm));
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets the instrument
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
public IInstrument GetInstrument(string name)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger = LogManager.GetLogger(name);
|
||||
return new DMMKeysightM9183(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(IDmm));
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets the instrument
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
public IInstrument GetInstrument(string name)
|
||||
{
|
||||
try
|
||||
{
|
||||
return new DMMKeysightM9183(name, _configurationManager);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the instrument
|
||||
@@ -106,12 +99,10 @@ namespace Raytheon.Instruments
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger = LogManager.GetLogger(name);
|
||||
|
||||
if (simulateHw)
|
||||
return new DMMSim(name, _configurationManager, _logger);
|
||||
return new DMMSim(name, _configurationManager);
|
||||
else
|
||||
return new DMMKeysightM9183(name, _configurationManager, _logger);
|
||||
return new DMMKeysightM9183(name, _configurationManager);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
@@ -124,17 +115,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -31,71 +31,64 @@
|
||||
// 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 = "DMMKeysightScpiFactory")]
|
||||
public class DMMKeysightScpiFactory : 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 = "DMMKeysightScpiFactory")]
|
||||
public class DMMKeysightScpiFactory : IInstrumentFactory
|
||||
{
|
||||
private readonly List<Type> _supportedInterfaces = new List<Type>();
|
||||
|
||||
public DMMKeysightScpiFactory(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 DMMKeysightScpiFactory([Import(AllowDefault = false)] IConfigurationManager configManager,
|
||||
[Import(AllowDefault = true)] string defaultConfigPath = null)
|
||||
{
|
||||
DefaultPath = defaultConfigPath;
|
||||
public DMMKeysightScpiFactory(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>
|
||||
/// DMMKeysightScpiFactory injection constructor
|
||||
/// </summary>
|
||||
[ImportingConstructor]
|
||||
public DMMKeysightScpiFactory([Import(AllowDefault = false)] IConfigurationManager configManager,
|
||||
[Import(AllowDefault = true)] string defaultConfigPath = null)
|
||||
{
|
||||
DefaultPath = defaultConfigPath;
|
||||
|
||||
_configurationManager = configManager ?? GetConfigurationManager();
|
||||
_supportedInterfaces.Add(typeof(IDmm));
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets the instrument
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
public IInstrument GetInstrument(string name)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger = LogManager.GetLogger(name);
|
||||
return new DMMKeysightScpi(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(IDmm));
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets the instrument
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
public IInstrument GetInstrument(string name)
|
||||
{
|
||||
try
|
||||
{
|
||||
return new DMMKeysightScpi(name, _configurationManager);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the instrument
|
||||
@@ -106,12 +99,10 @@ namespace Raytheon.Instruments
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger = LogManager.GetLogger(name);
|
||||
|
||||
if (simulateHw)
|
||||
return new DMMSim(name, _configurationManager, _logger);
|
||||
return new DMMSim(name, _configurationManager);
|
||||
else
|
||||
return new DMMKeysightScpi(name, _configurationManager, _logger);
|
||||
return new DMMKeysightScpi(name, _configurationManager);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
@@ -124,17 +115,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,537 +24,504 @@ using Raytheon.Units;
|
||||
|
||||
namespace Raytheon.Instruments
|
||||
{
|
||||
/// <summary>
|
||||
/// A simulation implementation of the DMM interface.
|
||||
/// This class basically just absorbs function calls and returns dummy data.
|
||||
/// </summary>
|
||||
public class DMMNiPxi : IDmm, IDisposable
|
||||
{
|
||||
#region PrivateMemberVariables
|
||||
/// <summary>
|
||||
/// A simulation implementation of the DMM interface.
|
||||
/// This class basically just absorbs function calls and returns dummy data.
|
||||
/// </summary>
|
||||
public class DMMNiPxi : IDmm, IDisposable
|
||||
{
|
||||
#region PrivateMemberVariables
|
||||
|
||||
private NIDmm _niDmm;
|
||||
private string _name;
|
||||
private readonly string _address;
|
||||
//private readonly string _options;
|
||||
private double _lastRange;
|
||||
private double _lastResolution;
|
||||
private MeasurementFunction _lastType;
|
||||
private State _state;
|
||||
private SelfTestResult _selfTestResult;
|
||||
private NIDmm _niDmm;
|
||||
private string _name;
|
||||
private readonly string _address;
|
||||
//private readonly string _options;
|
||||
private double _lastRange;
|
||||
private double _lastResolution;
|
||||
private MeasurementFunction _lastType;
|
||||
private State _state;
|
||||
private SelfTestResult _selfTestResult;
|
||||
|
||||
/// <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>
|
||||
/// The Finalizer.
|
||||
/// </summary>
|
||||
~DMMNiPxi()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
#region PrivateFunctions
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="disposing"></param>
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (_state == State.Ready)
|
||||
{
|
||||
_niDmm.DriverUtility.Reset();
|
||||
/// <summary>
|
||||
/// The Finalizer.
|
||||
/// </summary>
|
||||
~DMMNiPxi()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
_niDmm.Close();
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="disposing"></param>
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (_state == State.Ready)
|
||||
{
|
||||
_niDmm.DriverUtility.Reset();
|
||||
|
||||
_niDmm.Dispose();
|
||||
_niDmm.Close();
|
||||
|
||||
_state = State.Uninitialized;
|
||||
}
|
||||
}
|
||||
}
|
||||
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
|
||||
_niDmm.Dispose();
|
||||
|
||||
#region PublicFunctions
|
||||
_state = State.Uninitialized;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// DMMNiPxi factory constructor
|
||||
/// </summary>
|
||||
/// <param name="deviceName"></param>
|
||||
/// <param name="configurationManager"></param>
|
||||
public DMMNiPxi(string deviceName, IConfigurationManager configurationManager, ILogger logger)
|
||||
{
|
||||
Name = deviceName;
|
||||
#region PublicFunctions
|
||||
|
||||
_logger = logger;
|
||||
/// <summary>
|
||||
/// DMMNiPxi factory constructor
|
||||
/// </summary>
|
||||
/// <param name="deviceName"></param>
|
||||
/// <param name="configurationManager"></param>
|
||||
public DMMNiPxi(string deviceName, IConfigurationManager configurationManager)
|
||||
{
|
||||
Name = deviceName;
|
||||
|
||||
_configurationManager = configurationManager;
|
||||
_configuration = _configurationManager.GetConfiguration(Name);
|
||||
_logger = LogManager.GetLogger($"{this.GetType().Name} - {deviceName}");
|
||||
|
||||
_address = _configuration.GetConfigurationValue("DMMNiPxi", "Address", "");
|
||||
//_options = _configuration.GetConfigurationValue("DMMNiPxi", "Options", "");
|
||||
_configurationManager = configurationManager;
|
||||
_configuration = _configurationManager.GetConfiguration(Name);
|
||||
|
||||
_lastType = 0;
|
||||
_lastRange = 0;
|
||||
_lastResolution = 0;
|
||||
_address = _configuration.GetConfigurationValue("DMMNiPxi", "Address", "");
|
||||
//_options = _configuration.GetConfigurationValue("DMMNiPxi", "Options", "");
|
||||
|
||||
//created in Initialize()
|
||||
_niDmm = null;
|
||||
_lastType = 0;
|
||||
_lastRange = 0;
|
||||
_lastResolution = 0;
|
||||
|
||||
_state = State.Uninitialized;
|
||||
_selfTestResult = SelfTestResult.Unknown;
|
||||
}
|
||||
//created in Initialize()
|
||||
_niDmm = null;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="address"></param>
|
||||
/// <param name="options"></param>
|
||||
public DMMNiPxi(string name, string address)//, string options)
|
||||
{
|
||||
_name = name;
|
||||
_address = address;
|
||||
//_options = options;
|
||||
_lastType = 0;
|
||||
_lastRange = 0;
|
||||
_lastResolution = 0;
|
||||
_state = State.Uninitialized;
|
||||
_selfTestResult = SelfTestResult.Unknown;
|
||||
}
|
||||
|
||||
// set in Initialize()
|
||||
_niDmm = null;
|
||||
_logger = LogManager.GetCurrentClassLogger();
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="deviceName"></param>
|
||||
/// <param name="address"></param>
|
||||
/// <param name="options"></param>
|
||||
public DMMNiPxi(string deviceName, string address)//, string options)
|
||||
{
|
||||
_name = deviceName;
|
||||
_address = address;
|
||||
//_options = options;
|
||||
_lastType = 0;
|
||||
_lastRange = 0;
|
||||
_lastResolution = 0;
|
||||
|
||||
_state = State.Uninitialized;
|
||||
_selfTestResult = SelfTestResult.Unknown;
|
||||
}
|
||||
// set in Initialize()
|
||||
_niDmm = null;
|
||||
_logger = LogManager.GetLogger($"{this.GetType().Name} - {deviceName}");
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool ClearErrors()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
_state = State.Uninitialized;
|
||||
_selfTestResult = SelfTestResult.Unknown;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="range"></param>
|
||||
/// <param name="resolution"></param>
|
||||
public void ConfigureCurrentMeasurement(MeasurementFunction type, Current range, Current resolution)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
/*_lastType = type;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool ClearErrors()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="range"></param>
|
||||
/// <param name="resolution"></param>
|
||||
public void ConfigureCurrentMeasurement(MeasurementFunction type, Current range, Current resolution)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
/*_lastType = type;
|
||||
_lastRange = range.Amps;
|
||||
_lastResolution = resolution.Amps;*/
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="range"></param>
|
||||
/// <param name="resolution"></param>
|
||||
public void ConfigureFrequencyMeasurement(MeasurementFunction type, Frequency range, Frequency resolution)
|
||||
{
|
||||
if (type != MeasurementFunction.Frequency)
|
||||
{
|
||||
throw new Exception("only frequency is acceptable for param type: " + _lastType.ToString());
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="range"></param>
|
||||
/// <param name="resolution"></param>
|
||||
public void ConfigureFrequencyMeasurement(MeasurementFunction type, Frequency range, Frequency resolution)
|
||||
{
|
||||
if (type != MeasurementFunction.Frequency)
|
||||
{
|
||||
throw new Exception("only frequency is acceptable for param type: " + _lastType.ToString());
|
||||
}
|
||||
|
||||
_lastType = type;
|
||||
_lastRange = range.Hertz;
|
||||
_lastResolution = resolution.Hertz;
|
||||
}
|
||||
_lastType = type;
|
||||
_lastRange = range.Hertz;
|
||||
_lastResolution = resolution.Hertz;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="range"></param>
|
||||
/// <param name="resolution"></param>
|
||||
public void ConfigureResistanceMeasurement(MeasurementFunction type, Resistance range, Resistance resolution)
|
||||
{
|
||||
if (type != MeasurementFunction.FourWireResistance && type != MeasurementFunction.TwoWireResistance)
|
||||
{
|
||||
throw new Exception("only FourWireResistance or TwoWireResistance is acceptable for param type: " + _lastType.ToString());
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="range"></param>
|
||||
/// <param name="resolution"></param>
|
||||
public void ConfigureResistanceMeasurement(MeasurementFunction type, Resistance range, Resistance resolution)
|
||||
{
|
||||
if (type != MeasurementFunction.FourWireResistance && type != MeasurementFunction.TwoWireResistance)
|
||||
{
|
||||
throw new Exception("only FourWireResistance or TwoWireResistance is acceptable for param type: " + _lastType.ToString());
|
||||
}
|
||||
|
||||
_lastType = type;
|
||||
_lastRange = range.Ohms;
|
||||
_lastResolution = resolution.Ohms;
|
||||
}
|
||||
_lastType = type;
|
||||
_lastRange = range.Ohms;
|
||||
_lastResolution = resolution.Ohms;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="range"></param>
|
||||
/// <param name="resolution"></param>
|
||||
public void ConfigureVoltageMeasurement(MeasurementFunction type, Voltage range, Voltage resolution)
|
||||
{
|
||||
if (type != MeasurementFunction.DCVolts && type != MeasurementFunction.ACVolts)
|
||||
{
|
||||
throw new Exception("only ac or dc volt is acceptable for param type: " + type.ToString());
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="range"></param>
|
||||
/// <param name="resolution"></param>
|
||||
public void ConfigureVoltageMeasurement(MeasurementFunction type, Voltage range, Voltage resolution)
|
||||
{
|
||||
if (type != MeasurementFunction.DCVolts && type != MeasurementFunction.ACVolts)
|
||||
{
|
||||
throw new Exception("only ac or dc volt is acceptable for param type: " + type.ToString());
|
||||
}
|
||||
|
||||
_lastType = type;
|
||||
_lastRange = range.Volts;
|
||||
_lastResolution = resolution.Volts;
|
||||
}
|
||||
_lastType = type;
|
||||
_lastRange = range.Volts;
|
||||
_lastResolution = resolution.Volts;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string DetailedStatus
|
||||
{
|
||||
get
|
||||
{
|
||||
return "This is a NI Dmm";
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string DetailedStatus
|
||||
{
|
||||
get
|
||||
{
|
||||
return "This is a NI Dmm";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public bool DisplayEnabled
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public bool DisplayEnabled
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
try
|
||||
{
|
||||
Dispose(true);
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
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>
|
||||
///
|
||||
/// </summary>
|
||||
public bool FrontPanelEnabled
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public bool FrontPanelEnabled
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public InstrumentMetadata Info
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public InstrumentMetadata Info
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public void Initialize()
|
||||
{
|
||||
if (_state == State.Uninitialized)
|
||||
{
|
||||
_niDmm = new NIDmm(_address, false, true);// _options);
|
||||
_selfTestResult = PerformSelfTest();
|
||||
_state = State.Ready;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("expected the state to be Uninitialized, state was: " + _state.ToString());
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public void Initialize()
|
||||
{
|
||||
if (_state == State.Uninitialized)
|
||||
{
|
||||
_niDmm = new NIDmm(_address, false, true);// _options);
|
||||
_selfTestResult = PerformSelfTest();
|
||||
_state = State.Ready;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("expected the state to be Uninitialized, state was: " + _state.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public MeasurementFunction MeasurementType
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public MeasurementFunction MeasurementType
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="timeout"></param>
|
||||
/// <returns></returns>
|
||||
public Current MeasureCurrent(int timeout)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="timeout"></param>
|
||||
/// <returns></returns>
|
||||
public Current MeasureCurrent(int timeout)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
||||
/*
|
||||
/*
|
||||
if (_lastType != MeasurementFunction.DCVolts && _lastType != MeasurementFunction.ACVolts)
|
||||
{
|
||||
throw new Exception("only ac or dc volt is acceptable for param type: " + type.ToString());
|
||||
}
|
||||
|
||||
return Current.FromAmps(ReadCurrent();*/
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="timeout"></param>
|
||||
/// <returns></returns>
|
||||
public Frequency MeasureFrequency(int timeout)
|
||||
{
|
||||
if (_lastType != MeasurementFunction.Frequency)
|
||||
{
|
||||
throw new Exception("only frequency is acceptable for param type: " + _lastType.ToString());
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="timeout"></param>
|
||||
/// <returns></returns>
|
||||
public Frequency MeasureFrequency(int timeout)
|
||||
{
|
||||
if (_lastType != MeasurementFunction.Frequency)
|
||||
{
|
||||
throw new Exception("only frequency is acceptable for param type: " + _lastType.ToString());
|
||||
}
|
||||
|
||||
DmmAuto auto = DmmAuto.Off;
|
||||
DmmAuto auto = DmmAuto.Off;
|
||||
|
||||
if (_lastRange < 0)
|
||||
{
|
||||
auto = DmmAuto.On;
|
||||
// set the starting range for auto range to 10
|
||||
_lastRange = 10;
|
||||
}
|
||||
if (_lastRange < 0)
|
||||
{
|
||||
auto = DmmAuto.On;
|
||||
// set the starting range for auto range to 10
|
||||
_lastRange = 10;
|
||||
}
|
||||
|
||||
_niDmm.MeasurementFunction = DmmMeasurementFunction.Frequency;
|
||||
_niDmm.MeasurementFunction = DmmMeasurementFunction.Frequency;
|
||||
|
||||
_niDmm.Range = _lastRange;
|
||||
_niDmm.Range = _lastRange;
|
||||
|
||||
_niDmm.Resolution = _lastResolution;
|
||||
_niDmm.Resolution = _lastResolution;
|
||||
|
||||
_niDmm.AutoRange = auto;
|
||||
_niDmm.AutoRange = auto;
|
||||
|
||||
double frequency = _niDmm.Measurement.Read();
|
||||
double frequency = _niDmm.Measurement.Read();
|
||||
|
||||
return Frequency.FromHertz(frequency);
|
||||
}
|
||||
return Frequency.FromHertz(frequency);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="timeout"></param>
|
||||
/// <returns></returns>
|
||||
public Resistance MeasureResistance(int timeout)
|
||||
{
|
||||
if (_lastType != MeasurementFunction.FourWireResistance && _lastType != MeasurementFunction.TwoWireResistance)
|
||||
{
|
||||
throw new Exception("only FourWireResistance or TwoWireResistance is acceptable for param type: " + _lastType.ToString());
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="timeout"></param>
|
||||
/// <returns></returns>
|
||||
public Resistance MeasureResistance(int timeout)
|
||||
{
|
||||
if (_lastType != MeasurementFunction.FourWireResistance && _lastType != MeasurementFunction.TwoWireResistance)
|
||||
{
|
||||
throw new Exception("only FourWireResistance or TwoWireResistance is acceptable for param type: " + _lastType.ToString());
|
||||
}
|
||||
|
||||
if (_lastType == MeasurementFunction.FourWireResistance)
|
||||
{
|
||||
_niDmm.MeasurementFunction = DmmMeasurementFunction.FourWireResistance;
|
||||
}
|
||||
else
|
||||
{
|
||||
_niDmm.MeasurementFunction = DmmMeasurementFunction.TwoWireResistance;
|
||||
}
|
||||
if (_lastType == MeasurementFunction.FourWireResistance)
|
||||
{
|
||||
_niDmm.MeasurementFunction = DmmMeasurementFunction.FourWireResistance;
|
||||
}
|
||||
else
|
||||
{
|
||||
_niDmm.MeasurementFunction = DmmMeasurementFunction.TwoWireResistance;
|
||||
}
|
||||
|
||||
DmmAuto auto = DmmAuto.Off;
|
||||
DmmAuto auto = DmmAuto.Off;
|
||||
|
||||
if (_lastRange < 0)
|
||||
{
|
||||
auto = DmmAuto.On;
|
||||
// set the starting range for auto range to 10
|
||||
_lastRange = 10;
|
||||
}
|
||||
if (_lastRange < 0)
|
||||
{
|
||||
auto = DmmAuto.On;
|
||||
// set the starting range for auto range to 10
|
||||
_lastRange = 10;
|
||||
}
|
||||
|
||||
_niDmm.Range = _lastRange;
|
||||
_niDmm.Range = _lastRange;
|
||||
|
||||
_niDmm.Resolution = _lastResolution;
|
||||
_niDmm.Resolution = _lastResolution;
|
||||
|
||||
_niDmm.AutoRange = auto;
|
||||
_niDmm.AutoRange = auto;
|
||||
|
||||
double resistance = _niDmm.Measurement.Read();
|
||||
double resistance = _niDmm.Measurement.Read();
|
||||
|
||||
if (double.IsNaN(resistance))
|
||||
{
|
||||
resistance = double.MaxValue;
|
||||
}
|
||||
if (double.IsNaN(resistance))
|
||||
{
|
||||
resistance = double.MaxValue;
|
||||
}
|
||||
|
||||
return Resistance.FromOhms(resistance);
|
||||
}
|
||||
return Resistance.FromOhms(resistance);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="timeout"></param>
|
||||
/// <returns></returns>
|
||||
public Voltage MeasureVoltage(int timeout)
|
||||
{
|
||||
if (_lastType != MeasurementFunction.DCVolts && _lastType != MeasurementFunction.ACVolts)
|
||||
{
|
||||
throw new Exception("only ac or dc volt is acceptable for param type: " + _lastType.ToString());
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="timeout"></param>
|
||||
/// <returns></returns>
|
||||
public Voltage MeasureVoltage(int timeout)
|
||||
{
|
||||
if (_lastType != MeasurementFunction.DCVolts && _lastType != MeasurementFunction.ACVolts)
|
||||
{
|
||||
throw new Exception("only ac or dc volt is acceptable for param type: " + _lastType.ToString());
|
||||
}
|
||||
|
||||
if (_lastType == MeasurementFunction.ACVolts)
|
||||
{
|
||||
_niDmm.MeasurementFunction = DmmMeasurementFunction.ACVolts;
|
||||
}
|
||||
else
|
||||
{
|
||||
_niDmm.MeasurementFunction = DmmMeasurementFunction.DCVolts;
|
||||
}
|
||||
if (_lastType == MeasurementFunction.ACVolts)
|
||||
{
|
||||
_niDmm.MeasurementFunction = DmmMeasurementFunction.ACVolts;
|
||||
}
|
||||
else
|
||||
{
|
||||
_niDmm.MeasurementFunction = DmmMeasurementFunction.DCVolts;
|
||||
}
|
||||
|
||||
DmmAuto auto = DmmAuto.Off;
|
||||
DmmAuto auto = DmmAuto.Off;
|
||||
|
||||
if (_lastRange < 0)
|
||||
{
|
||||
auto = DmmAuto.On;
|
||||
// set the starting range for auto range to 10
|
||||
_lastRange = 10;
|
||||
}
|
||||
if (_lastRange < 0)
|
||||
{
|
||||
auto = DmmAuto.On;
|
||||
// set the starting range for auto range to 10
|
||||
_lastRange = 10;
|
||||
}
|
||||
|
||||
_niDmm.Range = _lastRange;
|
||||
_niDmm.Range = _lastRange;
|
||||
|
||||
_niDmm.Resolution = _lastResolution;
|
||||
_niDmm.Resolution = _lastResolution;
|
||||
|
||||
_niDmm.AutoRange = auto;
|
||||
_niDmm.AutoRange = auto;
|
||||
|
||||
double volts = _niDmm.Measurement.Read();
|
||||
double volts = _niDmm.Measurement.Read();
|
||||
|
||||
if (double.IsNaN(volts))
|
||||
{
|
||||
volts = double.MaxValue;
|
||||
}
|
||||
if (double.IsNaN(volts))
|
||||
{
|
||||
volts = double.MaxValue;
|
||||
}
|
||||
|
||||
return Voltage.FromVolts(volts);
|
||||
}
|
||||
return Voltage.FromVolts(volts);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get { return _name; }
|
||||
set { _name = value; }
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get { return _name; }
|
||||
set { _name = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public SelfTestResult PerformSelfTest()
|
||||
{
|
||||
DmmSelfTestResult res = _niDmm.DriverUtility.SelfTest();
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public SelfTestResult PerformSelfTest()
|
||||
{
|
||||
DmmSelfTestResult res = _niDmm.DriverUtility.SelfTest();
|
||||
|
||||
if (res.Code != 0)
|
||||
{
|
||||
_selfTestResult = Raytheon.Instruments.SelfTestResult.Fail;
|
||||
throw new Exception("self test returned: " + res.Code + "," + res.Message + " on card " + _name);
|
||||
}
|
||||
if (res.Code != 0)
|
||||
{
|
||||
_selfTestResult = Raytheon.Instruments.SelfTestResult.Fail;
|
||||
throw new Exception("self test returned: " + res.Code + "," + res.Message + " on card " + _name);
|
||||
}
|
||||
|
||||
_selfTestResult = Raytheon.Instruments.SelfTestResult.Pass;
|
||||
_selfTestResult = Raytheon.Instruments.SelfTestResult.Pass;
|
||||
|
||||
return _selfTestResult;
|
||||
}
|
||||
return _selfTestResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public void Reset()
|
||||
{
|
||||
_niDmm.DriverUtility.Reset();
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public void Reset()
|
||||
{
|
||||
_niDmm.DriverUtility.Reset();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public SelfTestResult SelfTestResult
|
||||
{
|
||||
get
|
||||
{
|
||||
return _selfTestResult;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public SelfTestResult SelfTestResult
|
||||
{
|
||||
get
|
||||
{
|
||||
return _selfTestResult;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public State Status
|
||||
{
|
||||
get
|
||||
{
|
||||
return _state;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public State Status
|
||||
{
|
||||
get
|
||||
{
|
||||
return _state;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public void Shutdown()
|
||||
{
|
||||
if (_state == State.Ready)
|
||||
{
|
||||
_niDmm.DriverUtility.Reset();
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public void Shutdown()
|
||||
{
|
||||
if (_state == State.Ready)
|
||||
{
|
||||
_niDmm.DriverUtility.Reset();
|
||||
|
||||
_niDmm.Close();
|
||||
_niDmm.Close();
|
||||
|
||||
_niDmm.Dispose();
|
||||
_niDmm.Dispose();
|
||||
|
||||
_state = State.Uninitialized;
|
||||
}
|
||||
}
|
||||
_state = State.Uninitialized;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,71 +31,64 @@
|
||||
// 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 = "DMMNiPxiFactory")]
|
||||
public class DMMNiPxiFactory : 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 = "DMMNiPxiFactory")]
|
||||
public class DMMNiPxiFactory : IInstrumentFactory
|
||||
{
|
||||
private readonly List<Type> _supportedInterfaces = new List<Type>();
|
||||
|
||||
public DMMNiPxiFactory(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 DMMNiPxiFactory([Import(AllowDefault = false)] IConfigurationManager configManager,
|
||||
[Import(AllowDefault = true)] string defaultConfigPath = null)
|
||||
{
|
||||
DefaultPath = defaultConfigPath;
|
||||
public DMMNiPxiFactory(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>
|
||||
/// DMMNiPxiFactory injection constructor
|
||||
/// </summary>
|
||||
[ImportingConstructor]
|
||||
public DMMNiPxiFactory([Import(AllowDefault = false)] IConfigurationManager configManager,
|
||||
[Import(AllowDefault = true)] string defaultConfigPath = null)
|
||||
{
|
||||
DefaultPath = defaultConfigPath;
|
||||
|
||||
_configurationManager = configManager ?? GetConfigurationManager();
|
||||
_supportedInterfaces.Add(typeof(IDmm));
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets the instrument
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
public IInstrument GetInstrument(string name)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger = LogManager.GetLogger(name);
|
||||
return new DMMNiPxi(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(IDmm));
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets the instrument
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
public IInstrument GetInstrument(string name)
|
||||
{
|
||||
try
|
||||
{
|
||||
return new DMMNiPxi(name, _configurationManager);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the instrument
|
||||
@@ -106,12 +99,10 @@ namespace Raytheon.Instruments
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger = LogManager.GetLogger(name);
|
||||
|
||||
if (simulateHw)
|
||||
return new DMMSim(name, _configurationManager, _logger);
|
||||
return new DMMSim(name, _configurationManager);
|
||||
else
|
||||
return new DMMNiPxi(name, _configurationManager, _logger);
|
||||
return new DMMNiPxi(name, _configurationManager);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
@@ -124,17 +115,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,412 +24,375 @@ using Raytheon.Units;
|
||||
|
||||
namespace Raytheon.Instruments
|
||||
{
|
||||
/// <summary>
|
||||
/// A simulation implementation of the DMM interface.
|
||||
/// This class basically just absorbs function calls and returns dummy data.
|
||||
/// </summary>
|
||||
public class DMMSim : IDmm
|
||||
{
|
||||
#region PrivateMemberVariables
|
||||
|
||||
private string _name;
|
||||
private double _lastRange;
|
||||
private State _state;
|
||||
private SelfTestResult _selfTestResult;
|
||||
|
||||
/// <summary>
|
||||
/// NLog logger
|
||||
/// </summary>
|
||||
private readonly ILogger _logger;
|
||||
/// <summary>
|
||||
/// Raytheon configuration
|
||||
/// </summary>
|
||||
private readonly IConfigurationManager _configurationManager;
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
#endregion
|
||||
|
||||
#region PrivateFunctions
|
||||
|
||||
/// <summary>
|
||||
/// The Finalizer.
|
||||
/// </summary>
|
||||
~DMMSim()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="disposing"></param>
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
// nothing to clean up
|
||||
}
|
||||
}
|
||||
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 PublicFunctions
|
||||
|
||||
/// <summary>
|
||||
/// DMMSim factory constructor
|
||||
/// </summary>
|
||||
/// <param name="deviceName"></param>
|
||||
/// <param name="configurationManager"></param>
|
||||
public DMMSim(string deviceName, IConfigurationManager configurationManager, ILogger logger)
|
||||
{
|
||||
Name = deviceName;
|
||||
|
||||
_logger = logger;
|
||||
|
||||
_configurationManager = configurationManager;
|
||||
_configuration = _configurationManager.GetConfiguration(Name);
|
||||
|
||||
_lastRange = 0;
|
||||
|
||||
_state = State.Uninitialized;
|
||||
|
||||
_selfTestResult = SelfTestResult.Unknown;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
public DMMSim(string name)
|
||||
{
|
||||
_name = name;
|
||||
|
||||
_lastRange = 0;
|
||||
|
||||
_logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
_state = State.Uninitialized;
|
||||
|
||||
_selfTestResult = SelfTestResult.Unknown;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool ClearErrors()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="range"></param>
|
||||
/// <param name="resolution"></param>
|
||||
public void ConfigureCurrentMeasurement(MeasurementFunction type, Current range, Current resolution)
|
||||
{
|
||||
_lastRange = range.Amps;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="range"></param>
|
||||
/// <param name="resolution"></param>
|
||||
public void ConfigureFrequencyMeasurement(MeasurementFunction type, Frequency range, Frequency resolution)
|
||||
{
|
||||
_lastRange = range.Hertz;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="range"></param>
|
||||
/// <param name="resolution"></param>
|
||||
public void ConfigureResistanceMeasurement(MeasurementFunction type, Resistance range, Resistance resolution)
|
||||
{
|
||||
_lastRange = range.Ohms;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="range"></param>
|
||||
/// <param name="resolution"></param>
|
||||
public void ConfigureVoltageMeasurement(MeasurementFunction type, Voltage range, Voltage resolution)
|
||||
{
|
||||
_lastRange = range.Volts;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string DetailedStatus
|
||||
{
|
||||
get
|
||||
{
|
||||
return "This is a Sim Dmm";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public bool DisplayEnabled
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
try
|
||||
{
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public bool FrontPanelEnabled
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public InstrumentMetadata Info
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public void Initialize()
|
||||
{
|
||||
if (_state == State.Uninitialized)
|
||||
{
|
||||
_selfTestResult = PerformSelfTest();
|
||||
_state = State.Ready;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("expected the state to be Uninitialized, state was: " + _state.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="timeout"></param>
|
||||
/// <returns></returns>
|
||||
public Current MeasureCurrent(int timeout)
|
||||
{
|
||||
double max = _lastRange;
|
||||
|
||||
double min = 1.0;
|
||||
|
||||
Random rnd = new Random();
|
||||
|
||||
double seed = rnd.NextDouble();
|
||||
|
||||
double dataToReturn = (seed * (max - min)) + min;
|
||||
|
||||
Thread.Sleep(200);
|
||||
|
||||
return Current.FromAmps(dataToReturn);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="timeout"></param>
|
||||
/// <returns></returns>
|
||||
public Frequency MeasureFrequency(int timeout)
|
||||
{
|
||||
double max = _lastRange;
|
||||
|
||||
double min = 1.0;
|
||||
|
||||
Random rnd = new Random();
|
||||
|
||||
double seed = rnd.NextDouble();
|
||||
|
||||
double dataToReturn = (seed * (max - min)) + min;
|
||||
|
||||
Thread.Sleep(200);
|
||||
|
||||
return Frequency.FromHertz(dataToReturn);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="timeout"></param>
|
||||
/// <returns></returns>
|
||||
public Resistance MeasureResistance(int timeout)
|
||||
{
|
||||
double max = _lastRange;
|
||||
|
||||
double min = 1.0;
|
||||
|
||||
Random rnd = new Random();
|
||||
|
||||
double seed = rnd.NextDouble();
|
||||
|
||||
double dataToReturn = (seed * (max - min)) + min;
|
||||
|
||||
Thread.Sleep(200);
|
||||
|
||||
return Resistance.FromOhms(dataToReturn);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="timeout"></param>
|
||||
/// <returns></returns>
|
||||
public Voltage MeasureVoltage(int timeout)
|
||||
{
|
||||
double max = _lastRange;
|
||||
|
||||
double min = 1.0;
|
||||
|
||||
Random rnd = new Random();
|
||||
|
||||
double seed = rnd.NextDouble();
|
||||
|
||||
double dataToReturn = (seed * (max - min)) + min;
|
||||
|
||||
Thread.Sleep(200);
|
||||
|
||||
return Voltage.FromVolts(dataToReturn);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public MeasurementFunction MeasurementType
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get { return _name; }
|
||||
set { _name = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public SelfTestResult PerformSelfTest()
|
||||
{
|
||||
_selfTestResult = SelfTestResult.Pass;
|
||||
return _selfTestResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public void Reset()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public SelfTestResult SelfTestResult
|
||||
{
|
||||
get
|
||||
{
|
||||
return _selfTestResult;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public State Status
|
||||
{
|
||||
get
|
||||
{
|
||||
return _state;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public void Shutdown()
|
||||
{
|
||||
_state = State.Uninitialized;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
/// <summary>
|
||||
/// A simulation implementation of the DMM interface.
|
||||
/// This class basically just absorbs function calls and returns dummy data.
|
||||
/// </summary>
|
||||
public class DMMSim : IDmm
|
||||
{
|
||||
#region PrivateMemberVariables
|
||||
|
||||
private string _name;
|
||||
private double _lastRange;
|
||||
private State _state;
|
||||
private SelfTestResult _selfTestResult;
|
||||
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly IConfigurationManager _configurationManager;
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
#endregion
|
||||
|
||||
#region PrivateFunctions
|
||||
|
||||
/// <summary>
|
||||
/// The Finalizer.
|
||||
/// </summary>
|
||||
~DMMSim()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="disposing"></param>
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region PublicFunctions
|
||||
|
||||
/// <summary>
|
||||
/// DMMSim factory constructor
|
||||
/// </summary>
|
||||
/// <param name="deviceName"></param>
|
||||
/// <param name="configurationManager"></param>
|
||||
public DMMSim(string deviceName, IConfigurationManager configurationManager)
|
||||
{
|
||||
Name = deviceName;
|
||||
|
||||
_logger = LogManager.GetLogger($"{this.GetType().Name} - {deviceName}");
|
||||
|
||||
_configurationManager = configurationManager;
|
||||
_configuration = _configurationManager.GetConfiguration(Name);
|
||||
|
||||
_lastRange = 0;
|
||||
|
||||
_state = State.Uninitialized;
|
||||
|
||||
_selfTestResult = SelfTestResult.Unknown;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="deviceName"></param>
|
||||
public DMMSim(string deviceName)
|
||||
{
|
||||
_name = deviceName;
|
||||
|
||||
_lastRange = 0;
|
||||
|
||||
_logger = LogManager.GetLogger($"{this.GetType().Name} - {deviceName}");
|
||||
|
||||
_state = State.Uninitialized;
|
||||
|
||||
_selfTestResult = SelfTestResult.Unknown;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool ClearErrors()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="range"></param>
|
||||
/// <param name="resolution"></param>
|
||||
public void ConfigureCurrentMeasurement(MeasurementFunction type, Current range, Current resolution)
|
||||
{
|
||||
_lastRange = range.Amps;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="range"></param>
|
||||
/// <param name="resolution"></param>
|
||||
public void ConfigureFrequencyMeasurement(MeasurementFunction type, Frequency range, Frequency resolution)
|
||||
{
|
||||
_lastRange = range.Hertz;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="range"></param>
|
||||
/// <param name="resolution"></param>
|
||||
public void ConfigureResistanceMeasurement(MeasurementFunction type, Resistance range, Resistance resolution)
|
||||
{
|
||||
_lastRange = range.Ohms;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="range"></param>
|
||||
/// <param name="resolution"></param>
|
||||
public void ConfigureVoltageMeasurement(MeasurementFunction type, Voltage range, Voltage resolution)
|
||||
{
|
||||
_lastRange = range.Volts;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string DetailedStatus
|
||||
{
|
||||
get
|
||||
{
|
||||
return "This is a Sim Dmm";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public bool DisplayEnabled
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public bool FrontPanelEnabled
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public InstrumentMetadata Info
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public void Initialize()
|
||||
{
|
||||
if (_state == State.Uninitialized)
|
||||
{
|
||||
_selfTestResult = PerformSelfTest();
|
||||
_state = State.Ready;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("expected the state to be Uninitialized, state was: " + _state.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="timeout"></param>
|
||||
/// <returns></returns>
|
||||
public Current MeasureCurrent(int timeout)
|
||||
{
|
||||
double max = _lastRange;
|
||||
|
||||
double min = 1.0;
|
||||
|
||||
Random rnd = new Random();
|
||||
|
||||
double seed = rnd.NextDouble();
|
||||
|
||||
double dataToReturn = (seed * (max - min)) + min;
|
||||
|
||||
Thread.Sleep(200);
|
||||
|
||||
return Current.FromAmps(dataToReturn);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="timeout"></param>
|
||||
/// <returns></returns>
|
||||
public Frequency MeasureFrequency(int timeout)
|
||||
{
|
||||
double max = _lastRange;
|
||||
|
||||
double min = 1.0;
|
||||
|
||||
Random rnd = new Random();
|
||||
|
||||
double seed = rnd.NextDouble();
|
||||
|
||||
double dataToReturn = (seed * (max - min)) + min;
|
||||
|
||||
Thread.Sleep(200);
|
||||
|
||||
return Frequency.FromHertz(dataToReturn);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="timeout"></param>
|
||||
/// <returns></returns>
|
||||
public Resistance MeasureResistance(int timeout)
|
||||
{
|
||||
double max = _lastRange;
|
||||
|
||||
double min = 1.0;
|
||||
|
||||
Random rnd = new Random();
|
||||
|
||||
double seed = rnd.NextDouble();
|
||||
|
||||
double dataToReturn = (seed * (max - min)) + min;
|
||||
|
||||
Thread.Sleep(200);
|
||||
|
||||
return Resistance.FromOhms(dataToReturn);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="timeout"></param>
|
||||
/// <returns></returns>
|
||||
public Voltage MeasureVoltage(int timeout)
|
||||
{
|
||||
double max = _lastRange;
|
||||
|
||||
double min = 1.0;
|
||||
|
||||
Random rnd = new Random();
|
||||
|
||||
double seed = rnd.NextDouble();
|
||||
|
||||
double dataToReturn = (seed * (max - min)) + min;
|
||||
|
||||
Thread.Sleep(200);
|
||||
|
||||
return Voltage.FromVolts(dataToReturn);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public MeasurementFunction MeasurementType
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get { return _name; }
|
||||
set { _name = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public SelfTestResult PerformSelfTest()
|
||||
{
|
||||
_selfTestResult = SelfTestResult.Pass;
|
||||
return _selfTestResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public void Reset()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public SelfTestResult SelfTestResult
|
||||
{
|
||||
get
|
||||
{
|
||||
return _selfTestResult;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public State Status
|
||||
{
|
||||
get
|
||||
{
|
||||
return _state;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public void Shutdown()
|
||||
{
|
||||
_state = State.Uninitialized;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,71 +31,64 @@
|
||||
// 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 = "DMMSimFactory")]
|
||||
public class DMMSimFactory : 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 = "DMMSimFactory")]
|
||||
public class DMMSimFactory : IInstrumentFactory
|
||||
{
|
||||
private readonly List<Type> _supportedInterfaces = new List<Type>();
|
||||
|
||||
public DMMSimFactory(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 DMMSimFactory([Import(AllowDefault = false)] IConfigurationManager configManager,
|
||||
[Import(AllowDefault = true)] string defaultConfigPath = null)
|
||||
{
|
||||
DefaultPath = defaultConfigPath;
|
||||
public DMMSimFactory(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>
|
||||
/// DMMSimFactory injection constructor
|
||||
/// </summary>
|
||||
[ImportingConstructor]
|
||||
public DMMSimFactory([Import(AllowDefault = false)] IConfigurationManager configManager,
|
||||
[Import(AllowDefault = true)] string defaultConfigPath = null)
|
||||
{
|
||||
DefaultPath = defaultConfigPath;
|
||||
|
||||
_configurationManager = configManager ?? GetConfigurationManager();
|
||||
_supportedInterfaces.Add(typeof(IDmm));
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets the instrument
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
public IInstrument GetInstrument(string name)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger = LogManager.GetLogger(name);
|
||||
return new DMMSim(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(IDmm));
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets the instrument
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
public IInstrument GetInstrument(string name)
|
||||
{
|
||||
try
|
||||
{
|
||||
return new DMMSim(name, _configurationManager);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the instrument
|
||||
@@ -106,9 +99,7 @@ namespace Raytheon.Instruments
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger = LogManager.GetLogger(name);
|
||||
|
||||
return new DMMSim(name, _configurationManager, _logger);
|
||||
return new DMMSim(name, _configurationManager);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
@@ -121,17 +112,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -17,6 +17,7 @@
|
||||
<PackageReference Include="NLog" Version="5.0.0" />
|
||||
<PackageReference Include="Raytheon.Common" Version="1.0.0" />
|
||||
<PackageReference Include="Raytheon.Instruments.Dmm.Contracts" Version="2.6.0" />
|
||||
<PackageReference Include="Raytheon.Instruments.GeneralIO.Contracts" Version="1.7.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -31,71 +31,64 @@
|
||||
// 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 = "DMMSquibMeter101SQBRAKFactory")]
|
||||
public class DMMSquibMeter101SQBRAKFactory : 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 = "DMMSquibMeter101SQBRAKFactory")]
|
||||
public class DMMSquibMeter101SQBRAKFactory : IInstrumentFactory
|
||||
{
|
||||
private readonly List<Type> _supportedInterfaces = new List<Type>();
|
||||
|
||||
public DMMSquibMeter101SQBRAKFactory(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 DMMSquibMeter101SQBRAKFactory([Import(AllowDefault = false)] IConfigurationManager configManager,
|
||||
[Import(AllowDefault = true)] string defaultConfigPath = null)
|
||||
{
|
||||
DefaultPath = defaultConfigPath;
|
||||
public DMMSquibMeter101SQBRAKFactory(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>
|
||||
/// DMMSquibMeter101SQBRAKFactory injection constructor
|
||||
/// </summary>
|
||||
[ImportingConstructor]
|
||||
public DMMSquibMeter101SQBRAKFactory([Import(AllowDefault = false)] IConfigurationManager configManager,
|
||||
[Import(AllowDefault = true)] string defaultConfigPath = null)
|
||||
{
|
||||
DefaultPath = defaultConfigPath;
|
||||
|
||||
_configurationManager = configManager ?? GetConfigurationManager();
|
||||
_supportedInterfaces.Add(typeof(IDmm));
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets the instrument
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
public IInstrument GetInstrument(string name)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger = LogManager.GetLogger(name);
|
||||
return new DMMSquibMeter101SQBRAK(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(IDmm));
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets the instrument
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
public IInstrument GetInstrument(string name)
|
||||
{
|
||||
try
|
||||
{
|
||||
return new DMMSquibMeter101SQBRAK(name, _configurationManager);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the instrument
|
||||
@@ -106,12 +99,10 @@ namespace Raytheon.Instruments
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger = LogManager.GetLogger(name);
|
||||
|
||||
if (simulateHw)
|
||||
return new DMMSim(name, _configurationManager, _logger);
|
||||
return new DMMSim(name, _configurationManager);
|
||||
else
|
||||
return new DMMSquibMeter101SQBRAK(name, _configurationManager, _logger);
|
||||
return new DMMSquibMeter101SQBRAK(name, _configurationManager);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
@@ -124,17 +115,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -16,518 +16,485 @@ UNPUBLISHED WORK - COPYRIGHT RAYTHEON COMPANY.
|
||||
-------------------------------------------------------------------------*/
|
||||
|
||||
using System;
|
||||
using VTI.VTEXDmm.Interop;
|
||||
using Raytheon.Instruments.Dmm;
|
||||
using Raytheon.Units;
|
||||
using NLog;
|
||||
using Raytheon.Common;
|
||||
using Raytheon.Instruments.Dmm;
|
||||
using Raytheon.Units;
|
||||
using VTI.VTEXDmm.Interop;
|
||||
|
||||
namespace Raytheon.Instruments
|
||||
{
|
||||
/// <summary>
|
||||
/// A VTI Dmm
|
||||
/// </summary>
|
||||
public class DMMVTI : IDmm
|
||||
{
|
||||
#region PrivateMemberVariables
|
||||
private readonly string _address;
|
||||
private VTEXDmm _dmm;
|
||||
private State _state;
|
||||
private SelfTestResult _selfTestResult;
|
||||
private readonly string _options;
|
||||
private const int _READ_TIMEOUT = 1000;
|
||||
private string _name;
|
||||
private MeasurementFunction _lastType;
|
||||
private double _lastRange;
|
||||
private double _lastResolution;
|
||||
/// <summary>
|
||||
/// A VTI Dmm
|
||||
/// </summary>
|
||||
public class DMMVTI : IDmm
|
||||
{
|
||||
#region PrivateMemberVariables
|
||||
private readonly string _address;
|
||||
private VTEXDmm _dmm;
|
||||
private State _state;
|
||||
private SelfTestResult _selfTestResult;
|
||||
private readonly string _options;
|
||||
private const int _READ_TIMEOUT = 1000;
|
||||
private string _name;
|
||||
private MeasurementFunction _lastType;
|
||||
private double _lastRange;
|
||||
private double _lastResolution;
|
||||
|
||||
/// <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
|
||||
/// <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)
|
||||
{
|
||||
if (_state == State.Ready)
|
||||
{
|
||||
_dmm.Utility.Reset();
|
||||
#endregion
|
||||
|
||||
_dmm.Close();
|
||||
#region PrivateFunctions
|
||||
/// <summary>
|
||||
/// Dispose of this object
|
||||
/// </summary>
|
||||
/// <param name="disposing">True = currently disposing, False = not disposing.</param>
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (_state == State.Ready)
|
||||
{
|
||||
_dmm.Utility.Reset();
|
||||
|
||||
_state = State.Uninitialized;
|
||||
}
|
||||
}
|
||||
}
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
_dmm.Close();
|
||||
|
||||
#endregion
|
||||
_state = State.Uninitialized;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region PublicFunctions
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// DMMVTI factory constructor
|
||||
/// </summary>
|
||||
/// <param name="deviceName"></param>
|
||||
/// <param name="configurationManager"></param>
|
||||
public DMMVTI(string deviceName, IConfigurationManager configurationManager, ILogger logger)
|
||||
{
|
||||
Name = deviceName;
|
||||
#region PublicFunctions
|
||||
|
||||
_logger = logger;
|
||||
/// <summary>
|
||||
/// DMMVTI factory constructor
|
||||
/// </summary>
|
||||
/// <param name="deviceName"></param>
|
||||
/// <param name="configurationManager"></param>
|
||||
public DMMVTI(string deviceName, IConfigurationManager configurationManager)
|
||||
{
|
||||
Name = deviceName;
|
||||
|
||||
_configurationManager = configurationManager;
|
||||
_configuration = _configurationManager.GetConfiguration(Name);
|
||||
_logger = LogManager.GetLogger($"{this.GetType().Name} - {deviceName}");
|
||||
|
||||
_address = _configuration.GetConfigurationValue("DMMVTI", "Address", "");
|
||||
_options = _configuration.GetConfigurationValue("DMMVTI", "Options", "");
|
||||
_configurationManager = configurationManager;
|
||||
_configuration = _configurationManager.GetConfiguration(Name);
|
||||
|
||||
_lastType = 0;
|
||||
_lastRange = 0;
|
||||
_lastResolution = 0;
|
||||
_address = _configuration.GetConfigurationValue("DMMVTI", "Address", "");
|
||||
_options = _configuration.GetConfigurationValue("DMMVTI", "Options", "");
|
||||
|
||||
//created in Initialize()
|
||||
_dmm = null;
|
||||
_lastType = 0;
|
||||
_lastRange = 0;
|
||||
_lastResolution = 0;
|
||||
|
||||
_state = State.Uninitialized;
|
||||
_selfTestResult = SelfTestResult.Unknown;
|
||||
}
|
||||
//created in Initialize()
|
||||
_dmm = null;
|
||||
|
||||
/// <summary>
|
||||
/// The constructor which opens the handle to the DMM instrument.
|
||||
/// </summary>
|
||||
/// <param name="address">The address of the DMM.</param>
|
||||
/// <param name="options">The options used for setting up the instrument.</param>
|
||||
public DMMVTI(string name, string address, string options)
|
||||
{
|
||||
_name = name;
|
||||
_address = address;
|
||||
_options = options;
|
||||
_lastType = 0;
|
||||
_lastRange = 0;
|
||||
_lastResolution = 0;
|
||||
_logger = LogManager.GetCurrentClassLogger();
|
||||
_state = State.Uninitialized;
|
||||
_selfTestResult = SelfTestResult.Unknown;
|
||||
}
|
||||
|
||||
// create in Initialize()
|
||||
_dmm = null;
|
||||
/// <summary>
|
||||
/// The constructor which opens the handle to the DMM instrument.
|
||||
/// </summary>
|
||||
/// <param name="address">The address of the DMM.</param>
|
||||
/// <param name="options">The options used for setting up the instrument.</param>
|
||||
public DMMVTI(string deviceName, string address, string options)
|
||||
{
|
||||
_name = deviceName;
|
||||
_address = address;
|
||||
_options = options;
|
||||
_lastType = 0;
|
||||
_lastRange = 0;
|
||||
_lastResolution = 0;
|
||||
_logger = LogManager.GetLogger($"{this.GetType().Name} - {deviceName}");
|
||||
|
||||
_state = State.Uninitialized;
|
||||
_selfTestResult = SelfTestResult.Unknown;
|
||||
}
|
||||
// create in Initialize()
|
||||
_dmm = null;
|
||||
|
||||
/// <summary>
|
||||
/// The Finalizer.
|
||||
/// </summary>
|
||||
~DMMVTI()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
_state = State.Uninitialized;
|
||||
_selfTestResult = SelfTestResult.Unknown;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool ClearErrors()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
/// <summary>
|
||||
/// The Finalizer.
|
||||
/// </summary>
|
||||
~DMMVTI()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="range"></param>
|
||||
/// <param name="resolution"></param>
|
||||
public void ConfigureCurrentMeasurement(MeasurementFunction type, Current range, Current resolution)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
/*_lastType = type;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool ClearErrors()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="range"></param>
|
||||
/// <param name="resolution"></param>
|
||||
public void ConfigureCurrentMeasurement(MeasurementFunction type, Current range, Current resolution)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
/*_lastType = type;
|
||||
_lastRange = range.Amps;
|
||||
_lastResolution = resolution.Amps;*/
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="range"></param>
|
||||
/// <param name="resolution"></param>
|
||||
public void ConfigureVoltageMeasurement(MeasurementFunction type, Voltage range, Voltage resolution)
|
||||
{
|
||||
if (type != MeasurementFunction.DCVolts && type != MeasurementFunction.ACVolts)
|
||||
{
|
||||
throw new Exception("only ac or dc volt is acceptable for param type: " + type.ToString());
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="range"></param>
|
||||
/// <param name="resolution"></param>
|
||||
public void ConfigureVoltageMeasurement(MeasurementFunction type, Voltage range, Voltage resolution)
|
||||
{
|
||||
if (type != MeasurementFunction.DCVolts && type != MeasurementFunction.ACVolts)
|
||||
{
|
||||
throw new Exception("only ac or dc volt is acceptable for param type: " + type.ToString());
|
||||
}
|
||||
|
||||
_lastType = type;
|
||||
_lastRange = range.Volts;
|
||||
_lastResolution = resolution.Volts;
|
||||
}
|
||||
_lastType = type;
|
||||
_lastRange = range.Volts;
|
||||
_lastResolution = resolution.Volts;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="range"></param>
|
||||
/// <param name="resolution"></param>
|
||||
public void ConfigureResistanceMeasurement(MeasurementFunction type, Resistance range, Resistance resolution)
|
||||
{
|
||||
if (type != MeasurementFunction.FourWireResistance && type != MeasurementFunction.TwoWireResistance)
|
||||
{
|
||||
throw new Exception("only FourWireResistance or TwoWireResistance is acceptable for param type: " + _lastType.ToString());
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="range"></param>
|
||||
/// <param name="resolution"></param>
|
||||
public void ConfigureResistanceMeasurement(MeasurementFunction type, Resistance range, Resistance resolution)
|
||||
{
|
||||
if (type != MeasurementFunction.FourWireResistance && type != MeasurementFunction.TwoWireResistance)
|
||||
{
|
||||
throw new Exception("only FourWireResistance or TwoWireResistance is acceptable for param type: " + _lastType.ToString());
|
||||
}
|
||||
|
||||
_lastType = type;
|
||||
_lastRange = range.Ohms;
|
||||
_lastResolution = resolution.Ohms;
|
||||
}
|
||||
_lastType = type;
|
||||
_lastRange = range.Ohms;
|
||||
_lastResolution = resolution.Ohms;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="range"></param>
|
||||
/// <param name="resolution"></param>
|
||||
public void ConfigureFrequencyMeasurement(MeasurementFunction type, Frequency range, Frequency resolution)
|
||||
{
|
||||
if (type != MeasurementFunction.Frequency)
|
||||
{
|
||||
throw new Exception("only frequency is acceptable for param type: " + _lastType.ToString());
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="range"></param>
|
||||
/// <param name="resolution"></param>
|
||||
public void ConfigureFrequencyMeasurement(MeasurementFunction type, Frequency range, Frequency resolution)
|
||||
{
|
||||
if (type != MeasurementFunction.Frequency)
|
||||
{
|
||||
throw new Exception("only frequency is acceptable for param type: " + _lastType.ToString());
|
||||
}
|
||||
|
||||
_lastType = type;
|
||||
_lastRange = range.Hertz;
|
||||
_lastResolution = resolution.Hertz;
|
||||
}
|
||||
_lastType = type;
|
||||
_lastRange = range.Hertz;
|
||||
_lastResolution = resolution.Hertz;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dispose of this objects resources
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
try
|
||||
{
|
||||
Dispose(true);
|
||||
/// <summary>
|
||||
/// Dispose of this objects resources
|
||||
/// </summary>
|
||||
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>
|
||||
///
|
||||
/// </summary>
|
||||
public string DetailedStatus
|
||||
{
|
||||
get
|
||||
{
|
||||
return "This is a VTI Dmm";
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string DetailedStatus
|
||||
{
|
||||
get
|
||||
{
|
||||
return "This is a VTI Dmm";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public bool DisplayEnabled
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public bool DisplayEnabled
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public bool FrontPanelEnabled
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public bool FrontPanelEnabled
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public InstrumentMetadata Info
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public InstrumentMetadata Info
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public void Initialize()
|
||||
{
|
||||
if (_state == State.Uninitialized)
|
||||
{
|
||||
_dmm = new VTEXDmm();
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public void Initialize()
|
||||
{
|
||||
if (_state == State.Uninitialized)
|
||||
{
|
||||
_dmm = new VTEXDmm();
|
||||
|
||||
_dmm.Initialize(_address, true, true, _options);
|
||||
_dmm.Initialize(_address, true, true, _options);
|
||||
|
||||
// Set measurement input to backplane after performing init(). Default is front panel.
|
||||
_dmm.Measurement.Input = VTEXDmmInputSelectEnum.VTEXDmmInputSelectInternal;
|
||||
// Set measurement input to backplane after performing init(). Default is front panel.
|
||||
_dmm.Measurement.Input = VTEXDmmInputSelectEnum.VTEXDmmInputSelectInternal;
|
||||
|
||||
_selfTestResult = PerformSelfTest();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("expected the state to be Uninitialized, state was: " + _state.ToString());
|
||||
}
|
||||
}
|
||||
_selfTestResult = PerformSelfTest();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("expected the state to be Uninitialized, state was: " + _state.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public MeasurementFunction MeasurementType
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public MeasurementFunction MeasurementType
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="timeout"></param>
|
||||
/// <returns></returns>
|
||||
public Current MeasureCurrent(int timeout)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="timeout"></param>
|
||||
/// <returns></returns>
|
||||
public Current MeasureCurrent(int timeout)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
||||
/*
|
||||
/*
|
||||
if (_lastType != MeasurementFunction.DCVolts && _lastType != MeasurementFunction.ACVolts)
|
||||
{
|
||||
throw new Exception("only ac or dc volt is acceptable for param type: " + type.ToString());
|
||||
}
|
||||
|
||||
return Current.FromAmps(ReadCurrent();*/
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="timeout"></param>
|
||||
/// <returns></returns>
|
||||
public Frequency MeasureFrequency(int timeout)
|
||||
{
|
||||
if (_lastType != MeasurementFunction.Frequency)
|
||||
{
|
||||
throw new Exception("only frequency is acceptable for param type: " + _lastType.ToString());
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="timeout"></param>
|
||||
/// <returns></returns>
|
||||
public Frequency MeasureFrequency(int timeout)
|
||||
{
|
||||
if (_lastType != MeasurementFunction.Frequency)
|
||||
{
|
||||
throw new Exception("only frequency is acceptable for param type: " + _lastType.ToString());
|
||||
}
|
||||
|
||||
double frequency = 0.0;
|
||||
double frequency = 0.0;
|
||||
|
||||
_dmm.Function = VTEXDmmFunctionEnum.VTEXDmmFunctionFreq;
|
||||
_dmm.Function = VTEXDmmFunctionEnum.VTEXDmmFunctionFreq;
|
||||
|
||||
_dmm.Range = _lastRange;
|
||||
_dmm.Range = _lastRange;
|
||||
|
||||
_dmm.Resolution = _lastResolution;
|
||||
_dmm.Resolution = _lastResolution;
|
||||
|
||||
_dmm.Measurement.Read(_READ_TIMEOUT, ref frequency);
|
||||
_dmm.Measurement.Read(_READ_TIMEOUT, ref frequency);
|
||||
|
||||
return Frequency.FromHertz(frequency);
|
||||
}
|
||||
return Frequency.FromHertz(frequency);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="timeout"></param>
|
||||
/// <returns></returns>
|
||||
public Resistance MeasureResistance(int timeout)
|
||||
{
|
||||
if (_lastType != MeasurementFunction.FourWireResistance && _lastType != MeasurementFunction.TwoWireResistance)
|
||||
{
|
||||
throw new Exception("only FourWireResistance or TwoWireResistance is acceptable for param type: " + _lastType.ToString());
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="timeout"></param>
|
||||
/// <returns></returns>
|
||||
public Resistance MeasureResistance(int timeout)
|
||||
{
|
||||
if (_lastType != MeasurementFunction.FourWireResistance && _lastType != MeasurementFunction.TwoWireResistance)
|
||||
{
|
||||
throw new Exception("only FourWireResistance or TwoWireResistance is acceptable for param type: " + _lastType.ToString());
|
||||
}
|
||||
|
||||
if (_lastType == MeasurementFunction.FourWireResistance)
|
||||
{
|
||||
_dmm.Function = VTEXDmmFunctionEnum.VTEXDmmFunction4WireRes;
|
||||
}
|
||||
else
|
||||
{
|
||||
_dmm.Function = VTEXDmmFunctionEnum.VTEXDmmFunction2WireRes;
|
||||
}
|
||||
if (_lastType == MeasurementFunction.FourWireResistance)
|
||||
{
|
||||
_dmm.Function = VTEXDmmFunctionEnum.VTEXDmmFunction4WireRes;
|
||||
}
|
||||
else
|
||||
{
|
||||
_dmm.Function = VTEXDmmFunctionEnum.VTEXDmmFunction2WireRes;
|
||||
}
|
||||
|
||||
double resistance = 0.0;
|
||||
double resistance = 0.0;
|
||||
|
||||
_dmm.Range = _lastRange;
|
||||
_dmm.Range = _lastRange;
|
||||
|
||||
_dmm.Resolution = _lastResolution;
|
||||
_dmm.Resolution = _lastResolution;
|
||||
|
||||
_dmm.Measurement.Read(_READ_TIMEOUT, ref resistance);
|
||||
_dmm.Measurement.Read(_READ_TIMEOUT, ref resistance);
|
||||
|
||||
if (double.IsNaN(resistance))
|
||||
{
|
||||
resistance = double.MaxValue;
|
||||
}
|
||||
if (double.IsNaN(resistance))
|
||||
{
|
||||
resistance = double.MaxValue;
|
||||
}
|
||||
|
||||
return Resistance.FromOhms(resistance);
|
||||
}
|
||||
return Resistance.FromOhms(resistance);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="timeout"></param>
|
||||
/// <returns></returns>
|
||||
public Voltage MeasureVoltage(int timeout)
|
||||
{
|
||||
if (_lastType != MeasurementFunction.DCVolts && _lastType != MeasurementFunction.ACVolts)
|
||||
{
|
||||
throw new Exception("only ac or dc volt is acceptable for param type: " + _lastType.ToString());
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="timeout"></param>
|
||||
/// <returns></returns>
|
||||
public Voltage MeasureVoltage(int timeout)
|
||||
{
|
||||
if (_lastType != MeasurementFunction.DCVolts && _lastType != MeasurementFunction.ACVolts)
|
||||
{
|
||||
throw new Exception("only ac or dc volt is acceptable for param type: " + _lastType.ToString());
|
||||
}
|
||||
|
||||
if (_lastType == MeasurementFunction.ACVolts)
|
||||
{
|
||||
_dmm.Function = VTEXDmmFunctionEnum.VTEXDmmFunctionACVolts;
|
||||
}
|
||||
else
|
||||
{
|
||||
_dmm.Function = VTEXDmmFunctionEnum.VTEXDmmFunctionDCVolts;
|
||||
}
|
||||
if (_lastType == MeasurementFunction.ACVolts)
|
||||
{
|
||||
_dmm.Function = VTEXDmmFunctionEnum.VTEXDmmFunctionACVolts;
|
||||
}
|
||||
else
|
||||
{
|
||||
_dmm.Function = VTEXDmmFunctionEnum.VTEXDmmFunctionDCVolts;
|
||||
}
|
||||
|
||||
double dcVoltage = 0.0;
|
||||
double dcVoltage = 0.0;
|
||||
|
||||
_dmm.Measurement.Read(_READ_TIMEOUT, ref dcVoltage);
|
||||
_dmm.Measurement.Read(_READ_TIMEOUT, ref dcVoltage);
|
||||
|
||||
if (double.IsNaN(dcVoltage))
|
||||
{
|
||||
dcVoltage = double.MaxValue;
|
||||
}
|
||||
if (double.IsNaN(dcVoltage))
|
||||
{
|
||||
dcVoltage = double.MaxValue;
|
||||
}
|
||||
|
||||
return Voltage.FromVolts(dcVoltage);
|
||||
}
|
||||
return Voltage.FromVolts(dcVoltage);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get { return _name; }
|
||||
set { _name = value; }
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get { return _name; }
|
||||
set { _name = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public SelfTestResult PerformSelfTest()
|
||||
{
|
||||
int testResult = 0;
|
||||
string result = "";
|
||||
_dmm.Utility.SelfTest(ref testResult, ref result);
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public SelfTestResult PerformSelfTest()
|
||||
{
|
||||
int testResult = 0;
|
||||
string result = "";
|
||||
_dmm.Utility.SelfTest(ref testResult, ref result);
|
||||
|
||||
// Set measurement input to backplane after performing self test. Default is front panel.
|
||||
_dmm.Measurement.Input = VTEXDmmInputSelectEnum.VTEXDmmInputSelectInternal;
|
||||
// Set measurement input to backplane after performing self test. Default is front panel.
|
||||
_dmm.Measurement.Input = VTEXDmmInputSelectEnum.VTEXDmmInputSelectInternal;
|
||||
|
||||
if (testResult > 0)
|
||||
{
|
||||
_selfTestResult = Raytheon.Instruments.SelfTestResult.Fail;
|
||||
throw new Exception("self test failed with an Error Code: " + testResult + " and Error Message: " + result);
|
||||
}
|
||||
if (testResult > 0)
|
||||
{
|
||||
_selfTestResult = Raytheon.Instruments.SelfTestResult.Fail;
|
||||
throw new Exception("self test failed with an Error Code: " + testResult + " and Error Message: " + result);
|
||||
}
|
||||
|
||||
_selfTestResult = Raytheon.Instruments.SelfTestResult.Pass;
|
||||
_selfTestResult = Raytheon.Instruments.SelfTestResult.Pass;
|
||||
|
||||
return _selfTestResult;
|
||||
}
|
||||
return _selfTestResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public void Reset()
|
||||
{
|
||||
_dmm.Utility.Reset();
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public void Reset()
|
||||
{
|
||||
_dmm.Utility.Reset();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public SelfTestResult SelfTestResult
|
||||
{
|
||||
get
|
||||
{
|
||||
return _selfTestResult;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public SelfTestResult SelfTestResult
|
||||
{
|
||||
get
|
||||
{
|
||||
return _selfTestResult;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public State Status
|
||||
{
|
||||
get
|
||||
{
|
||||
return _state;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public State Status
|
||||
{
|
||||
get
|
||||
{
|
||||
return _state;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public void Shutdown()
|
||||
{
|
||||
if (_state == State.Ready)
|
||||
{
|
||||
_dmm.Utility.Reset();
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public void Shutdown()
|
||||
{
|
||||
if (_state == State.Ready)
|
||||
{
|
||||
_dmm.Utility.Reset();
|
||||
|
||||
_dmm.Close();
|
||||
_dmm.Close();
|
||||
|
||||
_state = State.Uninitialized;
|
||||
}
|
||||
}
|
||||
_state = State.Uninitialized;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,71 +31,64 @@
|
||||
// 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 = "DMMVTIFactory")]
|
||||
public class DMMVTIFactory : 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 = "DMMVTIFactory")]
|
||||
public class DMMVTIFactory : IInstrumentFactory
|
||||
{
|
||||
private readonly List<Type> _supportedInterfaces = new List<Type>();
|
||||
|
||||
public DMMVTIFactory(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 DMMVTIFactory([Import(AllowDefault = false)] IConfigurationManager configManager,
|
||||
[Import(AllowDefault = true)] string defaultConfigPath = null)
|
||||
{
|
||||
DefaultPath = defaultConfigPath;
|
||||
public DMMVTIFactory(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>
|
||||
/// DMMVTIFactory injection constructor
|
||||
/// </summary>
|
||||
[ImportingConstructor]
|
||||
public DMMVTIFactory([Import(AllowDefault = false)] IConfigurationManager configManager,
|
||||
[Import(AllowDefault = true)] string defaultConfigPath = null)
|
||||
{
|
||||
DefaultPath = defaultConfigPath;
|
||||
|
||||
_configurationManager = configManager ?? GetConfigurationManager();
|
||||
_supportedInterfaces.Add(typeof(IDmm));
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets the instrument
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
public IInstrument GetInstrument(string name)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger = LogManager.GetLogger(name);
|
||||
return new DMMVTI(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(IDmm));
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets the instrument
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
public IInstrument GetInstrument(string name)
|
||||
{
|
||||
try
|
||||
{
|
||||
return new DMMVTI(name, _configurationManager);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the instrument
|
||||
@@ -106,12 +99,10 @@ namespace Raytheon.Instruments
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger = LogManager.GetLogger(name);
|
||||
|
||||
if (simulateHw)
|
||||
return new DMMSim(name, _configurationManager, _logger);
|
||||
return new DMMSim(name, _configurationManager);
|
||||
else
|
||||
return new DMMVTI(name, _configurationManager, _logger);
|
||||
return new DMMVTI(name, _configurationManager);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
@@ -124,17 +115,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user