1 Commits

Author SHA1 Message Date
30bd2fe73c AddToAction List colours 2025-12-02 12:59:40 +00:00
18 changed files with 212 additions and 232 deletions

View File

@@ -9,7 +9,8 @@ namespace AiQ_GUI
{ {
ERROR, ERROR,
WARNING, WARNING,
LOG LOG,
Success
} }
public partial class MainForm : Form public partial class MainForm : Form
@@ -47,7 +48,7 @@ namespace AiQ_GUI
Task<LocalDataStore> LDSWAIT = Task.Run(() => LDS.GetLDS()); // Get and deserialise LDS.json Task<LocalDataStore> LDSWAIT = Task.Run(() => LDS.GetLDS()); // Get and deserialise LDS.json
Task<string> guiVerTask = Task.Run(() => GUIUpdate.FindGUIVersion()); // Get GUI Version Task<string> guiVerTask = Task.Run(() => GUIUpdate.FindGUIVersion()); // Get GUI Version
Network.Initialize("admin", "admin"); // Initialise HTTP client with basic auth creds. Network.Initialize("admin", "admin"); // Initialise HTTP client
if (await Network.PingIP("8.8.8.8")) // Ping to check if we're online if (await Network.PingIP("8.8.8.8")) // Ping to check if we're online
{ {
@@ -77,7 +78,7 @@ namespace AiQ_GUI
if (localDataStore == null) if (localDataStore == null)
{ {
AddToActionsList("Could not deserialise LDS.json please help!"); AddToActionsList("Could not deserialise LDS.json please help!", Level.WARNING);
return; return;
} }
@@ -138,17 +139,17 @@ namespace AiQ_GUI
string LEDreply = await FlexiAPI.APIHTTPLED(CamOnTest.IP, LEDPOWER.SAFE); // Set LED's to safe (0x0E) to help with eye safety and trim check. string LEDreply = await FlexiAPI.APIHTTPLED(CamOnTest.IP, LEDPOWER.SAFE); // Set LED's to safe (0x0E) to help with eye safety and trim check.
if (!LEDreply.Contains("Power levels set successfully")) if (!LEDreply.Contains("Power levels set successfully"))
AddToActionsList($"LED level could not be set: {LEDreply}"); AddToActionsList($"LED level could not be set: {LEDreply}", Level.ERROR);
} }
else if (!await TestTube.CheckInTestTube(CamOnTest.IP)) // Sets LED's to medium power after checking it is in the test tube else if (!await TestTube.CheckInTestTube(CamOnTest.IP)) // Sets LED's to medium power after checking it is in the test tube
await TestFailed(BtnStartTest, "Camera not in test tube"); await TestFailed(BtnStartTest, "Camera not in test tube");
Task VisCheck = Helper.VisualCheck(BtnStartTest); Task VisCheck = Helper.VisualCheck(BtnStartTest);
if (!await CameraModules.ZoomModules("1F40", CamOnTest.IP)) // Zoom to 8000 (1F40h) at the same time. if (!await FlexiAPI.ZoomModules("1F40", CamOnTest.IP)) // Zoom to 8000 (1F40h) at the same time.
await TestFailed(BtnStartTest, "Could not zoom modules to 8000"); await TestFailed(BtnStartTest, "Could not zoom modules to 8000");
if (!await CameraModules.SetZoomLockOn(CamOnTest.IP)) if (!await FlexiAPI.SetZoomLockOn(CamOnTest.IP))
Helper.RestartApp(); Helper.RestartApp();
await Task.Delay(1000); // Without sleep it kept failing the factory reset as camera modules were not ready yet await Task.Delay(1000); // Without sleep it kept failing the factory reset as camera modules were not ready yet
@@ -157,7 +158,7 @@ namespace AiQ_GUI
string VISCAReply = await FlexiAPI.APIHTTPVISCA(CamOnTest.IP, "8101043903FF", true); // Manual mode to be able to manipulate the SIG settings. string VISCAReply = await FlexiAPI.APIHTTPVISCA(CamOnTest.IP, "8101043903FF", true); // Manual mode to be able to manipulate the SIG settings.
if (VISCAReply != "9041FF9051FF") if (VISCAReply != "9041FF9051FF")
AddToActionsList("Couldn't set to manual mode"); AddToActionsList("Couldn't set to manual mode",Level.ERROR);
await CameraModules.SetSIG(CbBxShutter, CbBxIris, CbBxGain, CamOnTest.IP); // Set SIG according to the drop downs in settings for a good picture ready for image check await CameraModules.SetSIG(CbBxShutter, CbBxIris, CbBxGain, CamOnTest.IP); // Set SIG according to the drop downs in settings for a good picture ready for image check
await ImageProcessing.ImageCheck(PicBxOV, PicBxIRF2, PicBxIRF16, LblIRImageF2, LblIRImageF16, CamOnTest); // Populates the picture boxes and checks iris changes await ImageProcessing.ImageCheck(PicBxOV, PicBxIRF2, PicBxIRF16, LblIRImageF2, LblIRImageF16, CamOnTest); // Populates the picture boxes and checks iris changes
@@ -169,9 +170,6 @@ namespace AiQ_GUI
// TODO - Force expire sighting. // TODO - Force expire sighting.
Task Wait = Task.Delay(5000); // Wait for 5 seconds to allow the camera to zoom in, set settings and capture some plates before auto trim Task Wait = Task.Delay(5000); // Wait for 5 seconds to allow the camera to zoom in, set settings and capture some plates before auto trim
if (CameraAccessInfo.HardwareExtras.Contains("GPS")) // Check GPS if the hardware has it
await FlexiAPI.GPSFix(CamOnTest.IP);
// While waiting do the SSH tasks. // While waiting do the SSH tasks.
sshData = SSH.CollectSSHData(CamOnTest.IP); // SSH into camera to get Vaxtor packages, filesystem size and if tailscale is installed. sshData = SSH.CollectSSHData(CamOnTest.IP); // SSH into camera to get Vaxtor packages, filesystem size and if tailscale is installed.
await SSH.CheckFSSize(CamOnTest.IP, LblFilesystemSize, sshData); // Check Filesystem size is between 100GB & 150GB await SSH.CheckFSSize(CamOnTest.IP, LblFilesystemSize, sshData); // Check Filesystem size is between 100GB & 150GB
@@ -191,7 +189,7 @@ namespace AiQ_GUI
await Wait; // Finished to 5s wait await Wait; // Finished to 5s wait
await FlexiAPI.SetTrim(CamOnTest.IP, LblTestTubePing.Text); // Auto trims the cameras, some plates should have been captured in the meantime await FlexiAPI.SetTrim(CamOnTest.IP, LblTestTubePing.Text); // Auto trims the cameras, some plates should have been captured in the meantime
if (!await CameraModules.ZoomModules("0000", CamOnTest.IP)) // Zoom to full wide if (!await FlexiAPI.ZoomModules("0000", CamOnTest.IP)) // Zoom to full wide
await TestFailed(BtnStartTest, "Could not zoom modules to full wide"); await TestFailed(BtnStartTest, "Could not zoom modules to full wide");
await Task.Delay(1000); // Wait to be sure cameras are zoomed out. await Task.Delay(1000); // Wait to be sure cameras are zoomed out.
@@ -203,7 +201,7 @@ namespace AiQ_GUI
string LEDreply = await FlexiAPI.APIHTTPLED(CamOnTest.IP, LEDPOWER.MID); // Set LED's to medium (0x30) string LEDreply = await FlexiAPI.APIHTTPLED(CamOnTest.IP, LEDPOWER.MID); // Set LED's to medium (0x30)
if (!LEDreply.Contains("Power levels set successfully")) if (!LEDreply.Contains("Power levels set successfully"))
AddToActionsList($"LED level could not be set: {LEDreply}"); AddToActionsList($"LED level could not be set: {LEDreply}", Level.ERROR);
} }
await FlexiAPI.SetVaxtorMinMaxPlate(CamOnTest.IP); await FlexiAPI.SetVaxtorMinMaxPlate(CamOnTest.IP);
@@ -238,13 +236,13 @@ namespace AiQ_GUI
BtnPreTest.Enabled = BtnStartTest.Enabled = false; // Disable buttons to stop user rnning multiple tests at the same time. BtnPreTest.Enabled = BtnStartTest.Enabled = false; // Disable buttons to stop user rnning multiple tests at the same time.
Logging.LogMessage("Pre Test Started"); Logging.LogMessage("Pre Test Started");
if (!await CameraModules.SetZoomLockOn(CamOnTest.IP)) if (!await FlexiAPI.SetZoomLockOn(CamOnTest.IP))
Helper.RestartApp(); Helper.RestartApp();
string LEDreply = await FlexiAPI.APIHTTPLED(CamOnTest.IP, LEDPOWER.MID); // Set LED's to medium (0x30) string LEDreply = await FlexiAPI.APIHTTPLED(CamOnTest.IP, LEDPOWER.MID); // Set LED's to medium (0x30)
if (!LEDreply.Contains("Power levels set successfully")) if (!LEDreply.Contains("Power levels set successfully"))
AddToActionsList($"LED level could not be set: {LEDreply}"); AddToActionsList($"LED level could not be set: {LEDreply}", Level.ERROR);
await CameraModules.FactoryResetModules(CamOnTest.IP); // Reset both modules and double check await CameraModules.FactoryResetModules(CamOnTest.IP); // Reset both modules and double check
@@ -276,7 +274,7 @@ namespace AiQ_GUI
if (await DisplayQuestion($"Would you like to allocate a serial number to this camera?")) if (await DisplayQuestion($"Would you like to allocate a serial number to this camera?"))
await AllocateSerial(); await AllocateSerial();
else if (GoogleAPI.UpdateSpreadSheetRePreTest(CameraAccessInfo.SpreadsheetID, Vers) != "OK") // If rerun might be different values so update SS else if (GoogleAPI.UpdateSpreadSheetRePreTest(CameraAccessInfo.SpreadsheetID, Vers) != "OK") // If rerun might be different values so update SS
AddToActionsList("Failed to write to spreadsheet, please check manually"); AddToActionsList("Failed to write to spreadsheet, please check manually",Level.WARNING);
// else if (Excel.UpdateSpreadSheetPreTest(CameraAccessInfo.SpreadsheetID, Vers, CamOnTest.GetCamDesc(), CamOnTest.Model) != "OK") // else if (Excel.UpdateSpreadSheetPreTest(CameraAccessInfo.SpreadsheetID, Vers, CamOnTest.GetCamDesc(), CamOnTest.Model) != "OK")
// AddToActionsList("Failed to write to spreadsheet, please check manually"); // AddToActionsList("Failed to write to spreadsheet, please check manually");
} }
@@ -299,7 +297,7 @@ namespace AiQ_GUI
string err = GoogleAPI.UpdateSpreadSheetFinalTest(CameraAccessInfo.SpreadsheetID, DiagsAPI, sshData, CamOnTest.RMANum); string err = GoogleAPI.UpdateSpreadSheetFinalTest(CameraAccessInfo.SpreadsheetID, DiagsAPI, sshData, CamOnTest.RMANum);
if (err != string.Empty) // If there is an error message, display it if (err != string.Empty) // If there is an error message, display it
AddToActionsList("Failed to write to spreadsheet " + err); AddToActionsList("Failed to write to spreadsheet " + err, Level.ERROR);
// Purge camera of all reads // Purge camera of all reads
await FlexiAPI.APIHTTPRequest("/api/purge-all", CamOnTest.IP); await FlexiAPI.APIHTTPRequest("/api/purge-all", CamOnTest.IP);
@@ -310,12 +308,12 @@ namespace AiQ_GUI
string[,] GOD_JSON = { { "propGodMode", "false" } }; string[,] GOD_JSON = { { "propGodMode", "false" } };
string IntConf = await FlexiAPI.HTTP_Update("GLOBAL--FlexiApplication", CamOnTest.IP, GOD_JSON); string IntConf = await FlexiAPI.HTTP_Update("GLOBAL--FlexiApplication", CamOnTest.IP, GOD_JSON);
if (!IntConf.Contains("\"propGodMode\": {\"value\": \"false\", \"datatype\": \"boolean\"},")) if (!IntConf.Contains("\"propGodMode\": {\"value\": \"false\", \"datatype\": \"boolean\"},"))
AddToActionsList("Could not turn off God mode"); AddToActionsList("Could not turn off God mode", Level.WARNING);
Thread Thr211 = new(async () => Thread Thr211 = new(async () =>
{ {
if (!await FlexiAPI.ChangeNetwork211(CamOnTest.IP)) // Change camera IP to 192.168.1.211. Waits for camera to come back. if (!await FlexiAPI.ChangeNetwork211(CamOnTest.IP)) // Change camera IP to 192.168.1.211. Waits for camera to come back.
AddToActionsList("Could not find camera at 192.168.1.211. Please check manually"); AddToActionsList("Could not find camera at 192.168.1.211. Please check manually", Level.WARNING);
}); });
Thr211.IsBackground = true; Thr211.IsBackground = true;
Thr211.Start(); Thr211.Start();
@@ -356,7 +354,7 @@ namespace AiQ_GUI
else else
Access.Stats("RMA Final Tests Failed", CamOnTest.Model); Access.Stats("RMA Final Tests Failed", CamOnTest.Model);
AddToActionsList(ErrMssg); AddToActionsList(ErrMssg, Level.ERROR);
string RedLbls = string.Join(Environment.NewLine, PnlLbls.Controls string RedLbls = string.Join(Environment.NewLine, PnlLbls.Controls
.OfType<Label>() .OfType<Label>()
@@ -505,12 +503,12 @@ namespace AiQ_GUI
else if (RegexCache.MACRegex().IsMatch(DiagsAPI.MAC)) // Is a valid MAC, but not NVIDIA else if (RegexCache.MACRegex().IsMatch(DiagsAPI.MAC)) // Is a valid MAC, but not NVIDIA
{ {
lblMac.ForeColor = Color.Red; lblMac.ForeColor = Color.Red;
AddToActionsList($"{DiagsAPI.MAC} not recognised as NVIDIA MAC address"); AddToActionsList($"{DiagsAPI.MAC} not recognised as NVIDIA MAC address", Level.ERROR);
} }
else else
{ {
lblMac.ForeColor = Color.Red; lblMac.ForeColor = Color.Red;
AddToActionsList($"{DiagsAPI.MAC} not recognised as a MAC address"); AddToActionsList($"{DiagsAPI.MAC} not recognised as a MAC address", Level.ERROR);
} }
// Check timestamp // Check timestamp
@@ -574,7 +572,7 @@ namespace AiQ_GUI
if (DiagsAPI.modelNumber != CamOnTest.Model) if (DiagsAPI.modelNumber != CamOnTest.Model)
{ {
AddToActionsList("Model number in camera doesn't match what has been selected"); AddToActionsList("Model number in camera doesn't match what has been selected", Level.WARNING);
lblModel.ForeColor = Color.Red; lblModel.ForeColor = Color.Red;
} }
else if (!GoogleAPI.CheckWIP(DiagsAPI.serialNumber, CameraAccessInfo.SpreadsheetID)) // Check WIP column in serial number register, if not ticked then RMA else if (!GoogleAPI.CheckWIP(DiagsAPI.serialNumber, CameraAccessInfo.SpreadsheetID)) // Check WIP column in serial number register, if not ticked then RMA
@@ -600,7 +598,7 @@ namespace AiQ_GUI
} }
else else
{ {
AddToActionsList("Camera has not been given a valid serial and model number, suggest you run through pre test again and check serial number register for any issues."); AddToActionsList("Camera has not been given a valid serial and model number, suggest you run through pre test again and check serial number register for any issues.", Level.ERROR);
} }
} }
catch { } catch { }
@@ -696,12 +694,12 @@ namespace AiQ_GUI
if (NewSerial.Contains("ERROR")) if (NewSerial.Contains("ERROR"))
{ {
AddToActionsList(NewSerial + Environment.NewLine + "Please remove any information that was put into the serial number mistake, change the camera model/serial to 'N/A' and retry the test."); AddToActionsList(NewSerial + Environment.NewLine + "Please remove any information that was put into the serial number mistake, change the camera model/serial to 'N/A' and retry the test.", Level.ERROR);
return; return;
} }
else if (NewSerial == "Last serial number not found") else if (NewSerial == "Last serial number not found")
{ {
AddToActionsList("Last serial number not found in spreadsheet. Please check spreadsheet is in correct format before retrying."); AddToActionsList("Last serial number not found in spreadsheet. Please check spreadsheet is in correct format before retrying.", Level.WARNING);
return; return;
} }
@@ -711,7 +709,7 @@ namespace AiQ_GUI
if (!JSONResponse.Contains(NewSerial) || !JSONResponse.Contains(CamOnTest.Model)) if (!JSONResponse.Contains(NewSerial) || !JSONResponse.Contains(CamOnTest.Model))
{ {
AddToActionsList("Could not set model or serial numbers into camera."); AddToActionsList("Could not set model or serial numbers into camera.",Level.ERROR);
await PreTestFailed("Failed To Set Model Or Serial Number"); await PreTestFailed("Failed To Set Model Or Serial Number");
} }
@@ -865,7 +863,7 @@ namespace AiQ_GUI
if (Vers == null) // If failed to get versions then return. Flexi most likely not running yet. if (Vers == null) // If failed to get versions then return. Flexi most likely not running yet.
{ {
AddToActionsList("Failed to get API from camera. Flexi not running yet or not an AiQ"); AddToActionsList("Failed to get API from camera. Flexi not running yet or not an AiQ", Level.WARNING);
return; return;
} }
@@ -928,7 +926,7 @@ namespace AiQ_GUI
} }
catch (Exception ex) catch (Exception ex)
{ {
AddToActionsList($"Failed to set God mode for camera {CamOnTest.IP}. Reason: {ex.Message}"); AddToActionsList($"Failed to set God mode for camera {CamOnTest.IP}. Reason: {ex.Message}", Level.ERROR);
} }
} }
@@ -946,6 +944,11 @@ namespace AiQ_GUI
RhTxBxActions.SelectionColor = Color.Orange; RhTxBxActions.SelectionColor = Color.Orange;
} }
else if (Lvl == Level.LOG) else if (Lvl == Level.LOG)
{
Logging.LogMessage(Mssg);
RhTxBxActions.SelectionColor = Color.White;
}
else if (Lvl == Level.Success)
{ {
Logging.LogMessage(Mssg); Logging.LogMessage(Mssg);
RhTxBxActions.SelectionColor = Color.LightGreen; RhTxBxActions.SelectionColor = Color.LightGreen;
@@ -1129,7 +1132,7 @@ namespace AiQ_GUI
bool Online = await FlexiAPI.ChangeNetwork211(CamOnTest.IP); // Change camera IP to 192.168.1.211 and hardware reboot. Waits for camera to come back for 50s. bool Online = await FlexiAPI.ChangeNetwork211(CamOnTest.IP); // Change camera IP to 192.168.1.211 and hardware reboot. Waits for camera to come back for 50s.
if (!Online) if (!Online)
AddToActionsList("Could not find camera at 192.168.1.211. Please check manually"); AddToActionsList("Could not find camera at 192.168.1.211. Please check manually", Level.ERROR);
else else
BtnSet211.Text = "Set to DHCP"; BtnSet211.Text = "Set to DHCP";
} }
@@ -1158,7 +1161,7 @@ namespace AiQ_GUI
} }
catch (Exception ex) catch (Exception ex)
{ {
AddToActionsList("Failed to set all cameras to 211. Reason: " + ex.Message); // In case non AiQ's get caught up AddToActionsList("Failed to set all cameras to 211. Reason: " + ex.Message, Level.ERROR); // In case non AiQ's get caught up
} }
} }
@@ -1185,7 +1188,7 @@ namespace AiQ_GUI
} }
catch (Exception ex) catch (Exception ex)
{ {
AddToActionsList($"Failed to set God mode for camera {SCL.IP}. Reason: {ex.Message}"); AddToActionsList($"Failed to set God mode for camera {SCL.IP}. Reason: {ex.Message}", Level.ERROR);
} }
} }
@@ -1313,7 +1316,7 @@ namespace AiQ_GUI
} }
catch catch
{ {
AddToActionsList("Failed to communicate with camera, please check network and try again."); AddToActionsList("Failed to communicate with camera, please check network and try again.", Level.ERROR);
return; return;
} }
@@ -1330,7 +1333,7 @@ namespace AiQ_GUI
string err = GoogleAPI.UpdateSpreadSheetVaxtor(VaxtorLicResp, Vers.Serial, CamOnTest.Model); string err = GoogleAPI.UpdateSpreadSheetVaxtor(VaxtorLicResp, Vers.Serial, CamOnTest.Model);
if (err != string.Empty) // If there is an error message, display it if (err != string.Empty) // If there is an error message, display it
AddToActionsList("Failed to update Vaxtor spreadsheet: " + err); AddToActionsList("Failed to update Vaxtor spreadsheet: " + err, Level.ERROR);
RhTxBxCode.AppendText("Licencing Success, Key ID: " + VaxtorLicResp.protectionKeyId + Environment.NewLine + "Waiting for files to save"); RhTxBxCode.AppendText("Licencing Success, Key ID: " + VaxtorLicResp.protectionKeyId + Environment.NewLine + "Waiting for files to save");
@@ -1468,7 +1471,7 @@ namespace AiQ_GUI
private async void BtnZoomWide_Click(object sender, EventArgs e) private async void BtnZoomWide_Click(object sender, EventArgs e)
{ {
if (await CameraModules.ZoomModules("0000", CamOnTest.IP)) if (await FlexiAPI.ZoomModules("0000", CamOnTest.IP))
BtnZoomWide.BackColor = Color.Green; BtnZoomWide.BackColor = Color.Green;
else else
BtnZoomWide.BackColor = Color.Red; BtnZoomWide.BackColor = Color.Red;
@@ -1478,7 +1481,7 @@ namespace AiQ_GUI
private async void BtnZoom8000_Click(object sender, EventArgs e) private async void BtnZoom8000_Click(object sender, EventArgs e)
{ {
if (await CameraModules.ZoomModules("1F40", CamOnTest.IP)) if (await FlexiAPI.ZoomModules("1F40", CamOnTest.IP))
BtnZoom8000.BackColor = Color.Green; BtnZoom8000.BackColor = Color.Green;
else else
BtnZoom8000.BackColor = Color.Red; BtnZoom8000.BackColor = Color.Red;
@@ -1582,7 +1585,7 @@ namespace AiQ_GUI
CancellationTokenSource cts = new(); CancellationTokenSource cts = new();
soakCtsList.Add(cts); soakCtsList.Add(cts);
soakTasks.Add(SoakTest.StartSoak(SCL, cts)); soakTasks.Add(SoakTest.StartSoak(SCL, SCL.CheckBox, cts.Token));
await Task.Delay(10000); await Task.Delay(10000);
} }
} }
@@ -1618,7 +1621,7 @@ namespace AiQ_GUI
} }
catch (Exception ex) catch (Exception ex)
{ {
AddToActionsList("Failed to set all cameras to 211 and god mode off. Reason: " + ex.Message); // In case non AiQ's get caught up 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
} }
if (SCL.CheckBox.ForeColor == Color.Red) if (SCL.CheckBox.ForeColor == Color.Red)
@@ -1634,7 +1637,7 @@ namespace AiQ_GUI
if ((FoundCams.Count == i && FoundCams.Contains("192.168.1.211")) || FoundCams.Count == 1) if ((FoundCams.Count == i && FoundCams.Contains("192.168.1.211")) || FoundCams.Count == 1)
{ {
AddToActionsList("All cameras successfully changed to 211.", Level.LOG); AddToActionsList("All cameras successfully changed to 211.", Level.Success);
} }
else else
{ {
@@ -1716,24 +1719,24 @@ namespace AiQ_GUI
// /api/config-ids - For getting all available config IDs // /api/config-ids - For getting all available config IDs
// Make every log file in the soak log directory into a soak test report PDF // Make every log file in the soak log directory into a soak test report PDF
var files = from file in Directory.EnumerateFiles("C:\\ProgramData\\MAV\\AiQ_GUI") select file; //var files = from file in Directory.EnumerateFiles("C:\\ProgramData\\MAV\\AiQ_GUI") select file;
foreach (var file in files) //foreach (var file in files)
{ //{
if (file.Contains("SoakLog")) // if (file.Contains("SoakLog"))
{ // {
// File name: SoakLog_{Serial}_{Model}.log // // File name: SoakLog_{Serial}_{Model}.log
string[] parts = file.Split('_', '.').Select(p => p.Trim()).ToArray(); // string[] parts = file.Split('_', '.').Select(p => p.Trim()).ToArray();
Camera NewCam = new() // Camera NewCam = new()
{ // {
Model = parts[3], // Model = parts[3],
Serial = parts[2], // Serial = parts[2],
}; // };
PDF.CreateSoakTestReport(NewCam, "SoakTestRig", DateTime.Now, file); // PDF.CreateSoakTestReport(NewCam, "SoakTestRig", DateTime.Now, file);
} // }
} //}
stopWatchTest.Stop(); stopWatchTest.Stop();
AddToActionsList("RunTime " + stopWatchTest.Elapsed.ToString(@"hh\:mm\:ss\.ff"), Level.LOG); AddToActionsList("RunTime " + stopWatchTest.Elapsed.ToString(@"hh\:mm\:ss\.ff"), Level.LOG);

View File

@@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<TargetFramework>net10.0-windows7.0</TargetFramework> <TargetFramework>net9.0-windows10.0.17763.0</TargetFramework>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms> <UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
@@ -16,7 +16,7 @@
<Product>AiQ GUI</Product> <Product>AiQ GUI</Product>
<Authors>MAV Systems Ltd</Authors> <Authors>MAV Systems Ltd</Authors>
<PackageId>AiQ GUI</PackageId> <PackageId>AiQ GUI</PackageId>
<Version>4.6.0</Version> <Version>4.5.0</Version>
<Description>A GUI to control and test the AiQ</Description> <Description>A GUI to control and test the AiQ</Description>
<Copyright>MAV Systems Ltd 2025</Copyright> <Copyright>MAV Systems Ltd 2025</Copyright>
<PackageIcon>MAV - Plain - Blue.png</PackageIcon> <PackageIcon>MAV - Plain - Blue.png</PackageIcon>
@@ -55,13 +55,14 @@
<PackageReference Include="ClosedXML" Version="0.105.0" /> <PackageReference Include="ClosedXML" Version="0.105.0" />
<PackageReference Include="Emgu.CV" Version="4.12.0.5764" /> <PackageReference Include="Emgu.CV" Version="4.12.0.5764" />
<PackageReference Include="Emgu.CV.runtime.windows" Version="4.12.0.5764" /> <PackageReference Include="Emgu.CV.runtime.windows" Version="4.12.0.5764" />
<PackageReference Include="Google.Apis.Auth" Version="1.73.0" /> <PackageReference Include="Google.Apis.Auth" Version="1.72.0" />
<PackageReference Include="Google.Apis.Sheets.v4" Version="1.72.0.3966" /> <PackageReference Include="Google.Apis.Gmail.v1" Version="1.70.0.3833" />
<PackageReference Include="Google.Apis.Sheets.v4" Version="1.70.0.3819" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
<PackageReference Include="PDFsharp-MigraDoc-gdi" Version="6.2.3" /> <PackageReference Include="PDFsharp-MigraDoc-gdi" Version="6.2.2" />
<PackageReference Include="Selenium.Support" Version="4.38.0" /> <PackageReference Include="Selenium.Support" Version="4.38.0" />
<PackageReference Include="Selenium.WebDriver" Version="4.38.0" /> <PackageReference Include="Selenium.WebDriver" Version="4.38.0" />
<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="142.0.7444.17500" /> <PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="142.0.7444.6100" />
<PackageReference Include="SSH.NET" Version="2025.1.0" /> <PackageReference Include="SSH.NET" Version="2025.1.0" />
<PackageReference Include="System.Data.OleDb" Version="10.0.0" /> <PackageReference Include="System.Data.OleDb" Version="10.0.0" />
</ItemGroup> </ItemGroup>

View File

@@ -8,7 +8,7 @@ namespace AiQ_GUI
{ {
if (CamMod == null || Lbl == null) if (CamMod == null || Lbl == null)
{ {
MainForm.Instance.AddToActionsList("Camera module or label was null in CheckCamModule."); MainForm.Instance.AddToActionsList("Camera module or label was null in CheckCamModule.", Level.ERROR);
return; return;
} }
@@ -25,13 +25,13 @@ namespace AiQ_GUI
} }
catch catch
{ {
MainForm.Instance.AddToActionsList($"{CamMod.firmwareVer} or {UniversalData.WonwooFirmware} could not be converted to a double"); MainForm.Instance.AddToActionsList($"{CamMod.firmwareVer} or {UniversalData.WonwooFirmware} could not be converted to a double", Level.ERROR);
} }
if (CamOnTest.RMANum > 0 && !LessTanOrEqualTo) if (CamOnTest.RMANum > 0 && LessTanOrEqualTo)
errMssg += $"Firmware: {CamMod.firmwareVer} should be less than or equal to {UniversalData.WonwooFirmware} for RMA {CamOnTest.RMANum}"; errMssg += $"Firmware: {CamMod.firmwareVer} should be less than or equal to {UniversalData.WonwooFirmware} for RMA {CamOnTest.RMANum}";
else if (CamOnTest.RMANum < 1 && CamMod.firmwareVer != UniversalData.WonwooFirmware) else if ((CamOnTest.RMANum == 0 || CamOnTest.RMANum == -1) && CamMod.firmwareVer != UniversalData.WonwooFirmware)
errMssg += $"Firmware: {CamMod.firmwareVer} should be {UniversalData.WonwooFirmware} "; errMssg += $"Firmware: {CamMod.firmwareVer} should be {UniversalData.WonwooFirmware} ";
if (CamMod.expMode != 0) // Auto 0=0x00 if (CamMod.expMode != 0) // Auto 0=0x00
@@ -55,7 +55,7 @@ namespace AiQ_GUI
} }
catch (Exception ex) catch (Exception ex)
{ {
MainForm.Instance.AddToActionsList("Exception in CheckCamModule: " + ex.Message); MainForm.Instance.AddToActionsList("Exception in CheckCamModule: " + ex.Message, Level.ERROR);
} }
} }
@@ -65,7 +65,7 @@ namespace AiQ_GUI
{ {
if (Shutter.SelectedIndex == -1 || Iris.SelectedIndex == -1 || Gain.SelectedIndex == -1) if (Shutter.SelectedIndex == -1 || Iris.SelectedIndex == -1 || Gain.SelectedIndex == -1)
{ {
MainForm.Instance.AddToActionsList("Shutter, Iris and Gain need selecting in images tab."); MainForm.Instance.AddToActionsList("Shutter, Iris and Gain need selecting in images tab.", Level.WARNING);
return; return;
} }
@@ -75,7 +75,7 @@ namespace AiQ_GUI
if (ShutterVISCA.Contains("ERROR") || IrisVISCA.Contains("ERROR") || GainVISCA.Contains("ERROR")) if (ShutterVISCA.Contains("ERROR") || IrisVISCA.Contains("ERROR") || GainVISCA.Contains("ERROR"))
{ {
MainForm.Instance.AddToActionsList("Problem with selected SIG values"); MainForm.Instance.AddToActionsList("Problem with selected SIG values", Level.ERROR);
return; return;
} }
@@ -85,7 +85,7 @@ namespace AiQ_GUI
string OneshotReply = await FlexiAPI.APIHTTPVISCA(IPAddress, "8101041801FF", true); // Oneshot auto focus string OneshotReply = await FlexiAPI.APIHTTPVISCA(IPAddress, "8101041801FF", true); // Oneshot auto focus
if (!ShutterReply.Contains("41") || !IrisReply.Contains("41") || !GainReply.Contains("41") || !OneshotReply.Contains("41")) if (!ShutterReply.Contains("41") || !IrisReply.Contains("41") || !GainReply.Contains("41") || !OneshotReply.Contains("41"))
MainForm.Instance.AddToActionsList("Could not set Shutter, Iris, Gain correctly" + Environment.NewLine + "Shutter: " + ShutterReply + Environment.NewLine + "Iris: " + IrisReply + Environment.NewLine + "Gain: " + GainReply + Environment.NewLine + "Oneshot: " + OneshotReply); MainForm.Instance.AddToActionsList("Could not set Shutter, Iris, Gain correctly" + Environment.NewLine + "Shutter: " + ShutterReply + Environment.NewLine + "Iris: " + IrisReply + Environment.NewLine + "Gain: " + GainReply + Environment.NewLine + "Oneshot: " + OneshotReply, Level.ERROR);
} }
// Sets back to the latest factory defaults CSV that is in Flexi. // Sets back to the latest factory defaults CSV that is in Flexi.
@@ -97,7 +97,7 @@ namespace AiQ_GUI
await Task.WhenAll(IRReply, OVReply); await Task.WhenAll(IRReply, OVReply);
if (IRReply.Result != "Factory reset OK." || OVReply.Result != "Factory reset OK.") if (IRReply.Result != "Factory reset OK." || OVReply.Result != "Factory reset OK.")
MainForm.Instance.AddToActionsList($"Could not reset camera modules to factory default.{Environment.NewLine}{IRReply}{Environment.NewLine}{OVReply}"); MainForm.Instance.AddToActionsList($"Could not reset camera modules to factory default.{Environment.NewLine}{IRReply}{Environment.NewLine}{OVReply}", Level.ERROR);
} }
public static string BuildVISCACommand(string command, int hexValue) public static string BuildVISCACommand(string command, int hexValue)
@@ -107,33 +107,5 @@ namespace AiQ_GUI
// Build the final VISCA command string using the input characters split as p and q // Build the final VISCA command string using the input characters split as p and q
return $"8101044{command}00000{hex[0]}0{hex[1]}FF"; return $"8101044{command}00000{hex[0]}0{hex[1]}FF";
} }
public static async Task<bool> SetZoomLockOn(string IP)
{
// Set Zoomlock on and if it fails ask user to set it manually
if (!(await FlexiAPI.APIHTTPRequest("/api/zoomLock?enable=true", IP)).Contains("Zoom lock enabled.")
&& !await MainForm.Instance.DisplayQuestion("Could not set zoomlock on" + Environment.NewLine + "Set Zoomlock to on then click YES. Click NO to restart."))
{
return false;
}
return true;
}
public static async Task<bool> ZoomModules(string VISCAInput, string IPAddress)
{
// Populate the VISCA command with the four zoom characters
string VISCA = $"810104470{VISCAInput[0]}0{VISCAInput[1]}0{VISCAInput[2]}0{VISCAInput[3]}FF";
Task<string> TS1 = FlexiAPI.APIHTTPVISCA(IPAddress, VISCA, true);
Task<string> TS2 = FlexiAPI.APIHTTPVISCA(IPAddress, VISCA, false);
await Task.WhenAll(TS1, TS2);
const string ExpReply = "9041FF9051FF";
if (TS1.Result == ExpReply && TS1.Result == ExpReply)
return true;
return false;
}
} }
} }

