コード例 #1
0
ファイル: Contract.g.cs プロジェクト: chin-gan/ch5navsegda
 public void RemoveDevice(BasicTriListWithSmartObject device)
 {
     InternalContactList.RemoveDevice(device);
     InternalSourceList.RemoveDevice(device);
     InternalRoom.RemoveDevice(device);
     InternalCameraList.RemoveDevice(device);
 }
コード例 #2
0
        void ConfigUserInterface(BasicTriListWithSmartObject currentDevice)
        {
            try
            {
                if (typeof(TswX60BaseClass).IsAssignableFrom(currentDevice.GetType()))
                {
                    ((TswX60BaseClass)currentDevice).ExtenderHardButtonReservedSigs.Use(); // must be done before registration. May cause, System.InvalidCastException: InvalidCastException
                    OnDebug(eDebugEventType.Info, "ui_{0:X2} {1} using HardButtonReservedSigs", currentDevice.ID, currentDevice.Name);
                }
                if (currentDevice.Register() == eDeviceRegistrationUnRegistrationResponse.Success)
                {
                    OnDebug(eDebugEventType.Info, "ui_{0:X2} {1} registration success", currentDevice.ID, currentDevice.Name);
                }
                else
                {
                    OnDebug(eDebugEventType.Error, "ui_{0:X2} {1} failed registration. Cause: {2}", currentDevice.ID, currentDevice.Name, currentDevice.RegistrationFailureReason);
                }
                currentDevice.OnlineStatusChange += new OnlineStatusChangeEventHandler(ui_OnlineStatusChange);
                currentDevice.SigChange          += new SigEventHandler(ui_SigChange);

                LoadUserInterfaceSmartObjectGraphics(currentDevice);
            }
            catch (Exception e)
            {
                OnDebug(eDebugEventType.Error, "Exception in ConfigUserInterfaces: {0}", e.Message);
            }
        }
コード例 #3
0
 public RoomUIController(SystemBase system, BasicTriListWithSmartObject device, RoomBase room, bool startInTechMode)
     : base(system, device, room)
 {
     _startInTechMode  = startInTechMode;
     _userPage         = new UserPageViewController(this);
     _techPage         = new TechPageViewController(this);
     _hiddenFlipButton = new UIButton(this, Digitals.HeaderHiddenButton, Serials.PageName)
     {
         HoldTime = TimeSpan.FromSeconds(0.5)
     };
     _hiddenFlipButton.ButtonEvent += (button, args) =>
     {
         if (args.EventType != ButtonEventType.Held)
         {
             return;
         }
         if (_userPage.Visible)
         {
             _techPage.Show();
             SetHeaderTitle("Tech Control Panel");
         }
         else
         {
             _userPage.Show();
             if (Room == null)
             {
                 return;
             }
             SetHeaderTitle(Room.Name);
         }
     };
 }
コード例 #4
0
 public void RemoveDevice(BasicTriListWithSmartObject device)
 {
     for (int index = 0; index < 20; index++)
     {
         InternalContact[index].RemoveDevice(device);
     }
 }
コード例 #5
0
        public SubpageReferenceList(BasicTriListWithSmartObject triList, uint smartObjectId,
                                    uint boolIncrement, uint ushortIncrement, uint stringIncrement)
        {
            SmartObject obj;

            // Fail cleanly if not defined
            if (triList.SmartObjects == null || triList.SmartObjects.Count == 0)
            {
                Debug.Console(0, "TriList {0:X2} Smart objects have not been loaded", triList.ID, smartObjectId);
                return;
            }
            if (triList.SmartObjects.TryGetValue(smartObjectId, out obj))
            {
                SRL                 = triList.SmartObjects[smartObjectId];
                ScrollToItemSig     = SRL.UShortInput["Scroll To Item"];
                SetNumberOfItemsSig = SRL.UShortInput["Set Number of Items"];
                BoolIncrement       = boolIncrement;
                UShortIncrement     = ushortIncrement;
                StringIncrement     = stringIncrement;

                // Count the enable lines to see what max items is
                MaxDefinedItems = (ushort)SRL.BooleanInput
                                  .Where(s => s.Name.Contains("Enable")).Count();
                Debug.Console(2, "SRL {0} contains max {1} items", SRL.ID, MaxDefinedItems);

                SRL.SigChange -= new SmartObjectSigChangeEventHandler(SRL_SigChange);
                SRL.SigChange += new SmartObjectSigChangeEventHandler(SRL_SigChange);
            }
            else
            {
                Debug.Console(0, "ERROR: TriList 0x{0:X2} Cannot load smart object {1}. Verify correct SGD file is loaded",
                              triList.ID, smartObjectId);
            }
        }
