NI官方labview培训教材Lesson 5-8.ppt
1,Lesson5Clusters,TOPICSIntroductiontoClustersClusterFunctionsErrorClusters,2,Clusters,DatastructurethatgroupsdatatogetherDatamaybeofdifferenttypesAnalogoustostructinCorarecordinPascalElementsmustbeeitherallcontrolsorallindicatorsThoughtofaswiresbundledintoacable,3,1.SelectaClustershellfromtheArrayeachnumberrepresentsacolorUsetheseoptionstosetanddisplaycolormappingschemeCursoralsoaddsathirddimension,26,,Thewavechartisaspecialnumericindicatorthatdisplaysoneormoreplots.ThewavecharthasthefollowingthreeupdatemodesAstripchartshowsrunningdatacontinuouslyscrollingfromlefttorightacrossthechart.Ascopechartshowsoneitemofdata,suchasapulseorwave,scrollingpartwayacrossthechartfromlefttotheright.Asweepworkssimilarlytoascopeexceptitshowstheolddataontherightandthenewdataontheleftseparatedbyaverticalline.WavegraphsandXYgraphsdisplaydatafromarrays.Right-clickawavechartorgraphoritscomponentstosetattributesofthechartanditsplots.,Summary,27,,YoucandisplaymorethanoneplotonagraphusingtheBuildArrayfunctionandtheBundlefunctionforchartsandXYgraphs.Thegraphbecomesamultiplotgraphwhenyouwirethearrayofoutputstotheterminal.Whenyouwiredatatochartsandgraphs,usetheContextHelpwindowtodeterminehowtowirethem.Youcanuseintensitychartsandgraphstoplotthree-dimensionaldata.Thethirddimensionisrepresentedbydifferentcolorscorrespondingtoacolormappingthatyoudefine.Intensitychartsandgraphsarecommonlyusedinconjunctionwithspectrumanalysis,temperaturedisplay,andimageprocessing.,Summary,cont.,28,Lesson7MakingDecisionsinaVI,TOPICSDecisionmakingwiththeSelectfunctionCaseStructuresulaNodes,29,SimpleDecisionSelectFunction,IfTempScaleisTRUE,passtop;iftempscaleisFALSE,passbottom.IfthedecisiontobemadeismorecomplexthanaSelectfunctioncancute,aCaseStructuremaybewhatisrequired.,30,,BooleanCaseStructureExampleIfTempScaleisTRUE,cuteTruecase;iftempscaleisFALSE,cuteFalsecase.,CaseStructures,31,,IntheStructuressubpaletteofFunctionspaletteEnclosenodesordragtheminsidethestructureStackedlikeadeckofcards,onlyonecasevisibleatatime,CaseStructures,32,BooleanandNumericCases,Wireallpossibleoutputsofthecasestructure,,33,String,Enum,andErrorCases,StringCaseEnumCaseErrorCase,34,IntheStructuressubpaletteImplementcomplicatedequationsVariablescreatedatborderVariablenamesarecasesensitiveEachstatementmustterminatewithasemicolon;ContextHelpWindowshowsavailablefunctions,Notesemicolon,ulaNode,,35,,DecisionMakingwithulaNodes,Twodifferentwaysofusinganif-thenstatementinaulaNodeBothstructuresproducethesameresult,36,,TheSelectfunctionisusedtochoosebetweentwosdependantonaboolean.ACasestructurehastwoormorecases.Onlyonecaseisvisibleatatime,andthestructurecutesonlyonecaseatatime.IfthecaseselectorterminalisBoolean,thestructurehasaTRUEcaseandaFALSEcase.Iftheselectorterminalisaninteger,string,orenumeratedtypue,thestructurecanhaveupto231–1cases.sareavailabletoallcases,butcasesdonotneedtouseeach.Ifatleastoneoutputtunnelisnotdefined,alloutputtunnelsonthestructureappearaswhitesquares.ulaNodesareusefulforcomplicatedequationsandforusingexistingtext-basedcode.Asemicolon;mustterminateeachstatement.,Summary,37,Lesson8StringsandFileI/O,TOPICSHowtocreatestringcontrolsandindicatorsHowtouseseveralStringfunctionsAboutfileI/OoperationsHowtousethehigh-levelFileI/OVIsHowtousethelow-levelFileI/OVIsHowtoattextfilesforuseinspreadsheets,38,,Astringisasequenceofdisplayableor-charactersASCIIManyusesdisplayingmessages,instrumentcontrol,fileI/OStringcontrol/indicatorisintheControlsStringsubpalette,Strings,39,StringDisplayModes,NormaldisplayPassworddisplay,\codedisplayHexdisplay,40,,ConcatenateStrings,,,,spaceshere,StringLength,StringFunctions,41,StringFunctions,StringSubset,MatchPattern,42,,ConvertingNumericstoStringsBuildString,43,,ConvertingStringstoNumericsScanFromString,44,EditatString,ScanFromStringFunction,45,FileandOutput,FourHierarchyLevelsHigh-levelFileVIsIntermediateFileVIsandFunctionsAdvancedFileFunctionssubpaletteExpressVIs,,,,,46,,WritetoSpreadsheetFileReadfromSpreadsheetFileWriteCharacterstoFileReadCharactersfromFileReadLinesfromFile,High-levelFileI/OVIs,47,FileI/OProgrammingModel-Intermediate,,Open/Create/ReplaceFile,Readand/orWritetoFile,CloseFile,CheckforErrors,48,WritetoFileExample,Open/Create/ReplaceopenstheexistingfileTEST1.DATandgeneratesrefnumanderrorclusterWriteFilewritesthedataCloseFileclosesthefileSimpleErrorHandlerchecksforerrors,49,ReadingDatafromaFile,Open/Create/ReplaceopensthefileReadFilereadsthespecifiednumberofbytesfromthefileCloseFileclosesthefileSimpleErrorHandlerchecksforerrors,50,attingaSpreadsheetString,SpreadsheetsarepopulartoolsfordatahandlingandanalysisTherearemanyatsforspreadsheetdata.Oneofthemostpopularistab-delimitedColumnsareseparatedbyatabcharacterRowsareseparatedbyanend-of-linecharacter,Tab,EndofLine,Aspreadsheetyields,,,,51,CreatingaSpreadsheetFile,CanreplaceatIntoStringandWriteFilewithatIntoFileinaboveexample,52,WriteLabVIEWMeasurementFile,Includestheopen,write,closeanderrorhandlingfunctionsHandlesattingthestringwitheitherataborcommadelimiterMergeSignalsfunctionisusedtocombinedataintothedynamicdatatype,53,,StringsgroupsequencesofASCIIcharacters.UsethestringcontrolandindicatorlocatedontheControlsStringPathpalettetosimulatetextentryboxesandlabels.UsetheStringfunctionslocatedontheFunctionsStringpalettetoeditandmanipulatestringsontheblockdiagram.UsetheatIntoStringfunctionandtheBuildStringExpressVItoconvertanumerictoastring.UsetheScanFromStringfunctiontoconvertastringtoanumeric.Right-clicktheatIntoStringorScanFromStringfunctionandselectEditatStringorEditScanStringfromtheshortcutmenutocreateoreditaatstring.,Summary,54,,UsetheFileI/OVIsandfunctionslocatedontheFunctionsFileI/OpalettetohandleallaspectsoffileI/O.Whenwritingtoafile,youopen,create,orreplaceafile,writethedata,andclosethefile.Similarly,whenyoureadfromafile,youopenanexistingfile,readthedata,andclosethefile.Toaccessafilethroughadialogbox,donotwirefilepathintheOpen/Create/ReplaceFileVI.Towritedatatoaspreadsheetfile,youmustatthestringasaspreadsheetstring,whichisastringthatincludesdelimiters,suchastabs.UsetheatIntoFilefunctiontoatstring,numeric,path,andBooleandataastextandwritethetexttoafile,Summary,cont.,