Merge pull request #19 from senaduka/last_fill_time

Added last valve open time
This commit is contained in:
2016-05-08 06:06:31 +02:00
4 changed files with 21 additions and 1 deletions

View File

@@ -14,6 +14,10 @@
<div><strong>Ulazni ventil/pumpa:</strong> {{pretty_valve state.in_valve }}</div> <div><strong>Ulazni ventil/pumpa:</strong> {{pretty_valve state.in_valve }}</div>
<div><strong>Zadnja komunikacija: {{ last_communication_time }}</strong> <div><strong>Zadnja komunikacija: {{ last_communication_time }}</strong>
</div> </div>
<div><strong>Zadnje zaljevanje: {{ last_out_valve_open }}</strong>
</div>
<div><strong>Zadnje punjenje: {{ last_in_valve_open }}</strong>
</div>
</div> </div>
</div> </div>
<div class="row"> <div class="row">

View File

@@ -7,6 +7,12 @@ Template.state_details.helpers({
}, },
last_communication_time: function() { last_communication_time: function() {
return moment(this.time).fromNow(); return moment(this.time).fromNow();
},
last_out_valve_open: function() {
return moment(this.significantEvents.lastOutValveOpen).fromNow();
},
last_in_valve_open: function() {
return moment(this.significantEvents.lastInValveOpen).fromNow();
} }
}); });
@@ -90,7 +96,7 @@ function buildTemperatureGraph() {
function buildHumidityGraph() { function buildHumidityGraph() {
var unfilteredReadings = sensor_data_collection(); var unfilteredReadings = sensor_data_collection();
// we want to show only 11 points from all data - filtering will add // we want to show only 11 points from all data - filtering will add
// the last one so 10 + 1 = 11 // the last one so 10 + 1 = 11
var breakingPoint = Math.floor(countValues(unfilteredReadings) / 10); var breakingPoint = Math.floor(countValues(unfilteredReadings) / 10);
var sensorReadings = filterDataPoints(unfilteredReadings, breakingPoint); var sensorReadings = filterDataPoints(unfilteredReadings, breakingPoint);

View File

@@ -37,6 +37,7 @@ function reactToSensorData(nextSensorReading) {
}, { }, {
'$set': { '$set': {
'state.in_valve': 'opening', 'state.in_valve': 'opening',
'significantEvents.lastInValveOpen': new Date(),
'time': new Date(), 'time': new Date(),
'set_by': 'server' 'set_by': 'server'
} }

View File

@@ -21,6 +21,15 @@ function setOutValveTo(controller_id, nextState) {
'set_by': 'server' 'set_by': 'server'
} }
}); });
if(nextState === "open") {
ControllerState.update(state._id, {
'$set': {
'significantEvents.lastOutValveOpen': new Date(),
}
});
}
} }
function openOutValve(controller_id) { function openOutValve(controller_id) {