Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="key"></param>
        public SecondsCountdownTimer(string key)
        {
            Key = key;
            IsRunningFeedback = new BoolFeedback(() => _IsRunning);

            TimeRemainingFeedback = new StringFeedback(() =>
            {
                // Need to handle up and down here.

                if (StartTime == null || FinishTime == null)
                {
                    return("");
                }
                var timeSpan = FinishTime - DateTime.Now;
                return(Math.Round(timeSpan.TotalSeconds).ToString());
            });

            PercentFeedback = new IntFeedback(() =>
            {
                if (StartTime == null || FinishTime == null)
                {
                    return(0);
                }
                double percent = (FinishTime - DateTime.Now).TotalSeconds
                                 / (FinishTime - StartTime).TotalSeconds
                                 * 100;
                return((int)percent);
            });
        }
Пример #2
0
        public MockDisplay(string key, string name)
            : base(key, name)
        {
            HdmiIn1 = new RoutingInputPort(RoutingPortNames.HdmiIn1, eRoutingSignalType.Audio | eRoutingSignalType.Video,
                                           eRoutingPortConnectionType.Hdmi, null, this);
            HdmiIn2 = new RoutingInputPort(RoutingPortNames.HdmiIn2, eRoutingSignalType.Audio | eRoutingSignalType.Video,
                                           eRoutingPortConnectionType.Hdmi, null, this);
            HdmiIn3 = new RoutingInputPort(RoutingPortNames.HdmiIn3, eRoutingSignalType.Audio | eRoutingSignalType.Video,
                                           eRoutingPortConnectionType.Hdmi, null, this);
            ComponentIn1 = new RoutingInputPort(RoutingPortNames.ComponentIn, eRoutingSignalType.Video,
                                                eRoutingPortConnectionType.Component, null, this);
            VgaIn1 = new RoutingInputPort(RoutingPortNames.VgaIn, eRoutingSignalType.Video,
                                          eRoutingPortConnectionType.Composite, null, this);
            InputPorts.AddRange(new[] { HdmiIn1, HdmiIn2, HdmiIn3, ComponentIn1, VgaIn1 });

            VolumeLevelFeedback = new IntFeedback(() => { return(_FakeVolumeLevel); });
            MuteFeedback        = new BoolFeedback("MuteOn", () => _IsMuted);
        }
Пример #3
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="key"></param>
        public SecondsCountdownTimer(string key)
        {
            Key = key;
            IsRunningFeedback = new BoolFeedback(() => _IsRunning);

            TimeRemainingFeedback = new StringFeedback(() =>
            {
                // Need to handle up and down here.

                if (StartTime == null || FinishTime == null)
                {
                    return("");
                }
                var timeSpan = FinishTime - DateTime.Now;

                if (timeSpan.TotalSeconds < 60)
                {
                    return(Math.Round(timeSpan.TotalSeconds).ToString());
                }
                else
                {
                    Debug.Console(2, this, "timeSpan.Minutes == {0}, timeSpan.Seconds == {1}", timeSpan.Minutes, timeSpan.Seconds);
                    return(String.Format("{0:D2}:{1:D2}",
                                         timeSpan.Minutes,
                                         timeSpan.Seconds));
                }
            });

            PercentFeedback = new IntFeedback(() =>
            {
                if (StartTime == null || FinishTime == null)
                {
                    return(0);
                }
                double percent = (FinishTime - DateTime.Now).TotalSeconds
                                 / (FinishTime - StartTime).TotalSeconds
                                 * 100;
                return((int)percent);
            });
        }
