Exemplo n.º 1
0
 public void resolveStreams()
 {
     Console.WriteLine("Resolving Streams...");
     StreamInfo[] streaminfo = resolve_stream("type", Type, 1, 1);
     Streams = new LSLStream[streaminfo.Length];
     for (int i = 0; i < streaminfo.Length; i++)
     {
         Streams[i] = new LSLStream(streaminfo[i], customts);
     }
     Console.WriteLine("Done. " + streaminfo.Length + " Streams found for device " + Type);
 }
        private void stream(LSLStream s)
        {
            while (true)
            {
                _mre.WaitOne();

                //t.ThrowIfCancellationRequested();

                Double[] data = s.pullData();

                double timestamp = data[data.Length - 1];

                if (!s.customts)
                {
                    timestamp  = timestamp * 1000;
                    timestamp += lsloffset;
                }

                double[] dat = new double[data.Length - 1];
                Console.Write(s.StreamInfo.type() + " " + s.StreamInfo.name() + " Timestamp:" + timestamp);
                for (int i = 0; i < data.Length - 1; i++)
                {
                    Console.Write("," + data[i]);
                    dat[i] = data[i];
                }
                Console.Write(Environment.NewLine);

                Console.WriteLine("STREAMINFOTYPE " + s.StreamInfo.type());

                if (_recording)
                {
                    writeStreamToFile(s.FilePath, s.streamtype, s.datatype, s.header, dat, timestamp);
                }

                if (_token.IsCancellationRequested)
                {
                    Console.WriteLine(s.StreamInfo.name() + " stream cancelled");
                    break;
                }
            }
        }