• 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);
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
if (RegexCache.VaxtorRegex().IsMatch(ProdcutKeyID)) // Valid Key ID
{
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;
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
{

4
AiQ_GUI.Designer.cs generated
View File

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

View File

@@ -1435,33 +1435,33 @@ namespace AiQ_GUI
Stopwatch stopWatchTest = Stopwatch.StartNew();
//await MobilePreTest.CheckFirmwareAsync();
await MobilePreTest.CheckFirmwareAsync();
//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;
_ = fakeCamera.StartAsync(CAMTYPE.GOOD).ContinueWith(task =>
{
//Network.Initialize("developer", "Pass123");
//_ = fakeCamera.StartAsync(CAMTYPE.GOOD).ContinueWith(task =>
//{
// //Network.Initialize("developer", "Pass123");
if (task.IsFaulted)
{
AddToActionsList("Error starting FakeCamera: " + task.Exception?.Message);
}
else
{
AddToActionsList($"FakeCamera started successfully. IP: {fakeCamera}");
}
});
// if (task.IsFaulted)
// {
// AddToActionsList("Error starting FakeCamera: " + task.Exception?.Message);
// }
// else
// {
// AddToActionsList($"FakeCamera started successfully. IP: {fakeCamera}");
// }
//});
await Task.Delay(3000); // Wait for server to start
CbBxFoundCams.Text = "localhost"; // Should force update in creds an network reinit
CmBoFoundCams_TextChanged(sender, e);
CbBxCameraModel.SelectedIndex = CbBxCameraModel.Items.Count - 1; // Selects AB12CD as model number
//await Task.Delay(3000); // Wait for server to start
//CbBxFoundCams.Text = "localhost"; // Should force update in creds an network reinit
//CmBoFoundCams_TextChanged(sender, e);
//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);
}
@@ -1471,7 +1471,7 @@ namespace AiQ_GUI
{
Location = new Point(5, yLoc),
Height = 20,
Width = 220,
Width = 700,
ForeColor = isRed ? Color.Red : Color.LightGreen,
Text = text,
Name = "Lbl_" + Guid.NewGuid(),
@@ -1489,8 +1489,5 @@ namespace AiQ_GUI
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.
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;
}
@@ -37,20 +37,39 @@ namespace AiQ_GUI
if (CamMod.expMode != 0) // Auto 0=0x00
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
{
Lbl.Invoke(() =>
{
if (string.IsNullOrWhiteSpace(errMssg))
{
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;
}
Lbl.Text = Lbl.Text.TrimEnd('=', ' ') + " = " + displayResult;
Lbl.ForeColor = isError ? Color.Red : Color.LimeGreen;
});
}
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
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
double LowerThreshold = ExpVorI * 0.8;
double UpperThreshold = ExpVorI * 1.2;
@@ -19,6 +36,11 @@
if (medianVorI < LowerThreshold || medianVorI > UpperThreshold)
{
medianText += $" (away from expected {ExpVorI}{VormA})";
if (lblVorI == null)
{
MainForm.Instance.AddLabelToPanel($"LED {VormA} = {medianText}", true);
return;
}
lblVorI.Invoke(() =>
{
lblVorI.Text = lblVorI.Text.TrimEnd('=', ' ') + " = " + medianText;
@@ -39,6 +61,11 @@
// If there are no single channels outside the threshold then green, else red
if (outOfRangeVoltageChannels.Count == 0)
{
if (lblVorI == null)
{
MainForm.Instance.AddLabelToPanel($"LED {VormA} = {medianText}", false);
return;
}
lblVorI.Invoke(() =>
{
lblVorI.Text = lblVorI.Text.TrimEnd('=', ' ') + " = " + medianText;
@@ -48,6 +75,11 @@
else if (outOfRangeVoltageChannels.Count != 0)
{
string errorText = medianText + " (error on " + string.Join(", ", outOfRangeVoltageChannels) + ")";
if (lblVorI == null)
{
MainForm.Instance.AddLabelToPanel($"LED {VormA} = {errorText}", true);
return;
}
lblVorI.Invoke(() =>
{
lblVorI.Text = lblVorI.Text.TrimEnd('=', ' ') + " = " + errorText;

View File

@@ -81,7 +81,7 @@ namespace AiQ_GUI
}
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 OleDbDataReader reader = cmd.ExecuteReader();
@@ -95,6 +95,7 @@ namespace AiQ_GUI
UniversalData.LatestVersion = Convert.ToString(reader["AiQGUIVersion"]);
UniversalData.PowerConsumption = Convert.ToInt16(reader["PowerConsumption"]);
UniversalData.LicencingServerURL = Convert.ToString(reader["LicencingServerURL"]);
UniversalData.SRZFirmware = Convert.ToString(reader["SRZFirmware"]);
}
// Populates CameraAccessInfo dynamically based on available columns
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");
// Attach JWT to all requests
client.DefaultRequestHeaders.Authorization =
new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", token);
client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", token);
// Request firmware information
HttpResponseMessage response =
await client.GetAsync("/app/v1/system/firmware");
HttpResponseMessage response = await client.GetAsync("/app/v1/system/firmware");
string body = await response.Content.ReadAsStringAsync();
MainForm.Instance.AddToActionsList(
$"Firmware check response: {(int)response.StatusCode} {response.StatusCode} | {body}",
Level.LOG);
MainForm.Instance.AddToActionsList($"Firmware check response: {(int)response.StatusCode} {response.StatusCode} | {body}",Level.LOG);
response.EnsureSuccessStatusCode();
JsonElement json =
JsonSerializer.Deserialize<JsonElement>(body);
JsonElement json = JsonSerializer.Deserialize<JsonElement>(body);
string version =
json.GetProperty("version").GetString();
string version = json.GetProperty("version").GetString()?.Trim();
MainForm.Instance.AddToActionsList(
$"Current firmware version: {version}",
Level.Success);
// Compare against expected SRZFirmware from UniversalData
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)
{
MainForm.Instance.AddToActionsList(
$"Firmware check failed: {ex.Message}",
Level.ERROR);
MainForm.Instance.AddToActionsList($"Firmware check failed: {ex.Message}",Level.ERROR);
}
}
@@ -65,13 +68,11 @@ public static class MobilePreTest
userPassword = Sha256(password)
};
HttpResponseMessage response =
await client.PostAsJsonAsync("/app/v1/login", payload);
HttpResponseMessage response = await client.PostAsJsonAsync("/app/v1/login", payload);
response.EnsureSuccessStatusCode();
JsonElement json =
await response.Content.ReadFromJsonAsync<JsonElement>();
JsonElement json = await response.Content.ReadFromJsonAsync<JsonElement>();
return json.GetProperty("token").GetString();
}