#NEWLINE# @ Action ( units = ( None , None , 'seconds' , None ) , values = ( None , { True , False } , None , _GROUP_BY ) ) #NEWLINE# def write( self , data , auto_start = True , timeout = 10.0 , group_by = 'scan' ) : #NEWLINE# #INDENT# "\n        Writes multiple samples to each digital line in a task. When\n        you create your write array, each sample per channel must\n        contain the number of bytes returned by the\n        DAQmx_Read_DigitalLines_BytesPerChan property.\n\n\tNote: If you configured timing for your task, your write is\n\tconsidered a buffered write. Buffered writes require a minimum\n\tbuffer size of 2 samples. If you do not configure the buffer\n\tsize using DAQmxCfgOutputBuffer, NI-DAQmx automatically\n\tconfigures the buffer when you configure sample timing. If you\n\tattempt to write one sample for a buffered write without\n\tconfiguring the buffer, you will receive an error.\n\n        Parameters\n        ----------\n\n        data : array\n\n          The samples to write to the task.\n\n        auto_start : bool\n\n          Specifies whether or not this function automatically starts\n          the task if you do not start it.\n\n        timeout : float\n\n          The amount of time, in seconds, to wait for this function to\n          write all the samples. The default value is 10.0 seconds. To\n          specify an infinite wait, pass -1\n          (DAQmx_Val_WaitInfinitely). This function returns an error\n          if the timeout elapses.\n\n          A value of 0 indicates to try once to write the submitted\n          samples. If this function successfully writes all submitted\n          samples, it does not return an error. Otherwise, the\n          function returns a timeout error and returns the number of\n          samples actually written.\n\n        layout : {'group_by_channel', 'group_by_scan_number'}\n\n          Specifies how the samples are arranged, either interleaved\n          or noninterleaved:\n\n            'group_by_channel' - Group by channel (non-interleaved).\n\n            'group_by_scan_number' - Group by scan number (interleaved).\n        " #NEWLINE# number_of_channels = self . get_number_of_channels ( ) #NEWLINE# if np . isscalar ( data ) : #NEWLINE# #INDENT# data = np . array ( ( [ data ] * number_of_channels ) , dtype = np . uint8 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# data = np . asarray ( data , dtype = np . uint8 ) #NEWLINE# #UNINDENT# if ( data . ndims == 1 ) : #NEWLINE# #INDENT# if ( number_of_channels == 1 ) : #NEWLINE# #INDENT# samples_per_channel = data . shape [ 0 ] #NEWLINE# shape = ( samples_per_channel , 1 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# samples_per_channel = ( data . size / number_of_channels ) #NEWLINE# shape = ( shape , number_of_channels ) #NEWLINE# #UNINDENT# if ( not ( group_by == Constants . Val_GroupByScanNumber ) ) : #NEWLINE# #INDENT# shape = tuple ( reversed ( shape ) ) #NEWLINE# #UNINDENT# data . reshape ( shape ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( group_by == Constants . Val_GroupByScanNumber ) : #NEWLINE# #INDENT# samples_per_channel = data . shape [ 0 ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# samples_per_channel = data . shape [ ( - 1 ) ] #NEWLINE# #UNINDENT# #UNINDENT# ( err , count ) = self . lib . WriteDigitalLines ( samples_per_channel , bool32 ( auto_start ) , float64 ( timeout ) , group_by , data . ctypes . data , RetValue ( 'u32' ) , None ) #NEWLINE# return count