• Camera/LED.cs

• Added null-checks so labels are created dynamically when lblVorI is null (uses MainForm.Instance.AddLabelToPanel).
• Camera/CameraModules.cs
• Added null-label handling to create dynamic module labels with the correct content (OK or the error message).
• AiQ_GUI.cs
• Increased dynamic label width in MakeNewLabel from 220 → 700 to avoid truncated messages.
• Succesfully ran through a pre-test with dynamic labels
This commit is contained in:
2026-01-05 12:35:28 +00:00
parent 36f9639baa
commit 693da58fcb
7 changed files with 115 additions and 68 deletions

View File

@@ -186,18 +186,15 @@ namespace AiQ_GUI.AiQ_Tests
{ {
string ProdcutKeyID = await MainForm.Instance.DisplayInput("What is the Key ID?", false); string ProdcutKeyID = await MainForm.Instance.DisplayInput("What is the Key ID?", false);
if (!RegexCache.VaxtorRegex().IsMatch(ProdcutKeyID)) // Means they chose valid Key ID if (RegexCache.VaxtorRegex().IsMatch(ProdcutKeyID)) // 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); 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"); 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;
vaxtorText = "Vaxtor Key ID = " + DiagsAPI.licenses.raptorKeyID;
vaxtorIsRed = false;
} }
else // Should have license but doesn't OR shouldn't have but does + any other unforeseen circumstance then fail else // Should have license but doesn't OR shouldn't have but does + any other unforeseen circumstance then fail
{ {

4
AiQ_GUI.Designer.cs generated
View File

@@ -712,7 +712,6 @@ namespace AiQ_GUI
PnlQuestion.Controls.Add(BtnNo); PnlQuestion.Controls.Add(BtnNo);
PnlQuestion.Controls.Add(BtnYes); PnlQuestion.Controls.Add(BtnYes);
PnlQuestion.Controls.Add(LblQuestion); PnlQuestion.Controls.Add(LblQuestion);
PnlQuestion.Controls.Add(PnlInputValue);
PnlQuestion.Location = new Point(251, 14); PnlQuestion.Location = new Point(251, 14);
PnlQuestion.Margin = new Padding(4, 3, 4, 3); PnlQuestion.Margin = new Padding(4, 3, 4, 3);
PnlQuestion.Name = "PnlQuestion"; PnlQuestion.Name = "PnlQuestion";
@@ -774,7 +773,7 @@ namespace AiQ_GUI
PnlInputValue.Controls.Add(BtnDont); PnlInputValue.Controls.Add(BtnDont);
PnlInputValue.Controls.Add(BtnDone); PnlInputValue.Controls.Add(BtnDone);
PnlInputValue.Controls.Add(LblRMA); PnlInputValue.Controls.Add(LblRMA);
PnlInputValue.Location = new Point(0, 0); PnlInputValue.Location = new Point(251, 136);
PnlInputValue.Margin = new Padding(4, 3, 4, 3); PnlInputValue.Margin = new Padding(4, 3, 4, 3);
PnlInputValue.Name = "PnlInputValue"; PnlInputValue.Name = "PnlInputValue";
PnlInputValue.Size = new Size(254, 127); PnlInputValue.Size = new Size(254, 127);
@@ -1828,6 +1827,7 @@ namespace AiQ_GUI
Controls.Add(RhTxBxActions); Controls.Add(RhTxBxActions);
Controls.Add(CbBxCamType); Controls.Add(CbBxCamType);
Controls.Add(LblGUIVers); Controls.Add(LblGUIVers);
Controls.Add(PnlInputValue);
Controls.Add(BtnOpenWebpage); Controls.Add(BtnOpenWebpage);
Controls.Add(TabImagesandSettings); Controls.Add(TabImagesandSettings);
Controls.Add(PicBxMAV); Controls.Add(PicBxMAV);

View File

@@ -1435,33 +1435,33 @@ namespace AiQ_GUI
Stopwatch stopWatchTest = Stopwatch.StartNew(); Stopwatch stopWatchTest = Stopwatch.StartNew();
//await MobilePreTest.CheckFirmwareAsync(); await MobilePreTest.CheckFirmwareAsync();
//AddLabelToPanel("Test Complete", false); //AddLabelToPanel("Test Complete", false);
FakeCamera fakeCamera = new FakeCamera(80); // Create an instance of FakeCamera //FakeCamera fakeCamera = new FakeCamera(80); // Create an instance of FakeCamera
//CamOnTest.IP = CbBxFoundCams.Text; //CamOnTest.IP = CbBxFoundCams.Text;
_ = fakeCamera.StartAsync(CAMTYPE.GOOD).ContinueWith(task => //_ = fakeCamera.StartAsync(CAMTYPE.GOOD).ContinueWith(task =>
{ //{
//Network.Initialize("developer", "Pass123"); // //Network.Initialize("developer", "Pass123");
if (task.IsFaulted) // if (task.IsFaulted)
{ // {
AddToActionsList("Error starting FakeCamera: " + task.Exception?.Message); // AddToActionsList("Error starting FakeCamera: " + task.Exception?.Message);
} // }
else // else
{ // {
AddToActionsList($"FakeCamera started successfully. IP: {fakeCamera}"); // AddToActionsList($"FakeCamera started successfully. IP: {fakeCamera}");
} // }
}); //});
await Task.Delay(3000); // Wait for server to start //await Task.Delay(3000); // Wait for server to start
CbBxFoundCams.Text = "localhost"; // Should force update in creds an network reinit //CbBxFoundCams.Text = "localhost"; // Should force update in creds an network reinit
CmBoFoundCams_TextChanged(sender, e); //CmBoFoundCams_TextChanged(sender, e);
CbBxCameraModel.SelectedIndex = CbBxCameraModel.Items.Count - 1; // Selects AB12CD as model number //CbBxCameraModel.SelectedIndex = CbBxCameraModel.Items.Count - 1; // Selects AB12CD as model number
await Task.Delay(3000); // Wait for server to start //await Task.Delay(3000); // Wait for server to start
BtnStartTest_Click(sender, e); //BtnStartTest_Click(sender, e);
AddToActionsList("RunTime " + stopWatchTest.Elapsed.ToString(@"hh\:mm\:ss\.ff"), Level.LOG); AddToActionsList("RunTime " + stopWatchTest.Elapsed.ToString(@"hh\:mm\:ss\.ff"), Level.LOG);
} }
@@ -1471,7 +1471,7 @@ namespace AiQ_GUI
{ {
Location = new Point(5, yLoc), Location = new Point(5, yLoc),
Height = 20, Height = 20,
Width = 220, Width = 700,
ForeColor = isRed ? Color.Red : Color.LightGreen, ForeColor = isRed ? Color.Red : Color.LightGreen,
Text = text, Text = text,
Name = "Lbl_" + Guid.NewGuid(), Name = "Lbl_" + Guid.NewGuid(),
@@ -1489,8 +1489,5 @@ namespace AiQ_GUI
PnlLbls.Controls.Add(lbl); PnlLbls.Controls.Add(lbl);
} }
} }
} }

