Jump to content


Photo
* * * * * 5 votes

LabVIEW, Websockets, and SVG


  • Please log in to reply
67 replies to this topic

#61 ShaunR

ShaunR

    LabVIEW Archetype

  • Members
  • PipPipPipPipPipPip
  • 2,721 posts
  • Version:LabVIEW 2009
  • Since:1994

Posted 07 October 2012 - 04:38 PM

Hi there!
So I tried this Websocket on a cRio.
The only thing that needs to be changed is the EOF,
I used the \r\n constant instead of CR\LF.

But theres one more problem that I am currently facing,
I cant access the svg file via web publish in the cRio. The svg file looks fine if I access to it via ftp.
But if I put it in the www folder and access via http, it comes out as text instead of graphics.
I tried a lot of method including creating a html file that calls the svg.
So far, none of them worked.

Currently using LabVIEW 2011 and Chrome ver 22.

He also has a website dedicated to this at http://blog.evexiall...=37#comment-54.
Might be worth asking the question there also.

A positive attitude may not solve all your problems, but it will annoy enough people to make it worth the effort. (Herm Albright 1876-1944).

Founder and general mischief maker on www.lvs-tools.co.uk.
SQlite aficionado and websocket zealot.
If it 'aint in LabVIEW, then you 'aint got a clue!


#62 madtofan

madtofan

    I've come back for more.

  • Members
  • 2 posts
  • Version:LabVIEW 2011
  • Since:2010

Posted 08 October 2012 - 09:40 AM

my bad.
I didnt notice the mime.types part

so i went into the cRio ni-rt/system/webserver/ folder and added "image/svg+xml svg svgz" into the mime.types file.
now it pops up fine.

thanks! :D

#63 sharkera

sharkera

    One hit wonder!

  • Members
  • 1 posts
  • Version:LabVIEW 2013
  • Since:2005

Posted 11 August 2014 - 08:04 AM

Hi smarlow,
 
I know this is a really old thread, but I am intrigued by the use of WebSockets and LabVIEW.  Lately I found a library that NI released:
https://decibel.ni.c.../docs/DOC-38927 and I found the code to be very similar to yours.  I was just curious if you knew about this ... basically this library combines WebSockets and NI's CVT so that CVT tags get pushed out and exposed through Websocket connections.  Still have write your own UI web code, tho.  There's another package that's fascinating lately: http://labsocket.com/.  This commercial software supposedly "scrapes" your front panel generates a thin-client webpage for you.  Haven't tried it but looks promising.  Cheers!


#64 smithd

smithd

    Active

  • NI
  • 23 posts
  • Version:LabVIEW 2013
  • Since:2011

Posted 11 August 2014 - 11:16 PM

 

Hi smarlow,
 
I know this is a really old thread, but I am intrigued by the use of WebSockets and LabVIEW.  Lately I found a library that NI released:
https://decibel.ni.c.../docs/DOC-38927 and I found the code to be very similar to yours.  I was just curious if you knew about this ... basically this library combines WebSockets and NI's CVT so that CVT tags get pushed out and exposed through Websocket connections.  Still have write your own UI web code, tho.  There's another package that's fascinating lately: http://labsocket.com/.  This commercial software supposedly "scrapes" your front panel generates a thin-client webpage for you.  Haven't tried it but looks promising.  Cheers!

 

 

Hey sharkera,

 

That toolset actually consists of a few things.

 

The first package, tagwebclient, is a javascript+HTML web page along with some LabVIEW type definitions which are intended to allow you to create new web services which provide tag-oriented data to the web using a standard interface. At present it needs some work, but the basic concept is down. For example, there is a "tag browse" page which requests the available list of tags from a correctly-formatted web service.

 

The second package, cvt web addon, is a LabVIEW web service which uses the CVT and aims to meet the contract required for the tagwebclient. Originally, these packages were combined but we are interested in making a web service which supports the new tag bus library (which is basically CVT on a wire): https://decibel.ni.c.../docs/DOC-36995

 

Finally, the cvt web addon does have a sample websocket server. However, to the best of my knowledge it currently just supports sending strings back and forth. It is not used to transfer tag data -- standard labview web service functions are used for that.

 

Thanks,

Daniel



#65 Jordan Kuehn

Jordan Kuehn

    Extremely Active

  • Members
  • PipPipPipPip
  • 367 posts
  • Version:LabVIEW 2011
  • Since:2009

Posted 16 September 2014 - 07:55 PM

I'll bring this back to life one more time.  I'm trying to use the webpanel demo, but I'm getting errors in the browser that suggest that jQuery is not being included correctly in the SVG file.  I've attempted to modify the SVG file to include the libraries, but this generates other errors.  Google suggests that jQuery assumes that it exists in HTML rather than SVG which may be causing the problems.  Is this an issue that others are encountering?  Could this simply be that I have up to date browsers and javascript installed and support broke along the way or am I doing something stupid?  I can navigate to 127.0.0.1:81 in Chrome and it begins downloading data and the VI shows a connection, so I think things are ok on that end.

ReferenceError: $ is not defined webpanel.js:34

Edit//

By downloading jQuery 1.9.1 and changing line 1321 from

if ( !all || !a || !all.length ) {

to

if (!all || !a || !all.length || !a.style) {

as described here I was able to get WP_jQuery.svg to work.  This page suggests it is a jQuery bug that may not have affected older browsers.  Perhaps a new release with the modified jQuery source is in order.


Edited by Jordan Kuehn, 16 September 2014 - 08:23 PM.

The Colex Group
Lead Software Engineer
Certified LabVIEW Developer

#66 CraigC

CraigC

    Active

  • Members
  • Pip
  • 12 posts
  • Location:England
  • Version:LabVIEW 2012
  • Since:2000

Posted 06 November 2014 - 05:26 PM

Hi,

 

I had a quick go at thisin order to learn some javascript.  Below I have got the websocket server running from a pure script file, no jquery but also no SVG.  I managed to get the Front panel of a vi displaying into an HTML 5 canvas and get canvas mouse clicks propegated back to LabVIEW.  You can also resizethe vi and the canvas is adjusted accordingly which means you should be able to display a viof your choosing into the canvas.  I managed to send the FP over as a byte array and load this into the canvas as a dataURL.  I dontknow if this is any quicker than using JSON etc but it seems to work reasonable well.  I have posted this as hopefuly it will serve as a simple example of how to setup websockets.

 

Craig

 

First time adding attachment, hope it works :)

 

Re-uploaded with missing class

 

Attached Files


Edited by CraigC, 11 November 2014 - 12:46 PM.

Craig

LabVIEW 2013
 


#67 VDB

VDB

    More Active

  • Members
  • PipPip
  • 26 posts

Posted 11 November 2014 - 09:03 AM

Hi,

 

unfortunately, the class "websocket.lvclass" is missing.

 

VDB



#68 CraigC

CraigC

    Active

  • Members
  • Pip
  • 12 posts
  • Location:England
  • Version:LabVIEW 2012
  • Since:2000

Posted 11 November 2014 - 12:48 PM

Hi,

 

I have re-uploaded with the missing class.  It is the same class created by the original poster I have just used his example to get my head around what is happening with websockets.  Hope it helps though.

 

Craig


Edited by CraigC, 11 November 2014 - 12:48 PM.

Craig

LabVIEW 2013