Example #1
0
        /// <summary>
        /// Adds InputPort
        /// </summary>
        void AddInputPortWithDebug(uint cardNum, string portName, eRoutingSignalType sigType, eRoutingPortConnectionType portType)
        {
            var portKey = string.Format("inputCard{0}--{1}", cardNum, portName);

            Debug.Console(2, this, "Adding input port '{0}'", portKey);
            var inputPort = new RoutingInputPort(portKey, sigType, portType, cardNum, this);

            InputPorts.Add(inputPort);
        }
Example #2
0
 public Amplifier(string key, string name)
     : base(key, name)
 {
     AudioIn = new RoutingInputPort(RoutingPortNames.AnyAudioIn, eRoutingSignalType.Audio,
                                    eRoutingPortConnectionType.None, null, this);
     InputPorts = new RoutingPortCollection <RoutingInputPort> {
         AudioIn
     };
 }
Example #3
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();
            }
        }
        /// <summary>
        ///  Make a Crestron RMC and put it in here
        /// </summary>
        public DmRmcX100CController(string key, string name, DmRmc100C rmc)
            : base(key, name, rmc)
        {
            Rmc  = rmc;
            DmIn = new RoutingInputPort(DmPortName.DmIn, eRoutingSignalType.Audio | eRoutingSignalType.Video,
                                        eRoutingPortConnectionType.DmCat, 0, this);
            HdmiOut = new RoutingOutputPort(DmPortName.HdmiOut, eRoutingSignalType.Audio | eRoutingSignalType.Video,
                                            eRoutingPortConnectionType.Hdmi, null, this);

            // Set Ports for CEC
            HdmiOut.Port = Rmc; // Unique case, this class has no HdmiOutput port and ICec is implemented on the receiver class itself
        }
Example #5
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;
            }
        }
        public DmTx4k100Controller(string key, string name, DmTx4K100C1G tx)
            : base(key, name, tx)
        {
            Tx = tx;

            HdmiIn = new RoutingInputPort(DmPortName.HdmiIn1,
                                          eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, eVst.Hdmi1, this);

            DmOut = new RoutingOutputPort(DmPortName.DmOut, eRoutingSignalType.Audio | eRoutingSignalType.Video,
                                          eRoutingPortConnectionType.DmCat, null, this);

            // Set Ports for CEC
            HdmiIn.Port = Tx;
        }
Example #7
0
        /// <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();
        }
        public HDBaseTRxController(string key, string name, HDRx3CB rmc)
            : base(key, name, rmc)
        {
            DmIn = new RoutingInputPort(DmPortName.DmIn, eRoutingSignalType.AudioVideo,
                                        eRoutingPortConnectionType.DmCat, 0, this);
            HDBaseTSink = new RoutingOutputPort(DmPortName.HdmiOut, eRoutingSignalType.AudioVideo,
                                                eRoutingPortConnectionType.Hdmi, null, this)
            {
                Port = Rmc
            };

            InputPorts = new RoutingPortCollection <RoutingInputPort> {
                DmIn
            };
            OutputPorts = new RoutingPortCollection <RoutingOutputPort> {
                HDBaseTSink
            };
        }
Example #9
0
        /// <summary>
        ///  Make a Crestron RMC and put it in here
        /// </summary>
        public DmRmcX100CController(string key, string name, DmRmc100C rmc)
            : base(key, name, rmc)
        {
            _rmc = rmc;
            DmIn = new RoutingInputPort(DmPortName.DmIn, eRoutingSignalType.AudioVideo,
                                        eRoutingPortConnectionType.DmCat, 0, this);
            HdmiOut = new RoutingOutputPort(DmPortName.HdmiOut, eRoutingSignalType.AudioVideo,
                                            eRoutingPortConnectionType.Hdmi, null, this)
            {
                Port = _rmc
            };

            InputPorts = new RoutingPortCollection <RoutingInputPort> {
                DmIn
            };
            OutputPorts = new RoutingPortCollection <RoutingOutputPort> {
                HdmiOut
            };
        }
