class PulseGeneratorStepperMotor(LoggedStepperMotor):
    def __init__(self,
                 step_channel,
                 counter_channel,
                 direction_channel,
                 log_file=None,
                 enable_channel=None,
                 step_rate=500.0,
                 backlash=0,
                 tasks=None):
        self.step_task = COTask()
        self.step_task.createChannel(step_channel)
        self.setStepRate(step_rate)
        LoggedStepperMotor.__init__(
            self,
            counter_channel,
            direction_channel,
            log_file,
            enable_channel=enable_channel,
            backlash=0,
            tasks=((tasks if tasks is not None else []) + [self.step_task]))

    def _generateSteps(self, steps, callback):
        self.step_task.generatePulses(steps, callback)

    # set pulse rate in Hz
    def setStepRate(self, rate):
        self.step_task.configureTiming(0.5 / rate, 0.5 / rate)

    def getStepRate(self):
        highTime, lowTime = self.step_task.getTimingConfiguration()
        period = highTime + lowTime
        rate = 1.0 / period
        return rate
 def __init__(self,
              step_channel,
              counter_channel,
              direction_channel,
              log_file=None,
              enable_channel=None,
              step_rate=500.0,
              backlash=0,
              tasks=None):
     self.step_task = COTask()
     self.step_task.createChannel(step_channel)
     self.setStepRate(step_rate)
     LoggedStepperMotor.__init__(
         self,
         counter_channel,
         direction_channel,
         log_file,
         enable_channel=enable_channel,
         backlash=0,
         tasks=((tasks if tasks is not None else []) + [self.step_task]))
 def __init__(
         self,
         step_channel,
         counter_channel,
         direction_channel,
         log_file=None,
         enable_channel=None,
         step_rate=500.0,
         backlash=0,
         tasks=None
 ):
     self.step_task = COTask()
     self.step_task.createChannel(step_channel)
     self.setStepRate(step_rate)
     LoggedStepperMotor.__init__(
         self,
         counter_channel,
         direction_channel,
         log_file,
         enable_channel=enable_channel,
         backlash=0,
         tasks=((tasks if tasks is not None else []) + [self.step_task])
     )
class PulseGeneratorStepperMotor(LoggedStepperMotor):
    def __init__(
            self,
            step_channel,
            counter_channel,
            direction_channel,
            log_file=None,
            enable_channel=None,
            step_rate=500.0,
            backlash=0,
            tasks=None
    ):
        self.step_task = COTask()
        self.step_task.createChannel(step_channel)
        self.setStepRate(step_rate)
        LoggedStepperMotor.__init__(
            self,
            counter_channel,
            direction_channel,
            log_file,
            enable_channel=enable_channel,
            backlash=0,
            tasks=((tasks if tasks is not None else []) + [self.step_task])
        )


    def _generateSteps(self,steps,callback):
        self.step_task.generatePulses(steps,callback)

    # set pulse rate in Hz
    def setStepRate(self,rate):
        self.step_task.configureTiming(0.5 / rate,0.5 / rate)

    def getStepRate(self):
        highTime, lowTime = self.step_task.getTimingConfiguration()
        period = highTime + lowTime
        rate = 1.0 / period
        return rate