Exemplo n.º 1
0
        private void SetLanguageInfo(BasicTriList trilist, I18NUtilityJoinMap joinMap)
        {
            if (_languagesConfig == null)
            {
                Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "No Language configs loaded.");
                return;
            }
            Debug.Console(1, this, "Setting supported language information");
            ushort i = 0;

            if (_languagesConfig.LanguageDefinitions.Count == 0)
            {
                return;
            }

            foreach (var lang in _languagesConfig.LanguageDefinitions.Select(language => language.Value))
            {
                Debug.Console(1, this, "Setting supported language information for locale {0}", lang.LocaleName);

                trilist.SetBool(joinMap.SupportedLanguageEnable.JoinNumber + i, lang.Enable);
                trilist.SetString(joinMap.SupportedLanguagesStart.JoinNumber + i, lang.LocaleName);
                trilist.SetString(joinMap.SupportedLanguagesDescriptionStart.JoinNumber + i, lang.FriendlyName);

                i++;
            }
        }
Exemplo n.º 2
0
        public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge)
        {
            var joinMap = new IBasicCommunicationJoinMap(joinStart);

            var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey);

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

            bridge.AddJoinMap(Key, joinMap);

            if (CommPort == null)
            {
                Debug.Console(1, this, "Unable to link device '{0}'.  CommPort is null", Key);
                return;
            }

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

            // this is a permanent event handler. This cannot be -= from event
            CommPort.TextReceived += (s, a) =>
            {
                Debug.Console(2, this, "RX: {0}", a.Text);
                trilist.SetString(joinMap.TextReceived.JoinNumber, a.Text);
            };
            trilist.SetStringSigAction(joinMap.SendText.JoinNumber, s => CommPort.SendText(s));
            trilist.SetStringSigAction(joinMap.SetPortConfig.JoinNumber, SetPortConfig);


            var sComm = CommPort as ISocketStatus;

            if (sComm == null)
            {
                return;
            }
            sComm.ConnectionChange += (s, a) =>
            {
                trilist.SetUshort(joinMap.Status.JoinNumber, (ushort)(a.Client.ClientStatus));
                trilist.SetBool(joinMap.Connected.JoinNumber, a.Client.ClientStatus ==
                                SocketStatus.SOCKET_STATUS_CONNECTED);
            };

            trilist.SetBoolSigAction(joinMap.Connect.JoinNumber, b =>
            {
                if (b)
                {
                    sComm.Connect();
                }
                else
                {
                    sComm.Disconnect();
                }
            });
        }
        public static void LinkToApi(this GenericComm comm, BasicTriList trilist, uint joinStart, string joinMapKey)
        {
            IBasicCommunicationJoinMap joinMap = new IBasicCommunicationJoinMap();

            var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey);

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

            if (comm.CommPort == null)
            {
                Debug.Console(1, comm, "Unable to link device '{0}'.  CommPort is null", comm.Key);
                return;
            }

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

            // this is a permanent event handler. This cannot be -= from event
            comm.CommPort.TextReceived += (s, a) =>
            {
                Debug.Console(2, comm, "RX: {0}", a.Text);
                trilist.SetString(joinMap.TextReceived, a.Text);
            };
            trilist.SetStringSigAction(joinMap.SendText, new Action <string>(s => comm.CommPort.SendText(s)));
            trilist.SetStringSigAction(joinMap.SetPortConfig, new Action <string>(s => comm.SetPortConfig(s)));


            var sComm = comm.CommPort as ISocketStatus;

            if (sComm != null)
            {
                sComm.ConnectionChange += (s, a) =>
                {
                    trilist.SetUshort(joinMap.Status, (ushort)(a.Client.ClientStatus));
                    trilist.SetBool(joinMap.Connected, a.Client.ClientStatus ==
                                    Crestron.SimplSharp.CrestronSockets.SocketStatus.SOCKET_STATUS_CONNECTED);
                };

                trilist.SetBoolSigAction(joinMap.Connect, new Action <bool>(b =>
                {
                    if (b)
                    {
                        sComm.Connect();
                    }
                    else
                    {
                        sComm.Disconnect();
                    }
                }));
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Hides CurrentJoin and shows join. Will check and re-set signal if join
        /// equals CurrentJoin
        /// </summary>
        public void ShowInterlocked(uint join)
        {
            var prevJoin = CurrentJoin;
            var wasShown = _IsShown;

            Debug.Console(2, "Trilist {0:X2}, interlock swapping {1} for {2}", TriList.ID, CurrentJoin, join);
            if (CurrentJoin == join && TriList.BooleanInput[join].BoolValue)
            {
                return;
            }
            SetButDontShow(join);
            TriList.SetBool(CurrentJoin, true);
            IsShown = true;

            OnStatusChange(prevJoin, CurrentJoin, wasShown, IsShown);
        }
Exemplo n.º 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="appServerController"></param>
        protected override void CustomRegisterWithAppServer(MobileControlSystemController appServerController)
        {
            var asc = appServerController;

            EISC.SetStringSigAction(SHookState, s =>
            {
                CurrentCallItem.Status = (eCodecCallStatus)Enum.Parse(typeof(eCodecCallStatus), s, true);
                PostFullStatus();                 // SendCallsList();
            });

            EISC.SetStringSigAction(SCurrentCallNumber, s =>
            {
                CurrentCallItem.Number = s;
                PostCallsList();
            });

            EISC.SetStringSigAction(SCurrentCallName, s =>
            {
                CurrentCallItem.Name = s;
                PostCallsList();
            });

            EISC.SetStringSigAction(SCallDirection, s =>
            {
                CurrentCallItem.Direction = (eCodecCallDirection)Enum.Parse(typeof(eCodecCallDirection), s, true);
                PostCallsList();
            });

            EISC.SetBoolSigAction(BCallIncoming, b =>
            {
                if (b)
                {
                    var ica = new CodecActiveCallItem()
                    {
                        Direction = eCodecCallDirection.Incoming,
                        Id        = "-video-incoming",
                        Name      = EISC.GetString(SIncomingCallName),
                        Number    = EISC.GetString(SIncomingCallNumber),
                        Status    = eCodecCallStatus.Ringing,
                        Type      = eCodecCallType.Video
                    };
                    IncomingCallItem = ica;
                }
                else
                {
                    IncomingCallItem = null;
                }
                PostCallsList();
            });

            EISC.SetBoolSigAction(BCameraSupportsAutoMode, b =>
            {
                PostStatusMessage(new
                {
                    cameraSupportsAutoMode = b
                });
            });
            EISC.SetBoolSigAction(BCameraSupportsOffMode, b =>
            {
                PostStatusMessage(new
                {
                    cameraSupportsOffMode = b
                });
            });

            // Directory insanity
            EISC.SetUShortSigAction(UDirectoryRowCount, u =>
            {
                // The length of the list comes in before the list does.
                // Splice the sig change operation onto the last string sig that will be changing
                // when the directory entries make it through.
                if (PreviousDirectoryLength > 0)
                {
                    EISC.ClearStringSigAction(SDirectoryEntriesStart + PreviousDirectoryLength - 1);
                }
                EISC.SetStringSigAction(SDirectoryEntriesStart + u - 1, s => PostDirectory());
                PreviousDirectoryLength = u;
            });

            EISC.SetStringSigAction(SDirectoryEntrySelectedName, s =>
            {
                PostStatusMessage(new
                {
                    directoryContactSelected = new
                    {
                        name = EISC.GetString(SDirectoryEntrySelectedName),
                    }
                });
            });

            EISC.SetStringSigAction(SDirectoryEntrySelectedNumber, s =>
            {
                PostStatusMessage(new
                {
                    directoryContactSelected = new
                    {
                        number = EISC.GetString(SDirectoryEntrySelectedNumber),
                    }
                });
            });

            EISC.SetStringSigAction(SDirectorySelectedFolderName, s => PostStatusMessage(new
            {
                directorySelectedFolderName = EISC.GetString(SDirectorySelectedFolderName)
            }));

            EISC.SetSigTrueAction(BCameraModeAuto, () => PostCameraMode());
            EISC.SetSigTrueAction(BCameraModeManual, () => PostCameraMode());
            EISC.SetSigTrueAction(BCameraModeOff, () => PostCameraMode());

            EISC.SetBoolSigAction(BCameraSelfView, b => PostStatusMessage(new
            {
                cameraSelfView = b
            }));

            EISC.SetUShortSigAction(UCameraNumberSelect, (u) => PostSelectedCamera());


            // Add press and holds using helper action
            Action <string, uint> addPHAction = (s, u) =>
                                                AppServerController.AddAction(MessagePath + s, new PressAndHoldAction(b => EISC.SetBool(u, b)));

            addPHAction("/cameraUp", BCameraControlUp);
            addPHAction("/cameraDown", BCameraControlDown);
            addPHAction("/cameraLeft", BCameraControlLeft);
            addPHAction("/cameraRight", BCameraControlRight);
            addPHAction("/cameraZoomIn", BCameraControlZoomIn);
            addPHAction("/cameraZoomOut", BCameraControlZoomOut);

            // Add straight pulse calls using helper action
            Action <string, uint> addAction = (s, u) =>
                                              AppServerController.AddAction(MessagePath + s, new Action(() => EISC.PulseBool(u, 100)));

            addAction("/endCallById", BDialHangup);
            addAction("/endAllCalls", BDialHangup);
            addAction("/acceptById", BIncomingAnswer);
            addAction("/rejectById", BIncomingReject);
            addAction("/speedDial1", BSpeedDial1);
            addAction("/speedDial2", BSpeedDial2);
            addAction("/speedDial3", BSpeedDial3);
            addAction("/speedDial4", BSpeedDial4);
            addAction("/cameraModeAuto", BCameraModeAuto);
            addAction("/cameraModeManual", BCameraModeManual);
            addAction("/cameraModeOff", BCameraModeOff);
            addAction("/cameraSelfView", BCameraSelfView);
            addAction("/cameraLayout", BCameraLayout);

            asc.AddAction("/cameraSelect", new Action <string>(SelectCamera));

            // camera presets
            for (uint i = 0; i < 6; i++)
            {
                addAction("/cameraPreset" + (i + 1), BCameraPresetStart + i);
            }

            asc.AddAction(MessagePath + "/isReady", new Action(PostIsReady));
            // Get status
            asc.AddAction(MessagePath + "/fullStatus", new Action(PostFullStatus));
            // Dial on string
            asc.AddAction(MessagePath + "/dial", new Action <string>(s =>
                                                                     EISC.SetString(SCurrentDialString, s)));
            // Pulse DTMF
            asc.AddAction(MessagePath + "/dtmf", new Action <string>(s =>
            {
                if (DTMFMap.ContainsKey(s))
                {
                    EISC.PulseBool(DTMFMap[s], 100);
                }
            }));

            // Directory madness
            asc.AddAction(MessagePath + "/directoryRoot", new Action(() => EISC.PulseBool(BDirectoryRoot)));
            asc.AddAction(MessagePath + "/directoryBack", new Action(() => EISC.PulseBool(BDirectoryFolderBack)));
            asc.AddAction(MessagePath + "/directoryById", new Action <string>(s =>
            {
                // the id should contain the line number to forward to simpl
                try
                {
                    var u = ushort.Parse(s);
                    EISC.SetUshort(UDirectorySelectRow, u);
                    EISC.PulseBool(BDirectoryLineSelected);
                }
                catch (Exception)
                {
                    Debug.Console(1, this, Debug.ErrorLogLevel.Warning,
                                  "/directoryById request contains non-numeric ID incompatible with DDVC bridge");
                }
            }));
            asc.AddAction(MessagePath + "/directorySelectContact", new Action <string>(s =>
            {
                try
                {
                    var u = ushort.Parse(s);
                    EISC.SetUshort(UDirectorySelectRow, u);
                    EISC.PulseBool(BDirectoryLineSelected);
                }
                catch
                {
                }
            }));
            asc.AddAction(MessagePath + "/directoryDialContact", new Action(() => {
                EISC.PulseBool(BDirectoryDialSelectedLine);
            }));
            asc.AddAction(MessagePath + "/getDirectory", new Action(() =>
            {
                if (EISC.GetUshort(UDirectoryRowCount) > 0)
                {
                    PostDirectory();
                }
                else
                {
                    EISC.PulseBool(BDirectoryRoot);
                }
            }));
        }
Exemplo n.º 6
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]);
        }
