Example #1
0
    def OnSettingChange(self, e):
        if self.type == 'profile':
            profile.putProfileSetting(self.configName, self.GetValue())
        else:
            profile.putPreference(self.configName, self.GetValue())
        result = validators.SUCCESS
        msgs = []
        for validator in self.validators:
            res, err = validator.validate()
            if res == validators.ERROR:
                result = res
            elif res == validators.WARNING and result != validators.ERROR:
                result = res
            if res != validators.SUCCESS:
                msgs.append(err)
        if result == validators.ERROR:
            self.ctrl.SetBackgroundColour('Red')
        elif result == validators.WARNING:
            self.ctrl.SetBackgroundColour('Yellow')
        else:
            self.ctrl.SetBackgroundColour(self.defaultBGColour)
        self.ctrl.Refresh()

        self.validationMsg = '\n'.join(msgs)
        self.panel.main.UpdatePopup(self)
Example #2
0
    def __init__(self, parent):
        super(UltimakerCalibrateStepsPerEPage,
              self).__init__(parent, "Ultimaker Calibration")

        if profile.getPreference('steps_per_e') == '0':
            profile.putPreference('steps_per_e', '865.888')

        self.AddText(
            "Calibrating the Steps Per E requires some manual actions.")
        self.AddText("First remove any filament from your machine.")
        self.AddText(
            "Next put in your filament so the tip is aligned with the\ntop of the extruder drive."
        )
        self.AddText("We'll push the filament 100mm")
        self.extrudeButton = self.AddButton("Extrude 100mm filament")
        self.AddText(
            "Now measure the amount of extruded filament:\n(this can be more or less then 100mm)"
        )
        self.lengthInput, self.saveLengthButton = self.AddTextCtrlButton(
            '100', 'Save')
        self.AddText("This results in the following steps per E:")
        self.stepsPerEInput = self.AddTextCtrl(
            profile.getPreference('steps_per_e'))
        self.AddText("You can repeat these steps to get better calibration.")
        self.AddSeperator()
        self.AddText(
            "If you still have filament in your printer which needs\nheat to remove, press the heat up button below:"
        )
        self.heatButton = self.AddButton("Heatup for filament removal")

        self.saveLengthButton.Bind(wx.EVT_BUTTON, self.OnSaveLengthClick)
        self.extrudeButton.Bind(wx.EVT_BUTTON, self.OnExtrudeClick)
        self.heatButton.Bind(wx.EVT_BUTTON, self.OnHeatClick)
Example #3
0
def main(splash):
    #app = wx.App(False)
    if profile.getPreference('machine_type') == 'unknown':
        if platform.system() == "Darwin":
            #Check if we need to copy our examples
            exampleFile = os.path.expanduser(
                '~/CuraExamples/UltimakerRobot_support.stl')
            if not os.path.isfile(exampleFile):
                try:
                    os.makedirs(os.path.dirname(exampleFile))
                except:
                    pass
                for filename in glob.glob(
                        os.path.normpath(
                            os.path.join(
                                os.path.dirname(os.path.abspath(__file__)),
                                '..', 'example', '*.*'))):
                    shutil.copy(
                        filename,
                        os.path.join(os.path.dirname(exampleFile),
                                     os.path.basename(filename)))
                profile.putPreference('lastFile', exampleFile)
        splash.Show(False)
        configWizard.configWizard()
    if profile.getPreference('startMode') == 'Simple':
        simpleMode.simpleModeWindow()
    else:
        mainWindow()
Example #4
0
def main():
	parser = OptionParser(usage="usage: %prog [options] <filename>.stl")
	parser.add_option("-i", "--ini", action="store", type="string", dest="profileini", help="Load settings from a profile ini file")
	parser.add_option("-P", "--project", action="store_true", dest="openprojectplanner", help="Open the project planner")
	parser.add_option("-F", "--flat", action="store_true", dest="openflatslicer", help="Open the 2D SVG slicer (unfinished)")
	parser.add_option("-r", "--print", action="store", type="string", dest="printfile", help="Open the printing interface, instead of the normal cura interface.")
	parser.add_option("-p", "--profile", action="store", type="string", dest="profile", help="Internal option, do not use!")
	parser.add_option("-s", "--slice", action="store_true", dest="slice", help="Slice the given files instead of opening them in Cura")
	(options, args) = parser.parse_args()
	if options.profile != None:
		profile.loadGlobalProfileFromString(options.profile)
	if options.profileini != None:
		profile.loadGlobalProfile(options.profileini)
	if options.openprojectplanner != None:
		from gui import projectPlanner
		projectPlanner.main()
		return
	if options.openflatslicer != None:
		from gui import flatSlicerWindow
		flatSlicerWindow.main()
		return
	if options.printfile != None:
		from gui import printWindow
		printWindow.startPrintInterface(options.printfile)
		return

	if options.slice != None:
		from util import sliceRun
		sliceRun.runSlice(args)
	else:
		if len(args) > 0:
			profile.putPreference('lastFile', ';'.join(args))
		from gui import splashScreen
		splashScreen.showSplash(mainWindowRunCallback)
Example #5
0
	def __init__(self, parent):
		super(UltimakerCalibrateStepsPerEPage, self).__init__(parent, "Ultimaker Calibration")

		if profile.getPreference('steps_per_e') == '0':
			profile.putPreference('steps_per_e', '865.888')
		
		self.AddText("Calibrating the Steps Per E requires some manual actions.")
		self.AddText("First remove any filament from your machine.")
		self.AddText("Next put in your filament so the tip is aligned with the\ntop of the extruder drive.")
		self.AddText("We'll push the filament 100mm")
		self.extrudeButton = self.AddButton("Extrude 100mm filament")
		self.AddText("Now measure the amount of extruded filament:\n(this can be more or less then 100mm)")
		p = wx.Panel(self)
		p.SetSizer(wx.BoxSizer(wx.HORIZONTAL))
		self.lengthInput = wx.TextCtrl(p, -1, '100')
		p.GetSizer().Add(self.lengthInput, 0, wx.RIGHT, 8)
		self.saveLengthButton = wx.Button(p, -1, 'Save')
		p.GetSizer().Add(self.saveLengthButton, 0)
		self.GetSizer().Add(p, 0, wx.LEFT, 5)
		self.AddText("This results in the following steps per E:")
		self.stepsPerEInput = wx.TextCtrl(self, -1, profile.getPreference('steps_per_e'))
		self.GetSizer().Add(self.stepsPerEInput, 0, wx.LEFT, 5)
		self.AddText("You can repeat these steps to get better calibration.")
		self.AddSeperator()
		self.AddText("If you still have filament in your printer which needs\nheat to remove, press the heat up button below:")
		self.heatButton = self.AddButton("Heatup for filament removal")
		
		self.saveLengthButton.Bind(wx.EVT_BUTTON, self.OnSaveLengthClick)
		self.extrudeButton.Bind(wx.EVT_BUTTON, self.OnExtrudeClick)
		self.heatButton.Bind(wx.EVT_BUTTON, self.OnHeatClick)
