Skip to content

Commit

Permalink
Merge pull request SoftwareDefinedBuildings#34 from rajasriramoju/rev…
Browse files Browse the repository at this point in the history
…ert-33-revert-32-20-update-dashboard-with-graphs

Revert "Revert "Graphs on dashboard - Total and HVAC comparison""
  • Loading branch information
rajasriramoju authored May 22, 2019
2 parents 837dfe6 + 9de8848 commit 7b0a420
Show file tree
Hide file tree
Showing 12 changed files with 150,807 additions and 124 deletions.
24,049 changes: 24,049 additions & 0 deletions dashboards/solarplus-ui/Historic_microgrid_data/1_week_raw_PV.csv

Large diffs are not rendered by default.

9,326 changes: 9,326 additions & 0 deletions dashboards/solarplus-ui/Historic_microgrid_data/AirTemperatureData.csv

Large diffs are not rendered by default.

28,226 changes: 28,226 additions & 0 deletions dashboards/solarplus-ui/Historic_microgrid_data/ArrayPlaneIrradianceData.csv

Large diffs are not rendered by default.

28,226 changes: 28,226 additions & 0 deletions dashboards/solarplus-ui/Historic_microgrid_data/BatteryPowerData.csv

Large diffs are not rendered by default.

28,226 changes: 28,226 additions & 0 deletions dashboards/solarplus-ui/Historic_microgrid_data/BatterySOCData.csv

Large diffs are not rendered by default.

3,938 changes: 3,938 additions & 0 deletions dashboards/solarplus-ui/Historic_microgrid_data/PVPowerGenData.csv

Large diffs are not rendered by default.

28,226 changes: 28,226 additions & 0 deletions dashboards/solarplus-ui/Historic_microgrid_data/RelativeHumidityData.csv

Large diffs are not rendered by default.

Binary file modified dashboards/solarplus-ui/__pycache__/app.cpython-37.pyc
Binary file not shown.
71 changes: 43 additions & 28 deletions dashboards/solarplus-ui/app.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
from flask import Flask, request, send_from_directory, json
def application(environ, start_response):
if environ['REQUEST_METHOD'] == 'OPTIONS':
start_response(
'200 OK',
[
('Content-Type', 'application/json'),
('Access-Control-Allow-Origin', '*'),
('Access-Control-Allow-Credentials', 'true'),
('Access-Control-Allow-Headers', 'Authorization, Content-Type'),
('Access-Control-Allow-Methods', 'POST'),
]
)
return ''

from flask import Flask, request, send_from_directory
import config
from flask import make_response, request, current_app
from flask import jsonify, redirect, url_for
Expand Down Expand Up @@ -284,6 +298,7 @@ def aws():

# Flask boilerplate,
# configure CORS to make HTTP requests from javascript

def crossdomain(origin=None, methods=None, headers=None,
max_age=21600, attach_to_all=True,
automatic_options=True):
Expand Down Expand Up @@ -406,41 +421,41 @@ def extractData_plotTwoQueries(filename, startDate, endDate, feature1, feature2)
dataInRange = dataInRange.loc[:,['Time', feature1, feature2]]

return dataInRange.to_json(orient = 'records')

