Example #1
0
 /// <summary>
 ///
 /// </summary>
 void SendFullStatus()
 {
     this.PostStatusMessage(new
     {
         calls             = GetCurrentCallList(),
         currentCallString = EISC.GetString(SCurrentCallNumber),
         currentDialString = EISC.GetString(SCurrentDialString),
         isInCall          = EISC.GetString(SHookState) == "Connected"
     });
 }
Example #2
0
 /// <summary>
 ///
 /// </summary>
 void SendFullStatus()
 {
     this.PostStatusMessage(new
     {
         calls             = GetCurrentCallList(),
         currentCallString = EISC.GetString(JoinMap.CurrentCallName.JoinNumber),
         currentDialString = EISC.GetString(JoinMap.CurrentDialString.JoinNumber),
         isInCall          = EISC.GetString(JoinMap.HookState.JoinNumber) == "Connected"
     });
 }
        /// <summary>
        /// Helper method to update the full status of the camera
        /// </summary>
        void SendCameraFullMessageObject()
        {
            var presetList = new List <CameraPreset>();

            // Build a list of camera presets based on the names and count
            if (EISC.GetBool(JoinMap.SupportsPresets.JoinNumber))
            {
                var presetStart = JoinMap.PresetLabelStart.JoinNumber;
                var presetEnd   = JoinMap.PresetLabelStart.JoinNumber + JoinMap.NumberOfPresets.JoinNumber;

                var presetId = 1;
                for (uint i = presetStart; i < presetEnd; i++)
                {
                    var presetName = EISC.GetString(i);
                    var preset     = new CameraPreset(presetId, presetName, string.IsNullOrEmpty(presetName), true);
                    presetList.Add(preset);
                    presetId++;
                }
            }

            PostStatusMessage(new
            {
                cameraMode = GetCameraMode(),
                hasPresets = EISC.GetBool(JoinMap.SupportsPresets.JoinNumber),
                presets    = presetList
            });
        }
Example #4
0
        protected override void CustomRegisterWithAppServer(MobileControlSystemController appServerController)
        {
            appServerController.AddAction(MessagePath + "/fullStatus", new Action(() =>
            {
                SendRoutingFullMessageObject(EISC.GetString(JoinStart + StringJoin.CurrentSource));
            }));

            appServerController.AddAction(MessagePath + "/source", new Action <SourceSelectMessageContent>(c =>
            {
                EISC.SetString(JoinStart + StringJoin.CurrentSource, c.SourceListItem);
            }));
        }
Example #5
0
        protected void LinkCameraToApi(CameraBase cameraDevice, BasicTriList trilist, uint joinStart, string joinMapKey,
                                       EiscApiAdvanced bridge)
        {
            CameraControllerJoinMap joinMap = new CameraControllerJoinMap(joinStart);

            // Adds the join map to the bridge
            bridge.AddJoinMap(cameraDevice.Key, joinMap);

            var customJoins = JoinMapHelper.TryGetJoinMapAdvancedForDevice(joinMapKey);

            if (customJoins != null)
            {
                joinMap.SetCustomJoinData(customJoins);
            }

            Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
            Debug.Console(0, "Linking to Bridge Type {0}", cameraDevice.GetType().Name.ToString());

            var commMonitor = cameraDevice as ICommunicationMonitor;

            commMonitor.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(
                trilist.BooleanInput[joinMap.IsOnline.JoinNumber]);

            var ptzCamera = cameraDevice as IHasCameraPtzControl;

            if (ptzCamera != null)
            {
                trilist.SetBoolSigAction(joinMap.PanLeft.JoinNumber, (b) =>
                {
                    if (b)
                    {
                        ptzCamera.PanLeft();
                    }
                    else
                    {
                        ptzCamera.PanStop();
                    }
                });
                trilist.SetBoolSigAction(joinMap.PanRight.JoinNumber, (b) =>
                {
                    if (b)
                    {
                        ptzCamera.PanRight();
                    }
                    else
                    {
                        ptzCamera.PanStop();
                    }
                });

                trilist.SetBoolSigAction(joinMap.TiltUp.JoinNumber, (b) =>
                {
                    if (b)
                    {
                        ptzCamera.TiltUp();
                    }
                    else
                    {
                        ptzCamera.TiltStop();
                    }
                });
                trilist.SetBoolSigAction(joinMap.TiltDown.JoinNumber, (b) =>
                {
                    if (b)
                    {
                        ptzCamera.TiltDown();
                    }
                    else
                    {
                        ptzCamera.TiltStop();
                    }
                });

                trilist.SetBoolSigAction(joinMap.ZoomIn.JoinNumber, (b) =>
                {
                    if (b)
                    {
                        ptzCamera.ZoomIn();
                    }
                    else
                    {
                        ptzCamera.ZoomStop();
                    }
                });

                trilist.SetBoolSigAction(joinMap.ZoomOut.JoinNumber, (b) =>
                {
                    if (b)
                    {
                        ptzCamera.ZoomOut();
                    }
                    else
                    {
                        ptzCamera.ZoomStop();
                    }
                });
            }

            if (cameraDevice is IPower)
            {
                var powerCamera = cameraDevice as IPower;
                trilist.SetSigTrueAction(joinMap.PowerOn.JoinNumber, () => powerCamera.PowerOn());
                trilist.SetSigTrueAction(joinMap.PowerOff.JoinNumber, () => powerCamera.PowerOff());

                powerCamera.PowerIsOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.PowerOn.JoinNumber]);
                powerCamera.PowerIsOnFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.PowerOff.JoinNumber]);
            }

            if (cameraDevice is ICommunicationMonitor)
            {
                var monitoredCamera = cameraDevice as ICommunicationMonitor;
                monitoredCamera.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(
                    trilist.BooleanInput[joinMap.IsOnline.JoinNumber]);
            }

            if (cameraDevice is IHasCameraPresets)
            {
                // Set the preset lables when they change
                var presetsCamera = cameraDevice as IHasCameraPresets;
                presetsCamera.PresetsListHasChanged += new EventHandler <EventArgs>((o, a) =>
                {
                    for (int i = 1; i <= joinMap.NumberOfPresets.JoinNumber; i++)
                    {
                        int tempNum = i - 1;

                        string label = "";

                        var preset = presetsCamera.Presets.FirstOrDefault(p => p.ID.Equals(i));

                        if (preset != null)
                        {
                            label = preset.Description;
                        }

                        trilist.SetString((ushort)(joinMap.PresetLabelStart.JoinNumber + tempNum), label);
                    }
                });

                for (int i = 0; i < joinMap.NumberOfPresets.JoinNumber; i++)
                {
                    int tempNum = i;

                    trilist.SetSigTrueAction((ushort)(joinMap.PresetRecallStart.JoinNumber + tempNum), () =>
                    {
                        presetsCamera.PresetSelect(tempNum);
                    });
                    trilist.SetSigTrueAction((ushort)(joinMap.PresetSaveStart.JoinNumber + tempNum), () =>
                    {
                        var label = trilist.GetString((ushort)(joinMap.PresetLabelStart.JoinNumber + tempNum));

                        presetsCamera.PresetStore(tempNum, label);
                    });
                }
            }
        }
Example #6
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);
                }
            }));
        }
Example #7
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);
                }
            }));
        }