/// <summary> /// Review the data coming back from the Matrix /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void _tcp_ReceivedDelimitedString(object sender, ReceivedDelimitedStringEventArgs e) { try { string response = e.RawResponse; Logger.DebugFormat("{0}: Recived - {1}", this.DeviceName, response); } catch (Exception ex) { Logger.ErrorFormat("{0}: Error in the Respone Recived - {1}", this.DeviceName, ex.Message); } }
private void ProjectorReceivedEvent(object sender, ReceivedDelimitedStringEventArgs e) { if (e.RawResponse.Length == 0) { return; } _logger.DebugFormat("ProjectorProtocol RX: {0}", e.RawResponse); try { _watchdogTimer.Stop(); if (_commandQueue.IsResponseEmpty()) { return; } var expected = _commandQueue.PeekResponse(); if (e.RawResponse == ProjectorProtocol.Unavailable || expected.IsMatch(e.RawResponse)) { _commandQueue.DequeueResponse(); ProcessProjectorResponse(e.RawResponse); if (!_commandQueue.IsCommandEmpty()) { SendCommand(_commandQueue.DequeueCommand()); } IsIdle = _commandQueue.IsResponseEmpty(); } } catch (Exception ex) { _logger.ErrorFormat("An error ocurred in the ProjectorProtocol received response event. Error: {0}", ex); } }
private void ReceivedDelimitedString(object sender, ReceivedDelimitedStringEventArgs e) { if (e.RawResponse.StartsWith(this.ZoneQueryPrefix)) { this._logger.Debug("Zone [" + this.Number.ToString() + "] handling response [" + e.RawResponse + "]."); string command = e.RawResponse.Substring(2, 2); int commandValue = (e.MessageIncludesDelimiter) ? int.Parse(e.RawResponse.Substring(4, e.RawResponse.Length - 5)) : int.Parse(e.RawResponse.Substring(4, e.RawResponse.Length - 4)); this._logger.Debug("Zone [" + this.Number.ToString() + "] processing response of type [" + command + "] with value [" + commandValue.ToString() + "]"); switch (command) { // Zone Power case "PR": this.IsPowerOn = (commandValue == 1); break; // Input (Source) Select case "SS": this.Source = (commandValue == LOCAL_SOURCE) ? LOCAL_SOURCE_NUMBER : commandValue; break; // Volume case "VO": this.Volume = commandValue; break; // Mute case "MU": this.IsMuted = (commandValue == 1); break; // Treble case "TR": this.TrebleLevel = commandValue + TREBLE_OFFSET; break; // Bass case "BS": this.BassLevel = commandValue + BASS_OFFSET; break; // Balance case "BA": this.Balance = commandValue + BALANCE_OFFSET; break; default: break; } } }