Exemple #1
0
        /// <summary>
        /// Stop a specific signal filter task
        /// </summary>
        public async Task StopSignalFilteringAsync(string filterName)
        {
            if (ActiveFilters.ContainsKey(filterName))
            {
                await ActiveFilters[filterName].StopRealTimeProcessingAsyncAsync();
                ActiveFilters[filterName].Log -= OnComponentLog;
            }

            ActiveFilters.Remove(filterName);
        }
Exemple #2
0
        //public async Task<SignalFiltering> StartSignalFilteringAsync()
        //{
        //    var filterName = ActiveFilters.FirstOrDefault().Key;
        //    if (filterName != null)
        //        return await StartSignalFilteringAsync(filterName);

        //    return null;
        //}

        /// <summary>
        /// Start the signal filtering task
        /// </summary>
        public async Task <RealTimeSignalProcessing> StartRealTimeSignalProcessingAsync(SignalFilter filter, ISignalMontage montage)
        {
            var useMontage = montage;

            if (useMontage == null)
            {
                useMontage = SignalMontages.MakeDefaultMontage(NumberOfChannels);
            }

            var montageName = useMontage.Name;
            var filterName  = filter == null ? "XXXDEFAULTXXX" : filter.Name;

            if (CancelTokenSource == null)
            {
                Log?.Invoke(this, new LogEventArgs(Name, this, "StartSignalFiltering", $"You must start the processor first.", LogLevel.ERROR));
                return(null);
            }


            if (ActiveFilters.ContainsKey(RealTimeSignalProcessing.KeyName(filterName, montageName)))
            {
                return(ActiveFilters[RealTimeSignalProcessing.KeyName(filterName, montageName)]);
            }



            var newFilter = new RealTimeSignalProcessing(BoardId, SampleRate, filter, useMontage)
            {
                FilterBufferLength = 30,
            };

            newFilter.GetRawChunk = GetRawChunk;
            newFilter.Log        += OnComponentLog;

            ActiveFilters.Add(RealTimeSignalProcessing.KeyName(filterName, montageName), newFilter);
            await newFilter.StartRealTimeProcessingAsync();

            return(newFilter);
        }