diff --git a/AiQ_GUI.cs b/AiQ_GUI.cs index 63bcc41..94813c9 100644 --- a/AiQ_GUI.cs +++ b/AiQ_GUI.cs @@ -18,8 +18,8 @@ namespace AiQ_GUI private List soakCameraList = []; private List soakCtsList = []; private List soakTasks = []; - - const string GoogleDrivePath = @"G:\Shared drives\MAV Production GUI's\AiQ\GUI's\"; + + public const string GoogleDrivePath = @"G:\Shared drives\MAV Production GUI's\AiQ\GUI's\"; // Colours public static readonly Color BtnColour = Color.FromArgb(70, 65, 80); @@ -1489,6 +1489,16 @@ namespace AiQ_GUI Process.Start(psi); } + private async void UploadWonwooSetOV_Click(object sender, EventArgs e) + { + await FlexiAPI.UploadWonwooSet(CbBxFoundCams.Text, false); // false = Colour + } + + private async void UploadWonwooSetIR_Click(object sender, EventArgs e) + { + await FlexiAPI.UploadWonwooSet(CbBxFoundCams.Text, true); // true = Infrared + } + private void TxBxSerialPrint_Click(object sender, EventArgs e) { if (TxBxSerialPrint.Text == "K – – – – – – –") // If at default then remove the dashes ready for user to put in number @@ -1601,7 +1611,7 @@ namespace AiQ_GUI } } } - } + } private void CkBxTickAll_CheckedChanged(object sender, EventArgs e) { @@ -1722,29 +1732,8 @@ namespace AiQ_GUI { Stopwatch stopWatchTest = Stopwatch.StartNew(); - //StatsExcel excelExporter = new(); - //excelExporter.ExportDatabaseToExcel(); - - FakeCamera fakeCamera = new FakeCamera(80); // Create an instance of FakeCamera - //CamOnTest.IP = CbBxFoundCams.Text; - _ = fakeCamera.StartAsync(CAMTYPE.GOOD).ContinueWith(task => - { - //Network.Initialize("developer", "Pass123"); - if (task.IsFaulted) - { - AddToActionsList("Error starting FakeCamera: " + task.Exception?.Message); - } - else - { - AddToActionsList($"FakeCamera started successfully. IP: {fakeCamera}", false); - } - }); - await Task.Delay(3000); // Wait for server to start - CbBxFoundCams.Text = "localhost"; // Should force update in creds an network reinit - CmBoFoundCams_TextChanged(sender, e); - CbBxCameraType.SelectedIndex = CbBxCameraType.Items.Count - 1; // Selects AB12CD as model number - await Task.Delay(3000); // Wait for server to start - BtnStartTest_Click(sender, e); + StatsExcel excelExporter = new(); + excelExporter.ExportDatabaseToExcel(); // /api/config-ids - For getting all available config IDs @@ -1752,94 +1741,5 @@ namespace AiQ_GUI AddToActionsList("RunTime " + stopWatchTest.Elapsed.ToString(@"hh\:mm\:ss\.ff")); } - - private async Task UploadWonwooSet(string ipAddress, bool isIR) - { - string fileToUpload = null; - - using OpenFileDialog openFileDialog1 = new() - { - InitialDirectory = GoogleDrivePath, - Filter = "CSV files (*.csv)|*.csv", - FilterIndex = 0 - }; - - if (openFileDialog1.ShowDialog() == DialogResult.OK) - fileToUpload = openFileDialog1.FileName; - else - { - AddToActionsList("File selection cancelled.", false); - return; - } - - //Filename validation - string filename = Path.GetFileName(fileToUpload).ToUpper(); - - if (isIR) - { - if (!filename.Contains("IR") || filename.Contains("OV")) - { - AddToActionsList("Incorrect file selected. Expected IR file.", false); - return; - } - } - else // OV - { - if (!filename.Contains("OV") || filename.Contains("IR")) - { - AddToActionsList("Incorrect file selected. Expected OV file.", false); - return; - } - } - - var lines = File.ReadAllLines(fileToUpload); - - for (int i = 1; i < lines.Length; i++) - { - var parts = lines[i].Split(',') - .Select(p => p.Trim()) - .ToArray(); - - if (parts.Length < 3) - { - AddToActionsList($"Invalid row format at line {i + 1}", false); - continue; - } - - string name = parts[0]; - string command = parts[1]; - string expectedResponse = parts[2]; - - // VISCA format check - if (!RegexCache.VISCAAPIRegex().IsMatch(command)) - { - AddToActionsList($"{name}: Invalid VISCA command ({command})", false); - continue; // do not send it if bad - } - - string result = await FlexiAPI.APIHTTPVISCA(ipAddress, command, isIR); - - if (result.Contains(expectedResponse)) - AddToActionsList($"{name}: Success ({(isIR ? "IR" : "Colour")})", true); - else - AddToActionsList($"{name}: Unexpected response ({result})", false); - - await Task.Delay(150); - } - - - AddToActionsList($"Upload complete ({(isIR ? "IR" : "Colour")}).", true); - } - - - private async void UploadWonwooSetOV_Click(object sender, EventArgs e) - { - await UploadWonwooSet(CbBxFoundCams.Text, false); // false = Colour - } - - private async void UploadWonwooSetIR_Click(object sender, EventArgs e) - { - await UploadWonwooSet(CbBxFoundCams.Text, true); // true = Infrared - } } } diff --git a/AiQ_GUI_NET_Test.csproj b/AiQ_GUI_NET_Test.csproj index 884eb62..1865f5e 100644 --- a/AiQ_GUI_NET_Test.csproj +++ b/AiQ_GUI_NET_Test.csproj @@ -16,7 +16,7 @@ AiQ GUI MAV Systems Ltd AiQ GUI - 4.2.0 + 4.3.0 A GUI to control and test the AiQ MAV Systems Ltd 2025 MAV - Plain - Blue.png diff --git a/AvailableCondigID.json b/AvailableConfigID.json similarity index 100% rename from AvailableCondigID.json rename to AvailableConfigID.json diff --git a/Camera/FlexiAPI.cs b/Camera/FlexiAPI.cs index c50aab9..1c08728 100644 --- a/Camera/FlexiAPI.cs +++ b/Camera/FlexiAPI.cs @@ -1,6 +1,5 @@ using Newtonsoft.Json; using System.Net.Http.Headers; -using System.Net.NetworkInformation; namespace AiQ_GUI { @@ -358,10 +357,10 @@ namespace AiQ_GUI public async static Task ChangeNetworkToDHCP(string IPAddress) { string[,] TEST_JSON = { { "propDHCP", "true" } }; - string result = await HTTP_Update("GLOBAL--NetworkConfig", IPAddress, TEST_JSON); + await HTTP_Update("GLOBAL--NetworkConfig", IPAddress, TEST_JSON); // Don't care about response because it will fail as it has changed IP. await Task.Delay(5000); // Wait for 5 seconds to allow the camera to restart - IList FoundCams = await Network.SearchForCams(); + IList FoundCams = await Network.SearchForCams(); if (FoundCams.Contains("192.168.1.211")) { @@ -373,6 +372,69 @@ namespace AiQ_GUI return true; } + public static async Task UploadWonwooSet(string ipAddress, bool isIR) + { + string fileToUpload = null; + + using OpenFileDialog openFileDialog1 = new() + { + InitialDirectory = MainForm.GoogleDrivePath, + Filter = "CSV files (*.csv)|*.csv", + FilterIndex = 0 + }; + + if (openFileDialog1.ShowDialog() == DialogResult.OK) + fileToUpload = openFileDialog1.FileName; + else + { + MainForm.Instance.AddToActionsList("File selection cancelled.", false); + return; + } + + //Filename validation + string filename = Path.GetFileName(fileToUpload).ToUpper(); + + if ((isIR && filename.Contains("IR")) || (!isIR && filename.Contains("OV"))) + { + MainForm.Instance.AddToActionsList($"Incorrect file selected. Expected {(isIR ? "IR" : "OV")} file", false); + return; + } + + string[] lines = File.ReadAllLines(fileToUpload); + + for (int i = 1; i < lines.Length; i++) + { + string[] parts = lines[i].Split(',').Select(p => p.Trim()).ToArray(); + + if (parts.Length < 3) + { + MainForm.Instance.AddToActionsList($"Invalid row format at line {i + 1}", false); + continue; + } + + string name = parts[0]; + string command = parts[1]; + string expectedResponse = parts[2]; + + // VISCA format check + if (!RegexCache.VISCAAPIRegex().IsMatch(command)) + { + MainForm.Instance.AddToActionsList($"{name}: Invalid VISCA command ({command})", false); + continue; // do not send it if bad + } + + string result = await APIHTTPVISCA(ipAddress, command, isIR); + + if (result.Contains(expectedResponse)) + MainForm.Instance.AddToActionsList($"{name}: Success ({(isIR ? "IR" : "Colour")})", true); + else + MainForm.Instance.AddToActionsList($"{name}: Unexpected response ({result})", false); + + await Task.Delay(150); + } + + MainForm.Instance.AddToActionsList($"Upload complete ({(isIR ? "IR" : "Colour")}).", true); + } } //Items recieved in Versions API diff --git a/Network.cs b/Network.cs index 575bdea..175e8ce 100644 --- a/Network.cs +++ b/Network.cs @@ -1,9 +1,7 @@ -using System.Diagnostics; -using System.Net; +using System.Net; using System.Net.NetworkInformation; using System.Net.Sockets; using System.Text; -using System.Threading; namespace AiQ_GUI {