Example #6
0
	def OnSettingChange(self, e):
		if self.type == 'profile':
			profile.putProfileSetting(self.configName, self.GetValue())
		else:
			profile.putPreference(self.configName, self.GetValue())
		result = validators.SUCCESS
		msgs = []
		for validator in self.validators:
			res, err = validator.validate()
			if res == validators.ERROR:
				result = res
			elif res == validators.WARNING and result != validators.ERROR:
				result = res
			if res != validators.SUCCESS:
				msgs.append(err)
		if result == validators.ERROR:
			self.ctrl.SetBackgroundColour('Red')
		elif result == validators.WARNING:
			self.ctrl.SetBackgroundColour('Yellow')
		else:
			self.ctrl.SetBackgroundColour(self.defaultBGColour)
		self.ctrl.Refresh()

		self.validationMsg = '\n'.join(msgs)
		self.panel.main.UpdatePopup(self)
Example #7
0
def main():
    #app = wx.App(False)
    if profile.getPreference('wizardDone') == 'False':
        configWizard.configWizard()
        profile.putPreference("wizardDone", "True")
    if profile.getPreference('startMode') == 'Simple':
        simpleMode.simpleModeWindow()
    else:
        mainWindow()
Example #8
0
	def OnDropFiles(self, filenames):
		for filename in filenames:
			item = ProjectObject(self, filename)
			profile.putPreference('lastFile', item.filename)
			self.list.append(item)
			self.selection = item
			self._updateListbox()
		self.OnListSelect(None)
		self.preview.Refresh()
Example #9
0
	def OnDropFiles(self, filenames):
		for filename in filenames:
			item = ProjectObject(self, filename)
			profile.putPreference('lastFile', item.filename)
			self.list.append(item)
			self.selection = item
			self._updateListbox()
		self.OnListSelect(None)
		self.preview.Refresh()
Example #10
0
def main():
	#app = wx.App(False)
	if profile.getPreference('wizardDone') == 'False':
		configWizard.configWizard()
		profile.putPreference("wizardDone", "True")
	if profile.getPreference('startMode') == 'Simple':
		simpleMode.simpleModeWindow()
	else:
		mainWindow()
Example #11
0
	def OnLoadModel(self, e):
		dlg=wx.FileDialog(self, "Open file to print", os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_OPEN|wx.FD_FILE_MUST_EXIST)
		dlg.SetWildcard("STL files (*.stl)|*.stl;*.STL")
		if dlg.ShowModal() == wx.ID_OK:
			self.filelist = [dlg.GetPath()]
			profile.putPreference('lastFile', ';'.join(self.filelist))
			self.preview3d.loadModelFiles(self.filelist)
			self.preview3d.setViewMode("Normal")
		dlg.Destroy()
Example #12
0
def main():
    app = wx.App(False)
    if profile.getPreference("wizardDone") == "False":
        configWizard.configWizard()
        profile.putPreference("wizardDone", "True")
    if profile.getPreference("startMode") == "Simple":
        simpleMode.simpleModeWindow()
    else:
        mainWindow()
    app.MainLoop()
Example #13
0
	def OnAddModel(self, e):
		dlg=wx.FileDialog(self, "Open file to batch slice", os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_OPEN|wx.FD_FILE_MUST_EXIST|wx.FD_MULTIPLE)
		dlg.SetWildcard("STL files (*.stl)|*.stl;*.STL")
		if dlg.ShowModal() == wx.ID_OK:
			for filename in dlg.GetPaths():
				profile.putPreference('lastFile', filename)
				self.list.append(filename)
				self.selection = filename
				self._updateListbox()
		dlg.Destroy()
Example #14
0
	def _showModelLoadDialog(self, amount):
		filelist = []
		for i in xrange(0, amount):
			filelist.append(self._showOpenDialog("Open file to print"))
			if filelist[-1] == False:
				return
			self.SetTitle(filelist[-1] + ' - Cura - ' + version.getVersion())
		self.filelist = filelist
		profile.putPreference('lastFile', ';'.join(self.filelist))
		self.preview3d.loadModelFiles(self.filelist)
		self.preview3d.setViewMode("Normal")
Example #15
0
 def _showModelLoadDialog(self, amount):
     filelist = []
     for i in xrange(0, amount):
         filelist.append(self._showOpenDialog("Open file to print"))
         if filelist[-1] == False:
             return
         self.SetTitle(filelist[-1] + ' - Cura - ' + version.getVersion())
     self.filelist = filelist
     profile.putPreference('lastFile', ';'.join(self.filelist))
     self.preview3d.loadModelFiles(self.filelist)
     self.preview3d.setViewMode("Normal")
Example #16
0
	def _showOpenDialog(self, title, wildcard = meshLoader.wildcardFilter()):
		dlg=wx.FileDialog(self, title, os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_OPEN|wx.FD_FILE_MUST_EXIST)
		dlg.SetWildcard(wildcard)
		if dlg.ShowModal() == wx.ID_OK:
			filename = dlg.GetPath()
			dlg.Destroy()
			if not(os.path.exists(filename)):
				return False
			profile.putPreference('lastFile', filename)
			return filename
		dlg.Destroy()
		return False
