コード例 #1
0
 def InitPrinter(self, port):
     self.port = port
     self.net = None
     self.printer = printcore(port, 115200)  # port = 'COM#' in windows
     self.printer.errorcb = self.__Error_  # on error
     self.printer.onlinecb = self.__Connected_  # on connection
     self.printer.recvcb = self.__Receive_  # listen for messages from printer
コード例 #2
0
 def startPrint(self, jobfile):
     self.p = printcore.printcore()
     self.p.tempcb = self._tempCallback
     self.p.errorcb = self._errorCallback
     self.p.loud = False
     try:
         self.printing = True
         self.connect()
         connectCount = 0
         while not self.isConnected():
             connectCount += 1
             time.sleep(1)
             if connectCount == 5:
                 self.log.debug("Trying to reset port")
                 self.p.printer.baudrate = 9600
                 self.p.printer.baudrate = self.config['baud']
             if connectCount == 20:
                 raise Exception("Could not connect to bot")
             self.log.debug("Waiting for driver to connect.")
         self.gcoder = gcoder.GCode(jobfile.localFile)
         self.p.startprint(self.gcoder)
         self.printThread = Thread(target=self.printThreadEntry).start()
     except Exception:
         self.disconnect()
         raise
コード例 #3
0
ファイル: robot.py プロジェクト: GriesbeckLab/Picker-Firmware
 def connect(self):
     """docstring for connect"""
     print("Connecting...")
     self.connection = printcore(self.port, self.baud)
     self.connection.loud = True
     time.sleep(2)
     self.connection.send_now("G90")
コード例 #4
0
 def startPrint(self, jobfile):
     self.p = printcore.printcore()
     self.p.tempcb = self._tempCallback
     self.p.errorcb = self._errorCallback
     self.p.loud = False
     try:
         self.printing = True
         self.connect()
         connectCount = 0
         while not self.isConnected():
             connectCount += 1
             time.sleep(1)
             if connectCount == 5:
                 self.log.debug("Trying to reset port")
                 self.p.printer.baudrate = 9600
                 self.p.printer.baudrate = self.config['baud']
             if connectCount == 20:
                 raise Exception("Could not connect to bot")
             self.log.debug("Waiting for driver to connect.")
         self.gcoder = gcoder.GCode(jobfile.localFile)
         self.p.startprint(self.gcoder)
         self.printThread = Thread(target=self.printThreadEntry).start()
     except Exception:
         self.disconnect()
         raise
コード例 #5
0
ファイル: main.py プロジェクト: kory75/Duplicator
	def connectprinter(self,activeswitch):
		if activeswitch:
			self.menu_bar.ids.short_message.text = 'disconnecting....'
			try:
				self.activeprinter.disconnect()
				self.menu_bar.ids.short_message.text = 'Done'
				self.sm.get_screen('Print').ids.connectprinterswitch.active=0
				self.activeprinter = None
				self.menu_bar.ids.indicator_printer.color = (0,0,0,.3)
			except:
				self.menu_bar.ids.short_message.text = 'No printer!'
				self.sm.get_screen('Print').ids.connectprinterswitch.active=0
				self.menu_bar.ids.indicator_printer.color = (1,0,0,1)
		else: 
			#print(self.sm.get_screen('Print').ids)
			#print('connecting....')
			self.menu_bar.ids.short_message.text ='connecting....'
			try:
				#self.config.get('printer','printer_com_port'),self.config.get('printer','printer_com_speed')
				self.activeprinter=printcore('/dev/tty.usbmodem1411','115200')
				#print('connected')
				self.menu_bar.ids.short_message.text = 'connected'
				self.sm.get_screen('Print').ids.connectprinterswitch.active=1
				self.sm.get_screen('Print').ids.connectprinterswitch.state = 'down'
				self.menu_bar.ids.indicator_printer.color = (0,1,0,1)
			except:
				self.menu_bar.ids.short_message.text = 'Unable to connect!'
				#print('Unable to connect!')
				self.sm.get_screen('Print').ids.connectprinterswitch.active=0
				self.sm.get_screen('Print').ids.connectprinterswitch.state = 'normal'
				self.menu_bar.ids.indicator_printer.color = (1,0,0,1)
コード例 #6
0
    def __init__(self, port, baudrate, magnet1_pin=4, magnet2_pin=5, config_file=None):
        self.port = port
        self.baudrate = baudrate
        self.magnet1_pin = magnet1_pin
        self.magnet2_pin = magnet2_pin
        self.config_file = config_file

        self.magic_table = printcore()
コード例 #7
0
ファイル: CoreXY.py プロジェクト: David-Estevez/magic-table
    def __init__(self, port='/dev/ttyACM0', baudrate=115200):
        super(CoreXY, self).__init__()
        self.port = port
        self.baudrate = baudrate
        self.comm = printcore()

        self.x = None
        self.y = None

        self.toolhead = None
