Closed solderq35 closed 7 months ago
If we end up manually recalculating the total real and reactive power, we can probably do it in chart.module.js: https://github.com/OSU-Sustainability-Office/energy-dashboard/blob/master/src/store/chart.module.js#L47
Check Reqpayload.point, then make 3? calls to metergroup with different point
values (phase A / B / C), then set to positive and sum up.
Also need to remember to ask if all values are meant to be positive. Voltage, apparent power, etc.
edit- also need to do this for download_data.vue probably
There are at least 2 places in the frontend src/store
where the Energy Dashboard tries to flip values to positive sign.
accumulated_real.js (known about):
accumulator
variable. Absolute value means both positive and negative input > positive output. So the accumulator (net energy) always grows in a positive directionmeter_group.module.js (new find)
negate
column in the meters
table in SQL database)meter.negate
in for (let meter of store.getters.meters) {...
in the file linked above, Nash hall's 1500 amp meter (meter ID 31) is set to true
for negate
column, on the default meter group ("Nash Electric"). But once you change meter group to "Nash 1500 Amp", the negate
value becomes false
.
negate
value as true after switching measurements to real power. Possibly because the meter group is not switched? Unclear.It should also be noted that Dixon's meter groups consist of one meter group with one electric meter in it, and another meter group with one steam meter in it. Only the default measurements (accumulated_real aka net energy for Electricity) support multiple meters in the same meter group, as explained here: https://github.com/OSU-Sustainability-Office/energy-dashboard/blob/master/src/store/meter_group.module.js#L94
negate
flag set properly in src/store/meter_group.module.js
, but the accumulated real (net power) is still set to positive due to an override in src/store/chart_modifiers/line_bar/accumulated_real.js
select * from data where meter_id = 31 order by time DESC;
with what's shown on the frontend at https://dashboard.sustainability.oregonstate.edu/#/building/28/2
src/store/meter_group.module.js
,(making the additional override in src/store/chart_modifiers/line_bar/accumulated_real.js
redundant). However, initially positive values for building like Dixon are flipped to negative by src/store/meter_group.module.js
, and this is not reversedselect * from data where meter_id = 5 order by time DESC;
with what's shown on the frontend at https://dashboard.sustainability.oregonstate.edu/#/building/10/2It's also still unclear to me which values (if any) should ever show a positive value
src\store\chart_modifiers\line_bar\base.js
negate
from meters table, and operation
from meter_group_relation (only from the energy dashboard codebase)negate
and operation
- Python / regex script I used for removing them from the backend test SQL queries:backend\tests\assertedData\meter_group_relation_insert.sql
):INSERT INTO `` (`id`,`meter_id`,`operation`,`group_id`) VALUES (160,8,9,1);
INSERT INTO `` (`id`,`meter_id`,operation`,`group_id`) VALUES (161,9,9,1);
INSERT INTO `` (`id`,`meter_id`,operation`,`group_id`) VALUES (166,40,11,1);
Remove operation
(or whichever variable) with just "find and replace" in text editor / vscode.
For VALUES (166,40,11,1);
, you can use script (tested on python 3.8.0)
import re
# replace line below to match input file name in directory
input_file_path = 'meter_group_relation_insert.sql'
output_file_path = 'modified_' + input_file_path
# originally 5 items in parentheses, remove 4th item
# regex_pattern = r'\(([^,]+),([^,]+),([^,]+),[^,]+,([^,]+)\);'
# originally 4 items in parentheses, remove 4th item
regex_pattern = r'\(([^,]+),([^,]+),([^,]+),[^,]+\);'
with open(input_file_path, 'r') as input_file, open(output_file_path, 'w') as output_file:
for line in input_file:
# originally 5 items in parentheses, remove 4th item
# modified_line = re.sub(regex_pattern, r'(\1,\2,\3,\4);', line)
# originally 4 items in parentheses, remove 4th item
modified_line = re.sub(regex_pattern, r'(\1,\2,\3);', line)
output_file.write(modified_line)
print('output saved to: ' + output_file_path)
negate
from meters table, and operation
from meter_group_relation columns can be deleted from SQL databaseSince the only changes here are either changes to frontend (VueX store), or GET requests on the backend, I think it is safe to review and merge this PR (if there are no obvious issues), and if anything needs to be changed later we can open a new PR.
operation
and negate
columns from meter_group_relation
and meter
SQL tables respectively
Fixes https://github.com/OSU-Sustainability-Office/energy-dashboard/issues/280
Findings
Conclusion
Other
The changes to
backend\dependencies\nodejs\models\meter.js
are in a GET endpoint, which will affect for example https://api.sustainability.oregonstate.edu/v2/energy/allbuildings (replacehttps://api.sustainability.oregonstate.edu
withhttp://localhost:3000
if testing locally). Therefore, there should not be any worries about overwriting old data etc.