コード例 #6
0
 void LoadUserInterfaceSmartObjectGraphics(BasicTriListWithSmartObject currentDevice)
 {
     try
     {
         string location = Directory.GetApplicationDirectory() + "\\" + SgdFileName;
         if (File.Exists(location))
         {
             currentDevice.LoadSmartObjects(location);
             OnDebug(eDebugEventType.Info, "{0} SmartObject items loaded", currentDevice.SmartObjects.Count.ToString());
             foreach (KeyValuePair <uint, SmartObject> kvp in currentDevice.SmartObjects)
             {
                 kvp.Value.SigChange += new SmartObjectSigChangeEventHandler(SmartObject_SigChange);
                 SG.PrintSmartObjectSigNames(kvp.Value);
             }
         }
         else
         {
             OnDebug(eDebugEventType.Info, "SmartObject file{0} does not exist", location);
         }
     }
     catch (Exception e)
     {
         OnDebug(eDebugEventType.Error, "Exception in LoadUserInterfaceSmartObjectGraphics: {0}", e.Message);
     }
 }
コード例 #7
0
ファイル: Contract.g.cs プロジェクト: chin-gan/ch5navsegda
 public void AddDevice(BasicTriListWithSmartObject device)
 {
     InternalContactList.AddDevice(device);
     InternalSourceList.AddDevice(device);
     InternalLightingList.AddDevice(device);
     InternalCameraList.AddDevice(device);
 }
コード例 #8
0
        void SmartObject_DPad_SigChange(BasicTriListWithSmartObject currentDevice, SmartObjectEventArgs args)
        {
            if (args.Sig.BoolValue)
            {
                switch (args.Sig.Name.ToUpper())
                {
                case "UP": OnDebug(eDebugEventType.Info, "Up pressed"); break;             // up

                case "DOWN": OnDebug(eDebugEventType.Info, "Down pressed"); break;         // dn

                case "LEFT": OnDebug(eDebugEventType.Info, "Left pressed"); break;         // le

                case "RIGHT": OnDebug(eDebugEventType.Info, "Right pressed"); break;       // ri

                case "CENTER": OnDebug(eDebugEventType.Info, "Center pressed"); break;     // OK

                default:
                    OnDebug(eDebugEventType.Info, "Unhandled keypad button {0} pressed, name:{1}", args.Sig.Number, args.Sig.Name);
                    break;
                }
            }
            else // release
            {
            }
        }
コード例 #9
0
 /// <summary>
 /// Sends the smart value to the specific panel.
 /// </summary>
 /// <param name="smartJoin">The join # of the smart object.</param>
 /// <param name="join">The join # to send the value to.</param>
 /// <param name="value">The value to send.</param>
 /// <param name="panel">The <see cref="BasicTriListWithSmartObject"/> to send the value to.</param>
 public void SendSmartValue(uint smartJoin, uint join, string value, BasicTriListWithSmartObject panel)
 {
     if (panels.Contains(panel) && panel.Registered)
     {
         panel.SmartObjects[smartJoin].StringInput[join].StringValue = value;
     }
 }
コード例 #10
0
ファイル: Contract.g.cs プロジェクト: ArunKurian555/CH5
 public void RemoveDevice(BasicTriListWithSmartObject device)
 {
     InternalArea.RemoveDevice(device);
     InternalScenes.RemoveDevice(device);
     InternalZones.RemoveDevice(device);
     InternalSch.RemoveDevice(device);
     InternalZonerename.RemoveDevice(device);
 }
