コード例 #1
0
ファイル: Program.cs プロジェクト: JorisSpriet/Temperaturen
        static void Main(string[] args)
        {
            AtalLogger.AtalLogger logger = null;
            AtalLoggerFinder      finder = new AtalLoggerFinder();

            Console.WriteLine("Detecting logger for 10s.  Press Ctrl-C to interrupt.");

            var attempts = 20;

            do
            {
                logger = finder.FindLoggerPort("COM3");
                Thread.Sleep(500);
                Console.Write(".");
            } while (logger == null && --attempts > 0);

            if (logger == null)
            {
                return;
            }

            Console.WriteLine("Logger detected on {0}", logger.SerialPortName);
            var detail = logger.GetDetailsFromDevice();

            Console.WriteLine("Serial number     : {0}", detail.SerialNumber);
            Console.WriteLine("Number of samples : {0}", detail.NumberOfSamples);

            var data = logger.GetSamplesFromDevice(detail.NumberOfSamples, null);

            foreach (var d in data)
            {
                Console.WriteLine("{0}\t{1}", d.TimeStamp.ToString("yyyy-MM-dd HH:mm:ss"), d.Temperature);
            }
            logger.Dispose();
        }
コード例 #2
0
        private AtalLogger.AtalLogger DetectLogger()
        {
            int  count = 5;
            bool done;

            AtalLogger.AtalLogger logger = null;
            do
            {
                ReportProgress(c, AtalLoggerDataRetrievalCycleState.FindingLogger,
                               string.Format("Detectie logger - nog {0}s", count));
                logger = new AtalLoggerFinder().FindLoggerPort(null);
                count--;
                done = logger == null && count > 0;
                if (!done)
                {
                    Thread.Sleep(1000);
                }
            } while (!done);
            if (logger == null)
            {
                throw new Exception("De logger werd niet gedecteerd !\nSteek de logger (opnieuw) in de USB poort\nen probeer opnieuw.");
            }
            return(logger);
        }