예제 #1
0
    def onPrint(self, evt):
        oldState = self.state
        self.state = PrintState.printing
        self.propDlg.setPrintStatus(PrintState.printing)
        self.enableButtonsByState()

        self.printPos = 0
        self.startTime = time.time()
        self.endTime = None
        self.origEta = self.startTime + self.totalTime
        self.elapsed = 0
        self.remaining = self.totalTime
        if oldState == PrintState.paused:
            action = "restarted"
            self.reprap.restartPrint(self.gcode)
        else:
            action = "started"
            self.reprap.startPrint(self.gcode)

        self.history.addEvent(
            PrintStarted(self.history.addFile(self.gcodeFile), ""))

        stime = time.strftime('%H:%M:%S', time.localtime(self.startTime))
        self.propDlg.setProperty(PropertyEnum.startTime, stime)
        self.propDlg.setProperty(
            PropertyEnum.origEta,
            time.strftime('%H:%M:%S', time.localtime(self.origEta)))
        self.propDlg.setProperty(PropertyEnum.elapsed,
                                 formatElapsed(self.elapsed))
        self.propDlg.setProperty(PropertyEnum.remaining,
                                 formatElapsed(self.remaining))
        self.propDlg.setProperty(PropertyEnum.revisedEta, "")
        self.log("Print %s at %s" % (action, stime))
예제 #2
0
    def resumeSDPrintTo(self, tfn):
        self.setSDTargetFile(tfn[1].lower())
        self.reprap.suspendTempProbe(True)
        self.reprap.sendNow("M28 %s" % self.sdTargetFile)
        self.printPos = 0
        self.startTime = time.time()
        self.endTime = None
        self.reprap.startPrint(self.gcode)

        self.origEta = self.startTime + self.totalTime
        self.elapsed = 0
        self.remaining = self.totalTime

        self.state = PrintState.sdprintingto

        stime = time.strftime('%H:%M:%S', time.localtime(self.startTime))
        self.propDlg.setProperty(PropertyEnum.startTime, stime)
        self.propDlg.setProperty(
            PropertyEnum.origEta,
            time.strftime('%H:%M:%S', time.localtime(self.origEta)))
        self.propDlg.setProperty(PropertyEnum.elapsed,
                                 formatElapsed(self.elapsed))
        self.propDlg.setProperty(PropertyEnum.remaining,
                                 formatElapsed(self.remaining))
        self.propDlg.setProperty(PropertyEnum.revisedEta, "")
        self.log("Print to SD: %s started at %s" % (self.sdTargetFile, stime))

        self.enableButtonsByState()
예제 #3
0
	def setLayerInfo(self, layernbr, z, minxy, maxxy, filament, prevfilament, ltime, gclines):
		self.gclines = gclines
		self.layernbr = layernbr
		self.z = z
		if self.layers == 0:
			self.setValue("layer", "%d (z=%.3f)" % (layernbr+1, z))
		else:
			self.setValue("layer", "%d/%d (z=%.3f/%.3f)" % (layernbr+1, self.layers, z, self.zmax))
			
		if minxy[0] > maxxy[0] or minxy[1] >maxxy[1]:
			self.setValue("minmaxxy", "")
		else:
			self.setValue("minmaxxy", "(%.3f, %.3f) <-> (%.3f, %.3f)" % (minxy[0], minxy[1], maxxy[0], maxxy[1]))

		for i in range(MAX_EXTRUDERS):
			tag = "filament%d" % i
			s = "T%d: %.3f/%.3f (%.3f)" % (i, filament[i], self.filament[i], prevfilament[i])
			self.setValue(tag, s)
		
		self.setValue("gclines", "%d -> %d" % (gclines[0], gclines[1]))
		
		if self.duration == 0:
			self.setValue("layertime", "%s" % formatElapsed(ltime))
		else:
			self.setValue("layertime", "%s/%s" % (formatElapsed(ltime), formatElapsed(self.duration)))
			
		self.updateUntilTime()
예제 #4
0
	def setPrintInfo(self, position, layer, gcodelines, layertime):
		self.position = position
		self.printLayer = layer
		pct = "??"
		if self.gcount != 0:
			pct = "%.2f" % (float(self.position) / float(self.gcount) * 100.0)
		
		self.setValue("gcode", "Line %d/%d total lines (%s%%)" % (position, self.gcount, pct))
		
		start = time.strftime('%H:%M:%S', time.localtime(self.startTime))
		now = time.time()
		elapsed = now - self.startTime
		strElapsed = formatElapsed(elapsed)
		if self.sdTargetFile is None:  # printing TO SD card
			self.remains = self.eta - now
			eta = time.strftime('%H:%M:%S', time.localtime(self.eta))
			self.setValue("eta", "Start: %s  Orig ETA: %s" % (start, eta))

			if layer is not None:
				expectedTime = self.prevTimes[layer]
				delta = 0
				if position >= gcodelines[0] and position <= gcodelines[1]:
					lct = gcodelines[1] - gcodelines[0]
					if lct != 0:
						lpos = position - gcodelines[0]
						lpct = float(lpos)/float(lct)
						delta = layertime * lpct
				expectedTime += delta
				self.revisedeta = expectedTime
				
				diff = elapsed - expectedTime
				try:
					lateness = float(elapsed) / float(expectedTime)
				except:
					lateness = 1.0
					
				remains = self.eta + diff - now
				self.remains = remains
				strRemains = formatElapsed(remains)
				self.newEta = now+(remains * lateness)
				strNewEta = time.strftime('%H:%M:%S', time.localtime(self.newEta))
				self.setValue("eta2", "Remaining: %s  New ETA: %s" % (strRemains, strNewEta))
				
				pctDiff = float(elapsed + remains)/float(self.duration) * 100.0
				secDiff = math.fabs(elapsed + remains - self.duration)
				strDiff = formatElapsed(secDiff)
				if pctDiff < 100:
					schedule = "%s ahead of sched (%.2f%%)" % (strDiff, (100.0-pctDiff))
				elif pctDiff >100:
					schedule = "%s behind sched (%.2f%%)" % (strDiff, (pctDiff - 100))
				else:
					schedule = "on schedule"
				self.setValue("eta3", "Elapsed: %s - %s" % (strElapsed, schedule))
			else:
				self.setValue("eta2", "")
				self.setValue("eta3", "")
		else:
			self.setValue("eta", "Start: %s" % start)
			self.setValue("eta2", "Elapsed: %s" % strElapsed)
			self.setValue("eta3", "Target File: %s" % self.sdTargetFile)
