From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
08-18-2015 11:06 AM
Hey guys,
I'm developing a datalogging code that datalogs various signals depending on if they have been updated by another thread. I currently have seven different calls to TDMS_SetChannelInfo, but within my actual logging function, depending on if that particular group of signals is ready it may or may not be logged (it will be skipped). As I understand it, the calls to TDMS_AdvancedSyncWrite must be in order of the calls to TDMS_SetChannelInfo, and if one TDMS_AdvancedSyncWrite is skipped then it throws off the write position for the next call.
My question is, can I use TDMS_SetNextWritePosition to set the write position to the beginning of my channel handle container before each respective call to TDMS_AdvancedSyncWrite to ensure it always starts writing at the correct location? I've tried this and it doesn't seem to work, but I could be screwing it up. Below is a quick example of what I'm talking about:
//Set meta data
TDMS_SetChannelInfo(&channel_handle_vector_1, channel_handle_vector_1.size(),1,TDMS_DataLayoutNonInterleaved);
TDMS_SetChannelInfo(&channel_handle_vector_2, channel_handle_vector_2.size(),1,TDMS_DataLayoutNonInterleaved);
TDMS_SetChannelInfo(&channel_handle_vector_3, channel_handle_vector_3.size(),1,TDMS_DataLayoutNonInterleaved);
TDMS_SetChannelInfo(&channel_handle_vector_4, channel_handle_vector_4.size(),1,TDMS_DataLayoutNonInterleaved);
TDMS_SetChannelInfo(&channel_handle_vector_5, channel_handle_vector_5.size(),1,TDMS_DataLayoutNonInterleaved);
TDMS_SetChannelInfo(&channel_handle_vector_6, channel_handle_vector_6.size(),1,TDMS_DataLayoutNonInterleaved);
TDMS_SetChannelInfo(&channel_handle_vector_7, channel_handle_vector_7.size(),1,TDMS_DataLayoutNonInterleaved);
//log data. Any of these calls to TDMS_AdvancedSyncWrite may or may not be called everytime.
TDMS_SetNextWritePosition(channel_handle_vector_1.at(0),0, TDMS_OffsetRelativeToChannelEnd);
TDMS_AdvancedSyncWrite(fileHandle, &Values_1.front(), Values.size()_1, TDMS_Float);
TDMS_SetNextWritePosition(channel_handle_vector_2.at(0),0, TDMS_OffsetRelativeToChannelEnd);
TDMS_AdvancedSyncWrite(fileHandle, &Values_2.front(), Values.size()_1, TDMS_Float);
TDMS_SetNextWritePosition(channel_handle_vector_3.at(0),0, TDMS_OffsetRelativeToChannelEnd);
TDMS_AdvancedSyncWrite(fileHandle, &Values_3.front(), Values.size()_1, TDMS_Float);
TDMS_SetNextWritePosition(channel_handle_vector_4.at(0),0, TDMS_OffsetRelativeToChannelEnd);
TDMS_AdvancedSyncWrite(fileHandle, &Values_4.front(), Values.size()_1, TDMS_Float);
TDMS_SetNextWritePosition(channel_handle_vector_5.at(0),0, TDMS_OffsetRelativeToChannelEnd);
TDMS_AdvancedSyncWrite(fileHandle, &Values_5.front(), Values.size()_1, TDMS_Float);
TDMS_SetNextWritePosition(channel_handle_vector_6.at(0),0, TDMS_OffsetRelativeToChannelEnd);
TDMS_AdvancedSyncWrite(fileHandle, &Values_6.front(), Values.size()_1, TDMS_Float);
TDMS_SetNextWritePosition(channel_handle_vector_7.at(0),0, TDMS_OffsetRelativeToChannelEnd);
TDMS_AdvancedSyncWrite(fileHandle, &Values_7.front(), Values.size()_1, TDMS_Float);
One other quick question. Upon every iteration of my datalogger loop, the number of channels within one channel handle vector being written could be dynamic. Meaning that I don't want to write every channel within a channel handle vector every iteration of the logger. I was considering trying to re-write the channel handle vector depending on what signals are currently being received, but I don't think this will work because the order of channel handles being written must match the order of channel handles used in TDMS_SetChannelInfo. Is that correct? Any ideas? I would like to avoid a lot of calls to TDMS_AdvancedSyncWrite if possible. Maybe the other option is to just use TDMS_AppendMultiChannel?
Thanks,