コード例 #8
0
ファイル: CoreXY.py プロジェクト: djdarkgr/magic-table
    def __init__(self, port = '/dev/ttyACM0', baudrate = 115200):
        super(CoreXY, self).__init__()
        self.port = port
        self.baudrate = baudrate
        self.comm = printcore()

        self.x = None
        self.y = None

        self.toolhead = None
コード例 #9
0
    def Print(self, file):
        from printrun import gcoder
        from printrun.printcore import printcore

        printer = printcore(self.comPort, self.baudRate)

        time.sleep(2)

        disectedGCode = [i.strip() for i in open(file)]

        disectedGCode = gcoder.LightGCode(disectedGCode)

        printer.startprint(disectedGCode)
コード例 #10
0
    def __init__(self, numX, numY):
        """ initiates a instance of size given """
        ps = pronsole()
        port = ps.scanserial()

        if len(port) > 1:
            print("Too many devices detected")
            return
        if len(port) < 1:
            print("no device detected")
            return

        self.printer = printcore(port[0], self.baud)
        self.nX = numX
        self.nY = numY
コード例 #11
0
	def __init__(self, numX, numY):
		""" initiates a instance of size given """
		ps = pronsole()
		port = ps.scanserial()

		if len(port) > 1:
			print ("Too many devices detected")
			return
		if len(port) < 1:
			print ("no device detected")
			return

		self.printer = printcore(port[0], self.baud)
		self.nX = numX
		self.nY = numY
コード例 #12
0
 def select_baudrate_and_connect(self):
     baudrates = self.profile['baudrate']
     self.logger.info('Baudrates list for %s : %s' %
                      (self.profile['name'], str(baudrates)))
     for baudrate in baudrates:
         self.error_code = 0
         self.error_message = ""
         self.online_flag = False
         self.logger.info("Connecting at baudrate %i" % baudrate)
         self.printcore = printcore()
         self.printcore.onlinecb = self.onlinecb
         self.printcore.errorcb = self.errorcb
         self.printcore.tempcb = self.tempcb
         self.printcore.recvcb = self.recvcb
         self.printcore.sendcb = self.sendcb
         self.printcore.endcb = self.endcb
         self.printcore.connect(self.profile['COM'], baudrate)
         time.sleep(0.1)
         if not self.printcore.printer:
             self.logger.warning("Error connecting to printer at %i" %
                                 baudrate)
             self.disconnect_printcore()
         else:
             wait_start_time = time.time()
             self.logger.info("Waiting for printer online")
             while time.time() < (wait_start_time +
                                  self.DEFAULT_TIMEOUT_FOR_PRINTER_ONLINE):
                 if config.get_app().stop_flag:
                     self.disconnect_printcore()
                     raise RuntimeError(
                         "Connection to printer interrupted by closing")
                 if self.online_flag:
                     self.logger.info(
                         "Successful connection to printer %s:%i" %
                         (self.profile['COM'], baudrate))
                     time.sleep(0.1)
                     self.logger.info("Sending homing gcodes...")
                     for gcode in self.profile["end_gcodes"]:
                         self.printcore.send_now(gcode)
                     self.logger.info("...done homing")
                     return True
             self.logger.warning(
                 "Timeout while waiting for printer online. Reseting and reconnecting..."
             )
             self.reset()
             time.sleep(2)
             self.logger.warning("...done reseting.")
     raise RuntimeError("No more baudrates to try")
コード例 #13
0
 def __init__(self,
              onlinecb=None,
              offlinecb=None,
              positioncb=None,
              tempcb=None,
              receivecb=None,
              sendcb=None):
     self.p = printcore.printcore()
     self.p.addEventHandler(self)
     self.onlinecb = onlinecb
     self.offlinecb = offlinecb
     self.positioncb = positioncb
     self.tempcb = tempcb
     self.receivecb = receivecb
     self.sendcb = sendcb
     self.liftdone = None
     self.port = None
コード例 #14
0
ファイル: tabHost.py プロジェクト: helpmanclock/tweetABall
    def connect(self):

        if self.repStat == True:
            sys.stdout.write("Connecting to TaB:")
            sys.stdout.flush()

        self.pCore = printcore(self.port, self.baud)
        while self.pCore.online == False:
            time.sleep(1)
            if self.repStat == True:
                sys.stdout.write(".")
                sys.stdout.flush()

        if self.repStat == True:
            sys.stdout.write("Tab conneceted!\n")

        self.pCore.loud = self.loud
        time.sleep(2)
