Update GUI with power supply's voltage and current readings
This commit is contained in:
@@ -137,6 +137,7 @@ namespace ProgramLib
|
||||
if (id == Events.EVENT_TIMED_OUT)
|
||||
{
|
||||
rnd = new Random();
|
||||
_mainWindow._mainWindowViewModel.UutPowerLedImagePath = _mainWindow._mainWindowViewModel._imageToResourcePathDict[MainWindowViewModel.Images.LED_OFF];
|
||||
|
||||
float num = 70.0f + GenerateRandomFraction();
|
||||
_passthroughData.SetValue(PassthroughData.Variables.VAR1, num.ToString("0.00"));
|
||||
@@ -151,6 +152,7 @@ namespace ProgramLib
|
||||
num = 50.0f + GenerateRandomFraction();
|
||||
_passthroughData.SetValue(PassthroughData.Variables.VAR4, num.ToString("0.00"));
|
||||
Thread.Sleep(100);
|
||||
_mainWindow._mainWindowViewModel.UutPowerLedImagePath = _mainWindow._mainWindowViewModel._imageToResourcePathDict[MainWindowViewModel.Images.LED_ON];
|
||||
num = 60.0f + GenerateRandomFraction();
|
||||
_passthroughData.SetValue(PassthroughData.Variables.VAR5, num.ToString("0.00"));
|
||||
Thread.Sleep(200);
|
||||
|
||||
@@ -151,6 +151,8 @@ namespace ProgramLib
|
||||
|
||||
if (IsVoltageWithinLimits(moduleName, voltage))
|
||||
break;
|
||||
|
||||
Program.Instance()._powerSupplySharedData.SetData(moduleName, voltage, current, _powerSupplyModuleInfoDict[moduleName]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace ProgramLib
|
||||
/// <summary>
|
||||
/// Class to spawn thread to update power supply data on GUI
|
||||
/// </summary>
|
||||
internal class PowerSupplyGuiUpdateThread : BasicThread
|
||||
internal class PowerSupplyUpdateThread : BasicThread
|
||||
{
|
||||
private enum Events
|
||||
{
|
||||
@@ -53,7 +53,7 @@ namespace ProgramLib
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
public PowerSupplyGuiUpdateThread()
|
||||
public PowerSupplyUpdateThread()
|
||||
{
|
||||
_logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace ProgramLib
|
||||
});
|
||||
}
|
||||
|
||||
~PowerSupplyGuiUpdateThread()
|
||||
~PowerSupplyUpdateThread()
|
||||
{
|
||||
_logger?.Debug($"Entering {this.GetType().Name}::{System.Reflection.MethodBase.GetCurrentMethod().Name}() ...");
|
||||
}
|
||||
@@ -97,7 +97,7 @@ namespace ProgramLib
|
||||
|
||||
if (id == Events.UUT_POWER_ON)
|
||||
{
|
||||
UpdatePowerSupplyGui();
|
||||
UpdatePowerSupplyData();
|
||||
}
|
||||
else
|
||||
break;
|
||||
@@ -113,11 +113,11 @@ namespace ProgramLib
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update GUI with data
|
||||
/// Log and update GUI with power supply data
|
||||
/// </summary>
|
||||
/// <param name=""></param>
|
||||
/// <returns></returns>
|
||||
private void UpdatePowerSupplyGui()
|
||||
private void UpdatePowerSupplyData()
|
||||
{
|
||||
int pollRateMs = 1000;
|
||||
_logger?.Debug($"{this.GetType().Name}::{System.Reflection.MethodBase.GetCurrentMethod().Name}() is running...");
|
||||
@@ -138,24 +138,18 @@ namespace ProgramLib
|
||||
|
||||
if (id == Events.EVENT_TIMED_OUT)
|
||||
{
|
||||
rnd = new Random();
|
||||
PowerSupplyData data = Program.Instance()._powerSupplySharedData.GetData(PowerSupplyConstants.POWER_DEVICE.STE_PVM_5V.ToString());
|
||||
|
||||
_mainWindow._mainWindowViewModel.UutPowerLedImagePath = _mainWindow._mainWindowViewModel._imageToResourcePathDict[MainWindowViewModel.Images.LED_OFF];
|
||||
float num = 20.0f + GenerateRandomFraction();
|
||||
_powerModuleToPowerDataModelDict["UUT_P20V"].ActualVoltage = num.ToString("0.00");
|
||||
_powerModuleToPowerDataModelDict["UUT_P20V"].ExpectedVoltage = "20.0";
|
||||
Thread.Sleep(100);
|
||||
num = 1.0f + GenerateRandomFraction();
|
||||
_powerModuleToPowerDataModelDict["UUT_P20V"].ActualCurrent = num.ToString("0.00");
|
||||
Thread.Sleep(100);
|
||||
num = 20.0f + GenerateRandomFraction();
|
||||
_powerModuleToPowerDataModelDict["UUT_N20V"].ActualVoltage = num.ToString("0.00");
|
||||
_powerModuleToPowerDataModelDict["UUT_N20V"].ExpectedVoltage = "20.0";
|
||||
Thread.Sleep(200);
|
||||
_mainWindow._mainWindowViewModel.UutPowerLedImagePath = _mainWindow._mainWindowViewModel._imageToResourcePathDict[MainWindowViewModel.Images.LED_ON];
|
||||
if (data._initialized)
|
||||
{
|
||||
_powerModuleToPowerDataModelDict["UUT_P20V"].ActualVoltage = data._voltage.ToString("0.00");
|
||||
_powerModuleToPowerDataModelDict["UUT_P20V"].ExpectedVoltage = data._powerSupplyModuleInfo.voltageSetpoint_.ToString("0.00");
|
||||
_powerModuleToPowerDataModelDict["UUT_P20V"].ActualCurrent = data._current.ToString("0.00");
|
||||
|
||||
num = 5.0f + GenerateRandomFraction();
|
||||
_powerModuleToPowerDataModelDict["UUT_N20V"].ActualCurrent = num.ToString("0.00");
|
||||
_powerModuleToPowerDataModelDict["UUT_N20V"].ActualVoltage = data._voltage.ToString("0.00");
|
||||
_powerModuleToPowerDataModelDict["UUT_N20V"].ExpectedVoltage = data._powerSupplyModuleInfo.voltageSetpoint_.ToString("0.00");
|
||||
_powerModuleToPowerDataModelDict["UUT_N20V"].ActualCurrent = data._current.ToString("0.00");
|
||||
}
|
||||
}
|
||||
else
|
||||
break;
|
||||
@@ -168,21 +162,5 @@ namespace ProgramLib
|
||||
|
||||
_logger?.Debug($"{this.GetType().Name}::{System.Reflection.MethodBase.GetCurrentMethod().Name}() is exiting...");
|
||||
}
|
||||
|
||||
static float GenerateRandomFraction()
|
||||
{
|
||||
Random rnd = new Random();
|
||||
int randNum = 0;
|
||||
const int minimum = 1;
|
||||
|
||||
randNum = rnd.Next(20);
|
||||
|
||||
if (randNum <= minimum)
|
||||
{
|
||||
randNum += minimum;
|
||||
}
|
||||
|
||||
return (float)(1.0 / (float)randNum);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user