Ejemplo n.º 1
0
        public void Record(double recTime)
        {
            var  switchTimes = new List <double> (10000);
            long loops       = 0;

            try {
                bool current    = false;
                long lastReport = -1;
                Console.WriteLine("Recording... ");
                var  tm        = Stopwatch.StartNew();
                long startTime = tm.ElapsedTicks;
                while (tm.Elapsed.TotalSeconds < recTime)
                {
                    var v = pin.Value;

                    if (current != v)
                    {
                        var t = tm.ElapsedTicks;
                        if (!current && switchTimes.Count == 0)
                        {
                            current   = v;
                            startTime = t;
                            continue;
                        }
                        switchTimes.Add(((double)(t - startTime) * 1000d) / (double)Stopwatch.Frequency);
                        current = v;
                    }

                    if (tm.ElapsedMilliseconds - lastReport > 1000)
                    {
                        lastReport = tm.ElapsedMilliseconds;
                        Console.WriteLine("* " + switchTimes.Count);
                    }
                    loops++;
                }
            } catch (Exception ex) {
                Console.WriteLine(ex);
            }

            Sample = new RfSample(switchTimes.ToArray());
        }
 public void Transmit(IRfSample sample)
 {
     Sample = sample;
     Transmit();
 }
 public void Load(string file)
 {
     Sample = new RfSample();
     Sample.Read(file);
 }