/// <summary> /// Constructor of the Control System Class. Make sure the constructor always exists. /// If it doesn't exit, the code will not run on your 3-Series processor. /// </summary> public ControlSystem() : base() { // subscribe to control system events CrestronEnvironment.SystemEventHandler += new SystemEventHandler(CrestronEnvironment_SystemEventHandler); CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(CrestronEnvironment_ProgramStatusEventHandler); CrestronEnvironment.EthernetEventHandler += new EthernetEventHandler(CrestronEnvironment_EthernetEventHandler); // Set the number of threads which you want to use in your program - At this point the threads cannot be created but we should // define the max number of threads which we will use in the system. // the right number depends on your project; do not make this number unnecessarily large Thread.MaxNumberOfUserThreads = 20; // ensure this processor has ethernet if (this.SupportsEthernet) { // create new dmtx401c object and subscribe to its events dmTx = new DmTx401C(0x03, this); // IPID for the dmtx is 3 dmTx.BaseEvent += dmTx_BaseEvent; dmTx.HdmiInput.InputStreamChange += HdmiInput_InputStreamChange; dmTx.HdmiInput.VideoAttributes.AttributeChange += Hdmi_AttributeChange; dmTx.VgaInput.InputStreamChange += VgaInput_InputStreamChange; dmTx.VgaInput.VideoAttributes.AttributeChange += Vga_AttributeChange; dmTx.DisplayPortInput.InputStreamChange += DisplayPortInput_InputStreamChange; dmTx.DisplayPortInput.VideoAttributes.AttributeChange += DisplayPort_AttributeChange; dmTx.OnlineStatusChange += Device_OnlineStatusChange; // create new tt100 object using the dmtx401 constructor, and subscribe to its events connectIt = new Tt1xx(dmTx); connectIt.ButtonStateChange += connectIt_ButtonStateChange; connectIt.OnlineStatusChange += Device_OnlineStatusChange; // register the dmtx to this program, the tt100 will be registered as part of the dmtx if (dmTx.Register() == eDeviceRegistrationUnRegistrationResponse.Success) ErrorLog.Notice(">>> The DM-TX-401-c has been registered successfully"); else ErrorLog.Error(">>> The DM-TX-401-C was not registered: {0}", dmTx.RegistrationFailureReason); // create new dmrmc100c object and subscribe to its events dmRmc = new DmRmcScalerC(0x04, this); // IPID for the dmtx is 4 dmRmc.DmInput.InputStreamChange += DmRmc_InputStreamChange; dmRmc.ComPorts[1].SerialDataReceived += DmRmc_SerialDataReceived; dmRmc.OnlineStatusChange += Device_OnlineStatusChange; dmRmc.Scaler.OutputChange += Scaler_OutputChange; // register device with the control system if (dmRmc.Register() == eDeviceRegistrationUnRegistrationResponse.Success) ErrorLog.Notice(">>> The DM-RMC-Scaler-C has been registered successfully"); else ErrorLog.Error(">>> The DM-RMC-Scaler-C was not registered: {0}", dmRmc.RegistrationFailureReason); // create a new xpanel room object and subscribe to its events xPanelUi = new XpanelForSmartGraphics(0x0b, this); xPanelUi.SigChange += xPanelUi_SigChange; xPanelUi.OnlineStatusChange += Device_OnlineStatusChange; // pathway to the SGD file for this ui project string xPanelSgdFilePath = string.Format("{0}\\Config.Standalone.sgd", Directory.GetApplicationDirectory()); // make sure file exists in the application directory if (File.Exists(xPanelSgdFilePath)) { // load the SGD file for this ui project xPanelUi.LoadSmartObjects(xPanelSgdFilePath); // create reference for the various smart objects in the ui project dmRmcOutputResList = xPanelUi.SmartObjects[(uint)eSmartObjectIds.DmRmcOutputResList]; dmRmcAspectModeList = xPanelUi.SmartObjects[(uint)eSmartObjectIds.DmRmcAspectList]; dmRmcUnderscanList = xPanelUi.SmartObjects[(uint)eSmartObjectIds.DmRmcUnderscanList]; // subscribe to the smart object sig events dmRmcOutputResList.SigChange += dmRmcOutputResList_SigChange; dmRmcAspectModeList.SigChange += dmRmcAspectModeList_SigChange; dmRmcUnderscanList.SigChange += dmRmcUnderscanList_SigChange; } else { ErrorLog.Error(">>> Could not find xpanel SGD file. SmartObjects will not work at this time"); } // register device with the control system if (xPanelUi.Register() == eDeviceRegistrationUnRegistrationResponse.Success) ErrorLog.Notice(">>> xPanel has been registered successfully"); else ErrorLog.Error(">>> xPanel was not registered: {0}", xPanelUi.RegistrationFailureReason); } else { ErrorLog.Error(">>> This processor does not support ethernet, so this program will not run"); } // create a new timer object to track system inactivity or unplugged cables ShutdownTimer = new CTimer(ShutownTimerCallback, Timeout.Infinite, Timeout.Infinite); }
private void CreatePanel(uint ipId, string sgdFilename) { _panel = new XpanelForSmartGraphics(ipId, this); _panel.LoadSmartObjects(sgdFilename); _panel.SmartObjects[(uint)PanelSmartObjects.DPad].SigChange += new SmartObjectSigChangeEventHandler(VideoServerDpadChange); _panel.SigChange += new SigEventHandler(PanelSigChange); _panel.Register(); }
private void CreatePanel(uint ipId, string sgdFilename) { _panel = new XpanelForSmartGraphics(ipId, this); _panel.LoadSmartObjects(sgdFilename); _panel.SmartObjects[(uint)PanelSmartObjects.DisplayInputList].SigChange += new SmartObjectSigChangeEventHandler(DisplayInputListChange); _panel.SigChange += new SigEventHandler(PanelSigChange); _panel.Register(); }
/// <summary> /// Constructor of the Control System Class. Make sure the constructor always exists. /// If it doesn't exit, the code will not run on your 3-Series processor. /// </summary> public ControlSystem() : base() { // Set the number of threads which you want to use in your program - At this point the threads cannot be created but we should // define the max number of threads which we will use in the system. // the right number depends on your project; do not make this number unnecessarily large Thread.MaxNumberOfUserThreads = 20; if (this.SupportsEthernet) { myPanel = new XpanelForSmartGraphics(0x3, this); if (myPanel.Register() != eDeviceRegistrationUnRegistrationResponse.Success) { ErrorLog.Error("Error Registering Xpanel"); } myPanel.LoadSmartObjects(@"\NVRAM\Xpnl.sgd"); foreach (KeyValuePair <uint, SmartObject> mySmartObject in myPanel.SmartObjects) { mySmartObject.Value.SigChange += new SmartObjectSigChangeEventHandler(Value_SigChange); } } }
/// <summary> /// InitializeSystem - this method gets called after the constructor /// has finished. /// /// Use InitializeSystem to: /// * Start threads /// * Configure ports, such as serial and verisports /// * Start and initialize socket connections /// Send initial device configurations /// /// Please be aware that InitializeSystem needs to exit quickly also; /// if it doesn't exit in time, the SIMPL#Pro program will exit. /// </summary> public override void InitializeSystem() { try { ui = new UI(); ui.DigitalChangeEvent += new UI.DigitalChangeEventHandler(ui_DigitalChangeEvent); ui.AnalogChangeEvent += new UI.AnalogChangeEventHandler(ui_AnalogChangeEvent); ui.SerialChangeEvent += new UI.SerialChangeEventHandler(ui_SerialChangeEvent); ui.SmartObjectChangeEvent += new UI.SmartObjectEventHandler(ui_SmartObjectChangeEvent); xpanel = new XpanelForSmartGraphics(0x03, this); xpanel.SigChange += new SigEventHandler(ui.xpanel_SigChange); xpanel.LoadSmartObjects(@"\USER\Pincode.sgd"); foreach (KeyValuePair <uint, SmartObject> kvp in xpanel.SmartObjects) { kvp.Value.SigChange += new SmartObjectSigChangeEventHandler(ui.SmartObject_SigChange); } xpanel.Register(); //create Pincode object pincode = new Pincode(xpanel, 1, "1234"); pincode.EnableBackdoorPassword("1988"); pincode.SetPinLimit(4); pincode.EnableStarText(); pincode.PasswordMiscOneDelegate = () => pincode.ClearText(); pincode.PasswordMiscTwoDelegate = () => pincode.ValidatePINEntry(); pincode.PasswordCorrectDelegate = () => xpanel.StringInput[1].StringValue = "Password Correct"; pincode.PasswordIncorrectDelegate = () => xpanel.StringInput[1].StringValue = "Password Incorrect"; } catch (Exception e) { ErrorLog.Error(">>> Error in InitializeSystem: {0}", e.Message); } }
/// <summary> /// ControlSystem Constructor. Starting point for the SIMPL#Pro program. /// Use the constructor to: /// * Initialize the maximum number of threads (max = 400) /// * Register devices /// * Register event handlers /// * Add Console Commands /// /// Please be aware that the constructor needs to exit quickly; if it doesn't /// exit in time, the SIMPL#Pro program will exit. /// /// You cannot send / receive data in the constructor /// </summary> public ControlSystem() : base() { try { Thread.MaxNumberOfUserThreads = 20; // * Register devices xPanel = new XpanelForSmartGraphics((uint)eIpId.xPanel, this); xPanel.Description = xPanelDescription; // Add SGD to tswPanel string xPanelSgdFilePath = Directory.GetApplicationDirectory() + Path.DirectorySeparatorChar + xPanelSgdFileName; // make sure file exists in the application directory if (File.Exists(xPanelSgdFilePath)) { // load the SGD file for this ui project try { xPanel.LoadSmartObjects(xPanelSgdFilePath); } catch (Exception) { ErrorLog.Error(">>> {0} (IPID 0x{1:X2}) Could not find {0} SGD file. SmartObjects will not work at this time", xPanel.Name, (uint)eIpId.xPanel, xPanelSgdFilePath); } ErrorLog.Notice(">>> {0} (IPID 0x{1:X2}) SmartObjects loaded from {2}", xPanel.Name, (uint)eIpId.xPanel, xPanelSgdFileName); } else { ErrorLog.Error(">>> {0} (IPID 0x{1:X2}) Could not find {2} SGD file. SmartObjects will not work at this time", xPanel.Name, (uint)eIpId.xPanel, xPanelSgdFilePath); } if (xPanel.Register() == eDeviceRegistrationUnRegistrationResponse.Success) { ErrorLog.Notice(">>> {0} (IPID 0x{1:X2}) has been registered successfully", xPanel.Name, (uint)eIpId.xPanel); } else { ErrorLog.Error(">>> {0} (IPID 0x{1:X2}) was not registered: {2}", xPanel.Name, (uint)eIpId.xPanel, xPanel.RegistrationFailureReason); } xPanel.UserSpecifiedObject = new AuthenticatedSubPageManager( Authenticate, xPanel, new PinLockSubPage(pinLockSubPageParameters), 60000, new List <SubPage>() { } ); // * Register event handlers //Subscribe to the controller events (System, Program, and Ethernet) CrestronEnvironment.SystemEventHandler += new SystemEventHandler(ControlSystem_ControllerSystemEventHandler); CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(ControlSystem_ControllerProgramEventHandler); CrestronEnvironment.EthernetEventHandler += new EthernetEventHandler(ControlSystem_ControllerEthernetEventHandler); xPanel.SigChange += new SigEventHandler(EventHandlers.ActionEventHandler); xPanel.SmartObjects[2].SigChange += new SmartObjectSigChangeEventHandler(EventHandlers.ActionEventHandler); xPanel.BooleanOutput[100].UserObject = new Action <bool>(x => { if (!x) { ((AuthenticatedSubPageManager)xPanel.UserSpecifiedObject).Lock(); } }); // local tests xPanel.SigChange += new SigEventHandler(panel_SigChange); xPanel.BaseEvent += new BaseEventHandler(xPanel_BaseEvent); foreach (var kv in xPanel.SmartObjects) { kv.Value.SigChange += new SmartObjectSigChangeEventHandler(so_SigChange); } ((AuthenticatedSubPageManager)xPanel.UserSpecifiedObject).Authenticated += new EventHandler <AuthenticatedSubPageManager.AuthenticatedEventArgs>(ControlSystem_Authenticated); // Panels Smart Objects SmartObjectReferenceListHelper smartObjectReferenceListHelper = new SmartObjectReferenceListHelper(xPanel.SmartObjects[smartObjectReferenceListParameters.Id], smartObjectReferenceListParameters); xPanel.SmartObjects[smartObjectReferenceListParameters.Id].SigChange += new SmartObjectSigChangeEventHandler(EventHandlers.ActionEventHandler); List <int> range = new List <int>() { 1, 2 }; smartObjectReferenceListHelper.NumberOfItems = (ushort)range.Count; foreach (uint itemIndex in range) { uint itemIndexFix = itemIndex; SmartObjectReferenceListItem item = smartObjectReferenceListHelper.Items[itemIndex]; smartObjectReferenceListHelper.Items[itemIndex].BooleanOutput[1].UserObject = new Action <bool>(x => { if (x) { CrestronConsole.PrintLine("Item: {0}", item.Id); item.UShortInput[1].UShortValue = (ushort)(item.UShortInput[1].UShortValue + 1); } }); } xPanel.SmartObjects[smartObjectDynamicListHelperParameters.Id].SigChange += new SmartObjectSigChangeEventHandler(EventHandlers.ActionEventHandler); CrestronConsole.AddNewConsoleCommand(ConsoleCommandTest, "test", "Test plug", ConsoleAccessLevelEnum.AccessOperator); ActionsManager.RegisterAction(Action1, "Action 1", "Action1 description"); ActionsManager.RegisterAction(Action2, "Action 2", "Action2 description"); ActionsManager.RegisterAction(Action2, "Action 2", "Action2 description", "special Action 2", "special Action2 params"); } catch (Exception e) { ErrorLog.Error("Error in the constructor: {0}\r\n{1}", e.Message, e.StackTrace); } }
// Entry point public ControlSystem() : base() { CrestronConsole.PrintLine("ssCertMain started ..."); GV.MyControlSystem = this; // Allows access to ControlSystem class outside class definition try { Thread.MaxNumberOfUserThreads = 20; CrestronEnvironment.SystemEventHandler += new SystemEventHandler(ControlSystem_ControllerSystemEventHandler); CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(ControlSystem_ControllerProgramEventHandler); CrestronEnvironment.EthernetEventHandler += new EthernetEventHandler(ControlSystem_ControllerEthernetEventHandler); // Injects a new console command for use in text console // I am thinking this may be handy to help debug - e.g. fire events to test (like doorbell ringing )... CrestronConsole.AddNewConsoleCommand(UpperCase, "ToUpper", "Converts string to UPPER case", ConsoleAccessLevelEnum.AccessOperator); CrestronConsole.AddNewConsoleCommand(PrintFullAssembly, "printass", "Loads and Prints Assembly", ConsoleAccessLevelEnum.AccessOperator); } catch (Exception e) { ErrorLog.Error("ControlSystem() - Error in constructor: {0}", e.Message); } #region Keypad if (this.SupportsCresnet) { // NOTE TO PAUL: Move this to Helper Class - loop through all keypads an register them // That might be a good place to name them and give them default stuff - like default room etc. myKeypad = new C2nCbdP(0x25, this); myKeypad.ButtonStateChange += new ButtonEventHandler(myKeypad_ButtonStateChange); if (myKeypad.Register() != eDeviceRegistrationUnRegistrationResponse.Success) ErrorLog.Error("myKeypad {0} failed registration. Cause: {1}", 0x25, myKeypad.RegistrationFailureReason); // List all the cresnet devices - note: Query might not work for duplicate devices PllHelperClass.DisplayCresnetDevices(); } #endregion #region Xpanel if (this.SupportsEthernet) { myXpanel = new XpanelForSmartGraphics(0x03, this); myXpanel.SigChange += new SigEventHandler(myXpanel_SigChange); if (myXpanel.Register() != eDeviceRegistrationUnRegistrationResponse.Success) ErrorLog.Error("myXpanel with SmartGraphics {0} failed registration. Cause: {1}", 0x03, myKeypad.RegistrationFailureReason); else { myXpanel.LoadSmartObjects(@"\NVRAM\Xpnl.sgd"); CrestronConsole.PrintLine("sgd"); foreach (KeyValuePair<uint, SmartObject>mySmartObject in myXpanel.SmartObjects) { mySmartObject.Value.SigChange += new SmartObjectSigChangeEventHandler(SmartObjectValue_SigChange); } // Typically you would create the group in init and then add items throughout the program // NOTE to PAUL: Create Group here and when setting TP Defaults create groups mySigGroup = CreateSigGroup(1, eSigType.String); mySigGroup.Add(myXpanel.StringInput[1]); mySigGroup.Add(myXpanel.StringInput[2]); } } #endregion }
// Entry point public ControlSystem() : base() { CrestronConsole.PrintLine("ssCertMain started ..."); GV.MyControlSystem = this; // Allows access to ControlSystem class outside class definition try { Thread.MaxNumberOfUserThreads = 20; CrestronEnvironment.SystemEventHandler += new SystemEventHandler(ControlSystem_ControllerSystemEventHandler); CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(ControlSystem_ControllerProgramEventHandler); CrestronEnvironment.EthernetEventHandler += new EthernetEventHandler(ControlSystem_ControllerEthernetEventHandler); // Injects a new console command for use in text console // I am thinking this may be handy to help debug - e.g. fire events to test (like doorbell ringing )... CrestronConsole.AddNewConsoleCommand(UpperCase, "ToUpper", "Converts string to UPPER case", ConsoleAccessLevelEnum.AccessOperator); CrestronConsole.AddNewConsoleCommand(PrintFullAssembly, "printass", "Loads and Prints Assembly", ConsoleAccessLevelEnum.AccessOperator); } catch (Exception e) { ErrorLog.Error("ControlSystem() - Error in constructor: {0}", e.Message); } #region Keypad if (this.SupportsCresnet) { // NOTE TO PAUL: Move this to Helper Class - loop through all keypads an register them // That might be a good place to name them and give them default stuff - like default room etc. myKeypad = new C2nCbdP(0x25, this); myKeypad.ButtonStateChange += new ButtonEventHandler(myKeypad_ButtonStateChange); if (myKeypad.Register() != eDeviceRegistrationUnRegistrationResponse.Success) { ErrorLog.Error("myKeypad {0} failed registration. Cause: {1}", 0x25, myKeypad.RegistrationFailureReason); } // List all the cresnet devices - note: Query might not work for duplicate devices PllHelperClass.DisplayCresnetDevices(); } #endregion #region Xpanel if (this.SupportsEthernet) { myXpanel = new XpanelForSmartGraphics(0x03, this); myXpanel.SigChange += new SigEventHandler(myXpanel_SigChange); if (myXpanel.Register() != eDeviceRegistrationUnRegistrationResponse.Success) { ErrorLog.Error("myXpanel with SmartGraphics {0} failed registration. Cause: {1}", 0x03, myKeypad.RegistrationFailureReason); } else { myXpanel.LoadSmartObjects(@"\NVRAM\Xpnl.sgd"); CrestronConsole.PrintLine("sgd"); foreach (KeyValuePair <uint, SmartObject> mySmartObject in myXpanel.SmartObjects) { mySmartObject.Value.SigChange += new SmartObjectSigChangeEventHandler(SmartObjectValue_SigChange); } // Typically you would create the group in init and then add items throughout the program // NOTE to PAUL: Create Group here and when setting TP Defaults create groups mySigGroup = CreateSigGroup(1, eSigType.String); mySigGroup.Add(myXpanel.StringInput[1]); mySigGroup.Add(myXpanel.StringInput[2]); } } #endregion }
/// <summary> /// ControlSystem Constructor. Starting point for the SIMPL#Pro program. /// Use the constructor to: /// * Initialize the maximum number of threads (max = 400) /// * Register devices /// * Register event handlers /// * Add Console Commands /// /// Please be aware that the constructor needs to exit quickly; if it doesn't /// exit in time, the SIMPL#Pro program will exit. /// /// You cannot send / receive data in the constructor /// </summary> public ControlSystem() : base() { try { Thread.MaxNumberOfUserThreads = 100; // // Lighting // eisc = new ThreeSeriesTcpIpEthernetIntersystemCommunications((uint)eIpId.EISC, eiscIP, this); eisc.Description = eiscDescription; if (eisc.Register() == eDeviceRegistrationUnRegistrationResponse.Success) { ErrorLog.Notice(">>> The EISC #{0} has been registered successfully", ((uint)eIpId.EISC).ToString("X2")); } else { ErrorLog.Error(">>> The EISC #{0} was not registered: {1}", ((uint)eIpId.EISC).ToString("X2"), eisc.RegistrationFailureReason); } uiAdminWeb = new XpanelForSmartGraphics((uint)eIpId.AdminUIweb, this); uiAdminWeb.Description = uiAdminWebDescription; //uiAdminWeb.SigChange += new SigEventHandler(uiAdminWeb_SigChange); // Add SGD to UI string uiAdminWebSgdFilePath = string.Format("{0}\\{1}", Directory.GetApplicationDirectory(), uiAdminWebSGD); if (File.Exists(uiAdminWebSgdFilePath)) { // load the SGD file for this ui project uiAdminWeb.LoadSmartObjects(uiAdminWebSgdFilePath); ErrorLog.Notice(">>> The {0} #{1} loaded SmartObjects SGD ({2}) loaded", uiAdminWeb.Description, ((uint)eIpId.AdminUIweb).ToString("X2"), uiAdminWebSGD); } else { ErrorLog.Error(">>> The {0} #{1} could not find {0} SGD file. SmartObjects will not work at this time", uiAdminWeb.Description, ((uint)eIpId.AdminUIweb).ToString("X2"), uiAdminWebSgdFilePath); } if (uiAdminWeb.Register() == eDeviceRegistrationUnRegistrationResponse.Success) { ErrorLog.Notice(">>> The {0} #{1} has been registered successfully", uiAdminWeb.Description, ((uint)eIpId.AdminUIweb).ToString("X2")); } else { ErrorLog.Error(">>> The {0} #{1} was not registered: {2}", uiAdminWeb.Description, ((uint)eIpId.AdminUIweb).ToString("X2"), uiAdminWeb.RegistrationFailureReason); } lightsControlUI = new LightsControlUI(new List <BasicTriListWithSmartObject>() { uiAdminWeb }); //Subscribe to the controller events (System, Program, and Ethernet) CrestronEnvironment.SystemEventHandler += new SystemEventHandler(ControlSystem_ControllerSystemEventHandler); CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(ControlSystem_ControllerProgramEventHandler); CrestronEnvironment.EthernetEventHandler += new EthernetEventHandler(ControlSystem_ControllerEthernetEventHandler); } catch (Exception e) { ErrorLog.Error("Error in the constructor: {0}", e.Message); } }
public ControlSystem() : base() { try { Thread.MaxNumberOfUserThreads = 20; //Hello World Crestron Console CrestronConsole.AddNewConsoleCommand(HelloPrinting, "HelloWorld", "Prints Hello & the text that follows", ConsoleAccessLevelEnum.AccessOperator); //Subscribe to the controller events (System, Program, and Ethernet) CrestronEnvironment.SystemEventHandler += new SystemEventHandler(ControlSystem_ControllerSystemEventHandler); CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(ControlSystem_ControllerProgramEventHandler); CrestronEnvironment.EthernetEventHandler += new EthernetEventHandler(ControlSystem_ControllerEthernetEventHandler); CrestronConsole.PrintLine("DefaultConstructor Complete"); //Hello World #region Keypad if (this.SupportsCresnet) //Make sure the system has CresNet { myKeypad = new C2nCbdP(0x25, this); myKeypad.ButtonStateChange += new ButtonEventHandler(myKeypad_ButtonStateChange); if (myKeypad.NumberOfVersiPorts > 0) //VersiPort addtion { for (uint i = 1; i < 2; i++) { myKeypad.VersiPorts[i].SetVersiportConfiguration(eVersiportConfiguration.DigitalInput); myKeypad.VersiPorts[i].VersiportChange += new VersiportEventHandler(ControlSystem_VersiportChange); } } if (myKeypad.Register() != eDeviceRegistrationUnRegistrationResponse.Success) // Hello World Keypad { ErrorLog.Error("Error Registering Keypad on ID 0x25: {0}", myKeypad.RegistrationFailureReason); } else { myKeypad.Button[1].Name = eButtonName.Up; myKeypad.Button[2].Name = eButtonName.Down; } } #endregion #region KeypadWithQuery //Define Keypad with Device Query if (this.SupportsCresnet) { var QueryResponse = CrestronCresnetHelper.Query(); if (QueryResponse == CrestronCresnetHelper.eCresnetDiscoveryReturnValues.Success) { //foreach (CrestronCresnetHelper.DiscoveredDeviceElement Item in CrestronCresnetHelper.DiscoveredElementsList) //Gets a little long so we do the var in instead and it works it out foreach (var Item in CrestronCresnetHelper.DiscoveredElementsList) { if (Item.DeviceModel.ToUpper().Contains("C2N-CBD")) { if (myKeypad == null) //Check to make sure we have not done created it already. { myKeypad = new C2nCbdP(Item.CresnetId, this); myKeypad.ButtonStateChange += new ButtonEventHandler(myKeypad_ButtonStateChange); if (myKeypad.Register() != eDeviceRegistrationUnRegistrationResponse.Success) { ErrorLog.Error("Error Registering Keypad: {0}", myKeypad.RegistrationFailureReason); myKeypad = null; } } } } } } #endregion #region IR if (this.SupportsIROut) { if (ControllerIROutputSlot.Register() != eDeviceRegistrationUnRegistrationResponse.Success) { ErrorLog.Error("Error Registering IR Slot: {0}", ControllerIROutputSlot.DeviceRegistrationFailureReason); } else { myPort = IROutputPorts[1]; myPort.LoadIRDriver(@"\NVRAM\AppleTV.ir"); foreach (string s in myPort.AvailableStandardIRCmds()) { CrestronConsole.PrintLine("AppleTV Std: {0}", s); } foreach (string s in myPort.AvailableIRCmds()) { CrestronConsole.PrintLine("AppleTV Std: {0}", s); } } } #endregion #region VersiPort if (this.SupportsVersiport) { for (uint i = 1; i <= 2; i++) { if (this.VersiPorts[i].Register() != eDeviceRegistrationUnRegistrationResponse.Success) { ErrorLog.Error("Error Registering Versiport 1: {0}", this.VersiPorts[i].DeviceRegistrationFailureReason); } else { this.VersiPorts[i].SetVersiportConfiguration(eVersiportConfiguration.DigitalOutput); } } } #endregion #region ComPorts if (this.SupportsComPort) { for (uint i = 1; i <= 2; i++) { this.ComPorts[i].SerialDataReceived += new ComPortDataReceivedEvent(ControlSystem_SerialDataReceived); if (this.ComPorts[i].Register() != eDeviceRegistrationUnRegistrationResponse.Success) { ErrorLog.Error("Error Registering ComPort{0}: {1}", i, ComPorts[i].DeviceRegistrationFailureReason); } else { this.ComPorts[i].SetComPortSpec(ComPort.eComBaudRates.ComspecBaudRate19200, ComPort.eComDataBits.ComspecDataBits8, ComPort.eComParityType.ComspecParityNone, ComPort.eComStopBits.ComspecStopBits1, ComPort.eComProtocolType.ComspecProtocolRS232, ComPort.eComHardwareHandshakeType.ComspecHardwareHandshakeNone, ComPort.eComSoftwareHandshakeType.ComspecSoftwareHandshakeNone, false); } } } #endregion1 #region Touchpanel if (this.SupportsEthernet) { myPanel = new XpanelForSmartGraphics(0x03, this); myPanel.SigChange += new SigEventHandler(myPanel_SigChange); if (myPanel.Register() != eDeviceRegistrationUnRegistrationResponse.Success) { ErrorLog.Error("Error in Registering xPanel: {0}", myPanel.RegistrationFailureReason); } else { myPanel.LoadSmartObjects(@"\NVRAM\xpnl.sgd"); CrestronConsole.PrintLine("Loaded SmartObjects: {0}", myPanel.SmartObjects.Count); foreach (KeyValuePair <uint, SmartObject> mySmartObject in myPanel.SmartObjects) { mySmartObject.Value.SigChange += new SmartObjectSigChangeEventHandler(Value_SigChange); } MySigGroup = CreateSigGroup(1, eSigType.String); MySigGroup.Add(myPanel.StringInput[1]); MySigGroup.Add(myPanel.StringInput[2]); } } #endregion #region EISC if (this.SupportsEthernet) { myEISC = new EthernetIntersystemCommunications(0x04, "127.0.0.2", this); myEISC.SigChange += new SigEventHandler(myEISC_SigChange); if (myEISC.Register() != eDeviceRegistrationUnRegistrationResponse.Success) { ErrorLog.Error("Error in Registering EISC: {0}", myEISC.RegistrationFailureReason); } else { myEISC.SigChange -= myEISC_SigChange; } } #endregion } catch (Exception e) { ErrorLog.Error("Error in the constructor: {0}", e.Message); } }