Compare commits
10 Commits
ui_modific
...
graph_fixi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
98983ea50d | ||
|
|
c947980844 | ||
| 974f18e067 | |||
|
|
534497e373 | ||
|
|
26052a9afc | ||
|
|
e9e808a1bc | ||
| 4197d06819 | |||
|
|
36d1adc626 | ||
|
|
2317ad3e61 | ||
| b2e619c2c9 |
@@ -26,3 +26,4 @@ percolate:synced-cron
|
|||||||
rzymek:moment-locale-bs
|
rzymek:moment-locale-bs
|
||||||
peppelg:bootstrap-3-modal
|
peppelg:bootstrap-3-modal
|
||||||
fortawesome:fontawesome
|
fortawesome:fontawesome
|
||||||
|
mfpierre:chartist-js
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ email@1.0.8
|
|||||||
es5-shim@4.1.14
|
es5-shim@4.1.14
|
||||||
fastclick@1.0.7
|
fastclick@1.0.7
|
||||||
fortawesome:fontawesome@4.5.0
|
fortawesome:fontawesome@4.5.0
|
||||||
|
fourseven:scss@3.4.1
|
||||||
geojson-utils@1.0.4
|
geojson-utils@1.0.4
|
||||||
handlebars@1.0.4
|
handlebars@1.0.4
|
||||||
hot-code-push@1.0.0
|
hot-code-push@1.0.0
|
||||||
@@ -47,6 +48,7 @@ localstorage@1.0.5
|
|||||||
logging@1.0.8
|
logging@1.0.8
|
||||||
meteor@1.1.10
|
meteor@1.1.10
|
||||||
meteor-base@1.0.1
|
meteor-base@1.0.1
|
||||||
|
mfpierre:chartist-js@1.6.1
|
||||||
minifiers@1.1.7
|
minifiers@1.1.7
|
||||||
minimongo@1.0.10
|
minimongo@1.0.10
|
||||||
mobile-experience@1.0.1
|
mobile-experience@1.0.1
|
||||||
|
|||||||
BIN
app/app.tar.gz
Normal file
@@ -2,13 +2,20 @@
|
|||||||
padding: 40px 15px;
|
padding: 40px 15px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.controller_selection {
|
.controller_selection {
|
||||||
padding-top: 10px;
|
padding-top: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media all and (orientation: portrait) {
|
||||||
#bucket_image {
|
#bucket_image {
|
||||||
width: 50%;
|
width: 90%;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media all and (orientation: landscape) {
|
||||||
|
#bucket_image {
|
||||||
|
width: 40%;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,88 +8,88 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<select name="time_of_day" id="time_of_day">
|
<div class="form-group">
|
||||||
<option value="00:00" selected={{ timeSelected "00:00" }}>00:00</option>
|
<select name="time_of_day" id="time_of_day" class="form-control">
|
||||||
<option value="00:30" selected={{ timeSelected "00:30" }}>00:30</option>
|
<option value="00:00" selected={{ timeSelected "00:00" }}>00:00</option>
|
||||||
<option value="01:00" selected={{ timeSelected "01:00" }}>01:00</option>
|
<option value="00:30" selected={{ timeSelected "00:30" }}>00:30</option>
|
||||||
<option value="01:30" selected={{ timeSelected "01:30" }}>01:30</option>
|
<option value="01:00" selected={{ timeSelected "01:00" }}>01:00</option>
|
||||||
<option value="02:00" selected={{ timeSelected "02:00" }}>02:00</option>
|
<option value="01:30" selected={{ timeSelected "01:30" }}>01:30</option>
|
||||||
<option value="02:30" selected={{ timeSelected "02:30" }}>02:30</option>
|
<option value="02:00" selected={{ timeSelected "02:00" }}>02:00</option>
|
||||||
<option value="03:00" selected={{ timeSelected "03:00" }}>03:00</option>
|
<option value="02:30" selected={{ timeSelected "02:30" }}>02:30</option>
|
||||||
<option value="03:30" selected={{ timeSelected "03:30" }}>03:30</option>
|
<option value="03:00" selected={{ timeSelected "03:00" }}>03:00</option>
|
||||||
<option value="04:00" selected={{ timeSelected "04:00" }}>04:00</option>
|
<option value="03:30" selected={{ timeSelected "03:30" }}>03:30</option>
|
||||||
<option value="04:30" selected={{ timeSelected "04:30" }}>04:30</option>
|
<option value="04:00" selected={{ timeSelected "04:00" }}>04:00</option>
|
||||||
<option value="05:00" selected={{ timeSelected "05:00" }}>05:00</option>
|
<option value="04:30" selected={{ timeSelected "04:30" }}>04:30</option>
|
||||||
<option value="05:30" selected={{ timeSelected "05:30" }}>05:30</option>
|
<option value="05:00" selected={{ timeSelected "05:00" }}>05:00</option>
|
||||||
<option value="06:00" selected={{ timeSelected "06:00" }}>06:00</option>
|
<option value="05:30" selected={{ timeSelected "05:30" }}>05:30</option>
|
||||||
<option value="06:30" selected={{ timeSelected "06:30" }}>06:30</option>
|
<option value="06:00" selected={{ timeSelected "06:00" }}>06:00</option>
|
||||||
<option value="07:00" selected={{ timeSelected "07:00" }}>07:00</option>
|
<option value="06:30" selected={{ timeSelected "06:30" }}>06:30</option>
|
||||||
<option value="07:30" selected={{ timeSelected "07:30" }}>07:30</option>
|
<option value="07:00" selected={{ timeSelected "07:00" }}>07:00</option>
|
||||||
<option value="08:00" selected={{ timeSelected "08:00" }}>08:00</option>
|
<option value="07:30" selected={{ timeSelected "07:30" }}>07:30</option>
|
||||||
<option value="08:30" selected={{ timeSelected "08:30" }}>08:30</option>
|
<option value="08:00" selected={{ timeSelected "08:00" }}>08:00</option>
|
||||||
<option value="09:00" selected={{ timeSelected "09:00" }}>09:00</option>
|
<option value="08:30" selected={{ timeSelected "08:30" }}>08:30</option>
|
||||||
<option value="09:30" selected={{ timeSelected "09:30" }}>09:30</option>
|
<option value="09:00" selected={{ timeSelected "09:00" }}>09:00</option>
|
||||||
<option value="10:00" selected={{ timeSelected "10:00" }}>10:00</option>
|
<option value="09:30" selected={{ timeSelected "09:30" }}>09:30</option>
|
||||||
<option value="10:30" selected={{ timeSelected "10:30" }}>10:30</option>
|
<option value="10:00" selected={{ timeSelected "10:00" }}>10:00</option>
|
||||||
<option value="11:00" selected={{ timeSelected "11:00" }}>11:00</option>
|
<option value="10:30" selected={{ timeSelected "10:30" }}>10:30</option>
|
||||||
<option value="11:30" selected={{ timeSelected "11:30" }}>11:30</option>
|
<option value="11:00" selected={{ timeSelected "11:00" }}>11:00</option>
|
||||||
<option value="12:00" selected={{ timeSelected "12:00" }}>12:00</option>
|
<option value="11:30" selected={{ timeSelected "11:30" }}>11:30</option>
|
||||||
<option value="12:30" selected={{ timeSelected "12:30" }}>12:30</option>
|
<option value="12:00" selected={{ timeSelected "12:00" }}>12:00</option>
|
||||||
<option value="13:00" selected={{ timeSelected "13:00" }}>13:00</option>
|
<option value="12:30" selected={{ timeSelected "12:30" }}>12:30</option>
|
||||||
<option value="13:30" selected={{ timeSelected "13:30" }}>13:30</option>
|
<option value="13:00" selected={{ timeSelected "13:00" }}>13:00</option>
|
||||||
<option value="14:00" selected={{ timeSelected "14:00" }}>14:00</option>
|
<option value="13:30" selected={{ timeSelected "13:30" }}>13:30</option>
|
||||||
<option value="14:30" selected={{ timeSelected "14:30" }}>14:30</option>
|
<option value="14:00" selected={{ timeSelected "14:00" }}>14:00</option>
|
||||||
<option value="15:00" selected={{ timeSelected "15:00" }}>15:00</option>
|
<option value="14:30" selected={{ timeSelected "14:30" }}>14:30</option>
|
||||||
<option value="15:30" selected={{ timeSelected "15:30" }}>15:30</option>
|
<option value="15:00" selected={{ timeSelected "15:00" }}>15:00</option>
|
||||||
<option value="16:00" selected={{ timeSelected "16:00" }}>16:00</option>
|
<option value="15:30" selected={{ timeSelected "15:30" }}>15:30</option>
|
||||||
<option value="16:30" selected={{ timeSelected "16:30" }}>16:30</option>
|
<option value="16:00" selected={{ timeSelected "16:00" }}>16:00</option>
|
||||||
<option value="17:00" selected={{ timeSelected "17:00" }}>17:00</option>
|
<option value="16:30" selected={{ timeSelected "16:30" }}>16:30</option>
|
||||||
<option value="17:30" selected={{ timeSelected "17:30" }}>17:30</option>
|
<option value="17:00" selected={{ timeSelected "17:00" }}>17:00</option>
|
||||||
<option value="18:00" selected={{ timeSelected "18:00" }}>18:00</option>
|
<option value="17:30" selected={{ timeSelected "17:30" }}>17:30</option>
|
||||||
<option value="18:30" selected={{ timeSelected "18:30" }}>18:30</option>
|
<option value="18:00" selected={{ timeSelected "18:00" }}>18:00</option>
|
||||||
<option value="19:00" selected={{ timeSelected "19:00" }}>19:00</option>
|
<option value="18:30" selected={{ timeSelected "18:30" }}>18:30</option>
|
||||||
<option value="19:30" selected={{ timeSelected "19:30" }}>19:30</option>
|
<option value="19:00" selected={{ timeSelected "19:00" }}>19:00</option>
|
||||||
<option value="20:00" selected={{ timeSelected "20:00" }}>20:00</option>
|
<option value="19:30" selected={{ timeSelected "19:30" }}>19:30</option>
|
||||||
<option value="20:30" selected={{ timeSelected "20:30" }}>20:30</option>
|
<option value="20:00" selected={{ timeSelected "20:00" }}>20:00</option>
|
||||||
<option value="21:00" selected={{ timeSelected "21:00" }}>21:00</option>
|
<option value="20:30" selected={{ timeSelected "20:30" }}>20:30</option>
|
||||||
<option value="21:30" selected={{ timeSelected "21:30" }}>21:30</option>
|
<option value="21:00" selected={{ timeSelected "21:00" }}>21:00</option>
|
||||||
<option value="22:00" selected={{ timeSelected "22:00" }}>22:00</option>
|
<option value="21:30" selected={{ timeSelected "21:30" }}>21:30</option>
|
||||||
<option value="22:30" selected={{ timeSelected "22:30" }}>22:30</option>
|
<option value="22:00" selected={{ timeSelected "22:00" }}>22:00</option>
|
||||||
<option value="23:00" selected={{ timeSelected "23:00" }}>23:00</option>
|
<option value="22:30" selected={{ timeSelected "22:30" }}>22:30</option>
|
||||||
<option value="23:30" selected={{ timeSelected "23:30" }}>23:30</option>
|
<option value="23:00" selected={{ timeSelected "23:00" }}>23:00</option>
|
||||||
</select>
|
<option value="23:30" selected={{ timeSelected "23:30" }}>23:30</option>
|
||||||
<div>
|
</select>
|
||||||
|
</div>
|
||||||
<input type="checkbox" id="day_1" name="day_1" value="2" class="day_checkbox" checked="{{ dayChecked '2' }}" />
|
<div class="form-group">
|
||||||
<label for="day_1">Ponedjeljak</label>
|
<div>
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<input type="checkbox" id="day_2" name="day_2" value="3" class="day_checkbox" checked="{{ dayChecked '3' }}" />
|
|
||||||
<label for="day_2">Utorak</label>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<input type="checkbox" id="day_3" name="day_3" value="4" class="day_checkbox" checked="{{ dayChecked '4' }}" />
|
|
||||||
<label for="day_3">Srijeda</label>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<input type="checkbox" id="day_4" name="day_4" value="5" class="day_checkbox" checked="{{ dayChecked '5' }}" />
|
|
||||||
<label for="day_4">Četvrtak</label>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<input type="checkbox" id="day_5" name="day_5" value="6" class="day_checkbox" checked="{{ dayChecked '6' }}" />
|
|
||||||
<label for="day_5">Petak</label>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<input type="checkbox" id="day_6" name="day_6" value="7" class="day_checkbox" checked="{{ dayChecked '7' }}" />
|
|
||||||
<label for="day_6">Subota</label>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<input type="checkbox" id="day_7" name="day_7" value="1" class="day_checkbox" checked="{{ dayChecked '1' }}" />
|
|
||||||
<label for="day_7">Nedjelja</label>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
|
|
||||||
|
<input type="checkbox" id="day_1" name="day_1" value="2" class="day_checkbox form_control" checked="{{ dayChecked '2' }}" />
|
||||||
|
<label for="day_1">Ponedjeljak</label>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<input type="checkbox" id="day_2" name="day_2" value="3" class="day_checkbox form_control" checked="{{ dayChecked '3' }}" />
|
||||||
|
<label for="day_2">Utorak</label>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<input type="checkbox" id="day_3" name="day_3" value="4" class="day_checkbox form_control" checked="{{ dayChecked '4' }}" />
|
||||||
|
<label for="day_3">Srijeda</label>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<input type="checkbox" id="day_4" name="day_4" value="5" class="day_checkbox form_control" checked="{{ dayChecked '5' }}" />
|
||||||
|
<label for="day_4">Četvrtak</label>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<input type="checkbox" id="day_5" name="day_5" value="6" class="day_checkbox form_control" checked="{{ dayChecked '6' }}" />
|
||||||
|
<label for="day_5">Petak</label>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<input type="checkbox" id="day_6" name="day_6" value="7" class="day_checkbox form_control" checked="{{ dayChecked '7' }}" />
|
||||||
|
<label for="day_6">Subota</label>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<input type="checkbox" id="day_7" name="day_7" value="1" class="day_checkbox form_control" checked="{{ dayChecked '1' }}" />
|
||||||
|
<label for="day_7">Nedjelja</label>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -7,13 +7,12 @@
|
|||||||
{{#with last_sensor_reading}} <strong> {{ temperatureValue }} °C, {{ humidityValue }} % </strong> {{/with}}
|
{{#with last_sensor_reading}} <strong> {{ temperatureValue }} °C, {{ humidityValue }} % </strong> {{/with}}
|
||||||
</div>
|
</div>
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
Automatsko zaljevanje: <strong>{{ pretty_days config.automaticDaysOfWeek }} {{ pretty_time config.automaticDaysOfWeek config.automaticTimeOfDay }}</strong> <button id="run_settings" class="btn btn-default"> <i class="fa fa-wrench"></i> </button>
|
Automatsko zalijevanje:<br /> <strong>{{ pretty_days config.automaticDaysOfWeek }} {{ pretty_time config.automaticDaysOfWeek config.automaticTimeOfDay }}</strong> <button id="run_settings" class="btn btn-default"> <i class="fa fa-wrench"></i> </button>
|
||||||
</div>
|
</div>
|
||||||
{{/with}}
|
{{/with}}
|
||||||
<div>
|
<div>
|
||||||
<button id="water_now" class="{{ water_now_button_class }}">Zalij sada</button>
|
<button id="water_now" class="{{ water_now_button_class }}">Zalij sada</button>
|
||||||
<button id="stop_water_now" class="{{ stop_button_class }}">Prekini zalijevanje</button>
|
<button id="stop_water_now" class="{{ stop_button_class }}">Prekini zalijevanje</button>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -46,15 +46,15 @@ Template.state.helpers({
|
|||||||
var sensor = last_sensor_reading();
|
var sensor = last_sensor_reading();
|
||||||
var stateObject = controller_state();
|
var stateObject = controller_state();
|
||||||
if (sensor) {
|
if (sensor) {
|
||||||
if (sensor.tankFull === 0 && stateObject.state.in_valve === 'open' && stateObject.state.out_valve === 'closed') return "/images/barellFillingUp.png";
|
if (parseInt(sensor.tankFull) === 0 && stateObject.state.in_valve === 'open' && stateObject.state.out_valve === 'closed') return "/images/barrellFillingUp.png";
|
||||||
else if (sensor.tankFull === 1 && (stateObject.state.out_valve === 'closed')) return "/images/barellFull.png";
|
else if (parseInt(sensor.tankFull) === 1 && (stateObject.state.out_valve === 'closed')) return "/images/barrellFull.png";
|
||||||
else if (sensor.tankFull === 1 && (stateObject.state.out_valve === 'opening')) return "/images/barellStartWateringFull.png";
|
else if (parseInt(sensor.tankFull) === 1 && (stateObject.state.out_valve === 'opening')) return "/images/barrellStartWateringFull.png";
|
||||||
else if (sensor.tankFull === 1 && (stateObject.state.out_valve === 'open')) return "/images/barellWateringFull.png";
|
else if (parseInt(sensor.tankFull) === 1 && (stateObject.state.out_valve === 'open')) return "/images/barrellWateringFull.png";
|
||||||
else if (sensor.tankFull === 1 && (stateObject.state.out_valve === 'closing')) return "/images/barellStopWateringFull.png";
|
else if (parseInt(sensor.tankFull) === 1 && (stateObject.state.out_valve === 'closing')) return "/images/barrellStopWateringFull.png";
|
||||||
else if (sensor.tankFull === 0 && (stateObject.state.out_valve === 'closed')) return "/images/barellNotFull.png";
|
else if (parseInt(sensor.tankFull) === 0 && (stateObject.state.out_valve === 'closed')) return "/images/barrellNotFull.png";
|
||||||
else if (sensor.tankFull === 0 && (stateObject.state.out_valve === 'opening')) return "/images/barellStartWateringNotFull.png";
|
else if (parseInt(sensor.tankFull) === 0 && (stateObject.state.out_valve === 'opening')) return "/images/barrellStartWateringNotFull.png";
|
||||||
else if (sensor.tankFull === 0 && (stateObject.state.out_valve === 'open')) return "/images/barellWateringNotFull.png"
|
else if (parseInt(sensor.tankFull) === 0 && (stateObject.state.out_valve === 'open')) return "/images/barrellWateringNotFull.png"
|
||||||
else if (sensor.tankFull === 0 && (stateObject.state.out_valve === 'closing')) return "/images/barellStopWateringNotFull.png"
|
else if (parseInt(sensor.tankFull) === 0 && (stateObject.state.out_valve === 'closing')) return "/images/barrellStopWateringNotFull.png"
|
||||||
else return "/images/statusAmber.png";
|
else return "/images/statusAmber.png";
|
||||||
} else return "/images/statusRed.png";
|
} else return "/images/statusRed.png";
|
||||||
},
|
},
|
||||||
@@ -80,10 +80,11 @@ Template.state.helpers({
|
|||||||
|
|
||||||
pretty_days: function(daysInNumbers) {
|
pretty_days: function(daysInNumbers) {
|
||||||
var days = ["Nedjelja", "Ponedjeljak", "Utorak", "Srijeda", "Četvrtak", "Petak", "Subota"];
|
var days = ["Nedjelja", "Ponedjeljak", "Utorak", "Srijeda", "Četvrtak", "Petak", "Subota"];
|
||||||
if (daysInNumbers.length == 7) {
|
if (!daysInNumbers || daysInNumbers.length == 0) {
|
||||||
return "Svaki dan"
|
|
||||||
} else if (!daysInNumbers || daysInNumbers.length == 0) {
|
|
||||||
return "Nikad"
|
return "Nikad"
|
||||||
|
}
|
||||||
|
else if (daysInNumbers.length == 7) {
|
||||||
|
return "Svaki dan"
|
||||||
} else {
|
} else {
|
||||||
return daysInNumbers.map(function(number) {
|
return daysInNumbers.map(function(number) {
|
||||||
return days[number -1 ];
|
return days[number -1 ];
|
||||||
|
|||||||
@@ -8,9 +8,29 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<div><strong>Otpusni ventil:</strong> {{pretty_valve state.out_valve }}</div>
|
<div class="row">
|
||||||
<div><strong>Ulazni ventil/pumpa:</strong> {{pretty_valve state.in_valve }}</div>
|
<div class="col-md-12 chart">
|
||||||
<div><strong>Zadnja komunikacija: {{ last_communication_time }}</strong></div>
|
<div><strong>Otpusni ventil:</strong> {{pretty_valve state.out_valve }}</div>
|
||||||
|
<div><strong>Ulazni ventil/pumpa:</strong> {{pretty_valve state.in_valve }}</div>
|
||||||
|
<div><strong>Zadnja komunikacija: {{ last_communication_time }}</strong>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12 chart">
|
||||||
|
<h3>Temperatura:</h3>
|
||||||
|
<div id="temperature_graph">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12 chart">
|
||||||
|
<h3>Vlažnost:</h3>
|
||||||
|
<div id="humidity_graph">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
|
|||||||
@@ -10,5 +10,144 @@ Template.state_details.helpers({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Template.state_details.events({
|
Template.state_details.events({});
|
||||||
});
|
|
||||||
|
Template.state_details.rendered = function() {
|
||||||
|
this.node = this.find('#temperature_graph'); // our d3 code goes here
|
||||||
|
var yScale = d3.scale.linear()
|
||||||
|
.domain([0, 4])
|
||||||
|
.range([10, 60]);
|
||||||
|
var xScale = d3.scale.linear()
|
||||||
|
.domain([0, self.duration])
|
||||||
|
.range([0, $(self.timelineWrapper).width()])
|
||||||
|
};
|
||||||
|
|
||||||
|
function sensor_data_collection() {
|
||||||
|
var controllerId = Session.get('controller_id');
|
||||||
|
return SensorData.find({
|
||||||
|
controllerId: controllerId
|
||||||
|
}, {
|
||||||
|
sort: {
|
||||||
|
created_at: 1
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Template.state_details.rendered = function() {
|
||||||
|
|
||||||
|
var self = this;
|
||||||
|
/*
|
||||||
|
* add point when new temperature is added
|
||||||
|
*/
|
||||||
|
setTimeout(function() {
|
||||||
|
self.autorun(function() {
|
||||||
|
sensor_data_collection().observe({
|
||||||
|
added: function(reading) {
|
||||||
|
buildTemperatureGraph();
|
||||||
|
buildHumidityGraph()
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Function to draw the graph
|
||||||
|
*/
|
||||||
|
function buildTemperatureGraph() {
|
||||||
|
|
||||||
|
var unfilteredReadings = sensor_data_collection();
|
||||||
|
|
||||||
|
// we want to show only 11 points from all data
|
||||||
|
var breakingPoint = Math.floor(countValues(unfilteredReadings) / 10);
|
||||||
|
|
||||||
|
var sensorReadings = filterDataPoints(unfilteredReadings, breakingPoint);
|
||||||
|
|
||||||
|
var times = sensorReadings.map(function(reading) {
|
||||||
|
return moment(reading.created_at).format("HH:mm:ss");
|
||||||
|
});
|
||||||
|
var values = sensorReadings.map(function(reading) {
|
||||||
|
return reading.temperatureValue;
|
||||||
|
});
|
||||||
|
|
||||||
|
var breakingPoint = Math.floor(times.length / 11);
|
||||||
|
|
||||||
|
return new Chartist.Line('#temperature_graph', {
|
||||||
|
labels: times,
|
||||||
|
series: [values]
|
||||||
|
}, {
|
||||||
|
fullWidth: true,
|
||||||
|
chartPadding: {
|
||||||
|
right: 40
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Function to draw the graph
|
||||||
|
*/
|
||||||
|
function buildHumidityGraph() {
|
||||||
|
var unfilteredReadings = sensor_data_collection();
|
||||||
|
// we want to show only 11 points from all data - filtering will add
|
||||||
|
// the last one so 10 + 1 = 11
|
||||||
|
var breakingPoint = Math.floor(countValues(unfilteredReadings) / 10);
|
||||||
|
|
||||||
|
var sensorReadings = filterDataPoints(unfilteredReadings, breakingPoint);
|
||||||
|
|
||||||
|
var times = sensorReadings.map(function(reading) {
|
||||||
|
return moment(reading.created_at).format("HH:mm:ss");
|
||||||
|
});
|
||||||
|
var values = sensorReadings.map(function(reading) {
|
||||||
|
return reading.humidityValue;
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return new Chartist.Line('#humidity_graph', {
|
||||||
|
labels: times,
|
||||||
|
series: [values]
|
||||||
|
}, {
|
||||||
|
fullWidth: true,
|
||||||
|
chartPadding: {
|
||||||
|
right: 40
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function filterDataPoints(data, breakingPoint) {
|
||||||
|
|
||||||
|
if (breakingPoint === 0) {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
var result = [];
|
||||||
|
var index = 0;
|
||||||
|
var lastUnpushedRow = null;
|
||||||
|
data.forEach(function(row) {
|
||||||
|
if (index % breakingPoint === 0) {
|
||||||
|
result.push(row);
|
||||||
|
lastUnpushedRow = null;
|
||||||
|
} else {
|
||||||
|
lastUnpushedRow = row;
|
||||||
|
}
|
||||||
|
index++;
|
||||||
|
});
|
||||||
|
|
||||||
|
// in order to always have the latest value
|
||||||
|
if(lastUnpushedRow) {
|
||||||
|
|
||||||
|
result.push(lastUnpushedRow);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// dirty hack for the complicated way of getting
|
||||||
|
// acual number of values
|
||||||
|
function countValues(data) {
|
||||||
|
var count = 0;
|
||||||
|
data.forEach(function(row) {
|
||||||
|
count++;
|
||||||
|
});
|
||||||
|
return count;
|
||||||
|
};
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 71 KiB |
|
Before Width: | Height: | Size: 109 KiB |
|
Before Width: | Height: | Size: 103 KiB |
|
Before Width: | Height: | Size: 88 KiB |
|
Before Width: | Height: | Size: 82 KiB |
BIN
app/public/images/barrellFillingUp.png
Normal file
|
After Width: | Height: | Size: 76 KiB |
|
Before Width: | Height: | Size: 61 KiB After Width: | Height: | Size: 66 KiB |
|
Before Width: | Height: | Size: 59 KiB After Width: | Height: | Size: 64 KiB |
|
Before Width: | Height: | Size: 75 KiB After Width: | Height: | Size: 81 KiB |
|
Before Width: | Height: | Size: 69 KiB After Width: | Height: | Size: 74 KiB |
BIN
app/public/images/barrellStopWateringFull.png
Normal file
|
After Width: | Height: | Size: 102 KiB |
BIN
app/public/images/barrellStopWateringNotFull.png
Normal file
|
After Width: | Height: | Size: 94 KiB |
BIN
app/public/images/barrellWateringFull.png
Normal file
|
After Width: | Height: | Size: 94 KiB |
BIN
app/public/images/barrellWateringNotFull.png
Normal file
|
After Width: | Height: | Size: 87 KiB |
@@ -24,10 +24,12 @@ Api.addRoute('sensorData', {
|
|||||||
|
|
||||||
|
|
||||||
function reactToSensorData(nextSensorReading) {
|
function reactToSensorData(nextSensorReading) {
|
||||||
console.log("reacting to sensor");
|
|
||||||
var controllerId = nextSensorReading.controllerId;
|
var controllerId = nextSensorReading.controllerId;
|
||||||
var state = stateOrDefault(controllerId).state;
|
var state = stateOrDefault(controllerId).state;
|
||||||
var shouldStartPumping = (!state.in_valve || state.in_valve === 'closed') && ((parseInt(nextSensorReading.tankFull) === 0) && (state.out_valve === 'closed' || state.out_valve === 'closing'));
|
console.log(nextSensorReading , state);
|
||||||
|
var shouldStartPumping = (!state.in_valve || state.in_valve === 'closed' || state.in_valve === 'closing') && ((parseInt(nextSensorReading.tankFull) === 0) && (state.out_valve === 'closed' || state.out_valve === 'closing'));
|
||||||
|
|
||||||
|
var shouldStopPumping = (state.in_valve === 'open' || state.in_valve === 'opening') && (parseInt(nextSensorReading.tankFull) === 1 || state.out_valve === 'open' || state.out_valve === 'opening');
|
||||||
|
|
||||||
if (shouldStartPumping) {
|
if (shouldStartPumping) {
|
||||||
ControllerState.update({
|
ControllerState.update({
|
||||||
@@ -39,10 +41,7 @@ function reactToSensorData(nextSensorReading) {
|
|||||||
'set_by': 'server'
|
'set_by': 'server'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
} else if (shouldStopPumping) {
|
||||||
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({
|
ControllerState.update({
|
||||||
controller_id: controllerId
|
controller_id: controllerId
|
||||||
}, {
|
}, {
|
||||||
@@ -102,3 +101,6 @@ function stateOrDefault(id) {
|
|||||||
});
|
});
|
||||||
return stateEntry;
|
return stateEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Meteor.sharedFunctions = Meteor.sharedFunctions || {};
|
||||||
|
Meteor.sharedFunctions.reactToSensorData = reactToSensorData;
|
||||||
|
|||||||
@@ -40,7 +40,9 @@ function openOutValve(controller_id) {
|
|||||||
closeOutValve(controller_id);
|
closeOutValve(controller_id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
console.log("Finished adding cron ", controller_id);
|
console.log(Meteor.sharedFunctions);
|
||||||
|
|
||||||
|
Meteor.sharedFunctions.reactToSensorData(last_sensor_reading(controller_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
function closeOutValve(controller_id) {
|
function closeOutValve(controller_id) {
|
||||||
@@ -51,6 +53,10 @@ function closeOutValve(controller_id) {
|
|||||||
SyncedCron.remove(jobName);
|
SyncedCron.remove(jobName);
|
||||||
setOutValveTo(controller_id, 'closing');
|
setOutValveTo(controller_id, 'closing');
|
||||||
console.log("Finished clearing cron ", controller_id);
|
console.log("Finished clearing cron ", controller_id);
|
||||||
|
|
||||||
|
console.log(Meteor.sharedFunctions);
|
||||||
|
|
||||||
|
Meteor.sharedFunctions.reactToSensorData(last_sensor_reading(controller_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearLog() {
|
function clearLog() {
|
||||||
@@ -88,6 +94,28 @@ function saveControllerConfig(controller_id, time, days) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function last_sensor_reading(controller_id) {
|
||||||
|
var result = null;
|
||||||
|
|
||||||
|
if (controller_id) {
|
||||||
|
result = SensorData.find({
|
||||||
|
controllerId: controller_id
|
||||||
|
}, {
|
||||||
|
sort: {
|
||||||
|
created_at: -1
|
||||||
|
},
|
||||||
|
limit: 1
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (result && result.count() > 0) {
|
||||||
|
return result.fetch()[0];
|
||||||
|
} else {
|
||||||
|
return {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Meteor.methods({
|
Meteor.methods({
|
||||||
openOutValve: openOutValve,
|
openOutValve: openOutValve,
|
||||||
closeOutValve: closeOutValve,
|
closeOutValve: closeOutValve,
|
||||||
|
|||||||
@@ -4,27 +4,10 @@ if (Meteor.isServer) {
|
|||||||
SyncedCron.start();
|
SyncedCron.start();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// Global API configuration
|
// Global API configuration
|
||||||
var Api = new Restivus({
|
var Api = new Restivus({
|
||||||
useDefaultAuth: true,
|
useDefaultAuth: true,
|
||||||
prettyJson: true
|
prettyJson: true
|
||||||
});
|
});
|
||||||
|
|
||||||
Api.addRoute('sensorData', {
|
|
||||||
authRequired: false
|
|
||||||
}, {
|
|
||||||
post: function() {
|
|
||||||
SensorData.insert({
|
|
||||||
temperatureValue: parseFloat(this.bodyParams.temperatureValue),
|
|
||||||
humidityValue: parseFloat(this.bodyParams.humidityValue),
|
|
||||||
tankFull: this.bodyParams.tankFull,
|
|
||||||
owner: this.bodyParams.owner,
|
|
||||||
created_at: new Date()
|
|
||||||
});
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,10 @@ import RPi.GPIO as GPIO
|
|||||||
# Try to read the state of GPIO_PIN_TANKFULL
|
# Try to read the state of GPIO_PIN_TANKFULL
|
||||||
GPIO.setmode(GPIO.BCM)
|
GPIO.setmode(GPIO.BCM)
|
||||||
GPIO.setup(config.GPIO_PIN_TANKFULL, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
|
GPIO.setup(config.GPIO_PIN_TANKFULL, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
|
||||||
tankFull = GPIO.input(config.GPIO_PIN_TANKFULL)
|
|
||||||
|
# tank sensor has inverse logic - 0 when it is full 1 when it is not
|
||||||
|
# so we are inverting its value here
|
||||||
|
tankFull = (not GPIO.input(config.GPIO_PIN_TANKFULL))
|
||||||
GPIO.cleanup()
|
GPIO.cleanup()
|
||||||
print 'Bacva puna: {}'.format(tankFull)
|
print 'Bacva puna: {}'.format(tankFull)
|
||||||
|
|
||||||
|
|||||||