Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added two more test cases and model goon UML
  • Loading branch information
dep11007 committed Feb 13, 2015
1 parent 296a4ca commit ad52904
Show file tree
Hide file tree
Showing 18 changed files with 163 additions and 10 deletions.
113 changes: 113 additions & 0 deletions ModelGoon_UML.mgc
@@ -0,0 +1,113 @@
<?xml version="1.0" encoding="UTF-8"?>
<ClassDiagram>
<Class name="thermostat.ThermostatDevice" x="623" y="369">
<AttributesDisplayFilter public-accepted="true"
private-accepted="true" protected-accepted="true"
default-accepted="true" static-accepted="false"/>
<MethodDisplayFilter public-accepted="true"
private-accepted="false" protected-accepted="false"
default-accepted="false" static-accepted="false"
accessors-accepted="false" constructors-accepted="false"/>
<Extension destinationClassName="thermostat.Deviceable"/>
<Association destinationClassName="thermostat.Sensorable"
endpointName="sensorList" kind="Simple"/>
<Association destinationClassName="thermostat.Actuatorable"
endpointName="actuatorList" kind="Simple"/>
</Class>
<Class name="thermostat.Deviceable" x="552" y="140">
<AttributesDisplayFilter public-accepted="true"
private-accepted="true" protected-accepted="true"
default-accepted="true" static-accepted="false"/>
<MethodDisplayFilter public-accepted="true"
private-accepted="false" protected-accepted="false"
default-accepted="false" static-accepted="false"
accessors-accepted="false" constructors-accepted="false"/>
</Class>
<Class name="thermostat.Sensorable" x="791" y="251">
<AttributesDisplayFilter public-accepted="true"
private-accepted="true" protected-accepted="true"
default-accepted="true" static-accepted="false"/>
<MethodDisplayFilter public-accepted="true"
private-accepted="false" protected-accepted="false"
default-accepted="false" static-accepted="false"
accessors-accepted="false" constructors-accepted="false"/>
</Class>
<Class name="networking.networking" x="55" y="75">
<AttributesDisplayFilter public-accepted="true"
private-accepted="true" protected-accepted="true"
default-accepted="true" static-accepted="false"/>
<MethodDisplayFilter public-accepted="true"
private-accepted="false" protected-accepted="false"
default-accepted="false" static-accepted="false"
accessors-accepted="false" constructors-accepted="false"/>
</Class>
<Class name="testing.Networking_Test" x="76" y="335">
<AttributesDisplayFilter public-accepted="true"
private-accepted="true" protected-accepted="true"
default-accepted="true" static-accepted="false"/>
<MethodDisplayFilter public-accepted="true"
private-accepted="false" protected-accepted="false"
default-accepted="false" static-accepted="false"
accessors-accepted="false" constructors-accepted="false"/>
<Extension destinationClassName="networking.networking"/>
</Class>
<Class name="testing.ThermostatTest" x="291" y="67">
<AttributesDisplayFilter public-accepted="true"
private-accepted="true" protected-accepted="true"
default-accepted="true" static-accepted="false"/>
<MethodDisplayFilter public-accepted="true"
private-accepted="false" protected-accepted="false"
default-accepted="false" static-accepted="false"
accessors-accepted="false" constructors-accepted="false"/>
<Association destinationClassName="thermostat.ThermostatDevice"
endpointName="testThermo" kind="Simple"/>
<Association
destinationClassName="thermostat.TemperatureActuator"
endpointName="testActuator" kind="Simple"/>
<Association destinationClassName="thermostat.TemperatureSensor"
endpointName="testSensor" kind="Simple"/>
<Communication destinationClassName="thermostat.TemperatureSensor"/>
<Communication destinationClassName="thermostat.TemperatureActuator"/>
</Class>
<Class name="thermostat.TemperatureSensor" x="640" y="24">
<AttributesDisplayFilter public-accepted="true"
private-accepted="true" protected-accepted="true"
default-accepted="true" static-accepted="false"/>
<MethodDisplayFilter public-accepted="true"
private-accepted="false" protected-accepted="false"
default-accepted="false" static-accepted="false"
accessors-accepted="false" constructors-accepted="false"/>
<Extension destinationClassName="thermostat.Sensorable"/>
<Association destinationClassName="thermostat.Deviceable"
endpointName="owner" kind="Simple"/>
<Communication destinationClassName="thermostat.Deviceable"/>
</Class>
<Class name="thermostat.DataObject" x="534" y="9">
<AttributesDisplayFilter public-accepted="true"
private-accepted="true" protected-accepted="true"
default-accepted="true" static-accepted="false"/>
<MethodDisplayFilter public-accepted="true"
private-accepted="false" protected-accepted="false"
default-accepted="false" static-accepted="false"
accessors-accepted="false" constructors-accepted="false"/>
</Class>
<Class name="thermostat.TemperatureActuator" x="343" y="424">
<AttributesDisplayFilter public-accepted="true"
private-accepted="true" protected-accepted="true"
default-accepted="true" static-accepted="false"/>
<MethodDisplayFilter public-accepted="true"
private-accepted="false" protected-accepted="false"
default-accepted="false" static-accepted="false"
accessors-accepted="false" constructors-accepted="false"/>
<Extension destinationClassName="thermostat.Actuatorable"/>
</Class>
<Class name="thermostat.Actuatorable" x="439" y="263">
<AttributesDisplayFilter public-accepted="true"
private-accepted="true" protected-accepted="true"
default-accepted="true" static-accepted="false"/>
<MethodDisplayFilter public-accepted="true"
private-accepted="false" protected-accepted="false"
default-accepted="false" static-accepted="false"
accessors-accepted="false" constructors-accepted="false"/>
</Class>
</ClassDiagram>
2 changes: 2 additions & 0 deletions bin/.gitignore
@@ -0,0 +1,2 @@
/testing/
/thermostat/
Binary file modified bin/main/Main.class
Binary file not shown.
Binary file modified bin/networking/networking.class
Binary file not shown.
Binary file modified bin/server/server.class
Binary file not shown.
Binary file modified bin/testing/JUnit_Test_Example.class
Binary file not shown.
Binary file modified bin/testing/Networking_Test.class
Binary file not shown.
Binary file modified bin/testing/ThermostatTest.class
Binary file not shown.
Binary file modified bin/thermostat/Actuatorable.class
Binary file not shown.
Binary file modified bin/thermostat/DataObject.class
Binary file not shown.
Binary file modified bin/thermostat/Deviceable.class
Binary file not shown.
Binary file modified bin/thermostat/Sensorable.class
Binary file not shown.
Binary file modified bin/thermostat/TemperatureActuator.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.
Binary file modified bin/user_interface/user_interface.class
Binary file not shown.
31 changes: 30 additions & 1 deletion src/testing/ThermostatTest.java
Expand Up @@ -7,12 +7,17 @@ public class ThermostatTest {

ThermostatDevice testThermo;
TemperatureSensor testSensor;
TemperatureActuator testActuator;

public ThermostatTest(){
this.testThermo = new ThermostatDevice();
this.testSensor = new TemperatureSensor(this.testThermo);
this.testActuator = new TemperatureActuator();


this.testRandomTempGenerator();
this.testEnterCoolingMode();
this.testEnterHeatingMode();
}

private void testRandomTempGenerator() {
Expand All @@ -22,10 +27,34 @@ public class ThermostatTest {
if(randomTemperatureValue.getValue() > 50 && randomTemperatureValue.getValue()<78){
testPassed = true;
}

this.printTestResults("Generate Random Temp", testPassed);
}

private void testEnterCoolingMode(){
Boolean testPassed = false;
DataObject<Float> actuatorPowerPercentage = new DataObject<Float>(new Float(.60));
this.testActuator.setActuatorPowerPercentage(actuatorPowerPercentage);
DataObject<Boolean> state = this.testActuator.getCurrentState();

if(state.getValue() == false){
testPassed = true;
}
this.printTestResults("Enter Cooling Mode", testPassed);
}

private void testEnterHeatingMode(){
Boolean testPassed = false;
DataObject<Float> actuatorPowerPercentage = new DataObject<Float>(new Float(.20));
this.testActuator.setActuatorPowerPercentage(actuatorPowerPercentage);
DataObject<Boolean> state = this.testActuator.getCurrentState();

if(state.getValue() == true){
testPassed = true;
}

this.printTestResults("Enter Heating Mode", testPassed);
}

private void printTestResults(String testName, Boolean testResult) {
if(testResult){
System.out.println("Test "+testName+": PASSED");
Expand Down
27 changes: 18 additions & 9 deletions src/thermostat/TemperatureActuator.java
@@ -1,21 +1,23 @@
package thermostat;

import com.pi4j.io.gpio.GpioController;
/*import com.pi4j.io.gpio.GpioController;
import com.pi4j.io.gpio.GpioFactory;
import com.pi4j.io.gpio.GpioPinDigitalOutput;
import com.pi4j.io.gpio.PinState;
import com.pi4j.io.gpio.RaspiPin;

*/
public class TemperatureActuator implements Actuatorable {

private final GpioController gpio = GpioFactory.getInstance();
/*private final GpioController gpio = GpioFactory.getInstance();
private GpioPinDigitalOutput temperatureCoolControlActuator;
private GpioPinDigitalOutput temperatureHeatControlActuator;
*/private DataObject<Boolean> currentState;

public TemperatureActuator() {
this.temperatureCoolControlActuator = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_04, "TemperatureCoolControlActuator", PinState.LOW);
this.temperatureHeatControlActuator = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_04, "TemperatureHeatControlActuator", PinState.LOW);
//this.temperatureCoolControlActuator = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_04, "TemperatureCoolControlActuator", PinState.LOW);
//this.temperatureHeatControlActuator = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_04, "TemperatureHeatControlActuator", PinState.LOW);
this.currentState = new DataObject<Boolean>(true);
}

public void setActuatorPowerPercentage(DataObject<Float> percentage) {
Expand All @@ -30,14 +32,21 @@ public class TemperatureActuator implements Actuatorable {
this.setActuatorPowerPercentage(value); //do this for use with LED demo unit
}

public DataObject<Boolean> getCurrentState(){
return this.currentState;
}

private void enterCoolingMode(){
this.temperatureCoolControlActuator.high();
this.temperatureHeatControlActuator.low();
//this.temperatureCoolControlActuator.high();
//this.temperatureHeatControlActuator.low();
this.currentState.setValue(false);
}

private void enterHeatingMode(){
this.temperatureCoolControlActuator.low();
this.temperatureHeatControlActuator.high();
//this.temperatureCoolControlActuator.low();
//this.temperatureHeatControlActuator.high();
this.currentState.setValue(true);

}

}

0 comments on commit ad52904

Please sign in to comment.