View File

@@ -24,7 +24,7 @@ namespace AiQ_GUI
} }
catch (Exception ex) catch (Exception ex)
{ {
return $"Error during GET request: {ex.Message}"; return $"Error during GET request: {ex.Message}{Level.ERROR}";
} }
} }
@@ -42,7 +42,7 @@ namespace AiQ_GUI
} }
catch (Exception ex) catch (Exception ex)
{ {
return $"Error in HTTP_Update: {ex.Message}"; return $"Error in HTTP_Update: {ex.Message}{Level.ERROR}";
} }
} }
@@ -56,7 +56,7 @@ namespace AiQ_GUI
} }
catch (Exception ex) catch (Exception ex)
{ {
return $"Error in HTTP_Fetch: {ex.Message}"; return $"Error in HTTP_Fetch: {ex.Message}{Level.ERROR}";
} }
} }
@@ -101,21 +101,22 @@ namespace AiQ_GUI
string responseBody = await response.Content.ReadAsStringAsync(); string responseBody = await response.Content.ReadAsStringAsync();
if (!response.IsSuccessStatusCode) if (!response.IsSuccessStatusCode)
return $"Server returned {(int)response.StatusCode}: {response.ReasonPhrase}. Details: {responseBody}"; return $"Server returned {(int)response.StatusCode}: {response.ReasonPhrase}. Details: {responseBody}{Level.ERROR}";
return responseBody; return responseBody;
} }
catch (TaskCanceledException) catch (TaskCanceledException)
{ {
return $"Timeout uploading to {url}."; return $"Timeout uploading to {url}.{Level.ERROR}";
} }
catch (HttpRequestException ex) catch (HttpRequestException ex)
{ {
return $"HTTP error uploading to {url}: {ex.Message}"; return $"HTTP error uploading to {url}: {ex.Message}{Level.ERROR}";
} }
catch (Exception ex) catch (Exception ex)
{ {
return $"Unexpected error uploading to {url}: {ex.Message} {(ex.InnerException?.Message ?? "")}"; return $"Unexpected error uploading to {url}: {ex.Message} {(ex.InnerException?.Message ?? string.Empty)} {Level.ERROR}";
} }
} }
@@ -145,7 +146,7 @@ namespace AiQ_GUI
if (JSON == null || JSON.Contains("Error") || JSON.Contains("Timeout")) if (JSON == null || JSON.Contains("Error") || JSON.Contains("Timeout"))
{ {
MainForm.Instance.AddToActionsList("Error talking to Flexi, are you sure this is an AiQ?" + Environment.NewLine + JSON); MainForm.Instance.AddToActionsList($"Error talking to Flexi, are you sure this is an AiQ?{Level.WARNING}" + Environment.NewLine + JSON);
return null; return null;
} }
@@ -173,13 +174,13 @@ namespace AiQ_GUI
// Treat "operation was canceled" as a successful apply // Treat "operation was canceled" as a successful apply
if (response.Contains("The operation was canceled", StringComparison.OrdinalIgnoreCase)) if (response.Contains("The operation was canceled", StringComparison.OrdinalIgnoreCase))
{ {
Logging.LogMessage("SetVaxtorMinMaxPlate: Camera applied config but closed connection early (safe to ignore)."); Logging.LogMessage($"SetVaxtorMinMaxPlate: Camera applied config but closed connection early (safe to ignore).{Level.WARNING}");
return true; return true;
} }
if (response.Contains("error", StringComparison.OrdinalIgnoreCase)) if (response.Contains("error", StringComparison.OrdinalIgnoreCase))
{ {
MainForm.Instance.DisplayQuestion($"SetVaxtorMinMaxPlate: failed - Please set manually"); MainForm.Instance.DisplayQuestion($"SetVaxtorMinMaxPlate: failed - Please set manually{Level.WARNING}");
return false; return false;
} }
@@ -187,21 +188,37 @@ namespace AiQ_GUI
} }
catch (Exception ex) catch (Exception ex)
{ {
MainForm.Instance.AddToActionsList($"Could not set Vaxtor Plate height and min confidence: {ex.Message}"); MainForm.Instance.AddToActionsList($"Could not set Vaxtor Plate height and min confidence: {ex.Message}{Level.ERROR}");
return false; return false;
} }
} }
public static async Task GPSFix(string IPAddress) public static async Task<bool> SetZoomLockOn(string IP)
{ {
string sysstatus = await APIHTTPRequest("/sysstatus", IPAddress, 5); // Set Zoomlock on and if it fails ask user to set it manually
SysStatus status = JsonConvert.DeserializeObject<SysStatus>(sysstatus); if (!(await APIHTTPRequest("/api/zoomLock?enable=true", IP)).Contains("Zoom lock enabled.")
&& !await MainForm.Instance.DisplayQuestion($"Could not set zoomlock on{Level.WARNING}" + Environment.NewLine + $"Set Zoomlock to on then click YES. Click NO to restart. {Level.WARNING}"))
if (status.gpsState == 0 || status.gpsPresent == "Not Fitted")
{ {
MainForm.Instance.AddToActionsList($"GPS not present in camera. State: {status.gpsState} & Status: {status.gpsPresent}"); return false;
return;
} }
return true;
}
public static async Task<bool> ZoomModules(string VISCAInput, string IPAddress)
{
// Populate the VISCA command with the four zoom characters
string VISCA = $"810104470{VISCAInput[0]}0{VISCAInput[1]}0{VISCAInput[2]}0{VISCAInput[3]}FF";
Task<string> TS1 = APIHTTPVISCA(IPAddress, VISCA, true);
Task<string> TS2 = APIHTTPVISCA(IPAddress, VISCA, false);
await Task.WhenAll(TS1, TS2);
const string ExpReply = "9041FF9051FF";
if (TS1.Result == ExpReply && TS1.Result == ExpReply)
return true;
return false;
} }
public static async Task SetTrim(string IPAddress, string LblTxt, int RetryCount = 0) // Sets trim by getting plate postion as metric public static async Task SetTrim(string IPAddress, string LblTxt, int RetryCount = 0) // Sets trim by getting plate postion as metric
@@ -216,7 +233,7 @@ namespace AiQ_GUI
} }
catch catch
{ {
MainForm.Instance.AddToActionsList("Error reading trim JSON - " + trimData); MainForm.Instance.AddToActionsList($"Error reading trim JSON - {Level.ERROR}" + trimData);
return; return;
} }
@@ -225,7 +242,7 @@ namespace AiQ_GUI
{ {
if (RetryCount >= 3) if (RetryCount >= 3)
{ {
await MainForm.Instance.DisplayOK("Please align trim in webpage then click OK."); // Awaited till OK has been clicked await MainForm.Instance.DisplayOK($"Please align trim in webpage then click OK.{Level.WARNING}"); // Awaited till OK has been clicked
return; return;
} }
@@ -253,11 +270,11 @@ namespace AiQ_GUI
} }
else // Ask user to centre the plate in the field of view else // Ask user to centre the plate in the field of view
{ {
await MainForm.Instance.DisplayOK("Please centralise plate in view THEN press OK"); // Awaited till OK has been clicked await MainForm.Instance.DisplayOK($"Please centralise plate in view THEN press OK {Level.WARNING}"); // Awaited till OK has been clicked
if (RetryCount >= 3) if (RetryCount >= 3)
{ {
await MainForm.Instance.DisplayOK("Please align trim in webpage then click OK."); // Awaited till OK has been clicked await MainForm.Instance.DisplayOK($"Please align trim in webpage then click OK. {Level.WARNING}"); // Awaited till OK has been clicked
return; return;
} }
await Task.Delay(5000); // Give 5 second delay for it to see a plate await Task.Delay(5000); // Give 5 second delay for it to see a plate
@@ -274,7 +291,7 @@ namespace AiQ_GUI
string TrimResp = await HTTP_Update("SightingCreator", IPAddress, Trim_JSON); string TrimResp = await HTTP_Update("SightingCreator", IPAddress, Trim_JSON);
if (!TrimResp.Contains($"\"propInterCameraOffsetX\": {{\"value\": \"{Convert.ToString(TrimX)}\", \"datatype\": \"int\"}}, \"propInterCameraOffsetY\": {{\"value\": \"{Convert.ToString(TrimY)}\", \"datatype\": \"int\"}},")) if (!TrimResp.Contains($"\"propInterCameraOffsetX\": {{\"value\": \"{Convert.ToString(TrimX)}\", \"datatype\": \"int\"}}, \"propInterCameraOffsetY\": {{\"value\": \"{Convert.ToString(TrimY)}\", \"datatype\": \"int\"}},"))
MainForm.Instance.AddToActionsList("Could not set camera trim"); MainForm.Instance.AddToActionsList($"Could not set camera trim{Level.ERROR}");
} }
// Processes the network config from the camera and returns a string indicating the status // Processes the network config from the camera and returns a string indicating the status
@@ -292,7 +309,7 @@ namespace AiQ_GUI
} }
catch (Exception ex) catch (Exception ex)
{ {
MainForm.Instance.AddToActionsList($"Error in getting network config from camera: {ex.Message}"); MainForm.Instance.AddToActionsList($"Error in getting network config from camera: {ex.Message}{Level.ERROR}");
return null; // Return empty string if there is an error return null; // Return empty string if there is an error
} }
} }
@@ -348,11 +365,11 @@ namespace AiQ_GUI
if (FoundCams.Contains("192.168.1.211")) if (FoundCams.Contains("192.168.1.211"))
{ {
MainForm.Instance.AddToActionsList("Could not set camera to DHCP please check camera."); MainForm.Instance.AddToActionsList($"Could not set camera to DHCP please check camera.{Level.ERROR}");
return false; return false;
} }
MainForm.Instance.AddToActionsList("Camera successfully set to DHCP."); MainForm.Instance.AddToActionsList($"Camera successfully set to DHCP.{Level.Success}");
return true; return true;
} }
@@ -410,14 +427,14 @@ namespace AiQ_GUI
string result = await APIHTTPVISCA(ipAddress, command, isIR); string result = await APIHTTPVISCA(ipAddress, command, isIR);
if (result.Contains(expectedResponse)) if (result.Contains(expectedResponse))
MainForm.Instance.AddToActionsList($"{name}: Success ({(isIR ? "IR" : "Colour")})", Level.LOG); MainForm.Instance.AddToActionsList($"{name}: Success ({(isIR ? "IR" : "Colour")})", Level.Success);
else else
MainForm.Instance.AddToActionsList($"{name}: Unexpected response ({result})", Level.ERROR); MainForm.Instance.AddToActionsList($"{name}: Unexpected response ({result})", Level.ERROR);
await Task.Delay(150); await Task.Delay(150);
} }
MainForm.Instance.AddToActionsList($"Upload complete ({(isIR ? "IR" : "Colour")}).", Level.LOG); MainForm.Instance.AddToActionsList($"Upload complete ({(isIR ? "IR" : "Colour")}).", Level.Success);
} }
public static async void UploadBlob(List<Camera> soakCameraList) public static async void UploadBlob(List<Camera> soakCameraList)
@@ -431,7 +448,7 @@ namespace AiQ_GUI
if (fileToUpload == null) if (fileToUpload == null)
{ {
MainForm.Instance.AddToActionsList("No .blob file found in the directory.", Level.ERROR); MainForm.Instance.AddToActionsList("No .blob file found in the directory.", Level.WARNING);
return; return;
} }
} }
@@ -472,7 +489,7 @@ namespace AiQ_GUI
result = await SendBlobFileUpload(apiUrl, fileToUpload, fileName); result = await SendBlobFileUpload(apiUrl, fileToUpload, fileName);
} }
MainForm.Instance.AddToActionsList($"Upload result for {cam.IP}: {result}", Level.LOG); MainForm.Instance.AddToActionsList($"Upload result for {cam.IP}: {result}");
await Task.Delay(500); await Task.Delay(500);
} }
} }
@@ -541,12 +558,6 @@ namespace AiQ_GUI
public int colourY { get; set; } public int colourY { get; set; }
} }
public class SysStatus
{
public int gpsState { get; set; } = 0;
public string gpsPresent { get; set; } = string.Empty;
}
public class NetworkConfig public class NetworkConfig
{ {
public Property propDHCP { get; set; } = new Property(); public Property propDHCP { get; set; } = new Property();

View File

@@ -26,7 +26,7 @@ namespace AiQ_GUI
HttpResponseMessage response = await httpClient.GetAsync(requestUrl); HttpResponseMessage response = await httpClient.GetAsync(requestUrl);
if (!response.IsSuccessStatusCode) if (!response.IsSuccessStatusCode)
{ {
MainForm.Instance.AddToActionsList($"No success from {requestUrl} replied {response.StatusCode}"); MainForm.Instance.AddToActionsList($"No success from {requestUrl} replied {response.StatusCode}{Level.ERROR}");
return null; return null;
} }
@@ -34,7 +34,7 @@ namespace AiQ_GUI
if (imageBytes.Length == 0) // Check if the imageBytes is empty if (imageBytes.Length == 0) // Check if the imageBytes is empty
{ {
MainForm.Instance.AddToActionsList($"No image data received from {requestUrl}"); MainForm.Instance.AddToActionsList($"No image data received from {requestUrl}{Level.ERROR}");
return null; return null;
} }
@@ -43,7 +43,7 @@ namespace AiQ_GUI
CvInvoke.Imdecode(imageBytes, ImreadModes.AnyColor, mat); CvInvoke.Imdecode(imageBytes, ImreadModes.AnyColor, mat);
if (mat.IsEmpty) if (mat.IsEmpty)
{ {
MainForm.Instance.AddToActionsList("Failed to decode image with Emgu CV."); MainForm.Instance.AddToActionsList($"Failed to decode image with Emgu CV.{Level.ERROR}");
return null; return null;
} }
@@ -70,12 +70,12 @@ namespace AiQ_GUI
} }
catch (HttpRequestException ex) catch (HttpRequestException ex)
{ {
MainForm.Instance.AddToActionsList($"HTTP error: {ex.Message}"); MainForm.Instance.AddToActionsList($"HTTP error: {ex.Message}{Level.ERROR}");
return null; return null;
} }
catch (Exception ex) catch (Exception ex)
{ {
MainForm.Instance.AddToActionsList($"Error processing image: {ex.Message}"); MainForm.Instance.AddToActionsList($"Error processing image: {ex.Message} {Level.ERROR}");
return null; return null;
} }
} }
@@ -123,7 +123,7 @@ namespace AiQ_GUI
} }
catch (Exception ex) catch (Exception ex)
{ {
MainForm.Instance.AddToActionsList($"Error awaiting Colour snapshot: {ex.Message}"); MainForm.Instance.AddToActionsList($"Error awaiting Colour snapshot: {ex.Message} {Level.ERROR}");
return; return;
} }
@@ -146,7 +146,7 @@ namespace AiQ_GUI
} }
catch (Exception ex) catch (Exception ex)
{ {
MainForm.Instance.AddToActionsList($"Error calculating luminance: {ex.Message}"); MainForm.Instance.AddToActionsList($"Error calculating luminance: {ex.Message} {Level.ERROR}");
return; return;
} }
} }

