Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/18/2009 in all areas

  1. I was working on something today and thought a "Concatenate Inputs Horizontally" would come in handy some times.. That way I could get rid of these 3 transpose array functions. I'm usually not on the cutting edge of thought... something like this hasn't been discussed before, has it? -James
    1 point
  2. OK, so has anyone else had problems with transferring projects from 8.6.1 to LV 2009? I have one major project that originally had large problems even running in 2009 but that was solved by uninstalling 8.6.1 and 2009 then reinstalling 2009 alone. It seems that there has been some significant reorganization done in the SPT, esp in the Wavelet Analysis subs. Ok so that DID get sorted out (essentially by the "virgin" install of 2009) but now when I do my build -- of a project that builds perfectly well in 2009 -- I can get the project to build BUT, i get the following error message when trying to run the built EXE: "LabVIEW: File is not a resource file. The file 'BuiltAPP.EXE' could not be loaded" Any good ideas, besides backing down to 8.6.1?
    1 point
  3. Ahhh... But LabVIEW isn't just any other programming language! And it's (native) implementation of OOP is very unique (thanks AQ ) Should we use standard terms of other languages? I have seen arguments for this, and against this, on the forums Does it hinder or help people learn, who may have or may not have other programming experience??? But I tend to agree - the term object reference sounds clear and concise. Great point on LVOOP-DVR vs LVOOP-SEQ !! I am thinking that LVOOP-DVR is the more native approach, as I can see DVR being the future of byRef OOP in LabVIEW, and as such warrents the term native object references IMO. What do others think?
    1 point
  4. I don't know whether word "voop" is not too meaningful...
    1 point
  5. What version of Camtasia are you using? I'm using V6 and it works just fine for me. No issues. You can also try Jing which is made by the same company. Jing is just a recorder (you can't do editing) but maybe you will get different results. One more thing, in your Camtasia recorder options try enabling layered window recording.
    1 point
  6. Hi Jim I gave it a go using Jing and it worked fine. http://www.screencast.com/users/jgcode/folders/Jing/media/bac74cd6-7641-4e97-9586-dc7a18df2658 Do you have Jing to try?
    1 point
  7. One of the purposes behind "friends" is to tighten the relationship (pun intended) between XControls (a type of library) and LVOOP classes. So now there is greater protection in setting up an XControl as the UI for the class data. Prior to this, the XControl would have to access the class data through public VIs. As such any other VI could access the data through those public VIs. Now, the class can declare the XControl as the friend. Thus there is protection of the class data for anything other than the XControl friend (or other descendants through protected methods). Hope this helps.
    1 point
  8. What about this one?
    1 point
  9. Rolf's suggestion is not the best way to do this. You actually can directly pass an array of clusters to C code and treat them as C structs, and you can even modify and resize that array. Here's how: Configure your call library node parameter as "Adapt to Type", and make sure that you have "Handles by Value" selected for the Data Format. Once that's done, wire up your array of clusters (if you start with an empty array, just create an empty array constant with the right type and wire that). Now, right-click on the call library node and choose "Create .c file...". That will generate a file containing C code with the proper C types for your array of clusters and the right function prototype. It will look something like this: /* Call Library source file */ #include "extcode.h" /* Typedefs */ typedef struct { int32_t Element; } TD2; typedef struct { int32_t dimSize; TD2 Cluster[1]; } TD1; typedef TD1 **TD1Hdl; void funcName(TD1Hdl arg1); void funcName(TD1Hdl arg1) { /* Insert code here */ } Obviously we don't do a good job of naming these types, so you should rename them first (ex: replace TD1 with MyArray and TD2 with MyStruct). Important: On 32-bit Windows you need to do one more thing to this code to make it work right in every case. Modify it like so: /* Call Library source file */ #include "extcode.h" /* Typedefs */ #if MSWin && ProcessorType != kX64 #pragma pack(push,1) #endif typedef struct { int32_t Element; } MyCluster; typedef struct { int32_t dimSize; MyCluster Cluster[1]; } MyArray; typedef MyArray **MyArrayHdl; #if MSWin && ProcessorType != kX64 #pragma pack(pop) #endif void funcName(MyArrayHdl arg1); void funcName(MyArrayHdl arg1) { /* Insert code here */ } The #if/endif and #pragma lines are the ones you need to add. This fixes alignment on 32-bit Windows because LabVIEW on that platform does not use the default alignment. If you don't do this then the C code will not interpret the data correctly in some cases. With that done, you just have to implement your code. Note that the function takes a MyArrayHdl (aka, a MyArray**). This is a "handle" to a LabVIEW array. LabVIEW arrays internally are structures containing an int32 dimension size (for each dimension) followed by an inline array of the elements. So, for instance, to sum all the elements in the example above you would write code like this: int32_t sum = 0; if(arg1) // empty arrays will have a NULL handle { for(int32_t i = 0; i < (*arg1)->dimSize; ++i) { sum += (*arg1)->Cluster[i].Element; } } That's all it takes to just read or modify the existing elements of the array of clusters. What about resizing? That's a bit trickier, but it's still possible. To resize the array you need to resize the handle, update the dimSize, and initialize any new elements (if you grew the array). When you resize the handle you have to calculate the size of the whole array in bytes. Here's the correct way to grow the array above by one element: MgErr err = mgNoErr; if( mgNoErr == (err = DSSetHSzClr(arg1, Offset(MyArray, Cluster) + sizeof(MyCluster)*numElems)) ) { (*arg1)->dimSize = numElements; // Initialize new elements } else { // error (probably mFullErr) } If you allow for an empty array to be passed in then you might get a NULL handle, which you can't resize. To allow for that, change your call library node by setting the Data Format of that parameter to "Pointers to Handles". This will change the type from MyArrayHdl to MyArrayHdl* (aka MyArray***). You would then work with it like this: MgErr err = mgNoErr; size_t arraySizeInBytes = Offset(MyArray, Cluster) + sizeof(MyCluster)*numElems; if(NULL != *arg1) { err = DSSetHSzClr(arg1, arraySizeInBytes); } else // empty array, must allocate { if( NULL != ( *arg1 = (MyArrayHdl)DSNewHClr(arraySizeInBytes) ) ) err = mFullErr; } if(mNoErr == err) { (**arg1)->dimSize = numElems; // Initialize new elements } else { // handle error } The last thing you have to do is to link your DLL to labviewv.lib (in the cintools directory of your LabVIEW installation, along with extcode.h). This gives you access to the DS* functions (and all the other functions in extcode.h). Make sure you use the labviewv.lib version. That's the one that's smart enough to make sure that it uses the correct versions of those functions even if you have multiple LabVIEW runtimes loaded in the same process. Now, obviously a lot of this is a bit tedious (much harder than using a simple C-style array), but it's not actually very difficult once you know how to do it. Don't be afraid to try it. It's easier than it looks, and it can make your LabVIEW/C interactions much more flexible.
    1 point
  10. The Call Library Node does not directly support to pass complex datatypes, resp. it does using the Adapt to Type but this passes an array as a LabVIEW handle which is absolutely not the same as a C array pointer. So you will have to trick this a bit. First configure the parameter as an array of bytes (8-bit integers). Then allocate a byte array of enough length with the Initiliaze Array function and pass this to the Call Library Node. The returned byte array can then be typecasted to a LabVIEW array of clusters and should after that be routed through a Swap Bytes and Swap Words node when you are on Windows. Alternately in LabVIEW 8.2 an newer you can use the Unflatten from String function (convert the byte array first to a string) where you set the endianess input to little endian, or even better native, host order, and the "data includes array or string size? (T)" set to false. With this you replace the Typecast and Swap Bytes and Swap Words. You will have to create a cluster that is compatible. For the char name[32] and char pad[3] you can NOT use a LabVIEW string but must instead insert another cluster of 32 resp. 3 8-bit integers. The get the length of the entire byte array typecast this entire cluster to a string and get the string length and multiply it with the number of struct elements you want to pass to the DLL function and then pass this value to the length input of the Initiliaze Array node. Rolf Kalbermatter
    1 point
×
×
  • Create New...

Important Information

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