Skip to content

Commit

Permalink
Raw power #118
Browse files Browse the repository at this point in the history
  • Loading branch information
smariel committed Oct 24, 2021
1 parent 87af3d1 commit f9939d5
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 5 deletions.
8 changes: 7 additions & 1 deletion html/itemEditor.html
Original file line number Diff line number Diff line change
Expand Up @@ -282,11 +282,13 @@ <h3>Characteristics</h3>
<div class="col-xs-12">
<label for="load_type">Load current</label>
<select id="load_type" data-itemdata="loadtype" class="form-control item-control" data-toggle="tooltip" data-placement="bottom" title="Current definition">
<option value="1">Raw</option>
<option value="1">Raw current</option>
<option value="3">Raw power</option>
<option value="0">In PTree partlist</option>
<option value="2">In external spreadsheet</option>
</select>
<p class="loadtype loadtype1">The current is defined here. Enter raw values in Amperes.</p>
<p class="loadtype loadtype3">The power is defined here. Enter raw values in Watts.</p>
<p class="loadtype loadtype0">The current is determined by the components of the part list. Nothing to do here. Open the part list.</p>
<p class="loadtype loadtype2">The current is defined in the synchronized spreadsheet. Enter the coordinates of the cells.</p>
</div>
Expand All @@ -299,6 +301,10 @@ <h3>Characteristics</h3>
<div class="col-xs-6"><label for="load_celltyp">I<sub>TYP</sub> (cell)</label><br /><input id="load_celltyp" data-itemdata="celltyp" class="col-xs-6 form-control input_cell" type="text" placeholder="A1" /></div>
<div class="col-xs-6"><label for="load_cellmax">I<sub>MAX</sub> (cell)</label><br /><input id="load_cellmax" data-itemdata="cellmax" class="col-xs-6 form-control input_cell" type="text" placeholder="B1" /></div>
</div>
<div class="form-group row loadtype loadtype3">
<div class="col-xs-6"><label for="load_ptyp">P<sub>TYP</sub> (W)</label><br /><input id="load_ptyp" data-itemdata="ptyp" class="col-xs-6 form-control input_num" type="text" /></div>
<div class="col-xs-6"><label for="load_pmax">P<sub>MAX</sub> (W)</label><br /><input id="load_pmax" data-itemdata="pmax" class="col-xs-6 form-control input_num" type="text" /></div>
</div>
</div>
</form>

Expand Down
39 changes: 35 additions & 4 deletions js/class.Item.Load.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,15 @@ class Load extends Item {
0: partlist
1: raw
2: sync (associated with celltyp and cellmax)
3: raw power (v2.1.0)
*/
celltyp : 'A1',
cellmax : 'B1',
hidden : false,
shape : 1, // v1.7.0
badge_in : '', // v1.7.0
ptyp : 0, // v2.1.0
pmax : 0, // v2.1.0
};
}

Expand Down Expand Up @@ -62,6 +65,12 @@ class Load extends Item {
}


// Check if the item is a load with the power defined as raw data
isRawPower() {
return ('3' == this.characs.loadtype);
}


// getInputVoltage() from the parent class


Expand All @@ -73,7 +82,18 @@ class Load extends Item {

// get the input current of an item
getInputCurrent(valType) {
return parseFloat(this.characs['i' + valType]);
let i_in = 0;

// if the load is a raw power value, i_in = p / v_in
if(this.isRawPower()) {
i_in = this.getInputPower(valType) / this.getInputVoltage(valType);
}
// for all other loads, return the user value
else {
i_in = parseFloat(this.characs['i' + valType]);
}

return i_in;
}


Expand All @@ -85,8 +105,18 @@ class Load extends Item {

// get the input power of an item
getInputPower(valType) {
// p_in = v_in_typ * i_in
return this.getInputVoltage('typ') * this.getInputCurrent(valType);
let p_in = 0;

// if the load is a raw power value, return the user value
if(this.isRawPower()) {
p_in = parseFloat(this.characs['p' + valType]);
}
// for all other loads, p_in = v_in * i_in
else {
p_in = this.getInputVoltage('typ') * this.getInputCurrent(valType);
}

return p_in;
}


Expand All @@ -104,9 +134,10 @@ class Load extends Item {

// get the reg or load type
getType() {
if (this.isRaw()) return 'Raw data';
if (this.isRaw()) return 'Raw current';
else if(this.isInPartlist()) return 'PTree partlist';
else if(this.isSynced()) return 'External spreadsheet';
else if(this.isRawPower()) return 'Raw power';
else return 'Other';
}

Expand Down

0 comments on commit f9939d5

Please sign in to comment.