예제 #5
0
	def getStatus(self):
		stat = {}
		
		if self.mode == MODE_NORMAL:
			stat['printmode'] = "Normal Print"
			stat['filename'] = self.filename
			stat['slicecfg'] = self.slicecfg
			stat['filament'] = self.slicefil
			stat['temps'] = self.temps
			stat['slicetime'] = self.sliceTime

			stat['currentlayer'] = self.layernbr
			stat['layers'] = self.layers
			stat['currentheight'] = self.z
			
			gcode = {}
			gcode['position'] = self.position
			gcode['linecount'] = self.gcount
			if self.gcount != 0:
				stat['percent'] = "%.2f%%" % (float(self.position) / float(self.gcount) * 100.0)
			stat['gcode'] = gcode
			
			times = {}
			times['starttime'] = time.strftime('%H:%M:%S', time.localtime(self.startTime))
			times['expectedduration'] = formatElapsed(self.duration)
			times['origeta'] = time.strftime('%H:%M:%S', time.localtime(self.eta))
			times['remaining'] = formatElapsed(self.remains)
			times['neweta'] = time.strftime('%H:%M:%S', time.localtime(self.newEta)) 
			elapsed = time.time() - self.startTime
			times['elapsed'] = formatElapsed(elapsed)
			stat['times'] = times
			
		elif self.mode == MODE_TO_SD:
			stat['printmode'] = "Print to SD"
			stat['targetfile'] = self.sdTargetFile
			
			times = {}
			times['starttime'] = time.strftime('%H:%M:%S', time.localtime(self.startTime))
			elapsed = time.time() - self.startTime
			times['elapsed'] = formatElapsed(elapsed)
			stat['times'] = times

		elif self.mode == MODE_FROM_SD:
			stat['printmode'] = "Print from SD"
			gcode = {}
			gcode['position'] = self.sdposition
			gcode['maxposition'] = self.maxsdposition
			if self.maxsdposition != 0:
				gcode['percent'] = "%.2f%%" % (float(self.sdposition) / float(self.maxsdposition) * 100.0)
			stat['gcode'] = gcode
			
			times = {}
			times['starttime'] = time.strftime('%H:%M:%S', time.localtime(self.sdstartTime))
			elapsed = time.time() - self.sdstartTime
			times['elapsed'] = formatElapsed(elapsed)
			stat['times'] = times
		
		return stat
예제 #6
0
	def showValues(self):
		mode = self.rbvTimeFmt.get()

		f = self.layerfinish[self.selection]
		frev = f/self.ratio
		l = self.layertime[self.selection]
		lrev = l/self.ratio
		
		s = f-l
		srev = frev - lrev
		
		if mode == TIME_START:
			so = formatElapsed(s)
			sr = formatElapsed(srev)
			
			fo = formatElapsed(f)
			fr = formatElapsed(frev)
			
		elif mode == TIME_NOW:
			if s < self.elapsed:
				so = '< now'
			else:
				so = formatElapsed(s-self.elapsed)
				
			if srev-self.elapsed < 0:
				sr = '< now'
			else:
				sr = formatElapsed(srev-self.elapsed)
				
			if f < self.elapsed:
				fo = '< now'
			else:
				fo = formatElapsed(f-self.elapsed)
				
			if frev-self.elapsed < 0:
				fr = '< now'
			else:
				fr = formatElapsed(frev-self.elapsed)
				
		elif mode == TIME_WALL:
			so = time.strftime('%H:%M:%S', time.localtime(s+self.app.startTime))
			sr = time.strftime('%H:%M:%S', time.localtime(srev+self.app.startTime))
			
			fo = time.strftime('%H:%M:%S', time.localtime(f+self.app.startTime))
			fr = time.strftime('%H:%M:%S', time.localtime(frev+self.app.startTime))

		self.timeOStart.config(text=so)
		self.timeRStart.config(text=sr)

		self.timeOFinish.config(text=fo)
		self.timeRFinish.config(text=fr)
		
		so = formatElapsed(l)
		sr = formatElapsed(lrev)

		self.timeOLayer.config(text=so)
		self.timeRLayer.config(text=sr)