Example #10
0
        public DmDge200CController(string key, string name, DmDge200C device, DeviceConfig dc, CrestronTouchpanelPropertiesConfig props)
            : base(key, name, device, dc, props)
        {
            _dge = device;

            DmIn = new RoutingInputPort(DmPortName.DmIn, eRoutingSignalType.AudioVideo,
                                        eRoutingPortConnectionType.DmCat, 0, this);
            HdmiOut = new RoutingOutputPort(DmPortName.HdmiOut, eRoutingSignalType.AudioVideo,
                                            eRoutingPortConnectionType.Hdmi, null, this);


            InputPorts = new RoutingPortCollection <RoutingInputPort> {
                DmIn
            };
            OutputPorts = new RoutingPortCollection <RoutingOutputPort> {
                HdmiOut
            };

            // Set Ports for CEC
            HdmiOut.Port = _dge.HdmiOut;;
        }
Example #11
0
        /// <summary>
        /// Adds InputPort and sets Port as ICec object
        /// </summary>
        void AddInputPortWithDebug(uint cardNum, string portName, eRoutingSignalType sigType, eRoutingPortConnectionType portType, ICec cecPort)
        {
            var portKey = string.Format("inputCard{0}--{1}", cardNum, portName);

            Debug.Console(2, this, "Adding input port '{0}'", portKey);
            var inputPort = new RoutingInputPort(portKey, sigType, portType, cardNum, this);

            if (inputPort != null)
            {
                if (cecPort != null)
                {
                    inputPort.Port = cecPort;
                }

                InputPorts.Add(inputPort);
            }
            else
            {
                Debug.Console(2, this, "inputPort is null");
            }
        }
        /// <summary>
        ///  Make a Crestron RMC and put it in here
        /// </summary>
        public DmRmc150SController(string key, string name, DmRmc150S rmc)
            : base(key, name, rmc)
        {
            Rmc  = rmc;
            DmIn = new RoutingInputPort(DmPortName.DmIn, eRoutingSignalType.Audio | eRoutingSignalType.Video,
                                        eRoutingPortConnectionType.DmCat, 0, this);
            HdmiOut = new RoutingOutputPort(DmPortName.HdmiOut, eRoutingSignalType.Audio | eRoutingSignalType.Video,
                                            eRoutingPortConnectionType.Hdmi, null, this);

            EdidManufacturerFeedback    = new StringFeedback(() => Rmc.HdmiOutput.ConnectedDevice.Manufacturer.StringValue);
            EdidNameFeedback            = new StringFeedback(() => Rmc.HdmiOutput.ConnectedDevice.Name.StringValue);
            EdidPreferredTimingFeedback = new StringFeedback(() => Rmc.HdmiOutput.ConnectedDevice.PreferredTiming.StringValue);
            EdidSerialNumberFeedback    = new StringFeedback(() => Rmc.HdmiOutput.ConnectedDevice.SerialNumber.StringValue);

            //VideoOutputResolutionFeedback = new StringFeedback(() => Rmc.HdmiOutput.GetVideoResolutionString());

            //Rmc.HdmiOutput.OutputStreamChange += HdmiOutput_OutputStreamChange;
            Rmc.HdmiOutput.ConnectedDevice.DeviceInformationChange += ConnectedDevice_DeviceInformationChange;

            // Set Ports for CEC
            HdmiOut.Port = Rmc.HdmiOutput;
        }
Example #13
0
        /// <summary>
        ///  Make a Crestron RMC and put it in here
        /// </summary>
        public DmRmc4kScalerCController(string key, string name, DmRmc4kScalerC rmc)
            : base(key, name, rmc)
        {
            _rmc = rmc;

            DmIn = new RoutingInputPort(DmPortName.DmIn, eRoutingSignalType.AudioVideo,
                                        eRoutingPortConnectionType.DmCat, 0, this);
            HdmiOut = new RoutingOutputPort(DmPortName.HdmiOut, eRoutingSignalType.AudioVideo,
                                            eRoutingPortConnectionType.Hdmi, null, this);
            BalancedAudioOut = new RoutingOutputPort(DmPortName.BalancedAudioOut, eRoutingSignalType.Audio,
                                                     eRoutingPortConnectionType.LineAudio, null, this);

            MuteFeedback = new BoolFeedback(() => false);

            VolumeLevelFeedback = new IntFeedback("MainVolumeLevelFeedback", () =>
                                                  rmc.AudioOutput.VolumeFeedback.UShortValue);

            EdidManufacturerFeedback    = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.Manufacturer.StringValue);
            EdidNameFeedback            = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.Name.StringValue);
            EdidPreferredTimingFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.PreferredTiming.StringValue);
            EdidSerialNumberFeedback    = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.SerialNumber.StringValue);

            InputPorts = new RoutingPortCollection <RoutingInputPort> {
                DmIn
            };
            OutputPorts = new RoutingPortCollection <RoutingOutputPort> {
                HdmiOut, BalancedAudioOut
            };

            VideoOutputResolutionFeedback = new StringFeedback(() => _rmc.HdmiOutput.GetVideoResolutionString());

            _rmc.HdmiOutput.OutputStreamChange += HdmiOutput_OutputStreamChange;
            _rmc.HdmiOutput.ConnectedDevice.DeviceInformationChange += ConnectedDevice_DeviceInformationChange;

            // Set Ports for CEC
            HdmiOut.Port = _rmc.HdmiOutput;
        }
