Example #1
0
        /// <summary>
        /// Reads all rooms from config and adds them to DeviceManager
        /// </summary>
        public void LoadRooms()
        {
            if (ConfigReader.ConfigObject.Rooms == null)
            {
                Debug.Console(0, Debug.ErrorLogLevel.Warning, "WARNING: Configuration contains no rooms");
                return;
            }

            foreach (var roomConfig in ConfigReader.ConfigObject.Rooms)
            {
                var room = EssentialsRoomConfigHelper.GetRoomObject(roomConfig) as EssentialsRoomBase;
                if (room != null)
                {
                    if (room is EssentialsHuddleSpaceRoom)
                    {
                        DeviceManager.AddDevice(room);

                        Debug.Console(0, Debug.ErrorLogLevel.Notice, "Room is EssentialsHuddleSpaceRoom, attempting to add to DeviceManager with Fusion");
                        DeviceManager.AddDevice(new Core.Fusion.EssentialsHuddleSpaceFusionSystemControllerBase((EssentialsHuddleSpaceRoom)room, 0xf1));


                        Debug.Console(0, Debug.ErrorLogLevel.Notice, "Attempting to build Mobile Control Bridge...");
                        // Mobile Control bridge
                        var bridge = new MobileConrolEssentialsHuddleSpaceRoomBridge(room as EssentialsHuddleSpaceRoom);
                        AddBridgePostActivationHelper(bridge); // Lets things happen later when all devices are present
                        DeviceManager.AddDevice(bridge);

                        Debug.Console(0, Debug.ErrorLogLevel.Notice, "Mobile Control Bridge Added...");
                    }
                    else if (room is EssentialsHuddleVtc1Room)
                    {
                        DeviceManager.AddDevice(room);

                        Debug.Console(0, Debug.ErrorLogLevel.Notice, "Room is EssentialsHuddleVtc1Room, attempting to add to DeviceManager with Fusion");
                        DeviceManager.AddDevice(new EssentialsHuddleVtc1FusionController((EssentialsHuddleVtc1Room)room, 0xf1));

                        Debug.Console(0, Debug.ErrorLogLevel.Notice, "Attempting to build Mobile Control Bridge...");
                        // Mobile Control bridge
                        var bridge = new MobileConrolEssentialsHuddleSpaceRoomBridge(room);
                        AddBridgePostActivationHelper(bridge); // Lets things happen later when all devices are present
                        DeviceManager.AddDevice(bridge);
                    }
                    else
                    {
                        Debug.Console(0, Debug.ErrorLogLevel.Notice, "Room is NOT EssentialsRoom, attempting to add to DeviceManager w/o Fusion");
                        DeviceManager.AddDevice(room);
                    }
                }
                else
                {
                    Debug.Console(0, Debug.ErrorLogLevel.Notice, "WARNING: Cannot create room from config, key '{0}'", roomConfig.Key);
                }
            }

            Debug.Console(0, Debug.ErrorLogLevel.Notice, "All Rooms Loaded.");
        }
        void Initialize()
        {
            try
            {
                if (DefaultAudioDevice is IBasicVolumeControls)
                {
                    DefaultVolumeControls = DefaultAudioDevice as IBasicVolumeControls;
                }
                else if (DefaultAudioDevice is IHasVolumeDevice)
                {
                    DefaultVolumeControls = (DefaultAudioDevice as IHasVolumeDevice).VolumeDevice;
                }
                CurrentVolumeControls = DefaultVolumeControls;


                // Combines call feedback from both codecs if available
                InCallFeedback = new BoolFeedback(() =>
                {
                    bool inAudioCall = false;
                    bool inVideoCall = false;

                    if (AudioCodec != null)
                    {
                        inAudioCall = AudioCodec.IsInCall;
                    }

                    if (VideoCodec != null)
                    {
                        inVideoCall = VideoCodec.IsInCall;
                    }

                    if (inAudioCall || inVideoCall)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                });

                var disp = DefaultDisplay as DisplayBase;
                if (disp != null)
                {
                    // Link power, warming, cooling to display
                    disp.PowerIsOnFeedback.OutputChange += (o, a) =>
                    {
                        if (disp.PowerIsOnFeedback.BoolValue != OnFeedback.BoolValue)
                        {
                            if (!disp.PowerIsOnFeedback.BoolValue)
                            {
                                CurrentSourceInfo = null;
                            }
                            OnFeedback.FireUpdate();
                        }
                        if (disp.PowerIsOnFeedback.BoolValue)
                        {
                            SetDefaultLevels();
                        }
                    };

                    disp.IsWarmingUpFeedback.OutputChange += (o, a) =>
                    {
                        IsWarmingUpFeedback.FireUpdate();
                        if (!IsWarmingUpFeedback.BoolValue)
                        {
                            (CurrentVolumeControls as IBasicVolumeWithFeedback).SetVolume(DefaultVolume);
                        }
                    };
                    disp.IsCoolingDownFeedback.OutputChange += (o, a) =>
                    {
                        IsCoolingDownFeedback.FireUpdate();
                    };
                }



                // Get Microphone Privacy object, if any  MUST HAPPEN AFTER setting InCallFeedback
                this.MicrophonePrivacy = EssentialsRoomConfigHelper.GetMicrophonePrivacy(PropertiesConfig, this);

                Debug.Console(2, this, "Microphone Privacy Config evaluated.");

                // Get emergency object, if any
                this.Emergency = EssentialsRoomConfigHelper.GetEmergency(PropertiesConfig, this);

                Debug.Console(2, this, "Emergency Config evaluated.");


                VideoCodec.CallStatusChange += (o, a) => this.InCallFeedback.FireUpdate();

                if (AudioCodec != null)
                {
                    AudioCodec.CallStatusChange += (o, a) => this.InCallFeedback.FireUpdate();
                }

                IsSharingFeedback = new BoolFeedback(() => VideoCodec.SharingContentIsOnFeedback.BoolValue);
                VideoCodec.SharingContentIsOnFeedback.OutputChange += (o, a) => this.IsSharingFeedback.FireUpdate();

                // link privacy to VC (for now?)
                PrivacyModeIsOnFeedback = new BoolFeedback(() => VideoCodec.PrivacyModeIsOnFeedback.BoolValue);
                VideoCodec.PrivacyModeIsOnFeedback.OutputChange += (o, a) => this.PrivacyModeIsOnFeedback.FireUpdate();

                CallTypeFeedback = new IntFeedback(() => 0);

                SourceListKey             = "default";
                EnablePowerOnToLastSource = true;
            }
            catch (Exception e)
            {
                Debug.Console(0, this, "Error Initializing Room: {0}", e);
            }
        }
        void Initialize()
        {
            if (DefaultAudioDevice is IBasicVolumeControls)
            {
                DefaultVolumeControls = DefaultAudioDevice as IBasicVolumeControls;
            }
            else if (DefaultAudioDevice is IHasVolumeDevice)
            {
                DefaultVolumeControls = (DefaultAudioDevice as IHasVolumeDevice).VolumeDevice;
            }
            CurrentVolumeControls = DefaultVolumeControls;


            var leftDisp = LeftDisplay as DisplayBase;

            if (leftDisp != null)
            {
                InitializeDisplay(leftDisp);
            }

            var rightDisp = RightDisplay as DisplayBase;

            if (rightDisp != null)
            {
                InitializeDisplay(rightDisp);
            }

            // Get Microphone Privacy object, if any
            this.MicrophonePrivacy = EssentialsRoomConfigHelper.GetMicrophonePrivacy(PropertiesConfig, this);

            Debug.Console(2, this, "Microphone Privacy Config evaluated.");

            // Get emergency object, if any
            this.Emergency = EssentialsRoomConfigHelper.GetEmergency(PropertiesConfig, this);

            Debug.Console(2, this, "Emergency Config evaluated.");

            // Combines call feedback from both codecs if available
            InCallFeedback = new BoolFeedback(() =>
            {
                bool inAudioCall = false;
                bool inVideoCall = false;

                if (AudioCodec != null)
                {
                    inAudioCall = AudioCodec.IsInCall;
                }

                if (VideoCodec != null)
                {
                    inVideoCall = VideoCodec.IsInCall;
                }

                if (inAudioCall || inVideoCall)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            });

            VideoCodec.CallStatusChange += (o, a) => this.InCallFeedback.FireUpdate();

            if (AudioCodec != null)
            {
                AudioCodec.CallStatusChange += (o, a) => this.InCallFeedback.FireUpdate();
            }

            IsSharingFeedback = new BoolFeedback(() => VideoCodec.SharingContentIsOnFeedback.BoolValue);
            VideoCodec.SharingContentIsOnFeedback.OutputChange += (o, a) => this.IsSharingFeedback.FireUpdate();

            // link privacy to VC (for now?)
            PrivacyModeIsOnFeedback = new BoolFeedback(() => VideoCodec.PrivacyModeIsOnFeedback.BoolValue);
            VideoCodec.PrivacyModeIsOnFeedback.OutputChange += (o, a) => this.PrivacyModeIsOnFeedback.FireUpdate();

            CallTypeFeedback = new IntFeedback(() => 0);

            SourceListKey             = "default";
            EnablePowerOnToLastSource = true;
        }