예제 #1
0
파일: print.py 프로젝트: johnhckuo/s3g
 def __init__(self):
     self.r = makerbot_driver.s3g()
     file = serial.Serial("/dev/cu.usbmodem641", 115200, timeout=1)
     self.r.writer = makerbot_driver.Writer.StreamWriter(file, threading.Condition())
     self.r.find_axes_maximums(['x', 'y'], 500, 60)
     self.r.find_axes_minimums(['z'], 500, 60)
     self.r.recall_home_positions(['x', 'y', 'z', 'a', 'b'])
예제 #2
0
def create_print_to_file_parser(filename, machine_name, legacy=False):
    parser = create_parser(machine_name, legacy)
    parser.s3g = makerbot_driver.s3g()
    condition = threading.Condition()
    parser.s3g.writer = makerbot_driver.Writer.FileWriter(
        open(filename, 'wb'), condition)
    return parser
예제 #3
0
 def __init__(self):
     self.condition = threading.Condition()
     self.driver = makerbot_driver.s3g()
     self.connected = False
     self.profileNames = {
         "The Replicator 2" : "Replicator2"
     }
예제 #4
0
    def setUp(self):
        self.mock = mock.Mock(makerbot_driver.s3g())

        self.g = makerbot_driver.Gcode.GcodeParser()
        self.g.s3g = self.mock
        profile = makerbot_driver.Profile("ReplicatorDual")
        self.g.state.profile = profile
예제 #5
0
파일: web_server.py 프로젝트: vongoethe/s3g
    def __init__(self, port, baud):
        """ Create a new connection to an s3g machine

        @param string port Serial port to connect to
        @param string baud Baud rate to communicate at
        """
        self.r = makerbot_driver.s3g()
        file = serial.Serial(port, baud, timeout=.2)
        self.r.writer = makerbot_driver.Writer.StreamWriter(file)
예제 #6
0
  def setUp(self):
    self.r = makerbot_driver.s3g()
    with tempfile.NamedTemporaryFile(delete=True, suffix='.gcode') as f:
      self.path = f.name

    self.r.writer = makerbot_driver.Writer.FileWriter(open(self.path, 'wb'))

    self.d = makerbot_driver.FileReader.FileReader()
    self.d.file = open(self.path, 'rb')
예제 #7
0
    def __init__(self, port, baud):
        """ Create a new connection to an s3g machine

        @param string port Serial port to connect to
        @param string baud Baud rate to communicate at
        """
        self.r = makerbot_driver.s3g()
        file = serial.Serial(port, baud, timeout=.2)
        self.r.writer = makerbot_driver.Writer.StreamWriter(file)
예제 #8
0
 def setUp(self):
     self.mock = mock.Mock(makerbot_driver.s3g())
     self.g = makerbot_driver.Gcode.GcodeParser()
     self.g.s3g = self.mock
     profile = makerbot_driver.Profile("ReplicatorDual")
     self.g.state.profile = profile
     for axis in ['X', 'Y', 'Z', 'A', 'B']:
         setattr(self.g.state.position, axis, 0)
     self.initial_position = [0, 0, 0, 0, 0]
예제 #9
0
파일: driver.py 프로젝트: hef/samsonspooler
 def connect(self, serial_port='/dev/ttyACM0'):
     self.r = makerbot_driver.s3g()
     try:
         file = serial.Serial(serial_port, 115200, timeout=1)
         self.r.writer = makerbot_driver.Writer.StreamWriter(file)
     except serial.SerialException:
         #todo log that this happened
         file = open("samson.s3g",'wb')
         self.r.writer = makerbot_driver.Writer.FileWriter(file) 
예제 #10
0
    def setUp(self):
        self.r = makerbot_driver.s3g()
        with tempfile.NamedTemporaryFile(delete=True, suffix='.gcode') as f:
            self.path = f.name

        self.r.writer = makerbot_driver.Writer.FileWriter(open(
            self.path, 'wb'))

        self.d = makerbot_driver.FileReader.FileReader()
        self.d.file = open(self.path, 'rb')
예제 #11
0
 def setUp(self):
     self.p = makerbot_driver.Gcode.GcodeParser()
     self.p.state = makerbot_driver.Gcode.LegacyGcodeStates()
     self.p.state.values['build_name'] = 'test'
     self.p.state.profile = makerbot_driver.Profile('TOMStepstruderSingle')
     self.s3g = makerbot_driver.s3g()
     with tempfile.NamedTemporaryFile(suffix='.gcode', delete=True) as f:
         path = f.name
     self.s3g.writer = makerbot_driver.Writer.FileWriter(open(path, 'wb'))
     self.p.s3g = self.s3g
예제 #12
0
 def setUp(self):
     self.p = makerbot_driver.Gcode.GcodeParser()
     self.p.state = makerbot_driver.Gcode.LegacyGcodeStates()
     self.p.state.values['build_name'] = 'test'
     self.p.state.profile = makerbot_driver.Profile('TOMStepstruderSingle')
     self.s3g = makerbot_driver.s3g()
     with tempfile.NamedTemporaryFile(suffix='.gcode', delete=True) as f:
         path = f.name
     self.s3g.writer = makerbot_driver.Writer.FileWriter(open(path, 'wb'))
     self.p.s3g = self.s3g
