|
1 | | -using System; |
2 | | -using System.Threading; |
3 | | -using LSL; |
4 | | - |
5 | | -namespace ConsoleApplication1 |
6 | | -{ |
7 | | - class Program |
8 | | - { |
9 | | - static void Main(string[] args) |
10 | | - { |
11 | | - // 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++) |
16 | | - chns.append_child("channel") |
17 | | - .append_child_value("label", labels[k]) |
18 | | - .append_child_value("unit", "microvolts") |
19 | | - .append_child_value("type","EEG"); |
20 | | - info.desc().append_child_value("manufacturer","SCCN"); |
21 | | - 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 | | - |
26 | | - // create outlet for the stream |
27 | | - liblsl.StreamOutlet outlet = new liblsl.StreamOutlet(info); |
28 | | - |
29 | | - // === the following could run on another computer === |
30 | | - |
31 | | - // 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]); |
34 | | - // get the full stream info (including custom meta-data) and dissect it |
35 | | - liblsl.StreamInfo inf = inlet.info(); |
36 | | - Console.WriteLine("The stream's XML meta-data is: "); |
37 | | - Console.WriteLine(inf.as_xml()); |
38 | | - Console.WriteLine("The manufacturer is: " + inf.desc().child_value("manufacturer")); |
39 | | - Console.WriteLine("The cap circumference is: " + inf.desc().child("cap").child_value("size")); |
40 | | - 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++) { |
43 | | - Console.WriteLine(" " + ch.child_value("label")); |
44 | | - ch = ch.next_sibling(); |
45 | | - } |
46 | | - Console.ReadKey(); |
47 | | - } |
48 | | - } |
49 | | -} |
| 1 | +using System; |
| 2 | +using System.Threading; |
| 3 | +using LSL; |
| 4 | + |
| 5 | +namespace ConsoleApplication1 |
| 6 | +{ |
| 7 | + class Program |
| 8 | + { |
| 9 | + static void Main(string[] args) |
| 10 | + { |
| 11 | + // 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++) |
| 16 | + chns.append_child("channel") |
| 17 | + .append_child_value("label", labels[k]) |
| 18 | + .append_child_value("unit", "microvolts") |
| 19 | + .append_child_value("type","EEG"); |
| 20 | + info.desc().append_child_value("manufacturer","SCCN"); |
| 21 | + 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 | + |
| 26 | + // create outlet for the stream |
| 27 | + liblsl.StreamOutlet outlet = new liblsl.StreamOutlet(info); |
| 28 | + |
| 29 | + // === the following could run on another computer === |
| 30 | + |
| 31 | + // 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]); |
| 34 | + // get the full stream info (including custom meta-data) and dissect it |
| 35 | + liblsl.StreamInfo inf = inlet.info(); |
| 36 | + Console.WriteLine("The stream's XML meta-data is: "); |
| 37 | + Console.WriteLine(inf.as_xml()); |
| 38 | + Console.WriteLine("The manufacturer is: " + inf.desc().child_value("manufacturer")); |
| 39 | + Console.WriteLine("The cap circumference is: " + inf.desc().child("cap").child_value("size")); |
| 40 | + 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++) { |
| 43 | + Console.WriteLine(" " + ch.child_value("label")); |
| 44 | + ch = ch.next_sibling(); |
| 45 | + } |
| 46 | + Console.ReadKey(); |
| 47 | + } |
| 48 | + } |
| 49 | +} |
0 commit comments