Compare commits

...

2 Commits

Author SHA1 Message Date
01268ddda5 Changes to SSH including new password 2025-10-21 14:01:27 +01:00
e39a36183a V3.15 iterim BR changes 2025-10-17 14:26:33 +01:00
15 changed files with 133 additions and 301 deletions

39
AiQ_GUI.Designer.cs generated
View File

@@ -148,6 +148,7 @@ namespace AiQ_GUI
BtnFirewall = new Button(); BtnFirewall = new Button();
TabImages = new TabPage(); TabImages = new TabPage();
TabSoak = new TabPage(); TabSoak = new TabPage();
BtnFactoryDefault = new Button();
SetGodModeAll = new Button(); SetGodModeAll = new Button();
BtnUploadBlob = new Button(); BtnUploadBlob = new Button();
CkBxTickAll = new CheckBox(); CkBxTickAll = new CheckBox();
@@ -157,7 +158,6 @@ namespace AiQ_GUI
LblGUIVers = new Label(); LblGUIVers = new Label();
timerTypeIP = new System.Windows.Forms.Timer(components); timerTypeIP = new System.Windows.Forms.Timer(components);
TimerFlash = new System.Windows.Forms.Timer(components); TimerFlash = new System.Windows.Forms.Timer(components);
BtnFactoryDefault = new Button();
((System.ComponentModel.ISupportInitialize)PicBxMAV).BeginInit(); ((System.ComponentModel.ISupportInitialize)PicBxMAV).BeginInit();
((System.ComponentModel.ISupportInitialize)PicBxAiQ).BeginInit(); ((System.ComponentModel.ISupportInitialize)PicBxAiQ).BeginInit();
((System.ComponentModel.ISupportInitialize)PicBxIRF2).BeginInit(); ((System.ComponentModel.ISupportInitialize)PicBxIRF2).BeginInit();
@@ -273,6 +273,7 @@ namespace AiQ_GUI
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", "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.Name = "CbBxUserName"; CbBxUserName.Name = "CbBxUserName";
CbBxUserName.Size = new Size(233, 25); CbBxUserName.Size = new Size(233, 25);
CbBxUserName.TabIndex = 159; CbBxUserName.TabIndex = 159;
@@ -1910,6 +1911,24 @@ namespace AiQ_GUI
TabSoak.TabIndex = 2; TabSoak.TabIndex = 2;
TabSoak.Text = "Soak"; 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
// //
SetGodModeAll.BackColor = Color.FromArgb(70, 65, 80); SetGodModeAll.BackColor = Color.FromArgb(70, 65, 80);
@@ -2000,24 +2019,6 @@ namespace AiQ_GUI
timerTypeIP.Interval = 2000; timerTypeIP.Interval = 2000;
timerTypeIP.Tick += timerTypeIP_Tick; 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 // MainForm
// //
AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleDimensions = new SizeF(7F, 15F);

View File

