From 292956d0adf221a1814de51edeb8bacbb4e72f55 Mon Sep 17 00:00:00 2001
From: Porter Libby <pelibby16@earlham.edu>
Date: Fri, 9 Dec 2022 10:10:12 -0500
Subject: [PATCH] update

---
 .env               |  4 ++--
 README.md          | 22 ++++++-----------
 collect            | 60 ----------------------------------------------
 public/js/graph.js |  6 ++++-
 vproweather        |  1 -
 5 files changed, 14 insertions(+), 79 deletions(-)
 delete mode 100755 collect
 delete mode 160000 vproweather

diff --git a/.env b/.env
index 41769ee..90414a9 100644
--- a/.env
+++ b/.env
@@ -1,4 +1,4 @@
 HOSTNAME=Dennis Beaglebone
-CSV_CURRENT=data/current-weather.csv
-CSV_HISTORY=data/history-weather.csv
+CSV_CURRENT=data-dir/current-weather.csv
+CSV_HISTORY=data-dir/history-weather.csv
 PORT=9900
diff --git a/README.md b/README.md
index ef3a4c2..a8ef1cd 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,4 @@
 # Weather Interface
-Uses https://github.com/bytesnz/vproweather to interface with Davis Vantage.
-
 View weather data collected through beaglebone.
 
 ## Setup Guide
@@ -9,14 +7,11 @@ View weather data collected through beaglebone.
     - NodeJS and NPM
     - Build Essentials
 3. `cd weather_interface`.
-4. `git submodule update --init --recursive` - installs vproweather package from github (submodule).
-5. `cd` into ~/weather_interface/vproweather and use the `make` command to build the program.
-6. Create a crontab entry that automatically runs the collect script at a set interval. Example: `*/5 * * * * cd /home/debian/weather_interface; ./collect;`.
-7. `nano .env` or `vi .env` and adjust the parameters to fit your needs.
-8. `npm install` - installs nodejs dependencies.
-9. `npm install -g forever` - install forever to keep the server running.
-10. `forever start index.js` - start the server with forever.
-11. Navigate to your machines IP or domain and see if the web front-end is visible on the port you defined in `.env`.
+4. `nano .env` or `vi .env` and adjust the parameters to fit your needs. Make sure that the CSV pointers are aimed at wherever your `weather_collect` is exporting them to.
+5. `npm install` - installs nodejs dependencies.
+6. `npm install -g forever` - install forever to keep the server running.
+7. `forever start index.js` - start the server with forever.
+8. Navigate to your machines IP or domain and see if the web front-end is visible on the port you defined in `.env`.
 
 ## Additional Setup
 These things arent required for functionality, but will make the beaglebone much more stable in the long term.
@@ -55,10 +50,7 @@ __Note__: This .env should not contain any credentials or sensetive information,
 Set up `.env` file following the template below:
 ```
 HOSTNAME=Beaglebone name                    // Identifies host machine on front-end
-CSV_CURRENT=data/current-weather.csv        // Path to current weather csv (default)
-CSV_HISTORY=data/history-weather.csv        // Path to all weather csv (default)
+CSV_CURRENT=data-dir/current-weather.csv        // Path to current weather csv (default)
+CSV_HISTORY=data-dir/history-weather.csv        // Path to all weather csv (default)
 PORT=9900                                   // Port to be used for webserver
 ```