예제 #13
0
 def setUp(self):
     self.read_from_eeprom_mock = mock.Mock()
     self.reader = makerbot_driver.EEPROM.EepromReader()
     self.reader.s3g = makerbot_driver.s3g()
     self.reader.s3g.read_from_EEPROM = self.read_from_eeprom_mock
     with open(os.path.join(
         os.path.abspath(os.path.dirname(__file__)),
         'test_files',
         'eeprom_map.json',
     )) as f:
         self.reader.eeprom_map = json.load(f)
예제 #14
0
 def setUp(self):
     self.read_from_eeprom_mock = mock.Mock()
     self.reader = makerbot_driver.EEPROM.EepromReader()
     self.reader.s3g = makerbot_driver.s3g()
     self.reader.s3g.read_from_EEPROM = self.read_from_eeprom_mock
     with open(
             os.path.join(
                 os.path.abspath(os.path.dirname(__file__)),
                 'test_files',
                 'eeprom_map.json',
             )) as f:
         self.reader.eeprom_map = json.load(f)
예제 #15
0
    def print_to_file(self, profile, input_path, output_path, file_type,
                      has_start_end, extruders, extruder_temperature,
                      platform_temperature, material_name, build_name, task):
        try:
            with open(output_path, 'wb') as output_fp:
                condition = threading.Condition()
                writer = makerbot_driver.Writer.FileWriter(
                    output_fp, condition)
                parser = makerbot_driver.Gcode.GcodeParser()
                parser.state.profile = profile._s3g_profile
                parser.state.set_build_name(str(build_name))
                parser.s3g = makerbot_driver.s3g()
                parser.s3g.set_print_to_file_type(file_type)
                parser.s3g.writer = writer
                gcode_scaffold = profile.get_gcode_scaffold(
                    extruders, extruder_temperature, platform_temperature,
                    material_name)
                parser.environment.update(gcode_scaffold.variables)
                if 'x3g' == file_type:
                    pid = parser.state.profile.values['PID']
                    # ^ Technical debt: we get this value from conveyor local bot info, not from the profile
                    parser.s3g.x3g_version(
                        1, 0, pid=pid)  # Currently hardcode x3g v1.0

                # TODO: clear build plate message
                # parser.s3g.wait_for_button('center', 0, True, False, False)

                progress = {
                    'name': 'print-to-file',
                    'progress': 0,
                }
                task.lazy_heartbeat(progress, task.progress)
                if not has_start_end:
                    self._execute_lines(task, parser, gcode_scaffold.start)
                if conveyor.task.TaskState.RUNNING == task.state:
                    with open(input_path) as input_fp:
                        self._execute_lines(task, parser, input_fp)
                if not has_start_end:
                    self._execute_lines(task, parser, gcode_scaffold.end)
            if conveyor.task.TaskState.RUNNING == task.state:
                progress = {
                    'name': 'print-to-file',
                    'progress': 100,
                }
                task.lazy_heartbeat(progress, task.progress)
                task.end(None)
        except Exception as e:
            self._log.exception('unhandled exception; print-to-file failed')
            failure = conveyor.util.exception_to_failure(e)
            task.fail(failure)
예제 #16
0
파일: s3g.py 프로젝트: Jnesselr/conveyor
    def print_to_file(
            self, profile, input_path, output_path, file_type, has_start_end,
            extruders, extruder_temperature, platform_temperature,
            material_name, build_name, task):
        try:
            with open(output_path, 'wb') as output_fp:
                condition = threading.Condition()
                writer = makerbot_driver.Writer.FileWriter(
                    output_fp, condition)
                parser = makerbot_driver.Gcode.GcodeParser()
                parser.state.profile = profile._s3g_profile
                parser.state.set_build_name(str(build_name))
                parser.s3g = makerbot_driver.s3g()
                parser.s3g.set_print_to_file_type(file_type)
                parser.s3g.writer = writer
                gcode_scaffold = profile.get_gcode_scaffold(
                    extruders, extruder_temperature, platform_temperature,
                    material_name)
                parser.environment.update(gcode_scaffold.variables)
                if 'x3g' == file_type:
                    pid = parser.state.profile.values['PID']
                    # ^ Technical debt: we get this value from conveyor local bot info, not from the profile
                    parser.s3g.x3g_version(1, 0, pid=pid) # Currently hardcode x3g v1.0

                # TODO: clear build plate message
                # parser.s3g.wait_for_button('center', 0, True, False, False)

                progress = {
                    'name': 'print-to-file',
                    'progress': 0,
                }
                task.lazy_heartbeat(progress, task.progress)
                if not has_start_end:
                    self._execute_lines(task, parser, gcode_scaffold.start)
                if conveyor.task.TaskState.RUNNING == task.state:
                    with open(input_path) as input_fp:
                        self._execute_lines(task, parser, input_fp)
                if not has_start_end:
                    self._execute_lines(task, parser, gcode_scaffold.end)
            if conveyor.task.TaskState.RUNNING == task.state:
                progress = {
                    'name': 'print-to-file',
                    'progress': 100,
                }
                task.lazy_heartbeat(progress, task.progress)
                task.end(None)
        except Exception as e:
            self._log.exception('unhandled exception; print-to-file failed')
            failure = conveyor.util.exception_to_failure(e)
            task.fail(failure)
예제 #17
0
파일: s3g.py 프로젝트: jsadusk/conveyor
 def cancelcallback(task):
     try:
         self._log.debug('setting external stop')
         writer.set_external_stop()
     except makerbot_driver.Writer.ExternalStopError:
         self._log.debug('handled exception', exc_info=True)
     if polltemperature:
         self._log.debug('aborting printer')
         # NOTE: need a new s3g object because the old one has
         # external stop set.
         # TODO: this is a horrible hack.
         s3g = makerbot_driver.s3g()
         s3g.writer = makerbot_driver.Writer.StreamWriter(parser.s3g.writer.file)
         s3g.abort_immediately()
