Exemplo n.º 1
0
        private void Send_InfluxDB_EDMS()
        {
            InfluxDB.LineProtocol.Client.LineProtocolClient client =
                new InfluxDB.LineProtocol.Client.LineProtocolClient(new Uri("http://127.0.0.1:8086"), "gravureprint");
            InfluxDB.LineProtocol.Payload.LineProtocolPayload payload =
                new InfluxDB.LineProtocol.Payload.LineProtocolPayload();

            if (distance > 100)
            {
                distance = 0;
            }
            _field.Clear();
            _tags.Clear();
            _tags["model"] = "model123";
            _tags["lot"]   = "lot123";

            var    val  = distance > 10 ? distance % 10 : distance;
            double dval = (double)val / 10.0;

            _field["distance"]  = dval;
            _field["variation"] = dval;
            var data = new InfluxDB.LineProtocol.Payload.LineProtocolPoint("edms", Fields, Tags);

            payload.Add(data);
            client.WriteAsync(payload);
        }
Exemplo n.º 2
0
        private void Send_InfluxDB_RVMS()
        {
            InfluxDB.LineProtocol.Client.LineProtocolClient client =
                new InfluxDB.LineProtocol.Client.LineProtocolClient(new Uri("http://127.0.0.1:8086"), "gravureprint");
            InfluxDB.LineProtocol.Payload.LineProtocolPayload payload =
                new InfluxDB.LineProtocol.Payload.LineProtocolPayload();

            if (distance > 100)
            {
                distance = 0;
            }
            _field.Clear();
            _tags.Clear();
            _tags["model"] = "model123";
            _tags["lot"]   = "lot123";


            var    val  = distance > 10 ? distance % 10 : distance;
            double dval = (double)val / 10.0;


            _field["distance"] = dval;
            _field["left"]     = dval;
            _field["right"]    = dval;

            var data = new InfluxDB.LineProtocol.Payload.LineProtocolPoint("rvms", Fields, Tags);

            payload.Add(data);
            Task <LineProtocolWriteResult> influxResult = client.WriteAsync(payload);

            if (!influxResult.Result.Success)
            {
                Debug.Print("▶--RVMS--" + influxResult.Result.ErrorMessage + "...\n");
            }
        }
 public InfluxDBEmitter(LineProtocolClient client)
 {
     if (client == null) throw new ArgumentNullException("client");
     _client = client;
 }
Exemplo n.º 4
0
        private void Send_InfluxDB_Test()
        {
            Task <LineProtocolWriteResult> influxResult = null;

            try
            {
                InfluxDB.LineProtocol.Client.LineProtocolClient client =
                    new InfluxDB.LineProtocol.Client.LineProtocolClient(new Uri("http://127.0.0.1:8086"), "unieye");
                InfluxDB.LineProtocol.Payload.LineProtocolPayload payload =
                    new InfluxDB.LineProtocol.Payload.LineProtocolPayload();

                if (client == null)
                {
                    Debug.Print("@@@@@@@@@@@@@@@@@@@@@\n");
                }

                if (distance > 100)
                {
                    distance = 0;
                }
                _field.Clear();
                _tags.Clear();
                _tags["model"] = "model123";
                _tags["lot"]   = "lot123";


                //var val = distance > 10 ? distance % 10 : distance;
                double val  = distance++;
                double dval = (double)val / 10.0;


                _field["distance"] = dval;
                _field["left"]     = dval;
                _field["right"]    = dval;

                var data = new InfluxDB.LineProtocol.Payload.LineProtocolPoint("rvms", Fields, Tags);
                payload.Add(data);

                //influxResult=client.WriteAsync(payload);

                //influxResult.Wait();
                //if (!influxResult.Result.Success)
                //    Console.Error.WriteLine(influxResult.Result.ErrorMessage);
            }
            catch (Exception e)
            {
                string    err = "";
                Exception er  = e;
                while (er.InnerException != null)
                {
                    err += er.Message + "\n";
                    er   = er.InnerException;
                }
                Debug.Print(err);
            }
            return;
            //influxResult.Wait();
            //await Task.WhenAll(influxResult);
            //var re = await influxResult;
            //if (!influxResult.Result.Success)
            //{
            //    //Debug.Print("▶-----------" + influxResult.ErrorMessage + "...\n");
            //}

            //var client = new LineProtocolClient(new Uri("http://my-server:8086"), "data");
            //var influxResult = await client.WriteAsync(payload);
            //if (!influxResult.Success)
            //    Console.Error.WriteLine(influxResult.ErrorMessage);
        }
 public HttpLineProtocolEmitter(LineProtocolClient client)
 {
     if (client == null) throw new ArgumentNullException(nameof(client));
     _client = client;
 }
 public override CollectorConfiguration InfluxDB(Uri serverBaseAddress, string database, string username = null, string password = null)
 {
     _client = new LineProtocolClient(serverBaseAddress, database, username, password);
     return _configuration;
 }