Beispiel #1
0
        /// <summary> Resolves the stream. </summary>
        /// <returns></returns>
        private IEnumerator ResolveExpectedStream()
        {
            yield return(new WaitUntil(() => readyToResolve));            // False mutex to wait Found Stream before search an other

            readyToResolve = false;                                       // Avoïd double resolver

            liblsl.StreamInfo[] results = resolver.Results();
            yield return(new WaitUntil(() => results.Length > 0));

            Debug.Log($"Resolving Stream : Name = {streamName}, Steam Info Name = {results[0].Name()}, Stream Info Type = ({results[0].Type()}");

            inlet            = new liblsl.StreamInlet(results[0]);
            expectedChannels = inlet.Info().ChannelCount();

            readyToResolve = true;
            yield return(null);
        }
Beispiel #2
0
        private void UpdateStreams()
        {
            namesOfStreams.Clear();
            streamInfos = resolver.Results();

            if (streamInfos.Length == 0)
            {
                streamLookUpResult = NO_STREAMS_FOUND;
            }
            else
            {
                foreach (liblsl.StreamInfo item in streamInfos)
                {
                    namesOfStreams.Add($"{item.Name()} {item.Type()} {item.Hostname()} {item.Sampling()}");
                }
                streamLookUpResult = namesOfStreams.Count + N_STREAMS_FOUND;
            }
        }
Beispiel #3
0
        private IEnumerator ResolveContinuously()
        {
            while (true)
            {
                var results = resolver.Results();

                //foreach (var item in streams) {
                //if (!results.Any(r => r.Name().Equals(item.name))) {
                //if (onStreamLost.GetPersistentEventCount() > 0) { onStreamLost.Invoke(item); } } }
                //Replace by LINQ Expression

                foreach (LSLStreamInfoWrapper item in streams.Where(item => !results.Any(r => r.Name().Equals(item.name)))
                         .Where(item => onStreamLost.GetPersistentEventCount() > 0))
                {
                    onStreamLost.Invoke(item);
                }

                // remove lost streams from cache
                streams.RemoveAll(s => !results.Any(r => r.Name().Equals(s.name)));

                // add new found streams to the cache
                foreach (var item in results)
                {
                    if (!streams.Any(s => s.name == item.Name() && s.type == item.Type()))
                    {
                        Debug.Log($"Found new Stream {item.Name()}");

                        var newStreamInfo = new LSLStreamInfoWrapper(item);
                        streams.Add(newStreamInfo);

                        if (onStreamFound.GetPersistentEventCount() > 0)
                        {
                            onStreamFound.Invoke(newStreamInfo);
                        }
                    }
                }
                yield return(new WaitForSecondsRealtime(0.1f));
            }
        }