├── README.md ├── Sample ├── Cpp │ ├── stdafx.h │ ├── Sample.cpp │ ├── stdafx.cpp │ ├── targetver.h │ ├── ReadMe.txt │ ├── Sample.vcxproj.filters │ └── InstrumentDemoCpp.vcxproj └── C# │ └── InstrumentDemoCSharp │ ├── Images │ └── logo.jpg │ ├── App.config │ ├── Properties │ ├── Settings.settings │ ├── Settings.Designer.cs │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ └── Resources.resx │ ├── App.xaml.cs │ ├── App.xaml │ ├── InstrumentDemoCSharp.csproj │ └── MainWindow.xaml.cs ├── libs └── Ivi.Visa.Interop.dll ├── InstrumentUtilityDotNet ├── app.config ├── Properties │ ├── Settings.settings │ ├── Settings.Designer.cs │ └── AssemblyInfo.cs ├── PowerMeterManager │ ├── PowerMeter.cs │ ├── IPowerMeter.cs │ └── RS_NRT.cs ├── NetworkAnalyzerManager │ ├── NetworkAnalyzer.cs │ ├── INetworkAnalyzer.cs │ └── RS_ZNB.cs ├── SynthesizeMeterManager │ ├── SynthesizeMeter.cs │ ├── ISynthesizeMeter.cs │ ├── RS_CMA180.cs │ ├── Ceyear_AV4957.cs │ └── Aglient_8920.cs ├── SpectrumAnalyzerManager │ ├── SpectrumAnalyzer.cs │ ├── ISpectrumAnalyzer.cs │ ├── RS_FSU.cs │ ├── Agilent_856x.cs │ └── Ceyear_4024D.cs ├── SignalSourceManager │ ├── SignalSource.cs │ ├── ISignalSource.cs │ ├── Agilent_E4400.cs │ ├── AV1431.cs │ └── HP_8360.cs ├── AddressConversion.cs ├── Enum.cs ├── InstrumentUtilityDotNet.csproj └── InstrumentManager.cs ├── InstrumentUtility ├── InstrumentUtility │ ├── RS_NRT.h │ ├── stdafx.h │ ├── dllmain.cpp │ ├── stdafx.cpp │ ├── targetver.h │ ├── Agilent_856x.h │ ├── Aglient_8920.h │ ├── Agilent_856x.cpp │ ├── Agilent_E4400.h │ ├── Agilent_ESA_E.h │ ├── InstrumentUtility.h │ ├── InstrumentUtility.cpp │ ├── Agilent_ESA_E.cpp │ ├── Aglient_8920.cpp │ ├── RS_NRT.cpp │ ├── Agilent_E4400.cpp │ ├── ReadMe.txt │ └── InstrumentUtility.vcxproj └── Visa │ └── visatype.h ├── InstrumentUtilityDLL.sln └── .gitignore /README.md: -------------------------------------------------------------------------------- 1 | # InstrumentUtility 2 | 仪表通讯管理库,包括频谱仪、信号源、功率计、综测仪等等,SCPI协议 3 | -------------------------------------------------------------------------------- /Sample/Cpp/stdafx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Uhifon/InstrumentUtilityDLL/HEAD/Sample/Cpp/stdafx.h -------------------------------------------------------------------------------- /Sample/Cpp/Sample.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Uhifon/InstrumentUtilityDLL/HEAD/Sample/Cpp/Sample.cpp -------------------------------------------------------------------------------- /Sample/Cpp/stdafx.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Uhifon/InstrumentUtilityDLL/HEAD/Sample/Cpp/stdafx.cpp -------------------------------------------------------------------------------- /Sample/Cpp/targetver.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Uhifon/InstrumentUtilityDLL/HEAD/Sample/Cpp/targetver.h -------------------------------------------------------------------------------- /libs/Ivi.Visa.Interop.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Uhifon/InstrumentUtilityDLL/HEAD/libs/Ivi.Visa.Interop.dll -------------------------------------------------------------------------------- /InstrumentUtilityDotNet/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /InstrumentUtility/InstrumentUtility/RS_NRT.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Uhifon/InstrumentUtilityDLL/HEAD/InstrumentUtility/InstrumentUtility/RS_NRT.h -------------------------------------------------------------------------------- /InstrumentUtility/InstrumentUtility/stdafx.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Uhifon/InstrumentUtilityDLL/HEAD/InstrumentUtility/InstrumentUtility/stdafx.h -------------------------------------------------------------------------------- /InstrumentUtility/InstrumentUtility/dllmain.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Uhifon/InstrumentUtilityDLL/HEAD/InstrumentUtility/InstrumentUtility/dllmain.cpp -------------------------------------------------------------------------------- /InstrumentUtility/InstrumentUtility/stdafx.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Uhifon/InstrumentUtilityDLL/HEAD/InstrumentUtility/InstrumentUtility/stdafx.cpp -------------------------------------------------------------------------------- /InstrumentUtility/InstrumentUtility/targetver.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Uhifon/InstrumentUtilityDLL/HEAD/InstrumentUtility/InstrumentUtility/targetver.h -------------------------------------------------------------------------------- /Sample/C#/InstrumentDemoCSharp/Images/logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Uhifon/InstrumentUtilityDLL/HEAD/Sample/C#/InstrumentDemoCSharp/Images/logo.jpg -------------------------------------------------------------------------------- /InstrumentUtility/InstrumentUtility/Agilent_856x.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Uhifon/InstrumentUtilityDLL/HEAD/InstrumentUtility/InstrumentUtility/Agilent_856x.h -------------------------------------------------------------------------------- /InstrumentUtility/InstrumentUtility/Aglient_8920.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Uhifon/InstrumentUtilityDLL/HEAD/InstrumentUtility/InstrumentUtility/Aglient_8920.h -------------------------------------------------------------------------------- /InstrumentUtility/InstrumentUtility/Agilent_856x.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Uhifon/InstrumentUtilityDLL/HEAD/InstrumentUtility/InstrumentUtility/Agilent_856x.cpp -------------------------------------------------------------------------------- /InstrumentUtility/InstrumentUtility/Agilent_E4400.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Uhifon/InstrumentUtilityDLL/HEAD/InstrumentUtility/InstrumentUtility/Agilent_E4400.h -------------------------------------------------------------------------------- /InstrumentUtility/InstrumentUtility/Agilent_ESA_E.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Uhifon/InstrumentUtilityDLL/HEAD/InstrumentUtility/InstrumentUtility/Agilent_ESA_E.h -------------------------------------------------------------------------------- /InstrumentUtility/InstrumentUtility/InstrumentUtility.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Uhifon/InstrumentUtilityDLL/HEAD/InstrumentUtility/InstrumentUtility/InstrumentUtility.h -------------------------------------------------------------------------------- /InstrumentUtility/InstrumentUtility/InstrumentUtility.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Uhifon/InstrumentUtilityDLL/HEAD/InstrumentUtility/InstrumentUtility/InstrumentUtility.cpp -------------------------------------------------------------------------------- /InstrumentUtility/InstrumentUtility/Agilent_ESA_E.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "Agilent_ESA_E.h" 3 | 4 | 5 | Agilent_ESA_E::Agilent_ESA_E() 6 | { 7 | } 8 | 9 | 10 | Agilent_ESA_E::~Agilent_ESA_E() 11 | { 12 | } 13 | -------------------------------------------------------------------------------- /Sample/C#/InstrumentDemoCSharp/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Sample/C#/InstrumentDemoCSharp/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /InstrumentUtilityDotNet/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Sample/C#/InstrumentDemoCSharp/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Configuration; 4 | using System.Data; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | 9 | namespace InstrumentDemoCsharp 10 | { 11 | /// 12 | /// App.xaml 的交互逻辑 13 | /// 14 | public partial class App : Application 15 | { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Sample/C#/InstrumentDemoCSharp/App.xaml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /InstrumentUtility/InstrumentUtility/Aglient_8920.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "Aglient_8920.h" 3 | 4 | 5 | Aglient_8920::Aglient_8920() 6 | { 7 | } 8 | 9 | 10 | Aglient_8920::~Aglient_8920() 11 | { 12 | } 13 | 14 | char * Aglient_8920::GetID() 15 | { 16 | return nullptr; 17 | } 18 | 19 | bool Aglient_8920::Reset() 20 | { 21 | return false; 22 | } 23 | 24 | bool Aglient_8920::SetCenterFreq(FrequencyUnit unit, double value) 25 | { 26 | return false; 27 | } 28 | 29 | bool Aglient_8920::SetRefLevel(double value) 30 | { 31 | return false; 32 | } 33 | 34 | double Aglient_8920::GetCenterFreq() 35 | { 36 | return 0.0; 37 | } 38 | 39 | bool Aglient_8920::SetAfgState(bool onOff) 40 | { 41 | return false; 42 | } 43 | -------------------------------------------------------------------------------- /InstrumentUtility/InstrumentUtility/RS_NRT.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "RS_NRT.h" 3 | 4 | 5 | RS_NRT::RS_NRT() 6 | { 7 | } 8 | 9 | 10 | RS_NRT::~RS_NRT() 11 | { 12 | } 13 | 14 | char * RS_NRT::GetID() 15 | { 16 | char* sendMsg = "*IDN ?;"; 17 | char* recvMsg = ""; 18 | try 19 | { 20 | bool res = WriteAndReadString(sendMsg, recvMsg); 21 | 22 | return recvMsg; 23 | } 24 | catch (char *str) 25 | { 26 | throw(str); 27 | } 28 | return nullptr; 29 | } 30 | 31 | bool RS_NRT::Reset() 32 | { 33 | char* sendMsg = "IP;"; 34 | try 35 | { 36 | WriteString(sendMsg); 37 | return true; 38 | } 39 | catch (char *str) 40 | { 41 | throw(str); 42 | } 43 | return false; 44 | } 45 | 46 | bool RS_NRT::PowerUnitChange(PowerUnit unit) 47 | { 48 | return false; 49 | } 50 | 51 | bool RS_NRT::GetPower(int sensorNum, double* avg, double* swr) 52 | { 53 | return false; 54 | } 55 | 56 | 57 | -------------------------------------------------------------------------------- /InstrumentUtilityDotNet/PowerMeterManager/PowerMeter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace InstrumentUtilityDotNet.PowerMeterManager 8 | { 9 | public class PowerMeter 10 | { 11 | internal PowerMeter() 12 | { 13 | 14 | } 15 | 16 | /// 17 | /// 获取对象实例 18 | /// 19 | /// 仪表型号 20 | /// 21 | public static IPowerMeter GetInstance(PowerMeterType powerMeterType) 22 | { 23 | 24 | switch(powerMeterType) 25 | { 26 | case PowerMeterType.RS_NRT: 27 | return new RS_NRT(); 28 | default: 29 | return null; 30 | } 31 | 32 | } 33 | 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Sample/Cpp/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | 控制台应用程序:Sample 项目概述 3 | ======================================================================== 4 | 5 | 应用程序向导已为您创建了此 Sample 应用程序。 6 | 7 | 本文件概要介绍组成 Sample 应用程序的每个文件的内容。 8 | 9 | 10 | Sample.vcxproj 11 | 这是使用应用程序向导生成的 VC++ 项目的主项目文件,其中包含生成该文件的 Visual C++ 的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。 12 | 13 | Sample.vcxproj.filters 14 | 这是使用“应用程序向导”生成的 VC++ 项目筛选器文件。它包含有关项目文件与筛选器之间的关联信息。在 IDE 中,通过这种关联,在特定节点下以分组形式显示具有相似扩展名的文件。例如,“.cpp”文件与“源文件”筛选器关联。 15 | 16 | Sample.cpp 17 | 这是主应用程序源文件。 18 | 19 | ///////////////////////////////////////////////////////////////////////////// 20 | 其他标准文件: 21 | 22 | StdAfx.h, StdAfx.cpp 23 | 这些文件用于生成名为 Sample.pch 的预编译头 (PCH) 文件和名为 StdAfx.obj 的预编译类型文件。 24 | 25 | ///////////////////////////////////////////////////////////////////////////// 26 | 其他注释: 27 | 28 | 应用程序向导使用“TODO:”注释来指示应添加或自定义的源代码部分。 29 | 30 | ///////////////////////////////////////////////////////////////////////////// 31 | -------------------------------------------------------------------------------- /InstrumentUtility/InstrumentUtility/Agilent_E4400.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "stdafx.h" 3 | #include "Agilent_E4400.h" 4 | 5 | 6 | Agilent_E4400::Agilent_E4400() 7 | { 8 | 9 | } 10 | 11 | Agilent_E4400::~Agilent_E4400() 12 | { 13 | 14 | } 15 | 16 | char * Agilent_E4400::GetID() 17 | { 18 | 19 | return nullptr; 20 | } 21 | 22 | bool Agilent_E4400::Reset() 23 | { 24 | return false; 25 | } 26 | 27 | bool Agilent_E4400::SetSignalSourceState(bool state) 28 | { 29 | return false; 30 | } 31 | 32 | bool Agilent_E4400::SetFreqAndLevel(FrequencyUnit unit, double freq, double level) 33 | { 34 | return false; 35 | } 36 | 37 | bool Agilent_E4400::SetFreq(FrequencyUnit unit, double freq) 38 | { 39 | return false; 40 | } 41 | 42 | bool Agilent_E4400::SetLevel(double level) 43 | { 44 | return false; 45 | } 46 | 47 | bool Agilent_E4400::SetPulse(bool onOff) 48 | { 49 | return false; 50 | } 51 | 52 | bool Agilent_E4400::SetPulseWidth(double width) 53 | { 54 | return false; 55 | } 56 | 57 | bool Agilent_E4400::SetPulsePeriod(double period) 58 | { 59 | return false; 60 | } 61 | 62 | 63 | -------------------------------------------------------------------------------- /InstrumentUtilityDotNet/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 此代码由工具生成。 4 | // 运行时版本:4.0.30319.42000 5 | // 6 | // 对此文件的更改可能会导致不正确的行为,并且如果 7 | // 重新生成代码,这些更改将会丢失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace InstrumentSCPILib.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")] 16 | public sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Sample/C#/InstrumentDemoCSharp/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 此代码由工具生成。 4 | // 运行时版本:4.0.30319.42000 5 | // 6 | // 对此文件的更改可能会导致不正确的行为,并且如果 7 | // 重新生成代码,这些更改将会丢失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace InstrumentDemoCsharp.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.3.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /InstrumentUtilityDotNet/NetworkAnalyzerManager/NetworkAnalyzer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace InstrumentUtilityDotNet.NetworkAnalyzerManager 7 | { 8 | public class NetworkAnalyzer 9 | { 10 | 11 | internal NetworkAnalyzer() 12 | { 13 | 14 | } 15 | /// 16 | ///获取对象实例 17 | /// 18 | /// 仪表型号 19 | /// 20 | public static INetworkAnalyzer GetInstance(NetworkAnalyzerType networkAnalyzerType) 21 | { 22 | switch (networkAnalyzerType) 23 | { 24 | case NetworkAnalyzerType.RS_ZNB: 25 | return new RS_ZNB(); 26 | case NetworkAnalyzerType.Aglient_E5071C: 27 | return new RS_ZNB(); 28 | case NetworkAnalyzerType.Aglient_E506X: 29 | return new RS_ZNB(); 30 | default: 31 | return null; 32 | 33 | } 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /InstrumentUtilityDotNet/SynthesizeMeterManager/SynthesizeMeter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace InstrumentUtilityDotNet.SynthesizeMeterManager 8 | { 9 | public class SynthesizeMeter 10 | { 11 | 12 | internal SynthesizeMeter() 13 | { 14 | 15 | } 16 | 17 | /// 18 | /// 获取对象实例 19 | /// 20 | /// 仪表型号 21 | /// 22 | public static ISynthesizeMeter GetInstance(SynthesizeMeterType synthesizeMeterType) 23 | { 24 | switch (synthesizeMeterType) 25 | { 26 | case SynthesizeMeterType.Aglient_8920: 27 | return new Aglient_8920(); 28 | case SynthesizeMeterType.Ceyear_AV4957: 29 | return new Ceyear_AV4957(); 30 | case SynthesizeMeterType.RS_CMA180: 31 | return new RS_CMA180(); 32 | default: 33 | return null; 34 | } 35 | } 36 | 37 | 38 | 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /InstrumentUtilityDotNet/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 有关程序集的一般信息由以下 6 | // 控制。更改这些特性值可修改 7 | // 与程序集关联的信息。 8 | [assembly: AssemblyTitle("InstrumentUtilityDotNet")] 9 | [assembly: AssemblyDescription("2019.12.4")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("武汉玉航科技有限公司")] 12 | [assembly: AssemblyProduct("InstrumentUtilityDotNet")] 13 | [assembly: AssemblyCopyright("WuHanYuHang Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // 将 ComVisible 设置为 false 会使此程序集中的类型 18 | //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 19 | //请将此类型的 ComVisible 特性设置为 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID 23 | [assembly: Guid("ab33c645-cc98-4ab0-ab96-fc0c29e924e4")] 24 | 25 | // 程序集的版本信息由下列四个值组成: 26 | // 27 | // 主版本 28 | // 次版本 29 | // 生成号 30 | // 修订号 31 | // 32 | // 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号 33 | //通过使用 "*",如下所示: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("2.0.0.0")] 36 | [assembly: AssemblyFileVersion("2.0.0.0")] 37 | -------------------------------------------------------------------------------- /InstrumentUtility/InstrumentUtility/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | 动态链接库:InstrmentControl 项目概述 3 | ======================================================================== 4 | 5 | 应用程序向导已为您创建了此 InstrmentControl DLL。 6 | 7 | 本文件概要介绍组成 InstrmentControl 应用程序的每个文件的内容。 8 | 9 | 10 | InstrmentControl.vcxproj 11 | 这是使用应用程序向导生成的 VC++ 项目的主项目文件,其中包含生成该文件的 Visual C++ 的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。 12 | 13 | InstrmentControl.vcxproj.filters 14 | 这是使用“应用程序向导”生成的 VC++ 项目筛选器文件。它包含有关项目文件与筛选器之间的关联信息。在 IDE 中,通过这种关联,在特定节点下以分组形式显示具有相似扩展名的文件。例如,“.cpp”文件与“源文件”筛选器关联。 15 | 16 | InstrmentControl.cpp 17 | 这是主 DLL 源文件。 18 | 19 | 此 DLL 在创建时不导出任何符号。因此,生成时不会产生 .lib 文件。如果希望此项目成为其他某个项目的项目依赖项,则需要添加代码以从 DLL 导出某些符号,以便产生一个导出库,或者,也可以在项目“属性页”对话框中的“链接器”文件夹中,将“常规”属性页上的“忽略输入库”属性设置为“是”。 20 | 21 | ///////////////////////////////////////////////////////////////////////////// 22 | 其他标准文件: 23 | 24 | StdAfx.h, StdAfx.cpp 25 | 这些文件用于生成名为 InstrmentControl.pch 的预编译头 (PCH) 文件和名为 StdAfx.obj 的预编译类型文件。 26 | 27 | ///////////////////////////////////////////////////////////////////////////// 28 | 其他注释: 29 | 30 | 应用程序向导使用“TODO:”注释来指示应添加或自定义的源代码部分。 31 | 32 | ///////////////////////////////////////////////////////////////////////////// 33 | -------------------------------------------------------------------------------- /Sample/Cpp/Sample.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 头文件 23 | 24 | 25 | 头文件 26 | 27 | 28 | 29 | 30 | 源文件 31 | 32 | 33 | 源文件 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /InstrumentUtilityDotNet/SpectrumAnalyzerManager/SpectrumAnalyzer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace InstrumentUtilityDotNet.SpectrumAnalyzerManager 8 | { 9 | 10 | /// 11 | /// SpectrumAnalyzer 12 | /// 13 | public class SpectrumAnalyzer 14 | { 15 | internal SpectrumAnalyzer() 16 | { 17 | 18 | } 19 | 20 | /// 21 | /// 获取对象实例 22 | /// 23 | /// 仪表型号 24 | /// 25 | public static ISpectrumAnalyzer GetInstance(SpectrumAnalyzerType spectrumAnalyzerType) 26 | { 27 | switch (spectrumAnalyzerType) 28 | { 29 | case SpectrumAnalyzerType.Agilent_856X: 30 | return new Agilent_856x(); 31 | case SpectrumAnalyzerType.Agilent_ESA_E: 32 | return new RS_FSU(); 33 | case SpectrumAnalyzerType.Agilent_E4407B: 34 | return new RS_FSU(); 35 | case SpectrumAnalyzerType.RS_FSU: 36 | return new RS_FSU(); 37 | case SpectrumAnalyzerType.RS_FSW: 38 | return new RS_FSU(); 39 | case SpectrumAnalyzerType.Ceyear_4024D_403X: 40 | return new Ceyear_4024D(); 41 | default: 42 | return null; 43 | } 44 | 45 | } 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /InstrumentUtilityDotNet/SignalSourceManager/SignalSource.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace InstrumentUtilityDotNet.SignalSourceManager 8 | { 9 | /// 10 | /// SpectrumAnalyzer 11 | /// 12 | public class SignalSource 13 | { 14 | internal SignalSource() 15 | { 16 | 17 | } 18 | 19 | /// 20 | /// 获取对象实例 21 | /// 22 | /// 仪表ID 型号 23 | /// 24 | public static ISignalSource GetInstance(SignalSourceType signalSourceType) 25 | { 26 | switch(signalSourceType) 27 | { 28 | case SignalSourceType.Agilent_E4400: 29 | return new Agilent_E4400(); 30 | case SignalSourceType.HP_8360: 31 | return new HP_8360(); 32 | case SignalSourceType.RS_SMHU: 33 | return new HP_8360(); 34 | case SignalSourceType.RS_SMA100A: 35 | return new HP_8360(); 36 | case SignalSourceType.RS_SMBV100A: 37 | return new HP_8360(); 38 | case SignalSourceType.Ceyear_AV1431: 39 | return new AV1431(); 40 | case SignalSourceType.Ceyear_AV146X: 41 | return new AV1431(); 42 | case SignalSourceType.RS_SMB100B: 43 | return new HP_8360(); 44 | default: 45 | return null; 46 | } 47 | } 48 | 49 | 50 | 51 | 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Sample/C#/InstrumentDemoCSharp/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Resources; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | using System.Windows; 6 | 7 | // 有关程序集的一般信息由以下 8 | // 控制。更改这些特性值可修改 9 | // 与程序集关联的信息。 10 | [assembly: AssemblyTitle("InstrumentDemoCsharp")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyConfiguration("")] 13 | [assembly: AssemblyCompany("")] 14 | [assembly: AssemblyProduct("InstrumentDemoCsharp")] 15 | [assembly: AssemblyCopyright("Copyright © 2019")] 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | 19 | // 将 ComVisible 设置为 false 会使此程序集中的类型 20 | //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 21 | //请将此类型的 ComVisible 特性设置为 true。 22 | [assembly: ComVisible(false)] 23 | 24 | //若要开始生成可本地化的应用程序,请设置 25 | //.csproj 文件中的 CultureYouAreCodingWith 26 | //例如,如果您在源文件中使用的是美国英语, 27 | //使用的是美国英语,请将 设置为 en-US。 然后取消 28 | //对以下 NeutralResourceLanguage 特性的注释。 更新 29 | //以下行中的“en-US”以匹配项目文件中的 UICulture 设置。 30 | 31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] 32 | 33 | 34 | [assembly: ThemeInfo( 35 | ResourceDictionaryLocation.None, //主题特定资源词典所处位置 36 | //(未在页面中找到资源时使用, 37 | //或应用程序资源字典中找到时使用) 38 | ResourceDictionaryLocation.SourceAssembly //常规资源词典所处位置 39 | //(未在页面中找到资源时使用, 40 | //、应用程序或任何主题专用资源字典中找到时使用) 41 | )] 42 | 43 | 44 | // 程序集的版本信息由下列四个值组成: 45 | // 46 | // 主版本 47 | // 次版本 48 | // 生成号 49 | // 修订号 50 | // 51 | // 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号 52 | // 方法是按如下所示使用“*”: : 53 | // [assembly: AssemblyVersion("1.0.*")] 54 | [assembly: AssemblyVersion("1.0.0.0")] 55 | [assembly: AssemblyFileVersion("1.0.0.0")] 56 | -------------------------------------------------------------------------------- /InstrumentUtilityDotNet/PowerMeterManager/IPowerMeter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace InstrumentUtilityDotNet.PowerMeterManager 7 | { 8 | public abstract class IPowerMeter: InstrumentManager 9 | { 10 | /// 11 | /// 连接仪表 12 | /// 13 | /// 14 | /// 15 | public bool Connect(string address) 16 | { 17 | return base.Open(address); 18 | } 19 | 20 | /// 21 | /// 断开连接 22 | /// 23 | public void DisConnect() 24 | { 25 | base.Close(); 26 | } 27 | /// 28 | /// Write 29 | /// 30 | /// 31 | public void WriteCommand(string command) 32 | { 33 | base.WriteString(command); 34 | } 35 | 36 | /// 37 | /// WriteAndRead 38 | /// 39 | /// 40 | /// 41 | public string WriteAndReadCommand(string command) 42 | { 43 | return base.WriteAndReadString(command); 44 | } 45 | /// 46 | /// 获取设备ID号 47 | /// 48 | public abstract string GetID(); 49 | 50 | /// 51 | /// 初始化仪表参数 52 | /// 53 | /// 54 | public abstract bool Reset(); 55 | 56 | /// 57 | /// 单位切换 58 | /// 59 | /// DBM,W 60 | public abstract bool PowerUnitChange(PowerUnit unit); 61 | 62 | 63 | /// 64 | /// 获取功率计DATA 功率AVG与驻波比SWR 功率计 65 | /// 66 | /// 传感器编号0-2 67 | /// 功率 68 | /// 驻波比 69 | /// 70 | public abstract bool GetPower(int sensorNum, out double avg, out double swr); 71 | 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /InstrumentUtilityDotNet/AddressConversion.cs: -------------------------------------------------------------------------------- 1 | using InstrumentUtilityDotNet.SynthesizeMeterManager; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace InstrumentUtilityDotNet 9 | { 10 | /// 11 | /// 地址转换 12 | /// 13 | public class AddressConversion 14 | { 15 | 16 | /// 17 | /// VISA地址转GPIB 18 | /// 19 | /// GPIB0::18::INSTR 20 | /// 21 | public static string[] VisaAddrToGPIB(string addr) 22 | { 23 | string[] Res = new string[2]; 24 | string[] arr = addr.Split(':'); 25 | if (arr != null && arr.Length == 5) 26 | { 27 | Res[0] = arr[0]; 28 | Res[1] = arr[2]; 29 | } 30 | return Res; 31 | } 32 | 33 | /// 34 | /// VISA地址转IP 35 | /// 36 | /// TCPIP0::192.168.0.10::8000::SOCKET 37 | /// 38 | public static string[] VisaAddrToIP(string addr) 39 | { 40 | string[] Res = new string[2]; 41 | string[] arr = addr.Split(':'); 42 | if (arr != null && arr.Length == 7) 43 | { 44 | Res[0] = arr[2]; 45 | Res[1] = arr[4]; 46 | } 47 | return Res; 48 | } 49 | 50 | /// 51 | /// GPIB地址转VISA格式 52 | /// 、 53 | /// 0 54 | /// 18 55 | /// 56 | public static string GPIBToVisaAddr(string id, string addr) 57 | { 58 | return id + "::" + addr + "::INSTR"; 59 | } 60 | 61 | /// 62 | /// TCPIP地址转VISA格式 63 | /// 、 64 | /// 0 65 | /// 18 66 | /// 67 | public static string TCPToVisaAddr(string ip, string port) 68 | { 69 | return "TCPIP0::" + ip + "::" + port + "::SOCKET"; 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /InstrumentUtilityDotNet/SynthesizeMeterManager/ISynthesizeMeter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace InstrumentUtilityDotNet.SynthesizeMeterManager 7 | { 8 | public abstract class ISynthesizeMeter: InstrumentManager 9 | { 10 | /// 11 | /// 连接仪表 12 | /// 13 | /// 14 | /// 15 | public bool Connect(string address) 16 | { 17 | return base.Open(address); 18 | } 19 | 20 | /// 21 | /// 断开连接 22 | /// 23 | public void DisConnect() 24 | { 25 | base.Close(); 26 | } 27 | 28 | /// 29 | /// Write 30 | /// 31 | /// 32 | public void WriteCommand(string command) 33 | { 34 | base.WriteString(command); 35 | } 36 | 37 | /// 38 | /// WriteAndRead 39 | /// 40 | /// 41 | /// 42 | public string WriteAndReadCommand(string command) 43 | { 44 | return base.WriteAndReadString(command); 45 | } 46 | 47 | /// 48 | /// 获取设备ID号 49 | /// 50 | public abstract string GetID(); 51 | 52 | /// 53 | /// 初始化仪表参数 54 | /// 55 | /// 56 | public abstract bool Reset(); 57 | 58 | /// 59 | /// 设置中心频率 60 | /// 61 | /// 频率 62 | /// 频率单位 63 | /// 64 | public abstract bool SetCenterFreq(double value, FrequencyUnit unit); 65 | 66 | /// 67 | /// 设置参考电平 幅度标尺 68 | /// 69 | /// 参考电平 单位dbm 70 | /// 71 | public abstract bool SetRefLevel(double value); 72 | 73 | 74 | /// 75 | /// 获取中心频率 76 | /// 77 | /// 78 | public abstract double GetCenterFreq(); 79 | 80 | /// 81 | /// 设置解调开关。 82 | /// 83 | /// 解调开关 84 | /// 85 | public abstract bool SetAfgState(bool onOff); 86 | 87 | 88 | 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /Sample/C#/InstrumentDemoCSharp/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 此代码由工具生成。 4 | // 运行时版本:4.0.30319.42000 5 | // 6 | // 对此文件的更改可能会导致不正确的行为,并且如果 7 | // 重新生成代码,这些更改将会丢失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace InstrumentDemoCsharp.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// 一个强类型的资源类,用于查找本地化的字符串等。 17 | /// 18 | // 此类是由 StronglyTypedResourceBuilder 19 | // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 20 | // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen 21 | // (以 /str 作为命令选项),或重新生成 VS 项目。 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// 返回此类使用的缓存的 ResourceManager 实例。 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("InstrumentDemoCsharp.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// 重写当前线程的 CurrentUICulture 属性 51 | /// 重写当前线程的 CurrentUICulture 属性。 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /InstrumentUtilityDotNet/Enum.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace InstrumentUtilityDotNet 8 | { 9 | #region 枚举 10 | /// 11 | /// 仪表连接方式 12 | /// 13 | public enum InstrumentCommunicationMode 14 | { 15 | GPIB, 16 | TCP, 17 | Serial 18 | } 19 | /// 20 | /// 频率单位 21 | /// 22 | public enum FrequencyUnit 23 | { 24 | Hz, 25 | KHz, 26 | MHz, 27 | GHz 28 | } 29 | 30 | /// 31 | /// 功率单位 32 | /// 33 | public enum PowerUnit 34 | { 35 | DBM, 36 | W 37 | } 38 | 39 | /// 40 | /// 仪表类型 41 | /// 42 | public enum InstrumentType 43 | { 44 | /// 45 | /// 频谱分析仪 46 | /// 47 | SpectrumAnalyzer, 48 | /// 49 | /// 信号源 50 | /// 51 | SignalSource, 52 | /// 53 | /// 功率计 54 | /// 55 | PowerMeter, 56 | /// 57 | /// 综测仪 58 | /// 59 | SynthesizeMeter, 60 | /// 61 | /// 网络分析仪 62 | /// 63 | NetworkAnalyzer 64 | 65 | } 66 | 67 | /// 68 | /// 频谱仪型号 69 | /// 70 | public enum SpectrumAnalyzerType 71 | { 72 | Agilent_856X, 73 | Agilent_ESA_E, 74 | Agilent_E4407B, 75 | RS_FSU, 76 | RS_FSW, 77 | Ceyear_4024D_403X 78 | } 79 | 80 | /// 81 | /// 信号源型号 82 | /// 83 | public enum SignalSourceType 84 | { 85 | Agilent_E4400, 86 | HP_8360, 87 | RS_SMHU, 88 | RS_SMA100A, 89 | RS_SMBV100A, 90 | Ceyear_AV1431, 91 | Ceyear_AV146X, 92 | RS_SMB100B, 93 | } 94 | 95 | /// 96 | /// 功率计型号 97 | /// 98 | public enum PowerMeterType 99 | { 100 | RS_NRT 101 | } 102 | 103 | /// 104 | /// 综测仪型号 105 | /// 106 | public enum SynthesizeMeterType 107 | { 108 | Aglient_8920, 109 | Ceyear_AV4957, 110 | RS_CMA180 111 | } 112 | 113 | 114 | /// 115 | /// 网络分析仪型号 116 | /// 117 | public enum NetworkAnalyzerType 118 | { 119 | RS_ZNB, 120 | Aglient_E5071C, 121 | Aglient_E506X 122 | } 123 | 124 | #endregion 125 | 126 | } 127 | -------------------------------------------------------------------------------- /InstrumentUtilityDotNet/PowerMeterManager/RS_NRT.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace InstrumentUtilityDotNet.PowerMeterManager 8 | { 9 | public class RS_NRT : IPowerMeter 10 | { 11 | 12 | /// 13 | /// 获取设备ID号 14 | /// 15 | public override string GetID() 16 | { 17 | string sendMsg = "*IDN?"; 18 | try 19 | { 20 | return base.WriteAndReadString(sendMsg); 21 | } 22 | catch (Exception ex) 23 | { 24 | throw (ex); 25 | } 26 | } 27 | 28 | /// 29 | /// 初始化仪表参数 30 | /// 31 | /// 32 | public override bool Reset() 33 | { 34 | string sendMsg = "IP;"; 35 | try 36 | { 37 | return base.WriteString(sendMsg); 38 | return true; 39 | } 40 | catch (Exception ex) 41 | { 42 | throw (ex); 43 | } 44 | } 45 | 46 | /// 47 | /// 单位切换 48 | /// 49 | /// DBM,W 50 | public override bool PowerUnitChange(PowerUnit unit) 51 | { 52 | string sendMsg = ":UNIT0:POW " + unit.ToString(); 53 | try 54 | { 55 | return base.WriteString(sendMsg); 56 | return true; 57 | } 58 | catch (Exception ex) 59 | { 60 | throw (ex); 61 | } 62 | } 63 | 64 | /// 65 | /// 获取功率计DATA 功率AVG与驻波比SWR 功率计 66 | /// 67 | /// 传感器编号0-2 68 | /// 功率 69 | /// 驻波比 70 | /// 71 | public override bool GetPower(int sensorNum, out double avg, out double swr) 72 | { 73 | avg = 0; 74 | swr = 0; 75 | string sendMsg = String.Format(":TRIG;*WAI;:SENS{0}:DATA?", sensorNum); 76 | try 77 | { 78 | string recvStr = base.WriteAndReadString(sendMsg); 79 | string[] data = recvStr.Split(','); 80 | avg = Math.Round(Convert.ToDouble(data[0]), 2); 81 | swr = Math.Round(Convert.ToDouble(data[1]), 2); 82 | return true; 83 | } 84 | catch (Exception ex) 85 | { 86 | avg = 0; 87 | swr = 0; 88 | throw (ex); 89 | } 90 | 91 | } 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /InstrumentUtilityDotNet/SignalSourceManager/ISignalSource.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace InstrumentUtilityDotNet.SignalSourceManager 7 | { 8 | public abstract class ISignalSource: InstrumentManager 9 | { 10 | /// 11 | /// 连接仪表 12 | /// 13 | /// 14 | /// 15 | public bool Connect(string address) 16 | { 17 | return base.Open(address); 18 | } 19 | 20 | /// 21 | /// 断开连接 22 | /// 23 | public void DisConnect() 24 | { 25 | base.Close(); 26 | } 27 | /// 28 | /// Write 29 | /// 30 | /// 31 | public void WriteCommand(string command) 32 | { 33 | base.WriteString(command); 34 | } 35 | 36 | /// 37 | /// WriteAndRead 38 | /// 39 | /// 40 | /// 41 | public string WriteAndReadCommand(string command) 42 | { 43 | return base.WriteAndReadString(command); 44 | } 45 | /// 46 | /// 获取设备ID号 47 | /// 48 | public abstract string GetID(); 49 | 50 | /// 51 | /// 初始化仪表参数 52 | /// 53 | /// 54 | public abstract bool Reset(); 55 | /// 56 | /// 信号源发射开关 57 | /// 58 | /// On:打开发射 Off:关闭发射 59 | /// 60 | public abstract bool SetSignalSourceState(bool state); 61 | 62 | /// 63 | /// 设置频率、功率 64 | /// 65 | /// 频率单位 66 | /// 频率 67 | /// 功率,单位DBM 68 | /// 69 | public abstract bool SetFreqAndLevel(FrequencyUnit unit, double freq, double level); 70 | /// 71 | /// 设置频率 72 | /// 73 | /// 频率单位 74 | /// 频率 75 | /// 76 | public abstract bool SetFreq(FrequencyUnit unit, double freq); 77 | /// 78 | /// 设置功率 79 | /// 80 | /// 功率 81 | /// 82 | public abstract bool SetLevel(double level); 83 | 84 | /// 85 | /// 打开脉冲开关 86 | /// 87 | /// 88 | /// 89 | public abstract bool SetPulseSwitch(bool onOff); 90 | 91 | /// 92 | /// 设置脉冲带宽 93 | /// 94 | /// 带宽 us 95 | /// 96 | public abstract bool SetPulseWidth(double width); 97 | 98 | 99 | /// 100 | /// 设置脉冲周期 101 | /// 102 | /// 周期 us 103 | /// 104 | public abstract bool SetPulsePeriod(double period); 105 | 106 | /// 107 | /// 设置调制开关 108 | /// 109 | /// 110 | /// 111 | public abstract bool SetModulationSwitch(bool state); 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /InstrumentUtilityDotNet/SpectrumAnalyzerManager/ISpectrumAnalyzer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace InstrumentUtilityDotNet.SpectrumAnalyzerManager 7 | { 8 | public abstract class ISpectrumAnalyzer: InstrumentManager 9 | { 10 | /// 11 | /// 连接仪表 12 | /// 13 | /// 14 | /// 15 | public bool Connect(string address) 16 | { 17 | return base.Open(address); 18 | } 19 | 20 | /// 21 | /// 断开连接 22 | /// 23 | public void DisConnect() 24 | { 25 | base.Close(); 26 | } 27 | /// 28 | /// Write 29 | /// 30 | /// 31 | public void WriteCommand(string command) 32 | { 33 | base.WriteString(command); 34 | } 35 | 36 | /// 37 | /// WriteAndRead 38 | /// 39 | /// 40 | /// 41 | public string WriteAndReadCommand(string command) 42 | { 43 | return base.WriteAndReadString(command); 44 | } 45 | /// 46 | /// 获取设备ID号 47 | /// 48 | public abstract string GetID(); 49 | 50 | /// 51 | /// 初始化仪表参数 52 | /// 53 | /// 54 | public abstract bool Reset(); 55 | 56 | /// 57 | /// 获取中心频率 58 | /// 59 | /// 60 | public abstract double GetCenterFreq(); 61 | 62 | /// 63 | /// 获取MKA 峰值电平 64 | /// 65 | /// 66 | public abstract double GetMKA(); 67 | 68 | /// 设置中心频率 69 | /// 70 | /// 值 71 | /// 频率单位 72 | /// 73 | public abstract bool SetCenterFreq(double value, FrequencyUnit unit); 74 | 75 | 76 | /// 77 | /// 设置自动/手动 RBW 78 | /// 79 | /// 自动/手动RBW 80 | /// 分辨率带宽,单位KHz 81 | /// 82 | public abstract bool SetRBW(bool isAuto, double value); 83 | /// 84 | /// 设置参考电平 85 | /// 86 | /// 参考电平,单位dBm 87 | /// 88 | public abstract bool SetRefLevel(double value); 89 | 90 | /// 91 | /// 激活标记并搜索峰值 92 | /// 93 | /// 94 | public abstract bool MarkPeak(); 95 | 96 | /// 97 | /// 设置衰减值 98 | /// 99 | /// 自动/手动衰减 100 | /// 衰减值 单位DB 101 | /// 102 | public abstract bool SetAttenuation(bool isAuto,double value); 103 | 104 | 105 | /// 106 | /// 设置SPAN 107 | /// 108 | /// 带宽 109 | /// 单位 110 | /// 111 | public abstract bool SetSpan(double value, FrequencyUnit unit); 112 | 113 | 114 | /// 115 | /// 线损 参考电平 补偿值 116 | /// 117 | /// 118 | /// 119 | public abstract bool SetRefOffset(double value); 120 | 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /InstrumentUtilityDotNet/SynthesizeMeterManager/RS_CMA180.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace InstrumentUtilityDotNet.SynthesizeMeterManager 8 | { 9 | public class RS_CMA180 :ISynthesizeMeter 10 | { 11 | 12 | /// 13 | /// 获取设备ID号 14 | /// 15 | public override string GetID() 16 | { 17 | string sendMsg = "*IDN?"; 18 | try 19 | { 20 | return base.WriteAndReadString(sendMsg); 21 | } 22 | catch (Exception ex) 23 | { 24 | throw(ex); 25 | } 26 | } 27 | 28 | /// 29 | /// 初始化仪表参数 30 | /// 31 | /// 32 | public override bool Reset() 33 | { 34 | string sendMsg = "*RST"; 35 | try 36 | { 37 | return base.WriteString(sendMsg); 38 | } 39 | catch (Exception ex) 40 | { 41 | throw (ex); 42 | } 43 | } 44 | /// 45 | /// 设置中心频率 46 | /// 47 | /// 频率 48 | /// 频率单位 49 | /// 50 | public override bool SetCenterFreq(double value, FrequencyUnit unit) 51 | { 52 | 53 | string sendMsg = "RFG: FREQ "; 54 | switch (unit) 55 | { 56 | case FrequencyUnit.Hz: 57 | sendMsg += "Hz;"; 58 | break; 59 | case FrequencyUnit.KHz: 60 | sendMsg += "KHz;"; 61 | break; 62 | case FrequencyUnit.MHz: 63 | sendMsg += "MHz;"; 64 | break; 65 | case FrequencyUnit.GHz: 66 | sendMsg += "GHz;"; 67 | break; 68 | } 69 | try 70 | { 71 | return base.WriteString(sendMsg); 72 | } 73 | catch (Exception ex) 74 | { 75 | throw (ex); 76 | } 77 | } 78 | 79 | /// 80 | /// 设置参考电平 幅度标尺 81 | /// 82 | /// 参考电平 单位dbm 83 | /// 84 | public override bool SetRefLevel(double value) 85 | { 86 | string sendMsg = "RFG:AMPL " + value + "DBM;"; 87 | try 88 | { 89 | return base.WriteString(sendMsg); 90 | } 91 | catch (Exception ex) 92 | { 93 | throw (ex); 94 | } 95 | } 96 | 97 | 98 | 99 | /// 100 | /// 获取中心频率 101 | /// 102 | /// 103 | public override double GetCenterFreq() 104 | { 105 | string sendMsg = "MEAS: AFR: FREQ ?;"; 106 | try 107 | { 108 | string recvMsg = base.WriteAndReadString(sendMsg); 109 | return Convert.ToDouble(recvMsg); 110 | } 111 | catch (Exception ex) 112 | { 113 | throw (ex); 114 | } 115 | } 116 | 117 | 118 | /// 119 | /// 设置解调开关 120 | /// 121 | /// 设置解调开关 122 | /// 123 | public override bool SetAfgState(bool onOff) 124 | { 125 | string sendMsg = null; 126 | if (!onOff) 127 | sendMsg = "AFG1:FM:STAT OFF"; 128 | else 129 | sendMsg = "AFG1:FM:STAT ON"; 130 | try 131 | { 132 | return base.WriteString(sendMsg); 133 | } 134 | catch (Exception ex) 135 | { 136 | throw (ex); 137 | } 138 | } 139 | 140 | 141 | 142 | 143 | } 144 | 145 | } 146 | -------------------------------------------------------------------------------- /InstrumentUtilityDotNet/SynthesizeMeterManager/Ceyear_AV4957.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace InstrumentUtilityDotNet.SynthesizeMeterManager 8 | { 9 | public class Ceyear_AV4957 : ISynthesizeMeter 10 | { 11 | 12 | 13 | /// 14 | /// 获取设备ID号 15 | /// 16 | public override string GetID() 17 | { 18 | string sendMsg = "*IDN?"; 19 | try 20 | { 21 | return base.WriteAndReadString(sendMsg); 22 | } 23 | catch (Exception ex) 24 | { 25 | throw (ex); 26 | } 27 | } 28 | 29 | /// 30 | /// 初始化仪表参数 31 | /// 32 | /// 33 | public override bool Reset() 34 | { 35 | string sendMsg = "*RST"; 36 | try 37 | { 38 | return base.WriteString(sendMsg); 39 | return true; 40 | } 41 | catch (Exception ex) 42 | { 43 | throw (ex); 44 | } 45 | } 46 | /// 47 | /// 设置中心频率 48 | /// 49 | /// 频率 50 | /// 频率单位 51 | /// 52 | public override bool SetCenterFreq(double value, FrequencyUnit unit) 53 | { 54 | string sendMsg = "FREQ: CENT "; 55 | switch (unit) 56 | { 57 | case FrequencyUnit.Hz: 58 | sendMsg += "Hz;"; 59 | break; 60 | case FrequencyUnit.KHz: 61 | sendMsg += "KHz;"; 62 | break; 63 | case FrequencyUnit.MHz: 64 | sendMsg += "MHz;"; 65 | break; 66 | case FrequencyUnit.GHz: 67 | sendMsg += "GHz;"; 68 | break; 69 | } 70 | try 71 | { 72 | return base.WriteString(sendMsg); 73 | } 74 | catch (Exception ex) 75 | { 76 | throw (ex); 77 | } 78 | 79 | } 80 | 81 | /// 82 | /// 设置参考电平 幅度标尺 83 | /// 84 | /// 参考电平 单位dbm 85 | /// 86 | public override bool SetRefLevel(double value) 87 | { 88 | string sendMsg = "DISP:WIND:TRAC:Y:RLEV " + value + "DBM"; ; 89 | try 90 | { 91 | return base.WriteString(sendMsg); 92 | } 93 | catch (Exception ex) 94 | { 95 | throw (ex); 96 | } 97 | } 98 | 99 | /// 100 | /// 获取中心频率 101 | /// 102 | /// 103 | public override double GetCenterFreq() 104 | { 105 | string sendMsg = "FREQ:CENT?"; 106 | try 107 | { 108 | string recvMsg = base.WriteAndReadString(sendMsg); 109 | return Convert.ToDouble(recvMsg); 110 | } 111 | catch (Exception ex) 112 | { 113 | throw (ex); 114 | } 115 | } 116 | 117 | /// 118 | /// 设置解调开关。 119 | /// 120 | /// 音频开关 121 | /// 122 | public override bool SetAfgState(bool onOff) 123 | { 124 | string sendMsg = null; 125 | if (!onOff) 126 | sendMsg = "DMOD:STAT OFF "; 127 | else 128 | sendMsg = "DMOD:STAT ON "; 129 | try 130 | { 131 | return base.WriteString(sendMsg); 132 | } 133 | catch (Exception ex) 134 | { 135 | throw (ex); 136 | } 137 | } 138 | 139 | } 140 | } 141 | -------------------------------------------------------------------------------- /InstrumentUtilityDotNet/SynthesizeMeterManager/Aglient_8920.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace InstrumentUtilityDotNet.SynthesizeMeterManager 8 | { 9 | public class Aglient_8920 :ISynthesizeMeter 10 | { 11 | 12 | /// 13 | /// 获取设备ID号 14 | /// 15 | public override string GetID() 16 | { 17 | string sendMsg = "*IDN?"; 18 | try 19 | { 20 | return base.WriteAndReadString(sendMsg); 21 | } 22 | catch (Exception ex) 23 | { 24 | throw(ex); 25 | } 26 | } 27 | 28 | /// 29 | /// 初始化仪表参数 30 | /// 31 | /// 32 | public override bool Reset() 33 | { 34 | string sendMsg = "*RST"; 35 | try 36 | { 37 | return base.WriteString(sendMsg); 38 | } 39 | catch (Exception ex) 40 | { 41 | throw (ex); 42 | } 43 | } 44 | /// 45 | /// 设置中心频率 46 | /// 47 | /// 频率 48 | /// 频率单位 49 | /// 50 | public override bool SetCenterFreq(double value, FrequencyUnit unit) 51 | { 52 | 53 | string sendMsg = "RFG: FREQ "; 54 | switch (unit) 55 | { 56 | case FrequencyUnit.Hz: 57 | sendMsg += "Hz;"; 58 | break; 59 | case FrequencyUnit.KHz: 60 | sendMsg += "KHz;"; 61 | break; 62 | case FrequencyUnit.MHz: 63 | sendMsg += "MHz;"; 64 | break; 65 | case FrequencyUnit.GHz: 66 | sendMsg += "GHz;"; 67 | break; 68 | } 69 | try 70 | { 71 | return base.WriteString(sendMsg); 72 | } 73 | catch (Exception ex) 74 | { 75 | throw (ex); 76 | } 77 | } 78 | 79 | /// 80 | /// 设置参考电平 幅度标尺 81 | /// 82 | /// 参考电平 单位dbm 83 | /// 84 | public override bool SetRefLevel(double value) 85 | { 86 | string sendMsg = "RFG:AMPL " + value + "DBM;"; 87 | try 88 | { 89 | return base.WriteString(sendMsg); 90 | } 91 | catch (Exception ex) 92 | { 93 | throw (ex); 94 | } 95 | } 96 | 97 | 98 | 99 | /// 100 | /// 获取中心频率 101 | /// 102 | /// 103 | public override double GetCenterFreq() 104 | { 105 | string sendMsg = "MEAS: AFR: FREQ ?;"; 106 | try 107 | { 108 | string recvMsg = base.WriteAndReadString(sendMsg); 109 | return Convert.ToDouble(recvMsg); 110 | } 111 | catch (Exception ex) 112 | { 113 | throw (ex); 114 | } 115 | } 116 | 117 | 118 | /// 119 | /// 设置解调开关 120 | /// 121 | /// 设置解调开关 122 | /// 123 | public override bool SetAfgState(bool onOff) 124 | { 125 | string sendMsg = null; 126 | if (!onOff) 127 | sendMsg = "AFG1:FM:STAT OFF"; 128 | else 129 | sendMsg = "AFG1:FM:STAT ON"; 130 | try 131 | { 132 | return base.WriteString(sendMsg); 133 | } 134 | catch (Exception ex) 135 | { 136 | throw (ex); 137 | } 138 | } 139 | 140 | 141 | 142 | 143 | } 144 | 145 | } 146 | -------------------------------------------------------------------------------- /InstrumentUtilityDLL.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.23107.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Sample", "Sample", "{881B9A17-5228-4DC3-8C56-2ADB12F93D20}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InstrumentDemoCSharp", "Sample\C#\InstrumentDemoCSharp\InstrumentDemoCSharp.csproj", "{0F20D118-8C4D-4A10-8734-3C8A980A58A4}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InstrumentUtilityDotNet", "InstrumentUtilityDotNet\InstrumentUtilityDotNet.csproj", "{AB33C645-CC98-4AB0-AB96-FC0C29E924E4}" 11 | EndProject 12 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "InstrumentDemoCpp", "Sample\Cpp\InstrumentDemoCpp.vcxproj", "{AC751C3D-7208-40CA-B12E-E0C751080E17}" 13 | EndProject 14 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "InstrumentUtility", "InstrumentUtility\InstrumentUtility\InstrumentUtility.vcxproj", "{8C3D9735-D99F-4577-974C-50E3A475C886}" 15 | EndProject 16 | Global 17 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 18 | Debug|Any CPU = Debug|Any CPU 19 | Debug|x64 = Debug|x64 20 | Debug|x86 = Debug|x86 21 | Release|Any CPU = Release|Any CPU 22 | Release|x64 = Release|x64 23 | Release|x86 = Release|x86 24 | EndGlobalSection 25 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 26 | {0F20D118-8C4D-4A10-8734-3C8A980A58A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 27 | {0F20D118-8C4D-4A10-8734-3C8A980A58A4}.Debug|Any CPU.Build.0 = Debug|Any CPU 28 | {0F20D118-8C4D-4A10-8734-3C8A980A58A4}.Debug|x64.ActiveCfg = Debug|x64 29 | {0F20D118-8C4D-4A10-8734-3C8A980A58A4}.Debug|x64.Build.0 = Debug|x64 30 | {0F20D118-8C4D-4A10-8734-3C8A980A58A4}.Debug|x86.ActiveCfg = Debug|x86 31 | {0F20D118-8C4D-4A10-8734-3C8A980A58A4}.Debug|x86.Build.0 = Debug|x86 32 | {0F20D118-8C4D-4A10-8734-3C8A980A58A4}.Release|Any CPU.ActiveCfg = Release|Any CPU 33 | {0F20D118-8C4D-4A10-8734-3C8A980A58A4}.Release|Any CPU.Build.0 = Release|Any CPU 34 | {0F20D118-8C4D-4A10-8734-3C8A980A58A4}.Release|x64.ActiveCfg = Release|Any CPU 35 | {0F20D118-8C4D-4A10-8734-3C8A980A58A4}.Release|x64.Build.0 = Release|Any CPU 36 | {0F20D118-8C4D-4A10-8734-3C8A980A58A4}.Release|x86.ActiveCfg = Release|x86 37 | {0F20D118-8C4D-4A10-8734-3C8A980A58A4}.Release|x86.Build.0 = Release|x86 38 | {AB33C645-CC98-4AB0-AB96-FC0C29E924E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 39 | {AB33C645-CC98-4AB0-AB96-FC0C29E924E4}.Debug|Any CPU.Build.0 = Debug|Any CPU 40 | {AB33C645-CC98-4AB0-AB96-FC0C29E924E4}.Debug|x64.ActiveCfg = Debug|x64 41 | {AB33C645-CC98-4AB0-AB96-FC0C29E924E4}.Debug|x64.Build.0 = Debug|x64 42 | {AB33C645-CC98-4AB0-AB96-FC0C29E924E4}.Debug|x86.ActiveCfg = Debug|x86 43 | {AB33C645-CC98-4AB0-AB96-FC0C29E924E4}.Debug|x86.Build.0 = Debug|x86 44 | {AB33C645-CC98-4AB0-AB96-FC0C29E924E4}.Release|Any CPU.ActiveCfg = Release|Any CPU 45 | {AB33C645-CC98-4AB0-AB96-FC0C29E924E4}.Release|Any CPU.Build.0 = Release|Any CPU 46 | {AB33C645-CC98-4AB0-AB96-FC0C29E924E4}.Release|x64.ActiveCfg = Release|Any CPU 47 | {AB33C645-CC98-4AB0-AB96-FC0C29E924E4}.Release|x64.Build.0 = Release|Any CPU 48 | {AB33C645-CC98-4AB0-AB96-FC0C29E924E4}.Release|x86.ActiveCfg = Release|x86 49 | {AB33C645-CC98-4AB0-AB96-FC0C29E924E4}.Release|x86.Build.0 = Release|x86 50 | {AC751C3D-7208-40CA-B12E-E0C751080E17}.Debug|Any CPU.ActiveCfg = Debug|Win32 51 | {AC751C3D-7208-40CA-B12E-E0C751080E17}.Debug|x64.ActiveCfg = Debug|x64 52 | {AC751C3D-7208-40CA-B12E-E0C751080E17}.Debug|x64.Build.0 = Debug|x64 53 | {AC751C3D-7208-40CA-B12E-E0C751080E17}.Debug|x86.ActiveCfg = Debug|Win32 54 | {AC751C3D-7208-40CA-B12E-E0C751080E17}.Debug|x86.Build.0 = Debug|Win32 55 | {AC751C3D-7208-40CA-B12E-E0C751080E17}.Release|Any CPU.ActiveCfg = Release|Win32 56 | {AC751C3D-7208-40CA-B12E-E0C751080E17}.Release|x64.ActiveCfg = Release|x64 57 | {AC751C3D-7208-40CA-B12E-E0C751080E17}.Release|x64.Build.0 = Release|x64 58 | {AC751C3D-7208-40CA-B12E-E0C751080E17}.Release|x86.ActiveCfg = Release|Win32 59 | {AC751C3D-7208-40CA-B12E-E0C751080E17}.Release|x86.Build.0 = Release|Win32 60 | {8C3D9735-D99F-4577-974C-50E3A475C886}.Debug|Any CPU.ActiveCfg = Debug|Win32 61 | {8C3D9735-D99F-4577-974C-50E3A475C886}.Debug|x64.ActiveCfg = Debug|x64 62 | {8C3D9735-D99F-4577-974C-50E3A475C886}.Debug|x64.Build.0 = Debug|x64 63 | {8C3D9735-D99F-4577-974C-50E3A475C886}.Debug|x86.ActiveCfg = Debug|Win32 64 | {8C3D9735-D99F-4577-974C-50E3A475C886}.Debug|x86.Build.0 = Debug|Win32 65 | {8C3D9735-D99F-4577-974C-50E3A475C886}.Release|Any CPU.ActiveCfg = Release|Win32 66 | {8C3D9735-D99F-4577-974C-50E3A475C886}.Release|x64.ActiveCfg = Release|x64 67 | {8C3D9735-D99F-4577-974C-50E3A475C886}.Release|x64.Build.0 = Release|x64 68 | {8C3D9735-D99F-4577-974C-50E3A475C886}.Release|x86.ActiveCfg = Release|Win32 69 | {8C3D9735-D99F-4577-974C-50E3A475C886}.Release|x86.Build.0 = Release|Win32 70 | EndGlobalSection 71 | GlobalSection(SolutionProperties) = preSolution 72 | HideSolutionNode = FALSE 73 | EndGlobalSection 74 | GlobalSection(NestedProjects) = preSolution 75 | {0F20D118-8C4D-4A10-8734-3C8A980A58A4} = {881B9A17-5228-4DC3-8C56-2ADB12F93D20} 76 | {AC751C3D-7208-40CA-B12E-E0C751080E17} = {881B9A17-5228-4DC3-8C56-2ADB12F93D20} 77 | EndGlobalSection 78 | GlobalSection(ExtensibilityGlobals) = postSolution 79 | SolutionGuid = {52E4E803-51A4-41CF-8A51-8D3E4BED967E} 80 | EndGlobalSection 81 | EndGlobal 82 | -------------------------------------------------------------------------------- /Sample/C#/InstrumentDemoCSharp/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /InstrumentUtilityDotNet/InstrumentUtilityDotNet.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {AB33C645-CC98-4AB0-AB96-FC0C29E924E4} 8 | Library 9 | Properties 10 | InstrumentUtilityDotNet 11 | InstrumentUtilityDotNet 12 | v4.0 13 | 512 14 | true 15 | 16 | 17 | 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | 34 | 35 | true 36 | bin\x86\Debug\ 37 | DEBUG;TRACE 38 | full 39 | x86 40 | prompt 41 | MinimumRecommendedRules.ruleset 42 | 43 | 44 | bin\x86\Release\ 45 | TRACE 46 | true 47 | pdbonly 48 | x86 49 | prompt 50 | MinimumRecommendedRules.ruleset 51 | 52 | 53 | true 54 | bin\x64\Debug\ 55 | DEBUG;TRACE 56 | full 57 | x64 58 | prompt 59 | MinimumRecommendedRules.ruleset 60 | 61 | 62 | bin\x64\Release\ 63 | TRACE 64 | true 65 | pdbonly 66 | x64 67 | prompt 68 | MinimumRecommendedRules.ruleset 69 | 70 | 71 | 72 | False 73 | False 74 | D:\dll\Ivi.Visa.Interop\5.11\x86\Ivi.Visa.Interop.dll 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | -------------------------------------------------------------------------------- /Sample/C#/InstrumentDemoCSharp/InstrumentDemoCSharp.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {0F20D118-8C4D-4A10-8734-3C8A980A58A4} 8 | WinExe 9 | InstrumentDemoCsharp 10 | InstrumentDemoCsharp 11 | v4.5.2 12 | 512 13 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 14 | 4 15 | true 16 | true 17 | 18 | 19 | AnyCPU 20 | true 21 | full 22 | false 23 | bin\Debug\ 24 | DEBUG;TRACE 25 | prompt 26 | 4 27 | 28 | 29 | AnyCPU 30 | pdbonly 31 | true 32 | bin\Release\ 33 | TRACE 34 | prompt 35 | 4 36 | 37 | 38 | true 39 | bin\x86\Debug\ 40 | DEBUG;TRACE 41 | full 42 | x86 43 | 6 44 | prompt 45 | MinimumRecommendedRules.ruleset 46 | true 47 | 48 | 49 | bin\x86\Release\ 50 | TRACE 51 | true 52 | pdbonly 53 | x86 54 | 6 55 | prompt 56 | MinimumRecommendedRules.ruleset 57 | true 58 | 59 | 60 | true 61 | bin\x64\Debug\ 62 | DEBUG;TRACE 63 | full 64 | x64 65 | prompt 66 | MinimumRecommendedRules.ruleset 67 | true 68 | 69 | 70 | bin\x64\Release\ 71 | TRACE 72 | true 73 | pdbonly 74 | x64 75 | prompt 76 | MinimumRecommendedRules.ruleset 77 | true 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 4.0 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | MSBuild:Compile 101 | 102 | 103 | MSBuild:Compile 104 | Designer 105 | 106 | 107 | App.xaml 108 | Code 109 | 110 | 111 | MainWindow.xaml 112 | Code 113 | 114 | 115 | 116 | 117 | Code 118 | 119 | 120 | True 121 | True 122 | Resources.resx 123 | 124 | 125 | True 126 | Settings.settings 127 | True 128 | 129 | 130 | ResXFileCodeGenerator 131 | Resources.Designer.cs 132 | 133 | 134 | SettingsSingleFileGenerator 135 | Settings.Designer.cs 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | {ab33c645-cc98-4ab0-ab96-fc0c29e924e4} 147 | InstrumentUtilityDotNet 148 | 149 | 150 | 151 | -------------------------------------------------------------------------------- /InstrumentUtility/Visa/visatype.h: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------*/ 2 | /* Distributed by IVI Foundation Inc. */ 3 | /* */ 4 | /* Do not modify the contents of this file. */ 5 | /*---------------------------------------------------------------------------*/ 6 | /* */ 7 | /* Title : VISATYPE.H */ 8 | /* Date : 06-08-2017 */ 9 | /* Purpose : Fundamental VISA data types and macro definitions */ 10 | /* */ 11 | /*---------------------------------------------------------------------------*/ 12 | 13 | #ifndef __VISATYPE_HEADER__ 14 | #define __VISATYPE_HEADER__ 15 | 16 | #if defined(_WIN64) 17 | #define _VI_FAR 18 | #define _VI_FUNC __fastcall 19 | #define _VI_FUNCC __fastcall 20 | #define _VI_FUNCH __fastcall 21 | #define _VI_SIGNED signed 22 | #elif (defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)) && !defined(_NI_mswin16_) 23 | #define _VI_FAR 24 | #define _VI_FUNC __stdcall 25 | #define _VI_FUNCC __cdecl 26 | #define _VI_FUNCH __stdcall 27 | #define _VI_SIGNED signed 28 | #elif defined(_CVI_) && defined(_NI_i386_) 29 | #define _VI_FAR 30 | #define _VI_FUNC _pascal 31 | #define _VI_FUNCC 32 | #define _VI_FUNCH _pascal 33 | #define _VI_SIGNED signed 34 | #elif (defined(_WINDOWS) || defined(_Windows)) && !defined(_NI_mswin16_) 35 | #define _VI_FAR _far 36 | #define _VI_FUNC _far _pascal _export 37 | #define _VI_FUNCC _far _cdecl _export 38 | #define _VI_FUNCH _far _pascal 39 | #define _VI_SIGNED signed 40 | #elif (defined(hpux) || defined(__hpux)) && (defined(__cplusplus) || defined(__cplusplus__)) 41 | #define _VI_FAR 42 | #define _VI_FUNC 43 | #define _VI_FUNCC 44 | #define _VI_FUNCH 45 | #define _VI_SIGNED 46 | #else 47 | #define _VI_FAR 48 | #define _VI_FUNC 49 | #define _VI_FUNCC 50 | #define _VI_FUNCH 51 | #define _VI_SIGNED signed 52 | #endif 53 | 54 | #define _VI_ERROR (-2147483647L-1) /* 0x80000000 */ 55 | #define _VI_PTR _VI_FAR * 56 | 57 | /*- VISA Types --------------------------------------------------------------*/ 58 | 59 | #ifndef _VI_INT64_UINT64_DEFINED 60 | #if defined(_WIN64) || ((defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)) && !defined(_NI_mswin16_)) 61 | #if (defined(_MSC_VER) && (_MSC_VER >= 1200)) || (defined(_CVI_) && (_CVI_ >= 700)) || (defined(__BORLANDC__) && (__BORLANDC__ >= 0x0520)) 62 | typedef unsigned __int64 ViUInt64; 63 | typedef _VI_SIGNED __int64 ViInt64; 64 | #define _VI_INT64_UINT64_DEFINED 65 | #if defined(_WIN64) 66 | #define _VISA_ENV_IS_64_BIT 67 | #else 68 | /* This is a 32-bit OS, not a 64-bit OS */ 69 | #endif 70 | #endif 71 | #elif defined(__GNUC__) && (__GNUC__ >= 3) 72 | #include 73 | #include 74 | typedef u_int64_t ViUInt64; 75 | typedef int64_t ViInt64; 76 | #define _VI_INT64_UINT64_DEFINED 77 | #if defined(LONG_MAX) && (LONG_MAX > 0x7FFFFFFFL) 78 | #define _VISA_ENV_IS_64_BIT 79 | #else 80 | /* This is a 32-bit OS, not a 64-bit OS */ 81 | #endif 82 | #else 83 | /* This platform does not support 64-bit types */ 84 | #endif 85 | #endif 86 | 87 | #if defined(_VI_INT64_UINT64_DEFINED) 88 | typedef ViUInt64 _VI_PTR ViPUInt64; 89 | typedef ViUInt64 _VI_PTR ViAUInt64; 90 | typedef ViInt64 _VI_PTR ViPInt64; 91 | typedef ViInt64 _VI_PTR ViAInt64; 92 | #endif 93 | 94 | #if defined(LONG_MAX) && (LONG_MAX > 0x7FFFFFFFL) 95 | typedef unsigned int ViUInt32; 96 | typedef _VI_SIGNED int ViInt32; 97 | #else 98 | typedef unsigned long ViUInt32; 99 | typedef _VI_SIGNED long ViInt32; 100 | #endif 101 | 102 | typedef ViUInt32 _VI_PTR ViPUInt32; 103 | typedef ViUInt32 _VI_PTR ViAUInt32; 104 | typedef ViInt32 _VI_PTR ViPInt32; 105 | typedef ViInt32 _VI_PTR ViAInt32; 106 | 107 | typedef unsigned short ViUInt16; 108 | typedef ViUInt16 _VI_PTR ViPUInt16; 109 | typedef ViUInt16 _VI_PTR ViAUInt16; 110 | 111 | typedef _VI_SIGNED short ViInt16; 112 | typedef ViInt16 _VI_PTR ViPInt16; 113 | typedef ViInt16 _VI_PTR ViAInt16; 114 | 115 | typedef unsigned char ViUInt8; 116 | typedef ViUInt8 _VI_PTR ViPUInt8; 117 | typedef ViUInt8 _VI_PTR ViAUInt8; 118 | 119 | typedef _VI_SIGNED char ViInt8; 120 | typedef ViInt8 _VI_PTR ViPInt8; 121 | typedef ViInt8 _VI_PTR ViAInt8; 122 | 123 | typedef char ViChar; 124 | typedef ViChar _VI_PTR ViPChar; 125 | typedef ViChar _VI_PTR ViAChar; 126 | 127 | typedef unsigned char ViByte; 128 | typedef ViByte _VI_PTR ViPByte; 129 | typedef ViByte _VI_PTR ViAByte; 130 | 131 | typedef void _VI_PTR ViAddr; 132 | typedef ViAddr _VI_PTR ViPAddr; 133 | typedef ViAddr _VI_PTR ViAAddr; 134 | 135 | typedef float ViReal32; 136 | typedef ViReal32 _VI_PTR ViPReal32; 137 | typedef ViReal32 _VI_PTR ViAReal32; 138 | 139 | typedef double ViReal64; 140 | typedef ViReal64 _VI_PTR ViPReal64; 141 | typedef ViReal64 _VI_PTR ViAReal64; 142 | 143 | typedef ViPByte ViBuf; 144 | typedef const ViByte * ViConstBuf; 145 | typedef ViPByte ViPBuf; 146 | typedef ViPByte _VI_PTR ViABuf; 147 | 148 | typedef ViPChar ViString; 149 | #ifndef _VI_CONST_STRING_DEFINED 150 | typedef const ViChar * ViConstString; 151 | #define _VI_CONST_STRING_DEFINED 152 | #endif 153 | typedef ViPChar ViPString; 154 | typedef ViPChar _VI_PTR ViAString; 155 | 156 | typedef ViString ViRsrc; 157 | typedef ViConstString ViConstRsrc; 158 | typedef ViString ViPRsrc; 159 | typedef ViString _VI_PTR ViARsrc; 160 | 161 | typedef ViUInt16 ViBoolean; 162 | typedef ViBoolean _VI_PTR ViPBoolean; 163 | typedef ViBoolean _VI_PTR ViABoolean; 164 | 165 | typedef ViInt32 ViStatus; 166 | typedef ViStatus _VI_PTR ViPStatus; 167 | typedef ViStatus _VI_PTR ViAStatus; 168 | 169 | typedef ViUInt32 ViVersion; 170 | typedef ViVersion _VI_PTR ViPVersion; 171 | typedef ViVersion _VI_PTR ViAVersion; 172 | 173 | typedef ViUInt32 ViObject; 174 | typedef ViObject _VI_PTR ViPObject; 175 | typedef ViObject _VI_PTR ViAObject; 176 | 177 | typedef ViObject ViSession; 178 | typedef ViSession _VI_PTR ViPSession; 179 | typedef ViSession _VI_PTR ViASession; 180 | 181 | typedef ViUInt32 ViAttr; 182 | 183 | 184 | /*- Completion and Error Codes ----------------------------------------------*/ 185 | 186 | #define VI_SUCCESS (0L) 187 | 188 | /*- Other VISA Definitions --------------------------------------------------*/ 189 | 190 | #define VI_NULL (0) 191 | 192 | #define VI_TRUE (1) 193 | #define VI_FALSE (0) 194 | 195 | /*- Backward Compatibility Macros -------------------------------------------*/ 196 | 197 | #define VISAFN _VI_FUNC 198 | #define ViPtr _VI_PTR 199 | 200 | #endif 201 | 202 | /*- The End -----------------------------------------------------------------*/ 203 | 204 | -------------------------------------------------------------------------------- /InstrumentUtilityDotNet/SignalSourceManager/Agilent_E4400.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace InstrumentUtilityDotNet.SignalSourceManager 8 | { 9 | /// 10 | /// E440系列 Old 11 | /// 12 | public class Agilent_E4400: ISignalSource 13 | { 14 | /// 15 | /// 获取设备ID号 16 | /// 17 | public override string GetID() 18 | { 19 | string sendMsg = "ID?;"; 20 | try 21 | { 22 | return base.WriteAndReadString(sendMsg); 23 | } 24 | catch (Exception ex) 25 | { 26 | throw (ex); 27 | } 28 | } 29 | /// 30 | /// 初始化仪表参数 31 | /// 32 | /// 33 | public override bool Reset() 34 | { 35 | string sendMsg = "IP;"; 36 | try 37 | { 38 | return base.WriteString(sendMsg); 39 | } 40 | catch (Exception ex) 41 | { 42 | throw (ex); 43 | } 44 | } 45 | /// 46 | /// 信号源发射开关 47 | /// 48 | /// On:打开发射 Off:关闭发射 49 | /// 50 | public override bool SetSignalSourceState(bool state) 51 | { 52 | string sendMsg = string.Empty; 53 | if (state) 54 | sendMsg = "OUTP:ALL ON"; 55 | else 56 | sendMsg = "OUTP:ALL OFF"; 57 | try 58 | { 59 | return base.WriteString(sendMsg); 60 | } 61 | catch (Exception ex) 62 | { 63 | throw (ex); 64 | } 65 | 66 | } 67 | 68 | /// 69 | /// 设置频率、功率 70 | /// 71 | /// 频率单位 72 | /// 频率 73 | /// 功率,单位DBM 74 | /// 75 | public override bool SetFreqAndLevel(FrequencyUnit unit, double freq, double level) 76 | { 77 | string sendMsg = "*RST;FREQ:CW "+freq; 78 | switch (unit) 79 | { 80 | case FrequencyUnit.Hz: 81 | sendMsg += "Hz;"; 82 | break; 83 | case FrequencyUnit.KHz: 84 | sendMsg += "KHz;"; 85 | break; 86 | case FrequencyUnit.MHz: 87 | sendMsg += "MHz;"; 88 | break; 89 | case FrequencyUnit.GHz: 90 | sendMsg += "GHz;"; 91 | break; 92 | } 93 | sendMsg += "POW:LEV " + level + "DBM"; 94 | try 95 | { 96 | return base.WriteString(sendMsg); 97 | } 98 | catch (Exception ex) 99 | { 100 | throw (ex); 101 | } 102 | } 103 | 104 | /// 105 | /// 设置频率 106 | /// 107 | /// 频率单位 108 | /// 频率 109 | /// 110 | public override bool SetFreq(FrequencyUnit unit, double freq) 111 | { 112 | 113 | string sendMsg = "*RST;FREQ:CW "+freq; 114 | switch (unit) 115 | { 116 | case FrequencyUnit.Hz: 117 | sendMsg += "Hz;"; 118 | break; 119 | case FrequencyUnit.KHz: 120 | sendMsg += "KHz;"; 121 | break; 122 | case FrequencyUnit.MHz: 123 | sendMsg += "MHz;"; 124 | break; 125 | case FrequencyUnit.GHz: 126 | sendMsg += "GHz;"; 127 | break; 128 | } 129 | try 130 | { 131 | return base.WriteString(sendMsg); 132 | } 133 | catch (Exception ex) 134 | { 135 | throw (ex); 136 | } 137 | } 138 | 139 | /// 140 | /// 设置功率 141 | /// 142 | /// 功率 143 | /// 144 | public override bool SetLevel(double level) 145 | { 146 | 147 | string sendMsg = "POW:LEV " + level + "DBM"; 148 | try 149 | { 150 | return base.WriteString(sendMsg); 151 | } 152 | catch (Exception ex) 153 | { 154 | throw (ex); 155 | } 156 | } 157 | /// 158 | /// 打开脉冲 159 | /// 160 | /// 161 | /// 162 | public override bool SetPulseSwitch(bool state) 163 | { 164 | string sendMsg = string.Empty; 165 | if (state) 166 | sendMsg = "PULM:STATe ON"; 167 | else 168 | sendMsg = "PULM:STATe OFF"; 169 | try 170 | { 171 | return base.WriteString(sendMsg); 172 | } 173 | catch (Exception ex) 174 | { 175 | throw (ex); 176 | } 177 | } 178 | /// 179 | /// 设置脉冲信号带宽 180 | /// 181 | /// 信号带宽(8us-脉冲周期) 单位:us 182 | /// 183 | public override bool SetPulseWidth(double width) 184 | { 185 | 186 | string sendMsg = "PULM:INTernal:PWIDth " + width + "us"; //INTernal可去掉 187 | try 188 | { 189 | return base.WriteString(sendMsg); 190 | } 191 | catch (Exception ex) 192 | { 193 | throw (ex); 194 | } 195 | } 196 | 197 | 198 | /// 199 | /// 设置脉冲周期(必须大于信号带宽) 200 | /// 201 | /// 周期(16us-30s) 单位:us 202 | /// 203 | public override bool SetPulsePeriod(double period) 204 | { 205 | 206 | string sendMsg = "PULM:INTernal:PERiod " + period + "us"; //INTernal可去掉 207 | try 208 | { 209 | return base.WriteString(sendMsg); 210 | } 211 | catch (Exception ex) 212 | { 213 | throw (ex); 214 | } 215 | } 216 | 217 | /// 218 | /// 设置调制开关 219 | /// 220 | /// 221 | /// 222 | public override bool SetModulationSwitch(bool state) 223 | { 224 | string sendMsg = string.Empty; 225 | if (state) 226 | sendMsg = "OUTPut:MODulation ON"; 227 | else 228 | sendMsg = "OUTPut:MODulation OFF"; 229 | try 230 | { 231 | return base.WriteString(sendMsg); 232 | 233 | } 234 | catch (Exception ex) 235 | { 236 | throw (ex); 237 | } 238 | } 239 | } 240 | } 241 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Build results 17 | [Dd]ebug/ 18 | [Dd]ebugPublic/ 19 | [Rr]elease/ 20 | [Rr]eleases/ 21 | x64/ 22 | x86/ 23 | [Aa][Rr][Mm]/ 24 | [Aa][Rr][Mm]64/ 25 | bld/ 26 | [Bb]in/ 27 | [Oo]bj/ 28 | [Ll]og/ 29 | 30 | # Visual Studio 2015/2017 cache/options directory 31 | .vs/ 32 | # Uncomment if you have tasks that create the project's static files in wwwroot 33 | #wwwroot/ 34 | 35 | # Visual Studio 2017 auto generated files 36 | Generated\ Files/ 37 | 38 | # MSTest test Results 39 | [Tt]est[Rr]esult*/ 40 | [Bb]uild[Ll]og.* 41 | 42 | # NUNIT 43 | *.VisualState.xml 44 | TestResult.xml 45 | 46 | # Build Results of an ATL Project 47 | [Dd]ebugPS/ 48 | [Rr]eleasePS/ 49 | dlldata.c 50 | 51 | # Benchmark Results 52 | BenchmarkDotNet.Artifacts/ 53 | 54 | # .NET Core 55 | project.lock.json 56 | project.fragment.lock.json 57 | artifacts/ 58 | 59 | # StyleCop 60 | StyleCopReport.xml 61 | 62 | # Files built by Visual Studio 63 | *_i.c 64 | *_p.c 65 | *_h.h 66 | *.ilk 67 | *.meta 68 | *.obj 69 | *.iobj 70 | *.pch 71 | *.pdb 72 | *.ipdb 73 | *.pgc 74 | *.pgd 75 | *.rsp 76 | *.sbr 77 | *.tlb 78 | *.tli 79 | *.tlh 80 | *.tmp 81 | *.tmp_proj 82 | *_wpftmp.csproj 83 | *.log 84 | *.vspscc 85 | *.vssscc 86 | .builds 87 | *.pidb 88 | *.svclog 89 | *.scc 90 | 91 | # Chutzpah Test files 92 | _Chutzpah* 93 | 94 | # Visual C++ cache files 95 | ipch/ 96 | *.aps 97 | *.ncb 98 | *.opendb 99 | *.opensdf 100 | *.sdf 101 | *.cachefile 102 | *.VC.db 103 | *.VC.VC.opendb 104 | 105 | # Visual Studio profiler 106 | *.psess 107 | *.vsp 108 | *.vspx 109 | *.sap 110 | 111 | # Visual Studio Trace Files 112 | *.e2e 113 | 114 | # TFS 2012 Local Workspace 115 | $tf/ 116 | 117 | # Guidance Automation Toolkit 118 | *.gpState 119 | 120 | # ReSharper is a .NET coding add-in 121 | _ReSharper*/ 122 | *.[Rr]e[Ss]harper 123 | *.DotSettings.user 124 | 125 | # JustCode is a .NET coding add-in 126 | .JustCode 127 | 128 | # TeamCity is a build add-in 129 | _TeamCity* 130 | 131 | # DotCover is a Code Coverage Tool 132 | *.dotCover 133 | 134 | # AxoCover is a Code Coverage Tool 135 | .axoCover/* 136 | !.axoCover/settings.json 137 | 138 | # Visual Studio code coverage results 139 | *.coverage 140 | *.coveragexml 141 | 142 | # NCrunch 143 | _NCrunch_* 144 | .*crunch*.local.xml 145 | nCrunchTemp_* 146 | 147 | # MightyMoose 148 | *.mm.* 149 | AutoTest.Net/ 150 | 151 | # Web workbench (sass) 152 | .sass-cache/ 153 | 154 | # Installshield output folder 155 | [Ee]xpress/ 156 | 157 | # DocProject is a documentation generator add-in 158 | DocProject/buildhelp/ 159 | DocProject/Help/*.HxT 160 | DocProject/Help/*.HxC 161 | DocProject/Help/*.hhc 162 | DocProject/Help/*.hhk 163 | DocProject/Help/*.hhp 164 | DocProject/Help/Html2 165 | DocProject/Help/html 166 | 167 | # Click-Once directory 168 | publish/ 169 | 170 | # Publish Web Output 171 | *.[Pp]ublish.xml 172 | *.azurePubxml 173 | # Note: Comment the next line if you want to checkin your web deploy settings, 174 | # but database connection strings (with potential passwords) will be unencrypted 175 | *.pubxml 176 | *.publishproj 177 | 178 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 179 | # checkin your Azure Web App publish settings, but sensitive information contained 180 | # in these scripts will be unencrypted 181 | PublishScripts/ 182 | 183 | # NuGet Packages 184 | *.nupkg 185 | # The packages folder can be ignored because of Package Restore 186 | **/[Pp]ackages/* 187 | # except build/, which is used as an MSBuild target. 188 | !**/[Pp]ackages/build/ 189 | # Uncomment if necessary however generally it will be regenerated when needed 190 | #!**/[Pp]ackages/repositories.config 191 | # NuGet v3's project.json files produces more ignorable files 192 | *.nuget.props 193 | *.nuget.targets 194 | 195 | # Microsoft Azure Build Output 196 | csx/ 197 | *.build.csdef 198 | 199 | # Microsoft Azure Emulator 200 | ecf/ 201 | rcf/ 202 | 203 | # Windows Store app package directories and files 204 | AppPackages/ 205 | BundleArtifacts/ 206 | Package.StoreAssociation.xml 207 | _pkginfo.txt 208 | *.appx 209 | 210 | # Visual Studio cache files 211 | # files ending in .cache can be ignored 212 | *.[Cc]ache 213 | # but keep track of directories ending in .cache 214 | !?*.[Cc]ache/ 215 | 216 | # Others 217 | ClientBin/ 218 | ~$* 219 | *~ 220 | *.dbmdl 221 | *.dbproj.schemaview 222 | *.jfm 223 | *.pfx 224 | *.publishsettings 225 | orleans.codegen.cs 226 | 227 | # Including strong name files can present a security risk 228 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 229 | #*.snk 230 | 231 | # Since there are multiple workflows, uncomment next line to ignore bower_components 232 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 233 | #bower_components/ 234 | 235 | # RIA/Silverlight projects 236 | Generated_Code/ 237 | 238 | # Backup & report files from converting an old project file 239 | # to a newer Visual Studio version. Backup files are not needed, 240 | # because we have git ;-) 241 | _UpgradeReport_Files/ 242 | Backup*/ 243 | UpgradeLog*.XML 244 | UpgradeLog*.htm 245 | ServiceFabricBackup/ 246 | *.rptproj.bak 247 | 248 | # SQL Server files 249 | *.mdf 250 | *.ldf 251 | *.ndf 252 | 253 | # Business Intelligence projects 254 | *.rdl.data 255 | *.bim.layout 256 | *.bim_*.settings 257 | *.rptproj.rsuser 258 | *- Backup*.rdl 259 | 260 | # Microsoft Fakes 261 | FakesAssemblies/ 262 | 263 | # GhostDoc plugin setting file 264 | *.GhostDoc.xml 265 | 266 | # Node.js Tools for Visual Studio 267 | .ntvs_analysis.dat 268 | node_modules/ 269 | 270 | # Visual Studio 6 build log 271 | *.plg 272 | 273 | # Visual Studio 6 workspace options file 274 | *.opt 275 | 276 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 277 | *.vbw 278 | 279 | # Visual Studio LightSwitch build output 280 | **/*.HTMLClient/GeneratedArtifacts 281 | **/*.DesktopClient/GeneratedArtifacts 282 | **/*.DesktopClient/ModelManifest.xml 283 | **/*.Server/GeneratedArtifacts 284 | **/*.Server/ModelManifest.xml 285 | _Pvt_Extensions 286 | 287 | # Paket dependency manager 288 | .paket/paket.exe 289 | paket-files/ 290 | 291 | # FAKE - F# Make 292 | .fake/ 293 | 294 | # JetBrains Rider 295 | .idea/ 296 | *.sln.iml 297 | 298 | # CodeRush personal settings 299 | .cr/personal 300 | 301 | # Python Tools for Visual Studio (PTVS) 302 | __pycache__/ 303 | *.pyc 304 | 305 | # Cake - Uncomment if you are using it 306 | # tools/** 307 | # !tools/packages.config 308 | 309 | # Tabs Studio 310 | *.tss 311 | 312 | # Telerik's JustMock configuration file 313 | *.jmconfig 314 | 315 | # BizTalk build output 316 | *.btp.cs 317 | *.btm.cs 318 | *.odx.cs 319 | *.xsd.cs 320 | 321 | # OpenCover UI analysis results 322 | OpenCover/ 323 | 324 | # Azure Stream Analytics local run output 325 | ASALocalRun/ 326 | 327 | # MSBuild Binary and Structured Log 328 | *.binlog 329 | 330 | # NVidia Nsight GPU debugger configuration file 331 | *.nvuser 332 | 333 | # MFractors (Xamarin productivity tool) working folder 334 | .mfractor/ 335 | 336 | # Local History for Visual Studio 337 | .localhistory/ 338 | 339 | # BeatPulse healthcheck temp database 340 | healthchecksdb -------------------------------------------------------------------------------- /InstrumentUtilityDotNet/SignalSourceManager/AV1431.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace InstrumentUtilityDotNet.SignalSourceManager 7 | { 8 | class AV1431:ISignalSource 9 | { 10 | /// 11 | /// 获取设备ID号 12 | /// 13 | public override string GetID() 14 | { 15 | string sendMsg = "*IDN?"; 16 | try 17 | { 18 | return base.WriteAndReadString(sendMsg); 19 | } 20 | catch (Exception ex) 21 | { 22 | throw (ex); 23 | } 24 | } 25 | 26 | /// 27 | /// 初始化仪表参数 28 | /// 29 | /// 30 | public override bool Reset() 31 | { 32 | string sendMsg = "*RST"; 33 | try 34 | { 35 | return base.WriteString(sendMsg); 36 | } 37 | catch (Exception ex) 38 | { 39 | throw (ex); 40 | } 41 | } 42 | 43 | /// 44 | /// 信号源发射开关 45 | /// 46 | /// On:打开发射 Off:关闭发射 47 | /// 48 | public override bool SetSignalSourceState(bool state) 49 | { 50 | string sendMsg = string.Empty; 51 | if (state) 52 | sendMsg = "OUTPut:STATe ON"; 53 | else 54 | sendMsg = "OUTPut:STATe OFF"; 55 | try 56 | { 57 | return base.WriteString(sendMsg); 58 | } 59 | catch (Exception ex) 60 | { 61 | throw (ex); 62 | } 63 | 64 | } 65 | 66 | 67 | /// 68 | /// 设置频率、功率 69 | /// 70 | /// 频率单位 71 | /// 频率 72 | /// 功率,单位DBM 73 | /// 74 | public override bool SetFreqAndLevel(FrequencyUnit unit, double freq, double level) 75 | { 76 | 77 | string sendMsg = "FREQ:CW " + freq; 78 | switch (unit) 79 | { 80 | case FrequencyUnit.Hz: 81 | sendMsg += "Hz;"; 82 | break; 83 | case FrequencyUnit.KHz: 84 | sendMsg += "KHz;"; 85 | break; 86 | case FrequencyUnit.MHz: 87 | sendMsg += "MHz;"; 88 | break; 89 | case FrequencyUnit.GHz: 90 | sendMsg += "GHz;"; 91 | break; 92 | } 93 | sendMsg += ":POW:LEV " + level + "DBM"; 94 | try 95 | { 96 | return base.WriteString(sendMsg); 97 | } 98 | catch (Exception ex) 99 | { 100 | throw (ex); 101 | } 102 | } 103 | 104 | /// 105 | /// 设置频率 106 | /// 107 | /// 频率单位 108 | /// 频率 109 | /// 110 | public override bool SetFreq(FrequencyUnit unit, double freq) 111 | { 112 | 113 | string sendMsg = "FREQ:CW " + freq; 114 | switch (unit) 115 | { 116 | case FrequencyUnit.Hz: 117 | sendMsg += "Hz;"; 118 | break; 119 | case FrequencyUnit.KHz: 120 | sendMsg += "KHz;"; 121 | break; 122 | case FrequencyUnit.MHz: 123 | sendMsg += "MHz;"; 124 | break; 125 | case FrequencyUnit.GHz: 126 | sendMsg += "GHz;"; 127 | break; 128 | } 129 | try 130 | { 131 | return base.WriteString(sendMsg); 132 | } 133 | catch (Exception ex) 134 | { 135 | throw (ex); 136 | } 137 | } 138 | 139 | /// 140 | /// 设置功率 141 | /// 142 | /// 功率 143 | /// 144 | public override bool SetLevel(double level) 145 | { 146 | 147 | string sendMsg = "POW:LEV " + level + "DBM"; 148 | try 149 | { 150 | return base.WriteString(sendMsg); 151 | } 152 | catch (Exception ex) 153 | { 154 | throw (ex); 155 | } 156 | } 157 | 158 | 159 | 160 | /// 161 | /// 打开脉冲发生器 162 | /// 163 | /// 164 | /// 165 | public override bool SetPulseSwitch(bool state) 166 | { 167 | string sendMsg = string.Empty; 168 | if (state) 169 | sendMsg = "PULM:STATe ON"; 170 | else 171 | sendMsg = "PULM:STATe OFF"; 172 | try 173 | { 174 | return base.WriteString(sendMsg); 175 | 176 | } 177 | catch (Exception ex) 178 | { 179 | throw (ex); 180 | } 181 | } 182 | 183 | /// 184 | /// 设置脉冲信号带宽 185 | /// 186 | /// 带宽(范围:10ns – 60s-10ns),单位:us 复位10us 187 | /// 188 | public override bool SetPulseWidth(double width) 189 | { 190 | //PULSe:WIDTh 200us 191 | string sendMsg = "PULM:INTernal:PWIDth " + width + "us"; 192 | try 193 | { 194 | return base.WriteString(sendMsg); 195 | 196 | } 197 | catch (Exception ex) 198 | { 199 | throw (ex); 200 | } 201 | } 202 | 203 | 204 | /// 205 | /// 设置脉冲周期(必须大于信号带宽) 206 | /// 207 | /// 带宽(范围:20ns – 60s),单位:us 复位20us 208 | /// 209 | public override bool SetPulsePeriod(double period) 210 | { 211 | //PULSe:PERiod 100us 212 | string sendMsg = "PULM:INTernal:PERiod " + period + "us"; 213 | try 214 | { 215 | return base.WriteString(sendMsg); 216 | 217 | } 218 | catch (Exception ex) 219 | { 220 | throw (ex); 221 | } 222 | } 223 | 224 | 225 | /// 226 | /// 设置调制开关 227 | /// 228 | /// 229 | /// 230 | public override bool SetModulationSwitch(bool state) 231 | { 232 | string sendMsg = string.Empty; 233 | if (state) 234 | sendMsg = "OUTPut:MODulation ON"; 235 | else 236 | sendMsg = "OUTPut:MODulation OFF"; 237 | try 238 | { 239 | return base.WriteString(sendMsg); 240 | 241 | } 242 | catch (Exception ex) 243 | { 244 | throw (ex); 245 | } 246 | } 247 | 248 | 249 | } 250 | } 251 | -------------------------------------------------------------------------------- /InstrumentUtilityDotNet/SignalSourceManager/HP_8360.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace InstrumentUtilityDotNet.SignalSourceManager 8 | { 9 | 10 | /// 11 | ///HP8360系列 12 | /// 13 | public class HP_8360 : ISignalSource 14 | { 15 | 16 | /// 17 | /// 获取设备ID号 18 | /// 19 | public override string GetID() 20 | { 21 | string sendMsg = "*IDN?"; 22 | try 23 | { 24 | return base.WriteAndReadString(sendMsg); 25 | } 26 | catch (Exception ex) 27 | { 28 | throw (ex); 29 | } 30 | } 31 | 32 | /// 33 | /// 初始化仪表参数 34 | /// 35 | /// 36 | public override bool Reset() 37 | { 38 | string sendMsg = "*RST"; 39 | try 40 | { 41 | return base.WriteString(sendMsg); 42 | } 43 | catch (Exception ex) 44 | { 45 | throw (ex); 46 | } 47 | } 48 | 49 | /// 50 | /// 信号源发射开关 51 | /// 52 | /// On:打开发射 Off:关闭发射 53 | /// 54 | public override bool SetSignalSourceState(bool state) 55 | { 56 | string sendMsg = string.Empty; 57 | if (state) 58 | sendMsg = "OUTPut:STATe ON"; 59 | else 60 | sendMsg = "OUTPut:STATe OFF"; 61 | try 62 | { 63 | return base.WriteString(sendMsg); 64 | } 65 | catch (Exception ex) 66 | { 67 | throw (ex); 68 | } 69 | 70 | } 71 | 72 | 73 | /// 74 | /// 设置频率、功率 75 | /// 76 | /// 频率单位 77 | /// 频率 78 | /// 功率,单位DBM 79 | /// 80 | public override bool SetFreqAndLevel(FrequencyUnit unit, double freq, double level) 81 | { 82 | 83 | string sendMsg = "FREQ:CW "+ freq; 84 | switch (unit) 85 | { 86 | case FrequencyUnit.Hz: 87 | sendMsg += "Hz;"; 88 | break; 89 | case FrequencyUnit.KHz: 90 | sendMsg += "KHz;"; 91 | break; 92 | case FrequencyUnit.MHz: 93 | sendMsg += "MHz;"; 94 | break; 95 | case FrequencyUnit.GHz: 96 | sendMsg += "GHz;"; 97 | break; 98 | } 99 | sendMsg += ":POW:LEV " + level + "DBM"; 100 | try 101 | { 102 | return base.WriteString(sendMsg); 103 | } 104 | catch (Exception ex) 105 | { 106 | throw (ex); 107 | } 108 | } 109 | 110 | /// 111 | /// 设置频率 112 | /// 113 | /// 频率单位 114 | /// 频率 115 | /// 116 | public override bool SetFreq(FrequencyUnit unit, double freq) 117 | { 118 | 119 | string sendMsg = "FREQ:CW "+ freq; 120 | switch (unit) 121 | { 122 | case FrequencyUnit.Hz: 123 | sendMsg += "Hz;"; 124 | break; 125 | case FrequencyUnit.KHz: 126 | sendMsg += "KHz;"; 127 | break; 128 | case FrequencyUnit.MHz: 129 | sendMsg += "MHz;"; 130 | break; 131 | case FrequencyUnit.GHz: 132 | sendMsg += "GHz;"; 133 | break; 134 | } 135 | try 136 | { 137 | return base.WriteString(sendMsg); 138 | } 139 | catch (Exception ex) 140 | { 141 | throw (ex); 142 | } 143 | } 144 | 145 | /// 146 | /// 设置功率 147 | /// 148 | /// 功率 149 | /// 150 | public override bool SetLevel (double level) 151 | { 152 | 153 | string sendMsg = ":POW:LEV " + level + "DBM"; 154 | try 155 | { 156 | return base.WriteString(sendMsg); 157 | } 158 | catch (Exception ex) 159 | { 160 | throw (ex); 161 | } 162 | } 163 | 164 | 165 | 166 | /// 167 | /// 打开脉冲发生器 168 | /// 169 | /// 170 | /// 171 | public override bool SetPulseSwitch(bool state) 172 | { 173 | string sendMsg = string.Empty; 174 | if (state) 175 | sendMsg = "PULM:STATe ON"; 176 | else 177 | sendMsg = "PULM:STATe OFF"; 178 | try 179 | { 180 | return base.WriteString(sendMsg); 181 | } 182 | catch (Exception ex) 183 | { 184 | throw (ex); 185 | } 186 | } 187 | 188 | /// 189 | /// 设置脉冲信号带宽 190 | /// 191 | /// 带宽(范围:1us to 65.5 ms),单位:us 192 | /// 193 | public override bool SetPulseWidth(double width) 194 | { 195 | //PULSe:WIDTh 200us 196 | string sendMsg = "PULM:INTernal:WIDth " + width + "us"; 197 | try 198 | { 199 | return base.WriteString(sendMsg); 200 | } 201 | catch (Exception ex) 202 | { 203 | throw (ex); 204 | } 205 | } 206 | 207 | 208 | /// 209 | /// 设置脉冲周期(必须大于信号带宽) 210 | /// 211 | /// 带宽(范围:2us - 信号带宽,max:65.5 ms),单位:us 212 | /// 213 | public override bool SetPulsePeriod(double period) 214 | { 215 | //PULSe:PERiod 100us 216 | string sendMsg = "PULM:INTernal:PERiod " + period + "us"; 217 | try 218 | { 219 | return base.WriteString(sendMsg); 220 | } 221 | catch (Exception ex) 222 | { 223 | throw (ex); 224 | } 225 | } 226 | 227 | 228 | /// 229 | /// 设置调制开关 230 | /// 231 | /// 232 | /// 233 | public override bool SetModulationSwitch(bool state) 234 | { 235 | string sendMsg = string.Empty; 236 | if (state) 237 | sendMsg = "OUTPut:MODulation ON"; 238 | else 239 | sendMsg = "OUTPut:MODulation OFF"; 240 | try 241 | { 242 | return base.WriteString(sendMsg); 243 | 244 | } 245 | catch (Exception ex) 246 | { 247 | throw (ex); 248 | } 249 | } 250 | } 251 | 252 | } 253 | -------------------------------------------------------------------------------- /InstrumentUtilityDotNet/SpectrumAnalyzerManager/RS_FSU.cs: -------------------------------------------------------------------------------- 1 | using Ivi.Visa; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace InstrumentUtilityDotNet.SpectrumAnalyzerManager 9 | { 10 | public class RS_FSU : ISpectrumAnalyzer 11 | { 12 | 13 | /// 14 | /// 获取设备ID号 15 | /// 16 | public override string GetID() 17 | { 18 | string sendMsg = "*IDN?"; 19 | try 20 | { 21 | return base.WriteAndReadString(sendMsg); 22 | } 23 | catch (Exception ex) 24 | { 25 | throw (ex); 26 | } 27 | } 28 | 29 | /// 30 | /// 初始化仪表参数 31 | /// 32 | /// 33 | public override bool Reset() 34 | { 35 | string sendMsg = "*RST"; 36 | try 37 | { 38 | return base.WriteString(sendMsg); 39 | } 40 | catch (Exception ex) 41 | { 42 | throw (ex); 43 | } 44 | } 45 | 46 | 47 | 48 | /// 49 | /// 获取中心频率 50 | /// 51 | /// 52 | public override double GetCenterFreq() 53 | { 54 | string recvMsg = null; 55 | try 56 | { 57 | recvMsg = base.WriteAndReadString("FREQ:CENT?"); 58 | if (recvMsg != "") 59 | return Convert.ToDouble(recvMsg); 60 | else 61 | return 0; 62 | } 63 | catch (Exception ex) 64 | { 65 | throw (ex); 66 | } 67 | } 68 | 69 | 70 | /// 71 | /// 获取MKA 峰值电平 72 | /// 73 | /// 74 | public override double GetMKA() 75 | { 76 | string recvMsg = null; 77 | try 78 | { 79 | recvMsg = base.WriteAndReadString("CALC:MARK:Y?"); 80 | double x = -999; 81 | bool res = double.TryParse(recvMsg, out x); 82 | if (res) 83 | return x; 84 | else 85 | return -999; 86 | } 87 | catch (Exception ex) 88 | { 89 | throw (ex); 90 | } 91 | 92 | } 93 | 94 | /// 95 | /// 设置中心频率 96 | /// 97 | /// 值 98 | /// 频率单位 99 | /// 100 | public override bool SetCenterFreq( double value, FrequencyUnit unit) 101 | { 102 | string sendMsg = "FREQ:CENT " + value; 103 | switch (unit) 104 | { 105 | case FrequencyUnit.Hz: 106 | sendMsg += "Hz"; 107 | break; 108 | case FrequencyUnit.KHz: 109 | sendMsg += "KHz"; 110 | break; 111 | case FrequencyUnit.MHz: 112 | sendMsg += "MHz"; 113 | break; 114 | case FrequencyUnit.GHz: 115 | sendMsg += "GHz"; 116 | break; 117 | } 118 | 119 | try 120 | { 121 | return base.WriteString(sendMsg); 122 | } 123 | catch (Exception ex) 124 | { 125 | throw (ex); 126 | } 127 | } 128 | /// 129 | /// 设置RBW 130 | /// 131 | /// 自动/手动RBW 132 | /// 分辨率带宽,单位KHz 133 | /// 134 | public override bool SetRBW(bool isAuto, double value = 0 ) 135 | { 136 | string sendMsg = null; 137 | try 138 | { 139 | if (isAuto) 140 | { 141 | sendMsg = "BAND:AUTO ON"; 142 | return base.WriteString(sendMsg); 143 | } 144 | else 145 | { 146 | sendMsg = "BAND:AUTO OFF;BAND:RES " + value + "kHz;"; 147 | return base.WriteString(sendMsg); 148 | } 149 | } 150 | catch (Exception ex) 151 | { 152 | throw (ex); 153 | } 154 | } 155 | 156 | 157 | /// 158 | /// 设置参考电平 159 | /// 160 | /// 参考电平,单位dBm 161 | /// 162 | public override bool SetRefLevel(double value) 163 | { 164 | string sendMsg = "DISP:WIND:TRAC:Y:RLEV " + value + "dBm;"; 165 | try 166 | { 167 | return base.WriteString(sendMsg); 168 | } 169 | catch (Exception ex) 170 | { 171 | throw (ex); 172 | } 173 | } 174 | 175 | /// 176 | /// 激活标记并搜索峰值 177 | /// 178 | /// 179 | public override bool MarkPeak() 180 | { 181 | string sendMsg = "CALC:MARK:MAX"; 182 | try 183 | { 184 | return base.WriteString(sendMsg); 185 | } 186 | catch (Exception ex) 187 | { 188 | throw (ex); 189 | } 190 | } 191 | 192 | /// 193 | /// 设置衰减 194 | /// 195 | /// 自动/手动衰减 196 | /// 衰减值 单位DB 197 | /// 198 | public override bool SetAttenuation(bool isAuto, double value =0 ) 199 | { 200 | string sendMsg = null; 201 | if (isAuto) 202 | { 203 | sendMsg = "INP:ATT:AUTO ON"; 204 | } 205 | else 206 | { 207 | sendMsg = "INP:ATT " + value + "DB" ; 208 | } 209 | try 210 | { 211 | return base.WriteString(sendMsg); 212 | } 213 | catch (Exception ex) 214 | { 215 | Console.WriteLine(ex.Message); 216 | return false; 217 | } 218 | 219 | } 220 | 221 | 222 | /// 223 | /// 设置SPAN 224 | /// 225 | /// 带宽 226 | /// 单位 227 | /// 228 | public override bool SetSpan(double value, FrequencyUnit unit) 229 | { 230 | string sendMsg = "FREQ:SPAN " + value+ unit.ToString(); 231 | try 232 | { 233 | return base.WriteString(sendMsg); 234 | } 235 | catch (Exception ex) 236 | { 237 | throw (ex); 238 | } 239 | } 240 | 241 | /// 242 | /// 线损设置 REF LVL OFFSET 243 | /// 244 | /// 245 | /// 246 | public override bool SetRefOffset(double value) 247 | { 248 | string sendMsg = " "; 249 | try 250 | { 251 | return base.WriteString(sendMsg); 252 | } 253 | catch (Exception ex) 254 | { 255 | throw (ex); 256 | } 257 | } 258 | } 259 | } 260 | -------------------------------------------------------------------------------- /InstrumentUtilityDotNet/NetworkAnalyzerManager/INetworkAnalyzer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace InstrumentUtilityDotNet.NetworkAnalyzerManager 7 | { 8 | public abstract class INetworkAnalyzer : InstrumentManager 9 | { 10 | /// 11 | /// 数据格式 12 | /// 13 | public enum Format 14 | { 15 | //Log Mag|Phase|Group Delay|Lin Mag|SWR|Real|Imaginary|Expand Phase| Positive Phase 16 | /// 17 | /// Log Mag 对数幅度格式 18 | /// 19 | MLOGarithmic, 20 | /// 21 | /// 相位格式 22 | /// 23 | PHASe, 24 | /// 25 | /// 群延迟格式 26 | /// 27 | GDELay, 28 | /// 29 | /// Smith图表格式(线性/相位) 30 | /// 31 | SLINear, 32 | /// 33 | /// Smith图表格式(对数/相位) 34 | /// 35 | SLOGarithmic, 36 | /// 37 | /// Smith图表格式(实部/虚部) 38 | /// 39 | SCOMplex, 40 | /// 41 | /// Smith图表格式(R+jX) 42 | /// 43 | SMITh, 44 | /// 45 | /// Smith图表格式(G+jB) 46 | /// 47 | SADMittance, 48 | /// 49 | /// 极性格式(Lin/相位) 50 | /// 51 | PLINear, 52 | /// 53 | /// 极性格式(对数/相位) 54 | /// 55 | PLOGarithmic, 56 | /// 57 | /// 极性格式(实部/虚部) 58 | /// 59 | POLar, 60 | /// 61 | /// 线性幅度格式 62 | /// 63 | MLINear, 64 | /// 65 | /// SWR格式 66 | /// 67 | SWR, 68 | /// 69 | /// 实部格式 70 | /// 71 | REAL, 72 | /// 73 | /// 虚部格式 74 | /// 75 | IMAGinary, 76 | /// 77 | /// 扩展相位格式 78 | /// 79 | UPHase, 80 | /// 81 | /// 正相位格式 82 | /// 83 | PPHase 84 | } 85 | 86 | 87 | /// 88 | /// 标记类型设置 89 | /// 90 | public enum MARKType 91 | { 92 | MAXimum, 93 | MINimum, 94 | PEAK 95 | } 96 | 97 | 98 | /// 99 | /// 触发模式 100 | /// 101 | public enum TriggerMode 102 | { 103 | Hold, 104 | Single, 105 | Continuous 106 | } 107 | 108 | /// 109 | /// 连接仪表 110 | /// 111 | /// 112 | /// 113 | public bool Connect(string address) 114 | { 115 | return base.Open(address); 116 | } 117 | 118 | /// 119 | /// 断开连接 120 | /// 121 | public void DisConnect() 122 | { 123 | base.Close(); 124 | } 125 | /// 126 | /// Write 127 | /// 128 | /// 129 | public void WriteCommand(string command) 130 | { 131 | base.WriteString(command); 132 | } 133 | 134 | /// 135 | /// WriteAndRead 136 | /// 137 | /// 138 | /// 139 | public string WriteAndReadCommand(string command) 140 | { 141 | return base.WriteAndReadString(command); 142 | } 143 | /// 144 | /// 获取设备ID号 145 | /// 146 | /// 147 | public abstract string GetID(); 148 | 149 | /// 150 | /// 初始化仪表参数 151 | /// 152 | /// 153 | public abstract bool Reset(); 154 | 155 | 156 | /// 157 | /// 设置开始频率 158 | /// 159 | /// Hz 160 | /// 161 | public abstract bool SetStartFreq(ulong freq); 162 | 163 | /// 164 | /// 设置终止频率 165 | /// 166 | /// Hz 167 | /// 168 | public abstract bool SetStopFreq(ulong freq); 169 | /// 170 | /// 设置测量点数 171 | /// 172 | /// 173 | /// 174 | public abstract bool SetSweepPoints(int num); 175 | /// 176 | /// 设置中心频率 177 | /// 178 | /// Hz 179 | /// 180 | public abstract bool SetCenterFreq(ulong freq); 181 | 182 | /// 183 | /// 设置带宽 184 | /// 185 | /// Hz 186 | /// 187 | public abstract bool SetSpan(ulong span); 188 | 189 | /// 190 | // (显示参数)对选择的通道(Ch)设置选择迹线(Tr)的测量参数。 191 | /// 192 | //从下列两项中选择: 193 | //“S” 194 | //这里: 195 | //x=1到4 196 | //Y=1到4 197 | //A|B|C|D 198 | //R(X= 1 - 4) 199 | //AUX1或AUX2 200 | /// 201 | public abstract bool SetDEFine(string para); 202 | 203 | /// 204 | /// 设置数据格式 205 | /// 206 | /// 207 | /// 208 | public abstract bool SetDataFormat(Format format); 209 | 210 | 211 | /// 212 | /// 标记类型设置 213 | /// 214 | /// 标记编号 215 | /// 标记类型 216 | /// 217 | public abstract bool SetMarkType(int markID,MARKType type); 218 | 219 | /// 220 | /// 获取Mark点Y值 221 | /// 222 | /// 标记编号 223 | /// 返回值 224 | /// 225 | public abstract bool ReadMarkY(int markID, out double[] values); 226 | 227 | /// 228 | /// 设置外部信号源功率设置的功率电平值 229 | /// 230 | /// 231 | /// 232 | public abstract bool SetLevel(double level); 233 | 234 | /// 235 | /// 开启/关闭激励信号输出,激励信号输出开启时才能进行测量 236 | /// 237 | /// 238 | /// 239 | public abstract bool SetRFOut(bool onoff); 240 | 241 | 242 | 243 | /// 244 | /// 设置触发模式 245 | /// 246 | /// 247 | /// 248 | public abstract bool SetTriggerMode(TriggerMode mode); 249 | 250 | /// 251 | /// 设置中频带宽 252 | /// 253 | /// 254 | /// 255 | public abstract bool SetBandwidth(double bandwidth ); 256 | 257 | 258 | } 259 | 260 | 261 | } 262 | -------------------------------------------------------------------------------- /InstrumentUtilityDotNet/SpectrumAnalyzerManager/Agilent_856x.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace InstrumentUtilityDotNet.SpectrumAnalyzerManager 4 | { 5 | public class Agilent_856x : ISpectrumAnalyzer 6 | { 7 | /// 8 | /// 获取设备ID号 9 | /// 10 | public override string GetID() 11 | { 12 | string sendMsg = "ID?;"; 13 | try 14 | { 15 | return base.WriteAndReadString(sendMsg); 16 | } 17 | catch (Exception ex) 18 | { 19 | throw (ex); 20 | } 21 | } 22 | /// 23 | /// 初始化仪表参数 24 | /// 25 | /// 26 | public override bool Reset() 27 | { 28 | string sendMsg = "IP;"; 29 | try 30 | { 31 | return base.WriteString(sendMsg); 32 | } 33 | catch (Exception ex) 34 | { 35 | throw (ex); 36 | } 37 | } 38 | 39 | 40 | 41 | /// 42 | /// 获取中心频率 43 | /// 44 | /// 45 | public override double GetCenterFreq() 46 | { 47 | string recvMsg = null; 48 | try 49 | { 50 | recvMsg = base.WriteAndReadString("CF?;"); 51 | if (recvMsg != "") 52 | return Convert.ToDouble(recvMsg); 53 | else 54 | return 0; 55 | } 56 | catch (Exception ex) 57 | { 58 | throw (ex); 59 | } 60 | } 61 | 62 | 63 | /// 64 | /// 获取MKA 峰值电平 65 | /// 66 | /// 67 | public override double GetMKA() 68 | { 69 | string recvMsg = null; 70 | try 71 | { 72 | recvMsg = base.WriteAndReadString("MKA?;"); 73 | double x = -999; 74 | bool res = double.TryParse(recvMsg, out x); 75 | if (res) 76 | return x; 77 | else 78 | return -999; 79 | } 80 | catch (Exception ex) 81 | { 82 | throw (ex); 83 | } 84 | 85 | } 86 | 87 | /// 88 | /// 设置中心频率 89 | /// 90 | /// 值 91 | /// 频率单位 92 | /// 93 | public override bool SetCenterFreq(double value, FrequencyUnit unit) 94 | { 95 | string sendMsg = "CF " + value; 96 | switch (unit) 97 | { 98 | case FrequencyUnit.Hz: 99 | sendMsg += "Hz"; 100 | break; 101 | case FrequencyUnit.KHz: 102 | sendMsg += "KHz"; 103 | break; 104 | case FrequencyUnit.MHz: 105 | sendMsg += "MHz"; 106 | break; 107 | case FrequencyUnit.GHz: 108 | sendMsg += "GHz"; 109 | break; 110 | } 111 | 112 | try 113 | { 114 | return base.WriteString(sendMsg); 115 | } 116 | catch (Exception ex) 117 | { 118 | throw (ex); 119 | } 120 | } 121 | 122 | /// 123 | /// 设置RBW 124 | /// 125 | /// 自动/手动RBW 126 | /// 分辨率带宽,单位KHz 127 | /// 128 | public override bool SetRBW(bool isAuto, double value = 0) 129 | { 130 | string sendMsg = null; 131 | try 132 | { 133 | if (isAuto) 134 | { 135 | sendMsg = "BAND:AUTO ON"; 136 | return base.WriteString(sendMsg); 137 | } 138 | else 139 | { 140 | sendMsg = "BAND:AUTO OFF;RB " + value + "kHz;"; 141 | return base.WriteString(sendMsg); 142 | } 143 | } 144 | catch (Exception ex) 145 | { 146 | throw (ex); 147 | } 148 | } 149 | 150 | 151 | 152 | /// 153 | /// 设置参考电平 154 | /// 155 | /// 参考电平,单位dBm 156 | /// 157 | public override bool SetRefLevel(double value) 158 | { 159 | string sendMsg = "RL " + value + "dBm;"; 160 | try 161 | { 162 | return base.WriteString(sendMsg); 163 | } 164 | catch (Exception ex) 165 | { 166 | Console.WriteLine(ex.Message); 167 | return false; 168 | } 169 | } 170 | 171 | /// 172 | /// 激活标记并搜索峰值 173 | /// 174 | /// 175 | public override bool MarkPeak() 176 | { 177 | string sendMsg = "TS;MKPK HI;"; 178 | try 179 | { 180 | return base.WriteString(sendMsg); 181 | } 182 | catch (Exception ex) 183 | { 184 | Console.WriteLine(ex.Message); 185 | return false; 186 | } 187 | } 188 | 189 | /// 190 | /// 设置衰减 191 | /// 192 | /// 自动/手动衰减 193 | /// 衰减值 单位DB 194 | /// 195 | public override bool SetAttenuation(bool isAuto,double value) 196 | { 197 | string sendMsg = null; 198 | if (isAuto) 199 | { 200 | sendMsg = "AT AUTO"; 201 | } 202 | else 203 | { 204 | sendMsg = "AT MANUAL;AT " + value + "DB"; 205 | } 206 | try 207 | { 208 | return base.WriteString(sendMsg); 209 | } 210 | catch (Exception ex) 211 | { 212 | Console.WriteLine(ex.Message); 213 | return false; 214 | } 215 | 216 | } 217 | 218 | 219 | 220 | /// 221 | /// 设置SPAN 222 | /// 223 | /// 带宽 224 | /// 单位 225 | /// 226 | public override bool SetSpan(double value,FrequencyUnit unit) 227 | { 228 | string sendMsg = "SP " + value + unit.ToString(); 229 | try 230 | { 231 | return base.WriteString(sendMsg); 232 | 233 | } 234 | catch (Exception ex) 235 | { 236 | Console.WriteLine(ex.Message); 237 | return false; 238 | } 239 | } 240 | 241 | /// 242 | /// 线损设置 REF LVL OFFSET 243 | /// 244 | /// 245 | /// 246 | public override bool SetRefOffset(double value) 247 | { 248 | string sendMsg = "ROFFSET " + value +"dB"; 249 | try 250 | { 251 | return base.WriteString(sendMsg); 252 | } 253 | catch (Exception ex) 254 | { 255 | Console.WriteLine(ex.Message); 256 | return false; 257 | } 258 | } 259 | 260 | } 261 | } 262 | -------------------------------------------------------------------------------- /InstrumentUtilityDotNet/SpectrumAnalyzerManager/Ceyear_4024D.cs: -------------------------------------------------------------------------------- 1 | using Ivi.Visa; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace InstrumentUtilityDotNet.SpectrumAnalyzerManager 9 | { 10 | public class Ceyear_4024D : ISpectrumAnalyzer 11 | { 12 | 13 | /// 14 | /// 获取设备ID号 15 | /// 16 | public override string GetID() 17 | { 18 | string sendMsg = "*IDN?"; 19 | try 20 | { 21 | return base.WriteAndReadString(sendMsg); 22 | } 23 | catch (Exception ex) 24 | { 25 | throw (ex); 26 | } 27 | } 28 | 29 | /// 30 | /// 初始化仪表参数 31 | /// 32 | /// 33 | public override bool Reset() 34 | { 35 | string sendMsg = "*RST"; 36 | try 37 | { 38 | return base.WriteString(sendMsg); 39 | } 40 | catch (Exception ex) 41 | { 42 | throw (ex); 43 | } 44 | } 45 | 46 | 47 | 48 | /// 49 | /// 获取中心频率 50 | /// 51 | /// 52 | public override double GetCenterFreq() 53 | { 54 | string recvMsg = null; 55 | try 56 | { 57 | recvMsg = base.WriteAndReadString(":FREQ:CENT?"); 58 | if (recvMsg != "") 59 | return Convert.ToDouble(recvMsg); 60 | else 61 | return 0; 62 | } 63 | catch (Exception ex) 64 | { 65 | throw (ex); 66 | } 67 | } 68 | 69 | 70 | /// 71 | /// 获取MKA 峰值电平 72 | /// 73 | /// 74 | public override double GetMKA() 75 | { 76 | string recvMsg = null; 77 | try 78 | { 79 | recvMsg = base.WriteAndReadString(":CALC:MARK1:Y?"); 80 | double x= -999; 81 | bool res = double.TryParse(recvMsg, out x); 82 | if (res) 83 | return x; 84 | else 85 | return -999; 86 | } 87 | catch (Exception ex) 88 | { 89 | throw (ex); 90 | } 91 | 92 | } 93 | 94 | /// 95 | /// 设置中心频率 96 | /// 97 | /// 值 98 | /// 频率单位 99 | /// 100 | public override bool SetCenterFreq(double value, FrequencyUnit unit) 101 | { 102 | string sendMsg = ":FREQ:CENT " + value; 103 | switch (unit) 104 | { 105 | case FrequencyUnit.Hz: 106 | sendMsg += "Hz"; 107 | break; 108 | case FrequencyUnit.KHz: 109 | sendMsg += "KHz"; 110 | break; 111 | case FrequencyUnit.MHz: 112 | sendMsg += "MHz"; 113 | break; 114 | case FrequencyUnit.GHz: 115 | sendMsg += "GHz"; 116 | break; 117 | } 118 | 119 | try 120 | { 121 | return base.WriteString(sendMsg); 122 | } 123 | catch (Exception ex) 124 | { 125 | throw (ex); 126 | } 127 | } 128 | /// 129 | /// 设置RBW 130 | /// 131 | /// 自动/手动RBW 132 | /// 分辨率带宽,单位KHz 133 | /// 134 | public override bool SetRBW(bool isAuto, double value = 0) 135 | { 136 | string sendMsg = null; 137 | try 138 | { 139 | if (isAuto) 140 | { 141 | sendMsg = ":BAND:AUTO ON"; 142 | return base.WriteString(sendMsg); 143 | } 144 | else 145 | { 146 | sendMsg = ":BAND:RES " + value + "kHz;"; 147 | return base.WriteString(sendMsg); 148 | } 149 | } 150 | catch (Exception ex) 151 | { 152 | throw (ex); 153 | } 154 | } 155 | 156 | 157 | /// 158 | /// 设置参考电平 159 | /// 160 | /// 参考电平,单位dBm 161 | /// 162 | public override bool SetRefLevel(double value) 163 | { 164 | 165 | string sendMsg = ":DISP:WIND:TRAC:Y:RLEV " + value; 166 | try 167 | { 168 | return base.WriteString(sendMsg); 169 | } 170 | catch (Exception ex) 171 | { 172 | throw (ex); 173 | } 174 | } 175 | 176 | /// 177 | /// 激活标记并搜索峰值 178 | /// 179 | /// 180 | public override bool MarkPeak() 181 | { 182 | //string sendMsg = ":CALC:MARK:MAX"; 183 | string sendMsg = ":CALC:MARK1:FUNC:PEAK"; 184 | try 185 | { 186 | return base.WriteString(sendMsg); 187 | } 188 | catch (Exception ex) 189 | { 190 | throw (ex); 191 | } 192 | } 193 | 194 | /// 195 | /// 设置衰减 196 | /// 197 | /// 自动/手动衰减 198 | /// 衰减值 单位DB 199 | /// 200 | public override bool SetAttenuation(bool isAuto, double value = 0) 201 | { 202 | string sendMsg = null; 203 | if (isAuto) 204 | { 205 | sendMsg = ":POWer:ATTenuation:AUTO ON"; 206 | } 207 | else 208 | { 209 | sendMsg = ":POWer:ATTenuation " + value; 210 | } 211 | try 212 | { 213 | return base.WriteString(sendMsg); 214 | } 215 | catch (Exception ex) 216 | { 217 | Console.WriteLine(ex.Message); 218 | return false; 219 | } 220 | 221 | } 222 | 223 | 224 | /// 225 | /// 设置SPAN 226 | /// 227 | /// 带宽 228 | /// 单位 229 | /// 230 | public override bool SetSpan(double value, FrequencyUnit unit) 231 | { 232 | string sendMsg = ":FREQ:SPAN " + value + unit.ToString(); 233 | try 234 | { 235 | return base.WriteString(sendMsg); 236 | } 237 | catch (Exception ex) 238 | { 239 | throw (ex); 240 | } 241 | } 242 | 243 | /// 244 | /// 线损设置 REF LVL OFFSET 245 | /// 246 | /// 247 | /// 248 | public override bool SetRefOffset(double value) 249 | { 250 | string sendMsg = " "; 251 | try 252 | { 253 | return base.WriteString(sendMsg); 254 | } 255 | catch (Exception ex) 256 | { 257 | throw (ex); 258 | } 259 | } 260 | } 261 | } 262 | -------------------------------------------------------------------------------- /InstrumentUtilityDotNet/NetworkAnalyzerManager/RS_ZNB.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace InstrumentUtilityDotNet.NetworkAnalyzerManager 7 | { 8 | public class RS_ZNB : INetworkAnalyzer 9 | { 10 | 11 | /// 12 | /// 获取设备ID号 13 | /// 14 | public override string GetID() 15 | { 16 | string sendMsg = "*IDN?"; 17 | try 18 | { 19 | return base.WriteAndReadString(sendMsg); 20 | } 21 | catch (Exception ex) 22 | { 23 | throw (ex); 24 | } 25 | } 26 | 27 | /// 28 | /// 初始化仪表参数 29 | /// 30 | /// 31 | public override bool Reset() 32 | { 33 | string sendMsg = "*RST"; 34 | try 35 | { 36 | return base.WriteString(sendMsg); 37 | 38 | } 39 | catch (Exception ex) 40 | { 41 | throw (ex); 42 | } 43 | } 44 | 45 | /// 46 | /// 设置开始频率 47 | /// 48 | /// Hz 49 | public override bool SetStartFreq(ulong freq) 50 | { 51 | string sendMsg = ":SENS1:FREQuency:STARt " + freq.ToString(); 52 | try 53 | { 54 | return base.WriteString(sendMsg); 55 | } 56 | catch (Exception ex) 57 | { 58 | throw (ex); 59 | } 60 | 61 | } 62 | 63 | /// 64 | /// 设置终止频率 65 | /// 66 | /// Hz 67 | public override bool SetStopFreq(ulong freq) 68 | { 69 | string sendMsg = ":SENS1:FREQuency:STOP " + freq.ToString(); 70 | try 71 | { 72 | return base.WriteString(sendMsg); 73 | } 74 | catch (Exception ex) 75 | { 76 | throw (ex); 77 | } 78 | 79 | } 80 | 81 | /// 82 | /// 设置测量点数 83 | /// 84 | /// 2到20001 85 | public override bool SetSweepPoints(int num) 86 | { 87 | string sendMsg = ":SENS1:SWE:POIN " + num.ToString(); 88 | try 89 | { 90 | return base.WriteString(sendMsg); 91 | } 92 | catch (Exception ex) 93 | { 94 | throw (ex); 95 | } 96 | 97 | } 98 | 99 | /// 100 | /// 设置中心频率 101 | /// 102 | /// Hz 103 | public override bool SetCenterFreq(ulong freq) 104 | { 105 | string sendMsg = ":SENS1:FREQ:CENT " + freq.ToString(); 106 | try 107 | { 108 | return base.WriteString(sendMsg); 109 | } 110 | catch (Exception ex) 111 | { 112 | throw (ex); 113 | } 114 | 115 | } 116 | 117 | /// 118 | /// 设置带宽 119 | /// 120 | /// Hz 121 | public override bool SetSpan(ulong span) 122 | { 123 | string sendMsg = ":SENS1:FREQuency:SPAN " + span.ToString(); 124 | try 125 | { 126 | return base.WriteString(sendMsg); 127 | } 128 | catch (Exception ex) 129 | { 130 | throw (ex); 131 | } 132 | } 133 | 134 | /// 135 | /// (显示参数)对选择的通道(Ch)设置选择迹线(Tr)的测量参数。 136 | /// 137 | /// "S21":测试频段,"S11":测试频段 138 | /// 139 | public override bool SetDEFine(string para="S21") 140 | { 141 | string sendMsg = ":CALC1:PAR1:DEF " + para; 142 | try 143 | { 144 | return base.WriteString(sendMsg); 145 | } 146 | catch (Exception ex) 147 | { 148 | throw (ex); 149 | } 150 | } 151 | 152 | /// 153 | /// 设置数据格式 154 | /// 155 | /// 156 | /// 157 | public override bool SetDataFormat(Format format) 158 | { 159 | string sendMsg = "CALC1:FORM " + format.ToString(); 160 | try 161 | { 162 | return base.WriteString(sendMsg); 163 | 164 | } 165 | catch (Exception ex) 166 | { 167 | throw (ex); 168 | } 169 | } 170 | 171 | /// 172 | /// 标记类型设置 173 | /// 174 | /// 175 | public override bool SetMarkType(int markID, MARKType type) 176 | { 177 | string sendMsg1 = string.Format(":CALC1:MARK{0}:FUNC:TYPE {1}", markID, type); 178 | string sendMsg2 = string.Format(":CALC1:MARK{0} ON", markID); 179 | string sendMsg3 = string.Format(":CALC1:MARK{0}:FUNC:TRAC ON", markID); 180 | 181 | try 182 | { 183 | bool ret1 = base.WriteString(sendMsg1); 184 | bool ret2 = base.WriteString(sendMsg2); 185 | bool ret3 = base.WriteString(sendMsg3); 186 | return ret1 && ret2 && ret3; 187 | } 188 | catch (Exception ex) 189 | { 190 | throw (ex); 191 | } 192 | } 193 | 194 | /// 195 | /// 获取Mark点Y值 196 | /// 197 | /// 198 | public override bool ReadMarkY(int markID, out double[] values) 199 | { 200 | values = new double[2]; 201 | string sendMsg = string.Format(":CALC1:MARK{0}:Y?", markID); 202 | try 203 | { 204 | string data = base.WriteAndReadString(sendMsg); 205 | //返回示例: +3.94924525217E-003,+0.00000000000E+000 数据(0):标记位置的响应值(主值)。 数据(1):标记位置的响应值(次值)。数据格式不是Smith图表格式或极性格式时数据值始终为0。 206 | if (data != "") 207 | { 208 | string[] arr = data.Split(','); 209 | values[0]= double.Parse(arr[0]); 210 | values[1]= double.Parse(arr[1]); 211 | return true; 212 | } 213 | else 214 | return false; 215 | } 216 | catch (Exception ex) 217 | { 218 | 219 | return false; 220 | } 221 | } 222 | 223 | 224 | 225 | 226 | /// 227 | /// 设置选择通道(Ch)的功率电平 228 | /// 229 | /// 功率dBm 230 | /// 231 | public override bool SetLevel(double level) 232 | { 233 | string sendMsg = "SOUR1:POW:LEV " + level.ToString(); 234 | try 235 | { 236 | return base.WriteString(sendMsg); 237 | } 238 | catch (Exception ex) 239 | { 240 | throw (ex); 241 | } 242 | } 243 | 244 | /// 245 | /// 射频开关 246 | /// 247 | /// 248 | /// 249 | public override bool SetRFOut(bool onoff) 250 | { 251 | string sendMsg = ""; 252 | if (onoff) 253 | sendMsg = ":OUTP ON"; 254 | else 255 | sendMsg = ":OUTP OFF"; 256 | try 257 | { 258 | return base.WriteString(sendMsg); 259 | 260 | } 261 | catch (Exception ex) 262 | { 263 | throw (ex); 264 | } 265 | } 266 | 267 | /// 268 | /// 设置触发模式 269 | /// 270 | /// 271 | /// 272 | public override bool SetTriggerMode(TriggerMode mode) 273 | { 274 | string sendMsg = ""; 275 | switch (mode) 276 | { 277 | case TriggerMode.Hold: 278 | sendMsg = ":INIT1:CONT OFF"; 279 | break; 280 | case TriggerMode.Single: 281 | sendMsg = ":INIT1"; 282 | break; 283 | case TriggerMode.Continuous: 284 | sendMsg = ":INIT1:CONT ON"; 285 | break; 286 | } 287 | try 288 | { 289 | return base.WriteString(sendMsg); 290 | 291 | } 292 | catch (Exception ex) 293 | { 294 | throw (ex); 295 | } 296 | } 297 | 298 | /// 299 | /// 设置中频带宽 10到500000Hz 预设值70000Hz 300 | /// 301 | /// 302 | /// 303 | public override bool SetBandwidth(double bandwidth) 304 | { 305 | string sendMsg = ":SENSe1:BANDwidth " + bandwidth.ToString(); 306 | try 307 | { 308 | return base.WriteString(sendMsg); 309 | } 310 | catch (Exception ex) 311 | { 312 | throw (ex); 313 | } 314 | 315 | } 316 | 317 | 318 | } 319 | 320 | } -------------------------------------------------------------------------------- /InstrumentUtility/InstrumentUtility/InstrumentUtility.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {8C3D9735-D99F-4577-974C-50E3A475C886} 23 | Win32Proj 24 | InstrmentControl 25 | 8.1 26 | InstrumentUtility 27 | 28 | 29 | 30 | DynamicLibrary 31 | true 32 | v140 33 | Unicode 34 | 35 | 36 | DynamicLibrary 37 | false 38 | v140 39 | true 40 | Unicode 41 | 42 | 43 | DynamicLibrary 44 | true 45 | v140 46 | Unicode 47 | 48 | 49 | DynamicLibrary 50 | false 51 | v140 52 | true 53 | Unicode 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | true 75 | $(IncludePath) 76 | ..\Win32\Debug\ 77 | 78 | 79 | true 80 | $(IncludePath) 81 | ..\x64\Debug\ 82 | 83 | 84 | false 85 | $(VC_IncludePath);$(WindowsSDK_IncludePath); 86 | ..\Win32\Release\ 87 | 88 | 89 | false 90 | $(VC_IncludePath);$(WindowsSDK_IncludePath); 91 | ..\x64\Release\ 92 | 93 | 94 | 95 | Create 96 | Level3 97 | Disabled 98 | WIN32;_DEBUG;_WINDOWS;_USRDLL;INSTRMENTCONTROL_EXPORTS;%(PreprocessorDefinitions) 99 | true 100 | Default 101 | ..\Visa 102 | StdCall 103 | 104 | 105 | Windows 106 | true 107 | ..\Visa\x86;%(AdditionalLibraryDirectories) 108 | visa32.lib;%(AdditionalDependencies) 109 | 110 | 111 | 112 | 113 | 114 | 115 | Create 116 | Level3 117 | Disabled 118 | _DEBUG;_WINDOWS;_USRDLL;INSTRMENTCONTROL_EXPORTS;%(PreprocessorDefinitions) 119 | true 120 | ..\Visa; 121 | 122 | 123 | Windows 124 | true 125 | ..\Visa\x64;%(AdditionalLibraryDirectories) 126 | visa32.lib;%(AdditionalDependencies) 127 | 128 | 129 | 130 | 131 | Level3 132 | Create 133 | MaxSpeed 134 | true 135 | true 136 | WIN32;NDEBUG;_WINDOWS;_USRDLL;INSTRMENTCONTROL_EXPORTS;%(PreprocessorDefinitions) 137 | true 138 | ..\Visa;%(AdditionalIncludeDirectories) 139 | StdCall 140 | 141 | 142 | Windows 143 | true 144 | true 145 | true 146 | ..\Visa\x86; 147 | visa32.lib;%(AdditionalDependencies) 148 | 149 | 150 | 151 | 152 | Level3 153 | Create 154 | MaxSpeed 155 | true 156 | true 157 | NDEBUG;_WINDOWS;_USRDLL;INSTRMENTCONTROL_EXPORTS;%(PreprocessorDefinitions) 158 | true 159 | ..\Visa; 160 | 161 | 162 | Windows 163 | true 164 | true 165 | true 166 | ..\Visa\x64; 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | -------------------------------------------------------------------------------- /Sample/Cpp/InstrumentDemoCpp.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {AC751C3D-7208-40CA-B12E-E0C751080E17} 23 | Win32Proj 24 | Sample 25 | 8.1 26 | InstrumentDemoCpp 27 | 28 | 29 | 30 | Application 31 | true 32 | v140 33 | Unicode 34 | 35 | 36 | Application 37 | false 38 | v140 39 | true 40 | Unicode 41 | 42 | 43 | Application 44 | true 45 | v140 46 | Unicode 47 | 48 | 49 | Application 50 | false 51 | v140 52 | true 53 | Unicode 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | true 75 | $(VC_IncludePath);$(WindowsSDK_IncludePath) 76 | ..\..\InstrumentUtility\Win32\Debug 77 | 78 | 79 | true 80 | ..\..\InstrumentUtility\x64\Debug 81 | 82 | 83 | false 84 | $(VC_IncludePath);$(WindowsSDK_IncludePath); 85 | ..\..\InstrumentUtility\Win32\Release 86 | 87 | 88 | false 89 | ..\..\InstrumentUtility\x64\Release 90 | 91 | 92 | 93 | Use 94 | Level3 95 | Disabled 96 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 97 | true 98 | ..\..\InstrumentUtility\Visa;..\..\InstrumentUtility\InstrumentUtility;%(AdditionalIncludeDirectories) 99 | StdCall 100 | 101 | 102 | Console 103 | true 104 | ..\..\InstrumentUtility\Win32\Debug;%(AdditionalLibraryDirectories) 105 | InstrumentUtility.lib;%(AdditionalDependencies) 106 | 107 | 108 | 109 | 110 | 111 | 112 | Use 113 | Level3 114 | Disabled 115 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 116 | true 117 | ..\..\InstrumentUtility\Visa;..\..\InstrumentUtility\InstrumentUtility; 118 | StdCall 119 | 120 | 121 | Console 122 | true 123 | ..\..\InstrumentUtility\Win32\Debug 124 | InstrumentUtility.lib;%(AdditionalDependencies) 125 | 126 | 127 | 128 | 129 | Level3 130 | Use 131 | MaxSpeed 132 | true 133 | true 134 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 135 | true 136 | ..\..\InstrumentUtility\Visa;..\..\InstrumentUtility\InstrumentUtility 137 | Cdecl 138 | 139 | 140 | Console 141 | true 142 | true 143 | true 144 | ..\..\InstrumentUtility\Win32\Release 145 | InstrumentUtility.lib;%(AdditionalDependencies) 146 | 147 | 148 | 149 | 150 | Level3 151 | Use 152 | MaxSpeed 153 | true 154 | true 155 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 156 | true 157 | ..\..\InstrumentUtility\Visa;..\..\InstrumentUtility\InstrumentUtility; 158 | Cdecl 159 | 160 | 161 | Console 162 | true 163 | true 164 | true 165 | ..\..\InstrumentUtility\x64\Release 166 | InstrumentUtility.lib;%(AdditionalDependencies) 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | Create 180 | Create 181 | Create 182 | Create 183 | 184 | 185 | 186 | 187 | 188 | -------------------------------------------------------------------------------- /InstrumentUtilityDotNet/InstrumentManager.cs: -------------------------------------------------------------------------------- 1 | using Ivi.Visa.Interop; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace InstrumentUtilityDotNet 9 | { 10 | 11 | /// 12 | /// IO488协议对象通信管理类 13 | /// 14 | public class InstrumentManager 15 | { 16 | private ResourceManagerClass m_IOResourceManager = new ResourceManagerClass(); 17 | private FormattedIO488Class m_IO488 = null; 18 | private string receive = string.Empty; 19 | private InstrumentCommunicationMode commMode; 20 | /// 21 | /// 寻找所有仪表资源 22 | /// 23 | /// 24 | public string[] FindAllResource() 25 | { 26 | IEnumerable resources = m_IOResourceManager.FindRsrc("?*");//寻找仪表 27 | return resources.ToArray(); 28 | } 29 | 30 | /// 31 | /// 寻找所有GPIB资源 32 | /// 33 | /// 34 | public string[] FindGPIBResource() 35 | { 36 | IEnumerable resources = m_IOResourceManager.FindRsrc("GPIB?*"); 37 | return resources.ToArray(); 38 | } 39 | /// 40 | /// 寻找所有TCPIP资源 41 | /// 42 | /// 43 | public string[] FindTcpIpResource() 44 | { 45 | IEnumerable resources = m_IOResourceManager.FindRsrc("TCPIP?*"); 46 | return resources.ToArray(); 47 | } 48 | /// 49 | /// 寻找所有USB资源 50 | /// 51 | /// 52 | public string[] FindUSBResource() 53 | { 54 | IEnumerable resources = m_IOResourceManager.FindRsrc("USB?*"); 55 | return resources.ToArray(); 56 | } 57 | /// 58 | /// 连接IO488对象,GPIB,TCP协议 59 | /// 60 | /// GPIB0::" + addr + "::INSTR,TCPIP0::192.168.0.10::5000::SOCKET 61 | /// 62 | public bool Open(string m_IOName) 63 | { 64 | if (m_IOName.Contains("GPIB")) 65 | commMode = InstrumentCommunicationMode.GPIB; 66 | if (m_IOName.Contains("TCPIP")) 67 | commMode = InstrumentCommunicationMode.TCP; 68 | try 69 | { 70 | Close(); 71 | string m_Description = string.Empty; 72 | m_IO488 = new FormattedIO488Class(); 73 | // 初始化m_IOName指定的接口 74 | m_IO488.IO = (IMessage)m_IOResourceManager.Open(m_IOName, AccessMode.NO_LOCK,5000); //TCPIP0::172.17.200.11::5025::SOCKET TCPIP0::169.254.190.65::inst0::INSTR 75 | return true; 76 | } 77 | catch(Exception ex) 78 | { 79 | Console.WriteLine(ex.Message); 80 | return false; 81 | } 82 | } 83 | 84 | /// 85 | /// 关闭IO488 IO接口 86 | /// 87 | public void Close() 88 | { 89 | try 90 | { 91 | if (m_IO488 != null&& m_IO488.IO!=null) 92 | { 93 | m_IO488.IO.Close(); 94 | m_IO488 = null; 95 | } 96 | } 97 | catch { } 98 | } 99 | 100 | /// 101 | /// 清理IO接口缓存区函数、关闭接口函数、设置超时时间函数 102 | /// 103 | public void Clear() 104 | { 105 | try 106 | { 107 | 108 | if (m_IO488 != null) 109 | m_IO488.IO.Clear(); 110 | } 111 | catch { } 112 | } 113 | 114 | /// 115 | /// 发送命令 字符串型 116 | /// 117 | /// 118 | public bool WriteString(string m_Command) 119 | { 120 | try 121 | { 122 | int n = 0; 123 | if (m_IO488 != null && commMode == InstrumentCommunicationMode.TCP) 124 | { 125 | m_IO488.WriteString(m_Command, true); 126 | return true; 127 | } 128 | else if (m_IO488 != null && m_IO488.IO!=null) 129 | { 130 | n = m_IO488.IO.WriteString(m_Command); 131 | if (n == m_Command.Length) 132 | return true; 133 | } 134 | } 135 | catch (System.IO.IOException error) //掉线 136 | { 137 | return false; 138 | } 139 | catch (Exception ex) 140 | { 141 | if (ex.Message == "VI_ERROR_NCIC: Not the controller-in-charge") //GPIB掉线 142 | return false; 143 | return false; 144 | } 145 | return false; 146 | } 147 | 148 | 149 | 150 | /// 151 | /// 读取(字符串) 152 | /// 153 | /// 154 | public string ReadString() 155 | { 156 | string m_Temp = string.Empty; 157 | try 158 | { 159 | if (m_IO488 != null) 160 | { 161 | if (commMode == InstrumentCommunicationMode.TCP) 162 | { 163 | while (m_IO488.IO!=null) 164 | { 165 | string str = m_IO488.IO.ReadString(1); //单字节获取 166 | if (str == "\n") 167 | break; 168 | else 169 | m_Temp += str; 170 | } 171 | } 172 | else 173 | { 174 | if (m_IO488 != null) 175 | m_Temp = m_IO488.ReadString(); 176 | } 177 | } 178 | } 179 | catch (System.IO.IOException error) //控制箱掉线 180 | { 181 | throw error; 182 | } 183 | catch (Exception ex) 184 | { 185 | if (ex.Message == "VI_ERROR_NCIC: Not the controller-in-charge") //掉线 186 | throw ex; 187 | } 188 | return m_Temp; 189 | } 190 | /// 191 | /// 发送并读取(字符串) 192 | /// 193 | /// 194 | /// 195 | public string WriteAndReadString(string m_Command) 196 | { 197 | string m_Temp = string.Empty; 198 | try 199 | { 200 | bool res = WriteString(m_Command); 201 | if (m_IO488 != null) 202 | m_Temp = ReadString(); 203 | } 204 | catch (System.IO.IOException error) 205 | { 206 | throw error; 207 | } 208 | catch (Exception ex) 209 | { 210 | if (ex.Message == "VI_ERROR_NCIC: Not the controller-in-charge") //掉线 211 | throw ex; 212 | } 213 | 214 | return m_Temp; 215 | } 216 | 217 | 218 | /// 219 | /// 发送命令 字节型 220 | /// 221 | /// 222 | public void WriteBytes(byte[] m_Command) 223 | { 224 | try 225 | { 226 | 227 | if (m_IO488 != null) 228 | m_IO488.WriteNumber(m_Command, IEEEASCIIType.ASCIIType_Any, true); 229 | 230 | } 231 | catch (System.IO.IOException error) 232 | { 233 | throw error; 234 | } 235 | 236 | } 237 | 238 | 239 | /// 240 | /// 发送命令,在返回1之前停止命令处理 241 | /// 242 | /// 243 | /// 244 | public void WriteOpc(string m_Command, int m_Timeout) 245 | { 246 | try 247 | { 248 | if (m_IO488 != null) 249 | { 250 | m_IO488.WriteString(m_Command, false); 251 | m_IO488.WriteString("*OPC?", false); // 在返回1之前停止命令处理 252 | } 253 | 254 | string m_Temp = string.Empty; 255 | for (int i = 0; i < m_Timeout * 10; i++) 256 | if (ReadString().Length > 0) 257 | return; 258 | else 259 | System.Threading.Thread.Sleep(100); 260 | 261 | } 262 | catch { } 263 | } 264 | 265 | /// 266 | /// 读取(字节) 267 | /// 268 | /// 269 | public byte[] ReadByte() 270 | { 271 | byte[] m_Temp = null; 272 | try 273 | { 274 | if (m_IO488 != null) 275 | m_Temp = m_IO488.IO.Read(0); 276 | } 277 | catch (System.IO.IOException error) //控制箱掉线 278 | { 279 | throw error; 280 | } 281 | catch (Exception ex) 282 | { 283 | if (ex.Message == "VI_ERROR_NCIC: Not the controller-in-charge") //GPIB掉线 284 | throw ex; 285 | } 286 | return m_Temp; 287 | } 288 | 289 | 290 | 291 | 292 | /// 293 | /// 发送并读取(字节) 294 | /// 295 | /// 296 | /// 297 | public byte[] WriteAndReadBytes(byte[] m_Command) 298 | { 299 | byte[] m_Temp = null; 300 | try 301 | { 302 | WriteBytes(m_Command); 303 | if (m_IO488 != null) 304 | m_Temp = m_IO488.IO.Read(0); 305 | 306 | } 307 | catch (System.IO.IOException error) 308 | { 309 | throw error; 310 | } 311 | catch (Exception ex) 312 | { 313 | if (ex.Message == "VI_ERROR_NCIC: Not the controller-in-charge") //掉线 314 | throw ex; 315 | } 316 | 317 | return m_Temp; 318 | } 319 | 320 | 321 | } 322 | } 323 | -------------------------------------------------------------------------------- /Sample/C#/InstrumentDemoCSharp/MainWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Data; 9 | using System.Windows.Documents; 10 | using System.Windows.Input; 11 | using System.Windows.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Navigation; 14 | using System.Windows.Shapes; 15 | 16 | using InstrumentUtilityDotNet; 17 | using InstrumentUtilityDotNet.PowerMeterManager; 18 | using InstrumentUtilityDotNet.SpectrumAnalyzerManager; 19 | using InstrumentUtilityDotNet.SignalSourceManager; 20 | using InstrumentUtilityDotNet.SynthesizeMeterManager; 21 | using System.Threading; 22 | 23 | namespace InstrumentDemoCsharp 24 | { 25 | /// 26 | /// MainWindow.xaml 的交互逻辑 27 | /// 28 | public partial class MainWindow : Window 29 | { 30 | bool isConnected = false; 31 | InstrumentUtilityDotNet.InstrumentManager instrument; 32 | 33 | bool isSpectrumMeterConnected = false; 34 | bool isSignalSourceConnected = false; 35 | bool isPowerMeterConnected = false; 36 | bool isSynthesizeMeterConnected = false; 37 | 38 | ISpectrumAnalyzer spectrumAnalyzer; 39 | ISignalSource signalSource; 40 | IPowerMeter powerMeter; 41 | ISynthesizeMeter synthesizeMeter; 42 | 43 | SolidColorBrush sucessColor = new SolidColorBrush(Colors.LawnGreen); 44 | SolidColorBrush normalColor = new SolidColorBrush(Colors.AliceBlue); 45 | 46 | 47 | public MainWindow() 48 | { 49 | InitializeComponent(); 50 | instrument = new InstrumentManager(); 51 | } 52 | 53 | private void btnConnect_Click(object sender, RoutedEventArgs e) 54 | { 55 | try 56 | { 57 | if (!isConnected) 58 | { 59 | isConnected = instrument.Open(tbAddr.Text); 60 | if (isConnected) 61 | this.btnConnect.Background = sucessColor; 62 | else 63 | this.btnConnect.Background = normalColor; 64 | } 65 | else 66 | this.btnConnect.Background = sucessColor; 67 | } 68 | catch (Exception ex) 69 | { 70 | isConnected = false; 71 | this.btnConnect.Background = normalColor; 72 | MessageBox.Show(ex.Message); 73 | } 74 | } 75 | 76 | 77 | private void btnSend_Click(object sender, RoutedEventArgs e) 78 | { 79 | if (isConnected) 80 | { 81 | try 82 | { 83 | instrument.WriteString(this.tbSend.Text); 84 | } 85 | catch (Exception ex) 86 | { 87 | MessageBox.Show(ex.Message); 88 | } 89 | } 90 | } 91 | 92 | private void btnSendAndRecv_Click(object sender, RoutedEventArgs e) 93 | { 94 | if (isConnected) 95 | { 96 | try 97 | { 98 | this.tbRecv.Text = instrument.WriteAndReadString(this.tbSend.Text); 99 | } 100 | catch (Exception ex) 101 | { 102 | MessageBox.Show(ex.Message); 103 | } 104 | } 105 | 106 | } 107 | 108 | private void btnFindResouce_Click(object sender, RoutedEventArgs e) 109 | { 110 | cmbAddress.Items.Clear(); 111 | InstrumentUtilityDotNet.InstrumentManager instrumentManager = new InstrumentUtilityDotNet.InstrumentManager(); 112 | string[] arr = instrumentManager.FindAllResource(); 113 | foreach (string addr in arr) 114 | cmbAddress.Items.Add(addr); 115 | } 116 | 117 | #region 频谱仪 118 | private void btnSpeOpen_Click(object sender, RoutedEventArgs e) 119 | { 120 | SpectrumAnalyzerType type = (SpectrumAnalyzerType)(this.cmbSpeType.SelectedIndex); 121 | string addr = this.tbSpeAddr.Text; 122 | if (!isSpectrumMeterConnected) 123 | { 124 | spectrumAnalyzer = SpectrumAnalyzer.GetInstance(type); 125 | isSpectrumMeterConnected = spectrumAnalyzer.Connect(addr); 126 | if (isSpectrumMeterConnected) 127 | this.btnSpeOpen.Background = sucessColor; 128 | else 129 | this.btnSpeOpen.Background = normalColor; 130 | } 131 | else 132 | this.btnSpeOpen.Background = sucessColor; 133 | } 134 | 135 | private void btnSpeClose_Click(object sender, RoutedEventArgs e) 136 | { 137 | if (isSpectrumMeterConnected) 138 | { 139 | spectrumAnalyzer.DisConnect(); 140 | } 141 | this.btnSpeOpen.Background = normalColor; 142 | } 143 | 144 | private void btnSpeReset_Click(object sender, RoutedEventArgs e) 145 | { 146 | if (!isSpectrumMeterConnected) 147 | return; 148 | spectrumAnalyzer.Reset(); 149 | } 150 | 151 | private void btnSpeIDQuery_Click(object sender, RoutedEventArgs e) 152 | { 153 | if (!isSpectrumMeterConnected) 154 | return; 155 | tbSpeID.Text = spectrumAnalyzer.GetID(); 156 | } 157 | 158 | private void btnSpeCentFreqSet_Click(object sender, RoutedEventArgs e) 159 | { 160 | if (!isSpectrumMeterConnected) 161 | return; 162 | double freq = Convert.ToDouble(this.tbSpeCentFreq.Text); 163 | FrequencyUnit unit = (FrequencyUnit)this.cmbSpeCentFreqUnit.SelectedIndex; 164 | spectrumAnalyzer.SetCenterFreq(freq, unit); 165 | } 166 | 167 | private void btnSpeSpanSet_Click(object sender, RoutedEventArgs e) 168 | { 169 | if (!isSpectrumMeterConnected) 170 | return; 171 | double span = Convert.ToDouble(this.tbSpeSpan.Text); 172 | FrequencyUnit unit = (FrequencyUnit)this.cmbSpeSpanUnit.SelectedIndex; 173 | spectrumAnalyzer.SetSpan(span, unit); 174 | } 175 | 176 | private void btnSpeRefLevelSet_Click(object sender, RoutedEventArgs e) 177 | { 178 | if (!isSpectrumMeterConnected) 179 | return; 180 | double refLevel = Convert.ToDouble(this.tbSpeRefLevel.Text); 181 | spectrumAnalyzer.SetRefLevel(refLevel); 182 | } 183 | 184 | private void btnSpeRBWSet_Click(object sender, RoutedEventArgs e) 185 | { 186 | if (!isSpectrumMeterConnected) 187 | return; 188 | bool b = (bool)rbSpeRBWAuto.IsChecked; 189 | double rbw = Convert.ToDouble(this.tbSpeRBW.Text); 190 | spectrumAnalyzer.SetRBW(b, rbw); 191 | } 192 | 193 | private void btnSpeMKA_Click(object sender, RoutedEventArgs e) 194 | { 195 | if (!isSpectrumMeterConnected) 196 | return; 197 | spectrumAnalyzer.MarkPeak(); 198 | Thread.Sleep(1000); 199 | this.tbSpeMKA.Text = spectrumAnalyzer.GetMKA().ToString(); 200 | } 201 | #endregion 202 | 203 | #region 信号源 204 | private void btnSigOpen_Click(object sender, RoutedEventArgs e) 205 | { 206 | SignalSourceType type = (SignalSourceType)(this.cmbSigType.SelectedIndex); 207 | string addr = this.tbSigAddr.Text; 208 | if (!isSignalSourceConnected) 209 | { 210 | signalSource = SignalSource.GetInstance(type); 211 | isSignalSourceConnected = signalSource.Connect(addr); 212 | if (isSignalSourceConnected) 213 | this.btnSigOpen.Background = sucessColor; 214 | else 215 | this.btnSigOpen.Background = normalColor; 216 | } 217 | else 218 | this.btnSigOpen.Background = sucessColor; 219 | } 220 | 221 | private void btnSigClose_Click(object sender, RoutedEventArgs e) 222 | { 223 | if (isSignalSourceConnected) 224 | { 225 | signalSource.DisConnect(); 226 | } 227 | this.btnSigOpen.Background = normalColor; 228 | } 229 | 230 | private void btnSigReset_Click(object sender, RoutedEventArgs e) 231 | { 232 | if (!isSignalSourceConnected) 233 | return; 234 | signalSource.Reset(); 235 | } 236 | 237 | private void btnSigIDQuery_Click(object sender, RoutedEventArgs e) 238 | { 239 | if (!isSignalSourceConnected) 240 | return; 241 | tbSigID.Text = signalSource.GetID(); 242 | } 243 | 244 | private void btnSigFreqPowerSet_Click(object sender, RoutedEventArgs e) 245 | { 246 | if (!isSignalSourceConnected) 247 | return; 248 | double freq = Convert.ToDouble(this.tbSigFreq.Text); 249 | double power = Convert.ToDouble(this.tbSigPower.Text); 250 | FrequencyUnit unit = (FrequencyUnit)this.cmbSigFreqUnit.SelectedIndex; 251 | signalSource.SetFreqAndLevel(unit, freq, power); 252 | } 253 | private void btnSigTriggerModeSet_Click(object sender, RoutedEventArgs e) 254 | { 255 | if (this.cmbSigTriggerMode.SelectedIndex == 1) 256 | { 257 | signalSource.SetPulseSwitch(true); 258 | double width = Convert.ToDouble(this.tbSigPulseWidth.Text); 259 | double period = Convert.ToDouble(this.tbSigPulsePeriod.Text); 260 | signalSource.SetPulseWidth(width); 261 | signalSource.SetPulsePeriod(period); 262 | } 263 | else 264 | { 265 | signalSource.SetPulseSwitch(false); 266 | } 267 | } 268 | private void cmbSigTriggerMode_SelectionChanged(object sender, SelectionChangedEventArgs e) 269 | { 270 | if (!this.IsLoaded) 271 | return; 272 | if (cmbSigTriggerMode.SelectedIndex == 0) 273 | { 274 | tbSigPulseWidth.IsEnabled = false; 275 | tbSigPulsePeriod.IsEnabled = false; 276 | } 277 | else 278 | { 279 | tbSigPulseWidth.IsEnabled = true; 280 | tbSigPulsePeriod.IsEnabled = true; 281 | } 282 | 283 | } 284 | 285 | private void cmbSigPluseSwitch_SelectionChanged(object sender, SelectionChangedEventArgs e) 286 | { 287 | if (!isSignalSourceConnected) 288 | return; 289 | if(this.cmbSigPluseSwitch.SelectedIndex==0) 290 | signalSource.SetPulseSwitch(false); 291 | else 292 | signalSource.SetPulseSwitch(true); 293 | } 294 | 295 | private void cmbSigModulationSwitch_SelectionChanged(object sender, SelectionChangedEventArgs e) 296 | { 297 | if (!isSignalSourceConnected) 298 | return; 299 | if (this.cmbSigModulationSwitch.SelectedIndex == 0) 300 | signalSource.SetModulationSwitch(false); 301 | else 302 | signalSource.SetModulationSwitch(true); 303 | } 304 | 305 | #endregion 306 | 307 | #region 功率计 308 | private void btnPowerOpen_Click(object sender, RoutedEventArgs e) 309 | { 310 | PowerMeterType type = (PowerMeterType)(this.cmbPowerType.SelectedIndex); 311 | string addr = this.tbPowerAddr.Text; 312 | if (!isPowerMeterConnected) 313 | { 314 | powerMeter = PowerMeter.GetInstance(type); 315 | isPowerMeterConnected = powerMeter.Connect(addr); 316 | if (isPowerMeterConnected) 317 | this.btnPowerOpen.Background = sucessColor; 318 | else 319 | this.btnPowerOpen.Background = normalColor; 320 | } 321 | else 322 | this.btnPowerOpen.Background = sucessColor; 323 | } 324 | 325 | private void btnPowerClose_Click(object sender, RoutedEventArgs e) 326 | { 327 | if (isPowerMeterConnected) 328 | { 329 | powerMeter.DisConnect(); 330 | } 331 | this.btnPowerOpen.Background = normalColor; 332 | } 333 | 334 | private void btnPowerReset_Click(object sender, RoutedEventArgs e) 335 | { 336 | if (!isPowerMeterConnected) 337 | return; 338 | powerMeter.Reset(); 339 | } 340 | 341 | private void btnPowerIDQuery_Click(object sender, RoutedEventArgs e) 342 | { 343 | if (!isPowerMeterConnected) 344 | return; 345 | tbPowerID.Text = powerMeter.GetID(); 346 | } 347 | private void btnPowerValueQuery_Click(object sender, RoutedEventArgs e) 348 | { 349 | if (!isPowerMeterConnected) 350 | return; 351 | int sensorNum = this.cmbPowerSensorNum.SelectedIndex; 352 | double avg; 353 | double swr; 354 | powerMeter.GetPower(sensorNum,out avg,out swr); 355 | this.tbPowerAvg.Text = avg.ToString(); 356 | this.tbPowerSwr.Text = swr.ToString(); 357 | } 358 | private void cmbPowerMeterUnit_SelectionChanged(object sender, SelectionChangedEventArgs e) 359 | { 360 | if (!isPowerMeterConnected) 361 | return; 362 | PowerUnit unit = (PowerUnit)this.cmbPowerMeterUnit.SelectedIndex; 363 | powerMeter.PowerUnitChange(unit); 364 | } 365 | 366 | 367 | #endregion 368 | 369 | #region 综测仪 370 | private void btnSynthesizeOpen_Click(object sender, RoutedEventArgs e) 371 | { 372 | SynthesizeMeterType type = (SynthesizeMeterType)(this.cmbSynthesizeType.SelectedIndex); 373 | string addr = this.tbSynthesizeAddr.Text; 374 | if (!isSynthesizeMeterConnected) 375 | { 376 | synthesizeMeter = SynthesizeMeter.GetInstance(type); 377 | isSynthesizeMeterConnected = synthesizeMeter.Connect(addr); 378 | if (isSynthesizeMeterConnected) 379 | this.btnSynthesizeOpen.Background = sucessColor; 380 | else 381 | this.btnSynthesizeOpen.Background = normalColor; 382 | } 383 | else 384 | this.btnSynthesizeOpen.Background = sucessColor; 385 | } 386 | 387 | private void btnSynthesizeClose_Click(object sender, RoutedEventArgs e) 388 | { 389 | if (isSynthesizeMeterConnected) 390 | { 391 | synthesizeMeter.DisConnect(); 392 | } 393 | this.btnSynthesizeOpen.Background = normalColor; 394 | } 395 | 396 | private void btnSynthesizeReset_Click(object sender, RoutedEventArgs e) 397 | { 398 | if (!isSynthesizeMeterConnected) 399 | return; 400 | synthesizeMeter.Reset(); 401 | } 402 | 403 | private void btnSynthesizeIDQuery_Click(object sender, RoutedEventArgs e) 404 | { 405 | if (!isSynthesizeMeterConnected) 406 | return; 407 | tbSynthesizeID.Text = synthesizeMeter.GetID(); 408 | } 409 | 410 | private void btnSynthesizeRefLevelSet_Click(object sender, RoutedEventArgs e) 411 | { 412 | if (!isSynthesizeMeterConnected) 413 | return; 414 | double level = Convert.ToDouble(this.tbSynthesizeRefLevel.Text); 415 | synthesizeMeter.SetRefLevel(level); 416 | } 417 | 418 | private void btnSynthesizeCentFreqSet_Click(object sender, RoutedEventArgs e) 419 | { 420 | if (!isSynthesizeMeterConnected) 421 | return; 422 | double freq = Convert.ToDouble(this.tbSynthesizeCentFreq.Text); 423 | FrequencyUnit unit = (FrequencyUnit)this.cmbSynthesizeCentFreqUnit.SelectedIndex; 424 | synthesizeMeter.SetCenterFreq(freq,unit); 425 | } 426 | 427 | private void btnSynthesizeAfgStateSet_Click(object sender, RoutedEventArgs e) 428 | { 429 | if (!isSynthesizeMeterConnected) 430 | return; 431 | if (this.cmbSynthesizeAfgState.SelectedIndex == 0) 432 | synthesizeMeter.SetAfgState(false); 433 | else 434 | synthesizeMeter.SetAfgState(true); 435 | } 436 | 437 | private void btnSynthesizeCentFreqGet_Click(object sender, RoutedEventArgs e) 438 | { 439 | if (!isSynthesizeMeterConnected) 440 | return; 441 | 442 | this.tbSynthesizeCentFreqGet.Text = synthesizeMeter.GetCenterFreq().ToString(); 443 | } 444 | 445 | 446 | 447 | 448 | #endregion 449 | 450 | 451 | 452 | } 453 | } 454 | --------------------------------------------------------------------------------