Exemplo n.º 7
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]);
        }
        public static void LinkToApiExt(this PanasonicDisplay displayDevice, BasicTriList trilist, uint joinStart, string joinMapKey)
        {
            DisplayControllerJoinMap joinMap = new DisplayControllerJoinMap();

            var JoinMapSerialized = JoinMapHelper.GetJoinMapForDevice(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]);
            }

            displayDevice.InputNumberFeedback.LinkInputSig(trilist.UShortInput[joinMap.InputSelect]);

            // Two way feedbacks
            var twoWayDisplay = displayDevice as PepperDash.Essentials.Core.TwoWayDisplayBase;

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

                twoWayDisplay.CurrentInputFeedback.OutputChange += new EventHandler <FeedbackEventArgs>(CurrentInputFeedback_OutputChange);
            }

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

            displayDevice.PowerIsOnFeedback.OutputChange += new EventHandler <FeedbackEventArgs>(PowerIsOnFeedback_OutputChange);
            displayDevice.PowerIsOnFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.PowerOff]);

            // PowerOn
            trilist.SetSigTrueAction(joinMap.PowerOn, () =>
            {
                displayDevice.PowerOn();
            });


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

            int count       = 1;
            var displayBase = displayDevice as PepperDash.Essentials.Core.DisplayBase;

            foreach (var input in displayDevice.InputPorts)
            {
                //displayDevice.InputKeys.Add(input.Key.ToString());
                //var tempKey = InputKeys.ElementAt(count - 1);
                trilist.SetSigTrueAction((ushort)(joinMap.InputSelectOffset + count), () => { displayDevice.ExecuteSwitch(displayDevice.InputPorts[input.Key.ToString()].Selector); });
                Debug.Console(2, displayDevice, "Setting Input Select Action on Digital Join {0} to Input: {1}", joinMap.InputSelectOffset + count, displayDevice.InputPorts[input.Key.ToString()].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();
                }
                else if (a > 0 && a < displayDevice.InputPorts.Count)
                {
                    displayDevice.ExecuteSwitch(displayDevice.InputPorts.ElementAt(a - 1).Selector);
                }
                else if (a == 102)
                {
                    displayDevice.PowerToggle();
                }
                Debug.Console(2, displayDevice, "InputChange {0}", a);
            });


            var volumeDisplay = displayDevice as IBasicVolumeControls;

            if (volumeDisplay != null)
            {
                trilist.SetBoolSigAction(joinMap.VolumeUp, (b) => volumeDisplay.VolumeUp(b));
                trilist.SetBoolSigAction(joinMap.VolumeDown, (b) => volumeDisplay.VolumeDown(b));
                trilist.SetSigTrueAction(joinMap.VolumeMute, () => volumeDisplay.MuteToggle());

                var volumeDisplayWithFeedback = volumeDisplay as IBasicVolumeWithFeedback;
                if (volumeDisplayWithFeedback != null)
                {
                    volumeDisplayWithFeedback.VolumeLevelFeedback.LinkInputSig(trilist.UShortInput[joinMap.VolumeLevelFB]);
                    volumeDisplayWithFeedback.MuteFeedback.LinkInputSig(trilist.BooleanInput[joinMap.VolumeMute]);
                }
            }
        }