'''
# This function takes in a file name, start and end date and returns json response
@app.route('/<filename>/<startDate>/<endDate>')

# This function extracts data for any feature's data from Control.csv data
# of the solarplus sample data -> will be used for total power consumption
# values for dashboard
@app.route('/dashboard/access/<feature1>')
@crossdomain(origin="*")
def extractData_anyFile(filename, startDate, endDate):
filePathString = "./solarplus_sample_data/" + filename + ".csv"
print(filePathString)
def extractData_oneFeature_Control2(feature1):
filePathString = "./solarplus_sample_data/Control2.csv"
readDF = pd.read_csv(filePathString)

# check for validity of range of dates
startYear,startMonth,startDay=[int(x) for x in startDate.split('-')]
endYear,endMonth,endDay=[int(x) for x in endDate.split('-')]
df = readDF.loc[:,['Time',feature1]]
return df.to_json(orient = 'records')

if(datetime.datetime(startYear,startMonth,startDay) > datetime.datetime(endYear,endMonth,endDay)):
print ('Wrong range of dates given. Start Date = ' ,startDate, "; End Date = ", endDate)
return 'Incorrect Range of dates'
# This function extracts data for any 2 features' data from Control.csv data
# of the solarplus sample data -> will be used for HVAC1 and HVAC2
# values for dashboard
@app.route('/dashboard/access/<feature1>/<feature2>')
@crossdomain(origin="*")
def extractData_twoFeatures_Control2(feature1, feature2):
filePathString = "./solarplus_sample_data/Control2.csv"
readDF = pd.read_csv(filePathString)

# This gets all the entries of the specific start date and end date
startDateEntries = readDF[readDF['Time'].str.contains(startDate)]
endDateEntries = readDF[readDF['Time'].str.contains(endDate)]
df = readDF.loc[:,['Time',feature1,feature2]]
return df.to_json(orient = 'records')

# finding the first index of start date entries and last index of the end date entries
# so that we can get the range of indices for the data in the specified timeframe
startDateIndex = startDateEntries.index[0]
endDateIndex = endDateEntries.index[-1]
# This function extracts data for solar production values from
@app.route('/dashboard/PVPowerGenData')
@crossdomain(origin="*")
def extractData_PVPowerGenData():
filePathString = "./Historic_microgrid_data/PVPowerGenData.csv"
readDF = pd.read_csv(filePathString)

#fetching data in the specific timeframe
dataInRange = readDF[startDateIndex:(endDateIndex+1)]
df = readDF.loc[:,['Date_PT','PVPower_kW']]
return df.to_json(orient = 'records')

return dataInRange.to_json(orient = 'records')
'''

if __name__ == '__main__':
app.run(host='0.0.0.0', debug=True)
Expand Down
48 changes: 1 addition & 47 deletions dashboards/solarplus-ui/static/assets/js/DR/chart-highchart.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ $(document).ready(function () {
var highChart = new Highcharts.chart('myChart', {
chart: {
//renderTo: "myChart",
type: 'line',
type: 'bar',
zoomType: "x"
},
title: {
Expand Down Expand Up @@ -50,52 +50,6 @@ $(document).ready(function () {
return Httpreq.responseText;
}

// $("#renderBtn-highchart").click(
// function () {
// var startDate = document.getElementById("Date1").value;
// var endDate = document.getElementById("Date2").value;

// var filename = document.getElementById("filename").value;
// var feature1 = document.getElementById("feature1").value;
// var feature2 = document.getElementById("feature2").value;

// console.log(startDate);
// console.log(endDate);
// console.log(filename);
// console.log(feature1);
// console.log(feature2);

// const uri = `http://localhost:5000/${filename}/${startDate}/${endDate}/${feature1}/${feature2}`;
// var res = JSON.parse(Get(uri)); //"http://localhost:5000/cieeData/2018-01-04/2018-01-05"));
// console.log(res);

// var feature1Vals = [];
// var feature2Vals = []
// var labels = [];


// for(let i = 0; i < 500; i++){

// let singleElement = res[i];

// for(let prop in singleElement){
// if(prop == feature1)
// feature1Vals.push(singleElement[prop]);
// if(prop == feature2)
// feature2Vals.push(singleElement[prop]);
// }
// labels.push(res[i].Time);

// }

// console.log(labels);
// console.log(feature1Vals);
// console.log(feature2Vals)
// renderChart(feature1, feature2, feature1Vals, feature2Vals, labels);

// }
// );

function render() {
var startDate = document.getElementById("Date1").value;
var endDate = document.getElementById("Date2").value;
Expand Down
Loading

0 comments on commit 7b0a420

Please sign in to comment.