Create threads to update GUI

This commit is contained in:
Duc
2025-01-04 08:33:01 -07:00
parent 1d8f6e4c96
commit 7e2a821337
9 changed files with 385 additions and 105 deletions

View File

@@ -70,17 +70,22 @@ namespace ProgramLib
{
_logger?.Debug($"Entering {this.GetType().Name}::{System.Reflection.MethodBase.GetCurrentMethod().Name}() method...");
Program.Instance().GetPowerSupplyMeasurementManager()[PowerSupplyConstants.POWER_DEVICE.STE_POWER_SUPPLY_SYSTEM].OutputDisable(ProgramLib.PowerSupplyConstants.POWER_DEVICE.STE_PVM_5V);
// enable front panel
Program.Instance().GetPowerSupplyMeasurementManager()[PowerSupplyConstants.POWER_DEVICE.STE_POWER_SUPPLY_SYSTEM].FrontPanelEnabled = true;
// signal to PowerSupplyReadThread to stop monitoring power
Program.Instance()._eventManager[EventManager.Events.UUT_POWER_OFF].Set();
ProgramLib.Program.Instance().GetGuiManager()[ProgramGuiManager.WINDOWS.MAIN].Dispatcher.Invoke((Action)delegate
if (Program.Instance()._isUutPwrOn)
{
ProgramLib.Program.Instance().GetGuiManager()[ProgramGuiManager.WINDOWS.MAIN].Hide();
});
Program.Instance().GetPowerSupplyMeasurementManager()[PowerSupplyConstants.POWER_DEVICE.STE_POWER_SUPPLY_SYSTEM].OutputDisable(ProgramLib.PowerSupplyConstants.POWER_DEVICE.STE_PVM_5V);
// enable front panel
Program.Instance().GetPowerSupplyMeasurementManager()[PowerSupplyConstants.POWER_DEVICE.STE_POWER_SUPPLY_SYSTEM].FrontPanelEnabled = true;
ProgramLib.Program.Instance().GetGuiManager()[ProgramGuiManager.WINDOWS.MAIN].Dispatcher.Invoke((Action)delegate
{
ProgramLib.Program.Instance().GetGuiManager()[ProgramGuiManager.WINDOWS.MAIN].Hide();
});
Program.Instance()._eventManager[EventManager.Events.UUT_POWER_ON].Reset();
Program.Instance()._eventManager[EventManager.Events.UUT_POWER_OFF].Set();
Program.Instance()._isUutPwrOn = false;
}
}
}
catch (Exception)
@@ -102,9 +107,7 @@ namespace ProgramLib
{
_logger?.Debug($"Entering {this.GetType().Name}::{System.Reflection.MethodBase.GetCurrentMethod().Name}() method...");
Program.Instance().GetPowerSupplyMeasurementManager()[PowerSupplyConstants.POWER_DEVICE.STE_POWER_SUPPLY_SYSTEM].ReadPowerSupplyData(ProgramLib.PowerSupplyConstants.POWER_DEVICE.STE_PVM_5V, out double voltage, out double current, out double voltageSetPoint, out bool isOn, out int faultStatus);
if (!isOn)
if (!Program.Instance()._isUutPwrOn)
{
Task.Factory.StartNew(() => PerformSttoTask());
ProgramLib.Program.Instance().GetGuiManager()[ProgramGuiManager.WINDOWS.IMPEDANCE_CHECK].Dispatcher.Invoke((Action)delegate
@@ -126,14 +129,20 @@ namespace ProgramLib
// disable front panel
Program.Instance().GetPowerSupplyMeasurementManager()[PowerSupplyConstants.POWER_DEVICE.STE_POWER_SUPPLY_SYSTEM].FrontPanelEnabled = false;
// signal to PowerSupplyReadThread to start monitoring power
Program.Instance()._eventManager[EventManager.Events.UUT_POWER_OFF].Reset();
Program.Instance()._eventManager[EventManager.Events.UUT_POWER_ON].Set();
Program.Instance()._isUutPwrOn = true;
}
else
{
throw new Exception(fatalErrorMsg);
}
}
else
{
throw new Exception("UUT power is already on.");
}
}
}
catch (Exception)