Exemplo n.º 9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="appServerController"></param>
        protected override void CustomRegisterWithAppServer(MobileControlSystemController appServerController)
        {
            //EISC.SetStringSigAction(SCurrentDialString, s => PostStatusMessage(new { currentDialString = s }));

            EISC.SetStringSigAction(SHookState, s =>
            {
                CurrentCallItem.Status = (eCodecCallStatus)Enum.Parse(typeof(eCodecCallStatus), s, true);
                //GetCurrentCallList();
                SendFullStatus();
            });

            EISC.SetStringSigAction(SCurrentCallNumber, s =>
            {
                CurrentCallItem.Number = s;
                SendCallsList();
            });

            EISC.SetStringSigAction(SCurrentCallName, s =>
            {
                CurrentCallItem.Name = s;
                SendCallsList();
            });

            EISC.SetStringSigAction(SCallDirection, s =>
            {
                CurrentCallItem.Direction = (eCodecCallDirection)Enum.Parse(typeof(eCodecCallDirection), s, true);
                SendCallsList();
            });

            // Add press and holds using helper
            Action <string, uint> addPHAction = (s, u) =>
                                                AppServerController.AddAction(MessagePath + s, new PressAndHoldAction(b => EISC.SetBool(u, b)));

            // Add straight pulse calls
            Action <string, uint> addAction = (s, u) =>
                                              AppServerController.AddAction(MessagePath + s, new Action(() => EISC.PulseBool(u, 100)));

            addAction("/endCallById", BDialHangupOnHook);
            addAction("/endAllCalls", BDialHangupOnHook);
            addAction("/acceptById", BIncomingAnswer);
            addAction("/rejectById", BIncomingReject);
            addAction("/speedDial1", BSpeedDial1);
            addAction("/speedDial2", BSpeedDial2);
            addAction("/speedDial3", BSpeedDial3);
            addAction("/speedDial4", BSpeedDial4);

            // Get status
            AppServerController.AddAction(MessagePath + "/fullStatus", new Action(SendFullStatus));
            // Dial on string
            AppServerController.AddAction(MessagePath + "/dial", new Action <string>(s => EISC.SetString(SCurrentDialString, s)));
            // Pulse DTMF
            AppServerController.AddAction(MessagePath + "/dtmf", new Action <string>(s =>
            {
                if (DTMFMap.ContainsKey(s))
                {
                    EISC.PulseBool(DTMFMap[s], 100);
                }
            }));
        }
