Okay, I'm probably making a bad rep for myself among LV folks, but what can I say, I think this is pretty neat.
One of the great things about .NET is that it supports multiple languages under a single runtime (C++, C#, VB.NET, etc). In addition to these traditional languages, scripting (aka Dynamic or Weakly Typed) languages are also supported. For example, you can use Python or PHP.
So, getting back to the topic, I've been asked several times whether LabVIEW would provide a simple text interface to do some simple ActiveX or .NET programming. This often comes up when dealing with Microsoft Office, due to the amount of properties you end up setting. The same can also be said for the .NET WinForm controls that we host on the front panel - lots and lots of properties to set.
Of course, you can do this with LabVIEW using the property nodes, but I must confess that the ratio of pixels to instructions can get pretty high in some cases. However, using the scripting languages of .NET and LabVIEW can get you this...
Start by downloading this example program. Note that this example does require LabVIEW 8.0 (sorry, but I need support for .NET 2.0, and LV 7.1.1f2 only avoids the hangs when using .NET 2.0 - I can't say .NET 2.0 is fully supported). If you don't have LV 8, you can always download the evaluation to give this a try. Also please note that I've included the beta version of IronPython to make it easy to try out the demo - you'll probably want to check with the IronPython site for updated versions.
So, open up the project and notice that there are two VIs to look at. Let's first take a look at BasicProgramming.vi.
The front panel has a large text box containing some simple Python code - adding a series of numbers to a variable called myList. When you run the VI, you'll see the number of items added to the myList variable displayed in the count indicator. Feel free to play around with this, adding more numbers, throwing in a myList.Clear(), etc. You can even type in garbage and see the exception information in the error out.
If you look at the diagram, you'll see what I'm doing. The IronPython engine is created and initialized with the text from the front panel. BUT - look at the invoke node for SetVariable. This handy little method lets me put any .NET object I've created into the engine and give it a variable name. Thus the default script is working on an instance of an System.Collections.ArrayList, which I can then continue to use in LabVIEW after the script completes.
So you can image what this gives you now - you can pass in an instance to Microsoft Excel or a front panel .NET control and do some text programming on it, then continue to use the object in native LabVIEW code...pretty nifty eh?
Wait, you say, Microsoft Excel uses ActiveX...how does that work? Remember, you can easily create an interop assembly for an ActiveX/COM class as long as it contains a TypeLib. If you have Visual Studio, it's pretty easy. If not, just download the .NET SDK and use the tlbimp.exe to create one. However, Office (at least the later version) has already created these for you.
As an example of this, check out TextProgramming.vi. You may have noticed in the zip file a DLL named LabVIEW.Interop.DLL. This is an interop assembly I created for the LV 8 ActiveX Server interface. If you look at the code, you'll see that in this example I use this assembly to get a .NET reference to a VI, and then program the VI within the Python script.
So, pretty much, this example shows how, using Python, you can get a little text into your graphical world. If you do end up using this, please post a comment on what you're doing and include your Python script, if possible, for others to see.
Exactly what i need for shrinking size of my block diagram with .NET nodes. Thank you Brian!
PS: can you publish the source code of LabVIEW.Interop.dll assembly? It would be interesting to see how does it work.
Posted by: Adnan | March 22, 2006 at 03:12 AM
Actually the code is generated automatically by the tool I mentioned for ActiveX (tlbimp.exe) - so the source code is actually .NET assembly (aka IL). In addition, COM interop in .NET is done mostly by the runtime engine as you execute, so even the IL doesn't show much.
Posted by: Brian Tyler | March 22, 2006 at 10:31 AM
hi,
i have a question ask u for your help,that is how can i call labview in my java application? someone suggeste that i should use the JNI technology to do this,but i donn't know how to do it in details!could you give me some advices about this or give me some related resources to solve the problem,thanks very much!
Posted by: Liao Yunya | March 27, 2006 at 07:57 PM
Ah, the wonderful world of Java. Don't get me wrong, I actually like Java - spent several years writing code in it, but it has a serious flaw in that accessing anything other than Java from it is a major pain. I often found writing kernel drivers easier than working with JNI *laugh*
But, back to your point. JNI would definately be one way, especially if you compile your VIs into a shared library. If you're on Windows, you can also access LabVIEW's ActiveX server interface via JNI.
However, if you're going to go with the ActiveX server interface, then I'd recommend using Jacob (http://sourceforge.net/projects/jacob-project/) instead of JNI - it's much easier. I haven't used Jacob in several years, but it was a bit unstable when I used it. It seems to still have active development, so I'm sure it's gotten better.
So you'll need to look at what you need. The fastest way to call is via JNI to a LabVIEW built DLL. The easier way (but slower execution) is Jacob to the ActiveX server.
Posted by: Brian Tyler | March 28, 2006 at 10:47 AM
This is quite likely the coolest thing since swiss cheese, which is pretty cool. I'd be interested to make the UI a little nicer, perhaps turning the whole code-writing part into an XControl. Rather than using a string control we could use a .NET rich textbox editor and use things like the tabs (imagine that :) ). Then we could effect things like intellisense using Reflection properties for the various objects we input (like myList). I've done that before for a regular string control. I'm still not 100% sure on the details of how to get information about objects in edit-mode that are only instantiated during run-time, but it would be cool! Maybe I'm missing the point of this saving time and all, but oh well...
Posted by: Jarrod Slocum | May 05, 2006 at 11:40 AM
Yes, there're a lot of things we could do to enhance this up, but as always it's finding the time.
If anyone out there does add some features to this example, please email me - I'd love to post an update back to the blog.
Posted by: Brian Tyler | May 08, 2006 at 10:18 AM
Do you know if it is possible to use Python to write a DLL which could then be used within LabVIEW?
Posted by: bm | July 14, 2006 at 02:47 PM
Well, I'm not much of a python expert, so I'd recommend checking out some Python groups. However, Python is traditionally left in script form and interpreted. If you were to compile it, you'd typically just compile the script into the DLL as a string.
IronPython is a different story, being a .NET language, but there are limitations there as well. I'd recommend starting at
http://www.gotdotnet.com/Workspaces/Workspace.aspx?id=ad7acff7-ab1e-4bcb-99c0-57ac5a3a9742
Posted by: Brian Tyler | July 18, 2006 at 10:44 AM
To use .NET Framework in JNI you should not make COM module and bridge them with tools like Jacob, J-integra, etc. This is the most curious approach. Use REGULAR JNI for .NET. See
http://codeproject.com/dotnet/JavaDOTNETIntegrate.asp
and
http://www.simtel.net/product.php[id]95126[sekid]0[SiteID]simtel.net
Posted by: vitallis | August 02, 2006 at 04:25 AM
Wow - thanks for those links. I haven't looked at the JNI projects in some time so I've not seen these before. However, they definately deserve a look.
Posted by: Brian Tyler | August 02, 2006 at 09:31 AM
Thanks for the information - it's very useful.
I've been linking LabVIEW and Python for some time now using ActiveX which works quite well. There are some advantages to using this IronPython implementation but there is one thing I'd need to be able to do:
How can you use the VI 'Call' method to call a subVI from Python. This differs from 'Run' in that you need to pass the input information to the subVI. The complication here is the inputs for this method are pointers to arrays of variants and I don't know how to form these objects in Python.
Have you ever tried the 'Call' method from Python? If I could make this work, I may switch to using IronPython.
Posted by: Mark Lumsden | January 08, 2007 at 01:45 PM
I've not tried it myself, but here is what I would recommend - use the Tlbimp.exe from the .NET SDK to create a .NET interop assembly from the LabVIEW.tlb file (you'll find it in /resource directory).
Now the same calls take arrays of .NET objects. I'd assume that IronPython can handle that automatically since it can call the .NET framework.
Let me know if that works for you.
Posted by: Brian Tyler | January 08, 2007 at 02:20 PM
very interesting, but I don't agree with you
Idetrorce
Posted by: Idetrorce | December 15, 2007 at 05:43 AM
dzrwtanl tlvzuigh hekj xgzan qexmkjf sgfcbe qihyvbnkf
Posted by: acdrtvepn gfadq | November 20, 2008 at 07:14 AM
Hi,I am Avinash from India.We are developing a machine vision application for speed measurement on roads using the existing tools in NI Vision Assistant 8.6.We have been fairly successful in achieving our targets and we now wish to make an executable file out of the code.
We have an Intel Atom Development Board at our disposal and we wish to deploy it on the same and make an embedded device.
We made an installer app out of a sample code and upon testing it on a remote system( without LabView) it failed as we had suspected.
Kindly advice us on how we may proceed from here on.
Looking forward to your reply
Regards,,
Posted by: Avinash Siravuru | May 29, 2010 at 05:04 AM
Thanks! One of my favorite rapidshare SE ( http://www.filecatch.com/trends/nl/29-07-2010.html ), with its help it's possible to find almost everything.
Posted by: Carson | July 30, 2010 at 06:15 AM
Are you felt that it is right? I do not really think that, but can keep personal opinions!
Posted by: coach outlet | October 29, 2010 at 09:32 PM
The blog article very surprised to me! Your writing is good. In this I learned a lot! Thank you!
Posted by: new jordans | November 01, 2010 at 01:00 AM
maybe it could be easy or difficult..
Posted by: Supra skytop | November 04, 2010 at 02:11 AM
walmart holiday pharmacy http://valium.posterous.com/buy-diazepam-online#167 - where van i buy diazepam online investment for medicine by gujarat government
online pharmacy directory http://valium.posterous.com/buy-diazepam-online-uk#457 - buy diazepam online uk valium anitque medicine eye cup
meridian adult medicine http://valium.posterous.com/buy-diazepam-without-prescription#607 - link disney pharmacy discount fl
medicine hat pottery classes http://valium.posterous.com/buy-valium#956 - buy valium online vancouver target pharmacy batavia il
mercy plaza pharmacy ca http://valium.posterous.com/buy-valium-cheap#336 - buy valium online with mastercard cheap the annals of internal medicine
midland pharmacies west des moines http://valium.posterous.com/buy-valium-from-india#749 - buy diazepam from india valium migraine medicine makes my headache worse
travel medicine online degree http://valium.posterous.com/buy-valium-no-prescription#210 - link appetite suppressant in house pharmacy
uva behavioral medicine center http://valium.posterous.com/buy-valium-online#693 - buy valium online legally us pharmacy skin cream barbados
mexican pharmacy vicodin http://valium.posterous.com/buy-valium-online-cheap#273 - buy valium cheap online pharmacy pediatric diabetes pharmacy
medicines australia http://valium.posterous.com/buy-valium-online-without-prescription#673 - buy valium online without prescription boutique of leathers medicine hat
ralphs pharmacy la jolla franklin street pharmacy
hampden pharmacy medicines that raise hdl cholesterol
sports medicine lanaster county pharmacy in thousand oaks california
mayan medicines wellbutrin pharmacies
unr sports medicine prescriptions online pharmacy
homeopathic medicine for obesity aetna mail order pharmacy
ultrasound used in medicine hcg pharmacy
digital imaging and communication in medicine bitter at pharmacy
sobal family medicine medicines for swelling
15 inch medicine cabinet mouth ulcer medicine
Posted by: worldpillehd | November 11, 2010 at 04:47 PM
If we want light, we must conquer darkness!
Posted by: air yeezy | November 12, 2010 at 01:51 AM
health mart pharmacy http://www.myspace.com/zithromax-online/blog/543481829#107 - zithromax susp drug traditional chinese medicine for healing ligaments
lisinopril pharmacy http://www.myspace.com/zithromax-online/blog/543481835#265 - zithromax suspension product information hills broadway pharmacy nz
recessed medicine cabinet nickle http://www.myspace.com/zithromax-online/blog/543481841#907 - zithromax pneumonia treatment american college of advanced medicine
university of arkansas college of pharmacy http://www.myspace.com/zithromax-online/blog/543481850#936 - zithromax tri pack nomi mountain medicine
pharmacy careers in home health care http://www.myspace.com/zithromax-online/blog/543481857#096 - zithromax tripack dosing world tree natural medicine
oxycontin us pharmacies http://www.myspace.com/zithromax-online/blog/543481868#339 - link ambien online pharmacy buy ambien
u s medicine http://www.myspace.com/zithromax-online/blog/543481881#099 - zithromax cost usa pharmco pharmacy
medicine hat tattoo http://www.myspace.com/zithromax-online/blog/543481888#455 - zithromax tongue uses pharmacy tech study book
sports medicine minnesota http://www.myspace.com/zithromax-online/blog/543481898#757 - zithromax for uti royal society of medicine
pharmacy tech school tx http://www.myspace.com/zithromax-online/blog/543481909#856 - zithromax without a perscription galaxy theaters in medicine hat
add adhd medicine listed happy trails rv medicine hat
volunteers in medicine bluffton sc internal coastal medicine
phytopharmica natural medicines medicine nausea
sleep medicine audio christian women medicine dentistry
medicine biomarkers fluorous ho istic medicine fletcher n c
certified pharmacy technician medication errors kumpulan medicine kerana cinta
kohlermann pharmacy malvern pa buy online order viagra reliable drugstore
bone shaped worm medicine what does tid mean in medicine
rejuvenator medicine virginia doctors of veterinary medicine
cbo on preventive medicine pharmacy mexican
Posted by: vkindtirows | July 14, 2011 at 03:01 AM
elizabethan england medicine http://mox.grouply.com/message/47#546 - veterinary amoxicillin dosage salary of an internal medicine doctor
medicine problem 600 http://mox.grouply.com/message/48#949 - link seymour pharmacy
journal of family medicine http://mox.grouply.com/message/49#351 - link pk drugstore
indiana state board of pharmacy http://mox.grouply.com/message/50#159 - yogurt and amoxicillin is pharmacy school hard
veterinary medicine exotic reptiles http://www.thoughts.com/trimox/500-mg-amoxicillin#998 - 500 mg amoxicillin capsules prescription medicine acid reflux
medicine for weight lost i portugal http://www.thoughts.com/trimox/allergic-reactions-to-amoxicillin#103 - allergic reactions to amoxicillin in adults when thyroid medicine is not working
pegasus medicine cabinet 24 x 30 http://www.thoughts.com/trimox/amoxicillin-500mg-cap#407 - amoxicillin 500mg cap infections chapel hill internal medicine nc
animal pharmacies in arizona http://www.thoughts.com/trimox/amoxicillin-and-breast-feeding#891 - link zodiac pet medicines
dog safe medicine http://www.thoughts.com/trimox/amoxicillin-alternatives#229 - amoxicillin alternatives sexual medicine research
prescribed medicine versus natural supplements http://www.thoughts.com/trimox/amoxicillin-and-ear-infections#180 - amoxicillin and ear infections medicines for laringitis
name brand narcotic cought medicine urinate medicine help
medicaid pharmacy list florida person street pharmacy raleigh
safeway pharmacy careers mermaid medicine
academy of pharmacy phobic anesthesia medicine phobic
phentermine pharmacy prices free access online no prescription pharmacy
redeye medicine hokkaido university school of medicine
american pharm partners questions pharmacy school interview
eldercare pharmacy herbal medicine plant
infant cough medicine medicine what is tcu
plano pharmacy tech pharmacy services manual
Posted by: qkindfsrows | August 20, 2011 at 03:00 AM
pain medicine dog http://ymlp.com/z1eDkT#913 - choline acetyltransferase alzheimer\\\'s montana pharmacy license renewal
state board of pharmacy oregon http://ymlp.com/zzSAXe#387 - choline bitartrate benefits depression salaries on pharmacy tech
tri city medicine http://ymlp.com/zfiiBG#557 - what is choline inositol ocd american association sleep medicine
medieval medicines http://ymlp.com/zMZXms#795 - choline supplements pregnancy rats sam alexander pharmacy harrison ar
ask the pharmacy board http://ymlp.com/zqal9L#963 - choline inositol benefits side effects desai pharmacy
medicine and osteopathy http://ymlp.com/z3MQ53#270 - cipla modapro modalert 200mg pharmacy enzymes
cold medicines and teen abuse http://ymlp.com/zhG0L0#359 - link 13 inch medicine cabinets
continuing education arkanasas pharmacy http://ymlp.com/zuJKsO#166 - citicoline drug study citicholine medicine anti-inflamatory
rite aide pharmacies http://ymlp.com/zBub2Q#504 - citicholine sodium arroyo grande alternative medicine healthcare
medicine hat alternative schools http://ymlp.com/zJhz7v#672 - link alternative department florida health medicine
hormone compounding pharmacy spokane cvs pharmacy prescription coupon gift card
internal medicine billing semiars doctor quinn medicine woman episodes
small prehistoric stone medicine millstone medicine sarch
maternal fetal medicine evms china beijing herbal medicine advice
dorfner family medicine tyndall air force base pharmacy
simvastatin lupin pharm the best medicine for thyroids
mariposa medicine hat medicine circuit in establishment of health
malleys pharmacy pharmacy bottles antiques
plan b and pharmacies medicine for stiff knees
baker universal pharmacy scale error 8 sports medicine chattanooga tn
Posted by: bkindbdrows | August 27, 2011 at 03:14 AM
indian pharmacy tramadol http://dailybooth.com/cialisnoprescription/18758912#526 - best price cialis 20mg online medicine men dayton ohio
whaley's pharmacy http://dailybooth.com/cialisnoprescription/18758939#425 - compare prices on cialis coconut in traditional medicine
entertainment alternative medicine entrepreneur re http://dailybooth.com/cialisnoprescription/18758956#661 - buy cheapest cialis medicine abroad london
masters of medicine eastern virginia http://dailybooth.com/cialisnoprescription/18758982#806 - cialis tadalafil php pill online pharmacy degree adamsville rhode island
online pharmacy degree allakaket alaska http://dailybooth.com/cialisnoprescription/18759005#731 - link online schools alternative medicine
toronto pharmacy http://dailybooth.com/cialisnoprescription/18759026#451 - cialis work for women prescription medicine id
cut-rate medicine chattanooga http://dailybooth.com/cialisnoprescription/18759053#953 - ptnrs searchfor cialis hyperbaric medicine allentown
mini pharmacy http://dailybooth.com/cialisnoprescription/18759076#000 - link alternative animal medicine
byron family medicine http://dailybooth.com/cialisnoprescription/18759098#777 - link vinegar medicine bottles for crafts
olive oil ancient greece medicine http://dailybooth.com/cialisnoprescription/18759121#734 - link best medicine for bipolar depression
universal healthcare and socialized medicine most abused drugstore medication
alternative medicines migraine headache eckard pharmacy murfreesboro tn
chinese medicine wandering wind evil trivia and medicine
ridgeview sports medicine waconia good online pharmacy
family medicine board review medstudy pharmacys in the plainfield illinois area
michigan state pharmacy medicine throughtout history
nevada pharmacy law memorial hermann sports medicine institute
centrifuge and medicine safe administration of medicines
ezekiel's medicine project on alternative medicine
chinese herbal medicine benifits history of roman medicine
Posted by: maryovcr | September 03, 2011 at 02:44 AM