Example #14
0
        /// <summary>
        /// Returns the appropriate tie line for either a card-based device or
        /// regular device with ports on-device.
        /// </summary>
        /// <returns>null if config data does not match ports, cards or devices</returns>
        public TieLine GetTieLine()
        {
            Debug.Console(0, "Build TieLine: {0}", this);
            // Get the source device
            var sourceDev = DeviceManager.GetDeviceForKey(SourceKey) as IRoutingOutputs;

            if (sourceDev == null)
            {
                LogError("Routable source not found");
                return(null);
            }

            // Get the destination device
            var destDev = DeviceManager.GetDeviceForKey(DestinationKey) as IRoutingInputs;

            if (destDev == null)
            {
                LogError("Routable destination not found");
                return(null);
            }

            //Get the source port
            RoutingOutputPort sourceOutputPort = null;

            //// If it's a card-based device, get the card and then the source port
            //if (sourceDev is ICardPortsDevice)
            //{
            //    if (SourceCard == null)
            //    {
            //        LogError("Card missing from source device config");
            //        return null;
            //    }
            //    sourceOutputPort = (sourceDev as ICardPortsDevice).GetChildOutputPort(SourceCard, SourcePort);
            //    if (sourceOutputPort == null)
            //    {
            //        LogError("Source card does not contain port");
            //        return null;
            //    }
            //}
            //// otherwise it's a normal port device, get the source port
            //else
            //{
            sourceOutputPort = sourceDev.OutputPorts[SourcePort];
            if (sourceOutputPort == null)
            {
                LogError("Source does not contain port");
                return(null);
            }
            //}


            //Get the Destination port
            RoutingInputPort destinationInputPort = null;

            //// If it's a card-based device, get the card and then the Destination port
            //if (destDev is ICardPortsDevice)
            //{
            //    if (DestinationCard == null)
            //    {
            //        LogError("Card missing from destination device config");
            //        return null;
            //    }
            //    destinationInputPort = (destDev as ICardPortsDevice).GetChildInputPort(DestinationCard, DestinationPort);
            //    if (destinationInputPort == null)
            //    {
            //        LogError("Destination card does not contain port");
            //        return null;
            //    }
            //}
            //// otherwise it's a normal port device, get the Destination port
            //else
            //{
            destinationInputPort = destDev.InputPorts[DestinationPort];
            if (destinationInputPort == null)
            {
                LogError("Destination does not contain port");
                return(null);
            }
            //}

            return(new TieLine(sourceOutputPort, destinationInputPort));
        }
Example #15
0
 public BlueJeansPc(string key, string name)
     : base(key, name)
 {
     InputPorts = new RoutingPortCollection <RoutingInputPort>();
     InputPorts.Add(AnyVideoIn = new RoutingInputPort(RoutingPortNames.AnyVideoIn, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.None, 0, this));
 }
Example #16
0
 void AddRoutingInputPort(RoutingInputPort port, byte fbMatch)
 {
     port.FeedbackMatchObject = fbMatch;
     InputPorts.Add(port);
 }
