Monitor power supply data for fault conditions

This commit is contained in:
Duc
2025-01-04 18:41:54 -07:00
parent 7e2a821337
commit b38765789d
14 changed files with 242 additions and 70 deletions

View File

@@ -51,15 +51,15 @@ namespace Raytheon.Instruments.PowerSupplies
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);
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();
_groupedModules = groupedModules.Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries).ToList();
if (_groupedModules.Count() > 1)
{
powerModules.Clear();
PowerModules.Clear();
// 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
@@ -74,9 +74,9 @@ namespace Raytheon.Instruments.PowerSupplies
double minCurrent = 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);
Double.TryParse(config.ReadValue(moduleName, PowerSupplyConfigIni.OCP.ToString(), Raytheon.Common.GeneralConstants.DefaultConfigValue), out ocp);
@@ -109,8 +109,7 @@ namespace Raytheon.Instruments.PowerSupplies
/// <returns></returns>
public override bool FrontPanelEnabled
{
get { SemObj?.Release(); throw new NotImplementedException(); }
set { _frontPanelEnabled = value; SemObj?.Release(); }
set {_frontPanelEnabled = value; SemObj?.Release(); }
}
/// <summary>
@@ -216,7 +215,7 @@ namespace Raytheon.Instruments.PowerSupplies
lock (SyncObj)
{
if (PowerModuleInfoDict[ActivePowerModule].isOn_)
val = (PowerModuleInfoDict[ActivePowerModule].lowerCurrentLimit_ + PowerModuleInfoDict[ActivePowerModule].upperCurrentLimit_) / 2.0;
val = (PowerModuleInfoDict[ActivePowerModule].currentLowerLimit_ + PowerModuleInfoDict[ActivePowerModule].currentUpperLimit_) / 2.0;
}
return val;

View File

@@ -102,15 +102,21 @@ namespace Raytheon.Instruments.PowerSupplies
{
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();
if (powerDeviceId != null)
_powerSupplyModule.SetActivePowerModule(powerDeviceId.ToString());
_powerSupplyModule.SetActivePowerModule(powerDeviceName);
return _powerSupplyModule;
}