Bläddra i källkod

Added historical profile viewer. Fixes #54

Neal Wilson 11 år sedan
förälder
incheckning
2ebdb91588
3 ändrade filer med 159 tillägg och 11 borttagningar
  1. 25
    11
      config/Windows/navigation.xml
  2. 133
    0
      config/Windows/profilehistory.xml
  3. 1
    0
      config/config.xml

+ 25
- 11
config/Windows/navigation.xml Visa fil

@@ -29,37 +29,47 @@
29 29
 			</column>
30 30
 		</row>
31 31
 		<row>
32
-			<column>	
32
+			<column>
33 33
 				<button name="Batch Log" id="history" type="push" />
34 34
 			</column>
35 35
 		</row>
36 36
 		<row>
37
-			<column>	
38
-				<button name="New Cupping Session" id="createcupping" type="push" />
37
+			<column>
38
+				<button name="New Cupping Session" id="createcupping"
39
+type="push" />
40
+			</column>
41
+		</row>
42
+		<row>
43
+			<column>
44
+				<button name="Join Cupping Session" id="joincupping" type="push"
45
+/>
39 46
 			</column>
40 47
 		</row>
41 48
 		<row>
42
-			<column>	
43
-				<button name="Join Cupping Session" id="joincupping" type="push" />
49
+			<column>
50
+				<button name="Summarize Cupping Session" id="sumcupping"
51
+type="push" />
44 52
 			</column>
45 53
 		</row>
46 54
 		<row>
47
-			<column>	
48
-				<button name="Summarize Cupping Session" id="sumcupping" type="push" />
55
+			<column>
56
+				<button name="View Target Roast Profiles" id="profilehistory"
57
+					type="push" />
49 58
 			</column>
50 59
 		</row>
51 60
 		<row>
52
-			<column>	
53
-				<button name="Import Target Roast Profiles" id="target" type="push" />
61
+			<column>
62
+				<button name="Import Target Roast Profiles" id="target"
63
+type="push" />
54 64
 			</column>
55 65
 		</row>
56 66
 		<row>
57
-			<column>	
67
+			<column>
58 68
 				<button name="Invoice List" id="invoicelist" type="push" />
59 69
 			</column>
60 70
 		</row>
61 71
 		<row>
62
-			<column>	
72
+			<column>
63 73
 				<button name="Enter Green Coffee Sales" id="greensales" type="push" />
64 74
 			</column>
65 75
 		</row>
@@ -87,6 +97,10 @@
87 97
 			QSettings.setValue("database/user", "");
88 98
 			QSettings.setValue("database/password", "");
89 99
 		});
100
+		var profilehistory = findChildObject(this, 'profilehistory');
101
+		profilehistory.clicked.connect(function() {
102
+			createWindow("profilehistory");
103
+		});
90 104
 		var greensalesbutton = findChildObject(this, 'greensales');