Exemplo n.º 10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="appServerController"></param>
        protected override void CustomRegisterWithAppServer(MobileControlSystemController appServerController)
        {
            var asc = appServerController;

            EISC.SetStringSigAction(JoinMap.HookState.JoinNumber, s =>
            {
                CurrentCallItem.Status = (eCodecCallStatus)Enum.Parse(typeof(eCodecCallStatus), s, true);
                PostFullStatus();                 // SendCallsList();
            });

            EISC.SetStringSigAction(JoinMap.CurrentCallNumber.JoinNumber, s =>
            {
                CurrentCallItem.Number = s;
                PostCallsList();
            });

            EISC.SetStringSigAction(JoinMap.CurrentCallName.JoinNumber, s =>
            {
                CurrentCallItem.Name = s;
                PostCallsList();
            });

            EISC.SetStringSigAction(JoinMap.CallDirection.JoinNumber, s =>
            {
                CurrentCallItem.Direction = (eCodecCallDirection)Enum.Parse(typeof(eCodecCallDirection), s, true);
                PostCallsList();
            });

            EISC.SetBoolSigAction(JoinMap.IncomingCall.JoinNumber, b =>
            {
                if (b)
                {
                    var ica = new CodecActiveCallItem()
                    {
                        Direction = eCodecCallDirection.Incoming,
                        Id        = "-video-incoming",
                        Name      = EISC.GetString(JoinMap.IncomingCallName.JoinNumber),
                        Number    = EISC.GetString(JoinMap.IncomingCallNumber.JoinNumber),
                        Status    = eCodecCallStatus.Ringing,
                        Type      = eCodecCallType.Video
                    };
                    IncomingCallItem = ica;
                }
                else
                {
                    IncomingCallItem = null;
                }
                PostCallsList();
            });

            EISC.SetBoolSigAction(JoinMap.CameraSupportsAutoMode.JoinNumber, b =>
            {
                PostStatusMessage(new
                {
                    cameraSupportsAutoMode = b
                });
            });
            EISC.SetBoolSigAction(JoinMap.CameraSupportsOffMode.JoinNumber, b =>
            {
                PostStatusMessage(new
                {
                    cameraSupportsOffMode = b
                });
            });

            // Directory insanity
            EISC.SetUShortSigAction(JoinMap.DirectoryRowCount.JoinNumber, u =>
            {
                // The length of the list comes in before the list does.
                // Splice the sig change operation onto the last string sig that will be changing
                // when the directory entries make it through.
                if (PreviousDirectoryLength > 0)
                {
                    EISC.ClearStringSigAction(JoinMap.DirectoryEntriesStart.JoinNumber + PreviousDirectoryLength - 1);
                }
                EISC.SetStringSigAction(JoinMap.DirectoryEntriesStart.JoinNumber + u - 1, s => PostDirectory());
                PreviousDirectoryLength = u;
            });

            EISC.SetStringSigAction(JoinMap.DirectoryEntrySelectedName.JoinNumber, s =>
            {
                PostStatusMessage(new
                {
                    directoryContactSelected = new
                    {
                        name = EISC.GetString(JoinMap.DirectoryEntrySelectedName.JoinNumber),
                    }
                });
            });

            EISC.SetStringSigAction(JoinMap.DirectoryEntrySelectedNumber.JoinNumber, s =>
            {
                PostStatusMessage(new
                {
                    directoryContactSelected = new
                    {
                        number = EISC.GetString(JoinMap.DirectoryEntrySelectedNumber.JoinNumber),
                    }
                });
            });

            EISC.SetStringSigAction(JoinMap.DirectorySelectedFolderName.JoinNumber, s => PostStatusMessage(new
            {
                directorySelectedFolderName = EISC.GetString(JoinMap.DirectorySelectedFolderName.JoinNumber)
            }));

            EISC.SetSigTrueAction(JoinMap.CameraModeAuto.JoinNumber, () => PostCameraMode());
            EISC.SetSigTrueAction(JoinMap.CameraModeManual.JoinNumber, () => PostCameraMode());
            EISC.SetSigTrueAction(JoinMap.CameraModeOff.JoinNumber, () => PostCameraMode());

            EISC.SetBoolSigAction(JoinMap.CameraSelfView.JoinNumber, b => PostStatusMessage(new
            {
                cameraSelfView = b
            }));

            EISC.SetUShortSigAction(JoinMap.CameraNumberSelect.JoinNumber, (u) => PostSelectedCamera());


            // Add press and holds using helper action
            Action <string, uint> addPHAction = (s, u) =>
                                                AppServerController.AddAction(MessagePath + s, new PressAndHoldAction(b => EISC.SetBool(u, b)));

            addPHAction("/cameraUp", JoinMap.CameraTiltUp.JoinNumber);
            addPHAction("/cameraDown", JoinMap.CameraTiltDown.JoinNumber);
            addPHAction("/cameraLeft", JoinMap.CameraPanLeft.JoinNumber);
            addPHAction("/cameraRight", JoinMap.CameraPanRight.JoinNumber);
            addPHAction("/cameraZoomIn", JoinMap.CameraZoomIn.JoinNumber);
            addPHAction("/cameraZoomOut", JoinMap.CameraZoomOut.JoinNumber);

            // Add straight pulse calls using helper action
            Action <string, uint> addAction = (s, u) =>
                                              AppServerController.AddAction(MessagePath + s, new Action(() => EISC.PulseBool(u, 100)));

            addAction("/endCallById", JoinMap.EndCall.JoinNumber);
            addAction("/endAllCalls", JoinMap.EndCall.JoinNumber);
            addAction("/acceptById", JoinMap.IncomingAnswer.JoinNumber);
            addAction("/rejectById", JoinMap.IncomingReject.JoinNumber);

            var speeddialStart = JoinMap.SpeedDialStart.JoinNumber;
            var speeddialEnd   = JoinMap.SpeedDialStart.JoinNumber + JoinMap.SpeedDialStart.JoinSpan;

            var speedDialIndex = 1;

            for (uint i = speeddialStart; i < speeddialEnd; i++)
            {
                addAction(string.Format("/speedDial{0}", speedDialIndex), i);
                speedDialIndex++;
            }

            addAction("/cameraModeAuto", JoinMap.CameraModeAuto.JoinNumber);
            addAction("/cameraModeManual", JoinMap.CameraModeManual.JoinNumber);
            addAction("/cameraModeOff", JoinMap.CameraModeOff.JoinNumber);
            addAction("/cameraSelfView", JoinMap.CameraSelfView.JoinNumber);
            addAction("/cameraLayout", JoinMap.CameraLayout.JoinNumber);

            asc.AddAction("/cameraSelect", new Action <string>(SelectCamera));

            // camera presets
            for (uint i = 0; i < 6; i++)
            {
                addAction("/cameraPreset" + (i + 1), JoinMap.CameraPresetStart.JoinNumber + i);
            }

            asc.AddAction(MessagePath + "/isReady", new Action(PostIsReady));
            // Get status
            asc.AddAction(MessagePath + "/fullStatus", new Action(PostFullStatus));
            // Dial on string
            asc.AddAction(MessagePath + "/dial", new Action <string>(s =>
                                                                     EISC.SetString(JoinMap.CurrentDialString.JoinNumber, s)));
            // Pulse DTMF
            AppServerController.AddAction(MessagePath + "/dtmf", new Action <string>(s =>
            {
                var join = JoinMap.Joins[s];
                if (join != null)
                {
                    if (join.JoinNumber > 0)
                    {
                        EISC.PulseBool(join.JoinNumber, 100);
                    }
                }
            }));

            // Directory madness
            asc.AddAction(MessagePath + "/directoryRoot", new Action(() => EISC.PulseBool(JoinMap.DirectoryRoot.JoinNumber)));
            asc.AddAction(MessagePath + "/directoryBack", new Action(() => EISC.PulseBool(JoinMap.DirectoryFolderBack.JoinNumber)));
            asc.AddAction(MessagePath + "/directoryById", new Action <string>(s =>
            {
                // the id should contain the line number to forward to simpl
                try
                {
                    var u = ushort.Parse(s);
                    EISC.SetUshort(JoinMap.DirectorySelectRow.JoinNumber, u);
                    EISC.PulseBool(JoinMap.DirectoryLineSelected.JoinNumber);
                }
                catch (Exception)
                {
                    Debug.Console(1, this, Debug.ErrorLogLevel.Warning,
                                  "/directoryById request contains non-numeric ID incompatible with DDVC bridge");
                }
            }));
            asc.AddAction(MessagePath + "/directorySelectContact", new Action <string>(s =>
            {
                try
                {
                    var u = ushort.Parse(s);
                    EISC.SetUshort(JoinMap.DirectorySelectRow.JoinNumber, u);
                    EISC.PulseBool(JoinMap.DirectoryLineSelected.JoinNumber);
                }
                catch
                {
                }
            }));
            asc.AddAction(MessagePath + "/directoryDialContact", new Action(() => {
                EISC.PulseBool(JoinMap.DirectoryDialSelectedLine.JoinNumber);
            }));
            asc.AddAction(MessagePath + "/getDirectory", new Action(() =>
            {
                if (EISC.GetUshort(JoinMap.DirectoryRowCount.JoinNumber) > 0)
                {
                    PostDirectory();
                }
                else
                {
                    EISC.PulseBool(JoinMap.DirectoryRoot.JoinNumber);
                }
            }));
        }