Example #17
0
        public DmpsInternalVirtualHdmiVgaBncInputController(string key, string name, Card.Dmps3HdmiVgaBncInput inputCard)
            : base(key, name, inputCard)
        {
            InputCard = inputCard;

            HdmiIn = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn, eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi,
                                                           eDmps3InputVideoSource.Hdmi, this, VideoStatusHelper.GetHdmiInputStatusFuncs(InputCard.HdmiInputPort));
            VgaIn = new RoutingInputPortWithVideoStatuses(DmPortName.VgaIn,
                                                          eRoutingSignalType.Video, eRoutingPortConnectionType.Vga, eDmps3InputVideoSource.Vga, this,
                                                          VideoStatusHelper.GetVgaInputStatusFuncs(InputCard.VgaInputPort));
            BncIn = new RoutingInputPortWithVideoStatuses(DmPortName.BncIn, eRoutingSignalType.Video, eRoutingPortConnectionType.Component,
                                                          eDmps3InputVideoSource.Bnc, this, VideoStatusHelper.GetBncInputStatusFuncs(InputCard.BncInputPort));
            SpdifIn = new RoutingInputPort(DmPortName.SpdifIn, eRoutingSignalType.Audio, eRoutingPortConnectionType.DigitalAudio,
                                           eDmps3InputAudioSource.Spdif, this);

            if (InputCard.HdmiInputPort.HdcpSupportedLevelFeedback == eHdcpSupportedLevel.Hdcp2xSupport)
            {
                HdcpSupportCapability = eHdcpCapabilityType.Hdcp2_2Support;
            }
            else if (InputCard.HdmiInputPort.HdcpSupportedLevelFeedback == eHdcpSupportedLevel.Hdcp1xSupport)
            {
                HdcpSupportCapability = eHdcpCapabilityType.Hdcp1xSupport;
            }

            var combinedFuncs = new VideoStatusFuncsWrapper
            {
                HdcpActiveFeedbackFunc = () =>
                                         (ActualVideoInput == eDmps3InputVideoSource.Hdmi &&
                                          InputCard.HdmiInputPort.VideoAttributes.HdcpActiveFeedback.BoolValue),

                HdcpStateFeedbackFunc = () =>
                {
                    if (ActualVideoInput == eDmps3InputVideoSource.Hdmi)
                    {
                        return(InputCard.HdmiInputPort.VideoAttributes.HdcpStateFeedback.ToString());
                    }
                    return("");
                },

                VideoResolutionFeedbackFunc = () =>
                {
                    if (ActualVideoInput == eDmps3InputVideoSource.Hdmi)
                    {
                        return(InputCard.HdmiInputPort.VideoAttributes.GetVideoResolutionString());
                    }
                    if (ActualVideoInput == eDmps3InputVideoSource.Vga)
                    {
                        return(InputCard.VgaInputPort.VideoAttributes.GetVideoResolutionString());
                    }
                    if (ActualVideoInput == eDmps3InputVideoSource.Bnc)
                    {
                        return(InputCard.BncInputPort.VideoAttributes.GetVideoResolutionString());
                    }
                    return("");
                },
                VideoSyncFeedbackFunc = () =>
                                        (ActualVideoInput == eDmps3InputVideoSource.Hdmi &&
                                         InputCard.HdmiInputPort.SyncDetectedFeedback.BoolValue) ||
                                        (ActualVideoInput == eDmps3InputVideoSource.Vga &&
                                         InputCard.VgaInputPort.SyncDetectedFeedback.BoolValue) ||
                                        (ActualVideoInput == eDmps3InputVideoSource.Bnc &&
                                         InputCard.BncInputPort.VideoDetectedFeedback.BoolValue),

                HasVideoStatusFunc = () =>
                                     (ActualVideoInput == eDmps3InputVideoSource.Hdmi &&
                                      HdmiIn.VideoStatus.HasVideoStatusFeedback.BoolValue) ||
                                     (ActualVideoInput == eDmps3InputVideoSource.Vga &&
                                      VgaIn.VideoStatus.HasVideoStatusFeedback.BoolValue) ||
                                     (ActualVideoInput == eDmps3InputVideoSource.Bnc &&
                                      BncIn.VideoStatus.HasVideoStatusFeedback.BoolValue)
            };

            AnyVideoInput = new RoutingInputPortWithVideoStatuses(DmPortName.AnyVideoIn,
                                                                  eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.None, 0, this, combinedFuncs);

            ActiveVideoInputFeedback = new StringFeedback("ActiveVideoInput", () => ActualVideoInput.ToString());

            VideoSourceNumericFeedback = new IntFeedback(() =>
            {
                return((int)InputCard.VideoSourceFeedback);
            });
            AudioSourceNumericFeedback = new IntFeedback(() =>
            {
                return((int)InputCard.AudioSourceFeedback);
            });

            HdmiInHdcpCapabilityFeedback = new IntFeedback("HdmiInHdcpCapability", () =>
            {
                if (InputCard.HdmiInputPort.HdcpSupportOnFeedback.BoolValue)
                {
                    return(1);
                }
                else
                {
                    return(0);
                }
            });

            // Set Ports for CEC
            HdmiIn.Port = InputCard.HdmiInputPort;

            VirtualDmOut = new RoutingOutputPort(DmPortName.DmOut, eRoutingSignalType.Audio | eRoutingSignalType.Video,
                                                 eRoutingPortConnectionType.None, null, this);

            AddToFeedbackList(ActiveVideoInputFeedback, VideoSourceNumericFeedback, AudioSourceNumericFeedback,
                              AnyVideoInput.VideoStatus.HasVideoStatusFeedback, AnyVideoInput.VideoStatus.HdcpActiveFeedback,
                              AnyVideoInput.VideoStatus.HdcpStateFeedback, AnyVideoInput.VideoStatus.VideoResolutionFeedback,
                              AnyVideoInput.VideoStatus.VideoSyncFeedback, HdmiInHdcpCapabilityFeedback);

            //AddPostActivationAction(() =>
            //{
            // Link up all of these damned events to the various RoutingPorts via a helper handler
            InputCard.HdmiInputPort.InputOutput.BaseDevice.BaseEvent += (o, a) => FowardInputStreamChange(HdmiIn, a.EventId);
            InputCard.HdmiInputPort.VideoAttributes.AttributeChange  += (o, a) => ForwardVideoAttributeChange(HdmiIn, a.EventId);

            InputCard.VgaInputPort.InputOutput.BaseDevice.BaseEvent += (o, a) => FowardInputStreamChange(VgaIn, a.EventId);
            InputCard.VgaInputPort.VideoAttributes.AttributeChange  += (o, a) => ForwardVideoAttributeChange(VgaIn, a.EventId);

            InputCard.BncInputPort.InputOutput.BaseDevice.BaseEvent += (o, a) => FowardInputStreamChange(HdmiIn, a.EventId);
            InputCard.BncInputPort.VideoAttributes.AttributeChange  += (o, a) => ForwardVideoAttributeChange(HdmiIn, a.EventId);
            //});
        }