コード例 #11
0
ファイル: Contract.g.cs プロジェクト: ArunKurian555/CH5
 public void AddDevice(BasicTriListWithSmartObject device)
 {
     InternalArea.AddDevice(device);
     InternalScenes.AddDevice(device);
     InternalZones.AddDevice(device);
     InternalSch.AddDevice(device);
     InternalZonerename.AddDevice(device);
 }
コード例 #12
0
 /// <summary>
 /// Pulses a boolean input on a smart object on a specific panel for a period of time.
 /// </summary>
 /// <param name="smartID">The ID of the smart object.</param>
 /// <param name="join">The Join # on the smart object to pulse.</param>
 /// <param name="millisecondDuration">The duration in milliseconds to pulse the join.</param>
 /// /// <param name="panel">The <see cref="BasicTriListWithSmartObject"/> to pulse the join on.</param>
 public void Pulse(uint smartID, uint join, int millisecondDuration, BasicTriListWithSmartObject panel)
 {
     if (panels.Contains(panel) && panel.Registered)
     {
         CrestronInvoke.BeginInvoke(
             (o) => panel.SmartObjects[smartID].BooleanInput[join].Pulse(millisecondDuration));
     }
 }
コード例 #13
0
        protected BaseUIController(SystemBase system, BasicTriListWithSmartObject device, RoomBase room)
            : base(system, device, room)
        {
            try
            {
                var assembly   = Assembly.GetExecutingAssembly();
                var streamName =
                    assembly.GetManifestResourceNames()
                    .FirstOrDefault(n => n.Contains(".sgd") && n.Contains(device.Name)) ??
                    assembly.GetManifestResourceNames()
                    .FirstOrDefault(
                        n => n.Contains(".sgd") && n.Contains("XPanel") && device is XpanelForSmartGraphics) ??
                    assembly.GetManifestResourceNames()
                    .FirstOrDefault(
                        n => n.Contains(".sgd") && n.Contains("CrestronApp") && device is CrestronApp) ??
                    assembly.GetManifestResourceNames()
                    .FirstOrDefault(n => n.Contains(".sgd"));
                CloudLog.Info("Loading Smartgraphics for {0} ID {1}, File: {2}", GetType().Name, Id, streamName);
                var stream = assembly.GetManifestResourceStream(streamName);
                LoadSmartObjects(stream);
            }
            catch
            {
                CloudLog.Error("Could not load SGD file for {0}", this);
            }

            _roomNameLabel          = new UILabel(this, Serials.RoomName);
            _roomContactNumberLabel = new UILabel(this, Serials.RoomContactNumber);

            _bootPage = new BootPageViewController(this, Digitals.PageBoot, null);

            var tswX60BaseClass = device as TswX60BaseClass;

            if (tswX60BaseClass != null)
            {
                tswX60BaseClass.ExtenderSystem2ReservedSigs.Use();
            }

            _restartingView = new ASubPage(this, Device.BooleanInput[Digitals.SubPageRestarting], string.Empty, TimeSpan.Zero);
            _restartingText = new UILabel(this, Serials.RestartingText)
            {
                Text = "System Restarting"
            };

            _homeButton = new UIButton(this, Digitals.HomeButton);
            _backButton = new UIButton(this, Digitals.BackButton)
            {
                VisibleJoin = Device.BooleanInput[Digitals.BackButtonVisible]
            };
            _backButton.Show();

            _homeButton.ButtonEvent += HomeButtonOnButtonEvent;

            _textEntryView = new TextFieldEntryViewController(this);

            _actionSheets[0] = new ActionSheetDefault(this);
        }
コード例 #14
0
 public void AddDevice(BasicTriListWithSmartObject device)
 {
     Devices.Add(device);
     ComponentMediator.HookSmartObjectEvents(device.SmartObjects[ControlJoinId]);
     for (int index = 0; index < Cameras.Length; index++)
     {
         ((Camera)Cameras[index]).AddDevice(device);
     }
 }
コード例 #15
0
ファイル: SourceList.g.cs プロジェクト: chin-gan/ch5navsegda
 public void RemoveDevice(BasicTriListWithSmartObject device)
 {
     Devices.Remove(device);
     ComponentMediator.Instance.UnHookSmartObjectEvents(device.SmartObjects[ControlJoinId]);
     for (int index = 0; index < Source.Length; index++)
     {
         ((Ch5_Sample_Contract.Selector.Source)Source[index]).RemoveDevice(device);
     }
 }
