Dynamic labels & Changed color to light green

- Filesystem size
- Flexi version
- Flexi Revision
- MAC
- Timestamp
- Temperature
- ZoomLock
- Serial and model Number
- Licenses
- CPU usage
This commit is contained in:
2025-12-23 13:01:15 +00:00
parent 872be2e105
commit 36f9639baa
7 changed files with 182 additions and 419 deletions

View File

@@ -2,9 +2,8 @@
using AiQ_GUI.AiQ_Tests;
public class AiQTests
{
public static async void AiQPreTest()
{
public static async Task AiQPreTest()
{
if (!await CameraModules.SetZoomLockOn(MainForm.Instance.CamOnTest.IP))
Helper.RestartApp();
@@ -60,9 +59,8 @@ public class AiQTests
}
public static async void AiQFinalTest()
public static async Task AiQFinalTest()
{
if (MainForm.Instance.LblTestTubePing.Text == "❌") // No test tube so test like an IQ
{
string LEDreply = await FlexiAPI.APIHTTPLED(MainForm.Instance.CamOnTest.IP, LEDPOWER.SAFE); // Set LED's to safe (0x0E) to help with eye safety and trim check.
@@ -70,11 +68,9 @@ public class AiQTests
if (!LEDreply.Contains("Power levels set successfully"))
MainForm.Instance.AddToActionsList($"LED level could not be set: {LEDreply}", Level.ERROR);
}
else if (!await TestTube.CheckInTestTube(MainForm.Instance.CamOnTest.IP)) // Sets LED's to medium power after checking it is in the test tube
await MainForm.Instance.TestFailed(MainForm.Instance.BtnStartTest, "Camera not in test tube");
//else if (!await TestTube.CheckInTestTube(MainForm.Instance.CamOnTest.IP)) // Sets LED's to medium power after checking it is in the test tube
// await MainForm.Instance.TestFailed(MainForm.Instance.BtnStartTest, "Camera not in test tube");
Task VisCheck = Helper.VisualCheck(MainForm.Instance.BtnStartTest);
if (!await CameraModules.ZoomModules("1F40", MainForm.Instance.CamOnTest.IP)) // Zoom to 8000 (1F40h) at the same time.
await MainForm.Instance.TestFailed(MainForm.Instance.BtnStartTest, "Could not zoom modules to 8000");

View File

@@ -22,90 +22,77 @@ namespace AiQ_GUI.AiQ_Tests
{
DiagsAPI = await FlexiAPI.GetDiagnostics(MainForm.Instance.CamOnTest.IP); // Diagnostic API request
MainForm.Instance.lblFlexiVer.Text += DiagsAPI.FlexiVersion; // Check Flexi Version
// Check Flexi Version
string flexiVerText = "Flexi Version = " + DiagsAPI.FlexiVersion;
bool flexiVerGreen = DiagsAPI.FlexiVersion == UniversalData.ExpFlexiVer;
if (!flexiVerGreen)
flexiVerText += " Expected = " + UniversalData.ExpFlexiVer;
MainForm.Instance.AddLabelToPanel(flexiVerText, !flexiVerGreen);
if (DiagsAPI.FlexiVersion == UniversalData.ExpFlexiVer)
{
MainForm.Instance.lblFlexiVer.ForeColor = Color.LightGreen;
}
else
{
MainForm.Instance.lblFlexiVer.Text += " Expected = " + UniversalData.ExpFlexiVer;
MainForm.Instance.lblFlexiVer.ForeColor = Color.Red;
}
MainForm.Instance.lblFlexiRev.Text += DiagsAPI.FlexiRevision; // Check Flexi Revision
if (DiagsAPI.FlexiRevision == UniversalData.ExpFlexiRev)
{
MainForm.Instance.lblFlexiRev.ForeColor = Color.LightGreen;
}
else
{
MainForm.Instance.lblFlexiRev.Text += " Expected = " + UniversalData.ExpFlexiRev;
MainForm.Instance.lblFlexiRev.ForeColor = Color.Red;
}
MainForm.Instance.lblMac.Text += DiagsAPI.MAC; // Display MAC
// Check Flexi Revision
string flexiRevText = "Flexi Revision = " + DiagsAPI.FlexiRevision;
bool flexiRevGreen = DiagsAPI.FlexiRevision == UniversalData.ExpFlexiRev;
if (!flexiRevGreen)
flexiRevText += " Expected = " + UniversalData.ExpFlexiRev;
MainForm.Instance.AddLabelToPanel(flexiRevText, !flexiRevGreen);
// Display MAC
string macText = "MAC = " + DiagsAPI.MAC;
bool macIsRed = false;
if (RegexCache.MACRegexNVIDIA().IsMatch(DiagsAPI.MAC)) // Checks it is in the right format and is a NVIDIA registered MAC address
{
MainForm.Instance.lblMac.ForeColor = Color.LightGreen;
// Valid NVIDIA MAC
}
else if (RegexCache.MACRegex().IsMatch(DiagsAPI.MAC)) // Is a valid MAC, but not NVIDIA
{
MainForm.Instance.lblMac.ForeColor = Color.Red;
macIsRed = true;
MainForm.Instance.AddToActionsList($"{DiagsAPI.MAC} not recognised as NVIDIA MAC address", Level.ERROR);
}
else
{
MainForm.Instance.lblMac.ForeColor = Color.Red;
macIsRed = true;
MainForm.Instance.AddToActionsList($"{DiagsAPI.MAC} not recognised as a MAC address", Level.ERROR);
}
MainForm.Instance.AddLabelToPanel(macText, macIsRed);
// Check timestamp
DateTime dateTime = new(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
dateTime = dateTime.AddSeconds(DiagsAPI.timeStamp).ToLocalTime();
MainForm.Instance.lbltimestamp.Text += dateTime;
long timediff = DateTimeOffset.UtcNow.ToUnixTimeSeconds() - DiagsAPI.timeStamp;
string timestampText = "Timestamp = " + dateTime;
bool timestampIsRed = false;
if (timediff > 10) // Over 10 seconds ago
{
MainForm.Instance.lbltimestamp.Text += $" Time behind by {timediff}s";
MainForm.Instance.lbltimestamp.ForeColor = Color.Red;
timestampText += $" Time behind by {timediff}s";
timestampIsRed = true;
}
else if (timediff < 0) // Time is in the future.
{
MainForm.Instance.lbltimestamp.Text += $" Time is in the future by {Math.Abs(timediff)}s";
MainForm.Instance.lbltimestamp.ForeColor = Color.Red;
timestampText += $" Time is in the future by {Math.Abs(timediff)}s";
timestampIsRed = true;
}
else
MainForm.Instance.lbltimestamp.ForeColor = Color.LightGreen;
MainForm.Instance.AddLabelToPanel(timestampText, timestampIsRed);
MainForm.Instance.lblTemp.Text += DiagsAPI.IntTemperature + "°C"; // Diagnostic API request
if (DiagsAPI.IntTemperature > 20 && DiagsAPI.IntTemperature < 70)
MainForm.Instance.lblTemp.ForeColor = Color.LightGreen;
else
MainForm.Instance.lblTemp.ForeColor = Color.Red;
MainForm.Instance.lblZoomLock.Text += DiagsAPI.zoomLock;
// Check Temperature
string tempText = "Temperature = " + DiagsAPI.IntTemperature + "°C";
bool tempIsRed = DiagsAPI.IntTemperature <= 20 || DiagsAPI.IntTemperature >= 70;
MainForm.Instance.AddLabelToPanel(tempText, tempIsRed);
// Check Zoom Lock
string zoomLockText = "Zoom Lock = " + DiagsAPI.zoomLock;
bool zoomLockIsRed = false;
if (DiagsAPI.zoomLock == true)
{
if (DiagsAPI.IRmodule.zoom == DiagsAPI.OVmodule.zoom) // Checks if zoomlock is doing what is says it should
if (DiagsAPI.IRmodule.zoom != DiagsAPI.OVmodule.zoom) // Checks if zoomlock is doing what is says it should
{
MainForm.Instance.lblZoomLock.ForeColor = Color.LightGreen;
}
else
{
MainForm.Instance.lblZoomLock.Text += $" Zoomlock on but {DiagsAPI.IRmodule.zoom}≠{DiagsAPI.OVmodule.zoom}";
MainForm.Instance.lblZoomLock.ForeColor = Color.Red;
zoomLockText += $" Zoomlock on but {DiagsAPI.IRmodule.zoom}≠{DiagsAPI.OVmodule.zoom}";
zoomLockIsRed = true;
}
}
else
MainForm.Instance.lblZoomLock.ForeColor = Color.Red;
zoomLockIsRed = true;
MainForm.Instance.AddLabelToPanel(zoomLockText, zoomLockIsRed);
}
public static async Task CheckDiagsAPIPt2() // Parts only done on final test
@@ -115,17 +102,19 @@ namespace AiQ_GUI.AiQ_Tests
try // In case serial or model are blank
{
MainForm.Instance.lblModel.Text += DiagsAPI.modelNumber; // Update labels with serial and model
MainForm.Instance.lblSerial.Text += DiagsAPI.serialNumber;
string serialText = "Serial Number = " + DiagsAPI.serialNumber;
bool serialIsRed = !RegexCache.SerialRegex().IsMatch(DiagsAPI.serialNumber);
MainForm.Instance.AddLabelToPanel(serialText, serialIsRed);
string modelText = "Model Number = " + DiagsAPI.modelNumber;
bool modelIsRed = !RegexCache.ModelRegex().IsMatch(DiagsAPI.modelNumber);
MainForm.Instance.AddLabelToPanel(modelText, modelIsRed);
if (RegexCache.SerialRegex().IsMatch(DiagsAPI.serialNumber) && RegexCache.ModelRegex().IsMatch(DiagsAPI.modelNumber))
{
MainForm.Instance.lblSerial.ForeColor = MainForm.Instance.lblModel.ForeColor = Color.LightGreen; // Set both to green
if (DiagsAPI.modelNumber != MainForm.Instance.CamOnTest.Model)
{
MainForm.Instance.AddToActionsList("Model number in camera doesn't match what has been selected", Level.WARNING);
MainForm.Instance.lblModel.ForeColor = Color.Red;
}
else if (!GoogleAPI.CheckWIP(DiagsAPI.serialNumber, CameraAccessInfo.SpreadsheetID)) // Check WIP column in serial number register, if not ticked then RMA
{
@@ -153,7 +142,10 @@ namespace AiQ_GUI.AiQ_Tests
MainForm.Instance.AddToActionsList("Camera has not been given a valid serial and model number, suggest you run through pre test again and check serial number register for any issues.", Level.ERROR);
}
}
catch { }
catch (Exception ex)
{
MainForm.Instance.AddToActionsList($"Error in CheckDiagsAPIPt2 serial/model: {ex.Message}", Level.ERROR);
}
// Check licenses
List<string> licensesOnCam = []; // Temporary list for licenses on camera
@@ -170,73 +162,59 @@ namespace AiQ_GUI.AiQ_Tests
licensesOnCam.Add("Audit");
if (DiagsAPI.licenses.stream)
licensesOnCam.Add("Stream");
if (MainForm.Instance.sshData.tailscale)
if (MainForm.Instance.sshData != null && MainForm.Instance.sshData.tailscale)
licensesOnCam.Add("Tailscale");
if (licensesOnCam.Count == 0) // No licenses found
MainForm.Instance.lblLic.Text += "None";
else if (licensesOnCam.Count != 0) // Join them comma and space seperated for displaying
MainForm.Instance.lblLic.Text += string.Join(", ", licensesOnCam);
MainForm.Instance.lblLic.ForeColor = Color.LightGreen;
string licText = "Licenses = " + (licensesOnCam.Count == 0 ? "None" : string.Join(", ", licensesOnCam));
MainForm.Instance.AddLabelToPanel(licText, false);
double CPUround = Math.Round(DiagsAPI.CPUusage); // Check CPU usage isn't near max
MainForm.Instance.LblCPUusage.Text += CPUround + "%";
if (CPUround <= 50)
{
MainForm.Instance.LblCPUusage.Text += " Unexpectedly low CPU usage";
MainForm.Instance.LblCPUusage.ForeColor = Color.Red;
}
else if (CPUround >= 98)
{
MainForm.Instance.LblCPUusage.Text += " Unexpectedly high CPU usage";
MainForm.Instance.LblCPUusage.ForeColor = Color.Red;
}
else
{
MainForm.Instance.LblCPUusage.ForeColor = Color.LightGreen;
}
string cpuText = "CPU Usage = " + CPUround + "%";
bool cpuIsRed = CPUround <= 50 || CPUround >= 98;
MainForm.Instance.AddLabelToPanel(cpuText, cpuIsRed);
// Check Vaxtor if it doesn't need or have license OR has and wants one then pass
bool vaxtorIsRed = false;
string vaxtorText = "Vaxtor Key ID = " + DiagsAPI.licenses.raptorKeyID;
if (CameraAccessInfo.VaxtorLic == false && DiagsAPI.licenses.raptorKeyID == "Not Licensed" || CameraAccessInfo.VaxtorLic == true && DiagsAPI.licenses.raptorKeyID != "Not Licensed")
{
MainForm.Instance.lblVaxtor.Text += DiagsAPI.licenses.raptorKeyID;
MainForm.Instance.lblVaxtor.ForeColor = Color.LightGreen;
// OK - passes condition
vaxtorIsRed = false;
}
else if (await MainForm.Instance.DisplayQuestion("Was this camera licensed manually?"))
{
string ProdcutKeyID = await MainForm.Instance.DisplayInput("What is the Key ID?", false);
if (RegexCache.VaxtorRegex().IsMatch(ProdcutKeyID)) // Means they chose the 'I don't know' option or isn't valid Key ID
if (!RegexCache.VaxtorRegex().IsMatch(ProdcutKeyID)) // Means they chose valid Key ID
{
DiagsAPI.licenses.raptorKeyID = MainForm.Instance.TxBxProductKey.Text;
vaxtorText = "Vaxtor Key ID = " + DiagsAPI.licenses.raptorKeyID;
vaxtorIsRed = false;
}
else
{
Access.Stats("Please Get A Valid Vaxtor Product Key Before Continuing", MainForm.Instance.CamOnTest.Model);
await MainForm.Instance.TestFailed(MainForm.Instance.BtnStartTest, "Please get a valid Vaxtor Product Key before continuing");
vaxtorIsRed = true;
}
DiagsAPI.licenses.raptorKeyID = MainForm.Instance.TxBxProductKey.Text;
MainForm.Instance.lblVaxtor.Text += DiagsAPI.licenses.raptorKeyID;
MainForm.Instance.lblVaxtor.ForeColor = Color.LightGreen;
}
else // Should have license but doesn't OR shouldn't have but does + any other unforseen circumstance then fail
else // Should have license but doesn't OR shouldn't have but does + any other unforeseen circumstance then fail
{
MainForm.Instance.lblVaxtor.Text += DiagsAPI.licenses.raptorKeyID;
MainForm.Instance.lblVaxtor.ForeColor = Color.Red;
vaxtorIsRed = true;
}
MainForm.Instance.AddLabelToPanel(vaxtorText, vaxtorIsRed);
// Check trim is within 10% both horizontally and vertically, from auto set done earlier in the test
MainForm.Instance.lblTrim.Text += "H: " + DiagsAPI.trim[0] + " V: " + DiagsAPI.trim[1];
string trimText = "Trim = H: " + DiagsAPI.trim[0] + " V: " + DiagsAPI.trim[1];
// Offset accounted for in the SetTrim function, so value should be close to 0,0.
const int HMax = 96; // 5% of 1920 each way = ±96
const int VMax = 54; // 5% of 1080 each way = ±54
if (Math.Abs(DiagsAPI.trim[0]) <= HMax && Math.Abs(DiagsAPI.trim[1]) <= VMax)
MainForm.Instance.lblTrim.ForeColor = Color.LightGreen;
else
MainForm.Instance.lblTrim.ForeColor = Color.Red;
bool trimIsRed = Math.Abs(DiagsAPI.trim[0]) > HMax || Math.Abs(DiagsAPI.trim[1]) > VMax;
MainForm.Instance.AddLabelToPanel(trimText, trimIsRed);
}
}
}