Пример #1
0
        public void Ramp(CameraTiltCommand tiltCommand, int speed)
        {
            CommandArgs args = new CommandArgs("CameraId", (int)this.ID);

            args.Add("Tilt", tiltCommand.ToString());
            args.Add("TiltSpeed", speed);
            this.Ramp(args);
        }
Пример #2
0
        public void Ramp(CameraPanCommand panCommand, int speed)
        {
            CommandArgs args = new CommandArgs("CameraId", (int)this.ID);

            args.Add("Pan", panCommand.ToString());
            args.Add("PanSpeed", speed);
            this.Ramp(args);
        }
Пример #3
0
        public void Ramp(CameraFocusCommand focusCommand, int speed)
        {
            CommandArgs args = new CommandArgs("CameraId", (int)this.ID);

            args.Add("Focus", focusCommand.ToString());
            args.Add("FocusSpeed", speed);
            this.Ramp(args);
        }
Пример #4
0
        public static CommandArgs BuildCommandArgs(PhonebookType phonebookType, string folderId)
        {
            CommandArgs args = new CommandArgs("PhonebookType", phonebookType.ToString());

            if (phonebookType == PhonebookType.Local)
            {
                args.Add("Recursive", "False");
            }
            args.Add("FolderId", folderId);
            return(args);
        }
Пример #5
0
        void SendCommand(string command, CommandArg arg)
        {
            CommandArgs args = new CommandArgs("CallId", this.ID);

            args.Add(arg);
            Codec.SendCommand(string.Format("Call/{0}", command), args);
        }
Пример #6
0
        public void DTMFSend(string dtmfString)
        {
            CommandArgs args = new CommandArgs("CallId", this.ID);

            args.Add(new CommandArg("DTMFString", dtmfString));
            Codec.SendCommand("Call/DTMFSend", args);
        }
Пример #7
0
        public void Ramp(CameraZoomCommand zoomCommand)
        {
            CommandArgs args = new CommandArgs("CameraId", (int)this.ID);

            args.Add("Zoom", zoomCommand.ToString());
            this.Ramp(args);
        }
Пример #8
0
        public DialResult Dial(string number, CallType callType)
        {
            CommandArgs args = new CommandArgs("Number", number);

            args.Add("CallType", callType.ToString());
            return(Dial(args));
        }
Пример #9
0
        /// <summary>
        /// Start a presentation
        /// </summary>
        /// <param name="presentationSource">The number of the codec source to use</param>
        /// <param name="sendingMode">PresentationSendingMode option to use</param>
        public void PresentationStart(int presentationSource, PresentationSendingMode sendingMode)
        {
            CommandArgs args = new CommandArgs("PresentationSource", presentationSource);

            args.Add("SendingMode", sendingMode.ToString());

            SendCommand("Presentation/Start", args);
        }
Пример #10
0
        void CheckStatus(object o)
        {
            try
            {
                bool commsOk = false;
                try
                {
                    //#if DEBUG
                    CrestronConsole.PrintLine("CiscoCodec Sending Heatbeat...");
                    //#endif
                    CommandArgs args = new CommandArgs();
                    args.Add("ID", CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_MAC_ADDRESS,
                                                                               CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(this.FeedbackServer.AdapterForIPAddress)));
                    XDocument response = this.SendCommand("Peripherals/HeartBeat", args);
                    //#if DEBUG
                    try
                    {
                        if (response.Element("Command").Element("PeripheralsHeartBeatResult").Attribute("status").Value == "OK")
                        {
                            CrestronConsole.PrintLine("HeatBeat OK");
                        }
                        else
                        {
                            CrestronConsole.PrintLine("status = {0}", response.Element("Command").Element("PeripheralsHeartBeatResult").Attribute("status").Value);
                        }
                    }
                    catch (Exception e)
                    {
                        ErrorLog.Exception("Error reading result from Heartbeat Send", e);
                    }
                    //#endif

                    this.DeviceCommunicating = true;
                    commsOk = true;
                }
                catch (Exception e)
                {
                    ErrorLog.Error("Error checking in with CiscoCodec, {0}", e.Message);
                    CrestronConsole.PrintLine("Error Sending CiscoCodec Heartbeat ...");
                    CrestronConsole.PrintLine(e.StackTrace);
                    CrestronConsole.PrintLine("Stopping CheckStatus Timer and calling CiscoCodec.Initialize()...");
                    this.DeviceCommunicating = false;
                    _CheckStatusTimer.Stop();
                    _CheckStatusTimer.Dispose();
                    this.Initialize();
                }

                if (commsOk && !this.FeedbackServer.Registered)
                {
                    ErrorLog.Warn("The CiscoCodec was not registered for feedback on CheckStatusThread. Codec could have unregistered itself due to Post errors or connectivity problems");
                    this.Registerfeedback();
                }
            }
            catch (Exception e)
            {
                ErrorLog.Exception("Error occured in CiscoCodec.CheckStatus() timer callback", e);
            }
        }
