// Monitor a random relay on the server control system. // This monitor can only subscribe to one relay at a time public void Monitor(string serverHostname) { try { if (monitor != null) { CrestronConsole.ConsoleCommandResponse("Already subscribed: " + monitor + "\r\n"); return; } string myHostname = ""; // adapterID 0 usually represents the outbound LAN port myHostname = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_HOSTNAME, 0).ToLower(); monitor = new RelayMonitor(myHostname); monitor.Subscribe(serverHostname); CrestronConsole.ConsoleCommandResponse("Now monitoring: " + monitor); } catch (Exception e) { if (monitor != null) { monitor.Dispose(); monitor = null; } CrestronConsole.ConsoleCommandResponse("Could not start client: {0}\r\n", e.Message); } finally { } }
public void Stop(string args) { if (monitor == null) { CrestronConsole.ConsoleCommandResponse("Monitor already stopped\r\n"); return; } monitor.Unsubscribe(); // sends a DELETE request to the server so it no longer will notify the monitor's listener URL monitor.Dispose(); monitor = null; CrestronConsole.ConsoleCommandResponse("Monitor has been stopped\r\n"); }
/// <summary> /// Event Handler for system events, Disk Inserted/Ejected, and Reboot /// Use this event to clean up when someone types in reboot, or when your SD /USB /// removable media is ejected / re-inserted. /// </summary> /// <param name="systemEventType"></param> void ControlSystem_ControllerSystemEventHandler(eSystemEventType systemEventType) { switch (systemEventType) { case (eSystemEventType.Rebooting): //The system is rebooting. //Very limited time to preform clean up and save any settings to disk. if (monitor != null) { monitor.Dispose(); monitor = null; } break; } }
/// <summary> /// Event Handler for Programmatic events: Stop, Pause, Resume. /// Use this event to clean up when a program is stopping, pausing, and resuming. /// This event only applies to this SIMPL#Pro program, it doesn't receive events /// for other programs stopping /// </summary> /// <param name="programStatusEventType"></param> void ControlSystem_ControllerProgramEventHandler(eProgramStatusEventType programStatusEventType) { switch (programStatusEventType) { case (eProgramStatusEventType.Stopping): //The program has been stopped. //Close all threads. //Shutdown all Client/Servers in the system. //General cleanup. //Unsubscribe to all System Monitor events if (monitor != null) { monitor.Dispose(); monitor = null; } break; } }
public DefaultHandler(RelayMonitor parent) { this.parent = parent; }