Skip to content
This repository has been archived by the owner on Feb 23, 2022. It is now read-only.

Commit

Permalink
Merge pull request #105 from stawen/unstable
Browse files Browse the repository at this point in the history
add #85 Conso Eau chaude sanitaire
  • Loading branch information
stawen authored Dec 3, 2020
2 parents 320f360 + d5253c1 commit 39f0072
Show file tree
Hide file tree
Showing 13 changed files with 248 additions and 117 deletions.
12 changes: 10 additions & 2 deletions Todo.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## FixTo
* Afficher les fixto à venir dans la version courante
Terminated
----------
(x) Ajouter colonne dans conso_by_day
(x) Ajouter le calcul dans le calcul de la synthese journaliere
(x) Ajouter dans la synthese saison
(x) Ajout dans le tableau de synthese saison
(x) Ajout dans le graphe de synthese saison
(x) Indiquer dans le change log de forcer le recalcul des syntheses pour faire apparaitre la valeur

In progress
-----------
6 changes: 4 additions & 2 deletions _include/okofen.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,19 +310,21 @@ private function isSyntheseDone($day)

private function insertSyntheseDay($day)
{
$query = 'INSERT INTO oko_resume_day ( jour, tc_ext_max, tc_ext_min, conso_kg, dju, nb_cycle ) VALUE ';
$query = 'INSERT INTO oko_resume_day ( jour, tc_ext_max, tc_ext_min, conso_kg, conso_ecs_kg, dju, nb_cycle ) VALUE ';

$rendu = new rendu();
$max = $rendu->getTcMaxByDay($day);
$min = $rendu->getTcMinByDay($day);
$conso = $rendu->getConsoByday($day);
$conso_ecs = $rendu->getConsoByday($day, null, null, 'hotwater');
$dju = $rendu->getDju($max->tcExtMax, $min->tcExtMin);
$cycle = $rendu->getNbCycleByDay($day);

$consoPellet = (null == $conso->consoPellet) ? 0 : $conso->consoPellet;
$consoEcsPellet = (null == $conso_ecs->consoPellet) ? 0 : $conso_ecs->consoPellet;
$nbCycle = (null == $cycle->nbCycle) ? 0 : $cycle->nbCycle;

$query .= "('".$day."', ".$max->tcExtMax.','.$min->tcExtMin.', '.$consoPellet.', '.$dju.', '.$nbCycle.' );';
$query .= "('".$day."', ".$max->tcExtMax.', '.$min->tcExtMin.', '.$consoPellet.', '.$consoEcsPellet.', '.$dju.', '.$nbCycle.' );';

$this->log->debug('Class '.__CLASS__.' | '.__FUNCTION__.' | '.$query);

Expand Down
61 changes: 48 additions & 13 deletions _include/rendu.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,37 @@ public function getIndicByDay($jour, $timeStart = null, $timeEnd = null)
}

$c = $this->getConsoByday($jour, $timeStart, $timeEnd);
$c_ecs = $this->getConsoByday($jour, $timeStart, $timeEnd, 'hotwater');
$min = $this->getTcMinByDay($jour, $timeStart, $timeEnd);
$max = $this->getTcMaxByDay($jour, $timeStart, $timeEnd);

$this->sendResponse(
json_encode(
['consoPellet' => $c->consoPellet,
'tcExtMax' => $max->tcExtMax,
'tcExtMin' => $min->tcExtMin,
],
JSON_NUMERIC_CHECK
)
[
'consoPellet' => $c->consoPellet,
'consoPelletHotwater' => $c_ecs->consoPellet,
'tcExtMax' => $max->tcExtMax,
'tcExtMin' => $min->tcExtMin,
],
JSON_NUMERIC_CHECK
)
);
}

public function getConsoByday($jour, $timeStart = null, $timeEnd = null)
/**
* function getConsoByDay
* Get pellet consomation.
*
* @default : all type of consommation
* $type :
*
* @param mixed $jour
* @param null|mixed $timeStart
* @param null|mixed $timeEnd
* @param mixed $type
* Specify type of consommation : default all, or heater (Chauffage) or hotwater (ECS)
*/
public function getConsoByday($jour, $timeStart = null, $timeEnd = null, $type = null)
{
$coeff = POIDS_PELLET_PAR_MINUTE / 1000;
$c = new capteur();
Expand All @@ -101,9 +117,16 @@ public function getConsoByday($jour, $timeStart = null, $timeEnd = null)
if (null != $timeStart && null != $timeEnd) {
$intervalle = 'AND timestamp BETWEEN '.$timeStart.' AND '.$timeEnd;
}
//make filter for calculate heater, hotwater or both,
$usage = '';
if ('hotwater' == $type) { //just first circuit for now
$capteur_ecs = $c->getByType('hotwater[0]');
$usage = ' AND a.col_'.$capteur_ecs['column_oko'].' = 1';
}

// Rejouter le filtre ECS dans la requette
$q = 'select round (sum((1/(a.col_'.$capteur_vis['column_oko'].' + a.col_'.$capteur_vis_pause['column_oko'].')) * a.col_'.$capteur_vis['column_oko'].')*('.$coeff.'),2) as consoPellet from oko_historique_full as a '
."WHERE a.jour = '".$jour."' ".$intervalle;
."WHERE a.jour = '".$jour."' ".$usage.' '.$intervalle;

$this->log->debug('Class '.__CLASS__.' | '.__FUNCTION__.' | '.$q);

Expand All @@ -112,6 +135,13 @@ public function getConsoByday($jour, $timeStart = null, $timeEnd = null)
return $result->fetch_object();
}

