Beispiel #1
0
 def __init__(self,name):
     Task.__init__(self,name)
     daqmx(
         dll.DAQmxCfgImplicitTiming,
         (
             self.handle,
             constants['DAQmx_Val_FiniteSamps'],
             c_uint64(200)
         )
     )
     self.stopped = False
Beispiel #2
0
 def __init__(self,name):
     Task.__init__(self,name)
     channel = self.get_channels()[0]
     physical_channel = create_string_buffer(BUF_SIZE)
     daqmx(
         dll.DAQmxGetPhysicalChanName,
         (
             self.handle, 
             channel, 
             physical_channel, 
             BUF_SIZE
             )
         )
     self.exponent = int(
         physical_channel.value.split('/')[-1].split('line')[-1]
         )
Beispiel #3
0
 def __init__(self,*channels):
     Task.__init__(self,*channels)
     daqmx(
         dll.DAQmxSetSampQuantSampMode,
         (
             self.handle,
             constants['DAQmx_Val_FiniteSamps']
         )
     )
     daqmx(
         dll.DAQmxSetSampTimingType,
         (
             self.handle,
             constants['DAQmx_Val_SampClk']
         )
     )
Beispiel #4
0
    def __init__(self, channelDicts=None):
        """
        create an analog input task
        
        @param channelDicts: tuple of dictionaries
            that can be unpacked into the        
            L{createChannel} method (e.g.
            C{({AITask.PHYSICAL_CHANNEL:'dev0/ai1',...},...)})
        """
        Task.__init__(self)

        if channelDicts is None:
            channelDicts = tuple([])

        self.callback = None
        self.acquiring = False

        def callback(handle, eType, samples, callbackData):
            samples = self.readSamples()
            self.stopSampling()
            if self.callback is not None: self.callback(samples)
            return 0

        DAQmxDoneEventCallbackPtr = CFUNCTYPE(c_int, c_void_p, c_int, c_uint32,
                                              c_void_p)
        c_callback = DAQmxDoneEventCallbackPtr(callback)
        self.c_callback = c_callback

        daqmx(dll.DAQmxRegisterDoneEvent,
              (self.handle, 0, self.c_callback, None))

        for channelDict in channelDicts:
            self.createChannel(channelDict)

        daqmx(dll.DAQmxSetSampTimingType,
              (self.handle, constants['DAQmx_Val_SampClk']))
        daqmx(dll.DAQmxSetSampQuantSampMode,
              (self.handle, constants['DAQmx_Val_FiniteSamps']))
        sampClkMaxRate = c_double()
        daqmx(dll.DAQmxGetSampClkMaxRate, (self.handle, byref(sampClkMaxRate)))
        daqmx(dll.DAQmxSetSampClkRate, (self.handle, sampClkMaxRate))
Beispiel #5
0
    def __init__(self,channelDicts=None):
        """
        create an analog input task
        
        @param channelDicts: tuple of dictionaries
            that can be unpacked into the        
            L{createChannel} method (e.g.
            C{({AITask.PHYSICAL_CHANNEL:'dev0/ai1',...},...)})
        """
        Task.__init__(self)

        if channelDicts is None:
            channelDicts = tuple([])

        self.callback = None
        self.acquiring = False

        def callback(handle,eType,samples,callbackData):
            samples = self.readSamples()
            self.stopSampling()
            if self.callback is not None: self.callback(samples)
            return 0

        DAQmxDoneEventCallbackPtr = CFUNCTYPE(c_int, c_void_p, c_int, c_uint32, c_void_p)
        c_callback = DAQmxDoneEventCallbackPtr(callback)
        self.c_callback = c_callback

        daqmx(
            dll.DAQmxRegisterDoneEvent,
            (
                self.handle,
                0,
                self.c_callback,
                None
            )
        )

        for channelDict in channelDicts:
            self.createChannel(channelDict)
            
        daqmx(
            dll.DAQmxSetSampTimingType,
            (
                self.handle,
                constants['DAQmx_Val_SampClk']
            )
        )
        daqmx(
            dll.DAQmxSetSampQuantSampMode,
            (
                self.handle,
                constants['DAQmx_Val_FiniteSamps']
            )
        )
        sampClkMaxRate = c_double()
        daqmx(
            dll.DAQmxGetSampClkMaxRate,
            (
                self.handle,
                byref(sampClkMaxRate)
            )
        )
        daqmx(
            dll.DAQmxSetSampClkRate,
            (
                self.handle,
                sampClkMaxRate
            )
        )
Beispiel #6
0
 def __init__(self,name):
     Task.__init__(self,name)
     self.count = 0
Beispiel #7
0
 def get_units(self):
     return Task.get_units(self).values()[0]