コード例 #16
0
 public void RemoveDevice(BasicTriListWithSmartObject device)
 {
     Devices.Remove(device);
     ComponentMediator.UnHookSmartObjectEvents(device.SmartObjects[ControlJoinId]);
     for (int index = 0; index < Cameras.Length; index++)
     {
         ((Ch5_Sample_Contract.Video.Camera)Cameras[index]).RemoveDevice(device);
     }
 }
コード例 #17
0
ファイル: ContactList.g.cs プロジェクト: chin-gan/ch5navsegda
 public void AddDevice(BasicTriListWithSmartObject device)
 {
     Devices.Add(device);
     ComponentMediator.HookSmartObjectEvents(device.SmartObjects[ControlJoinId]);
     for (int index = 0; index < Contact.Length; index++)
     {
         ((Ch5_Sample_Contract.Contact.Contact)Contact[index]).AddDevice(device);
     }
 }
コード例 #18
0
 public void RemoveDevice(BasicTriListWithSmartObject device)
 {
     Devices.Remove(device);
     ComponentMediator.Instance.UnHookSmartObjectEvents(device.SmartObjects[ControlJoinId]);
     for (int index = 0; index < DimmableLoad.Length; index++)
     {
         ((Ch5_Sample_Contract.Lighting.DimmableLoad)DimmableLoad[index]).RemoveDevice(device);
     }
 }
コード例 #19
0
 public void AddDevice(BasicTriListWithSmartObject device)
 {
     Devices.Add(device);
     ComponentMediator.Instance.HookSmartObjectEvents(device.SmartObjects[ControlJoinId]);
     for (int index = 0; index < DimmableLoad.Length; index++)
     {
         ((DimmableLoad)DimmableLoad[index]).AddDevice(device);
     }
 }
コード例 #20
0
ファイル: ContactList.g.cs プロジェクト: chin-gan/ch5navsegda
 public void RemoveDevice(BasicTriListWithSmartObject device)
 {
     Devices.Remove(device);
     ComponentMediator.UnHookSmartObjectEvents(device.SmartObjects[ControlJoinId]);
     for (int index = 0; index < Contact.Length; index++)
     {
         ((CH5SampleSSP.Contact.Contact)Contact[index]).RemoveDevice(device);
     }
 }
コード例 #21
0
        void SmartObject_BtnList_SigChange(BasicTriListWithSmartObject currentDevice, SmartObjectEventArgs args)
        {
            SmartObject so            = currentDevice.SmartObjects[args.SmartObjectArgs.ID];
            SmartObject soDynBtnList  = currentDevice.SmartObjects[SG_DYNAMIC_BTN_LIST];
            SmartObject soDynIconList = currentDevice.SmartObjects[SG_DYNAMIC_ICON_LIST];
            Sig         sig           = args.Sig;

            switch (sig.Type)
            {
            case eSigType.Bool:
                if (sig.BoolValue)
                {
                    OnDebug(eDebugEventType.Info, "Press event");
                    switch (sig.Number)
                    {
                    //case 1: break;
                    default:
                        //SG.ToggleSmartObjectVisible(soDynBtnList , (int)sig.Number);       // toggle visibility
                        //SG.ToggleSmartObjectVisible(soDynIconList, (int)sig.Number);       // toggle visibility

                        // toggle the button feedback and put some text onto it
                        string buttonText = "Item " + sig.Number.ToString();
                        SG.ToggleSmartObjectSelected(so, (int)sig.Number);         // standard button lists don't support feedback  so this doesn't do anything
                        SG.SetSmartObjectText(so, (int)sig.Number, buttonText);

                        // soDynBtnList uses dynamic IconAnalogs, of type MediaTransports
                        SG.ToggleSmartObjectVisible(soDynBtnList, (int)sig.Number);                     // toggle visibility
                        SG.SetSmartObjectEnabled(soDynBtnList, (int)sig.Number, true);                  // enable
                        SG.SetSmartObjectIconAnalog(soDynBtnList, (int)sig.Number, (ushort)sig.Number); // set icon to the next analog

                        // soDynIconList uses dynamic IconSerials, of type IconsLg
                        SG.ToggleSmartObjectVisible(soDynIconList, (int)sig.Number);               // toggle visibility
                        SG.SetSmartObjectEnabled(soDynIconList, (int)sig.Number, true);            // enable
                        string icon = UI.IconsLgDict[0];
                        SG.SetSmartObjectIconSerial(soDynIconList, (int)sig.Number, icon);         // set icon to the next serial
                        break;
                    }
                }
                else
                {
                    OnDebug(eDebugEventType.Info, "Release event");
                }
                break;

            case eSigType.UShort:
                OnDebug(eDebugEventType.Info, "UShortValue: {0}", sig.UShortValue.ToString());
                break;

            case eSigType.String:
                OnDebug(eDebugEventType.Info, "StringValue: {0}", sig.StringValue);
                break;

            default:
                OnDebug(eDebugEventType.Info, "Unhandled sig type: {0}", sig.Type.ToString());
                break;
            }
        }
