Esempio n. 1
0
def runGui(filename=None, debug=False):

	print "Starting Monkeyprint with GUI."
	# Create a debug console text buffer.
	console = monkeyprintGuiHelper.consoleText()

	# Create settings dictionary object for machine and program settings.
	programSettings = monkeyprintSettings.programSettings(console)
	
	# Create version message.
	console.addLine("You are using Monkeyprint " + str(programSettings['versionMajor'].value) + "." + str(programSettings['versionMinor'].value) + "." + str(programSettings['revision'].value))

	# Update settings from file.	
	programSettings.readFile()
	
	# Set debug mode if specified.
	if debug:
		print "Debug mode active."
		programSettings['Debug'].value = True
	else:
		programSettings['Debug'].value = False

	# Create model collection object.
	# This object contains model data and settings data for each model.
	# Pass program settings.
	modelCollection = monkeyprintModelHandling.modelCollection(programSettings, console)

	# Create gui.
	gui = monkeyprintGui.gui(modelCollection, programSettings, console, filename)

	# Start the gui main loop.
	gui.main()
Esempio n. 2
0
def runGui(filename=None, debug=False):

    # Create a debug console text buffer.
    console = monkeyprintGuiHelper.consoleText()
    #	console = None

    # Create settings dictionary object for machine and program settings.
    programSettings = monkeyprintSettings.programSettings(console)

    # Create version message.
    print "Starting Monkeyprint " + str(
        programSettings['versionMajor'].getValue()) + "." + str(
            programSettings['versionMinor'].getValue()) + "." + str(
                programSettings['revision'].getValue()) + " with GUI."
    console.addLine("You are using Monkeyprint " +
                    str(programSettings['versionMajor'].getValue()) + "." +
                    str(programSettings['versionMinor'].getValue()) + "." +
                    str(programSettings['revision'].getValue()))

    # Get current working directory and set paths.
    # Is this still relevant?
    cwd = os.getcwd()
    programSettings['localMkpPath'].setValue(cwd + "/currentPrint.mkp")

    base_path = programSettings.getInstallDir()

    # Update settings from file.
    programSettings.readFile(base_path)

    # Get cwd for exe
    programSettings['installDir'].setValue(getInstallDir())
    print "Running from " + programSettings['installDir'].getValue()
    # Set debug mode if specified.
    if debug:
        print "Debug mode active."
        programSettings['debug'].setValue(True)
    else:
        programSettings['debug'].setValue(False)

    # Create model collection object.
    # This object contains model data and settings data for each model.
    # Pass program settings.
    modelCollection = monkeyprintModelHandling.modelCollection(
        programSettings, console)

    # Create splash screen for given interval.
    # Get version string first.
    versionString = "Monkeyprint version " + str(
        programSettings['versionMajor'].getValue()) + "." + str(
            programSettings['versionMinor'].getValue()) + "." + str(
                programSettings['revision'].getValue())

    # Create gui.
    gui = monkeyprintGui.gui(modelCollection, programSettings, console,
                             filename)

    # Start the gui main loop.
    gui.main()
Esempio n. 3
0
def runNoGui(filename=None, debug=False):

	print "Starting without Gui."
	# Create settings dictionary object for machine and program settings.
	programSettings = monkeyprintSettings.programSettings()
	
	# Update settings from file.	
	programSettings.readFile()

	# Set debug mode if specified.
	if debug==True:
		programSettings['Debug'].value = debug
		print "Debug mode active."
	else:
		programSettings['Debug'].value = False
	
	# Create model collection object.
	# This object contains model data and settings data for each model.
	# Pass program settings.
	modelCollection = monkeyprintModelHandling.modelCollection(programSettings)
	
	
	#TODO disable this...
	modelCollection.jobSettings['Exposure time'].value = 0.1
	print ("Exposure time: " + str(modelCollection.jobSettings['Exposure time'].value) + ".")
	
	
	# Load project file.
	# TODO: test if file is mkp.
	modelCollection.loadProject(filename)
	print ("Project file: " + str(filename) + " loaded successfully.")
	print "Found the following models:"
	for model in modelCollection:
		if model != 'default':
			print ("   " + model)
	
	# Start the slicer.
	modelCollection.updateSliceStack()
	print ("Starting slicer.")

	# Wait for all slicer threads to finish.
	while(modelCollection.slicerRunning()):
		modelCollection.checkSlicerThreads()
		time.sleep(.2)
		sys.stdout.write('.')
		sys.stdout.flush()
	
	# Start print process when slicers are done.
	print "\nSlicer done. Starting print process."
	
	# Create the projector window.
	gui = monkeyprintGui.noGui(programSettings, modelCollection)	
	
	
	print "Print process done. Thank you for using Monkeyprint."
