Updated other uses of Internal Config to GLOBAL--FlexiApplication

This commit is contained in:
2025-11-04 13:16:07 +00:00
parent 1c89cf2847
commit 78c440ab76
8 changed files with 47 additions and 18 deletions

1
AiQ_GUI.Designer.cs generated
View File

@@ -587,6 +587,7 @@ namespace AiQ_GUI
BtnTest.TabIndex = 189; BtnTest.TabIndex = 189;
BtnTest.Text = "Test"; BtnTest.Text = "Test";
BtnTest.UseVisualStyleBackColor = false; BtnTest.UseVisualStyleBackColor = false;
BtnTest.Visible = false;
BtnTest.Click += BtnTest_Click; BtnTest.Click += BtnTest_Click;
// //
// PicBxIRF2 // PicBxIRF2

View File

@@ -304,7 +304,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");
@@ -397,15 +397,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)
@@ -925,7 +924,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;
} }
@@ -1171,7 +1170,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)
@@ -1580,9 +1579,24 @@ namespace AiQ_GUI
{ {
if (!SCL.IsChecked) if (!SCL.IsChecked)
continue; continue;
try
{
Network.Initialize("developer", SCL.DevPass); // Ensure network is initialized to the right camera, cannot be done in soak test finally becuase of this. Network.Initialize("developer", SCL.DevPass); // Ensure network is initialized to the right camera, cannot be done in soak test finally becuase of this.
await CameraModules.FactoryResetModules(SCL.IP); await CameraModules.FactoryResetModules(SCL.IP); // Reset camera modules
string[,] godJson = { { "propGodMode", "false" } }; // Set God mode explicitly off
string GOD = await FlexiAPI.HTTP_Update("GLOBAL--FlexiApplication", SCL.IP, godJson);
if (GOD.Contains("Error"))
throw new Exception("Could not set God mode off");
bool Pass = await FlexiAPI.ChangeNetwork211(SCL.IP); // set camera to 211
if (!Pass)
throw new Exception("Could not set camera to 211");
}
catch (Exception ex)
{
AddToActionsList("Failed to set God mode, reset camera modules or 211 for camera " + SCL.IP + ". Reason: " + ex.Message);
}
} }
} }
} }
@@ -1702,13 +1716,15 @@ namespace AiQ_GUI
} }
// ***** Test & Debug ***** // ***** Test & Debug *****
private async void BtnTest_Click(object sender, EventArgs e) private void BtnTest_Click(object sender, EventArgs e)
{ {
Stopwatch stopWatchTest = Stopwatch.StartNew(); Stopwatch stopWatchTest = Stopwatch.StartNew();
StatsExcel excelExporter = new(); StatsExcel excelExporter = new();
excelExporter.ExportDatabaseToExcel(); excelExporter.ExportDatabaseToExcel();
// /api/config-ids - For getting all available config IDs
stopWatchTest.Stop(); stopWatchTest.Stop();
AddToActionsList("RunTime " + stopWatchTest.Elapsed.ToString(@"hh\:mm\:ss\.ff")); AddToActionsList("RunTime " + stopWatchTest.Elapsed.ToString(@"hh\:mm\:ss\.ff"));
} }

View File

@@ -16,7 +16,7 @@
<Product>AiQ GUI</Product> <Product>AiQ GUI</Product>
<Authors>MAV Systems Ltd</Authors> <Authors>MAV Systems Ltd</Authors>
<PackageId>AiQ GUI</PackageId> <PackageId>AiQ GUI</PackageId>
<Version>4.0.0</Version> <Version>4.2.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>

View File

@@ -36,7 +36,6 @@ 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);
} }

View File

@@ -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 = "";

View File

@@ -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");

View File

@@ -9,7 +9,7 @@ namespace AiQ_GUI
public static async Task SendMssg(string ApprovalRow, string User) // Sometimes You will need to reauthenticate the workflow public static async Task SendMssg(string ApprovalRow, string User) // Sometimes You will need to reauthenticate the workflow
{ {
using HttpClient client = new HttpClient(); using HttpClient client = new();
string link = $"https://docs.google.com/spreadsheets/d/1bCcCr4OYqfjmydt6UqtmN4FQETezXmZRSStJdCCcqZM/edit#gid=1931079354&range=A{ApprovalRow}"; // Has to be parsed like this as teams doesnt hyperlink otherwise string link = $"https://docs.google.com/spreadsheets/d/1bCcCr4OYqfjmydt6UqtmN4FQETezXmZRSStJdCCcqZM/edit#gid=1931079354&range=A{ApprovalRow}"; // Has to be parsed like this as teams doesnt hyperlink otherwise
@@ -21,7 +21,7 @@ namespace AiQ_GUI
}; };
string json = JsonConvert.SerializeObject(payload); string json = JsonConvert.SerializeObject(payload);
StringContent content = new StringContent(json, Encoding.UTF8, "application/json"); StringContent content = new(json, Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.PostAsync(webhookUrl, content); HttpResponseMessage response = await client.PostAsync(webhookUrl, content);
} }

View File

@@ -1,7 +1,9 @@
using System.Net; using System.Diagnostics;
using System.Net;
using System.Net.NetworkInformation; using System.Net.NetworkInformation;
using System.Net.Sockets; using System.Net.Sockets;
using System.Text; using System.Text;
using System.Threading;
namespace AiQ_GUI namespace AiQ_GUI
{ {
@@ -10,7 +12,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 +25,17 @@ namespace AiQ_GUI
{ {
Timeout = TimeSpan.FromSeconds(20) Timeout = TimeSpan.FromSeconds(20)
}; };
bool UP = false;
int i = 0;
while (!UP)
{
UP = await PingIP("8.8.8.8");
await Task.Delay(500);
if (i >= 5) MainForm.Instance.AddToActionsList($"Could not initialise new network with USER: {username} & PSWD: {password}"); // Try 5 times max
i++;
}
} }
// Handles get and post to the camera API // Handles get and post to the camera API