Exemplo n.º 1
0
 def gcode_prep_bed_temp(self):
     self.temp_layer1.append_node(
         gcode_analyzer.GCode('M140', {
             'S':
             conf.bed_temperature(1, self.tool_activation_seq.keys())
         }))
     self.temp_layer1.append_node(gcode_analyzer.GCode('M190'))
Exemplo n.º 2
0
    def gcode_prep_header(self):
        # Prepare gcode in the header
        gcode_init = doublelinkedlist.DLList()
        gcode_wait = doublelinkedlist.DLList()

        # Check the runtime estimate between TC_TEMP_INITIALIZE and first tool activation
        for tool_id, activation_seq in self.tool_activation_seq.items():
            tool_info = activation_seq[0]

            time_delta = 0.0
            token = self.temp_header.next
            while token != tool_info.tool_change:
                time_delta += token.runtime
                token = token.next

            logger.debug(
                "INIT -> T{tool} - runtime estimate: {delta:0.2f}".format(
                    tool=tool_id, delta=time_delta))

            tool_temp = conf.tool_temperature(
                tool_info.tool_change.state_pre.layer_num, tool_id)
            # Check if should set idle temp or tool temp at INIT point
            # temp_idle = tool_temp - temp_idle_delta
            time_temp_idle2tool = float(conf.temp_idle_delta) / float(
                conf.temp_heating_rate)

            if time_temp_idle2tool < time_delta:
                # Find the inject point
                acc_time = 0.0
                inject_point = tool_info.tool_change.prev
                while inject_point is not None:
                    acc_time += inject_point.runtime
                    if acc_time >= time_temp_idle2tool:
                        break
                    inject_point = inject_point.prev

                logger.debug(
                    "Inject point for T{tool} is before \"{token}\" - time diff: {delta:0.2f}s"
                    .format(tool=tool_id,
                            token=str(inject_point),
                            delta=acc_time))

                # Insert idle temp in TC_INIT
                # Insert ramp up at inject point
                # Insert temp wait before tool change
                gcode_init.append_node(
                    gcode_analyzer.GCode('M104', {
                        'T': tool_id,
                        'S': tool_temp - conf.temp_idle_delta
                    }))
                gcode_wait.append_node(
                    gcode_analyzer.GCode('M116', {
                        'P': tool_id,
                        'S': 5
                    }))

                inject_point.append_node(
                    gcode_analyzer.GCode('G10', {
                        'P': tool_id,
                        'R': tool_temp
                    }))
                tool_info.tool_change.append_node_left(
                    gcode_analyzer.GCode('M116', {
                        'P': tool_id,
                        'S': 5
                    }))
            else:
                logger.debug(
                    "Inject point for T{tool} at TC_INIT".format(tool=tool_id))

                # Insert target temp at TC_INIT
                # Insert temp wait at TC_INIT
                gcode_init.append_node(
                    gcode_analyzer.GCode('M104', {
                        'T': tool_id,
                        'S': tool_temp
                    }))
                gcode_wait.append_node(
                    gcode_analyzer.GCode('M116', {
                        'P': tool_id,
                        'S': 5
                    }))

        # Inject code for bed temperature
        gcode_init.append_node(
            gcode_analyzer.GCode('M140', {
                'S':
                conf.bed_temperature(0, self.tool_activation_seq.keys())
            }))
        gcode_wait.append_node(gcode_analyzer.GCode('M190'))

        # Inject the gcode at TC_INIT
        self.temp_header.append_nodes_right(gcode_wait)
        self.temp_header.append_nodes_right(gcode_init)