Measurement-computing DAQFlex User Guide Bedienungsanleitung Seite 16

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 125
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 15
DAQFlex Software User's Guide Using DAQFlex Software
16
Reading a digital port
C#
// Read the value of digital port 0
String[] Devices;
DaqDevice MyDevice;
DaqResponse Response;
try
{
// Get a list of message-based DAQ devices
Devices = DaqDeviceManager.GetDeviceNames(DeviceNameFormat.NameAndSerno);
// Get a DaqDevice object for device 0
MyDevice = DaqDeviceManager.CreateDevice(Devices[0]);
// Send device messages
MyDevice.SendMessage("DIO{0}:DIR=IN");
// Read and display the daq response
Response = MyDevice.SendMessage("?DIO{0}:VALUE");
Label1.Text = Response.ToString();
}
catch (Exception ex)
{
// handle error
label1.Text = ex.Message;
}
VB
' Read the value of digital port 0
Dim MyDevice As DaqDevice
Dim Response As DaqResponse
Dim Devices As String ()
Try
' Get a list of message-based DAQ devices
Devices = DaqDeviceManager.GetDeviceNames(DeviceNameFormat.NameAndSerno)
' Get a DaqDevice object for device 0
MyDevice = DaqDeviceManager.CreateDevice(Devices(0))
' Send device messages
MyDevice.SendMessage("DIO{0}:DIR=IN")
' Read and display the daq response
Response = MyDevice.SendMessage("?DIO{0}:VALUE")
Label1.Text = Response.ToString()
Catch Ex As Exception
' handle error
Label1.Text = Ex.Message
End Try
Seitenansicht 15
1 2 ... 11 12 13 14 15 16 17 18 19 20 21 ... 124 125

Kommentare zu diesen Handbüchern

Keine Kommentare