Major upgrade
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -30,71 +30,64 @@
|
||||
// DISTRIBUTION/DISSEMINATION CONTROL: F
|
||||
// POC: Alex Kravchenko (1118268)
|
||||
// **********************************************************************************************************
|
||||
using NLog;
|
||||
using Raytheon.Common;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.Composition;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using NLog;
|
||||
using Raytheon.Common;
|
||||
|
||||
namespace Raytheon.Instruments
|
||||
{
|
||||
[ExportInstrumentFactory(ModelNumber = "DIOSiCp210xFactory")]
|
||||
public class DIOSiCp210xFactory : 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 = "DIOSiCp210xFactory")]
|
||||
public class DIOSiCp210xFactory : IInstrumentFactory
|
||||
{
|
||||
private readonly List<Type> _supportedInterfaces = new List<Type>();
|
||||
|
||||
public DIOSiCp210xFactory(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 DIOSiCp210xFactory([Import(AllowDefault = false)] IConfigurationManager configManager,
|
||||
[Import(AllowDefault = true)] string defaultConfigPath = null)
|
||||
{
|
||||
DefaultPath = defaultConfigPath;
|
||||
public DIOSiCp210xFactory(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>
|
||||
/// DIOSiCp210xFactory injection constructor
|
||||
/// </summary>
|
||||
[ImportingConstructor]
|
||||
public DIOSiCp210xFactory([Import(AllowDefault = false)] IConfigurationManager configManager,
|
||||
[Import(AllowDefault = true)] string defaultConfigPath = null)
|
||||
{
|
||||
DefaultPath = defaultConfigPath;
|
||||
|
||||
_configurationManager = configManager ?? GetConfigurationManager();
|
||||
_supportedInterfaces.Add(typeof(IGeneralIO));
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets the instrument
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
public IInstrument GetInstrument(string name)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger = LogManager.GetLogger(name);
|
||||
return new DIOSiCp210x(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(IGeneralIO));
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets the instrument
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
public IInstrument GetInstrument(string name)
|
||||
{
|
||||
try
|
||||
{
|
||||
return new DIOSiCp210x(name, _configurationManager);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the instrument
|
||||
@@ -105,12 +98,10 @@ namespace Raytheon.Instruments
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger = LogManager.GetLogger(name);
|
||||
|
||||
if (simulateHw)
|
||||
return new DIOSim(name, _configurationManager, _logger);
|
||||
return new DIOSim(name, _configurationManager);
|
||||
else
|
||||
return new DIOSiCp210x(name, _configurationManager, _logger);
|
||||
return new DIOSiCp210x(name, _configurationManager);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
@@ -123,17 +114,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,134 +1,132 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Win_API;
|
||||
using Raytheon.Instruments.GeneralIO;
|
||||
using CP210xRuntime_DLL;
|
||||
using NLog;
|
||||
using Raytheon.Common;
|
||||
using Raytheon.Instruments.GeneralIO;
|
||||
using Win_API;
|
||||
|
||||
namespace Raytheon.Instruments
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class ECPDIOSiCp210x : DIOSiCp210x
|
||||
{
|
||||
private string _comPort = string.Empty;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class ECPDIOSiCp210x : DIOSiCp210x
|
||||
{
|
||||
private string _comPort = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// ECPDIOSiCp210x factory constructor
|
||||
/// </summary>
|
||||
/// <param name="deviceName"></param>
|
||||
/// <param name="configurationManager"></param>
|
||||
public ECPDIOSiCp210x(string deviceName, IConfigurationManager configurationManager, ILogger logger)
|
||||
: base(deviceName, configurationManager, logger)
|
||||
{
|
||||
_comPort = _dioModuleConfig.ReadValue(Name, ConfigIni.COM_PORT.ToString());
|
||||
}
|
||||
/// <summary>
|
||||
/// ECPDIOSiCp210x factory constructor
|
||||
/// </summary>
|
||||
/// <param name="deviceName"></param>
|
||||
/// <param name="configurationManager"></param>
|
||||
public ECPDIOSiCp210x(string deviceName, IConfigurationManager configurationManager)
|
||||
: base(deviceName, configurationManager)
|
||||
{
|
||||
_comPort = _dioModuleConfig.ReadValue(Name, ConfigIni.COM_PORT.ToString());
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="deviceName"></param>
|
||||
/// <param name="deviceNum"></param>
|
||||
/// <param name="inputPins"></param>
|
||||
/// <param name="outputPins"></param>
|
||||
public ECPDIOSiCp210x(string deviceName, uint deviceNum)
|
||||
: base(deviceName, deviceNum)
|
||||
{ }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="deviceName"></param>
|
||||
/// <param name="deviceNum"></param>
|
||||
/// <param name="inputPins"></param>
|
||||
/// <param name="outputPins"></param>
|
||||
public ECPDIOSiCp210x(string deviceName, uint deviceNum)
|
||||
: base(deviceName, deviceNum)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="deviceName"></param>
|
||||
/// <param name="comPort"></param>
|
||||
/// <param name="inputPins"></param>
|
||||
/// <param name="outputPins"></param>
|
||||
public ECPDIOSiCp210x(string deviceName, string comPort)
|
||||
: base(deviceName, 0)
|
||||
{
|
||||
_comPort = comPort;
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="deviceName"></param>
|
||||
/// <param name="comPort"></param>
|
||||
/// <param name="inputPins"></param>
|
||||
/// <param name="outputPins"></param>
|
||||
public ECPDIOSiCp210x(string deviceName, string comPort)
|
||||
: base(deviceName, 0)
|
||||
{
|
||||
_comPort = comPort;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="comPort"></param>
|
||||
public void SetComPort(string comPort)
|
||||
{
|
||||
_comPort = comPort;
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="comPort"></param>
|
||||
public void SetComPort(string comPort)
|
||||
{
|
||||
_comPort = comPort;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private IntPtr GetHandle()
|
||||
{
|
||||
var comString = $"\\\\.\\{_comPort}";
|
||||
var securityAttbs = NativeMethods.InitWithDefaultAttributes();
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private IntPtr GetHandle()
|
||||
{
|
||||
var comString = $"\\\\.\\{_comPort}";
|
||||
var securityAttbs = NativeMethods.InitWithDefaultAttributes();
|
||||
|
||||
//Open a handle the device specified
|
||||
IntPtr hDevice = NativeMethods.CreateFileA(comString,
|
||||
//Open a handle the device specified
|
||||
IntPtr hDevice = NativeMethods.CreateFileA(comString,
|
||||
NativeMethods.GENERIC_READ | NativeMethods.GENERIC_WRITE,
|
||||
0,
|
||||
ref securityAttbs,
|
||||
3,
|
||||
NativeMethods.FILE_ATTRIBUTE_NORMAL | NativeMethods.FILE_FLAG_OVERLAPPED,
|
||||
IntPtr.Zero);
|
||||
0,
|
||||
ref securityAttbs,
|
||||
3,
|
||||
NativeMethods.FILE_ATTRIBUTE_NORMAL | NativeMethods.FILE_FLAG_OVERLAPPED,
|
||||
IntPtr.Zero);
|
||||
|
||||
if (hDevice != NativeMethods.INVALID_HANDLE_VALUE)
|
||||
{
|
||||
return hDevice;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"Unable to get a valid handle using COM port {_comPort}");
|
||||
}
|
||||
}
|
||||
if (hDevice != NativeMethods.INVALID_HANDLE_VALUE)
|
||||
{
|
||||
return hDevice;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"Unable to get a valid handle using COM port {_comPort}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public ushort ReadLatch()
|
||||
{
|
||||
var handle = GetHandle();
|
||||
ushort latch = 0;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public ushort ReadLatch()
|
||||
{
|
||||
var handle = GetHandle();
|
||||
ushort latch = 0;
|
||||
|
||||
var errCode = CP210xRuntime.CP210xRT_ReadLatch(handle, ref latch);
|
||||
var errCode = CP210xRuntime.CP210xRT_ReadLatch(handle, ref latch);
|
||||
|
||||
NativeMethods.CloseHandle(handle);
|
||||
|
||||
if (errCode == SI_SUCCESS)
|
||||
{
|
||||
return latch;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"Error when reading CP210X latch. Error code returned: {errCode}");
|
||||
}
|
||||
}
|
||||
if (errCode == SI_SUCCESS)
|
||||
{
|
||||
return latch;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"Error when reading CP210X latch. Error code returned: {errCode}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="bit"></param>
|
||||
/// <returns></returns>
|
||||
public override IODatatypes.BitState GetBitState(string signalName)
|
||||
{
|
||||
lock (_syncObj)
|
||||
{
|
||||
if (!_signalNameToChannelMap.ContainsKey(signalName))
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="bit"></param>
|
||||
/// <returns></returns>
|
||||
public override IODatatypes.BitState GetBitState(string signalName)
|
||||
{
|
||||
lock (_syncObj)
|
||||
{
|
||||
if (!_signalNameToChannelInfoMap.ContainsKey(signalName))
|
||||
throw new Exception($"Signal name {signalName} doesn't exist for card: " + _name);
|
||||
|
||||
if (_signalNameToChannelMap[signalName].channelNumber >= _numInputChannels || _signalNameToChannelMap[signalName].channelNumber < _channelStartIndex)
|
||||
if (_signalNameToChannelInfoMap[signalName].channelNumber >= _numInputChannels || _signalNameToChannelInfoMap[signalName].channelNumber < _channelStartIndex)
|
||||
{
|
||||
throw new Exception($"The input channel number {_signalNameToChannelMap[signalName].channelNumber} specified must be >= {_channelStartIndex} and < {_numInputChannels + _channelStartIndex} on card " + _name);
|
||||
throw new Exception($"The input channel number {_signalNameToChannelInfoMap[signalName].channelNumber} specified must be >= {_channelStartIndex} and < {_numInputChannels + _channelStartIndex} on card " + _name);
|
||||
}
|
||||
|
||||
int bitIndex = (int)_signalNameToChannelMap[signalName].channelNumber - _channelStartIndex;
|
||||
int bitIndex = (int)_signalNameToChannelInfoMap[signalName].channelNumber - _channelStartIndex;
|
||||
|
||||
ushort mask = (ushort)(0x1 << (int)bitIndex);
|
||||
|
||||
@@ -136,59 +134,59 @@ namespace Raytheon.Instruments
|
||||
|
||||
return (IODatatypes.BitState)(latch & mask);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="bit"></param>
|
||||
/// <param name="state"></param>
|
||||
public override void SetBit(string signalName, IODatatypes.BitState state)
|
||||
{
|
||||
lock (_syncObj)
|
||||
{
|
||||
if (!_signalNameToChannelMap.ContainsKey(signalName))
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="bit"></param>
|
||||
/// <param name="state"></param>
|
||||
public override void SetBit(string signalName, IODatatypes.BitState state)
|
||||
{
|
||||
lock (_syncObj)
|
||||
{
|
||||
if (!_signalNameToChannelInfoMap.ContainsKey(signalName))
|
||||
throw new Exception($"Signal name {signalName} doesn't exist for card: " + _name);
|
||||
|
||||
if (_signalNameToChannelMap[signalName].channelNumber >= _numOutputChannels || _signalNameToChannelMap[signalName].channelNumber < _channelStartIndex)
|
||||
if (_signalNameToChannelInfoMap[signalName].channelNumber >= _numOutputChannels || _signalNameToChannelInfoMap[signalName].channelNumber < _channelStartIndex)
|
||||
{
|
||||
throw new Exception($"The output channel number {_signalNameToChannelMap[signalName].channelNumber} specified must be >= {_channelStartIndex} and < {_numOutputChannels + _channelStartIndex} on card " + _name);
|
||||
throw new Exception($"The output channel number {_signalNameToChannelInfoMap[signalName].channelNumber} specified must be >= {_channelStartIndex} and < {_numOutputChannels + _channelStartIndex} on card " + _name);
|
||||
}
|
||||
|
||||
int bitIndex = (int)_signalNameToChannelMap[signalName].channelNumber - _channelStartIndex;
|
||||
int bitIndex = (int)_signalNameToChannelInfoMap[signalName].channelNumber - _channelStartIndex;
|
||||
|
||||
ushort mask = (ushort)(0x1 << (int)bitIndex);
|
||||
|
||||
if (state == IODatatypes.BitState.High)
|
||||
{
|
||||
WriteLatch(mask, mask);
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteLatch(mask, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (state == IODatatypes.BitState.High)
|
||||
{
|
||||
WriteLatch(mask, mask);
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteLatch(mask, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="mask"></param>
|
||||
/// <param name="latch"></param>
|
||||
/// <returns></returns>
|
||||
protected override void WriteLatch(ushort mask, ushort latch)
|
||||
{
|
||||
var handle = GetHandle();
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="mask"></param>
|
||||
/// <param name="latch"></param>
|
||||
/// <returns></returns>
|
||||
protected override void WriteLatch(ushort mask, ushort latch)
|
||||
{
|
||||
var handle = GetHandle();
|
||||
|
||||
int ret = CP210xRuntime.CP210xRT_WriteLatch(handle, mask, latch);
|
||||
int ret = CP210xRuntime.CP210xRT_WriteLatch(handle, mask, latch);
|
||||
|
||||
NativeMethods.CloseHandle(handle);
|
||||
NativeMethods.CloseHandle(handle);
|
||||
|
||||
if (ret != SI_SUCCESS)
|
||||
{
|
||||
throw new Exception("call to write latch returned error: " + ret.ToString() + " on card: " + _name);
|
||||
}
|
||||
}
|
||||
if (ret != SI_SUCCESS)
|
||||
{
|
||||
throw new Exception("call to write latch returned error: " + ret.ToString() + " on card: " + _name);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,71 +30,64 @@
|
||||
// DISTRIBUTION/DISSEMINATION CONTROL: F
|
||||
// POC: Alex Kravchenko (1118268)
|
||||
// **********************************************************************************************************
|
||||
using NLog;
|
||||
using Raytheon.Common;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.Composition;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using NLog;
|
||||
using Raytheon.Common;
|
||||
|
||||
namespace Raytheon.Instruments
|
||||
{
|
||||
[ExportInstrumentFactory(ModelNumber = "ECPDIOSiCp210xFactory")]
|
||||
public class ECPDIOSiCp210xFactory : 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 = "ECPDIOSiCp210xFactory")]
|
||||
public class ECPDIOSiCp210xFactory : IInstrumentFactory
|
||||
{
|
||||
private readonly List<Type> _supportedInterfaces = new List<Type>();
|
||||
|
||||
public ECPDIOSiCp210xFactory(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 ECPDIOSiCp210xFactory([Import(AllowDefault = false)] IConfigurationManager configManager,
|
||||
[Import(AllowDefault = true)] string defaultConfigPath = null)
|
||||
{
|
||||
DefaultPath = defaultConfigPath;
|
||||
public ECPDIOSiCp210xFactory(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>
|
||||
/// ECPDIOSiCp210xFactory injection constructor
|
||||
/// </summary>
|
||||
[ImportingConstructor]
|
||||
public ECPDIOSiCp210xFactory([Import(AllowDefault = false)] IConfigurationManager configManager,
|
||||
[Import(AllowDefault = true)] string defaultConfigPath = null)
|
||||
{
|
||||
DefaultPath = defaultConfigPath;
|
||||
|
||||
_configurationManager = configManager ?? GetConfigurationManager();
|
||||
_supportedInterfaces.Add(typeof(IGeneralIO));
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets the instrument
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
public IInstrument GetInstrument(string name)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger = LogManager.GetLogger(name);
|
||||
return new ECPDIOSiCp210x(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(IGeneralIO));
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets the instrument
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
public IInstrument GetInstrument(string name)
|
||||
{
|
||||
try
|
||||
{
|
||||
return new ECPDIOSiCp210x(name, _configurationManager);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the instrument
|
||||
@@ -105,12 +98,10 @@ namespace Raytheon.Instruments
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger = LogManager.GetLogger(name);
|
||||
|
||||
if (simulateHw)
|
||||
return new DIOSim(name, _configurationManager, _logger);
|
||||
return new DIOSim(name, _configurationManager);
|
||||
else
|
||||
return new ECPDIOSiCp210x(name, _configurationManager, _logger);
|
||||
return new ECPDIOSiCp210x(name, _configurationManager);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
@@ -123,17 +114,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