/**
* Get maximum Temperature in a specifique day, and in an intervalle.
*
* @param mixed $jour
* @param null|mixed $timeStart
* @param null|mixed $timeEnd
*/
public function getTcMaxByDay($jour, $timeStart = null, $timeEnd = null)
{
$c = new capteur();
Expand Down Expand Up @@ -183,7 +213,7 @@ public function getNbCycleByDay($jour)
public function getIndicByMonth($month, $year)
{
$q = 'SELECT max(Tc_ext_max) as tcExtMax, min(Tc_ext_min) as tcExtMin, '.
'sum(conso_kg) as consoPellet, sum(dju) as dju, sum(nb_cycle) as nbCycle '.
'sum(conso_kg) as consoPellet, sum(conso_ecs_kg) as consoEcsPellet, sum(dju) as dju, sum(nb_cycle) as nbCycle '.
'FROM oko_resume_day '.
'WHERE MONTH(oko_resume_day.jour) = '.$month.' AND '.
'YEAR(oko_resume_day.jour) = '.$year;
Expand All @@ -196,6 +226,7 @@ public function getIndicByMonth($month, $year)
$this->sendResponse(json_encode(['tcExtMax' => $r->tcExtMax,
'tcExtMin' => $r->tcExtMin,
'consoPellet' => $r->consoPellet,
'consoEcsPellet' => $r->consoEcsPellet,
'dju' => $r->dju,
'nbCycle' => $r->nbCycle,
], JSON_NUMERIC_CHECK));
Expand Down Expand Up @@ -347,9 +378,9 @@ public function getAshtrayStatus()
if ($remain <= 0) {
$this->sendResponse(
json_encode(
['emptying_ashtrey' => true,
]
)
['emptying_ashtrey' => true,
]
)
);
}
}
Expand All @@ -359,6 +390,7 @@ public function getHistoByMonth($month, $year)
$categorie = [session::getInstance()->getLabel('lang.text.graphe.label.tcmax') => 'tc_ext_max',
session::getInstance()->getLabel('lang.text.graphe.label.tcmin') => 'tc_ext_min',
session::getInstance()->getLabel('lang.text.graphe.label.conso') => 'conso_kg',
// session::getInstance()->getLabel('lang.text.graphe.label.conso.ecs') => 'conso_ecs_kg',
session::getInstance()->getLabel('lang.text.graphe.label.dju') => 'dju',
session::getInstance()->getLabel('lang.text.graphe.label.nbcycle') => 'nb_cycle',
];
Expand Down Expand Up @@ -397,7 +429,7 @@ public function getHistoByMonth($month, $year)
public function getTotalSaison($idSaison)
{
$q = 'SELECT max(Tc_ext_max) as tcExtMax, min(Tc_ext_min) as tcExtMin, '.
'sum(conso_kg) as consoPellet, sum(dju) as dju, sum(nb_cycle) as nbCycle '.
'sum(conso_kg) as consoPellet, sum(conso_ecs_kg) as consoEcsPellet, sum(dju) as dju, sum(nb_cycle) as nbCycle '.
'FROM oko_resume_day, oko_saisons '.
'WHERE oko_saisons.id = '.$idSaison.' '.
'AND oko_resume_day.jour BETWEEN oko_saisons.date_debut AND oko_saisons.date_fin ;';
Expand All @@ -410,6 +442,7 @@ public function getTotalSaison($idSaison)
$this->sendResponse(json_encode(['tcExtMax' => $r->tcExtMax,
'tcExtMin' => $r->tcExtMin,
'consoPellet' => $r->consoPellet,
'consoEcsPellet' => $r->consoEcsPellet,
'dju' => $r->dju,
'nbCycle' => $r->nbCycle,
], JSON_NUMERIC_CHECK));
Expand All @@ -422,6 +455,7 @@ public function getSyntheseSaison($idSaison)
session::getInstance()->getLabel('lang.text.graphe.label.conso') => 'sum(conso_kg)',
session::getInstance()->getLabel('lang.text.graphe.label.dju') => 'sum(dju)',
session::getInstance()->getLabel('lang.text.graphe.label.nbcycle') => 'sum(nb_cycle)',
session::getInstance()->getLabel('lang.text.graphe.label.conso.ecs') => 'sum(conso_ecs_kg)',
];