예제 #7
0
    def buildModel(self):
        cnc = CNC(self.settings.acceleration, self.settings.layerheight)
        if RECORD_TIMES:
            self.log("recording g code times in /tmp/gcodeTimes")
            fp = open("/tmp/gcodeTimes", "w")

        ln = -1
        for gl in self.gcode:
            ln += 1

            p = re.split("\\s+", gl, 1)

            params = {}
            if not (p[0].strip() in ["M117", "m117"]):
                if len(p) >= 2:
                    self.paramStr = p[1]

                    if "X" in self.paramStr:
                        params["X"] = self._get_float("X")

                    if "Y" in self.paramStr:
                        params["Y"] = self._get_float("Y")

                    if "Z" in self.paramStr:
                        params["Z"] = self._get_float("Z")

                    if "E" in self.paramStr:
                        params["E"] = self._get_float("E")

                    if "F" in self.paramStr:
                        params["F"] = self._get_float("F")

                    if "S" in self.paramStr:
                        params["S"] = self._get_float("S")

                    if "P" in self.paramStr:
                        params["P"] = self._get_float("P")

            t = cnc.execute(p[0], params, ln)
            if RECORD_TIMES:
                fp.write("(%s) (%.3f)\n" % (gl, t))

        if RECORD_TIMES:
            fp.close()

        gobj = cnc.getGObject()
        gobj.setMaxLine(ln)
        self.maxTool = cnc.getMaxTool()
        self.totalTime, self.layerTimes = cnc.getTimes()
        self.layerMap = []
        for lx in range(len(gobj)):
            self.layerMap.append(gobj.getGCodeLines(lx))

        self.totalTimeStr = formatElapsed(self.totalTime)
        self.layerTimeStr = [formatElapsed(s) for s in self.layerTimes]
        return gobj
예제 #8
0
 def updateTimeUntil(self):
     if self.currentLayer <= self.printLayer:
         self.propDlg.setProperty(PropertyEnum.timeUntil, "")
     elif self.printPosition is None:
         t = sum(self.layerTimes[:self.currentLayer])
         self.propDlg.setProperty(PropertyEnum.timeUntil, formatElapsed(t))
     else:
         t = sum(self.layerTimes[self.printLayer + 1:self.currentLayer]
                 ) + self.partialPrintingLayer()[1]
         self.propDlg.setProperty(PropertyEnum.timeUntil, formatElapsed(t))
예제 #9
0
	def buildModel(self):
		rgcode = [s.rstrip() for s in self.gcode]
		
		cnc = CNC(self.settings.acceleration, self.settings.layerheight)
		
		ln = -1
		for gl in rgcode:
			ln += 1
			if ";" in gl:
				gl = gl.split(";")[0]
			if gl.strip() == "":
				continue
			
			p = re.split("\\s+", gl, 1)
			
			params = {}
			if not (p[0].strip() in ["M117", "m117"]):
				if len(p) >= 2:
					self.paramStr = p[1]
					
					if "X" in self.paramStr:
						params["X"] = self._get_float("X")
						
					if "Y" in self.paramStr:
						params["Y"] = self._get_float("Y")
			
					if "Z" in self.paramStr:
						params["Z"] = self._get_float("Z")
			
					if "E" in self.paramStr:
						params["E"] = self._get_float("E")
			
					if "F" in self.paramStr:
						params["F"] = self._get_float("F")
			
					if "S" in self.paramStr:
						params["S"] = self._get_float("S")
			
			cnc.execute(p[0], params, ln)
			
		gobj = cnc.getGObject()
		gobj.setMaxLine(ln)
		self.totalTime, self.layerTimes = cnc.getTimes()

		self.totalTimeStr = formatElapsed(self.totalTime)
		self.layerTimeStr = [formatElapsed(s) for s in self.layerTimes]

		return gobj
예제 #10
0
	def prtMonEvent(self, evt):
		if evt.event == SD_PRINT_POSITION:
			if self.sdprintingfrom:
				if evt.pos < evt.max:
					self.infoPane.setSDPrintInfo(evt.pos, evt.max)
					self.M27Timer.Start(M27Interval, True)
			return

		if evt.event == SD_PRINT_COMPLETE:
			self.history.SDPrintFromComplete(self.prtname)
			self.endTime = time.time()
			self.infoPane.setSDPrintComplete()
			self.sdprintingfrom = False
			self.printing = False
			self.paused = False
			if self.hasFileLoaded():
				self.setStatus(PMSTATUS_READY)
				self.bPrint.Enable(True)
			else:
				self.setStatus(PMSTATUS_NOT_READY)
				self.bPrint.Enable(False)
			self.reprap.printComplete()
			self.setPrintMode(PRINT_MODE_PRINT)
			self.setPauseMode(PAUSE_MODE_PAUSE)
			self.bPull.Enable(self.app.currentPullStatus())
			self.bPause.Enable(False)
			self.bSDPrintFrom.Enable(True)
			self.bSDPrintTo.Enable(self.hasFileLoaded())
			self.bSDDelete.Enable(True)
			self.logger.LogMessage("SD Print completed at %s" % time.strftime('%H:%M:%S', time.localtime(self.endTime)))
			self.logger.LogMessage("Total elapsed time: %s" % formatElapsed(self.endTime - self.sdStartTime))
			self.updatePrintPosition(0)
			return
