diff --git a/AiQ_GUI.Designer.cs b/AiQ_GUI.Designer.cs index 570fafd..e88ec68 100644 --- a/AiQ_GUI.Designer.cs +++ b/AiQ_GUI.Designer.cs @@ -148,6 +148,7 @@ namespace AiQ_GUI BtnFirewall = new Button(); TabImages = new TabPage(); TabSoak = new TabPage(); + BtnFactoryDefault = new Button(); SetGodModeAll = new Button(); BtnUploadBlob = new Button(); CkBxTickAll = new CheckBox(); @@ -157,7 +158,6 @@ namespace AiQ_GUI LblGUIVers = new Label(); timerTypeIP = new System.Windows.Forms.Timer(components); TimerFlash = new System.Windows.Forms.Timer(components); - BtnFactoryDefault = new Button(); ((System.ComponentModel.ISupportInitialize)PicBxMAV).BeginInit(); ((System.ComponentModel.ISupportInitialize)PicBxAiQ).BeginInit(); ((System.ComponentModel.ISupportInitialize)PicBxIRF2).BeginInit(); @@ -270,7 +270,7 @@ namespace AiQ_GUI CbBxUserName.Font = new Font("Segoe UI Semibold", 10F, FontStyle.Bold); CbBxUserName.ForeColor = SystemColors.Control; CbBxUserName.FormattingEnabled = true; - CbBxUserName.Items.AddRange(new object[] { "Guest", "Clive", "Conor", "Charlie", "Henry", "Sam C", "Sam L", "Simon", "Toby", "Tom" }); + CbBxUserName.Items.AddRange(new object[] { "Guest", "Clive", "Conor", "Charlie", "Henry", "Sam C", "Sam L", "Simon", "Sophie", "Toby", "Tom" }); CbBxUserName.Location = new Point(10, 262); CbBxUserName.Margin = new Padding(4, 3, 4, 3); CbBxUserName.Name = "CbBxUserName"; @@ -1910,6 +1910,24 @@ namespace AiQ_GUI TabSoak.TabIndex = 2; TabSoak.Text = "Soak"; // + // BtnFactoryDefault + // + BtnFactoryDefault.BackColor = Color.FromArgb(70, 65, 80); + BtnFactoryDefault.Enabled = false; + BtnFactoryDefault.FlatAppearance.BorderColor = Color.FromArgb(70, 65, 80); + BtnFactoryDefault.FlatAppearance.BorderSize = 0; + BtnFactoryDefault.FlatStyle = FlatStyle.Flat; + BtnFactoryDefault.Font = new Font("Segoe UI Semibold", 10F, FontStyle.Bold); + BtnFactoryDefault.ForeColor = SystemColors.Control; + BtnFactoryDefault.Location = new Point(222, 209); + BtnFactoryDefault.Margin = new Padding(4, 3, 4, 3); + BtnFactoryDefault.Name = "BtnFactoryDefault"; + BtnFactoryDefault.Size = new Size(181, 49); + BtnFactoryDefault.TabIndex = 242; + BtnFactoryDefault.Text = "Set Modules to Factory Defaults"; + BtnFactoryDefault.UseVisualStyleBackColor = false; + BtnFactoryDefault.Click += BtnFactoryDefault_Click; + // // SetGodModeAll // SetGodModeAll.BackColor = Color.FromArgb(70, 65, 80); @@ -2000,24 +2018,6 @@ namespace AiQ_GUI timerTypeIP.Interval = 2000; timerTypeIP.Tick += timerTypeIP_Tick; // - // BtnFactoryDefault - // - BtnFactoryDefault.BackColor = Color.FromArgb(70, 65, 80); - BtnFactoryDefault.Enabled = false; - BtnFactoryDefault.FlatAppearance.BorderColor = Color.FromArgb(70, 65, 80); - BtnFactoryDefault.FlatAppearance.BorderSize = 0; - BtnFactoryDefault.FlatStyle = FlatStyle.Flat; - BtnFactoryDefault.Font = new Font("Segoe UI Semibold", 10F, FontStyle.Bold); - BtnFactoryDefault.ForeColor = SystemColors.Control; - BtnFactoryDefault.Location = new Point(222, 209); - BtnFactoryDefault.Margin = new Padding(4, 3, 4, 3); - BtnFactoryDefault.Name = "BtnFactoryDefault"; - BtnFactoryDefault.Size = new Size(181, 49); - BtnFactoryDefault.TabIndex = 242; - BtnFactoryDefault.Text = "Set Modules to Factory Defaults"; - BtnFactoryDefault.UseVisualStyleBackColor = false; - BtnFactoryDefault.Click += BtnFactoryDefault_Click; - // // MainForm // AutoScaleDimensions = new SizeF(7F, 15F); diff --git a/AiQ_GUI.cs b/AiQ_GUI.cs index 6fe65bc..5e13443 100644 --- a/AiQ_GUI.cs +++ b/AiQ_GUI.cs @@ -42,7 +42,7 @@ namespace AiQ_GUI Stopwatch stopwatch = Stopwatch.StartNew(); Task? closeProcessesTask = Windows.CloseProcesses(); // Fire and forget closing other apps - Windows.UpdateFirewall(); + //Windows.UpdateFirewall(); Task UniDataTask = Task.Run(() => Access.ReadUniData()); // Get universal data Task LDSWAIT = Task.Run(() => LDS.GetLDS()); // Get and deserialise LDS.json Task guiVerTask = Task.Run(() => GUIUpdate.FindGUIVersion()); // Get GUI Version @@ -209,6 +209,7 @@ namespace AiQ_GUI if (!LEDreply.Contains("Power levels set successfully")) AddToActionsList($"LED level could not be set: {LEDreply}"); } + await FlexiAPI.SetVaxtorMinMaxPlate(CamOnTest.IP); DateTime PCTime = DateTime.Now; // Grab PC time as close to the API as possible to pass onto PDF later @@ -1854,9 +1855,9 @@ namespace AiQ_GUI //double Spd = EstimateSpeed(frames); //AddToActionsList("Estimated Speed: " + Spd.ToString("F2") + " MPH"); - - StatsExcel excelExporter = new(); - excelExporter.ExportDatabaseToExcel(); + await FlexiAPI.SetVaxtorMinMaxPlate(CamOnTest.IP); + //StatsExcel excelExporter = new(); + //excelExporter.ExportDatabaseToExcel(); //FakeCamera fakeCamera = new FakeCamera(80); // Create an instance of FakeCamera diff --git a/Camera/FlexiAPI.cs b/Camera/FlexiAPI.cs index 43b0e0f..e6e5748 100644 --- a/Camera/FlexiAPI.cs +++ b/Camera/FlexiAPI.cs @@ -159,6 +159,37 @@ namespace AiQ_GUI return null; // If it fails to parse the JSON } } + public static async Task SetVaxtorMinMaxPlate(string IP) + { + try + { + // Build JSON array for Vaxtor min/max plate configuration + string[,] Vaxtor_JSON = { { "propMinCharHeight", "18" }, { "propMinGlobalConfidence", "30" } }; + string response = await HTTP_Update("RaptorOCR".Trim(), IP, Vaxtor_JSON); + + // Treat "operation was canceled" as a successful apply + if (response.Contains("The operation was canceled", StringComparison.OrdinalIgnoreCase)) + { + Logging.LogMessage("SetVaxtorMinMaxPlate: Camera applied config but closed connection early (safe to ignore)."); + return true; + } + + if (response.Contains("error", StringComparison.OrdinalIgnoreCase)) + { + MainForm.Instance.DisplayQuestion($"SetVaxtorMinMaxPlate: failed - Please set manually"); + return false; + } + + return true; + } + catch (Exception ex) + { + MainForm.Instance.AddToActionsList($"Could not set Vaxtor Plate height and min confidence: {ex.Message}"); + return false; + } + } + + public static async Task SetZoomLockOn(string IP) { @@ -404,5 +435,13 @@ namespace AiQ_GUI public class Property { public string Value { get; set; } = string.Empty; + public string datatype { get; set; } + } + public class VaxtorConfig + { + public string id { get; set; } + public long configHash { get; set; } + public Property propMinCharHeight { get; set; } + public Property propMinGlobalConfidence { get; set; } } } diff --git a/LDS.cs b/LDS.cs index 2f306d9..6ab47bc 100644 --- a/LDS.cs +++ b/LDS.cs @@ -35,7 +35,9 @@ namespace AiQ_GUI } catch // If file can't deserialise { + MainForm.Instance.AddToActionsList("Error loading Local Data Store"); return null; // Return null to indicate failure + } } diff --git a/Microsoft/StatsExcel.cs b/Microsoft/StatsExcel.cs index 7ad5a00..3fad46c 100644 --- a/Microsoft/StatsExcel.cs +++ b/Microsoft/StatsExcel.cs @@ -11,7 +11,7 @@ namespace AiQ_GUI.Microsoft @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=G:\Shared drives\MAV Production GUI's\AiQ\GUI's\AiQ_Final_Test.accdb;Persist Security Info=False;OLE DB Services=-1;"; private readonly string exportPath = - @"C:\Users\BradleyBorn\OneDrive - MAV Systems Ltd\Desktop\AiQ_Test_Stats.xlsx"; + @"G:\Shared drives\MAV Production GUI's\AiQ\GUI's\AiQ_Test_Stats.xlsx"; public void ExportDatabaseToExcel() {