Updated print window with statistics about the print. Filament used, and estimated print time.

master
daid 2012-04-03 12:06:02 +02:00
parent e999faf08a
commit c2ce7b9c24
4 changed files with 26 additions and 7 deletions

View File

@ -25,6 +25,10 @@ class preferencesDialog(configBase.configWindowBase):
c = configBase.SettingRow(left, 'Machine height (mm)', 'machine_height', '200', 'Size of the machine in mm', type = 'preference') c = configBase.SettingRow(left, 'Machine height (mm)', 'machine_height', '200', 'Size of the machine in mm', type = 'preference')
validators.validFloat(c, 10.0) validators.validFloat(c, 10.0)
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)
configBase.TitleRow(left, 'Communication settings') 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') c = configBase.SettingRow(left, 'Serial port', 'serial_port', ['AUTO'] + machineCom.serialList(), 'Serial port to use for communication with the printer', type = 'preference')
c = configBase.SettingRow(left, 'Baudrate', 'serial_baud', '250000', 'Speed of the serial port communication\nNeeds to match your firmware settings\nCommon values are 250000, 115200, 57600', type = 'preference') c = configBase.SettingRow(left, 'Baudrate', 'serial_baud', '250000', 'Speed of the serial port communication\nNeeds to match your firmware settings\nCommon values are 250000, 115200, 57600', type = 'preference')

View File

@ -24,6 +24,7 @@ class printWindow(wx.Frame):
self.machineCom = None self.machineCom = None
self.machineConnected = False self.machineConnected = False
self.thread = None self.thread = None
self.gcode = None
self.gcodeList = None self.gcodeList = None
self.printIdx = None self.printIdx = None
self.bufferLineCount = 4 self.bufferLineCount = 4
@ -78,8 +79,13 @@ class printWindow(wx.Frame):
def UpdateProgress(self): def UpdateProgress(self):
status = "" status = ""
if self.gcode != None:
status += "Filament: %.2fm %.2fg\n" % (self.gcode.extrusionAmount / 1000, self.gcode.calculateWeight() * 1000)
status += "Print time: %02d:%02d\n" % (int(self.gcode.totalMoveTimeMinute / 60), int(self.gcode.totalMoveTimeMinute % 60))
if self.printIdx == None: if self.printIdx == None:
self.progress.SetValue(0) self.progress.SetValue(0)
if self.gcodeList != None:
status += 'Line: -/%d\n' % (len(self.gcodeList))
else: else:
self.progress.SetValue(self.printIdx) self.progress.SetValue(self.printIdx)
status += 'Line: %d/%d\n' % (self.printIdx, len(self.gcodeList)) status += 'Line: %d/%d\n' % (self.printIdx, len(self.gcodeList))
@ -131,19 +137,19 @@ class printWindow(wx.Frame):
gcodeList.append(line) gcodeList.append(line)
gcode = gcodeInterpreter.gcode() gcode = gcodeInterpreter.gcode()
gcode.loadList(gcodeList) gcode.loadList(gcodeList)
print gcode.extrusionAmount
print gcode.totalMoveTimeMinute
print "Loaded: %s (%d)" % (filename, len(gcodeList)) print "Loaded: %s (%d)" % (filename, len(gcodeList))
self.progress.SetRange(len(gcodeList)) self.progress.SetRange(len(gcodeList))
self.gcode = gcode
self.gcodeList = gcodeList self.gcodeList = gcodeList
self.UpdateButtonStates() self.UpdateButtonStates()
self.UpdateProgress() self.UpdateProgress()
def sendLine(self, lineNr): def sendLine(self, lineNr):
if lineNr >= len(self.gcodeList): if lineNr >= len(self.gcodeList):
return return False
checksum = reduce(lambda x,y:x^y, map(ord, "N%d%s" % (lineNr, self.gcodeList[lineNr]))) checksum = reduce(lambda x,y:x^y, map(ord, "N%d%s" % (lineNr, self.gcodeList[lineNr])))
self.machineCom.sendCommand("N%d%s*%d" % (lineNr, self.gcodeList[lineNr], checksum)) self.machineCom.sendCommand("N%d%s*%d" % (lineNr, self.gcodeList[lineNr], checksum))
return True
def PrinterMonitor(self): def PrinterMonitor(self):
skipCount = 0 skipCount = 0
@ -151,7 +157,7 @@ class printWindow(wx.Frame):
line = self.machineCom.readline() line = self.machineCom.readline()
if line == None: if line == None:
self.machineConnected = False self.machineConnected = False
wx.CallAfter(self.UpdateButtonState) wx.CallAfter(self.UpdateButtonStates)
return return
if self.machineConnected: if self.machineConnected:
while self.sendCnt > 0: while self.sendCnt > 0:
@ -160,13 +166,13 @@ class printWindow(wx.Frame):
self.sendCnt -= 1 self.sendCnt -= 1
elif line.startswith("start"): elif line.startswith("start"):
self.machineConnected = True self.machineConnected = True
wx.CallAfter(self.UpdateButtonState) wx.CallAfter(self.UpdateButtonStates)
if self.printIdx != None: if self.printIdx != None:
if line.startswith("ok"): if line.startswith("ok"):
if skipCount > 0: if skipCount > 0:
skipCount -= 1 skipCount -= 1
else: else:
self.sendLine(self.printIdx) if self.sendLine(self.printIdx):
self.printIdx += 1 self.printIdx += 1
wx.CallAfter(self.UpdateProgress) wx.CallAfter(self.UpdateProgress)
elif "resend" in line.lower() or "rs" in line: elif "resend" in line.lower() or "rs" in line:
@ -177,3 +183,4 @@ class printWindow(wx.Frame):
lineNr=int(line.split()[1]) lineNr=int(line.split()[1])
self.printIdx = lineNr self.printIdx = lineNr
#we should actually resend the line here, but we also get an "ok" for each error from Marlin. And thus we'll resend on the OK. #we should actually resend the line here, but we also get an "ok" for each error from Marlin. And thus we'll resend on the OK.

View File

@ -7,6 +7,7 @@ import re
import os import os
from util import util3d from util import util3d
from util import profile
class gcodePath(): class gcodePath():
def __init__(self, newType, pathType, startPoint): def __init__(self, newType, pathType, startPoint):
@ -31,6 +32,12 @@ class gcode():
def loadList(self, l): def loadList(self, l):
self._load(l) self._load(l)
def calculateWeight(self):
#Calculates the weight of the filament in kg
radius = float(profile.getProfileSetting('filament_diameter')) / 2
volumeM3 = (self.extrusionAmount * (math.pi * radius * radius)) / (1000*1000*1000)
return volumeM3 * float(profile.getPreference('filament_density'))
def _load(self, gcodeFile): def _load(self, gcodeFile):
filePos = 0 filePos = 0
pos = util3d.Vector3() pos = util3d.Vector3()

View File

@ -69,6 +69,7 @@ preferencesDefaultSettings = {
'machine_width': '205', 'machine_width': '205',
'machine_depth': '205', 'machine_depth': '205',
'machine_height': '200', 'machine_height': '200',
'filament_density': '1300',
'steps_per_e': '0', 'steps_per_e': '0',
'serial_port': 'AUTO', 'serial_port': 'AUTO',
'serial_baud': '250000', 'serial_baud': '250000',