Example #18
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);
                }
            }
        }
Example #19
0
        /// <summary>
        /// CCDDisplay Plugin device constructor for ISerialComport transport
        /// </summary>
        /// <param name="key"></param>
        /// <param name="name"></param>
        /// <param name="config"></param>
        /// <param name="display">Loaded and initialized instance of CCD Display driver instance</param>
        public RVCDisplayDevice(string key, string name, RVCDisplayConfig config, RoomViewConnectedDisplay display)
            : base(key, name)
        {
            Debug.Console(0, this, "Constructing new {0} instance", name);

            _config  = config;
            _display = display;

            StatusFeedback = new IntFeedback(() => (int)CommunicationMonitor.Status);
            Feedbacks.Add(StatusFeedback);

            VolumeLevelFeedback = new IntFeedback(() => { return((int)_display.VolumeFeedback.UShortValue); });
            MuteFeedback        = new BoolFeedback(() => _display.MuteOnFeedback.BoolValue);
            Feedbacks.Add(VolumeLevelFeedback);
            Feedbacks.Add(MuteFeedback);

            CommunicationMonitor = new CrestronGenericBaseCommunicationMonitor(this, _display, 12000, 30000);

            for (uint i = 1; i <= _display.SourceSelectFeedbackSigs.Count; i++)
            {
                string sourceName = "input" + i.ToString();
                /// CompactFramework fix for inline Actions and using iterator variables
                uint             sourceIndex = i;
                RoutingInputPort inputPort   = new RoutingInputPort(sourceName, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, new Action(() => _display.SourceSelectSigs[sourceIndex].BoolValue = true), this)
                {
                    FeedbackMatchObject = sourceIndex
                };
                _display.SourceSelectSigs[sourceIndex].UserObject = inputPort;
                InputPorts.Add(inputPort);
            }

            CrestronConsole.AddNewConsoleCommand((s) =>
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine("Driver Information:");
                sb.AppendFormat("\tDevice ID:        {0}\r\n", _display.DeviceIdStringFeedback.StringValue);
                sb.AppendFormat("\tFirmware:         {0}\r\n", _display.FirmwareVersionFeedback.StringValue);
                sb.AppendFormat("\tName:             {0}\r\n", _display.ProjectorNameFeedback.StringValue);
                sb.AppendFormat("\tDescription:      {0}\r\n", _display.Description);
                sb.AppendFormat("\tStatus:           {0}\r\n", _display.StatusMessageFeedback.StringValue);
                sb.AppendFormat("\tLamp:             {0}\r\n", _display.LampHoursFeedback.UShortValue);
                sb.AppendFormat("\tLamp (text):      {0}\r\n", _display.LampHoursTextFeedback.StringValue);

                CrestronConsole.ConsoleCommandResponse("{0}", sb.ToString());
            },
                                                 Key + "INFO", "Print Driver Info", ConsoleAccessLevelEnum.AccessOperator);

            CrestronConsole.AddNewConsoleCommand((s) =>
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine("State:");
                sb.AppendFormat("\tName:             {0}\r\n", _display.Name);
                sb.AppendFormat("\tID:               {0}\r\n", _display.ID);
                sb.AppendFormat("\tOnline:           {0}\r\n", _display.IsOnline?"Online":"Offline");
                sb.AppendFormat("\tPower:            {0}\r\n", _display.PowerOnFeedback.BoolValue?"ON":"OFF");
                sb.AppendFormat("\tCooling:          {0}\r\n", _display.CoolingDownFeedback.BoolValue ? "ON" : "OFF");
                sb.AppendFormat("\tWarming:          {0}\r\n", _display.WarmingUpFeedback.BoolValue ? "ON" : "OFF");
                sb.AppendFormat("\tMute:             {0}\r\n", _display.MuteOnFeedback.BoolValue ? "ON" : "OFF");
                sb.AppendFormat("\tVolume:           {0}\r\n", _display.VolumeFeedback.UShortValue);
                sb.AppendFormat("\tLamp:             {0}\r\n", _display.LampHoursFeedback.UShortValue);

                CrestronConsole.ConsoleCommandResponse("{0}", sb.ToString());
            },
                                                 Key + "STATE", "Print display state", ConsoleAccessLevelEnum.AccessOperator);

            CrestronConsole.AddNewConsoleCommand((s) =>
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendFormat("Current Input:  {0}\r\n", _display.CurrentSourceFeedback.StringValue);
                sb.AppendFormat("Inputs:\r\n");
                for (uint i = 1; i <= _display.SourceSelectFeedbackSigs.Count; i++)
                {
                    string sourceName = _display.SourceNameTextFeedbackSigs[i].StringValue;
                    if (String.IsNullOrEmpty(sourceName) || String.IsNullOrEmpty(sourceName.Trim()))
                    {
                        break;
                    }
                    sb.AppendFormat("\t{0}: {1}\r\n", sourceName, _display.SourceSelectFeedbackSigs[i].BoolValue ? "ON" : "");
                }

                CrestronConsole.ConsoleCommandResponse(sb.ToString());
            },
                                                 Key + "INPUTS", "Display Driver Inputs", ConsoleAccessLevelEnum.AccessOperator);

            CrestronConsole.AddNewConsoleCommand((s) =>
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendFormat("Input Ports:\r\n");
                foreach (var inputPort in InputPorts)
                {
                    //uint sourceSelectIndex = _display.SourceSelectSigs.FirstOrDefault<BoolInputSig>(sig => sig.UserObject == inputPort).Number;
                    uint sourceSelectIndex = 0;
                    for (uint i = 1; i <= _display.SourceSelectSigs.Count; i++)
                    {
                        if (_display.SourceSelectSigs[i].UserObject == inputPort)
                        {
                            sourceSelectIndex = i;
                            break;
                        }
                    }
                    sb.AppendFormat("\t{0}: {1}\r\n", inputPort.Key, _display.SourceNameTextFeedbackSigs[sourceSelectIndex].StringValue);
                }

                CrestronConsole.ConsoleCommandResponse(sb.ToString());
            },
                                                 Key + "ROUTINGPORTS", "Display Driver Routing Ports", ConsoleAccessLevelEnum.AccessOperator);
        }
Example #20
0
 public GenericAudioOut(string key, string name)
     : base(key, name)
 {
     AnyAudioIn = new RoutingInputPort(RoutingPortNames.AnyAudioIn, eRoutingSignalType.Audio,
                                       eRoutingPortConnectionType.LineAudio, null, this);
 }