National Instruments 374318A-01 Benutzerhandbuch
Chapter 4
Getting Started with Measurement Studio
© National Instruments Corporation
4-19
[C#]
// This stops the scan
private void button2_Click(object sender, System.EventArgs e)
{
aiScan1.Stop();
}
5.
Double-click the
AIScan
component to open the code window.
6.
Add the following lines of code to the
DataReady
event of the
aiScan1
component to copy the analog data to an array.
[VB.NET]
Private Sub AiScan1_DataReady(ByVal sender As Object, ByVal e As System.Even-
tArgs) Handles AiScan1.DataReady
tArgs) Handles AiScan1.DataReady
WaveformGraph1.PlotY(AiScan.GetSingleChannelValues(), 0, 1.0 /
AiScan1.ActualRate)
[C#]
private void aiScan1_DataReady(object sender, System.EventArgs e)
{
waveformGraph1.PlotY(AiScan.GetSingleChannelValues(), 0,
1.0/aiScan1.ActualRate);
}
7.
Add the following lines of code to the
ErrorOccurred
event of the
aiScan1
component to display a message box if an error occurs.
[VB.NET]
Private Sub AiScan1_ErrorOccurred(ByVal sender As Object, ByVal e As
MccDaq.ScanComponents.ErrorOccurredEventArgs) Handles AiScan1.ErrorOccurred
AiScan1.Stop()
MessageBox.Show(AiScan1.Status, "AI Scan Error")
End Sub
[C#]
private void aiScan1_ErrorOccurred(object sender,
MccDaq.ScanComponents.ErrorOccurredEventArgs e)
{
aiScan1.Stop();
MessageBox.Show(aiScan1.Status, "AI Scan Error");
}