void ui_SigChange(BasicTriList currentDevice, SigEventArgs args)
        {
            Sig sig = args.Sig;

            OnDebug(eDebugEventType.Info, "{0} SigChange in {1} type: {2}, sig: {3}, Name: {4}", currentDevice.ToString(), currentDevice.ID.ToString(), sig.Type.ToString(), sig.Number.ToString(), sig.Name);
            switch (sig.Type)
            {
            case eSigType.Bool:
                if (sig.BoolValue)     // press
                {
                    OnDebug(eDebugEventType.Info, "Press event on sig number: {0}", sig.Number);
                    switch (sig.Number)
                    {
                    case DIG_TOGGLE_POWER:
                        UI.ToggleDigitalJoin(currentDevice, sig.Number);
                        break;

                    case DIG_MACRO:
                        UI.PulseDigitalJoin(currentDevice, DIG_TOGGLE_POWER);
                        var randomNumber = new Random().Next(ushort.MaxValue);
                        UI.SetAnalogJoin(currentDevice, ANA_RANDOM, (ushort)randomNumber);
                        UI.SetSerialJoin(currentDevice, SER_VALUE, randomNumber.ToString());
                        break;
                    }
                }
                else     // release
                {
                }
                break;

            case eSigType.UShort:
                OnDebug(eDebugEventType.Info, "UShortValue: {0}", sig.UShortValue.ToString());
                switch (sig.Number)
                {
                case ANA_BAR_GRAPH:
                    UI.SetAnalogJoin(currentDevice, sig.Number, sig.UShortValue);
                    UI.SetSerialJoin(currentDevice, SER_VALUE, sig.UShortValue.ToString());
                    break;

                case ANA_RANDOM:
                    UI.SetAnalogJoin(currentDevice, ANA_BAR_GRAPH, sig.UShortValue);
                    break;
                }
                break;

            case eSigType.String:
                OnDebug(eDebugEventType.Info, "StringValue: {0}", sig.StringValue);
                switch (sig.Number)
                {
                case SER_INPUT:
                    UI.SetSerialJoin(currentDevice, SER_VALUE, sig.StringValue.ToString());
                    break;
                }
                break;

            default:
                OnDebug(eDebugEventType.Info, "Unhandled sig type: {0}", sig.Type.ToString());
                break;
            }
        }