Esempio n. 4
0
def runNoGui(filename=None, debug=False):

    print "Starting without Gui."
    # Create settings dictionary object for machine and program settings.
    programSettings = monkeyprintSettings.programSettings()

    base_path = programSettings.getInstallDir()

    # Update settings from file.
    programSettings.readFile(base_path)

    # Set debug mode if specified.
    if debug == True:
        programSettings['debug'].value = debug
        print "Debug mode active."
    else:
        programSettings['debug'].value = False

    # Create model collection object.
    # This object contains model data and settings data for each model.
    # Pass program settings.
    modelCollection = monkeyprintModelHandling.modelCollection(programSettings)

    #TODO disable this...
    modelCollection.jobSettings['exposureTime'].value = 0.1
    print("Exposure time: " +
          str(modelCollection.jobSettings['exposureTime'].value) + ".")

    # Load project file.
    # TODO: test if file is mkp.
    modelCollection.loadProject(filename)
    print("Project file: " + str(filename) + " loaded successfully.")
    print "Found the following models:"
    for model in modelCollection:
        if model != 'default':
            print("   " + model)

    # Start the slicer.
    modelCollection.updateSliceStack()
    print("Starting slicer.")

    # Wait for all slicer threads to finish.
    while (modelCollection.slicerRunning()):
        modelCollection.checkSlicerThreads()
        time.sleep(.2)
        sys.stdout.write('.')
        sys.stdout.flush()

    # Start print process when slicers are done.
    print "\nSlicer done. Starting print process."

    # Create the projector window.
    gui = monkeyprintGui.noGui(programSettings, modelCollection)

    print "Print process done. Thank you for using Monkeyprint."
Esempio n. 5
0
def runGui(filename=None, debug=False):

    print "Starting Monkeyprint with GUI."
    # Create a debug console text buffer.
    console = monkeyprintGuiHelper.consoleText()

    # Create settings dictionary object for machine and program settings.
    programSettings = monkeyprintSettings.programSettings(console)

    # Create version message.
    console.addLine("You are using Monkeyprint " +
                    str(programSettings['versionMajor'].value) + "." +
                    str(programSettings['versionMinor'].value) + "." +
                    str(programSettings['revision'].value))

    # Update settings from file.
    programSettings.readFile()

    # Set debug mode if specified.
    if debug:
        print "Debug mode active."
        programSettings['debug'].value = True
    else:
        programSettings['debug'].value = False

    # Create model collection object.
    # This object contains model data and settings data for each model.
    # Pass program settings.
    modelCollection = monkeyprintModelHandling.modelCollection(
        programSettings, console)

    # Create splash screen for given interval.
    # Get version string first.
    versionString = "Monkeyprint version " + str(
        programSettings['versionMajor'].value) + "." + str(
            programSettings['versionMinor'].value) + "." + str(
                programSettings['revision'].value)
    print versionString
    splash = monkeyprintGuiHelper.splashWindow(imageFile='./logo.png',
                                               duration=1,
                                               infoString=versionString)

    # Create gui.
    gui = monkeyprintGui.gui(modelCollection, programSettings, console,
                             filename)

    # Start the gui main loop.
    gui.main()
