LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Call WebVi with parameters

Hello everyone,

 

I'm using LabVIEW NXG 3.1 with the Web module.

To recap I have :
1) A standard Labview NXG executable wich runs with DAQmx to communicate with a USB6001 module.
--> This exe is seen as the "server" IHM.
2) A WebVi that I built and now stocked in the NI Web Server folder of my computer as a .html file.
--> When I run my Exe (1) I can write the following url in my explorer :
"http://192.168.1.2:80/WebApp_Relay_Tester_Web%20Server/Client.html"
and I can display the IHM of my code (2) and interact with it.
This IHM (2) interacts with the Exe (1) and they share data though the "System Link Message" processus.
--> This application is seen as the "client" IHM.
3) An Android application that just ask the user to insert an IP address and then open the url (see above).

 

So, I have (3) --> calling --> (2) --> communicating with --> (3)

 

My problem is :
The communication between (2) and (3) is possible only because I have written the IP address of (3)
directly in the code of (2).
This is not a good trick because if my computer network changes, its IP address will too and it won't
work anymore.

 

So, my question is :
Can a WebVi (built in html) retrieve the URL used to call it ?
If it doesn't, can a WebVi be called with an input parameter ?
--> In NXG I can connect terminals to the WebVI but since it's the Top Level VI I don't know how I can pass the parameter...

Since the system is quite complicated to configure I didn't attach the code, but if you need more infos let me know.
I hope I made myself clear, thank you all for your support and see you soon (I hope) !

0 Kudos
Message 1 of 8
(4,509 Views)

I store the information in an ini file and read that when the webVI initially opens to configure various parameters. If you use an ini format you will need to do your own parsing as there are no configuration file utilities in the webVI palettes. You might be able to do more efficient parsing if you use JSON ad the file format.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 2 of 8
(4,500 Views)

Hi,

Thank you for your repond.

Indeed, I should be able to use files (binary or text) to transfer data but as you said, there is no such things in WebVis.

I can't parse data if I have no mean to get those data, right ?

The last option  I though about to avoid this problem, is to copy the input string (IP address) the user just wrote on the android application and then paste it on a control of my WebVi.

But I'm not even sure I can do that with android and this method is not very elegant...

That's why I prefer explore all the possibilities of NXG Web Service module before doing something weird.

 

0 Kudos
Message 3 of 8
(4,492 Views)

You use the HTTP VI to read the file. You pass the file name in as a URL. It will return the file contents as a string. From there use the string VIs to parse the data. You simply distribute your config file in the support folder as you would a graphic you wanted to display on the front panel/UI.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 4 of 8
(4,468 Views)

Hi TenJigoku77,

 

There is an alternative if the WebVI is hosted on the same NI Web Server that has the Messages API you are using. In the scenario described which I'll summarize as the following:

1) A WebVI is created in LabVIEW NXG 3.1 that uses the SystemLink Messages API

2) The built WebVI is Hosted on the NI Web Server in the htdocs directory, for example in a folder named mymessages

3) You visit the WebVI hosted on the NI Web Server (my server is on port 9090 and the webvi is in the folder mentioned above): http://localhost:9090/mymessages/

 

Then in the scenario where the WebVI is hosted on the NI Web Server that has the NI Message Service you are communicating with, you do not need to provide a server url, username, or password to the Open Configuration VI. When server url is blank it uses the server that the WebVI is hosted on and when user name and password are blank it uses the current user logged into the NI Web Server.

 

When you are testing the WebVI in the LabVIEW NXG Editor you need to provide the server url, username, and password to the Open Configuration VI as well as enable CORS to allow communication with the NI Web Server. When the WebVI is deployed to the NI Web Server you can leave off the server url (to use the server that the WebVI is hosted on), leave off username and password (to use the current logged in user), and disable CORS to increase security.

 

You can configure the users allowed to use the NI Message Service in the NI Web Server Configuration dialog.

 

The following demonstrates the workflow:messagesconfig.gif

 


Milan
Message 5 of 8
(4,450 Views)

Hello,

Thanks for the tips, it was well explained ! I tried and I could display the WebVi on the explorer without using the specific IP address.

Unfortunately, the EXE communicating with this WebVi couldn't open a SystemLink configuration with empty IP/Password/user and, obviously, even after sending an order from the WebVI the EXE didn't respond.

The second problem is my android app. Even if I am on the same network than my computer hosting the WebVi I can't find the IP address of the running server URI (I just insert in my phone explorer the same url that I used on my computer).

It might comes from my NI Web Server Configuration but since it works on my computer I'm quite confused. 

Anyway, since you propose this alternative I guess it means it's impossible to pass an input parameter to a WebVi or to retrieve, in the WebVi, the url used to access it...

I will continue searching following your idea and I'll keep you posted if I find anything !

If you have any additionnal infos do not hesitate to post it ^^

Thank you

0 Kudos
Message 6 of 8
(4,380 Views)

Hello people,

Unfortunately I didn't solve my probleme using classic NI tools.

So, I chose to call JavaScript in my Java code (on my android) to modify the HTML code of the WebVi application page after I load it into my browser.

I succeeded to modify the HTML controls value (here just a Number control) and I tought it was the end of all my problems.........BUT I found out that the value I injected with my JavaScript wasn't taken in account...

So I would like to understand more about the architecture of the Web module of NXG. There is obviously the HTML file displaying the controls but there are more like this text file just near the html (attached file), and all the others files...

So, does someone know if documentations, tutos or anything exist about all this.

Thanks you again for your help and see you !

0 Kudos
Message 7 of 8
(4,341 Views)
pass an input parameter to a WebVi or to retrieve, in the WebVi, the url used to access it

For future readers the post titled LabVIEW NXG WebVI's accessing the query string in its URL includes an example written with the JavaScript Library Interface (JSLI) to read and parse the URL of a page and navigate to a new URL from a WebVI.

 


Milan
0 Kudos
Message 8 of 8
(4,023 Views)