Files
AiQ_GUI/Camera/LED.cs
Bradley Born 36f9639baa Dynamic labels & Changed color to light green
- Filesystem size
- Flexi version
- Flexi Revision
- MAC
- Timestamp
- Temperature
- ZoomLock
- Serial and model Number
- Licenses
- CPU usage
2025-12-23 13:01:15 +00:00

65 lines
2.7 KiB
C#

namespace AiQ_GUI
{
internal class LED
{
// Checks the LED voltages and currents against expected values, displaying results in the provided label
public static void CheckLEDs(List<double> VorI, Label lblVorI, string VormA, double ExpVorI)
{
try
{
VorI.Sort(); // Sort the list from lowest to highest to prepare for finding the median
double medianVorI = (VorI[2] + VorI[3]) / 2.0; // Will always be even (6) number of channels therefore average the two middle elements
string medianText = $"Median: {medianVorI}{VormA}";
// Define the 20% threshold ranges
double LowerThreshold = ExpVorI * 0.8;
double UpperThreshold = ExpVorI * 1.2;
// Check median is within 20% of the expected value
if (medianVorI < LowerThreshold || medianVorI > UpperThreshold)
{
medianText += $" (away from expected {ExpVorI}{VormA})";
lblVorI.Invoke(() =>
{
lblVorI.Text = lblVorI.Text.TrimEnd('=', ' ') + " = " + medianText;
lblVorI.ForeColor = Color.Red;
});
return;
}
List<string> outOfRangeVoltageChannels = []; // List to store out-of-range channels
// Check each voltage/current channel is within 20% of expected
for (int i = 0; i < 6; i++)
{
if (VorI[i] < LowerThreshold || VorI[i] > UpperThreshold)
outOfRangeVoltageChannels.Add($"Ch{i + 1}");
}
// If there are no single channels outside the threshold then green, else red
if (outOfRangeVoltageChannels.Count == 0)
{
lblVorI.Invoke(() =>
{
lblVorI.Text = lblVorI.Text.TrimEnd('=', ' ') + " = " + medianText;
lblVorI.ForeColor = Color.LimeGreen;
});
}
else if (outOfRangeVoltageChannels.Count != 0)
{
string errorText = medianText + " (error on " + string.Join(", ", outOfRangeVoltageChannels) + ")";
lblVorI.Invoke(() =>
{
lblVorI.Text = lblVorI.Text.TrimEnd('=', ' ') + " = " + errorText;
lblVorI.ForeColor = Color.Red;
});
}
}
catch (Exception ex)
{
MainForm.Instance.AddToActionsList($"Error checking LEDs: {ex.Message}", Level.ERROR);
}
}
}
}