示例#2
0
        /// <summary>
        /// Updates panel feedback based on class variables
        /// </summary>
        void PanelFeedback()
        {
            uint button;

            for (int i = 0; i < LIMIT_DAYS; i++)
            {
                // start days
                button = (uint)(DigitalJoins.StartDayMonday + i + buttonOffset);
                UI.SetDigitalJoin(panel, button, events[EVENT_START].days[i]);

                // stop days
                button = (uint)(DigitalJoins.StopDayMonday + i + buttonOffset);
                UI.SetDigitalJoin(panel, button, events[EVENT_STOP].days[i]);
            }

            // start time text
            string timeStart = String.Format("{0}:{1:D2}", events[EVENT_START].hour, events[EVENT_START].minute);

            button = SerialJoins.StartText + buttonOffset;
            UI.SetSerialJoin(panel, button, timeStart);

            // stop time text
            string timeStop = String.Format("{0}:{1:D2}", events[EVENT_STOP].hour, events[EVENT_STOP].minute);

            button = SerialJoins.StopText + buttonOffset;
            UI.SetSerialJoin(panel, button, timeStop);
        }
        void ui_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args)
        {
            OnDebug(eDebugEventType.Info, "{0} online status {1}", currentDevice.ToString(), args.DeviceOnLine.ToString());
            Type type = currentDevice.GetType();

            SmartObject so            = ((BasicTriListWithSmartObject)currentDevice).SmartObjects[SG_DYNAMIC_BTN_LIST];
            int         i             = 0;
            ushort      fontsize      = 16;
            string      formattedText = UI.FormatTextForUi(currentDevice.Name, fontsize, UI.eCrestronFont.Crestron_Sans_Pro, UI.eNamedColour.White);

            SG.SetSmartObjectVisible(so, ++i, true);
            SG.SetSmartObjectText(so, i, formattedText);

            formattedText = String.Format("IPID: 0x{0:X2}", currentDevice.ID);
            formattedText = UI.FormatTextForUi(formattedText, fontsize, UI.eCrestronFont.Crestron_Sans_Pro, UI.eNamedColour.White);
            SG.SetSmartObjectVisible(so, ++i, true);
            SG.SetSmartObjectText(so, i, formattedText);

            formattedText = "Type: " + type.Name.ToString();
            formattedText = UI.FormatTextForUi(formattedText, fontsize, UI.eCrestronFont.Crestron_Sans_Pro, UI.eNamedColour.White);
            SG.SetSmartObjectVisible(so, ++i, true);
            SG.SetSmartObjectText(so, i, formattedText);

            try
            {
                if (typeof(TswFt5Button).IsAssignableFrom(currentDevice.GetType()))
                {
                    formattedText = "IP: " + ((TswFt5Button)currentDevice).ExtenderEthernetReservedSigs.IpAddressFeedback.ToString();
                    formattedText = UI.FormatTextForUi(formattedText, fontsize, UI.eCrestronFont.Crestron_Sans_Pro, UI.eNamedColour.White);
                    SG.SetSmartObjectVisible(so, ++i, true);
                    SG.SetSmartObjectText(so, i, formattedText);

                    formattedText = "MAC: " + ((TswFt5Button)currentDevice).ExtenderEthernetReservedSigs.MacAddressFeedback.ToString();
                    formattedText = UI.FormatTextForUi(formattedText, fontsize, UI.eCrestronFont.Crestron_Sans_Pro, UI.eNamedColour.White);
                    SG.SetSmartObjectVisible(so, ++i, true);
                    SG.SetSmartObjectText(so, i, formattedText);
                }

                if (typeof(TswX60BaseClass).IsAssignableFrom(currentDevice.GetType()))
                {
                    ((TswX60BaseClass)currentDevice).ExtenderHardButtonReservedSigs.DeviceExtenderSigChange -= ui_HardButton_SigChange; // remove existing event from invocation list
                    ((TswX60BaseClass)currentDevice).ExtenderHardButtonReservedSigs.DeviceExtenderSigChange += ui_HardButton_SigChange;
                }
            }
            catch (Exception e)
            {
                OnDebug(eDebugEventType.Info, "ui_OnlineStatusChange exception: {0}", e.Message);
            }
        }
        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;
            }
        }
 object ResetPinTextThread(object o) // not thread safe!
 {
     try
     {
         OnDebug(eDebugEventType.Info, "UResetPinText");
         Thread.Sleep(1000);
         keypadText = "";
         var ui = o as BasicTriList;
         if (ui != null)
         {
             UI.SetSerialJoin(ui, SER_INPUT, keypadText);
         }
     }
     catch (Exception e)
     {
         OnDebug(eDebugEventType.Info, "ResetPinText exception: {0}", e.Message);
     }
     return(null);
 }
 void SmartObject_KeyPad_SigChange(BasicTriListWithSmartObject currentDevice, SmartObjectEventArgs args)
 {
     if (args.Sig.BoolValue)
     {
         if (args.Sig.Number < 11) // 1 to 9
         {
             keypadText += args.Sig.Name;
         }
         else if (args.Sig.Number == 11) // MISC_1 - could be anything but we'll make it clear for this example
         {
             keypadText = "";
         }
         else if (args.Sig.Number == 12) // MISC_2 - could be anything but we'll make it enter for this example
         {
             keypadText = "PIN " + (keypadText.Equals(pin) ? "Correct": "Wrong");
             Thread keypad = new Thread(ResetPinTextThread, currentDevice);
         }
         UI.SetSerialJoin(currentDevice, SER_INPUT, keypadText);
     }
     else // release
     {
     }
 }