Exemplo n.º 11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="appServerController"></param>
        protected override void CustomRegisterWithAppServer(MobileControlSystemController appServerController)
        {
            //EISC.SetStringSigAction(SCurrentDialString, s => PostStatusMessage(new { currentDialString = s }));

            EISC.SetStringSigAction(JoinMap.HookState.JoinNumber, s =>
            {
                CurrentCallItem.Status = (eCodecCallStatus)Enum.Parse(typeof(eCodecCallStatus), s, true);
                //GetCurrentCallList();
                SendFullStatus();
            });

            EISC.SetStringSigAction(JoinMap.CurrentCallNumber.JoinNumber, s =>
            {
                CurrentCallItem.Number = s;
                SendCallsList();
            });

            EISC.SetStringSigAction(JoinMap.CurrentCallName.JoinNumber, s =>
            {
                CurrentCallItem.Name = s;
                SendCallsList();
            });

            EISC.SetStringSigAction(JoinMap.CallDirection.JoinNumber, s =>
            {
                CurrentCallItem.Direction = (eCodecCallDirection)Enum.Parse(typeof(eCodecCallDirection), s, true);
                SendCallsList();
            });

            // Add press and holds using helper
            Action <string, uint> addPHAction = (s, u) =>
                                                AppServerController.AddAction(MessagePath + s, new PressAndHoldAction(b => EISC.SetBool(u, b)));

            // Add straight pulse calls
            Action <string, uint> addAction = (s, u) =>
                                              AppServerController.AddAction(MessagePath + s, new Action(() => EISC.PulseBool(u, 100)));

            addAction("/endCallById", JoinMap.EndCall.JoinNumber);
            addAction("/endAllCalls", JoinMap.EndCall.JoinNumber);
            addAction("/acceptById", JoinMap.IncomingAnswer.JoinNumber);
            addAction("/rejectById", JoinMap.IncomingReject.JoinNumber);

            var speeddialStart = JoinMap.SpeedDialStart.JoinNumber;
            var speeddialEnd   = JoinMap.SpeedDialStart.JoinNumber + JoinMap.SpeedDialStart.JoinSpan;

            var speedDialIndex = 1;

            for (uint i = speeddialStart; i < speeddialEnd; i++)
            {
                addAction(string.Format("/speedDial{0}", speedDialIndex), i);
                speedDialIndex++;
            }

            // Get status
            AppServerController.AddAction(MessagePath + "/fullStatus", new Action(SendFullStatus));
            // Dial on string
            AppServerController.AddAction(MessagePath + "/dial", new Action <string>(s => EISC.SetString(JoinMap.CurrentDialString.JoinNumber, s)));
            // Pulse DTMF
            AppServerController.AddAction(MessagePath + "/dtmf", new Action <string>(s =>
            {
                var join = JoinMap.Joins[s];
                if (join != null)
                {
                    if (join.JoinNumber > 0)
                    {
                        EISC.PulseBool(join.JoinNumber, 100);
                    }
                }
            }));
        }