View File

@@ -6,9 +6,9 @@ namespace AiQ_GUI
// Chack camera modules are in default state according to what the diagnostics API. // Chack camera modules are in default state according to what the diagnostics API.
public static void CheckCamModule(Module CamMod, Label Lbl, Camera CamOnTest) public static void CheckCamModule(Module CamMod, Label Lbl, Camera CamOnTest)
{ {
if (CamMod == null || Lbl == null) if (CamMod == null)
{ {
MainForm.Instance.AddToActionsList("Camera module or label was null in CheckCamModule.", Level.ERROR); MainForm.Instance.AddToActionsList("Camera module was null in CheckCamModule.", Level.ERROR);
return; return;
} }
@@ -37,20 +37,39 @@ namespace AiQ_GUI
if (CamMod.expMode != 0) // Auto 0=0x00 if (CamMod.expMode != 0) // Auto 0=0x00
errMssg += $"Exp mode not set: {CamMod.expMode} "; errMssg += $"Exp mode not set: {CamMod.expMode} ";
// Determine display result
string displayResult = string.IsNullOrWhiteSpace(errMssg) ? "OK" : errMssg;
bool isError = !string.IsNullOrWhiteSpace(errMssg);
// Create label dynamically if not provided
if (Lbl == null)
{
string moduleName;
try
{
if (object.ReferenceEquals(CamMod, AiQ_GUI.AiQ_Tests.TestingFunctions.DiagsAPI.IRmodule))
moduleName = "IR Module";
else if (object.ReferenceEquals(CamMod, AiQ_GUI.AiQ_Tests.TestingFunctions.DiagsAPI.OVmodule))
moduleName = "OV Module";
else
moduleName = CamMod.firmwareVer == null ? "OV Module" : (CamMod.zoom < 5000 ? "IR Module" : "OV Module");
}
catch
{
moduleName = CamMod.firmwareVer == null ? "OV Module" : (CamMod.zoom < 5000 ? "IR Module" : "OV Module");
}
MainForm.Instance.AddLabelToPanel($"{moduleName} = {displayResult}", isError);
return;
}
// Update existing label
try try
{ {
Lbl.Invoke(() => Lbl.Invoke(() =>
{ {
if (string.IsNullOrWhiteSpace(errMssg)) Lbl.Text = Lbl.Text.TrimEnd('=', ' ') + " = " + displayResult;
{ Lbl.ForeColor = isError ? Color.Red : Color.LimeGreen;
Lbl.Text = Lbl.Text.TrimEnd('=', ' ') + " = OK"; // SET the text with proper format
Lbl.ForeColor = Color.LimeGreen;
}
else
{
Lbl.Text = Lbl.Text.TrimEnd('=', ' ') + " = " + errMssg; // SET the text with error message
Lbl.ForeColor = Color.Red;
}
}); });
} }
catch (Exception ex) catch (Exception ex)

View File

@@ -11,6 +11,23 @@
double medianVorI = (VorI[2] + VorI[3]) / 2.0; // Will always be even (6) number of channels therefore average the two middle elements 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}"; string medianText = $"Median: {medianVorI}{VormA}";
//Expected value of 0 means informational only (force green)
if (ExpVorI == 0)
{
if (lblVorI == null)
{
MainForm.Instance.AddLabelToPanel($"LED {VormA} = {medianText}", false);
return;
}
lblVorI.Invoke(() =>
{
lblVorI.Text = lblVorI.Text.TrimEnd('=', ' ') + " = " + medianText;
lblVorI.ForeColor = Color.LimeGreen;
});
return;
}
// Define the 20% threshold ranges // Define the 20% threshold ranges
double LowerThreshold = ExpVorI * 0.8; double LowerThreshold = ExpVorI * 0.8;
double UpperThreshold = ExpVorI * 1.2; double UpperThreshold = ExpVorI * 1.2;
@@ -19,6 +36,11 @@
if (medianVorI < LowerThreshold || medianVorI > UpperThreshold) if (medianVorI < LowerThreshold || medianVorI > UpperThreshold)
{ {
medianText += $" (away from expected {ExpVorI}{VormA})"; medianText += $" (away from expected {ExpVorI}{VormA})";
if (lblVorI == null)
{
MainForm.Instance.AddLabelToPanel($"LED {VormA} = {medianText}", true);
return;
}
lblVorI.Invoke(() => lblVorI.Invoke(() =>
{ {
lblVorI.Text = lblVorI.Text.TrimEnd('=', ' ') + " = " + medianText; lblVorI.Text = lblVorI.Text.TrimEnd('=', ' ') + " = " + medianText;
@@ -39,6 +61,11 @@
// If there are no single channels outside the threshold then green, else red // If there are no single channels outside the threshold then green, else red
if (outOfRangeVoltageChannels.Count == 0) if (outOfRangeVoltageChannels.Count == 0)
{ {
if (lblVorI == null)
{
MainForm.Instance.AddLabelToPanel($"LED {VormA} = {medianText}", false);
return;
}
lblVorI.Invoke(() => lblVorI.Invoke(() =>
{ {
lblVorI.Text = lblVorI.Text.TrimEnd('=', ' ') + " = " + medianText; lblVorI.Text = lblVorI.Text.TrimEnd('=', ' ') + " = " + medianText;
@@ -48,6 +75,11 @@
else if (outOfRangeVoltageChannels.Count != 0) else if (outOfRangeVoltageChannels.Count != 0)
{ {
string errorText = medianText + " (error on " + string.Join(", ", outOfRangeVoltageChannels) + ")"; string errorText = medianText + " (error on " + string.Join(", ", outOfRangeVoltageChannels) + ")";
if (lblVorI == null)
{
MainForm.Instance.AddLabelToPanel($"LED {VormA} = {errorText}", true);
return;
}
lblVorI.Invoke(() => lblVorI.Invoke(() =>
{ {
lblVorI.Text = lblVorI.Text.TrimEnd('=', ' ') + " = " + errorText; lblVorI.Text = lblVorI.Text.TrimEnd('=', ' ') + " = " + errorText;

View File

@@ -81,7 +81,7 @@ namespace AiQ_GUI
} }
const string query = const string query =
"SELECT FlexiVersion, FlexiRevision, WonwooFirmware, AiQGUIVersion, PowerConsumption, LicencingServerURL FROM UniversalData"; "SELECT FlexiVersion, FlexiRevision, WonwooFirmware, AiQGUIVersion, PowerConsumption, LicencingServerURL, SRZFirmware FROM UniversalData";
using OleDbCommand cmd = new(query, conn); using OleDbCommand cmd = new(query, conn);
using OleDbDataReader reader = cmd.ExecuteReader(); using OleDbDataReader reader = cmd.ExecuteReader();
@@ -95,6 +95,7 @@ namespace AiQ_GUI
UniversalData.LatestVersion = Convert.ToString(reader["AiQGUIVersion"]); UniversalData.LatestVersion = Convert.ToString(reader["AiQGUIVersion"]);
UniversalData.PowerConsumption = Convert.ToInt16(reader["PowerConsumption"]); UniversalData.PowerConsumption = Convert.ToInt16(reader["PowerConsumption"]);
UniversalData.LicencingServerURL = Convert.ToString(reader["LicencingServerURL"]); UniversalData.LicencingServerURL = Convert.ToString(reader["LicencingServerURL"]);
UniversalData.SRZFirmware = Convert.ToString(reader["SRZFirmware"]);
} }
// Populates CameraAccessInfo dynamically based on available columns // Populates CameraAccessInfo dynamically based on available columns
public static void ReadModelRow(string camType, string ModelOnTest) public static void ReadModelRow(string camType, string ModelOnTest)

View File

@@ -24,36 +24,39 @@ public static class MobilePreTest
string token = await LoginAsync(client, "ADMIN", "1234"); string token = await LoginAsync(client, "ADMIN", "1234");
// Attach JWT to all requests // Attach JWT to all requests
client.DefaultRequestHeaders.Authorization = client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", token);
new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", token);
// Request firmware information // Request firmware information
HttpResponseMessage response = HttpResponseMessage response = await client.GetAsync("/app/v1/system/firmware");
await client.GetAsync("/app/v1/system/firmware");
string body = await response.Content.ReadAsStringAsync(); string body = await response.Content.ReadAsStringAsync();
MainForm.Instance.AddToActionsList( MainForm.Instance.AddToActionsList($"Firmware check response: {(int)response.StatusCode} {response.StatusCode} | {body}",Level.LOG);
$"Firmware check response: {(int)response.StatusCode} {response.StatusCode} | {body}",
Level.LOG);
response.EnsureSuccessStatusCode(); response.EnsureSuccessStatusCode();
JsonElement json = JsonElement json = JsonSerializer.Deserialize<JsonElement>(body);
JsonSerializer.Deserialize<JsonElement>(body);
string version = string version = json.GetProperty("version").GetString()?.Trim();
json.GetProperty("version").GetString();
MainForm.Instance.AddToActionsList(
$"Current firmware version: {version}", // Compare against expected SRZFirmware from UniversalData
Level.Success); if (string.IsNullOrEmpty(UniversalData.SRZFirmware))
{
MainForm.Instance.AddToActionsList($"Firmware check failed: Expected SRZFirmware not loaded in UniversalData",Level.ERROR);
}
else if (version == UniversalData.SRZFirmware)
{
MainForm.Instance.AddToActionsList($"Firmware match successful: {version}",Level.Success);
}
else
{
MainForm.Instance.AddToActionsList($"Firmware mismatch: Camera has {version}, expected {UniversalData.SRZFirmware}",Level.ERROR);
}
} }
catch (Exception ex) catch (Exception ex)
{ {
MainForm.Instance.AddToActionsList( MainForm.Instance.AddToActionsList($"Firmware check failed: {ex.Message}",Level.ERROR);
$"Firmware check failed: {ex.Message}",
Level.ERROR);
} }
} }
@@ -65,13 +68,11 @@ public static class MobilePreTest
userPassword = Sha256(password) userPassword = Sha256(password)
}; };
HttpResponseMessage response = HttpResponseMessage response = await client.PostAsJsonAsync("/app/v1/login", payload);
await client.PostAsJsonAsync("/app/v1/login", payload);
response.EnsureSuccessStatusCode(); response.EnsureSuccessStatusCode();
JsonElement json = JsonElement json = await response.Content.ReadFromJsonAsync<JsonElement>();
await response.Content.ReadFromJsonAsync<JsonElement>();
return json.GetProperty("token").GetString(); return json.GetProperty("token").GetString();
} }