예제 #11
0
	def showLayerProperties(self, lx):
		if self.propDlg is None:
			return
		
		self.propDlg.setProperty(PropertyEnum.layerNum, "%d" % lx)
		x0, y0, xn, yn = self.gObj.getLayerMinMaxXY(lx)
		if x0 is None:
			self.propDlg.setProperty(PropertyEnum.minMaxXY, "")
		else:
			self.propDlg.setProperty(PropertyEnum.minMaxXY, "(%.2f, %.2f) - (%.2f, %.2f)" % (x0, y0, xn, yn))
		
		le, prior, after = self.gObj.getLayerFilament(lx)
		eUsed = self.gObj.getFilament()
		s = []
		for i in range(self.settings.nextruders):
			s.append("%.2f/%.2f    <: %.2f    >: %.2f" % (le[i], eUsed[i], prior[i], after[i]))
		self.propDlg.setProperty(PropertyEnum.filamentUsed, s)

		f, l = self.gObj.getGCodeLines(lx)
		if f is None:
			self.propDlg.setProperty(PropertyEnum.gCodeRange, "")
		else:
			self.propDlg.setProperty(PropertyEnum.gCodeRange, "%d - %d" % (f, l))
		
		self.propDlg.setProperty(PropertyEnum.layerPrintTime, self.layerTimeStr[lx])
		if lx == 0:
			self.propDlg.setProperty(PropertyEnum.timeUntil, "")
		else:
			t = sum(self.layerTimes[:lx])
			self.propDlg.setProperty(PropertyEnum.timeUntil, formatElapsed(t))
예제 #12
0
    def reprapEvent(self, evt):
        if evt.event == RepRapEventEnum.PRINT_COMPLETE:
            # TODO - do I need special consideration here for print FROM SD
            if self.state == PrintState.sdprintingto:
                self.reprap.sendNow("M29 %s" % self.sdTargetFile)
                self.reprap.suspendTempProbe(False)
                self.setSDTargetFile(None)

            if self.state == PrintState.printing:
                self.history.addEvent(
                    PrintCompleted(self.history.addFile(self.gcodeFile), ""))

            self.state = PrintState.idle
            self.oldState = None
            self.propDlg.setPrintStatus(PrintState.idle)
            self.gcf.setPrintPosition(-1)
            self.printPosition = None
            self.printLayer = 0
            self.enableButtonsByState()
            self.elapsed = time.time() - self.startTime
            cmpTime = time.time()
            expCmpTime = self.origEta - self.startTime
            cmpTimeStr = time.strftime('%H:%M:%S', time.localtime(cmpTime))
            self.log("Print completed at %s" % (cmpTimeStr))
            self.log("Total print time of %s - expected print time %s" %
                     (formatElapsed(self.elapsed), formatElapsed(expCmpTime)))
            self.reprap.printComplete()
        elif evt.event == RepRapEventEnum.PRINT_STOPPED:
            if self.state != PrintState.paused:
                self.oldState = self.state
                self.state = PrintState.paused
                self.propDlg.setPrintStatus(PrintState.paused)
                self.enableButtonsByState()
            self.reprap.printStopped()
        elif evt.event == RepRapEventEnum.PRINT_STARTED:
            pass
        elif evt.event == RepRapEventEnum.PRINT_RESUMED:
            pass
        elif evt.event == RepRapEventEnum.PRINT_ERROR:
            self.log("Error communicating with printer")
        elif evt.event == RepRapEventEnum.PRINT_SENDGCODE:
            self.log(evt.msg)
        else:
            self.log("unknown reprap event: %s" % str(evt.event))
예제 #13
0
    def updatePrintPosition(self, position):
        self.printLayer = self.getLayerByPosition(position)
        self.printPosition = position
        if self.state in [PrintState.printing, PrintState.sdprintingto]:
            posString = "%d/%d" % (position, self.maxLine)
            if self.maxLine != 0:
                pct = float(position) / float(self.maxLine) * 100.0
                posString += " (%.1f%%)" % pct
            self.propDlg.setProperty(PropertyEnum.position, posString)
            self.gcf.setPrintPosition(position)
            lx = self.gcf.getCurrentLayer()
            if lx != self.currentLayer:
                self.changeLayer(lx)

            layersSplit = self.sumLayerTimes(self.printLayer)
            layerSplit = self.partialPrintingLayer()

            self.elapsed = time.time() - self.startTime
            expected = layersSplit[0] + layerSplit[0]
            elapsedStr = "%s (expected: %s)" % (formatElapsed(
                self.elapsed), formatElapsed(expected))
            self.propDlg.setProperty(PropertyEnum.elapsed, elapsedStr)

            self.remaining = layersSplit[1] + layerSplit[1]
            self.propDlg.setProperty(PropertyEnum.remaining,
                                     formatElapsed(self.remaining))
            #TODO - probably don't need all the various time estimates when printing TO CD
            # BUT IT MAY BREAK LOGIC BELOW (update time until) that rely on these values

            newEta = time.time() + self.remaining
            revisedStr = time.strftime('%H:%M:%S', time.localtime(newEta))
            tdiff = newEta - self.origEta
            if tdiff < 0:
                revisedStr += "  (%s ahead of estimate)" % formatElapsed(
                    -tdiff)
            elif tdiff > 0:
                revisedStr += "  (%s behind estimate)" % formatElapsed(tdiff)
            self.propDlg.setProperty(PropertyEnum.revisedEta, revisedStr)
            self.updateTimeUntil()

        elif self.state == PrintState.sdprintingfrom:
            #TODO Need to convey print position when printing from SD card
            pass
예제 #14
0
	def setSDPrintComplete(self):		
		self.setValue("gcode", "")
		
		now = time.time()
		strNow = time.strftime('%H:%M:%S', time.localtime(now))
		elapsed = now - self.sdstartTime
		strElapsed = formatElapsed(elapsed)
		self.setValue("eta", "Print completed at %s, elapsed %s" % (strNow, strElapsed))
		self.setValue("eta2", "")
		self.setValue("eta3", "")
		self.sdstartTime = None
