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
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|