View File

@@ -45,7 +45,7 @@
} }
catch (Exception ex) catch (Exception ex)
{ {
MainForm.Instance.AddToActionsList($"Error checking LEDs: {ex.Message}"); MainForm.Instance.AddToActionsList($"Error checking LEDs: {ex.Message} {Level.ERROR}");
} }
} }
} }

View File

@@ -25,13 +25,13 @@ namespace AiQ_GUI
else if (Type == "Audit") else if (Type == "Audit")
salt = Auditsalt; salt = Auditsalt;
else else
return "Unrecognised challenge type: " + Type; return $"Unrecognised challenge type:{Level.ERROR}" + Type;
if (string.IsNullOrEmpty(challenge) || challenge.Length != 6) // Check challenge format if (string.IsNullOrEmpty(challenge) || challenge.Length != 6) // Check challenge format
return "Invalid challenge format. Challenge must be 6 characters."; return $"Invalid challenge format. Challenge must be 6 characters.{Level.ERROR}";
if (string.IsNullOrEmpty(salt) || salt.Length != 32) // Check salt format if (string.IsNullOrEmpty(salt) || salt.Length != 32) // Check salt format
return "Invalid salt format. Salt must be 32 characters."; return $"Invalid salt format. Salt must be 32 characters.{Level.ERROR}";
// Hash computation using SHA256 algorithm // Hash computation using SHA256 algorithm
byte[] inputBytes = Encoding.UTF8.GetBytes(challenge + " " + salt); // SHA hash format challenge and salt with space between byte[] inputBytes = Encoding.UTF8.GetBytes(challenge + " " + salt); // SHA hash format challenge and salt with space between
@@ -60,7 +60,7 @@ namespace AiQ_GUI
} }
catch (Exception ex) catch (Exception ex)
{ {
return "Error: Could not generate password " + ex.Message; return $"Error: Could not generate password{Level.ERROR}" + ex.Message;
} }
} }
@@ -85,7 +85,7 @@ namespace AiQ_GUI
} }
catch (Exception ex) catch (Exception ex)
{ {
MainForm.Instance.AddToActionsList("Exception in FetchDevPassword: " + ex.Message); MainForm.Instance.AddToActionsList($"Exception in FetchDevPassword: {Level.ERROR}" + ex.Message);
return null; return null;
} }
} }