91 105
 		greensalesbutton.clicked.connect(function() {
92 106
 			createWindow("greensales");

+ 133
- 0
config/Windows/profilehistory.xml Visa fil

@@ -0,0 +1,133 @@
1
+<window id="profilehistory">
2
+	<layout type="vertical">
3
+		<layout type="horizontal">
4
+			<label>Coffee:</label>
5
+			<sqldrop data="0" display="1" showdata="false" editable="false" id="coffees">
6
+				<query>SELECT id, name FROM items WHERE category = 'Coffee: Roasted' AND id IN (SELECT item FROM current_items) ORDER BY name</query>
7
+			</sqldrop>
8
+			<stretch />
9
+		</layout>
10
+		<splitter type="horizontal" id="outersplitter">
11
+			<widget>
12
+				<layout type="vertical">
13
+					<sqlview id="profilelist" />
14
+				</layout>
15
+			</widget>
16
+			<widget>
17
+				<layout type="vertical">
18
+					<layout type="horizontal">
19
+						<button name="Set as Current Target Roast Profile"
20
+							id="setcurrent" type="push" />
21
+						<stretch />
22
+					</layout>
23
+					<splitter type="horizontal">
24
+						<measurementtable id="log" />
25
+						<graph id = "graph" />
26
+					</splitter>
27
+				</layout>
28
+			</widget>
29
+		</splitter>
30
+	</layout>
31
+	<menu name="Log">
32
+		<item id="showC">Display Celsius</item>
33
+		<item id="showF">Display Fahrenheit</item>
34
+		<separator />
35
+		<item id="ms">Millisecond view</item>
36
+		<item id="1s">1 Second View</item>
37
+		<item id="5s">5 Second View</item>
38
+		<item id="10s">10 Second View</item>
39
+		<item id="15s">15 Second View</item>
40
+		<item id="30s">30 Second View</item>
41
+		<item id="1m">1 Minute View</item>
42
+	</menu>
43
+	<program>
44
+	<![CDATA[
45
+		var profileList = findChildObject(this, 'profilelist');
46
+		var coffeelist = findChildObject(this, 'coffees');
47
+		var graph = findChildObject(this, 'graph');
48
+		var log = findChildObject(this, 'log');
49
+		var setCurrent = findChildObject(this, 'setcurrent');
50
+		setCurrent.enabled = false;
51
+		var currentProfileID;
52
+		setCurrent.clicked.connect(function() {
53
+			var query = new QSqlQuery();
54
+			query.prepare("INSERT INTO item_files VALUES('now', :coffee, :profile)");
55
+			query.bind(":coffee", coffeelist.currentData());
56
+			query.bind(":profile", "{" + currentProfileID + "}");
57
+			query.exec();
58
+			query = query.invalidate();
59
+			listProfiles(coffeelist.currentData());
60
+		});
61
+		var listProfiles = function(roastedID) {
62
+			q = "SELECT time, files[1] AS profile FROM item_files WHERE item =";
63
+			q += roastedID;
64
+			q += " ORDER BY time DESC";
65
+			profileList.setQuery(q);
66
+		};
67
+		var displayProfile = function(profileID) {
68
+			currentProfileID = profileID;
69
+			setCurrent.enabled = true;
70
+			var query = new QSqlQuery();
71
+			query.prepare("SELECT file FROM files WHERE id = :id");
72
+			query.bind(":id", profileID);
73
+			query.exec();
74
+			if(query.next())
75
+			{
76
+				var buffer = new QBuffer(query.value(0));
77
+				var input = new XMLInput(buffer, 1);
78
+				input.newTemperatureColumn.connect(log.setHeaderData);
79
+				input.newAnnotationColumn.connect(log.setHeaderData);
80
+				input.measure.connect(graph.newMeasurement);
81
+				input.measure.connect(log.newMeasurement);
82
+				var lc;
83
+				input.lastColumn.connect(function(c) {
84
+					lc = c;
85
+				});
86
+				input.annotation.connect(function(annotation, mc, nc) {
87
+					for(var i = mc; i < lc; i++) {
88
+						log.newAnnotation(annotation, i, nc);
89
+					}
90
+				});
91
+				input.input();
92
+			}
93
+			query = query.invalidate();
94
+		};
95
+		coffeelist['currentIndexChanged(int)'].connect(function() {
96
+			listProfiles(coffeelist.currentData());
97
+			setCurrent.enabled = false;
98
+			log.clear();
99
+			graph.clear();
100
+		});
101
+		listProfiles(coffeelist.currentData());
102
+		profileList.openEntryRow.connect(function(row) {
103
+			log.clear();
104
+			graph.clear();
105
+			displayProfile(profileList.data(row, 1));
106
+		});
107
+		var v1 = findChildObject(this, 'ms');
108
+        v1.triggered.connect(log.LOD_ms);
109
+        var v2 = findChildObject(this, '1s');
110
+        v2.triggered.connect(log.LOD_1s);
111
+        var v3 = findChildObject(this, '5s');
112
+        v3.triggered.connect(log.LOD_5s);
113
+        var v4 = findChildObject(this, '10s');
114
+        v4.triggered.connect(log.LOD_10s);
115
+        var v5 = findChildObject(this, '15s');
116
+        v5.triggered.connect(log.LOD_15s);
117
+        var v6 = findChildObject(this, '30s');
118
+        v6.triggered.connect(log.LOD_30s);
119
+        var v7 = findChildObject(this, '1m');
120
+        v7.triggered.connect(log.LOD_1m);
121
+		var showC = findChildObject(this, 'showC');
122
+		showC.triggered.connect(function() {
123
+			log.setDisplayUnits(TemperatureDisplay.Celsius);
124
+			graph.showC();
125
+		});
126
+		var showF = findChildObject(this, 'showF');
127
+		showF.triggered.connect(function() {
128
+			log.setDisplayUnits(TemperatureDisplay.Fahrenheit);
129
+			graph.showF();
130
+		});
131
+	]]>
132
+	</program>
133
+</window>

+ 1
- 0
config/config.xml Visa fil

@@ -30,6 +30,7 @@
30 30
 	<include src="Windows/editfee.xml" />
31 31
 	<include src="Windows/optime.xml" />
32 32
 	<include src="Windows/greensales.xml" />
33
+	<include src="Windows/profilehistory.xml" />
33 34
 	<program>
34 35
 		var loggingWindow;
35 36
 		var currentBatchInfo;

Laddar…
Avbryt
Spara