Example #1
0
        /// <summary>
        /// Opens the microwave control service
        /// </summary>
        /// <param name="sourceName">source name to open</param>
        public void Open(ClientConnectRequest request)
        {
            try
            {
                this.clientRequest = request;
                AppLogger.Message(request.UserName + " MicrowaveControlService.Open " + request.SourceName);

                if (!ResourceManager.Acquire <ResourceManager.MutexRule>(request.SourceName,
                                                                         typeof(MicrowaveControlService),
                                                                         request.UserName))
                {
                    string owner = ResourceManager.GetOwner(request.SourceName, typeof(MicrowaveControlService));
                    throw new SourceHasMaxClientsException("The microwave receiver is in use by " + ((owner == null) ? "<unknown>" : owner) + ".");
                }
                resourceAcquired = true;

                StreamSourceInfo sourceConfig = StreamSources.LoadFromFile().FindSource(request.SourceName);
                if (sourceConfig.MicrowaveControl == null)
                {
                    throw new SourceConfigException("Source does not have MicrowaveControl section defined!");
                }
                microwaveConfig = sourceConfig.MicrowaveControl;

                //get client callback
                clientCallback = OperationContext.Current.GetCallbackChannel <IMicrowaveControl2Callback>();

                //create microwave receiver instance
                microwaveReceiver = MicrowaveControlService2.CreateInstance(microwaveConfig);
                if (!microwaveReceiver.Connected)
                {
                    throw new SourceConfigException("Communication with the microwave receiver could not be established.");
                }
                microwaveReceiver.ReceiverTuningChange      += new EventHandler <MicrowaveReceiver.ReceiverEventArgs>(microwaveReceiver_ReceiverTuningChange);
                microwaveReceiver.ReceiverLinkQualityChange += new EventHandler <MicrowaveReceiver.ReceiverEventArgs>(microwaveReceiver_ReceiverLinkQualityChange);
                microwaveReceiver.ReceiverConnectionChange  += new EventHandler(microwaveReceiver_ReceiverConnectionChange);

                scanner = new PeakScan(microwaveReceiver);
                scanner.ScanCompleted += new EventHandler <ScanCompleteEvent>(scanner_ScanCompleted);

                //load cached presets
                LoadSavedPresets();

                microwaveReceiver.StartPollingLinkQuality();
            }
            catch (Exception exc)
            {
                AppLogger.Dump(exc);
                throw;
            }
        }
Example #2
0
        public void Open(ClientConnectRequest request)
        {
            try
            {
                clientRequest = request;
                AppLogger.Message(request.UserName + " CameraControlService.Open " + request.SourceName);

                StreamSourceInfo sourceConfig = StreamSources.LoadFromFile().FindSource(request.SourceName);
                if (sourceConfig.CameraControl == null)
                {
                    throw new SourceConfigException("Source does not have CameraControl defined!");
                }

                //lock against the camera control address -- this allows multiple sources to share the same camera.
                //    if the particular camera control does not require an address, then lock against the source name
                this.ResourceID = string.IsNullOrEmpty(sourceConfig.CameraControl.Address) ?
                                  request.SourceName :
                                  sourceConfig.CameraControl.Address;

                if (!ResourceManager.Acquire <ResourceManager.MutexRule>(this.ResourceID,
                                                                         typeof(CameraControlService),
                                                                         request.UserName))
                {
                    string owner = ResourceManager.GetOwner(this.ResourceID, typeof(CameraControlService));
                    throw new SourceHasMaxClientsException("The camera control is in use by " +
                                                           (string.IsNullOrEmpty(owner) ? "<unknown>" : owner) + ".");
                }
                resourceAcquired = true;

                CameraControl = sourceConfig.CameraControl;
                Plugin        = CameraControls.PluginFactory.Create(CameraControl, this);
                LoadSavedPositions();
            }
            catch (Exception exc)
            {
                AppLogger.Dump(exc);
                //throw new Exception("Unable to open camera control for " + sourceName, exc);
                throw;
            }
        }
Example #3
0
        AsyncOperationHandle PreloadAssets()
        {
            // Check the metadata to see if we should preload. First we check the table preload data, if one does not exist then check the key database(global).
            var preload = GetMetadata <PreloadAssetTableMetadata>() ?? SharedData.Metadata.GetMetadata <PreloadAssetTableMetadata>();

            // If no preload metadata was found then we will preload all assets by default.
            if (preload?.Behaviour != PreloadAssetTableMetadata.PreloadBehaviour.NoPreload)
            {
                var handleList = ListPool <AsyncOperationHandle> .Get();

                // Preload all
                foreach (var entry in Values)
                {
                    if (!entry.IsEmpty && !entry.AsyncOperation.HasValue)
                    {
                        // We have to preload the asset as an array so that we get all sub objects. The reason for this is that some assets,
                        // such as Sprite can contain multiple sub objects and if we load it as Object then we may get the wrong one.
                        // For example, if we load a Sprite as an Object and it has the same name as its Texture asset then it will load as a Texture,
                        // not Sprite. So if we load as an array we get both, we can then pick the one we need later based on the type passed into GetAssetAsync. (LOC-143)
                        entry.AsyncOperation = AddressablesInterface.LoadAssetFromGUID <Object[]>(entry.Guid);
                        ResourceManager.Acquire(entry.AsyncOperation.Value);
                        handleList.Add(entry.AsyncOperation.Value);
                    }
                }
                if (handleList.Count > 0)
                {
                    return(ResourceManager.CreateGenericGroupOperation(handleList));
                }
                else
                {
                    ListPool <AsyncOperationHandle> .Release(handleList);
                }
            }

            // Nothing to preload, we are done
            return(ResourceManager.CreateCompletedOperation(this, null));
        }