예제 #18
0
    def __init__(self, port='/dev/ttyACM0'):
        self.r = makerbot_driver.s3g()
        self.file = serial.Serial(port, 115200, timeout=1)
        self.condition = threading.Condition()
        self.r.writer = makerbot_driver.Writer.StreamWriter(self.file, self.condition)

        printer_name = 'Replicator2'
        # printer_name = (r.getname()).replace(' ', '')
        current_point = self.r.get_extended_position()[0]
        self.p = params(printer_name, current_point)
        with open('gctx.json') as f:
            d = json.load(f)
        self.d = d
        self.buildname = 'Unknown'
        self.ec = 0
예제 #19
0
 def setUp(self):
     wd = os.path.join(
         os.path.abspath(os.path.dirname(__file__)),
         'test_files',
     )
     map_name = 'eeprom_writer_test_map.json'
     self.writer = makerbot_driver.EEPROM.EepromWriter(
         map_name=map_name,
         working_directory=wd,
     )
     with open(os.path.join(wd, map_name)) as f:
         self.map_vals = json.load(f)
     self.writer.s3g = makerbot_driver.s3g()
     self.write_to_eeprom_mock = mock.Mock()
     self.writer.s3g.write_to_EEPROM = self.write_to_eeprom_mock
예제 #20
0
 def setUp(self):
     self.p = makerbot_driver.Gcode.GcodeParser()
     self.s = makerbot_driver.Gcode.GcodeStates()
     self.s.values['build_name'] = 'test'
     self.profile = makerbot_driver.Profile('ReplicatorSingle')
     self.s.profile = self.profile
     self.p.state = self.s
     self.s3g = makerbot_driver.s3g()
     with tempfile.NamedTemporaryFile(suffix='.gcode', delete=False) as input_file:
         pass
     input_path = input_file.name
     os.unlink(input_path)
     self.writer = makerbot_driver.Writer.FileWriter(open(input_path, 'wb'))
     self.s3g.writer = self.writer
     self.p.s3g = self.s3g
예제 #21
0
파일: s3g.py 프로젝트: jsadusk/conveyor
 def cancelcallback(task):
     try:
         self._log.debug('setting external stop')
         writer.set_external_stop()
     except makerbot_driver.Writer.ExternalStopError:
         self._log.debug('handled exception', exc_info=True)
     if polltemperature:
         self._log.debug('aborting printer')
         # NOTE: need a new s3g object because the old one has
         # external stop set.
         # TODO: this is a horrible hack.
         s3g = makerbot_driver.s3g()
         s3g.writer = makerbot_driver.Writer.StreamWriter(
             parser.s3g.writer.file)
         s3g.abort_immediately()
예제 #22
0
 def setUp(self):
     self.p = makerbot_driver.Gcode.GcodeParser()
     self.s = makerbot_driver.Gcode.GcodeStates()
     self.s.values['build_name'] = 'test'
     self.profile = makerbot_driver.Profile('ReplicatorSingle')
     self.s.profile = self.profile
     self.p.state = self.s
     self.s3g = makerbot_driver.s3g()
     with tempfile.NamedTemporaryFile(suffix='.gcode', delete=False) as input_file:
         pass
     input_path = input_file.name
     os.unlink(input_path)
     self.writer = makerbot_driver.Writer.FileWriter(open(input_path, 'wb'))
     self.s3g.writer = self.writer
     self.p.s3g = self.s3g
예제 #23
0
 def setUp(self):
     wd = os.path.join(
         os.path.abspath(os.path.dirname(__file__)),
         'test_files',
     )
     map_name = 'eeprom_writer_test_map.json'
     self.writer = makerbot_driver.EEPROM.EepromWriter(
         map_name=map_name,
         working_directory=wd,
     )
     with open(os.path.join(wd, map_name)) as f:
         self.map_vals = json.load(f)
     self.writer.s3g = makerbot_driver.s3g()
     self.write_to_eeprom_mock = mock.Mock()
     self.writer.s3g.write_to_EEPROM = self.write_to_eeprom_mock
예제 #24
0
    def __init__(self, port='/dev/ttyACM0'):
        self.r = makerbot_driver.s3g()
        self.file = serial.Serial(port, 115200, timeout=1)
        self.condition = threading.Condition()
        self.r.writer = makerbot_driver.Writer.StreamWriter(
            self.file, self.condition)

        printer_name = 'Replicator2'
        # printer_name = (r.getname()).replace(' ', '')
        current_point = self.r.get_extended_position()[0]
        self.p = params(printer_name, current_point)
        with open('gctx.json') as f:
            d = json.load(f)
        self.d = d
        self.buildname = 'Unknown'
        self.ec = 0
예제 #25
0
	def __init__(self, port, file = None):
		self.port = port
		self.serial = serial.Serial(self.port,115200,timeout=1)
		self.buffer = makerbot_driver.s3g()
		self.buffer.writer =  makerbot_driver.Writer.StreamWriter(makerbotSerial,threading.Condition())
			
		self.open = false;
			
		if file is not None:
			self.file = file
			self.load(file)
			
		self.isPrinting = false
		self.isPaused = false
		self.isStarted = false
						
		self.listeners = []
