Exemplo n.º 1
0
	def _sendNext(self):
		with self._sendNextLock:
			if self._gcodePos >= len(self._gcodeList):
				self._changeState(self.STATE_OPERATIONAL)
				return
			if self._gcodePos == 100:
				self._printStartTime100 = time.time()
			line = self._gcodeList[self._gcodePos]
			if type(line) is tuple:
				self._printSection = line[1]
				line = line[0]
			try:
				if matchesGcode(line, "M0") or matchesGcode(line, "M1"):
					self.setPause(True)
					line = "M105" # Don't send the M0 or M1 to the machine, as M0 and M1 are handled as an LCD menu pause.
				if self._printSection in self._feedRateModifier:
					line = re.sub('F([0-9]*)', lambda m: 'F' + str(int(int(m.group(1)) * self._feedRateModifier[self._printSection])), line)
				if (matchesGcode(line, "G0") or matchesGcode(line, "G1")) and 'Z' in line:
					z = float(re.search('Z([0-9\.]*)', line).group(1))
					if self._currentZ != z:
						self._currentZ = z
						self._callback.mcZChange(z)
			except:
				self._log("Unexpected error: %s" % (getExceptionString()))
			self._sendCommand(line, True)
			self._gcodePos += 1
			self._callback.mcProgress()
Exemplo n.º 2
0
	def _sendNext(self):
		with self._sendNextLock:
			line = self._currentFile.getNext()
			if line is None:
				if self.isStreaming():
					self._sendCommand("M29")
					filename = self._currentFile.getFilename()
					self._currentFile = None
					self._callback.mcFileTransferDone()
					self._changeState(self.STATE_OPERATIONAL)
					eventManager().fire("TransferDone", filename)
				else:
					self._callback.mcPrintjobDone()
					self._changeState(self.STATE_OPERATIONAL)
					eventManager().fire("PrintDone", self._currentFile.getFilename())
				return

			if type(line) is tuple:
				self._printSection = line[1]
				line = line[0]

			if not self.isStreaming():
				try:
					if matchesGcode(line, "M0") or matchesGcode(line, "M1"):
						self.setPause(True)
						line = "M105" # Don't send the M0 or M1 to the machine, as M0 and M1 are handled as an LCD menu pause.
					if (matchesGcode(line, "G0") or matchesGcode(line, "G1")) and 'Z' in line:
						z = float(re.search('Z([0-9\.]*)', line).group(1))
						if self._currentZ != z:
							self._currentZ = z
							self._callback.mcZChange(z)
				except:
					self._log("Unexpected error: %s" % (getExceptionString()))
			self._sendCommand(line, True)
			self._callback.mcProgress()
Exemplo n.º 3
0
	def _sendNext(self):
		with self._sendNextLock:
			if self._gcodePos >= len(self._gcodeList):
				self._changeState(self.STATE_OPERATIONAL)
				return
			if self._gcodePos == 100:
				self._printStartTime100 = time.time()
			line = self._gcodeList[self._gcodePos]
			if type(line) is tuple:
				self._printSection = line[1]
				line = line[0]
			try:
				if matchesGcode(line, "M0") or matchesGcode(line, "M1"):
					self.setPause(True)
					line = "M105" # Don't send the M0 or M1 to the machine, as M0 and M1 are handled as an LCD menu pause.
				if self._printSection in self._feedRateModifier:
					line = re.sub('F([0-9]*)', lambda m: 'F' + str(int(int(m.group(1)) * self._feedRateModifier[self._printSection])), line)
				if (matchesGcode(line, "G0") or matchesGcode(line, "G1")) and 'Z' in line:
					z = float(re.search('Z([0-9\.]*)', line).group(1))
					if self._currentZ != z:
						self._currentZ = z
						self._callback.mcZChange(z)
			except:
				self._log("Unexpected error: %s" % (getExceptionString()))
			self._sendCommand(line, True)
			self._gcodePos += 1
			self._callback.mcProgress()