View File

@@ -32,7 +32,7 @@ namespace AiQ_GUI
} }
catch catch
{ {
MainForm.Instance.AddToActionsList("Is the router on the network? Has the MAV Config file been applied?"); MainForm.Instance.AddToActionsList($"Is the router on the network? Has the MAV Config file been applied?{Level.WARNING}");
} }
return null; return null;
@@ -48,31 +48,31 @@ namespace AiQ_GUI
if (Strength < 25.0) if (Strength < 25.0)
{ {
MainForm.Instance.AddToActionsList($"Router signal strength is {Strength} which is below 25%. Please check the router connection."); MainForm.Instance.AddToActionsList($"Router signal strength is {Strength} which is below 25%. Please check the router connection.{Level.WARNING}");
PassTest = false; PassTest = false;
} }
if (!Router.SimStatus.Contains("SIM Ready")) if (!Router.SimStatus.Contains("SIM Ready"))
{ {
MainForm.Instance.AddToActionsList($"SIM card is not ready. {Router.SimStatus} Please check the SIM card status."); MainForm.Instance.AddToActionsList($"SIM card is not ready. {Router.SimStatus} Please check the SIM card status.{Level.WARNING}");
PassTest = false; PassTest = false;
} }
if (!Router.Port3Status.Contains("port:3 link:up speed:100baseT full-duplex")) if (!Router.Port3Status.Contains("port:3 link:up speed:100baseT full-duplex"))
{ {
MainForm.Instance.AddToActionsList($"Port 3 is not connected properly. {Router.Port3Status} Please check the connection."); MainForm.Instance.AddToActionsList($"Port 3 is not connected properly. {Router.Port3Status} Please check the connection. {Level.WARNING}");
PassTest = false; PassTest = false;
} }
if (!Router.Port4Status.Contains("port:4 link:up speed:100baseT full-duplex")) if (!Router.Port4Status.Contains("port:4 link:up speed:100baseT full-duplex"))
{ {
MainForm.Instance.AddToActionsList($"Port 4 is not connected properly. {Router.Port4Status} Please check the connection."); MainForm.Instance.AddToActionsList($"Port 4 is not connected properly. {Router.Port4Status} Please check the connection. {Level.WARNING}");
PassTest = false; PassTest = false;
} }
if (!Router.GoodPing) if (!Router.GoodPing)
{ {
MainForm.Instance.AddToActionsList("Router could not ping 8.8.8.8. Please check the online connection."); MainForm.Instance.AddToActionsList($"Router could not ping 8.8.8.8. Please check the online connection.{Level.WARNING}");
PassTest = false; PassTest = false;
} }

