View Single Post
  #1  
Old 09-19-2012, 09:10 AM
mhead10 mhead10 is offline
Member
 
Join Date: Mar 2012
Posts: 40
Default Splashscreen Image Remains with Continuous Sampling (Must Finite Sample)

I'm currently obtaining continuous data from my USB DAQ. My splashscreen will not show the background I have prepared for it until all of my DAQ data has loaded (ie- I haven't figured out how to load my graphics if I use continuous sampling. If I have finite sampling, then the graphics will load after all samples have been taken).

How can I have continuous sampling with what I programmed into the viz.go window? I put viz.go() at the beginning of my program, so obviously there is something else that needs to occur before I can actually start viewing and interacting with the window.

I will attach relevant code below.

Thanks

Code:
import ctypes
import numpy
import viztask
nidaq = ctypes.windll.nicaiu # load the DLL
viz.go()

# constant and variables left out for simplicity

def CHK(err):
    if err < 0:
        buf_size = 100
        buf = ctypes.create_string_buffer('\000' * buf_size)
        nidaq.DAQmxGetErrorString(err,ctypes.byref(buf),buf_size)
        raise RuntimeError('nidaq call failed with error %d: %s'%(err,repr(buf.value)))

#Main Program
CHK(nidaq.DAQmxCreateTask("",ctypes.byref(taskHandle)))
CHK(nidaq.DAQmxCreateAIVoltageChan(taskHandle,"Dev2/ai0:1","",DAQmx_Val_Cfg_Default,float64(-13.0),float64(13.0),DAQmx_Val_Volts,None))
CHK(nidaq.DAQmxCfgSampClkTiming(taskHandle,"",float64(1),DAQmx_Val_Rising,DAQmx_Val_ContSamps,uInt64(max_num_samples))); 
CHK(nidaq.DAQmxStartTask(taskHandle))

def obtain_value():
    CHK(nidaq.DAQmxReadAnalogF64(taskHandle,1,float64(-1),DAQmx_Val_GroupByChannel,data.ctypes.data,max_num_samples,ctypes.byref(read),None)) 
    print '     after read'
    print data

i = 0
while i < 10:
    i += 1         # IF I COMMENT THIS LINE OUT, MY SPLASHSCREEN WILL NOT LOAD :(
    obtain_value()

if taskHandle.value != 0:
    CHK(nidaq.DAQmxStopTask(taskHandle))
    CHK(nidaq.DAQmxClearTask(taskHandle))
Reply With Quote