使用自定義模板和示例項(xiàng)目開(kāi)發(fā)LabVIEW項(xiàng)目
使用自定義模板和示例項(xiàng)目開(kāi)發(fā)LabVIEW項(xiàng)目
創(chuàng)建項(xiàng)目時(shí),LabVIEW會(huì)顯示創(chuàng)建項(xiàng)目對(duì)話(huà)框,以幫助開(kāi)發(fā)人員選擇可用作起點(diǎn)的模板或樣樣例項(xiàng)目。如果要將創(chuàng)建的項(xiàng)目用作自定義模板和示例項(xiàng)目,則須將每個(gè)項(xiàng)目的源文件和元數(shù)據(jù)添加到相應(yīng)的LabVIEW目錄中。然后,開(kāi)發(fā)人員可以使用自定義項(xiàng)目作為開(kāi)發(fā)項(xiàng)目的起點(diǎn)。
選擇LabVIEW目錄來(lái)存儲(chǔ)自定義內(nèi)容
LabVIEW在兩個(gè)位置搜索要在創(chuàng)建項(xiàng)目對(duì)話(huà)框中顯示的內(nèi)容。選擇最適合希望如何使用自定義內(nèi)容的位置:
<LabVIEW>\ProjectTemplates—如果具有版本管理的托管代碼實(shí)用程序(如VI軟件包管理器)安裝了自定義內(nèi)容,請(qǐng)使用此位置。
<LabVIEWData>\ProjectTemplates—如果沒(méi)有對(duì)<LabVIEW>目錄的寫(xiě)入權(quán)限,或者想要為多個(gè)LabVIEW版本單源自定義內(nèi)容,請(qǐng)使用此位置。
注意:LabVIEW對(duì)<LabVIEWData>\ProjectTemplates目錄中的所有模板和樣樣項(xiàng)目執(zhí)行版本檢查。如果項(xiàng)目的.lvproj文件保存在LabVIEW的更高版本中的LabVIEW中,則創(chuàng)建項(xiàng)目對(duì)話(huà)框中會(huì)省略該項(xiàng)目。
組織<LabVIEWData>目錄
首次將模板和示例項(xiàng)目添加到<LabVIEWData>目錄時(shí),必須創(chuàng)建子目錄以確保LabVIEW可以找到內(nèi)容。
完成以下步驟來(lái)組織<LabVIEWData>目錄:
1.???????在<LabVIEWData>下創(chuàng)建項(xiàng)目模板目錄。
2.???????匹配<LabVIEW>\ProjectTemplates目錄的文件層次結(jié)構(gòu),以便存在以下路徑:
<LabVIEWData>\ProjectTemplates\CategoryOverrides
<LabVIEW?Data>\ProjectTemplates\MetaData
<LabVIEW?Data>\ProjectTemplates\Source
儲(chǔ)源文件
源文件由每個(gè)自定義模板和示例項(xiàng)目的.lvproj文件、庫(kù)、VI和支持文件(如圖像和文檔)組成。
在“ProjectTemplates\Source”目錄中為要在“創(chuàng)建項(xiàng)目”對(duì)話(huà)框中顯示的每個(gè)項(xiàng)目創(chuàng)建一個(gè)子目錄,并將每個(gè)項(xiàng)目的源文件添加到其各自的子目錄中。確保沒(méi)有子目錄包含多個(gè)項(xiàng)目的源文件。
注意:
確保您的自定義模板和示例項(xiàng)目不包含任何自動(dòng)填充文件夾。
確保您的自定義模板和示例項(xiàng)目不包含任何受密碼保護(hù)的源VI。
確保源.lvproj中引用的所有文件都包含在其各自的子目錄中。當(dāng)開(kāi)發(fā)人員嘗試使用“創(chuàng)建項(xiàng)目”對(duì)話(huà)框創(chuàng)建模板或示例項(xiàng)目的實(shí)例時(shí),缺少項(xiàng)目文件可能會(huì)導(dǎo)致問(wèn)題。
創(chuàng)建和存儲(chǔ)元數(shù)據(jù)
元數(shù)據(jù)定義“創(chuàng)建項(xiàng)目”對(duì)話(huà)框中顯示的內(nèi)容。LabVIEW可識(shí)別XML格式的元數(shù)據(jù)。XML文件可以包含一個(gè)或多個(gè)項(xiàng)目的元數(shù)據(jù)。
完成以下步驟以創(chuàng)建和存儲(chǔ)自定義項(xiàng)目的元數(shù)據(jù):
1.???????創(chuàng)建一個(gè)XML文件并添加<元數(shù)據(jù)>標(biāo)記。此標(biāo)記包含所有元數(shù)據(jù)。
2.???????為要在“創(chuàng)建項(xiàng)目”對(duì)話(huà)框中顯示的每個(gè)項(xiàng)目添加<ProjectTemplate>標(biāo)記。此標(biāo)記包含每個(gè)項(xiàng)目的元數(shù)據(jù)。
3.???????使用以下標(biāo)記定義每個(gè)模板或示例項(xiàng)目。該表的“示例項(xiàng)目”列列出了使用每個(gè)XML標(biāo)記的項(xiàng)目。請(qǐng)參閱<LabVIEW>\ProjectTemplates\MetaData\NILV_Core_TemplateMetaData.xml中的文件,了解如何定義現(xiàn)有模板和示例項(xiàng)目的元數(shù)據(jù)。

