Esempio n. 1
0
        // This method will receive a list of sensors, then it will loop through this list and it will
        // search for the latest sensor reading of both pH and Temperatures sensors of a specific tank.
        // A Dictionary will be returned with the tank location as Key and the following as Value:
        // Depending on the first type the values will be in the following format:
        // If Temperature is first: temp°#pH#
        // If pH is first: pH#temp#
        public Dictionary <string, string> currentReadingPerSensor(List <Sensor> sensors)
        {
            Dictionary <string, string> sensorData = new Dictionary <string, string>();

            DataAccessLayer.DataHandler dataHandler = DataAccessLayer.DataHandler.getInstance();
            Sensor        s        = new Sensor();
            List <string> allTanks = s.getAllTanks();
            string        reading  = "";

            foreach (string tank in allTanks)
            {
                foreach (Sensor sen in sensors)
                {
                    if (sen.Location == tank)
                    {
                        if (sen.Type == "Temperature")
                        {
                            reading += Convert.ToString(dataHandler.getCurrentSensorReading(sen)) + "°#";
                        }
                        else if (sen.Type == "pH")
                        {
                            reading += Convert.ToString(dataHandler.getCurrentSensorReading(sen)) + "#";
                        }
                    }
                }

                sensorData.Add(tank, reading);
                reading = "";
            }

            return(sensorData);
        }
Esempio n. 2
0
        // Get the time interval in minutes
        public int getFrequency()
        {
            int frequency = 1;

            DataAccessLayer.DataHandler dataHandler = DataAccessLayer.DataHandler.getInstance();
            frequency = dataHandler.getCurrentFrequency();
            return(frequency);
        }
Esempio n. 3
0
        // Get the names of all the Tanks in the system
        public List <string> getAllTanks()
        {
            List <string> allTanks = new List <string>();

            DataAccessLayer.DataHandler dataHandler = DataAccessLayer.DataHandler.getInstance();
            allTanks = dataHandler.getAllLocations();

            return(allTanks);
        }
        public List <Notifications> getAllCriticalRanges()
        {
            List <Notifications> allRanges = new List <Notifications>();

            DataAccessLayer.DataHandler dataHandler = DataAccessLayer.DataHandler.getInstance();
            allRanges = dataHandler.getAllNotifications();

            return(allRanges);
        }
Esempio n. 5
0
        // Get readings for a 24 hour period
        public List <SensorReading> getDayReadings(Sensor sensor)
        {
            List <SensorReading> readings = new List <SensorReading>();

            DataAccessLayer.DataHandler dataHandler = DataAccessLayer.DataHandler.getInstance();
            readings = dataHandler.getSensorReadingsForDayPeriod(sensor);

            return(readings);
        }
Esempio n. 6
0
        public List <Contact> getAllContacts()
        {
            List <Contact> allContacts = new List <Contact>();

            DataAccessLayer.DataHandler dataHandler = DataAccessLayer.DataHandler.getInstance();
            allContacts = dataHandler.getAllContacts();

            return(allContacts);
        }
Esempio n. 7
0
        public List <User> getAllRegisteredUsers()
        {
            List <User> users = new List <User>();

            DataAccessLayer.DataHandler dataHandler = DataAccessLayer.DataHandler.getInstance();
            users = dataHandler.getAllUsers();

            return(users);
        }
Esempio n. 8
0
        public List <Sensor> getAllSensors()
        {
            List <Sensor> allSensors = new List <Sensor>();

            DataAccessLayer.DataHandler dataHandler = DataAccessLayer.DataHandler.getInstance();

            allSensors = dataHandler.getAllSensors();

            return(allSensors);
        }
