|
1 | 1 | using System; |
2 | | -using System.Threading; |
3 | 2 | using LSL; |
4 | 3 |
|
5 | | -namespace ConsoleApplication1 |
| 4 | +namespace LSLExamples |
6 | 5 | { |
7 | | - class Program |
| 6 | + static class HandleMetaData |
8 | 7 | { |
9 | | - static void Main(string[] args) |
| 8 | + public static void Main(string[] args) |
10 | 9 | { |
| 10 | + { |
| 11 | + using StreamInfo inf_ = new StreamInfo("Test", "EEG", 8, 100, channel_format_t.cf_double64, "test1234"); |
| 12 | + Console.Out.WriteLine("Test"); |
| 13 | + } |
11 | 14 | // create a new StreamInfo and declare some meta-data (in accordance with XDF format) |
12 | | - liblsl.StreamInfo info = new liblsl.StreamInfo("MetaTester","EEG",8,100,liblsl.channel_format_t.cf_float32,"myuid323457"); |
13 | | - liblsl.XMLElement chns = info.desc().append_child("channels"); |
14 | | - String[] labels = {"C3","C4","Cz","FPz","POz","CPz","O1","O2"}; |
15 | | - for (int k=0;k<labels.Length;k++) |
| 15 | + using StreamInfo info = new StreamInfo("MetaTester", "EEG", 8, 100, channel_format_t.cf_float32, "myuid323457"); |
| 16 | + XMLElement chns = info.desc().append_child("channels"); |
| 17 | + String[] labels = { "C3", "C4", "Cz", "FPz", "POz", "CPz", "O1", "O2" }; |
| 18 | + for (int k = 0; k < labels.Length; k++) |
16 | 19 | chns.append_child("channel") |
17 | 20 | .append_child_value("label", labels[k]) |
18 | 21 | .append_child_value("unit", "microvolts") |
19 | | - .append_child_value("type","EEG"); |
20 | | - info.desc().append_child_value("manufacturer","SCCN"); |
| 22 | + .append_child_value("type", "EEG"); |
| 23 | + info.desc().append_child_value("manufacturer", "SCCN"); |
21 | 24 | info.desc().append_child("cap") |
22 | | - .append_child_value("name","EasyCap") |
23 | | - .append_child_value("size","54") |
24 | | - .append_child_value("labelscheme","10-20"); |
| 25 | + .append_child_value("name", "EasyCap") |
| 26 | + .append_child_value("size", "54") |
| 27 | + .append_child_value("labelscheme", "10-20"); |
25 | 28 |
|
26 | 29 | // create outlet for the stream |
27 | | - liblsl.StreamOutlet outlet = new liblsl.StreamOutlet(info); |
28 | | - |
| 30 | + StreamOutlet outlet = new StreamOutlet(info); |
| 31 | + |
29 | 32 | // === the following could run on another computer === |
30 | | - |
| 33 | + |
31 | 34 | // resolve the stream and open an inlet |
32 | | - liblsl.StreamInfo[] results = liblsl.resolve_stream("name","MetaTester"); |
33 | | - liblsl.StreamInlet inlet = new liblsl.StreamInlet(results[0]); |
| 35 | + StreamInfo[] results = LSL.LSL.resolve_stream("name", "MetaTester"); |
| 36 | + using StreamInlet inlet = new StreamInlet(results[0]); |
| 37 | + results.DisposeArray(); |
| 38 | + |
34 | 39 | // get the full stream info (including custom meta-data) and dissect it |
35 | | - liblsl.StreamInfo inf = inlet.info(); |
| 40 | + using StreamInfo inf = inlet.info(); |
36 | 41 | Console.WriteLine("The stream's XML meta-data is: "); |
37 | 42 | Console.WriteLine(inf.as_xml()); |
38 | 43 | Console.WriteLine("The manufacturer is: " + inf.desc().child_value("manufacturer")); |
39 | 44 | Console.WriteLine("The cap circumference is: " + inf.desc().child("cap").child_value("size")); |
40 | 45 | Console.WriteLine("The channel labels are as follows:"); |
41 | | - liblsl.XMLElement ch = inf.desc().child("channels").child("channel"); |
42 | | - for (int k=0;k<info.channel_count();k++) { |
| 46 | + XMLElement ch = inf.desc().child("channels").child("channel"); |
| 47 | + for (int k = 0; k < info.channel_count(); k++) |
| 48 | + { |
43 | 49 | Console.WriteLine(" " + ch.child_value("label")); |
44 | 50 | ch = ch.next_sibling(); |
45 | 51 | } |
|
0 commit comments