08-17-2017 11:47 AM
But this erases all of the original settings for all of the other channels. I want to maintain all of the other channels settings and edit only one of the channels.
08-17-2017 11:54 AM
I think Kevin has the solution.
mcduff
08-17-2017 11:56 AM
@Kevin
I think you found the solution. Out of curiosity should the original task be closed after the property node? Is this a possible memory leak? (I have never used predefined tasks, that is why I am asking.)
mcduff
08-17-2017 12:08 PM
I am not understanding. Starting a new task with the small changes to the one channel in your #3 erases all of the the other channels, so I lose everything else. How do I maintain all of the other channels?
08-17-2017 12:22 PM
I do not have time to test it out (first day of kids school), but you should be able to loop over all of your channels, adding each channel to the task using a shift register. Something like the following
You will have to add all the parameters like Kevin showed, that I am excluding.
mcduff
08-17-2017 12:30 PM
Yes, that should work. This seems like an awful lot of programming is required just to change a channel name. I was hoping for an easier solution.
Hey NI - can you add a virtual channel name property to the channel property node? Please? 🙂
08-17-2017 12:33 PM
Thanks, but, you should mark Kevin's post as a solution. I just put stole his idea and put it in a loop.
mcduff
08-17-2017 12:37 PM - edited 08-17-2017 12:40 PM
Well, so you'd just extend the basic idea to the other channels before saving.
The mechanics of it would be that you'd probably auto-index over the array of channels returned from the global task. "DAQmx Create Virtual Channel" would be inside the loop. You'd output its task output to a right-side shift register. You'd feed its task input from the left-side shift register. The left-side shift register would have to be fed from outside the loop with the right kind of invalid task refnum, which you could likely create by right-clicking the task input from "DAQmx Create Virtual Channel" and creating a constant.
You'll iterate through all the channels from the original global task and make only the needed changes. (The code will get more complex if the subsets of settings that need to be retained and/or changed can vary from one channel to the next). At the end of the loop, the task coming out the right-side shift register will contain all the re-configured channels and can *then* be saved.
As mcduff said in his earlier post, it can get a little ugly but it oughta work. Persistent searches on the site for posts from Bob_Schorr may turn up some more detailed info.
@mcduff: I don't really use predefined tasks either, but I would guess you don't need to close the global task ref because the task was never started. Since it refers to something "statically" defined in a MAX database, I'm supposing it's analogous to the way GUI control references don't need to be closed.
-Kevin P
P.S. Looks like I was too slow. What mcduff posted is exactly what I was describing about iterating over the original channels and using a shift register for the (new) task refnum.
08-17-2017 01:11 PM - edited 08-17-2017 01:11 PM
Yes and thanks, and mcduff gives you the credit. I certainly hope NI makes it easier in the future. The virtual channel name is the only property you cannot edit with the property node.
08-17-2017 01:32 PM
And, one more for good measure.
Persist your DAQmx Tasks, scales, and channels to the project (*.lvproj) and build the application.
<MyApp>\Data\ will contain an NI DAQ\configuration ini file.
Simply create a config editor utility for that file.