Пример #1
0
        public UIController(uint id, BasicTriList device)
        {
            ID     = id;
            Device = device;

            if (Device != null)
            {
                _pages = new UIPageCollection(this);

                CrestronConsole.PrintLine("Registering UI Device \'{0}\'", device.GetType().ToString());
                CrestronConsole.PrintLine("UI Device \'{0}\' parent is {1}", device.GetType().Name, device.Parent.GetType().Name);

                if (device is TswFt5ButtonSystem)
                {
                    CrestronConsole.PrintLine("UI Device is TswFt5ButtonSystem device");
                    TswFt5ButtonSystem panelDevice = device as TswFt5ButtonSystem;
                    SystemReservedSigs = panelDevice.ExtenderSystemReservedSigs;
                    SystemReservedSigs.Use();
                }

                var x60Device = device as TswX60BaseClass;
                if (x60Device != null)
                {
                    x60Device.ExtenderHardButtonReservedSigs.Use();
                }

                try
                {
                    Device.IpInformationChange += new IpInformationChangeEventHandler(Device_IpInformationChange);
                }
                catch
                {
                    // Probably not an Ethernet device
                }

                Device.OnlineStatusChange += new OnlineStatusChangeEventHandler(DeviceOnlineStatusChanged);

                if (Device.Parent is CrestronControlSystem && Device.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
                {
                    ErrorLog.Error("Could not register User Interface device with ID: {0}, ipID: {1}", ID, Device.ID);
                }

                device.SigChange += DeviceOnSigChange;
            }
            else
            {
                ErrorLog.Error("Cannot register User Interface device with ID: {0} as device is null", ID);
            }
        }
Пример #2
0
        private void DeviceOnSigChange(BasicTriList currentDevice, SigEventArgs args)
        {
#if DEBUG
            CrestronConsole.PrintLine("{0}.SigChange ID 0x{1:X2} {2}", currentDevice.GetType().Name,
                                      currentDevice.ID, args.Sig.ToString());
#endif

            OnPanelActivity(this, new UIControllerActivityEventArgs(args.Sig, args.Event));
        }
Пример #3
0
        /// <summary>
        /// Create a UIController instance
        /// </summary>
        /// <param name="system">The base system</param>
        /// <param name="device">The UI device used for the UIController</param>
        /// <param name="defaultRoom">The default room for the UI</param>
        protected UIController(SystemBase system, BasicTriList device, RoomBase defaultRoom)
        {
            _idCount++;
            Id      = _idCount;
            _system = system;
            _system.SystemStartupProgressChange += OnSystemStartupProgressChange;

            Device      = device;
            DefaultRoom = defaultRoom;

            CloudLog.Debug("Creating {0} for device: {1} ({2}) with ID 0x{3:X2}", GetType().Name, device.GetType().Name, device.Name, device.ID);

            try
            {
                device.IpInformationChange += DeviceOnIpInformationChange;
                _isEthernetDevice           = true;
            }
            catch
            {
                CloudLog.Debug("{0} is not Ethernet Device", device.ToString());
            }
            device.OnlineStatusChange += DeviceOnOnlineStatusChange;
            device.SigChange          += OnSigChange;

            var tswFt5Button = device as TswFt5Button;

            if (tswFt5Button != null)
            {
                tswFt5Button.ExtenderEthernetReservedSigs.Use();
                tswFt5Button.ExtenderEthernetReservedSigs.DeviceExtenderSigChange +=
                    ExtenderEthernetReservedSigsOnDeviceExtenderSigChange;
            }

            var tswx52ButtonVoiceControl = device as Tswx52ButtonVoiceControl;

            if (tswx52ButtonVoiceControl != null)
            {
                tswx52ButtonVoiceControl.ExtenderSystemReservedSigs.Use();
                tswx52ButtonVoiceControl.ExtenderAutoUpdateReservedSigs.Use();
                tswx52ButtonVoiceControl.ExtenderAutoUpdateReservedSigs.DeviceExtenderSigChange += ExtenderAutoUpdateReservedSigsOnDeviceExtenderSigChange;
            }

            var tswX60BaseClass = device as TswX60BaseClass;

            if (tswX60BaseClass != null)
            {
                tswX60BaseClass.ExtenderHardButtonReservedSigs.Use();
                Debug.WriteInfo("Setting up hard buttons for TswX60BaseClass device");
                _hardButtons = new ButtonCollection();
                for (uint b = 1; b <= 5; b++)
                {
                    var extender  = tswX60BaseClass.ExtenderHardButtonReservedSigs;
                    var t         = extender.GetType().GetCType();
                    var offMethod = t.GetMethod(string.Format("TurnButton{0}BackLightOff", b));
                    var onMethod  = t.GetMethod(string.Format("TurnButton{0}BackLightOn", b));
                    var delType   = typeof(HardKeyBackLightMethod).GetCType();
                    var offDel    = (HardKeyBackLightMethod)CDelegate.CreateDelegate(delType, extender, offMethod);
                    var onDel     = (HardKeyBackLightMethod)CDelegate.CreateDelegate(delType, extender, onMethod);
                    var button    = new UIHardButton(this, b, onDel, offDel);
                    _hardButtons.Add(b, button);
                }
            }
            else if (device is Tswx52ButtonVoiceControl)
            {
                Debug.WriteInfo("Setting up hard buttons for Tswx52ButtonVoiceControl device");
                _hardButtons = new ButtonCollection();
                for (uint b = 1; b <= 5; b++)
                {
                    var button = new UIHardButton(this, b);
                    _hardButtons.Add(b, button);
                }
            }

            _system.UIControllers.Add(this);
        }