-CSV_CURRENT=data/current-weather.csv
-CSV_HISTORY=data/history-weather.csv
-PORT=9900
diff --git a/collect b/collect
deleted file mode 100755
index ed50702..0000000
--- a/collect
+++ /dev/null
@@ -1,60 +0,0 @@
-#!/bin/bash
-output1=data/history-weather.csv
-output2=data/current-weather.csv
-if ! test -f "$output1"; then
-    echo "status,timestamp,barometric,insideTemp,insideHum,outsideTemp,outsideHum,windSpeed,windSpeedAvg,windSpeed2mAvg,UVLevel,solarRad" > $output1
-    echo "Created"
-fi
-
-timestamp=$(date +"%m-%d-%Y %T")
-
-# Collect single lines of data
-rawOut=$(vproweather/vproweather -x /dev/ttyUSB0)
-baro=$(grep "rtBaroCurr" <<< "$rawOut")
-baroTrend=$(grep "rtBaroTrend " <<< "$rawOut")
-insideTemp=$(grep "rtInsideTemp" <<< "$rawOut")
-insideHum=$(grep "rtInsideHum" <<< "$rawOut")
-outsideTemp=$(grep "rtOutsideTemp" <<< "$rawOut")
-outsideHum=$(grep "rtOutsideHum" <<< "$rawOut")
-windSpeedAvg=$(grep "rtWindAvgSpeed" <<< "$rawOut")
-windSpeed2mAvg=$(grep "rtWind2mAvgSpeed" <<< "$rawOut")
-windSpeed=$(grep "rtWindSpeed" <<< "$rawOut")
-windDir=$(grep "rtWindDirRose" <<< "$rawOut")
-forecast=$(grep "rtForecast" <<< "$rawOut")
-sunrise=$(grep "rtSunrise" <<< "$rawOut")
-sunset=$(grep "rtSunset" <<< "$rawOut")
-UVLevel=$(grep "rtUVLevel" <<< "$rawOut")
-solarRad=$(grep "rtSolarRad" <<< "$rawOut")
-
-baro=${baro#*= }
-baroTrend=${baroTrend#*= }
-insideTemp=${insideTemp#*= }
-outsideTemp=${outsideTemp#*= }
-insideHum=${insideHum#*= }
-outsideHum=${outsideHum#*= }
-windSpeed=${windSpeed#*= }
-windSpeedAvg=${windSpeedAvg#*= }
-windSpeed2mAvg=${windSpeed2mAvg#*= }
-windDir=${windDir#*= }
-forecast=${forecast#*= }
-sunrise=${sunrise#*= }
-sunset=${sunset#*= }
-UVLevel=${UVLevel#*= }
-solarRad=${solarRad#*= }
-
-commaSpace=", "
-
-status="normal";
-
-if [ -z "$rawOut" ]
-then
-	echo "EMPTY";
-	status="no data"
-fi
-
-# Append new data to weather history
-echo "${status},${timestamp},${baro},${insideTemp},${insideHum},${outsideTemp},${outsideHum},${windSpeed},${windSpeedAvg},${windSpeed2mAvg},${UVLevel},${solarRad}" >> $output1
-
-# Update current weather (only one row of data)
-echo "status,timestamp,barometric,baroTrend,insideTemp,insideHum,outsideTemp,outsideHum,windSpeed,windSpeedAvg,windSpeed2mAvg,windDir,forecast,UVLevel,solarRad,sunrise,sunset," > $output2
-echo "${status},${timestamp},${baro},${baroTrend},${insideTemp},${insideHum},${outsideTemp},${outsideHum},${windSpeed},${windSpeed2mAvg},${windSpeedAvg},${windDir},\"${forecast//[,]/.}\",${UVLevel},${solarRad},${sunrise},${sunset}" >> $output2
diff --git a/public/js/graph.js b/public/js/graph.js
index 940d4ab..be86cdd 100644
--- a/public/js/graph.js
+++ b/public/js/graph.js
@@ -7,8 +7,12 @@ function make_graph(arr, depth, offset){
     if (chart){
         chart.destroy(); // clear old information so it doesnt overflow
     }
-    
+
     let stamp_index = arr[0].indexOf("timestamp");
+    console.log(stamp_index);
+    console.log(arr[1][stamp_index]);
+    console.log(arr[arr.length - 1][stamp_index]);
+    
     var oldest = arr[1][stamp_index];
     var newest = arr[arr.length - 1][stamp_index];
 
diff --git a/vproweather b/vproweather
deleted file mode 160000
index 534dddb..0000000
--- a/vproweather
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 534dddb294d8491f5d0920be283d379e9d62e099
-- 
GitLab