This article will describe how to shutdown the display when the Ignition Input is turned off as of version 4.x.
- In OpenPV from the Extensions tab add the IO Service Extension
- In your code base add the nuget package Ahsoka.Extensions.IO.
- Add the following code
using Ahsoka.Services.IO; //added to support ignition input
//In Main add the following
IOServiceClient IOClient = new();
// Listen to the IO Service Client for Ignition Input Messages
Dispatcher.Default.RegisterCallback<IOServiceClient.AhsokaNotificationArgs>(HandleIngition, IOClient);
//Add the following function
private static void HandleIngition(object sender, IOServiceClient.AhsokaNotificationArgs args)
{
if (args is IOServiceClient.AhsokaNotificationArgs e)
{
//When the ignition input state changes Ahsoka will send a event message
if (e.TransportId == IOMessageTypes.Ids.IgnitionOnNotification)
{
AhsokaLogging.LogMessage(AhsokaVerbosity.Medium, $"Ignition On");
}
else if (e.TransportId == IOMessageTypes.Ids.IgnitionOffNotification)
{
AhsokaLogging.LogMessage(AhsokaVerbosity.Medium, $"Ignition Off");
//Send a system message to Reboot which will shutdown power but since the ign pin is
//off it wont reboot and will stay off.
SystemServiceClient systemClient = new();
systemClient.RequestServiceShutdown(ShutdownTypes.Reboot);
}
}
}
Comments
0 comments
Please sign in to leave a comment.