Example #1
0
<?php

// No direct access
defined("EMONCMS_EXEC") or die("Restricted access");
// Global variables
global $path;
// Translations
require_once "Modules/ewatcher/ewatcher_translations.php";
?>
<link type="text/css" href="<?php 
echo $path;
?>
Modules/ewatcher/css/style.css" rel="stylesheet" property="stylesheet">
<div>
  <h2>
    <?php 
echo ewatcher_translate("This page is not accessible.");
?>
  </h2>
  <h4>
    <?php 
echo ewatcher_translate("Please contact the administrator to enable/disable the EWatcher panels.");
?>
  </h4>
</div>
Example #2
0
    public function view()
    {
        parent::view();
        // (Optional Configuration) set: cIn, cOut, units
        // Form: two dates (default to one week)
        // Value: tLoad, tPv, tPvToLoad, tPvToGrid, tLoadFromGrid (cumulative feeds), 100*tPvToLoad/tPv, 100*tPvToLoad/tLoad (dependent feeds)
        // Value: cGrid, cPvToGrid, cLoadNoPv, cLoadPv, savings (dependent feeds)
        // Table: eDLoad, eDPv, eDLoadFromPv, eDPvToGrid, eDGrid, dPSelf, dPLoadFromPv (daily table)
        ?>
      <div id="ewatcher-config" class="ewatcher-config">
        <div class="default-hidden-config" style="display:none">
          <div class="multiple-values-container">
            <div class="multiple-values multiple-3">
              <span class="single-value">
                <label><?php 
        echo ewatcher_translate("Energy imported cost (per kWh)");
        ?>
</label>
                <input id="cIn" type="number" value="<?php 
        echo $this->config->getcin();
        ?>
" step="any">
              </span>
              <span class="single-value">
                <label><?php 
        echo ewatcher_translate("Currency");
        ?>
</label>
                <input id="units" type="text" value="<?php 
        echo $this->config->getunits();
        ?>
">
              </span>
                <span class="single-value">
                <label><?php 
        echo ewatcher_translate("Energy exported cost (per kWh)");
        ?>
</label>
                <input id="cOut" type="number" value="<?php 
        echo $this->config->getcout();
        ?>
" step="any">
              </span>
            </div>
          </div>
          <span class="click-close"><i class="icon-arrow-up icon-white"></i></span>
        </div>
        <div class="default-shown-config">
          <span class="click-open"><?php 
        echo ewatcher_translate("Energy costs");
        ?>
<i class="icon-wrench icon-white"></i></span>
        </div>
        <hr>
      </div>
      <div class="multiple-values-container">
        <div class="formDates">
          <div class="dateInput">
            <label><?php 
        echo ewatcher_translate("Start date");
        ?>
</label>
            <div id="startDate" class="input-append date control-group">
              <input data-format="dd/MM/yyyy" value="<?php 
        echo date("d/m/Y", strtotime('-7 days'));
        ?>
" type="text" />
              <span class="add-on"> <i data-time-icon="icon-time" data-date-icon="icon-calendar"></i></span>
            </div>
          </div>
          <div class="dateInput">
            <label><?php 
        echo ewatcher_translate("End date");
        ?>
</label>
            <div id="endDate" class="input-append date control-group">
              <input data-format="dd/MM/yyyy" value="<?php 
        echo date("d/m/Y", strtotime('-1 days'));
        ?>
" type="text" />
              <span class="add-on"> <i data-time-icon="icon-time" data-date-icon="icon-calendar"></i></span>
            </div>
          </div>
        </div>
      </div>
      <hr>
      <div class="multiple-values-container">
        <div class="multiple-values multiple-3">
          <span class="single-value">
            <label><?php 
        echo ewatcher_translate("Total consumption");
        ?>
</label>
            <span id="tLoad" data-feedid="<?php 
        echo $this->feeds['tLoad']['id'];
        ?>
">
            </span>
            <span>kWh</span>
          </span>
          <span class="single-value">
            <label><?php 
        echo ewatcher_translate("PV energy produced");
        ?>
</label>
            <span id="tPv" class="ewatcher-yellow" data-feedid="<?php 
        echo $this->feeds['tPv']['id'];
        ?>
">
            </span>
            <span class="ewatcher-yellow">kWh</span>
          </span>
          <span class="single-value">
            <label><?php 
        echo ewatcher_translate("PV self-consumed energy");
        ?>
</label>
            <span id="tPvToLoad"  class="ewatcher-yellow" data-feedid="<?php 
        echo $this->feeds['tPvToLoad']['id'];
        ?>
">
            </span>
            <span class="ewatcher-yellow">kWh</span>
          </span>
        </div>
      </div>
      <div class="multiple-values-container">
        <div class="multiple-values multiple-2">
          <span class="single-value">
            <label><?php 
        echo ewatcher_translate("Energy imported from the grid");
        ?>
</label>
            <span id="tLoadFromGrid"  class="ewatcher-red" data-feedid="<?php 
        echo $this->feeds['tLoadFromGrid']['id'];
        ?>
">
            </span>
            <span class="ewatcher-red">kWh</span>
          </span>
          <span class="single-value">
            <label><?php 
        echo ewatcher_translate("PV energy exported to the grid");
        ?>
</label>
            <span id="tPvToGrid"  class="ewatcher-yellow" data-feedid="<?php 
        echo $this->feeds['tPvToGrid']['id'];
        ?>
">
            </span>
            <span class="ewatcher-yellow">kWh</span>
          </span>
        </div>
      </div>
      <div class="multiple-values-container">
        <div class="multiple-values multiple-2">
          <span title="<?php 
        echo ewatcher_translate('Self-consumed energy relative to the total PV energy produced');
        ?>
" class="single-value">
            <label><?php 
        echo ewatcher_translate("Self-consumption");
        ?>
</label>
            <span id="selfConsumption" class="ewatcher-green"></span>
            <span class="ewatcher-green">%</span>
          </span>
          <span title="<?php 
        echo ewatcher_translate('Self-consumed energy relative to the total load');
        ?>
" class="single-value">
            <label><?php 
        echo ewatcher_translate("Self-sufficiency");
        ?>
</label>
            <span id="selfSufficiency" class="ewatcher-yellow"></span>
            <span class="ewatcher-yellow">%</span>
          </span>
        </div>
      </div>
      <hr>
      <div class="multiple-values-container">
        <div class="multiple-values multiple-2">
          <span class="single-value">
            <label><?php 
        echo ewatcher_translate("Cost of the imported energy");
        ?>
</label>
            <span id="cGrid" class="ewatcher-red"></span>
            <span class="cost-units ewatcher-red"><?php 
        echo $this->config->getUnits();
        ?>
</span>
          </span>
          <span class="single-value">
            <label><?php 
        echo ewatcher_translate("Cost of the exported PV energy");
        ?>
</label>
            <span id="cPvToGrid" class="ewatcher-yellow"></span>
            <span class="cost-units ewatcher-yellow"><?php 
        echo $this->config->getUnits();
        ?>
</span>
          </span>
        </div>
      </div>
      <div class="multiple-values-container">
        <div class="multiple-values multiple-2">
          <span class="single-value">
            <label><?php 
        echo ewatcher_translate("Cost without PV production");
        ?>
</label>
            <span id="cLoadNoPv" class="ewatcher-red"></span>
            <span class="cost-units ewatcher-red"><?php 
        echo $this->config->getUnits();
        ?>
</span>
          </span>
          <span class="single-value">
            <label><?php 
        echo ewatcher_translate("Cost with PV production");
        ?>
</label>
            <span id="cLoadPv" class="ewatcher-yellow"></span>
            <span class="cost-units ewatcher-yellow"><?php 
        echo $this->config->getUnits();
        ?>
</span>
          </span>
        </div>
        <div class="multiple-values-container">
          <div class="multiple-values multiple-1">
            <span class="single-value">
              <label><?php 
        echo ewatcher_translate("Estimated savings");
        ?>
</label>
              <span id="savings" class="ewatcher-green"></span>
              <span class="cost-units ewatcher-green"><?php 
        echo $this->config->getUnits();
        ?>
</span>
            </span>
          </div>
        </div>
      </div>
      <hr>
      <div class="daily-values several-values" id="table"></div>
      <script>
        $(window).ready(function() {
          // Configuration panel
          var config = new EWatcherConfigPanel("#ewatcher-config", "#cIn", "#cOut", "#units");
          // Date form
          $('#startDate').datetimepicker({ pickTime: false });
          $('#endDate').datetimepicker({ pickTime: false });
          // Units
          var costUnits = new DependentValue(".cost-units", "#units", function(values) {
            return values["#units"];
          });
          // Dependent values (get it from the tables)
          // The table has a final total row (may be hidden) with the sum of each column, and the id of each column total is #<table_id>_total_f<feedid>
          var tLoad = new DependentValue("#tLoad", "#table_total_f<?php 
        echo $this->feeds['eDLoad']['id'];
        ?>
", function(values) {
            return parseFloat(values["#table_total_f<?php 
        echo $this->feeds['eDLoad']['id'];
        ?>
"]);
          });
          var tPv = new DependentValue("#tPv", "#table_total_f<?php 
        echo $this->feeds['eDPv']['id'];
        ?>
", function(values) {
            return parseFloat(values["#table_total_f<?php 
        echo $this->feeds['eDPv']['id'];
        ?>
"]);
          });
          var tLoadFromGrid = new DependentValue("#tLoadFromGrid", "#table_total_f<?php 
        echo $this->feeds['eDGrid']['id'];
        ?>
", function(values) {
            return parseFloat(values["#table_total_f<?php 
        echo $this->feeds['eDGrid']['id'];
        ?>
"]);
          });
          // Dependent values from the total values
          var tPvToLoad = new DependentValue("#tPvToLoad", "#tLoad,#tLoadFromGrid", function(values) {
            var tLoad = parseFloat(values["#tLoad"]);
            var tLoadFromGrid = parseFloat(values["#tLoadFromGrid"]);
            return (Math.round((tLoad - tLoadFromGrid) * 100) / 100);
          });
          var tPvToGrid = new DependentValue("#tPvToGrid", "#tPv,#tPvToLoad", function(values) {
            var tPv = parseFloat(values["#tPv"]);
            var tPvToLoad = parseFloat(values["#tPvToLoad"]);
            return (Math.round((tPv - tPvToLoad) * 100) / 100);
          });
          // Dependent values
          var selfConsumption = new DependentValue("#selfConsumption", "#tPvToLoad,#tPv", function(values) {
            var tPvToLoad = parseFloat(values["#tPvToLoad"]);
            var tPv = parseFloat(values["#tPv"]);
            if(tPv == 0) {
              return 0;
            }
            return (Math.round(100 * 100 * tPvToLoad / tPv) / 100);
          });
          var selfSufficiency = new DependentValue("#selfSufficiency", "#tPvToLoad,#tLoad", function(values) {
            var tPvToLoad = parseFloat(values["#tPvToLoad"]);
            var tLoad = parseFloat(values["#tLoad"]);
            if(tLoad == 0) {
              return 0;
            }
            return (Math.round(100 * 100 * tPvToLoad / tLoad) / 100);
          });
          // Costs
          var cGrid = new DependentValue("#cGrid", "#cIn,#tLoadFromGrid", function(values) {
            var cIn = parseFloat(values["#cIn"]);
            var tLoadFromGrid = parseFloat(values["#tLoadFromGrid"]);
            return Math.round(cIn * tLoadFromGrid * 100) / 100;
          });
          var cPvToGrid = new DependentValue("#cPvToGrid", "#cOut,#tPvToGrid", function(values) {
            var cOut = parseFloat(values["#cOut"]);
            var tPvToGrid = parseFloat(values["#tPvToGrid"]);
            return Math.round(cOut * tPvToGrid * 100) / 100;
          });
          var cLoadNoPv = new DependentValue("#cLoadNoPv", "#cIn,#tLoad", function(values) {
            var cIn = parseFloat(values["#cIn"]);
            var tLoad = parseFloat(values["#tLoad"]);
            return Math.round(cIn * tLoad * 100) / 100;
          });
          var cLoadPv = new DependentValue("#cLoadPv", "#cGrid,#cPvToGrid", function(values) {
            var cGrid = parseFloat(values["#cGrid"]);
            var cPvToGrid = parseFloat(values["#cPvToGrid"]);
            return Math.round((cGrid - cPvToGrid) * 100) / 100;
          });
          var savings = new DependentValue("#savings", "#cLoadPv,#cLoadNoPv", function(values) {
            var cLoadPv = parseFloat(values["#cLoadPv"]);
            var cLoadNoPv = parseFloat(values["#cLoadNoPv"]);
            return Math.round((cLoadNoPv - cLoadPv) * 100) / 100;
          });
          // Table
          var dailyTable = new FeedDailyTable("#table", "#startDate", "#endDate", [
            {
              id: <?php 
        echo $this->feeds['eDLoad']['id'];
        ?>
,
              name: '<?php 
        echo ewatcher_translate("Consumption (kWh)");
        ?>
'
            },
            {
              id: <?php 
        echo $this->feeds['eDPv']['id'];
        ?>
,
              name: '<?php 
        echo ewatcher_translate("PV energy (kWh)");
        ?>
'
            },
            {
              id: <?php 
        echo $this->feeds['eDLoadFromPv']['id'];
        ?>
,
              name: '<?php 
        echo ewatcher_translate("PV self-consumed energy (kWh)");
        ?>
'
            },
            {
              id: <?php 
        echo $this->feeds['eDPvToGrid']['id'];
        ?>
,
              name: '<?php 
        echo ewatcher_translate("PV energy exported to the grid (kWh)");
        ?>
'
            },
            {
              id: <?php 
        echo $this->feeds['eDGrid']['id'];
        ?>
,
              name: '<?php 
        echo ewatcher_translate("PV energy imported from the grid (kWh)");
        ?>
'
            }
          ],
          {
            day: "<?php 
        echo ewatcher_translate('Day');
        ?>
",
            nodata: "<?php 
        echo ewatcher_translate('No data available at the selected date range');
        ?>
",
            exportcsv: "<?php 
        echo ewatcher_translate('Export to CSV');
        ?>
",
            total: ""
          });
        });
      </script>
      <?php 
    }
Example #3
0
<?php

// Global variables
global $session, $mysqli;
// Configuration model
require_once "Modules/ewatcher/EWatcherConfig_model.php";
$ewatcherconfig = new EWatcherConfig($mysqli, $session["userid"]);
// Translations
require_once "Modules/ewatcher/ewatcher_translations.php";
// Panels available
$dropdown = array();
for ($indexEWatcher = 1; $indexEWatcher <= $ewatcherconfig->numPanels; $indexEWatcher++) {
    $panel = "P" . $indexEWatcher;
    if ($ewatcherconfig->panels[$panel]) {
        $dropdown[] = array(ewatcher_translate($ewatcherconfig->panelsNames[$panel]), "ewatcher/" . $panel);
    }
}
// If no panel is active, hide menu
if (count($dropdown) > 0) {
    $menu_left[] = array("name" => "EWatcher", "path" => "", "session" => "write", "order" => 5, "dropdown" => $dropdown);
}
Example #4
0
    public function view()
    {
        parent::view();
        // Graphic: eDPvToGrid, eDLoadFromPv (last 7 days + interactivity), daily graph
        // Graphic: eDPvToGrid, eDGrid (last 7 days + interactivity), daily graph
        // Graphic: eDGrid, eDLoadFromPv (last 7 days + interactivity), daily graph
        // Graphic: eDLoad, eDPv, eDGrid (last 7 days + interactivity), daily graph
        ?>
      <div class="multigraphs">
        <div id="DailyGraph1"><label><?php 
        echo ewatcher_translate("PV energy generated");
        ?>
<label></div>
        <div id="DailyGraph2"><label><?php 
        echo ewatcher_translate("Energy exchanged with the grid");
        ?>
<label></div>
        <div id="DailyGraph3"><label><?php 
        echo ewatcher_translate("Source of the energy consumed");
        ?>
<label></div>
        <div id="DailyGraph4"><label><?php 
        echo ewatcher_translate("Global summary");
        ?>
<label></div>
      </div>
      <script>
        $(window).ready(function() {
          var dailyGraphs = [];
          // Graphic 1
          dailyGraphs.push([
            {
              id: <?php 
        echo $this->feeds['eDLoadFromPv']['id'];
        ?>
,
              color: "#20CA36",
              legend: "<?php 
        echo ewatcher_translate('PV energy self-consumed (kWh)');
        ?>
"
            },
            {
              id: <?php 
        echo $this->feeds['eDPvToGrid']['id'];
        ?>
,
              color: "#DCCC1F",
              legend: "<?php 
        echo ewatcher_translate('PV energy exported to the grid (kWh)');
        ?>
"
            }
          ]);
          // Graphic 2
          dailyGraphs.push([
            {
              id: <?php 
        echo $this->feeds['eDGrid']['id'];
        ?>
,
              color: "#D52E2E",
              legend: "<?php 
        echo ewatcher_translate('Energy imported from the grid (kWh)');
        ?>
"
            },
            {
              id: <?php 
        echo $this->feeds['eDPvToGrid']['id'];
        ?>
,
              color: "#DCCC1F",
              legend: "<?php 
        echo ewatcher_translate('PV energy exported to the grid (kWh)');
        ?>
"
            }
          ]);
          // Graphic 3
          dailyGraphs.push([
            {
              id: <?php 
        echo $this->feeds['eDGrid']['id'];
        ?>
,
              color: "#D52E2E",
              legend: "<?php 
        echo ewatcher_translate('Energy imported from the grid (kWh)');
        ?>
"
            },
            {
              id: <?php 
        echo $this->feeds['eDLoadFromPv']['id'];
        ?>
,
              color: "#20CA36",
              legend: "<?php 
        echo ewatcher_translate('PV energy self-consumed (kWh)');
        ?>
"
            }
          ]);
          // Graphic 4
          dailyGraphs.push([
            {
              id: <?php 
        echo $this->feeds['eDLoad']['id'];
        ?>
,
              color: "#0699FA",
              legend: "<?php 
        echo ewatcher_translate('Consumption (kWh)');
        ?>
"
            },
            {
              id: <?php 
        echo $this->feeds['eDPv']['id'];
        ?>
,
              color: "#DCCC1F",
              legend: "<?php 
        echo ewatcher_translate('PV energy produced (kWh)');
        ?>
"
            },
            {
              id: <?php 
        echo $this->feeds['eDGrid']['id'];
        ?>
,
              color: "#D52E2E",
              legend: "<?php 
        echo ewatcher_translate('Energy imported from the grid (kWh)');
        ?>
"
            }
          ]);
          // Load graphs
          for(var i = 1; i <= dailyGraphs.length; i++) {
            FeedChartFactory.create("DailyGraph" + i, dailyGraphs[i - 1], {chartType: "daily"});
          }
        });
      </script>
      <?php 
    }
Example #5
0
    public function view()
    {
        parent::view();
        // Value: sPLoad, sPPv, iGridToLoad, iPvToGrid (instant feeds)
        // Graphic: sPLoad, sPPv, iGridToLoad (continuous graph)
        // Value: eDPv, eDLoadFromPv, eDPvToGrid, eDGrid, eDLoad (instant feeds)
        // Value: dPLoadFromPv, dPSelf (intant feeds)
        ?>
    <div class="multiple-values-container">
      <div class="multiple-values multiple-3">
        <span class="single-value">
          <label><?php 
        echo ewatcher_translate("PV produced power");
        ?>
</label>
          <span id="sPPv" class="ewatcher-yellow instant-feed" data-feedid="<?php 
        echo $this->feeds['sPPv']['id'];
        ?>
">
            <?php 
        echo $this->feeds['sPPv']['value'];
        ?>
          </span>
          <span class="ewatcher-yellow">W</span>
        </span>
        <span class="single-value">
          <label><?php 
        echo ewatcher_translate("Consumption");
        ?>
</label>
          <span id="sPLoad" class="instant-feed" data-feedid="<?php 
        echo $this->feeds['sPLoad']['id'];
        ?>
">
            <?php 
        echo $this->feeds['sPLoad']['value'];
        ?>
          </span>
          <span>W</span>
        </span>
        <span class="single-value">
          <label><?php 
        echo ewatcher_translate("PV power exported to the grid");
        ?>
</label>
          <span id="iPvToGrid" class="ewatcher-green"></span>
          <span class="ewatcher-green">W</span>
        </span>
      </div>
    </div>
    <div class="multiple-values-container">
      <div class="multiple-values multiple-1">
        <span class="single-value">
          <label><?php 
        echo ewatcher_translate("Consumption from the grid");
        ?>
</label>
          <span id="iGridToLoad" class="ewatcher-red"></span>
          <span class="ewatcher-red">W</span>
        </span>
      </div>
    </div>
    <div class="multigraphs">
      <div id="P3Graph1"></div>
      <div id="P3Graph2"></div>
    </div>
    <div class="title-separator">
      <h3><?php 
        echo ewatcher_translate("Today's energy values");
        ?>
 - <?php 
        echo date("d/m/Y");
        ?>
</h3>
    </div>
    <div class="multiple-values-container">
      <div class="multiple-values multiple-2">
        <span class="single-value">
          <label><?php 
        echo ewatcher_translate("PV produced energy");
        ?>
</label>
          <span class="ewatcher-yellow instant-feed" data-feedid="<?php 
        echo $this->feeds['eDPv']['id'];
        ?>
">
            <?php 
        echo $this->feeds['eDPv']['value'];
        ?>
          </span>
          <span class="ewatcher-yellow">kWh</span>
        </span>
        <span class="single-value">
          <label><?php 
        echo ewatcher_translate("PV self-consumed energy");
        ?>
</label>
          <span class="ewatcher-yellow instant-feed" data-feedid="<?php 
        echo $this->feeds['eDLoadFromPv']['id'];
        ?>
">
            <?php 
        echo $this->feeds['eDLoadFromPv']['value'];
        ?>
          </span>
          <span class="ewatcher-yellow">kWh</span>
        </span>
      </div>
    </div>
    <div class="multiple-values-container">
      <div class="multiple-values multiple-3">
        <span class="single-value">
          <label><?php 
        echo ewatcher_translate("PV energy exported to the grid");
        ?>
</label>
          <span class="ewatcher-green instant-feed" data-feedid="<?php 
        echo $this->feeds['eDPvToGrid']['id'];
        ?>
">
            <?php 
        echo $this->feeds['eDPvToGrid']['value'];
        ?>
          </span>
          <span class="ewatcher-green">kWh</span>
        </span>
        <span class="single-value">
          <label><?php 
        echo ewatcher_translate("Energy imported from the grid");
        ?>
</label>
          <span class="ewatcher-red instant-feed" data-feedid="<?php 
        echo $this->feeds['eDGrid']['id'];
        ?>
">
            <?php 
        echo $this->feeds['eDGrid']['value'];
        ?>
          </span>
          <span class="ewatcher-red">kWh</span>
        </span>
        <span class="single-value">
          <label><?php 
        echo ewatcher_translate("Consumption");
        ?>
</label>
          <span class="instant-feed" data-feedid="<?php 
        echo $this->feeds['eDLoad']['id'];
        ?>
">
            <?php 
        echo $this->feeds['eDLoad']['value'];
        ?>
          </span>
          <span>kWh</span>
        </span>
      </div>
    </div>
    <div class="multiple-values-container">
      <div class="multiple-values multiple-2">
        <span title="<?php 
        echo ewatcher_translate('Self-consumed energy relative to the total load');
        ?>
" class="single-value">
          <label><?php 
        echo ewatcher_translate("Self-sufficiency");
        ?>
</label>
          <span class="ewatcher-yellow instant-feed" data-feedid="<?php 
        echo $this->feeds['dPLoadFromPv']['id'];
        ?>
">
            <?php 
        echo $this->feeds['dPLoadFromPv']['value'];
        ?>
          </span>
          <span class="ewatcher-yellow">%</span>
        </span>
        <span title="<?php 
        echo ewatcher_translate('Self-consumed energy relative to the total PV energy produced');
        ?>
" class="single-value">
          <label><?php 
        echo ewatcher_translate("Self-consumption");
        ?>
</label>
          <span class="ewatcher-green instant-feed" data-feedid="<?php 
        echo $this->feeds['dPSelf']['id'];
        ?>
">
            <?php 
        echo $this->feeds['dPSelf']['value'];
        ?>
          </span>
          <span class="ewatcher-green">%</span>
        </span>
      </div>
    </div>
    <script>
      $(window).ready(function() {
        // iGridToLoad value
        var iGridToLoad = new DependentValue("#iGridToLoad", "#sPPv,#sPLoad", function(values) {
          var sPPv = parseFloat(values["#sPPv"]);
          var sPLoad = parseFloat(values["#sPLoad"]);
          var res = sPLoad - sPPv;
          if(res < 0) {
            res = 0;
          }
          return Math.round(res * 100) / 100;
        });
        // iPvToGrid value
        var iPvToGrid = new DependentValue("#iPvToGrid", "#sPPv,#sPLoad", function(values) {
          var sPPv = parseFloat(values["#sPPv"]);
          var sPLoad = parseFloat(values["#sPLoad"]);
          var res = sPPv - sPLoad;
          if(res < 0) {
            res = 0;
          }
          return Math.round(res * 100) / 100;
        });
        // P3 Graph 1
        var P3Graph1 = [
          {
            id: <?php 
        echo $this->feeds['sPLoad']['id'];
        ?>
,
            color: "#0699FA",
            legend: "<?php 
        echo ewatcher_translate('Consumption (W)');
        ?>
",
            fill: 0,
            line: 1.5
          },
          {
            id: <?php 
        echo $this->feeds['sPPv']['id'];
        ?>
,
            color: "#DCCC1F",
            legend: "<?php 
        echo ewatcher_translate('PV produced power (W)');
        ?>
",
            fill: 0,
            line: 1.5
          }
        ];
        FeedChartFactory.create("P3Graph1", P3Graph1, {defaultRange: 1, steps: false});
        // P3 Graph 2
        var P3Graph2 = [
          ,
          {
            id: <?php 
        echo $this->feeds['iGridToLoad']['id'];
        ?>
,
            color: "#D52E2E",
            legend: "<?php 
        echo ewatcher_translate('Consumption from the grid (W)');
        ?>
",
            fill: 0,
            line: 1.5
          },
          {
            id: <?php 
        echo $this->feeds['iPvToGrid']['id'];
        ?>
,
            color: "#20CA36",
            legend: "<?php 
        echo ewatcher_translate('PV power exported to the grid (W)');
        ?>
",
            fill: 0,
            line: 1.5
          }
        ];
        FeedChartFactory.create("P3Graph2", P3Graph2, {defaultRange: 1, steps: false});
      });
    </script>
    <?php 
    }
Example #6
0
    public function view()
    {
        parent::view();
        // Value: sPLoad, sVoltage, eDLoad (intant feeds)
        // Graphic: sPLoad (last 7 values + interactivity), continuous graph
        // Graphic: eDLoad (last 7 values + interactivity), daily graph
        ?>
      <div class="multiple-values-container">
        <div class="multiple-values multiple-3">
          <span class="single-value">
            <label><?php 
        echo ewatcher_translate("Consumption");
        ?>
</label>
            <span class="instant-feed" data-feedid="<?php 
        echo $this->feeds['sPLoad']['id'];
        ?>
">
              <?php 
        echo $this->feeds['sPLoad']['value'];
        ?>
            </span>
            <span>W</span>
          </span>
          <span class="single-value">
            <label><?php 
        echo ewatcher_translate("Voltage");
        ?>
</label>
            <span class="instant-feed" data-feedid="<?php 
        echo $this->feeds['sVoltage']['id'];
        ?>
">
              <?php 
        echo $this->feeds['sVoltage']['value'];
        ?>
            </span>
            <span>V</span>
          </span>
          <span class="single-value">
            <label><?php 
        echo ewatcher_translate("Energy consumed today");
        ?>
</label>
            <span class="instant-feed" data-feedid="<?php 
        echo $this->feeds['eDLoad']['id'];
        ?>
">
              <?php 
        echo $this->feeds['eDLoad']['value'];
        ?>
            </span>
            <span>kWh</span>
          </span>
        </div>
      </div>
      <div id="sPLoad"></div>
      <div id="eDLoad"></div>
      <script>
        $(window).ready(function() {
          // sPLoad graphic
          var sPLoad = [
            {
              id: <?php 
        echo $this->feeds['sPLoad']['id'];
        ?>
,
              color: "#0699FA",
              legend: "<?php 
        echo ewatcher_translate('Consumption (W)');
        ?>
",
              fill: 0.7,
              line: 1
            }
          ];
          FeedChartFactory.create("sPLoad", sPLoad, {defaultRange: 1, steps: false});
          // eDLoad graphic
          var eDLoad = [
            {
              id: <?php 
        echo $this->feeds['eDLoad']['id'];
        ?>
,
              color: "#0699FA",
              legend: "<?php 
        echo ewatcher_translate('Daily energy consumption (kWh)');
        ?>
"
            }
          ];
          FeedChartFactory.create("eDLoad", eDLoad, {chartType: "daily"});
        });
      </script>
      <?php 
    }
Example #7
0
    public function view()
    {
        parent::view();
        // Form: two dates (default to one week)
        // Table: eDLoad daily between the dates (daily table)
        ?>
      <div class="multiple-values-container">
        <div class="formDates">
          <div class="dateInput">
            <label><?php 
        echo ewatcher_translate("Start date");
        ?>
</label>
            <div id="startDate" class="input-append date control-group">
              <input data-format="dd/MM/yyyy" value="<?php 
        echo date("d/m/Y", strtotime('-7 days'));
        ?>
" type="text" />
              <span class="add-on"> <i data-time-icon="icon-time" data-date-icon="icon-calendar"></i></span>
            </div>
          </div>
          <div class="dateInput">
            <label><?php 
        echo ewatcher_translate("End date");
        ?>
</label>
            <div id="endDate" class="input-append date control-group">
              <input data-format="dd/MM/yyyy" value="<?php 
        echo date("d/m/Y", strtotime('-1 days'));
        ?>
" type="text" />
              <span class="add-on"> <i data-time-icon="icon-time" data-date-icon="icon-calendar"></i></span>
            </div>
          </div>
        </div>
      </div>
      <hr>
      <div class="multiple-values-container">
        <div class="multiple-values multiple-1">
          <span class="single-value">
            <label><?php 
        echo ewatcher_translate("Energy consumption");
        ?>
</label>
            <span id="tLoad"></span>
            <span>kWh</span>
          </span>
        </div>
      </div>
      <div class="daily-values" id="eDLoad"></div>
      <script>
        $(window).ready(function () {
          $('#startDate').datetimepicker({ pickTime: false });
          $('#endDate').datetimepicker({ pickTime: false });
          var tLoad = new DependentValue("#tLoad", "#eDLoad_total_f<?php 
        echo $this->feeds['eDLoad']['id'];
        ?>
", function(values) {
            return parseFloat(values["#eDLoad_total_f<?php 
        echo $this->feeds['eDLoad']['id'];
        ?>
"]);
          });
          var dailyTable = new FeedDailyTable("#eDLoad", "#startDate", "#endDate", [
            {
              id: <?php 
        echo $this->feeds['eDLoad']['id'];
        ?>
,
              name: '<?php 
        echo ewatcher_translate("Daily energy consumption (kWh)");
        ?>
'
            }
          ],
          {
            day: "<?php 
        echo ewatcher_translate('Day');
        ?>
",
            nodata: "<?php 
        echo ewatcher_translate('No data available at the selected date range');
        ?>
",
            exportcsv: "<?php 
        echo ewatcher_translate('Export to CSV');
        ?>
",
            total: ""
          });
        });
      </script>
      <?php 
    }