예제 #26
0
 def setUp(self):
     self.p = makerbot_driver.Gcode.GcodeParser()
     self.p.state = makerbot_driver.Gcode.LegacyGcodeStates()
     self.p.state.values['build_name'] = 'test'
     self.p.state.profile = makerbot_driver.Profile('TOMStepstruderSingle')
     start_pos = self.p.state.profile.values['print_start_sequence']['start_position']
     start_position = {
         'START_X' : start_pos['start_x'],
         'START_Y' : start_pos['start_y'],
         'START_Z' : start_pos['start_z']
     }
     self.p.environment.update(start_position)
     self.s3g = makerbot_driver.s3g()
     with tempfile.NamedTemporaryFile(suffix='.gcode', delete=True) as f:
         path = f.name
     condition = threading.Condition()
     self.s3g.writer = makerbot_driver.Writer.FileWriter(open(path, 'wb'), condition)
     self.p.s3g = self.s3g
예제 #27
0
 def setUp(self):
     self.p = makerbot_driver.Gcode.GcodeParser()
     self.s = makerbot_driver.Gcode.GcodeStates()
     self.s.values['build_name'] = 'test'
     self.profile = makerbot_driver.Profile('ReplicatorSingle')
     start_pos = self.profile.values['print_start_sequence']['start_position']
     start_position = {
         'START_X' : start_pos['start_x'],
         'START_Y' : start_pos['start_y'],
         'START_Z' : start_pos['start_z']
     }
     self.p.environment.update(start_position)
     self.s.profile = self.profile
     self.p.state = self.s
     self.s3g = makerbot_driver.s3g()
     with tempfile.NamedTemporaryFile(suffix='.gcode', delete=False) as input_file:
         pass
     input_path = input_file.name
     os.unlink(input_path)
     condition = threading.Condition()
     self.writer = makerbot_driver.Writer.FileWriter(open(input_path, 'wb'), condition)
     self.s3g.writer = self.writer
     self.p.s3g = self.s3g
예제 #28
0
파일: osc_demo.py 프로젝트: vongoethe/s3g
import optparse
import OSC
import threading

parser = optparse.OptionParser()
parser.add_option("-p", "--serialport", dest="serialportname",
                  help="serial port (ex: /dev/ttyUSB0)", default="/dev/ttyACM0")
parser.add_option("-b", "--baud", dest="serialbaud",
                  help="serial port baud rate", default="115200")
parser.add_option("-o", "--oscport", dest="oscport",
                  help="OSC port to listen on", default="10000")
(options, args) = parser.parse_args()


rLock = threading.Lock()
r = makerbot_driver.s3g()

file = serial.Serial(options.serialportname, options.serialbaud, timeout=0)
condition = threading.Condition()
r.writer = makerbot_driver.Writer.StreamWriter(file, condition)

# TODO: Remove this hack.
r.velocity = 1600

def velocity_handler(addr, tags, stuff, source):
    """
    Allow an external program to modify the movement rate
    """
    print stuff[0]
    with rLock:
        r.velocity = stuff[0]
예제 #29
0
 def pollMakerbot(self):
     # Structure to hold data.
     makerbotData = {"availability":"UNAVAILABLE",
                     "xPos":"UNAVAILABLE","yPos":"UNAVAILABLE","zPos":"UNAVAILABLE",
                     "aPos":"UNAVAILABLE","bPos":"UNAVAILABLE",
                     "toolheadTemp":"UNAVAILABLE", "toolheadReady":"UNAVAILABLE",
                     "extruderTemp":"UNAVAILABLE", "extruderReady":"UNAVAILABLE",
                     "platformTemp":"UNAVAILABLE", "platformReady":"UNAVAILABLE",
                     "powerError":"UNAVAILABLE", "waitForButton":"UNAVAILABLE",
                     "heatShutdown":"UNAVAILABLE", "preheat":"UNAVAILABLE",
                     "buildCancel":"UNAVAILABLE"
                     }
     
     # Variable to hold the port that will be determined.
     makerbotPort = None
     # Find the port on which the makerbot is connected, if it is.
     for port in list_ports.comports():
         # If it is a Replicator.
         if "Replicator" in port[1]:
             # Set the port.
             makerbotPort = port[0]
         # end if
     # end for
     
     # If the makerbot was found.
     if makerbotPort != None:
         # Get values from the makerbot.
         try:
             # Create the dictionary to hold the data to be collected from the makerbot.
             makerbotData = {}
             # Create the makerbot s3g interface object.
             replicator = makerbot_driver.s3g()
             # Open the port to the makerbot.
             makerbotStream = serial.Serial(makerbotPort, 115200, timeout=1)
             # Create the condition.
             condition = threading.Condition()
             # Set the stream writer to the opened stream.
             replicator.writer = makerbot_driver.Writer.StreamWriter(makerbotStream, condition)
             
             # ***Make the queries***
             
             # Availability
             makerbotData["availability"] = "AVAILABLE"
             
             # Axes
             axes = replicator.get_extended_position()
             makerbotData["xPos"] = axes[0][0]
             makerbotData["yPos"] = axes[0][1]
             makerbotData["zPos"] = axes[0][2]
             makerbotData["aPos"] = axes[0][3]
             makerbotData["bPos"] = axes[0][4]
             
             # Toolhead
             makerbotData["toolheadTemp"] = replicator.get_toolhead_temperature(0)
             toolheadReady = str(replicator.is_tool_ready(0))
             if toolheadReady:
                  makerbotData["toolheadReady"] = "READY"
             else:
                 makerbotData["toolheadReady"] = "STOPPED"
             
             # Extruder
             status = replicator.get_tool_status(0)
             extruderReady = status["ExtruderReady"]
             if extruderReady:
                 makerbotData["extruderReady"] = "READY"
             else:
                 makerbotData["extruderReady"] = "STOPPED"
             
             # Platform
             makerbotData["platformTemp"] = replicator.get_platform_temperature(0)
             platformReady = replicator.is_platform_ready(0)
             if platformReady:
                 makerbotData["platformReady"] = "READY"
             else:
                 makerbotData["platformReady"] = "STOPPED"
             
             # Motherboard
         except:
             print "MakerbotInterface.pollMakerbot, Error getting data from Makerbot: "+str(sys.exc_info())
         # end try-catch
     # end if
     # Otherwise, set things accordingly.
     else:
         self.available = False
     # end else
     
     # Return the reslts.
     return makerbotData
