fix: deactivate ComPortController on program stopping event

This commit is contained in:
copilot-swe-agent[bot] 2026-06-09 17:06:54 +00:00 committed by GitHub
parent 148dead020
commit a2388acf64
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -50,6 +50,7 @@ namespace PepperDash.Essentials.Core
ComPort.ComPortSpec spec, EssentialsControlPropertiesConfig config) : base(key)
{
StreamDebugging = new CommunicationStreamDebugging(key);
CrestronEnvironment.ProgramStatusEventHandler += CrestronEnvironment_ProgramStatusEventHandler;
Spec = spec;
@ -70,6 +71,8 @@ namespace PepperDash.Essentials.Core
public ComPortController(string key, ComPort port, ComPort.ComPortSpec spec)
: base(key)
{
CrestronEnvironment.ProgramStatusEventHandler += CrestronEnvironment_ProgramStatusEventHandler;
if (port == null)
{
Debug.LogMessage(LogEventLevel.Information, this, "ERROR: Invalid com port, continuing but comms will not function");
@ -142,6 +145,12 @@ namespace PepperDash.Essentials.Core
if (!eventSubscribed) Debug.LogMessage(LogEventLevel.Warning, this, "Received data but no handler is registered");
}
void CrestronEnvironment_ProgramStatusEventHandler(eProgramStatusEventType programEventType)
{
if (programEventType == eProgramStatusEventType.Stopping)
Deactivate();
}
/// <summary>
/// Deactivate method
/// </summary>