예제 #15
0
	def setPrintComplete(self):
		end = time.time();
		strEnd = time.strftime('%H:%M:%S', time.localtime(end))
		
		elapsed = end - self.startTime
		strElapsed = formatElapsed(elapsed)
		
		diff = elapsed - self.duration
		pctDiff = float(diff) / float(self.duration) * 100.0
		
		self.setValue("gcode", "")
		self.setValue("eta", "Print completed at %s, elapsed %s (%.2f%%)" % (strEnd, strElapsed, pctDiff))
		self.setValue("eta2", "")
		self.setValue("eta3", "")
예제 #16
0
	def replace(self, s, pm=None):
		d = {}

		d['%gcodebase%'] = ""
		d['%gcode%'] = ""
		
		if pm is not None:		
			st, et = self.pm.getPrintTimes()
			if st is not None:				
				d['%starttime%'] = time.strftime('%H:%M:%S', time.localtime(st))
			if et is not None:
				d['%endtime%'] = time.strftime('%H:%M:%S', time.localtime(et))
			if st is not None and et is not None:
				d['%elapsed%'] = formatElapsed(et - st)
				
			if self.pm.gcFile is not None:
				d['%gcodebase%'] = os.path.basename(self.pm.gcFile)
				d['%gcode%'] = self.pm.gcFile
						
		if 'configfile' in self.pgFilePrep.slicer.settings.keys():
			d['%config%'] = self.pgFilePrep.slicer.settings['configfile']
		else:
			d['%config%'] = ""
		d['%slicer%'] = self.pgFilePrep.settings.slicer
		
		if self.pgFilePrep.stlFile is not None:
			d['%stlbase%'] =  os.path.basename(self.pgFilePrep.stlFile)
			d['%stl%'] = self.pgFilePrep.stlFile
		else:
			d['%stlbase%'] = ""
			d['%stl%'] = ""

		if self.pgFilePrep.gcFile is not None:
			d['%slicegcodebase%'] = os.path.basename(self.pgFilePrep.gcFile)
			d['%slicegcode%'] = self.pgFilePrep.gcFile
		else:
			d['%slicegcodebase%'] = ""
			d['%slicegcode%'] = ""
			
		for t in d.keys():
			if d[t] is not None:
				s = s.replace(t, d[t])
			
		s = s.replace('""', '')
		return s
예제 #17
0
	def setSDPrintInfo(self, position, maxposition):  # printing FROM SD card
		self.sdposition = position
		self.maxsdposition = maxposition
		pct = "??"
		if self.maxsdposition != 0:
			pct = "%.2f" % (float(self.sdposition) / float(self.maxsdposition) * 100.0)
		
		self.setValue("gcode", "SD Byte %d/%d total (%s%%)" % (position, maxposition, pct))
		
		if self.sdstartTime != None:
			start = time.strftime('%H:%M:%S', time.localtime(self.sdstartTime))
			elapsed = time.time() - self.sdstartTime
			strElapsed = formatElapsed(elapsed)
			self.setValue("eta", "Start: %s  Elapsed: %s" % (start, strElapsed))
		else:
			self.setValue("eta", "")
			
		self.setValue("eta2", "")
		self.setValue("eta3", "")
예제 #18
0
    def showMetrics(self):
        if len(self.gcode) != 0:
            self.paused = False
            self.toolbar.initializeToolbar()
            self.toolbar.checkAllowPrint()
            self.allowGEdit()

            self.logger.logMsg(
                "Width: %f mm (%f -> %f)" % (self.gcodeInfo.width, self.gcodeInfo.xmin, self.gcodeInfo.xmax)
            )
            self.logger.logMsg(
                "Depth: %f mm (%f -> %f)" % (self.gcodeInfo.depth, self.gcodeInfo.ymin, self.gcodeInfo.ymax)
            )
            self.logger.logMsg(
                "Height: is %f mm (%f -> %f)" % (self.gcodeInfo.height, self.gcodeInfo.zmin, self.gcodeInfo.zmax)
            )
            self.logger.logMsg("Total extrusion length: %f mm" % self.gcodeInfo.filament_length())

            self.logger.logMsg("Estimated print time: %s" % formatElapsed(self.estEta))
예제 #19
0
	def printComplete(self):
		self.app.endTime = time.time()
		self.app.elapsedTime = self.app.endTime - self.app.startTime
		self.logger.logMsg("Printing completed at %s" % time.strftime('%H:%M:%S', time.localtime()))
		self.logger.logMsg("Total elapsed time: %s" % formatElapsed(self.app.elapsedTime))
		self.bPrintMode = PR_PRINT
		self.bPrint.config(text=printText[PR_PRINT], state=NORMAL)
		
		self.bPauseMode = PM_PAUSE
		self.bPause.config(text=pauseText[PM_PAUSE], state=DISABLED)
		
		self.app.printing = False
		self.bSlice.config(state=NORMAL)
		self.bLoad.config(state=NORMAL)
		self.app.allowLoadGCodeMenu(True)
		self.app.allowSliceMenu(True)
		self.app.paused = False
		self.app.gc.updatePrintProgress(0)
		self.app.closeAllReports()
		if self.settings.endprintmacro is not None:
			self.app.doMacro(name=self.settings.endprintmacro, silent=True)
