コード例 #1
0
        public async Task SimulateTemperatureEvents()
        {
            deviceId = "1";

            RegisterDeviceAsync().Wait();
            bool deviceActivated = await ActivateDeviceAsync();

            if (deviceActivated)
            {
                InitDeviceClient();

                stopWatch.Restart();
                numEventsSent = 0;
                LogStatus("Sending Temperature Events...");

                SensorBase sensor = new TemperatureSensor(deviceId, TransmitEvent);
                sensor.InitSchedule(10);
                Console.WriteLine("Generated {0:###,###,###} Events", sensor.CountOfDataPoints);
                sensor.Start().Wait();
                FlushIoTHubBuffer();
                stopWatch.Stop();

                Console.WriteLine("Completed transmission in {0} seconds. Sent {1:###,###,###} events.",
                                  stopWatch.Elapsed.TotalSeconds, numEventsSent);
            }
            else
            {
                LogError("Device Not Activated.");
            }
        }
        public void SimulateTemperatureEvents()
        {
            stopWatch.Restart();
            numEventsSent = 0;
            LogStatus("Sending Temperature Events...");
            SensorBase sensor = new TemperatureSensor("1", TransmitEvent);

            sensor.InitSchedule(10);
            Console.WriteLine("Generated {0:###,###,###} Events", sensor.CountOfDataPoints);
            sensor.Start().Wait();
            FlushEventHubBuffer();
            stopWatch.Stop();
            Console.WriteLine("Completed transmission in {0} seconds. Sent {1:###,###,###} events.",
                              stopWatch.Elapsed.TotalSeconds, numEventsSent);
        }