예제 #30
0
    def pollMakerbot(self):
        # Structure to hold data.
        makerbotData = {
            "availability": "UNAVAILABLE",
            "xPos": "UNAVAILABLE",
            "yPos": "UNAVAILABLE",
            "zPos": "UNAVAILABLE",
            "aPos": "UNAVAILABLE",
            "bPos": "UNAVAILABLE",
            "toolheadTemp": "UNAVAILABLE",
            "toolheadReady": "UNAVAILABLE",
            "extruderTemp": "UNAVAILABLE",
            "extruderReady": "UNAVAILABLE",
            "platformTemp": "UNAVAILABLE",
            "platformReady": "UNAVAILABLE",
            "powerError": "UNAVAILABLE",
            "waitForButton": "UNAVAILABLE",
            "heatShutdown": "UNAVAILABLE",
            "preheat": "UNAVAILABLE",
            "buildCancel": "UNAVAILABLE"
        }

        # Variable to hold the port that will be determined.
        makerbotPort = None
        # Find the port on which the makerbot is connected, if it is.
        for port in list_ports.comports():
            # If it is a Replicator.
            if "Replicator" in port[1]:
                # Set the port.
                makerbotPort = port[0]
            # end if
        # end for

        # If the makerbot was found.
        if makerbotPort != None:
            # Get values from the makerbot.
            try:
                # Create the dictionary to hold the data to be collected from the makerbot.
                makerbotData = {}
                # Create the makerbot s3g interface object.
                replicator = makerbot_driver.s3g()
                # Open the port to the makerbot.
                makerbotStream = serial.Serial(makerbotPort, 115200, timeout=1)
                # Create the condition.
                condition = threading.Condition()
                # Set the stream writer to the opened stream.
                replicator.writer = makerbot_driver.Writer.StreamWriter(
                    makerbotStream, condition)

                # ***Make the queries***

                # Availability
                makerbotData["availability"] = "AVAILABLE"

                # Axes
                axes = replicator.get_extended_position()
                makerbotData["xPos"] = axes[0][0]
                makerbotData["yPos"] = axes[0][1]
                makerbotData["zPos"] = axes[0][2]
                makerbotData["aPos"] = axes[0][3]
                makerbotData["bPos"] = axes[0][4]

                # Toolhead
                makerbotData[
                    "toolheadTemp"] = replicator.get_toolhead_temperature(0)
                toolheadReady = str(replicator.is_tool_ready(0))
                if toolheadReady:
                    makerbotData["toolheadReady"] = "READY"
                else:
                    makerbotData["toolheadReady"] = "STOPPED"

                # Extruder
                status = replicator.get_tool_status(0)
                extruderReady = status["ExtruderReady"]
                if extruderReady:
                    makerbotData["extruderReady"] = "READY"
                else:
                    makerbotData["extruderReady"] = "STOPPED"

                # Platform
                makerbotData[
                    "platformTemp"] = replicator.get_platform_temperature(0)
                platformReady = replicator.is_platform_ready(0)
                if platformReady:
                    makerbotData["platformReady"] = "READY"
                else:
                    makerbotData["platformReady"] = "STOPPED"

                # Motherboard
            except:
                print "MakerbotInterface.pollMakerbot, Error getting data from Makerbot: " + str(
                    sys.exc_info())
            # end try-catch
        # end if
        # Otherwise, set things accordingly.
        else:
            self.available = False
        # end else

        # Return the reslts.
        return makerbotData
예제 #31
0
 def setUp(self):
     self.reader = makerbot_driver.EEPROM.EepromReader()
     self.reader.s3g = makerbot_driver.s3g()
예제 #32
0
# Variable to hold the makerbot port.
makerbotPort = None

# Find the port on which the maker bot is connected.
for port in list_ports.comports():
    # If it is a Replicator.
    if "Replicator" in port[1]:
        # Set the port.
        makerbotPort = port[0]
    # end if
# end for

# If the makerbot port was found (if it is connected).
if makerbotPort != None:
    # Create the makerbot s3g interface object.
    replicator = makerbot_driver.s3g()
    # Open the port to the makerbot.
    makerbotFile = serial.Serial(makerbotPort, 115200, timeout=1)
    # Create the condition.
    condition = threading.Condition()
    # Set the stream writer to the opened port/stream.
    replicator.writer = makerbot_driver.Writer.StreamWriter(
        makerbotFile, condition)

    # *** Other Queries ***

    print "\n**************\n"

    # name: string
    print "Name: " + str(replicator.get_name())