Пример #4
0
        protected void LinkDisplayToApi(DisplayBase displayDevice, BasicTriList trilist, uint joinStart, string joinMapKey,
                                        EiscApiAdvanced bridge)
        {
            var inputNumber = 0;
            var inputKeys   = new List <string>();

            var joinMap = new DisplayControllerJoinMap();

            var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey);

            if (!string.IsNullOrEmpty(joinMapSerialized))
            {
                joinMap = JsonConvert.DeserializeObject <DisplayControllerJoinMap>(joinMapSerialized);
            }

            joinMap.OffsetJoinNumbers(joinStart);

            Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
            Debug.Console(0, "Linking to Display: {0}", displayDevice.Name);

            trilist.StringInput[joinMap.Name].StringValue = displayDevice.Name;

            var commMonitor = displayDevice as ICommunicationMonitor;

            if (commMonitor != null)
            {
                commMonitor.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]);
            }

            var inputNumberFeedback = new IntFeedback(() => inputNumber);

            // Two way feedbacks
            var twoWayDisplay = displayDevice as TwoWayDisplayBase;

            if (twoWayDisplay != null)
            {
                trilist.SetBool(joinMap.IsTwoWayDisplay, true);

                twoWayDisplay.CurrentInputFeedback.OutputChange += (o, a) => Debug.Console(0, "CurrentInputFeedback_OutputChange {0}", a.StringValue);


                inputNumberFeedback.LinkInputSig(trilist.UShortInput[joinMap.InputSelect]);
            }

            // Power Off
            trilist.SetSigTrueAction(joinMap.PowerOff, () =>
            {
                inputNumber = 102;
                inputNumberFeedback.FireUpdate();
                displayDevice.PowerOff();
            });

            displayDevice.PowerIsOnFeedback.OutputChange += (o, a) =>
            {
                if (!a.BoolValue)
                {
                    inputNumber = 102;
                    inputNumberFeedback.FireUpdate();
                }
                else
                {
                    inputNumber = 0;
                    inputNumberFeedback.FireUpdate();
                }
            };

            displayDevice.PowerIsOnFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.PowerOff]);

            // PowerOn
            trilist.SetSigTrueAction(joinMap.PowerOn, () =>
            {
                inputNumber = 0;
                inputNumberFeedback.FireUpdate();
                displayDevice.PowerOn();
            });


            displayDevice.PowerIsOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.PowerOn]);

            var count = 1;

            foreach (var input in displayDevice.InputPorts)
            {
                inputKeys.Add(input.Key);
                var tempKey = inputKeys.ElementAt(count - 1);
                trilist.SetSigTrueAction((ushort)(joinMap.InputSelectOffset + count), () => displayDevice.ExecuteSwitch(displayDevice.InputPorts[tempKey].Selector));
                Debug.Console(2, displayDevice, "Setting Input Select Action on Digital Join {0} to Input: {1}", joinMap.InputSelectOffset + count, displayDevice.InputPorts[tempKey].Key.ToString());
                trilist.StringInput[(ushort)(joinMap.InputNamesOffset + count)].StringValue = input.Key.ToString();
                count++;
            }

            Debug.Console(2, displayDevice, "Setting Input Select Action on Analog Join {0}", joinMap.InputSelect);
            trilist.SetUShortSigAction(joinMap.InputSelect, (a) =>
            {
                if (a == 0)
                {
                    displayDevice.PowerOff();
                    inputNumber = 0;
                }
                else if (a > 0 && a < displayDevice.InputPorts.Count && a != inputNumber)
                {
                    displayDevice.ExecuteSwitch(displayDevice.InputPorts.ElementAt(a - 1).Selector);
                    inputNumber = a;
                }
                else if (a == 102)
                {
                    displayDevice.PowerToggle();
                }
                if (twoWayDisplay != null)
                {
                    inputNumberFeedback.FireUpdate();
                }
            });


            var volumeDisplay = displayDevice as IBasicVolumeControls;

            if (volumeDisplay == null)
            {
                return;
            }

            trilist.SetBoolSigAction(joinMap.VolumeUp, volumeDisplay.VolumeUp);
            trilist.SetBoolSigAction(joinMap.VolumeDown, volumeDisplay.VolumeDown);
            trilist.SetSigTrueAction(joinMap.VolumeMute, volumeDisplay.MuteToggle);

            var volumeDisplayWithFeedback = volumeDisplay as IBasicVolumeWithFeedback;

            if (volumeDisplayWithFeedback == null)
            {
                return;
            }

            trilist.SetUShortSigAction(joinMap.VolumeLevel, volumeDisplayWithFeedback.SetVolume);
            volumeDisplayWithFeedback.VolumeLevelFeedback.LinkInputSig(trilist.UShortInput[joinMap.VolumeLevel]);
            volumeDisplayWithFeedback.MuteFeedback.LinkInputSig(trilist.BooleanInput[joinMap.VolumeMute]);
        }
