예제 #1
0
        public void SetAvailable(bool available)
        {
            if (IsOn)
            {
                TurnOff();
            }

            if (!available)
            {
                TemperatureReadings.Clear();
                PowerReadings.Clear();
                ReadingsUpdated?.Invoke(this, EventArgs.Empty);
            }

            IsAvailable = available;

            PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(IsAvailable)));
            PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(IsOn)));
            PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(TurnOnEnabled)));
            PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(TurnOffEnabled)));
            PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(Status)));
            PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(CoolerTabInfoVisibility)));
            PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(CoolerTabNotOnVisibility)));
            PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(IsOffVisibility)));
            PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(IsOnVisibility)));
        }
        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();
            }
        }