Compare commits
17 Commits
cfe8a57a9d
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 791cee91d2 | |||
| 00b225a3db | |||
| e94a1f1f5c | |||
| a91c3b846f | |||
| 42a4778555 | |||
| 3d71ab7e9b | |||
| 78c440ab76 | |||
| dd8e87258f | |||
| 1c89cf2847 | |||
| f95e958ffb | |||
| 95fb5d6ab8 | |||
| c18514802c | |||
| f78e44903b | |||
| ed121fa3db | |||
| aa28a43347 | |||
| b59d023887 | |||
| a2f86625be |
44
AiQ_GUI.Designer.cs
generated
44
AiQ_GUI.Designer.cs
generated
@@ -144,6 +144,8 @@ namespace AiQ_GUI
|
|||||||
BtnZoom8000 = new Button();
|
BtnZoom8000 = new Button();
|
||||||
BtnZoomWide = new Button();
|
BtnZoomWide = new Button();
|
||||||
TabSettings = new TabPage();
|
TabSettings = new TabPage();
|
||||||
|
BtnUploadWonwooSetIR = new Button();
|
||||||
|
BtnUploadWonwooSetOV = new Button();
|
||||||
BtnAdminStart = new Button();
|
BtnAdminStart = new Button();
|
||||||
BtnFirewall = new Button();
|
BtnFirewall = new Button();
|
||||||
TabImages = new TabPage();
|
TabImages = new TabPage();
|
||||||
@@ -270,7 +272,7 @@ namespace AiQ_GUI
|
|||||||
CbBxUserName.Font = new Font("Segoe UI Semibold", 10F, FontStyle.Bold);
|
CbBxUserName.Font = new Font("Segoe UI Semibold", 10F, FontStyle.Bold);
|
||||||
CbBxUserName.ForeColor = SystemColors.Control;
|
CbBxUserName.ForeColor = SystemColors.Control;
|
||||||
CbBxUserName.FormattingEnabled = true;
|
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.Location = new Point(10, 262);
|
||||||
CbBxUserName.Margin = new Padding(4, 3, 4, 3);
|
CbBxUserName.Margin = new Padding(4, 3, 4, 3);
|
||||||
CbBxUserName.MaxDropDownItems = 20;
|
CbBxUserName.MaxDropDownItems = 20;
|
||||||
@@ -1146,7 +1148,7 @@ namespace AiQ_GUI
|
|||||||
TxBxFlexiVer.Name = "TxBxFlexiVer";
|
TxBxFlexiVer.Name = "TxBxFlexiVer";
|
||||||
TxBxFlexiVer.Size = new Size(205, 25);
|
TxBxFlexiVer.Size = new Size(205, 25);
|
||||||
TxBxFlexiVer.TabIndex = 162;
|
TxBxFlexiVer.TabIndex = 162;
|
||||||
TxBxFlexiVer.Text = "1.6.4";
|
TxBxFlexiVer.Text = "1.7.1";
|
||||||
TxBxFlexiVer.TextAlign = HorizontalAlignment.Center;
|
TxBxFlexiVer.TextAlign = HorizontalAlignment.Center;
|
||||||
TxBxFlexiVer.TextChanged += TxBxFlexiVer_TextChanged;
|
TxBxFlexiVer.TextChanged += TxBxFlexiVer_TextChanged;
|
||||||
//
|
//
|
||||||
@@ -1836,6 +1838,8 @@ namespace AiQ_GUI
|
|||||||
// TabSettings
|
// TabSettings
|
||||||
//
|
//
|
||||||
TabSettings.BackColor = Color.FromArgb(39, 37, 55);
|
TabSettings.BackColor = Color.FromArgb(39, 37, 55);
|
||||||
|
TabSettings.Controls.Add(BtnUploadWonwooSetIR);
|
||||||
|
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);
|
||||||
@@ -1846,6 +1850,40 @@ namespace AiQ_GUI
|
|||||||
TabSettings.TabIndex = 3;
|
TabSettings.TabIndex = 3;
|
||||||
TabSettings.Text = "Settings";
|
TabSettings.Text = "Settings";
|
||||||
//
|
//
|
||||||
|
// BtnUploadWonwooSetIR
|
||||||
|
//
|
||||||
|
BtnUploadWonwooSetIR.BackColor = Color.FromArgb(70, 65, 80);
|
||||||
|
BtnUploadWonwooSetIR.FlatAppearance.BorderColor = Color.FromArgb(70, 65, 80);
|
||||||
|
BtnUploadWonwooSetIR.FlatAppearance.BorderSize = 0;
|
||||||
|
BtnUploadWonwooSetIR.FlatStyle = FlatStyle.Flat;
|
||||||
|
BtnUploadWonwooSetIR.Font = new Font("Segoe UI Semibold", 10F, FontStyle.Bold);
|
||||||
|
BtnUploadWonwooSetIR.ForeColor = SystemColors.Control;
|
||||||
|
BtnUploadWonwooSetIR.Location = new Point(210, 304);
|
||||||
|
BtnUploadWonwooSetIR.Margin = new Padding(4, 3, 4, 3);
|
||||||
|
BtnUploadWonwooSetIR.Name = "BtnUploadWonwooSetIR";
|
||||||
|
BtnUploadWonwooSetIR.Size = new Size(180, 49);
|
||||||
|
BtnUploadWonwooSetIR.TabIndex = 244;
|
||||||
|
BtnUploadWonwooSetIR.Text = "Upload Wonwoo Settings IR";
|
||||||
|
BtnUploadWonwooSetIR.UseVisualStyleBackColor = false;
|
||||||
|
BtnUploadWonwooSetIR.Click += UploadWonwooSetIR_Click;
|
||||||
|
//
|
||||||
|
// BtnUploadWonwooSetOV
|
||||||
|
//
|
||||||
|
BtnUploadWonwooSetOV.BackColor = Color.FromArgb(70, 65, 80);
|
||||||
|
BtnUploadWonwooSetOV.FlatAppearance.BorderColor = Color.FromArgb(70, 65, 80);
|
||||||
|
BtnUploadWonwooSetOV.FlatAppearance.BorderSize = 0;
|
||||||
|
BtnUploadWonwooSetOV.FlatStyle = FlatStyle.Flat;
|
||||||
|
BtnUploadWonwooSetOV.Font = new Font("Segoe UI Semibold", 10F, FontStyle.Bold);
|
||||||
|
BtnUploadWonwooSetOV.ForeColor = SystemColors.Control;
|
||||||
|
BtnUploadWonwooSetOV.Location = new Point(19, 304);
|
||||||
|
BtnUploadWonwooSetOV.Margin = new Padding(4, 3, 4, 3);
|
||||||
|
BtnUploadWonwooSetOV.Name = "BtnUploadWonwooSetOV";
|
||||||
|
BtnUploadWonwooSetOV.Size = new Size(181, 49);
|
||||||
|
BtnUploadWonwooSetOV.TabIndex = 243;
|
||||||
|
BtnUploadWonwooSetOV.Text = "Upload Wonwoo Settings OV";
|
||||||
|
BtnUploadWonwooSetOV.UseVisualStyleBackColor = false;
|
||||||
|
BtnUploadWonwooSetOV.Click += UploadWonwooSetOV_Click;
|
||||||
|
//
|
||||||
// BtnAdminStart
|
// BtnAdminStart
|
||||||
//
|
//
|
||||||
BtnAdminStart.BackColor = Color.FromArgb(70, 65, 80);
|
BtnAdminStart.BackColor = Color.FromArgb(70, 65, 80);
|
||||||
@@ -2211,5 +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 BtnUploadWonwooSetOV;
|
||||||
|
private Button BtnUploadWonwooSetIR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
290
AiQ_GUI.cs
290
AiQ_GUI.cs
@@ -1,9 +1,6 @@
|
|||||||
using AiQ_GUI.Microsoft;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json;
|
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Data.OleDb;
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Numerics;
|
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
namespace AiQ_GUI
|
namespace AiQ_GUI
|
||||||
@@ -22,14 +19,14 @@ namespace AiQ_GUI
|
|||||||
private List<CancellationTokenSource> soakCtsList = [];
|
private List<CancellationTokenSource> soakCtsList = [];
|
||||||
private List<Task> soakTasks = [];
|
private List<Task> soakTasks = [];
|
||||||
|
|
||||||
|
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);
|
||||||
public static readonly Color TxBxColour = Color.FromArgb(53, 51, 64);
|
public static readonly Color TxBxColour = Color.FromArgb(53, 51, 64);
|
||||||
|
|
||||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||||
public static MainForm? Instance { get; private set; }
|
public static MainForm? Instance { get; private set; }
|
||||||
// For Access Stats
|
|
||||||
const string connString = @"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;";
|
|
||||||
|
|
||||||
public MainForm()
|
public MainForm()
|
||||||
{
|
{
|
||||||
@@ -42,7 +39,7 @@ namespace AiQ_GUI
|
|||||||
Stopwatch stopwatch = Stopwatch.StartNew();
|
Stopwatch stopwatch = Stopwatch.StartNew();
|
||||||
|
|
||||||
Task? closeProcessesTask = Windows.CloseProcesses(); // Fire and forget closing other apps
|
Task? closeProcessesTask = Windows.CloseProcesses(); // Fire and forget closing other apps
|
||||||
//Windows.UpdateFirewall();
|
Windows.UpdateFirewall();
|
||||||
Task UniDataTask = Task.Run(() => Access.ReadUniData()); // Get universal data
|
Task UniDataTask = Task.Run(() => Access.ReadUniData()); // Get universal data
|
||||||
Task<LocalDataStore> LDSWAIT = Task.Run(() => LDS.GetLDS()); // Get and deserialise LDS.json
|
Task<LocalDataStore> LDSWAIT = Task.Run(() => LDS.GetLDS()); // Get and deserialise LDS.json
|
||||||
Task<string> guiVerTask = Task.Run(() => GUIUpdate.FindGUIVersion()); // Get GUI Version
|
Task<string> guiVerTask = Task.Run(() => GUIUpdate.FindGUIVersion()); // Get GUI Version
|
||||||
@@ -108,7 +105,7 @@ namespace AiQ_GUI
|
|||||||
CbBxIris.SelectedIndex = lds.Iris;
|
CbBxIris.SelectedIndex = lds.Iris;
|
||||||
CbBxGain.SelectedIndex = lds.Gain;
|
CbBxGain.SelectedIndex = lds.Gain;
|
||||||
|
|
||||||
if (lds.User == "Bradley")
|
if (lds.User == "Bradley" || lds.User == "Sophie")
|
||||||
BtnTest.Visible = true;
|
BtnTest.Visible = true;
|
||||||
|
|
||||||
TxBxCheckValid(TxBxPsuIP); // Set save button color if valid
|
TxBxCheckValid(TxBxPsuIP); // Set save button color if valid
|
||||||
@@ -204,6 +201,7 @@ namespace AiQ_GUI
|
|||||||
if (!LEDreply.Contains("Power levels set successfully"))
|
if (!LEDreply.Contains("Power levels set successfully"))
|
||||||
AddToActionsList($"LED level could not be set: {LEDreply}");
|
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
|
DateTime PCTime = DateTime.Now; // Grab PC time as close to the API as possible to pass onto PDF later
|
||||||
|
|
||||||
@@ -223,83 +221,11 @@ namespace AiQ_GUI
|
|||||||
// If there are any actions identified then fail the test.
|
// If there are any actions identified then fail the test.
|
||||||
// If any labels are red then fail. Only labels in panel so can foreach on labels not controls
|
// If any labels are red then fail. Only labels in panel so can foreach on labels not controls
|
||||||
if (RhTxBxActions.Text.Length > 2 || PnlLbls.Controls.OfType<Label>().Any(c => c.ForeColor == Color.Red) == true)
|
if (RhTxBxActions.Text.Length > 2 || PnlLbls.Controls.OfType<Label>().Any(c => c.ForeColor == Color.Red) == true)
|
||||||
await TestFailed(BtnStartTest, "Failed due to action box text and/or red label");// If approved then pass otherwise GUI would have restarted before getting to TestPassed.
|
|
||||||
{
|
|
||||||
await TestFailed(BtnStartTest, "Diagnostic Failure");// If approved then pass otherwise GUI would have restarted before getting to TestPassed.
|
await TestFailed(BtnStartTest, "Diagnostic Failure");// If approved then pass otherwise GUI would have restarted before getting to TestPassed.
|
||||||
}
|
|
||||||
|
|
||||||
await TestPassed(PCTime);
|
await TestPassed(PCTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Stats(string TypeOfTest)
|
|
||||||
{
|
|
||||||
Stats([TypeOfTest]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Stats(string[] TypeOfTest)
|
|
||||||
{
|
|
||||||
using OleDbConnection conn = new(connString); // Opens connection to Access database
|
|
||||||
try
|
|
||||||
{
|
|
||||||
conn.Open(); // Opens DB
|
|
||||||
string modelNumber = CbBxCameraType.Text.Substring(0, 6); // Get model number from combobox and make sure it is only 6 characters.
|
|
||||||
|
|
||||||
foreach (string type in TypeOfTest)
|
|
||||||
{
|
|
||||||
string query = $"UPDATE AiQ SET [{type}] = [{type}] + 1 WHERE [ModelNumber] = ?"; // Add one for every test ran of this type for this model number
|
|
||||||
using OleDbCommand cmd = new(query, conn); // Create command
|
|
||||||
cmd.Parameters.AddWithValue("?", modelNumber); // Add model number to prevent injection
|
|
||||||
|
|
||||||
int rowsAffected = cmd.ExecuteNonQuery();
|
|
||||||
// Execute the command and get the number of rows affected
|
|
||||||
//if (rowsAffected > 0) // If one or more rows were updated
|
|
||||||
// AddToActionsList($"Updated {TypeOfTest} for {modelNumber}");
|
|
||||||
//else
|
|
||||||
// AddToActionsList($"No rows found for {modelNumber}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
AddToActionsList("Could not access Access in Google Drive. Is it running?");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void StatsDiags(string redDiagLabels, string RhTxBxActionsText)
|
|
||||||
{
|
|
||||||
using OleDbConnection conn = new(connString);
|
|
||||||
conn.Open();
|
|
||||||
|
|
||||||
// Null checks
|
|
||||||
string redVal = string.IsNullOrWhiteSpace(redDiagLabels) ? "-" : redDiagLabels;
|
|
||||||
string actVal = string.IsNullOrWhiteSpace(RhTxBxActionsText) ? "-" : RhTxBxActionsText;
|
|
||||||
string model = string.IsNullOrWhiteSpace(CamOnTest?.Model) ? "-" : CamOnTest.Model;
|
|
||||||
|
|
||||||
string sql = @"
|
|
||||||
INSERT INTO DiagsStats ([Date], [Model], [Red Diags Labels], [RhTxBxActions Contents])
|
|
||||||
VALUES (?, ?, ?, ?)";
|
|
||||||
|
|
||||||
using OleDbCommand cmd = new(sql, conn);
|
|
||||||
|
|
||||||
cmd.Parameters.Add(new OleDbParameter
|
|
||||||
{
|
|
||||||
OleDbType = OleDbType.Date,
|
|
||||||
Value = DateTime.Now
|
|
||||||
});
|
|
||||||
cmd.Parameters.AddWithValue("?", model);
|
|
||||||
cmd.Parameters.AddWithValue("?", redVal);
|
|
||||||
cmd.Parameters.AddWithValue("?", actVal);
|
|
||||||
|
|
||||||
int rows = cmd.ExecuteNonQuery();
|
|
||||||
|
|
||||||
//if (rows > 0)
|
|
||||||
// AddToActionsList($"DiagsStats inserted ({rows} row) for model '{model}' on {DateTime.Now:yyyy-MM-dd}");
|
|
||||||
//else
|
|
||||||
// AddToActionsList("No rows inserted into DiagsStats (unexpected).");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private async void BtnPreTest_Click(object sender, EventArgs e)
|
private async void BtnPreTest_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
// Show user test has started
|
// Show user test has started
|
||||||
@@ -347,6 +273,8 @@ namespace AiQ_GUI
|
|||||||
await AllocateSerial();
|
await AllocateSerial();
|
||||||
else if (GoogleAPI.UpdateSpreadSheetRePreTest(CameraAccessInfo.SpreadsheetID, Vers) != "OK") // If rerun might be different values so update SS
|
else if (GoogleAPI.UpdateSpreadSheetRePreTest(CameraAccessInfo.SpreadsheetID, Vers) != "OK") // If rerun might be different values so update SS
|
||||||
AddToActionsList("Failed to write to spreadsheet, please check manually");
|
AddToActionsList("Failed to write to spreadsheet, please check manually");
|
||||||
|
// else if (Excel.UpdateSpreadSheetPreTest(CameraAccessInfo.SpreadsheetID, Vers, CamOnTest.GetCamDesc(), CamOnTest.Model) != "OK")
|
||||||
|
// AddToActionsList("Failed to write to spreadsheet, please check manually");
|
||||||
}
|
}
|
||||||
else // No serial or model so allocate one
|
else // No serial or model so allocate one
|
||||||
await AllocateSerial();
|
await AllocateSerial();
|
||||||
@@ -378,7 +306,7 @@ namespace AiQ_GUI
|
|||||||
{
|
{
|
||||||
// Turn off God mode
|
// Turn off God mode
|
||||||
string[,] GOD_JSON = { { "propGodMode", "false" } };
|
string[,] GOD_JSON = { { "propGodMode", "false" } };
|
||||||
string IntConf = await FlexiAPI.HTTP_Update("Internal Config", CamOnTest.IP, GOD_JSON);
|
string IntConf = await FlexiAPI.HTTP_Update("GLOBAL--FlexiApplication", CamOnTest.IP, GOD_JSON);
|
||||||
if (!IntConf.Contains("\"propGodMode\": {\"value\": \"false\", \"datatype\": \"boolean\"},"))
|
if (!IntConf.Contains("\"propGodMode\": {\"value\": \"false\", \"datatype\": \"boolean\"},"))
|
||||||
AddToActionsList("Could not turn off God mode");
|
AddToActionsList("Could not turn off God mode");
|
||||||
|
|
||||||
@@ -410,11 +338,11 @@ namespace AiQ_GUI
|
|||||||
Logging.LogMessage("Final Test Passed");
|
Logging.LogMessage("Final Test Passed");
|
||||||
if (CamOnTest.RMANum == 0) // Yap to check if it is not a RMA
|
if (CamOnTest.RMANum == 0) // Yap to check if it is not a RMA
|
||||||
{
|
{
|
||||||
Stats("Final Tests Passed");
|
Access.Stats("Final Tests Passed", CamOnTest.Model);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Stats("RMA Final Tests Passed");
|
Access.Stats("RMA Final Tests Passed", CamOnTest.Model);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -424,13 +352,14 @@ namespace AiQ_GUI
|
|||||||
// Indicators to the user the test has failed
|
// Indicators to the user the test has failed
|
||||||
Btn.BackColor = Color.Maroon;
|
Btn.BackColor = Color.Maroon;
|
||||||
Btn.Text = "Test Failed";
|
Btn.Text = "Test Failed";
|
||||||
|
|
||||||
if (!(CamOnTest.RMANum != 0)) // Yap to check if it is not a RMA
|
if (!(CamOnTest.RMANum != 0)) // Yap to check if it is not a RMA
|
||||||
{
|
{
|
||||||
Stats( ["Final Tests Failed", ErrMssg]);
|
Access.Stats(["Final Tests Failed", ErrMssg], CamOnTest.Model);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Stats("RMA Final Tests Failed");
|
Access.Stats("RMA Final Tests Failed", CamOnTest.Model);
|
||||||
}
|
}
|
||||||
AddToActionsList(ErrMssg);
|
AddToActionsList(ErrMssg);
|
||||||
|
|
||||||
@@ -440,8 +369,7 @@ namespace AiQ_GUI
|
|||||||
.Select(lbl => lbl.Text)); // Extract text
|
.Select(lbl => lbl.Text)); // Extract text
|
||||||
string FullFailureValues = RhTxBxActions.Text + Environment.NewLine + RedLbls;
|
string FullFailureValues = RhTxBxActions.Text + Environment.NewLine + RedLbls;
|
||||||
|
|
||||||
StatsDiags(RedLbls, RhTxBxActions.Text); // Log to Access database
|
Access.StatsDiags(RedLbls, RhTxBxActions.Text, CamOnTest.Model); // Log to Access database
|
||||||
|
|
||||||
|
|
||||||
if (await DisplayQuestion("Test failed, appeal?" + Environment.NewLine + "See Actions textbox for details."))
|
if (await DisplayQuestion("Test failed, appeal?" + Environment.NewLine + "See Actions textbox for details."))
|
||||||
{
|
{
|
||||||
@@ -459,9 +387,6 @@ namespace AiQ_GUI
|
|||||||
// Joins the actions box to any red labels to use as a full failed text
|
// Joins the actions box to any red labels to use as a full failed text
|
||||||
Logging.LogErrorMessage(FullFailureValues);
|
Logging.LogErrorMessage(FullFailureValues);
|
||||||
|
|
||||||
|
|
||||||
Logging.LogErrorMessage(FullFailureValues);
|
|
||||||
|
|
||||||
IList<IList<object>> values = GoogleAPI.service.Spreadsheets.Values.Get(GoogleAPI.spreadsheetId_ModelInfo, "'Approval'!A1:A").Execute().Values;
|
IList<IList<object>> values = GoogleAPI.service.Spreadsheets.Values.Get(GoogleAPI.spreadsheetId_ModelInfo, "'Approval'!A1:A").Execute().Values;
|
||||||
|
|
||||||
if (values?.Count > 0)
|
if (values?.Count > 0)
|
||||||
@@ -474,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)
|
||||||
@@ -514,14 +438,11 @@ namespace AiQ_GUI
|
|||||||
PnlQuestion.Visible = true;
|
PnlQuestion.Visible = true;
|
||||||
BtnNo.Visible = false;
|
BtnNo.Visible = false;
|
||||||
Logging.LogMessage("Pre Test Passed");
|
Logging.LogMessage("Pre Test Passed");
|
||||||
|
|
||||||
if (CamOnTest.RMANum == 0) // Yap to check if it is not a RMA
|
if (CamOnTest.RMANum == 0) // Yap to check if it is not a RMA
|
||||||
{
|
Access.Stats("Pre Tests Passed", CamOnTest.Model);
|
||||||
Stats("Pre Tests Passed");
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
Access.Stats("RMA Pre Tests Passed", CamOnTest.Model);
|
||||||
Stats("RMA Pre Tests Passed");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (await DisplayQuestion("Test passed, restart?"))
|
if (await DisplayQuestion("Test passed, restart?"))
|
||||||
Helper.RestartApp();
|
Helper.RestartApp();
|
||||||
@@ -536,13 +457,9 @@ namespace AiQ_GUI
|
|||||||
Logging.LogMessage("Pre Test Failed");
|
Logging.LogMessage("Pre Test Failed");
|
||||||
|
|
||||||
if (CamOnTest.RMANum == 0) // Yap to check if it is not a RMA
|
if (CamOnTest.RMANum == 0) // Yap to check if it is not a RMA
|
||||||
{
|
Access.Stats(["Pre Tests Failed", ErrMssg], CamOnTest.Model);
|
||||||
Stats(["Pre Tests Failed", ErrMssg]);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
Access.Stats("RMA Pre Tests Failed", CamOnTest.Model);
|
||||||
Stats("RMA Pre Tests Failed");
|
|
||||||
}
|
|
||||||
|
|
||||||
string RedLbls = string.Join(Environment.NewLine, PnlLbls.Controls
|
string RedLbls = string.Join(Environment.NewLine, PnlLbls.Controls
|
||||||
.OfType<Label>()
|
.OfType<Label>()
|
||||||
@@ -550,7 +467,7 @@ namespace AiQ_GUI
|
|||||||
.Select(lbl => lbl.Text)); // Extract text
|
.Select(lbl => lbl.Text)); // Extract text
|
||||||
string FullFailureValues = RhTxBxActions.Text + Environment.NewLine + RedLbls;
|
string FullFailureValues = RhTxBxActions.Text + Environment.NewLine + RedLbls;
|
||||||
|
|
||||||
StatsDiags(RedLbls, RhTxBxActions.Text); // Log to Access database
|
Access.StatsDiags(RedLbls, RhTxBxActions.Text, CamOnTest.Model); // Log to Access database
|
||||||
|
|
||||||
if (await DisplayQuestion("Test failed, restart?" + Environment.NewLine + "See Actions textbox for details."))
|
if (await DisplayQuestion("Test failed, restart?" + Environment.NewLine + "See Actions textbox for details."))
|
||||||
Helper.RestartApp();
|
Helper.RestartApp();
|
||||||
@@ -748,7 +665,7 @@ namespace AiQ_GUI
|
|||||||
|
|
||||||
if (RegexCache.VaxtorRegex().IsMatch(ProdcutKeyID)) // Means they chose the 'I don't know' option or isn't valid Key ID
|
if (RegexCache.VaxtorRegex().IsMatch(ProdcutKeyID)) // Means they chose the 'I don't know' option or isn't valid Key ID
|
||||||
{
|
{
|
||||||
Stats("Please Get A Valid Vaxtor Product Key Before Continuing");
|
Access.Stats("Please Get A Valid Vaxtor Product Key Before Continuing", CamOnTest.Model);
|
||||||
await TestFailed(BtnStartTest, "Please get a valid Vaxtor Product Key before continuing");
|
await TestFailed(BtnStartTest, "Please get a valid Vaxtor Product Key before continuing");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -795,7 +712,7 @@ namespace AiQ_GUI
|
|||||||
|
|
||||||
// Set serial and model into camera
|
// Set serial and model into camera
|
||||||
string[,] TEST_JSON = { { "propSerialNumber", NewSerial }, { "propMavModelNumber", CamOnTest.Model } };
|
string[,] TEST_JSON = { { "propSerialNumber", NewSerial }, { "propMavModelNumber", CamOnTest.Model } };
|
||||||
string JSONResponse = await FlexiAPI.HTTP_Update("Internal Config", CamOnTest.IP, TEST_JSON);
|
string JSONResponse = await FlexiAPI.HTTP_Update("GLOBAL--FlexiApplication", CamOnTest.IP, TEST_JSON);
|
||||||
|
|
||||||
if (!JSONResponse.Contains(NewSerial) || !JSONResponse.Contains(CamOnTest.Model))
|
if (!JSONResponse.Contains(NewSerial) || !JSONResponse.Contains(CamOnTest.Model))
|
||||||
{
|
{
|
||||||
@@ -854,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();
|
||||||
@@ -970,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();
|
||||||
@@ -1009,7 +926,7 @@ namespace AiQ_GUI
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await FlexiAPI.HTTP_Update("Internal Config", CamOnTest.IP, GOD_JSON);
|
await FlexiAPI.HTTP_Update("GLOBAL--FlexiApplication", CamOnTest.IP, GOD_JSON);
|
||||||
BtnSetGodMode.Text = newGodModeValue == "true" ? "Set God Mode Off" : "Set God Mode On";
|
BtnSetGodMode.Text = newGodModeValue == "true" ? "Set God Mode Off" : "Set God Mode On";
|
||||||
BtnSetGodMode.BackColor = Color.Green;
|
BtnSetGodMode.BackColor = Color.Green;
|
||||||
}
|
}
|
||||||
@@ -1055,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)
|
||||||
@@ -1255,7 +1172,7 @@ namespace AiQ_GUI
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
Network.Initialize("developer", SCL.DevPass); // Ensure network is initialized to the right camera
|
Network.Initialize("developer", SCL.DevPass); // Ensure network is initialized to the right camera
|
||||||
string RESP = await FlexiAPI.HTTP_Update("Internal Config", SCL.IP, GOD_JSON);
|
string RESP = await FlexiAPI.HTTP_Update("GLOBAL--FlexiApplication", SCL.IP, GOD_JSON);
|
||||||
Instance.AddToActionsList($"Setting God mode for camera {SCL.IP} to {newGodModeValue}", false);
|
Instance.AddToActionsList($"Setting God mode for camera {SCL.IP} to {newGodModeValue}", false);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -1572,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
|
||||||
@@ -1648,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
|
||||||
@@ -1659,14 +1586,44 @@ 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
|
||||||
|
{
|
||||||
|
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
|
||||||
|
|
||||||
Network.Initialize("developer", SCL.DevPass); // Ensure network is initialized to the right camera, cannot be done in soak test finally becuase of this.
|
string GOD = await FlexiAPI.HTTP_Update("GLOBAL--FlexiApplication", SCL.IP, GOD_JSON);
|
||||||
await CameraModules.FactoryResetModules(SCL.IP);
|
if (GOD.Contains("Error"))
|
||||||
|
throw new Exception("Could not set God mode off");
|
||||||
|
|
||||||
|
// Update GLOBAL--NetworkConfig with fixed IP and turn off DHCP
|
||||||
|
await FlexiAPI.HTTP_Update("GLOBAL--NetworkConfig", SCL.IP, Network_JSON);
|
||||||
|
i--; // Decriment count becuase they will stack into 211
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1752,7 +1709,7 @@ namespace AiQ_GUI
|
|||||||
{
|
{
|
||||||
string apiUrl = $"http://{cam.IP}/upload/software-update/2";
|
string apiUrl = $"http://{cam.IP}/upload/software-update/2";
|
||||||
Network.Initialize("developer", cam.DevPass);
|
Network.Initialize("developer", cam.DevPass);
|
||||||
|
await Task.Delay(1000); // Gives extra time to allow for Network to initialize
|
||||||
AddToActionsList($"Uploading to {cam.IP}...", false);
|
AddToActionsList($"Uploading to {cam.IP}...", false);
|
||||||
string result = await FlexiAPI.SendBlobFileUpload(apiUrl, fileToUpload, fileName);
|
string result = await FlexiAPI.SendBlobFileUpload(apiUrl, fileToUpload, fileName);
|
||||||
|
|
||||||
@@ -1785,105 +1742,20 @@ namespace AiQ_GUI
|
|||||||
BtnFactoryDefault.BackColor = Color.Green;
|
BtnFactoryDefault.BackColor = Color.Green;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Constants
|
|
||||||
const double RealPlateWidthMeters = 0.52; // UK standard plate width
|
|
||||||
// const double FocalLengthPixels = (50 * 1280) / 14.111224; // focal mm * pixel width / sensor width for IQ
|
|
||||||
const double FocalLengthPixels = (35 * 1920) / 6.95; // focal mm * pixel width / sensor width for AiQ
|
|
||||||
const double FrameRate = 25.0; // Frames per second
|
|
||||||
|
|
||||||
public class FrameData
|
|
||||||
{
|
|
||||||
public long FrameID;
|
|
||||||
public int PlatePosX;
|
|
||||||
public int PlatePosY;
|
|
||||||
public int PlateWidthPixels;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double EstimateSpeed(List<FrameData> frames)
|
|
||||||
{
|
|
||||||
double TimeElapsed = 0;
|
|
||||||
int frameCount = frames.Count;
|
|
||||||
|
|
||||||
for (int i = 1; i < frameCount; i++)
|
|
||||||
{
|
|
||||||
double time = (frames[i].FrameID - frames[i - 1].FrameID) / FrameRate;
|
|
||||||
TimeElapsed += time;
|
|
||||||
}
|
|
||||||
|
|
||||||
double FarDist = (FocalLengthPixels * RealPlateWidthMeters) / frames[0].PlateWidthPixels;
|
|
||||||
double CloseDist = (FocalLengthPixels * RealPlateWidthMeters) / frames[frameCount - 1].PlateWidthPixels;
|
|
||||||
|
|
||||||
double speedMph = (Math.Abs(FarDist - CloseDist) / TimeElapsed) * 2.237;
|
|
||||||
return speedMph;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ***** Test & Debug *****
|
// ***** Test & Debug *****
|
||||||
private async void BtnTest_Click(object sender, EventArgs e)
|
private async void BtnTest_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Stopwatch stopWatchTest = Stopwatch.StartNew();
|
Stopwatch stopWatchTest = Stopwatch.StartNew();
|
||||||
//string[,] GOD_JSON = { { "propURI", "rtsp://ADMIN:1234@192.168.0.49:554/live/main" } };
|
|
||||||
//string str = FlexiAPI.BuildJsonUpdate(GOD_JSON, "CameraA");
|
|
||||||
//AddToActionsList(str);
|
|
||||||
|
|
||||||
// To estimate speed
|
//StatsExcel excelExporter = new();
|
||||||
//List<FrameData> frames = new List<FrameData>
|
//excelExporter.ExportDatabaseToExcel();
|
||||||
//{
|
|
||||||
// new FrameData { FrameID = 60192555, PlatePosX = 1172, PlatePosY = 393, PlateWidthPixels = 108 },
|
|
||||||
// new FrameData { FrameID = 60192556, PlatePosX = 1103, PlatePosY = 361, PlateWidthPixels = 105 },
|
|
||||||
// new FrameData { FrameID = 60192558, PlatePosX = 983, PlatePosY = 331, PlateWidthPixels = 99 },
|
|
||||||
// new FrameData { FrameID = 60192559, PlatePosX = 930, PlatePosY = 301, PlateWidthPixels = 95 },
|
|
||||||
// new FrameData { FrameID = 60192560, PlatePosX = 880, PlatePosY = 304, PlateWidthPixels = 93 },
|
|
||||||
// new FrameData { FrameID = 60192561, PlatePosX = 834, PlatePosY = 278, PlateWidthPixels = 89 },
|
|
||||||
// new FrameData { FrameID = 60192562, PlatePosX = 792, PlatePosY = 229, PlateWidthPixels = 87 },
|
|
||||||
// new FrameData { FrameID = 60192563, PlatePosX = 752, PlatePosY = 208, PlateWidthPixels = 85 },
|
|
||||||
// new FrameData { FrameID = 60192565, PlatePosX = 680, PlatePosY = 187, PlateWidthPixels = 81 },
|
|
||||||
// new FrameData { FrameID = 60192566, PlatePosX = 648, PlatePosY = 167, PlateWidthPixels = 78 },
|
|
||||||
// new FrameData { FrameID = 60192567, PlatePosX = 617, PlatePosY = 149, PlateWidthPixels = 76 },
|
|
||||||
// new FrameData { FrameID = 60192568, PlatePosX = 588, PlatePosY = 132, PlateWidthPixels = 75 },
|
|
||||||
// new FrameData { FrameID = 60192569, PlatePosX = 561, PlatePosY = 100, PlateWidthPixels = 70 },
|
|
||||||
// new FrameData { FrameID = 60192570, PlatePosX = 535, PlatePosY = 85, PlateWidthPixels = 72 },
|
|
||||||
// new FrameData { FrameID = 60192572, PlatePosX = 488, PlatePosY = 70, PlateWidthPixels = 69 },
|
|
||||||
// new FrameData { FrameID = 60192573, PlatePosX = 466, PlatePosY = 55, PlateWidthPixels = 67 }
|
|
||||||
//};
|
|
||||||
|
|
||||||
//double Spd = EstimateSpeed(frames);
|
string ans = await FlexiAPI.HTTP_Fetch("GLOBAL--Device", "192.168.0.71");
|
||||||
//AddToActionsList("Estimated Speed: " + Spd.ToString("F2") + " MPH");
|
AddToActionsList(ans);
|
||||||
|
// /api/config-ids - For getting all available config IDs
|
||||||
|
|
||||||
StatsExcel excelExporter = new();
|
|
||||||
excelExporter.ExportDatabaseToExcel();
|
|
||||||
|
|
||||||
// FakeCamera fakeCamera = new FakeCamera(80); // Create an instance of FakeCamera
|
|
||||||
|
|
||||||
// //CamOnTest.IP = CbBxFoundCams.Text;
|
|
||||||
// _ = fakeCamera.StartAsync(CAMTYPE.BAD).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
|
|
||||||
|
|
||||||
//BtnPreTest_Click(sender, e);
|
|
||||||
|
|
||||||
AddToActionsList("Estimated Speed: " + Spd.ToString("F2") + " MPH");
|
|
||||||
|
|
||||||
stopWatchTest.Stop();
|
stopWatchTest.Stop();
|
||||||
//AddToActionsList("RunTime " + stopWatchTest.Elapsed.ToString(@"hh\:mm\:ss\.ff"));
|
AddToActionsList("RunTime " + stopWatchTest.Elapsed.ToString(@"hh\:mm\:ss\.ff"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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>3.14.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>
|
||||||
@@ -49,11 +59,11 @@
|
|||||||
<PackageReference Include="Google.Apis.Sheets.v4" Version="1.70.0.3819" />
|
<PackageReference Include="Google.Apis.Sheets.v4" Version="1.70.0.3819" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
|
||||||
<PackageReference Include="PDFsharp-MigraDoc-gdi" Version="6.2.2" />
|
<PackageReference Include="PDFsharp-MigraDoc-gdi" Version="6.2.2" />
|
||||||
<PackageReference Include="Selenium.Support" Version="4.37.0" />
|
<PackageReference Include="Selenium.Support" Version="4.38.0" />
|
||||||
<PackageReference Include="Selenium.WebDriver" Version="4.37.0" />
|
<PackageReference Include="Selenium.WebDriver" Version="4.38.0" />
|
||||||
<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="141.0.7390.7800" />
|
<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="142.0.7444.6100" />
|
||||||
<PackageReference Include="SSH.NET" Version="2025.0.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>
|
||||||
|
|||||||
@@ -36,9 +36,9 @@ namespace AiQ_GUI
|
|||||||
{
|
{
|
||||||
string JSONdata = BuildJsonUpdate(jsonArrayData, ID);
|
string JSONdata = BuildJsonUpdate(jsonArrayData, ID);
|
||||||
JSONdata = JSONdata.Replace("\"14\"", "14").Replace("\"30\"", "30"); // Fixes & encoding issue
|
JSONdata = JSONdata.Replace("\"14\"", "14").Replace("\"30\"", "30"); // Fixes & encoding issue
|
||||||
MainForm.Instance.AddToActionsList(JSONdata);
|
|
||||||
string url = $"http://{IPAddress}/api/update-config";
|
string url = $"http://{IPAddress}/api/update-config";
|
||||||
return await Network.SendHttpRequest(url, HttpMethod.Post, 2, JSONdata);
|
return await Network.SendHttpRequest(url, HttpMethod.Post, 2, JSONdata);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -81,7 +81,7 @@ namespace AiQ_GUI
|
|||||||
// Always Infrared as LED's are controlled from infrared page
|
// Always Infrared as LED's are controlled from infrared page
|
||||||
// Level can be word eg. SAFE or hex eg. 0x0E
|
// Level can be word eg. SAFE or hex eg. 0x0E
|
||||||
string suffix = $"/Infrared/led-controls?power={LEVEL}";
|
string suffix = $"/Infrared/led-controls?power={LEVEL}";
|
||||||
return await APIHTTPRequest(suffix, IPAddress);
|
return await APIHTTPRequest(suffix, IPAddress, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<string> SendBlobFileUpload(string url, string filePath, string fileName)
|
public static async Task<string> SendBlobFileUpload(string url, string filePath, string fileName)
|
||||||
@@ -162,6 +162,36 @@ namespace AiQ_GUI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static async Task<bool> SetVaxtorMinMaxPlate(string IP)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Build JSON array for Vaxtor min/max plate configuration
|
||||||
|
string[,] Vaxtor_JSON = { { "propMinCharHeight", "14" }, { "propMaxCharHeight", "40" }, { "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<bool> SetZoomLockOn(string IP)
|
public static async Task<bool> SetZoomLockOn(string IP)
|
||||||
{
|
{
|
||||||
// Set Zoomlock on and if it fails ask user to set it manually
|
// Set Zoomlock on and if it fails ask user to set it manually
|
||||||
@@ -207,8 +237,7 @@ namespace AiQ_GUI
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check no value is -1 (no plate found) or if the positions are identical (one plate found). If it is then try again 3 times
|
// Check no value is -1 (no plate found) or if the positions are identical (one plate found). If it is then try again 3 times
|
||||||
if (new[] { trim.infraredX, trim.infraredY, trim.colourX, trim.colourY }.Any(value => value == -1)
|
if (new[] { trim.infraredX, trim.infraredY, trim.colourX, trim.colourY }.Any(value => value == -1) || (trim.infraredX == trim.colourX && trim.infraredY == trim.colourY))
|
||||||
|| (trim.infraredX == trim.colourX && trim.infraredY == trim.colourY))
|
|
||||||
{
|
{
|
||||||
if (RetryCount >= 3)
|
if (RetryCount >= 3)
|
||||||
{
|
{
|
||||||
@@ -217,7 +246,7 @@ namespace AiQ_GUI
|
|||||||
}
|
}
|
||||||
|
|
||||||
await Task.Delay(5000); // Give 5 second delay for it to see a plate
|
await Task.Delay(5000); // Give 5 second delay for it to see a plate
|
||||||
await SetTrim(IPAddress, LblTxt, RetryCount++);
|
await SetTrim(IPAddress, LblTxt, RetryCount + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int offset = 105;
|
int offset = 105;
|
||||||
@@ -248,7 +277,7 @@ namespace AiQ_GUI
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await Task.Delay(5000); // Give 5 second delay for it to see a plate
|
await Task.Delay(5000); // Give 5 second delay for it to see a plate
|
||||||
await SetTrim(IPAddress, LblTxt, RetryCount++);
|
await SetTrim(IPAddress, LblTxt, RetryCount + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -325,11 +354,86 @@ namespace AiQ_GUI
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Change network settings to DHCP and restart camera for it to take effect
|
// Change network settings to DHCP and restart camera for it to take effect
|
||||||
public async static Task ChangeNetworkToDHCP(string IPAddress)
|
public async static Task<bool> ChangeNetworkToDHCP(string IPAddress)
|
||||||
{
|
{
|
||||||
string[,] TEST_JSON = { { "propDHCP", "true" } }; // Update GLOBAL--NetworkConfig with fixed IP and turn off DHCP
|
string[,] TEST_JSON = { { "propDHCP", "true" } };
|
||||||
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.
|
||||||
// TODO - Check if this worked, if not return false
|
|
||||||
|
await Task.Delay(5000); // Wait for 5 seconds to allow the camera to restart
|
||||||
|
IList<string> FoundCams = await Network.SearchForCams();
|
||||||
|
|
||||||
|
if (FoundCams.Contains("192.168.1.211"))
|
||||||
|
{
|
||||||
|
MainForm.Instance.AddToActionsList("Could not set camera to DHCP please check camera.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
MainForm.Instance.AddToActionsList("Camera successfully set to DHCP.");
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -406,5 +510,13 @@ namespace AiQ_GUI
|
|||||||
public class Property
|
public class Property
|
||||||
{
|
{
|
||||||
public string Value { get; set; } = string.Empty;
|
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; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"cameraName": "AiQ-ANPR-Camera",
|
"cameraName": "AiQ-ANPR-Camera",
|
||||||
"version": "1.6.4",
|
"version": "1.7.1",
|
||||||
"revision": "bf16134",
|
"revision": "4b63df5",
|
||||||
"serialNumber": "K1005001",
|
"serialNumber": "K1005001",
|
||||||
"modelNumber": "AB12CD",
|
"modelNumber": "AB12CD",
|
||||||
"MAC": "3C:6D:66:0A:BA:18",
|
"MAC": "3C:6D:66:0A:BA:18",
|
||||||
|
|||||||
@@ -293,7 +293,7 @@ namespace AiQ_GUI
|
|||||||
{
|
{
|
||||||
await HTTPReplySetup(context, "Update successful.", 200, "text/plain");
|
await HTTPReplySetup(context, "Update successful.", 200, "text/plain");
|
||||||
}
|
}
|
||||||
else if (fo.Id == "Internal Config")
|
else if (fo.Id == "GLOBAL--FlexiApplication")
|
||||||
{
|
{
|
||||||
string SerialNumber = "";
|
string SerialNumber = "";
|
||||||
string ModelNumber = "";
|
string ModelNumber = "";
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"version": "1.6.4",
|
"version": "1.7.1",
|
||||||
"revision": "77e042f",
|
"revision": "4b63df5",
|
||||||
"buildtime": "2025-07-24T10:35:36.445241784Z",
|
"buildtime": "2025-07-24T10:35:36.445241784Z",
|
||||||
"appname": "FlexiAI",
|
"appname": "FlexiAI",
|
||||||
"MAC": "3C:6D:66:0A:BA:18",
|
"MAC": "3C:6D:66:0A:BA:18",
|
||||||
|
|||||||
@@ -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");
|
||||||
|
|||||||
@@ -54,21 +54,36 @@ namespace AiQ_GUI
|
|||||||
public static void PrintGBLbl()
|
public static void PrintGBLbl()
|
||||||
{
|
{
|
||||||
// New Label with UKCA logo
|
// New Label with UKCA logo
|
||||||
const string MadeInGB = "^XA~TA000~JSN^LT0^MNW^MTT^PON^PMN^LH0,0^JMA^PR2,2~SD15^JUS^LRN^CI0^XZ\n" +
|
const string MadeInGB = "^CT~~CD,~CC^~CT~\n" +
|
||||||
|
"^XA\n" +
|
||||||
|
"~TA000\n" +
|
||||||
|
"~JSN\n" +
|
||||||
|
"^LT0\n" +
|
||||||
|
"^MNW\n" +
|
||||||
|
"^MTT\n" +
|
||||||
|
"^PON\n" +
|
||||||
|
"^PMN\n" +
|
||||||
|
"^LH0,0\n" +
|
||||||
|
"^JMA\n" +
|
||||||
|
"^PR2,2\n" +
|
||||||
|
"~SD15\n" +
|
||||||
|
"^JUS\n" +
|
||||||
|
"^LRN\n" +
|
||||||
|
"^CI27\n" +
|
||||||
|
"^PA0,1,1,0\n" +
|
||||||
|
"^XZ\n" +
|
||||||
"^XA\n" +
|
"^XA\n" +
|
||||||
"^MMT\n" +
|
"^MMT\n" +
|
||||||
"^PW384\n" +
|
"^PW384\n" +
|
||||||
"^LL0096\n" +
|
"^LL96\n" +
|
||||||
"^LS0\n" +
|
"^LS0\n" +
|
||||||
"^FO192,0^GFA,01152,01152,00012,:Z64:\n" +
|
"^FO212,34^GFA,225,280,8,:Z64:eJxVkDEKwkAQRZ+GRbs0oo2CtYcwV0hno+AR0oiVkKOk9jTbWAa2TLllKte/uJi1WIbHnz/zZ5l3cABMAyfVaqQILVwsphcHTxlgdoNNDcWoFsnGwlly6eCtutBrIktTCztZvOpRFrWwFl8TD0vYil/1l4MMK/G9mTjX3f7f79J8m+377U95Yr4HKW835ScMuie7r/JaGAek++N/PFs+dGoy4g==:0511\n" +
|
||||||
"eJzt0DEKgDAMBdCUDo49Qm9ij2aP1qN4BEeHYvziL0TURRcHA4VXaEryRf76agWciVZcaQ8nuoMHOsBKxypO2ZqK+Jke0NK+XNAy0hUuOx3exkzjbZSzPdw3j0cnzY999efdDHZOO/9hL7tvyuIrHSfEyGbk5vQiT5uzzX+bwDX/9a5WFTRBPA==:FF83\n" +
|
"^FO336,26^GFA,217,384,8,:Z64:eJxrYEAAFiBWAGIOME8ACIFsvncdIDEWFhERByDNZLdqXwOQZhRkFAQrW8DABaYDGETAtAGDFVQ7hM+htQNMi9QLgGkuZQUwzQi1lKMDwmdwgPINoHwBVHmYei4mBbhjwfIMD6DKIQZoMHyASDBCDOjhfgWmWUMDQBQTE8MGJC+D/boAia/AQBng////P8hB8kD6ABKfHwcfACScKCU=:8B00\n" +
|
||||||
"^FO320,0^GFA,00768,00768,00008,:Z64:\n" +
|
"^FO11,27^GFA,817,1125,25,:Z64:eJxtkkFu00AYhf/pgBwJKcOCbjM3KDewc4QusFhyBZYsAp7UCyIhkSuwZsEZJgKJJSdAmaoLsmqmQhUjYfnn/WMnrVRsRbYz8+nNe/+jlVxuQhP5rWi1ognh9ZNiubwlQ5ZsRw2TLbwh0nkhVC7f7Jip0sGc0JGoqCHLXggd7R0RsBlE4N7ZNpnVUcM31HhbxAVBo7M0PxCR3d9Q6pQIGr1xR+KG6befqUzo/p4GZ4JS/5lsy+uLyUjMmh/qJswoNR00tnc+ymrdXkUQ3ENjvyZSdV0LYY26jDN6I4T+viUi59qRCGkgbHvFDitUCPHIFLdpplL2sWH5n4wQZN5zOvi4T5ApuJvpwYdnOVWqBmLNfcW77APBId1YDYT5thjTLRAciMAj4crjPCr4kE2ZwAAt5wlqn7NqhTij6Ud39mXnrq/d9CJMRQOnYU8PLmTPicPDBdUVHP9LwMaOw2T8nOQ7E7Dh2Z++oPpcndf1/BmdqvljELDhZIKOexVllrlXIMQr+iF2VGzwOPSqRZOEALlMIDj3Cj5gg9CSl/7tq02sb+dYKBKIE9ggZKVDMsuoA6GP0iuZRnwKQvtFsYkqqj94RxMxL97BefkkdGaTdFB7b9tMwMbrrDESv/zQK8JhYvbRPxcNfRWGXlE+fvbRYH/UmzD0SnO/TkcfQkTb7vcyj65AuhZYJwSEbPF1bEkUH1GyQkr4zr1CS+xALMpM4FtvMrGTCZYfUldBYwfi0CvfCLGNCyuE+dkderXk7GPMyrp3h15BJfsYnFtajL3q15x9uM5cwkfpSmggq38uZhFX:58F1\n" +
|
||||||
"eJxjYBjOgAWIHYCYA4gNGOwYBEBs9v8HFEBycnY2IDkmOwabBiDNaP//L1jTBAYxMB3AIAOmDaC0AIMNmJawLwDTMvUTwLQQswCYlmRSANMcLVA6A0obQOkKVHlOqHouRgjNw/AAIs+QALEHSuswfADTLow/QBRjC2MNiGZi//8L7Ec2xo8MUD82gJ3JANaoAHY65UD+////D0ighxYAAPB/L1Q=:B1A7\n" +
|
"^FO278,28^GFA,273,360,8,:Z64:eJx1j7ENwjAQRX8UoRQUKel8LcoMyG6yB2ukCCSlR0EMgSgYgBEyAUrpwspxZwcJIWFLPj3/++fvC/YNGqBHb+RAgLVyoMPBFHPmeso63TM7ZF3alV1I3NO88pR1mr508dPaLw+s86Qu15jmDxxMJdVxsKUYdjynPFseLW74v7yHH4ENx2J4AjUvJYufOFYcdd4iV8CpbelxBM5yJVvygWTrVy1qzQOj9cOdctYdc9JJ6y8v3rsXa/6Y/PJe8pMypTyJ30wJYOg=:5E2C\n" +
|
||||||
"^FO0,0^GFA,02688,02688,00028,:Z64:\n" +
|
"^PQ1,0,1,Y\n" +
|
||||||
"eJzt071OwzAQB/BEHjL6ETzwAowMSH4Y3gMXdejII/RRcJWBsY9QVx0YsdTFEsbH3fmjSaGMDKhXZ/oldc73T9dd61r/sLTXcACnu8ENXsBCAHRGLhRbyLaQTqKFbDZbUmxWsaVsLhtINvwpemjJ5osNv9jI5o1TEW1kC8X2bAGvKLweQ4cWi3m2z2zqwJaqGTLAKwkvs0GxqIuZRzJIZGsyBUmRGXCPRvhhahJAsr27NLFdsRWZRtPNdkBGLZGprYt6WffbsvUAezL5vMdDqe/5ynYL4HlGEm2s/Y1sdwbCw8nMODVs8IbtAHhA5Tw3bPeKZnayPAfLphVAtjd6SShzN2wrujfbcKxzt5ptSXuwObQwsz1t4y5kEOB40Qx8XDLMJ1wyzCfNPOJd1FASoUs115hPMrC0qtmWTzZeaENEcy2fbJ5WNd/yObc0Md8skEmy0PJJtvRaBN3h2ZHlXDPPDNBSNTUz9YIG1WTZr9oitcxD7W9g02zrmXEPZIpsN7PQzKaS66k5Mhx6Krmu9hTprMnApZLrn208N8X/id/AueHnK32zzfm7DGQ9m/1m1HsfRUg116fe+cz6wKZnZvERNBH6WO1a1/qD+gLCtYx7:603A\n" +
|
"^XZ";
|
||||||
"^FO256,0^GFA,01152,01152,00012,:Z64:\n" +
|
|
||||||
"eJzt0DEKwzAMBVAJDxlzBB/F18pQcI7mo/gIGlVwqzpBrkSbDoGO+V4egXy+DXDlv8EKtMCyO1QkRjZPZJ6LOa7mDOZmfrBZyLk4rz++1+9/kZDuzcxPtQhx0suIVI7FPGtRlsJBi6LAuOPpRKFpDM1CcYzrG5Lw21mNu5tuBrj1M9zUoU/kkxbt9N46D83O21tpD3hn5+R85SMvvQiYIA==:00E3\n" +
|
|
||||||
"^PQ1,0,1,Y^XZ";
|
|
||||||
|
|
||||||
if (!PrintToZebra(MadeInGB))
|
if (!PrintToZebra(MadeInGB))
|
||||||
MainForm.Instance.AddToActionsList("Error printing GB label");
|
MainForm.Instance.AddToActionsList("Error printing GB label");
|
||||||
|
|||||||
2
LDS.cs
2
LDS.cs
@@ -35,7 +35,9 @@ namespace AiQ_GUI
|
|||||||
}
|
}
|
||||||
catch // If file can't deserialise
|
catch // If file can't deserialise
|
||||||
{
|
{
|
||||||
|
MainForm.Instance.AddToActionsList("Error loading Local Data Store");
|
||||||
return null; // Return null to indicate failure
|
return null; // Return null to indicate failure
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ namespace AiQ_GUI
|
|||||||
{
|
{
|
||||||
class Access
|
class Access
|
||||||
{
|
{
|
||||||
const string connString = @"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;";
|
public const string connString = @"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;";
|
||||||
|
|
||||||
// Reads camera model numbers and descriptions from the database, sorts them alphabetically by model number (except "AB12CD", which appears last), and formats each entry as "ModelNumber - Description".
|
// Reads camera model numbers and descriptions from the database, sorts them alphabetically by model number (except "AB12CD", which appears last), and formats each entry as "ModelNumber - Description".
|
||||||
public static string[] ReadCamTypes()
|
public static string[] ReadCamTypes()
|
||||||
@@ -101,10 +101,73 @@ namespace AiQ_GUI
|
|||||||
CameraAccessInfo.SpreadsheetID = Convert.ToString(reader["SSID"]);
|
CameraAccessInfo.SpreadsheetID = Convert.ToString(reader["SSID"]);
|
||||||
conn.Close();
|
conn.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void Stats(string TypeOfTest, string modelNumber)
|
||||||
|
{
|
||||||
|
Stats([TypeOfTest], modelNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void Stats(string[] TypeOfTest, string modelNumber)
|
||||||
|
{
|
||||||
|
using OleDbConnection conn = new(connString); // Opens connection to Access database
|
||||||
|
try
|
||||||
|
{
|
||||||
|
conn.Open(); // Opens DB
|
||||||
|
|
||||||
|
foreach (string type in TypeOfTest)
|
||||||
|
{
|
||||||
|
string query = $"UPDATE AiQ SET [{type}] = [{type}] + 1 WHERE [ModelNumber] = ?"; // Add one for every test ran of this type for this model number
|
||||||
|
using OleDbCommand cmd = new(query, conn); // Create command
|
||||||
|
cmd.Parameters.AddWithValue("?", modelNumber); // Add model number to prevent injection
|
||||||
|
|
||||||
|
int rowsAffected = cmd.ExecuteNonQuery();
|
||||||
|
// Execute the command and get the number of rows affected
|
||||||
|
//if (rowsAffected > 0) // If one or more rows were updated
|
||||||
|
// AddToActionsList($"Updated {TypeOfTest} for {modelNumber}");
|
||||||
|
//else
|
||||||
|
// AddToActionsList($"No rows found for {modelNumber}");
|
||||||
|
}
|
||||||
|
conn.Close();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
MainForm.Instance.AddToActionsList("Could not access Access in Google Drive. Is it running?");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void StatsDiags(string redDiagLabels, string RhTxBxActionsText, string ModelNumber)
|
||||||
|
{
|
||||||
|
using OleDbConnection conn = new(connString);
|
||||||
|
conn.Open();
|
||||||
|
|
||||||
|
// Null checks
|
||||||
|
string redVal = string.IsNullOrWhiteSpace(redDiagLabels) ? "-" : redDiagLabels;
|
||||||
|
string actVal = string.IsNullOrWhiteSpace(RhTxBxActionsText) ? "-" : RhTxBxActionsText;
|
||||||
|
string model = string.IsNullOrWhiteSpace(ModelNumber) ? "-" : ModelNumber;
|
||||||
|
|
||||||
|
const string sql = @"INSERT INTO DiagsStats ([Date], [Model], [Red Diags Labels], [RhTxBxActions Contents]) VALUES (?, ?, ?, ?)";
|
||||||
|
|
||||||
|
using OleDbCommand cmd = new(sql, conn);
|
||||||
|
|
||||||
|
cmd.Parameters.Add(new OleDbParameter
|
||||||
|
{
|
||||||
|
OleDbType = OleDbType.Date,
|
||||||
|
Value = DateTime.Now
|
||||||
|
});
|
||||||
|
cmd.Parameters.AddWithValue("?", model);
|
||||||
|
cmd.Parameters.AddWithValue("?", redVal);
|
||||||
|
cmd.Parameters.AddWithValue("?", actVal);
|
||||||
|
|
||||||
|
int rows = cmd.ExecuteNonQuery();
|
||||||
|
conn.Close();
|
||||||
|
|
||||||
|
//if (rows > 0)
|
||||||
|
// AddToActionsList($"DiagsStats inserted ({rows} row) for model '{model}' on {DateTime.Now:yyyy-MM-dd}");
|
||||||
|
//else
|
||||||
|
// AddToActionsList("No rows inserted into DiagsStats (unexpected).");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Expected universal data for the GUI, read from the database
|
// Expected universal data for the GUI, read from the database
|
||||||
public class UniversalData
|
public class UniversalData
|
||||||
|
|||||||
@@ -1,17 +1,12 @@
|
|||||||
using System;
|
using ClosedXML.Excel;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Data.OleDb;
|
using System.Data.OleDb;
|
||||||
using ClosedXML.Excel;
|
|
||||||
|
|
||||||
namespace AiQ_GUI.Microsoft
|
namespace AiQ_GUI
|
||||||
{
|
{
|
||||||
internal class StatsExcel
|
internal class StatsExcel
|
||||||
{
|
{
|
||||||
private const string connString =
|
private const string exportPath = @"G:\Shared drives\MAV Production GUI's\AiQ\GUI's\AiQ_Test_Stats.xlsx";
|
||||||
@"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";
|
|
||||||
|
|
||||||
public void ExportDatabaseToExcel()
|
public void ExportDatabaseToExcel()
|
||||||
{
|
{
|
||||||
@@ -19,13 +14,28 @@ namespace AiQ_GUI.Microsoft
|
|||||||
{
|
{
|
||||||
MainForm.Instance.AddToActionsList("=== ExportDatabaseToExcel START ===");
|
MainForm.Instance.AddToActionsList("=== ExportDatabaseToExcel START ===");
|
||||||
|
|
||||||
using (OleDbConnection conn = new(connString))
|
using OleDbConnection conn = new(Access.connString);
|
||||||
{
|
|
||||||
conn.Open();
|
conn.Open();
|
||||||
MainForm.Instance.AddToActionsList("Connected to Access database.");
|
MainForm.Instance.AddToActionsList("Connected to Access database.");
|
||||||
|
|
||||||
DateTime now = DateTime.Now;
|
DateTime now = DateTime.Now;
|
||||||
|
|
||||||
|
// Read LastStatsRun from UniversalData (if any)
|
||||||
|
DateTime? lastStatsRun = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (OleDbCommand cmdPeriod = new OleDbCommand("SELECT LastStatsRun FROM UniversalData", conn))
|
||||||
|
{
|
||||||
|
object res = cmdPeriod.ExecuteScalar();
|
||||||
|
if (res != null && res != DBNull.Value)
|
||||||
|
lastStatsRun = (DateTime)res;
|
||||||
|
}
|
||||||
|
MainForm.Instance.AddToActionsList($"Fetched LastStatsRun: {(lastStatsRun.HasValue ? lastStatsRun.Value.ToString("yyyy-MM-dd HH:mm:ss") : "none")}");
|
||||||
|
}
|
||||||
|
catch (Exception periodEx)
|
||||||
|
{
|
||||||
|
MainForm.Instance.AddToActionsList($"Warning: could not read LastStatsRun. Details: {periodEx.Message}");
|
||||||
|
}
|
||||||
|
|
||||||
// ==================== MAIN STATS EXPORT ====================
|
// ==================== MAIN STATS EXPORT ====================
|
||||||
string selectColumns = @"
|
string selectColumns = @"
|
||||||
ModelNumber,
|
ModelNumber,
|
||||||
@@ -72,7 +82,7 @@ namespace AiQ_GUI.Microsoft
|
|||||||
MainForm.Instance.AddToActionsList($"Adding sheet: {sheetName}");
|
MainForm.Instance.AddToActionsList($"Adding sheet: {sheetName}");
|
||||||
|
|
||||||
XLWorkbook workbook;
|
XLWorkbook workbook;
|
||||||
if (System.IO.File.Exists(exportPath))
|
if (File.Exists(exportPath))
|
||||||
{
|
{
|
||||||
workbook = new XLWorkbook(exportPath);
|
workbook = new XLWorkbook(exportPath);
|
||||||
MainForm.Instance.AddToActionsList("Opened existing workbook.");
|
MainForm.Instance.AddToActionsList("Opened existing workbook.");
|
||||||
@@ -89,17 +99,30 @@ namespace AiQ_GUI.Microsoft
|
|||||||
MainForm.Instance.AddToActionsList($"Deleted old sheet: {sheetName}");
|
MainForm.Instance.AddToActionsList($"Deleted old sheet: {sheetName}");
|
||||||
}
|
}
|
||||||
|
|
||||||
var ws = workbook.Worksheets.Add(sheetName);
|
IXLWorksheet ws = workbook.Worksheets.Add(sheetName);
|
||||||
ws.Cell(1, 1).InsertTable(dataTable, "AiQ_Stats", true);
|
ws.Cell(1, 1).InsertTable(dataTable, "AiQ_Stats", true);
|
||||||
ws.Columns().AdjustToContents();
|
ws.Columns().AdjustToContents();
|
||||||
|
|
||||||
ws.Cell(1, dataTable.Columns.Count + 2).Value = "Exported:";
|
// Write Data Period label and computed period string to the right of the table
|
||||||
ws.Cell(2, dataTable.Columns.Count + 2).Value = now.ToString("yyyy-MM-dd HH:mm:ss");
|
int infoCol = dataTable.Columns.Count + 2;
|
||||||
|
ws.Cell(1, infoCol).Value = "Data Period";
|
||||||
|
|
||||||
|
string periodText;
|
||||||
|
if (lastStatsRun.HasValue)
|
||||||
|
{
|
||||||
|
periodText = $"{lastStatsRun.Value:yyyy-MM-dd HH:mm:ss} - {now:yyyy-MM-dd HH:mm:ss}";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
periodText = $"Up to {now:yyyy-MM-dd HH:mm:ss}";
|
||||||
|
}
|
||||||
|
|
||||||
|
ws.Cell(2, infoCol).Value = periodText;
|
||||||
|
|
||||||
// ==================== DIAGS STATS EXPORT (CURRENT MONTH ONLY) ====================
|
// ==================== DIAGS STATS EXPORT (CURRENT MONTH ONLY) ====================
|
||||||
MainForm.Instance.AddToActionsList("Exporting DiagsStats for current month...");
|
MainForm.Instance.AddToActionsList("Exporting DiagsStats for current month...");
|
||||||
|
|
||||||
DateTime monthStart = new DateTime(now.Year, now.Month, 1);
|
DateTime monthStart = new(now.Year, now.Month, 1);
|
||||||
DateTime nextMonth = monthStart.AddMonths(1);
|
DateTime nextMonth = monthStart.AddMonths(1);
|
||||||
|
|
||||||
string diagsQuery = @"
|
string diagsQuery = @"
|
||||||
@@ -107,20 +130,25 @@ namespace AiQ_GUI.Microsoft
|
|||||||
[Date],
|
[Date],
|
||||||
[Model],
|
[Model],
|
||||||
[Red Diags Labels],
|
[Red Diags Labels],
|
||||||
[RhTxBxActions Contents]
|
[RhTxBxActions Contents],
|
||||||
|
[IsRma],
|
||||||
|
[RMA]
|
||||||
FROM DiagsStats
|
FROM DiagsStats
|
||||||
WHERE [Date] >= ? AND [Date] < ?";
|
WHERE [Date] >= ? AND [Date] < ?";
|
||||||
|
|
||||||
OleDbDataAdapter diagsAdapter = new(diagsQuery, conn);
|
using (OleDbCommand diagsCmd = new OleDbCommand(diagsQuery, conn))
|
||||||
diagsAdapter.SelectCommand.Parameters.Add(new OleDbParameter { OleDbType = OleDbType.Date, Value = monthStart });
|
{
|
||||||
diagsAdapter.SelectCommand.Parameters.Add(new OleDbParameter { OleDbType = OleDbType.Date, Value = nextMonth });
|
diagsCmd.Parameters.Add(new OleDbParameter { OleDbType = OleDbType.Date, Value = monthStart });
|
||||||
|
diagsCmd.Parameters.Add(new OleDbParameter { OleDbType = OleDbType.Date, Value = nextMonth });
|
||||||
|
|
||||||
|
using (OleDbDataAdapter diagsAdapter = new OleDbDataAdapter(diagsCmd))
|
||||||
|
{
|
||||||
DataTable diagsTable = new();
|
DataTable diagsTable = new();
|
||||||
diagsAdapter.Fill(diagsTable);
|
diagsAdapter.Fill(diagsTable);
|
||||||
|
|
||||||
if (diagsTable.Rows.Count > 0)
|
if (diagsTable.Rows.Count > 0)
|
||||||
{
|
{
|
||||||
int startRow = ws.LastRowUsed().RowNumber() + 3;
|
int startRow = (ws.LastRowUsed()?.RowNumber() ?? 0) + 3;
|
||||||
|
|
||||||
ws.Cell(startRow, 1).Value = "Diags Stats (Current Month)";
|
ws.Cell(startRow, 1).Value = "Diags Stats (Current Month)";
|
||||||
ws.Cell(startRow, 1).Style.Font.Bold = true;
|
ws.Cell(startRow, 1).Style.Font.Bold = true;
|
||||||
@@ -131,9 +159,7 @@ namespace AiQ_GUI.Microsoft
|
|||||||
|
|
||||||
MainForm.Instance.AddToActionsList($"Added DiagsStats ({diagsTable.Rows.Count} rows) starting at row {startRow}.");
|
MainForm.Instance.AddToActionsList($"Added DiagsStats ({diagsTable.Rows.Count} rows) starting at row {startRow}.");
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{
|
|
||||||
MainForm.Instance.AddToActionsList("No DiagsStats data found for current month.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==================== SAVE MAIN SHEET ====================
|
// ==================== SAVE MAIN SHEET ====================
|
||||||
@@ -156,7 +182,7 @@ namespace AiQ_GUI.Microsoft
|
|||||||
FROM AiQ";
|
FROM AiQ";
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (var cmdBackup = new OleDbCommand(backupSql, conn))
|
using (OleDbCommand cmdBackup = new(backupSql, conn))
|
||||||
{
|
{
|
||||||
cmdBackup.ExecuteNonQuery();
|
cmdBackup.ExecuteNonQuery();
|
||||||
}
|
}
|
||||||
@@ -169,7 +195,7 @@ namespace AiQ_GUI.Microsoft
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
using (var tx = conn.BeginTransaction())
|
using (OleDbTransaction tx = conn.BeginTransaction())
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -197,14 +223,14 @@ namespace AiQ_GUI.Microsoft
|
|||||||
[Visual Test Fail - Not All Rear Screws Fitted] = 0,
|
[Visual Test Fail - Not All Rear Screws Fitted] = 0,
|
||||||
[Visual Test Fail - Unit rattles] = 0;";
|
[Visual Test Fail - Unit rattles] = 0;";
|
||||||
|
|
||||||
using (var cmdReset = new OleDbCommand(resetSql, conn, tx))
|
using (OleDbCommand cmdReset = new(resetSql, conn, tx))
|
||||||
{
|
{
|
||||||
int affected = cmdReset.ExecuteNonQuery();
|
int affected = cmdReset.ExecuteNonQuery();
|
||||||
MainForm.Instance.AddToActionsList($"Zeroed counters on AiQ rows: {affected} row(s).");
|
MainForm.Instance.AddToActionsList($"Zeroed counters on AiQ rows: {affected} row(s).");
|
||||||
}
|
}
|
||||||
|
|
||||||
int updatedRows;
|
int updatedRows;
|
||||||
using (var cmdUpd = new OleDbCommand("UPDATE UniversalData SET LastStatsRun = ?", conn, tx))
|
using (OleDbCommand cmdUpd = new("UPDATE UniversalData SET LastStatsRun = ?", conn, tx))
|
||||||
{
|
{
|
||||||
cmdUpd.Parameters.Add(new OleDbParameter { OleDbType = OleDbType.Date, Value = now });
|
cmdUpd.Parameters.Add(new OleDbParameter { OleDbType = OleDbType.Date, Value = now });
|
||||||
updatedRows = cmdUpd.ExecuteNonQuery();
|
updatedRows = cmdUpd.ExecuteNonQuery();
|
||||||
@@ -212,13 +238,11 @@ namespace AiQ_GUI.Microsoft
|
|||||||
|
|
||||||
if (updatedRows == 0)
|
if (updatedRows == 0)
|
||||||
{
|
{
|
||||||
using (var cmdIns = new OleDbCommand("INSERT INTO UniversalData (LastStatsRun) VALUES (?)", conn, tx))
|
using OleDbCommand cmdIns = new("INSERT INTO UniversalData (LastStatsRun) VALUES (?)", conn, tx);
|
||||||
{
|
|
||||||
cmdIns.Parameters.Add(new OleDbParameter { OleDbType = OleDbType.Date, Value = now });
|
cmdIns.Parameters.Add(new OleDbParameter { OleDbType = OleDbType.Date, Value = now });
|
||||||
cmdIns.ExecuteNonQuery();
|
cmdIns.ExecuteNonQuery();
|
||||||
MainForm.Instance.AddToActionsList("Inserted LastStatsRun row.");
|
MainForm.Instance.AddToActionsList("Inserted LastStatsRun row.");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MainForm.Instance.AddToActionsList("Updated LastStatsRun successfully.");
|
MainForm.Instance.AddToActionsList("Updated LastStatsRun successfully.");
|
||||||
@@ -232,7 +256,8 @@ namespace AiQ_GUI.Microsoft
|
|||||||
tx.Rollback();
|
tx.Rollback();
|
||||||
MainForm.Instance.AddToActionsList($"ERROR during reset, rolled back. Details: {resetEx.Message}");
|
MainForm.Instance.AddToActionsList($"ERROR during reset, rolled back. Details: {resetEx.Message}");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
conn.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
MainForm.Instance.AddToActionsList("=== ExportDatabaseToExcel END ===");
|
MainForm.Instance.AddToActionsList("=== ExportDatabaseToExcel END ===");
|
||||||
|
|||||||
@@ -7,9 +7,9 @@ namespace AiQ_GUI
|
|||||||
{
|
{
|
||||||
const string webhookUrl = "https://default71bd136a1c65418fb59e927135629c.ac.environment.api.powerplatform.com:443/powerautomate/automations/direct/workflows/b27c5192e83f4f48b20c1b115985b0b3/triggers/manual/paths/invoke/?api-version=1&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=1-eCbYXms6xInRKHwz3tgAcdQ9x7CSjl3Yzw2V_1MlA";
|
const string webhookUrl = "https://default71bd136a1c65418fb59e927135629c.ac.environment.api.powerplatform.com:443/powerautomate/automations/direct/workflows/b27c5192e83f4f48b20c1b115985b0b3/triggers/manual/paths/invoke/?api-version=1&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=1-eCbYXms6xInRKHwz3tgAcdQ9x7CSjl3Yzw2V_1MlA";
|
||||||
|
|
||||||
public static async Task SendMssg(string ApprovalRow, string User)
|
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);
|
||||||
}
|
}
|
||||||
|
|||||||
22
Network.cs
22
Network.cs
@@ -10,7 +10,7 @@ namespace AiQ_GUI
|
|||||||
public static HttpClient? SingleHTTPClient;
|
public static HttpClient? SingleHTTPClient;
|
||||||
public static HttpClient Client => SingleHTTPClient ?? throw new InvalidOperationException("Client not initialized.");
|
public static HttpClient Client => SingleHTTPClient ?? throw new InvalidOperationException("Client not initialized.");
|
||||||
|
|
||||||
public static void Initialize(string username, string password)
|
public async static void Initialize(string username, string password)
|
||||||
{
|
{
|
||||||
HttpClientHandler handler = new()
|
HttpClientHandler handler = new()
|
||||||
{
|
{
|
||||||
@@ -23,6 +23,21 @@ namespace AiQ_GUI
|
|||||||
{
|
{
|
||||||
Timeout = TimeSpan.FromSeconds(20)
|
Timeout = TimeSpan.FromSeconds(20)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool UP = false;
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
while (!UP)
|
||||||
|
{
|
||||||
|
UP = await PingIP("10.10.10.137");
|
||||||
|
await Task.Delay(500);
|
||||||
|
if (i >= 5)
|
||||||
|
{
|
||||||
|
//MainForm.Instance.AddToActionsList($"Could not initialise new network with USER: {username} & PSWD: {password}");
|
||||||
|
return; // Try 5 times max
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handles get and post to the camera API
|
// Handles get and post to the camera API
|
||||||
@@ -74,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];
|
||||||
@@ -88,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