SD card slice and write functional. Added remove STL on delete of Gcode

This commit is contained in:
Ross Hendrickson 2013-08-04 05:22:31 +00:00
parent d4bb75a2ee
commit aef0322617
4 changed files with 20 additions and 11 deletions

View file

@ -174,10 +174,8 @@ class GcodeManager:
config = self._settings.get(["curaEngine", "config"])
curaEngine.process_file(
config, gcodePath, absolutePath, callBack, callBackArgs)
config, gcodePath, absolutePath, callBack, callBackArgs)
def processGcode(self, absolutePath):
logging.info("Processing Gcode:%s" % str(absolutePath))
if absolutePath is None:
return None
@ -206,10 +204,16 @@ class GcodeManager:
def removeFile(self, filename):
filename = self._getBasicFilename(filename)
absolutePath = self.getAbsolutePath(filename)
stlPath = util.genStlFileName(absolutePath)
if absolutePath is None:
return
if stlPath:
os.remove(stlPath)
os.remove(absolutePath)
if filename in self._metadata.keys():
del self._metadata[filename]
self._metadataDirty = True

View file

@ -484,12 +484,9 @@ class Printer():
absolutePath, callBack, callBackArgs)
def streamSdFile(self, filename, path):
logging.info("Stream SD file called:%s" % filename)
if not self._comm or self._comm.isBusy():
return
logging.info("Starting to stream file")
self._comm.startFileTransfer(path, filename[:8].lower() + ".gco")
logging.info("File is streaming to SD Card")
def deleteSdFile(self, filename):
if not self._comm:

View file

@ -82,7 +82,16 @@ def genGcodeFileName(filename):
return filename.replace('.stl', '.gcode')
def genStlFileName(filename):
if not filename:
return None
if "." not in filename:
return filename + ".stl"
return filename.replace('.gcode', '.stl')
def isDevVersion():
gitPath = os.path.abspath(os.path.join(os.path.split(os.path.abspath(__file__))[0], "../../.git"))
return os.path.exists(gitPath)

View file

@ -353,7 +353,6 @@ class MachineCom(object):
if not self.isOperational():
# printer is not connected, can't use SD
return
logging.info("Select SD file: %s" % filename)
self.sendCommand("M23 %s" % filename)
else:
self._currentFile = PrintingGcodeFileInformation(filename)
@ -427,9 +426,7 @@ class MachineCom(object):
self.refreshSdFiles()
def refreshSdFiles(self):
logging.info("refresh sd files")
if not self.isOperational() or self.isBusy():
logging.info("refresh busy")
return
self.sendCommand("M20")
@ -602,6 +599,8 @@ class MachineCom(object):
self._callback.mcPrintjobDone()
self._changeState(self.STATE_OPERATIONAL)
eventManager().fire("PrintDone")
elif 'Done saving file' in line:
self.refreshSdFiles()
##~~ Message handling
elif line.strip() != '' and line.strip() != 'ok' and not line.startswith("wait") and not line.startswith('Resend:') and line != 'echo:Unknown command:""\n' and self.isOperational():
@ -681,8 +680,8 @@ class MachineCom(object):
startSeen = True
elif "ok" in line and startSeen:
self._changeState(self.STATE_OPERATIONAL)
if self._sdAvailable:
self.refreshSdFiles()
if not self._sdAvailable:
self.initSdCard()
eventManager().fire("Connected", "%s at %s baud" % (self._port, self._baudrate))
elif time.time() > timeout:
self.close()