- AddToActionsList(Level.DEBUG) method has been changed to only visible when ChBXDevLog is true to avoid DEVS always having it on.

- added Level.DEBUG logs throughout selenium and soak test. Due to having prior issues with selenium and Soaktest
- Bug fix in LDS.cs this stops a crossthread exception as its trying to write to AddToActionsList before it loads.
This commit is contained in:
2026-01-16 11:42:34 +00:00
parent 4dace8edef
commit 8770469fd4
5 changed files with 75 additions and 7 deletions

View File

@@ -162,7 +162,7 @@ namespace AiQ_GUI
CbBxGain.SelectedIndex = lds.Gain;
if (lds.User == "Bradley" || lds.User == "Sophie")
BtnTest.Visible = true;
BtnTest.Visible = ChBxDevLog.Visible = true;
TxBxCheckValid(TxBxPsuIP); // Set save button color if valid
}
@@ -396,6 +396,7 @@ namespace AiQ_GUI
{
// Update the serial number register with new cameras details
// Cam description is in model drop down 6 digit model num + 3 for " - "
AddToActionsList($"Allocating serial for model {CamOnTest.Model} from spreadsheet", Level.DEBUG);
string NewSerial = GoogleAPI.UpdateSpreadSheetPreTest(CameraAccessInfo.SpreadsheetID, Vers, CbBxCameraModel.Text.Substring(9), CamOnTest.Model);
if (NewSerial.Contains("ERROR"))
@@ -409,15 +410,24 @@ namespace AiQ_GUI
return;
}
AddToActionsList($"Allocated serial: {NewSerial} for model {CamOnTest.Model}", Level.DEBUG);
// Set serial and model into camera
string[,] TEST_JSON = { { "propSerialNumber", NewSerial }, { "propMavModelNumber", CamOnTest.Model } };
AddToActionsList($"Sending JSON update to camera {CamOnTest.IP}: Serial={NewSerial}, Model={CamOnTest.Model}", Level.DEBUG);
string JSONResponse = await FlexiAPI.HTTP_Update("GLOBAL--FlexiApplication", CamOnTest.IP, TEST_JSON);
if (!JSONResponse.Contains(NewSerial) || !JSONResponse.Contains(CamOnTest.Model))
{
AddToActionsList($"JSON response validation failed. Expected serial: {NewSerial}, model: {CamOnTest.Model}", Level.DEBUG);
AddToActionsList("Could not set model or serial numbers into camera.", Level.ERROR);
await PreTestFailed("Failed To Set Model Or Serial Number");
}
else
{
AddToActionsList($"Successfully set serial and model in camera", Level.DEBUG);
}
TestingFunctions.DiagsAPI.modelNumber = CamOnTest.Model; // Update Diags and labels
TestingFunctions.DiagsAPI.serialNumber = NewSerial;
@@ -548,6 +558,7 @@ namespace AiQ_GUI
{
CamOnTest.IP = ipOnly; // Always store clean IP
CbBxFoundCams.BackColor = BtnColour;
AddToActionsList($"Camera selected: {ipOnly} (Onvif: {isOnvif})", Level.DEBUG);
// ONVIF cameras: webpage only
if (isOnvif)
@@ -560,12 +571,13 @@ namespace AiQ_GUI
// AiQ cameras
if (!await Network.PingIP(ipOnly))
{
AddToActionsList($"Failed to ping camera at {ipOnly}", Level.DEBUG);
CbBxFoundCams.BackColor = Color.Red;
return;
}
BtnSecret.Enabled = true;
AddToActionsList($"Retrieving API versions from {ipOnly}", Level.DEBUG);
Vers = await FlexiAPI.GetVersions(ipOnly);
// Wont be filled out before the pre test but needed for final test
@@ -579,6 +591,7 @@ namespace AiQ_GUI
if (Vers == null) // Flexi not running or not AiQ
{
AddToActionsList("Failed to get API from camera. Flexi not running yet or not an AiQ", Level.WARNING);
AddToActionsList($"API request returned null for {ipOnly}", Level.DEBUG);
return;
}
@@ -654,8 +667,8 @@ namespace AiQ_GUI
// ***** Helper functions *****
public void AddToActionsList(string Mssg, Level Lvl = Level.LOG)
{
// DEBUG messages only visible to Bradley
if (Lvl == Level.DEBUG && CbBxUserName.Text != "Bradley")
// DEBUG messages only visible to Bradley and is checked
if (Lvl == Level.DEBUG && !ChBxDevLog.Checked)
return;
if (Lvl == Level.ERROR)
@@ -1315,21 +1328,26 @@ namespace AiQ_GUI
soakCtsList.Clear();
soakTasks.Clear();
int soakCount = 0;
foreach (Camera SCL in soakCameraList)
{
if (!SCL.IsChecked)
continue;
soakCount++;
AddToActionsList($"Starting soak test for camera {soakCount}: {SCL.Serial} ({SCL.Model}) at {SCL.IP}", Level.DEBUG);
CancellationTokenSource cts = new();
soakCtsList.Add(cts);
soakTasks.Add(SoakTest.StartSoak(SCL, cts));
await Task.Delay(10000);
}
AddToActionsList($"Soak test initiated for {soakCount} camera(s)", Level.DEBUG);
}
else
{
BtnSoak.BackColor = BtnColour; // Reset button colour
BtnSoak.Text = "Start Soak";
AddToActionsList($"Stopping soak test - cancelling {soakCtsList.Count} task(s)", Level.DEBUG);
foreach (CancellationTokenSource cts in soakCtsList)
cts.Cancel();
soakCtsList.Clear();
@@ -1338,6 +1356,7 @@ namespace AiQ_GUI
string[,] Network_JSON = { { "propDHCP", "false" }, { "propHost", "192.168.1.211" }, { "propNetmask", "255.255.255.0" }, { "propGateway", "192.168.1.1" } };
string[,] GOD_JSON = { { "propGodMode", "false" } };
AddToActionsList($"Finalizing soak: resetting {soakCameraList.Where(c => c.IsChecked).Count()} camera(s) to 211 and disabling God mode", Level.DEBUG);
foreach (Camera SCL in soakCameraList.Where(c => c.IsChecked)) // only checked cameras
{
if (!SCL.IsChecked)
@@ -1346,6 +1365,7 @@ namespace AiQ_GUI
{
AddToActionsList($"Setting 211 & God Mode off for camera {SCL.IP}", Level.LOG);
Network.Initialize("developer", SCL.DevPass); // Ensure network is initialized to the right camera
AddToActionsList($"Resetting modules for {SCL.Serial}", Level.DEBUG);
await CameraModules.FactoryResetModules(SCL.IP); // Reset camera modules
string GOD = await FlexiAPI.HTTP_Update("GLOBAL--FlexiApplication", SCL.IP, GOD_JSON);
@@ -1354,10 +1374,12 @@ namespace AiQ_GUI
// Update GLOBAL--NetworkConfig with fixed IP and turn off DHCP
await FlexiAPI.HTTP_Update("GLOBAL--NetworkConfig", SCL.IP, Network_JSON);
AddToActionsList($"Successfully configured {SCL.Serial} for 211 static IP", Level.DEBUG);
i--; // Decriment count becuase they will stack into 211
}
catch (Exception ex)
{
AddToActionsList($"Configuration failed for {SCL.Serial}: {ex.Message}", Level.DEBUG);
AddToActionsList("Failed to set all cameras to 211 and god mode off. Reason: " + ex.Message, Level.ERROR); // In case non AiQ's get caught up
}
@@ -1497,13 +1519,12 @@ public static Label MakeNewLabel(string text, bool isRed, int yLoc)
//VLC.Play(VidView);
//await Task.Delay(5000);
//VLC.TakeSnapshot(VidView);
SSH.MobiletxtCheck("100.118.196.113");
//SSH.MobiletxtCheck("100.118.196.113");
// await MobileAPI.SetDayModeAsync();
AddToActionsList("RunTime " + stopWatchTest.Elapsed.ToString(@"hh\:mm\:ss\.ff"), Level.DEBUG);
}
}
}