private void getSelectedNodeTempData()
        {
            TemperatureReadings.Clear();

            foreach (string sensor in tempSensors)
            {
                //Database Stuff
                NpgsqlConnection conn = new NpgsqlConnection("Server=flick.cs.niu.edu;Port=5432;User Id=readonly;Database=aot;CommandTimeout=240");
                conn.Open();
                NpgsqlCommand command = new NpgsqlCommand("SELECT value_hrf FROM data WHERE aot_node_id = '" +
                                                          SelectedNodeId +
                                                          "' AND sensor = '" +
                                                          sensor +
                                                          "' and parameter = 'temperature' AND timestamp >= '" +
                                                          StartTime +
                                                          "' AND timestamp < '" +
                                                          EndTime + "' LIMIT 1;", conn);

                try
                {
                    NpgsqlDataReader reader = command.ExecuteReader();
                    while (reader.Read())
                    {
                        TemperatureReadings.Add(sensor, reader.GetString(0));
                    }
                }
                catch (System.Exception ex)
                {
                    print(ex);
                }

                conn.Close();
            }
        }
Example #2
0
        public void AddReading(DateTime readingTime, double?temperature, double?power)
        {
            LastReadingTime = readingTime;

            TemperatureReadings.Add(new DataPoint(DateTimeAxis.ToDouble(readingTime), temperature ?? double.NaN));
            PowerReadings.Add(new DataPoint(DateTimeAxis.ToDouble(readingTime), power ?? double.NaN));

            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(LastPowerReading)));
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(LastTemperatureReading)));
            ReadingsUpdated?.Invoke(this, EventArgs.Empty);
        }