From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Updating image using ActiveX

Hello,

 

I'm a student intern and have been tasked with updating an image 4 times per second.

The boss asked me to look into doing it via an ActiveX control, as suggested here (last of the five options): 

http://digital.ni.com/public.nsf/allkb/2E60AF970E49531586256A8C0051332C

 

Now, I'm (very) new to labview and ActiveX is a first for me as well (tho much easier for me to wrap myself around, as I'm on a familiar platform there (.NET)).

So my question is, has anyone done this before? Perhaps even have code they are willing to share?

 

Any tips and input are very welcome, and a C# example would be ideal.

 

Thanks for your time,

-Tobias

 

 

0 Kudos
Message 1 of 5
(2,590 Views)

Greetings,

 

You might have a  look at this Calling ActiveX Code from LabVIEW

Regards,
Eirikur Runarsson
0 Kudos
Message 2 of 5
(2,564 Views)

Hi Eirikur,

 

Thanks for the link. Hadn't seen that page yet, though I have found similar information elsewhere.

 

I was about to start putting together a little test, when it struck me that ActiveX is purely windows, while the Labview program will run on a linux machine.

 

I found this post, stating that that's impossible (that is, using ActiveX in Labview running on Linux). It's quite old, though, so I wonder if anyone can confirm whether it is still impossible?

 

If it is, suggestions on how else to tackle this problem of near-continuous image updates would be greatly appreciated.

0 Kudos
Message 3 of 5
(2,553 Views)

Hi Tobias,

 

You are correct in that ActiveX is only for Windows.

 

I think you have good suggestions in the link you initially posted.

Regards,
Eirikur Runarsson
0 Kudos
Message 4 of 5
(2,512 Views)

Hi Eirikur, thanks for getting back to me 🙂

 

We ended up trying with javascript, ajax. Being tested tomorrow at the factory.

 

The script is quite simple, with the final html displayed looking something like this:

 

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js"></script>
<title></title>
</head>
<body>
<div id="imgHolder"></div>
<p>default</p>


<script>
//Script checks for update on contents of 'last_modified.txt' 10 times per sec.
//If the path given in that file is different from last check, updates html.

var path = "";
var img = document.createElement('img');
img.height = 200;
img.width = 200;

//ajax options when requesting 'last_modified.txt'
var reqOptions = {
   type: 'GET',
   url: 'last_modified.txt',
   dataType: 'html',
   success: function (data, status) {
   //if data (contents of 'last_modified.txt')
   //is different from last time, update path variable and html
   if (path != data) {
      path = data;
      $('p').html(path); //update file name txt
      //update source of image
      img.src=path;
      //update image
      $('#imgHolder').html(img);
   }
}
};

 

//When document is ready...
$(document).ready(function () {
   //Request file every .1 second
   setInterval(function () {
   $.ajax(reqOptions);
   }, 100);
})
</script>

</body>
</html>

 

The idea is that labview writes to the file 'last_modifed.txt', inputting the filename of the last image it wrote to disk.

The JS then requests this file every 100 ms, and updates the html if the filename is different from last pass.

 

Comments and ideas very welcome!

 

0 Kudos
Message 5 of 5
(2,500 Views)