Compare commits
2 Commits
cfe8a57a9d
...
ExcelStats
| Author | SHA1 | Date | |
|---|---|---|---|
| b59d023887 | |||
| a2f86625be |
40
AiQ_GUI.Designer.cs
generated
40
AiQ_GUI.Designer.cs
generated
@@ -148,6 +148,7 @@ namespace AiQ_GUI
|
||||
BtnFirewall = new Button();
|
||||
TabImages = new TabPage();
|
||||
TabSoak = new TabPage();
|
||||
BtnFactoryDefault = new Button();
|
||||
SetGodModeAll = new Button();
|
||||
BtnUploadBlob = new Button();
|
||||
CkBxTickAll = new CheckBox();
|
||||
@@ -157,7 +158,6 @@ namespace AiQ_GUI
|
||||
LblGUIVers = new Label();
|
||||
timerTypeIP = new System.Windows.Forms.Timer(components);
|
||||
TimerFlash = new System.Windows.Forms.Timer(components);
|
||||
BtnFactoryDefault = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)PicBxMAV).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)PicBxAiQ).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)PicBxIRF2).BeginInit();
|
||||
@@ -270,7 +270,7 @@ namespace AiQ_GUI
|
||||
CbBxUserName.Font = new Font("Segoe UI Semibold", 10F, FontStyle.Bold);
|
||||
CbBxUserName.ForeColor = SystemColors.Control;
|
||||
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.Margin = new Padding(4, 3, 4, 3);
|
||||
CbBxUserName.Name = "CbBxUserName";
|
||||
@@ -1910,6 +1910,24 @@ namespace AiQ_GUI
|
||||
TabSoak.TabIndex = 2;
|
||||
TabSoak.Text = "Soak";
|
||||
//
|
||||
// BtnFactoryDefault
|
||||
//
|
||||
BtnFactoryDefault.BackColor = Color.FromArgb(70, 65, 80);
|
||||
BtnFactoryDefault.Enabled = false;
|
||||
BtnFactoryDefault.FlatAppearance.BorderColor = Color.FromArgb(70, 65, 80);
|
||||
BtnFactoryDefault.FlatAppearance.BorderSize = 0;
|
||||
BtnFactoryDefault.FlatStyle = FlatStyle.Flat;
|
||||
BtnFactoryDefault.Font = new Font("Segoe UI Semibold", 10F, FontStyle.Bold);
|
||||
BtnFactoryDefault.ForeColor = SystemColors.Control;
|
||||
BtnFactoryDefault.Location = new Point(222, 209);
|
||||
BtnFactoryDefault.Margin = new Padding(4, 3, 4, 3);
|
||||
BtnFactoryDefault.Name = "BtnFactoryDefault";
|
||||
BtnFactoryDefault.Size = new Size(181, 49);
|
||||
BtnFactoryDefault.TabIndex = 242;
|
||||
BtnFactoryDefault.Text = "Set Modules to Factory Defaults";
|
||||
BtnFactoryDefault.UseVisualStyleBackColor = false;
|
||||
BtnFactoryDefault.Click += BtnFactoryDefault_Click;
|
||||
//
|
||||
// SetGodModeAll
|
||||
//
|
||||
SetGodModeAll.BackColor = Color.FromArgb(70, 65, 80);
|
||||
@@ -2000,24 +2018,6 @@ namespace AiQ_GUI
|
||||
timerTypeIP.Interval = 2000;
|
||||
timerTypeIP.Tick += timerTypeIP_Tick;
|
||||
//
|
||||
// BtnFactoryDefault
|
||||
//
|
||||
BtnFactoryDefault.BackColor = Color.FromArgb(70, 65, 80);
|
||||
BtnFactoryDefault.Enabled = false;
|
||||
BtnFactoryDefault.FlatAppearance.BorderColor = Color.FromArgb(70, 65, 80);
|
||||
BtnFactoryDefault.FlatAppearance.BorderSize = 0;
|
||||
BtnFactoryDefault.FlatStyle = FlatStyle.Flat;
|
||||
BtnFactoryDefault.Font = new Font("Segoe UI Semibold", 10F, FontStyle.Bold);
|
||||
BtnFactoryDefault.ForeColor = SystemColors.Control;
|
||||
BtnFactoryDefault.Location = new Point(222, 209);
|
||||
BtnFactoryDefault.Margin = new Padding(4, 3, 4, 3);
|
||||
BtnFactoryDefault.Name = "BtnFactoryDefault";
|
||||
BtnFactoryDefault.Size = new Size(181, 49);
|
||||
BtnFactoryDefault.TabIndex = 242;
|
||||
BtnFactoryDefault.Text = "Set Modules to Factory Defaults";
|
||||
BtnFactoryDefault.UseVisualStyleBackColor = false;
|
||||
BtnFactoryDefault.Click += BtnFactoryDefault_Click;
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
|
||||
103
AiQ_GUI.cs
103
AiQ_GUI.cs
@@ -108,7 +108,7 @@ namespace AiQ_GUI
|
||||
CbBxIris.SelectedIndex = lds.Iris;
|
||||
CbBxGain.SelectedIndex = lds.Gain;
|
||||
|
||||
if (lds.User == "Bradley")
|
||||
if (lds.User == "Bradley" || lds.User == "Sophie")
|
||||
BtnTest.Visible = true;
|
||||
|
||||
TxBxCheckValid(TxBxPsuIP); // Set save button color if valid
|
||||
@@ -209,6 +209,7 @@ namespace AiQ_GUI
|
||||
if (!LEDreply.Contains("Power levels set successfully"))
|
||||
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
|
||||
|
||||
@@ -269,7 +270,7 @@ namespace AiQ_GUI
|
||||
}
|
||||
}
|
||||
|
||||
public void StatsDiags(string redDiagLabels, string RhTxBxActionsText)
|
||||
public void StatsDiags(string redDiagLabels, string RhTxBxActionsText, string IsRMA, int RMA)
|
||||
{
|
||||
using OleDbConnection conn = new(connString);
|
||||
conn.Open();
|
||||
@@ -280,26 +281,20 @@ namespace AiQ_GUI
|
||||
string model = string.IsNullOrWhiteSpace(CamOnTest?.Model) ? "-" : CamOnTest.Model;
|
||||
|
||||
string sql = @"
|
||||
INSERT INTO DiagsStats ([Date], [Model], [Red Diags Labels], [RhTxBxActions Contents])
|
||||
VALUES (?, ?, ?, ?)";
|
||||
INSERT INTO DiagsStats ([Date], [Model], [Red Diags Labels], [RhTxBxActions Contents],[IsRMA],[RMA])
|
||||
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);
|
||||
// OleDb uses positional parameters — order must match the VALUES list above
|
||||
cmd.Parameters.Add(new OleDbParameter { OleDbType = OleDbType.Date, Value = DateTime.Now });
|
||||
cmd.Parameters.Add(new OleDbParameter { OleDbType = OleDbType.VarWChar, Value = model });
|
||||
cmd.Parameters.Add(new OleDbParameter { OleDbType = OleDbType.VarWChar, Value = redVal });
|
||||
cmd.Parameters.Add(new OleDbParameter { OleDbType = OleDbType.VarWChar, Value = actVal });
|
||||
cmd.Parameters.Add(new OleDbParameter { OleDbType = OleDbType.Boolean, Value = IsRMA });
|
||||
cmd.Parameters.Add(new OleDbParameter { OleDbType = OleDbType.VarWChar, Value = RMA });
|
||||
|
||||
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).");
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
|
||||
@@ -428,15 +423,6 @@ namespace AiQ_GUI
|
||||
// Indicators to the user the test has failed
|
||||
Btn.BackColor = Color.Maroon;
|
||||
Btn.Text = "Test Failed";
|
||||
if (!(CamOnTest.RMANum != 0)) // Yap to check if it is not a RMA
|
||||
{
|
||||
Stats( ["Final Tests Failed", ErrMssg]);
|
||||
}
|
||||
else
|
||||
{
|
||||
Stats("RMA Final Tests Failed");
|
||||
}
|
||||
AddToActionsList(ErrMssg);
|
||||
|
||||
string RedLbls = string.Join(Environment.NewLine, PnlLbls.Controls
|
||||
.OfType<Label>()
|
||||
@@ -444,7 +430,18 @@ namespace AiQ_GUI
|
||||
.Select(lbl => lbl.Text)); // Extract text
|
||||
string FullFailureValues = RhTxBxActions.Text + Environment.NewLine + RedLbls;
|
||||
|
||||
StatsDiags(RedLbls, RhTxBxActions.Text); // Log to Access database
|
||||
|
||||
// Database logging \\
|
||||
if (!(CamOnTest.RMANum != 0)) // Yap to check if it is not a RMA
|
||||
{
|
||||
Stats(["Final Tests Failed", ErrMssg]);
|
||||
StatsDiags(RedLbls, RhTxBxActions.Text, "FALSE", CamOnTest.RMANum);
|
||||
}
|
||||
else
|
||||
{
|
||||
Stats("RMA Final Tests Failed");
|
||||
StatsDiags(RedLbls, RhTxBxActions.Text, "TRUE", CamOnTest.RMANum);
|
||||
}
|
||||
|
||||
|
||||
if (await DisplayQuestion("Test failed, appeal?" + Environment.NewLine + "See Actions textbox for details."))
|
||||
@@ -538,22 +535,24 @@ namespace AiQ_GUI
|
||||
BtnNo.Visible = false;
|
||||
Logging.LogMessage("Pre Test Failed");
|
||||
|
||||
if (CamOnTest.RMANum == 0) // Yap to check if it is not a RMA
|
||||
{
|
||||
Stats(["Pre Tests Failed", ErrMssg]);
|
||||
}
|
||||
else
|
||||
{
|
||||
Stats("RMA Pre Tests Failed");
|
||||
}
|
||||
|
||||
string RedLbls = string.Join(Environment.NewLine, PnlLbls.Controls
|
||||
.OfType<Label>()
|
||||
.Where(lbl => lbl.ForeColor == Color.Red) // Only include red labels
|
||||
.Select(lbl => lbl.Text)); // Extract text
|
||||
string FullFailureValues = RhTxBxActions.Text + Environment.NewLine + RedLbls;
|
||||
|
||||
StatsDiags(RedLbls, RhTxBxActions.Text); // Log to Access database
|
||||
if (CamOnTest.RMANum == 0) // Yap to check if it is not a RMA
|
||||
{
|
||||
Stats(["Pre Tests Failed", ErrMssg]);
|
||||
StatsDiags(RedLbls, RhTxBxActions.Text, "FALSE", CamOnTest.RMANum);
|
||||
}
|
||||
else
|
||||
{
|
||||
Stats("RMA Pre Tests Failed");
|
||||
StatsDiags(RedLbls, RhTxBxActions.Text, "TRUE", CamOnTest.RMANum);
|
||||
}
|
||||
|
||||
// Log to Access database
|
||||
|
||||
if (await DisplayQuestion("Test failed, restart?" + Environment.NewLine + "See Actions textbox for details."))
|
||||
Helper.RestartApp();
|
||||
@@ -1856,15 +1855,15 @@ namespace AiQ_GUI
|
||||
//double Spd = EstimateSpeed(frames);
|
||||
//AddToActionsList("Estimated Speed: " + Spd.ToString("F2") + " MPH");
|
||||
|
||||
await FlexiAPI.SetVaxtorMinMaxPlate(CamOnTest.IP);
|
||||
//StatsExcel excelExporter = new();
|
||||
//excelExporter.ExportDatabaseToExcel();
|
||||
|
||||
StatsExcel excelExporter = new();
|
||||
excelExporter.ExportDatabaseToExcel();
|
||||
//FakeCamera fakeCamera = new FakeCamera(80); // Create an instance of FakeCamera
|
||||
|
||||
// FakeCamera fakeCamera = new FakeCamera(80); // Create an instance of FakeCamera
|
||||
|
||||
// //CamOnTest.IP = CbBxFoundCams.Text;
|
||||
// _ = fakeCamera.StartAsync(CAMTYPE.BAD).ContinueWith(task =>
|
||||
// {
|
||||
////CamOnTest.IP = CbBxFoundCams.Text;
|
||||
//_ = fakeCamera.StartAsync(CAMTYPE.GOOD).ContinueWith(task =>
|
||||
//{
|
||||
// //Network.Initialize("developer", "Pass123");
|
||||
|
||||
// if (task.IsFaulted)
|
||||
@@ -1875,16 +1874,16 @@ namespace AiQ_GUI
|
||||
// {
|
||||
// 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
|
||||
//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
|
||||
//await Task.Delay(3000); // Wait for server to start
|
||||
|
||||
//BtnPreTest_Click(sender, e);
|
||||
//BtnStartTest_Click(sender, e);
|
||||
|
||||
|
||||
stopWatchTest.Stop();
|
||||
|
||||
@@ -159,6 +159,37 @@ namespace AiQ_GUI
|
||||
return null; // If it fails to parse the JSON
|
||||
}
|
||||
}
|
||||
public static async Task<bool> SetVaxtorMinMaxPlate(string IP)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Build JSON array for Vaxtor min/max plate configuration
|
||||
string[,] Vaxtor_JSON = { { "propMinCharHeight", "18" }, { "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)
|
||||
{
|
||||
@@ -404,5 +435,13 @@ namespace AiQ_GUI
|
||||
public class Property
|
||||
{
|
||||
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; }
|
||||
}
|
||||
}
|
||||
|
||||
2
LDS.cs
2
LDS.cs
@@ -35,7 +35,9 @@ namespace AiQ_GUI
|
||||
}
|
||||
catch // If file can't deserialise
|
||||
{
|
||||
MainForm.Instance.AddToActionsList("Error loading Local Data Store");
|
||||
return null; // Return null to indicate failure
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace AiQ_GUI.Microsoft
|
||||
@"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";
|
||||
@"G:\Shared drives\MAV Production GUI's\AiQ\GUI's\AiQ_Test_Stats.xlsx";
|
||||
|
||||
public void ExportDatabaseToExcel()
|
||||
{
|
||||
@@ -26,6 +26,23 @@ namespace AiQ_GUI.Microsoft
|
||||
|
||||
DateTime now = DateTime.Now;
|
||||
|
||||
// Read LastStatsRun from UniversalData (if any)
|
||||
DateTime? lastStatsRun = null;
|
||||
try
|
||||
{
|
||||
using (var 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 ====================
|
||||
string selectColumns = @"
|
||||
ModelNumber,
|
||||
@@ -93,8 +110,21 @@ namespace AiQ_GUI.Microsoft
|
||||
ws.Cell(1, 1).InsertTable(dataTable, "AiQ_Stats", true);
|
||||
ws.Columns().AdjustToContents();
|
||||
|
||||
ws.Cell(1, dataTable.Columns.Count + 2).Value = "Exported:";
|
||||
ws.Cell(2, dataTable.Columns.Count + 2).Value = now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
// Write Data Period label and computed period string to the right of the table
|
||||
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) ====================
|
||||
MainForm.Instance.AddToActionsList("Exporting DiagsStats for current month...");
|
||||
@@ -107,20 +137,25 @@ namespace AiQ_GUI.Microsoft
|
||||
[Date],
|
||||
[Model],
|
||||
[Red Diags Labels],
|
||||
[RhTxBxActions Contents]
|
||||
[RhTxBxActions Contents],
|
||||
[IsRma],
|
||||
[RMA]
|
||||
FROM DiagsStats
|
||||
WHERE [Date] >= ? AND [Date] < ?";
|
||||
|
||||
OleDbDataAdapter diagsAdapter = new(diagsQuery, conn);
|
||||
diagsAdapter.SelectCommand.Parameters.Add(new OleDbParameter { OleDbType = OleDbType.Date, Value = monthStart });
|
||||
diagsAdapter.SelectCommand.Parameters.Add(new OleDbParameter { OleDbType = OleDbType.Date, Value = nextMonth });
|
||||
using (var diagsCmd = new OleDbCommand(diagsQuery, conn))
|
||||
{
|
||||
diagsCmd.Parameters.Add(new OleDbParameter { OleDbType = OleDbType.Date, Value = monthStart });
|
||||
diagsCmd.Parameters.Add(new OleDbParameter { OleDbType = OleDbType.Date, Value = nextMonth });
|
||||
|
||||
using (var diagsAdapter = new OleDbDataAdapter(diagsCmd))
|
||||
{
|
||||
DataTable diagsTable = new();
|
||||
diagsAdapter.Fill(diagsTable);
|
||||
|
||||
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).Style.Font.Bold = true;
|
||||
@@ -131,9 +166,7 @@ namespace AiQ_GUI.Microsoft
|
||||
|
||||
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 ====================
|
||||
|
||||
Reference in New Issue
Block a user