lib_path = os.path.abspath('../')
sys.path.insert(0, lib_path)
lib_path = os.path.abspath('s3g/')
sys.path.insert(0, lib_path)


import optparse
import serial
import io
import struct
import array
import makerbot_driver
import csv
import time

s3g_port = makerbot_driver.s3g()

def GetHeaterReads():
  
  log_file = csv.writer(open(options.filename, 'wb'), delimiter=' ')
  start_time = time.time()

  while 1:
    temps = [time.time()-start_time]
    try:
      if options.platform:
        platform_temp = s3g_port.get_platform_temperature(0)
        temps.append(platform_temp)
        print "platform %d" % (platform_temp)
      if options.toolhead:
        raw_temp = s3g_port.get_toolhead_temperature(int(options.toolhead))
예제 #34
0
파일: s3g.py 프로젝트: jsadusk/conveyor
 def create_s3g_from_fp(self, fp):
     s = makerbot_driver.s3g()
     s.writer = makerbot_driver.Writer.StreamWriter(fp)
     return s
예제 #35
0
파일: s3g.py 프로젝트: jsadusk/conveyor
 def run(self):
     try:
         s3g = makerbot_driver.s3g()
         s3g.writer = makerbot_driver.Writer.StreamWriter(self._fp)
         now = time.time()
         polltime = now + 5.0
         while not self._stop:
             if self._states['idle'] and self._curprintjob is None:
                 with self._condition:
                     if 0 < len(self._queue):
                         self._curprintjob = self._queue.pop()
                 now = time.time()
                 if polltime <= now:
                     polltime = now + 5.0
                     try:
                         with self._condition:  # TODO: this is a hack
                             temperature = _gettemperature(
                                 self._profile, s3g)
                     except makerbot_driver.BuildCancelledError:
                         self._log.debug('handled exception', exc_info=True)
                         # This happens when print from SD and cancel it on
                         # the bot. There is no conveyor job to cancel.
                     else:
                         self._server.changeprinter(self._portname,
                                                    temperature)
                 with self._condition:
                     self._log.debug('waiting')
                     self._condition.wait(1.0)
                     self._log.debug('resumed')
             elif self._states['idle'] and self._curprintjob is not None:
                 job, buildname, gcodepath, skip_start_end, slicer_settings, material, task = self._curprintjob
                 driver = S3gDriver()
                 try:
                     with self._condition:
                         self._statetransition("idle", "printing")
                         self._currenttask = task
                     driver.print(self._server, self._portname, self._fp,
                                  self._profile, buildname, gcodepath,
                                  skip_start_end, slicer_settings, material,
                                  task)
                 except PrinterThreadNotIdleError:
                     self._log.debug('handled exception', exc_info=True)
                 except makerbot_driver.BuildCancelledError:
                     self._log.debug('handled exception', exc_info=True)
                     self._log.info('print canceled')
                     if (None is not self._currenttask
                             and conveyor.task.TaskState.STOPPED !=
                             self._currenttask.state):
                         with self._condition:
                             self._currenttask.cancel()
                 except makerbot_driver.Writer.ExternalStopError:
                     self._log.debug('handled exception', exc_info=True)
                     self._log.info('print canceled')
                     if (None is not self._currenttask
                             and conveyor.task.TaskState.STOPPED !=
                             self._currenttask.state):
                         with self._condition:
                             self._currenttask.cancel()
                 except Exception as e:
                     self._log.error('unhandled exception', exc_info=True)
                     with self._condition:
                         if None is not self._currenttask:
                             self._currenttask.fail(e)
                 now = time.time()
                 polltime = now + 5.0
     except:
         self._log.exception('unhandled exception')
         self._server.evictprinter(self._portname, self._fp)
     finally:
         self._fp.close()
