Beispiel #1
0
        private void SetMoCapStreamDefinition()
        {
            StreamInfo mocapStreamMetaData =
                new StreamInfo("EuroMov-Mocap-Kinect", "MoCap",
                               CHANNELS_PER_SKELETON, DATA_STREAM_NOMINAL_RATE, channel_format_t.cf_double64, currentKinectSensor.UniqueKinectId);

            XMLElement channels = mocapStreamMetaData.desc().append_child("channels");

            //Timestamp channel
            AddNewChannel(channels, "Timestamp", "Time", "Unix time");

            for (int skeletonNumber = 0; skeletonNumber < MAX_SKELETON_TRACKED; skeletonNumber++)
            {
                for (int skeletonJointNumber = 0; skeletonJointNumber < JOINT_COUNT; skeletonJointNumber++)
                {
                    String currentJointName = Enum.GetName(typeof(JointType), skeletonJointNumber);

                    for (int i = 0; i < 3; i++)
                    {
                        AddNewJointChannel(channels, currentJointName + (JointValueNameSuffix)i, (MoCapChannelType)i, "meters");
                    }
                    AddNewJointChannel(channels, currentJointName + JointValueNameSuffix._Conf, MoCapChannelType.Confidence, "normalized");
                }
            }

            // misc meta-data
            mocapStreamMetaData.desc().append_child("acquisition")
            .append_child_value("manufacturer", "Microsoft")
            .append_child_value("model", "Kinect 2.0");

            outletData = new StreamOutlet(mocapStreamMetaData);
        }
Beispiel #2
0
        public static void Main(string[] args)
        {
            {
                using StreamInfo inf_ = new StreamInfo("Test", "EEG", 8, 100, channel_format_t.cf_double64, "test1234");
                Console.Out.WriteLine("Test");
            }
            // create a new StreamInfo and declare some meta-data (in accordance with XDF format)
            using StreamInfo info = new StreamInfo("MetaTester", "EEG", 8, 100, channel_format_t.cf_float32, "myuid323457");
            XMLElement chns = info.desc().append_child("channels");

            String[] labels = { "C3", "C4", "Cz", "FPz", "POz", "CPz", "O1", "O2" };
            for (int k = 0; k < labels.Length; k++)
            {
                chns.append_child("channel")
                .append_child_value("label", labels[k])
                .append_child_value("unit", "microvolts")
                .append_child_value("type", "EEG");
            }
            info.desc().append_child_value("manufacturer", "SCCN");
            info.desc().append_child("cap")
            .append_child_value("name", "EasyCap")
            .append_child_value("size", "54")
            .append_child_value("labelscheme", "10-20");

            // create outlet for the stream
            StreamOutlet outlet = new StreamOutlet(info);

            // === the following could run on another computer ===

            // resolve the stream and open an inlet
            StreamInfo[] results = LSL.LSL.resolve_stream("name", "MetaTester");
            using StreamInlet inlet = new StreamInlet(results[0]);
            results.DisposeArray();

            // get the full stream info (including custom meta-data) and dissect it
            using StreamInfo inf = inlet.info();
            Console.WriteLine("The stream's XML meta-data is: ");
            Console.WriteLine(inf.as_xml());
            Console.WriteLine("The manufacturer is: " + inf.desc().child_value("manufacturer"));
            Console.WriteLine("The cap circumference is: " + inf.desc().child("cap").child_value("size"));
            Console.WriteLine("The channel labels are as follows:");
            XMLElement ch = inf.desc().child("channels").child("channel");

            for (int k = 0; k < info.channel_count(); k++)
            {
                Console.WriteLine("  " + ch.child_value("label"));
                ch = ch.next_sibling();
            }
            Console.ReadKey();
        }
        /// <summary>
        /// Run function
        /// </summary>
        private async Task RunDataBroadcastServerAsync(CancellationToken cancelToken)
        {
            try
            {
                var info = new StreamInfo("bhStatus", "bhStatus", 1, IRREGULAR_RATE, channel_format_t.cf_string, NetworkUtilities.GetHostName());

                info.desc().append_child_value("boardId", BoardId.ToString());
                info.desc().append_child_value("sampleRate", SampleRate.ToString());

                //  create UDP client
                using (var outlet = new StreamOutlet(info))
                {
                    try
                    {
                        while (!cancelToken.IsCancellationRequested)
                        {
                            await NotifyDataToBroadcast.WaitAsync(cancelToken);

                            while (!StringsToBroadcast.IsEmpty)
                            {
                                try
                                {
                                    StringsToBroadcast.TryDequeue(out var broadcastString);
                                    outlet.push_sample(new string[]  { broadcastString });
                                }
                                catch (Exception ex)
                                {
                                    Log?.Invoke(this, new LogEventArgs(this, "RunBroadcastServerAsync", ex, LogLevel.ERROR));
                                }
                            }
                        }
                    }
                    catch (OperationCanceledException)
                    { }
                    catch (Exception e)
                    {
                        Log?.Invoke(this, new LogEventArgs(this, "RunBroadcastServerAsync", e, LogLevel.ERROR));
                    }
                }
            }
            catch (Exception e)
            {
                Log?.Invoke(this, new LogEventArgs(this, "RunBroadcastServerAsync", e, LogLevel.ERROR));
            }
        }
Beispiel #4
0
        public static void Main(string[] args)
        {
            Random rnd = new Random();

            // create stream info and outlet
            using StreamInfo info     = new StreamInfo("TestCSharp", "EEG", 8, 100, channel_format_t.cf_float32, "sddsfsdf");
            using StreamOutlet outlet = new StreamOutlet(info);
            float[] data = new float[8];
            while (!Console.KeyAvailable)
            {
                // generate random data and send it
                for (int k = 0; k < data.Length; k++)
                {
                    data[k] = rnd.Next(-100, 100);
                }
                outlet.push_sample(data);
                Thread.Sleep(10);
            }
        }
Beispiel #5
0
        public static void Main(string[] args)
        {
            // create stream info and outlet
            using StreamInfo inf    = new StreamInfo("Test1", "Markers", 1, 0, channel_format_t.cf_string, "giu4569");
            using StreamOutlet outl = new StreamOutlet(inf);

            Random rnd = new Random();

            string[] strings = new string[] { "Test", "ABC", "123" };
            string[] sample  = new string[1];
            for (int k = 0; !Console.KeyAvailable; k++)
            {
                // send a marker and wait for a random interval
                sample[0] = strings[k % 3];
                outl.push_sample(sample);
                Console.Out.WriteLine(sample[0]);
                Thread.Sleep(rnd.Next(1000));
            }
        }
        public static void Main(string[] args)
        {
            Random rnd = new Random();

            // create stream info and outlet
            using StreamInfo info     = new StreamInfo("TestCSharp", "EEG", 8, 100, channel_format_t.cf_float32, "sddsfsdf");
            using StreamOutlet outlet = new StreamOutlet(info);

            // send data in chunks of 10 samples and 8 channels
            float[,] data = new float[10, 8];
            while (!Console.KeyAvailable)
            {
                for (int s = 0; s < 10; s++)
                {
                    for (int c = 0; c < 8; c++)
                    {
                        data[s, c] = rnd.Next(-100, 100);
                    }
                }
                outlet.push_chunk(data);
                Thread.Sleep(100);
            }
        }
Beispiel #7
0
        private void SetMarkersStreamDefinition()
        {
            StreamInfo streamMarker = new StreamInfo("EuroMov-Markers-Kinect", "Markers", 1, 0, channel_format_t.cf_string, currentKinectSensor.UniqueKinectId);

            outletMarker = new StreamOutlet(streamMarker);
        }