From 72046f8bf50a63b4de233969e919f6a36aae42d6 Mon Sep 17 00:00:00 2001 From: abdelrahman Date: Tue, 24 Oct 2017 20:34:29 +0200 Subject: [PATCH 1/5] Fixed radius to get more accurate power estimation. --- .idea/misc.xml | 2 +- app/src/main/java/com/vmal/solarify/PowerForecastActivity.java | 2 +- build.gradle | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 8774759..7158618 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -37,7 +37,7 @@ - + diff --git a/app/src/main/java/com/vmal/solarify/PowerForecastActivity.java b/app/src/main/java/com/vmal/solarify/PowerForecastActivity.java index 571ea66..5033e52 100644 --- a/app/src/main/java/com/vmal/solarify/PowerForecastActivity.java +++ b/app/src/main/java/com/vmal/solarify/PowerForecastActivity.java @@ -199,7 +199,7 @@ void getPowerData() { String losses = "0"; //fixed String dataset = "intl"; String timeFrame = "hourly"; - String radius = "900"; + String radius = "1200"; final String JSONRequest = BASE_URL + "&lat=" + lati + "&lon=" + lon + "&system_capacity=" + systemCapacity + "&azimuth=" + azimuth + "&tilt=" + tilt + "&array_type=" + arrayType + "&module_type=" + moduleType + "&losses=" + diff --git a/build.gradle b/build.gradle index 1376266..34ab191 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.3.1' + classpath 'com.android.tools.build:gradle:2.3.3' classpath 'com.google.gms:google-services:3.0.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files From dab9c69b72d572b2aa48ad6f063f685e6c46a4db Mon Sep 17 00:00:00 2001 From: abdelrahman Date: Tue, 24 Oct 2017 20:37:25 +0200 Subject: [PATCH 2/5] Added a default case for the day cycle to stop the random "null" --- .../java/com/vmal/solarify/PowerForecastActivity.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/src/main/java/com/vmal/solarify/PowerForecastActivity.java b/app/src/main/java/com/vmal/solarify/PowerForecastActivity.java index 5033e52..f6a690b 100644 --- a/app/src/main/java/com/vmal/solarify/PowerForecastActivity.java +++ b/app/src/main/java/com/vmal/solarify/PowerForecastActivity.java @@ -342,6 +342,14 @@ void viewData() { case 0: + d1 = "Sun"; + d2 = "Mon"; + d3 = "Tue"; + d4 = "Wed"; + d5 = "Thu"; + d6 = "Fri"; + break; + default: d1 = "Sun"; d2 = "Mon"; d3 = "Tue"; From 546850ae2524079aad866ef72e45776fe5ab4729 Mon Sep 17 00:00:00 2001 From: abdelrahman Date: Tue, 24 Oct 2017 20:41:35 +0200 Subject: [PATCH 3/5] Cleaned some parts of the code and added some comments --- .../com/vmal/solarify/ApplianceListActivity.java | 1 - .../com/vmal/solarify/PowerForecastActivity.java | 13 ++++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/vmal/solarify/ApplianceListActivity.java b/app/src/main/java/com/vmal/solarify/ApplianceListActivity.java index b8304ed..4d140bf 100644 --- a/app/src/main/java/com/vmal/solarify/ApplianceListActivity.java +++ b/app/src/main/java/com/vmal/solarify/ApplianceListActivity.java @@ -108,7 +108,6 @@ protected void onPreExecute() { String formula_value = jo_inside.getString("A"); String url_value = jo_inside.getString("B"); - //Add your values in your `ArrayList` as below: m_li = new HashMap(); m_li.put("appliances", formula_value); m_li.put("value", url_value); diff --git a/app/src/main/java/com/vmal/solarify/PowerForecastActivity.java b/app/src/main/java/com/vmal/solarify/PowerForecastActivity.java index f6a690b..90357e4 100644 --- a/app/src/main/java/com/vmal/solarify/PowerForecastActivity.java +++ b/app/src/main/java/com/vmal/solarify/PowerForecastActivity.java @@ -98,13 +98,7 @@ protected void onCreate(Bundle savedInstanceState) { startActivity(intent); } if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { - // TODO: Consider calling - // ActivityCompat#requestPermissions - // here to request the missing permissions, and then overriding - // public void onRequestPermissionsResult(int requestCode, String[] permissions, - // int[] grantResults) - // to handle the case where the user grants the permission. See the documentation - // for ActivityCompat#requestPermissions for more details. + requestPermissions(new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION}, 1); } @@ -178,6 +172,7 @@ public void onClick(View v) { void getPowerData() { + // this is the base URL for NREL API that is used to fetch the sunlight hourly data though out the day String BASE_URL = "https://developer.nrel.gov/api/pvwatts/v5.json?api_key=KhjqE5Ln7Ri9ckKXIej5onPadY3FDvCzlusgqPYB"; @@ -273,6 +268,10 @@ void calcData(String[] data) { } + /* + viewData is responsible for viewing the days of the week for the power forecast + */ + void viewData() { // Calendar calendar = Calendar.getInstance(); From 6f12adbe283bb84d07bbbd39765f92d81d9320aa Mon Sep 17 00:00:00 2001 From: abdelrahman Date: Tue, 24 Oct 2017 20:43:01 +0200 Subject: [PATCH 4/5] Cleaned some parts of the code and added some comments --- .../java/com/vmal/solarify/PowerForecastActivity.java | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/app/src/main/java/com/vmal/solarify/PowerForecastActivity.java b/app/src/main/java/com/vmal/solarify/PowerForecastActivity.java index 90357e4..a0e0d50 100644 --- a/app/src/main/java/com/vmal/solarify/PowerForecastActivity.java +++ b/app/src/main/java/com/vmal/solarify/PowerForecastActivity.java @@ -90,9 +90,6 @@ protected void onCreate(Bundle savedInstanceState) { boolean enabled = service .isProviderEnabled(LocationManager.GPS_PROVIDER); - // check if enabled and if not send user to the GSP settings - // Better solution would be to display a dialog and suggesting to - // go to the settings if (!enabled) { Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); startActivity(intent); @@ -161,8 +158,6 @@ public void onCancelled(DatabaseError databaseError) { avgConsumption.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { -// Intent i = new Intent(PowerForecastActivity.this, ApplianceListActivity.class); -// startActivity(i); } }); @@ -221,7 +216,7 @@ protected String doInBackground(Void... params) { Log.d("testData", testData2); acData = acDataString.split(","); - // Log.d("DataInStringArray", acData[13]); + runOnUiThread(new Runnable() { @Override public void run() { @@ -398,7 +393,6 @@ void tilt() { } else{ // bigger than zero - if(month == 9 || month == 10 || month == 11){ season = "fall"; }else From dbeae5e36d151cbd4ab147da72187d47804aa3d3 Mon Sep 17 00:00:00 2001 From: abdelrahman Date: Tue, 24 Oct 2017 20:44:58 +0200 Subject: [PATCH 5/5] Cleaned some parts of the code and added some comments --- app/src/main/java/com/vmal/solarify/MainActivity.java | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/java/com/vmal/solarify/MainActivity.java b/app/src/main/java/com/vmal/solarify/MainActivity.java index 0945a8f..d645dfd 100644 --- a/app/src/main/java/com/vmal/solarify/MainActivity.java +++ b/app/src/main/java/com/vmal/solarify/MainActivity.java @@ -169,6 +169,7 @@ public void updateUI(FirebaseUser user){ // Start home activity startActivity(new Intent(this, PlanetActivity.class)); finish(); + //this sends you to the next page } }