예제 #36
0
파일: s3g.py 프로젝트: jsadusk/conveyor
    def _genericprint(self, server, portname, profile, buildname, writer,
                      polltemperature, pollinterval, gcodepath, skip_start_end,
                      slicer_settings, material, task):
        current_progress = None
        new_progress = {'name': 'print', 'progress': 0}
        current_progress = self._update_progress(current_progress,
                                                 new_progress, task)
        parser = makerbot_driver.Gcode.GcodeParser()
        parser.state.profile = profile
        parser.state.set_build_name(str(buildname))
        parser.s3g = makerbot_driver.s3g()
        parser.s3g.writer = writer

        def cancelcallback(task):
            try:
                self._log.debug('setting external stop')
                writer.set_external_stop()
            except makerbot_driver.Writer.ExternalStopError:
                self._log.debug('handled exception', exc_info=True)
            if polltemperature:
                self._log.debug('aborting printer')
                # NOTE: need a new s3g object because the old one has
                # external stop set.
                # TODO: this is a horrible hack.
                s3g = makerbot_driver.s3g()
                s3g.writer = makerbot_driver.Writer.StreamWriter(
                    parser.s3g.writer.file)
                s3g.abort_immediately()

        task.cancelevent.attach(cancelcallback)
        if polltemperature:
            self._log.debug('resetting machine %s', portname)
            parser.s3g.reset()
        now = time.time()
        polltime = now + pollinterval
        if not polltemperature:
            temperature = None
        else:
            temperature = _gettemperature(profile, parser.s3g)
            server.changeprinter(portname, temperature)
        gcodelines, variables = self._gcodelines(profile, gcodepath,
                                                 skip_start_end,
                                                 slicer_settings, material)
        parser.environment.update(variables)
        # TODO: remove this {current,total}{byte,line} stuff; we have
        # proper progress from the slicer now.
        totallines, totalbytes = self._countgcodelines(gcodelines)
        currentbyte = 0
        for currentline, data in enumerate(gcodelines):
            if conveyor.task.TaskState.RUNNING != task.state:
                break
            else:
                # Increment currentbyte *before* stripping whitespace
                # out of data or the currentbyte will not match the
                # actual file position.
                currentbyte += len(data)
                data = data.strip()
                now = time.time()
                if polltemperature and polltime <= now:
                    temperature = _gettemperature(profile, parser.s3g)
                self._log.debug('gcode: %r', data)
                # The s3g module cannot handle unicode strings.
                data = str(data)
                parser.execute_line(data)
                new_progress = {
                    'name': 'print',
                    'progress': int(parser.state.percentage)
                }
                if polltime <= now:
                    polltime = now + pollinterval
                    if polltemperature:
                        server.changeprinter(portname, temperature)
                current_progress = self._update_progress(
                    current_progress, new_progress, task)

        if polltemperature:
            '''
                # This is the code that should be, but it requires new
                # firmware.
                while conveyor.task.TaskState.STOPPED != task.state:
                    build_stats = parser.s3g.get_build_stats()
                    build_state = build_stats['BuildState']
                    self._log.debug('build_stats=%r', build_stats)
                    self._log.debug('build_state=%r', build_state)
                    if 0 == build_state or 2 == build_state or 4 == build_state: # TODO: constants for these magic codes
                        break
                    else:
                        time.sleep(0.2) # TODO: wait on a condition
                '''
            while conveyor.task.TaskState.STOPPED != task.state:
                available = parser.s3g.get_available_buffer_size()
                if 512 == available:
                    break
                else:
                    time.sleep(0.2)  # TODO: wait on a condition

        if conveyor.task.TaskState.STOPPED != task.state:
            new_progress = {'name': 'print', 'progress': 100}
            current_progress = self._update_progress(current_progress,
                                                     new_progress, task)
            task.end(None)
예제 #37
0
파일: s3g.py 프로젝트: jsadusk/conveyor
    def _genericprint(
        self, server, portname, profile, buildname, writer, polltemperature,
        pollinterval, gcodepath, skip_start_end, slicer_settings, material,
        task):
            current_progress = None
            new_progress = {
                'name': 'print',
                'progress': 0
            }
            current_progress = self._update_progress(
                current_progress, new_progress, task)
            parser = makerbot_driver.Gcode.GcodeParser()
            parser.state.profile = profile
            parser.state.set_build_name(str(buildname))
            parser.s3g = makerbot_driver.s3g()
            parser.s3g.writer = writer
            def cancelcallback(task):
                try:
                    self._log.debug('setting external stop')
                    writer.set_external_stop()
                except makerbot_driver.Writer.ExternalStopError:
                    self._log.debug('handled exception', exc_info=True)
                if polltemperature:
                    self._log.debug('aborting printer')
                    # NOTE: need a new s3g object because the old one has
                    # external stop set.
                    # TODO: this is a horrible hack.
                    s3g = makerbot_driver.s3g()
                    s3g.writer = makerbot_driver.Writer.StreamWriter(parser.s3g.writer.file)
                    s3g.abort_immediately()
            task.cancelevent.attach(cancelcallback)
            if polltemperature:
                self._log.debug('resetting machine %s', portname)
                parser.s3g.reset()
            now = time.time()
            polltime = now + pollinterval
            if not polltemperature:
                temperature = None
            else:
                temperature = _gettemperature(profile, parser.s3g)
                server.changeprinter(portname, temperature)
            gcodelines, variables = self._gcodelines(
                profile, gcodepath, skip_start_end, slicer_settings, material)
            parser.environment.update(variables)
            # TODO: remove this {current,total}{byte,line} stuff; we have
            # proper progress from the slicer now.
            totallines, totalbytes = self._countgcodelines(gcodelines)
            currentbyte = 0
            for currentline, data in enumerate(gcodelines):
                if conveyor.task.TaskState.RUNNING != task.state:
                    break
                else:
                    # Increment currentbyte *before* stripping whitespace
                    # out of data or the currentbyte will not match the
                    # actual file position.
                    currentbyte += len(data)
                    data = data.strip()
                    now = time.time()
                    if polltemperature and polltime <= now:
                        temperature = _gettemperature(profile, parser.s3g)
                    self._log.debug('gcode: %r', data)
                    # The s3g module cannot handle unicode strings.
                    data = str(data)
                    parser.execute_line(data)
                    new_progress = {
                        'name': 'print',
                        'progress': int(parser.state.percentage)
                    }
                    if polltime <= now:
                        polltime = now + pollinterval
                        if polltemperature:
                            server.changeprinter(portname, temperature)
                    current_progress = self._update_progress(
                        current_progress, new_progress, task)

            if polltemperature:
                '''
                # This is the code that should be, but it requires new
                # firmware.
                while conveyor.task.TaskState.STOPPED != task.state:
                    build_stats = parser.s3g.get_build_stats()
                    build_state = build_stats['BuildState']
                    self._log.debug('build_stats=%r', build_stats)
                    self._log.debug('build_state=%r', build_state)
                    if 0 == build_state or 2 == build_state or 4 == build_state: # TODO: constants for these magic codes
                        break
                    else:
                        time.sleep(0.2) # TODO: wait on a condition
                '''
                while conveyor.task.TaskState.STOPPED != task.state:
                    available = parser.s3g.get_available_buffer_size()
                    if 512 == available:
                        break
                    else:
                        time.sleep(0.2) # TODO: wait on a condition

            if conveyor.task.TaskState.STOPPED != task.state:
                new_progress = {
                    'name': 'print',
                    'progress': 100
                }
                current_progress = self._update_progress(
                    current_progress, new_progress, task)
                task.end(None)
