Beispiel #1
0
        /// <summary>
        /// Parses the response from the DspBase
        /// </summary>
        /// <param name="customName"></param>
        /// <param name="value"></param>
        public void ParseSubscriptionMessage(string customName, string value)
        {
            // Check for valid subscription response
            Debug.Console(1, this, "Level {0} Response: '{1}'", customName, value);
            if (customName == MuteInstanceTag)
            {
                if (value == "muted")
                {
                    _IsMuted         = true;
                    MuteIsSubscribed = true;
                }
                else if (value == "unmuted")
                {
                    _IsMuted         = false;
                    MuteIsSubscribed = true;
                }

                MuteFeedback.FireUpdate();
            }
            else if (customName == LevelInstanceTag)
            {
                var _value = Double.Parse(value);

                _VolumeLevel = (ushort)(_value * 65535);
                Debug.Console(1, this, "Level {0} VolumeLevel: '{1}'", customName, _VolumeLevel);
                LevelIsSubscribed = true;

                VolumeLevelFeedback.FireUpdate();
            }
        }
        /// <summary>
        ///
        /// </summary>
        void UpdateMuteFb(byte b)
        {
            var newMute = b == 1;

            if (newMute != _IsMuted)
            {
                _IsMuted = newMute;
                MuteFeedback.FireUpdate();
            }
        }
Beispiel #3
0
        private void displayEvent(GenericBase device, BaseEventArgs args)
        {
            switch (args.EventId)
            {
            case RoomViewConnectedDisplay.OnLineFeedbackEventId:
                // TODO: figure out what to do with OnLine event in BaseEvent
                // Read current state of the projector power and if differ from room state update room state accordingly without setters actions.
                foreach (var feeedback in Feedbacks)
                {
                    //feeedback.FireUpdate();
                }
                break;

            case RoomViewConnectedDisplay.PowerOffFeedbackEventId:
            case RoomViewConnectedDisplay.PowerOnFeedbackEventId:
                PowerIsOnFeedback.FireUpdate();
                break;

            case RoomViewConnectedDisplay.CoolingDownFeedbackEventId:
                IsCoolingDownFeedback.FireUpdate();
                break;

            case RoomViewConnectedDisplay.WarmingUpFeedbackEventId:
                IsWarmingUpFeedback.FireUpdate();
                break;

            case RoomViewConnectedDisplay.MuteOnFeedbackEventId:
                MuteFeedback.FireUpdate();
                break;

            case RoomViewConnectedDisplay.VolumeFeedbackEventId:
                VolumeLevelFeedback.FireUpdate();
                break;

            case RoomViewConnectedDisplay.SourceSelectFeedbackEventId:
                uint sourceSelectIndex = (uint)args.Index;
                if (_display.SourceSelectFeedbackSigs[sourceSelectIndex].BoolValue == true)
                {
                    RoutingInputPort newInputPort = (RoutingInputPort)_display.SourceSelectFeedbackSigs[sourceSelectIndex].UserObject;
                    CurrentInputFeedback.FireUpdate();
                    OnSwitchChange(new RoutingNumericEventArgs(null, newInputPort, eRoutingSignalType.AudioVideo));
                }
                break;

            case RoomViewConnectedDisplay.SourceNameTextFeedbackEventId:
                break;

            case RoomViewConnectedDisplay.LampHoursFeedbackEventId:
            case RoomViewConnectedDisplay.LampHoursTextFeedbackEventId:
                break;
            }
        }
