V4.3 changes and merge
This commit is contained in:
121
AiQ_GUI.cs
121
AiQ_GUI.cs
@@ -18,6 +18,8 @@ namespace AiQ_GUI
|
||||
private List<Camera> soakCameraList = [];
|
||||
private List<CancellationTokenSource> soakCtsList = [];
|
||||
private List<Task> soakTasks = [];
|
||||
|
||||
const string GoogleDrivePath = @"G:\Shared drives\MAV Production GUI's\AiQ\GUI's\";
|
||||
|
||||
// Colours
|
||||
public static readonly Color BtnColour = Color.FromArgb(70, 65, 80);
|
||||
@@ -1599,7 +1601,7 @@ namespace AiQ_GUI
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CkBxTickAll_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
@@ -1682,7 +1684,7 @@ namespace AiQ_GUI
|
||||
{
|
||||
string apiUrl = $"http://{cam.IP}/upload/software-update/2";
|
||||
Network.Initialize("developer", cam.DevPass);
|
||||
|
||||
await Task.Delay(1000); // Gives extra time to allow for Network to initialize
|
||||
AddToActionsList($"Uploading to {cam.IP}...", false);
|
||||
string result = await FlexiAPI.SendBlobFileUpload(apiUrl, fileToUpload, fileName);
|
||||
|
||||
@@ -1720,13 +1722,124 @@ namespace AiQ_GUI
|
||||
{
|
||||
Stopwatch stopWatchTest = Stopwatch.StartNew();
|
||||
|
||||
StatsExcel excelExporter = new();
|
||||
excelExporter.ExportDatabaseToExcel();
|
||||
//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);
|
||||
|
||||
// /api/config-ids - For getting all available config IDs
|
||||
|
||||
stopWatchTest.Stop();
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user