예제 #20
0
    def replace(self, s, slicer):
        if slicer == SLIC3R:
            d = os.path.expandvars(os.path.expanduser(self.settings.s3profiledir))
            profile = os.path.join(d, self.slic3r.getProfile() + ".ini")
        else:
            profile = self.skeinforge.getProfile()

        d = {}

        d["%starttime%"] = time.strftime("%H:%M:%S", time.localtime(self.startTime))
        d["%endtime%"] = time.strftime("%H:%M:%S", time.localtime(self.endTime))
        d["%elapsed%"] = formatElapsed(self.elapsedTime)

        d["%profile%"] = profile
        d["%slicer%"] = self.settings.slicer

        if self.StlFile is not None:
            d["%stlbase%"] = os.path.basename(self.StlFile)
            d["%stl%"] = self.StlFile
        else:
            d["%stlbase%"] = ""
            d["%stl%"] = ""

        if self.GCodeFile is not None:
            d["%gcodebase%"] = os.path.basename(self.GCodeFile)
            d["%gcode%"] = self.GCodeFile
        else:
            d["%gcodebase%"] = ""
            d["%gcode%"] = ""

        for t in d.keys():
            if d[t] is not None:
                s = s.replace(t, d[t])

        s = s.replace('""', "")
        return s
예제 #21
0
	def updateUntilTime(self):
		t = self.timeUntil(self.layernbr)
		if t == 0:
			self.setValue("timeuntil", "")
		else:
			self.setValue("timeuntil", "%s" % formatElapsed(self.timeUntil(self.layernbr)))
예제 #22
0
	def queryStatus(self, q):
		status = {}
		if self.app.connected:
			status['connection'] = "on-line"
			status['location'] = {}
			status['location']['X'] = self.app.location[XAxis]
			status['location']['Y'] = self.app.location[YAxis]
			status['location']['Z'] = self.app.location[ZAxis]
			status['location']['E'] = self.app.location[EAxis]
			if self.app.printing or self.app.paused:
				if self.app.printing:
					status['printing'] = "printing"
				else:
					status['printing'] = "paused"
					
				ngcode = len(self.app.gcode)
				if ngcode == 0:
					pct = 0.0
				else:
					pct = float(self.printer.queueindex) / float(ngcode) * float(100)

				status['position'] = {}						
				status['position']['linecount'] = self.printer.queueindex
				status['position']['linemax'] = ngcode
				status['position']['pct'] = "%.2f" % pct
					
			elif self.app.sdprinting or self.app.sdpaused:
				if self.app.sdprinting:
					status['printing'] = "SD printing"
				else:
					status['printing'] = "SD paused"
					
				if self.app.sdmaxbytes == 0:
					pct = 0.0
				else:
					pct = float(self.app.sdbytes) / float(self.app.sdmaxbytes) * float(100)
					
				status['position'] = {}
				status['position']['bytecount'] = self.app.sdbytes
				status['position']['bytemax'] = self.app.sdmaxbytes
				status['position']['pct'] = "%.2f" % pct
			else:
				status['printing'] = "idle"
		else:
			status['connection'] = "off-line"

		if self.app.slicing:
			status['file'] = "slicing"
		elif self.app.GCodeFile:
			status['file'] = self.app.GCodeFile

		if self.app.monitorTemp and self.app.connected:
			status['temps'] = {}
			status['temps']['bed'] = self.app.bedtemp
			status['temps']['bedtarget'] = self.app.bedtarget
			status['temps']['ext'] = self.app.exttemp
			status['temps']['exttarget'] = self.app.exttarget
		
		if self.app.printing:
			elapsed = time.time() - self.app.startTime
			status['times'] = {}
			status['times']['start'] = "%s" % time.strftime('%H:%M:%S', time.localtime(self.app.startTime))
			status['times']['elapsed'] = "%s" % formatElapsed(elapsed)
			status['times']['eta'] = self.app.eta
			status['times']['origestimate'] = "%s" % formatElapsed(self.app.estEta)
		
		return {'status' : status}
예제 #23
0
	def doPrint(self, evt):
		if self.sdpaused:
			self.reprap.send_now("M26 S0")
			self.setPauseMode(PAUSE_MODE_PAUSE)
			self.setPrintMode(PRINT_MODE_PRINT)
			self.bPrint.Enable(False)
			self.bPull.Enable(False)
			self.sdprintingfrom = True
			self.reprap.send_now("M24")
			self.infoPane.setSDStartTime(time.time())
			self.M27Timer.Start(M27Interval, True)
		else:
			self.printPos = 0
			self.startTime = time.time()
			self.endTime = None
			if self.printMode == PRINT_MODE_RESTART:
				action = "restarted"
				self.reprap.restartPrint(self.model)
			else:
				self.history.PrintStart(self.gcFile, self.prtname)
				action = "started"
				self.reprap.startPrint(self.model)
			self.logger.LogMessage("Print %s at %s" % (action, time.strftime('%H:%M:%S', time.localtime(self.startTime))))
			self.origEta = self.startTime + self.model.duration
			self.logger.LogMessage("ETA at %s (%s)" % (time.strftime('%H:%M:%S', time.localtime(self.startTime+self.model.duration)), formatElapsed(self.model.duration)))
			self.countGLines = len(self.model)
			self.infoPane.setMode(MODE_NORMAL)
			self.infoPane.setStartTime(self.startTime)
			self.infoPane.showFileInfo()
			self.bPrint.Enable(False)
			self.bPull.Enable(False)
			self.bPause.Enable(False)
			self.setSDTargetFile(None)
