Programming Manual UTG900E Series
Instruments.uni-trend.com
}
C# Example
Condition: Windows System & Visual Studio.
Description: Access the device through the USBTMC and TCP/IP, and send "*IDN?" command in NI-VISA
to check the device information.
Steps
1. Open the Visual Studio software, and newly create a C# console project.
2. Add the C# reference of VISA, Ivi.Visa.dll and NationalInstruments.Visa.dll.
3. Source Code
a) USBTMC Example
class Program
{
void usbtmc_test()
{
using (var rmSession = new ResourceManager())
{
var resources = rmSession.Find("USB?*INSTR");
foreach (string s in resources)
{
try
{
var mbSession = (MessageBasedSession)rmSession.Open(s);
mbSession.RawIO.Write("*IDN?\n");
System.Console.WriteLine(mbSession.RawIO.ReadString());
}
catch (Exception ex)
{
System.Console.WriteLine(ex.Message);
}
}
}
}
void Main(string[] args)
{
usbtmc_test();
}
}
b) TCP/IP Example
class Program
{
void tcp_ip_test(string ip)
{
using (var rmSession = new ResourceManager())
{