View File

@@ -25,7 +25,7 @@ namespace AiQ_GUI
} }
catch (Exception Ex) catch (Exception Ex)
{ {
MainForm.Instance.AddToActionsList($"SSH connection failed: {Ex.Message}. Check password or network."); MainForm.Instance.AddToActionsList($"SSH connection failed: {Ex.Message}. Check password or network. {Level.WARNING}");
} }
return null; return null;
@@ -75,7 +75,7 @@ namespace AiQ_GUI
} }
catch (Exception ex) catch (Exception ex)
{ {
MainForm.Instance.AddToActionsList($"SSH connection failed: {ex.Message}. Check password or network."); MainForm.Instance.AddToActionsList($"SSH connection failed: {ex.Message}. Check password or network. {Level.WARNING}");
} }
string LogMssg = string.Join(" | ", typeof(SSHData).GetProperties().Select(p => $"{p.Name}: {p.GetValue(Data)}")); string LogMssg = string.Join(" | ", typeof(SSHData).GetProperties().Select(p => $"{p.Name}: {p.GetValue(Data)}"));
@@ -170,7 +170,7 @@ namespace AiQ_GUI
} }
catch (Exception ex) catch (Exception ex)
{ {
MainForm.Instance.AddToActionsList($"SSH connection failed: {ex.Message}. Check password or network."); MainForm.Instance.AddToActionsList($"SSH connection failed: {ex.Message}. Check password or network. {Level.WARNING}");
} }
return (string.Empty, string.Empty); return (string.Empty, string.Empty);
@@ -323,7 +323,7 @@ namespace AiQ_GUI
if (checkDevice.Result.Trim() != "OK") // Device not found if (checkDevice.Result.Trim() != "OK") // Device not found
{ {
MainForm.Instance.AddToActionsList($"Block device {device} not found."); MainForm.Instance.AddToActionsList($"Block device {device} not found. {Level.WARNING}");
return false; return false;
} }
@@ -378,7 +378,7 @@ namespace AiQ_GUI
if (checkDevice.Result.Trim().Length > 1) // Device not found if (checkDevice.Result.Trim().Length > 1) // Device not found
{ {
MainForm.Instance.AddToActionsList($"Cannot sync files to disk. Replied: {checkDevice.Result}. DO NOT TURN OFF, GET SUPERVISOR"); MainForm.Instance.AddToActionsList($"Cannot sync files to disk. Replied: {checkDevice.Result}. DO NOT TURN OFF, GET SUPERVISOR {Level.ERROR}");
return; return;
} }
@@ -387,7 +387,7 @@ namespace AiQ_GUI
} }
catch (Exception ex) catch (Exception ex)
{ {
MainForm.Instance.AddToActionsList($"Cannot sync becuase: {ex.Message}. DO NOT TURN OFF, GET SUPERVISOR"); MainForm.Instance.AddToActionsList($"Cannot sync becuase: {ex.Message}. DO NOT TURN OFF, GET SUPERVISOR {Level.ERROR}");
} }
} }
} }