$where = ", DATE_FORMAT(oko_dateref.jour,'%Y-%m-01 00:00:00') FROM oko_saisons, oko_resume_day ".
Expand Down Expand Up @@ -461,6 +495,7 @@ public function getSyntheseSaisonTable($idSaison)
$q = "select DATE_FORMAT(oko_dateref.jour,'%m-%Y') as mois, ".
"IFNULL(sum(oko_resume_day.nb_cycle),'-') as nbCycle, ".
"IFNULL(sum(oko_resume_day.conso_kg),'-') as conso, ".
"IFNULL(sum(oko_resume_day.conso_ecs_kg),'-') as conso_ecs, ".
"IFNULL(sum(oko_resume_day.dju),'-') as dju, ".
'IFNULL(round( ((sum(oko_resume_day.conso_kg) * 1000) / sum(oko_resume_day.dju) / '.SURFACE_HOUSE."),2),'-') as g_dju_m ".
'FROM oko_saisons, oko_resume_day '.
Expand Down
2 changes: 1 addition & 1 deletion _include/version.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.8.5
1.9.0
4 changes: 2 additions & 2 deletions _langs/fr.matrice.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
},
"WW1 Pumpe": {
"name": "Circulateur ECS",
"type": "",
"type": "hotwater[0]",
"boiler": "CAPPL:LOCAL.L_ww[0].pumpe"
},
"WW2 EinT Ist[°C]": {
Expand All @@ -121,7 +121,7 @@
},
"WW2 Pumpe": {
"name": "ECS 2 - Circulateur ECS",
"type": "",
"type": "hotwater[1]",
"boiler": "CAPPL:LOCAL.L_ww[1].pumpe"
},
"Zubrp1 Pumpe": {
Expand Down
2 changes: 2 additions & 0 deletions _langs/fr.text.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@
"lang.text.page.import.table.title": "Fichiers dans _tmp/ pouvant être importés",

"lang.text.page.label.conso": "Conso :",
"lang.text.page.label.conso.ecs": "dont ECS :",
"lang.text.page.label.tcmax": "T°C Max (ext) :",
"lang.text.page.label.tcmoy": "T°C Moy (ext) :",
"lang.text.page.label.tcmin": "T°C Min (ext) :",
Expand Down Expand Up @@ -156,6 +157,7 @@
"lang.text.graphe.label.tcmax": "T°C Extérieure (Max)",
"lang.text.graphe.label.tcmin": "T°C Extérieure (Min)",
"lang.text.graphe.label.conso": "Pellets (Kg)",
"lang.text.graphe.label.conso.ecs": "ECS (Kg)",
"lang.text.graphe.label.dju": "DJU",
"lang.text.graphe.label.nbcycle": "NB Cycles",

Expand Down
18 changes: 18 additions & 0 deletions _upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,24 @@

// ici le code pour un upgrade

$q = "UPDATE oko_capteur set type='hotwater[0]' where original_name = 'WW1 Pumpe'";
$this->log->info("UPGRADE | {$version} | Add type (hotwater[0]) into oko_capteur");
if (!$this->query($q)) {
$this->log->info("UPGRADE | {$version} | Failed | ".$q);
}

$q = "UPDATE oko_capteur set type='hotwater[1]' where original_name = 'WW2 Pumpe'";
$this->log->info("UPGRADE | {$version} | Add type (hotwater[1]) into oko_capteur");
if (!$this->query($q)) {
$this->log->info("UPGRADE | {$version} | Failed | ".$q);
}

$q = 'ALTER TABLE oko_resume_day ADD conso_ecs_kg DECIMAL(6,2);';
$this->log->info("UPGRADE | {$version} | Add column conso_ecs_kg into oko_resume_day");
if (!$this->query($q)) {
$this->log->info("UPGRADE | {$version} | Failed | ".$q);
}

$this->log->info("UPGRADE | {$version} | end :".$t->getTime());

?>
11 changes: 5 additions & 6 deletions ajax.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<?php
/*
* Projet : Okovision - Supervision chaudiere OeKofen
* Auteur : Stawen Dronek
* Utilisation commerciale interdite sans mon accord
*/

/**
* Projet : Okovision - Supervision chaudiere OeKofen
* Auteur : Stawen Dronek
* Utilisation commerciale interdite sans mon accord.
*/
include_once 'config.php';

function is_ajax()
Expand Down
Loading

0 comments on commit 39f0072

Please sign in to comment.