Creating a .NET DAQ Component Programmatically
- Updated2023-02-17
- 2 minute(s) read
Creating a .NET DAQ Component Programmatically
You can use a .NET DAQ component programmatically by directly creating an instance of the component and calling its methods and handling its events. The specific methods and events that you use differ depending on the type of task you configured. The following are task types and corresponding DAQ component members that are commonly used.
Finite Input
Finite input DAQ components derive from FiniteInputDaqComponent<TReader,TData>.
- Create an instance of a finite input component.
-
Call Read to read the data.
VB.NET Dim component As MyFiniteInputComponent = New MyFiniteInputComponent() Dim data() As Double = component.Read()
C# MyFiniteInputComponent component = new MyFiniteInputComponent(); double [] data = component.Read();
Finite Output
- Create an instance of a finite output component.
- Call WriteAsync to write the data.
VB.NET Dim component As MyFiniteOutputComponent = New MyFiniteOutputComponent() Dim data() As Double '' Populate data … component.WriteAsync(data)
C# MyFiniteOutputComponent component = new MyFiniteOutputComponent(); double[] data; // Populate data … component.WriteAsync(data);
Continuous Input
- Create an instance of a continuous input component.
- Add an event handler for the DataReady event.
- Call StartRead to start the continuous input data acquisition.
VB.NET Dim component As MyContinuousInputComponent = New MyContinuousInputComponent() AddHandler component.DataReady, AddressOf OnDataReady component.StartRead() ' … Sub OnDataReady(ByVal sender As Object, ByVal e As MyContinuousInputComponentDataReadyEventArgs) Dim data() As Double = e.GetData() ' … End Sub
C# MyContinuousInputComponent component = new MyContinuousInputComponent(); component.DataReady += OnDataReady; // … void OnDataReady(object sender, MyContinuousInputComponentDataReadyEventArgs e) { double[] data = e.GetData(); // … }
Continuous Output
- Create an instance of a continuous output component.
- Add an event handler for the GenerateData event.
- Call StartWrite to start the continuous output data acquisition.
VB.NET Dim component As MyContinuousOutputComponent = New MyContinuousOuptutComponent() AddHandler component.GenerateData, AddressOf OnGenerateData component.StartWrite() ' … Sub OnGenerateData(ByVal sender As Object, ByVal e As MyContinuousOutputComponentGenerateDataEventArgs e) Dim data() As Double ' Populate data … e.SetData(data) End Sub
C# MyContinuousOutputComponent component = new MyContinuousOutputComponent(); component.GenerateData += OnGenerateData(); component.StartWrite(); // … void OnGenerateData(object sender, MyContinuousOutputComponentGenerateDataEventArgs e) { double[] data; // Populate data … e.SetData(data); }
Regenerative Output
- Create an instance of a regenerative output component.
- Call StartWrite to start the continuous input data acquisition.
VB.NET Dim component As MyRegenerativeOutputComponent = New MyRegenerativeOutputComponent() Dim data() As Double '’ Populate data … component.StartWrite(data)
C# MyRegenerativeOutputComponent component = new MyRegenerativeOutputComponent(); double[] data; // Populate data … component.StartWrite(data);