• 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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user