Beispiel #1
0
        public override void Push(EquipmentConnectorCfg equipment, IndicatorConnectorCfg indicator, IndicatorValue[] values)
        {
            progressBar.MaxTicks = values.Length;

            using (var connection = new SqlConnection(Cfg.Connection)) {
                if (connection.State != ConnectionState.Open)
                {
                    connection.Open();
                }

                foreach (var value in values)
                {
                    using (var cmd = new SqlCommand(Cfg.Command, connection)) {
                        foreach (var param in Cfg.Params)
                        {
                            var paramValue = param.GetParamValue(equipment, indicator, value);
                            var sqlParam   = new SqlParameter(param.Name, paramValue);
                            cmd.Parameters.Add(sqlParam);
                        }
                        cmd.ExecuteNonQuery();
                    }

                    progressBar.Tick();
                }
            }
        }
        public override void Push(EquipmentConnectorCfg equipment, IndicatorConnectorCfg indicator, IndicatorValue[] values)
        {
            foreach (var value in values)
            {
                string outString = Cfg.Format;
                foreach (var param in Cfg.Params)
                {
                    var paramValue = param.GetParamValue(equipment, indicator, value);
                    outString = outString.Replace("{" + param.Name + "}", paramValue.ToString());
                }

                Console.WriteLine(outString);
            }
        }
        private static async Task <EquipmentConnectorCfg> CreateEquipmentConnectorCfg(DpaRestClient client, Equipment equipment)
        {
            var cfg = new EquipmentConnectorCfg {
                ID             = equipment.ID,
                Name           = equipment.Name,
                DepartmentName = equipment.DepartmentName
            };

            var indicators = await client.GetIndicators(equipment);

            cfg.Indicators = indicators
                             .Select(ind => new IndicatorConnectorCfg {
                ID          = ind.ID,
                Name        = ind.Name,
                ModuleName  = ind.ModuleName,
                Device      = ind.Device,
                DeviceClass = ind.DeviceClass,
                Connector   = "connectorName"
            })
                             .ToArray();

            return(cfg);
        }
Beispiel #4
0
        public override void Push(EquipmentConnectorCfg equipment, IndicatorConnectorCfg indicator, IndicatorValue[] values)
        {
            var influxDBClient = InfluxDBClientFactory.Create(Cfg.Url, Cfg.Token);

            progressBar.MaxTicks = values.Length;

            using (var writeApi = influxDBClient.GetWriteApi()) {
                foreach (var value in values)
                {
                    var point = PointData.Measurement($"{equipment.Name}\\{indicator.Name}");
                    foreach (var param in Cfg.Params)
                    {
                        var paramValue = param.GetParamValue(equipment, indicator, value);
                        point = point.Tag(param.Name, paramValue.ToString());
                    }
                    point = point.Field("value", value.Value.GetDouble())
                            .Timestamp(value.TimeStamp, WritePrecision.Ms);

                    writeApi.WritePoint(Cfg.Bucket, Cfg.Org, point);

                    progressBar.Tick();
                }
            }
        }
Beispiel #5
0
 public abstract void Push(EquipmentConnectorCfg equipment, IndicatorConnectorCfg indicator, IndicatorValue[] values);
 public object GetParamValue(EquipmentConnectorCfg equipment, IndicatorConnectorCfg indicator, IndicatorValue value)
 {
     return(lambda0.Value.DynamicInvoke(equipment, indicator, value));
 }