static void Main(string[] args)
        {
            var          rand    = new Random();
            var          client  = EventHubClient.CreateFromConnectionString(_connectionString);
            int          carId   = 42;
            CarStatistic initial = new CarStatistic()
            {
                Acceleration = 20,
                Braking      = 0,
                Speed        = 50,
                CarId        = carId
            };

            while (true)
            {
                CarStatistic current = new CarStatistic(initial);
                initial = current;


                // Send an event to the event hub
                var message = JsonConvert.SerializeObject(current);
                System.Threading.Thread.Sleep(1000);
                client.Send(new EventData(Encoding.UTF8.GetBytes(message)));
                Console.WriteLine("[{0}] Event transmitted", current.GuId.ToString());
            }
        }
        public CarStatistic(CarStatistic previous)
        {
            Random random = new Random();

            this.GuId  = Guid.NewGuid();
            this.CarId = previous.CarId;
            int isBraking = 0;

            isBraking = random.Next(15);
            if (previous.Braking > 0)
            {
                isBraking += 2;
            }

            if (isBraking >= 15)
            {
                this.Braking      = 100;
                this.Acceleration = 0;
                if (random.Next(0, 1) == 0)
                {
                    this.Speed = 0;
                }
                else
                {
                    this.Speed = previous.Speed / 3;
                }
            }

            if (isBraking < 11)
            {
                this.Braking      = 0;
                this.Acceleration = Math.Abs(previous.Acceleration + random.Next(-15, 15));
                this.Speed        = Math.Abs(previous.Speed + (this.Acceleration - previous.Acceleration) * 2);
            }

            if (isBraking >= 11 && isBraking < 15)
            {
                this.Acceleration = 0;
                this.Braking      = random.Next(10, 70);
                this.Speed        = Math.Abs(previous.Speed - this.Braking / 2);
            }
        }