Exemplo n.º 4
0
	def _sendCommand(self, cmd, sendChecksum=False):
		# Make sure we are only handling one sending job at a time
		with self._sendingLock:
			if self._serial is None:
				return

			if not self.isStreaming():
				for gcode in gcodeToEvent.keys():
					if matchesGcode(cmd, gcode):
						eventManager().fire(gcodeToEvent[gcode])

				if matchesGcode(cmd, "M109") or matchesGcode(cmd, "M190"):
					self._heatupWaitStartTime = time.time()
				if matchesGcode(cmd, "M104") or matchesGcode(cmd, "M109"):
					try:
						self._targetTemp = float(re.search('S([0-9]+)', cmd).group(1))
					except:
						pass
				if matchesGcode(cmd, "M140") or matchesGcode(cmd, "M190"):
					try:
						self._bedTargetTemp = float(re.search('S([0-9]+)', cmd).group(1))
					except:
						pass

				#supplress M110 commands from Grbl, does not play nice.
				#^ this has been disabled in gcodeInterpreter.py
				if matchesGcode(cmd, "M110"):
					newLineNumber = None
					if " N" in cmd:
						try:
							newLineNumber = int(re.search("N([0-9]+)", cmd).group(1))
						except:
							pass
					else:
						newLineNumber = 0

						# send M110 command with new line number
					self._doSendWithChecksum(cmd, newLineNumber)
					self._currentLine = newLineNumber + 1

						# after a reset of the line number we have no way to determine what line exactly the printer now wants
					self._lastLines = []
					self._resendDelta = None
					return
			self._doSend(cmd, sendChecksum)
Exemplo n.º 5
0
	def _sendCommand(self, cmd, sendChecksum=False):
		# Make sure we are only handling one sending job at a time
		with self._sendingLock:
			if self._serial is None:
				return
			if matchesGcode(cmd, "M109") or matchesGcode(cmd, "M190"):
				self._heatupWaitStartTime = time.time()
			if matchesGcode(cmd, "M104") or matchesGcode(cmd, "M109"):
				try:
					self._targetTemp = float(re.search('S([0-9]+)', cmd).group(1))
				except:
					pass
			if matchesGcode(cmd, "M140") or matchesGcode(cmd, "M190"):
				try:
					self._bedTargetTemp = float(re.search('S([0-9]+)', cmd).group(1))
				except:
					pass

			if matchesGcode(cmd, "M110"):
				newLineNumber = None
				if " N" in cmd:
					try:
						newLineNumber = int(re.search("N([0-9]+)", cmd).group(1))
					except:
						pass
				else:
					newLineNumber = 0

				if settings().getBoolean(["feature", "resetLineNumbersWithPrefixedN"]) and newLineNumber is not None:
					# let's rewrite the M110 command to fit repetier syntax
					self._addToLastLines(cmd)
					self._doSendWithChecksum("M110", newLineNumber)
				else:
					self._doSend(cmd, sendChecksum)

				if newLineNumber is not None:
					self._currentLine = newLineNumber + 1

				# after a reset of the line number we have no way to determine what line exactly the printer now wants
				self._lastLines = []
				self._resendDelta = None
			else:
				self._doSend(cmd, sendChecksum)
Exemplo n.º 6
0
	def _sendCommand(self, cmd, sendChecksum=False):
		# Make sure we are only handling one sending job at a time
		with self._sendingLock:
			if self._serial is None:
				return
			if matchesGcode(cmd, "M109") or matchesGcode(cmd, "M190"):
				self._heatupWaitStartTime = time.time()
			if matchesGcode(cmd, "M104") or matchesGcode(cmd, "M109"):
				try:
					self._targetTemp = float(re.search('S([0-9]+)', cmd).group(1))
				except:
					pass
			if matchesGcode(cmd, "M140") or matchesGcode(cmd, "M190"):
				try:
					self._bedTargetTemp = float(re.search('S([0-9]+)', cmd).group(1))
				except:
					pass

			if matchesGcode(cmd, "M110"):
				newLineNumber = None
				if " N" in cmd:
					try:
						newLineNumber = int(re.search("N([0-9]+)", cmd).group(1))
					except:
						pass
				else:
					newLineNumber = 0

				if settings().getBoolean(["feature", "resetLineNumbersWithPrefixedN"]) and newLineNumber is not None:
					# let's rewrite the M110 command to fit repetier syntax
					self._addToLastLines(cmd)
					self._doSendWithChecksum("M110", newLineNumber)
				else:
					self._doSend(cmd, sendChecksum)

				if newLineNumber is not None:
					self._currentLine = newLineNumber + 1

				# after a reset of the line number we have no way to determine what line exactly the printer now wants
				self._lastLines = []
				self._resendDelta = None
			else:
				self._doSend(cmd, sendChecksum)