Example #17
0
	def OnAddModel(self, e):
		dlg=wx.FileDialog(self, "Open file to print", os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_OPEN|wx.FD_FILE_MUST_EXIST|wx.FD_MULTIPLE)
		dlg.SetWildcard("STL files (*.stl)|*.stl;*.STL")
		if dlg.ShowModal() == wx.ID_OK:
			for filename in dlg.GetPaths():
				item = ProjectObject(self, filename)
				profile.putPreference('lastFile', item.filename)
				self.list.append(item)
				self.selection = item
				self._updateListbox()
				self.OnListSelect(None)
		self.preview.Refresh()
		dlg.Destroy()
Example #18
0
 def OnLoadModel(self, e):
     dlg = wx.FileDialog(self,
                         "Open file to print",
                         os.path.split(
                             profile.getPreference('lastFile'))[0],
                         style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
     dlg.SetWildcard(meshLoader.wildcardFilter())
     if dlg.ShowModal() == wx.ID_OK:
         self.filelist = [dlg.GetPath()]
         profile.putPreference('lastFile', ';'.join(self.filelist))
         self.preview3d.loadModelFiles(self.filelist, True)
         self.preview3d.setViewMode("Normal")
     dlg.Destroy()
Example #19
0
	def OnAddModel(self, e):
		dlg=wx.FileDialog(self, "Open file to print", os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_OPEN|wx.FD_FILE_MUST_EXIST|wx.FD_MULTIPLE)
		dlg.SetWildcard(meshLoader.wildcardFilter())
		if dlg.ShowModal() == wx.ID_OK:
			for filename in dlg.GetPaths():
				item = ProjectObject(self, filename)
				profile.putPreference('lastFile', item.filename)
				self.list.append(item)
				self.selection = item
				self._updateListbox()
				self.OnListSelect(None)
		self.preview.Refresh()
		dlg.Destroy()
Example #20
0
	def onLoad(self, event):

		dlg = wx.FileDialog(self, "Open file to print", style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
		dlg.SetWildcard(meshLoader.wildcardFilter())

		if dlg.ShowModal() == wx.ID_OK:
			frame = self.GetParent().GetParent().GetParent()
			frame.filename = dlg.GetPath() 
			frame.step5_panel.ClearPrintSummary()
			profile.putPreference('lastFile', frame.filename)
			transform = frame.step2_panel
			transform.load(frame.filename)
			frame.onNext(None)
		dlg.Destroy()
Example #21
0
 def _showOpenDialog(self, title, wildcard="STL files (*.stl)|*.stl;*.STL"):
     dlg = wx.FileDialog(
         self, title, os.path.split(profile.getPreference("lastFile"))[0], style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST
     )
     dlg.SetWildcard(wildcard)
     if dlg.ShowModal() == wx.ID_OK:
         filename = dlg.GetPath()
         dlg.Destroy()
         if not (os.path.exists(filename)):
             return False
         profile.putPreference("lastFile", filename)
         return filename
     dlg.Destroy()
     return False
Example #22
0
 def OnAddModel(self, e):
     dlg = wx.FileDialog(
         self,
         "Open file to batch slice",
         os.path.split(profile.getPreference('lastFile'))[0],
         style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST | wx.FD_MULTIPLE)
     dlg.SetWildcard("STL files (*.stl)|*.stl;*.STL")
     if dlg.ShowModal() == wx.ID_OK:
         for filename in dlg.GetPaths():
             profile.putPreference('lastFile', filename)
             self.list.append(filename)
             self.selection = filename
             self._updateListbox()
     dlg.Destroy()
Example #23
0
 def _showOpenDialog(self, title, wildcard=meshLoader.wildcardFilter()):
     dlg = wx.FileDialog(self,
                         title,
                         os.path.split(
                             profile.getPreference('lastFile'))[0],
                         style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
     dlg.SetWildcard(wildcard)
     if dlg.ShowModal() == wx.ID_OK:
         filename = dlg.GetPath()
         dlg.Destroy()
         if not (os.path.exists(filename)):
             return False
         profile.putPreference('lastFile', filename)
         return filename
     dlg.Destroy()
     return False
Example #24
0
	def StoreData(self):
		profile.putPreference('machine_width', self.machineWidth.GetValue())
		profile.putPreference('machine_depth', self.machineDepth.GetValue())
		profile.putPreference('machine_height', self.machineHeight.GetValue())
		profile.putProfileSetting('nozzle_size', self.nozzleSize.GetValue())
		profile.putProfileSetting('machine_center_x', profile.getPreferenceFloat('machine_width') / 2)
		profile.putProfileSetting('machine_center_y', profile.getPreferenceFloat('machine_depth') / 2)
		profile.putProfileSetting('wall_thickness', float(profile.getProfileSettingFloat('nozzle_size')) * 2)
		profile.putPreference('has_heated_bed', str(self.heatedBed.GetValue()))
Example #25
0
def main(splash):
	#app = wx.App(False)
	if profile.getPreference('machine_type') == 'unknown':
		if platform.system() == "Darwin":
			#Check if we need to copy our examples
			exampleFile = os.path.expanduser('~/CuraExamples/UltimakerRobot_support.stl')
			if not os.path.isfile(exampleFile):
				try:
					os.makedirs(os.path.dirname(exampleFile))
				except:
					pass
				for filename in glob.glob(os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'example', '*.*'))):
					shutil.copy(filename, os.path.join(os.path.dirname(exampleFile), os.path.basename(filename)))
				profile.putPreference('lastFile', exampleFile)
		splash.Show(False)
		configWizard.configWizard()
	if profile.getPreference('startMode') == 'Simple':
		simpleMode.simpleModeWindow()
	else:
		mainWindow()
Example #26
0
 def StoreData(self):
     profile.putPreference('machine_width', self.machineWidth.GetValue())
     profile.putPreference('machine_depth', self.machineDepth.GetValue())
     profile.putPreference('machine_height', self.machineHeight.GetValue())
     profile.putProfileSetting('nozzle_size', self.nozzleSize.GetValue())
     profile.putProfileSetting(
         'machine_center_x',
         profile.getPreferenceFloat('machine_width') / 2)
     profile.putProfileSetting(
         'machine_center_y',
         profile.getPreferenceFloat('machine_depth') / 2)
     profile.putProfileSetting(
         'wall_thickness',
         float(profile.getProfileSettingFloat('nozzle_size')) * 2)
     profile.putPreference('has_heated_bed', str(self.heatedBed.GetValue()))
Example #27
0
	def OnNormalSwitch(self, e):
		from gui import mainWindow
		profile.putPreference('startMode', 'Normal')
		mainWindow.mainWindow()
		self.Close()
Example #28
0
 def OnSimpleSwitch(self, e):
     profile.putPreference('startMode', 'Simple')
     simpleMode.simpleModeWindow()
     self.Close()
Example #29
0
 def OnDropFiles(self, filenames):
     for filename in filenames:
         profile.putPreference('lastFile', filename)
         self.list.append(filename)
         self.selection = filename
         self._updateListbox()
Example #30
0
 def StoreData(self):
     profile.putPreference('steps_per_e', self.stepsPerEInput.GetValue())
Example #31
0
 def StoreData(self):
     if self.UltimakerRadio.GetValue():
         profile.putPreference("machine_width", "205")
         profile.putPreference("machine_depth", "205")
         profile.putPreference("machine_height", "200")
         profile.putProfileSetting("nozzle_size", "0.4")
         profile.putProfileSetting("machine_center_x", "100")
         profile.putProfileSetting("machine_center_y", "100")
     else:
         profile.putPreference("machine_width", "80")
         profile.putPreference("machine_depth", "80")
         profile.putPreference("machine_height", "60")
         profile.putProfileSetting("nozzle_size", "0.5")
         profile.putProfileSetting("machine_center_x", "40")
         profile.putProfileSetting("machine_center_y", "40")
     profile.putProfileSetting("wall_thickness", float(profile.getProfileSetting("nozzle_size")) * 2)
Example #32
0
 def StoreData(self):
     if self.UltimakerRadio.GetValue():
         profile.putPreference('machine_width', '205')
         profile.putPreference('machine_depth', '205')
         profile.putPreference('machine_height', '200')
         profile.putPreference('machine_type', 'ultimaker')
         profile.putProfileSetting('nozzle_size', '0.4')
         profile.putProfileSetting('machine_center_x', '100')
         profile.putProfileSetting('machine_center_y', '100')
     else:
         profile.putPreference('machine_width', '80')
         profile.putPreference('machine_depth', '80')
         profile.putPreference('machine_height', '60')
         profile.putPreference('machine_type', 'reprap')
         profile.putPreference('startMode', 'Normal')
         profile.putProfileSetting('nozzle_size', '0.5')
         profile.putProfileSetting('machine_center_x', '40')
         profile.putProfileSetting('machine_center_y', '40')
     profile.putProfileSetting(
         'wall_thickness',
         float(profile.getProfileSetting('nozzle_size')) * 2)
Example #33
0
 def OnDropFiles(self, filenames):
     self.filelist = filenames
     profile.putPreference('lastFile', ';'.join(self.filelist))
     self.preview3d.loadModelFiles(self.filelist, True)
     self.preview3d.setViewMode("Normal")
Example #34
0
 def OnSimpleSwitch(self, e):
     profile.putPreference("startMode", "Simple")
     simpleMode.simpleModeWindow()
     self.Close()
Example #35
0
	def __init__(self, port = None, baudrate = None, callbackObject = None):
		if port == None:
			port = profile.getPreference('serial_port')
		if baudrate == None:
			if profile.getPreference('serial_baud') == 'AUTO':
				baudrate = 0
			else:
				baudrate = int(profile.getPreference('serial_baud'))
		if callbackObject == None:
			callbackObject = MachineComPrintCallback()

		self._callback = callbackObject
		self._state = self.STATE_NONE
		self._serial = None
		self._baudrateDetectList = baudrateList()
		self._baudrateDetectRetry = 0
		self._temp = 0
		self._bedTemp = 0
		self._gcodeList = None
		self._gcodePos = 0
		self._commandQueue = queue.Queue()
		self._logQueue = queue.Queue(256)
		self._feedRateModifier = {}
		self._currentZ = -1
		
		if port == 'AUTO':
			programmer = stk500v2.Stk500v2()
			self._log("Serial port list: %s" % (str(serialList())))
			for p in serialList():
				try:
					self._log("Connecting to: %s" % (p))
					programmer.connect(p)
					self._serial = programmer.leaveISP()
					profile.putPreference('serial_port_auto', p)
					break
				except ispBase.IspError as (e):
					self._log("Error while connecting to %s: %s" % (p, str(e)))
					pass
				except:
					self._log("Unexpected error while connecting to serial port: %s %s" % (p, getExceptionString()))
				programmer.close()
		elif port == 'VIRTUAL':
			self._serial = VirtualPrinter()
		else:
			try:
				self._log("Connecting to: %s" % (port))
				if baudrate == 0:
					self._serial = Serial(port, 115200, timeout=0.1)
				else:
					self._serial = Serial(port, baudrate, timeout=2)
			except:
				self._log("Unexpected error while connecting to serial port: %s %s" % (port, getExceptionString()))
		if self._serial == None:
			self._log("Failed to open serial port (%s)" % (port))
			self._errorValue = 'Failed to autodetect serial port.'
			self._changeState(self.STATE_ERROR)
			return
		self._log("Connected to: %s, starting monitor" % (self._serial))
		if baudrate == 0:
			self._changeState(self.STATE_DETECT_BAUDRATE)
		else:
			self._changeState(self.STATE_CONNECTING)
		self.thread = threading.Thread(target=self._monitor)
		self.thread.daemon = True
		self.thread.start()
Example #36
0
 def OnNormalSwitch(self, e):
     from gui import mainWindow
     profile.putPreference('startMode', 'Normal')
     mainWindow.mainWindow()
     self.Close()
Example #37
0
 def _loadModels(self, filelist):
     self.filelist = filelist
     self.SetTitle(filelist[-1] + " - Cura - " + version.getVersion())
     profile.putPreference("lastFile", ";".join(self.filelist))
     self.preview3d.loadModelFiles(self.filelist, True)
     self.preview3d.setViewMode("Normal")
Example #38
0
	def StoreData(self):
		if self.UltimakerRadio.GetValue():
			profile.putPreference('machine_width', '205')
			profile.putPreference('machine_depth', '205')
			profile.putPreference('machine_height', '200')
			profile.putPreference('machine_type', 'ultimaker')
			profile.putProfileSetting('nozzle_size', '0.4')
			profile.putProfileSetting('machine_center_x', '100')
			profile.putProfileSetting('machine_center_y', '100')
		else:
			profile.putPreference('machine_width', '80')
			profile.putPreference('machine_depth', '80')
			profile.putPreference('machine_height', '60')
			profile.putPreference('machine_type', 'reprap')
			profile.putPreference('startMode', 'Normal')
			profile.putProfileSetting('nozzle_size', '0.5')
			profile.putProfileSetting('machine_center_x', '40')
			profile.putProfileSetting('machine_center_y', '40')
		profile.putProfileSetting('wall_thickness', float(profile.getProfileSetting('nozzle_size')) * 2)
Example #39
0
	def StoreData(self):
		profile.putPreference('steps_per_e', self.stepsPerEInput.GetValue())
Example #40
0
	def OnSimpleSwitch(self, e):
		profile.putPreference('startMode', 'Simple')
		simpleMode.simpleModeWindow()
		self.Close()
	def _monitor(self):
		#Open the serial port.
		if self._port == 'AUTO':
			self._changeState(self.STATE_DETECT_SERIAL)
			programmer = stk500v2.Stk500v2()
			self._log("Serial port list: %s" % (str(serialList())))
			for p in serialList():
				try:
					self._log("Connecting to: %s" % (p))
					programmer.connect(p)
					self._serial = programmer.leaveISP()
					profile.putPreference('serial_port_auto', p)
					break
				except ispBase.IspError as (e):
					self._log("Error while connecting to %s: %s" % (p, str(e)))
					pass
				except:
					self._log("Unexpected error while connecting to serial port: %s %s" % (p, getExceptionString()))
				programmer.close()
		elif self._port == 'VIRTUAL':
			self._changeState(self.STATE_OPEN_SERIAL)
			self._serial = VirtualPrinter()
		else:
			self._changeState(self.STATE_OPEN_SERIAL)
			try:
				self._log("Connecting to: %s" % (self._port))
				if self._baudrate == 0:
					self._serial = serial.Serial(str(self._port), 115200, timeout=0.1, writeTimeout=10000)
				else:
					self._serial = serial.Serial(str(self._port), self._baudrate, timeout=2, writeTimeout=10000)
			except:
				self._log("Unexpected error while connecting to serial port: %s %s" % (self._port, getExceptionString()))
		if self._serial == None:
			self._log("Failed to open serial port (%s)" % (self._port))
			self._errorValue = 'Failed to autodetect serial port.'
			self._changeState(self.STATE_ERROR)
			return
		self._log("Connected to: %s, starting monitor" % (self._serial))
		if self._baudrate == 0:
			self._changeState(self.STATE_DETECT_BAUDRATE)
		else:
			self._changeState(self.STATE_CONNECTING)

		#Start monitoring the serial port.
		timeout = time.time() + 5
		tempRequestTimeout = timeout
		while True:
			line = self._readline()
			if line == None:
				break
			
			#No matter the state, if we see an error, goto the error state and store the error for reference.
			if line.startswith('Error:'):
				#Oh YEAH, consistency.
				# Marlin reports an MIN/MAX temp error as "Error:x\n: Extruder switched off. MAXTEMP triggered !\n"
				#	But a bed temp error is reported as "Error: Temperature heated bed switched off. MAXTEMP triggered !!"
				#	So we can have an extra newline in the most common case. Awesome work people.
				if re.match('Error:[0-9]\n', line):
					line = line.rstrip() + self._readline()
				#Skip the communication errors, as those get corrected.
				if 'checksum mismatch' in line or 'Line Number is not Last Line Number' in line or 'No Line Number with checksum' in line:
					pass
				elif not self.isError():
					self._errorValue = line[6:]
					self._changeState(self.STATE_ERROR)
			if ' T:' in line or line.startswith('T:'):
				self._temp = float(re.search("[0-9\.]*", line.split('T:')[1]).group(0))
				if ' B:' in line:
					self._bedTemp = float(re.search("[0-9\.]*", line.split(' B:')[1]).group(0))
				self._callback.mcTempUpdate(self._temp, self._bedTemp, self._targetTemp, self._bedTargetTemp)
				#If we are waiting for an M109 or M190 then measure the time we lost during heatup, so we can remove that time from our printing time estimate.
				if not 'ok' in line and self._heatupWaitStartTime != 0:
					t = time.time()
					self._heatupWaitTimeLost = t - self._heatupWaitStartTime
					self._heatupWaitStartTime = t
			elif line.strip() != '' and line.strip() != 'ok' and not line.startswith('Resend:') and line != 'echo:Unknown command:""\n' and self.isOperational():
				self._callback.mcMessage(line)

			if self._state == self.STATE_DETECT_BAUDRATE:
				if line == '' or time.time() > timeout:
					if len(self._baudrateDetectList) < 1:
						self.close()
						self._errorValue = "No more baudrates to test, and no suitable baudrate found."
						self._changeState(self.STATE_ERROR)
					elif self._baudrateDetectRetry > 0:
						self._baudrateDetectRetry -= 1
						self._serial.write('\n')
						self._log("Baudrate test retry: %d" % (self._baudrateDetectRetry))
						self._sendCommand("M105")
						self._testingBaudrate = True
					else:
						baudrate = self._baudrateDetectList.pop(0)
						try:
							self._serial.baudrate = baudrate
							self._serial.timeout = 0.5
							self._log("Trying baudrate: %d" % (baudrate))
							self._baudrateDetectRetry = 5
							self._baudrateDetectTestOk = 0
							timeout = time.time() + 5
							self._serial.write('\n')
							self._sendCommand("M105")
							self._testingBaudrate = True
						except:
							self._log("Unexpected error while setting baudrate: %d %s" % (baudrate, getExceptionString()))
				elif 'ok' in line and 'T:' in line:
					self._baudrateDetectTestOk += 1
					if self._baudrateDetectTestOk < 10:
						self._log("Baudrate test ok: %d" % (self._baudrateDetectTestOk))
						self._sendCommand("M105")
					else:
						self._sendCommand("M999")
						self._serial.timeout = 2
						profile.putPreference('serial_baud_auto', self._serial.baudrate)
						self._changeState(self.STATE_OPERATIONAL)
				else:
					self._testingBaudrate = False
			elif self._state == self.STATE_CONNECTING:
				if line == '':
					self._sendCommand("M105")
				elif 'ok' in line:
					self._changeState(self.STATE_OPERATIONAL)
				if time.time() > timeout:
					self.close()
			elif self._state == self.STATE_OPERATIONAL:
				#Request the temperature on comm timeout (every 2 seconds) when we are not printing.
				if line == '':
					self._sendCommand("M105")
					tempRequestTimeout = time.time() + 5
			elif self._state == self.STATE_PRINTING:
				if line == '' and time.time() > timeout:
					self._log("Communication timeout during printing, forcing a line")
					line = 'ok'
				#Even when printing request the temperture every 5 seconds.
				if time.time() > tempRequestTimeout:
					self._commandQueue.put("M105")
					tempRequestTimeout = time.time() + 5
				if 'ok' in line:
					timeout = time.time() + 5
					if not self._commandQueue.empty():
						self._sendCommand(self._commandQueue.get())
					else:
						self._sendNext()
				elif "resend" in line.lower() or "rs" in line:
					try:
						self._gcodePos = int(line.replace("N:"," ").replace("N"," ").replace(":"," ").split()[-1])
					except:
						if "rs" in line:
							self._gcodePos = int(line.split()[1])
		self._log("Connection closed, closing down monitor")
Example #42
0
	def _monitor(self):
		timeout = time.time() + 5
		tempRequestTimeout = timeout
		while True:
			line = self._readline()
			if line == None:
				break
			
			#No matter the state, if we see an error, goto the error state and store the error for reference.
			if line.startswith('Error: '):
				#Oh YEAH, consistency.
				# Marlin reports an MIN/MAX temp error as "Error: x\n: Extruder switched off. MAXTEMP triggered !\n"
				#	But a bed temp error is reported as "Error: Temperature heated bed switched off. MAXTEMP triggered !!"
				#	So we can have an extra newline in the most common case. Awesome work people.
				if re.match('Error: [0-9]\n', line):
					line = line.rstrip() + self._readline()
				self._errorValue = line
				self._changeState(self.STATE_ERROR)
			if ' T:' in line:
				self._temp = float(re.search("[0-9\.]*", line.split(' T:')[1]).group(0))
				if ' B:' in line:
					self._bedTemp = float(re.search("[0-9\.]*", line.split(' B:')[1]).group(0))
				self._callback.mcTempUpdate(self._temp, self._bedTemp)
			elif line.strip() != 'ok':
				self._callback.mcMessage(line)

			if self._state == self.STATE_DETECT_BAUDRATE:
				if line == '' or time.time() > timeout:
					if len(self._baudrateDetectList) < 1:
						self._log("No more baudrates to test, and no suitable baudrate found.")
						self.close()
					elif self._baudrateDetectRetry > 0:
						self._baudrateDetectRetry -= 1
						self._serial.write('\n')
						self._sendCommand("M105")
					else:
						baudrate = self._baudrateDetectList.pop(0)
						try:
							self._serial.baudrate = baudrate
							self._serial.timeout = 0.5
							self._log("Trying baudrate: %d" % (baudrate))
							self._baudrateDetectRetry = 5
							timeout = time.time() + 5
							self._serial.write('\n')
							self._sendCommand("M105")
						except:
							self._log("Unexpected error while setting baudrate: %d %s" % (baudrate, getExceptionString()))
				elif 'ok' in line:
					self._serial.timeout = 2
					profile.putPreference('serial_baud_auto', self._serial.baudrate)
					self._changeState(self.STATE_OPERATIONAL)
			elif self._state == self.STATE_CONNECTING:
				if line == '':
					self._sendCommand("M105")
				elif 'ok' in line:
					self._changeState(self.STATE_OPERATIONAL)
				if time.time() > timeout:
					self.close()
			elif self._state == self.STATE_OPERATIONAL:
				#Request the temperature on comm timeout (every 2 seconds) when we are not printing.
				if line == '':
					self._sendCommand("M105")
					tempRequestTimeout = time.time() + 5
			elif self._state == self.STATE_PRINTING:
				if line == '' and time.time() > timeout:
					self._log("Communication timeout during printing, forcing a line")
					line = 'ok'
				#Even when printing request the temperture every 5 seconds.
				if time.time() > tempRequestTimeout:
					self._commandQueue.put("M105")
					tempRequestTimeout = time.time() + 5
				if 'ok' in line:
					timeout = time.time() + 5
					if not self._commandQueue.empty():
						self._sendCommand(self._commandQueue.get())
					else:
						self._sendNext()
				elif "resend" in line.lower() or "rs" in line:
					try:
						self._gcodePos = int(line.replace("N:"," ").replace("N"," ").replace(":"," ").split()[-1])
					except:
						if "rs" in line:
							self._gcodePos = int(line.split()[1])
		self._log("Connection closed, closing down monitor")
Example #43
0
 def _loadModels(self, filelist):
     self.filelist = filelist
     self.SetTitle(filelist[-1] + ' - Cura - ' + version.getVersion())
     profile.putPreference('lastFile', ';'.join(self.filelist))
     self.preview3d.loadModelFiles(self.filelist, True)
     self.preview3d.setViewMode("Normal")
Example #44
0
    def _monitor(self):
        timeout = time.time() + 5
        while True:
            line = self._readline()
            if line == None:
                break

            #No matter the state, if we see an error, goto the error state and store the error for reference.
            if line.startswith('Error: '):
                #Oh YEAH, consistency.
                # Marlin reports an MIN/MAX temp error as "Error: x\n: Extruder switched off. MAXTEMP triggered !\n"
                #	But a bed temp error is reported as "Error: Temperature heated bed switched off. MAXTEMP triggered !!"
                #	So we can have an extra newline in the most common case. Awesome work people.
                if re.match('Error: [0-9]\n', line):
                    line = line.rstrip() + self._readline()
                self._errorValue = line
                self._changeState(self.STATE_ERROR)
            if 'T:' in line:
                self._temp = float(
                    re.search("[0-9\.]*",
                              line.split('T:')[1]).group(0))
                if 'B:' in line:
                    self._bedTemp = float(
                        re.search("[0-9\.]*",
                                  line.split('B:')[1]).group(0))
                self._callback.mcTempUpdate(self._temp, self._bedTemp)
            elif line.strip() != 'ok':
                self._callback.mcMessage(line)

            if self._state == self.STATE_DETECT_BAUDRATE:
                if line == '' or time.time() > timeout:
                    if len(self._baudrateDetectList) < 1:
                        self._log(
                            "No more baudrates to test, and no suitable baudrate found."
                        )
                        self.close()
                    elif self._baudrateDetectRetry > 0:
                        self._baudrateDetectRetry -= 1
                        self._serial.write('\n')
                        self._sendCommand("M105")
                    else:
                        baudrate = self._baudrateDetectList.pop(0)
                        try:
                            self._serial.baudrate = baudrate
                            self._serial.timeout = 0.5
                            self._log("Trying baudrate: %d" % (baudrate))
                            self._baudrateDetectRetry = 5
                            timeout = time.time() + 5
                            self._serial.write('\n')
                            self._sendCommand("M105")
                        except:
                            self._log(
                                "Unexpected error while setting baudrate: %d %s"
                                % (baudrate, getExceptionString()))
                elif 'ok' in line:
                    self._serial.timeout = 2
                    profile.putPreference('serial_baud_auto',
                                          self._serial.baudrate)
                    self._changeState(self.STATE_OPERATIONAL)
            elif self._state == self.STATE_CONNECTING:
                if line == '':
                    self._sendCommand("M105")
                elif 'ok' in line:
                    self._changeState(self.STATE_OPERATIONAL)
                if time.time() > timeout:
                    self.close()
            elif self._state == self.STATE_OPERATIONAL:
                #Request the temperature on comm timeout (every 2 seconds) when we are not printing.
                if line == '':
                    self._sendCommand("M105")
                    tempRequestTimeout = time.time() + 5
            elif self._state == self.STATE_PRINTING:
                if line == '' and time.time() > timeout:
                    self._log(
                        "Communication timeout during printing, forcing a line"
                    )
                    line = 'ok'
                #Even when printing request the temperture every 5 seconds.
                if time.time() > tempRequestTimeout:
                    self._commandQueue.put("M105")
                    tempRequestTimeout = time.time() + 5
                if 'ok' in line:
                    timeout = time.time() + 5
                    if not self._commandQueue.empty():
                        self._sendCommand(self._commandQueue.get())
                    else:
                        self._sendNext()
                elif "resend" in line.lower() or "rs" in line:
                    try:
                        self._gcodePos = int(
                            line.replace("N:", " ").replace("N", " ").replace(
                                ":", " ").split()[-1])
                    except:
                        if "rs" in line:
                            self._gcodePos = int(line.split()[1])
        self._log("Connection closed, closing down monitor")
Example #45
0
    def _monitor(self):
        #Open the serial port.
        if self._port == 'AUTO':
            self._changeState(self.STATE_DETECT_SERIAL)
            programmer = stk500v2.Stk500v2()
            self._log("Serial port list: %s" % (str(serialList())))
            for p in serialList():
                try:
                    self._log("Connecting to: %s" % (p))
                    programmer.connect(p)
                    self._serial = programmer.leaveISP()
                    profile.putPreference('serial_port_auto', p)
                    break
                except ispBase.IspError as (e):
                    self._log("Error while connecting to %s: %s" % (p, str(e)))
                    pass
                except:
                    self._log(
                        "Unexpected error while connecting to serial port: %s %s"
                        % (p, getExceptionString()))
                programmer.close()
        elif self._port == 'VIRTUAL':
            self._changeState(self.STATE_OPEN_SERIAL)
            self._serial = VirtualPrinter()
        else:
            self._changeState(self.STATE_OPEN_SERIAL)
            try:
                self._log("Connecting to: %s" % (self._port))
                if self._baudrate == 0:
                    self._serial = serial.Serial(self._port,
                                                 115200,
                                                 timeout=0.1,
                                                 writeTimeout=10000)
                else:
                    self._serial = serial.Serial(self._port,
                                                 self._baudrate,
                                                 timeout=2,
                                                 writeTimeout=10000)
            except:
                self._log(
                    "Unexpected error while connecting to serial port: %s %s" %
                    (self._port, getExceptionString()))
        if self._serial == None:
            self._log("Failed to open serial port (%s)" % (self._port))
            self._errorValue = 'Failed to autodetect serial port.'
            self._changeState(self.STATE_ERROR)
            return
        self._log("Connected to: %s, starting monitor" % (self._serial))
        if self._baudrate == 0:
            self._changeState(self.STATE_DETECT_BAUDRATE)
        else:
            self._changeState(self.STATE_CONNECTING)

        #Start monitoring the serial port.
        timeout = time.time() + 5
        tempRequestTimeout = timeout
        while True:
            line = self._readline()
            if line == None:
                break

            #No matter the state, if we see an error, goto the error state and store the error for reference.
            if line.startswith('Error:'):
                #Oh YEAH, consistency.
                # Marlin reports an MIN/MAX temp error as "Error:x\n: Extruder switched off. MAXTEMP triggered !\n"
                #	But a bed temp error is reported as "Error: Temperature heated bed switched off. MAXTEMP triggered !!"
                #	So we can have an extra newline in the most common case. Awesome work people.
                if re.match('Error:[0-9]\n', line):
                    line = line.rstrip() + self._readline()
                #Skip the communication errors, as those get corrected.
                if 'checksum mismatch' in line or 'Line Number is not Last Line Number' in line or 'No Line Number with checksum' in line:
                    pass
                elif not self.isError():
                    self._errorValue = line[6:]
                    self._changeState(self.STATE_ERROR)
            if ' T:' in line or line.startswith('T:'):
                self._temp = float(
                    re.search("[0-9\.]*",
                              line.split('T:')[1]).group(0))
                if ' B:' in line:
                    self._bedTemp = float(
                        re.search("[0-9\.]*",
                                  line.split(' B:')[1]).group(0))
                self._callback.mcTempUpdate(self._temp, self._bedTemp,
                                            self._targetTemp,
                                            self._bedTargetTemp)
                #If we are waiting for an M109 or M190 then measure the time we lost during heatup, so we can remove that time from our printing time estimate.
                if not 'ok' in line and self._heatupWaitStartTime != 0:
                    t = time.time()
                    self._heatupWaitTimeLost = t - self._heatupWaitStartTime
                    self._heatupWaitStartTime = t
            elif line.strip() != '' and line.strip(
            ) != 'ok' and not line.startswith(
                    'Resend:'
            ) and line != 'echo:Unknown command:""\n' and self.isOperational():
                self._callback.mcMessage(line)

            if self._state == self.STATE_DETECT_BAUDRATE:
                if line == '' or time.time() > timeout:
                    if len(self._baudrateDetectList) < 1:
                        self.close()
                        self._errorValue = "No more baudrates to test, and no suitable baudrate found."
                        self._changeState(self.STATE_ERROR)
                    elif self._baudrateDetectRetry > 0:
                        self._baudrateDetectRetry -= 1
                        self._serial.write('\n')
                        self._log("Baudrate test retry: %d" %
                                  (self._baudrateDetectRetry))
                        self._sendCommand("M105")
                        self._testingBaudrate = True
                    else:
                        baudrate = self._baudrateDetectList.pop(0)
                        try:
                            self._serial.baudrate = baudrate
                            self._serial.timeout = 0.5
                            self._log("Trying baudrate: %d" % (baudrate))
                            self._baudrateDetectRetry = 5
                            self._baudrateDetectTestOk = 0
                            timeout = time.time() + 5
                            self._serial.write('\n')
                            self._sendCommand("M105")
                            self._testingBaudrate = True
                        except:
                            self._log(
                                "Unexpected error while setting baudrate: %d %s"
                                % (baudrate, getExceptionString()))
                elif 'ok' in line and 'T:' in line:
                    self._baudrateDetectTestOk += 1
                    if self._baudrateDetectTestOk < 10:
                        self._log("Baudrate test ok: %d" %
                                  (self._baudrateDetectTestOk))
                        self._sendCommand("M105")
                    else:
                        self._sendCommand("M999")
                        self._serial.timeout = 2
                        profile.putPreference('serial_baud_auto',
                                              self._serial.baudrate)
                        self._changeState(self.STATE_OPERATIONAL)
                else:
                    self._testingBaudrate = False
            elif self._state == self.STATE_CONNECTING:
                if line == '':
                    self._sendCommand("M105")
                elif 'ok' in line:
                    self._changeState(self.STATE_OPERATIONAL)
                if time.time() > timeout:
                    self.close()
            elif self._state == self.STATE_OPERATIONAL:
                #Request the temperature on comm timeout (every 2 seconds) when we are not printing.
                if line == '':
                    self._sendCommand("M105")
                    tempRequestTimeout = time.time() + 5
            elif self._state == self.STATE_PRINTING:
                if line == '' and time.time() > timeout:
                    self._log(
                        "Communication timeout during printing, forcing a line"
                    )
                    line = 'ok'
                #Even when printing request the temperture every 5 seconds.
                if time.time() > tempRequestTimeout:
                    self._commandQueue.put("M105")
                    tempRequestTimeout = time.time() + 5
                if 'ok' in line:
                    timeout = time.time() + 5
                    if not self._commandQueue.empty():
                        self._sendCommand(self._commandQueue.get())
                    else:
                        self._sendNext()
                elif "resend" in line.lower() or "rs" in line:
                    try:
                        self._gcodePos = int(
                            line.replace("N:", " ").replace("N", " ").replace(
                                ":", " ").split()[-1])
                    except:
                        if "rs" in line:
                            self._gcodePos = int(line.split()[1])
        self._log("Connection closed, closing down monitor")
Example #46
0
	def OnDropFiles(self, filenames):
		self.filelist = filenames
		profile.putPreference('lastFile', ';'.join(self.filelist))
		self.preview3d.loadModelFiles(self.filelist, True)
		self.preview3d.setViewMode("Normal")
Example #47
0
	def OnDropFiles(self, filenames):
		for filename in filenames:
			profile.putPreference('lastFile', filename)
			self.list.append(filename)
			self.selection = filename
			self._updateListbox()
Example #48
0
    def __init__(self, port=None, baudrate=None, callbackObject=None):
        if port == None:
            port = profile.getPreference('serial_port')
        if baudrate == None:
            if profile.getPreference('serial_baud') == 'AUTO':
                baudrate = 0
            else:
                baudrate = int(profile.getPreference('serial_baud'))
        if callbackObject == None:
            callbackObject = MachineComPrintCallback()

        self._callback = callbackObject
        self._state = self.STATE_NONE
        self._serial = None
        self._baudrateDetectList = baudrateList()
        self._baudrateDetectRetry = 0
        self._temp = 0
        self._bedTemp = 0
        self._gcodeList = None
        self._gcodePos = 0
        self._commandQueue = queue.Queue()
        self._logQueue = queue.Queue(256)
        self._feedRateModifier = {}
        self._currentZ = -1

        if port == 'AUTO':
            programmer = stk500v2.Stk500v2()
            self._log("Serial port list: %s" % (str(serialList())))
            for p in serialList():
                try:
                    self._log("Connecting to: %s" % (p))
                    programmer.connect(p)
                    self._serial = programmer.leaveISP()
                    profile.putPreference('serial_port_auto', p)
                    break
                except ispBase.IspError as (e):
                    self._log("Error while connecting to %s: %s" % (p, str(e)))
                    pass
                except:
                    self._log(
                        "Unexpected error while connecting to serial port: %s %s"
                        % (p, getExceptionString()))
                programmer.close()
        elif port == 'VIRTUAL':
            self._serial = VirtualPrinter()
        else:
            try:
                self._log("Connecting to: %s" % (port))
                if baudrate == 0:
                    self._serial = Serial(port, 115200, timeout=0.1)
                else:
                    self._serial = Serial(port, baudrate, timeout=2)
            except:
                self._log(
                    "Unexpected error while connecting to serial port: %s %s" %
                    (port, getExceptionString()))
        if self._serial == None:
            self._log("Failed to open serial port (%s)" % (port))
            self._errorValue = 'Failed to autodetect serial port.'
            self._changeState(self.STATE_ERROR)
            return
        self._log("Connected to: %s, starting monitor" % (self._serial))
        if baudrate == 0:
            self._changeState(self.STATE_DETECT_BAUDRATE)
        else:
            self._changeState(self.STATE_CONNECTING)
        self.thread = threading.Thread(target=self._monitor)
        self.thread.daemon = True
        self.thread.start()