DAQExpress

cancel
Showing results for 
Search instead for 
Did you mean: 

Load and execute saved Tasks in MAX

Hello All, 

i have created a couple of tasks in MAX and i want to load and execute these task in my application C#.

what i can find in the doc is just how to load the task by its name : Task myTask = DaqSystem.Local.LoadTask(TaskName);

now task is loaded, how can i access to every channel and execute the desired channel based on the name ?

Thank you

0 Kudos
Message 1 of 7
(4,632 Views)

I believe you are looking for the CreateChannel Method:

 

http://zone.ni.com/reference/en-XX/help/370473J-01/ninetdaqmxfx40ref/html/m_nationalinstruments_daqmx_dichannelcollection_createchannel/ 

 

This will allow you to pull in the channels from your task. 

Conner A.
Technical Support Engineer
National Instruments
0 Kudos
Message 2 of 7
(4,609 Views)

Your example shows how to create channel.Task.png

my request is : i already have defined "task" in MAX and i want to load --> Execute --> get mesurement , independently if they are DI, DO,AO...

For example in the image i attached i want to execute task : 12VLin_HW_1 and the channel sysSpg12V.

so far i found this method that load saved task from MAX but there is no further code examples

DaqSystem.Local.LoadTask(TaskName);
0 Kudos
Message 3 of 7
(4,601 Views)

I was looking further into your issue and I realized that you are trying to run a specific channel from a task, which you cannot do in C# or LabVIEW. If you want to run those channels separately you need to put them in different tasks. Once the task is loaded all channels that are configured will run. To run the task I recommend referring to the getting started guide here:

 

Using NI-DAQmx in Text Based Programming Environments

Conner A.
Technical Support Engineer
National Instruments
0 Kudos
Message 4 of 7
(4,589 Views)

Good morning,

so far i succeeded to read a bulk or single Channel from a stored Task AI or DI, here is the example i use :

 

                // Laden die ausgewählte Aufgabe
                var aiTask = DaqSystem.Local.LoadTask(TaskName);

                using (aiTask)
                {
                    // Laden den angegebenen Kanal
                    aiTask.Stream.ChannelsToRead = ChannelName;

                    // Konfigurieren den Reader
                    AnalogSingleChannelReader reader = new AnalogSingleChannelReader(aiTask.Stream);

                    // Verify the Task
                    aiTask.Control(TaskAction.Verify);

                    //Führen den Reader aus
                    return reader.ReadSingleSample();
                }

now i want to do the same but this time with outputs. (AO or DO). unfortunatly there is no defined API that let you select the desired AO channel like :

 

                  // Laden den angegebenen Kanal
                    aiTask.Stream.ChannelsToRead = ChannelName;

is there any alternative ?

0 Kudos
Message 5 of 7
(4,585 Views)

I recommend using the DAQmx commands in the link that I sent. That is the recommended method of running tasks made in MAX. 

 

Also, in the future I recommend posting to the Measurement Studio forum for help on this issue. DAQExpress is a different product and it doesn't sound like that's what you're using, you're likely to get more responses in the appropriate forum.  

Conner A.
Technical Support Engineer
National Instruments
0 Kudos
Message 6 of 7
(4,552 Views)

Thank you Conner for the support, 

even though thats not solving my issue but im satisfied with the support.

Regards.

0 Kudos
Message 7 of 7
(4,549 Views)