double OscilloscopeChannel::sampleValueAtOffset (uint offsetToLatest , void* rightTypeData ,t_TimeStamp *time, bool* noValid )
{
	if ( ( offsetToLatest & 0x80000000 ) || ( offsetToLatest >= samplesSize() ) )		// 如果索引太大就设置 noValid
	{
        if ( noValid ) { *noValid = true ; }
		if ( rightTypeData ) { memset ( rightTypeData, 0 , sizeOfEachSample() ) ; }
        if ( time ) { *time = 0 ; }
		return 0.0 ;
	}

	int offset = - (int)offsetToLatest ;
    int index = getSampleIndex(latestValidPos(),offset) ;
    if ( index < 0 )
    {
        if ( noValid ) { *noValid = true ; }
        if ( rightTypeData ) { memset ( rightTypeData, 0 , sizeOfEachSample() ) ; }
        if ( time ) { *time = 0 ; }
        return 0.0 ;
    }

    return sampleValue(index , rightTypeData, time , noValid ) ;
}
Example #2
0
bool VcfFile::hasSample(String name) {
   return getSampleIndex(name) != -1;
}