[triangle-zpug] Linking DAQs to Data Turbine

David Handy david at handysoftware.com
Thu Jan 24 14:07:21 CET 2008


Hi Lee, welcome to the wonderful world of Python!

Python is a great tool for writing "glue" between other programs, it sounds
like you are on the right track with your approach.

> .         Try to convert the fake_daq C code to Python - essentially try to
> copy the design of fake_daq.  The code in fake_daq is much more advanced and
> robust than what I was trying to write by myself in Python.

I agree that is the approach you ought to take - convert a working example
from C to Python, before you do your own custom stuff.

> In fake_daq this is where they start a separate thread to stream data.  If
> I continue with this code, I will probably try to do the same thing but I
> will have to learn some more about threading first (another reason to
> consider adapting the fake_daq code for now).

No worries, threading is fun. It's *too* easy, that's why people get into
trouble... to keep your program debuggable, threading needs to be used to the
minimum extent possible.

I haven't had a chance to look at your code yet. If you go ahead and
post your actual error, and it is a stack trace that mentions a file and
line number, that would give us something specific to look for.

David H

On Wed, Jan 23, 2008 at 06:16:16PM -0500, Lee Nelson wrote:
> I'm sorry I wasn't more prepared last night but here is the problem I was
> trying to present.  For anybody who wasn't there, I am new to Python but I
> am trying to create a Python link between two programs.  I have been
> investigating, working on this, and trying to learn Python for about six
> months.  While the problem seems relatively simple, I'm currently
> overwhelmed with all of the options and everything I'm trying to learn.  I'm
> hoping this group might provide me with some direction.  
> 
>  
> 
> All of the files referenced in this email can be accessed by downloading
> this file: http://www.cfl.ncsu.edu/temp/Python_Group_Attachements.zip. 
> 
>  
> 
> As a quick summary, I want use Python to access data from a program called
> StrainSmart via a COM interface, do a small amount of string manipulation,
> and stream the data in an ASCII format over the network to a program called
> Data Turbine.  StrainSmart is a program from Vishay Micromeasurements in
> Wendell, NC and it is designed to control their data acquisition hardware.
> Data Turbine is an open source java program that synchronizes and archives
> data and video from multiple sources.  Once the data and video is in Data
> Turbine, there is a very powerful front end called RDV or "Real-Time Data
> Viewer" for viewing and plotting live and archived data over the network
> (http://it.nees.org/software/rdv/index.php).  The details of each program
> and it's interface is below:
> 
>  
> 
> StrainSmart:
> 
>  
> 
> .         StrainSmart software is used to control data acquisition hardware
> from Vishay Micromeasurements, a company which is located in Wendell, NC. 
> 
>  
> 
> .         Vishay provides a number of methods for accessing data from
> StrainSmart.  The most appealing method to me is their "High Level OLE
> Automation Server" which is documented here:
> http://www.vishay.com/company/brands/measurements-group/Software/Interfac/hi
> _level.htm.  I chose this interface over the lower level interfaces because
> it doesn't interfere with the operation of StrainSmart and it outputs fully
> reduced data rather than A/D counts.  I have been able to access the
> properties and methods of the high level interface with Python (using the
> win32com module).
> 
>  
> 
> .         One of Vishay's Applications Engineers wrote the attached VBA
> example of how to access this interface (Reduced Data.zip).  The VBA example
> has a graphical interface and streams data from StrainSmart into an excel
> worksheet while StrainSmart is recording.  I was able to sit down with the
> Applications Engineer who wrote this program and have him explain how it
> works.  
> 
>  
> 
> Data Turbine:
> 
>  
> 
> .         Data Turbine is an open source java program that is supported by
> NEESit: http://it.nees.org/software/dataturbine/index.php.  NEES is the NSF
> sponsored "Network for Earthquake Engineering Simulation" and it consists of
> about 15 large structural testing facilities.  NEESit is a part of NEES that
> develops and supports IT infrastructure and software for these labs.  My lab
> at NC State (www.cfl.ncsu.edu) is not a part of NEES but I am very
> interested in using the same open source software.  I recently spent a week
> at the UCSD Supercomputing Center learning how to use everything.  In order
> to implement the software, I first have to develop software links to our
> specific hardware.  These data acquisition systems are the first and most
> important piece of equipment that I want to link into Data Turbine.  I
> already have network cameras which send video streams directly into
> DataTurbine.  
> 
>  
> 
> .         NEESit provides a LabView program called NEESdaq
> (http://it.nees.org/software/daq/index.php) which is capable of getting data
> from National Instruments hardware and this is what most of the NEES labs
> use.  My lab has invested heavily in Vishay hardware and there is no desire
> to purchase high channel count National Instruments systems.
> 
>  
> 
> .         Data Turbine is also known as RBNB or "Ring Buffered Network Bus"
> and it was originally written by a company called Creare
> (http://outlet.creare.com/rbnb/index.html).  It has a Java API which is
> documented on the Creare website:
> http://outlet.creare.com/rbnb/WP/V2.0/Documentation/Java/com/rbnb/sapi/packa
> ge-summary.html.
> 
>  
> 
> .         To simplify the interface with Data Turbine, NEESit used the Java
> API to create an intermediate program called DaqToRbnb.   DaqToRbnb accepts
> simple ASCII commands and data over TCP and it is documented in the attached
> file (TR-2004-35.pdf).  
> 
>  
> 
> .         After several months of unsuccessfully trying to write this
> program by myself in Python, I contacted NEESit and they sent me the code
> for the attached program called fake_daq (fake_daq.zip).  Fake_daq is
> written in C and it basically sends sine-wave data to Data Turbine through
> DaqToRbnb.  The idea is that somebody could replace the sine-wave generator
> with their DAQ code and use this program.  
> 
>  
> 
> So with all of this information, these are some of the options I have come
> up with for proceeding with this project:
> 
>  
> 
> .         Interface directly with the Data Turbine Java API.  I know very
> little about Java and this seems like a very difficult option compared to
> using DaqToRbnb.  It could be possible using something like Jython???  The
> data acquisition and the Data Turbine server would always be separate
> computers so there would have to be some network programming involved.  To
> me it seems much easier to use DaqToRBNB which is already written and
> extensively tested.  I initially looked at doing this whole program in Java
> but I abandoned the idea when I tried to access the StrainSmart COM
> interface using one of the open source Java to COM bridges.  The COM
> interface is why I initially switched to Python.
> 
>  
> 
> .         Try to adapt the LabView code of NEESDaq to my Vishay hardware.  I
> think there may even be some VI's for executing python code in LabView.
> I've done a lot with LabView in the past but I would have to learn a lot
> more to work with NEESDaq.  I enjoy real coding and if I'm going to spend
> time learning a programming language, I would rather learn Python because I
> probably won't have a license for LabView if I ever leave the University.
> 
>  
> 
> .         Write my own Python Code from scratch - I have been working on
> this but I am currently stuck.  A professor in my department's Computer
> Aided Engineering group suggested that I look into some packet sniffing
> software to look at the network communication between my program and
> DaqToRBNB so that I can compare this to some successful communication
> between NEESDaq or fake_daq and DaqToRBNB.  This is what I'm presently
> working on with my code.
> 
>  
> 
> .         Try to convert the fake_daq C code to Python - essentially try to
> copy the design of fake_daq.  The code in fake_daq is much more advanced and
> robust than what I was trying to write by myself in Python.
> 
>  
> 
> .         Try to access the COM interface from within C - I've read that
> this is possible.
> 
>  
> 
> .         Try to compile the C program in C++ where I've read it's easier to
> access the COM interface.
> 
>  
> 
> .         Use SWIG generate an interface and use the C functions from
> fake_daq in Python.
> 
>  
> 
> .         Use C-Types ???
> 
>  
> 
> .         Try to embed my Python function to get data from the COM interface
> in fake_daq.
> 
>  
> 
>  
> 
> I'm sure there are also many other options.  Thus far I am very excited
> about learning Python and am hoping to use it on several other projects, so
> I would like to stay with a Python solution if at all possible.    Please
> let me know if you have any suggestions or advice and thanks in advance for
> your help.  
> 
>  
> 
> For what it's worth I attached the code that I am working on.  I basically
> just set up two sockets, a control socket and a data socket.  When I start
> both programs, I start receiving commands from DaqToRbnb and my Python code
> responds to those commands (currently with predetermined arbitrary responses
> - I will eventually have to work with the COM interface to extract this
> information from StrainSmart and send it to DaqToRBNB - I am currently
> working on this in a separate program).  My program works fine until it asks
> me to start streaming data on the data socket, then it crashes (I don't
> recall the exact message . I will have to get all of the programs up and
> running to recreate the error).  In fake_daq this is where they start a
> separate thread to stream data.  If I continue with this code, I will
> probably try to do the same thing but I will have to learn some more about
> threading first (another reason to consider adapting the fake_daq code for
> now).  
> 
>  
> 
> Thanks,
> 
>  
> 
> Lee
> 
>  
> 
> __________________________________
> Lee Nelson
> Research Engineer and Laboratory Manager
> North Carolina State University
> Constructed Facilities Laboratory
> 2414 Campus Shore Dr
> Campus Box 7533
> Raleigh, NC 27695-7533
> P: 919-513-4793
> F: 919-513-1765
> www.cfl.ncsu.edu
> 
>  
> 

> _______________________________________________
> triangle-zpug mailing list
> triangle-zpug at starship.python.net
> http://starship.python.net/mailman/listinfo/triangle-zpug


-- 
David Handy
Computer Programming is Fun!
Beginning Computer Programming with Python
http://www.handysoftware.com/cpif/




More information about the TriZPUG mailing list