Пример #11
0
        public void Register(int feedbackSlot, string[] expressions, bool deregisterFirst)
        {
            CommandArgs args = new CommandArgs();

            args.Add("FeedbackSlot", feedbackSlot.ToString());

            if (deregisterFirst || deregisterOnBoot)
            {
                if (deregisterOnBoot)
                {
                    CrestronConsole.PrintLine("Deregistering codec feedback on first boot to combat potential issue with codec lockups");
                }
#if DEBUG
                CrestronConsole.PrintLine("Deresgistering feedback mechanism with CiscoCodec");
#endif
                Codec.SendCommand("HttpFeedback/Deregister", args);

                if (deregisterOnBoot)
                {
                    deregisterOnBoot = false;
                }
            }

            args.Add("ServerUrl", this.ServerURL);

            int count = 1;

            foreach (string expression in expressions)
            {
                args.Add("Expression", count, expression);
                count++;
            }
#if DEBUG
            CrestronConsole.PrintLine("Resgistering feedback mechanism with CiscoCodec");
#endif

            Codec.SendCommand("HttpFeedback/Register", args);
        }
Пример #12
0
        object CiscoCodecRegisterProcess(object threadObject)
        {
            while (!programStopping)
            {
                try
                {
                    if (this.HttpClient.StartSession().Length > 0)
                    {
                        ErrorLog.Notice("Codec has connected and received a session id");
                    }
                    else
                    {
                        ErrorLog.Warn("Codec has connected but did not receive session id");
                    }

                    break;
                }
                catch (Exception e)
                {
                    ErrorLog.Warn("Could not start session with Cisco codec, {0}", e.Message);
                }

                CrestronConsole.PrintLine("Waiting for codec connection... will retry in 30 seconds");
                ErrorLog.Warn("Waiting for codec connection... will retry in 30 seconds");

                CrestronEnvironment.AllowOtherAppsToRun();
                Thread.Sleep(30000);
            }

            try
            {
                CrestronConsole.PrintLine("Connecting ControlSystem to codec and registering...");

                CommandArgs args = new CommandArgs();
                args.Add("HardwareInfo", ControlSystem.ControllerPrompt);
                args.Add("ID",
                         CrestronEthernetHelper.GetEthernetParameter(
                             CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_MAC_ADDRESS,
                             CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(
                                 FeedbackServer.AdapterForIPAddress)));
                args.Add("Name", "Crestron Control System");
                args.Add("NetworkAddress",
                         CrestronEthernetHelper.GetEthernetParameter(
                             CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS,
                             CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(
                                 FeedbackServer.AdapterForIPAddress)));
                args.Add("SerialNumber", "Unknown");
                args.Add("Type", "ControlSystem");
                var assembly = Assembly.GetExecutingAssembly().GetName();
                args.Add("SoftwareInfo", assembly.Name + " " + assembly.Version);
                XDocument response = SendCommand("Peripherals/Connect", args);

                CrestronConsole.PrintLine("Codec registration {0}",
                                          response.Element("Command").Element("PeripheralsConnectResult").Attribute("status").Value == "OK");
            }
            catch (Exception e)
            {
                ErrorLog.Exception("Error trying to register control system with Cisco Codec", e);
            }

            try
            {
                CrestronConsole.PrintLine("Registering for HttpFeedback...");
                this.Registerfeedback();
            }
            catch (Exception e)
            {
                ErrorLog.Exception("Error trying to register feedback notifications with Cisco Codec", e);
            }

            try
            {
                CrestronConsole.PrintLine("Getting call status...");
                this.Calls.Update();
            }
            catch (Exception e)
            {
                ErrorLog.Exception("Error trying to update calls status with Cisco Codec", e);
            }

            try
            {
                if (this.HasConnected != null)
                {
                    this.HasConnected(this);
                }
            }
            catch (Exception e)
            {
                ErrorLog.Exception("Error calling CiscoCodec.HasConnected thread", e);
            }

            try
            {
                CrestronConsole.PrintLine("Creating timer to periodically check the codec connection every 60 seconds");
                _CheckStatusTimer = new CTimer(CheckStatus, null, 60000, 60000);
            }
            catch (Exception e)
            {
                CrestronConsole.PrintLine("Error crating CiscoCodec CheckStatus Timer", e.Message);
                ErrorLog.Error("Error creating CiscoCodec CheckStatus Timer", e.Message);
            }

            this.DeviceCommunicating = true;

            return(null);
        }
