• Introduced new Mobile API.cs module • Encapsulates firmware checks, day/night mode switching, and snapshot operations • Methods: CheckFirmwareAsync(), SetDayModeAsync(), SetNightModeAsync() • Improves code maintainability and separates API logic from test execution UI Components • DayImgPcbx PictureBox: Displays day snapshot • NightImgPcbx PictureBox: Displays night snapshot • DayImage Label: Shows day luminance percentage • NightImage Label: Shows night luminance percentage Features Implemented • Luminance-based validation: Uses ImageProcessing.GetMeanLuminance() to quantitatively analyze day and night snapshots • Validation logic: Day luminance must exceed night luminance to pass the test • Real-time luminance display: Appends calculated luminance percentages (0-100%) to day and night image labels • Enhanced error reporting: Logs detailed luminance values when test fails for debugging purposes • Captures day mode snapshot → Analyzes luminance • Captures night mode snapshot → Analyzes luminance • Compares values and updates UI labels with percentages • Result: "Day/Night Mode = Passed" (green) or "Day/Night Mode = Failed" (red) with error details
69 lines
2.7 KiB
C#
69 lines
2.7 KiB
C#
using LibVLCSharp.WinForms;
|
|
using System;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace AiQ_GUI.Mobile_Tests
|
|
{
|
|
public static class MobilePreTest
|
|
{
|
|
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);
|
|
|
|
}
|
|
}
|
|
|
|
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
|
|
}
|
|
}
|
|
}
|
|
|