Beispiel #1
0
    def doAutoTemp(self, moves):

        # Sum up path time and extrusion volume of moves
        tsum = 0
        vsum = 0
        for move in moves:
            tsum += move.accelData.getTime()
            vsum += move.getExtrusionVolume(MatProfile.get())

        avgERate = vsum / tsum

        print "Average extrusion rate: ", avgERate, "mm³/s", "layer 0 increase: ", self.planner.l0TempIncrease

        # Compute temperature for this segment and add tempcommand into the stream.
        newTemp = \
            MatProfile.getTempForFlowrate(avgERate * (1.0+AutotempSafetyMargin), PrinterProfile.getHwVersion(), NozzleProfile.getSize()) + \
            self.planner.l0TempIncrease

        # Don't go below startTemp from material profile
        newTemp = max(newTemp, MatProfile.getHotendStartTemp())
        # Don't go above max temp from material profile
        newTemp = min(newTemp, MatProfile.getHotendMaxTemp())

        if newTemp != self.lastTemp:  #  and self.mode != "pre":

            print "Newtemp:", avgERate, newTemp

            # Schedule target temp command
            self.planner.addSynchronizedCommand(
                CmdSyncTargetTemp,
                p1=packedvalue.uint8_t(HeaterEx1),
                p2=packedvalue.uint16_t(newTemp),
                moveNumber=move.moveNumber)

            self.lastTemp = int(newTemp)

        if debugAutoTemp:
            print "AutoTemp: collected moves with %.2f s duration." % tsum
            print "AutoTemp: max. extrusion rate: %.2f mm³/s." % avgERate
            print "AutoTemp: new temp: %d." % newTemp