Jump to content

cschneider

Members
  • Posts

    6
  • Joined

  • Last visited

cschneider's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Yeah, you did it all right...it's just a simple C++ Coding error...your variable name is Cluster, the type is TD2... So try changing the line TD2 clusterElem = (*arg1)->TD2[1]; to TD2 clusterElem= (*arg1)->Cluster[1] and see if this works... good luck Chrisitan
  2. Hi, the way you are using is totally right...create the cluster, wire it to a call library node and then create the c file. I only worked with "Handle by Value" because, as you already said, the other is totally blank. To manipulate the data, I have to say that it's not allowed by labview to alter the size of you data...that means adding of array elements is not possible, you can only manipulate existing elements. For other things (expanding of your array), you have to use CIN-nodes (but I never worked with them so far) If you pass an array, the size of the array is added in the struct, as you said. so dimSize is the size of your array, elt[1] the first array element. In Labview, data is represented by "Handles", that means "Pointers to Pointers to struct"..what means that you have to dereference it first if you like to access it (with the **). So if you create an object (i hope I am right as I write this code out of my mind... ;-)): TD3Hdl handle; int dimension_size=(*handle)->dimSize; OR int dimension_size=(**handle).dimsize -> means something like "dereference and access of object", whereas . means only access to object. Like this, you can expand your code to more complex structures. If you have, for example, another structure like "TD2Hdl" (which you don't have at the moment), then you can by (*td2handle)->unsignedByteArray access your unsignedByte-Array variable fo type TD3Hdl and then, by *((*td2handle)->unsignedByteArray)->dimSize access the upper dimSize...and so on, and so on, and so on.. Hope this helps, good luck Christian /* Typedefs for array of clusters with strings */ typedef struct { int32 dimSize; uInt8 elt[1]; } TD3; typedef TD3 **TD3Hdl; typedef struct { TD3Hdl unsignedByteArray; int32 elt2; } TD2; typedef struct { int32 dimSize; TD2 elt[1]; } TD1; typedef TD1 **TD1Hdl; I imagine dimSize for TD1 is the size of the array (so maybe I don't have to pass that into the fct as a separate argument?) and that dimSize for TD3 is the size of the U8 char array. Does TD3Hdl represent a handle to the individual unsignedByteArrays? Any help would be greatly appreciated. Thanks very much
  3. Hi Felix! Thank you for your reply...As I am a beginner in object oriented programming with Labview (did only some stuff in C++, programming Labview without objectorientation since 6 years now...), I am trying hard to understand your ideas and reading on the design patterns... First of all, as far as I understand, the factory design pattern let me initialize objects at runtime as needed without loading the class (perfect for plugins?). So this would help me to handle all my different data devices...like camera, scanner, ad-card and so on. Is this right? I am only trying to implement my devices in classes to use dynamic dispatching which seems to me very useful for what I am trying (i can use a record.vi for every device). So, if I have, let's say, 5 data devices which have totally different settings (meaning I have to expand my front panel for every new device) and I have to implement several different VIs (for example for the AD-Card: channels to record, for the camera somethink like region of interest...), will this pattern be useful for me? If yes, why? As a second, I understand how to use DVR (only worked with single-element-queues so far), but how I can intialize all my different data devices (camera, scanner..) with the same DVR? If I initialize the camera, the DVR (which is a member variable of my ImageDevice-class), will be created...if I know initialize the scanner, how can I pass the DVR from the camera-object to the scanner-object? Is this meant by "the factory object (the DVR??) needs to be a singleton), that if i initialize my camera and later the scanner, the same buffer is used? What do you mean, btw, with "serialization that naturally takes place"? If it's really a design constraint to make this buffer static? Let me say...the only thing I'd like to do is to know where I can find my data...if I use the camera or the scanner, there shoudn't be separate buffers...as all saving, displaying and manipulation-functions are already implemented, I don't like to distinguish where my data comes from. The saving, for example, is the same routine for scanner as it is for camera...so I want to use the same data buffer. To make the buffer an object itself would be a good method, but I think I would then have to pass this object to all created data devices, so that they can write into this buffer if i call the "record.vi". But I think this would be a very easy solution...create the data buffer on start, and on initialization of a data device, I can pass the buffer to a member variable. By the way: How objects are passed in LabView? I started using queues to do a "by reference" call, as I have to transfer large amounts of data...if I now use classes and pass these classes into my program, the class data is handled by reference or by value? Meaning: If i have one wire which goes parallel to 2 sub-vis, if the upper subvi changes something in the class, it will simultaneously change in the lower subvi? Thank you again for all of your help! Christian
  4. Ok, thank you for your help! Just had a look for the factory design pattern you mentioned...at the moment, it seems to me that I can handle with this all my data access devices, but so far, I couldn't figure out how to initialize all of my subclasses with the same DVR...It's enough to create a DVR as object member variable, or it's still needed to use something like global variables? Thank you very much! Christian
  5. Hi everybody, 2 years ago, I started a program which uses the producer / consumer - loop design pattern. As the program growed very fast, I now decided to use object oriented programming, but I have now several problems, I hope you can help me. More concret, I have several data acquisition devices which record images (cameras) or 1D arrays of values (AD card). In producer / consumer design pattern, I can't use these devices in parallel, only a serial data acquisiton is possible. I now found a design pattern called "worker pool" on http://expressionflow.com/2009/11/04/worker-pool/, which seems to be perfectly suited for my approach. I now have to implement the functions of every data device in a class and use dynamic dispatching to call the appropriate "record" function for every class at runtime. So I can use all devices in parallel. Unforunately, NI couldn't tell me if this approach will work as they don't know the design pattern. Somebody already tried it? As I'm not very familiar with OOP (just made some C++-programs), I now try to figure out: - How I can realize static member variables? As I have several devices recording images, I like to create a parent class "ImageDevice" and inherit from it...the ImageDevice class should hold the data buffer. But as I only need one image buffer, I like to realize it as static...it's only possible by global variables? - How I separate my "device control code" from my "front panel control code", that means: If I hit "Record" on the front panel for one device, a boolean indicator should indicate that the recording is in progress... one way to do this would be to create (for the specific device) a member variable which is a reference to my front panel indicator, and on record, I can (in the "record.vi" from the specific device) switch the indicator from false to true...but this would end in a mix up between "device code" and "program code"...how I can handle this? You see, lots of problems...hope you can help me somehow, as I can't really figure out how to do it the best way... Thanks in advance, Christian
  6. Hi, i am trying to convert a time-signal to a frequency signal using FFT Spectrum (Mag-Phase).vi. As the frequency expected is in the Terahertz range (10^15 Hz) and the frequency range is very smallband, I need a good resolution in the frequency range, but as the Labview output starts at 0 Hz, it's not very well resolved. So I need a way to increase the resolution (i. e. decrease the df of my output signal), but I don't know how to do this...can somebody help me? thanks in advance, christian
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.