Пример #13
0
        public CallHistory(CiscoCodec codec, int limit)
        {
            this.Codec = codec;

            CommandArgs args = new CommandArgs();

            args.Add("Filter", "All");
            args.Add("DetailLevel", "Full");
            args.Add("Limit", limit);

            XDocument xml;

            try
            {
                xml = Codec.SendCommand("Command/CallHistory/Get", args);

                if (xml == null)
                {
                    ErrorLog.Error("Error getting Call History from codec, xml == null");
                }
            }
            catch (Exception e)
            {
                ErrorLog.Exception("Error getting Call history data", e);
                return;
            }
#if DEBUG
            CrestronConsole.PrintLine("Callhistory: \r\n{0}", xml.ToString());
#endif
            foreach (XElement item in xml.Root.Elements().Elements("Entry"))
            {
                CallHistoryItem call = new CallHistoryItem(Codec,
                                                           int.Parse(item.Element("CallHistoryId").Value),
                                                           int.Parse(item.Element("CallId").Value));

                calls.Add(call.ID, call);

                if (item.Element("CallbackNumber") != null)
                {
                    call.CallbackNumber = item.Element("CallbackNumber").Value;
                }
                if (item.Element("RemoteNumber") != null)
                {
                    call.RemoteNumber = item.Element("RemoteNumber").Value;
                }
                if (item.Element("DisplayName") != null)
                {
                    call.DisplayName = item.Element("DisplayName").Value;
                }
                if (item.Element("Direction") != null)
                {
                    call.Direction = (CallDirection)Enum.Parse(
                        typeof(CallDirection), item.Element("Direction").Value, false);
                }
                if (item.Element("CallType") != null)
                {
                    call.Type = (CallType)Enum.Parse(
                        typeof(CallType), item.Element("CallType").Value, false);
                }
                if (item.Element("OccurrenceType") != null)
                {
                    call.OccurrenceType = (CallOccurrenceType)Enum.Parse(
                        typeof(CallOccurrenceType), item.Element("OccurrenceType").Value, false);
                }
                if (item.Element("Protocol") != null)
                {
                    call.Protocol = item.Element("Protocol").Value;
                }
                if (item.Element("StartTime") != null)
                {
                    call.StartTime = DateTime.Parse(item.Element("StartTime").Value);
                }
                if (item.Element("EndTime") != null)
                {
                    call.EndTime = DateTime.Parse(item.Element("EndTime").Value);
                }
                if (item.Element("DisconnectCause") != null)
                {
                    call.DisconnectCause = item.Element("DisconnectCause").Value;
                }
                if (item.Element("DisconnectCauseType") != null)
                {
                    call.DisconnectCauseType = (CallDisconnectCauseType)Enum.Parse(
                        typeof(CallDisconnectCauseType), item.Element("DisconnectCauseType").Value, false);
                }
            }
        }