Dmps |
The DMSystemChange event will trigger with the FrontPanelBrightnessLowEventId.
public class Dmps3System : CrestronControlSystem { private CTimer _brightnessCycleTimer; private Dmps3SystemControl _dmps3SystemControl; //setup the application as needed. public override void InitializeSystem() { base.InitializeSystem(); if (SystemControl == null) { ErrorLog.Error("Application requires to be apart of a DMPS system."); return; } if (SystemControl.SystemControlType == eSystemControlType.Dmps3SystemControl) _dmps3SystemControl = SystemControl as Dmps3SystemControl; else { ErrorLog.Error("Incorrect Dmps3 system for this application."); return; } _brightnessCycleTimer = new CTimer(BrightnessCycleTimerMethod, null, 5000, 5000); DMSystemChange += Dmps3System_DMSystemChange; CrestronEnvironment.ProgramStatusEventHandler += ProgramStatusChange; } //Event handler to catch when the front panel's brightness changes. void Dmps3System_DMSystemChange(Switch device, DMSystemEventArgs args) { switch (args.EventId) { case(DMSystemEventIds.FrontPanelBrightnessHighEventId): if (_dmps3SystemControl.FrontPanelBrightnessHighFeedBack.BoolValue) CrestronConsole.PrintLine("Front panel brightness is set to high."); break; case(DMSystemEventIds.FrontPanelBrightnessLowEventId): if (_dmps3SystemControl.FrontPanelBrightnessLowFeedBack.BoolValue) CrestronConsole.PrintLine("Front panel brightness is set to low."); break; case(DMSystemEventIds.FrontPanelBrightnessMediumEventId): if (_dmps3SystemControl.FrontPanelBrightnessMediumFeedBack.BoolValue) CrestronConsole.PrintLine("Front panel brightness is set to medium."); break; } } //subscription to the program stopping event private void ProgramStatusChange(eProgramStatusEventType programEventType) { if (programEventType == eProgramStatusEventType.Stopping) _brightnessCycleTimer.Dispose(); } private eDmSystemFrontPanelBrightness _nextBrightnessSetting = eDmSystemFrontPanelBrightness.High; //Timer callback method to cycle the front panel's brightness. private void BrightnessCycleTimerMethod(object userSpecificObject) { switch (_nextBrightnessSetting) { case eDmSystemFrontPanelBrightness.Low: case eDmSystemFrontPanelBrightness.Medium: _nextBrightnessSetting++; break; case eDmSystemFrontPanelBrightness.High: _nextBrightnessSetting = eDmSystemFrontPanelBrightness.Low; break; default: throw new ArgumentOutOfRangeException(); } _dmps3SystemControl.FrontPanelBrightness(_nextBrightnessSetting); } }