V4.3 release
This commit is contained in:
@@ -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<bool> 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<string> FoundCams = await Network.SearchForCams();
|
||||
IList<string> 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
|
||||
|
||||
Reference in New Issue
Block a user