示例#1
0
        /// <summary>
        ///
        /// </summary>
        void UpdateInputFb(byte b)
        {
            var newInput = InputPorts.FirstOrDefault(i => i.FeedbackMatchObject.Equals(b));

            if (newInput != null && newInput != _CurrentInputPort)
            {
                _CurrentInputPort = newInput;
                CurrentInputFeedback.FireUpdate();
            }
        }
示例#2
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;
            }
        }
示例#3
0
        ///// <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);
                }
            }
        }