protected void Setup() { Device = new CrestronApp(0x10, System); Device.ParameterProjectName.Value = "HomeMobile"; Device.SigChange += new SigEventHandler(Phone_SigChange); System.GarageControl.GarageStateChange += new EventHandler <GarageEventArgs>(GarageControl_GarageStateChange); if (Device.Register() != eDeviceRegistrationUnRegistrationResponse.Success) { ErrorLog.Notice("Unable to register your phone: {0}", Device.RegistrationFailureReason); } }
/// <summary> /// Config constructor /// </summary> public EssentialsTouchpanelController(string key, string name, string type, CrestronTouchpanelPropertiesConfig props, uint id) : base(key, name) { AddPostActivationAction(() => { Debug.Console(0, this, "post-activation linking"); type = type.ToLower(); try { if (type == "crestronapp") { var app = new CrestronApp(id, Global.ControlSystem); app.ParameterProjectName.Value = props.ProjectName; Panel = app; } else if (type == "tsw560") { Panel = new Tsw560(id, Global.ControlSystem); } else if (type == "tsw752") { Panel = new Tsw752(id, Global.ControlSystem); } else if (type == "tsw1052") { Panel = new Tsw1052(id, Global.ControlSystem); } else { Debug.Console(0, this, "WARNING: Cannot create TSW controller with type '{0}'", type); return; } } catch (Exception e) { Debug.Console(0, this, "WARNING: Cannot create TSW base class. Panel will not function: {0}", e.Message); return; } // Reserved sigs if (Panel is TswFt5ButtonSystem) { var tsw = Panel as TswFt5ButtonSystem; tsw.ExtenderSystemReservedSigs.Use(); tsw.ExtenderSystemReservedSigs.DeviceExtenderSigChange += ExtenderSystemReservedSigs_DeviceExtenderSigChange; } new CTimer(o => { var regSuccess = Panel.Register(); if (regSuccess != eDeviceRegistrationUnRegistrationResponse.Success) { Debug.Console(0, this, "WARNING: Registration failed. Continuing, but panel may not function: {0}", regSuccess); } // Give up cleanly if SGD is not present. var sgdName = @"\NVRAM\Program" + InitialParametersClass.ApplicationNumber + @"\sgd\" + props.SgdFile; if (!File.Exists(sgdName)) { Debug.Console(0, this, "WARNING: Smart object file '{0}' not present. Exiting TSW load", sgdName); return; } Panel.LoadSmartObjects(sgdName); Panel.SigChange += Tsw_SigChange; var mainDriver = new EssentialsPanelMainInterfaceDriver(Panel, props); // Then the AV driver // spin up different room drivers depending on room type var room = DeviceManager.GetDeviceForKey(props.DefaultRoomKey); if (room is EssentialsHuddleSpaceRoom) { Debug.Console(0, this, "Adding huddle space driver"); var avDriver = new EssentialsHuddlePanelAvFunctionsDriver(mainDriver, props); avDriver.CurrentRoom = room as EssentialsHuddleSpaceRoom; avDriver.DefaultRoomKey = props.DefaultRoomKey; mainDriver.AvDriver = avDriver; LoadAndShowDriver(mainDriver); // This is a little convoluted. if (Panel is TswFt5ButtonSystem) { var tsw = Panel as TswFt5ButtonSystem; // Wire up hard keys tsw.Power.UserObject = new Action <bool>(b => { if (!b) { avDriver.PowerButtonPressed(); } }); //tsw.Home.UserObject = new Action<bool>(b => { if (!b) HomePressed(); }); tsw.Up.UserObject = new Action <bool>(avDriver.VolumeUpPress); tsw.Down.UserObject = new Action <bool>(avDriver.VolumeDownPress); tsw.ButtonStateChange += new ButtonEventHandler(Tsw_ButtonStateChange); } } else if (room is EssentialsPresentationRoom) { Debug.Console(0, this, "Adding presentation room driver"); var avDriver = new EssentialsPresentationPanelAvFunctionsDriver(mainDriver, props); avDriver.CurrentRoom = room as EssentialsPresentationRoom; avDriver.DefaultRoomKey = props.DefaultRoomKey; mainDriver.AvDriver = avDriver; LoadAndShowDriver(mainDriver); if (Panel is TswFt5ButtonSystem) { var tsw = Panel as TswFt5ButtonSystem; // Wire up hard keys tsw.Power.UserObject = new Action <bool>(b => { if (!b) { avDriver.PowerButtonPressed(); } }); //tsw.Home.UserObject = new Action<bool>(b => { if (!b) HomePressed(); }); tsw.Up.UserObject = new Action <bool>(avDriver.VolumeUpPress); tsw.Down.UserObject = new Action <bool>(avDriver.VolumeDownPress); tsw.ButtonStateChange += new ButtonEventHandler(Tsw_ButtonStateChange); } } else { Debug.Console(0, this, "ERROR: Cannot load AvFunctionsDriver for room '{0}'", props.DefaultRoomKey); } }, 0); }); }
/// <summary> /// Config constructor /// </summary> public EssentialsTouchpanelController(string key, string name, string type, CrestronTouchpanelPropertiesConfig props, uint id) : base(key, name) { Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Creating touchpanel hardware..."); type = type.ToLower(); try { if (type == "crestronapp") { var app = new CrestronApp(id, Global.ControlSystem); app.ParameterProjectName.Value = props.ProjectName; Panel = app; } else if (type == "tsw550") { Panel = new Tsw550(id, Global.ControlSystem); } else if (type == "tsw552") { Panel = new Tsw552(id, Global.ControlSystem); } else if (type == "tsw560") { Panel = new Tsw560(id, Global.ControlSystem); } else if (type == "tsw750") { Panel = new Tsw750(id, Global.ControlSystem); } else if (type == "tsw752") { Panel = new Tsw752(id, Global.ControlSystem); } else if (type == "tsw760") { Panel = new Tsw760(id, Global.ControlSystem); } else if (type == "tsw1050") { Panel = new Tsw1050(id, Global.ControlSystem); } else if (type == "tsw1052") { Panel = new Tsw1052(id, Global.ControlSystem); } else if (type == "tsw1060") { Panel = new Tsw1060(id, Global.ControlSystem); } else { Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "WARNING: Cannot create TSW controller with type '{0}'", type); return; } } catch (Exception e) { Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "WARNING: Cannot create TSW base class. Panel will not function: {0}", e.Message); return; } // Reserved sigs if (Panel is TswFt5ButtonSystem) { var tsw = Panel as TswFt5ButtonSystem; tsw.ExtenderSystemReservedSigs.Use(); tsw.ExtenderSystemReservedSigs.DeviceExtenderSigChange += ExtenderSystemReservedSigs_DeviceExtenderSigChange; tsw.ButtonStateChange += new ButtonEventHandler(Tsw_ButtonStateChange); } if (Panel.Register() != eDeviceRegistrationUnRegistrationResponse.Success) { Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "WARNING: Registration failed. Continuing, but panel may not function: {0}", Panel.RegistrationFailureReason); } // Give up cleanly if SGD is not present. var sgdName = Global.FilePathPrefix + "sgd" + Global.DirectorySeparator + props.SgdFile; if (!File.Exists(sgdName)) { Debug.Console(0, this, "Smart object file '{0}' not present in User folder. Looking for embedded file", sgdName); sgdName = Global.ApplicationDirectoryPathPrefix + Global.DirectorySeparator + "SGD" + Global.DirectorySeparator + props.SgdFile; if (!File.Exists(sgdName)) { Debug.Console(0, this, "Unable to find SGD file '{0}' in User sgd or application SGD folder. Exiting touchpanel load.", sgdName); return; } } Panel.LoadSmartObjects(sgdName); Panel.SigChange += Panel_SigChange; }
public override void InitializeSystem() { try { // List of all Touchscreens in system IList <BasicTriListWithSmartObject> panelList = new List <BasicTriListWithSmartObject>(); Tsw1060 touchScreen1060 = new Tsw1060(0x0C, this); touchScreen1060.Register(); Tsw760 touchScreen760 = new Tsw760(0x0A, this); touchScreen760.Register(); Tsw560 touchScreen560 = new Tsw560(0x0E, this); touchScreen560.Register(); Tsw560P touchScreen560P = new Tsw560P(0x0D, this); touchScreen560P.Register(); CrestronApp mobileApp = new CrestronApp(0x0B, this); mobileApp.ParameterProjectName.Value = "ch5-sample-project"; mobileApp.Register(); panelList.Add(touchScreen1060); panelList.Add(touchScreen760); panelList.Add(touchScreen560); panelList.Add(touchScreen560P); panelList.Add(mobileApp); // --------------------------------------------------------------------------------------------------------------- // Create Contract Instance to program all touchscreens in system. This Contract Reference will globablly program // Lights, Source Selection, and ContactList // --------------------------------------------------------------------------------------------------------------- // Contract Instance var globalContract = new Contract(panelList.ToArray()); // Sample Programming of Lights/Scenes for all Touchscreens var demoLightingLogic = new DemoRoomLogic(globalContract.Room); // Sample Programming of Contact List for all Touchscreens var demoContactListingLogic = new DemoContactListingLogic(globalContract.ContactList); // Sample Programming of Source Selection for all Touchscreens var demoSourceSelectionLogic = new DemoSourceSelectLogic(globalContract.SourceList); // -------------------------------------------------------------------------------------------------------------- // Creating Multiple Contract Instances for each Touchscreen to program VIDEO CAMERA PAGE. // This will allow each Touchscreen Device to independantly play a different video camera. // For example TSW1060 can watch camera 2 while TSW760 can watch camera 1 and so on. // -------------------------------------------------------------------------------------------------------------- //Contract Instance for TSW1060 Touchscreen1060Contract = new Contract(touchScreen1060); Touchscreen1060VideoCamera = new DemoVideoCameraLogic(Touchscreen1060Contract.CameraList); // Contact Instance for TSW760 Touchscreen760Contract = new Contract(touchScreen760); Touchscreen760VideoCamera = new DemoVideoCameraLogic(Touchscreen760Contract.CameraList); // Contact Instance for TSW560 Touchscreen560Contract = new Contract(touchScreen560); Touchscreen560VideoCamera = new DemoVideoCameraLogic(Touchscreen560Contract.CameraList); // Contact Instance for TSW560P Touchscreen560PContract = new Contract(touchScreen560P); Touchscreen560PVideoCamera = new DemoVideoCameraLogic(Touchscreen560PContract.CameraList); // Contact Instance for MobileApp MobileAppContract = new Contract(mobileApp); MobileAppVideoCamera = new DemoVideoCameraLogic(MobileAppContract.CameraList); } catch (Exception e) { ErrorLog.Error("Error in InitializeSystem: {0}", e.Message); } }