Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'master' of github.uconn.edu:jar07014/Thermocontroller
  • Loading branch information
pid1 committed May 1, 2015
2 parents f821159 + 9acda74 commit b394ec3
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 16 deletions.
Binary file modified bin/thermostat/ThermostatDevice.class
Binary file not shown.
34 changes: 34 additions & 0 deletions src/InputOutput/CurrentUser.java
@@ -0,0 +1,34 @@
package InputOutput;

/**
* Created by David on 5/1/15.
*/
public class CurrentUser {

private static CurrentUser instance = null;

private String email;

public static CurrentUser getInstance() {
if (instance == null){
try {
instance = new CurrentUser();
} catch (Exception e) {
e.printStackTrace();
}
}
return instance;
}

public CurrentUser(){
}

public String getEmail(){
return this.email;
}

public void setEmail(String email){
this.email = email;
}

}
4 changes: 4 additions & 0 deletions src/InputOutput/Database.java
Expand Up @@ -68,5 +68,9 @@ public class Database extends DataStructure implements Thermostatable, Serializa
// don't use this here
}

public void printDataBase(){
this.printStruct();
}

}

28 changes: 21 additions & 7 deletions src/InputOutput/Thermocontroller.java
Expand Up @@ -10,6 +10,8 @@ import server.server;
import java.util.Timer;
import java.util.TimerTask;

import javax.swing.SwingUtilities;

import testing.UITest;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
Expand All @@ -26,6 +28,8 @@ public class Thermocontroller implements Initializable{
public boolean slide = false;
server _server;
Timer _timer;
String _serial;
CurrentUser _user = CurrentUser.getInstance();

@FXML
private Slider slider;
Expand All @@ -44,6 +48,7 @@ public class Thermocontroller implements Initializable{
@Override
public void initialize(URL arg0, ResourceBundle arg1) {
_server = server.getInstance();
_serial = _server.getDevicesFromEmail(_user.getEmail());
this.slider.valueProperty().addListener(new ChangeListener<Number>() {
@Override
//Slider action, changes text color and message, displays disired temp
Expand All @@ -63,13 +68,22 @@ public class Thermocontroller implements Initializable{
}
});
_timer = new Timer();
_timer.schedule(new TimerTask() {
public void run() {
currentTemp.setText("");
System.out.println("temp changed");
}
}, 90*10, 90*10);
}
_timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run(){
currentTemp.setText(
_server.getCurrentTempFromSerialNumber(_serial));
System.out.println("temp changed " + _server.getCurrentTempFromSerialNumber(_serial));
}

});
}
}, 0, 2000);
}


public boolean getSlide(){
return slide;
Expand Down
2 changes: 2 additions & 0 deletions src/InputOutput/UserLogin.java
Expand Up @@ -29,6 +29,7 @@ public class UserLogin implements Initializable {
private String _password;
private boolean _loggedin = false;
server _server;
CurrentUser _user = CurrentUser.getInstance();
@FXML
private Button loginButton;

Expand Down Expand Up @@ -72,6 +73,7 @@ public class UserLogin implements Initializable {
} else {
if (enteredEmail.equals(queriedEmail) && enteredPassword.equals(queriedPassword)){
_loggedin = true;
_user.setEmail(queriedEmail);
try{//opens new window when login true
Parent root = FXMLLoader.load(getClass().getResource("/interface_xml_files/Thermocontroller.fxml"));
Stage stage = new Stage();
Expand Down
6 changes: 4 additions & 2 deletions src/server/server.java
Expand Up @@ -82,7 +82,7 @@ public class server extends ServerNetworking implements Thermostatable, Serializ
}

public String getDevicesFromEmail(String email) {
return null;
return this.dataStorage.getDevicesFromEmail(email);
}

// Sends the desired temperature on port sendDesiredTempPORT
Expand Down Expand Up @@ -208,6 +208,8 @@ public class server extends ServerNetworking implements Thermostatable, Serializ

public void datastructureLogEvent(String query) {
}

public void printDataBase(){
this.dataStorage.printDataBase();
}

}
21 changes: 14 additions & 7 deletions src/testing/DatabaseTest.java
Expand Up @@ -23,25 +23,32 @@ public class DatabaseTest implements Thermostatable, Serializable{
Hashtable<String, String> testuser = testbase.getUserFromEmail("herp@derp.com");

testbase.createThermostat("testthermo1", "testthemo", "123456789.1", "80", "90");


if(testuser.get("email").equals("herp@derp.com")){
System.out.println("email pass");
}
else{
System.out.println("user email fail");
}


if(testuser.get("ipaddress").equals("123456789.0")){
System.out.println("user ip pass");
}
else{
System.out.println("user ip fail");
}




if(testuser.get("devices").equals("testthermo1")){
System.out.println("devices permissions pass");
}
else{
System.out.println("devices permissions fail");
}



//if(testuser.get()))
}

Expand Down

0 comments on commit b394ec3

Please sign in to comment.