Sfoglia il codice sorgente

Support IKAWA CSV with headers: time, state, temp set, exaust temp, fan set (%), fan speed (RPM) heater power (%)

Neal Wilson 5 anni fa
parent
commit
0b5e382fcd
Firmato da: Neal Wilson <neal@typica.us> ID Chiave GPG: 2A0BDDE701E66EB9
1 ha cambiato i file con 35 aggiunte e 11 eliminazioni
  1. 35
    11
      config/ImportFilters/IKAWA.js

+ 35
- 11
config/ImportFilters/IKAWA.js Vedi File

@@ -11,17 +11,41 @@ pluginContext.table.addOutputControlColumn(3);
11 11
 pluginContext.table.addOutputControlColumn(4);
12 12
 pluginContext.table.addOutputAnnotationColumn(5);
13 13
 var lines = pluginContext.data.split('\n');
14
-for(var i = 0; i < lines.length; i++) {
15
-	var fields = lines[i].split(',');
16
-	if(fields[5] == "roasting") {
17
-		var time = new QTime;
18
-		time = time.addSecs(Number(fields[0]));
19
-		pluginContext.newMeasurement(new Measurement(Units.convertTemperature(fields[4], Units.Celsius, Units.Fahrenheit), time), 1);
20
-		pluginContext.newMeasurement(new Measurement(Units.convertTemperature(fields[2], Units.Celsius, Units.Fahrenheit), time), 2);
21
-		pluginContext.newMeasurement(new Measurement(fields[1], time, Units.Unitless), 3);
22
-		pluginContext.newMeasurement(new Measurement(fields[6], time, Units.Unitless), 4);
23
-	}
14
+var headers = lines[0].split(',');
15
+if(headers[1] == 'state') {
16
+    importV2(lines);
17
+} else {
18
+    importV1(lines);
24 19
 }
25 20
 for(var i = 1; i < 5; i++) {
26 21
 	pluginContext.table.newAnnotation("End", i, 5);
27
-}
22
+}
23
+
24
+function importV1(lines) {
25
+    for(var i = 0; i < lines.length; i++) {
26
+        var fields = lines[i].split(',');
27
+        if(fields[5] == "roasting") {
28
+            var time = new QTime;
29
+            time = time.addSecs(Number(fields[0]));
30
+            pluginContext.newMeasurement(new Measurement(Units.convertTemperature(fields[4], Units.Celsius, Units.Fahrenheit), time), 1);
31
+            pluginContext.newMeasurement(new Measurement(Units.convertTemperature(fields[2], Units.Celsius, Units.Fahrenheit), time), 2);
32
+            pluginContext.newMeasurement(new Measurement(fields[1], time, Units.Unitless), 3);
33
+            pluginContext.newMeasurement(new Measurement(fields[6], time, Units.Unitless), 4);
34
+        }
35
+    }
36
+}
37
+
38
+function importV2(lines) {
39
+    for(var i = 0; i < lines.length; i++) {
40
+        var fields = lines[i].split(',');
41
+        if(fields[1] == "roasting") {
42
+            var time = new QTime;
43
+            time = time.addSecs(Number(fields[0]));
44
+            pluginContext.newMeasurement(new Measurement(Units.convertTemperature(fields[3], Units.Celsius, Units.Fahrenheit), time), 1);
45
+            pluginContext.newMeasurement(new Measurement(Units.convertTemperature(fields[2], Units.Celsius, Units.Fahrenheit), time), 2);
46
+            pluginContext.newMeasurement(new Measurement(fields[4], time, Units.Unitless), 3);
47
+            pluginContext.newMeasurement(new Measurement(fields[6], time, Units.Unitless), 4);
48
+        }
49
+    }
50
+}
51
+

Loading…
Annulla
Salva