Skip to content

Commit

Permalink
Timer added in thermocontroller to set time, change in server to make it
Browse files Browse the repository at this point in the history
singalizable. Server passed to different windows.
  • Loading branch information
aed10006 committed Apr 25, 2015
1 parent b5d7c05 commit 169fc44
Show file tree
Hide file tree
Showing 15 changed files with 86 additions and 19 deletions.
8 changes: 6 additions & 2 deletions bin/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
/InputOutput/
/UML.cld
/Use_Cases.ucd
/interface_xml_files/
/main/
/networking/
/server/
/testing/
/thermostat/
/user_interface/
/InputOutput/
/testing/
Binary file modified bin/InputOutput/InputOutput.class
Binary file not shown.
10 changes: 8 additions & 2 deletions bin/interface_xml_files/Thermocontroller.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="216.0" prefWidth="339.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="InputOutput.Thermocontroller">
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="243.0" prefWidth="353.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="InputOutput.Thermocontroller">
<children>
<Label fx:id="currentTemp" alignment="CENTER" contentDisplay="CENTER" layoutX="9.0" layoutY="23.0" prefHeight="52.0" prefWidth="339.0" text="63 ˚F" AnchorPane.bottomAnchor="141.0" AnchorPane.leftAnchor="9.0" AnchorPane.rightAnchor="-9.0" AnchorPane.topAnchor="23.0">
<font>
Expand All @@ -24,11 +24,17 @@
<Font name="Helvetica Neue" size="13.0" />
</font>
</Label>
<Label fx:id="heating" layoutX="194.0" layoutY="190.0" text="heating" textFill="#e40000">
<Label fx:id="heating" layoutX="201.0" layoutY="214.0" text="heating" textFill="#e40000">
<font>
<Font name="Helvetica Neue" size="13.0" />
</font>
</Label>
<Separator layoutX="21.0" layoutY="107.0" prefHeight="3.0" prefWidth="299.0" />
<TextField layoutX="165.0" layoutY="109.0" />
<Label fx:id="thermostatLabel" layoutX="38.0" layoutY="112.0" text="Thermostat Name:">
<font>
<Font size="14.0" />
</font>
</Label>
</children>
</AnchorPane>
Binary file modified bin/testing/Networking_Test.class
Binary file not shown.
Binary file modified bin/testing/TestforIO.class
Binary file not shown.
Binary file modified bin/testing/ThermostatTest.class
Binary file not shown.
Binary file modified bin/thermostat/Sensorable.class
Binary file not shown.
Binary file modified bin/thermostat/TemperatureSensor.class
Binary file not shown.
Binary file modified bin/thermostat/ThermostatDevice.class
Binary file not shown.
14 changes: 10 additions & 4 deletions src/InputOutput/ServerThermo.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package InputOutput;


import java.io.Serializable;
import java.net.URL;
import java.util.ResourceBundle;

import server.server;
import testing.UITest;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
Expand All @@ -17,8 +19,12 @@
import javafx.scene.control.TextArea;
import javafx.stage.Stage;

