Skip to content

Commit

Permalink
total load power summary
Browse files Browse the repository at this point in the history
  • Loading branch information
smariel committed Mar 25, 2023
1 parent cd982bf commit dd806cc
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
6 changes: 6 additions & 0 deletions html/PTree.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@
<td class="totalcell totalpower max">0</td>
<td class="totalcell">W</td>
</tr>
<tr>
<td class="totalcell">Load Power</td>
<td class="totalcell loadpower typ">0</td>
<td class="totalcell loadpower max">0</td>
<td class="totalcell">W</td>
</tr>
<tr>
<td class="totalcell">Total Loss</td>
<td class="totalcell totalloss typ">0</td>
Expand Down
8 changes: 7 additions & 1 deletion js/class.Canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -583,16 +583,22 @@ class Canvas {
$('.totalpower.typ').text(Util.numberToSi(totalpower.typ,3));
$('.totalpower.max').text(Util.numberToSi(totalpower.max,3));

// refresh the load power
const loadpower = this.tree.getLoadPower();
$('.loadpower.typ').text(Util.numberToSi(loadpower.typ,3));
$('.loadpower.max').text(Util.numberToSi(loadpower.max,3));

// refresh the total losses
const loss = this.tree.getTotalLoss();
$('.totalloss.typ').text(Util.numberToSi(loss.typ,3));
$('.totalloss.max').text(Util.numberToSi(loss.max,3));


// refresh the total efficiency
const efficiency = this.tree.getTotalEfficiency();
$('.totaleff.typ').text(Util.numberToSi(efficiency.typ,3));
$('.totaleff.max').text(Util.numberToSi(efficiency.max,3));


/*
// refresh the total losses
const dcdcloss = this.tree.getTotalDCDCloss();
Expand Down
17 changes: 14 additions & 3 deletions js/class.Tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,18 +162,26 @@ class Tree {
else return totalpower[typmax];
}


// get the total efficiency = load_power / total_power
getTotalEfficiency(typmax='both') {
// return the power of all load
getLoadPower(typmax='both') {
// get the total usefull power
let loadpower = {typ:0, max:0};
this.forEachLoad((load) => {
loadpower.typ += load.getInputPower('typ');
loadpower.max += load.getInputPower('max');
});

// return the typ or max or both
if('both' === typmax) return loadpower;
else return loadpower[typmax];
}


// get the total efficiency = load_power / total_power
getTotalEfficiency(typmax='both') {
// refresh the total efficiency
let totalpower = this.getTotalPower();
let loadpower = this.getLoadPower();
const efficiency = {
typ: (0 == totalpower.typ) ? 100 : (loadpower.typ / totalpower.typ) * 100,
max: (0 == totalpower.max) ? 100 : (loadpower.max / totalpower.max) * 100
Expand All @@ -185,6 +193,9 @@ class Tree {
}





// return the loss of all DCDC
getTotalDCDCloss(typmax='both') {
let totalloss = {typ:0, max:0};
Expand Down

0 comments on commit dd806cc

Please sign in to comment.