Ejemplo n.º 1
0
            public void Dispose()
            {
                if (_service == null)
                {
                    return;
                }

                var elapsed = _stopwatch.ElapsedMilliseconds;

                _service.Send(_key, elapsed);
                _service = null;
            }
Ejemplo n.º 2
0
        public void Send(DeviceReadings deviceReadings)
        {
            var config = new Config();

            var hgClient = new HostedGraphiteService();
            hgClient.ActivateForUse(config.GraphiteApiKey);
            hgClient.Send("humidity", Convert.ToSingle(deviceReadings.CurrentHumidity));
            hgClient.Send("temperature", Convert.ToSingle(deviceReadings.CurrentTemp));
            hgClient.Send("target_temperature", Convert.ToSingle(deviceReadings.TargetTemp));
            hgClient.Send("heating_on", deviceReadings.HeatState ? 1 : 0);
            hgClient.Send("auto_away", deviceReadings.AutoAway);

            if (config.SendRandom)
            {
                Random rnd = new Random();
                hgClient.Send("random", rnd.Next(1, 100));
            }

            Console.WriteLine("Tracked on Graphite");
        }
            public void Dispose()
            {
                if (_service == null)
                    return;

                var elapsed = _stopwatch.ElapsedMilliseconds;
                _service.Send(_key, elapsed);
                _service = null;
            }
 public MetricTimer(string key, HostedGraphiteService service)
 {
     _key = key;
     _service = service;
     _stopwatch = Stopwatch.StartNew();
 }
Ejemplo n.º 5
0
 public MetricTimer(string key, HostedGraphiteService service)
 {
     _key       = key;
     _service   = service;
     _stopwatch = Stopwatch.StartNew();
 }