《Writing Data.docx》由会员分享,可在线阅读,更多相关《Writing Data.docx(4页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。
1、WritingDataTheTDMSfileformatwasdesignedtostreamdataasquicklyaspossiblewhilestillbeingflexibleenoughtoaccommodatechangesinthenumberofchannelsandtheirsamplingratesduringtheacquisition.Datafilesthatstreamquickly,though,donotnecessarilyloadquickly.TheTDMSfileisanentirelybinaryfilethatconsistsofmultiples
2、ections,onelayeredontopoftheotherasyouwritetothefile.Thesesectionscontainbuffersofdatavaluesassignedtooneormorechannelsand/ormeta-datapropertiesattachedtooneormorelevels.ThefewersectionstheTDMSfilehas,ingeneral,thefasteritwillload.EachtimeaTDMSfileiswrittenorread,aTDMS_Indexfileiscreatedthatcontains
3、amapofthebinarysections.SubsequentreadsofthesameTDMSfileconsulttheTDMS_Indexfiletoreadallthepropertiesandtodeterminethecorrectbytepositionstoreadouteachstoredblockofeachchannel.Roughlyspeaking,iftheresultingTDMS_IndexfileissimilarinsizetoitsTDMSfile,thenthisTDMSfileis“fragmented,meaningithasmoresect
4、ionsthanitneedsandwillthereforeloadslowerthanitshould.Thereareseveralapproachesyoucanimplement,bothduringandaftertheacquisition,thatwillminimizethenumberofunnecessarysectionsandmaximizethereadingspeedoftheresultingTDMSfile.WritingTDMSFileswithMinimalFragmentationFirstoff,ifyouareacquiringdatawithNIs
5、dataacquisitionhardware,considerusingtheNI-DAQmxTDMSwritingcapability,sinceitautomaticallywritesun-fragmentedTDMSfiles.IfyouareusingNILabVIEWtoacquireyourdatachannels,youcanchoosetheVIsfromtheTDMSAdvancedpalettetowriteaminimallyfragmentedTDMSfile.IfyouareusingthestandardTDMSwritingfunctions,thefollo
6、wingtipswillhelpminimizetheTDMSfilefragmentation.WritealltheTDMSpropertieseitherbeforeorafterthedataacquisition(loop).Writepropertyvaluesfromsame-datatypepropertiesusinga2DarrayandoneTDMSwritefunction.Writeatleast1000datapointsatatimetoeachdatachannelintheTDMSfile.Ifyouhavetowrite1datapointatatime,s
7、etthechannelpropertyNI_MinimumBufferSizeequalto1000.DefragmentingTDMSFilesAftertheAcquisitionEvenifyourdataacquisitionconstraintsforceyoutocreatefragmentedTDMSdatafiles,youcanstilladdresstheissueaftertheacquisition.IfyouareusingNILabVIEW,youcanexecutetheTDMSDefragmentfunctiontorewritetheTDMSfilewith
8、minimalfragmentation.Alternatively,ifyouloadtheTDMSdatafileintoNIDIAdemandsimplyresaveit,theresultingTDMSdatafilewillbeminimallyfragmented.WritingLoad-Speed-EnhancingChannelPropertiesIfyourtargetapplicationtoreadTDMSfilesisNIDIAdem,youcandramaticallyimproveloadingspeedintoNIDIAdembycreatingthefollow
9、ingfourpropertiesattachedtoeverynumericordatetimedatachannelintheTDMSfile.IfanyoneofthesefourpropertiesismissingornotpopulatedwithavalidvaluewhenagivenTDMSdatachannelisbeingloaded,thenNIDIAdemwillautomaticallycalculateallfourpropertiesforthatchannelinordertospeedupgraphaxisauto-scaling.Iftheseproper
10、tiesarealreadycreatedandfilledwithvalidvaluesandattachedtoeachdatachannelintheTDMSfile,thenthatTDMSfilewillloadmuchfasterintoNIDIAdem,becausethatcalculationforeachchannelwillbeavoidedduringtheTDMSfileloadingprocess.Notethatthepropertynamesarecasesensitiveandmustbeinlowercase.NoneofthesefourchannelpropertiesaresetbydefaultinNILabVIEWyouneedtoaddthosepropertiesyourselftoeverywaveformchannelyoucreateintheTDMSfile.Table3.PropertiestoImproveLoadingSpeedinNIDIAdem