コード例 #15
0
ファイル: control.py プロジェクト: adammhaile/PlotterCon
    def __init__(self):
        self.pr = None
        self.pc = printcore()
        self.pc.addEventHandler(self)

        self.dev = None
        self.baud = 115200
        self.console_callbacks = {}
        self.cmd_map = SMOO
        self.pos = [0,0,0]

        self.jog_speed = 100
        self.jog_z_speed = 5

        self.pos_lock = Lock()

        self.pollThread = StatusPollThread()
        pub.subscribe(self.GetStatus, "get_status")
コード例 #16
0
ファイル: gSend.py プロジェクト: C-o-r-E/turboChef
        def printGcodeFile(self, path_to_file):
                sys.path.insert(0, '/home/corey/git/Printrun')
                from printrun import gcoder
                from printrun import printcore

                #for testing
                path_to_file = "/home/corey/100actions.gcode"
                #path_to_file = "/home/corey/test1.gcode"
                
                #default printer
                plist = Printer.objects.all()
                
                if(len(plist) > 0):
                        self.current_printer = plist[0]
                        
                try:
                        #print "printing gcode for " + path_to_file
                        gcFile = open(path_to_file, "rU")
                        
                        self.device = printcore.printcore('/dev/ttyUSB0', 115200)
                        self.device.recvcb = self.replycb
                        self.device.errorcb = self.errorcb 

			self.device.startcb = self.startcb
			self.device.endcb = self.endcb
			self.device.sendcb = self.sendcb
			self.device.onlinecb = self.onlinecb
			self.device.preprintsendcb = self.preprintsendcb
			self.device.printsendcb = self.printsendcb
			self.device.layerchangecb = self.layerchangecb
                        
                        time.sleep(1)
                        
                        gcode = gcoder.GCode(gcFile)
                        
                        self.device.startprint(gcode)                
                        print "done printing?"
			
                        
                except IOError:
                        print "Failed to open gcode file: " + path_to_file
                                
		except Exception:
			print "Some kind of exception happened"
コード例 #17
0
ファイル: DeltaLevel.py プロジェクト: xaevman/DeltaLevel
def main():
    lock = threading.Condition()

    handler = BasicHandler(lock)

    printer = printcore()
    printer.addEventHandler(handler)

    t = threading.Thread(target=sendCommands, args=(printer, lock, handler))
    t.start()

    printer.connect(COM_PORT, 115200)

    while printer.online == False:
        log('Waiting to connect...')
        time.sleep(1)

    t.join()

    printer.disconnect()
def roundRobinSch():
    #Premliminary variables and function go here.
    mode = 0
    #Mode 0: Camera Mode - Communicates with Camera to establish connection and waits for data to be sent.
    #Mode 1: Conversion Mode - Converts and Builds Gcode file to be sent to printer movement.
    #Mode 2: Movement Mode - Establish connection with printer and moves the actuator to the target location based on gcode file.
    #Mode 3: Pump Mode - Establish connection with pump system and sends a pulse to the actuator to eject suficient amount of solution.
    p = printcore(
        'COM4', 115200
    )  #Establish connection with printer- Arguments:port name, Baud Rate
    n = 0
    remTargetfiles()
    while (True):
        if (mode == 0):
            x = int(input("Enter the x-coordinate:"))
            y = int(input("Enter the y-coordinate:"))
            n += 1
            mode += 1
        elif (mode == 1):
            createFile(x, y)
            gcode = [
                i.strip()
                for i in open("./targets/TargetLoc" + str(n) + ".gcode")
            ]
            gcode1 = gcoder.LightGCode(gcode)
            mode += 1
        elif (mode == 2):
            #SEND code file to printer
            p.startprint(gcode1)
            mode += 1
        elif (mode == 3):
            #SEND code to activate laser actuator.
            time.sleep(5)
            #SEND code to disactivate laser actuator.
            mode += 1
        else:  ##Default Path.
            #Resets Round-Robin Scheduler
            mode = 0
        ##Clean up routine when microcontroller s waiting for a response or data.

    return
コード例 #19
0
 def select_baudrate_and_connect(self):
     baudrates = self.profile['baudrate']
     self.logger.info('Baudrates list for %s : %s' % (self.profile['name'], str(baudrates)))
     for baudrate in baudrates:
         self.error_code = 0
         self.error_message = ""
         self.online_flag = False
         self.logger.info("Connecting at baudrate %i" % baudrate)
         self.printcore = printcore()
         self.printcore.onlinecb = self.onlinecb
         self.printcore.errorcb = self.errorcb
         self.printcore.tempcb = self.tempcb
         self.printcore.recvcb = self.recvcb
         self.printcore.sendcb = self.sendcb
         self.printcore.endcb = self.endcb
         self.printcore.connect(self.profile['COM'], baudrate)
         time.sleep(0.1)
         if not self.printcore.printer:
             self.logger.warning("Error connecting to printer at %i" % baudrate)
             self.disconnect_printcore()
         else:
             wait_start_time = time.time()
             self.logger.info("Waiting for printer online")
             while time.time() < (wait_start_time + self.DEFAULT_TIMEOUT_FOR_PRINTER_ONLINE):
                 if config.get_app().stop_flag:
                     self.disconnect_printcore()
                     raise RuntimeError("Connection to printer interrupted by closing")
                 if self.online_flag:
                     self.logger.info("Successful connection to printer %s:%i" % (self.profile['COM'], baudrate))
                     time.sleep(0.1)
                     self.logger.info("Sending homing gcodes...")
                     for gcode in self.profile["end_gcodes"]:
                         self.printcore.send_now(gcode)
                     self.logger.info("...done homing")
                     return True
             self.logger.warning("Timeout while waiting for printer online. Reseting and reconnecting...")
             self.reset()
             time.sleep(2)
             self.logger.warning("...done reseting.")
     raise RuntimeError("No more baudrates to try")
