コード例 #1
0
def setspeed(self, **words):
    try:
        c = self.blocks[self.remap_level]
        if not c.s_flag:
            self.set_errormsg("S requires a value")
            return INTERP_ERROR
        self.params["speed"] = c.s_number

        speeds = {
            0: [2, 3, 2, 1],
            40: [2, 3, 3, 1],
            50: [3, 3, 3, 1],
            63: [1, 3, 3, 1],
            80: [2, 1, 3, 1],
            100: [3, 1, 3, 1],
            125: [1, 1, 3, 1],
            160: [2, 2, 3, 1],
            200: [3, 2, 3, 1],
            250: [1, 2, 3, 1],
            315: [2, 3, 1, 1],
            400: [3, 3, 1, 1],
            500: [1, 3, 1, 1],
            630: [2, 1, 1, 1],
            800: [3, 1, 1, 1],
            1000: [1, 1, 1, 1],
            1250: [2, 2, 1, 1],
            1600: [3, 2, 1, 1],
            2000: [1, 2, 1, 1],
            2500: [2, 2, 1, 2],
            3150: [3, 2, 1, 2],
            4000: [1, 2, 1, 2]
        }

        if c.s_number in speeds:
            gear = speeds[c.s_number]
            hal.set_p("gearbox.block_1_cmd", str(gear[0]))
            hal.set_p("gearbox.block_2_cmd", str(gear[1]))
            hal.set_p("gearbox.block_3_cmd", str(gear[2]))
            if gear[3] == 1:
                hal.set_p("gearbox.stage_1", '1')
                hal.set_p("gearbox.stage_2", '0')
            else:
                hal.set_p("gearbox.stage_1", '0')
                hal.set_p("gearbox.stage_2", '1')

        emccanon.enqueue_SET_SPINDLE_SPEED(0, c.s_number)
        print("SETSPEED: Here I am")
        return INTERP_OK

    except Exception, e:
        self.set_errormsg("Setspeed: %s" % (e))
        return INTERP_ERROR
コード例 #2
0
def setspeed_new(self, **words):
    speed = 0
    c = self.blocks[self.remap_level]
    if c.s_flag:
        speed = int(c.s_number)
    else:
        cmd.error_msg("S command without speed value was provided")

    speeds = {
        0: [2, 3, 2, 1],
        40: [2, 3, 3, 1],
        50: [3, 3, 3, 1],
        63: [1, 3, 3, 1],
        80: [2, 1, 3, 1],
        100: [3, 1, 3, 1],
        125: [1, 1, 3, 1],
        160: [2, 2, 3, 1],
        200: [3, 2, 3, 1],
        250: [1, 2, 3, 1],
        315: [2, 3, 1, 1],
        400: [3, 3, 1, 1],
        500: [1, 3, 1, 1],
        630: [2, 1, 1, 1],
        800: [3, 1, 1, 1],
        1000: [1, 1, 1, 1],
        1250: [2, 2, 1, 1],
        1600: [3, 2, 1, 1],
        2000: [1, 2, 1, 1],
        2500: [2, 2, 1, 2],
        3150: [3, 2, 1, 2],
        4000: [1, 2, 1, 2]
    }

    if speed in speeds:
        gear = speeds[speed]
        hal.set_p("gearbox.block_1_cmd", str(gear[0]))
        hal.set_p("gearbox.block_2_cmd", str(gear[1]))
        hal.set_p("gearbox.block_3_cmd", str(gear[2]))
        if gear[3] == 1:
            hal.set_p("gearbox.stage_1", '1')
            hal.set_p("gearbox.stage_2", '0')
        else:
            hal.set_p("gearbox.stage_1", '0')
            hal.set_p("gearbox.stage_2", '1')

        emccanon.enqueue_SET_SPINDLE_SPEED(0, float(speed))

        print("gearbox set")
    else:
        cmd.error_msg("Spindle speed not available")
コード例 #3
0
ファイル: stdglue.py プロジェクト: LinuxCNC/linuxcnc
def setspeed_epilog(self,**words):
    try:
        if not self.value_returned:
            r = self.blocks[self.remap_level].executing_remap
            self.set_errormsg("the %s remap procedure %s did not return a value"
                             % (r.name,r.remap_ngc if r.remap_ngc else r.remap_py))
            return INTERP_ERROR
        if self.return_value < -TOLERANCE_EQUAL: # 'less than 0 within interp's precision'
            self.set_errormsg("S: remap procedure returned %f" % (self.return_value)) 
            return INTERP_ERROR
        if self.blocks[self.remap_level].builtin_used:
            pass
            #print "---------- S builtin recursion, nothing to do"
        else:
            self.speed = self.params["speed"]
            emccanon.enqueue_SET_SPINDLE_SPEED(self.speed)
        return INTERP_OK
    except Exception,e:
        self.set_errormsg("S/setspeed_epilog: %s)" % (e))
        return INTERP_ERROR
コード例 #4
0
ファイル: stdglue.py プロジェクト: zhandl/linuxcnc
def setspeed_epilog(self,**words):
    try:
        if not self.value_returned:
            r = self.blocks[self.remap_level].executing_remap
            self.set_errormsg("the %s remap procedure %s did not return a value"
                             % (r.name,r.remap_ngc if r.remap_ngc else r.remap_py))
            return INTERP_ERROR
        if self.return_value < -TOLERANCE_EQUAL: # 'less than 0 within interp's precision'
            self.set_errormsg("S: remap procedure returned %f" % (self.return_value)) 
            return INTERP_ERROR
        if self.blocks[self.remap_level].builtin_used:
            pass
            #print "---------- S builtin recursion, nothing to do"
        else:
            self.speed = self.params["speed"]
            emccanon.enqueue_SET_SPINDLE_SPEED(self.speed)
        return INTERP_OK
    except Exception,e:
        self.set_errormsg("S/setspeed_epilog: %s)" % (e))
        return INTERP_ERROR