Esempio n. 6
0
    def __init__(self, port, debug):

        self.runningOnRasPi = True

        self.port = port
        self.debug = debug

        self.console = None

        # Printer messages.
        # Status can be: Idle, Slicing, Printing, Done

        self.sliceNumber = 0

        self.printFlag = False

        # Local file path.
        self.localPath = os.getcwd() + "/tmpServerFiles"
        self.localFilename = "/currentPrint.mkp"

        # Create the working directory.
        if not os.path.isdir(self.localPath):
            os.mkdir(self.localPath)

        self.printProcess = None

        # Allow background threads.****************************
        # Very important, otherwise threads will be
        # blocked by gui main thread.
        gtk.gdk.threads_init()

        # Register timeout functions. *************************
        pollPrintQueuesId = gobject.timeout_add(50, self.pollPrintQueues)
        #	statusUpdateId = gobject.timeout_add(10, self.pollPrinterStatus)

        # Create file transfer socket.
        self.queueFileTransferIn = Queue.Queue(maxsize=1)
        self.queueFileTransferOut = Queue.Queue(maxsize=1)
        self.fileReceiver = monkeyprintSocketCommunication.fileReceiver(
            ip="*",
            port="6000",
            queueFileTransferIn=self.queueFileTransferIn,
            queueFileTransferOut=self.queueFileTransferOut)
        self.fileReceiver.start()

        # Create queues for inter-thread communication.********
        # Queue for setting print progess bar.
        self.queueSliceOut = Queue.Queue(maxsize=1)
        self.queueSliceIn = Queue.Queue(maxsize=1)
        # Queue for commands.
        self.queueCommands = Queue.Queue(maxsize=1)
        # Queue for status infos displayed above the status bar.
        self.queueStatus = Queue.Queue()
        # Queue for console messages.
        self.queueConsole = Queue.Queue()

        # Create settings dictionary object for machine and program settings.
        self.programSettings = monkeyprintSettings.programSettings()

        # Update settings from file.
        self.programSettings.readFile()

        # Create communication socket.
        self.socket = monkeyprintSocketCommunication.communicationSocket(
            port=self.programSettings['Network port RasPi'].value,
            ip=None,
            queueCommands=self.queueCommands)
        # Add socket listener to GTK event loop.
        gobject.io_add_watch(self.socket.fileDescriptor, gobject.IO_IN,
                             self.socket.callbackIOActivity,
                             self.socket.socket)
        #gobject.io_add_watch(self.socket.fileDescriptor, gobject.IO_IN, self.zmq_callback, self.socket.socket)

        # Set debug mode if specified.
        if self.debug == True:
            self.programSettings['Debug'].value = debug
            print "Debug mode active."
        else:
            self.programSettings['Debug'].value = False

        # Create model collection object.
        # This object contains model data and settings data for each model.
        # Pass program settings.
        self.modelCollection = monkeyprintModelHandling.modelCollection(
            self.programSettings)

        #TODO disable this...
        #	self.modelCollection.jobSettings['Exposure time'].value = 0.1
        #	print ("Exposure time: " + str(self.modelCollection.jobSettings['Exposure time'].value) + ".")

        print "Monkeyprint started in server mode."
        gtk.main()
Esempio n. 7
0

import monkeyprintModelHandling
import monkeyprintSettings
import monkeyprintGui
import monkeyprintGuiHelper


# Test if this file is executed as the main application contrary to being executed as a model from inside another file.
if __name__ == "__main__":

	# Create a debug console text buffer.
	console = monkeyprintGuiHelper.consoleText()

	# Create settings dictionary object for machine and program settings.
	programSettings = monkeyprintSettings.programSettings(console)

	# Create version message.
	console.addLine("You are using Monkeyprint " + str(programSettings['versionMajor'].value) + "." + str(programSettings['versionMinor'].value) + "." + str(programSettings['revision'].value))

	# Update settings from file.	
	programSettings.readFile()

	# Create model collection object.
	# This object contains model data and settings data for each model.
	# Pass printer and program settings.
	modelCollection = monkeyprintModelHandling.modelCollection(programSettings, console)

	# Create gui.
	gui = monkeyprintGui.gui(modelCollection, programSettings, console)