コード例 #22
0
 public void RemoveDevice(BasicTriListWithSmartObject device)
 {
     Devices.Remove(device);
     ComponentMediator.UnHookSmartObjectEvents(device.SmartObjects[ControlJoinId]);
     for (int index = 0; index < Sources.Length; index++)
     {
         ((Source)Sources[index]).RemoveDevice(device);
     }
 }
コード例 #23
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="trilist"></param>
        /// <param name="parent"></param>
        public EssentialsHuddleTechPageDriver(BasicTriListWithSmartObject trilist, EssentialsRoomTechConfig config)
            : base(trilist)
        {
            Config = config;

            PagesInterlock = new JoinedSigInterlock(trilist);
            PagesInterlock.SetButDontShow(UIBoolJoin.TechSystemStatusVisible);

            trilist.SetSigFalseAction(UIBoolJoin.TechExitButton, Hide);

            MenuList = new SmartObjectDynamicList(trilist.SmartObjects[UISmartObjectJoin.TechMenuList],
                                                  true, 3100);

            MenuList.SetFeedback(1, true); // initial fb
            ushort count = 0;

            MenuList.SetItemMainText(1, "System Status");
            MenuList.SetItemButtonAction(1, b => {
                if (b)
                {
                    PagesInterlock.ShowInterlocked(UIBoolJoin.TechSystemStatusVisible);
                }
                MenuList.SetFeedback(1, true);
            });

            MenuList.SetItemMainText(2, "Display Controls");
            MenuList.SetItemButtonAction(2, b => {
                if (b)
                {
                    PagesInterlock.ShowInterlocked(UIBoolJoin.TechDisplayControlsVisible);
                }
                MenuList.SetFeedback(2, true);
            });

            count = 2;

            // Don't show panel setup on iPad or xpanel
            if (TriList is Crestron.SimplSharpPro.DeviceSupport.TswFt5Button)
            {
                count++;
                MenuList.SetItemMainText(count, "Panel Setup");
                MenuList.SetItemButtonAction(count, b =>
                {
                    if (b)
                    {
                        PagesInterlock.ShowInterlocked(UIBoolJoin.TechPanelSetupVisible);
                    }
                    MenuList.SetFeedback(count, true);
                });
            }

            MenuList.Count = count;
            BuildStatusList();
            BuildDisplayList();
            SetupPinModal();
        }
コード例 #24
0
 public SetTopBoxMediumPageManager(ISetTopBoxControls stb, BasicTriListWithSmartObject trilist)
     : base(stb.DisplayUiType)
 {
     SetTopBox = stb;
     TriList   = trilist;
     if (stb.PresetsModel != null)
     {
         PresetsView = new DevicePresetsView(trilist, stb.PresetsModel);
     }
 }
コード例 #25
0
ファイル: Room.g.cs プロジェクト: chin-gan/ch5navsegda
 public void AddDevice(BasicTriListWithSmartObject device)
 {
     Devices.Add(device);
     ComponentMediator.HookSmartObjectEvents(device.SmartObjects[ControlJoinId]);
     for (int index = 0; index < DimmableLights.Length; index++)
     {
         ((DimmableLight)DimmableLights[index]).AddDevice(device);
     }
     for (int index = 0; index < Scenes.Length; index++)
     {
         ((Scene)Scenes[index]).AddDevice(device);
     }
 }