Exemplo n.º 12
0
        protected override void CustomRegisterWithAppServer(MobileControlSystemController appServerController)
        {
            var asc = appServerController;

            asc.AddAction(MessagePath + "/fullStatus", new Action(SendCameraFullMessageObject));

            // Add press and holds using helper action
            Action <string, uint> addPHAction = (s, u) =>
                                                asc.AddAction(MessagePath + s, new PressAndHoldAction(b => EISC.SetBool(u, b)));

            addPHAction("/cameraUp", JoinMap.TiltUp.JoinNumber);
            addPHAction("/cameraDown", JoinMap.TiltDown.JoinNumber);
            addPHAction("/cameraLeft", JoinMap.PanLeft.JoinNumber);
            addPHAction("/cameraRight", JoinMap.PanRight.JoinNumber);
            addPHAction("/cameraZoomIn", JoinMap.ZoomIn.JoinNumber);
            addPHAction("/cameraZoomOut", JoinMap.ZoomOut.JoinNumber);

            Action <string, uint> addAction = (s, u) =>
                                              asc.AddAction(MessagePath + s, new Action(() => EISC.PulseBool(u, 100)));

            addAction("/cameraModeAuto", JoinMap.CameraModeAuto.JoinNumber);
            addAction("/cameraModeManual", JoinMap.CameraModeManual.JoinNumber);
            addAction("/cameraModeOff", JoinMap.CameraModeOff.JoinNumber);

            var presetStart = JoinMap.PresetRecallStart.JoinNumber;
            var presetEnd   = JoinMap.PresetRecallStart.JoinNumber + JoinMap.PresetRecallStart.JoinSpan;

            int presetId = 1;

            // camera presets
            for (uint i = presetStart; i <= presetEnd; i++)
            {
                addAction("/cameraPreset" + (presetId), i);
                presetId++;
            }
        }