Ejemplo n.º 1
0
 private void SendSelectedBodyData(double[] data)
 {
     if (isBroadcasting)
     {
         double timestamp = local_clock() - localClockStartingPoint;
         outletData.push_sample(data, timestamp);
         AddRowToDataTable(moCapDataTable, data);
     }
 }
Ejemplo n.º 2
0
        private void SendMarker(Marker marker)
        {
            string   message = marker.Type.ToString() + " : " + marker.Content;
            DateTime now     = DateTime.Now;

            markerDescriptionTextBlock.Text = "\"" + message + "\"\n"
                                              + "At timestamp : " + now.ToString("HH:mm:ss.fff");

            outletMarker.push_sample(new string[] { message }, local_clock() - localClockStartingPoint);

            string[] data = new string[] { now.ToString("yyyy-MM-dd HH:mm:ss.fff", CultureInfo.InvariantCulture), message };
            AddRowToDataTable(markerDataTable, data);
        }
        /// <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));
            }
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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));
            }
        }