コード例 #20
0
ファイル: repWrapper.py プロジェクト: PrintToPeer/Burijji
    def __init__(self, server):
        self._server           = server
        self._mutex            = threading.Lock()
        self._temp_subscribers = []
        self._info_subscribers = []
        self._raw_subscribers  = []
        self._temperatures     = {}
        self._current_line     = None
        self._printing         = False
        self._paused           = False
        self._ok               = True
        self._machine_info     = {}
        self._routines         = {}
        self._raw_output       = deque()
        self._other_messages   = deque()
        self.__printer         = printcore()
        self._machine_info     = {'type': 'RepRap', 'model':  'Unknown', 'uuid': None}
        self._current_segment  = 'none'
        self._gcode_file       = None

        self.__printer.errorcb = self.errorcb
        self.__printer.sendcb = self.sendcb
        self.printer_lock = threading.Lock()
コード例 #21
0
def callback(message):
    print("in call back")
    # gcodeFileName = '/home/xueyelin/Thermite_Boom_Boom/Code/Examples/test2Offset.gcode'
    gcodeFileName = message.data
    # gcodeFileName = data
    print("trying gcode sender")
    print(gcodeFileName)
    # or p.printcore('COM3',115200) on Windows
    p = printcore('/dev/ttyACM1', 115200)

    # Sleeps for 1 sec t o allow for UArm's serial jiberish
    # or pass in your own array of gcode lines instead of reading from a file

    rospy.sleep(1)

    gcode = [i.strip() for i in open(gcodeFileName)]
    gcode = gcoder.LightGCode(gcode)
    p.startprint(gcode)  # this will start a print

    prev_cmd = None
    while (p.printing is True):
        if (prev_cmd != p.sent[-1]):
            print(p.sent[-1])
            prev_cmd = p.sent[-1]
コード例 #22
0
    timeout=0.5
) as ser:
    log.debug('done.')
    log.debug('creating IOWrapper...')
    with io.TextIOWrapper(
        io.BufferedReader(ser, 1),
        newline='\r',
        errors='backslashreplace'
    ) as sio:
        log.debug('done.')
        usb_modem_names = glob.glob(args.controller)
        assert len(usb_modem_names) > 0, "No Smoothieboard found. Try '--controller=<controller_port>'?"
        assert len(usb_modem_names) == 1, "More than one file matches. Can't tell which one is the Smoothieboard."
        printer_interface = usb_modem_names[0]
        log.debug('opening printer_interface = {} ...'.format(printer_interface))
        printer = printcore()
        printer._send = MethodType(patched_send, printer)
        printer.connect(port=printer_interface, baud=115200)
        log.debug('done.')
        rsleep(3)
        printer.send("G91")
        if args.test_origin:
            test_set_to_weight(sio, ser, args.pump, args.wait)
        for test_set_name, test_set_params in (('deep', deep_params), ('broad', broad_params)):
            result_file_name = os.path.join(args.result_path, outfile_name_format.format(args.fluid, args.test_scope, test_set_name))
            if test_set_params['n_repeats']:
                with open(result_file_name,'w') as result_file:
                    log.debug('generating {} tests...'.format(test_set_name))
                    tests = generate_tests(args=args, result_file=result_file, **test_set_params)
                    log.debug('done.')
                    log.info('starting {} tests ({} parameter combinations, expected runtime {})...'.format(test_set_name, len(tests), estimate_runtime(tests)))
コード例 #23
0
 def printer_connect(self):
     if self.print is None:
         self.print = printcore(self.project_data["Setup"]["RobotPort"],
                                115200)
         self.print.addEventHandler(self)
コード例 #24
0
#p.disconnect() # this is how you disconnect from the printer once you are done. This will also stop running prints.
"""
Uncomment the section below to run on Raspberry Pi
"""

