常規的VI web發布很簡單,然而,當需要生成Exe可執行文件后進行Web該如何做呢?
1.创建一个labview 项目.
2.编写源代码并将其添加到项目中.
3.生成VI的Web页
(1)从VI的前面板上, 选择工具» Web 发布工具.
(2)按照你希望的方式配置查看模式 (点击帮助按钮以获得各选项的说明).点击下一步.
(3)创建一个文档题目并点击下一步.
(4)保存HTML文档至[LabVIEW]www 目录下. 点击保存至磁盘. 确认你已记下URL地址. 现在需要显示的Web页就已经生成并保存到你的硬盘上了.
4.在LabVIEW项目浏览器中, 右键单击我的电脑图片选择添加文件添加HTML文档到项目中. 找到你新生成的HTML文档并将其添加进来.
5.右键点击 程序生成规范» 新建» 应用程序来生成可执行文件. 选择源文件 部分将顶层VI添加至启动VI 并添加您的HTML文件至动态VI及支持文件. 点击生成按键生成您的可执行文件.
6.复制可执行文件及生成的其他所有文件到目标机器上(请确认在目标机器上已安装LabVIEW运行时引擎).
7.在你的目标机器上找到应用程序存储的目录. 打开.ini 文件.
(1)添加WebServer.Enabled=True这个键值 到其他WebServer键值之后.
(2)将web server root path从原来的[LabVIEW]www改为现在您的HTML网页所在的目录(它应该在您的应用程序所在的data 目录下).
(3)保存对.ini 文件所做的修改并关闭文件.
8.运行您的应用程序. 注意: 如果你在代码的开发机器上运行应用程序,请确认LabVIEW已经关闭.
9.打开其他机器的网页浏览器,输入你在步骤3d中获得的网址. 如果在网页中得到错误This page cannot bedisplayed, 请尝试将网址从http://TargetComputerName/VIname.html改为http://TargetComputerIPaddress/VIname.html. 另外若使用Windows XP请检查您的防火墙设置.
10.您现在应该可以访问到您的程序.
对于一个安装程序中使用远程前面板,思想是相同的. 创建一个Web页. 在项目中包含这个Web页. 生成应用程序并将Web页包含到支持文件中. 创建一个安装程序并在安装程序的源代码设置中将安装程序包含进来. 生成并发布安装程序.最后, 修改 .ini文件.
注意: 默认情况下, 在这个应用程序中对于远程前面板有一个应用许可. 如果你有LabVIEW 专业版, 你会有5个许可. 为了使用这些许可 (或者其他更多您购买
的许可), 你需要在安装文件中包含你的应用程序和在附加安装程序中包含 LabVIEW 8.x发布许可. 如果不添加这些附加许可信息, 您发布的应用程序只可以由一台机器进行远程连接.
注意: 如果容量许可管理器在同一台机器上使用,则一个LabVIEW Web服务器不能允许一个以上的许可(因为它们在使用相同的技术).
英文更詳細
How Can I Use Remote Front Panels With LabVIEW Executables?
Hardware: PXI/CompactPCI>>Controllers
- Troubleshooting:Create a LabVIEW project
- Add your source code to the project
- Build the web page for your VI:
- Select Tools»Web Publishing Tool...
- Select the VI to publish from the VI name drop down menu.
- Configure the Viewing Mode as either Embedded, Snapshot, or Monitor (click the Helpbutton for an explanation of each option) and click Next
- Edit the Document title, Header, and Footer and click Next
- Ensure that the HTML document is saved in your LabVIEWwww directory and clickSave to Disk.
- Note the Document URL for use in step 9 and
- Add the HTML document from step 3 to Project Explorer by right-clicking My Computer and selecting Add»File and then select the HTML file from your LabVIEWwww directory.
- Save your project and build your executable by right-clicking Build Specifications andselecting New»Application (EXE). Select the Source Files category. Then, place your top level VI under Startup VIs and your HTML file under Always Included. Click Build and then clickDone when the build is complete.
- Copy the executable and all of the generated files to your target computerNote: The target computer must have the LabVIEW Run-Time Engine installed and it must match the version of LabVIEW used to develop the executable.
- On the target computer, browse to the directory where you just copied your executable. Open the .ini file in a text editor and perform the following:
- Verify the token WebServer.Enabled=True exists. If you cannot find it, add it to the end of the file
LabVIEW 8.x prior to LabVIEW 8.6:
- Add or modify the WebServer.RootPath so that its value is set to the directory where the HTML page currently resides (it should be located in the application's datadirectory)
- Save the changes to the .ini file and close it
LabVIEW 8.6 and later:
- Close the .ini file and open niwebserver.conf in a text editor. This file was created to handle the new functionality provided by the LabVIEW web server in LabVIEW 8.6
- In the second section labeled Directives that apply to the default server there is aDocumentRoot tag. Replace the default LabVIEWwww with the location of your HTML file. Do not include the name of the HTML file in the path
- Launch your executable
Note: Running the executable on the development machine requires that LabVIEW be completely shutdown - Open a web browser on another computer and navigate to the URL you obtained in step 3. If you are not running the executable on your development machine, replace the name of the development computer in the URL with the name of the target computer. You can now view and control the LabVIEW executable remotely
Q. What steps can I take to resolve the This page cannot be displayed error?
A. Try changing the URL from http://TargetComputerName/VIname.html tohttp://TargetComputerIPAddress/VIname.html. Also, verify that your firewall allows access to the port that the LabVIEW web server is using (default is 80).
Q. Why do I receive an error statingRemote Panel Connection Refused by Specified Server?
A. Typically, this message results from a mismatch in LabVIEW versions. Ensure that the version of the LabVIEW Run-Time Engine on the target computer matches the version of LabVIEW used on the development machine.
Installers:
To enable remote front panels for an installer, the same ideas apply. Create a web page. Include the web page in your project. Build your executable and include your web page in the support files. Create an installer and include your executable in the installer under the source files setting of the installer. Build and deploy the installer. Lastly, change the .ini and niwebserver.conf files.
Licensing:
By default, LabVIEW includes one remote front panel license. This means that one connection at a time can be made to the remote front panel of your executable. If you have LabVIEW Professional Edition you are entitled to five licenses for remote panels. In order to have access to these additional licenses (or any others that you may have purchased), you need to build an installer that contains your executable along with the LabVIEW 8.x Deployable License under Additional Installers.
Note: A LabVIEW web server cannot permit more than one connection if Volume License Manager is in use on the same computer. This is due to the fact that remote front panel licenses share components with the Volume License Manager.
22