Monitor power supply data for fault conditions
This commit is contained in:
@@ -57,7 +57,7 @@ namespace Raytheon.Instruments.PowerSupplies
|
|||||||
string coupledModules = _config.ReadValue(PowerSupplyConfigIni.GENERAL.ToString(), PowerSupplyConfigIni.COUPLED_MODULES.ToString(), Raytheon.Common.GeneralConstants.DefaultConfigValue);
|
string coupledModules = _config.ReadValue(PowerSupplyConfigIni.GENERAL.ToString(), PowerSupplyConfigIni.COUPLED_MODULES.ToString(), Raytheon.Common.GeneralConstants.DefaultConfigValue);
|
||||||
string groupedModules = _config.ReadValue(PowerSupplyConfigIni.GENERAL.ToString(), PowerSupplyConfigIni.GROUPED_MODULES.ToString(), Raytheon.Common.GeneralConstants.DefaultConfigValue);
|
string groupedModules = _config.ReadValue(PowerSupplyConfigIni.GENERAL.ToString(), PowerSupplyConfigIni.GROUPED_MODULES.ToString(), Raytheon.Common.GeneralConstants.DefaultConfigValue);
|
||||||
|
|
||||||
List<string> powerModules = moduleDef.Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries).ToList();
|
PowerModules = moduleDef.Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries).ToList();
|
||||||
_coupledModules = coupledModules.Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries).ToList();
|
_coupledModules = coupledModules.Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries).ToList();
|
||||||
_groupedModules = groupedModules.Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries).ToList();
|
_groupedModules = groupedModules.Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries).ToList();
|
||||||
|
|
||||||
@@ -81,9 +81,9 @@ namespace Raytheon.Instruments.PowerSupplies
|
|||||||
|
|
||||||
if (_groupedModules.Count() > 1)
|
if (_groupedModules.Count() > 1)
|
||||||
{
|
{
|
||||||
powerModules.Clear();
|
PowerModules.Clear();
|
||||||
// since modules are grouped, we pick the first module as the representative module
|
// since modules are grouped, we pick the first module as the representative module
|
||||||
powerModules.Add(_groupedModules[0]);
|
PowerModules.Add(_groupedModules[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// build the power module map
|
// build the power module map
|
||||||
@@ -98,9 +98,9 @@ namespace Raytheon.Instruments.PowerSupplies
|
|||||||
double minCurrent = 0.0;
|
double minCurrent = 0.0;
|
||||||
double maxCurrent = 0.0;
|
double maxCurrent = 0.0;
|
||||||
|
|
||||||
for (int i = 0; i < powerModules.Count(); i++)
|
for (int i = 0; i < PowerModules.Count(); i++)
|
||||||
{
|
{
|
||||||
string moduleName = powerModules[i];
|
string moduleName = PowerModules[i];
|
||||||
|
|
||||||
moduleIndex = _config.ReadValue(moduleName, PowerSupplyConfigIni.INDEX.ToString(), Raytheon.Common.GeneralConstants.DefaultConfigValue);
|
moduleIndex = _config.ReadValue(moduleName, PowerSupplyConfigIni.INDEX.ToString(), Raytheon.Common.GeneralConstants.DefaultConfigValue);
|
||||||
Double.TryParse(_config.ReadValue(moduleName, PowerSupplyConfigIni.OCP.ToString(), Raytheon.Common.GeneralConstants.DefaultConfigValue), out ocp);
|
Double.TryParse(_config.ReadValue(moduleName, PowerSupplyConfigIni.OCP.ToString(), Raytheon.Common.GeneralConstants.DefaultConfigValue), out ocp);
|
||||||
@@ -143,7 +143,6 @@ namespace Raytheon.Instruments.PowerSupplies
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public override bool FrontPanelEnabled
|
public override bool FrontPanelEnabled
|
||||||
{
|
{
|
||||||
get { SemObj?.Release(); throw new NotImplementedException(); }
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
string command;
|
string command;
|
||||||
|
|||||||
@@ -97,15 +97,21 @@ namespace Raytheon.Instruments.PowerSupplies
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (!(powerDeviceId == null || powerDeviceId.GetType().IsEnum))
|
string powerDeviceName = String.Empty;
|
||||||
|
|
||||||
|
if (powerDeviceId != null && (powerDeviceId.GetType().IsEnum || powerDeviceId is string))
|
||||||
{
|
{
|
||||||
throw new ArgumentException($"{nameof(powerDeviceId)} must be an enumerated type or null");
|
powerDeviceName = powerDeviceId.ToString();
|
||||||
|
}
|
||||||
|
else if (powerDeviceId != null)
|
||||||
|
{
|
||||||
|
throw new ArgumentException($"{nameof(powerDeviceId)} must be null or enumerated or string type");
|
||||||
}
|
}
|
||||||
|
|
||||||
_powerSupplyModule.GetSemphamore().WaitOne();
|
_powerSupplyModule.GetSemphamore().WaitOne();
|
||||||
|
|
||||||
if (powerDeviceId != null)
|
if (powerDeviceId != null)
|
||||||
_powerSupplyModule.SetActivePowerModule(powerDeviceId.ToString());
|
_powerSupplyModule.SetActivePowerModule(powerDeviceName);
|
||||||
|
|
||||||
return _powerSupplyModule;
|
return _powerSupplyModule;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,15 +51,15 @@ namespace Raytheon.Instruments.PowerSupplies
|
|||||||
string coupledModules = config.ReadValue(PowerSupplyConfigIni.GENERAL.ToString(), PowerSupplyConfigIni.COUPLED_MODULES.ToString(), Raytheon.Common.GeneralConstants.DefaultConfigValue);
|
string coupledModules = config.ReadValue(PowerSupplyConfigIni.GENERAL.ToString(), PowerSupplyConfigIni.COUPLED_MODULES.ToString(), Raytheon.Common.GeneralConstants.DefaultConfigValue);
|
||||||
string groupedModules = config.ReadValue(PowerSupplyConfigIni.GENERAL.ToString(), PowerSupplyConfigIni.GROUPED_MODULES.ToString(), Raytheon.Common.GeneralConstants.DefaultConfigValue);
|
string groupedModules = config.ReadValue(PowerSupplyConfigIni.GENERAL.ToString(), PowerSupplyConfigIni.GROUPED_MODULES.ToString(), Raytheon.Common.GeneralConstants.DefaultConfigValue);
|
||||||
|
|
||||||
List<string> powerModules = moduleDef.Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries).ToList();
|
PowerModules = moduleDef.Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries).ToList();
|
||||||
_coupledModules = coupledModules.Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries).ToList();
|
_coupledModules = coupledModules.Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries).ToList();
|
||||||
_groupedModules = groupedModules.Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries).ToList();
|
_groupedModules = groupedModules.Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries).ToList();
|
||||||
|
|
||||||
if (_groupedModules.Count() > 1)
|
if (_groupedModules.Count() > 1)
|
||||||
{
|
{
|
||||||
powerModules.Clear();
|
PowerModules.Clear();
|
||||||
// since modules are grouped, we pick the first module as the representative module
|
// since modules are grouped, we pick the first module as the representative module
|
||||||
powerModules.Add(_groupedModules[0]);
|
PowerModules.Add(_groupedModules[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// build the power module map
|
// build the power module map
|
||||||
@@ -74,9 +74,9 @@ namespace Raytheon.Instruments.PowerSupplies
|
|||||||
double minCurrent = 0.0;
|
double minCurrent = 0.0;
|
||||||
double maxCurrent = 0.0;
|
double maxCurrent = 0.0;
|
||||||
|
|
||||||
for (int i = 0; i < powerModules.Count(); i++)
|
for (int i = 0; i < PowerModules.Count(); i++)
|
||||||
{
|
{
|
||||||
string moduleName = powerModules[i];
|
string moduleName = PowerModules[i];
|
||||||
|
|
||||||
moduleIndex = config.ReadValue(moduleName, PowerSupplyConfigIni.INDEX.ToString(), Raytheon.Common.GeneralConstants.DefaultConfigValue);
|
moduleIndex = config.ReadValue(moduleName, PowerSupplyConfigIni.INDEX.ToString(), Raytheon.Common.GeneralConstants.DefaultConfigValue);
|
||||||
Double.TryParse(config.ReadValue(moduleName, PowerSupplyConfigIni.OCP.ToString(), Raytheon.Common.GeneralConstants.DefaultConfigValue), out ocp);
|
Double.TryParse(config.ReadValue(moduleName, PowerSupplyConfigIni.OCP.ToString(), Raytheon.Common.GeneralConstants.DefaultConfigValue), out ocp);
|
||||||
@@ -109,8 +109,7 @@ namespace Raytheon.Instruments.PowerSupplies
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public override bool FrontPanelEnabled
|
public override bool FrontPanelEnabled
|
||||||
{
|
{
|
||||||
get { SemObj?.Release(); throw new NotImplementedException(); }
|
set {_frontPanelEnabled = value; SemObj?.Release(); }
|
||||||
set { _frontPanelEnabled = value; SemObj?.Release(); }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -216,7 +215,7 @@ namespace Raytheon.Instruments.PowerSupplies
|
|||||||
lock (SyncObj)
|
lock (SyncObj)
|
||||||
{
|
{
|
||||||
if (PowerModuleInfoDict[ActivePowerModule].isOn_)
|
if (PowerModuleInfoDict[ActivePowerModule].isOn_)
|
||||||
val = (PowerModuleInfoDict[ActivePowerModule].lowerCurrentLimit_ + PowerModuleInfoDict[ActivePowerModule].upperCurrentLimit_) / 2.0;
|
val = (PowerModuleInfoDict[ActivePowerModule].currentLowerLimit_ + PowerModuleInfoDict[ActivePowerModule].currentUpperLimit_) / 2.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return val;
|
return val;
|
||||||
|
|||||||
@@ -102,15 +102,21 @@ namespace Raytheon.Instruments.PowerSupplies
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (!(powerDeviceId == null || powerDeviceId.GetType().IsEnum))
|
string powerDeviceName = String.Empty;
|
||||||
|
|
||||||
|
if (powerDeviceId != null && (powerDeviceId.GetType().IsEnum || powerDeviceId is string))
|
||||||
{
|
{
|
||||||
throw new ArgumentException($"{nameof(powerDeviceId)} must be an enumerated type or null");
|
powerDeviceName = powerDeviceId.ToString();
|
||||||
|
}
|
||||||
|
else if (powerDeviceId != null)
|
||||||
|
{
|
||||||
|
throw new ArgumentException($"{nameof(powerDeviceId)} must be null or enumerated or string type");
|
||||||
}
|
}
|
||||||
|
|
||||||
_powerSupplyModule.GetSemphamore().WaitOne();
|
_powerSupplyModule.GetSemphamore().WaitOne();
|
||||||
|
|
||||||
if (powerDeviceId != null)
|
if (powerDeviceId != null)
|
||||||
_powerSupplyModule.SetActivePowerModule(powerDeviceId.ToString());
|
_powerSupplyModule.SetActivePowerModule(powerDeviceName);
|
||||||
|
|
||||||
return _powerSupplyModule;
|
return _powerSupplyModule;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,5 +49,15 @@ namespace Raytheon.Instruments
|
|||||||
{
|
{
|
||||||
return _powerSupplyModule.PowerModuleInfoDict;
|
return _powerSupplyModule.PowerModuleInfoDict;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get power supply module names
|
||||||
|
/// </summary>
|
||||||
|
/// <param></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public List<string> GetPowerSupplyModuleNames()
|
||||||
|
{
|
||||||
|
return _powerSupplyModule.PowerModules;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ namespace Raytheon.Instruments
|
|||||||
protected Semaphore SemObj = new System.Threading.Semaphore(initialCount: 1, maximumCount: 1);
|
protected Semaphore SemObj = new System.Threading.Semaphore(initialCount: 1, maximumCount: 1);
|
||||||
protected object SyncObj = new object();
|
protected object SyncObj = new object();
|
||||||
protected string ActivePowerModule;
|
protected string ActivePowerModule;
|
||||||
|
|
||||||
|
public List<string> PowerModules { get; protected set; }
|
||||||
|
|
||||||
public Dictionary<string, PowerSupplyModuleInfo> PowerModuleInfoDict { get; protected set; }
|
public Dictionary<string, PowerSupplyModuleInfo> PowerModuleInfoDict { get; protected set; }
|
||||||
|
|
||||||
@@ -63,7 +65,7 @@ namespace Raytheon.Instruments
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual bool FrontPanelEnabled
|
public virtual bool FrontPanelEnabled
|
||||||
{
|
{
|
||||||
get;
|
private get;
|
||||||
set;
|
set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,10 +31,10 @@ namespace Raytheon.Instruments.PowerSupplies
|
|||||||
overVoltageProtection_ = -1.0;
|
overVoltageProtection_ = -1.0;
|
||||||
voltageSetpoint_ = -1.0;
|
voltageSetpoint_ = -1.0;
|
||||||
voltageSlewRate_ = -1.0;
|
voltageSlewRate_ = -1.0;
|
||||||
lowerVoltageLimit_ = -1.0;
|
voltageLowerLimit_ = -1.0;
|
||||||
upperVoltageLimit_ = -1.0;
|
voltageUpperLimit_ = -1.0;
|
||||||
lowerCurrentLimit_ = -1.0;
|
currentLowerLimit_ = -1.0;
|
||||||
upperCurrentLimit_ = -1.0;
|
currentUpperLimit_ = -1.0;
|
||||||
isOn_ = false;
|
isOn_ = false;
|
||||||
faultStatus = -1;
|
faultStatus = -1;
|
||||||
}
|
}
|
||||||
@@ -45,10 +45,10 @@ namespace Raytheon.Instruments.PowerSupplies
|
|||||||
overVoltageProtection_ = overVoltageProtection;
|
overVoltageProtection_ = overVoltageProtection;
|
||||||
voltageSetpoint_ = voltageSetpoint;
|
voltageSetpoint_ = voltageSetpoint;
|
||||||
voltageSlewRate_ = voltageSlewRate;
|
voltageSlewRate_ = voltageSlewRate;
|
||||||
lowerVoltageLimit_ = minVoltage;
|
voltageLowerLimit_ = minVoltage;
|
||||||
upperVoltageLimit_ = maxVoltage;
|
voltageUpperLimit_ = maxVoltage;
|
||||||
lowerCurrentLimit_ = minCurrent;
|
currentLowerLimit_ = minCurrent;
|
||||||
upperCurrentLimit_ = maxCurrent;
|
currentUpperLimit_ = maxCurrent;
|
||||||
isOn_ = false;
|
isOn_ = false;
|
||||||
faultStatus = -1;
|
faultStatus = -1;
|
||||||
|
|
||||||
@@ -58,10 +58,10 @@ namespace Raytheon.Instruments.PowerSupplies
|
|||||||
public string moduleNameFormat;
|
public string moduleNameFormat;
|
||||||
public double overCurrentProtection_;
|
public double overCurrentProtection_;
|
||||||
public double overVoltageProtection_;
|
public double overVoltageProtection_;
|
||||||
public double lowerVoltageLimit_;
|
public double voltageLowerLimit_;
|
||||||
public double upperVoltageLimit_;
|
public double voltageUpperLimit_;
|
||||||
public double lowerCurrentLimit_;
|
public double currentLowerLimit_;
|
||||||
public double upperCurrentLimit_;
|
public double currentUpperLimit_;
|
||||||
public double voltageSetpoint_;
|
public double voltageSetpoint_;
|
||||||
public double voltageSlewRate_;
|
public double voltageSlewRate_;
|
||||||
public bool isOn_;
|
public bool isOn_;
|
||||||
|
|||||||
@@ -15,14 +15,11 @@ GOVERNMENT.
|
|||||||
|
|
||||||
UNPUBLISHED WORK - COPYRIGHT RAYTHEON COMPANY.
|
UNPUBLISHED WORK - COPYRIGHT RAYTHEON COMPANY.
|
||||||
-------------------------------------------------------------------------*/
|
-------------------------------------------------------------------------*/
|
||||||
using NLog;
|
|
||||||
using Raytheon.Common;
|
using Raytheon.Common;
|
||||||
using Raytheon.Instruments;
|
using Raytheon.Instruments;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using NLog;
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Raytheon
|
namespace Raytheon
|
||||||
{
|
{
|
||||||
@@ -45,16 +42,7 @@ namespace Raytheon
|
|||||||
|
|
||||||
public bool FrontPanelEnabled
|
public bool FrontPanelEnabled
|
||||||
{
|
{
|
||||||
get
|
private get { return false; }
|
||||||
{
|
|
||||||
if (_powerSupply != null)
|
|
||||||
{
|
|
||||||
return _powerSupply[null].FrontPanelEnabled;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (_powerSupply != null)
|
if (_powerSupply != null)
|
||||||
@@ -67,7 +55,7 @@ namespace Raytheon
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// constructor
|
/// constructor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="stePowerSupplyInstanceName">the name specified in the Instruments.xml file</param>
|
/// <param></param>
|
||||||
public PowerModuleMeasurementManager(PowerSupply powerSupply, IConfigurationFile powerOffAndSelfTestConfig)
|
public PowerModuleMeasurementManager(PowerSupply powerSupply, IConfigurationFile powerOffAndSelfTestConfig)
|
||||||
{
|
{
|
||||||
_logger = LogManager.GetCurrentClassLogger();
|
_logger = LogManager.GetCurrentClassLogger();
|
||||||
@@ -109,6 +97,22 @@ namespace Raytheon
|
|||||||
_powerSupply[module].ReadPowerSupplyData(out voltage, out current, out voltageSetPoint, out isOn, out faultStatus);
|
_powerSupply[module].ReadPowerSupplyData(out voltage, out current, out voltageSetPoint, out isOn, out faultStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get all the names of modules in the power system
|
||||||
|
/// </summary>
|
||||||
|
public List<string> GetModuleNames()
|
||||||
|
{
|
||||||
|
return _powerSupply.GetPowerSupplyModuleNames();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get all the configuration information for each module
|
||||||
|
/// </summary>
|
||||||
|
public Dictionary<string, Instruments.PowerSupplies.PowerSupplyModuleInfo> GetPowerSupplyModuleInfoDict()
|
||||||
|
{
|
||||||
|
return _powerSupply.GetPowerSupplyModuleInfoDict();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Enable the output of the power supply.
|
/// Enable the output of the power supply.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -76,17 +76,22 @@ namespace Raytheon
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (!powerSystemId.GetType().IsEnum)
|
string powerSystemName;
|
||||||
|
if (powerSystemId.GetType().IsEnum || powerSystemId is string)
|
||||||
{
|
{
|
||||||
throw new ArgumentException($"{nameof(powerSystemId)} must be an enumerated type");
|
powerSystemName = powerSystemId.ToString();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new ArgumentException($"{nameof(powerSystemId)} must be an enumerated or string type");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_powerSystemNameToPowerModuleMeasurementManagerDict.ContainsKey(powerSystemId.ToString()))
|
if (!_powerSystemNameToPowerModuleMeasurementManagerDict.ContainsKey(powerSystemName))
|
||||||
{
|
{
|
||||||
throw new Exception($"Invalid power supply system: {powerSystemId.ToString()}");
|
throw new Exception($"Invalid power supply system: {powerSystemName}");
|
||||||
}
|
}
|
||||||
|
|
||||||
return _powerSystemNameToPowerModuleMeasurementManagerDict[powerSystemId.ToString()];
|
return _powerSystemNameToPowerModuleMeasurementManagerDict[powerSystemName];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,8 +55,8 @@ namespace ProgramLib
|
|||||||
|
|
||||||
private ILogger _logger;
|
private ILogger _logger;
|
||||||
|
|
||||||
private object _fatalErrorMsgFromThreadSyncObj = new object();
|
private object _fatalErrorMsgFromSupportThreadSyncObj = new object();
|
||||||
private string _fatalErrorMsgFromThread;
|
private string _fatalErrorMsgFromSupportThread;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -249,7 +249,7 @@ namespace ProgramLib
|
|||||||
if (!_terminateTestInitiated)
|
if (!_terminateTestInitiated)
|
||||||
{
|
{
|
||||||
// tells teststand there's a exception occurred and give it the error message
|
// tells teststand there's a exception occurred and give it the error message
|
||||||
_testStandSeqContext.SequenceErrorMessage = _fatalErrorMsgFromThread + " ";
|
_testStandSeqContext.SequenceErrorMessage = _fatalErrorMsgFromSupportThread + " ";
|
||||||
_testStandSeqContext.SequenceErrorOccurred = true;
|
_testStandSeqContext.SequenceErrorOccurred = true;
|
||||||
|
|
||||||
// tells TestStand to go to clean up
|
// tells TestStand to go to clean up
|
||||||
@@ -267,13 +267,13 @@ namespace ProgramLib
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name=""></param>
|
/// <param name=""></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
internal void SetFatalErrorMsgFromThread(string errorMsg)
|
internal void SetFatalErrorMsgFromSupportThread(string errorMsg)
|
||||||
{
|
{
|
||||||
lock(_fatalErrorMsgFromThreadSyncObj)
|
lock(_fatalErrorMsgFromSupportThreadSyncObj)
|
||||||
{
|
{
|
||||||
if (String.IsNullOrEmpty(_fatalErrorMsgFromThread))
|
if (String.IsNullOrEmpty(_fatalErrorMsgFromSupportThread))
|
||||||
{
|
{
|
||||||
_fatalErrorMsgFromThread = errorMsg;
|
_fatalErrorMsgFromSupportThread = errorMsg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,6 +81,8 @@ namespace ProgramLib
|
|||||||
|
|
||||||
if (id == Events.FATAL_FAILURE)
|
if (id == Events.FATAL_FAILURE)
|
||||||
{
|
{
|
||||||
|
Program.Instance()._eventManager[EventManager.Events.GLOBAL_QUIT].Set();
|
||||||
|
|
||||||
UutPowerAction uutPowerAction = new UutPowerAction();
|
UutPowerAction uutPowerAction = new UutPowerAction();
|
||||||
uutPowerAction.UutPowerOff();
|
uutPowerAction.UutPowerOff();
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace ProgramLib
|
namespace ProgramLib
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Class to spawn thread to update passthrough data on GUI
|
||||||
|
/// </summary>
|
||||||
internal class PassthroughDataGuiUpdateThread : BasicThread
|
internal class PassthroughDataGuiUpdateThread : BasicThread
|
||||||
{
|
{
|
||||||
private enum Events
|
private enum Events
|
||||||
@@ -46,6 +49,9 @@ namespace ProgramLib
|
|||||||
private MainWindow _mainWindow;
|
private MainWindow _mainWindow;
|
||||||
private PassthroughData _passthroughData = null;
|
private PassthroughData _passthroughData = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor
|
||||||
|
/// </summary>
|
||||||
public PassthroughDataGuiUpdateThread()
|
public PassthroughDataGuiUpdateThread()
|
||||||
{
|
{
|
||||||
_logger = LogManager.GetCurrentClassLogger();
|
_logger = LogManager.GetCurrentClassLogger();
|
||||||
@@ -65,6 +71,11 @@ namespace ProgramLib
|
|||||||
_logger?.Debug($"Entering {this.GetType().Name}::{System.Reflection.MethodBase.GetCurrentMethod().Name}() ...");
|
_logger?.Debug($"Entering {this.GetType().Name}::{System.Reflection.MethodBase.GetCurrentMethod().Name}() ...");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Method that executes on the thread.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name=""></param>
|
||||||
|
/// <returns></returns>
|
||||||
protected override void DoWork()
|
protected override void DoWork()
|
||||||
{
|
{
|
||||||
_logger?.Debug($"{this.GetType().Name}::{System.Reflection.MethodBase.GetCurrentMethod().Name}() is running...");
|
_logger?.Debug($"{this.GetType().Name}::{System.Reflection.MethodBase.GetCurrentMethod().Name}() is running...");
|
||||||
@@ -99,6 +110,11 @@ namespace ProgramLib
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Update GUI with data
|
||||||
|
/// </summary>
|
||||||
|
/// <param name=""></param>
|
||||||
|
/// <returns></returns>
|
||||||
private void UpdatePassthroughDataGui()
|
private void UpdatePassthroughDataGui()
|
||||||
{
|
{
|
||||||
int pollRateMs = 1000;
|
int pollRateMs = 1000;
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace ProgramLib
|
namespace ProgramLib
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Class to spawn thread to update power supply data on GUI
|
||||||
|
/// </summary>
|
||||||
internal class PowerSupplyGuiUpdateThread : BasicThread
|
internal class PowerSupplyGuiUpdateThread : BasicThread
|
||||||
{
|
{
|
||||||
private enum Events
|
private enum Events
|
||||||
@@ -47,6 +50,9 @@ namespace ProgramLib
|
|||||||
|
|
||||||
private Dictionary<string, PowerModuleDataModel> _powerModuleToPowerDataModelDict = new Dictionary<string, PowerModuleDataModel>();
|
private Dictionary<string, PowerModuleDataModel> _powerModuleToPowerDataModelDict = new Dictionary<string, PowerModuleDataModel>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor
|
||||||
|
/// </summary>
|
||||||
public PowerSupplyGuiUpdateThread()
|
public PowerSupplyGuiUpdateThread()
|
||||||
{
|
{
|
||||||
_logger = LogManager.GetCurrentClassLogger();
|
_logger = LogManager.GetCurrentClassLogger();
|
||||||
@@ -67,6 +73,11 @@ namespace ProgramLib
|
|||||||
_logger?.Debug($"Entering {this.GetType().Name}::{System.Reflection.MethodBase.GetCurrentMethod().Name}() ...");
|
_logger?.Debug($"Entering {this.GetType().Name}::{System.Reflection.MethodBase.GetCurrentMethod().Name}() ...");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Method that executes on the thread.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name=""></param>
|
||||||
|
/// <returns></returns>
|
||||||
protected override void DoWork()
|
protected override void DoWork()
|
||||||
{
|
{
|
||||||
_logger?.Debug($"{this.GetType().Name}::{System.Reflection.MethodBase.GetCurrentMethod().Name}() is running...");
|
_logger?.Debug($"{this.GetType().Name}::{System.Reflection.MethodBase.GetCurrentMethod().Name}() is running...");
|
||||||
@@ -101,6 +112,11 @@ namespace ProgramLib
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Update GUI with data
|
||||||
|
/// </summary>
|
||||||
|
/// <param name=""></param>
|
||||||
|
/// <returns></returns>
|
||||||
private void UpdatePowerSupplyGui()
|
private void UpdatePowerSupplyGui()
|
||||||
{
|
{
|
||||||
int pollRateMs = 1000;
|
int pollRateMs = 1000;
|
||||||
|
|||||||
@@ -15,20 +15,17 @@ GOVERNMENT.
|
|||||||
|
|
||||||
UNPUBLISHED WORK - COPYRIGHT RAYTHEON COMPANY.
|
UNPUBLISHED WORK - COPYRIGHT RAYTHEON COMPANY.
|
||||||
-------------------------------------------------------------------------*/
|
-------------------------------------------------------------------------*/
|
||||||
using NLog;
|
|
||||||
using ProgramGui;
|
|
||||||
using ProgramGui.Model;
|
|
||||||
using ProgramGui.ViewModel;
|
|
||||||
using ProgramLib;
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using NLog;
|
||||||
|
|
||||||
namespace ProgramLib
|
namespace ProgramLib
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Class to spawn thread to read power supply data
|
||||||
|
/// </summary>
|
||||||
internal class PowerSupplyReadThread : BasicThread
|
internal class PowerSupplyReadThread : BasicThread
|
||||||
{
|
{
|
||||||
private enum Events
|
private enum Events
|
||||||
@@ -46,7 +43,12 @@ namespace ProgramLib
|
|||||||
|
|
||||||
private string _powerSupplySystemName;
|
private string _powerSupplySystemName;
|
||||||
|
|
||||||
|
private List<string> _powerModuleNameList;
|
||||||
|
Dictionary<string, Raytheon.Instruments.PowerSupplies.PowerSupplyModuleInfo> _powerSupplyModuleInfoDict;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor
|
||||||
|
/// </summary>
|
||||||
public PowerSupplyReadThread(string powerSupplySystemName)
|
public PowerSupplyReadThread(string powerSupplySystemName)
|
||||||
{
|
{
|
||||||
_logger = LogManager.GetCurrentClassLogger();
|
_logger = LogManager.GetCurrentClassLogger();
|
||||||
@@ -60,6 +62,11 @@ namespace ProgramLib
|
|||||||
_logger?.Debug($"Entering {this.GetType().Name}::{System.Reflection.MethodBase.GetCurrentMethod().Name}() ...");
|
_logger?.Debug($"Entering {this.GetType().Name}::{System.Reflection.MethodBase.GetCurrentMethod().Name}() ...");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Method that executes on the thread.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name=""></param>
|
||||||
|
/// <returns></returns>
|
||||||
protected override void DoWork()
|
protected override void DoWork()
|
||||||
{
|
{
|
||||||
_logger?.Debug($"{this.GetType().Name}::{System.Reflection.MethodBase.GetCurrentMethod().Name}() for {_powerSupplySystemName} is running...");
|
_logger?.Debug($"{this.GetType().Name}::{System.Reflection.MethodBase.GetCurrentMethod().Name}() for {_powerSupplySystemName} is running...");
|
||||||
@@ -73,6 +80,9 @@ namespace ProgramLib
|
|||||||
|
|
||||||
EventGroup<Events, EventWaitHandle> eventGroup = new EventGroup<Events, EventWaitHandle>(eventDict);
|
EventGroup<Events, EventWaitHandle> eventGroup = new EventGroup<Events, EventWaitHandle>(eventDict);
|
||||||
|
|
||||||
|
_powerModuleNameList = Program.Instance().GetPowerSupplyMeasurementManager()[_powerSupplySystemName].GetModuleNames();
|
||||||
|
_powerSupplyModuleInfoDict = Program.Instance().GetPowerSupplyMeasurementManager()[_powerSupplySystemName].GetPowerSupplyModuleInfoDict();
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
Events id = eventGroup.WaitAny();
|
Events id = eventGroup.WaitAny();
|
||||||
@@ -94,6 +104,11 @@ namespace ProgramLib
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Read power supply data and check for faults
|
||||||
|
/// </summary>
|
||||||
|
/// <param name=""></param>
|
||||||
|
/// <returns></returns>
|
||||||
private void ReadPowerSupplyData()
|
private void ReadPowerSupplyData()
|
||||||
{
|
{
|
||||||
int pollRateMs = 1000;
|
int pollRateMs = 1000;
|
||||||
@@ -108,15 +123,53 @@ namespace ProgramLib
|
|||||||
|
|
||||||
EventGroup<Events, EventWaitHandle> eventGroup = new EventGroup<Events, EventWaitHandle>(eventDict);
|
EventGroup<Events, EventWaitHandle> eventGroup = new EventGroup<Events, EventWaitHandle>(eventDict);
|
||||||
|
|
||||||
Random rnd = new Random();
|
double voltage;
|
||||||
|
double current;
|
||||||
|
double voltageSetPoint;
|
||||||
|
bool isOn;
|
||||||
|
int faultStatus;
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
Events id = eventGroup.WaitAny(pollRateMs);
|
Events id = eventGroup.WaitAny(pollRateMs);
|
||||||
|
|
||||||
if (id == Events.EVENT_TIMED_OUT)
|
if (id == Events.EVENT_TIMED_OUT)
|
||||||
{
|
{
|
||||||
Thread.Sleep(100);
|
foreach (string moduleName in _powerModuleNameList)
|
||||||
|
{
|
||||||
|
Program.Instance().GetPowerSupplyMeasurementManager()[_powerSupplySystemName].ReadPowerSupplyData(moduleName, out voltage, out current, out voltageSetPoint, out isOn, out faultStatus);
|
||||||
|
|
||||||
|
BitArray statusReg = new BitArray(new int[] { faultStatus });
|
||||||
|
|
||||||
|
bool ovpTriggeredInPowerSupply = statusReg[0];
|
||||||
|
bool ocpTriggeredInPowerSupply = statusReg[1];
|
||||||
|
|
||||||
|
if (!ovpTriggeredInPowerSupply && !ocpTriggeredInPowerSupply)
|
||||||
|
{
|
||||||
|
if (IsCurrentWithinLimits(moduleName, current))
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (IsVoltageWithinLimits(moduleName, voltage))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string errorMsg = String.Empty;
|
||||||
|
|
||||||
|
if (ovpTriggeredInPowerSupply)
|
||||||
|
{
|
||||||
|
errorMsg = moduleName + "'s OVP circuitry has tripped";
|
||||||
|
}
|
||||||
|
else if (ocpTriggeredInPowerSupply)
|
||||||
|
{
|
||||||
|
errorMsg = moduleName + "'s OCP circuitry has tripped";
|
||||||
|
}
|
||||||
|
|
||||||
|
HandleOutOfToleranceCondition(errorMsg);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
@@ -130,5 +183,59 @@ namespace ProgramLib
|
|||||||
_logger?.Debug($"{this.GetType().Name}::{System.Reflection.MethodBase.GetCurrentMethod().Name}() for {_powerSupplySystemName} is exiting...");
|
_logger?.Debug($"{this.GetType().Name}::{System.Reflection.MethodBase.GetCurrentMethod().Name}() for {_powerSupplySystemName} is exiting...");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check for current's upper limit
|
||||||
|
/// </summary>
|
||||||
|
/// <param name=""></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private bool IsCurrentWithinLimits(string moduleName, double current)
|
||||||
|
{
|
||||||
|
bool outOfLimits = false;
|
||||||
|
Raytheon.Instruments.PowerSupplies.PowerSupplyModuleInfo powerSupplyModuleInfo = _powerSupplyModuleInfoDict[moduleName];
|
||||||
|
|
||||||
|
if ((current < powerSupplyModuleInfo.currentLowerLimit_ || current > powerSupplyModuleInfo.currentUpperLimit_) && powerSupplyModuleInfo.isOn_)
|
||||||
|
{
|
||||||
|
outOfLimits = true;
|
||||||
|
string errorMsg = moduleName + "'s current is out of limits (" + powerSupplyModuleInfo.currentLowerLimit_.ToString("0.00") + "," + powerSupplyModuleInfo.currentUpperLimit_.ToString("0.00") + "). Current reading: " + current.ToString("0.00");
|
||||||
|
HandleOutOfToleranceCondition(errorMsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
return outOfLimits;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check for voltage's limit exceedence
|
||||||
|
/// </summary>
|
||||||
|
/// <param name=""></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private bool IsVoltageWithinLimits(string moduleName, double voltage)
|
||||||
|
{
|
||||||
|
bool outOfLimits = false;
|
||||||
|
Raytheon.Instruments.PowerSupplies.PowerSupplyModuleInfo powerSupplyModuleInfo = _powerSupplyModuleInfoDict[moduleName];
|
||||||
|
|
||||||
|
if ((voltage < powerSupplyModuleInfo.voltageLowerLimit_ || voltage > powerSupplyModuleInfo.voltageUpperLimit_) && powerSupplyModuleInfo.isOn_)
|
||||||
|
{
|
||||||
|
outOfLimits = true;
|
||||||
|
string errorMsg = moduleName + "'s voltage is out of limits (" + powerSupplyModuleInfo.voltageLowerLimit_.ToString("0.00") + "," + powerSupplyModuleInfo.voltageUpperLimit_.ToString("0.00") + "). Voltage reading: " + voltage.ToString("0.00");
|
||||||
|
HandleOutOfToleranceCondition(errorMsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
return outOfLimits;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Handle power fault conditions
|
||||||
|
/// </summary>
|
||||||
|
/// <param name=""></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private void HandleOutOfToleranceCondition(string errorMsg)
|
||||||
|
{
|
||||||
|
if (!Program.Instance()._eventManager[EventManager.Events.FATAL_FAILURE].WaitOne(0))
|
||||||
|
{
|
||||||
|
Program.Instance().SetFatalErrorMsgFromSupportThread(errorMsg);
|
||||||
|
Program.Instance()._eventManager[EventManager.Events.FATAL_FAILURE].Set();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user