# Kliment default file with printcore, from: https://github.com/kliment/Printrun#cython-based-g-code-parser
# #to send a file of gcode to the printer
from printrun.printcore import printcore
from printrun import gcoder
"""
viewing ports on the Pi is a little strange. I've heard that USBs tend to appear 
as ttyUSB<number> however, pronterface autoconnected to ttyACM0. For now I'm 
assuming this is a reliable port name.
"""
serial_port = '/dev/ttyACM0'
p = printcore(serial_port, 115200)  # or p.printcore('COM3',115200) on Windows

# Wait until the motor is ready to receive commands
while not p.online:
    time.sleep(0.1)

gcode = [
    i.strip() for i in open('test.gcode')
]  # or pass in your own array of gcode lines instead of reading from a file
gcode = gcoder.LightGCode(gcode)
p.startprint(gcode)  # this will start a print

#If you need to interact with the printer:
# p.send_now("M105") # this will send M105 immediately, ahead of the rest of the print
# p.pause() # use these to pause/resume the current print
# p.resume()
コード例 #25
0
#to send a file of gcode to the printer
from printrun.printcore import printcore
from printrun import gcoder
import time
#gcodeFileName = '/home/xueyelin/Thermite_Boom_Boom/Code/Examples/test2Offset.gcode'
gcodeFileName = '/home/xueyelin/Thermite_Boom_Boom/Code/ROS/uarmws/src/swiftpro/python_test/test.gcode'

p = printcore('/dev/ttyACM1',
              115200)  # or p.printcore('COM3',115200) on Windows
time.sleep(1)
gcode = [
    i.strip() for i in open(gcodeFileName)
]  # or pass in your own array of gcode lines instead of reading from a file
gcode = gcoder.LightGCode(gcode)
p.startprint(gcode)  # this will start a print

while (p.printing is True):
    print(p.sent[-1])
    #p.disconnect()
