labview web service
TRANSCRIPT
Høgskolen i Telemark
Telemark University College Department of Electrical Engineering, Information Technology and Cybernetics
Faculty of Technology, Postboks 203, Kjølnes ring 56, N-3901 Porsgrunn, Norway. Tel: +47 35 57 50 00 Fax: +47 35 57 54 01
LabVIEW Web Service Cuong Nguyen, 2013.06.19
2
Table of Contents
Introduction ............................................................................................................................................. 3
1 Technical Implementation .............................................................................................................. 4
1.1 Step 1: Create a LabVIEW VI .................................................................................................... 4
1.2 Step 2: Specify connector panes. ............................................................................................ 5
1.3 Step 3: Configure LabVIEW Web Server .................................................................................. 6
1.4 Step 4: Create a Web Service project ...................................................................................... 6
1.5 Step 5: Deploy a Web Service. ................................................................................................. 9
1.6 Step 6: Accessing a Web Service ........................................................................................... 10
2 Web Service Management ........................................................................................................... 13
3
1 Introduction
This tutorial will go through how to create a LabVIEW Web Service of Restful type. Once the Web
Service is created, broad casted data is available on the world wide level. Meaning real time data can
be monitored at any corner of the world (wireless), where internet availability is the only limitation.
The final result of this tutorial is to publish temperature data from “Temp_value.vi” to the internet,
from which other Web Service clients are able to access the data. How to create “Temp_value.vi” is
described in “Wi-Fi_tutorial_TUC” tutorial. This documentation is created based on experiment by
using the following equipment.
Software
LabVIEW 2012
Windows 7
The creation of a Web Service involves mainly four different steps.
Step 1: Create a LabVIEW VI (application) to Deploy as a Web Service INFO: We will modify the “Temp_value.vi “created earlier for our Web Service. If you do not have the “Temp_value.vi” yet, kindly go through step 5 in “Wifi_TUC”.
Step 2: Specify the parameters to be broad casted to the connector pane. Step 3: Configuring the LabVIEW Application Web Server. Step 4: Create a Web Service project containing “Temp_value.vi” and Build Specification. Step 5: Deploying a Web Service to the Web Server. Step 6: Accessing a Web Service.
How to manage and maintain a LabVIEW Web Service of RESTful type is described at the end of this
tutorial. The tutorial will be focused on viewing all the Web Services that is being published from
your computer, how to delete (undeploy) a Web Service.
4
2 Technical Implementation
This section will explain the process of creating a LabVIEW Web Service in details, which covers all
the involving six steps stated above. By following the instructions, as the result temperature data
shall be broad casted. This tutorial is a continuation of “Wi-Fi_tutorial_TUC”, the only dependency is
the usage of Temp_value.vi created from the “WiFI_TUC”.
2.1 Step 1: Create a LabVIEW VI
As mentioned above, since we already have created a LabVIEW VI from previous, all we have to do
now is to locate and open up the “Temp_value.vi” and do some small modification.
Start “Temp_value.vi”
Modify until as seen in the figure 2-1.
Hint: Temperature 32,7 is a “numeric indicator” and String °C is a “string indicator”. To get
the “°C” you can use Google then copy and paste.
Figure 2-1: Create LabVIEW application.
We want the text string “°C” to appears in the indicator every time we start our
“Temp_value.vi”
Click: on the “string indicator” (°C) →right click: Data Operations -> Make Current
Value Default.
We want the stop button to only active on released.
Click: on the “STOP” button →right click: Mechanical Action -> Latch When Released.
Reduce the number of decimal to one only.
Double click: Format Into String → Corresponding format string: %.1f
Set “Temp” and ”Unit” together into the same indicator
5 Technical Implementation
LabVIEW Web Service
Double click: Build Text → Text with Parameters in Percents: %Value% %Unit%
Parameter: set both Value and Unit as Text. As shown from the Figure 2-2.
Figure 2-2: "Build Text" function to unite Tem and Unit indicators.
2.2 Step 2: Specify Connector Panes
Web method Vis use front-panel parameters (controls and indicators) to exchanged data via Web
services, the requirement is that the controls and indicators have to be specified in the connector
panes. In this case we wish to set our indicator (Temperature) to the connector pane as output of the
“Temp_value.vi” application. Figure 2-3 illustrates the indicator and its corresponding connector
pane.
To assign a connector with an indicator (as output of a Web method VI)
Move your cursor (mouse) to the chosen pane → Click → move the cursor to the
Temperature indicator (27,8 °C) → double click.
INFO: if you wish to set a connector pane for input (normally controls) to your Web
method VI, just simply follow the same procedures as above, but use the connector
panes on the left hand side. In this case, there is no input.
6 Technical Implementation
LabVIEW Web Service
Figure 2-3: Define a connector pane to indicator.
2.3 Step 3: Configure LabVIEW Web Server
We need to do some necessary configuration on the LabVIEW Web Server, as default everything
should be already set correctly but we need to check.
Open any Web browser (for example firefox or explorer)
Enter the Url below to setup a Web Server on the local host system.
http://localhost:3580
INFO: To setup a Web Server on a remote target system, enter the following Url:
http://[remote device IP address].
Click on icon → Web Servers
Make sure your computer is similar to illustrated figure 2-4.
Figure 2-4: Configure LabVIEW Web Server.
2.4 Step 4: Create a Web Service project
We are now creating a LabVIEW project to organize, which contains the “Temp_value.vi” and build a
Web Service application.
7 Technical Implementation
LabVIEW Web Service
Add all Web method Vis (LabVIEW applications) in our case “Temp_value.vi” to the project
that you want to deploy as a Web Service.
Open up the “Tem_value.vi” that has been modified on the previous steps.
Click: File → New → Empty Project → OK
In figure 2-5 add “Temp_value.vi” to the project.
Figure 2-5: Add VI prompt when creating a LabVIEW project.
The pop up window as seen in figure 2-6 illustrates the new project (by the name Untitled
Project 1) is created with “Temp_value.vi” method included. You may change the project
name if you wish by: right click on “Project: Untitled Project 1” → Save as. I changed the
project name to Temp_Webservice.lvproj.
Figure 2-6: A new LabView project.
Now we build a Web Service from the project.
Right click: Build Specifications → New → Web Service (RESTful).
As illustrated in figure 2-7.
8 Technical Implementation
LabVIEW Web Service
Figure 2-7: Create a LabVIEW Web Service.
Complete the following steps as shown in figures 2-8 to create Web Service.
Build specification name: Temp Web Service.
INFO: Give any name as you want.
Service name: WebService.
INFO: Give any name as you want. The given name will be part of the Url when Web
Service clients want to exchange data.
Figure 2-8: Assigne Build specification name and Service name.
In Source Files
In Project Files: Click “Temp_value.vi” → click arrow to the right.
9 Technical Implementation
LabVIEW Web Service
Figure 2-9: Select source file to deploy a in the Web Service.
Click: OK on the pop up window as seen 2-10.
Figure 2-10: WS RESTful configuration.
When a window is pop up as in figure 2-11.
Click: Build
Figure 2-11: Build a Web Service.
2.5 Step 5: Deploy a Web Service.
Since you have already built the Web Service, now you deploy it.
10 Technical Implementation
LabVIEW Web Service
Right click: My Web Service → Deploy.
As shown in the figure 2-12.
Figure 2-12: Deploy a Web Service.
A new Web Service should be created and deployed. Use a web browser to validate a successful
deployment.
Open a web browser
In the address bar, enter: localhost:3580
Click: button
Your Web Service by the name “WebService” is successfully deployed as seen in figure
2-13.
Figure 2-13: WS management environment.
2.6 Step 6: Accessing a Web Service
Since we have successfully built and deployed our Web Service. Now we want to access the Web
Service and this can be done by either using a web browser, web client or other Web Service client
application, such as iOS (Iphone, Ipad ), Windows OS or Android application.
Alternative 1: Web browser
Accessing a Web Service through a web browser on the same computer.
Open a web browser
Type: http://localhost:8080/WebService/Temp_value
INFO: Case-sensitive is not important.
11 Technical Implementation
LabVIEW Web Service
Accessing a Web Service through a web browser from a remote computer.
Open a web browser
Type: http://IP-address:8080/webservice/temp_value
In this case your computers IP-address, which is 128.39.35.239 or to find your IP-address:
Start → Type: cmd → Type: ipconfig
INFO: Case-sensitive is not important.
To update the latest data obtained by the sensor
Push: F5
Figure 2-14: Published data read by a web browser.
The Structure of exchanging data with a deployed Web method VI.
Figure 2-15: Path structure to the broad casted WS.
Alternative 2: Create an app (Android) of your own
Based on the data published by the Web Service we can create different applications to present the
data in an appropriate manner to monitor the value on remote devices, which are called for Web
Service clients.
We will create a Web Service client (application) to monitor data captured by PT-100. The application
is created by Android “Native” code. A tutorial on how to create is documented in
“Android_WS_Client.pdf”. Before you are able do any programming on android, you need to setup
up the programming environment and download necessary libraries. A proper documentation on
how to setup Android programming environment is described in “Android_Startup.pdf”. The final
result of the created Android application is shown in figure 2-16.
12 Technical Implementation
LabVIEW Web Service
Figure 2-16: "Native" Android Web Service client.
13
3 Web Service Management
This section will explain how to manage Web Services on your computer. It is able to view which of
the Web Services are deploying (publishing) and for undesired deployed Web Services are able to be
deleted from the system, to save resources on your computer.
View and delete deployed Web Services.
Start: a web browser → Type: localhost:3580 → Push: icon
or from the LabVIEW project → right click: “Temp Web Service” → Manage Web Server.
A similar page as shown in figure 3-1 appears, from which all the deployed Web Services are
listed. In this case the Web server consists of two Web Servcices by the name WebService
and WebServicer).
To erase a Web Service just simply click on the unwanted and push the “Undeploy” button as
shown in figure 3-1.
Figure 3-1: Web Sevice managment environment.
Delete a created Web Service is shown in figure 3-2.
14 Web Service Management
LabVIEW Web Service
Figure 3-2: Delete a build Web Service.
Høgskolen i Telemark
Telemark University College Department of Electrical Engineering, Information Technology and Cybernetics
Faculty of Technology, Postboks 203, Kjølnes ring 56, N-3901 Porsgrunn, Norway. Tel: +47 35 57 50 00 Fax: +47 35 57 54 01
Telemark University College
Faculty of Technology
Kjølnes Ring 56
N-3918 Porsgrunn, Norway
www.hit.no