Jump to content

ShaunR

Members
  • Posts

    4,940
  • Joined

  • Days Won

    308

Posts posted by ShaunR

  1. I did a little research and it appears that this is not as simple as I thought. Serializing access to a shared resource seems to be a potential trouble spot for any kind of software. The only way to guarantee that a race condition does not occur is for process A to lock the file, and for process B to wait for the lock to be released. By accident I have created a poor-man's file lock by deleting the original file after reading, although there is still a narrow window where a race condition can still occur. Does anyone know if there is a "file lock" vi and a "wait for lock" vi? Can I do this from the command line in Unix using the system exec vi?

    Ok, here is an idea I got from the internet:

    1. Check for the existence of sharedfile.lock
    2. If sharedfile.lock exists, wait 10ms, go back to step 1
    3. Create sharedfile.lock
    4. Open sharedfile.txt
    5. Overwrite sharedfile.txt with new value
    6. Delete sharedfile.lock

    Does this sound like it would work?

    Why not just use the "Deny Access" vi (should be in LV7.0 - under file IO>>advanced file functions).

  2. ShaunR

    It's interesting I didn't know that . Thanks. I Use Firefox and i did what you said but it just pasted it as an image and not converted to code. How can we differentiate a simple png file from a snippet?

    If you are having difficulty with firefox. Open the image in a new tab before dragging to the desktop. It can be a bit of a pain in firefox. (it's even worse in chrome)

    You can tell it's a snippet because it has the hand,arrow and lv icon in the top left of the diagram image. It also has the labview version in the top right.

  3. Thanks Neville But it's a png file.

    If you are using exploere, just drag the image from explorer to an empty diagram.

    If you are using firefox, drag it to your desktop then drag it from there to an empty diagram.

    VI snippits are png image files with the actual code embedded in the image. When you drag the png image to a diagram, labview will re-create the code.

  4. Can't help with the problem. But maybe can explain how it is different

    It is a "plug-in" control and resides in the "\resource\PlugInControls" directory. As far as I'm aware, it is an undocumented interface allowing controls to be created from external DLLs and resources. I have a feeling it was the way NI was going for custom controls before they decided on Xcontrols.

  5. Well. My 2 cents.

    In practical terms; to transmit data over TCPIP you only need to know the length (ignore transport layers-at the application layer). How you bundle that data into the payload is irrelevant as long as you know how many bytes you are expecting. So simplest and most effective is a n-bit length and then your payload. You can use delimiters, but then you cannot send binary data without escaping it all and/or you have to put a lot more logic into your software to keep reading and testing data to find the end.

    That ticks all your boxes, for sending and receiving. It's the payload, however, that you need to decide how to package to make it "future" proof. Abstract the interface from the data and treat them separately. Once you have decided on how you are going to package it, it will either be a simple case of adding a length byte and transmitting, or the packaging will dictate that you use delimiters and (probably) some bloaty engine to parse it.

  6. Your proposal will work well. It''s a centralised system and is proven to work well on small scale apps thumbup1.gif

    You could also consider a "de-centralised" system where each "module" (your serial thingies) is a producer AND consumer so that data can not only be streamed from them, but control messages can be sent to them.

    Consider, for example, that your new UI module wants to stop one (or all) of the serial modules - a common requirement. In a centralised system, the responsibly for that lies with the messaging node (your consumer) since it is the only part that is aware of the "STOP" message. At that point, things can get ugly as the app grows since now it's no longer just a consumer (just processing data), it's also a controller - so the responsibility boundary becomes blurred.

    In a decentralised system, you can (don't have to...but can) pass the message straight from the UI to one or all of the modules directly. It doesn't stop you having a centralised processing point for data being emitted from the modules. It's just a little more "modular" in terms of how everything can fit together.

  7. Well. I've got no idea what you are talking about. biggrin.gif

    However. A LV picture speaks a thousand words so a quick glance at your code and it looks like you are just wanting to detect sign changes between 2 arrays of doubles?

    If this is correct then I would do something like this:

  8. Well that the DLL call is done in the UI thread may be just a byproduct. What I was meaning to say is that the execution of the entire XNode may be forced into the UI thread. I have never bothered to look into XNodes and how they work, but it wouldn't surprise me if they are more of a quick and dirty hack added to LabVIEW than a properly designed feature, which might be one of the reasons that it never made it into a public feature. And taking the shortcut of executing XNodes in the UI thread would make creating such a feature much easier. Of course it's not ideal to do it that way but hey I have no idea what the intended use cases were so it may have made perfect sense.

    Xnodes don't quite work like that (you would think it was similar to an Xcontrol...But it isn't) They are basically pre-packaged script nodes that are programmed to generate code when executed. So the xnode in question has lots of script to create a CLN and all the function parameters to interface to the DLL. The result is that at some point (not sure exactly when, maybe after compilation, or when you press the run button) the xnode runs, then creates the code and it is this generated code which runs in the place of the xnode - In this case a CLN in the UI thread.

    It's a lot of [script] code to generate a relatively small amount of real code that could have been created as you described and wrapped in a polymorphic VI for the adapt-to-type (no need for the intermediary DLL then and it wouldn't have to execute in the UI thread).

  9. Well that the DLL call is done in the UI thread may be just a byproduct. What I was meaning to say is that the execution of the entire XNode may be forced into the UI thread. I have never bothered to look into XNodes and how they work, but it wouldn't surprise me if they are more of a quick and dirty hack added to LabVIEW than a properly designed feature, which might be one of the reasons that it never made it into a public feature. And taking the shortcut of executing XNodes in the UI thread would make creating such a feature much easier. Of course it's not ideal to do it that way but hey I have no idea what the intended use cases were so it may have made perfect sense.

    Xnodes don't quite work like that (you would think it was similar to an Xcontrol...But it isn't) They are basically pre-packaged script nodes that are programmed to generate code when executed. So the xnode in question has lots of script to create a CLN and all the function parameters to interface to the DLL. The result is that at some point (not sure exactly when, maybe after compilation, or when you press the run button) the xnode runs, then creates the code and it is this generated code which runs in the place of the xnode - In this case a CLN in the UI thread.

    It's a lot of [script] code to generate a relatively small amount of real code that could have been created as you described and wrapped in a polymorphic VI for the adapt-to-type (no need for the intermediary DLL then and it wouldn't have to execute in the UI thread).

  10. Looked at the config file port in the installer but hadn't played with it yet. So in this case, I could have the installer set up the cDAQ in MAX and configure the names of the cDAQ and the module to use? Then just use the serial number and a unique PC identifier in the file name to track usage as Shaun mentioned? Or is there something I'm missing here? Or something even easier or slicker?

    -Ian

    Depends on which way you are looking at it.........

    Set it up once in MAX (make sure it all works). Export an nce file. Add it you your project. and set it in the installer. Once you build your installer you will only need to put it on a CD or USB stick or whatever and install it on any machine So effectively you use MAX to create your hardware "template" and then roll that out with the installer which will take care of configuring the target machines hardware. Your software will always use the same taks/channels regardless of which machine it is on and, as long as you put the C ID and DEV ID somewhere (file name is good if you just want to see at a glance in xplorer without opening files), you'll be able to track the results to the hardware.

    I would suggest also adding the date to the file name (e.g 2001-01-21) in that order then when you view the results you can sort them in explorer. Additionally, you can set the file date as a directory name and store your results by date making it easy to identify what was tested on which days. But it's just personal preference (one directory with lots of files or a few directories with a few files)

  11. Use the same name (in the tasks/channel/hardware configuration) or all the DAQ devices (say cDAQ).

    In your results file also save the DAQ devices serial number (you can read this using a property node shown below) and the computers ID (anything that identifies a unique computer - computer name, network card, IP address, HD serial etc). This way the executable will run on any suitcase, with any PC/DAQ (as long as they are all the same) but will save data that is traceable to a particular suitcase PC and/or a particular cDAQ.

  12. Benchmarked in 7.1.:

    1 million iterations

    straight wire through 186 ms

    error case structure 306 ms

    so the case structure costs about 120 ns.

    Hey, just checked without any wire (so a clear error vi).

    424 ms!

    So this is most likely slower due to the buffer reuse in above cases.

    Test in newer version: takes more than 500ms and the difference between straight wire and error case struct is almost gone.

    Felix

    Set the vi to subroutine (assuming you are using a sub-vi vi in a for loop) and you'll probably halve those timesthumbup1.gif

×
×
  • Create New...

Important Information

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