/// <summary> /// Parses any subscription-unrelated messages directed to this object /// </summary> /// <param name="attributeCode">Message attribute code to determine parsing algorithm</param> /// <param name="message">Data to be parsed</param> public override void ParseGetMessage(string attributeCode, string message) { try { Debug.Console(2, this, "Parsing Message - '{0}' : Message has an attributeCode of {1}", message, attributeCode); // Parse an "+OK" message const string pattern = "[^ ]* (.*)"; var match = Regex.Match(message, pattern); if (!match.Success) { return; } var value = match.Groups[1].Value; Debug.Console(1, this, "Response: '{0}' Value: '{1}'", attributeCode, value); if (message.IndexOf("+OK", StringComparison.Ordinal) <= -1) { return; } switch (attributeCode) { case "autoAnswer": { AutoAnswerState = bool.Parse(value); Debug.Console(1, this, "AutoAnswerState is '{0}'", AutoAnswerState); AutoAnswerFeedback.FireUpdate(); break; } case "dndEnable": { DoNotDisturbState = bool.Parse(value); Debug.Console(1, this, "DoNotDisturbState is '{0}'", DoNotDisturbState); DoNotDisturbFeedback.FireUpdate(); break; } default: { Debug.Console(2, "Response does not match expected attribute codes: '{0}'", message); break; } } } catch (Exception e) { Debug.Console(2, "Unable to parse message: '{0}'\n{1}", message, e); } }
void DisplayControl_DisplayControlChange(object sender, Crestron.SimplSharpPro.DeviceSupport.GenericEventArgs args) { if (args.EventId == AmX00.VideoOutFeedbackEventId) { VideoOutFeedback.FireUpdate(); } else if (args.EventId == AmX00.EnableAutomaticRoutingFeedbackEventId) { AutomaticInputRoutingEnabledFeedback.FireUpdate(); } }
void socket_ConnectionChange(object sender, GenericSocketStatusChageEventArgs e) { StatusFeedback.FireUpdate(); ConnectedFeedback.FireUpdate(); if (e.Client.IsConnected) { // Tasks on connect } else { // Cleanup items from this session } }
/// <summary> /// /// </summary> public MockVC(DeviceConfig config) : base(config) { PropertiesConfig = JsonConvert.DeserializeObject <VideoCodec.MockVcPropertiesConfig>(config.Properties.ToString()); CodecInfo = new MockCodecInfo(); // Get favoritesw if (PropertiesConfig.Favorites != null) { CallFavorites = new CodecCallFavorites(); CallFavorites.Favorites = PropertiesConfig.Favorites; } DirectoryBrowseHistory = new List <CodecDirectory>(); // Debug helpers MuteFeedback.OutputChange += (o, a) => Debug.Console(1, this, "Mute={0}", _IsMuted); PrivacyModeIsOnFeedback.OutputChange += (o, a) => Debug.Console(1, this, "Privacy={0}", _PrivacyModeIsOn); SharingSourceFeedback.OutputChange += (o, a) => Debug.Console(1, this, "SharingSource={0}", _SharingSource); VolumeLevelFeedback.OutputChange += (o, a) => Debug.Console(1, this, "Volume={0}", _VolumeLevel); CurrentDirectoryResultIsNotDirectoryRoot = new BoolFeedback(() => DirectoryBrowseHistory.Count > 0); CurrentDirectoryResultIsNotDirectoryRoot.FireUpdate(); CodecOsdIn = new RoutingInputPort(RoutingPortNames.CodecOsd, eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, 0, this); InputPorts.Add(CodecOsdIn); HdmiIn1 = new RoutingInputPort(RoutingPortNames.HdmiIn1, eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, 1, this); InputPorts.Add(HdmiIn1); HdmiIn2 = new RoutingInputPort(RoutingPortNames.HdmiIn2, eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, 2, this); InputPorts.Add(HdmiIn2); HdmiOut = new RoutingOutputPort(RoutingPortNames.HdmiOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, null, this); OutputPorts.Add(HdmiOut); CallHistory = new CodecCallHistory(); for (int i = 0; i < 10; i++) { var call = new CodecCallHistory.CallHistoryEntry(); call.Name = "Call " + i; call.Number = i + "@call.com"; CallHistory.RecentCalls.Add(call); } // eventually fire history event here SetupCameras(); SetIsReady(); }
void SetupCameras() { Cameras = new List <CameraBase>(); var internalCamera = new MockVCCamera(Key + "-camera1", "Near End", this); Cameras.Add(internalCamera); var farEndCamera = new MockFarEndVCCamera(Key + "-cameraFar", "Far End", this); Cameras.Add(farEndCamera); SelectedCameraFeedback = new StringFeedback(() => SelectedCamera.Key); ControllingFarEndCameraFeedback = new BoolFeedback(() => SelectedCamera is IAmFarEndCamera); CameraAutoModeIsOnFeedback = new BoolFeedback(() => _CameraAutoModeIsOn); CameraAutoModeIsOnFeedback.FireUpdate(); DeviceManager.AddDevice(internalCamera); DeviceManager.AddDevice(farEndCamera); NearEndPresets = new List <CodecRoomPreset>(15); // Fix the capacity to emulate Cisco NearEndPresets = PropertiesConfig.Presets; FarEndRoomPresets = new List <CodecRoomPreset>(15); // Fix the capacity to emulate Cisco // Add the far end presets for (int i = 1; i <= FarEndRoomPresets.Capacity; i++) { var label = string.Format("Far End Preset {0}", i); FarEndRoomPresets.Add(new CodecRoomPreset(i, label, true, false)); } SelectedCamera = internalCamera;; // call the method to select the camera and ensure the feedbacks get updated. }
public void ParseSubscriptionMessage(string customName, string value) { // Check for valid subscription response Debug.Console(1, "QscDialerTag {0} Response: '{1}'", customName, value); if (customName == Tags.dialStringTag) { Debug.Console(2, "QscDialerTag DialStringChanged ", value); this.DialString = value; this.DialStringFeedback.FireUpdate(); } else if (customName == Tags.doNotDisturbTag) { if (value == "on") { this.DoNotDisturbState = true; } else if (value == "off") { this.DoNotDisturbState = false; } DoNotDisturbFeedback.FireUpdate(); } else if (customName == Tags.callStatusTag) { if (value == "Dialing") { this.OffHook = true; } else if (value == "Disconnected") { this.OffHook = false; if (Tags.ClearOnHangup) { this.SendKeypad(eKeypadKeys.Clear); } } this.OffHookFeedback.FireUpdate(); } else if (customName == Tags.autoAnswerTag) { if (value == "on") { this.AutoAnswerState = true; } else if (value == "off") { this.AutoAnswerState = false; } AutoAnswerFeedback.FireUpdate(); } else if (customName == Tags.hookStatusTag) { if (value == "true") { this.OffHook = true; } else if (value == "false") { this.OffHook = false; } this.OffHookFeedback.FireUpdate(); } }
/// <summary> /// Parses incoming subscription-related messages directed to this object /// </summary> /// <param name="customName">CustomName of subscribed control within the component</param> /// <param name="value">Data to be parsed</param> public void ParseSubscriptionMessage(string customName, string value) { try { Debug.Console(2, this, "New Subscription Message to Dialer"); if (customName == ControlStatusCustomName || customName == PotsDialerCustomName) { //Pulls Entire Value "array" and seperates call appearances const string pattern1 = "\\[([^\\[\\]]+)\\]"; //Seperates each call appearance into their constituent parts const string pattern2 = "\\[(?<state>\\d+)\\s+(?<line>\\d+)\\s+(?<call>\\d+)\\s+(?<action>\\d+)\\s+(?<cid>\".+\"|\"\")\\s+(?<prompt>\\d+)\\]"; //Pulls CallerID Data const string pattern3 = "(?:(?:\\\\\"(?<time>.*)\\\\\")(?:\\\\\"(?<number>.*)\\\\\")(?:\\\\\"(?<name>.*)\\\\\"))|\"\""; var myMatches = Regex.Matches(value, pattern1); Debug.Console(2, this, "This is the list of Call States - {0}", myMatches.ToString()); var match = myMatches[CallAppearance - 1]; var match2 = Regex.Match(match.Value, pattern2); if (match2.Success) { Debug.Console(2, this, "VoIPControlStatus Subscribed Response = {0}", match.Value); var lineNumber = (int)(ushort.Parse(match2.Groups["line"].Value) + 1); var callStatusInt = int.Parse(match2.Groups["state"].Value); CallStatusEnum = (eCallStatus)(callStatusInt); Debug.Console(2, this, "Callstate for Line {0} is {1}", lineNumber, int.Parse(match2.Groups["state"].Value)); Debug.Console(2, this, "Callstate Enum for Line {0} is {1}", lineNumber, (int)CallStatusEnum); IncomingCallFeedback.FireUpdate(); OffHookFeedback.FireUpdate(); var match3 = Regex.Match(match2.Groups["cid"].Value, pattern3); if (match3.Success) { CallerIdNumber = match3.Groups["number"].Value; CallerIdName = match3.Groups["name"].Value; ActiveCalls.First().Name = CallerIdName; ActiveCalls.First().Number = CallerIdNumber; if (lineNumber == LineNumber) { Debug.Console(2, this, "CallState Complete - Firing Updates"); CallerIdNumberFeedback.FireUpdate(); OffHookFeedback.FireUpdate(); if (IsVoip) { VoipIsSubscribed = true; } if (!IsVoip) { PotsIsSubscribed = true; } } } else { ActiveCalls.First().Name = ""; ActiveCalls.First().Number = ""; } } } } catch (Exception e) { Debug.Console(0, this, "Error in ParseSubscriptioMessage - {0}", e.Message); } if (customName == AutoAnswerCustomName) { AutoAnswerState = bool.Parse(value); AutoAnswerIsSubscribed = true; AutoAnswerFeedback.FireUpdate(); } if (customName == HookStateCustomName) { if (value.IndexOf("OFF", StringComparison.Ordinal) > -1) { OffHookStatus = true; } if (value.IndexOf("ON", StringComparison.Ordinal) > -1) { OffHookStatus = false; } OffHookFeedback.FireUpdate(); } if (customName != LastDialedCustomName) { return; } LastDialed = value; LastDialedFeedback.FireUpdate(); }
/// <summary> /// CameraVisca Plugin device constructor using IBasicCommunication /// </summary> /// <param name="key"></param> /// <param name="name"></param> /// <param name="config"></param> /// <param name="comms"></param> public CameraVisca(string key, string name, CameraViscaConfig config, IBasicCommunication comm) : base(key, name) { Debug.Console(0, this, "Constructing new {0} instance", name); _config = config; Enabled = _config.Enabled; _visca = new ViscaProtocolProcessor(comm.SendBytes, new Action <byte, string, object[]>((l, f, o) => { Debug.Console(l, this, f, o); })); _camera = new ViscaCamera((ViscaCameraId)_config.Id, null, _visca); _camera.PollEnabled = Enabled; Capabilities = eCameraCapabilities.Pan | eCameraCapabilities.Tilt | eCameraCapabilities.Zoom | eCameraCapabilities.Focus; ControlMode = eCameraControlMode.Auto; ConnectFeedback = new BoolFeedback(() => Connect); OnlineFeedback = new BoolFeedback(() => _commsMonitor.IsOnline); StatusFeedback = new IntFeedback(() => (int)_commsMonitor.Status); PowerIsOnFeedback = new BoolFeedback(() => _camera.Power); CameraIsOffFeedback = new BoolFeedback(() => !_camera.Power); CameraIsMutedFeedback = new BoolFeedback(() => _camera.Mute); _camera.PowerChanged += (o, e) => { PowerIsOnFeedback.FireUpdate(); CameraIsOffFeedback.FireUpdate(); }; _camera.MuteChanged += (o, e) => { CameraIsMutedFeedback.FireUpdate(); }; _cameraPollCommands = new Dictionary <string, Action>() { { "AE", _camera.AEPoll }, { "Aperture", _camera.AperturePoll }, { "BackLight", _camera.BackLightPoll }, { "BGain", _camera.BGainPoll }, { "ExpComp", _camera.ExpCompPoll }, { "FocusAuto", _camera.FocusAutoPoll }, { "FocusPosition", _camera.FocusPositionPoll }, { "Gain", _camera.GainPoll }, { "Iris", _camera.IrisPoll }, { "Mute", _camera.MutePoll }, { "PTZPosition", _camera.PanTiltPositionPoll }, { "Power", _camera.PowerPoll }, { "RGain", _camera.RGainPoll }, { "Shutter", _camera.ShutterPoll }, { "Title", _camera.TitlePoll }, { "WB", _camera.WBModePoll }, { "WD", _camera.WideDynamicModePoll }, { "ZoomPosition", _camera.ZoomPositionPoll }, }; _comms = comm; // TODO: For VISCA camera current library implementation only // serial is supported, so socket code is not needed var socket = _comms as ISocketStatus; if (socket != null) { socket.ConnectionChange += socket_ConnectionChange; if (Enabled) { Connect = true; } } if (_config.CommunicationMonitorProperties != null) { if (!String.IsNullOrEmpty(_config.CommunicationMonitorProperties.PollString)) { foreach (var poll in _config.CommunicationMonitorProperties.PollString.Split(',')) { if (_cameraPollCommands.ContainsKey(poll.Trim())) { _poll.Add(_cameraPollCommands[poll.Trim()]); } } } _commsMonitor = new GenericCommunicationMonitor(this, _comms, _config.CommunicationMonitorProperties.PollInterval, _config.CommunicationMonitorProperties.TimeToWarning, _config.CommunicationMonitorProperties.TimeToError, () => _poll.ForEach((pollAction) => pollAction()) ); } else { // We do not have CommunicationMonitorProperties and therefore // no Poll string defined, using ALL poll functions _poll.AddRange(_cameraPollCommands.Values); _commsMonitor = new GenericCommunicationMonitor(this, _comms, 10000, 20000, 30000, () => _poll.ForEach((pollAction) => pollAction())); } _commsMonitor.Client.BytesReceived += (s, e) => _visca.ProcessIncomingData(e.Bytes); DeviceManager.AddDevice(CommunicationMonitor); // Handle Increase PTZ move speed #region PTZ Speed Increase // if FastSpeedHoldTimeMs defined in config, enable SpeedIncrease behaivor if (_config.FastSpeedHoldTimeMs > 0) { _ptzSpeedIncreaseBehaivor = true; if (_config.PanSpeedSlow > 0) { _camera.PanSpeed = _config.PanSpeedSlow; } if (_config.TiltSpeedSlow > 0) { _camera.TiltSpeed = _config.TiltSpeedSlow; } _ptzPanNormalSpeed = _camera.PanSpeed; _ptzTiltNormalSpeed = _camera.TiltSpeed; _ptzSpeedIncreaseAction = ptzCommand => { // Kill Speed Increase Timer as we already in fast pace ptzSpeedChangeTimerDispose(); // if Fast speeds not defined, use Max values _camera.PanSpeed = (_config.PanSpeedFast > 0) ? _config.PanSpeedFast : Visca.ViscaDefaults.PanSpeedLimits.High; _camera.TiltSpeed = (_config.TiltSpeedFast > 0) ? _config.PanSpeedFast : Visca.ViscaDefaults.TiltSpeedLimits.High; // we passed current ptz command to action, so we repeat it with increased speed (ptzCommand as Action).Invoke(); }; } #endregion PTZ Speed Increase }