/// <summary> /// Crea un nuevo histograma /// </summary> private HistogramModel CreateNewHistogram(double value) { HistogramModel histogram = new HistogramModel(); // Añade el valor al histograma histogram.Add(value); // Devuelve el histograma creado return(histogram); }
public List <HistogramModel> Histogram(string code, DateTime from, DateTime to, string exit) { var result = new List <HistogramModel>(); using (var connection = new NpgsqlConnection(_connectionString)) { NpgsqlCommand command; // old table: a1_balance_prc_nominal_bcg_04_prueba1 if (exit == "max") { command = new NpgsqlCommand( @"select fecha, fase, prc_nominal, num_horas from b1_balance_prc_nominal_bcg_04_prueba1 where matricula = @Code and fecha >= @From and fecha <= @To and fase <> 'TODAS FASES' and tpo_salida_max = 1", connection); command.Parameters.Add("Code", NpgsqlDbType.Varchar).Value = code; command.Parameters.Add("From", NpgsqlDbType.Timestamp).Value = from; command.Parameters.Add("To", NpgsqlDbType.Timestamp).Value = to; } else { command = new NpgsqlCommand( @"select fecha, fase, prc_nominal, num_horas from b1_balance_prc_nominal_bcg_04_prueba1 where matricula = @Code and fecha >= @From and fecha <= @To and fase <> 'TODAS FASES' and salida = @Exit", connection); command.Parameters.Add("Code", NpgsqlDbType.Varchar).Value = code; command.Parameters.Add("From", NpgsqlDbType.Timestamp).Value = from; command.Parameters.Add("To", NpgsqlDbType.Timestamp).Value = to; command.Parameters.Add("Exit", NpgsqlDbType.Varchar).Value = exit.ToUpperInvariant(); } connection.Open(); var reader = command.ExecuteReader(); while (reader.Read()) { if (reader.IsDBNull(1) || reader.IsDBNull(2) || reader.IsDBNull(3)) { continue; } var model = new HistogramModel { Date = (DateTime)reader["fecha"], Fase = (string)reader["fase"], Threshold = Math.Round((double)reader["prc_nominal"]), Count = (long)reader["num_horas"] }; result.Add(model); } reader.Close(); } return(result); }
/// <summary> /// Obtiene las marcas de los últimos n minutos /// </summary> private HistogramModel GetMarksLast(int minutes) { HistogramModel histogram = new HistogramModel(); // Obtiene el histograma con los elementos del intervalo foreach (HistogramModel item in Meters.GetMarksLast(minutes)) { histogram.Values.AddRange(item.Values); } // Devuelve el histograma return(histogram); }
public void GetNumbers() { Console.WriteLine("How many numbers?"); int n = int.Parse(Console.ReadLine()); List<int> numbers = new List<int>(); Console.WriteLine("Input numbers"); for (int i = 0; i < n; i++) { int number = int.Parse(Console.ReadLine()); numbers.Add(number); } this.NumbersModel = new HistogramModel(numbers); }
public HistogramPresenter(DataSetManagerPresenter dataSetPresenter) { this.dataSetPresenter = dataSetPresenter; this.model = new HistogramModel(); }