예제 #24
0
    def statusChecker(self):
        printing = False
        if self.app.connected:
            stat = "Printer on-line"
            if self.app.printing or self.app.paused:
                if self.app.printing:
                    printing = True
                    stat += " - printing"
                else:
                    stat += " - paused"
                ngcode = len(self.app.gcode)
                if ngcode == 0:
                    self.app.percent = 0.0
                else:
                    self.app.percent = float(self.printer.queueindex) / float(ngcode) * float(100)
                    stat += " | Line# %d/%d (%.2f%%)" % (self.printer.queueindex, ngcode, self.app.percent)

            elif self.app.sdprinting or self.app.sdpaused:
                if self.app.sdprinting:
                    printing = True
                    stat += " - SD printing"
                else:
                    stat += " - SD paused"
                if self.app.sdmaxbytes == 0:
                    self.app.percent = 0.0
                else:
                    self.app.percent = float(self.app.sdbytes) / float(self.app.sdmaxbytes) * float(100)
                    stat += " | Byte# %d/%d (%.2f%%)" % (self.app.sdbytes, self.app.sdmaxbytes, self.app.percent)
            else:
                self.app.percent = 0.0
                stat += " - idle"
            stat += " | Loc: X%.2f Y%.2f Z%.2f E%.2f" % (
                self.app.location[0],
                self.app.location[1],
                self.app.location[2],
                self.app.location[3],
            )
        else:
            self.app.percent = 0.0
            stat = "Printer off-line"

        if DLPRINTER in self.app.dataLoggers.keys():
            if printing:
                self.app.dataLoggers[DLPRINTER].startLog()
            else:
                self.app.dataLoggers[DLPRINTER].endLog()

        if self.app.slicing:
            stat += " | Slicing %s" % os.path.basename(self.app.slicerfn)

        self.iCycle += 1
        if self.iCycle % TEMPINTERVAL == 0:
            if self.app.monitorTemp:
                if self.app.connected:
                    self.printer.send_now("M105")

        if self.iCycle % SDINTERVAL == 0 and self.app.sdprinting:
            if self.app.connected:
                self.printer.send_now("M27")

        if self.iCycle % LOCINTERVAL == 0:
            if self.app.connected:
                self.app.m114count += 1
                self.printer.send_now("M114")
                if self.settings.speedcommand is not None:
                    self.app.speedcount += 1
                    self.printer.send_now(self.settings.speedcommand)

        if self.iCycle % SCREENINTERVAL == 0:
            self.app.updateScreen()

        hotend = False
        buildplatform = False
        if self.app.monitorTemp and self.app.connected:
            if self.app.bedtarget != 0:
                buildplatform = True
            if self.app.exttarget != 0:
                hotend = True
            stat += " | Temps: Bed: %.1f/%.1f  Hotend: %.1f/%.1f" % (
                self.app.bedtemp,
                self.app.bedtarget,
                self.app.exttemp,
                self.app.exttarget,
            )
        else:
            stat += " | Temps: Bed: ??/??  Hotend: ??/??"

        if DLHOTEND in self.app.dataLoggers.keys():
            if hotend:
                self.app.dataLoggers[DLHOTEND].startLog()
            else:
                self.app.dataLoggers[DLHOTEND].endLog()

        if DLBUILDPLATFORM in self.app.dataLoggers.keys():
            if buildplatform:
                self.app.dataLoggers[DLBUILDPLATFORM].startLog()
            else:
                self.app.dataLoggers[DLBUILDPLATFORM].endLog()

        if self.app.printing:
            elapsed = time.time() - self.app.startTime
            stat += " | Elapsed: %s" % formatElapsed(elapsed)

            if self.app.percent > 2:
                remains = self.app.calcEta(self.printer.queueindex, elapsed)
                eta = formatElapsed(remains)
            else:
                eta = "??"
            stat += " | ETA: " + eta
            self.app.eta = eta

        self.config(state=NORMAL)
        self.delete(0, END)
        self.insert(0, stat)
        self.config(state="readonly")

        if self.iCycle % M117INTERVAL == 0 and self.app.printing and self.settings.lcdstatus:
            self.m117cycle += 1
            if self.app.connected and self.app.GCodeFile is not None:
                fname = os.path.splitext(os.path.basename(self.app.GCodeFile))[0]
                if self.m117cycle % 3 == 0 and self.app.eta != "??" and len(self.app.eta) < 6:
                    eta = self.app.eta.replace(":", "m")
                    self.printer.send_now("M117 %-12.12s %5.5ss" % (fname, eta))
                else:
                    self.printer.send_now("M117 %-12.12s %5.1f%%" % (fname, self.app.percent))

        self.afterID = self.app.master.after(INTERVAL * 1000, self.statusChecker)