Пример #5
0
        protected void LinkDisplayToApi(DisplayBase displayDevice, BasicTriList trilist, uint joinStart, string joinMapKey,
                                        EiscApiAdvanced bridge)
        {
            var inputNumber = 0;
            var inputKeys   = new List <string>();

            var joinMap = new DisplayControllerJoinMap(joinStart);

            var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey);

            if (!string.IsNullOrEmpty(joinMapSerialized))
            {
                joinMap = JsonConvert.DeserializeObject <DisplayControllerJoinMap>(joinMapSerialized);
            }

            bridge.AddJoinMap(Key, joinMap);

            Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
            Debug.Console(0, "Linking to Display: {0}", displayDevice.Name);

            trilist.StringInput[joinMap.Name.JoinNumber].StringValue = displayDevice.Name;

            var commMonitor = displayDevice as ICommunicationMonitor;

            if (commMonitor != null)
            {
                commMonitor.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]);
            }

            var inputNumberFeedback = new IntFeedback(() => inputNumber);

            // Two way feedbacks
            var twoWayDisplay = displayDevice as TwoWayDisplayBase;

            if (twoWayDisplay != null)
            {
                trilist.SetBool(joinMap.IsTwoWayDisplay.JoinNumber, true);

                twoWayDisplay.CurrentInputFeedback.OutputChange += (o, a) => Debug.Console(0, "CurrentInputFeedback_OutputChange {0}", a.StringValue);


                inputNumberFeedback.LinkInputSig(trilist.UShortInput[joinMap.InputSelect.JoinNumber]);
            }

            // Power Off
            trilist.SetSigTrueAction(joinMap.PowerOff.JoinNumber, () =>
            {
                inputNumber = 102;
                inputNumberFeedback.FireUpdate();
                displayDevice.PowerOff();
            });

            displayDevice.PowerIsOnFeedback.OutputChange += (o, a) =>
            {
                if (!a.BoolValue)
                {
                    inputNumber = 102;
                    inputNumberFeedback.FireUpdate();
                }
                else
                {
                    inputNumber = 0;
                    inputNumberFeedback.FireUpdate();
                }
            };

            displayDevice.PowerIsOnFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.PowerOff.JoinNumber]);

            // PowerOn
            trilist.SetSigTrueAction(joinMap.PowerOn.JoinNumber, () =>
            {
                inputNumber = 0;
                inputNumberFeedback.FireUpdate();
                displayDevice.PowerOn();
            });


            displayDevice.PowerIsOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.PowerOn.JoinNumber]);

            for (int i = 0; i < displayDevice.InputPorts.Count; i++)
            {
                if (i < joinMap.InputNamesOffset.JoinSpan)
                {
                    inputKeys.Add(displayDevice.InputPorts[i].Key);
                    var tempKey = inputKeys.ElementAt(i);
                    trilist.SetSigTrueAction((ushort)(joinMap.InputSelectOffset.JoinNumber + i),
                                             () => displayDevice.ExecuteSwitch(displayDevice.InputPorts[tempKey].Selector));
                    Debug.Console(2, displayDevice, "Setting Input Select Action on Digital Join {0} to Input: {1}",
                                  joinMap.InputSelectOffset.JoinNumber + i, displayDevice.InputPorts[tempKey].Key.ToString());
                    trilist.StringInput[(ushort)(joinMap.InputNamesOffset.JoinNumber + i)].StringValue = displayDevice.InputPorts[i].Key.ToString();
                }
                else
                {
                    Debug.Console(0, displayDevice, Debug.ErrorLogLevel.Warning, "Device has {0} inputs.  The Join Map allows up to {1} inputs.  Discarding inputs {2} - {3} from bridge.",
                                  displayDevice.InputPorts.Count, joinMap.InputNamesOffset.JoinSpan, i + 1, displayDevice.InputPorts.Count);
                }
            }

            Debug.Console(2, displayDevice, "Setting Input Select Action on Analog Join {0}", joinMap.InputSelect);
            trilist.SetUShortSigAction(joinMap.InputSelect.JoinNumber, (a) =>
            {
                if (a == 0)
                {
                    displayDevice.PowerOff();
                    inputNumber = 0;
                }
                else if (a > 0 && a < displayDevice.InputPorts.Count && a != inputNumber)
                {
                    displayDevice.ExecuteSwitch(displayDevice.InputPorts.ElementAt(a - 1).Selector);
                    inputNumber = a;
                }
                else if (a == 102)
                {
                    displayDevice.PowerToggle();
                }
                if (twoWayDisplay != null)
                {
                    inputNumberFeedback.FireUpdate();
                }
            });


            var volumeDisplay = displayDevice as IBasicVolumeControls;

            if (volumeDisplay == null)
            {
                return;
            }

            trilist.SetBoolSigAction(joinMap.VolumeUp.JoinNumber, volumeDisplay.VolumeUp);
            trilist.SetBoolSigAction(joinMap.VolumeDown.JoinNumber, volumeDisplay.VolumeDown);
            trilist.SetSigTrueAction(joinMap.VolumeMute.JoinNumber, volumeDisplay.MuteToggle);

            var volumeDisplayWithFeedback = volumeDisplay as IBasicVolumeWithFeedback;

            if (volumeDisplayWithFeedback == null)
            {
                return;
            }
            trilist.SetSigTrueAction(joinMap.VolumeMuteOn.JoinNumber, volumeDisplayWithFeedback.MuteOn);
            trilist.SetSigTrueAction(joinMap.VolumeMuteOff.JoinNumber, volumeDisplayWithFeedback.MuteOff);


            trilist.SetUShortSigAction(joinMap.VolumeLevel.JoinNumber, volumeDisplayWithFeedback.SetVolume);
            volumeDisplayWithFeedback.VolumeLevelFeedback.LinkInputSig(trilist.UShortInput[joinMap.VolumeLevel.JoinNumber]);
            volumeDisplayWithFeedback.MuteFeedback.LinkInputSig(trilist.BooleanInput[joinMap.VolumeMute.JoinNumber]);
            volumeDisplayWithFeedback.MuteFeedback.LinkInputSig(trilist.BooleanInput[joinMap.VolumeMuteOn.JoinNumber]);
            volumeDisplayWithFeedback.MuteFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.VolumeMuteOff.JoinNumber]);
        }
Пример #6
0
 public InUseTracking()
 {
     InUseFeedback      = new BoolFeedback(() => _Users.Count > 0);
     InUseCountFeedback = new IntFeedback(() => _Users.Count);
 }