Esempio n. 9
0
        public void newSensorReading(Sensor sensor)
        {
            string               filename          = sensor.Location + "_" + sensor.SensorName + ".txt";
            List <string>        allSensorValues   = new List <string>();
            List <SensorReading> allSensorReadings = new List <SensorReading>();
            List <string>        allSavedDates     = new List <string>();
            DateTime             dateOfReading     = new DateTime();
            decimal              reading           = 0;

            DataAccessLayer.FileHandler fh = new DataAccessLayer.FileHandler(filename);
            allSensorValues = fh.ReadFromTxt();

            DataAccessLayer.DataHandler dh = DataAccessLayer.DataHandler.getInstance();
            allSensorReadings = dh.getSensorReadings(sensor);

            foreach (SensorReading item in allSensorReadings)
            {
                allSavedDates.Add(item.Date.ToString());
            }

            foreach (string item in allSensorValues)
            {
                // Example of data format in the text file:
                // DateTime#SensorReading
                string[] fields = item.Split('#');
                dateOfReading = Convert.ToDateTime(fields[0]);
                reading       = Convert.ToDecimal(fields[1]);
                if (!allSavedDates.Contains(dateOfReading.ToString()))
                {
                    this.Date       = dateOfReading;
                    this.ReadingVal = reading;
                    this.SensorId   = sensor.SensorID;
                    addReading();
                }
            }
        }
 public void insertNotification()
 {
     DataAccessLayer.DataHandler dh = DataAccessLayer.DataHandler.getInstance();
     dh.newNotification(this);
 }
Esempio n. 11
0
 public void deleteUsers()
 {
     DataAccessLayer.DataHandler dh = DataAccessLayer.DataHandler.getInstance();
     dh.removeUser(this);
 }
Esempio n. 12
0
 public void updateUsers()
 {
     DataAccessLayer.DataHandler dh = DataAccessLayer.DataHandler.getInstance();
     dh.updateUser(this);
 }
Esempio n. 13
0
 public void newUser()
 {
     DataAccessLayer.DataHandler dh = DataAccessLayer.DataHandler.getInstance();
     dh.insertUser(this);
 }
Esempio n. 14
0
 public void insertNotification()
 {
     DataAccessLayer.DataHandler dh = new DataAccessLayer.DataHandler();
     dh.newNotification(this);
 }
Esempio n. 15
0
 public void deleteContact()
 {
     DataAccessLayer.DataHandler dh = DataAccessLayer.DataHandler.getInstance();
     dh.removeContact(this);
 }
Esempio n. 16
0
 public void updateContact(string prevEmail)
 {
     DataAccessLayer.DataHandler dh = DataAccessLayer.DataHandler.getInstance();
     dh.updateContact(this, prevEmail);
 }
Esempio n. 17
0
 public void insertContact()
 {
     DataAccessLayer.DataHandler dh = DataAccessLayer.DataHandler.getInstance();
     dh.newContact(this);
 }
Esempio n. 18
0
 public void newFrequency()
 {
     DataAccessLayer.DataHandler dh = new DataAccessLayer.DataHandler();
     dh.insertFrequency(this);
 }
Esempio n. 19
0
 public void newFrequency()
 {
     DataAccessLayer.DataHandler dh = DataAccessLayer.DataHandler.getInstance();
     dh.insertFrequency(this);
 }
Esempio n. 20
0
 public void newSensor()
 {
     DataAccessLayer.DataHandler dh = new DataAccessLayer.DataHandler();
     dh.insertSensor(this);
 }
Esempio n. 21
0
 public void deleteContact()
 {
     DataAccessLayer.DataHandler dh = new DataAccessLayer.DataHandler();
     dh.removeContact(this);
 }
Esempio n. 22
0
 public void updateContact(string prevEmail)
 {
     DataAccessLayer.DataHandler dh = new DataAccessLayer.DataHandler();
     dh.updateContact(this, prevEmail);
 }
Esempio n. 23
0
 public void insertContact()
 {
     DataAccessLayer.DataHandler dh = new DataAccessLayer.DataHandler();
     dh.newContact(this);
 }
Esempio n. 24
0
 public void addReading()
 {
     DataAccessLayer.DataHandler dh = DataAccessLayer.DataHandler.getInstance();
     dh.insertSensorReading(this);
 }
 public void updateNotifications()
 {
     DataAccessLayer.DataHandler dh = DataAccessLayer.DataHandler.getInstance();
     dh.updateNotification(this);
 }
Esempio n. 26
0
 public void updateNotifications()
 {
     DataAccessLayer.DataHandler dh = new DataAccessLayer.DataHandler();
     dh.updateNotification(this);
 }
Esempio n. 27
0
 public void deleteSensor()
 {
     DataAccessLayer.DataHandler dh = new DataAccessLayer.DataHandler();
     dh.removeSensor(this);
 }
Esempio n. 28
0
 public void updateUsers()
 {
     DataAccessLayer.DataHandler dh = new DataAccessLayer.DataHandler();
     dh.updateUser(this);
 }