// 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); }
// Get the time interval in minutes public int getFrequency() { int frequency = 1; DataAccessLayer.DataHandler dataHandler = DataAccessLayer.DataHandler.getInstance(); frequency = dataHandler.getCurrentFrequency(); return(frequency); }
// 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); }
// 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); }
public List <Contact> getAllContacts() { List <Contact> allContacts = new List <Contact>(); DataAccessLayer.DataHandler dataHandler = DataAccessLayer.DataHandler.getInstance(); allContacts = dataHandler.getAllContacts(); return(allContacts); }
public List <User> getAllRegisteredUsers() { List <User> users = new List <User>(); DataAccessLayer.DataHandler dataHandler = DataAccessLayer.DataHandler.getInstance(); users = dataHandler.getAllUsers(); return(users); }
public List <Sensor> getAllSensors() { List <Sensor> allSensors = new List <Sensor>(); DataAccessLayer.DataHandler dataHandler = DataAccessLayer.DataHandler.getInstance(); allSensors = dataHandler.getAllSensors(); return(allSensors); }
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); }
public void deleteUsers() { DataAccessLayer.DataHandler dh = DataAccessLayer.DataHandler.getInstance(); dh.removeUser(this); }
public void updateUsers() { DataAccessLayer.DataHandler dh = DataAccessLayer.DataHandler.getInstance(); dh.updateUser(this); }
public void newUser() { DataAccessLayer.DataHandler dh = DataAccessLayer.DataHandler.getInstance(); dh.insertUser(this); }
public void insertNotification() { DataAccessLayer.DataHandler dh = new DataAccessLayer.DataHandler(); dh.newNotification(this); }
public void deleteContact() { DataAccessLayer.DataHandler dh = DataAccessLayer.DataHandler.getInstance(); dh.removeContact(this); }
public void updateContact(string prevEmail) { DataAccessLayer.DataHandler dh = DataAccessLayer.DataHandler.getInstance(); dh.updateContact(this, prevEmail); }
public void insertContact() { DataAccessLayer.DataHandler dh = DataAccessLayer.DataHandler.getInstance(); dh.newContact(this); }
public void newFrequency() { DataAccessLayer.DataHandler dh = new DataAccessLayer.DataHandler(); dh.insertFrequency(this); }
public void newFrequency() { DataAccessLayer.DataHandler dh = DataAccessLayer.DataHandler.getInstance(); dh.insertFrequency(this); }
public void newSensor() { DataAccessLayer.DataHandler dh = new DataAccessLayer.DataHandler(); dh.insertSensor(this); }
public void deleteContact() { DataAccessLayer.DataHandler dh = new DataAccessLayer.DataHandler(); dh.removeContact(this); }
public void updateContact(string prevEmail) { DataAccessLayer.DataHandler dh = new DataAccessLayer.DataHandler(); dh.updateContact(this, prevEmail); }
public void insertContact() { DataAccessLayer.DataHandler dh = new DataAccessLayer.DataHandler(); dh.newContact(this); }
public void addReading() { DataAccessLayer.DataHandler dh = DataAccessLayer.DataHandler.getInstance(); dh.insertSensorReading(this); }
public void updateNotifications() { DataAccessLayer.DataHandler dh = DataAccessLayer.DataHandler.getInstance(); dh.updateNotification(this); }
public void updateNotifications() { DataAccessLayer.DataHandler dh = new DataAccessLayer.DataHandler(); dh.updateNotification(this); }
public void deleteSensor() { DataAccessLayer.DataHandler dh = new DataAccessLayer.DataHandler(); dh.removeSensor(this); }
public void updateUsers() { DataAccessLayer.DataHandler dh = new DataAccessLayer.DataHandler(); dh.updateUser(this); }