Developing Applications with the LabVIEW Statechar

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

DevelopingApplicationswiththeLabVIEWStatechartModule5ratings|4.40outof5ReadinEnglish|PrintOverviewThisdocumentexplainsthedefinitionofstatechartdiagramsanddemonstratesthebasicsoftheLabVIEWStatechartModule.TableofContents1.Introduction2.UsingLabVIEWStatecharts3.BenefitsofStatecharts4.Conclusion5.RelatedLinksIntroductionThismoduleaddstheabilitytocreatestatechartsinLabVIEWfordevelopingevent-basedcontrolandtestsystems.ThestatechartprogrammingmodelcomplementstheexistingLabVIEWmodelsfordataflow,textualmath,dynamicsystemmodeling,andconfiguration-baseddevelopment.Youcanchoosetherightmodelorcombinationofmodelstodevelopyoursystembasedonyourapplicationrequirements.[+]EnlargeImageTheNationalInstrumentsgraphicalsystemdesignplatformcombinestheprogrammingmodelsinLabVIEWwithoff-the-shelfdesktopandembeddedcontrollersandmeasurementI/O.Withthiscombination,youhaveanintegrateddevelopmenttoolchainfordesigning,prototyping,anddeployingsystems.LabVIEWstatechartsofferahigh-leveldesigntoolwithpowerfulscalabilitythroughprogrammingconceptssuchashierarchy,concurrency,andevents.Becausestatechartsprovideasystem-levelview,youcanuseLabVIEWstatechartsasexecutablespecifications.Thestatechartprogrammingmodelisespeciallyusefulfordevelopingcomplexsystemsthatmustrespondtoavarietyofeventssuchasembeddedcontrolsystemsandcommunicationssystems.WiththeLabVIEWStatechartModule,youcandeploydesignstoavarietyofhardwareplatformsrangingfromdesktopPCstoFPGAs.Note:ForcompleteLabVIEWStatechartModuledocumentation,refertotheshippingdocumentation.HistoryofStatechartsThestatechartdiagramwasinventedbyDavidHareloftheWeizmannInstituteofScienceinthe1980s.AccordingtoHarel,thepurposeofthestatechartdiagramwasto“extendconventionalstate-transitiondiagramswith…thenotionsofhierarchy,concurrency,andcommunication.”Harelinventedthediagramwhilehehelpeddesignacomplexavionicssystem,presumablyfindingtheexistingtoolsforsuchasystemlacking.Inthe1990s,statechartswereadoptedasabehaviordiagramwithintheUnifiedModelingLanguage(UML)specification,whichiswidelyusedformodelingembeddedsystems.HowStatechartsWorkTobeginunderstandingstatecharts,itisbesttostartwiththeclassicstatediagramandthenaddthenotionsofhierarchy,concurrency,andevents.Theclassicstatediagramconsistsoftwomainconstructs:statesandtransitions.InFigure2,thestatediagramdescribesasimplesodavendingmachinewithfivestatesandseventransitionstoillustratehowthemachineoperates.Themachinestartsinthe“idle”stateandtransitionstothe“countcoins”statewhencoinsareinserted.Thestatediagramshowsadditionalstatesandtransitionswhenthemachinewaitsforaselection,dispensesasoda,andgiveschange.Figure3showsastatechartthatdescribesthebehaviorofthesamemachine.Noticehowthenotionofhierarchyandeventsreducesthenumberofstatesandtransitions.Inthestatechart,youcannestthe“countcoins”and“dispense”stateswithinasuperstate.Youhavetodefineonlyonetransition(T3)fromeitherofthesetwostatestothe“givechange”state.YoucanconfiguretheT3transitiontorespondtothreeevents:sodadispensed,changerequested,orcoinsrejected.Additionally,youcaneliminatethe“selectsoda”stateintheclassicstatediagrambyintroducinga“guard”conditiontotransitionT2.Guardconditionsmustevaluateto“true”forthetransitiontooccur.Iftheresultoftheguardconditionis“false”theeventisignoredandthetransitiondoesnottakeplace.[+]EnlargeImageAtthispoint,youcanexpandthestatecharttodemonstratethenotionofconcurrencybyaddingatemperaturecontrolelementtothesoftwarewithinthevendingmachine.Figure4showshowyoucanencapsulatethedispensinglogicandthetemperaturecontrolintoanand-state.And-statesdescribeasystemthatissimultaneouslyintwostatesthatareindependentofeachother.TheT7transitionshowshowstatechartscandefineanexitthatappliestobothsub-statecharts.[+]EnlargeImageInadditiontohierarchyandconcurrency,statechartshaveotherfeaturesthatmakethemvaluableforcomplexsystems.Statechartshaveaconceptofhistory,allowingasuperstateto“remember”whichsubstatewithinitwaspreviouslyactive.Forexample,considerasuperstatethatdescribesamachinethatpoursasubstanceandthenheatsit.Ahalteventmaypausetheexecutionofthemachinewhileitispouring.Whenaresumeeventoccurs,themachinerememberstoresumepouring.UsingLabVIEWStatechartsWiththeLabVIEWStatechartModule,youcandesignsoftwarecomponentswithastatechartdiagramanddefinethebehaviorofthestatesandtransitionlogicwithdataflowgraphicalprogramming.UsetheLabVIEWProjectExplorertofullyintegratestatechartsintotheLabVIEWenvironment.EachLabVIEWstatecharthasseveralcomponentsthatyoucanusetoconfigurethecontextofthedesign.Figure5showsanexamplestatechartcalledLVStatechart1.lvsc.Youcancreatetriggersthatcorrespondtotransitionsandstatereactionsaswellaseditthelistofinputandoutputdatavariablesthatthestatechartuses.TheDiagram.vifilecontainstheactualstatechartdiagram.Withinthisdiagram,youcreatethestatesofthesystemandthetransitionsbetweenthem.Oneofthemainbenefitsofstatechartsishowtheyvisuallyrepresentthebehaviorofthesystemand,therefore,self-documentthesoftware.Figure6showsastatechartthatdescribesapackagingmachine.Youcaneasilyseethedifferentstatesofamachineandthetransitionsbe

1 / 9
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功