public class ServerThermo implements Initializable{
public class ServerThermo extends server implements Initializable,Serializable {

/**
*
*/
private static final long serialVersionUID = 1105146094425728795L;
public boolean user = false;
public boolean server = false;

Expand All @@ -35,12 +41,12 @@ public class ServerThermo implements Initializable{
public void initialize(URL arg0, ResourceBundle arg1) {
this.goToUser.setOnAction(new EventHandler<ActionEvent>() {
@Override
//When button pressed will go to user page ThermoController
//When button pressed will go to user page login
public void handle(ActionEvent e) {
System.out.println("goToUser button pressed");
user = true;
try{ //changes scene from ServerThermo to ThermoController
Parent root1 = FXMLLoader.load(getClass().getResource("/interface_xml_files/Thermocontroller.fxml"));
try{ //changes scene from ServerThermo to login
Parent root1 = FXMLLoader.load(getClass().getResource("/interface_xml_files/login.fxml"));
Stage stage1 = new Stage();
stage1.setScene(new Scene(root1));
stage1.show();
Expand Down
2 changes: 1 addition & 1 deletion src/InputOutput/SetupThermo.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void handle(ActionEvent e) {
System.out.println("userMode button pressed");
statusUserMode = true;
try{//opens page
Parent root2 = FXMLLoader.load(getClass().getResource("/interface_xml_files/Thermocontroller.fxml"));
Parent root2 = FXMLLoader.load(getClass().getResource("/interface_xml_files/login.fxml"));
Stage stage2 = new Stage();
stage2.setScene(new Scene(root2));
stage2.show();
Expand Down
24 changes: 23 additions & 1 deletion src/InputOutput/Thermocontroller.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
package InputOutput;


import java.awt.event.ActionListener;
import java.net.URL;
import java.util.ResourceBundle;

import server.server;

import java.util.Timer;
import java.util.TimerTask;

import testing.UITest;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
Expand All @@ -12,11 +18,15 @@
import javafx.scene.control.Label;
import javafx.scene.control.ProgressIndicator;
import javafx.scene.control.Slider;
import javafx.scene.control.TextField;
import javafx.scene.paint.Color;

public class Thermocontroller implements Initializable{

public boolean slide = false;
public String _enteredSerial;
server _server;
Timer _timer;

@FXML
private Slider slider;
Expand All @@ -30,16 +40,22 @@ public class Thermocontroller implements Initializable{
@FXML
private Label temp;

@FXML
private TextField thermostatName;

@FXML
private Label heating;
@Override
public void initialize(URL arg0, ResourceBundle arg1) {
_server = server.getInstance();
this.slider.valueProperty().addListener(new ChangeListener<Number>() {
@Override
//Slider action, changes text color and message, displays disired temp
public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
System.out.println("Sliding");
slide = true;
_enteredSerial = thermostatName.getText();
_server.setDesiredTempForSerialNumber(_enteredSerial, Double.toString(slider.getValue()));
temp.setText(newValue.intValue() + "");
if (slider.getValue() <= 60.0){
heating.setText("cooling");
Expand All @@ -49,7 +65,13 @@ public void changed(ObservableValue<? extends Number> observable, Number oldValu
heating.setText("heating");
heating.setTextFill(Color.RED);
}

_timer = new Timer();
_timer.schedule(new TimerTask() {
public void run() {
String currentTempFromServer = _server.getCurrentTempFromSerialNumber(_enteredSerial);
currentTemp.setText(currentTempFromServer);
}
}, 90*10000, 90*1000);
}
});
}
Expand Down
26 changes: 20 additions & 6 deletions src/InputOutput/UserLogin.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@


import java.net.URL;
import java.util.Hashtable;
import java.util.ResourceBundle;

import server.server;
import testing.UITest;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
Expand All @@ -19,13 +21,14 @@
import javafx.scene.control.TextField;
import javafx.stage.Stage;

public class UserLogin implements Initializable{
public class UserLogin implements Initializable {

public String enteredEmail;
public String enteredPassword;
private String _email = "cse2102@gmail.com";
private String _password = "password";
private String _email;
private String _password;
private boolean _loggedin = false;
server _server;
@FXML
private Button loginButton;

Expand All @@ -35,17 +38,24 @@ public class UserLogin implements Initializable{
@FXML
private PasswordField password;

//@FXML
//private Button newUserButton;

@Override
public void initialize(URL arg0, ResourceBundle arg1) {
_server = server.getInstance();
this.loginButton.setOnAction(new EventHandler<ActionEvent>() {
@Override
//checks user name and pass word when login button pressed. If not true nothing happens.
public void handle(ActionEvent e) {
enteredEmail = email.getText();

enteredPassword = password.getText();
enteredPassword = password.getText();
/*_login = _owner.getUserFromEmail(enteredEmail);
_password = _login.get(enteredEmail);
enteredPassword = password.getText();
boolean goodKey = _login.containsKey(enteredEmail);*/

if (getEnteredEmail().equals(_email) && getEnteredPassword().equals(_password)){
if (_server.getUserFromEmail(enteredEmail).get("email").equals(enteredEmail) && _server.getUserFromEmail(enteredEmail).get("password").equals(enteredPassword)){
_loggedin = true;
try{//opens new window when login true
Parent root = FXMLLoader.load(getClass().getResource("/interface_xml_files/SetupThermo.fxml"));
Expand All @@ -64,12 +74,15 @@ public void handle(ActionEvent e) {

}
});

}



public void login(ActionEvent event){}

//public void newUser(ActionEvent event){}

public String getEnteredEmail(){
return enteredEmail;
}
Expand All @@ -89,4 +102,5 @@ public String getPassword(){
public boolean getStatus(){
return _loggedin;
}

}
10 changes: 8 additions & 2 deletions src/interface_xml_files/Thermocontroller.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="216.0" prefWidth="339.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="InputOutput.Thermocontroller">
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="243.0" prefWidth="353.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="InputOutput.Thermocontroller">
<children>
<Label fx:id="currentTemp" alignment="CENTER" contentDisplay="CENTER" layoutX="9.0" layoutY="23.0" prefHeight="52.0" prefWidth="339.0" text="63 ˚F" AnchorPane.bottomAnchor="141.0" AnchorPane.leftAnchor="9.0" AnchorPane.rightAnchor="-9.0" AnchorPane.topAnchor="23.0">
<font>
Expand All @@ -24,11 +24,17 @@
<Font name="Helvetica Neue" size="13.0" />
</font>
</Label>
<Label fx:id="heating" layoutX="194.0" layoutY="190.0" text="heating" textFill="#e40000">
<Label fx:id="heating" layoutX="201.0" layoutY="214.0" text="heating" textFill="#e40000">
<font>
<Font name="Helvetica Neue" size="13.0" />
</font>
</Label>
<Separator layoutX="21.0" layoutY="107.0" prefHeight="3.0" prefWidth="299.0" />
<TextField layoutX="165.0" layoutY="109.0" />
<Label fx:id="thermostatLabel" layoutX="38.0" layoutY="112.0" text="Thermostat Name:">
<font>
<Font size="14.0" />
</font>
</Label>
</children>
</AnchorPane>
11 changes: 10 additions & 1 deletion src/server/server.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
package server;
import java.io.Serializable;
import java.util.Hashtable;

import InputOutput.*;
import networking.*;

public class server extends ServerNetworking implements Thermostatable {
public class server extends ServerNetworking implements Thermostatable, Serializable {
private static server instance = null;

public static server getInstance(){
if (instance == null){
instance = new server();
}
return instance;
}

// Desired temperature
int desiredTemperature;
Expand Down

0 comments on commit 169fc44

Please sign in to comment.