refactor(gui,api,logging): UI layout tweaks, cleanup, and improved diagnostics
- CbBxCamType now spans the full width of CbBxCameraModel - BtnTest_Click moved to the bottom of AiQ_GUI.cs for easier testing/navigation - Unused using directives removed across files - Login credentials factored out and reused in MobileAPI.cs - VLC.cs Capture function reviewed and superseded by TakeSnapshot - InsertCamTab implementation updated to avoid use of `var` - Misleading '// Non-ONVIF cameras' comment corrected - Added Level.Debug logging, accessible only to developers, for detailed diagnostics
This commit is contained in:
83
MobileTests/MobileTests.cs
Normal file
83
MobileTests/MobileTests.cs
Normal file
@@ -0,0 +1,83 @@
|
||||
using LibVLCSharp.WinForms;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AiQ_GUI.Mobile_Tests
|
||||
{
|
||||
public static class MobileTests
|
||||
{
|
||||
public static async Task RunPreTestAsync()
|
||||
{
|
||||
|
||||
await MobileAPI.CheckFirmwareAsync();// Check firmware version
|
||||
|
||||
VLC.Play(MainForm.Instance.VidView);// Test Live Video streaming
|
||||
await Task.Delay(5000);
|
||||
|
||||
VLC.TakeSnapshot(MainForm.Instance.VidView);
|
||||
|
||||
if (!VLC.IsPLaying(MainForm.Instance.VidView))// Check Live Video streaming
|
||||
{
|
||||
MainForm.Instance.AddToActionsList("Live Video streaming test failed: Video is not playing.", Level.ERROR);
|
||||
MainForm.Instance.AddLabelToPanel("Live Video = Not Playing", true);
|
||||
}
|
||||
else
|
||||
{
|
||||
MainForm.Instance.AddLabelToPanel("Live Video = Playing", false);
|
||||
}
|
||||
|
||||
await TestDayNightMode();// Test day/night mode cycling
|
||||
|
||||
double dayLuminance = ImageProcessing.GetMeanLuminance(MainForm.Instance.DayImgPcbx.Image); // Calculates the Luminance
|
||||
double nightLuminance = ImageProcessing.GetMeanLuminance(MainForm.Instance.NightImgPcbx.Image);
|
||||
|
||||
MainForm.Instance.DayImage.Text += $" - Luminance: {dayLuminance}%";
|
||||
MainForm.Instance.NightImage.Text += $" - Luminance: {nightLuminance}%";
|
||||
|
||||
if (dayLuminance > nightLuminance)
|
||||
{
|
||||
MainForm.Instance.AddLabelToPanel("Day/Night Mode = Passed", false);
|
||||
}
|
||||
else
|
||||
{
|
||||
MainForm.Instance.AddToActionsList($"Day/Night mode test failed: Day luminance ({dayLuminance}%) is not greater than night luminance ({nightLuminance}%).", Level.ERROR);
|
||||
MainForm.Instance.AddLabelToPanel("Day/Night Mode = Failed", true);
|
||||
|
||||
}
|
||||
}
|
||||
public static async Task RunFinalTestAsync()
|
||||
{
|
||||
// Placeholder for any final tests if needed in the future
|
||||
//RunPreTestAsync().Wait();
|
||||
//SSH.MobiletxtCheck(MainForm.Instance.CamOnTest.IP);// Verify mobile.txt presence
|
||||
if (SSH.MobiletxtCheck(MainForm.Instance.CamOnTest.IP) == true)
|
||||
{
|
||||
MainForm.Instance.AddLabelToPanel("MobileSetup.sh = True", false);
|
||||
}
|
||||
else
|
||||
{
|
||||
MainForm.Instance.AddToActionsList("MobileSetup.sh test failed: mobile.txt not found on device.", Level.ERROR);
|
||||
MainForm.Instance.AddLabelToPanel("MobileSetup.sh = False", true);
|
||||
}
|
||||
}
|
||||
|
||||
private static async Task TestDayNightMode()
|
||||
{
|
||||
await MobileAPI.SetDayModeAsync();// Set to Day mode
|
||||
|
||||
await Task.Delay(5000);
|
||||
|
||||
VLC.TakeSnapshot(MainForm.Instance.VidView, "Mobile_day_snapshot.png");// Take Day Image Snapshot
|
||||
|
||||
MainForm.Instance.DayImgPcbx.Image = System.Drawing.Image.FromFile(Path.Combine(LDS.MAVPath, "Mobile_day_snapshot.png"));// Display Day mode snapshot
|
||||
|
||||
await MobileAPI.SetNightModeAsync();// Set to Night mode
|
||||
|
||||
await Task.Delay(5000);
|
||||
|
||||
VLC.TakeSnapshot(MainForm.Instance.VidView, "Mobile_night_snapshot.png");// Take Night Image Snapshot
|
||||
MainForm.Instance.NightImgPcbx.Image = System.Drawing.Image.FromFile(Path.Combine(LDS.MAVPath, "Mobile_night_snapshot.png"));// Display Night mode snapshot
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user