AddToAction List colours

This commit is contained in:
2025-12-02 12:59:40 +00:00
parent e29d104d47
commit 30bd2fe73c
18 changed files with 171 additions and 160 deletions

View File

@@ -9,7 +9,8 @@ namespace AiQ_GUI
{
ERROR,
WARNING,
LOG
LOG,
Success
}
public partial class MainForm : Form
@@ -77,7 +78,7 @@ namespace AiQ_GUI
if (localDataStore == null)
{
AddToActionsList("Could not deserialise LDS.json please help!");
AddToActionsList("Could not deserialise LDS.json please help!", Level.WARNING);
return;
}
@@ -138,7 +139,7 @@ namespace AiQ_GUI
string LEDreply = await FlexiAPI.APIHTTPLED(CamOnTest.IP, LEDPOWER.SAFE); // Set LED's to safe (0x0E) to help with eye safety and trim check.
if (!LEDreply.Contains("Power levels set successfully"))
AddToActionsList($"LED level could not be set: {LEDreply}");
AddToActionsList($"LED level could not be set: {LEDreply}", Level.ERROR);
}
else if (!await TestTube.CheckInTestTube(CamOnTest.IP)) // Sets LED's to medium power after checking it is in the test tube
await TestFailed(BtnStartTest, "Camera not in test tube");
@@ -157,7 +158,7 @@ namespace AiQ_GUI
string VISCAReply = await FlexiAPI.APIHTTPVISCA(CamOnTest.IP, "8101043903FF", true); // Manual mode to be able to manipulate the SIG settings.
if (VISCAReply != "9041FF9051FF")
AddToActionsList("Couldn't set to manual mode");
AddToActionsList("Couldn't set to manual mode",Level.ERROR);
await CameraModules.SetSIG(CbBxShutter, CbBxIris, CbBxGain, CamOnTest.IP); // Set SIG according to the drop downs in settings for a good picture ready for image check
await ImageProcessing.ImageCheck(PicBxOV, PicBxIRF2, PicBxIRF16, LblIRImageF2, LblIRImageF16, CamOnTest); // Populates the picture boxes and checks iris changes
@@ -200,7 +201,7 @@ namespace AiQ_GUI
string LEDreply = await FlexiAPI.APIHTTPLED(CamOnTest.IP, LEDPOWER.MID); // Set LED's to medium (0x30)
if (!LEDreply.Contains("Power levels set successfully"))
AddToActionsList($"LED level could not be set: {LEDreply}");
AddToActionsList($"LED level could not be set: {LEDreply}", Level.ERROR);
}
await FlexiAPI.SetVaxtorMinMaxPlate(CamOnTest.IP);
@@ -241,7 +242,7 @@ namespace AiQ_GUI
string LEDreply = await FlexiAPI.APIHTTPLED(CamOnTest.IP, LEDPOWER.MID); // Set LED's to medium (0x30)
if (!LEDreply.Contains("Power levels set successfully"))
AddToActionsList($"LED level could not be set: {LEDreply}");
AddToActionsList($"LED level could not be set: {LEDreply}", Level.ERROR);
await CameraModules.FactoryResetModules(CamOnTest.IP); // Reset both modules and double check
@@ -273,7 +274,7 @@ namespace AiQ_GUI
if (await DisplayQuestion($"Would you like to allocate a serial number to this camera?"))
await AllocateSerial();
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",Level.WARNING);
// else if (Excel.UpdateSpreadSheetPreTest(CameraAccessInfo.SpreadsheetID, Vers, CamOnTest.GetCamDesc(), CamOnTest.Model) != "OK")
// AddToActionsList("Failed to write to spreadsheet, please check manually");
}
@@ -296,7 +297,7 @@ namespace AiQ_GUI
string err = GoogleAPI.UpdateSpreadSheetFinalTest(CameraAccessInfo.SpreadsheetID, DiagsAPI, sshData, CamOnTest.RMANum);
if (err != string.Empty) // If there is an error message, display it
AddToActionsList("Failed to write to spreadsheet " + err);
AddToActionsList("Failed to write to spreadsheet " + err, Level.ERROR);
// Purge camera of all reads
await FlexiAPI.APIHTTPRequest("/api/purge-all", CamOnTest.IP);
@@ -307,12 +308,12 @@ namespace AiQ_GUI
string[,] GOD_JSON = { { "propGodMode", "false" } };
string IntConf = await FlexiAPI.HTTP_Update("GLOBAL--FlexiApplication", CamOnTest.IP, GOD_JSON);
if (!IntConf.Contains("\"propGodMode\": {\"value\": \"false\", \"datatype\": \"boolean\"},"))
AddToActionsList("Could not turn off God mode");
AddToActionsList("Could not turn off God mode", Level.WARNING);
Thread Thr211 = new(async () =>
{
if (!await FlexiAPI.ChangeNetwork211(CamOnTest.IP)) // Change camera IP to 192.168.1.211. Waits for camera to come back.
AddToActionsList("Could not find camera at 192.168.1.211. Please check manually");
AddToActionsList("Could not find camera at 192.168.1.211. Please check manually", Level.WARNING);
});
Thr211.IsBackground = true;
Thr211.Start();
@@ -353,7 +354,7 @@ namespace AiQ_GUI
else
Access.Stats("RMA Final Tests Failed", CamOnTest.Model);
AddToActionsList(ErrMssg);
AddToActionsList(ErrMssg, Level.ERROR);
string RedLbls = string.Join(Environment.NewLine, PnlLbls.Controls
.OfType<Label>()
@@ -502,12 +503,12 @@ namespace AiQ_GUI
else if (RegexCache.MACRegex().IsMatch(DiagsAPI.MAC)) // Is a valid MAC, but not NVIDIA
{
lblMac.ForeColor = Color.Red;
AddToActionsList($"{DiagsAPI.MAC} not recognised as NVIDIA MAC address");
AddToActionsList($"{DiagsAPI.MAC} not recognised as NVIDIA MAC address", Level.ERROR);
}
else
{
lblMac.ForeColor = Color.Red;
AddToActionsList($"{DiagsAPI.MAC} not recognised as a MAC address");
AddToActionsList($"{DiagsAPI.MAC} not recognised as a MAC address", Level.ERROR);
}
// Check timestamp
@@ -571,7 +572,7 @@ namespace AiQ_GUI
if (DiagsAPI.modelNumber != CamOnTest.Model)
{
AddToActionsList("Model number in camera doesn't match what has been selected");
AddToActionsList("Model number in camera doesn't match what has been selected", Level.WARNING);
lblModel.ForeColor = Color.Red;
}
else if (!GoogleAPI.CheckWIP(DiagsAPI.serialNumber, CameraAccessInfo.SpreadsheetID)) // Check WIP column in serial number register, if not ticked then RMA
@@ -597,7 +598,7 @@ namespace AiQ_GUI
}
else
{
AddToActionsList("Camera has not been given a valid serial and model number, suggest you run through pre test again and check serial number register for any issues.");
AddToActionsList("Camera has not been given a valid serial and model number, suggest you run through pre test again and check serial number register for any issues.", Level.ERROR);
}
}
catch { }
@@ -693,12 +694,12 @@ namespace AiQ_GUI
if (NewSerial.Contains("ERROR"))
{
AddToActionsList(NewSerial + Environment.NewLine + "Please remove any information that was put into the serial number mistake, change the camera model/serial to 'N/A' and retry the test.");
AddToActionsList(NewSerial + Environment.NewLine + "Please remove any information that was put into the serial number mistake, change the camera model/serial to 'N/A' and retry the test.", Level.ERROR);
return;
}
else if (NewSerial == "Last serial number not found")
{
AddToActionsList("Last serial number not found in spreadsheet. Please check spreadsheet is in correct format before retrying.");
AddToActionsList("Last serial number not found in spreadsheet. Please check spreadsheet is in correct format before retrying.", Level.WARNING);
return;
}
@@ -708,7 +709,7 @@ namespace AiQ_GUI
if (!JSONResponse.Contains(NewSerial) || !JSONResponse.Contains(CamOnTest.Model))
{
AddToActionsList("Could not set model or serial numbers into camera.");
AddToActionsList("Could not set model or serial numbers into camera.",Level.ERROR);
await PreTestFailed("Failed To Set Model Or Serial Number");
}
@@ -862,7 +863,7 @@ namespace AiQ_GUI
if (Vers == null) // If failed to get versions then return. Flexi most likely not running yet.
{
AddToActionsList("Failed to get API from camera. Flexi not running yet or not an AiQ");
AddToActionsList("Failed to get API from camera. Flexi not running yet or not an AiQ", Level.WARNING);
return;
}
@@ -925,7 +926,7 @@ namespace AiQ_GUI
}
catch (Exception ex)
{
AddToActionsList($"Failed to set God mode for camera {CamOnTest.IP}. Reason: {ex.Message}");
AddToActionsList($"Failed to set God mode for camera {CamOnTest.IP}. Reason: {ex.Message}", Level.ERROR);
}
}
@@ -943,12 +944,17 @@ namespace AiQ_GUI
RhTxBxActions.SelectionColor = Color.Orange;
}
else if (Lvl == Level.LOG)
{
Logging.LogMessage(Mssg);
RhTxBxActions.SelectionColor = Color.White;
}
else if (Lvl == Level.Success)
{
Logging.LogMessage(Mssg);
RhTxBxActions.SelectionColor = Color.LightGreen;
}
RhTxBxActions.AppendText(Mssg + Environment.NewLine);
RhTxBxActions.AppendText(Mssg + Environment.NewLine);
RhTxBxActions.SelectionStart = RhTxBxActions.Text.Length;
RhTxBxActions.SelectionColor = SystemColors.Control;
RhTxBxActions.ScrollToCaret();
@@ -1126,7 +1132,7 @@ namespace AiQ_GUI
bool Online = await FlexiAPI.ChangeNetwork211(CamOnTest.IP); // Change camera IP to 192.168.1.211 and hardware reboot. Waits for camera to come back for 50s.
if (!Online)
AddToActionsList("Could not find camera at 192.168.1.211. Please check manually");
AddToActionsList("Could not find camera at 192.168.1.211. Please check manually", Level.ERROR);
else
BtnSet211.Text = "Set to DHCP";
}
@@ -1155,7 +1161,7 @@ namespace AiQ_GUI
}
catch (Exception ex)
{
AddToActionsList("Failed to set all cameras to 211. Reason: " + ex.Message); // In case non AiQ's get caught up
AddToActionsList("Failed to set all cameras to 211. Reason: " + ex.Message, Level.ERROR); // In case non AiQ's get caught up
}
}
@@ -1182,7 +1188,7 @@ namespace AiQ_GUI
}
catch (Exception ex)
{
AddToActionsList($"Failed to set God mode for camera {SCL.IP}. Reason: {ex.Message}");
AddToActionsList($"Failed to set God mode for camera {SCL.IP}. Reason: {ex.Message}", Level.ERROR);
}
}
@@ -1310,7 +1316,7 @@ namespace AiQ_GUI
}
catch
{
AddToActionsList("Failed to communicate with camera, please check network and try again.");
AddToActionsList("Failed to communicate with camera, please check network and try again.", Level.ERROR);
return;
}
@@ -1327,7 +1333,7 @@ namespace AiQ_GUI
string err = GoogleAPI.UpdateSpreadSheetVaxtor(VaxtorLicResp, Vers.Serial, CamOnTest.Model);
if (err != string.Empty) // If there is an error message, display it
AddToActionsList("Failed to update Vaxtor spreadsheet: " + err);
AddToActionsList("Failed to update Vaxtor spreadsheet: " + err, Level.ERROR);
RhTxBxCode.AppendText("Licencing Success, Key ID: " + VaxtorLicResp.protectionKeyId + Environment.NewLine + "Waiting for files to save");
@@ -1615,7 +1621,7 @@ namespace AiQ_GUI
}
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
AddToActionsList("Failed to set all cameras to 211 and god mode off. Reason: " + ex.Message, Level.ERROR); // In case non AiQ's get caught up
}
if (SCL.CheckBox.ForeColor == Color.Red)
@@ -1631,7 +1637,7 @@ namespace AiQ_GUI
if ((FoundCams.Count == i && FoundCams.Contains("192.168.1.211")) || FoundCams.Count == 1)
{
AddToActionsList("All cameras successfully changed to 211.", Level.LOG);
AddToActionsList("All cameras successfully changed to 211.", Level.Success);
}
else
{
@@ -1713,24 +1719,24 @@ namespace AiQ_GUI
// /api/config-ids - For getting all available config IDs
// Make every log file in the soak log directory into a soak test report PDF
var files = from file in Directory.EnumerateFiles("C:\\ProgramData\\MAV\\AiQ_GUI") select file;
//var files = from file in Directory.EnumerateFiles("C:\\ProgramData\\MAV\\AiQ_GUI") select file;
foreach (var file in files)
{
if (file.Contains("SoakLog"))
{
// File name: SoakLog_{Serial}_{Model}.log
string[] parts = file.Split('_', '.').Select(p => p.Trim()).ToArray();
//foreach (var file in files)
//{
// if (file.Contains("SoakLog"))
// {
// // File name: SoakLog_{Serial}_{Model}.log
// string[] parts = file.Split('_', '.').Select(p => p.Trim()).ToArray();
Camera NewCam = new()
{
Model = parts[3],
Serial = parts[2],
};
// Camera NewCam = new()
// {
// Model = parts[3],
// Serial = parts[2],
// };
PDF.CreateSoakTestReport(NewCam, "SoakTestRig", DateTime.Now, file);
}
}
// PDF.CreateSoakTestReport(NewCam, "SoakTestRig", DateTime.Now, file);
// }
//}
stopWatchTest.Stop();
AddToActionsList("RunTime " + stopWatchTest.Elapsed.ToString(@"hh\:mm\:ss\.ff"), Level.LOG);