public VisaInstrumentApp() { try { myScope = new VisaInstrument("USB0::0x0957::0x17A6::MY52010925::0::INSTR"); myScope.SetTimeoutSeconds(10); // Initialize - start from a known state. Initialize(); // Capture data. Capture(); // Analyze the captured waveform. Analyze(); } catch (System.ApplicationException err) { Console.WriteLine("*** VISA Error Message : " + err.Message); } catch (System.SystemException err) { Console.WriteLine("*** System Error Message : " + err.Message); } catch (System.Exception err) { System.Diagnostics.Debug.Fail("Unexpected Error"); Console.WriteLine("*** Unexpected Error : " + err.Message); } finally { myScope.Close(); } }
private bool InstrScopeImage(int Count, string instruCmd, ref string RdStr) { bool ret = true; string strPath = null, FileName = null; SL_IO_Util IOUtil = new SL_IO_Util(); byte[] ScopeScreenResultsArray; // Screen Results array. int g_ScreenLength; VisaInstrument visaScope = new VisaInstrument(EquipUtil[Count].getInstrName()); //ScopeList.SimpleScopeGraph(devices[1], ":DISPLAY:DATA? PNG, SCREEN, COLOR\r\n"); // Download the screen image. // ----------------------------------------------------------- visaScope.SetTimeoutSeconds(30000); visaScope.DoCommand(":STOP"); visaScope.DoCommand(":HARDcopy:INKSaver OFF"); // Get the screen data. g_ScreenLength = visaScope.DoQueryIEEEBlock(":DISPlay:DATA? PNG, COLor", out ScopeScreenResultsArray); if (instruCmd.CompareTo("auto") == 0) { FileName = "Scope_" + DateTime.Now.ToLocalTime().ToString("yyyyMMdd-HHmmss") + ".png"; } else { FileName = instruCmd; } strPath = Setting.ExeScopeDirPath + "\\" + FileName; if (IOUtil.isFileExist(strPath)) { IOUtil.FileDelete(strPath); } if (IOUtil.GetExtName(strPath).CompareTo("png") != 0) { strPath += ".png"; } FileStream fStream = File.Open(strPath, FileMode.Create); fStream.Write(ScopeScreenResultsArray, 0, g_ScreenLength); fStream.Close(); visaScope.DoCommand(":RUN"); visaScope.Close(); return(ret); }