コード例 #26
0
        void SmartObject_DynIconList_SigChange(BasicTriListWithSmartObject currentDevice, SmartObjectEventArgs args)
        {
            SmartObject so           = currentDevice.SmartObjects[args.SmartObjectArgs.ID];
            SmartObject soBtnList    = currentDevice.SmartObjects[SG_BTN_LIST];
            SmartObject soDynBtnList = currentDevice.SmartObjects[SG_DYNAMIC_BTN_LIST];
            Sig         sig          = args.Sig;

            switch (sig.Type)
            {
            case eSigType.Bool:
                if (sig.BoolValue)
                {
                    OnDebug(eDebugEventType.Info, "Press event");
                    switch (sig.Number)
                    {
                    default:
                        int number = StringHelper.Atoi(sig.Name);         // Number is offset by 10 so we need item with no offset
                        // toggle the button feedback and put some text onto it
//                                SG.ToggleSmartObjectDigitalJoin(so, (int)sig.Number);
                        string buttonText = "Item " + sig.Number.ToString() + " " + SG.GetSmartObjectDigitalJoin(so, (int)sig.Number).ToString();
                        //SG.SetSmartObjectText        (so, (int)sig.Number, buttonText);
//                                SG.SetSmartObjectText          (so, number, buttonText);
                        string icon = UI.IconsLgDict[(ushort)number];
                        SG.SetSmartObjectIconSerial(so, number, icon);             // set icon to the next serial

                        //SG.ToggleSmartObjectEnabled(soDynBtnList, number);       // enable

                        //SG.ToggleSmartObjectDigitalJoin(soBtnList, number);
                        //SG.SetSmartObjectText          (soBtnList, number, buttonText);
                        break;
                    }
                }
                else
                {
                    OnDebug(eDebugEventType.Info, "Release event");
                }
                break;

            case eSigType.UShort:
                OnDebug(eDebugEventType.Info, "UShortValue: {0}", sig.UShortValue.ToString());
                break;

            case eSigType.String:
                OnDebug(eDebugEventType.Info, "StringValue: {0}", sig.StringValue);
                break;

            default:
                OnDebug(eDebugEventType.Info, "Unhandled sig type: {0}", sig.Type.ToString());
                break;
            }
        }
コード例 #27
0
        public DevicePresetsView(BasicTriListWithSmartObject tl, DevicePresetsModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model", "DevicePresetsView Cannot be instantiated with null model");
            }
            ShowIcon = true;
            ShowName = true;

            Model = model;

            SRL = new SubpageReferenceList(tl, 10012, 3, 0, 4);
            Model.PresetsLoaded += new EventHandler(Model_PresetsLoaded);
        }
コード例 #28
0
        void SmartObject_DynBtnList_SigChange(BasicTriListWithSmartObject currentDevice, SmartObjectEventArgs args)
        {
            SmartObject so            = currentDevice.SmartObjects[args.SmartObjectArgs.ID];
            SmartObject soBtnList     = currentDevice.SmartObjects[SG_BTN_LIST];
            SmartObject soDynIconList = currentDevice.SmartObjects[SG_DYNAMIC_ICON_LIST];
            Sig         sig           = args.Sig;

            switch (sig.Type)
            {
            case eSigType.Bool:
                if (sig.BoolValue)
                {
                    OnDebug(eDebugEventType.Info, "Press event");
                    switch (sig.Number)
                    {
                    default:
                        int number = AVPlus.Utils.StringHelper.Atoi(sig.Name);         // Number is offset by 10 so we need item with no offset
                        // toggle the button feedback and put some text onto it
                        SG.ToggleSmartObjectDigitalJoin(so, (int)sig.Number);
                        string buttonText    = "Item " + sig.Number.ToString() + " " + SG.GetSmartObjectDigitalJoin(so, (int)sig.Number).ToString();
                        string formattedText = UI.FormatTextForUi(buttonText, 20, UI.eCrestronFont.Crestron_Sans_Pro, UI.eNamedColour.White);
                        SG.SetSmartObjectText(so, number, formattedText);

                        SG.ToggleSmartObjectEnabled(soDynIconList, number);               // enable
                        break;
                    }
                }
                else
                {
                    OnDebug(eDebugEventType.Info, "Release event");
                }
                break;

            case eSigType.UShort:
                OnDebug(eDebugEventType.Info, "UShortValue: {0}", sig.UShortValue.ToString());
                break;

            case eSigType.String:
                OnDebug(eDebugEventType.Info, "StringValue: {0}", sig.StringValue);
                break;

            default:
                OnDebug(eDebugEventType.Info, "Unhandled sig type: {0}", sig.Type.ToString());
                break;
            }
        }
