Added 4 new images for opening and closing out valve while barrell is either full or not full... also tried to add additional constraints for pump handling in means of that the pump should not be pumping if the out valve is open or opening

This commit is contained in:
2016-03-18 22:26:41 +01:00
parent 24a1b81b92
commit 5cd8420bcf
6 changed files with 12 additions and 8 deletions

View File

@@ -46,11 +46,15 @@ Template.state.helpers({
var sensor = last_sensor_reading();
var stateObject = controller_state();
if (sensor) {
if (sensor.tankFull === 1 && (stateObject.state.out_valve === 'closed' || stateObject.state.out_valve === 'opening')) return "/images/barellFull.png";
else if (sensor.tankFull === 0 && (stateObject.state.out_valve === 'closed' || stateObject.state.out_valve === 'opening')) return "/images/barellNotFull.png";
else if (sensor.tankFull === 1 && (stateObject.state.out_valve === 'open' || stateObject.state.out_valve === 'closing')) return "/images/barellWateringFull.png";
else if (sensor.tankFull === 0 && (stateObject.state.out_valve === 'open' || stateObject.state.out_valve === 'closing')) return "/images/barellWateringNotFull.png"
else if (sensor.tankFull === 0 && stateObject.state.in_valve === 'open') return "/images/barellFillingUp.png";
if (sensor.tankFull === 0 && stateObject.state.in_valve === 'open' && stateObject.state.out_valve === 'closed') return "/images/barellFillingUp.png";
else if (sensor.tankFull === 1 && (stateObject.state.out_valve === 'closed')) return "/images/barellFull.png";
else if (sensor.tankFull === 1 && (stateObject.state.out_valve === 'opening')) return "/images/barellStartWateringFull.png";
else if (sensor.tankFull === 1 && (stateObject.state.out_valve === 'open')) return "/images/barellWateringFull.png";
else if (sensor.tankFull === 1 && (stateObject.state.out_valve === 'closing')) return "/images/barellStopWateringFull.png";
else if (sensor.tankFull === 0 && (stateObject.state.out_valve === 'closed')) return "/images/barellNotFull.png";
else if (sensor.tankFull === 0 && (stateObject.state.out_valve === 'opening')) return "/images/barellStartWateringNotFull.png";
else if (sensor.tankFull === 0 && (stateObject.state.out_valve === 'open')) return "/images/barellWateringNotFull.png"
else if (sensor.tankFull === 0 && (stateObject.state.out_valve === 'closing')) return "/images/barellStopWateringNotFull.png"
else return "/images/statusAmber.png";
}
else return "/images/statusRed.png";

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 69 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB

View File

@@ -27,7 +27,7 @@ function reactToSensorData(nextSensorReading) {
console.log("reacting to sensor");
var controllerId = nextSensorReading.controllerId;
var state = stateOrDefault(controllerId).state;
var shouldStartPumping = (parseInt(nextSensorReading.tankFull) === 0 && (!state.in_valve || state.in_valve === 'closed'));
var shouldStartPumping = (!state.in_valve || state.in_valve === 'closed') && ((parseInt(nextSensorReading.tankFull) === 0) && (state.out_valve === 'closed' || state.out_valve === 'closing'));
if (shouldStartPumping) {
ControllerState.update({
@@ -40,7 +40,7 @@ function reactToSensorData(nextSensorReading) {
}
});
}
var shouldStopPumping = parseInt(nextSensorReading.tankFull) === 1 && (state.in_valve === 'open' || state.in_valve === 'opening');
var shouldStopPumping = (state.in_valve === 'open' || state.in_valve === 'opening') && (parseInt(nextSensorReading.tankFull) === 1 || state.out_valve === 'open' || state.out_valve === 'opening');
if (shouldStopPumping) {
ControllerState.update({
@@ -91,7 +91,7 @@ function stateOrDefault(id) {
},
time: new Date(),
config: {
draining_period_amount: 5,
draining_period_amount: 60,
draining_period_unit: 'minutes'
},
set_by: 'server'