原文內(nèi)容如下
UsingCustom?Templates?and?Sample?Projects?to?Develop?LabVIEW?Projects
Whenyou?create?a?project,?LabVIEW?displays?the?Create?Project?dialogbox?to?help?you?select?a?template?or?sample?project?you?can?use?as?a?startingpoint.?If?you?want?to?use?projects?you?create?as?custom?templates?and?sampleprojects,?you?must?add?source?files?and?meta?data?for?each?project?to?thecorresponding?LabVIEW?directories.?Then,?users?can?use?the?custom?projects?asstarting?points?to?develop?their?projects.?In?addition?to?this?document,?referto?the?\ProjectTemplates?directory?to?see?how?source?files,?meta?data,?andcategory?overrides?are?stored?for?existing?templates?and?sample?projects.?Usethese?files?as?examples?of?how?to?create?and?store?files?for?custom?templatesand?sample?projects.
Selecting?a?LabVIEW?Directory?to?StoreCustom?Content
LabVIEWsearches?for?content?to?display?in?the?Create?Project?dialogbox?in?two?locations.?Select?the?location?that?best?suits?how?you?want?to?usethe?custom?content:
§??<LabVIEW>\ProjectTemplates—Usethis?location?if?a?managed?code?utility?with?version?management,?such?the?VIPackage?Manager,?installs?the?custom?content.
§??<LabVIEWData>\ProjectTemplates—Use?this?location?if?you?donot?have?write?access?to?the?<LabVIEW>?directory,?or?if?you?want?to?single-source?the?customcontent?for?multiple?LabVIEW?versions.
Note:?LabVIEW?performs?a?version?check?on?all?templates?andsample?projects?in?the?<LabVIEWData>\ProjectTemplates?directory.?If?the?.lvproj?filefor?a?project?is?saved?in?a?later?version?of?LabVIEW?than?the?version?currentlyrunning,?the?project?is?omitted?from?the?Create?Project?dialogbox.
?Organizing?the?<LabVIEW?Data>Directory
Whenyou?add?templates?and?sample?projects?to?the?<LabVIEW?Data>?directory?for?the?first?time,?you?must?createsubdirectories?to?ensure?that?LabVIEW?can?find?the?content.
Completethe?following?steps?to?organize?the?<LabVIEWData>?directory:
1.?????Create?the?ProjectTemplates?directory?under?<LabVIEWData>.
2.?????Match?the?file?hierarchy?of?the?<LabVIEW>\ProjectTemplates?directory?such?that?the?following?paths?exist:
§??<LabVIEWData>\ProjectTemplates\CategoryOverrides
§??<LabVIEWData>\ProjectTemplates\MetaData
§??<LabVIEWData>\ProjectTemplates\Source
Storing?Source?Files
Sourcefiles?consist?of?the?.lvproj?file,?libraries,?VIs,?and?support?files,?such?as?imagesand?documentation,?for?each?custom?template?and?sample?project.
Create?a?subdirectory?in?the?ProjectTemplates\Source?directory?for?each?project?you?want?to?display?in?the?CreateProject?dialog?box?and?add?the?source?files?for?eachproject?to?their?respective?subdirectories.?Ensure?that?no?subdirectorycontains?source?files?for?multiple?projects.
Notes:
§??Ensure?that?your?custom?templates?and?sample?projects?do?notcontain?any?auto-populating?folders.
§??Ensure?that?your?custom?templates?and?sample?projects?do?notcontain?any?source?VIs?that?are?password-protected.
§??Make?sure?that?all?the?files?referenced?in?your?source?.lvproj?areincluded?in?their?respective?subdirectories.?Missing?project?files?can?causeproblems?when?developers?attempt?to?use?the?Create?Project?dialogbox?to?create?an?instance?of?your?template?or?sample?project.
Creating?and?Storing?Meta?Data
Metadata?defines?the?content?that?appears?in?the?Create?Project?dialogbox.?LabVIEW?recognizes?meta?data?in?XML?format.?An?XML?file?can?contain?metadata?for?one?or?more?projects.
Completethe?following?steps?to?create?and?store?meta?data?for?custom?projects:
1.?????Create?an?XML?file?and?add?the?<MetaData>?tag.?This?tag?encloses?all?meta?data.
2.?????Add?a?<ProjectTemplate>?tag?for?each?project?you?want?to?display?in?the?CreateProject?dialog?box.?This?tag?encloses?meta?data?for?eachproject.
3.?????Use?the?following?tags?to?define?each?template?or?sampleproject.?The?Example?Project?columnof?the?table?lists?projects?that?use?each?XML?tag.?Refer?to?the?file?located?at?<LabVIEW>\ProjectTemplates\MetaData\NILV_Core_TemplateMetaData.xml?to?see?how?the?meta?data?for?existing?templates?and?sampleprojects?is?defined.
?
XML?Tag
Description
Example?Project
Required?Tags
<Title>
Defines?the?title?of?the?project?as?it?appears?in??the?Create?Project?dialog?box.
All?projects
<Description>
Defines?the?description?of?the?project?as?it?appears??in?the?Create?Project?dialog?box.
All?projects
<Filters>
Determines?filters?for?the?project,?which?allow??users?to?filter?items?in?the?Create?Project?dialog??box?by?category.?Use?a?colon?to?separate?categories?and?a?semicolon?to??separate?multiple?filters.
All?projects
<LocationPath>
Specifies?the?path?to?the?directory?that?contains??source?files?for?the?project.?Use?a?forward?slash?(/)?as?the?path?separator.
??This?path?is?relative?to?the?ProjectTemplates\Source?directory.?All?other?paths?in?the??meta?data?for?the?project?are?relative?to?the?path?you?provide?in?the?<LocationPath>?tag.
All?projects
<ListboxImagePath>
Specifies?the?path?to?the?image?you?want?LabVIEW?to??display?beside?the?project?title?in?the?Create?Project?dialog??box.?Ensure?that?the?dimensions?of?the?image?are?32x32?pixels.
All?projects
<ProjectPath>
Specifies?the?path?to?the?.lvproj?file?for?the?project.?If?you?set?the?value?of??the?<CustomVIMode>?to?AfterPage1,?this?tag?is??optional.
Simple?State?Machine
Optional?Tags
<Keywords>
Determines?which?keywords?users?can?enter?in?the?Additional?Search?box?of?the?Create?Project?dialog?box?to?search?for?the?project.??Use?semicolons?to?separate?keywords.
All?projects
<DocumentationPath>
Specifies?the?path?to?the?HTML?file?you?create?to??provide?help?for?the?project.?If?you?use?this?tag,?the?project?displays?a?More?Information?link?after?the?description,?which??links?to?the?HTML?document.
Simple?State?Machine
<CustomVIMode>
Determines?when?to?run?a?custom?VI?during?the??project?creation?process.?Select?from?the?following?values:
§??None—No?custom?VI?runs.?If?you?omit?the?<CustomVIMode>?tag,?None?is?the?default?value.
§??AfterPage1—After?the?user?selects?a??project,?the?Create?Project?dialog??box?closes,?and?the?custom?VI?runs.
§??AfterPage2NoUI—After?the?second?page?of??the?Create?Project?dialog?box??creates?the?project,?the?custom?VI?runs?and?completes.?Then,?the?Create?Project?dialog?box?closes.
§??AfterPage2WithUI—After?the?Create?Project?dialog?box?creates?the?project,?the?Create?Project?dialog?box?closes,?and?the?custom?VI??runs.?The?custom?VI?is?responsible?for?showing?or?hiding?its?panel.
Simple?State?Machine,?Blank?VI,?Actor?Framework
<CustomVIPath>
Specifies?the?path?to?the?custom?VI?you?want?to?run??during?the?project?creation?process.?If?you?set?the?<CustomVIMode>?tag?to?None,?LabVIEW?ignores?the?<CustomVIPath>?tag.
Note:?For?the?Create?Project?dialog??to?call?the?custom?VI,?you?must?match?the?connector?pane?of?the?custom?VI?to??the?connector?pane?of?the?PostCopyScripting.vi?in?the?labview\ProjectTemplates\Source\Core\Actor??Framework\scripting\TwoTasksMetaDataObj?directory.
Actor?Framework
<SortPriority>
Determines?the?order?of?the?project?in?the?project??list?of?the?Create?Project?dialog??box.
??The?value?of?this?tag?is?an?index?number,?so?a?value?of?0?places?the?project??at?the?top?of?the?list.?If?multiple?items?have?the?same?priority?value,??LabVIEW?sorts?them?alphabetically.
All?projects
<MetaDataClass>
Specifies?the?path?to?a?class?that?defines?custom??behavior?for?the?user?interface?of?the?second?page?of?the?Create?Project?dialog?box.
Actor?Framework
<HidePrefix>
Determines?whether?to?hide?the?File?Prefix?control?on?the?second?page?of?the?Create?Project?dialog?box.?The?default?value?is??FALSE.
Feedback?Evaporative?Cooler
<HideIconOverlay>
Determines?whether?to?hide?the?icon?overlay?controls??on?the?second?page?of?the?Create?Project?dialog??box.?The?default?value?is?FALSE.
Feedback?Evaporative?Cooler
?
4.?????Store?the?XML?file?in?the?ProjectTemplates\MetaData?directory.
Overriding?the?Sorting?Order?forFilters
Theleft?pane?of?the?first?page?of?the?Create?Project?dialogbox?lists?all?the?filters?you?specify?in?the?meta?data?XML?file.?By?default,LabVIEW?lists?filters?you?create?in?alphabetical?order.
Completethe?following?steps?to?override?the?default?sorting?order?for?the?filter?list:
1.?????Create?an?XML?file?and?add?the?<CategoryOverrides>?tag.?This?tag?encloses?all?category?override?data.
2.?????Add?a?<Category>?tag?for?each?filter?for?which?you?want?to?specify?customsorting?behavior.?This?tag?encloses?the?name?and?sorting?priority?of?eachfilter.
3.?????For?each?filter,?create?a?<Name>?tag?and?set?the?value?to?the?name?of?the?filter?you?usedin?the?meta?data?XML?file.
4.?????For?each?filter,?create?a?<Priority>?tag?and?set?the?value?according?to?the?behavior?you?want.
The?value?of?this?tag?is?an?index?number,?so?a?value?of?0?places?the?filter?atthe?top?of?the?list.?Any?parent?filter?for?which?you?specify?a?value?less?than100?appears?above?the?default?parent?filters,?such?as?Templates?and?SampleProjects.?If?you?specify?a?value?for?any?child?filter,?the?filter?appears?abovethe?default?child?filters,?such?as?Desktop.
5.?????Store?the?XML?file?in?the?ProjectTemplates\CategoryOverrides?directory.
?
需要說(shuō)明的是,上述的例程和文檔,都是可以下載的,雙擊即可打開(kāi),其中壓縮文件是可以采用粘貼復(fù)制的方式,拷貝到硬盤(pán)上。這不是圖片,各位小伙伴看到后嘗試一下,這個(gè)問(wèn)題就不用加微信咨詢(xún)了。有關(guān)LabVIEW編程、LabVIEW開(kāi)發(fā)等相關(guān)項(xiàng)目,可聯(lián)系們。附件中的資料這里無(wú)法上傳,可去公司網(wǎng)站搜索下載。