Beispiel #4
0
        void Port_LineReceived(object dev, GenericCommMethodReceiveTextArgs args)
        {
            if (Debug.Level == 2)
            {
                Debug.Console(2, this, "Received: '{0}'", ComTextHelper.GetEscapedText(args.Text));
            }

            if (args.Text == "DO SOMETHING HERE EVENTUALLY")
            {
                _IsMuted = true;
                MuteFeedback.FireUpdate();
            }
        }
        /// <summary>
        /// Parses the response from the DspBase
        /// </summary>
        /// <param name="customName"></param>
        /// <param name="value"></param>
        public void ParseSubscriptionMessage(string customName, string value)
        {
            // Check for valid subscription response

            if (this.HasMute && customName == MuteCustomName)
            {
                //if (value.IndexOf("+OK") > -1)
                //{
                //    int pointer = value.IndexOf(" +OK");

                //    MuteIsSubscribed = true;

                //    // Removes the +OK
                //    value = value.Substring(0, value.Length - (value.Length - (pointer - 1)));
                //}

                if (value.IndexOf("true") > -1)
                {
                    _IsMuted         = true;
                    MuteIsSubscribed = true;
                }
                else if (value.IndexOf("false") > -1)
                {
                    _IsMuted         = false;
                    MuteIsSubscribed = true;
                }

                MuteFeedback.FireUpdate();
            }
            else if (this.HasLevel && customName == LevelCustomName)
            {
                //if (value.IndexOf("+OK") > -1)
                //{
                //    int pointer = value.IndexOf(" +OK");

                //    LevelIsSubscribed = true;

                //}

                var _value = Double.Parse(value);

                _VolumeLevel = (ushort)Scale(_value, MinLevel, MaxLevel, 0, 65535);

                LevelIsSubscribed = true;

                VolumeLevelFeedback.FireUpdate();
            }
        }
Beispiel #6
0
        /// <summary>
        /// Parses response
        /// </summary>
        /// <param name="message">The message to parse</param>
        /// <returns> true if message associated with this parser</returns>
        public bool Parse(string message)
        {
            if (message.StartsWith(_muteCmdFeedbackKey, StringComparison.Ordinal))
            {
                switch (message.Substring(_muteCmdFeedbackKey.Length))
                {
                case OnOffToggle.Off:
                    if (_isMuted)
                    {
                        _isMuted = false;
                        MuteFeedback.FireUpdate();
                    }
                    break;

                case OnOffToggle.On:
                    if (!_isMuted)
                    {
                        _isMuted = true;
                        MuteFeedback.FireUpdate();
                    }
                    break;

                default:
                    Debug.Console(1, this, "Can't parse MUTE feedback: \'{0}\'", message);
                    break;
                }
                return(true);
            }
            else if (message.StartsWith(_gainCmdFeedbackKey, StringComparison.Ordinal))
            {
                string val = message.Substring(_gainCmdFeedbackKey.Length, message.IndexOf(' ', _gainCmdFeedbackKey.Length) - _gainCmdFeedbackKey.Length);
                if (!String.IsNullOrEmpty(val))
                {
                    var    db             = Double.Parse(val);
                    ushort newVolumeLevel = (ushort)scale(db, -65.00, 20.00, 0, 65535);
                    if (_volumeLevel != newVolumeLevel)
                    {
                        _volumeLevel = newVolumeLevel;
                        VolumeLevelFeedback.FireUpdate();
                    }
                    Debug.Console(1, this, "Volume feedback: \'{0}\'", _volumeLevel);
                }
                return(true);
            }
            return(false);
        }
Beispiel #7
0
 /// <summary>
 ///
 /// </summary>
 public override void MuteToggle()
 {
     _IsMuted = !_IsMuted;
     MuteFeedback.FireUpdate();
 }
Beispiel #8
0
 /// <summary>
 ///
 /// </summary>
 public override void MuteOn()
 {
     _IsMuted = true;
     MuteFeedback.FireUpdate();
 }
Beispiel #9
0
 /// <summary>
 ///
 /// </summary>
 public override void MuteOff()
 {
     _IsMuted = false;
     MuteFeedback.FireUpdate();
 }
Beispiel #10
0
 public void MuteOff()
 {
     _IsMuted = false;
     MuteFeedback.InvokeFireUpdate();
 }
