LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Error -200072 While Editing a Task Progammatically

Solved!
Go to solution

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.

0 Kudos
Message 11 of 22
(1,522 Views)

I think Kevin has the solution.

 

  1. Use the predefined task to get all the predefined parameters you need.
  2. Change only parameters you want for the new task leaving everything else the same. So you should have every parameter you need in the task.
  3. Start a new Task with the small changes.

mcduff

 

0 Kudos
Message 12 of 22
(1,518 Views)

@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

0 Kudos
Message 13 of 22
(1,513 Views)

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?

0 Kudos
Message 14 of 22
(1,508 Views)
Solution
Accepted by topic author JaNeily

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

snip.png

 

 

 

You will have to add all the parameters like Kevin showed, that I am excluding.

 

mcduff

Message 15 of 22
(1,503 Views)

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? 🙂

0 Kudos
Message 16 of 22
(1,500 Views)

Thanks, but, you should mark Kevin's post as a solution. I just put stole his idea and put it in a loop.

 

mcduff

0 Kudos
Message 17 of 22
(1,496 Views)
Solution
Accepted by topic author JaNeily

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.

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
Message 18 of 22
(1,491 Views)

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.

0 Kudos
Message 19 of 22
(1,477 Views)

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.


"Should be" isn't "Is" -Jay
Message 20 of 22
(1,470 Views)