forked from nallath/PrintCostCalculator
-
Notifications
You must be signed in to change notification settings - Fork 3
/
ElectricPrintCostCalculator.qml
264 lines (234 loc) · 6.3 KB
/
ElectricPrintCostCalculator.qml
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
// Copyright (c) 2017 Zoff
// https://github.com/zoff99/ElectricPrintCostCalculator
// Copyright (c) 2015 Jaime van Kessel.
// PrintCostCalculator is released under the terms of the AGPLv3 or higher.
import QtQuick 2.2
import QtQuick.Window 2.2
import QtQuick.Controls 1.2
import UM 1.0 as UM
UM.Dialog
{
modality: Qt.NonModal
id: base;
width: 480 * Screen.devicePixelRatio;
height: 390 * Screen.devicePixelRatio;
visible: true;
title: qsTr("Calculate electrical print cost")
property real material_amount_length: manager.materialAmountLength == -1 ? 0 : manager.materialAmountLength
property real pi: 3.1415
property real material_radius: 0.5 * manager.materialDiameter
property real material_amount_volume: pi * material_radius * material_radius * material_amount_length / 1000000
property real density: manager.density
property real kg_material: material_amount_volume * density
property real price_per_kg : manager.pricePerKg
property real price_kwh_cent: manager.price_kwh_cent
property real power_consumtion_printer_watt: manager.power_consumtion_printer_watt
property real printer_cost: manager.printer_cost
property real printer_lasting_hours: manager.printer_lasting_hours
property real printing_time_h: manager.printing_time_h
property real printing_time_m: manager.printing_time_m
property real printing_time_in_hours: (printing_time_h + (printing_time_m/60))
property real material_cost: manager.material_cost
property string currency_symbol: manager.currency_symbol
property string dummy002: manager.updateme
Column
{
anchors.fill: parent;
Row
{
Text
{
text: "Price per Kwh in " + currency_symbol + " Cent: "
}
TextField
{
id: price_kwh_cent_field
text: price_kwh_cent
Keys.onReleased:
{
manager.setPricePKWH(price_kwh_cent_field.text)
}
}
}
Row
{
Text
{
text: "Power consumption in Watt: "
}
TextField
{
id: power_consumtion_printer_watt_field
text: power_consumtion_printer_watt
Keys.onReleased:
{
manager.setPowerConsump(power_consumtion_printer_watt_field.text)
}
}
}
Row
{
Text
{
text: "Printer cost in " + currency_symbol + ": "
}
TextField
{
id: printer_cost_field
text: printer_cost
Keys.onReleased:
{
manager.setPrinterCost(printer_cost_field.text)
}
}
}
Row
{
Text
{
text: "Printer will last this many hours: "
}
TextField
{
id: printer_lasting_hours_field
text: printer_lasting_hours
Keys.onReleased:
{
manager.setPrinterLastingHours(printer_lasting_hours_field.text)
}
}
}
Row
{
Text
{
text: " "
}
}
// Row
// {
// Text
// {
// color: "green"
// text: "fill these with your current model values:"
// }
// }
Row
{
Text
{
color: "green"
text: "Printing Time: [HH:MM]"
}
TextField
{
width: 36 * Screen.devicePixelRatio
readOnly : true
id: printing_time_h_field
text: printing_time_h
maximumLength: 4
}
TextField
{
width: 18 * Screen.devicePixelRatio
id: printing_time_colon
readOnly : true
text: ":"
maximumLength: 1
}
TextField
{
width: 36 * Screen.devicePixelRatio
readOnly : true
id: printing_time_m_field
text: printing_time_m
maximumLength: 2
}
}
Row
{
Text
{
color: "green"
text: "Material Cost in " + currency_symbol + ": "
}
TextField
{
id: material_cost_field
readOnly : true
text: material_cost.toFixed(2)
}
}
Row
{
Text
{
text: " "
}
}
Row
{
Text
{
text: "Electrical Cost: " + ( (price_kwh_cent/100) * (power_consumtion_printer_watt/1000) * printing_time_in_hours ).toFixed(2) + " " + currency_symbol
}
}
// ( (price_kwh_cent/100) * (power_consumtion_printer_watt/1000) * printing_time_in_hours )
Row
{
Text
{
text: "Material Cost: " + (material_cost_field.text * 1.0).toFixed(2) + " " + currency_symbol
}
}
Row
{
Text
{
text: "Printer Cost: " + ( (printer_cost/printer_lasting_hours) * printing_time_in_hours ).toFixed(2) + " " + currency_symbol
}
}
// (printer_cost/printer_lasting_hours) * printing_time_in_hours
Row
{
Text
{
text: " "
}
}
Row
{
Text
{
color: "red"
text: "TOTAL Cost: " + (1.0*(( (price_kwh_cent/100) * (power_consumtion_printer_watt/1000) * printing_time_in_hours )* 1.0 + ((printer_cost/printer_lasting_hours) * printing_time_in_hours)* 1.0 + (material_cost_field.text * 1.0))).toFixed(2) + " " + currency_symbol
}
}
Row
{
Text
{
text: " "
}
}
Row
{
Button
{
text: qsTr("Update");
onClicked:
{
manager.updateme()
}
}
Button
{
text: qsTr("Close");
onClicked:
{
base.visible = false;
}
}
}
}
}