Beispiel #11
0
 public void MuteOn()
 {
     _IsMuted = true;
     MuteFeedback.InvokeFireUpdate();
 }
        ///// <summary>
        ///// /
        ///// </summary>
        ///// <param name="sender"></param>
        //void Communication_BytesReceived(object sender, GenericCommMethodReceiveBytesArgs e)
        //{
        //    // This is probably not thread-safe buffering
        //    // Append the incoming bytes with whatever is in the buffer
        //    var newBytes = new byte[IncomingBuffer.Length + e.Bytes.Length];
        //    IncomingBuffer.CopyTo(newBytes, 0);
        //    e.Bytes.CopyTo(newBytes, IncomingBuffer.Length);

        //    if (Debug.Level == 2) // This check is here to prevent following string format from building unnecessarily on level 0 or 1
        //        Debug.Console(2, this, "Received:{0}", ComTextHelper.GetEscapedText(newBytes));

        //    // Need to find AA FF and have
        //    for (int i = 0; i < newBytes.Length; i++)
        //    {
        //        if (newBytes[i] == 0xAA && newBytes[i + 1] == 0xFF)
        //        {
        //            newBytes = newBytes.Skip(i).ToArray(); // Trim off junk if there's "dirt" in the buffer

        //            // parse it
        //            // If it's at least got the header, then process it,
        //            while (newBytes.Length > 4 && newBytes[0] == 0xAA && newBytes[1] == 0xFF)
        //            {
        //                var msgLen = newBytes[3];
        //                // if the buffer is shorter than the header (3) + message (msgLen) + checksum (1),
        //                // give and save it for next time
        //                if (newBytes.Length < msgLen + 4)
        //                    break;

        //                // Good length, grab the message
        //                var message = newBytes.Skip(4).Take(msgLen).ToArray();

        //                // At this point, the ack/nak is the first byte
        //                if (message[0] == 0x41)
        //                {
        //                    switch (message[1]) // type byte
        //                    {
        //                        case 0x00: // General status
        //                            UpdatePowerFB(message[2], message[5]); // "power" can be misrepresented when the display sleeps
        //                            UpdateInputFb(message[5]);
        //                            UpdateVolumeFB(message[3]);
        //                            UpdateMuteFb(message[4]);
        //                            UpdateInputFb(message[5]);
        //                            break;

        //                        case 0x11:
        //                            UpdatePowerFB(message[2]);
        //                            break;

        //                        case 0x12:
        //                            UpdateVolumeFB(message[2]);
        //                            break;

        //                        case 0x13:
        //                            UpdateMuteFb(message[2]);
        //                            break;

        //                        case 0x14:
        //                            UpdateInputFb(message[2]);
        //                            break;

        //                        default:
        //                            break;
        //                    }
        //                }
        //                // Skip over what we've used and save the rest for next time
        //                newBytes = newBytes.Skip(5 + msgLen).ToArray();
        //            }

        //            break; // parsing will mean we can stop looking for header in loop
        //        }
        //    }

        //    // Save whatever partial message is here
        //    IncomingBuffer = newBytes;
        //}

        void PortGather_LineReceived(object sender, GenericCommMethodReceiveTextArgs e)
        {
            Debug.Console(1, this, "Receivied: '{0}'", ComTextHelper.GetEscapedText(e.Text));

            if (e.Text.IndexOf("\x50\x4F\x57") > -1)
            {
                // Power Status Response

                var value = e.Text.ToCharArray();

                switch (value[6])
                {
                case '\x00':
                {
                    _PowerIsOn = false;
                    break;
                }

                case '\x01':
                {
                    _PowerIsOn = true;
                    break;
                }
                }

                PowerIsOnFeedback.FireUpdate();
                Debug.Console(1, this, "PowerIsOn State: {0}", PowerIsOnFeedback.BoolValue);
            }
            else if (e.Text.IndexOf("\x4D\x49\x4E") > -1)
            {
                var value = e.Text.ToCharArray();

                var b = value[6];

                var newInput = InputPorts.FirstOrDefault(i => i.FeedbackMatchObject.Equals(b));
                if (newInput != null && newInput != _CurrentInputPort)
                {
                    _CurrentInputPort = newInput;
                    CurrentInputFeedback.FireUpdate();
                    Debug.Console(1, this, "Current Input: {0}", CurrentInputFeedback.StringValue);
                }
            }
            else if (e.Text.IndexOf("\x56\x4F\x4C") > -1)
            {
                // Volume Status Response

                var value = e.Text.ToCharArray();

                var b = value[6];

                var newVol = (ushort)NumericalHelpers.Scale((double)b, 0, 100, 0, 65535);
                if (!VolumeIsRamping)
                {
                    _LastVolumeSent = newVol;
                }
                if (newVol != _VolumeLevelForSig)
                {
                    _VolumeLevelForSig = newVol;
                    VolumeLevelFeedback.FireUpdate();

                    if (_VolumeLevelForSig > 0)
                    {
                        _IsMuted = false;
                    }
                    else
                    {
                        _IsMuted = true;
                    }

                    MuteFeedback.FireUpdate();

                    Debug.Console(1, this, "Volume Level: {0}", VolumeLevelFeedback.IntValue);
                }
            }
        }