View File

@@ -107,12 +107,12 @@ namespace AiQ_GUI
} }
else else
{ {
return "Last serial number not found"; return $"Last serial number not found{Level.ERROR}";
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
return $"ERROR: {ex.Message}"; return $"ERROR: {ex.Message}{Level.ERROR}";
} }
} }
@@ -148,12 +148,12 @@ namespace AiQ_GUI
} }
else else
{ {
return "Serial number not found"; return $"Serial number not found{Level.ERROR}";
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
return $"ERROR: {ex.Message}"; return $"ERROR: {ex.Message}{Level.ERROR}";
} }
} }
@@ -196,7 +196,7 @@ namespace AiQ_GUI
} }
catch (Exception ex) catch (Exception ex)
{ {
return "Failed to update spreadsheet data, please check manually" + ex.Message; return $"Failed to update spreadsheet data, please check manually{Level.ERROR}" + ex.Message;
} }
} }
@@ -225,7 +225,7 @@ namespace AiQ_GUI
} }
catch (Exception ex) catch (Exception ex)
{ {
return "Failed to update spreadsheet data, please check manually" + ex.Message; return $"Failed to update spreadsheet data, please check manually{Level.WARNING}" + ex.Message;
} }
} }

View File

@@ -83,26 +83,26 @@ namespace AiQ_GUI
case 0: case 0:
if (!await MainForm.Instance.DisplayQuestion("Is the sleeve aligned correctly?")) if (!await MainForm.Instance.DisplayQuestion("Is the sleeve aligned correctly?"))
{ {
await MainForm.Instance.TestFailed(Btn, "Visual Test Fail - Sleeve not aligned"); await MainForm.Instance.TestFailed(Btn, $"Visual Test Fail - Sleeve not aligned{Level.ERROR}");
} }
break; break;
case 1: case 1:
if (!await MainForm.Instance.DisplayQuestion("Are all the screws fitted in the front?")) if (!await MainForm.Instance.DisplayQuestion("Are all the screws fitted in the front?"))
{ {
await MainForm.Instance.TestFailed(Btn, "Visual Test Fail - Not all front screws fitted"); await MainForm.Instance.TestFailed(Btn, $"Visual Test Fail - Not all front screws fitted{Level.ERROR}");
} }
break; break;
case 2: case 2:
if (!await MainForm.Instance.DisplayQuestion("Are all the screws fitted in the rear?")) if (!await MainForm.Instance.DisplayQuestion("Are all the screws fitted in the rear?"))
{ {
await MainForm.Instance.TestFailed(Btn, "Visual Test Fail - Not all rear screws fitted"); await MainForm.Instance.TestFailed(Btn, $"Visual Test Fail - Not all rear screws fitted{Level.ERROR}");
} }
break; break;
case 3: case 3:
if (await MainForm.Instance.DisplayQuestion("Shake unit, does it rattle?")) if (await MainForm.Instance.DisplayQuestion("Shake unit, does it rattle?"))
{ {
await MainForm.Instance.TestFailed(Btn, "Visual Test Fail - Unit rattles"); await MainForm.Instance.TestFailed(Btn, $"Visual Test Fail - Unit rattles{Level.ERROR}");
} }
break; break;
default: default:
@@ -123,7 +123,7 @@ namespace AiQ_GUI
} }
catch (Exception ex) catch (Exception ex)
{ {
MainForm.Instance.AddToActionsList($"Error fetching versions for {IPAddress}: {ex.Message}"); MainForm.Instance.AddToActionsList($"Error fetching versions for {IPAddress}: {ex.Message}{Level.ERROR}");
return null; return null;
} }

4
LDS.cs
View File

@@ -30,7 +30,7 @@ namespace AiQ_GUI
} }
catch // If file can't deserialise catch // If file can't deserialise
{ {
MainForm.Instance.AddToActionsList("Error loading Local Data Store"); MainForm.Instance.AddToActionsList($"Error loading Local Data Store{Level.WARNING}");
return null; // Return null to indicate failure return null; // Return null to indicate failure
} }
} }
@@ -45,7 +45,7 @@ namespace AiQ_GUI
} }
catch (Exception ex) catch (Exception ex)
{ {
MainForm.Instance.AddToActionsList($"Error saving Local Data Store: {ex.Message}"); MainForm.Instance.AddToActionsList($"Error saving Local Data Store: {ex.Message}{Level.WARNING}");
} }
} }
} }

View File

@@ -1,4 +1,6 @@
namespace AiQ_GUI using System.Diagnostics;
namespace AiQ_GUI
{ {
internal class Logging internal class Logging
{ {
@@ -41,7 +43,7 @@
} }
catch (Exception ex) catch (Exception ex)
{ {
MessageBox.Show($"Error logging message: {ex.Message}"); MainForm.Instance.AddToActionsList($"Error logging message: {ex.Message}{Level.ERROR}");
} }
} }
} }

View File

