Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .idea/copyright/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

84 changes: 84 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/modules/HVAC.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions .idea/modules/HVAC_main.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions .idea/modules/HVAC_test.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
language: java
160 changes: 160 additions & 0 deletions src/main/java/EnvironmentController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
/**
* Created by rosanna_corvino on 6/14/16.
*/
public class EnvironmentController implements EnvironmentInterface{
private HVAC hvac;
private Integer minTemp;
private Integer maxTemp;

public boolean heatStatus;
public boolean coolStatus;
public boolean fanStatus;
public int heatOnCount;
public int heatOffCount;
public int coolOnCount;
public int coolOffCount;

public EnvironmentController(HVAC hvac, Integer minTemp, Integer maxTemp){
this.hvac = hvac;
this.minTemp = minTemp;
this.maxTemp = maxTemp;

heatStatus = false;
coolStatus = false;
fanStatus = false;
heatOnCount = 0;
heatOffCount = 0;
coolOnCount = 0;
coolOffCount = 0;
}

public void tick(){
if (hvac.temp() < minTemp){
turnOnHeat();
}

if (hvac.temp() > maxTemp){
turnOnCool();
}
}

private void turnOnHeat(){
hvac.heat(true);
hvac.fan(true);
turnOffCool();

heatOnCheckHeatStatusAdjustCount();

heatStatus = true;
}

private void turnOnCool(){
hvac.cool(true);
hvac.fan(true);
turnOffHeat();

coolOnCheckCoolStatusAdjustCount();

coolStatus = true;
}

private void turnOffHeat(){
hvac.heat(false);

heatOffCheckHeatStatusAdjustCount();

heatStatus = false;

if (heatOffCount <= 5){
turnFanOff();
}
else{
turnFanOn();
}
}

private void turnOffCool(){
hvac.cool(false);

coolOffCheckStatusAdjustCount();

coolStatus = false;

if (coolOffCount <= 3){
turnFanOff();
}
else{
turnFanOn();
}
}

private void turnFanOn(){
hvac.fan(true);
fanStatus = true;
}

private void turnFanOff(){
hvac.fan(false);
fanStatus = false;
}

private void heatOnCheckHeatStatusAdjustCount(){
if (heatStatus == false){
heatOnCount = 1;
heatOffCount = 0;
}
else{
heatOnCount = heatOnCount + 1;
}
}

private void coolOnCheckCoolStatusAdjustCount(){
if (coolStatus == false){
coolOnCount = 1;
coolOffCount = 0;
turnFanOff();
}
else{
coolOnCount = coolOnCount + 1;
}
}

private void heatOffCheckHeatStatusAdjustCount(){
if (heatStatus == true){
heatOnCount = 0;
heatOffCount = 1;
turnFanOff();
}
else{
heatOffCount = heatOffCount + 1;
}
}

private void coolOffCheckStatusAdjustCount(){
if (coolStatus == true){
coolOnCount = 0;
coolOffCount = 1;
}
else{
coolOffCount = coolOffCount + 1;
}
}

public Integer getMinTemp() {
return minTemp;
}

public Integer getMaxTemp() {
return maxTemp;
}

@Override
public void setMinTemp(int minTemp) {
this.minTemp = minTemp;
}

@Override
public void setMaxTemp(int maxTemp) {
this.maxTemp = maxTemp;
}
}
12 changes: 12 additions & 0 deletions src/main/java/EnvironmentInterface.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* Created by rosanna_corvino on 6/15/16.
*/
public interface EnvironmentInterface {
void setMinTemp(int minTemp);

void setMaxTemp(int maxTemp);

Integer getMinTemp();

Integer getMaxTemp();
}
Loading