Fixed #46 - added support for calculating print costs.

This commit is contained in:
daid 2012-04-12 14:26:03 +02:00
parent 2d10cb47f4
commit 3b2b76a8ac
3 changed files with 15 additions and 0 deletions

View File

@ -28,6 +28,10 @@ class preferencesDialog(configBase.configWindowBase):
configBase.TitleRow(left, 'Filament settings')
c = configBase.SettingRow(left, 'Filament density (kg/m3)', 'filament_density', '1300', 'Weight of the filament per m3. Around 1300 for PLA. And around 1040 for ABS. This value is used to estimate the weight if the filament used for the print.', type = 'preference')
validators.validFloat(c, 500.0, 3000.0)
c = configBase.SettingRow(left, 'Filament cost (price/kg)', 'filament_cost_kg', '0', 'Cost of your filament per kg, to estimate the cost of the final print.', type = 'preference')
validators.validFloat(c, 0.0)
c = configBase.SettingRow(left, 'Filament cost (price/m)', 'filament_cost_meter', '0', 'Cost of your filament per meter, to estimate the cost of the final print.', type = 'preference')
validators.validFloat(c, 0.0)
configBase.TitleRow(left, 'Communication settings')
c = configBase.SettingRow(left, 'Serial port', 'serial_port', ['AUTO'] + machineCom.serialList(), 'Serial port to use for communication with the printer', type = 'preference')

View File

@ -5,6 +5,7 @@ import wx, threading, re
from gui import machineCom
from gui import icon
from util import profile
from util import gcodeInterpreter
printWindowHandle = None
@ -95,6 +96,14 @@ class printWindow(wx.Frame):
status = ""
if self.gcode != None:
status += "Filament: %.2fm %.2fg\n" % (self.gcode.extrusionAmount / 1000, self.gcode.calculateWeight() * 1000)
cost_kg = float(profile.getPreference('filament_cost_kg'))
cost_meter = float(profile.getPreference('filament_cost_meter'))
if cost_kg > 0.0 and cost_meter > 0.0:
status += "Filament cost: %.2f / %.2f\n" % (self.gcode.calculateWeight() * cost_kg, self.gcode.extrusionAmount / 1000 * cost_meter)
elif cost_kg > 0.0:
status += "Filament cost: %.2f\n" % (self.gcode.calculateWeight() * cost_kg)
elif cost_meter > 0.0:
status += "Filament cost: %.2f\n" % (self.gcode.extrusionAmount / 1000 * cost_meter)
status += "Print time: %02d:%02d\n" % (int(self.gcode.totalMoveTimeMinute / 60), int(self.gcode.totalMoveTimeMinute % 60))
if self.printIdx == None:
self.progress.SetValue(0)

View File

@ -80,6 +80,8 @@ preferencesDefaultSettings = {
'serial_baud': '250000',
'slicer': 'Cura (Skeinforge based)',
'save_profile': 'False',
'filament_cost_kg': '0',
'filament_cost_meter': '0',
}
def getDefaultProfilePath():