コード例 #1
0
        private void PlayFile()
        {
            EnablePlayback();

            var tmp = System.IO.Directory.GetCurrentDirectory();

            tmp += "\\DataFile\\Base_EEG_Data_Play.txt";
            if (File.Exists(tmp))
            {
                using (StreamReader sr = File.OpenText(tmp))
                {
                    while (!sr.EndOfStream && _StopEnabled == false)
                    {
                        _TimeSlice timeslice = new _TimeSlice();
                        var        line      = sr.ReadLine();
                        string[]   values    = line.Split(',');
                        var        floats    = new List <double>();
                        for (int channel = 0; channel < 15; channel++)
                        {
                            try
                            {
                                var value = ((float)Convert.ToDouble(values[channel]) / 10);
                                if (isInverted == true)
                                {
                                    value *= -1;
                                }
                                _writeBuffer buff = new _writeBuffer(channel, value);
                                timeslice.timeSlice.Add(buff);
                            }
                            catch (Exception ex)
                            {
                                var error = ex.Message.ToString();
                            }
                        }
                        ad5360.add_WrtieFrame(timeslice);
                    }
                    //set output to 0 volts at the end of the file
                    _TimeSlice Lasttimeslice = new _TimeSlice();
                    for (int channel = 0; channel < 15; channel++)
                    {
                        try
                        {
                            var          value = 0;
                            _writeBuffer buff  = new _writeBuffer(channel, value);
                            Lasttimeslice.timeSlice.Add(buff);
                        }
                        catch (Exception ex)
                        {
                            var error = ex.Message.ToString();
                        }
                    }
                    ad5360.add_WrtieFrame(Lasttimeslice);
                }
            }
        }
コード例 #2
0
        private async void btnSquareWave_Click(object sender, RoutedEventArgs e)
        {
            EnablePlayback();

            int count = 1000;

            for (int index = 0; index < count; index++)
            {
                _TimeSlice timeslice = new _TimeSlice();
                if (index % 2 == 0)
                {
                    for (int channel = 0; channel < 15; channel++)
                    {
                        try
                        {
                            var          value = 1;
                            _writeBuffer buff  = new _writeBuffer(channel, value);
                            timeslice.timeSlice.Add(buff);
                        }
                        catch (Exception ex)
                        {
                            var error = ex.Message.ToString();
                        }
                    }
                }
                else
                {
                    for (int channel = 0; channel < 15; channel++)
                    {
                        try
                        {
                            var          value = (float)0.5;
                            _writeBuffer buff  = new _writeBuffer(channel, value);
                            timeslice.timeSlice.Add(buff);
                        }
                        catch (Exception ex)
                        {
                            var error = ex.Message.ToString();
                        }
                    }
                }
                ad5360.add_WrtieFrame(timeslice);
            }
        }