예제 #1
0
        public static EmeterEntity ToEmeterEntity(Emeter emeter)
        {
            EmeterEntity emeterEntity = new EmeterEntity
            {
                Current   = emeter.Current,
                Voltage   = emeter.Voltage,
                Power     = emeter.Power,
                CreatedAt = DateTime.Now
            };

            return(emeterEntity);
        }
예제 #2
0
        private static void OnTimedEvent(Object source, ElapsedEventArgs e)
        {
            try
            {
                dynamic stats = Utils.Send(plugAddress, Commands.Emeter());

                Emeter emeter = JsonConvert.DeserializeObject <Emeter>(JsonConvert.SerializeObject(stats["emeter"]["get_realtime"]));
                emeterEntityRepository.Insert(EmeterConvertor.ToEmeterEntity(emeter));

                Console.WriteLine("The Elapsed event was raised at {0:HH:mm:ss.fff}",
                                  e.SignalTime);
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.ToString());
            }
        }