-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrestart-points.js
32 lines (28 loc) · 1.07 KB
/
restart-points.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
//Enable/Restart a group of data points read from a csv file of the form:
// id,xid,other,rows
const Files = Java.type('java.nio.file.Files');
function readCsv(fileStore, filePath) {
const path = services.fileStoreService.getPathForRead(fileStore, filePath);
const lines = Array.from(Files.readAllLines(path));
const header = lines.shift().split(',');
for (let i = 0; i < lines.length; i++) {
const row = lines[i].split(',');
const data = lines[i] = {};
for (let j = 0; j < row.length; j++) {
data[header[j]] = row[j];
}
}
return lines;
}
const dataPointService = services.dataPointService;
const pointsArray = readCsv('default', 'data-points-to-restart.csv');
console.log(`Restarting ${pointsArray.length} points`);
let count = 0;
for(const point of pointsArray) {
dataPointService.setDataPointState(point.xid, true, true);
count++;
if(count % 10 == 0){
console.log(`Restarted ${count} points out of ${pointsArray.length}`);
}
}
console.log(`Finished restarting ${pointsArray.length} points`);