Skip to content

Commit

Permalink
Update test data
Browse files Browse the repository at this point in the history
  • Loading branch information
Djaygo committed Jun 23, 2017
1 parent 081f060 commit d97ab4d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 38 deletions.
4 changes: 2 additions & 2 deletions app.js
Expand Up @@ -15,7 +15,7 @@ const socketio = require('socket.io');

const app = express();
// Init modules
// const FTP = require('./modules/getFTPFiles');
const FTP = require('./modules/getFTPFiles');
const webSockets = require('./modules/websockets');
// const serviceWorker = require('./modules/server-service-worker');

Expand Down Expand Up @@ -46,7 +46,7 @@ mongoose.connect(process.env.DB_URL);
// FTP.checkForNewLocalFiles('alarm'); // does not work with current filenames

// WebSockets
webSockets(app, io);
// webSockets(app, io);

// view engine setup
app.set('views', path.join(__dirname, 'views'));
Expand Down
7 changes: 4 additions & 3 deletions data/sd-card/VALUE/test VALUE/test.sh
Expand Up @@ -11,14 +11,15 @@ header="Date,Time,Temp_PT100_1,Temp_PT100_2,pH_Value,Bag_Height"
# done
# done

# for date in 2016-02-{01..28} 2016-{04,06,09,11}-{01..30} 2016-{01,03,05,07,08,10,12}-{01..31}
for date in 2017-02-{01..28} 2017-04-{01..30} 2017-{01,03,05}-{01..31}
# for date in 2015-02-{01..28} 2015-{04,06,09,11}-{01..30} 2015-{03,05,07,08,10,12}-{01..31}
# for date in 2017-02-{01..28} 2017-04-{01..30} 2017-{01,03,05}-{01..31}
for date in 2015-01-{02..31}
do
year=$(printf "%02s" ${date:2:2})
month=$(printf "%02s" ${date:5:2})
day=$(printf "%02s" ${date:8:2})
fileName=$(printf "%02s%02s%02s.csv\n" $year $month $day )
cat ./170607.CSV | awk -v year=$year -v month=$month -v day=$day -F ',' 'BEGIN{
cat ./150101.csv | awk -v year=$year -v month=$month -v day=$day -F ',' 'BEGIN{
OFS = ","
} {
if (substr($1,1,1) == "D") {print $0}
Expand Down
2 changes: 1 addition & 1 deletion modules/getFTPFiles.js
Expand Up @@ -112,5 +112,5 @@ function parseFileDataToJSON(data, directoryKey) {
function addFileToMongo(data, directoryKey) {
FTP[directoryKey].schema.insertMany(data)
.then(mongooseDocuments => {})
.catch(err => {});
.catch(err => {console.log(err)});
}
32 changes: 0 additions & 32 deletions modules/websockets.js
Expand Up @@ -33,38 +33,6 @@ function webSokets(app, io) {
io.sockets.emit('dataPoint', dataCollection, tileStatus(dataPoints[i]));
}, 1000);
});

// fs.readFile('./data/sample-data.csv', (err, data) => {
// if (err) {
// throw err;
// }
// parse(data, {
// columns: ['Date', 'Time', 'PT100_real_1', 'PT100_real_2', 'Bag_Height', 'ph_value']
// }, (error, output) => {
// if (error) {
// throw error;
// }

// let i = 1;
// const sendItemsCount = 30;

// setInterval(() => {
// if (!output[i + sendItemsCount]) {
// i = 1;
// }

// const dataCollection = [];

// for (let x = 1; x <= sendItemsCount; x++) {
// dataCollection.push(output[x + i]);
// }

// i += 30;

// io.sockets.emit('dataPoint', dataCollection, tileStatus(output[i]));
// }, 1000);
// });
// });
}

module.exports = webSokets;

0 comments on commit d97ab4d

Please sign in to comment.