@@ -218,7 +218,7 @@ 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);// If approved then pass otherwise GUI would have restarted before getting to TestPassed. 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 TestPassed(PCTime); await TestPassed(PCTime);
} }
@@ -293,7 +293,7 @@ namespace AiQ_GUI
// Purge camera of all reads // Purge camera of all reads
await FlexiAPI.APIHTTPRequest("/api/purge-all", CamOnTest.IP); await FlexiAPI.APIHTTPRequest("/api/purge-all", CamOnTest.IP);
if (await DisplayQuestion("Do you want to set this camera to 211 and God mode?")) if (await DisplayQuestion("Do you want to set this camera to 211 and God mode off?"))
{ {
// Turn off God mode // Turn off God mode
string[,] GOD_JSON = { { "propGodMode", "false" } }; string[,] GOD_JSON = { { "propGodMode", "false" } };
@@ -331,17 +331,14 @@ namespace AiQ_GUI
} }
public async Task TestFailed(Button Btn, string ErrMssg) public async Task TestFailed(Button Btn, string ErrMssg)
{
AddToActionsList(ErrMssg);
await TestFailed(Btn);
}
private async Task TestFailed(Button Btn)
{ {
// 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";
AddToActionsList(ErrMssg);
// TODO Track Tests Failed
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."))
{ {
if (CbBxUserName.Text == "Bradley") if (CbBxUserName.Text == "Bradley")
@@ -638,8 +635,8 @@ namespace AiQ_GUI
lblTrim.Text += "H: " + DiagsAPI.trim[0] + " V: " + DiagsAPI.trim[1]; lblTrim.Text += "H: " + DiagsAPI.trim[0] + " V: " + DiagsAPI.trim[1];
// Offset accounted for in the SetTrim function, so value should be close to 0,0. // Offset accounted for in the SetTrim function, so value should be close to 0,0.
int HMax = 96; // 5% of 1920 each way = ±96 const int HMax = 96; // 5% of 1920 each way = ±96
int VMax = 54; // 5% of 1080 each way = ±54 const int VMax = 54; // 5% of 1080 each way = ±54
if (Math.Abs(DiagsAPI.trim[0]) <= HMax && Math.Abs(DiagsAPI.trim[1]) <= VMax) if (Math.Abs(DiagsAPI.trim[0]) <= HMax && Math.Abs(DiagsAPI.trim[1]) <= VMax)
lblTrim.ForeColor = Color.LightGreen; lblTrim.ForeColor = Color.LightGreen;
@@ -1003,9 +1000,8 @@ namespace AiQ_GUI
PnlInputValue.Visible = true; PnlInputValue.Visible = true;
while (Flags.Done == false) // Waiting for user input in RMA Num panel while (Flags.Done == false) // Waiting for user input in RMA Num panel
{
await Task.Delay(100); // Check every 100ms await Task.Delay(100); // Check every 100ms
}
Flags.Done = false; // Reset flag Flags.Done = false; // Reset flag
PnlInputValue.Visible = false; PnlInputValue.Visible = false;
@@ -1657,67 +1653,14 @@ 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 = (50 * 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 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[,] Vaxtor_JSON = { { "propMinCharHeight", "14" }, { "propMinGlobalConfidence", "30" } };
List<FrameData> frames = new List<FrameData> string response = await FlexiAPI.HTTP_Update("RaptorOCR", "192.168.0.100", Vaxtor_JSON);
{ AddToActionsList(response);
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);
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"));

View File

@@ -44,16 +44,16 @@
<PackageReference Include="ClosedXML" Version="0.105.0" /> <PackageReference Include="ClosedXML" Version="0.105.0" />
<PackageReference Include="Emgu.CV" Version="4.12.0.5764" /> <PackageReference Include="Emgu.CV" Version="4.12.0.5764" />
<PackageReference Include="Emgu.CV.runtime.windows" Version="4.12.0.5764" /> <PackageReference Include="Emgu.CV.runtime.windows" Version="4.12.0.5764" />
<PackageReference Include="Google.Apis.Auth" Version="1.71.0" /> <PackageReference Include="Google.Apis.Auth" Version="1.72.0" />
<PackageReference Include="Google.Apis.Gmail.v1" Version="1.70.0.3833" /> <PackageReference Include="Google.Apis.Gmail.v1" Version="1.70.0.3833" />
<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.1" /> <PackageReference Include="PDFsharp-MigraDoc-gdi" Version="6.2.2" />
<PackageReference Include="Selenium.Support" Version="4.35.0" /> <PackageReference Include="Selenium.Support" Version="4.37.0" />
<PackageReference Include="Selenium.WebDriver" Version="4.35.0" /> <PackageReference Include="Selenium.WebDriver" Version="4.37.0" />
<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="140.0.7339.8200" /> <PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="141.0.7390.7800" />
<PackageReference Include="SSH.NET" Version="2025.0.0" /> <PackageReference Include="SSH.NET" Version="2025.0.0" />
<PackageReference Include="System.Data.OleDb" Version="9.0.9" /> <PackageReference Include="System.Data.OleDb" Version="9.0.10" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -35,6 +35,8 @@ namespace AiQ_GUI
try try
{ {
string JSONdata = BuildJsonUpdate(jsonArrayData, ID); string JSONdata = BuildJsonUpdate(jsonArrayData, ID);
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);
} }

View File

@@ -10,13 +10,13 @@ namespace AiQ_GUI
internal class ImageProcessing internal class ImageProcessing
{ {
// API to get snapshot then downsize and downscale image to save size. // API to get snapshot then downsize and downscale image to save size.
public static async Task<Image?> GetProcessedImage(string suffix, string IPAddress, string DevPass, string? savePath = null, PictureBox? PcBx = null, bool SaveDisplay = false) public static async Task<Image?> GetProcessedImage(string Module, string IPAddress, string DevPass, string? savePath = null, PictureBox? PcBx = null, bool SaveDisplay = false)
{ {
try try
{ {
string requestUrl = $"http://{IPAddress}/{suffix}"; string requestUrl = $"http://{IPAddress}/{Module}-snapshot";
HttpClientHandler handler = new HttpClientHandler HttpClientHandler handler = new()
{ {
Credentials = new NetworkCredential("developer", DevPass), Credentials = new NetworkCredential("developer", DevPass),
PreAuthenticate = true PreAuthenticate = true
@@ -85,7 +85,7 @@ namespace AiQ_GUI
public static async Task ImageCheck(PictureBox PicBxOV, PictureBox PicBxF2, PictureBox PicBxF16, Label LblF2, Label LblF16, Camera CamOnTest) public static async Task ImageCheck(PictureBox PicBxOV, PictureBox PicBxF2, PictureBox PicBxF16, Label LblF2, Label LblF16, Camera CamOnTest)
{ {
// Take OV snapshot // Take OV snapshot
Task<Image?> Colour_Response = GetProcessedImage("Colour-snapshot", CamOnTest.IP, CamOnTest.DevPass, LDS.MAVPath + LDS.OVsavePath, PicBxOV, true); Task<Image?> Colour_Response = GetProcessedImage("Colour", CamOnTest.IP, CamOnTest.DevPass, LDS.MAVPath + LDS.OVsavePath, PicBxOV, true);
// Change to wide iris F2.0 // Change to wide iris F2.0
await FlexiAPI.APIHTTPVISCA(CamOnTest.IP, "8101044B00000100FF", true); await FlexiAPI.APIHTTPVISCA(CamOnTest.IP, "8101044B00000100FF", true);
@@ -93,7 +93,7 @@ namespace AiQ_GUI
await Task.Delay(200); // Wait for iris to settle before taking IR image await Task.Delay(200); // Wait for iris to settle before taking IR image
// Take IR bright light image // Take IR bright light image
Image? F2_Response = await GetProcessedImage("Infrared-snapshot", CamOnTest.IP, CamOnTest.DevPass, LDS.MAVPath + LDS.IROpensavePath, PicBxF2, true); Image? F2_Response = await GetProcessedImage("Infrared", CamOnTest.IP, CamOnTest.DevPass, LDS.MAVPath + LDS.IROpensavePath, PicBxF2, true);
if (F2_Response == null) if (F2_Response == null)
{ {
MainForm.Instance.AddToActionsList("IR F2.0 image response is blank."); MainForm.Instance.AddToActionsList("IR F2.0 image response is blank.");
@@ -106,7 +106,7 @@ namespace AiQ_GUI
await Task.Delay(200); // Wait for iris to settle before taking IR image await Task.Delay(200); // Wait for iris to settle before taking IR image
// Take IR low light image // Take IR low light image
Image? F16_Response = await GetProcessedImage("Infrared-snapshot", CamOnTest.IP, CamOnTest.DevPass, LDS.MAVPath + LDS.IRTightsavePath, PicBxF16, true); Image? F16_Response = await GetProcessedImage("Infrared", CamOnTest.IP, CamOnTest.DevPass, LDS.MAVPath + LDS.IRTightsavePath, PicBxF16, true);
if (F16_Response == null) if (F16_Response == null)
{ {
MainForm.Instance.AddToActionsList("IR F16.0 image response is blank."); MainForm.Instance.AddToActionsList("IR F16.0 image response is blank.");

View File

@@ -1,4 +1,5 @@
using Renci.SshNet; using Renci.SshNet;
using Renci.SshNet.Common;
namespace AiQ_GUI namespace AiQ_GUI
{ {
@@ -6,6 +7,29 @@ namespace AiQ_GUI
{ {
public const string SSHUsername = "mav"; public const string SSHUsername = "mav";
public const string SSHPassword = "mavPA$$"; public const string SSHPassword = "mavPA$$";
public const string SSHPasswordNEW = "#!mavsoftMESA19"; // New password for SSH after last one got leaked
private static SshClient SshConnect(string IPAddress)
{
SshClient client = new(IPAddress, SSHUsername, SSHPasswordNEW);
try
{
client.Connect();
return client;
}
catch (SshAuthenticationException)
{
client = new(IPAddress, SSHUsername, SSHPassword);
client.Connect();
return client;
}
catch (Exception Ex)
{
MainForm.Instance.AddToActionsList($"SSH connection failed: {Ex.Message}. Check password or network.");
}
return null;
}
// Connects to camera over SSH and collects the Vaxtor packages, filesystem name, filesystem size, and tailscale status. // Connects to camera over SSH and collects the Vaxtor packages, filesystem name, filesystem size, and tailscale status.
public static SSHData CollectSSHData(string IPAddress) public static SSHData CollectSSHData(string IPAddress)
@@ -14,8 +38,7 @@ namespace AiQ_GUI
try try
{ {
using SshClient client = new(IPAddress, SSHUsername, SSHPassword); SshClient client = SshConnect(IPAddress);
client.Connect();
try try
{ {
@@ -34,8 +57,7 @@ namespace AiQ_GUI
catch (Exception ex) catch (Exception ex)
{ {
MainForm.Instance.AddToActionsList($"Failed to get filesystem info: {ex.Message}"); MainForm.Instance.AddToActionsList($"Failed to get filesystem info: {ex.Message}");
Data.FilesystemName = "Unknown"; Data.FilesystemName = Data.FilesystemSize = "Unknown";
Data.FilesystemSize = "Unknown";
} }
try try
@@ -49,6 +71,7 @@ namespace AiQ_GUI
} }
client.Disconnect(); client.Disconnect();
client.Dispose();
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -131,8 +154,7 @@ namespace AiQ_GUI
{ {
try try
{ {
using SshClient client = new SshClient(IPAddress, SSHUsername, SSHPassword); SshClient client = SshConnect(IPAddress);
client.Connect();
try try
{ {
@@ -144,6 +166,7 @@ namespace AiQ_GUI
} }
client.Disconnect(); client.Disconnect();
client.Dispose();
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -191,10 +214,10 @@ namespace AiQ_GUI
{ {
try try
{ {
using SshClient client = new(IPAddress, SSHUsername, SSHPassword); SshClient client = SshConnect(IPAddress);
client.Connect();
(string FilesystemName, string FilesystemSize) = GetRootFilesystemInfo(client); (string FilesystemName, string FilesystemSize) = GetRootFilesystemInfo(client);
client.Disconnect(); client.Disconnect();
client.Dispose();
return (FilesystemName, FilesystemSize); return (FilesystemName, FilesystemSize);
} }
catch (Exception ex) catch (Exception ex)
@@ -207,19 +230,19 @@ namespace AiQ_GUI
// Checks the filesystem size and expands it if necessary, displays on the label how big the SD card is. // Checks the filesystem size and expands it if necessary, displays on the label how big the SD card is.
public static async Task<SSHData> CheckFSSize(string IPAddress, Label LblFSSize, SSHData sshData) public static async Task<SSHData> CheckFSSize(string IPAddress, Label LblFSSize, SSHData sshData)
{ {
const double MinGoodSize = 100.0; // 100GB const double GoodSize = 128.0; // 128GB
const double MaxGoodSize = 150.0; // 150GB const double Deviation = 20.0; // ±20GB
double currentSize = NormaliseFSSize(sshData.FilesystemSize); double currentSize = NormaliseFSSize(sshData.FilesystemSize);
LblFSSize.Text = $"Filesystem Size = {currentSize}GB"; LblFSSize.Text = $"Filesystem Size = {currentSize}GB";
if (currentSize >= MinGoodSize && currentSize <= MaxGoodSize) if (Math.Abs(GoodSize - currentSize) < Deviation)
{ {
LblFSSize.ForeColor = Color.LightGreen; LblFSSize.ForeColor = Color.LightGreen;
return sshData; return sshData;
} }
if (currentSize < MinGoodSize) if (currentSize < GoodSize - Deviation)
{ {
try try
{ {
@@ -230,7 +253,7 @@ namespace AiQ_GUI
double newSize = NormaliseFSSize(sshData.FilesystemSize); double newSize = NormaliseFSSize(sshData.FilesystemSize);
LblFSSize.Text = $"Filesystem Size = {newSize}GB"; LblFSSize.Text = $"Filesystem Size = {newSize}GB";
if (newSize >= MinGoodSize && newSize <= MaxGoodSize) if (Math.Abs(GoodSize - newSize) < Deviation)
{ {
LblFSSize.ForeColor = Color.LightGreen; LblFSSize.ForeColor = Color.LightGreen;
return sshData; return sshData;
@@ -261,10 +284,9 @@ namespace AiQ_GUI
// Extract value & unit // Extract value & unit
System.Text.RegularExpressions.Match match = RegexCache.FileSizeRegex().Match(rootSize.Trim()); System.Text.RegularExpressions.Match match = RegexCache.FileSizeRegex().Match(rootSize.Trim());
if (!match.Success)
return 0;
if (!double.TryParse(match.Groups["value"].Value, out double value)) // Return 0 if no match or invalid number
if (!match.Success || !double.TryParse(match.Groups["value"].Value, out double value))
return 0; return 0;
string unit = match.Groups["unit"].Value.ToUpperInvariant(); string unit = match.Groups["unit"].Value.ToUpperInvariant();
@@ -288,15 +310,14 @@ namespace AiQ_GUI
return 0; return 0;
} }
// Expands the filesystem to max // Expands the filesystem to max
public async static Task<bool> ExpandFS(string device, string IPAddress) public async static Task<bool> ExpandFS(string device, string IPAddress)
{ {
try try
{ {
using SshClient ssh = new SshClient(IPAddress, SSHUsername, SSHPassword); SshClient client = SshConnect(IPAddress);
ssh.Connect();
SshCommand checkDevice = ssh.RunCommand($"[ -b {device} ] && echo OK || echo NOT_FOUND"); SshCommand checkDevice = client.RunCommand($"[ -b {device} ] && echo OK || echo NOT_FOUND");
if (!string.IsNullOrWhiteSpace(checkDevice.Error)) if (!string.IsNullOrWhiteSpace(checkDevice.Error))
throw new Exception(checkDevice.Error); throw new Exception(checkDevice.Error);
@@ -306,7 +327,7 @@ namespace AiQ_GUI
return false; return false;
} }
SshCommand umountCmd = ssh.RunCommand($"sudo umount {device}"); SshCommand umountCmd = client.RunCommand($"sudo umount {device}");
if (!string.IsNullOrWhiteSpace(umountCmd.Error) && !umountCmd.Error.Contains("not mounted")) if (!string.IsNullOrWhiteSpace(umountCmd.Error) && !umountCmd.Error.Contains("not mounted"))
{ {
MainForm.Instance.AddToActionsList($"Unmount error: {umountCmd.Error}"); MainForm.Instance.AddToActionsList($"Unmount error: {umountCmd.Error}");
@@ -315,15 +336,16 @@ namespace AiQ_GUI
await Task.Delay(1000); // Wait for mount to settle await Task.Delay(1000); // Wait for mount to settle
SshCommand fsckCmd = ssh.RunCommand($"sudo e2fsck -f -y -v -C 0 {device}"); SshCommand fsckCmd = client.RunCommand($"sudo e2fsck -f -y -v -C 0 {device}");
if (!string.IsNullOrWhiteSpace(fsckCmd.Error)) if (!string.IsNullOrWhiteSpace(fsckCmd.Error))
{ {
MainForm.Instance.AddToActionsList($"e2fsck error: {fsckCmd.Error}"); MainForm.Instance.AddToActionsList($"e2fsck error: {fsckCmd.Error}");
return false; return false;
} }
SshCommand resizeFs = ssh.RunCommand($"sudo resize2fs {device}"); SshCommand resizeFs = client.RunCommand($"sudo resize2fs {device}");
ssh.Disconnect(); client.Disconnect();
client.Dispose();
if (!string.IsNullOrWhiteSpace(resizeFs.Error)) if (!string.IsNullOrWhiteSpace(resizeFs.Error))
{ {
@@ -348,10 +370,9 @@ namespace AiQ_GUI
{ {
try try
{ {
using SshClient ssh = new SshClient(IPAddress, SSHUsername, SSHPassword); SshClient client = SshConnect(IPAddress);
ssh.Connect();
SshCommand checkDevice = ssh.RunCommand("sync"); SshCommand checkDevice = client.RunCommand("sync");
if (!string.IsNullOrWhiteSpace(checkDevice.Error)) if (!string.IsNullOrWhiteSpace(checkDevice.Error))
throw new Exception(checkDevice.Error); throw new Exception(checkDevice.Error);
@@ -360,6 +381,9 @@ namespace AiQ_GUI
MainForm.Instance.AddToActionsList($"Cannot sync files to disk. Replied: {checkDevice.Result}. DO NOT TURN OFF, GET SUPERVISOR"); MainForm.Instance.AddToActionsList($"Cannot sync files to disk. Replied: {checkDevice.Result}. DO NOT TURN OFF, GET SUPERVISOR");
return; return;
} }
client.Disconnect();
client.Dispose();
} }
catch (Exception ex) catch (Exception ex)
{ {

View File

@@ -15,9 +15,7 @@ namespace AiQ_GUI
// If there is no dot in the version string, return the version as is // If there is no dot in the version string, return the version as is
if (dotLocation < 0) if (dotLocation < 0)
{
return GUIVersion; return GUIVersion;
}
// Check if the next character after the dot is "0" // Check if the next character after the dot is "0"
if (dotLocation + 1 < GUIVersion.Length && GUIVersion[dotLocation + 1] == '0') if (dotLocation + 1 < GUIVersion.Length && GUIVersion[dotLocation + 1] == '0')
@@ -48,7 +46,7 @@ namespace AiQ_GUI
{ {
if (ComapreVersions()) // Checks if the current version is older than the latest version if (ComapreVersions()) // Checks if the current version is older than the latest version
{ {
string GUIPath = $"{GoogleAPI.DrivePath}AiQ\\GUI's\\AiQ_Final_Test\\AiQ_GUI.application"; const string GUIPath = $"{GoogleAPI.DrivePath}AiQ\\GUI's\\AiQ_Final_Test\\AiQ_GUI.application";
// Check if path is real // Check if path is real
if (!File.Exists(GUIPath)) if (!File.Exists(GUIPath))

View File

@@ -24,7 +24,7 @@ namespace AiQ_GUI
{ {
try try
{ {
string streamPath = $"{DrivePath}R50IQ\\client_secret.json"; const string streamPath = $"{DrivePath}R50IQ\\client_secret.json";
string[] Scopes = [SheetsService.Scope.Spreadsheets]; string[] Scopes = [SheetsService.Scope.Spreadsheets];
FileStream stream = new(streamPath, FileMode.Open, FileAccess.Read); FileStream stream = new(streamPath, FileMode.Open, FileAccess.Read);
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(GoogleClientSecrets.FromStream(stream).Secrets, Scopes, "user", CancellationToken.None, new FileDataStore(credPath, true)).Result; credential = GoogleWebAuthorizationBroker.AuthorizeAsync(GoogleClientSecrets.FromStream(stream).Secrets, Scopes, "user", CancellationToken.None, new FileDataStore(credPath, true)).Result;
@@ -231,7 +231,7 @@ namespace AiQ_GUI
// Checks RMA control sheet for a model and serial that match current camera // Checks RMA control sheet for a model and serial that match current camera
public static int CheckRMANum(string serial, string model) public static int CheckRMANum(string serial, string model)
{ {
string spreadsheetId_RMAControl = "1tZhkYrqBQ3BcL7ZS4q3ghzCgHSJ8f5LVSj7nh6fIRC8"; const string spreadsheetId_RMAControl = "1tZhkYrqBQ3BcL7ZS4q3ghzCgHSJ8f5LVSj7nh6fIRC8";
try try
{ {
// Get all info in H and I columns // Get all info in H and I columns

View File

@@ -151,15 +151,11 @@ namespace AiQ_GUI
double Exp_PSU_V = Convert.ToDouble(CameraAccessInfo.PowerType.Remove(CameraAccessInfo.PowerType.IndexOf('V'))); double Exp_PSU_V = Convert.ToDouble(CameraAccessInfo.PowerType.Remove(CameraAccessInfo.PowerType.IndexOf('V')));
double Exp_PSU_I = Math.Round(UniversalData.PowerConsumption / Exp_PSU_V, 2); // 32W device if AiQ Mk2 on medium LED power double Exp_PSU_I = Math.Round(UniversalData.PowerConsumption / Exp_PSU_V, 2); // 32W device if AiQ Mk2 on medium LED power
if (PSU_V > Exp_PSU_V + 1 || PSU_V < Exp_PSU_V - 1) if (Math.Abs(PSU_V - Exp_PSU_V) > 1)
{
MainForm.Instance.AddToActionsList($"PSU Voltage out of range: {PSUVoltage}V. Expected {Exp_PSU_V}V ± 1V."); MainForm.Instance.AddToActionsList($"PSU Voltage out of range: {PSUVoltage}V. Expected {Exp_PSU_V}V ± 1V.");
}
if (PSU_I < Exp_PSU_I * 0.8 || PSU_I > Exp_PSU_I * 1.2) if (Math.Abs(PSU_I - Exp_PSU_I) > 0.2 * Math.Abs(Exp_PSU_I))
{
MainForm.Instance.AddToActionsList($"PSU Current out of range: {PSUCurrent}A. Expected {Exp_PSU_I}A ± 20%."); MainForm.Instance.AddToActionsList($"PSU Current out of range: {PSUCurrent}A. Expected {Exp_PSU_I}A ± 20%.");
}
} }
catch catch
{ {

View File

@@ -9,7 +9,7 @@ namespace AiQ_GUI
// 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()
{ {
List<Tuple<string, string>> modelTuples = new List<Tuple<string, string>>(30); // Preallocate list with estimated capacity to reduce internal resizing List<Tuple<string, string>> modelTuples = new(30); // Preallocate list with estimated capacity to reduce internal resizing
using OleDbConnection conn = new(connString); using OleDbConnection conn = new(connString);
try try
@@ -38,6 +38,7 @@ namespace AiQ_GUI
IOrderedEnumerable<Tuple<string, string>> sorted = modelTuples.OrderBy(t => t.Item1.Equals("AB12CD", StringComparison.OrdinalIgnoreCase) ? 1 : 0) IOrderedEnumerable<Tuple<string, string>> sorted = modelTuples.OrderBy(t => t.Item1.Equals("AB12CD", StringComparison.OrdinalIgnoreCase) ? 1 : 0)
.ThenBy(t => t.Item1, StringComparer.OrdinalIgnoreCase); .ThenBy(t => t.Item1, StringComparer.OrdinalIgnoreCase);
conn.Close();
// Format the sorted tuples as "ModelNumber - Description" strings and return as array // Format the sorted tuples as "ModelNumber - Description" strings and return as array
return sorted.Select(t => $"{t.Item1} - {t.Item2}").ToArray(); return sorted.Select(t => $"{t.Item1} - {t.Item2}").ToArray();
} }
@@ -67,6 +68,7 @@ namespace AiQ_GUI
UniversalData.LatestVersion = Convert.ToString(reader["AiQGUIVersion"]); UniversalData.LatestVersion = Convert.ToString(reader["AiQGUIVersion"]);
UniversalData.PowerConsumption = Convert.ToInt16(reader["PowerConsumption"]); UniversalData.PowerConsumption = Convert.ToInt16(reader["PowerConsumption"]);
UniversalData.LicencingServerURL = Convert.ToString(reader["LicencingServerURL"]); UniversalData.LicencingServerURL = Convert.ToString(reader["LicencingServerURL"]);
conn.Close();
} }
// Knowing the model number on test, this function reads the database and populates the Camera class with the values. // Knowing the model number on test, this function reads the database and populates the Camera class with the values.
@@ -97,6 +99,7 @@ namespace AiQ_GUI
CameraAccessInfo.LED_V = Convert.ToDouble(reader["LEDVoltage"]); CameraAccessInfo.LED_V = Convert.ToDouble(reader["LEDVoltage"]);
CameraAccessInfo.LED_I = Convert.ToInt32(reader["LEDCurrent"]); CameraAccessInfo.LED_I = Convert.ToInt32(reader["LEDCurrent"]);
CameraAccessInfo.SpreadsheetID = Convert.ToString(reader["SSID"]); CameraAccessInfo.SpreadsheetID = Convert.ToString(reader["SSID"]);
conn.Close();
} }
} }

View File

@@ -66,28 +66,22 @@ namespace AiQ_GUI
return "Spreadsheet not found"; return "Spreadsheet not found";
} }
using XLWorkbook workbook = new XLWorkbook(FilePath); using XLWorkbook workbook = new(FilePath);
IXLWorksheet worksheet = workbook.Worksheets.First(); IXLWorksheet worksheet = workbook.Worksheets.First();
// Start from row 1 and check downwards to find next empty row in column B // Start from row 1 and check downwards to find next empty row in column B
int row = 1; int row = 1;
while (!worksheet.Cell(row, 2).IsEmpty()) // Column B = Serial numbers while (!worksheet.Cell(row, 2).IsEmpty()) // Column B = Serial numbers
{
row++; row++;
}
// Safety check to avoid invalid index // Safety check to avoid invalid index
if (row <= 1) if (row <= 1)
{
return "Last serial number not found"; return "Last serial number not found";
}
// Generate new serial number from previous // Generate new serial number from previous
string lastSerialNumber = worksheet.Cell(row - 1, 2).GetString(); // Column B string lastSerialNumber = worksheet.Cell(row - 1, 2).GetString(); // Column B
if (string.IsNullOrWhiteSpace(lastSerialNumber) || !lastSerialNumber.StartsWith("K")) if (string.IsNullOrWhiteSpace(lastSerialNumber) || !lastSerialNumber.StartsWith("K"))
{
return "Invalid last serial number format"; return "Invalid last serial number format";
}
int NewSerialNumberInt = Convert.ToInt32(lastSerialNumber.Substring(1)) + 1; int NewSerialNumberInt = Convert.ToInt32(lastSerialNumber.Substring(1)) + 1;
string newSerialNumber = "K" + NewSerialNumberInt; string newSerialNumber = "K" + NewSerialNumberInt;
@@ -124,7 +118,7 @@ namespace AiQ_GUI
return "Spreadsheet not found"; return "Spreadsheet not found";
} }
using XLWorkbook workbook = new XLWorkbook(filePath); using XLWorkbook workbook = new(filePath);
IXLWorksheet worksheet = workbook.Worksheets.First(); IXLWorksheet worksheet = workbook.Worksheets.First();
// Find the row with the matching serial number in column B // Find the row with the matching serial number in column B
@@ -136,8 +130,7 @@ namespace AiQ_GUI
{ {
// Update columns D-E // Update columns D-E
worksheet.Cell(row, 4).Value = "Pre Test: " + DateTime.Now.ToString("dd/MM/yyyy"); worksheet.Cell(row, 4).Value = "Pre Test: " + DateTime.Now.ToString("dd/MM/yyyy");
worksheet.Cell(row, 5).Value = Vers.version + " - " + Vers.revision + Environment.NewLine + worksheet.Cell(row, 5).Value = $"{Vers.version} - {Vers.revision}" + Environment.NewLine + Vers.buildtime + Environment.NewLine + Vers.proquint;
Vers.buildtime + Environment.NewLine + Vers.proquint;
// Update MAC to column H // Update MAC to column H
worksheet.Cell(row, 8).Value = Vers.MAC; worksheet.Cell(row, 8).Value = Vers.MAC;
@@ -172,7 +165,7 @@ namespace AiQ_GUI
return "Spreadsheet not found"; return "Spreadsheet not found";
} }
using XLWorkbook workbook = new XLWorkbook(FilePath); using XLWorkbook workbook = new(FilePath);
IXLWorksheet worksheet = workbook.Worksheets.First(); IXLWorksheet worksheet = workbook.Worksheets.First();
// Find the row with the matching serial number in column B // Find the row with the matching serial number in column B
@@ -224,15 +217,13 @@ namespace AiQ_GUI
return "Spreadsheet not found"; return "Spreadsheet not found";
} }
using XLWorkbook workbook = new XLWorkbook(FilePath); using XLWorkbook workbook = new(FilePath);
IXLWorksheet worksheet = workbook.Worksheets.First(); IXLWorksheet worksheet = workbook.Worksheets.First();
// Find next free row by checking column C // Find next free row by checking column C
int row = 2; int row = 2;
while (!worksheet.Cell(row, 3).IsEmpty()) // Column C while (!worksheet.Cell(row, 3).IsEmpty()) // Column C
{
row++; row++;
}
// Write model, serial, date, and protectionKeyId to columns CF // Write model, serial, date, and protectionKeyId to columns CF
worksheet.Cell(row, 3).Value = model; // Column C worksheet.Cell(row, 3).Value = model; // Column C
@@ -263,7 +254,7 @@ namespace AiQ_GUI
return 0; return 0;
} }
using XLWorkbook workbook = new XLWorkbook(filePath); using XLWorkbook workbook = new(filePath);
IXLWorksheet worksheet = workbook.Worksheets.First(); IXLWorksheet worksheet = workbook.Worksheets.First();
int row = 2; // Start from row 2 int row = 2; // Start from row 2
@@ -277,10 +268,9 @@ namespace AiQ_GUI
if (sheetSerial.Contains(serial) && sheetModel.Contains(model)) if (sheetSerial.Contains(serial) && sheetModel.Contains(model))
{ {
string rmaStr = worksheet.Cell(row, 1).GetString(); // Column A string rmaStr = worksheet.Cell(row, 1).GetString(); // Column A
if (int.TryParse(rmaStr, out int rmaNumber)) if (int.TryParse(rmaStr, out int rmaNumber))
{
return rmaNumber; return rmaNumber;
}
} }
} }
catch { /* Safe to ignore bad row */ } catch { /* Safe to ignore bad row */ }
@@ -306,7 +296,7 @@ namespace AiQ_GUI
return 0; return 0;
} }
using XLWorkbook workbook = new XLWorkbook(filePath); using XLWorkbook workbook = new(filePath);
IXLWorksheet worksheet = workbook.Worksheets.First(); IXLWorksheet worksheet = workbook.Worksheets.First();
int row = 1; int row = 1;
@@ -315,10 +305,9 @@ namespace AiQ_GUI
try try
{ {
string cellSerial = worksheet.Cell(row, 2).GetString(); string cellSerial = worksheet.Cell(row, 2).GetString();
if (cellSerial.Contains(serial)) if (cellSerial.Contains(serial))
{
return row; return row;
}
} }
catch { /* Ignore malformed rows */ } catch { /* Ignore malformed rows */ }
@@ -343,14 +332,12 @@ namespace AiQ_GUI
return -1; return -1;
} }
using XLWorkbook workbook = new XLWorkbook(filePath); using XLWorkbook workbook = new(filePath);
IXLWorksheet worksheet = workbook.Worksheets.First(); IXLWorksheet worksheet = workbook.Worksheets.First();
int row = 2; // Start from C2 int row = 2; // Start from C2
while (!worksheet.Cell(row, 3).IsEmpty()) // Column C = 3 while (!worksheet.Cell(row, 3).IsEmpty()) // Column C = 3
{
row++; row++;
}
return row; return row;
} }
@@ -368,7 +355,7 @@ namespace AiQ_GUI
// 1. Ensure spreadsheet exists and has valid starting data // 1. Ensure spreadsheet exists and has valid starting data
if (!File.Exists(filePath)) if (!File.Exists(filePath))
{ {
XLWorkbook workbook = new XLWorkbook(); XLWorkbook workbook = new();
IXLWorksheet ws = workbook.Worksheets.Add("Sheet1"); IXLWorksheet ws = workbook.Worksheets.Add("Sheet1");
// Pre-fill first row with dummy data for serial // Pre-fill first row with dummy data for serial
@@ -379,7 +366,7 @@ namespace AiQ_GUI
} }
// 2. Run Pre-Test update // 2. Run Pre-Test update
Versions fakeVersion = new Versions Versions fakeVersion = new()
{ {
version = "1.6.4", version = "1.6.4",
revision = "bf16134", revision = "bf16134",
@@ -388,11 +375,11 @@ namespace AiQ_GUI
MAC = "00:1A:2B:3C:4D:5E" MAC = "00:1A:2B:3C:4D:5E"
}; };
string preTestResult = Excel.UpdateSpreadSheetPreTest(filePath, fakeVersion, "Fake Cam", "TestModel"); string preTestResult = UpdateSpreadSheetPreTest(filePath, fakeVersion, "Fake Cam", "TestModel");
Debug.WriteLine("Pre-Test Result: " + preTestResult); Debug.WriteLine("Pre-Test Result: " + preTestResult);
// 3. Run Final Test update // 3. Run Final Test update
Diags fakeDiags = new Diags Diags fakeDiags = new()
{ {
serialNumber = preTestResult, // Newly generated serial serialNumber = preTestResult, // Newly generated serial
licenses = new Licenses licenses = new Licenses
@@ -404,13 +391,13 @@ namespace AiQ_GUI
} }
}; };
SSHData fakeSSH = new SSHData SSHData fakeSSH = new()
{ {
packages = "\r\nlibvaxtorocr10 - 8.4.20-1\r\nvaxtorocrdatacpu3 - 8.4.20-1", packages = "\r\nlibvaxtorocr10 - 8.4.20-1\r\nvaxtorocrdatacpu3 - 8.4.20-1",
tailscale = true tailscale = true
}; };
string finalTestResult = Excel.UpdateSpreadSheetFinalTest(filePath, fakeDiags, fakeSSH, 0); string finalTestResult = UpdateSpreadSheetFinalTest(filePath, fakeDiags, fakeSSH, 0);
Debug.WriteLine("Final-Test Result: " + finalTestResult); Debug.WriteLine("Final-Test Result: " + finalTestResult);
// // 4. Run Vaxtor update // // 4. Run Vaxtor update
@@ -430,7 +417,6 @@ namespace AiQ_GUI
// int nextFree = Excel.CheckNextFree(filePath); // int nextFree = Excel.CheckNextFree(filePath);
// Debug.WriteLine("Next free row in Vaxtor sheet (Column C): " + nextFree); // Debug.WriteLine("Next free row in Vaxtor sheet (Column C): " + nextFree);
//} //}
} }
} }
} }

View File

@@ -1,6 +1,5 @@
using System.Diagnostics; using System.Diagnostics;
using System.Reflection; using System.Reflection;
using System.Runtime.InteropServices;
using System.Security.Principal; using System.Security.Principal;
namespace AiQ_GUI namespace AiQ_GUI
@@ -16,14 +15,11 @@ namespace AiQ_GUI
.Where(p => targetProcesses.Any(tp => p.ProcessName.Contains(tp))) .Where(p => targetProcesses.Any(tp => p.ProcessName.Contains(tp)))
.Select(clsProcess => .Select(clsProcess =>
{ {
using (clsProcess) try
{ {
try clsProcess.CloseMainWindow();
{
clsProcess.CloseMainWindow();
}
catch { }
} }
catch { }
return Task.CompletedTask; return Task.CompletedTask;
}); });
@@ -34,7 +30,7 @@ namespace AiQ_GUI
{ {
Logging.LogMessage($"Starting exe from {ExeLoc}"); Logging.LogMessage($"Starting exe from {ExeLoc}");
ProcessStartInfo processInfo = new ProcessStartInfo(ExeLoc) ProcessStartInfo processInfo = new(ExeLoc)
{ {
UseShellExecute = true, UseShellExecute = true,
Verb = "runas" Verb = "runas"
@@ -64,7 +60,7 @@ namespace AiQ_GUI
{ {
StartAsAdmin(ExeLoc); StartAsAdmin(ExeLoc);
} }
else if (runAsAdmin) else if (Properties.Settings.Default.FirstRun && runAsAdmin)
{ {
try try
{ {
@@ -86,6 +82,8 @@ namespace AiQ_GUI
Properties.Settings.Default.FirstRun = false; Properties.Settings.Default.FirstRun = false;
Properties.Settings.Default.Save(); Properties.Settings.Default.Save();
Application.Restart(); // Restart to not be in admin mode
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -95,43 +93,4 @@ namespace AiQ_GUI
} }
} }
} }
[ComImport, Guid("AF230D27-BABA-4E42-ACED-F524F22CFCE2")]
public interface INetFwRule
{
string Name { get; set; }
string Description { get; set; }
string ApplicationName { get; set; }
string ServiceName { get; set; }
int Protocol { get; set; }
string LocalPorts { get; set; }
string RemotePorts { get; set; }
string LocalAddresses { get; set; }
string RemoteAddresses { get; set; }
string IcmpTypesAndCodes { get; set; }
int Direction { get; set; }
object Interfaces { get; set; }
string InterfaceTypes { get; set; }
bool Enabled { get; set; }
string Grouping { get; set; }
int Profiles { get; set; }
bool EdgeTraversal { get; set; }
int Action { get; set; }
}
[ComImport, Guid("98325047-C671-4174-8D81-DEFCD3F03186")]
public interface INetFwPolicy2
{
int CurrentProfileTypes { get; }
void get_FirewallEnabled(int profileType, out bool enabled);
void put_FirewallEnabled(int profileType, bool enabled);
void get_ExcludedInterfaces(int profileType, out object interfaces);
void put_ExcludedInterfaces(int profileType, object interfaces);
int BlockAllInboundTraffic { get; set; }
int NotificationsDisabled { get; set; }
int UnicastResponsesToMulticastBroadcastDisabled { get; set; }
object Rules { get; }
object ServiceRestriction { get; }
// ...other members omitted for brevity
}
} }

View File

@@ -39,14 +39,8 @@ namespace AiQ_GUI
return elementID; return elementID;
} }
// Clicks the element with the specified ID using Chromedriver
public static void ClickElementByID(string elementID, ChromeDriver driver)
{
ClickElementByID(elementID, true, driver);
}
// 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, bool tryagain, ChromeDriver driver) public static void ClickElementByID(string elementID, ChromeDriver driver, bool tryagain = true)
{ {
try try
{ {
@@ -61,7 +55,7 @@ namespace AiQ_GUI
driver.Navigate().Refresh(); driver.Navigate().Refresh();
WebDriverWait wait = new(driver, TimeSpan.FromSeconds(10)); WebDriverWait wait = new(driver, TimeSpan.FromSeconds(10));
wait.Until(d => ((IJavaScriptExecutor)d).ExecuteScript("return document.readyState").Equals("complete")); wait.Until(d => ((IJavaScriptExecutor)d).ExecuteScript("return document.readyState").Equals("complete"));
ClickElementByID(elementID, false, driver); ClickElementByID(elementID, driver, false);
} }
MainForm.Instance.AddToActionsList("Could not click " + elementID); MainForm.Instance.AddToActionsList("Could not click " + elementID);

View File

@@ -138,7 +138,6 @@ namespace AiQ_GUI
// Create Test report in the same directory as the final test reports. // Create Test report in the same directory as the final test reports.
string soakLogPath = LDS.MAVPath + SoakLogFile; string soakLogPath = LDS.MAVPath + SoakLogFile;
string SoakTestPath = PDF.CreateSoakTestReport(CamInfo, MainForm.Instance.CbBxUserName.Text, DateTime.Now, soakLogPath); string SoakTestPath = PDF.CreateSoakTestReport(CamInfo, MainForm.Instance.CbBxUserName.Text, DateTime.Now, soakLogPath);
if (SoakTestPath != null) if (SoakTestPath != null)
@@ -207,7 +206,7 @@ namespace AiQ_GUI
await Task.Delay(500); await Task.Delay(500);
// Take bright image // Take bright image
Image ImageBright = await ImageProcessing.GetProcessedImage("Infrared-snapshot", IP, DevPass); Image ImageBright = await ImageProcessing.GetProcessedImage("Infrared", IP, DevPass);
if (ImageBright == null) if (ImageBright == null)
{ {
Logging.LogWarningMessage($"Bright image is null for {controlType} at setting {SettingMinMax[0]}", SoakLogFile); Logging.LogWarningMessage($"Bright image is null for {controlType} at setting {SettingMinMax[0]}", SoakLogFile);
@@ -221,7 +220,7 @@ namespace AiQ_GUI
await Task.Delay(500); await Task.Delay(500);
// Take dark image // Take dark image
Image ImageDark = await ImageProcessing.GetProcessedImage("Infrared-snapshot", IP, DevPass); Image ImageDark = await ImageProcessing.GetProcessedImage("Infrared", IP, DevPass);
if (ImageDark == null) if (ImageDark == null)
{ {
Logging.LogWarningMessage($"Dark image is null for {controlType} at setting {SettingMinMax[1]}", SoakLogFile); Logging.LogWarningMessage($"Dark image is null for {controlType} at setting {SettingMinMax[1]}", SoakLogFile);

View File

@@ -1,73 +0,0 @@
{
"id": "GLOBAL--Device",
"configHash": "101478235",
"propHardwarePlatform": {
"value": "JETSON_NANO",
"datatype": "mav.flexi.web.pages.SystemConfig$HardwareConfigurationOption",
"accepted": "[NONE, JETSON_NANO, JETSON_XAVIER, RASPBERRY_PI_CM4, RASPBERRY_PI_CM5, DEVELOPER_WORKSTATION]"
},
"propApplicationPlatform": {
"value": "CUSTOM",
"datatype": "mav.flexi.web.pages.SystemConfig$ApplicationConfigurationOption",
"accepted": "[NONE, CUSTOM, MONO_BASIC_ANPR, DUAL_CAMERA_BASIC_ANPR, SINGLE_SAF_DUAL_CAMERA_BASIC_ANPR, DUAL_CAMERA_STREAMING, BAYGUARD, SITE_ACCESS_CONTROL_WITH_MODBUS, WAPOL_IQ50_VRM_CORRECTION, BAYWATCH_MONO_CAM, BAYWATCH_DUAL_CAM, BAYWATCH_TRIPLE_CAM, BAYWATCH_QUADRUPLE_CAM, IN_CAR_ANPR]"
},
"propDeviceName": {
"value": "Test Nano",
"datatype": "java.lang.String"
},
"propLocalTimeZone": {
"value": "Europe/London (UTC+00)",
"datatype": "mav.util.TimeZoneEnum",
"accepted": "[Africa/Cairo (UTC+02), Africa/Johannesburg (UTC+02), Africa/Lagos (UTC+01), Africa/Monrousing (UTC+00), America/Anchorage (UTC-09), America/Chicago (UTC-06), America/Denver (UTC-07), America/Edmonton (UTC-07), America/Jamaica (UTC-05), America/Los Angeles (UTC-08), America/Mexico City (UTC-06), America/Montreal (UTC-05), America/New/York (UTC-05), America/Phoenix (UTC-07), America/Puerto Rico (UTC-04), America/Sao Paulo (UTC-03), America/Toronto (UTC-05), America/Vancouver (UTC-08), Asia/Hong Kong (UTC+08), Asia/Jerusalem (UTC+02), Asia/Manila (UTC+08), Asia/Seoul (UTC+09), Asia/Tokyo (UTC+09), Atlantic/Reykjavik (UTC+00), Australia/Perth (UTC+08), Australia/Sydney (UTC+10), Europe/Athens (UTC+02), Europe/Berlin (UTC+01), Europe/Brussels (UTC+01), Europe/Copenhagen (UTC+01), Europe/London (UTC+00), Europe/Madrid (UTC+01), Europe/Moscow (UTC+04), Europe/Paris (UTC+01), Europe/Prague (UTC+01), Europe/Rome (UTC+01), Europe/Warsaw (UTC+01), Pacific/Guam (UTC+10), Pacific/Honolulu (UTC-10), UTC (UTC-00)]"
},
"propTimeSource": {
"value": "SNTP Only",
"datatype": "mav.flexi.web.pages.SystemConfig$TimeSourceEnum",
"accepted": "[SNTP Only, GPS Only, SNTP + Soft GPS]"
},
"propSNTPServer": {
"value": "1.uk.pool.ntp.org",
"datatype": "java.lang.String"
},
"propSNTPIntervalMinutes": {
"value": "public long mav.flexi.web.pages.SystemConfig$DeviceConfig.propSNTPIntervalMinutes",
"datatype": "long",
"range": {
"minimum": "1.000000",
"maximum": "99999.000000"
}
},
"propOutputsMaxTimeSyncAge": {
"value": "24 hours",
"datatype": "mav.flexi.web.pages.SystemConfig$HoursEnum",
"accepted": "[NO LIMIT, 01 hours, 02 hours, 03 hours, 04 hours, 05 hours, 06 hours, 07 hours, 08 hours, 09 hours, 10 hours, 11 hours, 12 hours, 18 hours, 24 hours, 36 hours, 48 hours, 72 hours, 96 hours]"
},
"propReservedMemoryMegabytes": {
"value": "public long mav.flexi.web.pages.SystemConfig$DeviceConfig.propReservedMemoryMegabytes",
"datatype": "long",
"range": {
"minimum": "1000.000000",
"maximum": "128000.000000"
}
},
"propClientTrustStorePassword": {
"value": "",
"datatype": "java.lang.String"
},
"propFlexiScriptPath": {
"value": "/home/mav/FlexiAI/bin/FlexiAI",
"datatype": "java.lang.String"
},
"propVideo0Tee": {
"value": "video0tee",
"datatype": "java.lang.String"
},
"propVideo1Tee": {
"value": "video1tee",
"datatype": "java.lang.String"
},
"propRestartCameraModulesOnBoot": {
"value": "true",
"datatype": "boolean"
}
}