• MobileTests.cs

- Pre test now checks firmware and adds the label dynamically to the panel

• AiQ_GUI.Designer.cs
  - Added CbBxCameraModel.SelectedIndexChanged to properly wire UI element.

• Microsoft/StatsExcel.cs
  - Improved workbook loading error handling to distinguish between corruption and file access issues.
This commit is contained in:
2026-01-09 15:49:54 +00:00
parent 693da58fcb
commit 90b3f7caff
6 changed files with 97 additions and 85 deletions

View File

@@ -1,21 +1,23 @@
using AiQ_GUI;
using System;
using System.IO;
using System.Net.Http;
using System.Net.Http.Json;
using System.Security.Cryptography;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Diagnostics;
public static class MobilePreTest
{
public static async Task CheckFirmwareAsync()
{
const string cameraIp = "192.168.0.112";
using HttpClient client = new HttpClient
{
BaseAddress = new Uri($"http://{cameraIp}")
BaseAddress = new Uri($"http://{MainForm.Instance.CamOnTest.IP}")
};
try
@@ -31,32 +33,32 @@ public static class MobilePreTest
string body = await response.Content.ReadAsStringAsync();
MainForm.Instance.AddToActionsList($"Firmware check response: {(int)response.StatusCode} {response.StatusCode} | {body}",Level.LOG);
response.EnsureSuccessStatusCode();
JsonElement json = JsonSerializer.Deserialize<JsonElement>(body);
string version = json.GetProperty("version").GetString()?.Trim();
// 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);
MainForm.Instance.AddLabelToPanel($"Firmware = {version}", true);
}
else if (version == UniversalData.SRZFirmware)
{
MainForm.Instance.AddToActionsList($"Firmware match successful: {version}",Level.Success);
MainForm.Instance.AddLabelToPanel($"Firmware = {version}", false);
}
else
{
MainForm.Instance.AddToActionsList($"Firmware mismatch: Camera has {version}, expected {UniversalData.SRZFirmware}",Level.ERROR);
MainForm.Instance.AddLabelToPanel($"Firmware = {version}", true);
}
}
catch (Exception ex)
{
MainForm.Instance.AddToActionsList($"Firmware check failed: {ex.Message}",Level.ERROR);
MainForm.Instance.AddLabelToPanel("Firmware = Unknown", true);
}
}
@@ -83,4 +85,10 @@ public static class MobilePreTest
byte[] bytes = sha.ComputeHash(Encoding.UTF8.GetBytes(input));
return BitConverter.ToString(bytes).Replace("-", "").ToLower();
}
public static async Task RunPreTestAsync()
{
await CheckFirmwareAsync();
}
}