コード例 #26
0
            sys.exit(1)
        if o in ('-b', '--baud'):
            baud = int(a)
        if o in ('-v', '--verbose'):
            loud = True
        elif o in ('-s', '--statusreport'):
            statusreport = True

    if len(args) > 1:
        port = args[-2]
        filename = args[-1]
        print "Printing: %s on %s with baudrate %d" % (filename, port, baud)
    else:
        print "Usage: python [-h|-b|-v|-s] printcore.py /dev/tty[USB|ACM]x filename.gcode"
        sys.exit(2)
    p = printcore("tty.usbserial-AM0227LU", baud)
    p.loud = True
    time.sleep(2)
    gcode = [i.strip() for i in open(filename)]
    gcode = gcoder.GCode(gcode)
    p.startprint(gcode)

    try:
        if statusreport:
            p.loud = False
            sys.stdout.write("Progress: 00.0%\r")
            sys.stdout.flush()
        while p.printing:
            time.sleep(1)
            if statusreport:
                sys.stdout.write("Progress: %02.1f%%\r"
コード例 #27
0
import os
import time
from printrun.printcore import printcore
from printrun import gcoder
#from Activation_Function import activation
# import RPi.GPIO as GPIO
#from time import sleep

# This program is for manually moving the actuator

speed = 8000

#GPIO.setwarnings(False)

p = printcore(
    "/dev/ttyUSB0",
    115200)  #Establish connection with printer- Arguments:port name, Baud Rate
time.sleep(4)
p.send_now("G90")
#p.send_now("G28 F"+str(speed))
p.send_now("G0 Z20 F" + str(speed))
p.send_now("G0 X235 Y235 ")

# in1 = 23
# in2 = 24
# en = 25
#
# L1 = 13 #HI
# L2 = 6 #LOW
# delay = 0.1
#
コード例 #28
0
 def printer_connect(self):
     if self.print is None:
         self.print = printcore(self.project_data['Setup']['RobotPort'], 115200)
コード例 #29
0
#!/usr/bin/python

import atexit
atexit.register(lambda: input("\nPress Enter to exit."))

print('          YOOOOO WHATS UP CRONUS !!!           ')

#import serial
import time
from printrun.printcore import printcore

p = printcore('COM5', 115200)
#ArduinoUnoSerial = serial.Serial('COM25',9600)
#time.sleep(2)
#while 1:
#   arduinoData = ArduinoUnoSerial.readline()

# Wait for connection to the printer
print('Waiting for printer ...')

while not p.online:
    time.sleep(5)
print('Connected to printer !')

# Je fais une for loop pour faire bouger la cam

print('Sending X Y Z instructions (G92)')
p.send('G0 X100 Y100 Z100 F1200')

print('Sending home instruction (G28)')
#p.send('G28')
コード例 #30
0
ファイル: printcore.py プロジェクト: tobbelobb/D3D-Printrun
                sys.exit(2)
        elif o in ('-v', '--verbose'):
            loud = True
        elif o in ('-s', '--statusreport'):
            statusreport = True

    if len(args) <= 1:
        print "Error: Port or gcode file were not specified.\n"
        print usage
        sys.exit(2)
    elif len(args) > 1:
        port = args[-2]
        filename = args[-1]
        print "Printing: %s on %s with baudrate %d" % (filename, port, baud)

    p = printcore(port, baud)
    p.loud = loud
    time.sleep(2)
    gcode = [i.strip() for i in open(filename)]
    gcode = gcoder.LightGCode(gcode)
    p.startprint(gcode)

    try:
        if statusreport:
            p.loud = False
            sys.stdout.write("Progress: 00.0%\r")
            sys.stdout.flush()
        while p.printing:
            time.sleep(1)
            if statusreport:
                progress = 100 * float(p.queueindex) / len(p.mainqueue)
コード例 #31
0
            <form method="post" action="move">
              <input type="text" value="0" name="x" />
              <input type="text" value="0" name="y" />
              <button type="submit">Submit</button>
            </form>
          </body>
        </html>"""

    @cherrypy.expose
    def move(self, x=0, y=0):
        self.printer.send("G1 F6000 X%s Y%s\n" % (x, y))
        return 'Ok!'

if __name__ == '__main__':
    pc =  printcore()
    time.sleep(2)
    print '[+] Connecting to device...'
    pc.connect('/dev/ttyACM1', 115200)
    time.sleep(2)
    if pc.online:
            print '[!] Connected!'
    else:
            exit()

    pc.send("G28 Y0\nG28 X0\n")

    cherrypy.config.update({'server.socket_host': '172.16.17.241',
                        'server.socket_port': 8080,
                       })
    cherrypy.quickstart(HelloWorld(pc))
コード例 #32
0
#! /usr/bin/env python

print "your code is running..."

from printrun.printcore import printcore
from printrun import gcoder
from printrun.pronsole import pronsole
import time

# write stop_print file with 0 in it.... this will turn into a 1 if the user says to stop printing
filename = "/home/pi/421_521_final_project/GUI/toastGUI/stop_print.txt"
fo = open(filename, "wb")  # file that will tell print to stop if needed
fo.write('0')
fo.close()

p = printcore('/dev/ttyACM0', 250000)
p.send_now('G28')
p.disconnect()
#p.kill()

p = printcore('/dev/ttyACM0', 250000)

print "you are connected"

gcode = [
    i.strip()
    for i in open('/home/pi/421_521_final_project/GUI/toastGUI/gcode.gcode')
]

gcode = gcoder.LightGCode(gcode)
コード例 #33
0
import time
import serial
import sys
import pickle
from printrun.printcore import printcore
from printrun import gcoder
from imageProc import objectDet
from interface import start, insert, FPickupErr, PPickupErr, AssemFail, restockF, restockP, calib, feedIns, Xadj, Yadj

printer = printcore('/dev/ttyUSB1', 115200)  #Connects to the printer.
arduino = serial.Serial('/dev/ttyUSB0', 9600)  #Connects to the arduino.

#The following imports gcode text files and assigns them to arrays to be sent to the printer.
home = [i.strip() for i in open('/home/pi/Printrun/testfiles/home.gcode')]
home = gcoder.LightGCode(home)
getComponent = [
    i.strip() for i in open('/home/pi/Printrun/testfiles/getComponent.gcode')
]
getComponent = gcoder.LightGCode(getComponent)
feedthroughView = [
    i.strip()
    for i in open('/home/pi/Printrun/testfiles/feedthroughView.gcode')
]
feedthroughView = gcoder.LightGCode(feedthroughView)
preformView = [
    i.strip() for i in open('/home/pi/Printrun/testfiles/preformView.gcode')
]
preformView = gcoder.LightGCode(preformView)
feedthroughPickup = [
    i.strip()
    for i in open('/home/pi/Printrun/testfiles/feedthroughPickup.gcode')
コード例 #34
0
ファイル: commander.py プロジェクト: xyReaper/Builder
from printrun.utils import setup_logging

if __name__ == '__main__':

    loud = True
    work = "/home/flyprint/Desktop/Printrun/Brick_test"
    os.chdir(work)
    filename = "left"
    cmd = "slic3r" + " " + filename + ".stl" + " --load v1.ini --print-center -60,0" + " --output" + " " + filename + ".gcode"
    print cmd
    subprocess.Popen(cmd, shell=True, stderr=subprocess.PIPE)

    time.sleep(1)

    from printrun.printcore import __version__ as printcore_version
    p = printcore('/dev/ttyACM2', 115200)
    p.loud = True
    time.sleep(2)
    gcode = [
        i.strip() for i in open(filename + ".gcode")
    ]  # or pass in your own array of gcode lines instead of reading from a file
    gcode = gcoder.LightGCode(gcode)

    p.startprint(gcode)  # this will start a print
    statusreport = True
    if statusreport:
        p.loud = False
        sys.stdout.write("Progress: 00.0%\r")
        sys.stdout.flush()
    while p.printing:
        time.sleep(1)
コード例 #35
0
from printrun.printcore import printcore
from printrun import gcoder

p = printcore('/dev/ttyACM1',115200)
gcode = [i.strip() for i in open('./Gcode/2015-November-18/01-16-38 AM Test1.gcode')]
#gcode = gcoder.LightGCode(gcode)
gcode = gcoder.LightGCode(["G0 X5"])
print gcode
print p
p.startprint(gcode)
#p.disconnect()
#p.send_now("G0 X5")

#import serial
#ser = serial.Serial('/dev/ttyACM1', 115200, timeout = 1)
#line = ser.readline()
#ser.close()
#print line
コード例 #36
0
ファイル: gui.py プロジェクト: ngopaul/dual-extrusion
import os
import pygame, sys
from pygame.locals import *
from printrun.printcore import printcore
from printrun import gcoder
import xmlrpc.client
import time

# rpc = xmlrpc.client.ServerProxy('http://localhost:7978')
p = printcore('COM3', 115200)
gcode = []
pygame.init()
pygame.font.init()
background = (30, 30, 30)
COLOR_INACTIVE = pygame.Color('lightskyblue3')
COLOR_ACTIVE = pygame.Color('dodgerblue2')
FONT = pygame.font.Font(None, 32)
DISPLAYSURF = pygame.display.set_mode((0, 0), pygame.FULLSCREEN)
w, h = pygame.display.get_surface().get_size()
print("Width of screen:", w, "::", "Height of screen:", h)
mainLoop = True
current_state = [0]
printcount = 0


def do_nothing(*args):
    pass


def display_loading():
    text_wait.visible = True
コード例 #37
0
ファイル: gui.py プロジェクト: ngopaul/dual-extrusion
def connect_printer():
    global p
    p = printcore('COM3', 115200)
コード例 #38
0
ファイル: calibrator.py プロジェクト: nzinov/delta_calibrator
 def __init__(self, optimize_for=[]):
     self.core = printcore("/dev/kossel", 250000)
     self.probed_points = []
     self.settings = Settings()
     self.optimize_for = optimize_for
     sleep(1)
コード例 #39
0
#code adapted from www.github.com/kliment/Printrun

#to send a file of gcode to the printer
from printrun.printcore import printcore
from printrun import gcoder

p = printcore('COM3', 250000)  # or p.printcore('COM3',115200) on Windows
print('1')
gcode = [
    i.strip() for i in open('gcode.gcode')
]  # or pass in your own array of gcode lines instead of reading from a file
gcode = gcoder.LightGCode(gcode)
p.startprint(gcode)  # this will start a print

#If you need to interact with the printer:
p.send_now(
    "M105")  # this will send M105 immediately, ahead of the rest of the print
p.pause()  # use these to pause/resume the current print
p.resume()
p.disconnect(
)  # this is how you disconnect from the printer once you are done. This will also stop running prints.
コード例 #40
0
ファイル: game_loop.py プロジェクト: ANC-Hackathons/ancprb
    PebbleKeys.GAME_OVER.value: Uint8(PebbleKeys.GAME_WIN.value)
  })
  global cur_state
  cur_state = States.WAIT_FOR_RESET.value
  print 'state', cur_state

def game_loss():
  messenger.send_message(pebble_app_uuid, {
    PebbleKeys.GAME_OVER.value: Uint8(PebbleKeys.GAME_LOSS.value)
  })
  global cur_state
  cur_state = States.WAIT_FOR_RESET.value
  print 'state', cur_state

# Connect and zero out the printer
printer = printcore(parser.parse_args().usb, 115200)
time.sleep(5.0)

# Go to starting position
def reset_pos():
  print 'in reset_pos'
  printer.send(the_lulz.zero())
  init_position = RO_init_position.copy()
  init_direction = RO_init_direction.copy()
  command = the_lulz.send_g_code(init_position,"fast")
  print command
  printer.send(command)
  time.sleep(19.0)
  global collision_status
  collision_status = 0
  flying_toaster.set_position(init_position)
def roundRobinSch():

    actMode = 2  # 1 for Laser, 2 for pump
    lamp = 0  #controls pixy lamp during cord_grab() call 0=off 1=half brightness, 2=full brightness
    lTime = 0.5  #time lamp stays on when lamp==1 or lamp==2
    iniDelay = 2  #wait time for starting movements
    pumTime = 0.05  #activation time for pump

    mode = 0  #Starting mode for Round Robin
    GPIO.setwarnings(False)

    posZ = 20  #operation Height of actuator
    speed = 8000  #speed setting for stepper motors
    numCords = 20  #size of coordinate array
    lasTime = 0.5  #activation time for laser
    actDelay = 0.5  #wait time for after activation

    #Mode 0: Camera Mode - Communicates with Camera to establish connection and waits for data to be sent.
    #Mode 1: Conversion Mode - Converts and Builds Gcode file to be sent to printer movement.
    #Mode 2: Movement Mode - Establish connection with printer and moves the actuator to the target location based on gcode file.
    #Mode 3: Actuator Mode - Establish connection with pump system and sends a pulse to the actuator to eject suficient amount of solution.
    p = printcore(
        "/dev/ttyUSB0", 115200
    )  #Establish connection with printer- Arguments:port name, Baud Rate
    time.sleep(4)
    print("Printer is now online.")
    p.send_now("G90")
    #p.send_now("G28 F"+str(speed))
    p.send_now("M92 X80 y80")
    #p.send_now("G0 Z"+str(posZ)+" F"+str(speed))
    p.send_now("G0 X234.9 Y234.9 Z" + str(posZ) + " F" + str(speed))
    print("...Waiting")
    #     for j in range (0,iniDelay):
    #         print(iniDelay-j)
    #         time.sleep(1)
    time.sleep(iniDelay)

    n = 1
    remTargetfiles()
    createLog()
    pixyArray = coordinates(numCords, actMode, lamp, lTime)
    #Calls PixyCam's function and returns array.
    populateLog(pixyArray)  #Populate Log File with PixyCam's Coords.

    while (True):

        if (mode == 0):
            print("Coordinate Read MODE")
            if ((int(pixyArray[n][0]) == 0) and (int(pixyArray[n][1]) == 0)):
                break
            x = int(pixyArray[n][0])
            y = int(pixyArray[n][1])
            n += 1
            mode += 1

        elif (mode == 1):
            print("Coordinate Conversion MODE")
            print("Point #" + str(n - 1) + "\n")
            createFile(x, y, actMode)
            gcode = [
                i.strip()
                for i in open("./targets/TargetLoc" + str(n - 1) + ".gcode")
            ]
            gcode1 = gcoder.LightGCode(gcode)
            mode += 1

        elif (mode == 2):
            print("Movement MODE")
            #SEND code file to printer
            p.startprint(gcode1)
            #time.sleep(2)
            #while (position == False):
            #    position = checkPos()
            time.sleep(
                1
            )  #At least one second needs to pass before the function is called.
            while (
                    p.endChecker()
            ):  #Function call that returns true or false whether the actuator movement system is running gcode.
                #time.sleep(1)
                continue
            mode += 1

        elif (mode == 3):
            if (actMode == 1):
                print("Laser MODE")
                print("\nLaser On")
                activationL(lasTime)
                print("Laser Off\n")
                time.sleep(actDelay)
                mode += 1
            elif (actMode == 2):
                print("PUMP MODE")
                print("\nPump On")
                activationP(pumTime)
                print("Pump Off\n")
                time.sleep(actDelay)
                mode += 1

        else:  ##Default Path.
            #Resets Round-Robin Scheduler
            mode = 0
        ##Clean up routine when microcontroller is waiting for a response or data.
    print("Process Complete!\n")
    p.send_now("G1 X235 Y235 Z" + str(posZ) + " F" + str(speed))
    return
コード例 #42
0
                sys.exit(2)
        elif o in ('-v', '--verbose'):
            loud = True
        elif o in ('-s', '--statusreport'):
            statusreport = True

    if len(args) <= 1:
        print("Error: Port or gcode file were not specified.\n")
        print(usage)
        sys.exit(2)
    elif len(args) > 1:
        port = args[-2]
        filename = args[-1]
        print("Printing: %s on %s with baudrate %d" % (filename, port, baud))

    p = printcore(port, baud)
    p.loud = loud
    time.sleep(2)
    gcode = [i.strip() for i in open(filename)]
    gcode = gcoder.LightGCode(gcode)
    p.startprint(gcode)

    try:
        if statusreport:
            p.loud = False
            sys.stdout.write("Progress: 00.0%\r")
            sys.stdout.flush()
        while p.printing:
            time.sleep(1)
            if statusreport:
                progress = 100 * float(p.queueindex) / len(p.mainqueue)
コード例 #43
0
ファイル: gcdoe_repl.py プロジェクト: ANC-Hackathons/ancprb
#!/usr/bin/env python

# This file is part of the Printrun suite.
#
# Printrun is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Printrun is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Printrun.  If not, see <http://www.gnu.org/licenses/>.

import sys
import traceback
import logging
from printrun.printcore import printcore

if __name__ == "__main__":
	printer = printcore('/dev/tty.usbmodem1411', 115200)

	while (1) :
		command = raw_input("cmd: ")
		printer.send(command)