import os, sys
lib_path = os.path.abspath('../')
sys.path.insert(0, lib_path)
lib_path = os.path.abspath('s3g/')
sys.path.insert(0, lib_path)

import optparse
import serial
import io
import struct
import array
import makerbot_driver
import csv
import time

s3g_port = makerbot_driver.s3g()


def GetHeaterReads():

    log_file = csv.writer(open(options.filename, 'wb'), delimiter=' ')
    start_time = time.time()

    while 1:
        temps = [time.time() - start_time]
        try:
            if options.platform:
                platform_temp = s3g_port.get_platform_temperature(0)
                temps.append(platform_temp)
                print "platform %d" % (platform_temp)
            if options.toolhead:
예제 #39
0
파일: s3g.py 프로젝트: jsadusk/conveyor
 def create_s3g_from_fp(self, fp):
     s = makerbot_driver.s3g()
     s.writer = makerbot_driver.Writer.StreamWriter(fp)
     return s
예제 #40
0
 def setUp(self):
     self.reader = makerbot_driver.EEPROM.EepromReader()
     self.reader.s3g = makerbot_driver.s3g()
예제 #41
0
def create_print_to_file_parser(filename, machine_name, legacy=False):
    parser = create_parser(machine_name, legacy)
    parser.s3g = makerbot_driver.s3g()
    condition = threading.Condition()
    parser.s3g.writer = makerbot_driver.Writer.FileWriter(open(filename, 'wb'), condition)
    return parser
예제 #42
0
파일: s3g.py 프로젝트: jsadusk/conveyor
 def run(self):
     try:
         s3g = makerbot_driver.s3g()
         s3g.writer = makerbot_driver.Writer.StreamWriter(self._fp)
         now = time.time()
         polltime = now + 5.0
         while not self._stop:
             if self._states['idle'] and self._curprintjob is None:
                 with self._condition:
                     if 0 < len(self._queue):
                         self._curprintjob = self._queue.pop()
                 now = time.time()
                 if polltime <= now:
                     polltime = now + 5.0
                     try:
                         with self._condition: # TODO: this is a hack
                             temperature = _gettemperature(self._profile, s3g)
                     except makerbot_driver.BuildCancelledError:
                         self._log.debug('handled exception', exc_info=True)
                         # This happens when print from SD and cancel it on
                         # the bot. There is no conveyor job to cancel.
                     else:
                         self._server.changeprinter(
                             self._portname, temperature)
                 with self._condition:
                     self._log.debug('waiting')
                     self._condition.wait(1.0)
                     self._log.debug('resumed')
             elif self._states['idle'] and self._curprintjob is not None:
                 job, buildname, gcodepath, skip_start_end, slicer_settings, material, task = self._curprintjob
                 driver = S3gDriver()
                 try:
                     with self._condition:
                         self._statetransition("idle", "printing")
                         self._currenttask = task
                     driver.print(
                         self._server, self._portname, self._fp,
                         self._profile, buildname, gcodepath,
                         skip_start_end, slicer_settings, material, task)
                 except PrinterThreadNotIdleError:
                     self._log.debug('handled exception', exc_info=True)
                 except makerbot_driver.BuildCancelledError:
                     self._log.debug('handled exception', exc_info=True)
                     self._log.info('print canceled')
                     if (None is not self._currenttask
                         and conveyor.task.TaskState.STOPPED != self._currenttask.state):
                             with self._condition:
                                 self._currenttask.cancel()
                 except makerbot_driver.Writer.ExternalStopError:
                     self._log.debug('handled exception', exc_info=True)
                     self._log.info('print canceled')
                     if (None is not self._currenttask
                         and conveyor.task.TaskState.STOPPED != self._currenttask.state):
                             with self._condition:
                                 self._currenttask.cancel()
                 except Exception as e:
                     self._log.error('unhandled exception', exc_info=True)
                     with self._condition:
                         if None is not self._currenttask:
                             self._currenttask.fail(e)
                 now = time.time()
                 polltime = now + 5.0
     except:
         self._log.exception('unhandled exception')
         self._server.evictprinter(self._portname, self._fp)
     finally:
         self._fp.close()
예제 #43
0
# Variable to hold the makerbot port.
makerbotPort = None

# Find the port on which the maker bot is connected.
for port in list_ports.comports():
    # If it is a Replicator.
    if "Replicator" in port[1]:
        # Set the port.
        makerbotPort = port[0]
    # end if
# end for

# If the makerbot port was found (if it is connected).
if makerbotPort != None:
    # Create the makerbot s3g interface object.
    replicator = makerbot_driver.s3g()
    # Open the port to the makerbot.
    makerbotFile = serial.Serial(makerbotPort, 115200, timeout=1)
    # Create the condition.
    condition = threading.Condition()
    # Set the stream writer to the opened port/stream.
    replicator.writer = makerbot_driver.Writer.StreamWriter(makerbotFile,condition)
    
    # *** Other Queries ***
    
    print "\n**************\n"
    
    # name: string
    print "Name: "+str(replicator.get_name())
    
    # Version