コード例 #29
0
        bool isAccessLevelChosen = false;                               // Indicates whether user has clicked an access level (cannot create group if false)
        /////////////////////////////////////////////////////////////////////////////////

        /// <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
            {
                //Subscribe to the controller events (System, Program, and Ethernet)
                CrestronEnvironment.SystemEventHandler        += new SystemEventHandler(ControlSystem_ControllerSystemEventHandler);
                CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(ControlSystem_ControllerProgramEventHandler);

                // IPID = 3
                panel = new Tsw752(0x3, this);

                // Subscribe to all signal changes from the touchpanel. This handler will be invoked everytime the
                // user presses a button or types into a text box
                panel.SigChange += new SigEventHandler(Panel_SigChange);
                // If the smart graphics file exists, load it to the panel
                if (File.Exists(Directory.GetApplicationDirectory() + "\\" + sgdFileName))
                {
                    panel.LoadSmartObjects(Directory.GetApplicationDirectory() + "\\" + sgdFileName);

                    // Register the event handler for each Smart Object found
                    foreach (KeyValuePair <uint, SmartObject> so in panel.SmartObjects)
                    {
                        so.Value.SigChange += new SmartObjectSigChangeEventHandler(SmartObject_SigChange);
                    }
                }
                else
                {
                    ErrorLog.Error("Failed to load SGD file {0} for panel", sgdFileName);
                }

                if (panel.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
                {
                    ErrorLog.Error("Error Registering panel at IPID {0}: {1}", panel.ID, panel.RegistrationFailureReason);
                }

                // Create the timer now, but don't start it until the user logs in
                authTimeout = new CTimer(authTimeoutCallback, Timeout.Infinite);
            }
            catch (Exception e)
            {
                CrestronConsole.PrintLine("Error in the constructor: {0}", e);
                ErrorLog.Error("Error in the constructor: {0}", e.Message);
            }
        }
コード例 #30
0
ファイル: TouchpanelUI.cs プロジェクト: plinck/MSS601Lab1
        /// <summary>
        /// Register the touchpanel using the proper information
        /// </summary>
        /// <returns>true or false, depending on if the registration succeeded</returns>
        public bool Register()
        {
            try
            {
                this.UserInterface = this.RetrieveUiObject(this.Type, this.Id);

                if (this.UserInterface == null)
                {
                    return false;
                }

                this.UserInterface.Description = this.Label;

                this.UserInterface.SigChange += this.UserInterfaceObject_SigChange;
                
                // load smart objects
                string sgdPath = Path.Combine(Directory.GetApplicationDirectory(), "XPanel_v1.sgd");

                this.UserInterface.LoadSmartObjects(sgdPath);

                ErrorLog.Error(string.Format(LogHeader + "Loaded SmartObjects: {0}", this.UserInterface.SmartObjects.Count));
                foreach (KeyValuePair<uint, SmartObject> smartObject in this.UserInterface.SmartObjects)
                {
                    smartObject.Value.SigChange += new Crestron.SimplSharpPro.SmartObjectSigChangeEventHandler(this.SO_SigChange);
                }

                if (this.UserInterface.Register() != Crestron.SimplSharpPro.eDeviceRegistrationUnRegistrationResponse.Success)
                {
                    ErrorLog.Error(LogHeader + "Error registering UI {0}", this.Label);
                    return false;
                }
                else
                {
                    return true;
                }
            }
            catch (Exception e)
            {
                ErrorLog.Error(LogHeader + "Excepting when trying to register UI {0}: {1}", this.Label, e.Message);
                return false;
            }
        }