Visual C# サンプルプログラム
設定と問い合わせのサンプルプログラム(USB)
// VISAのResourceManagerオブジェクトを作成
Ivi.Visa.Interop.ResourceManager rm = new Ivi.Visa.Interop.ResourceManager();
Ivi.Visa.Interop.AccessMode accessMode = Ivi.Visa.Interop.AccessMode.NO_LOCK;
// ファンクションジェネレータの製造番号
string serial = "0123456";
int timeOut = 0;
string optionString = "";
// デバイスと接続(USB)
// WF1973の場合 "USB0::0x0D4A::0x000D::" としてください
// WF1974の場合 "USB0::0x0D4A::0x000E::" としてください
Ivi.Visa.Interop.IMessage msg = (Ivi.Visa.Interop.IMessage)rm.Open(
"USB0::0x0D4A::0x000D::" + serial + "::INSTR",
accessMode,
timeOut,
optionString);
// 周波数を5.0kHzに設定し、その値を問い合わせる
msg.WriteString(":SOUR1:FREQ 5000;:SOUR1:FREQ?\n");
Console.WriteLine(msg.ReadString(256));
// デバイスを閉じる
msg.Close();
設定と問い合わせのサンプルプログラム(GPIB)
// VISAのResourceManagerオブジェクトを作成
Ivi.Visa.Interop.ResourceManager rm = new Ivi.Visa.Interop.ResourceManager();
Ivi.Visa.Interop.AccessMode accessMode = Ivi.Visa.Interop.AccessMode.NO_LOCK;
int timeOut = 0;
string optionString = "";
// デバイスと接続(GPIB address:2)
Ivi.Visa.Interop.IMessage msg = (Ivi.Visa.Interop.IMessage)rm.Open(
"GPIB0::2::INSTR",
accessMode,
timeOut,
optionString);
// オフセット 0.0V、振幅 20.0Vp-p、出力 オンを設定し、振幅の値を問い合わせる
msg.WriteString(":SOUR1:VOLT:OFFS 0V;:SOUR1:VOLT 20VPP;OUTP1 1;:SOUR1:VOLT?\n")
Console.WriteLine(msg.ReadString(256));
// デバイスを閉じる
msg.Close();