@@ -123,13 +123,13 @@ namespace AiQ_GUI
int rowsAffected = cmd.ExecuteNonQuery(); int rowsAffected = cmd.ExecuteNonQuery();
// Execute the command and get the number of rows affected // Execute the command and get the number of rows affected
if (rowsAffected == 0) // If one or more rows were updated if (rowsAffected == 0) // If one or more rows were updated
MainForm.Instance.AddToActionsList($"No rows affected for {modelNumber}"); MainForm.Instance.AddToActionsList($"No rows affected for {modelNumber}{Level.ERROR}");
} }
conn.Close(); conn.Close();
} }
catch catch
{ {
MainForm.Instance.AddToActionsList("Could not access Access in Google Drive. Is it running?"); MainForm.Instance.AddToActionsList($"Could not access Access in Google Drive. Is it running?{Level.WARNING}");
return; return;
} }
} }
@@ -161,7 +161,7 @@ namespace AiQ_GUI
conn.Close(); conn.Close();
if (rows == 0) if (rows == 0)
MainForm.Instance.AddToActionsList("No rows inserted into DiagsStats (unexpected)."); MainForm.Instance.AddToActionsList($"No rows inserted into DiagsStats (unexpected).{Level.ERROR}");
} }
} }

View File

@@ -17,7 +17,7 @@ namespace AiQ_GUI
} }
else else
{ {
MainForm.Instance.AddToActionsList("Could not find spreadsheet :("); MainForm.Instance.AddToActionsList($"Could not find spreadsheet :( {Level.ERROR}");
} }
} }
@@ -31,7 +31,7 @@ namespace AiQ_GUI
} }
else else
{ {
MainForm.Instance.AddToActionsList("Could not find spreadsheet :("); MainForm.Instance.AddToActionsList($"Could not find spreadsheet :( {Level.ERROR}");
} }
return null; return null;
} }
@@ -40,7 +40,7 @@ namespace AiQ_GUI
{ {
if (!File.Exists(FilePath)) if (!File.Exists(FilePath))
{ {
MainForm.Instance.AddToActionsList("Could not find spreadsheet :("); MainForm.Instance.AddToActionsList($"Could not find spreadsheet :( {Level.ERROR}");
return -1; return -1;
} }
@@ -62,7 +62,7 @@ namespace AiQ_GUI
{ {
if (!File.Exists(FilePath)) if (!File.Exists(FilePath))
{ {
MainForm.Instance.AddToActionsList("Could not find spreadsheet :("); MainForm.Instance.AddToActionsList($"Could not find spreadsheet :( {Level.ERROR}");
return "Spreadsheet not found"; return "Spreadsheet not found";
} }
@@ -114,7 +114,7 @@ namespace AiQ_GUI
{ {
if (!File.Exists(filePath)) if (!File.Exists(filePath))
{ {
MainForm.Instance.AddToActionsList("Could not find spreadsheet :("); MainForm.Instance.AddToActionsList($"Could not find spreadsheet :) {Level.ERROR}");
return "Spreadsheet not found"; return "Spreadsheet not found";
} }
@@ -150,7 +150,7 @@ namespace AiQ_GUI
} }
catch (Exception ex) catch (Exception ex)
{ {
MainForm.Instance.AddToActionsList("Error updating spreadsheet: " + ex.Message); MainForm.Instance.AddToActionsList($"Error updating spreadsheet:{Level.ERROR} " + ex.Message);
return $"ERROR: {ex.Message}"; return $"ERROR: {ex.Message}";
} }
} }
@@ -161,7 +161,7 @@ namespace AiQ_GUI
{ {
if (!File.Exists(FilePath)) if (!File.Exists(FilePath))
{ {
MainForm.Instance.AddToActionsList("Could not find spreadsheet :("); MainForm.Instance.AddToActionsList($"Could not find spreadsheet :( {Level.ERROR}");
return "Spreadsheet not found"; return "Spreadsheet not found";
} }
@@ -202,8 +202,8 @@ namespace AiQ_GUI
} }
catch (Exception ex) catch (Exception ex)
{ {
MainForm.Instance.AddToActionsList("Error updating spreadsheet: " + ex.Message); MainForm.Instance.AddToActionsList($"Error updating spreadsheet: {Level.WARNING}" + ex.Message);
return "Failed to update spreadsheet data, please check manually: " + ex.Message; return $"Failed to update spreadsheet data, please check manually: {Level.WARNING}" + ex.Message;
} }
} }
@@ -213,8 +213,9 @@ namespace AiQ_GUI
{ {
if (!File.Exists(FilePath)) if (!File.Exists(FilePath))
{ {
MainForm.Instance.AddToActionsList("Could not find spreadsheet :("); MainForm.Instance.AddToActionsList($"Could not find spreadsheet :( {Level.ERROR}");
return "Spreadsheet not found"; return $"Spreadsheet not found{ Level.ERROR}"
;
} }
using XLWorkbook workbook = new(FilePath); using XLWorkbook workbook = new(FilePath);
@@ -239,8 +240,8 @@ namespace AiQ_GUI
} }
catch (Exception ex) catch (Exception ex)
{ {
MainForm.Instance.AddToActionsList("Error updating Vaxtor spreadsheet: " + ex.Message); MainForm.Instance.AddToActionsList($"Error updating Vaxtor spreadsheet: {Level.WARNING}" + ex.Message);
return "Failed to update spreadsheet data, please check manually: " + ex.Message; return $"Failed to update spreadsheet data, please check manually: {Level.WARNING}" + ex.Message;
} }
} }
@@ -250,7 +251,7 @@ namespace AiQ_GUI
{ {
if (!File.Exists(filePath)) if (!File.Exists(filePath))
{ {
MainForm.Instance.AddToActionsList("Could not find RMA Control spreadsheet :("); MainForm.Instance.AddToActionsList($"Could not find RMA Control spreadsheet :({Level.ERROR}");
return 0; return 0;
} }
@@ -280,7 +281,7 @@ namespace AiQ_GUI
} }
catch (Exception ex) catch (Exception ex)
{ {
MainForm.Instance.AddToActionsList("Error reading RMA Control spreadsheet: " + ex.Message); MainForm.Instance.AddToActionsList($"Error reading RMA Control spreadsheet: {Level.ERROR}" + ex.Message);
} }
return 0; // Default if not found return 0; // Default if not found
@@ -292,7 +293,7 @@ namespace AiQ_GUI
{ {
if (!File.Exists(filePath)) if (!File.Exists(filePath))
{ {
MainForm.Instance.AddToActionsList("Could not find spreadsheet :("); MainForm.Instance.AddToActionsList($"Could not find spreadsheet :( {Level.ERROR}");
return 0; return 0;
} }
@@ -316,7 +317,7 @@ namespace AiQ_GUI
} }
catch (Exception ex) catch (Exception ex)
{ {
MainForm.Instance.AddToActionsList("Error checking serial number row: " + ex.Message); MainForm.Instance.AddToActionsList($"Error checking serial number row: {Level.ERROR}" + ex.Message);
} }
return 0; return 0;
@@ -328,7 +329,7 @@ namespace AiQ_GUI
{ {
if (!File.Exists(filePath)) if (!File.Exists(filePath))
{ {
MainForm.Instance.AddToActionsList("Could not find spreadsheet :("); MainForm.Instance.AddToActionsList($"Could not find spreadsheet :({Level.ERROR}");
return -1; return -1;
} }
@@ -343,7 +344,7 @@ namespace AiQ_GUI
} }
catch (Exception ex) catch (Exception ex)
{ {
MainForm.Instance.AddToActionsList("Error checking next free row: " + ex.Message); MainForm.Instance.AddToActionsList($"Error checking next free row: {Level.ERROR}" + ex.Message);
return -1; return -1;
} }
} }

View File

@@ -71,15 +71,15 @@ namespace AiQ_GUI
} }
catch (TaskCanceledException ex) catch (TaskCanceledException ex)
{ {
return $"HTTP error calling {url}: {ex.Message}"; return $"HTTP error calling {url}: {ex.Message}{Level.ERROR}";
} }
catch (HttpRequestException ex) catch (HttpRequestException ex)
{ {
return $"HTTP error calling {url}: {ex.Message}"; return $"HTTP error calling {url}: {ex.Message}{Level.ERROR}";
} }
catch (Exception ex) catch (Exception ex)
{ {
return $"Unexpected error calling {url}: {ex.Message}"; return $"Unexpected error calling {url}: {ex.Message}{Level.ERROR}";
} }
} }
@@ -157,9 +157,9 @@ namespace AiQ_GUI
PingReply reply = await myPing.SendPingAsync(ipAddress, 1000); // Timeout is 1s PingReply reply = await myPing.SendPingAsync(ipAddress, 1000); // Timeout is 1s
return reply.Status == IPStatus.Success; return reply.Status == IPStatus.Success;
} }
catch (PingException ex) { MainForm.Instance.AddToActionsList($"PingException: Unable to ping {ipAddress}. Reason: {ex.Message}"); } catch (PingException ex) { MainForm.Instance.AddToActionsList($"PingException: Unable to ping {ipAddress}. Reason: {ex.Message}{Level.WARNING}"); }
catch (SocketException ex) { MainForm.Instance.AddToActionsList($"SocketException: Network error while pinging {ipAddress}. Reason: {ex.Message}"); } catch (SocketException ex) { MainForm.Instance.AddToActionsList($"SocketException: Network error while pinging {ipAddress}. Reason: {ex.Message}{Level.ERROR}"); }
catch (Exception ex) { MainForm.Instance.AddToActionsList($"Unexpected error while pinging {ipAddress}: {ex.Message}"); } catch (Exception ex) { MainForm.Instance.AddToActionsList($"Unexpected error while pinging {ipAddress}: {ex.Message}{Level.ERROR}"); }
} }
return false; return false;

View File

