Compare commits
7 Commits
dd8e87258f
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 791cee91d2 | |||
| 00b225a3db | |||
| e94a1f1f5c | |||
| a91c3b846f | |||
| 42a4778555 | |||
| 3d71ab7e9b | |||
| 78c440ab76 |
72
AiQ_GUI.Designer.cs
generated
72
AiQ_GUI.Designer.cs
generated
@@ -144,8 +144,8 @@ namespace AiQ_GUI
|
|||||||
BtnZoom8000 = new Button();
|
BtnZoom8000 = new Button();
|
||||||
BtnZoomWide = new Button();
|
BtnZoomWide = new Button();
|
||||||
TabSettings = new TabPage();
|
TabSettings = new TabPage();
|
||||||
UploadWonwooSetIR = new Button();
|
BtnUploadWonwooSetIR = new Button();
|
||||||
UploadWonwooSetOV = new Button();
|
BtnUploadWonwooSetOV = new Button();
|
||||||
BtnAdminStart = new Button();
|
BtnAdminStart = new Button();
|
||||||
BtnFirewall = new Button();
|
BtnFirewall = new Button();
|
||||||
TabImages = new TabPage();
|
TabImages = new TabPage();
|
||||||
@@ -1838,8 +1838,8 @@ namespace AiQ_GUI
|
|||||||
// TabSettings
|
// TabSettings
|
||||||
//
|
//
|
||||||
TabSettings.BackColor = Color.FromArgb(39, 37, 55);
|
TabSettings.BackColor = Color.FromArgb(39, 37, 55);
|
||||||
TabSettings.Controls.Add(UploadWonwooSetIR);
|
TabSettings.Controls.Add(BtnUploadWonwooSetIR);
|
||||||
TabSettings.Controls.Add(UploadWonwooSetOV);
|
TabSettings.Controls.Add(BtnUploadWonwooSetOV);
|
||||||
TabSettings.Controls.Add(BtnAdminStart);
|
TabSettings.Controls.Add(BtnAdminStart);
|
||||||
TabSettings.Controls.Add(BtnFirewall);
|
TabSettings.Controls.Add(BtnFirewall);
|
||||||
TabSettings.Controls.Add(PanelSettings);
|
TabSettings.Controls.Add(PanelSettings);
|
||||||
@@ -1850,39 +1850,39 @@ namespace AiQ_GUI
|
|||||||
TabSettings.TabIndex = 3;
|
TabSettings.TabIndex = 3;
|
||||||
TabSettings.Text = "Settings";
|
TabSettings.Text = "Settings";
|
||||||
//
|
//
|
||||||
// UploadWonwooSetIR
|
// BtnUploadWonwooSetIR
|
||||||
//
|
//
|
||||||
UploadWonwooSetIR.BackColor = Color.FromArgb(70, 65, 80);
|
BtnUploadWonwooSetIR.BackColor = Color.FromArgb(70, 65, 80);
|
||||||
UploadWonwooSetIR.FlatAppearance.BorderColor = Color.FromArgb(70, 65, 80);
|
BtnUploadWonwooSetIR.FlatAppearance.BorderColor = Color.FromArgb(70, 65, 80);
|
||||||
UploadWonwooSetIR.FlatAppearance.BorderSize = 0;
|
BtnUploadWonwooSetIR.FlatAppearance.BorderSize = 0;
|
||||||
UploadWonwooSetIR.FlatStyle = FlatStyle.Flat;
|
BtnUploadWonwooSetIR.FlatStyle = FlatStyle.Flat;
|
||||||
UploadWonwooSetIR.Font = new Font("Segoe UI Semibold", 10F, FontStyle.Bold);
|
BtnUploadWonwooSetIR.Font = new Font("Segoe UI Semibold", 10F, FontStyle.Bold);
|
||||||
UploadWonwooSetIR.ForeColor = SystemColors.Control;
|
BtnUploadWonwooSetIR.ForeColor = SystemColors.Control;
|
||||||
UploadWonwooSetIR.Location = new Point(210, 304);
|
BtnUploadWonwooSetIR.Location = new Point(210, 304);
|
||||||
UploadWonwooSetIR.Margin = new Padding(4, 3, 4, 3);
|
BtnUploadWonwooSetIR.Margin = new Padding(4, 3, 4, 3);
|
||||||
UploadWonwooSetIR.Name = "UploadWonwooSetIR";
|
BtnUploadWonwooSetIR.Name = "BtnUploadWonwooSetIR";
|
||||||
UploadWonwooSetIR.Size = new Size(180, 49);
|
BtnUploadWonwooSetIR.Size = new Size(180, 49);
|
||||||
UploadWonwooSetIR.TabIndex = 244;
|
BtnUploadWonwooSetIR.TabIndex = 244;
|
||||||
UploadWonwooSetIR.Text = "Upload Wonwoo Settings IR";
|
BtnUploadWonwooSetIR.Text = "Upload Wonwoo Settings IR";
|
||||||
UploadWonwooSetIR.UseVisualStyleBackColor = false;
|
BtnUploadWonwooSetIR.UseVisualStyleBackColor = false;
|
||||||
UploadWonwooSetIR.Click += UploadWonwooSetIR_Click;
|
BtnUploadWonwooSetIR.Click += UploadWonwooSetIR_Click;
|
||||||
//
|
//
|
||||||
// UploadWonwooSetOV
|
// BtnUploadWonwooSetOV
|
||||||
//
|
//
|
||||||
UploadWonwooSetOV.BackColor = Color.FromArgb(70, 65, 80);
|
BtnUploadWonwooSetOV.BackColor = Color.FromArgb(70, 65, 80);
|
||||||
UploadWonwooSetOV.FlatAppearance.BorderColor = Color.FromArgb(70, 65, 80);
|
BtnUploadWonwooSetOV.FlatAppearance.BorderColor = Color.FromArgb(70, 65, 80);
|
||||||
UploadWonwooSetOV.FlatAppearance.BorderSize = 0;
|
BtnUploadWonwooSetOV.FlatAppearance.BorderSize = 0;
|
||||||
UploadWonwooSetOV.FlatStyle = FlatStyle.Flat;
|
BtnUploadWonwooSetOV.FlatStyle = FlatStyle.Flat;
|
||||||
UploadWonwooSetOV.Font = new Font("Segoe UI Semibold", 10F, FontStyle.Bold);
|
BtnUploadWonwooSetOV.Font = new Font("Segoe UI Semibold", 10F, FontStyle.Bold);
|
||||||
UploadWonwooSetOV.ForeColor = SystemColors.Control;
|
BtnUploadWonwooSetOV.ForeColor = SystemColors.Control;
|
||||||
UploadWonwooSetOV.Location = new Point(19, 304);
|
BtnUploadWonwooSetOV.Location = new Point(19, 304);
|
||||||
UploadWonwooSetOV.Margin = new Padding(4, 3, 4, 3);
|
BtnUploadWonwooSetOV.Margin = new Padding(4, 3, 4, 3);
|
||||||
UploadWonwooSetOV.Name = "UploadWonwooSetOV";
|
BtnUploadWonwooSetOV.Name = "BtnUploadWonwooSetOV";
|
||||||
UploadWonwooSetOV.Size = new Size(181, 49);
|
BtnUploadWonwooSetOV.Size = new Size(181, 49);
|
||||||
UploadWonwooSetOV.TabIndex = 243;
|
BtnUploadWonwooSetOV.TabIndex = 243;
|
||||||
UploadWonwooSetOV.Text = "Upload Wonwoo Settings OV";
|
BtnUploadWonwooSetOV.Text = "Upload Wonwoo Settings OV";
|
||||||
UploadWonwooSetOV.UseVisualStyleBackColor = false;
|
BtnUploadWonwooSetOV.UseVisualStyleBackColor = false;
|
||||||
UploadWonwooSetOV.Click += UploadWonwooSetOV_Click;
|
BtnUploadWonwooSetOV.Click += UploadWonwooSetOV_Click;
|
||||||
//
|
//
|
||||||
// BtnAdminStart
|
// BtnAdminStart
|
||||||
//
|
//
|
||||||
@@ -2249,7 +2249,7 @@ namespace AiQ_GUI
|
|||||||
private Button BtnAdminStart;
|
private Button BtnAdminStart;
|
||||||
private Button SetGodModeAll;
|
private Button SetGodModeAll;
|
||||||
private Button BtnFactoryDefault;
|
private Button BtnFactoryDefault;
|
||||||
private Button UploadWonwooSetOV;
|
private Button BtnUploadWonwooSetOV;
|
||||||
private Button UploadWonwooSetIR;
|
private Button BtnUploadWonwooSetIR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
169
AiQ_GUI.cs
169
AiQ_GUI.cs
@@ -19,7 +19,7 @@ namespace AiQ_GUI
|
|||||||
private List<CancellationTokenSource> soakCtsList = [];
|
private List<CancellationTokenSource> soakCtsList = [];
|
||||||
private List<Task> soakTasks = [];
|
private List<Task> 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
|
// Colours
|
||||||
public static readonly Color BtnColour = Color.FromArgb(70, 65, 80);
|
public static readonly Color BtnColour = Color.FromArgb(70, 65, 80);
|
||||||
@@ -399,15 +399,14 @@ namespace AiQ_GUI
|
|||||||
List<object> oblistCD = [CamOnTest.Model, FullFailureValues];
|
List<object> oblistCD = [CamOnTest.Model, FullFailureValues];
|
||||||
GoogleAPI.WriteToSS(oblistCD, "'Approval'!C" + nextRow + ":D" + nextRow, GoogleAPI.spreadsheetId_ModelInfo);
|
GoogleAPI.WriteToSS(oblistCD, "'Approval'!C" + nextRow + ":D" + nextRow, GoogleAPI.spreadsheetId_ModelInfo);
|
||||||
|
|
||||||
//await Teams.SendMssg(Convert.ToString(nextRow), CbBxUserName.Text);
|
await Teams.SendMssg(Convert.ToString(nextRow), CbBxUserName.Text);
|
||||||
GoogleAPI.EmailApproval(Convert.ToString(nextRow), CbBxUserName.Text);
|
//GoogleAPI.EmailApproval(Convert.ToString(nextRow), CbBxUserName.Text);
|
||||||
|
|
||||||
string Approved = "";
|
string Approved = "";
|
||||||
|
|
||||||
while (Approved != "TRUE")
|
while (Approved != "TRUE")
|
||||||
{
|
{
|
||||||
await Task.Delay(1000);
|
await Task.Delay(1000);
|
||||||
|
|
||||||
values = GoogleAPI.service.Spreadsheets.Values.Get(GoogleAPI.spreadsheetId_ModelInfo, "'Approval'!B" + nextRow).Execute().Values;
|
values = GoogleAPI.service.Spreadsheets.Values.Get(GoogleAPI.spreadsheetId_ModelInfo, "'Approval'!B" + nextRow).Execute().Values;
|
||||||
|
|
||||||
if (values?.Count > 0)
|
if (values?.Count > 0)
|
||||||
@@ -772,7 +771,7 @@ namespace AiQ_GUI
|
|||||||
private async void BtnFindCams_Click(object sender, EventArgs e)
|
private async void BtnFindCams_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
CbBxFoundCams.Text = "Searching";
|
CbBxFoundCams.Text = "Searching";
|
||||||
BtnFindCams.Enabled = BtnSetAll211.Enabled = BtnSoak.Enabled = BtnSet211.Enabled = BtnSetGodMode.Enabled = BtnUploadBlob.Enabled = SetGodModeAll.Enabled = BtnFactoryDefault.Enabled = false;
|
BtnFindCams.Enabled = BtnSetAll211.Enabled = BtnSoak.Enabled = BtnSet211.Enabled = BtnSetGodMode.Enabled = BtnUploadBlob.Enabled = SetGodModeAll.Enabled = BtnFactoryDefault.Enabled = BtnUploadWonwooSetIR.Enabled = BtnUploadWonwooSetOV.Enabled = false;
|
||||||
BtnSetGodMode.BackColor = BtnUploadBlob.BackColor = BtnFactoryDefault.BackColor = BtnSetAll211.BackColor = BtnColour;
|
BtnSetGodMode.BackColor = BtnUploadBlob.BackColor = BtnFactoryDefault.BackColor = BtnSetAll211.BackColor = BtnColour;
|
||||||
CbBxFoundCams.Items.Clear();
|
CbBxFoundCams.Items.Clear();
|
||||||
soakCameraList.Clear();
|
soakCameraList.Clear();
|
||||||
@@ -888,7 +887,7 @@ namespace AiQ_GUI
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
CbBxFoundCams.BackColor = Color.Red;
|
CbBxFoundCams.BackColor = Color.Red;
|
||||||
BtnSecret.Enabled = BtnOpenWebpage.Enabled = BtnSet211.Enabled = BtnSetGodMode.Enabled = false;
|
BtnSecret.Enabled = BtnOpenWebpage.Enabled = BtnSet211.Enabled = BtnSetGodMode.Enabled = BtnUploadWonwooSetIR.Enabled = BtnUploadWonwooSetOV.Enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
TestStartConditions();
|
TestStartConditions();
|
||||||
@@ -973,7 +972,7 @@ namespace AiQ_GUI
|
|||||||
if (CbBxFoundCams.BackColor != BtnColour || CbBxFoundCams.Text.Contains("Found"))
|
if (CbBxFoundCams.BackColor != BtnColour || CbBxFoundCams.Text.Contains("Found"))
|
||||||
TSC = SetInvalid("Select camera IP address.");
|
TSC = SetInvalid("Select camera IP address.");
|
||||||
else
|
else
|
||||||
BtnOpenWebpage.Enabled = BtnSet211.Enabled = BtnSetGodMode.Enabled = BtnZoom8000.Enabled = BtnZoomWide.Enabled = true; // Allow user to go to camera webpage & change DHCP/211
|
BtnOpenWebpage.Enabled = BtnSet211.Enabled = BtnSetGodMode.Enabled = BtnZoom8000.Enabled = BtnZoomWide.Enabled = BtnUploadWonwooSetIR.Enabled = BtnUploadWonwooSetOV.Enabled = true; // Allow user to go to camera webpage & change DHCP/211
|
||||||
|
|
||||||
// Name chosen
|
// Name chosen
|
||||||
if (CbBxUserName.Text == "Select Operator to Begin Test" || CbBxUserName.Text.Length < 2)
|
if (CbBxUserName.Text == "Select Operator to Begin Test" || CbBxUserName.Text.Length < 2)
|
||||||
@@ -1490,6 +1489,16 @@ namespace AiQ_GUI
|
|||||||
Process.Start(psi);
|
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)
|
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
|
if (TxBxSerialPrint.Text == "K – – – – – – –") // If at default then remove the dashes ready for user to put in number
|
||||||
@@ -1566,7 +1575,7 @@ namespace AiQ_GUI
|
|||||||
CancellationTokenSource cts = new();
|
CancellationTokenSource cts = new();
|
||||||
soakCtsList.Add(cts);
|
soakCtsList.Add(cts);
|
||||||
soakTasks.Add(SoakTest.StartSoak(SCL, cts.Token));
|
soakTasks.Add(SoakTest.StartSoak(SCL, cts.Token));
|
||||||
await Task.Delay(5000);
|
await Task.Delay(10000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1577,30 +1586,45 @@ namespace AiQ_GUI
|
|||||||
cts.Cancel();
|
cts.Cancel();
|
||||||
soakCtsList.Clear();
|
soakCtsList.Clear();
|
||||||
soakTasks.Clear();
|
soakTasks.Clear();
|
||||||
|
int i = soakCameraList.Count + 1; // Add 1 for 211 itself staying in the list
|
||||||
|
|
||||||
foreach (Camera SCL in soakCameraList) // Reset all cameras that were being soaked to default module settings
|
string[,] Network_JSON = { { "propDHCP", "false" }, { "propHost", "192.168.1.211" }, { "propNetmask", "255.255.255.0" }, { "propGateway", "192.168.1.1" } };
|
||||||
|
string[,] GOD_JSON = { { "propGodMode", "false" } };
|
||||||
|
foreach (Camera SCL in soakCameraList.Where(c => c.IsChecked)) // only checked cameras
|
||||||
{
|
{
|
||||||
if (!SCL.IsChecked)
|
if (!SCL.IsChecked)
|
||||||
continue;
|
continue;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Network.Initialize("developer", SCL.DevPass); // Ensure network is initialized to the right camera, cannot be done in soak test finally becuase of this.
|
AddToActionsList($"Setting 211 & God Mode off for camera {SCL.IP}", false);
|
||||||
|
Network.Initialize("developer", SCL.DevPass); // Ensure network is initialized to the right camera
|
||||||
await CameraModules.FactoryResetModules(SCL.IP); // Reset camera modules
|
await CameraModules.FactoryResetModules(SCL.IP); // Reset camera modules
|
||||||
|
|
||||||
string[,] godJson = { { "propGodMode", "false" } }; // Set God mode explicitly off
|
string GOD = await FlexiAPI.HTTP_Update("GLOBAL--FlexiApplication", SCL.IP, GOD_JSON);
|
||||||
string GOD = await FlexiAPI.HTTP_Update("GLOBAL--FlexiApplication", SCL.IP, godJson);
|
|
||||||
if (GOD.Contains("Error"))
|
if (GOD.Contains("Error"))
|
||||||
throw new Exception("Could not set God mode off");
|
throw new Exception("Could not set God mode off");
|
||||||
|
|
||||||
bool Pass = await FlexiAPI.ChangeNetwork211(SCL.IP); // set camera to 211
|
// Update GLOBAL--NetworkConfig with fixed IP and turn off DHCP
|
||||||
if (!Pass)
|
await FlexiAPI.HTTP_Update("GLOBAL--NetworkConfig", SCL.IP, Network_JSON);
|
||||||
throw new Exception("Could not set camera to 211");
|
i--; // Decriment count becuase they will stack into 211
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
AddToActionsList("Failed to set God mode, reset camera modules or 211 for camera " + SCL.IP + ". Reason: " + ex.Message);
|
AddToActionsList("Failed to set all cameras to 211 and god mode off. Reason: " + ex.Message); // In case non AiQ's get caught up
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await Task.Delay(5000); // Wait for 5 seconds to allow the camera to restart
|
||||||
|
IList<string> FoundCams = await Network.SearchForCams(); // Have to check via broadcast becuase Ping sometimes fails across subnets
|
||||||
|
|
||||||
|
if ((FoundCams.Count == i && FoundCams.Contains("192.168.1.211")) || FoundCams.Count == 1)
|
||||||
|
{
|
||||||
|
AddToActionsList("All cameras successfully changed to 211.", false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AddToActionsList($"Some cameras failed: Found {FoundCams.Count}, expected {i}.", true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1726,119 +1750,12 @@ namespace AiQ_GUI
|
|||||||
//StatsExcel excelExporter = new();
|
//StatsExcel excelExporter = new();
|
||||||
//excelExporter.ExportDatabaseToExcel();
|
//excelExporter.ExportDatabaseToExcel();
|
||||||
|
|
||||||
FakeCamera fakeCamera = new FakeCamera(80); // Create an instance of FakeCamera
|
string ans = await FlexiAPI.HTTP_Fetch("GLOBAL--Device", "192.168.0.71");
|
||||||
//CamOnTest.IP = CbBxFoundCams.Text;
|
AddToActionsList(ans);
|
||||||
_ = fakeCamera.StartAsync(CAMTYPE.GOOD).ContinueWith(task =>
|
// /api/config-ids - For getting all available config IDs
|
||||||
{
|
|
||||||
//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);
|
|
||||||
|
|
||||||
stopWatchTest.Stop();
|
stopWatchTest.Stop();
|
||||||
AddToActionsList("RunTime " + stopWatchTest.Elapsed.ToString(@"hh\:mm\:ss\.ff"));
|
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
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,6 +123,9 @@
|
|||||||
<metadata name="ToolTipClipboard.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
<metadata name="ToolTipClipboard.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
<value>159, 17</value>
|
<value>159, 17</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
|
<metadata name="ToolTipAvailable.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
<metadata name="TimerDDC.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
<metadata name="TimerDDC.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
<value>690, 19</value>
|
<value>690, 19</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
<Product>AiQ GUI</Product>
|
<Product>AiQ GUI</Product>
|
||||||
<Authors>MAV Systems Ltd</Authors>
|
<Authors>MAV Systems Ltd</Authors>
|
||||||
<PackageId>AiQ GUI</PackageId>
|
<PackageId>AiQ GUI</PackageId>
|
||||||
<Version>4.0.0</Version>
|
<Version>4.4.0</Version>
|
||||||
<Description>A GUI to control and test the AiQ</Description>
|
<Description>A GUI to control and test the AiQ</Description>
|
||||||
<Copyright>MAV Systems Ltd 2025</Copyright>
|
<Copyright>MAV Systems Ltd 2025</Copyright>
|
||||||
<PackageIcon>MAV - Plain - Blue.png</PackageIcon>
|
<PackageIcon>MAV - Plain - Blue.png</PackageIcon>
|
||||||
@@ -30,10 +30,20 @@
|
|||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
<Optimize>True</Optimize>
|
<Optimize>True</Optimize>
|
||||||
|
<DefineConstants>$(DefineConstants);_PUBLISH_CHROMEDRIVER</DefineConstants>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'">
|
||||||
<Optimize>True</Optimize>
|
<Optimize>True</Optimize>
|
||||||
|
<DefineConstants>$(DefineConstants);_PUBLISH_CHROMEDRIVER</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||||
|
<DefineConstants>$(DefineConstants);_PUBLISH_CHROMEDRIVER</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x86'">
|
||||||
|
<DefineConstants>$(DefineConstants);_PUBLISH_CHROMEDRIVER</DefineConstants>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@@ -51,9 +61,9 @@
|
|||||||
<PackageReference Include="PDFsharp-MigraDoc-gdi" Version="6.2.2" />
|
<PackageReference Include="PDFsharp-MigraDoc-gdi" Version="6.2.2" />
|
||||||
<PackageReference Include="Selenium.Support" Version="4.38.0" />
|
<PackageReference Include="Selenium.Support" Version="4.38.0" />
|
||||||
<PackageReference Include="Selenium.WebDriver" Version="4.38.0" />
|
<PackageReference Include="Selenium.WebDriver" Version="4.38.0" />
|
||||||
<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="142.0.7444.5900" />
|
<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="142.0.7444.6100" />
|
||||||
<PackageReference Include="SSH.NET" Version="2025.1.0" />
|
<PackageReference Include="SSH.NET" Version="2025.1.0" />
|
||||||
<PackageReference Include="System.Data.OleDb" Version="9.0.10" />
|
<PackageReference Include="System.Data.OleDb" Version="10.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System.Net.Http.Headers;
|
using System.Net.Http.Headers;
|
||||||
using System.Net.NetworkInformation;
|
|
||||||
|
|
||||||
namespace AiQ_GUI
|
namespace AiQ_GUI
|
||||||
{
|
{
|
||||||
@@ -358,7 +357,7 @@ namespace AiQ_GUI
|
|||||||
public async static Task<bool> ChangeNetworkToDHCP(string IPAddress)
|
public async static Task<bool> ChangeNetworkToDHCP(string IPAddress)
|
||||||
{
|
{
|
||||||
string[,] TEST_JSON = { { "propDHCP", "true" } };
|
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
|
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();
|
||||||
@@ -373,6 +372,69 @@ namespace AiQ_GUI
|
|||||||
return true;
|
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
|
//Items recieved in Versions API
|
||||||
|
|||||||
@@ -297,7 +297,7 @@ namespace AiQ_GUI
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Build the MIME message with attachment
|
// Build the MIME message with attachment
|
||||||
using MailMessage mail = new MailMessage();
|
using MailMessage mail = new();
|
||||||
mail.From = new MailAddress("me");
|
mail.From = new MailAddress("me");
|
||||||
mail.To.Add("richard.porter@mav-systems.com");
|
mail.To.Add("richard.porter@mav-systems.com");
|
||||||
mail.To.Add("bradley.relyea@mav-systems.com");
|
mail.To.Add("bradley.relyea@mav-systems.com");
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ namespace AiQ_GUI
|
|||||||
|
|
||||||
public static async Task SendMssg(string ApprovalRow, string User) // Sometimes You will need to reauthenticate the workflow
|
public static async Task SendMssg(string ApprovalRow, string User) // Sometimes You will need to reauthenticate the workflow
|
||||||
{
|
{
|
||||||
using HttpClient client = new HttpClient();
|
using HttpClient client = new();
|
||||||
|
|
||||||
string link = $"https://docs.google.com/spreadsheets/d/1bCcCr4OYqfjmydt6UqtmN4FQETezXmZRSStJdCCcqZM/edit#gid=1931079354&range=A{ApprovalRow}"; // Has to be parsed like this as teams doesnt hyperlink otherwise
|
string link = $"https://docs.google.com/spreadsheets/d/1bCcCr4OYqfjmydt6UqtmN4FQETezXmZRSStJdCCcqZM/edit#gid=1931079354&range=A{ApprovalRow}"; // Has to be parsed like this as teams doesnt hyperlink otherwise
|
||||||
|
|
||||||
@@ -21,7 +21,7 @@ namespace AiQ_GUI
|
|||||||
};
|
};
|
||||||
|
|
||||||
string json = JsonConvert.SerializeObject(payload);
|
string json = JsonConvert.SerializeObject(payload);
|
||||||
StringContent content = new StringContent(json, Encoding.UTF8, "application/json");
|
StringContent content = new(json, Encoding.UTF8, "application/json");
|
||||||
|
|
||||||
HttpResponseMessage response = await client.PostAsync(webhookUrl, content);
|
HttpResponseMessage response = await client.PostAsync(webhookUrl, content);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ namespace AiQ_GUI
|
|||||||
{
|
{
|
||||||
const int sendPort = 6666;
|
const int sendPort = 6666;
|
||||||
const int receivePort = 6667;
|
const int receivePort = 6667;
|
||||||
|
const int discoveryTimeoutMs = 1000;
|
||||||
IList<string> FoundCams = [];
|
IList<string> FoundCams = [];
|
||||||
|
|
||||||
byte[] discoveryPacket = [0x50, 0x4f, 0x4c, 0x4c, 0xaf, 0xb0, 0xb3, 0xb3, 0xb6, 0x01, 0xa8, 0xc0, 0x0b, 0x1a, 0x00, 0x00];
|
byte[] discoveryPacket = [0x50, 0x4f, 0x4c, 0x4c, 0xaf, 0xb0, 0xb3, 0xb3, 0xb6, 0x01, 0xa8, 0xc0, 0x0b, 0x1a, 0x00, 0x00];
|
||||||
@@ -103,9 +104,9 @@ namespace AiQ_GUI
|
|||||||
}
|
}
|
||||||
|
|
||||||
using UdpClient receiver = new(receivePort); // Listen for replies on fixed port
|
using UdpClient receiver = new(receivePort); // Listen for replies on fixed port
|
||||||
receiver.Client.ReceiveTimeout = 750;
|
receiver.Client.ReceiveTimeout = discoveryTimeoutMs;
|
||||||
|
|
||||||
DateTime timeout = DateTime.Now.AddMilliseconds(750);
|
DateTime timeout = DateTime.Now.AddMilliseconds(discoveryTimeoutMs);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
while (DateTime.Now < timeout)
|
while (DateTime.Now < timeout)
|
||||||
|
|||||||
@@ -39,6 +39,47 @@ namespace AiQ_GUI
|
|||||||
return elementID;
|
return elementID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void SwitchUser(ChromeDriver driver)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
WebDriverWait wait = new(driver, TimeSpan.FromSeconds(10));
|
||||||
|
|
||||||
|
// Click "Switch User"
|
||||||
|
IWebElement switchBtn = wait.Until(d =>
|
||||||
|
d.FindElement(By.XPath("//*[contains(text(),'Switch User')]"))
|
||||||
|
);
|
||||||
|
switchBtn.Click();
|
||||||
|
|
||||||
|
// Username
|
||||||
|
IWebElement userBox = wait.Until(d => d.FindElement(By.Id("username")));
|
||||||
|
userBox.Clear();
|
||||||
|
userBox.SendKeys("admin");
|
||||||
|
|
||||||
|
// Password
|
||||||
|
IWebElement passBox = wait.Until(d => d.FindElement(By.Id("password")));
|
||||||
|
passBox.Clear();
|
||||||
|
passBox.SendKeys("admin");
|
||||||
|
|
||||||
|
// Login button
|
||||||
|
IWebElement loginBtn = wait.Until(d =>
|
||||||
|
d.FindElement(By.XPath("//button[contains(normalize-space(text()), 'Login')]"))
|
||||||
|
);
|
||||||
|
|
||||||
|
// Wait until it's clickable manually (no SeleniumExtras)
|
||||||
|
wait.Until(d => loginBtn.Displayed && loginBtn.Enabled);
|
||||||
|
|
||||||
|
loginBtn.Click();
|
||||||
|
|
||||||
|
MainForm.Instance.AddToActionsList("Switched user and logged in.");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MainForm.Instance.AddToActionsList("SwitchUser failed: " + ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Attempts to click the web element with the specified ID; refreshes the page and retries once if the initial attempt fails
|
// Attempts to click the web element with the specified ID; refreshes the page and retries once if the initial attempt fails
|
||||||
public static void ClickElementByID(string elementID, ChromeDriver driver, bool tryagain = true)
|
public static void ClickElementByID(string elementID, ChromeDriver driver, bool tryagain = true)
|
||||||
{
|
{
|
||||||
@@ -65,17 +106,40 @@ namespace AiQ_GUI
|
|||||||
// Initialises and opens a ChromeDriver with specific options
|
// Initialises and opens a ChromeDriver with specific options
|
||||||
public static ChromeDriver OpenDriver()
|
public static ChromeDriver OpenDriver()
|
||||||
{
|
{
|
||||||
ChromeDriverService chromeDriverService = ChromeDriverService.CreateDefaultService();
|
string tempProfile = null;
|
||||||
chromeDriverService.HideCommandPromptWindow = true;
|
|
||||||
ChromeOptions options = new();
|
|
||||||
options.AddArguments("--app=data:,", "--window-size=960,1040", "--window-position=0,0");
|
|
||||||
options.AddExcludedArgument("enable-automation");
|
|
||||||
options.AddAdditionalChromeOption("useAutomationExtension", false);
|
|
||||||
|
|
||||||
ChromeDriver driver = new(chromeDriverService, options);
|
try
|
||||||
|
{
|
||||||
|
ChromeOptions options = new();
|
||||||
|
options.AddArguments("--app=data:,",
|
||||||
|
"--window-size=960,1040",
|
||||||
|
"--window-position=0,0",
|
||||||
|
"--no-sandbox",
|
||||||
|
"--incognito",
|
||||||
|
"--no-first-run",
|
||||||
|
"--no-default-browser-check",
|
||||||
|
"--disable-features=BrowserAddPersonFeature,InterestFeedContentSuggestions");
|
||||||
|
|
||||||
|
// Use a unique temporary profile to avoid conflicts
|
||||||
|
tempProfile = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
|
||||||
|
options.AddArguments($"--user-data-dir={tempProfile}");
|
||||||
|
|
||||||
|
// manual driver path
|
||||||
|
string driverPath = @"C:\ProgramData\MAV\AiQ_GUI";
|
||||||
|
ChromeDriverService service = ChromeDriverService.CreateDefaultService(driverPath);
|
||||||
|
service.HideCommandPromptWindow = true;
|
||||||
|
|
||||||
|
ChromeDriver driver = new(service, options);
|
||||||
driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(5);
|
driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(5);
|
||||||
|
|
||||||
return driver;
|
return driver;
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MainForm.Instance.AddToActionsList("Failed to create ChromeDriver: " + ex.Message);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Changes the value of a dropdown element by ID, logs the action, and verifies the result using flashline feedback
|
// Changes the value of a dropdown element by ID, logs the action, and verifies the result using flashline feedback
|
||||||
public static async Task Dropdown_Change(string fullId, string value, ChromeDriver driver, string SoakLogFile, string CamAct)
|
public static async Task Dropdown_Change(string fullId, string value, ChromeDriver driver, string SoakLogFile, string CamAct)
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ namespace AiQ_GUI
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
driver = Selenium.OpenDriver();
|
driver = Selenium.OpenDriver();
|
||||||
|
await Task.Delay(1000); // Small delay to ensure driver is ready
|
||||||
|
|
||||||
// Keep retrying until connected or cancelled
|
// Keep retrying until connected or cancelled
|
||||||
bool connected = false;
|
bool connected = false;
|
||||||
@@ -27,6 +28,7 @@ namespace AiQ_GUI
|
|||||||
{
|
{
|
||||||
// Attempt initial connection and navigation to setup tab
|
// Attempt initial connection and navigation to setup tab
|
||||||
Selenium.GoToUrl($"http://{CamInfo.IP}", driver);
|
Selenium.GoToUrl($"http://{CamInfo.IP}", driver);
|
||||||
|
Selenium.SwitchUser(driver);
|
||||||
Selenium.ClickElementByID("tabSetup", driver);
|
Selenium.ClickElementByID("tabSetup", driver);
|
||||||
connected = true;
|
connected = true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user