/// <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); }
public override void InitializeSystem() { try { tp1 = new XpanelForSmartGraphics(0x03, this); tp1.OnlineStatusChange += tp_OnlineChange; tp1.UserSpecifiedObject = new Action <bool>(online => { if (online) { UpdateFeedback(); } }); tp1.SigChange += tp_SigChange; tp1.BooleanOutput[(uint)SystemJoins.PowerToggle].UserObject = new Action <bool>(press => { if (press) { ToggleSystemPower(); } }); tp1.BooleanOutput[(uint)SystemJoins.PowerTransition].UserObject = new Action <bool>(done => { if (done) { UpdatePowerStatusText(); } }); tp1.Register(); } catch (Exception e) { ErrorLog.Error("Error in InitializeSystem: {0}", e.Message); } }
/// Constructor public ControlSystem() : base() { // Set the number of threads which you want to use in your program Thread.MaxNumberOfUserThreads = 20; //Subscribe to the controller events (System, Program, and Etherent) CrestronEnvironment.SystemEventHandler += new SystemEventHandler(ControlSystem_ControllerSystemEventHandler); CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(ControlSystem_ControllerProgramEventHandler); CrestronEnvironment.EthernetEventHandler += new EthernetEventHandler(ControlSystem_ControllerEthernetEventHandler); // Check if device supports Ethernet if (this.SupportsEthernet) { myXpanel = new XpanelForSmartGraphics(0xA5, this); // Register the Xpanel on IPID 0xA5 // Register a single eventhandler for all UIs. myXpanel.SigChange += new SigEventHandler(MySigChangeHandler); // Register the devices for usage, after eventhandler registration, to ensure no data is missed. if (myXpanel.Register() != eDeviceRegistrationUnRegistrationResponse.Success) ErrorLog.Error("MyXpanel failed registration. Cause: {0}", myXpanel.RegistrationFailureReason); } return; }
/// <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; xp = new XpanelForSmartGraphics(0xaa, this); xp.SigChange += new SigEventHandler(xp_SigChange); xp.OnlineStatusChange += new OnlineStatusChangeEventHandler(xp_OnlineStatusChange); xp.Register(); matrix = new DmMd8x8(0x20, this); matrix.DMInputChange += new DMInputEventHandler(matrix_DMInputChange); matrix.DMOutputChange += new DMOutputEventHandler(matrix_DMOutputChange); matrix.OnlineStatusChange += new OnlineStatusChangeEventHandler(matrix_OnlineStatusChange); matrix.Register(); //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); } }
/// Constructor public ControlSystem() : base() { // Set the number of threads which you want to use in your program Thread.MaxNumberOfUserThreads = 20; //Subscribe to the controller events (System, Program, and Etherent) CrestronEnvironment.SystemEventHandler += new SystemEventHandler(ControlSystem_ControllerSystemEventHandler); CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(ControlSystem_ControllerProgramEventHandler); CrestronEnvironment.EthernetEventHandler += new EthernetEventHandler(ControlSystem_ControllerEthernetEventHandler); // Check if device supports Ethernet if (this.SupportsEthernet) { myXpanel = new XpanelForSmartGraphics(0xA5, this); // Register the Xpanel on IPID 0xA5 // Register a single eventhandler for all UIs. myXpanel.SigChange += new SigEventHandler(MySigChangeHandler); // Register the devices for usage, after eventhandler registration, to ensure no data is missed. if (myXpanel.Register() != eDeviceRegistrationUnRegistrationResponse.Success) { ErrorLog.Error("MyXpanel failed registration. Cause: {0}", myXpanel.RegistrationFailureReason); } } return; }
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(); }
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(); }
public Xpanel(uint ipId) { _xpanel = new XpanelForSmartGraphics(ipId, ControlSystem.Instance); if (_xpanel.Register() != eDeviceRegistrationUnRegistrationResponse.Success) { ErrorLog.Error("Xpanel could not register: " + _xpanel.RegistrationFailureReason); } _chargerPage = new XpanelChargerPage(_xpanel); _receiverPage = new XpanelReceiverPage(_xpanel); _tccPage = new XpanelTccPage(_xpanel); }
/// <summary> /// Initializes a new instance of the <see cref="ControlSystem" /> class. /// 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; // Subscribe to the controller events (System, Program, and Ethernet) CrestronEnvironment.SystemEventHandler += new SystemEventHandler(this.ControlSystem_ControllerSystemEventHandler); CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(this.ControlSystem_ControllerProgramEventHandler); CrestronEnvironment.EthernetEventHandler += new EthernetEventHandler(this.ControlSystem_ControllerEthernetEventHandler); if (this.SupportsEthernet) { // TODO: Level 1,2,3. Create new XpanelForSmartGraphics on IPID 03 // You can use the XpanelForSmartGraphics defined on line 40 tp01 = new XpanelForSmartGraphics(0x03, this); // Example. This is how you can subscribe to the SigChange event handler this.tp01.SigChange += Tp01_SigChange; // TODO: Level 1,2,3. Register the OnlineStatusChange event handler yourself here this.tp01.OnlineStatusChange += Xpanel_OnlineStatusChange; // TODO: Level 1,2,3. After all the event handlers are done, register the touchpanel. Try to check for success tp01.Register(); // We have left this in to show how to use Smart Objects // However we are not using them for this exercise // You should only proceed with this if the touchpanel registration was successful! string sgdPath = string.Format(@"{0}/XPanel_Masters2020.sgd", Directory.GetApplicationDirectory()); this.tp01.LoadSmartObjects(sgdPath); ErrorLog.Error(string.Format(LogHeader + "Loaded {0} SmartObjects", this.tp01.SmartObjects.Count)); foreach (KeyValuePair <uint, SmartObject> smartObject in this.tp01.SmartObjects) { smartObject.Value.SigChange += new SmartObjectSigChangeEventHandler(this.Xpanel_SO_SigChange); } } } catch (Exception e) { ErrorLog.Error(string.Format(LogHeader + "Error in the constructor: {0}", e.Message)); } }
/// <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; xp = new XpanelForSmartGraphics(0xaa, this); xp.SigChange += new SigEventHandler(xp_SigChange); xp.Register(); gateway = new CenRfgwEx(0x03, this); lampDimmer = new ClwLdimex1(0x03, gateway); lampDimmer.Description = "Bedroom lamp dimmer"; // this is what shows in the IP table description field lampDimmer.LoadStateChange += new LoadEventHandler(lampDimmer_LoadStateChange); lampDimmer.ParameterRaiseLowerRate = SimplSharpDeviceHelper.SecondsToUshort(4.0f); // ^^^^^^^^^^^^^^^^^^^^ - this is a very helpful class wallDimmer = new ClwDelvexE(0x04, gateway); wallDimmer.DimmerRemoteButtonSettings.ParameterBargraphBehavior = ClwDimExDimmerRemoteButtonSettings.eBargraphBehavior.AlwaysOn; wallDimmer.DimmerRemoteButtonSettings.ParameterBargraphTimeout = SimplSharpDeviceHelper.SecondsToUshort(2.0f); wallDimmer.DimmerRemoteButtonSettings.ParameterRemoteDoubleTapTime = SimplSharpDeviceHelper.SecondsToUshort(0.5f); wallDimmer.DimmerRemoteButtonSettings.ParameterRemoteHoldTime = SimplSharpDeviceHelper.SecondsToUshort(0.5f); wallDimmer.DimmerRemoteButtonSettings.ParameterRemoteWaitForDoubleTap = eRemoteWaitForDoubleTap.No; wallDimmer.DimmerRemoteButtonSettings.ParameterReservedButtonForLocalMode = 0; wallDimmer.DimmerUISettings.ParameterButtonLogic = eButtonLogic.Remote; wallDimmer.DimmerUISettings.ParameterLEDOnLevel = ushort.MaxValue; wallDimmer.DimmerUISettings.ParameterNightLightLevel = SimplSharpDeviceHelper.PercentToUshort(10.0f); wallDimmer.ParameterDimmerDelayedOffTime = SimplSharpDeviceHelper.SecondsToUshort(1.0f); wallDimmer.ParameterOffFadeTime = SimplSharpDeviceHelper.SecondsToUshort(0.5f); wallDimmer.ParameterPresetFadeTime = SimplSharpDeviceHelper.SecondsToUshort(1.0f); wallDimmer.ParameterRaiseLowerRate = SimplSharpDeviceHelper.SecondsToUshort(3.0f); wallDimmer.DimmingLoads[1].ParameterDimmerMinLevel = ushort.MinValue; wallDimmer.DimmingLoads[1].ParameterDimmerMaxLevel = ushort.MaxValue; wallDimmer.ButtonStateChange += new ButtonEventHandler(wallDimmer_ButtonStateChange); wallDimmer.LoadStateChange += new LoadEventHandler(wallDimmer_LoadStateChange); // registering the gateway after adding all of the devices will register everything at once gateway.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); } } }
public ControlSystem() : base() { try { Thread.MaxNumberOfUserThreads = 20; //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); //Subscribe to the touchpanel UserInterface = new XpanelForSmartGraphics(03, this); UserInterface.SigChange += new SigEventHandler(UserInterface_SigChange); UserInterface.Register(); //subscribe to comport comport = ComPorts[1]; comport.Register(); comport.SetComPortSpec(Crestron.SimplSharpPro.ComPort.eComBaudRates.ComspecBaudRate9600, Crestron.SimplSharpPro.ComPort.eComDataBits.ComspecDataBits8, Crestron.SimplSharpPro.ComPort.eComParityType.ComspecParityNone, Crestron.SimplSharpPro.ComPort.eComStopBits.ComspecStopBits1, Crestron.SimplSharpPro.ComPort.eComProtocolType.ComspecProtocolRS232, Crestron.SimplSharpPro.ComPort.eComHardwareHandshakeType.ComspecHardwareHandshakeNone, Crestron.SimplSharpPro.ComPort.eComSoftwareHandshakeType.ComspecSoftwareHandshakeNone, false); //interlock function } catch (Exception e) { ErrorLog.Error("Error in the constructor: {0}", e.Message); } }
/// <summary> /// InitializeSystem - this method gets called after the constructor /// has finished. /// /// Use InitializeSystem to: /// * Start threads /// * Configure ports, such as serial and versiports /// * 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() // Remember HERE we have access to IO, Hardware and Threads { try { // ***** Session 3 // This is ONLY for masters Training session for creating a file to read var myMasters = new Masters2021(); // Instantiate our masters 2021 Class to create data for Session 3 file read // ***** Session 2 //Question: Why did we not have to instantiate the Virtual Console class? VirtualConsole.Start(40000); // Launch the virtual Console on port 40000 you can use telnet or even text console in Toolbox VirtualConsole.AddNewConsoleCommand(TestFunc, "Test", "This should respond with a message"); // ***** Session 1 myClient = new TCPClientHelper("127.0.0.1", 55555); // Creates our client instance myClient.tcpHelperEvent += MyClient_tcpHelperEvent; // Subscribe to its event handler and what method to pass it to myXpanel = new XpanelForSmartGraphics(0x03, this); //myXpanel.Register(); // How do we know we have actually registered the Touchpanel? We should check. if (myXpanel.Register() == eDeviceRegistrationUnRegistrationResponse.Success) // Did we actually get the Device? { myXpanel.SigChange += MyXpanel_SigChange; // Subscribe to our event handler // Any other settings for the device } else { // This will write to the error log why the Touch Panel was unable to be registered. ErrorLog.Error("Unable To register Xpanel at IPID{0:X} for Reason {1}", myXpanel.ID, myXpanel.RegistrationFailureReason); } } catch (Exception e) { ErrorLog.Error("Error in InitializeSystem: {0}", e.Message); } }
/// <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> /// 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() { CrestronConsole.PrintLine("Hello World - Program SIMPL#Pro LinckATLSIMPLSharpPro started ..."); // 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 try { Thread.MaxNumberOfUserThreads = 20; //Subscribe to the controller events (System, Program, and Etherent) CrestronEnvironment.SystemEventHandler += new SystemEventHandler(ControlSystem_ControllerSystemEventHandler); CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(ControlSystem_ControllerProgramEventHandler); CrestronEnvironment.EthernetEventHandler += new EthernetEventHandler(ControlSystem_ControllerEthernetEventHandler); CrestronConsole.AddNewConsoleCommand(UpperCase, "ToUpper", "Replies to strings un Upper case", ConsoleAccessLevelEnum.AccessOperator); var returnVar = CrestronCresnetHelper.Query(); if (returnVar == CrestronCresnetHelper.eCresnetDiscoveryReturnValues.Success) { foreach (var item in CrestronCresnetHelper.DiscoveredElementsList) { CrestronConsole.PrintLine("Found Item: {0}, {1}", item.CresnetId, item.DeviceModel); } } } catch (Exception e) { ErrorLog.Error("Error in constructor: {0}", e.Message); } // Reghister Keypad if (this.SupportsCresnet) { myKeypad = new C2nCbdP(0x25, this); myKeypad.ButtonStateChange += new ButtonEventHandler(myKeypad_ButtonStateChange); if (myKeypad.Register() != eDeviceRegistrationUnRegistrationResponse.Success) ErrorLog.Error("myKeypad failed registration. Cause: {0}", myKeypad.RegistrationFailureReason); } // Register all devices which the program wants to use // Check if device supports Ethernet if (this.SupportsEthernet) { myXpanel = new XpanelForSmartGraphics(0xA5, this); // Register the Xpanel on IPID 0xA5 // Register a single eventhandler for all three UIs. This guarantees that they all operate // the same way. myXpanel.SigChange += new SigEventHandler(MySigChangeHandler); // Register the devices for usage. This should happen after the // eventhandler registration, to ensure no data is missed. if (myXpanel.Register() != eDeviceRegistrationUnRegistrationResponse.Success) ErrorLog.Error("MyXpanel failed registration. Cause: {0}", myXpanel.RegistrationFailureReason); } // Load IR DriverC:\Users\paul\Documents\GitHubWin10\SIMPLSharp\LinckATLSIMPLSharpPro\LinckATLSIMPLSharpPro\Properties\ControlSystem.cfg myIROutputDevice = IROutputPorts[1]; myIROutputDevice.LoadIRDriver(String.Format(@"{0}\IR\Samsung_LNS4051.ir", Directory.GetApplicationDirectory())); return; }
/// <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); } }
// 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> /// 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() { CrestronConsole.PrintLine("Hello World - Program SIMPL#Pro LinckATLSIMPLSharpPro started ..."); // 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 try { Thread.MaxNumberOfUserThreads = 20; //Subscribe to the controller events (System, Program, and Etherent) CrestronEnvironment.SystemEventHandler += new SystemEventHandler(ControlSystem_ControllerSystemEventHandler); CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(ControlSystem_ControllerProgramEventHandler); CrestronEnvironment.EthernetEventHandler += new EthernetEventHandler(ControlSystem_ControllerEthernetEventHandler); CrestronConsole.AddNewConsoleCommand(UpperCase, "ToUpper", "Replies to strings un Upper case", ConsoleAccessLevelEnum.AccessOperator); var returnVar = CrestronCresnetHelper.Query(); if (returnVar == CrestronCresnetHelper.eCresnetDiscoveryReturnValues.Success) { foreach (var item in CrestronCresnetHelper.DiscoveredElementsList) { CrestronConsole.PrintLine("Found Item: {0}, {1}", item.CresnetId, item.DeviceModel); } } } catch (Exception e) { ErrorLog.Error("Error in constructor: {0}", e.Message); } // Reghister Keypad if (this.SupportsCresnet) { myKeypad = new C2nCbdP(0x25, this); myKeypad.ButtonStateChange += new ButtonEventHandler(myKeypad_ButtonStateChange); if (myKeypad.Register() != eDeviceRegistrationUnRegistrationResponse.Success) { ErrorLog.Error("myKeypad failed registration. Cause: {0}", myKeypad.RegistrationFailureReason); } } // Register all devices which the program wants to use // Check if device supports Ethernet if (this.SupportsEthernet) { myXpanel = new XpanelForSmartGraphics(0xA5, this); // Register the Xpanel on IPID 0xA5 // Register a single eventhandler for all three UIs. This guarantees that they all operate // the same way. myXpanel.SigChange += new SigEventHandler(MySigChangeHandler); // Register the devices for usage. This should happen after the // eventhandler registration, to ensure no data is missed. if (myXpanel.Register() != eDeviceRegistrationUnRegistrationResponse.Success) { ErrorLog.Error("MyXpanel failed registration. Cause: {0}", myXpanel.RegistrationFailureReason); } } // Load IR DriverC:\Users\paul\Documents\GitHubWin10\SIMPLSharp\LinckATLSIMPLSharpPro\LinckATLSIMPLSharpPro\Properties\ControlSystem.cfg myIROutputDevice = IROutputPorts[1]; myIROutputDevice.LoadIRDriver(String.Format(@"{0}\IR\Samsung_LNS4051.ir", Directory.GetApplicationDirectory())); return; }
/// <summary> /// Eventhandler for boolean/ushort/string sigs /// </summary> /// <param name="currentDevice">The device that triggered the event</param> /// <param name="args">Contains the SigType, Sig.Number and Sig.Value and more</param> public void Tp01_SigChange(BasicTriList currentDevice, SigEventArgs args) { // You want to check which type of Sig it is first. // This can be either Boolean, UShort or String switch (args.Sig.Type) { // Handle the specific Sig type individually case eSigType.Bool: // args.Sig.Number is your join number for this specific Sig type switch (args.Sig.Number) { // Example only to show to handle digital join 1 // You can remove this if wanted case 1: ErrorLog.Notice("Digital Join 1 was triggered!"); break; // TODO: Level1. Implement digital join 12 to show/hide Hello World string on serial join 11 case 12: ErrorLog.Notice("Digital Join 12 was triggered!"); tp01.StringInput[11].StringValue = args.Sig.BoolValue ? "Hello World!" : string.Empty; break; // TODO: Level2. Implement toggle button logic on digital join 21 case 21: if (args.Sig.BoolValue == true && tp01.BooleanInput[21].BoolValue == false) { tp01.BooleanInput[21].BoolValue = true; tp01.StringInput[21].StringValue = "Hello World"; } else if (args.Sig.BoolValue == true && tp01.BooleanInput[21].BoolValue == true) { tp01.BooleanInput[21].BoolValue = false; tp01.StringInput[21].StringValue = ""; } break; // TODO: Level2. Implement interlock button logic on digital joins 22,23 and 24 // TODO: Level2. Implement interlock clear button on digital join 25 case 22: case 23: case 24: case 25: currentDevice.BooleanInput[22].BoolValue = false; currentDevice.BooleanInput[23].BoolValue = false; currentDevice.BooleanInput[24].BoolValue = false; currentDevice.BooleanInput[args.Sig.Number].BoolValue = true; var interlockStates = new[] { "Interlock 1", "Interlock 2", "Interlock 3", string.Empty }; currentDevice.StringInput[21].StringValue = interlockStates[args.Sig.Number - 22]; break; // TODO: Level3. Implement additional TP registration button on digital join 31 case 31: if (currentDevice.ID == tp01.ID && args.Sig.Type == eSigType.Bool && args.Sig.Number == 31) { if (currentDevice.BooleanOutput[31].BoolValue == true) { if (tp02.Registered == true) { tp02.UnRegister(); } else { tp02.Register(); } } } break; } break; case eSigType.UShort: // TODO: Level3. Implement slider logic for analog join 31. double value = currentDevice.UShortOutput[31].UShortValue * 100 / 65535; currentDevice.UShortInput[31].UShortValue = currentDevice.UShortOutput[31].UShortValue; currentDevice.UShortInput[32].UShortValue = Convert.ToUInt16(value); currentDevice.UShortInput[33].UShortValue = Convert.ToUInt16( value < 1 ? 0 : value < 33 ? 1 : value < 66 ? 2 : 3 ); break; case eSigType.String: break; } }
/// <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 IncludeSampleCode //Subscribe to the controller events (System, Program, and Etherent) CrestronEnvironment.SystemEventHandler += new SystemEventHandler(ControlSystem_ControllerSystemEventHandler); CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(ControlSystem_ControllerProgramEventHandler); CrestronEnvironment.EthernetEventHandler += new EthernetEventHandler(ControlSystem_ControllerEthernetEventHandler); // Register all devices which the program wants to use // Check if device supports Ethernet if (this.SupportsEthernet) { My750 = new Tsw750(0x03, this); // Register the TSW750 on IPID 0x03 My550 = new Tsw550(0x04, this); // Register the TSW550 on IPID 0x04 MyXpanel = new XpanelForSmartGraphics(0x05, this); // Register the Xpanel on IPID 0x05 // Register a single eventhandler for all three UIs. This guarantees that they all operate // the same way. My750.SigChange += new SigEventHandler(MySigChangeHandler); My550.SigChange += new SigEventHandler(MySigChangeHandler); MyXpanel.SigChange += new SigEventHandler(MySigChangeHandler); // Register the devices for usage. This should happen after the // eventhandler registration, to ensure no data is missed. if (My750.Register() != eDeviceRegistrationUnRegistrationResponse.Success) { ErrorLog.Error("My750 failed registration. Cause: {0}", My750.RegistrationFailureReason); } if (My550.Register() != eDeviceRegistrationUnRegistrationResponse.Success) { ErrorLog.Error("My550 failed registration. Cause: {0}", My550.RegistrationFailureReason); } if (MyXpanel.Register() != eDeviceRegistrationUnRegistrationResponse.Success) { ErrorLog.Error("MyXpanel failed registration. Cause: {0}", MyXpanel.RegistrationFailureReason); } } if (this.SupportsComPort) { MyCOMPort = this.ComPorts[1]; MyCOMPort.SerialDataReceived += new ComPortDataReceivedEvent(myComPort_SerialDataReceived); if (MyCOMPort.Register() != eDeviceRegistrationUnRegistrationResponse.Success) { ErrorLog.Error("COM Port couldn't be registered. Cause: {0}", MyCOMPort.DeviceRegistrationFailureReason); } if (MyCOMPort.Registered) { MyCOMPort.SetComPortSpec(ComPort.eComBaudRates.ComspecBaudRate38400, ComPort.eComDataBits.ComspecDataBits8, ComPort.eComParityType.ComspecParityNone, ComPort.eComStopBits.ComspecStopBits1, ComPort.eComProtocolType.ComspecProtocolRS232, ComPort.eComHardwareHandshakeType.ComspecHardwareHandshakeNone, ComPort.eComSoftwareHandshakeType.ComspecSoftwareHandshakeNone, false); } } #endif }
/// <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); } }
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); } }