void Initialize(ControlSystem cs, uint ipid, string projectName, bool traceEnabled) { this.cs = cs; this.TraceEnabled = traceEnabled; this.TraceName = this.GetType().Name; // set defaults state = new UserInterfaceState(); state.page = Page.Home; state.modalPopup = ModalPopup.None; panel = new Tsw760(ipid, cs); // add callbacks panel.OnlineStatusChange += new OnlineStatusChangeEventHandler(PanelOnlineStatusChangeHandler); panel.SigChange += new SigEventHandler(PanelSigChangeHandler); // register panel if (panel.Register() == eDeviceRegistrationUnRegistrationResponse.Success) { Trace("Initialize() panel registered successfully."); } else { Trace("Initialize() panel failed to register."); return; } // load SmartGraphics objects string sgdPath = String.Format("{0}\\{1}.sgd", Directory.GetApplicationDirectory(), projectName); if (File.Exists(sgdPath)) { if (panel.LoadSmartObjects(sgdPath) > 0) { Trace(String.Format("Initialize() loaded {0} SmartObjects.", panel.SmartObjects.Count)); foreach (KeyValuePair <uint, SmartObject> pair in panel.SmartObjects) { pair.Value.SigChange += new SmartObjectSigChangeEventHandler(PanelSmartObjectHandler); } } else { Trace("Initialize() error, couldn't load any SmartObjects!"); } } else { Trace(String.Format("Initialize() error, SGD file: {0}, does not exist.", sgdPath)); } }
private const uint keypadID = 1; // smart graphic object id public ControlSystem() : base() { Thread.MaxNumberOfUserThreads = 60; if (this.SupportsEthernet) { tsw760 = new Tsw760(0x05, this); string TSW760SgdFilePath = string.Format("{0}\\Passcode.sgd", Directory.GetApplicationDirectory()); if (File.Exists(TSW760SgdFilePath)) { tsw760.LoadSmartObjects(TSW760SgdFilePath); CrestronConsole.PrintLine("[SYSTEM] TSW SGD FOUND!!!"); PasscodeKeypad = tsw760.SmartObjects[keypadID]; } else { CrestronConsole.PrintLine("[SYSTEM] Could not find TSW SGD file. TSW SmartObjects will not work at this time"); } if (tsw760.Register() == eDeviceRegistrationUnRegistrationResponse.Success) { CrestronConsole.PrintLine("[SYSTEM] tsw760 has been registered successfully"); } else { CrestronConsole.PrintLine("[SYSTEM] tsw760 failed registration. Cause: {0}", tsw760.RegistrationFailureReason); } } else { CrestronConsole.PrintLine("[SYSTEM] This processor does not support ethernet, so this program will not run"); } /// set up passcode PIN = new Passcode(); PIN.Init(tsw760, PasscodeKeypad, passcodeChangeButton, passcodeTextField); PIN.debug_enable = true; PIN.SetCallback(PINCodeEntered); }