예제 #25
0
	def refresh(self):
		if not self.app.printing:
			self.doCancel()
			return False
			
		if self.selection != None:
			currentZ = str(self.layerZ[self.selection])
			firstZ = self.layerZ[0]
		else:
			currentZ = ""
			firstZ = None
			
		self.now = time.time()		
		self.elapsed = self.now - self.app.startTime
		foundLayer = False
		line = self.printer.queueindex
		thisLayerLine = 0
		thisLayerTime = 0.0
		thisLayerStart = 0.0
		for i in self.app.timeLayers:
			if i[0] >= line:
				nextLayerLine = i[0]
				foundLayer = True
				break
				
			thisLayerLine = i[0]
			thisLayerTime = i[1]
			thisLayerStart = i[2] - thisLayerTime
					
		if not foundLayer:
			self.doCancel()
			return False

		pct = (line-thisLayerLine)/float(nextLayerLine-thisLayerLine)
		thisLayerTime *= pct
		self.ratio = (thisLayerStart+thisLayerTime)/float(self.elapsed)
		if self.ratio == 0:
			self.logger.logMsg("Invalid ratio calculated")
			self.doCancel()
			return False

		self.layertime = []
		self.layerfinish = []
		self.layerZ = []
		self.selection = None
		skipped = 0
		for i in self.app.timeLayers:
			if i[0] >= thisLayerLine:
				if currentZ == str(i[3]):
					self.selection = len(self.layerZ)
					
				self.layerZ.append(i[3])
				self.layertime.append(i[1])
				self.layerfinish.append(i[2])
			else:
				skipped += 1

		if self.selection == None:
			self.selection = 0
			
		if len(self.layerZ) == 0:
			self.logger.logMsg("Unable to find any unprinted layers")
			self.doCancel()
			return False

		if self.layerZ[0] != firstZ:
			# new first layer - update things	
			self.lbLayers.delete(0, END)
			ln = skipped	
			for i in self.layerZ:
				ln += 1
				s = "%8.3f (%d)" % (i, ln)
				self.lbLayers.insert(END, s)
				
			self.lbLayers.selection_set(self.selection)
			
			self.lbLayers.see(self.selection)
			
		s = time.strftime('%H:%M:%S', time.localtime(self.app.startTime))
		self.timePStart.config(text=s)
		
		s = formatElapsed(self.elapsed)
		self.timeElapsed.config(text=s)
		
		s = time.strftime('%H:%M:%S', time.localtime(self.now))
		self.timeNow.config(text=s)
		
		self.showValues()
		return True
예제 #26
0
	def reprapEvent(self, evt):
		if evt.event in [ PRINT_STARTED, PRINT_RESUMED ]:
			self.printing = True
			self.setStatus(PMSTATUS_PRINTING)
			self.paused = False
			self.setPrintMode(PRINT_MODE_PRINT)
			self.setPauseMode(PAUSE_MODE_PAUSE)
			self.bPrint.Enable(False)
			self.bPull.Enable(False)
			self.bPause.Enable(True)
			if self.hassd:
				self.bSDPrintFrom.Enable(False)
				self.bSDPrintTo.Enable(False)
				self.bSDDelete.Enable(False)
			
		elif evt.event in [PRINT_STOPPED, PRINT_AUTOSTOPPED]:
			self.paused = True
			self.setStatus(PMSTATUS_PAUSED)
			self.printing = False
			self.reprap.printStopped()
			self.setPrintMode(PRINT_MODE_RESTART)
			self.setPauseMode(PAUSE_MODE_RESUME)
			self.bPrint.Enable(True)
			self.bPull.Enable(self.app.currentPullStatus())
			self.bPause.Enable(True)
			if self.hassd:
				self.bSDPrintFrom.Enable(True)
				self.bSDPrintTo.Enable(True)
				self.bSDDelete.Enable(True)
			if evt.event == PRINT_AUTOSTOPPED:
				self.logger.LogMessage(evt.msg)
				
			
		elif evt.event == PRINT_COMPLETE:
			
			self.endTime = time.time()
			self.infoPane.setPrintComplete()
			if self.sdTargetFile is not None:
				self.history.SDPrintToComplete(self.prtname)
				self.reprap.send_now("M29 %s" % self.sdTargetFile)
				self.suspendTempProbe(False)
				self.setSDTargetFile(None)
			else:
				self.history.PrintComplete(self.prtname)

			self.printing = False
			self.paused = False
			self.setStatus(PMSTATUS_READY)
			self.reprap.printComplete()
			self.setPrintMode(PRINT_MODE_PRINT)
			self.setPauseMode(PAUSE_MODE_PAUSE)
			self.bPrint.Enable(True)
			self.bPull.Enable(self.app.currentPullStatus())
			self.bPause.Enable(False)
			if self.hassd:
				self.bSDPrintFrom.Enable(True)
				self.bSDPrintTo.Enable(True)
				self.bSDDelete.Enable(True)
			self.logger.LogMessage("Print completed at %s" % time.strftime('%H:%M:%S', time.localtime(self.endTime)))
			self.logger.LogMessage("Total elapsed time: %s" % formatElapsed(self.endTime - self.startTime))
			rs, rq = self.reprap.getCounters()
			if rs + rq != 0:
				self.logger.LogMessage("Resend Requests: %d, messages retransmitted: %d" % (rq, rs))
			self.updatePrintPosition(0)
			
		elif evt.event == PRINT_ERROR:
			self.logger.LogError(evt.msg)
			self.app.doPrinterError(self.prtname)
			
		elif evt.event == PRINT_MESSAGE:
			if evt.immediate:
				self.logger.LogMessage(evt.msg)
			elif evt.primary:
				self.logger.LogCMessage(evt.msg)
			else:
				self.logger.LogGMessage(evt.msg)

		elif evt.event == QUEUE_DRAINED:
			self.logger.LogMessage("Print Queue drained")
			self.reprap.reprapEvent(evt)
		else:
			self.reprap.reprapEvent(evt)
예제 #27
0
 def getToNowStr(self):
     return formatElapsed(self.getToNow())