Mon, 07 Jan 2019 22:35:32 +0100
Fermenter monitor screen added control boxes and LED's.
/***************************************************************************** * Copyright (C) 2019 * * Michiel Broek <mbroek at mbse dot eu> * * This file is part of BMS * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2, or (at your option) any * later version. * * Brewery Management System istributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with ThermFerm; see the file COPYING. If not, write to the Free * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *****************************************************************************/ $(document).ready(function () { var bname = ''; var bcode = ''; var yl = 12; // Normal yeast temp range var yh = 24; var gaugeoptions = { min: 0, max: 40, width: 375, height: 375, ranges: [{ startValue: 0, endValue: yl, style: { fill: '#3399FF', stroke: '#3399FF' }, endWidth: 10, startWidth: 10 }, { startValue: yl, endValue: yh, style: { fill: '#00CC33', stroke: '#00CC33' }, endWidth: 10, startWidth: 10 }, { startValue: yh, endValue: 40, style: { fill: '#FC6A6A', stroke: '#FC6A6A' }, endWidth: 10, startWidth: 10 }], ticksMinor: { interval: 1, size: '5%' }, ticksMajor: { interval: 5, size: '9%' }, labels: { interval: 5 }, style: { fill: '#eeeeee', stroke: '#666666' }, value: 0, colorScheme: 'scheme05', animationDuration: 1200 }; var gaugeSmalloptions = { min: -15, max: 25, width: 190, height: 190, ranges: [{ startValue: -15, endValue: 0, startWidth: 5, endWidth: 5, style: { fill: '#3399FF', stroke: '#3399FF' }}, { startValue: 0, endValue: 10, startWidth: 5, endWidth: 5, style: { fill: '#00CC33', stroke: '#00CC33' }}, { startValue: 10, endValue: 25, startWidth: 5, endWidth: 5, style: { fill: '#FC6A6A', stroke: '#FC6A6A' }}], ticksMinor: { interval: 1, size: '5%' }, ticksMajor: { interval: 5, size: '9%' }, labels: { interval: 5 }, style: { fill: '#eeeeee', stroke: '#666666' }, value: 0, colorScheme: 'scheme05', animationDuration: 1200, caption: { value: 'Chiller', position: 'bottom', offset: [0, 10] } }; $("#gaugeContainer_air").jqxGauge( gaugeoptions ); $("#gaugeContainer_air").jqxGauge( { caption: { value: 'Air', position: 'bottom', offset: [0, 10] }} ); $("#gaugeContainer_beer").jqxGauge( gaugeoptions ); $("#gaugeContainer_beer").jqxGauge( { caption: { value: 'Beer', position: 'bottom', offset: [0, 10] }} ); $("#gaugeContainer_chiller").jqxGauge( gaugeSmalloptions ); var url = "getfermenter.php?uuid='" + my_uuid + "'"; var source = { datatype: "json", datafields: [ { name: 'record', type: 'int' }, { name: 'uuid', type: 'string' }, { name: 'alias', type: 'string' }, { name: 'node', type: 'string' }, { name: 'online', type: 'bool' }, { name: 'beercode', type: 'string' }, { name: 'beername', type: 'string' }, { name: 'air_state', type: 'string' }, { name: 'air_temperature', type: 'float' }, { name: 'beer_state', type: 'string' }, { name: 'beer_temperature', type: 'float' }, { name: 'chiller_state', type: 'string' }, { name: 'chiller_temperature', type: 'float' }, { name: 'heater_state', type: 'int' }, { name: 'heater_usage', type: 'int' }, { name: 'cooler_state', type: 'int' }, { name: 'cooler_usage', type: 'int' }, { name: 'fan_state', type: 'int' }, { name: 'fan_usage', type: 'int' }, { name: 'light_state', type: 'int' }, { name: 'light_usage', type: 'int' }, { name: 'door_state', type: 'int' }, { name: 'psu_state', type: 'int' }, { name: 'mode', type: 'string' }, { name: 'alarm', type: 'int' }, { name: 'setpoint_high', type: 'float' }, { name: 'setpoint_low', type: 'float' }, { name: 'profile_uuid', type: 'string' }, { name: 'profile_name', type: 'string' }, { name: 'profile_state', type: 'string' }, { name: 'profile_precent', type: 'int' }, { name: 'profile_inittemp_high', type: 'float' }, { name: 'profile_inittemp_low', type: 'float' }, { name: 'profile_steps', type: 'string' }, { name: 'stage', type: 'string' } ], id: 'record', url: url }; var dataAdapter = new $.jqx.dataAdapter(source, { loadComplete: function (records) { var record = dataAdapter.records[0]; var oline = (record.online) ? "On-line" : "Off-line"; var html = "<table style='width: 100%; padding: 10px;'>"; html += "<tr><th colspan=2>Klimaatkast overzicht</th></tr>"; html += "<tr><td>Uuid</td><td>" + record.uuid + "</td></tr>"; html += "<tr><td>Systeem</td><td>" + record.node + "/" + record.alias + " " + oline + "</td></tr>"; html += "<tr><td>Bier</td><td>" + record.beercode + " - " + record.beername + "</td></tr>"; html += "<tr><td>Werking</td><td>" + record.mode + "</td></tr>"; html += "<tr><td>Fase</td><td>" + record.stage + "</td></tr>" html += "</<table>"; $("#fermenter_info").html(html); bcode = record.beercode; bname = record.beername; if (record.online && (record.mode != "OFF")) { $("#fermentor_powerled").html('<div class="LEDblue_on"></div>Power'); } else { $("#fermentor_powerled").html('<div class="LEDblue_off"></div>Power'); } if (record.online && (record.alarm != "0")) { $("#fermentor_alarmled").html('<div class="LEDred_on"></div>Alarm'); } else { $("#fermentor_alarmled").html('<div class="LEDred_off"></div>Alarm'); } $("#target_lo").html(record.setpoint_low.toFixed(1)); $("#target_hi").html(record.setpoint_high.toFixed(1)); $("#load_air").html(record.air_temperature.toFixed(3)); $("#load_beer").html(record.beer_temperature.toFixed(3)); if (record.online && (record.heater_state != "0")) { $("#fermentor_led1").html('<div class="LEDgreen_on"></div>Heat'); } else { $("#fermentor_led1").html('<div class="LEDgreen_off"></div>Heat'); } if (record.online && (record.cooler_state != "0")) { $("#fermentor_led2").html('<div class="LEDgreen_on"></div>Cool'); } else { $("#fermentor_led2").html('<div class="LEDgreen_off"></div>Cool'); } if (record.online && (record.fan_state != "0")) { $("#fermentor_led3").html('<div class="LEDgreen_on"></div>Fan'); } else { $("#fermentor_led3").html('<div class="LEDgreen_off"></div>Fan'); } $('#gaugeContainer_air').jqxGauge({ value: record.air_temperature }); if (record.online && (record.air_state == "OK")) { $("#gaugeContainer_air").jqxGauge({ disabled: false }); } else { $("#gaugeContainer_air").jqxGauge({ disabled: true }); } $('#gaugeContainer_beer').jqxGauge({ value: record.beer_temperature }); if (record.online && (record.beer_state == "OK")) { $("#gaugeContainer_beer").jqxGauge({ disabled: false }); } else { $("#gaugeContainer_beer").jqxGauge({ disabled: true }); } $("#gaugeContainer_chiller").jqxGauge({ value: record.chiller_temperature }); if (record.online && (record.chiller_state == "OK")) { $("#gaugeContainer_chiller").jqxGauge({ disabled: false }); } else { $("#gaugeContainer_chiller").jqxGauge({ disabled: true }); } } }); // Get the data immediatly and then at regular intervals to refresh. dataAdapter.dataBind(); setInterval(function(){ dataAdapter.dataBind(); }, 10000); // The chart button. $("#FLog").jqxButton({ template: "info", width: '150px', theme: theme }); $("#FLog").click(function () { var url="log_fermentation.php?code=" + bcode + "&name=" + bname; window.open(url); }); });