@@ -19,7 +19,7 @@ namespace AiQ_GUI
} }
catch (WebDriverTimeoutException) catch (WebDriverTimeoutException)
{ {
MainForm.Instance.AddToActionsList("Could not load web page " + url + "1. Check camera has no password set. " + Environment.NewLine + "2. If unable to fix speak to supervisor."); MainForm.Instance.AddToActionsList($"Could not load web page {Level.ERROR}" + url + $"1. Check camera has no password set. {Level.ERROR}" + Environment.NewLine + $"2. If unable to fix speak to supervisor.{Level.ERROR}");
} }
} }
@@ -71,11 +71,11 @@ namespace AiQ_GUI
loginBtn.Click(); loginBtn.Click();
MainForm.Instance.AddToActionsList("Switched user and logged in."); MainForm.Instance.AddToActionsList($"Switched user and logged in.{Level.Success}");
} }
catch (Exception ex) catch (Exception ex)
{ {
MainForm.Instance.AddToActionsList("SwitchUser failed: " + ex.Message); MainForm.Instance.AddToActionsList($"SwitchUser failed: {Level.ERROR}" + ex.Message);
} }
} }
@@ -99,13 +99,15 @@ namespace AiQ_GUI
ClickElementByID(elementID, driver, false); ClickElementByID(elementID, driver, false);
} }
MainForm.Instance.AddToActionsList("Could not click " + elementID); MainForm.Instance.AddToActionsList($"Could not click {Level.WARNING}" + elementID);
} }
} }
// Initialises and opens a ChromeDriver with specific options // Initialises and opens a ChromeDriver with specific options
public static ChromeDriver OpenDriver() public static ChromeDriver OpenDriver()
{ {
string tempProfile = null;
try try
{ {
ChromeOptions options = new(); ChromeOptions options = new();
@@ -119,7 +121,7 @@ namespace AiQ_GUI
"--disable-features=BrowserAddPersonFeature,InterestFeedContentSuggestions"); "--disable-features=BrowserAddPersonFeature,InterestFeedContentSuggestions");
// Use a unique temporary profile to avoid conflicts // Use a unique temporary profile to avoid conflicts
string tempProfile = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); tempProfile = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
options.AddArguments($"--user-data-dir={tempProfile}"); options.AddArguments($"--user-data-dir={tempProfile}");
// manual driver path // manual driver path
@@ -134,7 +136,7 @@ namespace AiQ_GUI
} }
catch (Exception ex) catch (Exception ex)
{ {
MainForm.Instance.AddToActionsList("Failed to create ChromeDriver: " + ex.Message); MainForm.Instance.AddToActionsList($"Failed to create ChromeDriver: {Level.ERROR}" + ex.Message);
throw; throw;
} }
} }

View File

@@ -7,9 +7,8 @@ namespace AiQ_GUI
internal class SoakTest internal class SoakTest
{ {
// Main soak test loop: Randomise dropdowns, run luminance test every hour, power cycle at 7am // Main soak test loop: Randomise dropdowns, run luminance test every hour, power cycle at 7am
public static async Task StartSoak(Camera CamInfo, CancellationTokenSource CTS) public static async Task StartSoak(Camera CamInfo, CheckBox CkBx, CancellationToken token)
{ {
CancellationToken token = CTS.Token;
if (CamInfo.Serial == "N/A") if (CamInfo.Serial == "N/A")
CamInfo.Serial = "UNKNOWN"; // If serial is not set, set it to UNKNOWN. Cannot have N/A in file names. CamInfo.Serial = "UNKNOWN"; // If serial is not set, set it to UNKNOWN. Cannot have N/A in file names.
@@ -19,7 +18,6 @@ namespace AiQ_GUI
try try
{ {
driver = Selenium.OpenDriver(); driver = Selenium.OpenDriver();
Logging.LogMessage("----- Soak test started -----", SoakLogFile);
await Task.Delay(1000); // Small delay to ensure driver is ready await Task.Delay(1000); // Small delay to ensure driver is ready
// Keep retrying until connected or cancelled // Keep retrying until connected or cancelled
@@ -37,7 +35,7 @@ namespace AiQ_GUI
catch (Exception ex) catch (Exception ex)
{ {
SoakError($"Initial connection failed: {ex.Message}", SoakLogFile, CamInfo.CheckBox); SoakError($"Initial connection failed: {ex.Message}", SoakLogFile, CamInfo.CheckBox);
MainForm.Instance.AddToActionsList($"[{CamInfo.IP}] Initial connection failed: {ex.Message}"); MainForm.Instance.AddToActionsList($"[{CamInfo.IP}] Initial connection failed: {Level.ERROR}{ex.Message}");
// Wait 10 seconds before trying again // Wait 10 seconds before trying again
await Task.Delay(TimeSpan.FromSeconds(10), token); await Task.Delay(TimeSpan.FromSeconds(10), token);
@@ -52,7 +50,7 @@ namespace AiQ_GUI
} }
catch (Exception ex) catch (Exception ex)
{ {
SoakError($"Failed to get element IDs: {ex.Message}", SoakLogFile, CamInfo.CheckBox); SoakError($"Failed to get element IDs: {Level.ERROR} {ex.Message}", SoakLogFile, CamInfo.CheckBox);
return; return;
} }
@@ -60,16 +58,6 @@ namespace AiQ_GUI
while (!token.IsCancellationRequested) while (!token.IsCancellationRequested)
{ {
try
{
string TheString = "Selenium string: " + driver.Manage().Window.Size; // Fails out if Window doesn't exist.
}
catch
{
CTS.Cancel();
continue;
}
int currentHour = DateTime.Now.Hour; int currentHour = DateTime.Now.Hour;
// At 7am, power cycle the camera // At 7am, power cycle the camera
@@ -84,7 +72,7 @@ namespace AiQ_GUI
// Retry ping until camera responds or cancelled // Retry ping until camera responds or cancelled
while (!await Network.PingIP(CamInfo.IP) && !token.IsCancellationRequested) while (!await Network.PingIP(CamInfo.IP) && !token.IsCancellationRequested)
{ {
SoakError($"Camera did not respond after restart.", SoakLogFile, CamInfo.CheckBox); SoakError($"Camera did not respond after restart.{Level.ERROR}", SoakLogFile, CamInfo.CheckBox);
await Task.Delay(TimeSpan.FromMinutes(1), token); // Retry after delay of 1 minute await Task.Delay(TimeSpan.FromMinutes(1), token); // Retry after delay of 1 minute
} }
@@ -98,7 +86,7 @@ namespace AiQ_GUI
} }
catch (Exception ex) catch (Exception ex)
{ {
SoakError($"Error during power cycle: {ex.Message}", SoakLogFile, CamInfo.CheckBox); SoakError($"Error during power cycle: {Level.ERROR} {ex.Message}", SoakLogFile, CamInfo.CheckBox);
} }
} }
@@ -112,7 +100,7 @@ namespace AiQ_GUI
} }
catch (Exception ex) catch (Exception ex)
{ {
SoakError($"ImageCheck failed: {ex.Message}", SoakLogFile, CamInfo.CheckBox); SoakError($"ImageCheck failed: {Level.ERROR}{Level.ERROR} {ex.Message}", SoakLogFile, CamInfo.CheckBox);
} }
lastHour = currentHour; lastHour = currentHour;
} }
@@ -131,7 +119,7 @@ namespace AiQ_GUI
} }
catch (Exception ex) catch (Exception ex)
{ {
SoakError($"ChangeRandomDropdown failed: {ex.Message}", SoakLogFile, CamInfo.CheckBox); SoakError($"ChangeRandomDropdown failed: {Level.WARNING} {ex.Message}", SoakLogFile, CamInfo.CheckBox);
} }
try try
@@ -184,13 +172,13 @@ namespace AiQ_GUI
} }
catch (Exception ex) catch (Exception ex)
{ {
MainForm.Instance.AddToActionsList($"Failed to find final test report: {ex.Message}"); MainForm.Instance.AddToActionsList($"Failed to find final test report: {Level.ERROR}{ex.Message}");
} }
// Link PDFs if both exist // Link PDFs if both exist
if (!string.IsNullOrEmpty(finalTestPath) && File.Exists(finalTestPath) && !string.IsNullOrEmpty(SoakTestPath) && File.Exists(SoakTestPath)) if (!string.IsNullOrEmpty(finalTestPath) && File.Exists(finalTestPath) && !string.IsNullOrEmpty(SoakTestPath) && File.Exists(SoakTestPath))
{ {
string outputPath = finalTestDir + $"Final&SoakTestReport_{CamInfo.Model}_{CamInfo.Serial}_{DateTime.Now.ToString("dd-MM-yyyy_HH-mm-ss")}.pdf"; string outputPath = finalTestDir + $"Final&SoakTestReport_{CamInfo.Model}_{CamInfo.Serial}_{DateTime.Now.ToString("dd-MM-yyyy_HH-mm-ss")}.pdf{Level.Success}";
try try
{ {
if (PDF.LinkPDFs(finalTestPath, SoakTestPath, outputPath)) // Delete the separate soak and final test reports if Linking was successful if (PDF.LinkPDFs(finalTestPath, SoakTestPath, outputPath)) // Delete the separate soak and final test reports if Linking was successful
@@ -200,7 +188,7 @@ namespace AiQ_GUI
File.Delete(SoakTestPath); File.Delete(SoakTestPath);
} }
else else
MainForm.Instance.AddToActionsList($"Failed to link or delete PDFs"); MainForm.Instance.AddToActionsList($"Failed to link or delete PDFs {Level.ERROR}");
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -226,7 +214,7 @@ namespace AiQ_GUI
if (ImageBright == null) if (ImageBright == null)
{ {
Logging.LogWarningMessage($"Bright image is null for {controlType} at setting {SettingMinMax[0]}", SoakLogFile); Logging.LogWarningMessage($"Bright image is null for {controlType} at setting {SettingMinMax[0]}", SoakLogFile);
MainForm.Instance.AddToActionsList($"Bright image is null for {controlType} at setting {SettingMinMax[0]}"); MainForm.Instance.AddToActionsList($"Bright image is null for {controlType} at setting {SettingMinMax[0]}{Level.WARNING}");
return; return;
} }
@@ -240,7 +228,7 @@ namespace AiQ_GUI
if (ImageDark == null) if (ImageDark == null)
{ {
Logging.LogWarningMessage($"Dark image is null for {controlType} at setting {SettingMinMax[1]}", SoakLogFile); Logging.LogWarningMessage($"Dark image is null for {controlType} at setting {SettingMinMax[1]}", SoakLogFile);
MainForm.Instance.AddToActionsList($"Dark image is null for {controlType} at setting {SettingMinMax[1]}"); MainForm.Instance.AddToActionsList($"Dark image is null for {controlType} at setting {SettingMinMax[1]}{Level.WARNING}");
return; return;
} }
@@ -251,7 +239,7 @@ namespace AiQ_GUI
if (Bright_Lum < Dark_Lum * 1.01) if (Bright_Lum < Dark_Lum * 1.01)
{ {
SoakError( SoakError(
$"Insufficient luminance contrast. Bright: {Bright_Lum:F2}, Dark: {Dark_Lum:F2} | Type: {controlType} | Bright Setting: {SettingMinMax[0]}, Dark Setting: {SettingMinMax[1]}", $"Insufficient luminance contrast. Bright: {Bright_Lum:F2}, Dark: {Dark_Lum:F2} | Type: {controlType} | Bright Setting: {SettingMinMax[0]}, Dark Setting: {SettingMinMax[1]}{Level.WARNING}",
SoakLogFile, SoakLogFile,
CamInfo.CheckBox CamInfo.CheckBox
); );