V4.6
This commit is contained in:
19
AiQ_GUI.cs
19
AiQ_GUI.cs
@@ -47,7 +47,7 @@ namespace AiQ_GUI
|
||||
Task<LocalDataStore> LDSWAIT = Task.Run(() => LDS.GetLDS()); // Get and deserialise LDS.json
|
||||
Task<string> guiVerTask = Task.Run(() => GUIUpdate.FindGUIVersion()); // Get GUI Version
|
||||
|
||||
Network.Initialize("admin", "admin"); // Initialise HTTP client
|
||||
Network.Initialize("admin", "admin"); // Initialise HTTP client with basic auth creds.
|
||||
|
||||
if (await Network.PingIP("8.8.8.8")) // Ping to check if we're online
|
||||
{
|
||||
@@ -145,10 +145,10 @@ namespace AiQ_GUI
|
||||
|
||||
Task VisCheck = Helper.VisualCheck(BtnStartTest);
|
||||
|
||||
if (!await FlexiAPI.ZoomModules("1F40", CamOnTest.IP)) // Zoom to 8000 (1F40h) at the same time.
|
||||
if (!await CameraModules.ZoomModules("1F40", CamOnTest.IP)) // Zoom to 8000 (1F40h) at the same time.
|
||||
await TestFailed(BtnStartTest, "Could not zoom modules to 8000");
|
||||
|
||||
if (!await FlexiAPI.SetZoomLockOn(CamOnTest.IP))
|
||||
if (!await CameraModules.SetZoomLockOn(CamOnTest.IP))
|
||||
Helper.RestartApp();
|
||||
|
||||
await Task.Delay(1000); // Without sleep it kept failing the factory reset as camera modules were not ready yet
|
||||
@@ -169,6 +169,9 @@ namespace AiQ_GUI
|
||||
// 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
|
||||
|
||||
if (CameraAccessInfo.HardwareExtras.Contains("GPS")) // Check GPS if the hardware has it
|
||||
await FlexiAPI.GPSFix(CamOnTest.IP);
|
||||
|
||||
// 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.
|
||||
await SSH.CheckFSSize(CamOnTest.IP, LblFilesystemSize, sshData); // Check Filesystem size is between 100GB & 150GB
|
||||
@@ -188,7 +191,7 @@ namespace AiQ_GUI
|
||||
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
|
||||
|
||||
if (!await FlexiAPI.ZoomModules("0000", CamOnTest.IP)) // Zoom to full wide
|
||||
if (!await CameraModules.ZoomModules("0000", CamOnTest.IP)) // Zoom 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.
|
||||
@@ -235,7 +238,7 @@ namespace AiQ_GUI
|
||||
BtnPreTest.Enabled = BtnStartTest.Enabled = false; // Disable buttons to stop user rnning multiple tests at the same time.
|
||||
Logging.LogMessage("Pre Test Started");
|
||||
|
||||
if (!await FlexiAPI.SetZoomLockOn(CamOnTest.IP))
|
||||
if (!await CameraModules.SetZoomLockOn(CamOnTest.IP))
|
||||
Helper.RestartApp();
|
||||
|
||||
string LEDreply = await FlexiAPI.APIHTTPLED(CamOnTest.IP, LEDPOWER.MID); // Set LED's to medium (0x30)
|
||||
@@ -1465,7 +1468,7 @@ namespace AiQ_GUI
|
||||
|
||||
private async void BtnZoomWide_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (await FlexiAPI.ZoomModules("0000", CamOnTest.IP))
|
||||
if (await CameraModules.ZoomModules("0000", CamOnTest.IP))
|
||||
BtnZoomWide.BackColor = Color.Green;
|
||||
else
|
||||
BtnZoomWide.BackColor = Color.Red;
|
||||
@@ -1475,7 +1478,7 @@ namespace AiQ_GUI
|
||||
|
||||
private async void BtnZoom8000_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (await FlexiAPI.ZoomModules("1F40", CamOnTest.IP))
|
||||
if (await CameraModules.ZoomModules("1F40", CamOnTest.IP))
|
||||
BtnZoom8000.BackColor = Color.Green;
|
||||
else
|
||||
BtnZoom8000.BackColor = Color.Red;
|
||||
@@ -1579,7 +1582,7 @@ namespace AiQ_GUI
|
||||
|
||||
CancellationTokenSource cts = new();
|
||||
soakCtsList.Add(cts);
|
||||
soakTasks.Add(SoakTest.StartSoak(SCL, SCL.CheckBox, cts.Token));
|
||||
soakTasks.Add(SoakTest.StartSoak(SCL, cts));
|
||||
await Task.Delay(10000);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net9.0-windows7.0</TargetFramework>
|
||||
<TargetFramework>net10.0-windows7.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
@@ -16,7 +16,7 @@
|
||||
<Product>AiQ GUI</Product>
|
||||
<Authors>MAV Systems Ltd</Authors>
|
||||
<PackageId>AiQ GUI</PackageId>
|
||||
<Version>4.5.0</Version>
|
||||
<Version>4.6.0</Version>
|
||||
<Description>A GUI to control and test the AiQ</Description>
|
||||
<Copyright>MAV Systems Ltd 2025</Copyright>
|
||||
<PackageIcon>MAV - Plain - Blue.png</PackageIcon>
|
||||
@@ -26,6 +26,7 @@
|
||||
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<SignAssembly>False</SignAssembly>
|
||||
<StartupObject>AiQ_GUI.Program</StartupObject>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
@@ -54,14 +55,13 @@
|
||||
<PackageReference Include="ClosedXML" Version="0.105.0" />
|
||||
<PackageReference Include="Emgu.CV" Version="4.12.0.5764" />
|
||||
<PackageReference Include="Emgu.CV.runtime.windows" Version="4.12.0.5764" />
|
||||
<PackageReference Include="Google.Apis.Auth" Version="1.72.0" />
|
||||
<PackageReference Include="Google.Apis.Gmail.v1" Version="1.70.0.3833" />
|
||||
<PackageReference Include="Google.Apis.Sheets.v4" Version="1.70.0.3819" />
|
||||
<PackageReference Include="Google.Apis.Auth" Version="1.73.0" />
|
||||
<PackageReference Include="Google.Apis.Sheets.v4" Version="1.72.0.3966" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
|
||||
<PackageReference Include="PDFsharp-MigraDoc-gdi" Version="6.2.2" />
|
||||
<PackageReference Include="PDFsharp-MigraDoc-gdi" Version="6.2.3" />
|
||||
<PackageReference Include="Selenium.Support" Version="4.38.0" />
|
||||
<PackageReference Include="Selenium.WebDriver" Version="4.38.0" />
|
||||
<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="142.0.7444.6100" />
|
||||
<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="142.0.7444.17500" />
|
||||
<PackageReference Include="SSH.NET" Version="2025.1.0" />
|
||||
<PackageReference Include="System.Data.OleDb" Version="10.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -28,10 +28,10 @@ namespace AiQ_GUI
|
||||
MainForm.Instance.AddToActionsList($"{CamMod.firmwareVer} or {UniversalData.WonwooFirmware} could not be converted to a double");
|
||||
}
|
||||
|
||||
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}";
|
||||
|
||||
else if ((CamOnTest.RMANum == 0 || CamOnTest.RMANum == -1) && CamMod.firmwareVer != UniversalData.WonwooFirmware)
|
||||
else if (CamOnTest.RMANum < 1 && CamMod.firmwareVer != UniversalData.WonwooFirmware)
|
||||
errMssg += $"Firmware: {CamMod.firmwareVer} should be {UniversalData.WonwooFirmware} ";
|
||||
|
||||
if (CamMod.expMode != 0) // Auto 0=0x00
|
||||
@@ -107,5 +107,33 @@ namespace AiQ_GUI
|
||||
// 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";
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -192,32 +192,16 @@ namespace AiQ_GUI
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task<bool> SetZoomLockOn(string IP)
|
||||
public static async Task GPSFix(string IPAddress)
|
||||
{
|
||||
// Set Zoomlock on and if it fails ask user to set it manually
|
||||
if (!(await 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."))
|
||||
string sysstatus = await APIHTTPRequest("/sysstatus", IPAddress, 5);
|
||||
SysStatus status = JsonConvert.DeserializeObject<SysStatus>(sysstatus);
|
||||
|
||||
if (status.gpsState == 0 || status.gpsPresent == "Not Fitted")
|
||||
{
|
||||
return false;
|
||||
MainForm.Instance.AddToActionsList($"GPS not present in camera. State: {status.gpsState} & Status: {status.gpsPresent}");
|
||||
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
|
||||
@@ -557,6 +541,12 @@ namespace AiQ_GUI
|
||||
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 Property propDHCP { get; set; } = new Property();
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MainForm.Instance.AddToActionsList($"Error logging message: {ex.Message}");
|
||||
MessageBox.Show($"Error logging message: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,8 +106,6 @@ namespace AiQ_GUI
|
||||
// Initialises and opens a ChromeDriver with specific options
|
||||
public static ChromeDriver OpenDriver()
|
||||
{
|
||||
string tempProfile = null;
|
||||
|
||||
try
|
||||
{
|
||||
ChromeOptions options = new();
|
||||
@@ -121,7 +119,7 @@ namespace AiQ_GUI
|
||||
"--disable-features=BrowserAddPersonFeature,InterestFeedContentSuggestions");
|
||||
|
||||
// Use a unique temporary profile to avoid conflicts
|
||||
tempProfile = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
|
||||
string tempProfile = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
|
||||
options.AddArguments($"--user-data-dir={tempProfile}");
|
||||
|
||||
// manual driver path
|
||||
|
||||
@@ -7,8 +7,9 @@ namespace AiQ_GUI
|
||||
internal class SoakTest
|
||||
{
|
||||
// Main soak test loop: Randomise dropdowns, run luminance test every hour, power cycle at 7am
|
||||
public static async Task StartSoak(Camera CamInfo, CheckBox CkBx, CancellationToken token)
|
||||
public static async Task StartSoak(Camera CamInfo, CancellationTokenSource CTS)
|
||||
{
|
||||
CancellationToken token = CTS.Token;
|
||||
if (CamInfo.Serial == "N/A")
|
||||
CamInfo.Serial = "UNKNOWN"; // If serial is not set, set it to UNKNOWN. Cannot have N/A in file names.
|
||||
|
||||
@@ -18,6 +19,7 @@ namespace AiQ_GUI
|
||||
try
|
||||
{
|
||||
driver = Selenium.OpenDriver();
|
||||
Logging.LogMessage("----- Soak test started -----", SoakLogFile);
|
||||
await Task.Delay(1000); // Small delay to ensure driver is ready
|
||||
|
||||
// Keep retrying until connected or cancelled
|
||||
@@ -58,6 +60,16 @@ namespace AiQ_GUI
|
||||
|
||||
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;
|
||||
|
||||
// At 7am, power cycle the camera
|
||||
|
||||
Reference in New Issue
Block a user