├── .gitattributes ├── .gitignore ├── IVI.C.NET.Adapter.ConfigUtility ├── IVI.C.NET.Adapter.ConfigUtility.csproj ├── IVIHandler.cs ├── Program.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings ├── Utility.Designer.cs ├── Utility.cs ├── Utility.resx └── app.config ├── IVI.C.NET.Adapter.Setup ├── IVI.C.NET.Adapter.Setup.vdproj └── ModifyMsiToEnableLaunchApplication.js ├── IVI.C.NET.Adapter.Test ├── IVI.C.NET.Adapter.Test.csproj ├── IVI.C.NET.Adapter.Test.csproj.user ├── IviCounterAdapterTest.cs ├── IviDCPwrAdapterTest.cs ├── IviDigitizerAdapterTest.cs ├── IviDmmAdapterTest.cs ├── IviDriverAdapterTest.cs ├── IviScopeAdapterTest.cs ├── IviSpecAnAdapterTest.cs ├── IviSwtchAdapterTest.cs ├── Libs │ ├── nunit.framework.dll │ └── nunit.framework.xml └── Properties │ └── AssemblyInfo.cs ├── IVI.C.NET.Adapter.sln ├── IVI.C.NET.Adapter.suo ├── IVI.C.NET.Adapter ├── DriverAdapterBase.cs ├── DriverIdentity.cs ├── DriverOperation.cs ├── DriverUtility.cs ├── IDriverAdapterBase.cs ├── IVI.C.NET.Adapter.csproj ├── IVI.C.NET.Adapter.csproj.user ├── IviACPwrAdapter.cs ├── IviCInterop │ ├── IviACPwr.cs │ ├── IviACPwrAttribute.cs │ ├── IviCounter.cs │ ├── IviCounterAttribute.cs │ ├── IviDCPwr.cs │ ├── IviDCPwrAttribute.cs │ ├── IviDigitizer.cs │ ├── IviDigitizerAttribute.cs │ ├── IviDmm.cs │ ├── IviDmmAttribute.cs │ ├── IviDownconverter.cs │ ├── IviDownconverterAttribute.cs │ ├── IviDriver.cs │ ├── IviDriverAttribute.cs │ ├── IviFgen.cs │ ├── IviFgenAttribute.cs │ ├── IviPwrMeter.cs │ ├── IviPwrMeterAttribute.cs │ ├── IviRFSigGen.cs │ ├── IviRFSigGenAttribute.cs │ ├── IviScope.cs │ ├── IviScopeAttribute.cs │ ├── IviSpecAn.cs │ ├── IviSpecAnAttribute.cs │ ├── IviSwtch.cs │ ├── IviSwtchAttribute.cs │ ├── IviUpconverter.cs │ └── IviUpconverterAttribute.cs ├── IviCounterAdapter.cs ├── IviDCPwrAdapter.cs ├── IviDigitizerAdapter.cs ├── IviDmmAdapter.cs ├── IviDownconverterAdapter.cs ├── IviEnumCMapping.cs ├── IviFgenAdapter.cs ├── IviPwrMeterAdapter.cs ├── IviRFSigGenAdapter.cs ├── IviScopeAdapter.cs ├── IviSpecAnAdapter.cs ├── IviSwtchAdapter.cs ├── IviUpconverterAdapter.cs ├── Properties │ └── AssemblyInfo.cs ├── Win32Interop │ └── Win32LibInterop.cs ├── _IVI.C.NET.Adapter.pfx └── _IVI.C.NET.Adapter_nopwd.snk ├── LICENSE ├── NUnit ├── Logo.ico └── license.txt ├── README.md └── UML ├── Classdiagram.png └── IVI.C.NET.Adapter.simp /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.sln.docstates 8 | 9 | # Build results 10 | [Dd]ebug/ 11 | [Dd]ebugPublic/ 12 | [Rr]elease/ 13 | x64/ 14 | build/ 15 | bld/ 16 | [Bb]in/ 17 | [Oo]bj/ 18 | 19 | # Roslyn cache directories 20 | *.ide/ 21 | 22 | # MSTest test Results 23 | [Tt]est[Rr]esult*/ 24 | [Bb]uild[Ll]og.* 25 | 26 | #NUNIT 27 | *.VisualState.xml 28 | TestResult.xml 29 | 30 | # Build Results of an ATL Project 31 | [Dd]ebugPS/ 32 | [Rr]eleasePS/ 33 | dlldata.c 34 | 35 | *_i.c 36 | *_p.c 37 | *_i.h 38 | *.ilk 39 | *.meta 40 | *.obj 41 | *.pch 42 | *.pdb 43 | *.pgc 44 | *.pgd 45 | *.rsp 46 | *.sbr 47 | *.tlb 48 | *.tli 49 | *.tlh 50 | *.tmp 51 | *.tmp_proj 52 | *.log 53 | *.vspscc 54 | *.vssscc 55 | .builds 56 | *.pidb 57 | *.svclog 58 | *.scc 59 | 60 | # Chutzpah Test files 61 | _Chutzpah* 62 | 63 | # Visual C++ cache files 64 | ipch/ 65 | *.aps 66 | *.ncb 67 | *.opensdf 68 | *.sdf 69 | *.cachefile 70 | 71 | # Visual Studio profiler 72 | *.psess 73 | *.vsp 74 | *.vspx 75 | 76 | # TFS 2012 Local Workspace 77 | $tf/ 78 | 79 | # Guidance Automation Toolkit 80 | *.gpState 81 | 82 | # ReSharper is a .NET coding add-in 83 | _ReSharper*/ 84 | *.[Rr]e[Ss]harper 85 | *.DotSettings.user 86 | 87 | # JustCode is a .NET coding addin-in 88 | .JustCode 89 | 90 | # TeamCity is a build add-in 91 | _TeamCity* 92 | 93 | # DotCover is a Code Coverage Tool 94 | *.dotCover 95 | 96 | # NCrunch 97 | _NCrunch_* 98 | .*crunch*.local.xml 99 | 100 | # MightyMoose 101 | *.mm.* 102 | AutoTest.Net/ 103 | 104 | # Web workbench (sass) 105 | .sass-cache/ 106 | 107 | # Installshield output folder 108 | [Ee]xpress/ 109 | 110 | # DocProject is a documentation generator add-in 111 | DocProject/buildhelp/ 112 | DocProject/Help/*.HxT 113 | DocProject/Help/*.HxC 114 | DocProject/Help/*.hhc 115 | DocProject/Help/*.hhk 116 | DocProject/Help/*.hhp 117 | DocProject/Help/Html2 118 | DocProject/Help/html 119 | 120 | # Click-Once directory 121 | publish/ 122 | 123 | # Publish Web Output 124 | *.[Pp]ublish.xml 125 | *.azurePubxml 126 | ## TODO: Comment the next line if you want to checkin your 127 | ## web deploy settings but do note that will include unencrypted 128 | ## passwords 129 | #*.pubxml 130 | 131 | # NuGet Packages Directory 132 | packages/* 133 | ## TODO: If the tool you use requires repositories.config 134 | ## uncomment the next line 135 | #!packages/repositories.config 136 | 137 | # Enable "build/" folder in the NuGet Packages folder since 138 | # NuGet packages use it for MSBuild targets. 139 | # This line needs to be after the ignore of the build folder 140 | # (and the packages folder if the line above has been uncommented) 141 | !packages/build/ 142 | 143 | # Windows Azure Build Output 144 | csx/ 145 | *.build.csdef 146 | 147 | # Windows Store app package directory 148 | AppPackages/ 149 | 150 | # Others 151 | sql/ 152 | *.Cache 153 | ClientBin/ 154 | [Ss]tyle[Cc]op.* 155 | ~$* 156 | *~ 157 | *.dbmdl 158 | *.dbproj.schemaview 159 | *.pfx 160 | *.publishsettings 161 | node_modules/ 162 | 163 | # RIA/Silverlight projects 164 | Generated_Code/ 165 | 166 | # Backup & report files from converting an old project file 167 | # to a newer Visual Studio version. Backup files are not needed, 168 | # because we have git ;-) 169 | _UpgradeReport_Files/ 170 | Backup*/ 171 | UpgradeLog*.XML 172 | UpgradeLog*.htm 173 | 174 | # SQL Server files 175 | *.mdf 176 | *.ldf 177 | 178 | # Business Intelligence projects 179 | *.rdl.data 180 | *.bim.layout 181 | *.bim_*.settings 182 | 183 | # Microsoft Fakes 184 | FakesAssemblies/ 185 | 186 | # LightSwitch generated files 187 | GeneratedArtifacts/ 188 | _Pvt_Extensions/ 189 | ModelManifest.xml -------------------------------------------------------------------------------- /IVI.C.NET.Adapter.ConfigUtility/IVI.C.NET.Adapter.ConfigUtility.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | x86 6 | 8.0.30703 7 | 2.0 8 | {C3269A52-A820-4296-837C-365C21E0F1AE} 9 | WinExe 10 | Properties 11 | IVI.C.NET.Adapter.ConfigUtility 12 | IVI.C.NET.Adapter.ConfigUtility 13 | v2.0 14 | 15 | 16 | 512 17 | 18 | 19 | true 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | full 23 | AnyCPU 24 | prompt 25 | MinimumRecommendedRules.ruleset 26 | 27 | 28 | bin\Release\ 29 | TRACE 30 | true 31 | pdbonly 32 | AnyCPU 33 | prompt 34 | MinimumRecommendedRules.ruleset 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | Form 47 | 48 | 49 | Utility.cs 50 | 51 | 52 | 53 | 54 | Utility.cs 55 | 56 | 57 | ResXFileCodeGenerator 58 | Resources.Designer.cs 59 | Designer 60 | 61 | 62 | True 63 | Resources.resx 64 | True 65 | 66 | 67 | 68 | SettingsSingleFileGenerator 69 | Settings.Designer.cs 70 | 71 | 72 | True 73 | Settings.settings 74 | True 75 | 76 | 77 | 78 | 79 | {C6F576F5-7394-458E-B38A-C20C668585E7} 80 | 1 81 | 6 82 | 0 83 | primary 84 | False 85 | True 86 | 87 | 88 | 89 | 96 | -------------------------------------------------------------------------------- /IVI.C.NET.Adapter.ConfigUtility/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Forms; 3 | 4 | namespace IVI.C.NET.Adapter.ConfigUtility 5 | { 6 | static class Program 7 | { 8 | /// 9 | /// The main entry point for the application. 10 | /// 11 | [STAThread] 12 | static void Main() 13 | { 14 | Application.EnableVisualStyles(); 15 | Application.SetCompatibleTextRenderingDefault(false); 16 | Application.Run(new Utility()); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /IVI.C.NET.Adapter.ConfigUtility/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("IVI.C.NET.Adapter.ConfigUtility")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("IVI.C.NET.Adapter.ConfigUtility")] 13 | [assembly: AssemblyCopyright("Copyright © 2014")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("fe59e525-2652-4593-b2bc-9097772ade40")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /IVI.C.NET.Adapter.ConfigUtility/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.34014 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace IVI.C.NET.Adapter.ConfigUtility.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.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 | /// Returns the cached ResourceManager instance used by this class. 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("IVI.C.NET.Adapter.ConfigUtility.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 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 | -------------------------------------------------------------------------------- /IVI.C.NET.Adapter.ConfigUtility/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 | -------------------------------------------------------------------------------- /IVI.C.NET.Adapter.ConfigUtility/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.34014 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace IVI.C.NET.Adapter.ConfigUtility.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.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 | -------------------------------------------------------------------------------- /IVI.C.NET.Adapter.ConfigUtility/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /IVI.C.NET.Adapter.ConfigUtility/Utility.cs: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------------------- 2 | // 3 | // Copyright Tom Lu 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //-------------------------------------------------------------------------------------------------- 18 | 19 | using System; 20 | using System.Collections; 21 | using System.Collections.Generic; 22 | using System.ComponentModel; 23 | using System.Data; 24 | using System.Drawing; 25 | using System.Windows.Forms; 26 | using Ivi.ConfigServer.Interop; 27 | 28 | 29 | namespace IVI.C.NET.Adapter.ConfigUtility 30 | { 31 | public partial class Utility : Form 32 | { 33 | private IVIHandler IviHandler = IVIHandler.Instance; 34 | private string[] IviCAdapterList = new string[] {"IviACPwrAdapter", "IviCounterAdapter", "IviDCPwrAdapter", "IviDigitizerAdapter", "IviDmmAdapter", 35 | "IviDownconverterAdapter", "IviFgenAdapter", "IviPwrMeterAdapter", "IviRFSigGenAdapter", "IviScopeAdapter", 36 | "IviSpecAnAdapter", "IviSwtchAdapter", "IviUpconverterAdapter" }; 37 | 38 | private string[] PublishedAPIList = new string[] {"IviACPwr", "IviCounter", "IviDCPwr", "IviDigitizer", "IviDmm", 39 | "IviDownconverter", "IviFgen", "IviPwrMeter", "IviRFSigGen", "IviScope", 40 | "IviSpecAn", "IviSwtch", "IviUpconverter" }; 41 | 42 | private const string AssemblyQualifiedClassNameTemplatePfx = "IVI.C.NET.Adapter.{0}, IVI.C.NET.Adapter, Version=1.0.0.1, Culture=neutral, PublicKeyToken=55d3badc1a673a0b"; 43 | private const string AssemblyQualifiedClassNameTemplateSnk = "IVI.C.NET.Adapter.{0}, IVI.C.NET.Adapter, Version=1.0.0.1, Culture=neutral, PublicKeyToken=d25ace325c488ee2"; 44 | private string AssemblyQualifiedClassNameTemplateToUse = null; 45 | 46 | public Utility() 47 | { 48 | InitializeComponent(); 49 | } 50 | 51 | private void Utility_Shown(object sender, EventArgs e) 52 | { 53 | if (Type.GetType(string.Format(AssemblyQualifiedClassNameTemplateSnk, "IviDmmAdapter"), false) != null) 54 | AssemblyQualifiedClassNameTemplateToUse = AssemblyQualifiedClassNameTemplateSnk; 55 | else if (Type.GetType(string.Format(AssemblyQualifiedClassNameTemplatePfx, "IviDmmAdapter"), false) != null) 56 | AssemblyQualifiedClassNameTemplateToUse = AssemblyQualifiedClassNameTemplatePfx; 57 | else AssemblyQualifiedClassNameTemplateToUse = null; 58 | 59 | if (String.IsNullOrEmpty(AssemblyQualifiedClassNameTemplateToUse)) 60 | { 61 | MessageBox.Show("IVI.C.NET.Adapter assembly not installed in GAC.\r\nPlease try reinstall IVI.C.NET.Adapter to fix this issue!", "Assembly not in GAC", MessageBoxButtons.OK); 62 | Close(); 63 | } 64 | else 65 | { 66 | UpdateDisplay(); 67 | autoSetupBtn_Click(null, null); 68 | } 69 | } 70 | 71 | private void UpdateDisplay() 72 | { 73 | IVIHandler.Reset(); 74 | IviHandler = IVIHandler.Instance; 75 | IviHandler.IviConfigStore.Deserialize(IviHandler.IviConfigStore.MasterLocation); 76 | 77 | AdapterConfigList.Rows.Clear(); 78 | foreach (IIviSoftwareModule2 SoftwareModule in IviHandler.IviConfigStore.SoftwareModules) 79 | { 80 | if (!SoftwareModule.Name.StartsWith("nis")) 81 | { 82 | DataGridViewRow Row = new DataGridViewRow(); 83 | DataGridViewCheckBoxCell UpdateCheckBox = new DataGridViewCheckBoxCell(); 84 | DataGridViewTextBoxCell SoftwareModuleTextBox = new DataGridViewTextBoxCell(); 85 | DataGridViewTextBoxCell CurrentAdapterClassTextBox = new DataGridViewTextBoxCell(); 86 | DataGridViewComboBoxCell NewAdapterClassComboBox = new DataGridViewComboBoxCell(); 87 | 88 | UpdateCheckBox.Value = false; 89 | SoftwareModuleTextBox.Value = SoftwareModule.Name; 90 | string className = SoftwareModule.AssemblyQualifiedClassName; 91 | 92 | if (!className.Equals(string.Empty)) 93 | { 94 | Type type = Type.GetType(SoftwareModule.AssemblyQualifiedClassName); 95 | if (type != null) 96 | { 97 | CurrentAdapterClassTextBox.Value = type.Name; 98 | } 99 | } 100 | 101 | NewAdapterClassComboBox.Items.Add(string.Empty); 102 | NewAdapterClassComboBox.Items.AddRange(IviCAdapterList); 103 | NewAdapterClassComboBox.Value = NewAdapterClassComboBox.Items[0]; 104 | 105 | Row.Cells.Add(UpdateCheckBox); 106 | Row.Cells.Add(SoftwareModuleTextBox); 107 | Row.Cells.Add(CurrentAdapterClassTextBox); 108 | Row.Cells.Add(NewAdapterClassComboBox); 109 | 110 | AdapterConfigList.Rows.Add(Row); 111 | } 112 | } 113 | } 114 | 115 | private void refreshBtn_Click(object sender, EventArgs e) 116 | { 117 | UpdateDisplay(); 118 | } 119 | 120 | private void autoSetupBtn_Click(object sender, EventArgs e) 121 | { 122 | foreach (DataGridViewRow Row in AdapterConfigList.Rows) 123 | { 124 | string SoftwareModuleName = (string)Row.Cells[1].Value; 125 | IIviSoftwareModule2 SoftwareModule = (IIviSoftwareModule2)IviHandler.GetSoftwareModule(SoftwareModuleName); 126 | string AdapterClass = GetSuitableAdapter(SoftwareModule.PublishedAPIs); 127 | if (AdapterClass != null && !AdapterClass.Equals(Row.Cells[2].Value)) 128 | { 129 | Row.Cells[0].Value = true; 130 | Row.Cells[3].Value = AdapterClass; 131 | } 132 | else 133 | { 134 | Row.Cells[0].Value = false; 135 | Row.Cells[3].Value = string.Empty; 136 | } 137 | } 138 | } 139 | 140 | private string GetSuitableAdapter(IIviPublishedAPICollection PublishedAPIs) 141 | { 142 | ArrayList PubAPIList = new ArrayList(PublishedAPIList); 143 | foreach (IIviPublishedAPI PublishedAPI in PublishedAPIs) 144 | { 145 | if (PublishedAPI.Type.Equals("IVI-C") && PubAPIList.Contains(PublishedAPI.Name)) 146 | { 147 | return IviCAdapterList[PubAPIList.IndexOf(PublishedAPI.Name)]; 148 | } 149 | } 150 | return null; 151 | } 152 | 153 | private void clearAdapterSetup_Click(object sender, EventArgs e) 154 | { 155 | foreach (DataGridViewRow Row in AdapterConfigList.Rows) 156 | { 157 | if (Row.Cells[2].Value != null && !Row.Cells[2].Value.Equals(string.Empty)) 158 | { 159 | Row.Cells[0].Value = true; 160 | Row.Cells[3].Value = string.Empty; 161 | } 162 | else 163 | { 164 | Row.Cells[0].Value = false; 165 | Row.Cells[3].Value = string.Empty; 166 | } 167 | } 168 | } 169 | 170 | private void saveBtn_Click(object sender, EventArgs e) 171 | { 172 | foreach (DataGridViewRow Row in AdapterConfigList.Rows) 173 | { 174 | if (Row.Cells[0].Value != null && (bool)Row.Cells[0].Value) 175 | { 176 | IIviSoftwareModule2 SoftwareModule = (IIviSoftwareModule2)IviHandler.GetSoftwareModule((string)Row.Cells[1].Value); 177 | if (SoftwareModule != null) 178 | { 179 | if (Row.Cells[3].Value == null || Row.Cells[3].Value.Equals(string.Empty)) 180 | { 181 | SoftwareModule.AssemblyQualifiedClassName = string.Empty; 182 | } 183 | else 184 | { 185 | SoftwareModule.AssemblyQualifiedClassName = string.Format(AssemblyQualifiedClassNameTemplateToUse, Row.Cells[3].Value); 186 | } 187 | } 188 | } 189 | } 190 | 191 | IviHandler.IviConfigStore.Serialize(IviHandler.IviConfigStore.MasterLocation); 192 | 193 | UpdateDisplay(); 194 | } 195 | 196 | private void exitBtn_Click(object sender, EventArgs e) 197 | { 198 | Close(); 199 | } 200 | } 201 | } 202 | -------------------------------------------------------------------------------- /IVI.C.NET.Adapter.ConfigUtility/Utility.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 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | True 122 | 123 | 124 | True 125 | 126 | 127 | True 128 | 129 | 130 | True 131 | 132 | -------------------------------------------------------------------------------- /IVI.C.NET.Adapter.ConfigUtility/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /IVI.C.NET.Adapter.Setup/ModifyMsiToEnableLaunchApplication.js: -------------------------------------------------------------------------------- 1 | // EnableLaunchApplication.js 2 | // Performs a post-build fixup of an msi to launch a specific file when the install has completed 3 | 4 | // Configurable values 5 | var checkboxChecked = true; // Is the checkbox on the finished dialog checked by default? 6 | var checkboxText = "Launch [ProductName].ConfigUtility"; // Text for the checkbox on the finished dialog 7 | var filename = "IVI.C.NET.Adapter.ConfigUtility.exe"; // The name of the executable to launch - change this to match the file you want to launch at the end of your setup 8 | 9 | // Constant values from Windows Installer 10 | var msiOpenDatabaseModeTransact = 1; 11 | 12 | var msiViewModifyInsert = 1; 13 | var msiViewModifyUpdate = 2; 14 | var msiViewModifyAssign = 3; 15 | var msiViewModifyReplace = 4; 16 | var msiViewModifyDelete = 6; 17 | 18 | if (WScript.Arguments.Length != 1) 19 | { 20 | WScript.StdErr.WriteLine(WScript.ScriptName + " file"); 21 | WScript.Quit(1); 22 | } 23 | 24 | var filespec = WScript.Arguments(0); 25 | var installer = WScript.CreateObject("WindowsInstaller.Installer"); 26 | var database = installer.OpenDatabase(filespec, msiOpenDatabaseModeTransact); 27 | 28 | var sql; 29 | var view; 30 | var record; 31 | 32 | try 33 | { 34 | var fileId = FindFileIdentifier(database, filename); 35 | if (!fileId) 36 | throw "Unable to find '" + filename + "' in File table"; 37 | 38 | WScript.Echo("Updating the Control table..."); 39 | // Modify the Control_Next of BannerBmp control to point to the new CheckBox 40 | sql = "SELECT `Dialog_`, `Control`, `Type`, `X`, `Y`, `Width`, `Height`, `Attributes`, `Property`, `Text`, `Control_Next`, `Help` FROM `Control` WHERE `Dialog_`='FinishedForm' AND `Control`='BannerBmp'"; 41 | view = database.OpenView(sql); 42 | view.Execute(); 43 | record = view.Fetch(); 44 | record.StringData(11) = "CheckboxLaunch"; 45 | view.Modify(msiViewModifyReplace, record); 46 | view.Close(); 47 | 48 | // Insert the new CheckBox control 49 | sql = "INSERT INTO `Control` (`Dialog_`, `Control`, `Type`, `X`, `Y`, `Width`, `Height`, `Attributes`, `Property`, `Text`, `Control_Next`, `Help`) VALUES ('FinishedForm', 'CheckboxLaunch', 'CheckBox', '9', '201', '343', '12', '3', 'LAUNCHAPP', '{\\VSI_MS_Sans_Serif13.0_0_0}" + checkboxText + "', 'CloseButton', '|')"; 50 | view = database.OpenView(sql); 51 | view.Execute(); 52 | view.Close(); 53 | 54 | WScript.Echo("Updating the ControlEvent table..."); 55 | // Modify the Order of the EndDialog event of the FinishedForm to 1 56 | sql = "SELECT `Dialog_`, `Control_`, `Event`, `Argument`, `Condition`, `Ordering` FROM `ControlEvent` WHERE `Dialog_`='FinishedForm' AND `Event`='EndDialog'"; 57 | view = database.OpenView(sql); 58 | view.Execute(); 59 | record = view.Fetch(); 60 | record.IntegerData(6) = 1; 61 | view.Modify(msiViewModifyReplace, record); 62 | view.Close(); 63 | 64 | // Insert the Event to launch the application 65 | sql = "INSERT INTO `ControlEvent` (`Dialog_`, `Control_`, `Event`, `Argument`, `Condition`, `Ordering`) VALUES ('FinishedForm', 'CloseButton', 'DoAction', 'VSDCA_Launch', 'LAUNCHAPP=1', '0')"; 66 | view = database.OpenView(sql); 67 | view.Execute(); 68 | view.Close(); 69 | 70 | WScript.Echo("Updating the CustomAction table..."); 71 | // Insert the custom action to launch the application when finished 72 | sql = "INSERT INTO `CustomAction` (`Action`, `Type`, `Source`, `Target`) VALUES ('VSDCA_Launch', '210', '" + fileId + "', '')"; 73 | view = database.OpenView(sql); 74 | view.Execute(); 75 | view.Close(); 76 | 77 | if (checkboxChecked) 78 | { 79 | WScript.Echo("Updating the Property table..."); 80 | // Set the default value of the CheckBox 81 | sql = "INSERT INTO `Property` (`Property`, `Value`) VALUES ('LAUNCHAPP', '1')"; 82 | view = database.OpenView(sql); 83 | view.Execute(); 84 | view.Close(); 85 | } 86 | 87 | database.Commit(); 88 | } 89 | catch(e) 90 | { 91 | WScript.StdErr.WriteLine(e); 92 | WScript.Quit(1); 93 | } 94 | 95 | function FindFileIdentifier(database, fileName) 96 | { 97 | // First, try to find the exact file name 98 | var sql = "SELECT `File` FROM `File` WHERE `FileName`='" + fileName + "'"; 99 | var view = database.OpenView(sql); 100 | view.Execute(); 101 | var record = view.Fetch(); 102 | if (record) 103 | { 104 | var value = record.StringData(1); 105 | view.Close(); 106 | return value; 107 | } 108 | view.Close(); 109 | 110 | // The file may be in SFN|LFN format. Look for a filename in this case next 111 | sql = "SELECT `File`, `FileName` FROM `File`"; 112 | view = database.OpenView(sql); 113 | view.Execute(); 114 | record = view.Fetch(); 115 | while (record) 116 | { 117 | if (StringEndsWith(record.StringData(2), "|" + fileName)) 118 | { 119 | var value = record.StringData(1); 120 | view.Close(); 121 | return value; 122 | } 123 | 124 | record = view.Fetch(); 125 | } 126 | view.Close(); 127 | } 128 | 129 | function StringEndsWith(str, value) 130 | { 131 | if (str.length < value.length) 132 | return false; 133 | 134 | return (str.indexOf(value, str.length - value.length) != -1); 135 | } -------------------------------------------------------------------------------- /IVI.C.NET.Adapter.Test/IVI.C.NET.Adapter.Test.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | x86 6 | 8.0.30703 7 | 2.0 8 | {E84FFD27-A24B-437B-A738-4BA2C994363E} 9 | Library 10 | Properties 11 | IVI.C.NET.Adapter.Test 12 | IVI.C.NET.Adapter.Test 13 | v2.0 14 | 512 15 | 16 | 17 | 18 | 19 | 20 | true 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | full 24 | x86 25 | prompt 26 | MinimumRecommendedRules.ruleset 27 | 28 | 29 | bin\Release\ 30 | TRACE 31 | true 32 | pdbonly 33 | x86 34 | prompt 35 | MinimumRecommendedRules.ruleset 36 | 37 | 38 | 39 | 40 | ..\IVI.C.NET.Adapter\Libs\Ivi.DCPwr.dll 41 | 42 | 43 | False 44 | ..\IVI.C.NET.Adapter\Libs\Ivi.Digitizer.dll 45 | 46 | 47 | ..\IVI.C.NET.Adapter\Libs\Ivi.Dmm.dll 48 | 49 | 50 | ..\IVI.C.NET.Adapter\Libs\Ivi.Driver.dll 51 | 52 | 53 | False 54 | ..\IVI.C.NET.Adapter\Libs\Ivi.Scope.dll 55 | 56 | 57 | 58 | ..\IVI.C.NET.Adapter\Libs\Ivi.Swtch.dll 59 | 60 | 61 | False 62 | Libs\nunit.framework.dll 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 87 | -------------------------------------------------------------------------------- /IVI.C.NET.Adapter.Test/IVI.C.NET.Adapter.Test.csproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(SolutionDir)\NUnit\bin\nunit-x86.exe 5 | IVI.C.NET.Adapter.Test.dll 6 | Program 7 | 8 | 9 | $(SolutionDir)\NUnit\bin\nunit-x86.exe 10 | IVI.C.NET.Adapter.Test.dll 11 | Program 12 | 13 | -------------------------------------------------------------------------------- /IVI.C.NET.Adapter.Test/IviCounterAdapterTest.cs: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------------------- 2 | // 3 | // Copyright Tom Lu 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //-------------------------------------------------------------------------------------------------- 18 | 19 | using System; 20 | using NUnit.Framework; 21 | using Ivi.Driver; 22 | using Ivi.Counter; 23 | 24 | namespace IVI.C.NET.Adapter.Test 25 | { 26 | [TestFixture] 27 | public class IviCounterAdapterTest 28 | { 29 | private IIviCounter Counter = null; 30 | 31 | [SetUp] 32 | public void InitAdapter() 33 | { 34 | Counter = (IIviCounter)IviDriver.Create("ag5313xni", true, true, "Simulate=1,RangeCheck=1,QueryInstrStatus=0,Cache=1"); 35 | } 36 | 37 | [Test] 38 | public void Arm() 39 | { 40 | IIviCounterArm Arm = Counter.Arm; 41 | Assert.IsNotNull(Arm); 42 | 43 | Arm.Start.External.Configure("EXT", 5, Slope.Positive, new PrecisionTimeSpan(new TimeSpan((long)(TimeSpan.TicksPerSecond * 0.000001)))); 44 | Arm.Stop.External.Configure("EXT", 3.3, Slope.Negative, new PrecisionTimeSpan(new TimeSpan((long)(TimeSpan.TicksPerSecond * 0.01)))); 45 | 46 | Assert.AreEqual("EXT", Arm.Start.External.Source); 47 | Assert.AreEqual(5, Arm.Start.External.Level); 48 | Assert.AreEqual(Slope.Positive, Arm.Start.External.Slope); 49 | Assert.AreEqual(new PrecisionTimeSpan(new TimeSpan((long)(TimeSpan.TicksPerSecond * 0.000001))), Arm.Start.External.Delay); 50 | Assert.AreEqual("EXT", Arm.Stop.External.Source); 51 | Assert.AreEqual(3.3, Arm.Stop.External.Level); 52 | Assert.AreEqual(Slope.Negative, Arm.Stop.External.Slope); 53 | Assert.AreEqual(new PrecisionTimeSpan(new TimeSpan((long)(TimeSpan.TicksPerSecond * 0.01))), Arm.Stop.External.Delay); 54 | 55 | Arm.Start.Type = ArmType.Immediate; 56 | Arm.Stop.Type = ArmType.Immediate; 57 | Assert.AreEqual(ArmType.Immediate, Arm.Start.Type); 58 | Assert.AreEqual(ArmType.Immediate, Arm.Stop.Type); 59 | 60 | Arm.Start.Type = ArmType.External; 61 | Arm.Stop.Type = ArmType.External; 62 | Assert.AreEqual(ArmType.External, Arm.Start.Type); 63 | Assert.AreEqual(ArmType.External, Arm.Stop.Type); 64 | 65 | } 66 | 67 | [Test] 68 | public void DutyCycle() 69 | { 70 | IIviCounterDutyCycle DutyCycle = Counter.DutyCycle; 71 | Assert.IsNotNull(DutyCycle); 72 | 73 | DutyCycle.Configure("1", 1E7, 0.01); 74 | Assert.AreEqual("1", DutyCycle.Channel); 75 | Assert.AreEqual(1E7, DutyCycle.FrequencyEstimate); 76 | Assert.AreEqual(0.01, DutyCycle.Resolution); 77 | 78 | DutyCycle.Configure("1", 1E6, 0.1); 79 | Assert.AreEqual("1", DutyCycle.Channel); 80 | Assert.AreEqual(1E6, DutyCycle.FrequencyEstimate); 81 | Assert.AreEqual(0.1, DutyCycle.Resolution); 82 | 83 | } 84 | 85 | [Test] 86 | public void EdgeTime() 87 | { 88 | IIviCounterEdgeTime EdgeTime = Counter.EdgeTime; 89 | Assert.IsNotNull(EdgeTime); 90 | 91 | EdgeTime.Configure("1", new PrecisionTimeSpan(new TimeSpan((long)(TimeSpan.TicksPerSecond * 0.1))), new PrecisionTimeSpan(new TimeSpan((long)(TimeSpan.TicksPerSecond * 0.000001)))); 92 | Assert.AreEqual("1", EdgeTime.Channel); 93 | Assert.AreEqual(new PrecisionTimeSpan(new TimeSpan((long)(TimeSpan.TicksPerSecond * 0.1))), EdgeTime.Estimate); 94 | Assert.AreEqual(new PrecisionTimeSpan(new TimeSpan((long)(TimeSpan.TicksPerSecond * 0.000001))), EdgeTime.Resolution); 95 | 96 | EdgeTime.Configure("1", new PrecisionTimeSpan(new TimeSpan((long)(TimeSpan.TicksPerSecond * 0.01))), new PrecisionTimeSpan(new TimeSpan((long)(TimeSpan.TicksPerSecond * 0.0000001)))); 97 | Assert.AreEqual("1", EdgeTime.Channel); 98 | Assert.AreEqual(new PrecisionTimeSpan(new TimeSpan((long)(TimeSpan.TicksPerSecond * 0.01))), EdgeTime.Estimate); 99 | Assert.AreEqual(new PrecisionTimeSpan(new TimeSpan((long)(TimeSpan.TicksPerSecond * 0.0000001))), EdgeTime.Resolution); 100 | } 101 | 102 | [Test] 103 | public void Frequency() 104 | { 105 | IIviCounterFrequency Frequency = Counter.Frequency; 106 | Assert.IsNotNull(Frequency); 107 | 108 | Frequency.ConfigureManual("1", 1E7, 1E3); 109 | Assert.AreEqual("1", Frequency.Channel); 110 | Assert.AreEqual(1E7, Frequency.Estimate); 111 | Assert.GreaterOrEqual(1E3, Frequency.Resolution); 112 | } 113 | 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /IVI.C.NET.Adapter.Test/IviDCPwrAdapterTest.cs: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------------------- 2 | // 3 | // Copyright Tom Lu 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //-------------------------------------------------------------------------------------------------- 18 | 19 | using System; 20 | using NUnit.Framework; 21 | using Ivi.Driver; 22 | using Ivi.DCPwr; 23 | 24 | namespace IVI.C.NET.Adapter.Test 25 | { 26 | [TestFixture] 27 | public class IviDCPwrAdapterTest 28 | { 29 | private IIviDCPwr DCPwr = null; 30 | [SetUp] 31 | public void InitAdapter() 32 | { 33 | DCPwr = (IIviDCPwr)IviDriver.Create("AgE36xx", true, true, "Simulate=1,RangeCheck=1,QueryInstrStatus=0,Cache=1"); 34 | } 35 | 36 | [Test] 37 | public void OutputTest() 38 | { 39 | Assert.AreEqual(1, DCPwr.Outputs.Count); 40 | 41 | foreach (IIviDCPwrOutput Output in DCPwr.Outputs) 42 | { 43 | Output.ConfigureCurrentLimit(CurrentLimitBehavior.Regulate, 1); 44 | Output.ConfigureOvp(true, 10); 45 | Output.ConfigureRange(RangeType.Voltage, 50); 46 | Output.VoltageLevel = 8; 47 | Output.TriggerSource = "Immediate"; 48 | Output.TriggeredCurrentLimit = 0.5; 49 | Output.TriggeredVoltageLevel = 7; 50 | Output.Enabled = true; 51 | 52 | Assert.AreEqual(CurrentLimitBehavior.Regulate, Output.CurrentLimitBehavior); 53 | Assert.AreEqual(1, Output.CurrentLimit); 54 | Assert.AreEqual(true, Output.OvpEnabled); 55 | Assert.AreEqual(10, Output.OvpLimit); 56 | Assert.AreEqual(8, Output.VoltageLevel); 57 | Assert.AreEqual("Immediate", Output.TriggerSource); 58 | Assert.AreEqual(0.5, Output.TriggeredCurrentLimit); 59 | Assert.AreEqual(7, Output.TriggeredVoltageLevel); 60 | Assert.AreEqual(true, Output.Enabled); 61 | Assert.IsTrue(Math.Abs((Output.Measure(MeasurementType.Voltage) - Output.VoltageLevel)) < 0.5); 62 | 63 | 64 | Output.ConfigureCurrentLimit(CurrentLimitBehavior.Trip, 5); 65 | Output.ConfigureOvp(false, 8); 66 | //Output.ConfigureRange(RangeType.Current, 10); 67 | Output.VoltageLevel = 5; 68 | Output.TriggerSource = "Software"; 69 | Output.TriggeredCurrentLimit = 2; 70 | Output.TriggeredVoltageLevel = 5.1; 71 | Output.Enabled = false; 72 | 73 | Assert.AreEqual(CurrentLimitBehavior.Trip, Output.CurrentLimitBehavior); 74 | Assert.AreEqual(5, Output.CurrentLimit); 75 | Assert.AreEqual(false, Output.OvpEnabled); 76 | Assert.AreEqual(8, Output.OvpLimit); 77 | Assert.AreEqual(5, Output.VoltageLevel); 78 | Assert.AreEqual("Software", Output.TriggerSource); 79 | Assert.AreEqual(2, Output.TriggeredCurrentLimit); 80 | Assert.AreEqual(5.1, Output.TriggeredVoltageLevel); 81 | Assert.AreEqual(false, Output.Enabled); 82 | Assert.IsTrue(Output.Measure(MeasurementType.Current) < 0.001); 83 | 84 | } 85 | } 86 | 87 | [Test] 88 | public void TriggerTest() 89 | { 90 | DCPwr.Trigger.Initiate(); 91 | DCPwr.Trigger.SendSoftwareTrigger(); 92 | DCPwr.Trigger.Abort(); 93 | } 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /IVI.C.NET.Adapter.Test/IviDigitizerAdapterTest.cs: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------------------- 2 | // 3 | // Copyright Tom Lu 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //-------------------------------------------------------------------------------------------------- 18 | 19 | using System; 20 | using NUnit.Framework; 21 | using Ivi.Driver; 22 | using Ivi.Digitizer; 23 | 24 | namespace IVI.C.NET.Adapter.Test 25 | { 26 | [TestFixture] 27 | public class IviDigitizerAdapterTest 28 | { 29 | private IIviDigitizer Digitizer = null; 30 | 31 | [SetUp] 32 | public void InitAdapter() 33 | { 34 | Digitizer = (IIviDigitizer)IviDriver.Create("agl453xdni", true, true, "Simulate=1,RangeCheck=1,QueryInstrStatus=0,Cache=1"); 35 | } 36 | 37 | [Test] 38 | public void Acquisition() 39 | { 40 | IIviDigitizerAcquisition Acquisition = Digitizer.Acquisition; 41 | Assert.IsNotNull(Acquisition); 42 | 43 | Acquisition.ConfigureAcquisition(10, 100, 1E6); 44 | Assert.AreEqual(10, Acquisition.NumberOfRecordsToAcquire); 45 | Assert.AreEqual(100, Acquisition.RecordSize); 46 | Assert.AreEqual(1E6, Acquisition.SampleRate); 47 | 48 | Acquisition.SampleMode = SampleMode.RealTime; 49 | Assert.AreEqual(SampleMode.RealTime, Acquisition.SampleMode); 50 | 51 | Acquisition.Initiate(); 52 | Acquisition.WaitForAcquisitionComplete(new PrecisionTimeSpan((decimal)1)); 53 | Acquisition.Abort(); 54 | } 55 | 56 | [Test] 57 | public void Channels() 58 | { 59 | foreach (IIviDigitizerChannel Channel in Digitizer.Channels) 60 | { 61 | Channel.Configure(10, 0, VerticalCoupling.DC, true); 62 | Assert.AreEqual(16, Channel.Range); 63 | Assert.AreEqual(0, Channel.Offset); 64 | Assert.AreEqual(VerticalCoupling.DC, Channel.Coupling); 65 | Assert.IsTrue(Channel.Enabled); 66 | 67 | Channel.Configure(20, 0, VerticalCoupling.DC, true); 68 | Assert.AreEqual(32, Channel.Range); 69 | Assert.AreEqual(0, Channel.Offset); 70 | Assert.AreEqual(VerticalCoupling.DC, Channel.Coupling); 71 | Assert.IsTrue(Channel.Enabled); 72 | 73 | Digitizer.Acquisition.ConfigureAcquisition(1, 1000, 1E6); 74 | 75 | IWaveform waveformDouble = Digitizer.Acquisition.CreateWaveformDouble(1000); 76 | waveformDouble = Channel.Measurement.ReadWaveform(new PrecisionTimeSpan((decimal)10), waveformDouble); 77 | Assert.AreEqual(1000, waveformDouble.ValidPointCount); 78 | 79 | Digitizer.Acquisition.ConfigureAcquisition(10, 1000, 1E6); 80 | Digitizer.Acquisition.Initiate(); 81 | Digitizer.Acquisition.WaitForAcquisitionComplete(new PrecisionTimeSpan((decimal) 20)); 82 | IWaveformCollection waveforms = Channel.MultiRecordMeasurement.FetchMultiRecordWaveform(0, 10, 0, 1000, (IWaveformCollection)null); 83 | 84 | Assert.AreEqual(10, waveforms.ValidWaveformCount); 85 | Assert.AreEqual(1000, waveforms[0].ValidPointCount); 86 | 87 | } 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /IVI.C.NET.Adapter.Test/IviDmmAdapterTest.cs: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------------------- 2 | // 3 | // Copyright Tom Lu 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //-------------------------------------------------------------------------------------------------- 18 | 19 | using System; 20 | using NUnit.Framework; 21 | using Ivi.Driver; 22 | using Ivi.Dmm; 23 | 24 | namespace IVI.C.NET.Adapter.Test 25 | { 26 | [TestFixture] 27 | public class IviDmmAdapterTest 28 | { 29 | private IIviDmm Dmm = null; 30 | [SetUp] 31 | public void InitAdapter() 32 | { 33 | Dmm = (IIviDmm)IviDriver.Create("Ag34401", true, true, "Simulate=1,RangeCheck=1,QueryInstrStatus=0,Cache=1"); 34 | } 35 | 36 | [Test] 37 | public void ConfigureMeasurement() 38 | { 39 | Dmm.Configure(MeasurementFunction.DCCurrent, Auto.On, 0.001); 40 | Assert.AreEqual(MeasurementFunction.DCCurrent, Dmm.MeasurementFunction); 41 | Assert.AreEqual(Auto.On, Dmm.AutoRange); 42 | // Assert.Less(0, Dmm.Range); 43 | Assert.GreaterOrEqual(0.001, Dmm.Resolution); 44 | 45 | Dmm.Configure(MeasurementFunction.DCVolts, 10, 0.01); 46 | Assert.AreEqual(MeasurementFunction.DCVolts, Dmm.MeasurementFunction); 47 | Assert.AreEqual(Auto.Off, Dmm.AutoRange); 48 | Assert.AreEqual(10, Dmm.Range); 49 | Assert.GreaterOrEqual(0.01, Dmm.Resolution); 50 | 51 | } 52 | 53 | [Test] 54 | public void AC() 55 | { 56 | Dmm.MeasurementFunction = MeasurementFunction.ACVolts; 57 | IIviDmmAC AC = Dmm.AC; 58 | AC.ConfigureBandwidth(10, 100); 59 | Assert.AreEqual(10, AC.FrequencyMin); 60 | Assert.AreEqual(300000, AC.FrequencyMax); 61 | 62 | AC.ConfigureBandwidth(5, 50); 63 | Assert.AreEqual(5, AC.FrequencyMin); 64 | Assert.AreEqual(300000, AC.FrequencyMax); 65 | } 66 | 67 | [Test] 68 | public void Advanced() 69 | { 70 | IIviDmmAdvanced Advanced = Dmm.Advanced; 71 | Advanced.AutoZero = Auto.On; 72 | Assert.AreEqual(Auto.On, Advanced.AutoZero); 73 | Advanced.AutoZero = Auto.Off; 74 | Assert.AreEqual(Auto.Off, Advanced.AutoZero); 75 | 76 | Assert.AreEqual(10, Advanced.ApertureTime); 77 | Assert.AreEqual(ApertureTimeUnits.PowerlineCycles, Advanced.ApertureTimeUnits); 78 | 79 | Advanced.PowerlineFrequency = 60; 80 | Assert.AreEqual(60, Advanced.PowerlineFrequency); 81 | 82 | Advanced.PowerlineFrequency = 100; 83 | Assert.AreEqual(60, Advanced.PowerlineFrequency); 84 | } 85 | 86 | [Test] 87 | public void Frequency() 88 | { 89 | IIviDmmFrequency Frequency = Dmm.Frequency; 90 | Frequency.VoltageAutoRange = true; 91 | // due to difference between IVI-C and IVI.NET driver, this property will always return false. 92 | Assert.AreEqual(false, Frequency.VoltageAutoRange); 93 | Frequency.VoltageRange = 5; 94 | Assert.AreEqual(5, Frequency.VoltageRange); 95 | 96 | Frequency.VoltageAutoRange = false; 97 | // due to difference between IVI-C and IVI.NET driver, this property will always return false. 98 | Assert.AreEqual(false, Frequency.VoltageAutoRange); 99 | Frequency.VoltageRange = 10; 100 | Assert.AreEqual(10, Frequency.VoltageRange); 101 | } 102 | 103 | [Test] 104 | [Ignore] 105 | public void Temperature() 106 | { 107 | Dmm.MeasurementFunction = MeasurementFunction.Temperature; 108 | IIviDmmTemperature Temperature = Dmm.Temperature; 109 | Temperature.TransducerType = TransducerType.Thermistor; 110 | //Assert.AreEqual(TransducerType.Thermistor, Temperature.TransducerType); 111 | Temperature.TransducerType = TransducerType.Thermocouple; 112 | //Assert.AreEqual(TransducerType.Thermocouple, Temperature.TransducerType); 113 | 114 | //Temperature.Rtd.Configure(10, 100); 115 | //Assert.AreEqual(10, Temperature.Rtd.Alpha); 116 | //Assert.AreEqual(100, Temperature.Rtd.Resistance); 117 | 118 | //Temperature.Rtd.Configure(20, 200); 119 | //Assert.AreEqual(20, Temperature.Rtd.Alpha); 120 | //Assert.AreEqual(200, Temperature.Rtd.Resistance); 121 | 122 | Temperature.Thermistor.Resistance = 100; 123 | Assert.AreEqual(100, Temperature.Thermistor.Resistance); 124 | 125 | Temperature.Thermistor.Resistance = 50; 126 | Assert.AreEqual(50, Temperature.Thermistor.Resistance); 127 | 128 | Temperature.Thermocouple.Configure(ThermocoupleType.B, ReferenceJunctionType.Internal); 129 | Assert.AreEqual(ThermocoupleType.B, Temperature.Thermocouple.Type); 130 | Assert.AreEqual(ReferenceJunctionType.Internal, Temperature.Thermocouple.ReferenceJunctionType); 131 | } 132 | 133 | [Test] 134 | public void Trigger() 135 | { 136 | IIviDmmTrigger Trigger = Dmm.Trigger; 137 | Trigger.Configure("Software", true); 138 | Assert.AreEqual("Software", Trigger.Source); 139 | // due to difference between IVI-C and IVI.NET driver, this property will always return false. 140 | Assert.AreEqual(false, Trigger.DelayAuto); 141 | PrecisionTimeSpan delay = new PrecisionTimeSpan((decimal)100); 142 | Trigger.Configure("External", delay); 143 | Assert.AreEqual("External", Trigger.Source); 144 | Assert.AreEqual(delay, Trigger.Delay); 145 | 146 | Trigger.Slope = Slope.Positive; 147 | // Assert.AreEqual(Slope.Positive, Trigger.Slope); // Failed, why? 148 | Trigger.Slope = Slope.Negative; 149 | Assert.AreEqual(Slope.Negative, Trigger.Slope); 150 | 151 | Trigger.MeasurementCompleteDestination = "TTL0"; 152 | // Assert.AreEqual("TTL0", Trigger.MeasurementCompleteDestination); // Failed 153 | 154 | Trigger.MeasurementCompleteDestination = "External"; 155 | Assert.AreEqual("External", Trigger.MeasurementCompleteDestination); 156 | 157 | Trigger.MultiPoint.Configure(1, 10, "Software", new PrecisionTimeSpan((decimal)10)); 158 | Assert.AreEqual(1, Trigger.MultiPoint.TriggerCount); 159 | Assert.AreEqual(10, Trigger.MultiPoint.SampleCount); 160 | Assert.AreEqual("Software", Trigger.MultiPoint.SampleTrigger); 161 | 162 | 163 | } 164 | 165 | [Test] 166 | public void MeasurementTest() 167 | { 168 | Dmm.Configure(MeasurementFunction.DCCurrent, Auto.Off, 0.001); 169 | IIviDmmMeasurement Measurement = Dmm.Measurement; 170 | Assert.IsNotNull(Measurement); 171 | 172 | 173 | Dmm.Trigger.Configure("Immediate", true); 174 | Assert.AreNotEqual(double.NaN, Measurement.Read(new PrecisionTimeSpan((decimal)10))); 175 | 176 | Dmm.Trigger.MultiPoint.Configure(1, 100, "Immediate", new PrecisionTimeSpan((decimal)1)); 177 | double[] ReadMultiPointResult = Measurement.ReadMultiPoint(new PrecisionTimeSpan((decimal)10), 100); 178 | 179 | Assert.AreEqual(100, ReadMultiPointResult.Length); 180 | 181 | 182 | Dmm.Measurement.Initiate(); 183 | 184 | Dmm.Trigger.Configure("Immediate", true); 185 | Assert.AreNotEqual(double.NaN, Measurement.Fetch(new PrecisionTimeSpan((decimal)10))); 186 | 187 | Dmm.Trigger.MultiPoint.Configure(1, 100, "Immediate", new PrecisionTimeSpan((decimal)1)); 188 | double[] FetchMultiPointResult = Measurement.FetchMultiPoint(new PrecisionTimeSpan((decimal)10), 100); 189 | 190 | Assert.AreEqual(100, FetchMultiPointResult.Length); 191 | 192 | Dmm.Measurement.Abort(); 193 | 194 | } 195 | } 196 | } 197 | -------------------------------------------------------------------------------- /IVI.C.NET.Adapter.Test/IviDriverAdapterTest.cs: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------------------- 2 | // 3 | // Copyright Tom Lu 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //-------------------------------------------------------------------------------------------------- 18 | 19 | using System; 20 | using System.Collections.Generic; 21 | using System.Text; 22 | using NUnit.Framework; 23 | using Ivi.Driver; 24 | 25 | namespace IVI.C.NET.Adapter.Test 26 | { 27 | [TestFixture] 28 | public class IviDriverAdapterTest 29 | { 30 | private IIviDriver Driver = null; 31 | [SetUp] 32 | public void InitAdapter() 33 | { 34 | Driver = IviDriver.Create("Ag34401", true, true, "Simulate=1,RangeCheck=1,QueryInstrStatus=0,Cache=1"); 35 | } 36 | 37 | [Test] 38 | public void DriverIdentity() 39 | { 40 | IIviDriverIdentity Identity = Driver.Identity; 41 | Assert.IsNotNull(Identity); 42 | Assert.AreEqual("IVI driver for Agilent Technologies 34401A Digital Multi Meter", Identity.Description); 43 | Assert.AreEqual("Ag34401", Identity.Identifier); 44 | Assert.AreEqual("1.2.5.0", Identity.Revision); 45 | Assert.AreEqual("Agilent Technologies", Identity.InstrumentManufacturer); 46 | Assert.AreEqual("34401A", Identity.InstrumentModel); 47 | Assert.AreEqual("Sim1.2.5.0", Identity.InstrumentFirmwareRevision); 48 | Assert.AreEqual(3, Identity.SpecificationMajorVersion); 49 | 50 | // Error with 34401 Driver 51 | // Assert.AreEqual(0, Identity.SpecificationMinorVersion); 52 | 53 | string SupportedInstrumentModels = "34401A"; 54 | Assert.AreEqual(SupportedInstrumentModels.Split(','), Identity.GetSupportedInstrumentModels()); 55 | string GetGroupCapabilities = "IviDmmBase,IviDmmACMeasurement,IviDmmFrequencyMeasurement,IviDmmMultiPoint,IviDmmTriggerSlope,IviDmmSoftwareTrigger,IviDmmDeviceInfo,IviDmmAutoRangeValue,IviDmmAutoZero"; 56 | Assert.AreEqual(GetGroupCapabilities.Split(','), Identity.GetGroupCapabilities()); 57 | } 58 | 59 | [Test] 60 | public void DriverOperation() 61 | { 62 | IIviDriverOperation DriverOperation = Driver.DriverOperation; 63 | Assert.IsNotNull(DriverOperation); 64 | Assert.AreEqual("Ag34401", DriverOperation.LogicalName); 65 | Assert.AreEqual("COM1", DriverOperation.IOResourceDescriptor); 66 | Assert.AreEqual("Ag34401", DriverOperation.DriverSetup); 67 | Assert.AreEqual(false, DriverOperation.Cache); 68 | Assert.AreEqual(false, DriverOperation.RangeCheck); 69 | Assert.AreEqual(false, DriverOperation.QueryInstrumentStatus); 70 | Assert.AreEqual(true, DriverOperation.Simulate); 71 | 72 | // Unsupported by 34401 driver 73 | // DriverOperation.ResetInterchangeCheck(); 74 | DriverOperation.InvalidateAllAttributes(); 75 | } 76 | 77 | [Test] 78 | public void DriverUtility() 79 | { 80 | IIviDriverUtility DriverUtility = Driver.Utility; 81 | DriverUtility.Reset(); 82 | DriverUtility.ResetWithDefaults(); 83 | ErrorQueryResult ErrorResult = DriverUtility.ErrorQuery(); 84 | Assert.AreEqual(0, ErrorResult.Code); 85 | Assert.AreEqual("No error.", ErrorResult.Message); 86 | 87 | SelfTestResult SelfTestResult = DriverUtility.SelfTest(); 88 | Assert.AreEqual(0, SelfTestResult.Code); 89 | Assert.AreEqual("Selftest passed", SelfTestResult.Message); 90 | 91 | IIviDriverLock DriverLock = DriverUtility.Lock(); 92 | DriverLock.Unlock(); 93 | DriverUtility.Disable(); 94 | 95 | } 96 | 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /IVI.C.NET.Adapter.Test/IviScopeAdapterTest.cs: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------------------- 2 | // 3 | // Copyright Tom Lu 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //-------------------------------------------------------------------------------------------------- 18 | 19 | using System; 20 | using NUnit.Framework; 21 | using Ivi.Driver; 22 | using Ivi.Scope; 23 | 24 | namespace IVI.C.NET.Adapter.Test 25 | { 26 | [TestFixture] 27 | public class IviScopeAdapterTest 28 | { 29 | private IIviScope Scope = null; 30 | [SetUp] 31 | public void InitAdapter() 32 | { 33 | Scope = (IIviScope)IviDriver.Create("ag1000ni", true, true, "Simulate=1,RangeCheck=1,QueryInstrStatus=0,Cache=1"); 34 | } 35 | 36 | [Test] 37 | public void Acquisition() 38 | { 39 | IIviScopeAcquisition Acquisition = Scope.Acquisition; 40 | 41 | Assert.IsNotNull(Acquisition); 42 | Acquisition.ConfigureRecord(new PrecisionTimeSpan((decimal)10), 100, new PrecisionTimeSpan((decimal)5)); 43 | 44 | Assert.AreEqual(10, Acquisition.TimePerRecord.TotalSeconds); 45 | Assert.AreEqual(100, Acquisition.RecordLength); 46 | Assert.AreEqual(5, Acquisition.StartTime.TotalSeconds); 47 | 48 | Acquisition.Type = AcquisitionType.Average; 49 | Assert.AreEqual(AcquisitionType.Average, Acquisition.Type); 50 | 51 | Acquisition.Type = AcquisitionType.Normal; 52 | Assert.AreEqual(AcquisitionType.Normal, Acquisition.Type); 53 | 54 | } 55 | 56 | [Test] 57 | public void Channel() 58 | { 59 | foreach (IIviScopeChannel Channel in Scope.Channels) 60 | { 61 | Channel.Configure(10, 0, VerticalCoupling.DC, 10, true); 62 | Assert.AreEqual(10, Channel.Range); 63 | Assert.AreEqual(0, Channel.Offset); 64 | Assert.AreEqual(VerticalCoupling.DC, Channel.Coupling); 65 | Assert.AreEqual(10, Channel.ProbeAttenuation); 66 | Assert.AreEqual(true, Channel.Enabled); 67 | 68 | Channel.Configure(9, 1, VerticalCoupling.AC, 100, false); 69 | Assert.AreEqual(9, Channel.Range); 70 | Assert.AreEqual(1, Channel.Offset); 71 | Assert.AreEqual(VerticalCoupling.AC, Channel.Coupling); 72 | Assert.AreEqual(100, Channel.ProbeAttenuation); 73 | Assert.AreEqual(false, Channel.Enabled); 74 | 75 | Channel.Enabled = false; 76 | Assert.AreEqual(false, Channel.Enabled); 77 | 78 | Channel.Enabled = true; 79 | Assert.AreEqual(true, Channel.Enabled); 80 | 81 | Channel.InputImpedance = 1E6; 82 | Assert.AreEqual(1E6, Channel.InputImpedance); 83 | 84 | Channel.InputFrequencyMaximum = 10E6; 85 | Assert.AreEqual(10E6, Channel.InputFrequencyMaximum); 86 | Channel.InputFrequencyMaximum = 100E6; 87 | Assert.AreEqual(100E6, Channel.InputFrequencyMaximum); 88 | 89 | 90 | Scope.Trigger.Configure(TriggerType.Edge, new PrecisionTimeSpan((decimal)1)); 91 | IWaveform waveformDouble = Scope.Measurement.CreateWaveformDouble(100); 92 | waveformDouble = Channel.Measurement.ReadWaveform(new PrecisionTimeSpan((decimal) 10), waveformDouble); 93 | 94 | Assert.AreEqual(100, waveformDouble.ValidPointCount); 95 | 96 | IWaveform waveformByte = Scope.Measurement.CreateWaveformByte(100); 97 | waveformByte = Channel.Measurement.ReadWaveform(new PrecisionTimeSpan((decimal)10), waveformByte); 98 | 99 | Assert.AreEqual(100, waveformByte.ValidPointCount); 100 | 101 | } 102 | } 103 | 104 | [Test] 105 | public void Measurement() 106 | { 107 | IIviScopeMeasurement Measurement = Scope.Measurement; 108 | Assert.IsNotNull(Measurement); 109 | 110 | Assert.AreEqual(AcquisitionStatus.Complete, Measurement.Status()); 111 | Measurement.AutoSetup(); 112 | Measurement.Initiate(); 113 | Assert.AreEqual(AcquisitionStatus.Complete, Measurement.Status()); 114 | Measurement.Abort(); 115 | 116 | IWaveform waveformByte = Measurement.CreateWaveformByte(100); 117 | IWaveform waveformInt16 = Measurement.CreateWaveformInt16(100); 118 | IWaveform waveformInt32 = Measurement.CreateWaveformInt32(100); 119 | IWaveform waveformDouble = Measurement.CreateWaveformDouble(100); 120 | 121 | Assert.AreEqual(100, waveformByte.Capacity); 122 | Assert.AreEqual(100, waveformInt16.Capacity); 123 | Assert.AreEqual(100, waveformInt32.Capacity); 124 | Assert.AreEqual(100, waveformDouble.Capacity); 125 | 126 | } 127 | 128 | [Test] 129 | public void ReferenceLevel() 130 | { 131 | IIviScopeReferenceLevel ReferenceLevel = Scope.ReferenceLevel; 132 | Assert.IsNotNull(ReferenceLevel); 133 | 134 | ReferenceLevel.Configure(0.7, 1.5, 3.0); 135 | Assert.AreEqual(0.7, ReferenceLevel.Low); 136 | Assert.AreEqual(1.5, ReferenceLevel.Mid); 137 | Assert.AreEqual(3.0, ReferenceLevel.High); 138 | } 139 | 140 | [Test] 141 | public void Trigger() 142 | { 143 | IIviScopeTrigger Trigger = Scope.Trigger; 144 | Assert.IsNotNull(Trigger); 145 | 146 | Trigger.Configure(TriggerType.Edge, new PrecisionTimeSpan((decimal)1)); 147 | Assert.AreEqual(TriggerType.Edge, Trigger.Type); 148 | Assert.AreEqual(1, Trigger.Holdoff.TotalSeconds); 149 | 150 | Trigger.Source = "External"; 151 | Assert.AreEqual("External", Trigger.Source); 152 | 153 | Trigger.Source = "TTL0"; 154 | Assert.AreEqual("TTL0", Trigger.Source); 155 | 156 | Trigger.Coupling = TriggerCoupling.DC; 157 | Assert.AreEqual(TriggerCoupling.DC, Trigger.Coupling); 158 | 159 | Trigger.Coupling = TriggerCoupling.AC; 160 | Assert.AreEqual(TriggerCoupling.AC, Trigger.Coupling); 161 | 162 | Trigger.Continuous = false; 163 | Assert.AreEqual(false, Trigger.Continuous); 164 | 165 | Trigger.Continuous = true; 166 | Assert.AreEqual(true, Trigger.Continuous); 167 | 168 | // Trigger.ACLine.Slope = ACLineSlope.Positive; 169 | // Assert.AreEqual(ACLineSlope.Positive, Trigger.ACLine.Slope); 170 | 171 | // Trigger.ACLine.Slope = ACLineSlope.Negative; 172 | // Assert.AreEqual(ACLineSlope.Negative, Trigger.ACLine.Slope); 173 | 174 | Trigger.Edge.Slope = Slope.Positive; 175 | Assert.AreEqual(Slope.Positive, Trigger.Edge.Slope); 176 | Trigger.Edge.Slope = Slope.Negative; 177 | Assert.AreEqual(Slope.Negative, Trigger.Edge.Slope); 178 | 179 | } 180 | 181 | 182 | } 183 | } -------------------------------------------------------------------------------- /IVI.C.NET.Adapter.Test/IviSpecAnAdapterTest.cs: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------------------- 2 | // 3 | // Copyright Tom Lu 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //-------------------------------------------------------------------------------------------------- 18 | 19 | using System; 20 | using NUnit.Framework; 21 | using Ivi.Driver; 22 | using Ivi.SpecAn; 23 | 24 | namespace IVI.C.NET.Adapter.Test 25 | { 26 | [TestFixture] 27 | public class IviSpecAnAdapterTest 28 | { 29 | private IIviSpecAn SpecAn = null; 30 | 31 | [SetUp] 32 | public void InitAdapter() 33 | { 34 | SpecAn = (IIviSpecAn)IviDriver.Create("agpsa", true, true, "Simulate=1,RangeCheck=1,QueryInstrStatus=0,Cache=1"); 35 | } 36 | 37 | [Test] 38 | public void Acquisition() 39 | { 40 | IIviSpecAnAcquisition Acquisition = SpecAn.Acquisition; 41 | Assert.IsNotNull(Acquisition); 42 | Acquisition.Configure(true, 1, DetectorType.AutoPeak, VerticalScale.Linear); 43 | Assert.AreEqual(true, Acquisition.SweepModeContinuous); 44 | Assert.AreEqual(1, Acquisition.NumberOfSweeps); 45 | Assert.AreEqual(DetectorType.AutoPeak, Acquisition.DetectorType); 46 | Assert.AreEqual(VerticalScale.Linear, Acquisition.VerticalScale); 47 | } 48 | 49 | [Test] 50 | public void Trace() 51 | { 52 | SpecAn.Frequency.ConfigureStartStop(500.0e6, 600.0e6); 53 | SpecAn.SweepCoupling.Configure(true, true, true); 54 | SpecAn.Acquisition.Configure(false, 1, DetectorType.MaxPeak, VerticalScale.Logarithmic); 55 | SpecAn.Level.Configure(AmplitudeUnits.dBm, 50, 0, 0, true); 56 | // SpecAn.Trigger.Source = "Immediate"; 57 | SpecAn.Marker.DisableAll(); 58 | 59 | foreach (IIviSpecAnTrace Trace in SpecAn.Traces) 60 | { 61 | Trace.Type = TraceType.ClearWrite; 62 | IWaveform waveform = new Ivi.Driver.Waveform(new PrecisionTimeSpan((decimal)1), 100); 63 | waveform = Trace.ReadY(new PrecisionTimeSpan((decimal)10), waveform); 64 | 65 | } 66 | } 67 | 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /IVI.C.NET.Adapter.Test/IviSwtchAdapterTest.cs: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------------------- 2 | // 3 | // Copyright Tom Lu 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //-------------------------------------------------------------------------------------------------- 18 | 19 | using System; 20 | using NUnit.Framework; 21 | using Ivi.Driver; 22 | using Ivi.Swtch; 23 | 24 | namespace IVI.C.NET.Adapter.Test 25 | { 26 | [TestFixture] 27 | public class IviSwtchAdapterTest 28 | { 29 | private IIviSwtch Swtch = null; 30 | 31 | [SetUp] 32 | public void InitAdapter() 33 | { 34 | Swtch = (IIviSwtch)IviDriver.Create("age1442a", true, true, "Simulate=1,RangeCheck=1,QueryInstrStatus=0,Cache=1"); 35 | } 36 | 37 | [Test] 38 | public void Channels() 39 | { 40 | foreach (IIviSwtchChannel Channel in Swtch.Channels) 41 | { 42 | Assert.IsNotNullOrEmpty(Channel.Name); 43 | Assert.IsFalse(Channel.IsSourceChannel); 44 | Assert.IsFalse(Channel.IsConfigurationChannel); 45 | 46 | IIviSwtchCharacteristics Characteristics = Channel.Characteristics; 47 | Assert.AreEqual(1, Characteristics.WireMode); 48 | } 49 | } 50 | 51 | [Test] 52 | [Ignore("Unsupported by age1442a driver")] 53 | public void Scan() 54 | { 55 | IIviSwtchScan Scan = Swtch.Scan; 56 | Assert.IsNotNull(Scan); 57 | 58 | string ScanList = "00C->00NC & 01C->01NC & 02C->02NC"; 59 | Scan.ConfigureList(ScanList, ScanMode.BreakAfterMake); 60 | 61 | Assert.AreEqual(ScanList, Scan.List); 62 | Assert.AreEqual(ScanMode.BreakAfterMake, Scan.Mode); 63 | } 64 | 65 | [Test] 66 | public void Path() 67 | { 68 | IIviSwtchPath Path = Swtch.Path; 69 | Assert.IsNotNull(Path); 70 | 71 | string ch1 = "00C"; 72 | string ch2 = "00NC"; 73 | string ch3 = "00NO"; 74 | 75 | Assert.AreEqual(PathCapability.Available, Path.CanConnect(ch1, ch2)); 76 | Assert.AreEqual(PathCapability.Available, Path.CanConnect(ch1, ch3)); 77 | Assert.AreEqual(PathCapability.Unsupported, Path.CanConnect(ch2, ch3)); 78 | Path.Connect(ch1, ch2); 79 | Assert.AreEqual(PathCapability.Exists, Path.CanConnect(ch1, ch2)); 80 | Assert.AreEqual(PathCapability.ResourceInUse, Path.CanConnect(ch1, ch3)); 81 | Assert.AreEqual(PathCapability.Unsupported, Path.CanConnect(ch2, ch3)); 82 | try 83 | { 84 | Path.Disconnect(ch1, ch2); 85 | } 86 | catch (Exception e) 87 | { 88 | Assert.IsInstanceOf(typeof(InstrumentStatusException), e); 89 | Assert.AreEqual("Some connections remain after disconnecting.", ((InstrumentStatusException)e).Message); 90 | } 91 | 92 | 93 | Assert.AreEqual(PathCapability.Available, Path.CanConnect(ch1, ch2)); 94 | Assert.AreEqual(PathCapability.Available, Path.CanConnect(ch1, ch3)); 95 | Assert.AreEqual(PathCapability.Unsupported, Path.CanConnect(ch2, ch3)); 96 | Path.Connect(ch1, ch3); 97 | Assert.AreEqual(PathCapability.ResourceInUse, Path.CanConnect(ch1, ch2)); 98 | Assert.AreEqual(PathCapability.Exists, Path.CanConnect(ch1, ch3)); 99 | Assert.AreEqual(PathCapability.Unsupported, Path.CanConnect(ch2, ch3)); 100 | try 101 | { 102 | Path.Disconnect(ch1, ch3); 103 | } 104 | catch (Exception e) 105 | { 106 | Assert.IsInstanceOf(typeof(InstrumentStatusException), e); 107 | Assert.AreEqual("Some connections remain after disconnecting.", ((InstrumentStatusException)e).Message); 108 | } 109 | 110 | } 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /IVI.C.NET.Adapter.Test/Libs/nunit.framework.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tom-Lu/IVI.C.NET.Adapter/09f8c5df4aa608ca7f129c04b5793edfef6a42d3/IVI.C.NET.Adapter.Test/Libs/nunit.framework.dll -------------------------------------------------------------------------------- /IVI.C.NET.Adapter.Test/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("IVI.C.NET.Adapter.Test")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("IVI.C.NET.Adapter.Test")] 13 | [assembly: AssemblyCopyright("Copyright © 2014")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("4cce0399-f34a-4bb7-9a8a-c7b73331aaee")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /IVI.C.NET.Adapter.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.40629.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IVI.C.NET.Adapter.Test", "IVI.C.NET.Adapter.Test\IVI.C.NET.Adapter.Test.csproj", "{E84FFD27-A24B-437B-A738-4BA2C994363E}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IVI.C.NET.Adapter.ConfigUtility", "IVI.C.NET.Adapter.ConfigUtility\IVI.C.NET.Adapter.ConfigUtility.csproj", "{C3269A52-A820-4296-837C-365C21E0F1AE}" 9 | EndProject 10 | Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "IVI.C.NET.Adapter.Setup", "IVI.C.NET.Adapter.Setup\IVI.C.NET.Adapter.Setup.vdproj", "{A603C92F-9840-4568-8281-4D80776CB26E}" 11 | EndProject 12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IVI.C.NET.Adapter", "IVI.C.NET.Adapter\IVI.C.NET.Adapter.csproj", "{E95C0FE2-1BCB-4CA4-9BE4-FDA9D5568881}" 13 | EndProject 14 | Global 15 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 16 | Debug|Any CPU = Debug|Any CPU 17 | Release|Any CPU = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 20 | {E84FFD27-A24B-437B-A738-4BA2C994363E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {E84FFD27-A24B-437B-A738-4BA2C994363E}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {E84FFD27-A24B-437B-A738-4BA2C994363E}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {E84FFD27-A24B-437B-A738-4BA2C994363E}.Release|Any CPU.Build.0 = Release|Any CPU 24 | {C3269A52-A820-4296-837C-365C21E0F1AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 25 | {C3269A52-A820-4296-837C-365C21E0F1AE}.Debug|Any CPU.Build.0 = Debug|Any CPU 26 | {C3269A52-A820-4296-837C-365C21E0F1AE}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {C3269A52-A820-4296-837C-365C21E0F1AE}.Release|Any CPU.Build.0 = Release|Any CPU 28 | {A603C92F-9840-4568-8281-4D80776CB26E}.Debug|Any CPU.ActiveCfg = Debug 29 | {A603C92F-9840-4568-8281-4D80776CB26E}.Release|Any CPU.ActiveCfg = Release 30 | {E95C0FE2-1BCB-4CA4-9BE4-FDA9D5568881}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 31 | {E95C0FE2-1BCB-4CA4-9BE4-FDA9D5568881}.Debug|Any CPU.Build.0 = Debug|Any CPU 32 | {E95C0FE2-1BCB-4CA4-9BE4-FDA9D5568881}.Release|Any CPU.ActiveCfg = Release|Any CPU 33 | {E95C0FE2-1BCB-4CA4-9BE4-FDA9D5568881}.Release|Any CPU.Build.0 = Release|Any CPU 34 | EndGlobalSection 35 | GlobalSection(SolutionProperties) = preSolution 36 | HideSolutionNode = FALSE 37 | EndGlobalSection 38 | EndGlobal 39 | -------------------------------------------------------------------------------- /IVI.C.NET.Adapter.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tom-Lu/IVI.C.NET.Adapter/09f8c5df4aa608ca7f129c04b5793edfef6a42d3/IVI.C.NET.Adapter.suo -------------------------------------------------------------------------------- /IVI.C.NET.Adapter/DriverIdentity.cs: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------------------- 2 | // 3 | // Copyright Tom Lu 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //-------------------------------------------------------------------------------------------------- 18 | 19 | using System; 20 | using System.Collections.Generic; 21 | using System.Text; 22 | using Ivi.Driver; 23 | using IVI.C.NET.Adapter.IviCInterop; 24 | 25 | namespace IVI.C.NET.Adapter 26 | { 27 | internal class DriverIdentity : IIviDriverIdentity 28 | { 29 | private IDriverAdapterBase Adapter; 30 | private string TargetSoftwareModuleName; 31 | public DriverIdentity(IDriverAdapterBase Adapter, string TargetSoftwareModuleName) 32 | { 33 | this.Adapter = Adapter; 34 | this.TargetSoftwareModuleName = TargetSoftwareModuleName; 35 | } 36 | 37 | public string[] GetGroupCapabilities() 38 | { 39 | return Adapter.GetAttributeViString(IviDriverAttribute.IVI_ATTR_GROUP_CAPABILITIES).Split(','); 40 | } 41 | 42 | public string[] GetSupportedInstrumentModels() 43 | { 44 | return Adapter.GetAttributeViString(IviDriverAttribute.IVI_ATTR_SUPPORTED_INSTRUMENT_MODELS).Split(','); 45 | } 46 | 47 | public string Identifier 48 | { 49 | //TODO: need implement this function 50 | get { return TargetSoftwareModuleName; } 51 | } 52 | 53 | public string InstrumentFirmwareRevision 54 | { 55 | get 56 | { 57 | return Adapter.GetAttributeViString(IviDriverAttribute.IVI_ATTR_INSTRUMENT_FIRMWARE_REVISION); 58 | } 59 | } 60 | 61 | public string InstrumentManufacturer 62 | { 63 | get 64 | { 65 | return Adapter.GetAttributeViString(IviDriverAttribute.IVI_ATTR_INSTRUMENT_MANUFACTURER); 66 | } 67 | } 68 | 69 | public string InstrumentModel 70 | { 71 | get 72 | { 73 | return Adapter.GetAttributeViString(IviDriverAttribute.IVI_ATTR_INSTRUMENT_MODEL); 74 | } 75 | } 76 | 77 | public int SpecificationMajorVersion 78 | { 79 | get 80 | { 81 | return Adapter.GetAttributeViInt32(IviDriverAttribute.IVI_ATTR_SPECIFIC_DRIVER_CLASS_SPEC_MAJOR_VERSION); 82 | } 83 | } 84 | 85 | public int SpecificationMinorVersion 86 | { 87 | get 88 | { 89 | return Adapter.GetAttributeViInt32(IviDriverAttribute.IVI_ATTR_CLASS_DRIVER_CLASS_SPEC_MINOR_VERSION); 90 | } 91 | } 92 | 93 | public string Description 94 | { 95 | get 96 | { 97 | return Adapter.GetAttributeViString(IviDriverAttribute.IVI_ATTR_SPECIFIC_DRIVER_DESCRIPTION); 98 | } 99 | } 100 | 101 | public string Revision 102 | { 103 | get 104 | { 105 | return Adapter.GetAttributeViString(IviDriverAttribute.IVI_ATTR_SPECIFIC_DRIVER_REVISION); 106 | } 107 | } 108 | 109 | public string Vendor 110 | { 111 | get 112 | { 113 | return Adapter.GetAttributeViString(IviDriverAttribute.IVI_ATTR_SPECIFIC_DRIVER_VENDOR); 114 | } 115 | } 116 | } 117 | } -------------------------------------------------------------------------------- /IVI.C.NET.Adapter/DriverOperation.cs: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------------------- 2 | // 3 | // Copyright Tom Lu 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //-------------------------------------------------------------------------------------------------- 18 | 19 | using System; 20 | using System.Collections.Generic; 21 | using System.Text; 22 | using Ivi.Driver; 23 | using IVI.C.NET.Adapter.IviCInterop; 24 | 25 | namespace IVI.C.NET.Adapter 26 | { 27 | internal class DriverOperation : IIviDriverOperation 28 | { 29 | private IDriverAdapterBase Adapter; 30 | public DriverOperation(IDriverAdapterBase Adapter) 31 | { 32 | this.Adapter = Adapter; 33 | } 34 | 35 | public bool Cache 36 | { 37 | get 38 | { 39 | return Adapter.GetAttributeViBoolean(IviDriverAttribute.IVI_ATTR_CACHE); 40 | } 41 | set 42 | { 43 | Adapter.SetAttributeViBoolean(IviDriverAttribute.IVI_ATTR_CACHE, value); 44 | } 45 | } 46 | 47 | #pragma warning disable 48 | public event EventHandler Coercion; 49 | #pragma warning restore 50 | 51 | public string DriverSetup 52 | { 53 | get 54 | { 55 | return Adapter.GetAttributeViString(IviDriverAttribute.IVI_ATTR_DRIVER_SETUP); 56 | } 57 | } 58 | 59 | public string IOResourceDescriptor 60 | { 61 | get 62 | { 63 | return Adapter.GetAttributeViString(IviDriverAttribute.IVI_ATTR_IO_RESOURCE_DESCRIPTOR); 64 | } 65 | } 66 | 67 | #pragma warning disable 68 | public event EventHandler InterchangeCheckWarning; 69 | #pragma warning restore 70 | 71 | public void InvalidateAllAttributes() 72 | { 73 | Adapter.ViSessionStatusCheck(Adapter.Interop.InvalidateAllAttributes(Adapter.Session)); 74 | } 75 | 76 | public string LogicalName 77 | { 78 | get 79 | { 80 | return Adapter.GetAttributeViString(IviDriverAttribute.IVI_ATTR_LOGICAL_NAME); 81 | } 82 | } 83 | 84 | public bool QueryInstrumentStatus 85 | { 86 | get 87 | { 88 | return Adapter.GetAttributeViBoolean(IviDriverAttribute.IVI_ATTR_QUERY_INSTRUMENT_STATUS); 89 | } 90 | set 91 | { 92 | Adapter.SetAttributeViBoolean(IviDriverAttribute.IVI_ATTR_QUERY_INSTRUMENT_STATUS, value); 93 | } 94 | } 95 | 96 | public bool RangeCheck 97 | { 98 | get 99 | { 100 | return Adapter.GetAttributeViBoolean(IviDriverAttribute.IVI_ATTR_RANGE_CHECK); 101 | } 102 | set 103 | { 104 | Adapter.SetAttributeViBoolean(IviDriverAttribute.IVI_ATTR_RANGE_CHECK, value); 105 | } 106 | } 107 | 108 | public void ResetInterchangeCheck() 109 | { 110 | Adapter.ViSessionStatusCheck(Adapter.Interop.ResetInterchangeCheck(Adapter.Session)); 111 | } 112 | 113 | public bool Simulate 114 | { 115 | get 116 | { 117 | return Adapter.GetAttributeViBoolean(IviDriverAttribute.IVI_ATTR_SIMULATE); 118 | } 119 | set 120 | { 121 | Adapter.SetAttributeViBoolean(IviDriverAttribute.IVI_ATTR_SIMULATE, value); 122 | } 123 | } 124 | 125 | #pragma warning disable 126 | public event EventHandler Warning; 127 | #pragma warning restore 128 | } 129 | } -------------------------------------------------------------------------------- /IVI.C.NET.Adapter/DriverUtility.cs: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------------------- 2 | // 3 | // Copyright Tom Lu 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //-------------------------------------------------------------------------------------------------- 18 | 19 | using System; 20 | using System.Collections.Generic; 21 | using System.Text; 22 | using Ivi.Driver; 23 | using IVI.C.NET.Adapter.IviCInterop; 24 | 25 | namespace IVI.C.NET.Adapter 26 | { 27 | internal class DriverUtility : IIviDriverUtility 28 | { 29 | private IDriverAdapterBase Adapter; 30 | public DriverUtility(IDriverAdapterBase Adapter) 31 | { 32 | this.Adapter = Adapter; 33 | } 34 | 35 | public void Disable() 36 | { 37 | Adapter.Interop.Disable(Adapter.Session); 38 | } 39 | 40 | public ErrorQueryResult ErrorQuery() 41 | { 42 | int error_code = 0; 43 | StringBuilder error_message = new StringBuilder(256); 44 | Adapter.ViSessionStatusCheck(Adapter.Interop.error_query(Adapter.Session, ref error_code, error_message)); 45 | return new ErrorQueryResult(error_code, error_message.ToString()); 46 | } 47 | 48 | public IIviDriverLock Lock(PrecisionTimeSpan maxTime) 49 | { 50 | throw new NotImplementedException(); 51 | } 52 | 53 | public IIviDriverLock Lock() 54 | { 55 | return new IviDriverLock(Adapter); 56 | } 57 | 58 | public void Reset() 59 | { 60 | Adapter.ViSessionStatusCheck(Adapter.Interop.reset(Adapter.Session)); 61 | } 62 | 63 | public void ResetWithDefaults() 64 | { 65 | Adapter.ViSessionStatusCheck(Adapter.Interop.ResetWithDefaults(Adapter.Session)); 66 | } 67 | 68 | public SelfTestResult SelfTest() 69 | { 70 | short selfTestResult = 0; 71 | StringBuilder selfTestMessage = new StringBuilder(1024); 72 | Adapter.ViSessionStatusCheck(Adapter.Interop.self_test(Adapter.Session, ref selfTestResult, selfTestMessage)); 73 | return new SelfTestResult(selfTestResult, selfTestMessage.ToString()); 74 | } 75 | 76 | public class IviDriverLock : IIviDriverLock 77 | { 78 | private bool HasLock = false; 79 | private IDriverAdapterBase Adapter; 80 | public IviDriverLock(IDriverAdapterBase Adapter) 81 | { 82 | this.Adapter = Adapter; 83 | Adapter.ViSessionStatusCheck(Adapter.Interop.LockSession(Adapter.Session, ref HasLock)); 84 | } 85 | 86 | public void Unlock() 87 | { 88 | Adapter.ViSessionStatusCheck(Adapter.Interop.UnlockSession(Adapter.Session, ref HasLock)); 89 | } 90 | 91 | public void Dispose() 92 | { 93 | } 94 | } 95 | } 96 | } -------------------------------------------------------------------------------- /IVI.C.NET.Adapter/IDriverAdapterBase.cs: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------------------- 2 | // 3 | // Copyright Tom Lu 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //-------------------------------------------------------------------------------------------------- 18 | 19 | using System; 20 | using System.Text; 21 | 22 | // Ivi type mapping 23 | using ViStatus = System.Int32; 24 | using ViSession = System.IntPtr; 25 | using ViString = System.String; 26 | using ViBoolean = System.Boolean; 27 | using ViInt8 = System.Byte; 28 | using ViInt16 = System.Int16; 29 | using ViInt32 = System.Int32; 30 | using ViAttr = System.UInt32; 31 | using ViInt64 = System.Int64; 32 | using ViReal64 = System.Double; 33 | 34 | namespace IVI.C.NET.Adapter 35 | { 36 | internal interface IDriverAdapterBase 37 | { 38 | IntPtr Session { get; } 39 | Adapter.IviCInterop.IviDriver Interop { get; } 40 | 41 | void ViSessionStatusCheck(ViStatus Status); 42 | 43 | /*- Set, Get, and Check Attribute Functions -*/ 44 | ViInt32 GetAttributeViInt32(ViAttr attributeId); 45 | ViInt32 GetAttributeViInt32(ViString channelName, ViAttr attributeId); 46 | void SetAttributeViInt32(ViAttr attributeId, ViInt32 value); 47 | void SetAttributeViInt32(ViString channelName, ViAttr attributeId, ViInt32 value); 48 | 49 | 50 | ViInt64 GetAttributeViInt64(ViAttr attributeId); 51 | ViInt64 GetAttributeViInt64(ViString channelName, ViAttr attributeId); 52 | void SetAttributeViInt64(ViAttr attributeId, ViInt64 value); 53 | void SetAttributeViInt64(ViString channelName, ViAttr attributeId, ViInt64 value); 54 | 55 | ViReal64 GetAttributeViReal64(ViAttr attributeId); 56 | ViReal64 GetAttributeViReal64(ViString channelName, ViAttr attributeId); 57 | void SetAttributeViReal64(ViAttr attributeId, ViReal64 value); 58 | void SetAttributeViReal64(ViString channelName, ViAttr attributeId, ViReal64 value); 59 | 60 | string GetAttributeViString(ViAttr attributeId); 61 | string GetAttributeViString(ViString channelName, ViAttr attributeId); 62 | void SetAttributeViString(ViAttr attributeId, ViString value); 63 | void SetAttributeViString(ViString channelName, ViAttr attributeId, ViString value); 64 | 65 | ViBoolean GetAttributeViBoolean(ViAttr attributeId); 66 | ViBoolean GetAttributeViBoolean(ViString channelName, ViAttr attributeId); 67 | void SetAttributeViBoolean(ViAttr attributeId, ViBoolean value); 68 | void SetAttributeViBoolean(ViString channelName, ViAttr attributeId, ViBoolean value); 69 | 70 | ViSession GetAttributeViSession(ViAttr attributeId); 71 | ViSession GetAttributeViSession(ViString channelName, ViAttr attributeId); 72 | void SetAttributeViSession(ViAttr attributeId, ViSession value); 73 | void SetAttributeViSession(ViString channelName, ViAttr attributeId, ViSession value); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /IVI.C.NET.Adapter/IVI.C.NET.Adapter.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | x86 6 | 8.0.30703 7 | 2.0 8 | {E95C0FE2-1BCB-4CA4-9BE4-FDA9D5568881} 9 | Library 10 | Properties 11 | IVI.C.NET.Adapter 12 | IVI.C.NET.Adapter 13 | v2.0 14 | 512 15 | 16 | 17 | 18 | true 19 | 20 | 21 | _IVI.C.NET.Adapter_nopwd.snk 22 | 23 | 24 | true 25 | bin\Debug\ 26 | DEBUG;TRACE 27 | full 28 | AnyCPU 29 | prompt 30 | MinimumRecommendedRules.ruleset 31 | 32 | 33 | bin\Release\ 34 | TRACE 35 | true 36 | pdbonly 37 | AnyCPU 38 | prompt 39 | MinimumRecommendedRules.ruleset 40 | 41 | 42 | 43 | False 44 | Libs\Ivi.Counter.dll 45 | 46 | 47 | False 48 | Libs\Ivi.DCPwr.dll 49 | 50 | 51 | False 52 | Libs\Ivi.Digitizer.dll 53 | 54 | 55 | False 56 | C:\Program Files (x86)\IVI Foundation\IVI\Microsoft.NET\Framework32\v2.0.50727\IviFoundationSharedComponents 1.1.0\Ivi.Dmm.dll 57 | 58 | 59 | False 60 | Libs\Ivi.Downconverter.dll 61 | 62 | 63 | False 64 | Libs\Ivi.Driver.dll 65 | 66 | 67 | False 68 | Libs\Ivi.Fgen.dll 69 | 70 | 71 | False 72 | Libs\Ivi.PwrMeter.dll 73 | 74 | 75 | False 76 | Libs\Ivi.RFSigGen.dll 77 | 78 | 79 | False 80 | Libs\Ivi.Scope.dll 81 | 82 | 83 | False 84 | Libs\Ivi.SpecAn.dll 85 | 86 | 87 | False 88 | Libs\Ivi.Swtch.dll 89 | 90 | 91 | False 92 | Libs\Ivi.Upconverter.dll 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | {C6F576F5-7394-458E-B38A-C20C668585E7} 156 | 1 157 | 6 158 | 0 159 | primary 160 | False 161 | True 162 | 163 | 164 | 165 | 166 | 167 | "%25ProgramFiles%25\Microsoft SDKs\Windows\v7.0A\bin\gacutil.exe" /i "$(TargetPath)" 168 | 169 | 170 | "%25ProgramFiles%25\Microsoft SDKs\Windows\v7.0A\bin\gacutil.exe" /u "IVI.C.NET.Adapter, Version=1.0.0.0, Culture=neutral, PublicKeyToken=55d3badc1a673a0b" 171 | "%25ProgramFiles%25\Microsoft SDKs\Windows\v7.0A\bin\gacutil.exe" /u "IVI.C.NET.Adapter, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d25ace325c488ee2" 172 | 173 | 180 | -------------------------------------------------------------------------------- /IVI.C.NET.Adapter/IVI.C.NET.Adapter.csproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | ProjectFiles 5 | 6 | -------------------------------------------------------------------------------- /IVI.C.NET.Adapter/IviACPwrAdapter.cs: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------------------- 2 | // 3 | // Copyright Tom Lu 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //-------------------------------------------------------------------------------------------------- 18 | 19 | using System; 20 | using Ivi.Driver; 21 | using IVI.C.NET.Adapter.IviCInterop; 22 | 23 | namespace IVI.C.NET.Adapter 24 | { 25 | public class IviACPwrAdapter : DriverAdapterBase 26 | { 27 | public IviACPwrAdapter(string name, bool idQuery, bool reset, string options) 28 | : base(name, idQuery, reset, options) 29 | { 30 | throw new NotImplementedException(); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /IVI.C.NET.Adapter/IviCInterop/IviACPwr.cs: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------------------- 2 | // 3 | // Copyright Tom Lu 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //-------------------------------------------------------------------------------------------------- 18 | 19 | using System; 20 | 21 | // Ivi type mapping 22 | using ViStatus = System.Int32; 23 | using ViSession = System.IntPtr; 24 | using ViString = System.String; 25 | using ViBoolean = System.Boolean; 26 | using ViInt8 = System.Byte; 27 | using ViInt16 = System.Int16; 28 | using ViInt32 = System.Int32; 29 | using ViAttr = System.UInt32; 30 | using ViInt64 = System.Int64; 31 | using ViReal64 = System.Double; 32 | 33 | namespace IVI.C.NET.Adapter.IviCInterop 34 | { 35 | public interface IviACPwr : IviDriver 36 | { 37 | /*- IviACPwrBase Functions -*/ 38 | ViStatus ConfigureCurrentLimit(ViSession vi, ViString PhaseName, ViReal64 Limit); 39 | ViStatus ConfigureOutputEnabled(ViSession vi, ViString PhaseName, ViBoolean Enabled); 40 | ViStatus ConfigureVoltageLevel(ViSession vi, ViString PhaseName, ViReal64 VoltageLevel); 41 | ViStatus ConfigureVoltageRange(ViSession vi, ViString PhaseName, ViReal64 Range); 42 | ViStatus ConfigureFrequency(ViSession vi, ViReal64 Frequency); 43 | ViStatus ConfigureFrequencyRange(ViSession vi, ViReal64 Range); 44 | ViStatus ConfigureWaveform(ViSession vi, ViString PhaseName, ViString WaveformName); 45 | ViStatus QueryVoltageRangeCapabilities(ViSession vi, ViString PhaseName, ViInt32 Range, ViString WaveformName, ref ViReal64 MinVoltage, ref ViReal64 MaxVoltage); 46 | ViStatus QueryFrequencyRangeCapabilities(ViSession vi, ViInt32 Range, ref ViReal64 MinFrequency, ref ViReal64 MaxFrequency); 47 | ViStatus GetOutputPhaseName(ViSession vi, ViInt32 Index, ViInt32 NameBufferSize, ref ViString Name); 48 | 49 | /*- IviACPwrMeasurement Functions -*/ 50 | ViStatus InitiateMeasurement(ViSession vi, ViInt32 Group); 51 | ViStatus FetchMeasurement(ViSession vi, ViString PhaseName, ViInt32 MeasurementType, ref ViReal64 Measurement); 52 | ViStatus FetchMeasurementArray(ViSession vi, ViString PhaseName, ViInt32 MeasurementType, ViInt32 MeasurementBufferSize, ref ViReal64[] Measurement, ref ViInt32 MeasurementActualSize); 53 | 54 | /*- IviACPwrPhase Functions -*/ 55 | ViStatus ConfigurePhaseAngle(ViSession vi, ViString PhaseName, ViReal64 PhaseAngle); 56 | 57 | /*- IviACPwrExternalSync Functions -*/ 58 | ViStatus ConfigureExternalSync(ViSession vi, ViBoolean Enabled, ViReal64 PhaseOffset); 59 | ViStatus QueryExternalSyncLocked(ViSession vi, ref ViBoolean Locked); 60 | 61 | /*- IviACPwrCurrentProtection Functions -*/ 62 | ViStatus QueryCurrentProtectionTripped(ViSession vi, ViString PhaseName, ref ViBoolean Tripped); 63 | ViStatus ResetCurrentProtection(ViSession vi, ViString PhaseName); 64 | ViStatus ConfigureCurrentProtection(ViSession vi, ViString PhaseName, ViBoolean Enabled, ViReal64 Threshold, ViReal64 Delay); 65 | 66 | /*- IviACPwrVoltageProtection Functions -*/ 67 | ViStatus QueryVoltageProtectionTripped(ViSession vi, ViString PhaseName, ref ViBoolean Tripped); 68 | ViStatus ResetVoltageProtection(ViSession vi, ViString PhaseName); 69 | ViStatus ConfigureVoltageProtection(ViSession vi, ViString PhaseName, ViBoolean UnderEnabled, ViBoolean OverEnabled, ViReal64 UnderLimit, ViReal64 OverLimit); 70 | 71 | /*- IviACPwrArbWaveform Functions -*/ 72 | ViStatus ClearArbWaveform(ViSession vi, ViString WaveformName); 73 | ViStatus WriteArbWaveform(ViSession vi, ViString WaveformName, ViInt32 WaveformDataBufferSize, ref ViReal64[] WaveformData); 74 | ViStatus QueryArbWaveformCatalog(ViSession vi, ViInt32 CatalogType, ViInt32 CatalogBufferSize, ref ViString Catalog); 75 | 76 | /*- IviACPwrImpedance Functions -*/ 77 | ViStatus ConfigureOutputImpedance(ViSession vi, ViString PhaseName, ViBoolean Enabled, ViReal64 ResistiveValue, ViReal64 InductiveValue); 78 | ViStatus QueryOutputImpedanceCapabilities(ViSession vi, ViString PhaseName, ref ViReal64 ResistiveMin, ref ViReal64 ResistiveMax, ref ViReal64 InductiveMin, ref ViReal64 InductiveMax); 79 | 80 | /*- IviACPwrDCGeneration Functions -*/ 81 | ViStatus ConfigureDC(ViSession vi, ViString PhaseName, ViInt32 Mode, ViReal64 DCVoltageLevel); 82 | ViStatus ConfigureDCRange(ViSession vi, ViString PhaseName, ViReal64 Minimum, ViReal64 Maximum); 83 | ViStatus QueryDCCapabilities(ViSession vi, ViString PhaseName, ViInt32 Range, ref ViReal64 Minimum, ref ViReal64 Maximum); 84 | 85 | /*- IviACPwrVoltageRamp Functions -*/ 86 | ViStatus RampVoltage(ViSession vi, ViString PhaseName, ViReal64 StartVoltage, ViReal64 EndVoltage, ViReal64 Duration); 87 | ViStatus QueryVoltageRampBusy(ViSession vi, ViString PhaseName, ref ViBoolean Busy); 88 | ViStatus AbortVoltageRamp(ViSession vi, ViString PhaseName); 89 | 90 | /*- IviACPwrCurrentRamp Functions -*/ 91 | ViStatus RampCurrent(ViSession vi, ViString PhaseName, ViReal64 StartCurrent, ViReal64 EndCurrent, ViReal64 Duration); 92 | ViStatus QueryCurrentRampBusy(ViSession vi, ViString PhaseName, ref ViBoolean Busy); 93 | ViStatus AbortCurrentRamp(ViSession vi, ViString PhaseName); 94 | 95 | /*- IviACPwrFrequencyRamp Functions -*/ 96 | ViStatus RampFrequency(ViSession vi, ViReal64 StartFrequency, ViReal64 EndFrequency, ViReal64 Duration); 97 | ViStatus QueryFrequencyRampBusy(ViSession vi, ref ViBoolean Busy); 98 | ViStatus AbortFrequencyRamp(ViSession vi); 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /IVI.C.NET.Adapter/IviCInterop/IviCounter.cs: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------------------- 2 | // 3 | // Copyright Tom Lu 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //-------------------------------------------------------------------------------------------------- 18 | 19 | using System; 20 | using System.Text; 21 | 22 | // Ivi type mapping 23 | using ViStatus = System.Int32; 24 | using ViSession = System.IntPtr; 25 | using ViString = System.String; 26 | using ViBoolean = System.Boolean; 27 | using ViInt8 = System.Byte; 28 | using ViInt16 = System.Int16; 29 | using ViInt32 = System.Int32; 30 | using ViAttr = System.UInt32; 31 | using ViInt64 = System.Int64; 32 | using ViReal64 = System.Double; 33 | 34 | namespace IVI.C.NET.Adapter.IviCInterop 35 | { 36 | public interface IviCounter : IviDriver 37 | { 38 | /*- IviCounterBase Functions -*/ 39 | ViStatus GetChannelName(ViSession vi, ViInt32 ChannelIndex, ViInt32 ChannelNameBufferSize, StringBuilder ChannelName); 40 | ViStatus ConfigureChannel(ViSession vi, ViString Channel, ViReal64 Impedance, ViInt32 Coupling, ViReal64 Attenuation); 41 | ViStatus ConfigureChannelLevel(ViSession vi, ViString Channel, ViReal64 TriggerLevel, ViReal64 Hysteresis); 42 | ViStatus ConfigureChannelSlope(ViSession vi, ViString Channel, ViInt32 Slope); 43 | ViStatus ConfigureChannelFilterEnabled(ViSession vi, ViString Channel, ViBoolean FilterEnabled); 44 | ViStatus ConfigureFrequency(ViSession vi, ViString Channel); 45 | ViStatus ConfigureFrequencyManual(ViSession vi, ViString Channel, ViReal64 Estimate, ViReal64 Resolution); 46 | ViStatus ConfigureFrequencyWithApertureTime(ViSession vi, ViString Channel, ViReal64 ApertureTime); 47 | ViStatus ConfigurePeriod(ViSession vi, ViString Channel, ViReal64 Estimate, ViReal64 Resolution); 48 | ViStatus ConfigurePeriodWithApertureTime(ViSession vi, ViString Channel, ViReal64 ApertureTime); 49 | ViStatus ConfigurePulseWidth(ViSession vi, ViString Channel, ViReal64 Estimate, ViReal64 Resolution); 50 | ViStatus ConfigureDutyCycle(ViSession vi, ViString Channel, ViReal64 FrequencyEstimate, ViReal64 Resolution); 51 | ViStatus ConfigureEdgeTime(ViSession vi, ViString Channel, ViReal64 Estimate, ViReal64 Resolution); 52 | ViStatus ConfigureEdgeTimeReferenceLevels(ViSession vi, ViString Channel, ViInt32 ReferenceType, ViReal64 Estimate, ViReal64 Resolution, ViReal64 HighReference, ViReal64 LowReference); 53 | ViStatus ConfigureFrequencyRatio(ViSession vi, ViString NumeratorChannel, ViString DenominatorChannel, ViReal64 NumeratorFrequencyEstimate, ViReal64 Estimate, ViReal64 Resolution); 54 | ViStatus ConfigureTimeInterval(ViSession vi, ViString StartChannel, ViString StopChannel, ViReal64 Estimate, ViReal64 Resolution); 55 | ViStatus ConfigurePhase(ViSession vi, ViString MeasurementChannel, ViString ReferenceChannel, ViReal64 FrequencyEstimate, ViReal64 Resolution); 56 | ViStatus ConfigureContinuousTotalize(ViSession vi, ViString Channel); 57 | ViStatus ConfigureGatedTotalize(ViSession vi, ViString Channel, ViString GateSource, ViInt32 GateSlope); 58 | ViStatus ConfigureTimedTotalize(ViSession vi, ViString Channel, ViReal64 GateTime); 59 | ViStatus ConfigureStartArm(ViSession vi, ViInt32 Type); 60 | ViStatus ConfigureExternalStartArm(ViSession vi, ViString Source, ViReal64 Level, ViInt32 Slope, ViReal64 Delay); 61 | ViStatus ConfigureStopArm(ViSession vi, ViInt32 Type); 62 | ViStatus ConfigureExternalStopArm(ViSession vi, ViString Source, ViReal64 Level, ViInt32 Slope, ViReal64 Delay); 63 | ViStatus ConfigureFilter(ViSession vi, ViString Channel, ViReal64 MinimumFrequency, ViReal64 MaximumFrequency); 64 | ViStatus ConfigureTimeIntervalStopHoldoff(ViSession vi, ViReal64 Time); 65 | ViStatus ConfigureVoltage(ViSession vi, ViString Channel, ViInt32 Function, ViReal64 Estimate, ViReal64 Resolution); 66 | ViStatus StartContinuousTotalize(ViSession vi); 67 | ViStatus StopContinuousTotalize(ViSession vi); 68 | ViStatus FetchContinuousTotalizeCount(ViSession vi, ref ViInt32 Measurement); 69 | ViStatus Read(ViSession vi, ViInt32 MaximumTime, ref ViReal64 Measurement); 70 | ViStatus Initiate(ViSession vi); 71 | ViStatus Abort(ViSession vi); 72 | ViStatus Fetch(ViSession vi, ref ViReal64 Measurement); 73 | ViStatus IsMeasurementComplete(ViSession vi, ref ViInt32 MeasurementStatus); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /IVI.C.NET.Adapter/IviCInterop/IviDCPwr.cs: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------------------- 2 | // 3 | // Copyright Tom Lu 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //-------------------------------------------------------------------------------------------------- 18 | 19 | using System; 20 | using System.Text; 21 | 22 | // Ivi type mapping 23 | using ViStatus = System.Int32; 24 | using ViSession = System.IntPtr; 25 | using ViString = System.String; 26 | using ViBoolean = System.Boolean; 27 | using ViInt8 = System.Byte; 28 | using ViInt16 = System.Int16; 29 | using ViInt32 = System.Int32; 30 | using ViAttr = System.UInt32; 31 | using ViInt64 = System.Int64; 32 | using ViReal64 = System.Double; 33 | 34 | 35 | namespace IVI.C.NET.Adapter.IviCInterop 36 | { 37 | public interface IviDCPwr : IviDriver 38 | { 39 | /*- IviDCPwrBase Functions -*/ 40 | ViStatus ConfigureOutputEnabled(ViSession vi, ViString channelName, ViBoolean enabled); 41 | ViStatus ConfigureOutputRange(ViSession vi, ViString channelName, ViInt32 rangeType, ViReal64 range); 42 | ViStatus ConfigureCurrentLimit(ViSession vi, ViString channelName, ViInt32 behavior, ViReal64 limit); 43 | ViStatus ConfigureOVP(ViSession vi, ViString channelName, ViBoolean enabled, ViReal64 limit); 44 | ViStatus ConfigureVoltageLevel(ViSession vi, ViString channelName, ViReal64 level); 45 | ViStatus GetChannelName(ViSession vi, ViInt32 index, ViInt32 bufferSize, StringBuilder name); 46 | ViStatus QueryOutputState(ViSession vi, ViString channelName, ViInt32 outputState, ref ViBoolean inState); 47 | ViStatus QueryMaxCurrentLimit(ViSession vi, ViString channelName, ViReal64 voltageLevel, ref ViReal64 maxCurrentLimit); 48 | ViStatus QueryMaxVoltageLevel(ViSession vi, ViString channelName, ViReal64 currentLimit, ref ViReal64 maxVoltageLevel); 49 | ViStatus ResetOutputProtection(ViSession vi, ViString channelName); 50 | 51 | /*- IviDcPwrTrigger Functions -*/ 52 | ViStatus ConfigureTriggerSource(ViSession vi, ViString channelName, ViInt32 source); 53 | ViStatus ConfigureTriggeredVoltageLevel(ViSession vi, ViString channelName, ViReal64 level); 54 | ViStatus ConfigureTriggeredCurrentLimit(ViSession vi, ViString channelName, ViReal64 limit); 55 | 56 | ViStatus Abort(ViSession vi); 57 | ViStatus Initiate(ViSession vi); 58 | 59 | /*- IviDCPwrSoftwareTrigger Functions -*/ 60 | ViStatus SendSoftwareTrigger(ViSession vi); 61 | 62 | /*- IviDCPwrMeasure Functions -*/ 63 | ViStatus Measure(ViSession vi, ViString channelName, ViInt32 measurementType, ref ViReal64 measurement); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /IVI.C.NET.Adapter/IviCInterop/IviDCPwrAttribute.cs: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------------------- 2 | // 3 | // Copyright Tom Lu 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //-------------------------------------------------------------------------------------------------- 18 | 19 | using System; 20 | using System.Collections.Generic; 21 | using System.Text; 22 | 23 | namespace IVI.C.NET.Adapter.IviCInterop 24 | { 25 | public class IviDCPwrAttribute 26 | { 27 | 28 | /*- Defined values for rangeType parameter of function -*/ 29 | /*- IviDCPwr_ConfigureOutputRange -*/ 30 | public const int IVIDCPWR_VAL_RANGE_CURRENT = (0); 31 | public const int IVIDCPWR_VAL_RANGE_VOLTAGE = (1); 32 | 33 | public const int IVIDCPWR_VAL_RANGE_TYPE_CLASS_EXT_BASE = (500); 34 | public const int IVIDCPWR_VAL_RANGE_TYPE_SPECIFIC_EXT_BASE = (1000); 35 | 36 | /*- Defined values for outputState parameter of function -*/ 37 | /*- IviDCPwr_QueryOutputState -*/ 38 | public const int IVIDCPWR_VAL_OUTPUT_CONSTANT_VOLTAGE = (0); 39 | public const int IVIDCPWR_VAL_OUTPUT_CONSTANT_CURRENT = (1); 40 | public const int IVIDCPWR_VAL_OUTPUT_OVER_VOLTAGE = (2); 41 | public const int IVIDCPWR_VAL_OUTPUT_OVER_CURRENT = (3); 42 | public const int IVIDCPWR_VAL_OUTPUT_UNREGULATED = (4); 43 | 44 | public const int IVIDCPWR_VAL_OUTPUT_STATE_CLASS_EXT_BASE = (500); 45 | public const int IVIDCPWR_VAL_OUTPUT_STATE_SPECIFIC_EXT_BASE = (1000); 46 | 47 | /*- Defined values for measurementType parameter of function -*/ 48 | /*- IviDCPwr_Measure -*/ 49 | public const int IVIDCPWR_VAL_MEASURE_CURRENT = (0); 50 | public const int IVIDCPWR_VAL_MEASURE_VOLTAGE = (1); 51 | 52 | public const int IVIDCPWR_VAL_MEASURE_CLASS_EXT_BASE = (500); 53 | public const int IVIDCPWR_VAL_MEASURE_SPECIFIC_EXT_BASE = (1000); 54 | 55 | /*- IviDCPwr Fundamental Attributes -*/ 56 | public const int IVIDCPWR_ATTR_CHANNEL_COUNT = IviDriverAttribute.IVI_ATTR_CHANNEL_COUNT; /* ViInt32, read-only */ 57 | public const int IVIDCPWR_ATTR_VOLTAGE_LEVEL = (IviDriverAttribute.IVI_CLASS_PUBLIC_ATTR_BASE + 1); /* ViReal64, multi-channel */ 58 | public const int IVIDCPWR_ATTR_OVP_ENABLED = (IviDriverAttribute.IVI_CLASS_PUBLIC_ATTR_BASE + 2); /* ViBoolean, multi-channel */ 59 | public const int IVIDCPWR_ATTR_OVP_LIMIT = (IviDriverAttribute.IVI_CLASS_PUBLIC_ATTR_BASE + 3); /* ViReal64, multi-channel */ 60 | public const int IVIDCPWR_ATTR_CURRENT_LIMIT_BEHAVIOR = (IviDriverAttribute.IVI_CLASS_PUBLIC_ATTR_BASE + 4); /* ViInt32, multi-channel */ 61 | public const int IVIDCPWR_ATTR_CURRENT_LIMIT = (IviDriverAttribute.IVI_CLASS_PUBLIC_ATTR_BASE + 5); /* ViReal64, multi-channel */ 62 | public const int IVIDCPWR_ATTR_OUTPUT_ENABLED = (IviDriverAttribute.IVI_CLASS_PUBLIC_ATTR_BASE + 6); /* ViBoolean, multi-channel */ 63 | 64 | /*- IviDCPwr Extended Attributes -*/ 65 | /*- Trigger Attributes -*/ 66 | public const int IVIDCPWR_ATTR_TRIGGER_SOURCE = (IviDriverAttribute.IVI_CLASS_PUBLIC_ATTR_BASE + 101); /* ViInt32, multi-channel */ 67 | public const int IVIDCPWR_ATTR_TRIGGERED_CURRENT_LIMIT = (IviDriverAttribute.IVI_CLASS_PUBLIC_ATTR_BASE + 102); /* ViReal64, multi-channel */ 68 | public const int IVIDCPWR_ATTR_TRIGGERED_VOLTAGE_LEVEL = (IviDriverAttribute.IVI_CLASS_PUBLIC_ATTR_BASE + 103); /* ViReal64, multi-channel */ 69 | 70 | /**************************************************************************** 71 | *----------------- IviDCPwr Class Attribute Value Defines -----------------* 72 | ****************************************************************************/ 73 | 74 | /*- Defined values for attribute IVIDCPWR_ATTR_CURRENT_LIMIT_BEHAVIOR -*/ 75 | public const int IVIDCPWR_VAL_CURRENT_REGULATE = (0); 76 | public const int IVIDCPWR_VAL_CURRENT_TRIP = (1); 77 | 78 | public const int IVIDCPWR_VAL_CURRENT_LIMIT_BEHAVIOR_CLASS_EXT_BASE = (500); 79 | public const int IVIDCPWR_VAL_CURRENT_LIMIT_BEHAVIOR_SPECIFIC_EXT_BASE = (1000); 80 | 81 | /*- Defined values for attribute IVIDCPWR_ATTR_TRIGGER_SOURCE -*/ 82 | public const int IVIDCPWR_VAL_TRIG_IMMEDIATE = (0); 83 | public const int IVIDCPWR_VAL_TRIG_EXTERNAL = (1); 84 | public const int IVIDCPWR_VAL_SOFTWARE_TRIG = (2); 85 | public const int IVIDCPWR_VAL_TRIG_TTL0 = (3); 86 | public const int IVIDCPWR_VAL_TRIG_TTL1 = (4); 87 | public const int IVIDCPWR_VAL_TRIG_TTL2 = (5); 88 | public const int IVIDCPWR_VAL_TRIG_TTL3 = (6); 89 | public const int IVIDCPWR_VAL_TRIG_TTL4 = (7); 90 | public const int IVIDCPWR_VAL_TRIG_TTL5 = (8); 91 | public const int IVIDCPWR_VAL_TRIG_TTL6 = (9); 92 | public const int IVIDCPWR_VAL_TRIG_TTL7 = (10); 93 | public const int IVIDCPWR_VAL_TRIG_ECL0 = (11); 94 | public const int IVIDCPWR_VAL_TRIG_ECL1 = (12); 95 | public const int IVIDCPWR_VAL_TRIG_PXI_STAR = (13); 96 | public const int IVIDCPWR_VAL_TRIG_RTSI_0 = (14); 97 | public const int IVIDCPWR_VAL_TRIG_RTSI_1 = (15); 98 | public const int IVIDCPWR_VAL_TRIG_RTSI_2 = (16); 99 | public const int IVIDCPWR_VAL_TRIG_RTSI_3 = (17); 100 | public const int IVIDCPWR_VAL_TRIG_RTSI_4 = (18); 101 | public const int IVIDCPWR_VAL_TRIG_RTSI_5 = (19); 102 | public const int IVIDCPWR_VAL_TRIG_RTSI_6 = (20); 103 | 104 | public const int IVIDCPWR_VAL_TRIG_SRC_CLASS_EXT_BASE = (500); 105 | public const int IVIDCPWR_VAL_TRIG_SRC_SPECIFIC_EXT_BASE = (1000); 106 | 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /IVI.C.NET.Adapter/IviCInterop/IviDmm.cs: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------------------- 2 | // 3 | // Copyright Tom Lu 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //-------------------------------------------------------------------------------------------------- 18 | 19 | using System; 20 | 21 | // Ivi type mapping 22 | using ViStatus = System.Int32; 23 | using ViSession = System.IntPtr; 24 | using ViString = System.String; 25 | using ViBoolean = System.Boolean; 26 | using ViInt8 = System.Byte; 27 | using ViInt16 = System.Int16; 28 | using ViInt32 = System.Int32; 29 | using ViAttr = System.UInt32; 30 | using ViInt64 = System.Int64; 31 | using ViReal64 = System.Double; 32 | 33 | namespace IVI.C.NET.Adapter.IviCInterop 34 | { 35 | public interface IviDmm : IviDriver 36 | { 37 | /*- IviDmmBase Functions -*/ 38 | ViStatus ConfigureMeasurement(ViSession vi, ViInt32 function, ViReal64 range, ViReal64 resolution); 39 | ViStatus ConfigureTrigger(ViSession vi, ViInt32 triggerSource, ViReal64 triggerDelay); 40 | 41 | ViStatus Read(ViSession vi, ViInt32 MaxTimeMilliseconds, ref ViReal64 reading); 42 | ViStatus Fetch(ViSession vi, ViInt32 MaxTimeMilliseconds, ref ViReal64 reading); 43 | ViStatus Abort(ViSession vi); 44 | ViStatus Initiate(ViSession vi); 45 | 46 | ViStatus IsOverRange(ViSession vi, ViReal64 measurementValue, ref ViBoolean isOverRange); 47 | 48 | /*- IviDmmAcMeasurement Functions -*/ 49 | ViStatus ConfigureACBandwidth(ViSession vi, ViReal64 minFreq, ViReal64 maxFreq); 50 | 51 | /*- IviDmmFrequencyMeasurement Functions -*/ 52 | ViStatus ConfigureFrequencyVoltageRange(ViSession vi, ViReal64 frequencyVoltageRange); 53 | 54 | /*- IviDmmTemperatureMeasurement Functions -*/ 55 | ViStatus ConfigureTransducerType(ViSession vi, ViInt32 transducerType); 56 | 57 | /*- IviDmmThermocouple Functions -*/ 58 | ViStatus ConfigureFixedRefJunction(ViSession vi, ViReal64 fixedRefJunction); 59 | ViStatus ConfigureThermocouple(ViSession vi, ViInt32 thermocoupleType, ViInt32 refJunctionType); 60 | 61 | /*- IviDmmRTD Functions -*/ 62 | ViStatus ConfigureRTD(ViSession vi, ViReal64 alpha, ViReal64 resistance); 63 | 64 | /*- IviDmmThermistor Functions -*/ 65 | ViStatus ConfigureThermistor(ViSession vi, ViReal64 resistance); 66 | 67 | /*- IviDmmMultiPoint Functions -*/ 68 | ViStatus ConfigureMeasCompleteDest(ViSession vi, ViInt32 measCompleteDest); 69 | ViStatus ConfigureMultiPoint(ViSession vi, ViInt32 triggerCount, ViInt32 sampleCount, ViInt32 sampleTrigger, ViReal64 sampleInterval); 70 | ViStatus ReadMultiPoint(ViSession vi, ViInt32 maxTime, ViInt32 arraySize, IntPtr readingArray, ref ViInt32 actualPts); 71 | ViStatus FetchMultiPoint(ViSession vi, ViInt32 maxTime, ViInt32 arraySize, IntPtr readingArray, ref ViInt32 actualPts); 72 | 73 | /*- IviDmmTriggerSlope Functions -*/ 74 | ViStatus ConfigureTriggerSlope(ViSession vi, ViInt32 polarity); 75 | /*- IviDmmSoftwareTrigger Functions -*/ 76 | ViStatus SendSoftwareTrigger(ViSession vi); 77 | /*- IviDmmDeviceInfo Functions -*/ 78 | ViStatus GetApertureTimeInfo(ViSession vi, ref ViReal64 apertureTime, ref ViInt32 apertureTimeUnits); 79 | /*- IviDmmAutoRangeValue Functions -*/ 80 | ViStatus GetAutoRangeValue(ViSession vi, ref ViReal64 autoRangeValue); 81 | /*- IviDmmAutoZero Functions -*/ 82 | ViStatus ConfigureAutoZeroMode(ViSession vi, ViInt32 autoZeroMode); 83 | /*- IviDmmPowerLineFrequency Functions -*/ 84 | ViStatus ConfigurePowerLineFrequency(ViSession vi, ViReal64 powerLineFreq); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /IVI.C.NET.Adapter/IviCInterop/IviDownconverter.cs: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------------------- 2 | // 3 | // Copyright Tom Lu 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //-------------------------------------------------------------------------------------------------- 18 | 19 | using System; 20 | using System.Text; 21 | 22 | // Ivi type mapping 23 | using ViStatus = System.Int32; 24 | using ViSession = System.IntPtr; 25 | using ViString = System.String; 26 | using ViBoolean = System.Boolean; 27 | using ViInt8 = System.Byte; 28 | using ViInt16 = System.Int16; 29 | using ViInt32 = System.Int32; 30 | using ViAttr = System.UInt32; 31 | using ViInt64 = System.Int64; 32 | using ViReal64 = System.Double; 33 | 34 | namespace IVI.C.NET.Adapter.IviCInterop 35 | { 36 | public interface IviDownconverter : IviDriver 37 | { 38 | /*- IviDownconverterBase Functions -*/ 39 | ViStatus ConfigureIFOutputEnabled(ViSession vi, 40 | ViBoolean enabled); 41 | 42 | ViStatus ConfigureIFOutputGain(ViSession vi, 43 | ViReal64 gain); 44 | 45 | ViStatus GetIFOutputName(ViSession vi, 46 | ViInt32 index, 47 | ViInt32 nameBufferSize, 48 | StringBuilder name); 49 | 50 | ViStatus SetActiveIFOutput(ViSession vi, 51 | ViString name); 52 | 53 | ViStatus ConfigureRFInputAttenuation(ViSession vi, 54 | ViReal64 attenuation); 55 | 56 | ViStatus ConfigureRFInputFrequency(ViSession vi, 57 | ViReal64 frequency); 58 | 59 | ViStatus GetRFInputName(ViSession vi, 60 | ViInt32 index, 61 | ViInt32 nameBufferSize, 62 | StringBuilder name); 63 | 64 | ViStatus SetActiveRFInput(ViSession vi, 65 | ViString name); 66 | 67 | ViStatus WaitUntilSettled(ViSession vi, 68 | ViInt32 maxTimeMilliseconds); 69 | 70 | /*- IviDownconverterBypass Functions -*/ 71 | ViStatus ConfigureBypass(ViSession vi, 72 | ViBoolean bypass); 73 | 74 | /*- IviDownconverterExternalMixer Functions -*/ 75 | ViStatus ConfigureExternalMixerBias(ViSession vi, 76 | ViReal64 bias, 77 | ViReal64 biasLimit); 78 | 79 | /*- IviDownconverterFrequencyStep Functions -*/ 80 | ViStatus ConfigureFrequencyStepDwell(ViSession vi, 81 | ViBoolean singleStepEnabled, 82 | ViReal64 dwell); 83 | 84 | ViStatus ConfigureFrequencyStepStartStop(ViSession vi, 85 | ViReal64 start, 86 | ViReal64 stop, 87 | ViInt32 scaling, 88 | ViReal64 stepSize); 89 | 90 | ViStatus ResetFrequencyStep(ViSession vi); 91 | 92 | /*- IviDownconverterFrequencySweep Functions -*/ 93 | ViStatus ConfigureFrequencySweep(ViSession vi, 94 | ViInt32 mode, 95 | ViString triggerSource); 96 | 97 | ViStatus ConfigureFrequencySweepStartStop(ViSession vi, 98 | ViReal64 start, 99 | ViReal64 stop); 100 | 101 | ViStatus ConfigureFrequencySweepTime(ViSession vi, 102 | ViReal64 sweepTime); 103 | 104 | ViStatus WaitUntilFrequencySweepComplete(ViSession vi, 105 | ViInt32 maxTimeMilliseconds); 106 | 107 | /*- IviDownconverterFrequencySweepList Functions -*/ 108 | ViStatus ClearAllFrequencySweepLists(ViSession vi); 109 | 110 | ViStatus ConfigureFrequencySweepListDwell(ViSession vi, 111 | ViBoolean singleStepEnabled, 112 | ViReal64 dwell); 113 | 114 | ViStatus CreateFrequencySweepList(ViSession vi, 115 | ViString name, 116 | ViInt32 frequencyListBufferSize, 117 | ViReal64[] frequencyList); 118 | 119 | ViStatus ResetFrequencySweepList(ViSession vi); 120 | 121 | /*- IviDownconverterBandCrossingInformation Functions -*/ 122 | ViStatus GetBandCrossingInfo(ViSession vi, 123 | ViInt32 bufferSize, 124 | IntPtr startFrequencies, 125 | IntPtr stopFrequencies, 126 | ref ViInt32 actualNumFrequencies); 127 | 128 | /*- IviDownconverterSoftwareTrigger Functions -*/ 129 | ViStatus SendSoftwareTrigger(ViSession vi); 130 | 131 | /*- IviDownconverterIFFilter Functions -*/ 132 | ViStatus ConfigureIFOutputFilterBandwidth(ViSession vi, 133 | ViReal64 bandwidth); 134 | 135 | /*- IviDownconverterPreselector Functions -*/ 136 | ViStatus ConfigurePreselectorEnabled(ViSession vi, 137 | ViBoolean enabled); 138 | 139 | /*- IviDownconverterVideoDetectorBandwidth Functions -*/ 140 | ViStatus ConfigureIFOutputVideoDetectorBandwidth(ViSession vi, 141 | ViReal64 bandwidth); 142 | 143 | /*- IviDownconverterCalibration Functions -*/ 144 | ViStatus Calibrate(ViSession vi); 145 | 146 | ViStatus IsCalibrationComplete(ViSession vi, 147 | ref ViInt32 status); 148 | 149 | ViStatus IsCalibrated(ViSession vi, 150 | ref ViInt32 status); 151 | 152 | /*- IviDownconverterReferenceOscillator Functions -*/ 153 | ViStatus ConfigureReferenceOscillator(ViSession vi, 154 | ViInt32 source, 155 | ViReal64 frequency); 156 | 157 | ViStatus ConfigureReferenceOscillatorOutputEnabled(ViSession vi, 158 | ViBoolean enabled); 159 | } 160 | } 161 | 162 | -------------------------------------------------------------------------------- /IVI.C.NET.Adapter/IviCInterop/IviDriver.cs: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------------------- 2 | // 3 | // Copyright Tom Lu 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //-------------------------------------------------------------------------------------------------- 18 | 19 | using System; 20 | using System.Text; 21 | 22 | // Ivi type mapping 23 | using ViStatus = System.Int32; 24 | using ViSession = System.IntPtr; 25 | using ViString = System.String; 26 | using ViBoolean = System.Boolean; 27 | using ViInt8 = System.Byte; 28 | using ViInt16 = System.Int16; 29 | using ViInt32 = System.Int32; 30 | using ViAttr = System.UInt32; 31 | using ViInt64 = System.Int64; 32 | using ViReal64 = System.Double; 33 | 34 | namespace IVI.C.NET.Adapter.IviCInterop 35 | { 36 | public interface IviDriver 37 | { 38 | ViStatus init(ViString logicalName, ViBoolean idQuery, ViBoolean resetDevice, ref ViSession vi); 39 | ViStatus close(ViSession vi); 40 | ViStatus reset(ViSession vi); 41 | 42 | ViStatus self_test(ViSession vi, ref ViInt16 selfTestResult, StringBuilder selfTestMessage); 43 | ViStatus error_query(ViSession vi, ref ViInt32 errorCode, StringBuilder errorMessage); 44 | ViStatus error_message(ViSession vi, ViStatus statusCode, StringBuilder message); 45 | ViStatus revision_query(ViSession vi, StringBuilder driverRev, StringBuilder instrRev); 46 | 47 | /*- Utility Functions -*/ 48 | ViStatus InvalidateAllAttributes(ViSession vi); 49 | ViStatus ResetWithDefaults(ViSession vi); 50 | ViStatus Disable(ViSession vi); 51 | 52 | /*- Required IVI Functions -*/ 53 | ViStatus InitWithOptions(ViString logicalName, ViBoolean IDQuery, ViBoolean resetDevice, ViString optionString, ref ViSession vi); 54 | 55 | /*- Set, Get, and Check Attribute Functions -*/ 56 | ViStatus GetAttributeViInt32(ViSession vi, ViString channelName, ViAttr attributeId, ref ViInt32 value); 57 | ViStatus SetAttributeViInt32(ViSession vi, ViString channelName, ViAttr attributeId, ViInt32 value); 58 | ViStatus CheckAttributeViInt32(ViSession vi, ViString channelName, ViAttr attributeId, ViInt32 value); 59 | 60 | ViStatus GetAttributeViInt64(ViSession vi, ViString channelName, ViAttr attributeId, ref ViInt64 value); 61 | ViStatus SetAttributeViInt64(ViSession vi, ViString channelName, ViAttr attributeId, ViInt64 value); 62 | ViStatus CheckAttributeViInt64(ViSession vi, ViString channelName, ViAttr attributeId, ViInt64 value); 63 | 64 | ViStatus GetAttributeViReal64(ViSession vi, ViString channelName, ViAttr attributeId, ref ViReal64 value); 65 | ViStatus SetAttributeViReal64(ViSession vi, ViString channelName, ViAttr attributeId, ViReal64 value); 66 | ViStatus CheckAttributeViReal64(ViSession vi, ViString channelName, ViAttr attributeId, ViReal64 value); 67 | 68 | ViStatus GetAttributeViString(ViSession vi, ViString channelName, ViAttr attributeId, ViInt32 bufferSize, StringBuilder value); 69 | // ViStatus GetAttributeViString(ViSession vi, ViString channelName, ViAttr attributeId, ViInt32 bufferSize, ref ViString value); 70 | ViStatus SetAttributeViString(ViSession vi, ViString channelName, ViAttr attributeId, ViString value); 71 | ViStatus CheckAttributeViString(ViSession vi, ViString channelName, ViAttr attributeId, ViString value); 72 | 73 | ViStatus GetAttributeViBoolean(ViSession vi, ViString channelName, ViAttr attributeId, ref ViBoolean value); 74 | ViStatus SetAttributeViBoolean(ViSession vi, ViString channelName, ViAttr attributeId, ViBoolean value); 75 | ViStatus CheckAttributeViBoolean(ViSession vi, ViString channelName, ViAttr attributeId, ViBoolean value); 76 | 77 | ViStatus GetAttributeViSession(ViSession vi, ViString channelName, ViAttr attributeId, ref ViSession value); 78 | ViStatus SetAttributeViSession(ViSession vi, ViString channelName, ViAttr attributeId, ViSession value); 79 | ViStatus CheckAttributeViSession(ViSession vi, ViString channelName, ViAttr attributeId, ViSession value); 80 | 81 | /*- Lock and Unlock Functions -*/ 82 | ViStatus LockSession(ViSession vi, ref ViBoolean callerHasLock); 83 | ViStatus UnlockSession(ViSession vi, ref ViBoolean callerHasLock); 84 | /*- Error Information Functions -*/ 85 | ViStatus GetError(ViSession vi, ref ViStatus errorCode, ViInt32 bufferSize, ref ViString description); 86 | ViStatus ClearError(ViSession vi); 87 | 88 | /*- Interchangeability Checking Functions -*/ 89 | ViStatus GetNextInterchangeWarning(ViSession vi, ViInt32 bufferSize, ref ViString warning); 90 | ViStatus ClearInterchangeWarnings(ViSession vi); 91 | ViStatus ResetInterchangeCheck(ViSession vi); 92 | ViStatus GetNextCoercionRecord(ViSession vi, ViInt32 bufferSize, ref ViInt8[] record); 93 | ViStatus GetSpecificDriverCHandle(ViSession vi, ref ViSession specificDriverCHandle); 94 | ViStatus GetSpecificDriverIUnknownPtr(ViSession vi, ref object specificDriverIUnknownPtr); 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /IVI.C.NET.Adapter/IviCInterop/IviPwrMeter.cs: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------------------- 2 | // 3 | // Copyright Tom Lu 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //-------------------------------------------------------------------------------------------------- 18 | 19 | using System; 20 | using System.Text; 21 | 22 | // Ivi type mapping 23 | using ViStatus = System.Int32; 24 | using ViSession = System.IntPtr; 25 | using ViString = System.String; 26 | using ViBoolean = System.Boolean; 27 | using ViInt8 = System.Byte; 28 | using ViInt16 = System.Int16; 29 | using ViInt32 = System.Int32; 30 | using ViAttr = System.UInt32; 31 | using ViInt64 = System.Int64; 32 | using ViReal64 = System.Double; 33 | 34 | namespace IVI.C.NET.Adapter.IviCInterop 35 | { 36 | public interface IviPwrMeter : IviDriver 37 | { 38 | /*- IviPwrMeter Fundamental Capabilities -*/ 39 | ViStatus Abort(ViSession vi); 40 | 41 | ViStatus ConfigureAveragingAutoEnabled(ViSession vi, 42 | ViString Channel, 43 | ViBoolean AveragingAutoEnabled); 44 | 45 | ViStatus ConfigureCorrectionFrequency(ViSession vi, 46 | ViString Channel, 47 | ViReal64 CorrectionFrequency); 48 | 49 | ViStatus ConfigureMeasurement(ViSession vi, 50 | ViInt32 Operator, 51 | ViString Operand1, 52 | ViString Operand2); 53 | 54 | ViStatus ConfigureOffset(ViSession vi, 55 | ViString Channel, 56 | ViReal64 Offset); 57 | 58 | ViStatus ConfigureRangeAutoEnabled(ViSession vi, 59 | ViString Channel, 60 | ViBoolean RangeAutoEnabled); 61 | 62 | ViStatus ConfigureUnits(ViSession vi, 63 | ViInt32 Units); 64 | 65 | ViStatus Fetch(ViSession vi, 66 | ref ViReal64 Result); 67 | 68 | ViStatus GetChannelName(ViSession vi, 69 | ViInt32 ChannelIndex, 70 | ViInt32 ChannelNameBufferSize, 71 | StringBuilder ChannelName); 72 | 73 | ViStatus Initiate(ViSession vi); 74 | 75 | ViStatus IsMeasurementComplete(ViSession vi, 76 | ref ViInt32 MeasurementStatus); 77 | 78 | ViStatus QueryResultRangeType(ViSession vi, 79 | ViReal64 MeasurementValue, 80 | ref ViInt32 RangeType); 81 | 82 | ViStatus Read(ViSession vi, 83 | ViInt32 MaxTime, 84 | ref ViReal64 Result); 85 | 86 | 87 | /*- IviPwrMeterChannelAcquisition Extension Group -*/ 88 | ViStatus ConfigureChannelEnabled(ViSession vi, 89 | ViString Channel, 90 | ViBoolean ChannelEnabled); 91 | 92 | ViStatus FetchChannel(ViSession vi, 93 | ViString Channel, 94 | ref ViReal64 Result); 95 | 96 | ViStatus ReadChannel(ViSession vi, 97 | ViString Channel, 98 | ViInt32 MaxTime, 99 | ref ViReal64 Result); 100 | 101 | 102 | /*- IviPwrMeterManualRange Extension Group -*/ 103 | ViStatus ConfigureRange(ViSession vi, 104 | ViString Channel, 105 | ViReal64 RangeLower, 106 | ViReal64 RangeUpper); 107 | 108 | 109 | /*- IviPwrMeterTriggerSource Extension Group -*/ 110 | ViStatus ConfigureTriggerSource(ViSession vi, 111 | ViInt32 TriggerSource); 112 | 113 | 114 | /*- IviPwrMeterInternalTrigger Extension Group -*/ 115 | ViStatus ConfigureInternalTrigger(ViSession vi, 116 | ViString EventSource, 117 | ViInt32 Slope); 118 | 119 | ViStatus ConfigureInternalTriggerLevel(ViSession vi, 120 | ViReal64 TriggerLevel); 121 | 122 | 123 | /*- IviPwrMeterSoftwareTrigger Extension Group -*/ 124 | ViStatus SendSoftwareTrigger(ViSession vi); 125 | 126 | 127 | /*- IviPwrMeterAveragingCount Extension Group -*/ 128 | ViStatus ConfigureAveragingCount(ViSession vi, 129 | ViString Channel, 130 | ViInt32 Count); 131 | 132 | 133 | /*- IviPwrMeterZeroCorrection Extension Group -*/ 134 | ViStatus IsZeroComplete(ViSession vi, 135 | ref ViInt32 ZeroStatus); 136 | 137 | ViStatus Zero(ViSession vi, 138 | ViString Channel); 139 | 140 | ViStatus ZeroAllChannels(ViSession vi); 141 | 142 | 143 | /*- IviPwrMeterDutyCycleCorrection Extension Group -*/ 144 | ViStatus ConfigureDutyCycleCorrection(ViSession vi, 145 | ViString Channel, 146 | ViBoolean CorrectionEnabled, 147 | ViReal64 Correction); 148 | 149 | 150 | /*- IviPwrMeterCalibration Extension Group -*/ 151 | ViStatus Calibrate(ViSession vi, 152 | ViString Channel); 153 | 154 | ViStatus IsCalibrationComplete(ViSession vi, 155 | ref ViInt32 CalibrationStatus); 156 | 157 | 158 | /*- IviPwrMeterReferenceOscillator Extension Group -*/ 159 | ViStatus ConfigureRefOscillator(ViSession vi, 160 | ViReal64 Frequency, 161 | ViReal64 Level); 162 | 163 | ViStatus ConfigureRefOscillatorEnabled(ViSession vi, 164 | ViBoolean RefOscillatorEnabled); 165 | } 166 | } 167 | -------------------------------------------------------------------------------- /IVI.C.NET.Adapter/IviCInterop/IviPwrMeterAttribute.cs: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------------------- 2 | // 3 | // Copyright Tom Lu 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //-------------------------------------------------------------------------------------------------- 18 | 19 | using System; 20 | using System.Collections.Generic; 21 | using System.Text; 22 | 23 | namespace IVI.C.NET.Adapter.IviCInterop 24 | { 25 | public class IviPwrMeterAttribute 26 | { 27 | 28 | /*- IviPwrMeter Fundamental Attributes -*/ 29 | public const int IVIPWRMETER_ATTR_AVERAGING_AUTO_ENABLED = (IviDriverAttribute.IVI_CLASS_PUBLIC_ATTR_BASE + 3); /* ViBoolean */ 30 | public const int IVIPWRMETER_ATTR_CORRECTION_FREQUENCY = (IviDriverAttribute.IVI_CLASS_PUBLIC_ATTR_BASE + 4); /* ViReal64 */ 31 | public const int IVIPWRMETER_ATTR_OFFSET = (IviDriverAttribute.IVI_CLASS_PUBLIC_ATTR_BASE + 5); /* ViReal64 */ 32 | public const int IVIPWRMETER_ATTR_RANGE_AUTO_ENABLED = (IviDriverAttribute.IVI_CLASS_PUBLIC_ATTR_BASE + 2); /* ViBoolean */ 33 | public const int IVIPWRMETER_ATTR_UNITS = (IviDriverAttribute.IVI_CLASS_PUBLIC_ATTR_BASE + 1); /* ViInt32 */ 34 | 35 | /* Instrument Capabilities */ 36 | public const int IVIPWRMETER_ATTR_CHANNEL_COUNT = (IviDriverAttribute.IVI_ATTR_CHANNEL_COUNT); /* ViInt32, read-only */ 37 | 38 | /*- IviPwrMeter Extended Attributes -*/ 39 | /*- IviPwrMeterChannelAcquisition Extension Group -*/ 40 | public const int IVIPWRMETER_ATTR_CHANNEL_ENABLED = (IviDriverAttribute.IVI_CLASS_PUBLIC_ATTR_BASE + 51); /* ViBoolean */ 41 | 42 | /*- IviPwrMeterManualRange Extension Group -*/ 43 | public const int IVIPWRMETER_ATTR_RANGE_LOWER = (IviDriverAttribute.IVI_CLASS_PUBLIC_ATTR_BASE + 101); /* ViReal64 */ 44 | public const int IVIPWRMETER_ATTR_RANGE_UPPER = (IviDriverAttribute.IVI_CLASS_PUBLIC_ATTR_BASE + 102); /* ViReal64 */ 45 | 46 | /*- IviPwrMeterTriggerSource Extension Group -*/ 47 | public const int IVIPWRMETER_ATTR_TRIGGER_SOURCE = (IviDriverAttribute.IVI_CLASS_PUBLIC_ATTR_BASE + 201); /* ViInt32 */ 48 | 49 | /*- IviPwrMeterInternalTrigger Extension Group -*/ 50 | public const int IVIPWRMETER_ATTR_INTERNAL_TRIGGER_EVENT_SOURCE = (IviDriverAttribute.IVI_CLASS_PUBLIC_ATTR_BASE + 251); /* ViString */ 51 | public const int IVIPWRMETER_ATTR_INTERNAL_TRIGGER_LEVEL = (IviDriverAttribute.IVI_CLASS_PUBLIC_ATTR_BASE + 252); /* ViReal64 */ 52 | public const int IVIPWRMETER_ATTR_INTERNAL_TRIGGER_SLOPE = (IviDriverAttribute.IVI_CLASS_PUBLIC_ATTR_BASE + 253); /* ViInt32 */ 53 | 54 | /*- IviPwrMeterAveragingCount Extension Group -*/ 55 | public const int IVIPWRMETER_ATTR_AVERAGING_COUNT = (IviDriverAttribute.IVI_CLASS_PUBLIC_ATTR_BASE + 301); /* ViInt32 */ 56 | 57 | /*- IviPwrMeterDutyCycleCorrection Extension Group -*/ 58 | public const int IVIPWRMETER_ATTR_DUTY_CYCLE_CORRECTION = (IviDriverAttribute.IVI_CLASS_PUBLIC_ATTR_BASE + 402); /* ViReal64 */ 59 | public const int IVIPWRMETER_ATTR_DUTY_CYCLE_CORRECTION_ENABLED = (IviDriverAttribute.IVI_CLASS_PUBLIC_ATTR_BASE + 401); /* ViBoolean */ 60 | 61 | /*- IviPwrMeterReferenceOscillator Extension Group -*/ 62 | public const int IVIPWRMETER_ATTR_REF_OSCILLATOR_ENABLED = (IviDriverAttribute.IVI_CLASS_PUBLIC_ATTR_BASE + 501); /* ViBoolean */ 63 | public const int IVIPWRMETER_ATTR_REF_OSCILLATOR_FREQUENCY = (IviDriverAttribute.IVI_CLASS_PUBLIC_ATTR_BASE + 502); /* ViReal64 */ 64 | public const int IVIPWRMETER_ATTR_REF_OSCILLATOR_LEVEL = (IviDriverAttribute.IVI_CLASS_PUBLIC_ATTR_BASE + 503); /* ViReal64 */ 65 | 66 | 67 | /**************************************************************************** 68 | *----------------- IviPwrMeter Class Attribute Value Defines -----------------* 69 | ****************************************************************************/ 70 | /*- Defined values for attribute IVIPWRMETER_ATTR_UNITS -*/ 71 | public const int IVIPWRMETER_VAL_DBM = (1); 72 | public const int IVIPWRMETER_VAL_DBMV = (2); 73 | public const int IVIPWRMETER_VAL_DBUV = (3); 74 | public const int IVIPWRMETER_VAL_WATTS = (4); 75 | public const int IVIPWRMETER_VAL_UNITS_CLASS_EXT_BASE = (500); 76 | public const int IVIPWRMETER_VAL_UNITS_SPECIFIC_EXT_BASE = (1000); 77 | 78 | /*- Defined values for attribute IVIPWRMETER_ATTR_TRIGGER_SOURCE -*/ 79 | public const int IVIPWRMETER_VAL_IMMEDIATE = (1); 80 | public const int IVIPWRMETER_VAL_EXTERNAL = (2); 81 | public const int IVIPWRMETER_VAL_INTERNAL = (3); 82 | public const int IVIPWRMETER_VAL_SOFTWARE_TRIG = (4); 83 | public const int IVIPWRMETER_VAL_TTL0 = (100); 84 | public const int IVIPWRMETER_VAL_TTL1 = (101); 85 | public const int IVIPWRMETER_VAL_TTL2 = (102); 86 | public const int IVIPWRMETER_VAL_TTL3 = (103); 87 | public const int IVIPWRMETER_VAL_TTL4 = (104); 88 | public const int IVIPWRMETER_VAL_TTL5 = (105); 89 | public const int IVIPWRMETER_VAL_TTL6 = (106); 90 | public const int IVIPWRMETER_VAL_TTL7 = (107); 91 | public const int IVIPWRMETER_VAL_ECL0 = (200); 92 | public const int IVIPWRMETER_VAL_ECL1 = (201); 93 | public const int IVIPWRMETER_VAL_PXI_STAR = (300); 94 | public const int IVIPWRMETER_VAL_RTSI_0 = (400); 95 | public const int IVIPWRMETER_VAL_RTSI_1 = (401); 96 | public const int IVIPWRMETER_VAL_RTSI_2 = (402); 97 | public const int IVIPWRMETER_VAL_RTSI_3 = (403); 98 | public const int IVIPWRMETER_VAL_RTSI_4 = (404); 99 | public const int IVIPWRMETER_VAL_RTSI_5 = (405); 100 | public const int IVIPWRMETER_VAL_RTSI_6 = (406); 101 | public const int IVIPWRMETER_VAL_TRIGGER_SOURCE_CLASS_EXT_BASE = (500); 102 | public const int IVIPWRMETER_VAL_TRIGGER_SOURCE_SPECIFIC_EXT_BASE = (1000); 103 | 104 | /*- Defined values for attribute IVIPWRMETER_ATTR_INTERNAL_TRIGGER_SLOPE -*/ 105 | public const int IVIPWRMETER_VAL_NEGATIVE = (0); 106 | public const int IVIPWRMETER_VAL_POSITIVE = (1); 107 | public const int IVIPWRMETER_VAL_TRIGGER_SLOPE_CLASS_EXT_BASE = (500); 108 | public const int IVIPWRMETER_VAL_TRIGGER_SLOPE_SPECIFIC_EXT_BASE = (1000); 109 | 110 | 111 | /*- Defined values for Operator parameter of function -*/ 112 | /*- IviPwrMeter_ConfigureMeasurement -*/ 113 | public const int IVIPWRMETER_VAL_NONE = (0); 114 | public const int IVIPWRMETER_VAL_DIFFERENCE = (1); 115 | public const int IVIPWRMETER_VAL_SUM = (2); 116 | public const int IVIPWRMETER_VAL_QUOTIENT = (3); 117 | 118 | /*- Defined values for MeasurementStatus parameter of function -*/ 119 | /*- IviPwrMeter_IsMeasurementComplete -*/ 120 | public const int IVIPWRMETER_VAL_MEAS_COMPLETE = (1); 121 | public const int IVIPWRMETER_VAL_MEAS_IN_PROGRESS = (0); 122 | public const int IVIPWRMETER_VAL_MEAS_STATUS_UNKNOWN = (-1); 123 | 124 | /*- Defined values for RangeType parameter of function -*/ 125 | /*- IviPwrMeter_QueryResultRangeType -*/ 126 | public const int IVIPWRMETER_VAL_IN_RANGE = (0); 127 | public const int IVIPWRMETER_VAL_UNDER_RANGE = (-1); 128 | public const int IVIPWRMETER_VAL_OVER_RANGE = (1); 129 | 130 | /*- Defined values for MaxTime parameter of function -*/ 131 | /*- IviPwrMeter_Read -*/ 132 | /*- Defined values for MaxTime parameter of function -*/ 133 | /*- IviPwrMeter_ReadChannel -*/ 134 | public const int IVIPWRMETER_VAL_MAX_TIME_IMMEDIATE = (0x0); 135 | public const uint IVIPWRMETER_VAL_MAX_TIME_INFINITE = (0xFFFFFFFFU); 136 | 137 | /*- Defined values for ZeroStatus parameter of function -*/ 138 | /*- IviPwrMeter_IsZeroComplete -*/ 139 | public const int IVIPWRMETER_VAL_ZERO_COMPLETE = (1); 140 | public const int IVIPWRMETER_VAL_ZERO_IN_PROGRESS = (0); 141 | public const int IVIPWRMETER_VAL_ZERO_STATUS_UNKNOWN = (-1); 142 | 143 | /*- Defined values for CalibrationStatus parameter of function -*/ 144 | /*- IviPwrMeter_IsCalibrationComplete -*/ 145 | public const int IVIPWRMETER_VAL_CALIBRATION_COMPLETE = (1); 146 | public const int IVIPWRMETER_VAL_CALIBRATION_IN_PROGRESS = (0); 147 | public const int IVIPWRMETER_VAL_CALIBRATION_STATUS_UNKNOWN = (-1); 148 | 149 | 150 | } 151 | } -------------------------------------------------------------------------------- /IVI.C.NET.Adapter/IviCInterop/IviScope.cs: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------------------- 2 | // 3 | // Copyright Tom Lu 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //-------------------------------------------------------------------------------------------------- 18 | 19 | using System; 20 | using System.Text; 21 | 22 | // Ivi type mapping 23 | using ViStatus = System.Int32; 24 | using ViSession = System.IntPtr; 25 | using ViString = System.String; 26 | using ViBoolean = System.Boolean; 27 | using ViInt8 = System.Byte; 28 | using ViInt16 = System.Int16; 29 | using ViInt32 = System.Int32; 30 | using ViAttr = System.UInt32; 31 | using ViInt64 = System.Int64; 32 | using ViReal64 = System.Double; 33 | 34 | namespace IVI.C.NET.Adapter.IviCInterop 35 | { 36 | public interface IviScope : IviDriver 37 | { 38 | /*- IviScope Fundamental Capabilities -*/ 39 | ViStatus ConfigureChannel(ViSession vi, ViString channel, ViReal64 range, ViReal64 offset, ViInt32 coupling, ViReal64 probeAttenuation, ViBoolean enabled); 40 | ViStatus ConfigureChanCharacteristics(ViSession vi, ViString channel, ViReal64 inputImpedance, ViReal64 maxInputFrequency); 41 | ViStatus ConfigureAcquisitionType(ViSession vi, ViInt32 acquisitionType); 42 | ViStatus ConfigureAcquisitionRecord(ViSession vi, ViReal64 timePerRecord, ViInt32 minimumRecordLength, ViReal64 acqStartTime); 43 | ViStatus ActualRecordLength(ViSession vi, ref ViInt32 actualRecordLength); 44 | 45 | ViStatus SampleRate(ViSession vi, ref ViReal64 sampleRate); 46 | 47 | ViStatus ConfigureTrigger(ViSession vi, ViInt32 triggerType, ViReal64 holdoff); 48 | ViStatus ConfigureTriggerCoupling(ViSession vi, ViInt32 coupling); 49 | ViStatus ConfigureEdgeTriggerSource(ViSession vi, ViString source, ViReal64 level, ViInt32 slope); 50 | 51 | ViStatus ReadWaveform(ViSession vi, ViString channel, ViInt32 waveformSize, ViInt32 maxTime, IntPtr waveform, ref ViInt32 actualPoints, ref ViReal64 initialX, ref ViReal64 xIncrement); 52 | 53 | ViStatus Abort(ViSession vi); 54 | ViStatus InitiateAcquisition(ViSession vi); 55 | ViStatus AcquisitionStatus(ViSession vi, ref ViInt32 status); 56 | ViStatus FetchWaveform(ViSession vi, ViString channel, ViInt32 waveformSize, IntPtr waveform, ref ViInt32 actualPoints, ref ViReal64 initialX, ref ViReal64 xIncrement); 57 | 58 | ViStatus IsInvalidWfmElement(ViSession vi, ViReal64 elementValue, ref ViBoolean isInvalid); 59 | 60 | ViStatus GetChannelName(ViSession vi, ViInt32 index, ViInt32 bufferSize, StringBuilder name); 61 | 62 | /*- IviScopeTVTrigger Extension Group -*/ 63 | ViStatus ConfigureTVTriggerSource(ViSession vi, ViString source, ViInt32 TVSignalFormat, ViInt32 TVEvent, ViInt32 TVPolarity); 64 | ViStatus ConfigureTVTriggerLineNumber(ViSession vi, ViInt32 lineNumber); 65 | 66 | /*- IviScopeRuntTrigger Extension Group -*/ 67 | ViStatus ConfigureRuntTriggerSource(ViSession vi, ViString source, ViReal64 runtLowThreshold, ViReal64 runtHighThreshold, ViInt32 runtPolarity); 68 | 69 | /*- IviScopeGlitchTrigger Extension Group -*/ 70 | ViStatus ConfigureGlitchTriggerSource(ViSession vi, ViString source, ViReal64 level, ViReal64 glitchWidth, ViInt32 glitchPolarity, ViInt32 glitchCondition); 71 | 72 | /*- IviScopeWidthTrigger Extension Group -*/ 73 | ViStatus ConfigureWidthTriggerSource(ViSession vi, ViString source, ViReal64 level, ViReal64 widthLowThreshold, ViReal64 widthHighThreshold, ViInt32 widthPolarity, ViInt32 widthCondition); 74 | 75 | /*- IviScopeAcLineTrigger Extension Group -*/ 76 | ViStatus ConfigureAcLineTriggerSlope(ViSession vi, ViInt32 slope); 77 | 78 | /*- IviScopeTriggerModifier Extension Group -*/ 79 | ViStatus ConfigureTriggerModifier(ViSession vi, ViInt32 triggerModifier); 80 | 81 | /*- IviScopeMinMaxWaveform Extension Group -*/ 82 | ViStatus ConfigureNumEnvelopes(ViSession vi, ViInt32 numberOfEnvelopes); 83 | 84 | ViStatus ReadMinMaxWaveform(ViSession vi, ViString channel, ViInt32 waveformSize, ViInt32 maxTime, IntPtr minWaveform, IntPtr maxWaveform, ref ViInt32 actualPoints, ref ViReal64 initialX, ref ViReal64 xIncrement); 85 | 86 | ViStatus FetchMinMaxWaveform(ViSession vi, ViString channel, ViInt32 waveformSize, IntPtr minWaveform, IntPtr maxWaveform, ref ViInt32 actualPoints, ref ViReal64 initialX, ref ViReal64 xIncrement); 87 | 88 | /*- IviScopeWaveformMeas Extension Group -*/ 89 | ViStatus ConfigureRefLevels(ViSession vi, ViReal64 lowRef, ViReal64 midRef, ViReal64 highRef); 90 | 91 | ViStatus ReadWaveformMeasurement(ViSession vi, ViString channel, ViInt32 measurementFunction, ViInt32 maxTime, ref ViReal64 measurement); 92 | 93 | ViStatus FetchWaveformMeasurement(ViSession vi, ViString channel, ViInt32 measurementFunction, ref ViReal64 measurement); 94 | 95 | /*- IviScope Average Acquisition Extension Group -*/ 96 | ViStatus ConfigureNumAverages(ViSession vi, ViInt32 numberOfAverages); 97 | 98 | /*- IviScope Continuous Acquisition Extension Group -*/ 99 | ViStatus ConfigureInitiateContinuous(ViSession vi, ViBoolean continuousAcquisition); 100 | 101 | /*- IviScope Interpolation Extension Group -*/ 102 | ViStatus ConfigureInterpolation(ViSession vi, ViInt32 interpolation); 103 | 104 | /*- IviScope Sample Mode Extension Group -*/ 105 | ViStatus SampleMode(ViSession vi, ref ViInt32 sampleMode); 106 | 107 | /*- IviScope Probe Auto Sense Extension Group -*/ 108 | ViStatus AutoProbeSenseValue(ViSession vi, ViString channel, ref ViReal64 autoProbeSenseValue); 109 | /*- IviScope Auto Setup Extension Group -*/ 110 | ViStatus AutoSetup(ViSession vi); 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /IVI.C.NET.Adapter/IviCInterop/IviSpecAn.cs: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------------------- 2 | // 3 | // Copyright Tom Lu 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //-------------------------------------------------------------------------------------------------- 18 | 19 | using System; 20 | using System.Text; 21 | 22 | // Ivi type mapping 23 | using ViStatus = System.Int32; 24 | using ViSession = System.IntPtr; 25 | using ViString = System.String; 26 | using ViBoolean = System.Boolean; 27 | using ViInt8 = System.Byte; 28 | using ViInt16 = System.Int16; 29 | using ViInt32 = System.Int32; 30 | using ViAttr = System.UInt32; 31 | using ViInt64 = System.Int64; 32 | using ViReal64 = System.Double; 33 | 34 | 35 | namespace IVI.C.NET.Adapter.IviCInterop 36 | { 37 | public interface IviSpecAn : IviDriver 38 | { 39 | /*- IviSpecAn Fundamental Capabilities -*/ 40 | ViStatus Abort(ViSession vi); 41 | 42 | ViStatus AcquisitionStatus(ViSession vi, 43 | ref ViInt32 status); 44 | 45 | ViStatus ConfigureAcquisition(ViSession vi, 46 | ViBoolean sweepModeContinuous, 47 | ViInt32 numberOfSweeps, 48 | ViBoolean detectorTypeAuto, 49 | ViInt32 detectorType, 50 | ViInt32 verticalScale); 51 | 52 | ViStatus ConfigureFrequencyCenterSpan(ViSession vi, 53 | ViReal64 CenterFrequency, 54 | ViReal64 Span); 55 | 56 | ViStatus ConfigureFrequencyOffset(ViSession vi, 57 | ViReal64 FrequencyOffset); 58 | 59 | ViStatus ConfigureFrequencyStartStop(ViSession vi, 60 | ViReal64 StartFrequency, 61 | ViReal64 StopFrequency); 62 | 63 | ViStatus ConfigureLevel(ViSession vi, 64 | ViInt32 AmplitudeUnits, 65 | ViReal64 InputImpedance, 66 | ViReal64 ReferenceLevel, 67 | ViReal64 ReferenceLevelOffset, 68 | ViBoolean AttenuationAuto, 69 | ViReal64 Attenuation); 70 | 71 | ViStatus ConfigureSweepCoupling(ViSession vi, 72 | ViBoolean ResolutionBandwidtAuto, 73 | ViReal64 ResolutionBandwidth, 74 | ViBoolean VideoBandwidthAuto, 75 | ViReal64 VideoBandwidth, 76 | ViBoolean SweepTimeAuto, 77 | ViReal64 SweepTime); 78 | 79 | ViStatus ConfigureTraceType(ViSession vi, 80 | ViString TraceName, 81 | ViInt32 TraceType); 82 | 83 | ViStatus FetchYTrace(ViSession vi, 84 | ViString TraceName, 85 | ViInt32 ArrayLength, 86 | ref ViInt32 ActualPoints, 87 | IntPtr Amplitude); 88 | 89 | ViStatus GetTraceName(ViSession vi, 90 | ViInt32 Index, 91 | ViInt32 NameBufferSize, 92 | StringBuilder Name); 93 | 94 | ViStatus Initiate(ViSession vi); 95 | 96 | ViStatus QueryTraceSize(ViSession vi, 97 | ViString TraceName, 98 | ref ViInt32 TraceSize); 99 | 100 | ViStatus ReadYTrace(ViSession vi, 101 | ViString TraceName, 102 | ViInt32 MaxTime, 103 | ViInt32 ArrayLength, 104 | ref ViInt32 ActualPoints, 105 | IntPtr Amplitude); 106 | 107 | 108 | /*- IviSpecAnMultitrace Extension Group -*/ 109 | ViStatus AddTraces(ViSession vi, 110 | ViString DestinationTrace, 111 | ViString Trace1, 112 | ViString Trace2); 113 | 114 | ViStatus CopyTrace(ViSession vi, 115 | ViString DestinationTrace, 116 | ViString SourceTrace); 117 | 118 | ViStatus ExchangeTraces(ViSession vi, 119 | ViString Trace1, 120 | ViString Trace2); 121 | 122 | ViStatus SubtractTraces(ViSession vi, 123 | ViString DestinationTrace, 124 | ViString Trace1, 125 | ViString Trace2); 126 | 127 | 128 | /*- IviSpecAnMarker Extension Group -*/ 129 | ViStatus ConfigureMarkerEnabled(ViSession vi, 130 | ViBoolean MarkerEnabled, 131 | ViString MarkerTraceName); 132 | 133 | ViStatus ConfigureMarkerFrequencyCounter(ViSession vi, 134 | ViBoolean Enabled, 135 | ViReal64 Resolution); 136 | 137 | ViStatus ConfigureMarkerSearch(ViSession vi, 138 | ViReal64 PeakExcursion, 139 | ViReal64 MarkerThreshold); 140 | 141 | ViStatus ConfigureSignalTrackEnabled(ViSession vi, 142 | ViBoolean SignalTrackEnabled); 143 | 144 | ViStatus DisableAllMarkers(ViSession vi); 145 | 146 | ViStatus GetMarkerName(ViSession vi, 147 | ViInt32 Index, 148 | ViInt32 NameBufferSize, 149 | StringBuilder Name); 150 | 151 | ViStatus MarkerSearch(ViSession vi, 152 | ViInt32 SearchType); 153 | 154 | ViStatus MoveMarker(ViSession vi, 155 | ViReal64 MarkerPosition); 156 | 157 | ViStatus QueryMarker(ViSession vi, 158 | ref ViReal64 MarkerPosition, 159 | ref ViReal64 MarkerAmplitude); 160 | 161 | ViStatus SetActiveMarker(ViSession vi, 162 | ViString ActiveMarker); 163 | 164 | ViStatus SetInstrumentFromMarker(ViSession vi, 165 | ViInt32 InstrumentSetting); 166 | 167 | 168 | /*- IviSpecAnTrigger Extension Group -*/ 169 | ViStatus ConfigureTriggerSource(ViSession vi, 170 | ViInt32 TriggerSource); 171 | 172 | 173 | /*- IviSpecAnExternalTrigger Extension Group -*/ 174 | ViStatus ConfigureExternalTrigger(ViSession vi, 175 | ViReal64 ExternalTriggerLevel, 176 | ViInt32 ExternalTriggerSlope); 177 | 178 | 179 | /*- IviSpecAnSoftwareTrigger Extension Group -*/ 180 | ViStatus SendSoftwareTrigger(ViSession vi); 181 | 182 | 183 | /*- IviSpecAnVideoTrigger Extension Group -*/ 184 | ViStatus ConfigureVideoTrigger(ViSession vi, 185 | ViReal64 VideoTriggerLevel, 186 | ViInt32 VideoTriggerSlope); 187 | 188 | 189 | /*- IviSpecAnMarkerType Extension Group -*/ 190 | ViStatus QueryMarkerType(ViSession vi, 191 | ref ViInt32 MarkerType); 192 | 193 | 194 | /*- IviSpecAnDeltaMarker Extension Group -*/ 195 | ViStatus MakeMarkerDelta(ViSession vi, 196 | ViBoolean DeltaMarker); 197 | 198 | ViStatus QueryReferenceMarker(ViSession vi, 199 | ref ViReal64 ReferenceMarkerAmplitude, 200 | ref ViReal64 ReferenceMarkerPosition); 201 | 202 | 203 | /*- IviSpecAnExternalMixer Extension Group -*/ 204 | ViStatus ConfigureConversionLossTable(ViSession vi, 205 | ViInt32 Count, 206 | ViReal64[] Frequency, 207 | ViReal64[] ConversionLoss); 208 | 209 | ViStatus ConfigureConversionLossTableEnabled(ViSession vi, 210 | ViBoolean ConversionLossTableEnabled); 211 | 212 | ViStatus ConfigureExternalMixer(ViSession vi, 213 | ViInt32 Harmonic, 214 | ViReal64 AverageConversionLoss); 215 | 216 | ViStatus ConfigureExternalMixerBias(ViSession vi, 217 | ViReal64 Bias, 218 | ViReal64 BiasLimit); 219 | 220 | ViStatus ConfigureExternalMixerBiasEnabled(ViSession vi, 221 | ViBoolean BiasEnabled); 222 | 223 | ViStatus ConfigureExternalMixerEnabled(ViSession vi, 224 | ViBoolean ExternalMixerEnabled); 225 | 226 | ViStatus ConfigureExternalMixerNumberOfPorts(ViSession vi, 227 | ViInt32 NumberOfPorts); 228 | 229 | 230 | /*- IviSpecAnPreselector Extension Group -*/ 231 | ViStatus PeakPreselector(ViSession vi); 232 | 233 | } 234 | } 235 | -------------------------------------------------------------------------------- /IVI.C.NET.Adapter/IviCInterop/IviSwtch.cs: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------------------- 2 | // 3 | // Copyright Tom Lu 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //-------------------------------------------------------------------------------------------------- 18 | 19 | using System; 20 | using System.Text; 21 | 22 | // Ivi type mapping 23 | using ViStatus = System.Int32; 24 | using ViSession = System.IntPtr; 25 | using ViString = System.String; 26 | using ViBoolean = System.Boolean; 27 | using ViInt8 = System.Byte; 28 | using ViInt16 = System.Int16; 29 | using ViInt32 = System.Int32; 30 | using ViAttr = System.UInt32; 31 | using ViInt64 = System.Int64; 32 | using ViReal64 = System.Double; 33 | 34 | namespace IVI.C.NET.Adapter.IviCInterop 35 | { 36 | public interface IviSwtch : IviDriver 37 | { 38 | /*- IviSwtchBase Capability Group Functions -*/ 39 | ViStatus CanConnect(ViSession vi, ViString channel1, ViString channel2, ref ViInt32 pathCapability); 40 | 41 | ViStatus Connect(ViSession vi, ViString channel1, ViString channel2); 42 | 43 | ViStatus Disconnect(ViSession vi, ViString channel1, ViString channel2); 44 | 45 | ViStatus DisconnectAll(ViSession vi); 46 | 47 | ViStatus GetChannelName(ViSession vi, ViInt32 index, ViInt32 bufferSize, StringBuilder name); 48 | 49 | ViStatus GetPath(ViSession vi, ViString channel1, ViString channel2, ViInt32 bufferSize, StringBuilder pathList); 50 | 51 | ViStatus IsDebounced(ViSession vi, ref ViBoolean isDebounced); 52 | 53 | ViStatus SetPath(ViSession vi, ViString pathList); 54 | 55 | ViStatus WaitForDebounce(ViSession vi, ViInt32 maxTime); 56 | 57 | /*- IviSwtchScanner Extension Group Functions -*/ 58 | ViStatus AbortScan(ViSession vi); 59 | 60 | ViStatus ConfigureScanList(ViSession vi, ViString scanList, ViInt32 scanMode); 61 | 62 | ViStatus ConfigureScanTrigger(ViSession vi, ViReal64 scanDelay, ViInt32 triggerInput, ViInt32 scanAdvancedOutput); 63 | 64 | ViStatus InitiateScan(ViSession vi); 65 | 66 | ViStatus IsScanning(ViSession vi, ref ViBoolean isScanning); 67 | 68 | ViStatus SetContinuousScan(ViSession vi, ViBoolean status); 69 | 70 | ViStatus WaitForScanComplete(ViSession vi, ViInt32 maxTime); 71 | 72 | /*- IviSwtchSoftwareTrigger Extension Group Functions -*/ 73 | ViStatus SendSoftwareTrigger(ViSession vi); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /IVI.C.NET.Adapter/IviCInterop/IviSwtchAttribute.cs: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------------------- 2 | // 3 | // Copyright Tom Lu 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //-------------------------------------------------------------------------------------------------- 18 | 19 | using System; 20 | using System.Collections.Generic; 21 | using System.Text; 22 | 23 | namespace IVI.C.NET.Adapter.IviCInterop 24 | { 25 | public class IviSwtchAttribute 26 | { 27 | 28 | 29 | /*- IviSwtch Fundamental Attributes -*/ 30 | public const int IVISWTCH_ATTR_CHANNEL_COUNT = IviDriverAttribute.IVI_ATTR_CHANNEL_COUNT; /* ViInt32, read-only */ 31 | public const int IVISWTCH_ATTR_IS_SOURCE_CHANNEL = (IviDriverAttribute.IVI_CLASS_PUBLIC_ATTR_BASE + 1); /* ViBoolean, Channel-based */ 32 | public const int IVISWTCH_ATTR_IS_DEBOUNCED = (IviDriverAttribute.IVI_CLASS_PUBLIC_ATTR_BASE + 2); /* ViBoolean, Read-only */ 33 | public const int IVISWTCH_ATTR_IS_CONFIGURATION_CHANNEL = (IviDriverAttribute.IVI_CLASS_PUBLIC_ATTR_BASE + 3); /* ViBoolean, Channel-based */ 34 | public const int IVISWTCH_ATTR_SETTLING_TIME = (IviDriverAttribute.IVI_CLASS_PUBLIC_ATTR_BASE + 4); /* ViReal64, Read-only, Channel-based */ 35 | public const int IVISWTCH_ATTR_BANDWIDTH = (IviDriverAttribute.IVI_CLASS_PUBLIC_ATTR_BASE + 5); /* ViReal64, Read-only, Channel-based */ 36 | public const int IVISWTCH_ATTR_MAX_DC_VOLTAGE = (IviDriverAttribute.IVI_CLASS_PUBLIC_ATTR_BASE + 6); /* ViReal64, Read-only, Channel-based */ 37 | public const int IVISWTCH_ATTR_MAX_AC_VOLTAGE = (IviDriverAttribute.IVI_CLASS_PUBLIC_ATTR_BASE + 7); /* ViReal64, Read-only, Channel-based */ 38 | public const int IVISWTCH_ATTR_MAX_SWITCHING_DC_CURRENT = (IviDriverAttribute.IVI_CLASS_PUBLIC_ATTR_BASE + 8); /* ViReal64, Read-only, Channel-based */ 39 | public const int IVISWTCH_ATTR_MAX_SWITCHING_AC_CURRENT = (IviDriverAttribute.IVI_CLASS_PUBLIC_ATTR_BASE + 9); /* ViReal64, Read-only, Channel-based */ 40 | public const int IVISWTCH_ATTR_MAX_CARRY_DC_CURRENT = (IviDriverAttribute.IVI_CLASS_PUBLIC_ATTR_BASE + 10); /* ViReal64, Read-only, Channel-based */ 41 | public const int IVISWTCH_ATTR_MAX_CARRY_AC_CURRENT = (IviDriverAttribute.IVI_CLASS_PUBLIC_ATTR_BASE + 11); /* ViReal64, Read-only, Channel-based */ 42 | public const int IVISWTCH_ATTR_MAX_SWITCHING_DC_POWER = (IviDriverAttribute.IVI_CLASS_PUBLIC_ATTR_BASE + 12); /* ViReal64, Read-only, Channel-based */ 43 | public const int IVISWTCH_ATTR_MAX_SWITCHING_AC_POWER = (IviDriverAttribute.IVI_CLASS_PUBLIC_ATTR_BASE + 13); /* ViReal64, Read-only, Channel-based */ 44 | public const int IVISWTCH_ATTR_MAX_CARRY_DC_POWER = (IviDriverAttribute.IVI_CLASS_PUBLIC_ATTR_BASE + 14); /* ViReal64, Read-only, Channel-based */ 45 | public const int IVISWTCH_ATTR_MAX_CARRY_AC_POWER = (IviDriverAttribute.IVI_CLASS_PUBLIC_ATTR_BASE + 15); /* ViReal64, Read-only, Channel-based */ 46 | public const int IVISWTCH_ATTR_CHARACTERISTIC_IMPEDANCE = (IviDriverAttribute.IVI_CLASS_PUBLIC_ATTR_BASE + 16); /* ViReal64, Read-only, Channel-based */ 47 | public const int IVISWTCH_ATTR_WIRE_MODE = (IviDriverAttribute.IVI_CLASS_PUBLIC_ATTR_BASE + 17); /* ViInt32, Read-only, Channel-based */ 48 | 49 | /*- IviSwtch Extended Attributes -*/ 50 | /*- IviSwitchScanner Extension Group -*/ 51 | public const int IVISWTCH_ATTR_NUM_OF_ROWS = (IviDriverAttribute.IVI_CLASS_PUBLIC_ATTR_BASE + 18); /* ViInt32, Read-only */ 52 | public const int IVISWTCH_ATTR_NUM_OF_COLUMNS = (IviDriverAttribute.IVI_CLASS_PUBLIC_ATTR_BASE + 19); /* ViInt32, Read-only */ 53 | public const int IVISWTCH_ATTR_SCAN_LIST = (IviDriverAttribute.IVI_CLASS_PUBLIC_ATTR_BASE + 20); /* ViString */ 54 | public const int IVISWTCH_ATTR_SCAN_MODE = (IviDriverAttribute.IVI_CLASS_PUBLIC_ATTR_BASE + 21); /* ViInt32 */ 55 | public const int IVISWTCH_ATTR_TRIGGER_INPUT = (IviDriverAttribute.IVI_CLASS_PUBLIC_ATTR_BASE + 22); /* ViInt32 */ 56 | public const int IVISWTCH_ATTR_SCAN_ADVANCED_OUTPUT = (IviDriverAttribute.IVI_CLASS_PUBLIC_ATTR_BASE + 23); /* ViInt32 */ 57 | public const int IVISWTCH_ATTR_IS_SCANNING = (IviDriverAttribute.IVI_CLASS_PUBLIC_ATTR_BASE + 24); /* ViBoolean, Read-only */ 58 | public const int IVISWTCH_ATTR_SCAN_DELAY = (IviDriverAttribute.IVI_CLASS_PUBLIC_ATTR_BASE + 25); /* ViReal64 */ 59 | public const int IVISWTCH_ATTR_CONTINUOUS_SCAN = (IviDriverAttribute.IVI_CLASS_PUBLIC_ATTR_BASE + 26); /* ViBoolean */ 60 | 61 | /***************************************************************************** 62 | *---------------- IviSwtch Class Attribute Value Defines -------------------* 63 | *****************************************************************************/ 64 | 65 | /*- Defined values for attribute IVISWTCH_ATTR_SCAN_MODE -*/ 66 | public const int IVISWTCH_VAL_NONE = (0); 67 | public const int IVISWTCH_VAL_BREAK_BEFORE_MAKE = (1); 68 | public const int IVISWTCH_VAL_BREAK_AFTER_MAKE = (2); 69 | public const int IVISWTCH_VAL_SCAN_MODE_CLASS_EXT_BASE = (500); 70 | public const int IVISWTCH_VAL_SCAN_MODE_SPECIFIC_EXT_BASE = (1000); 71 | 72 | /*- Defined values for attribute IVISWTCH_ATTR_TRIGGER_INPUT -*/ 73 | public const int IVISWTCH_VAL_IMMEDIATE = (1); 74 | public const int IVISWTCH_VAL_EXTERNAL = (2); 75 | public const int IVISWTCH_VAL_SOFTWARE_TRIG = (3); 76 | public const int IVISWTCH_VAL_TTL0 = (111); 77 | public const int IVISWTCH_VAL_TTL1 = (112); 78 | public const int IVISWTCH_VAL_TTL2 = (113); 79 | public const int IVISWTCH_VAL_TTL3 = (114); 80 | public const int IVISWTCH_VAL_TTL4 = (115); 81 | public const int IVISWTCH_VAL_TTL5 = (116); 82 | public const int IVISWTCH_VAL_TTL6 = (117); 83 | public const int IVISWTCH_VAL_TTL7 = (118); 84 | public const int IVISWTCH_VAL_ECL0 = (119); 85 | public const int IVISWTCH_VAL_ECL1 = (120); 86 | public const int IVISWTCH_VAL_PXI_STAR = (125); 87 | public const int IVISWTCH_VAL_RTSI_0 = (140); 88 | public const int IVISWTCH_VAL_RTSI_1 = (141); 89 | public const int IVISWTCH_VAL_RTSI_2 = (142); 90 | public const int IVISWTCH_VAL_RTSI_3 = (143); 91 | public const int IVISWTCH_VAL_RTSI_4 = (144); 92 | public const int IVISWTCH_VAL_RTSI_5 = (145); 93 | public const int IVISWTCH_VAL_RTSI_6 = (146); 94 | public const int IVISWTCH_VAL_TRIGGER_INPUT_CLASS_EXT_BASE = (500); 95 | public const int IVISWTCH_VAL_TRIGGER_INPUT_SPECIFIC_EXT_BASE = (1000); 96 | 97 | /*- Defined values for attribute IVISWTCH_ATTR_SCAN_ADVANCED_OUTPUT -*/ 98 | public const int IVISWTCH_VAL_GPIB_SRQ = (5); 99 | 100 | public const int IVISWTCH_VAL_SCAN_ADVANCED_OUTPUT_CLASS_EXT_BASE = (500); 101 | public const int IVISWTCH_VAL_SCAN_ADVANCED_OUTPUT_SPECIFIC_EXT_BASE = (1000); 102 | 103 | /*- Defined values for IviSwtch_CanConnect path capability parameter -*/ 104 | public const int IVISWTCH_VAL_PATH_AVAILABLE = (1); 105 | public const int IVISWTCH_VAL_PATH_EXISTS = (2); 106 | public const int IVISWTCH_VAL_PATH_UNSUPPORTED = (3); 107 | public const int IVISWTCH_VAL_RSRC_IN_USE = (4); 108 | public const int IVISWTCH_VAL_SOURCE_CONFLICT = (5); 109 | public const int IVISWTCH_VAL_CHANNEL_NOT_AVAILABLE = (6); 110 | public const int IVISWTCH_VAL_CAN_CONNECT_CLASS_EXT_BASE = (500); 111 | public const int IVISWTCH_VAL_CAN_CONNECT_SPECIFIC_EXT_BASE = (1000); 112 | 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /IVI.C.NET.Adapter/IviEnumCMapping.cs: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------------------- 2 | // 3 | // Copyright Tom Lu 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //-------------------------------------------------------------------------------------------------- 18 | 19 | using System; 20 | using System.Collections.Generic; 21 | using System.Collections; 22 | 23 | namespace IVI.C.NET.Adapter 24 | { 25 | internal class IviEnumCMapping 26 | { 27 | IDictionary forward; 28 | IDictionary backward; 29 | 30 | private IviEnumCMapping() 31 | { 32 | forward = new Dictionary(); 33 | backward = new Dictionary(); 34 | } 35 | 36 | public C_Value getC_Value(EnumValue Key) 37 | { 38 | return forward[Key]; 39 | } 40 | 41 | public EnumValue getEnum(C_Value Value) 42 | { 43 | return backward[Value]; 44 | } 45 | 46 | public IviEnumCMapping Map(EnumValue enumValue, C_Value cValue) 47 | { 48 | forward.Add(enumValue, cValue); 49 | backward.Add(cValue, enumValue); 50 | return this; 51 | } 52 | 53 | public static IviEnumCMapping Instance 54 | { 55 | get 56 | { 57 | return new IviEnumCMapping(); 58 | } 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /IVI.C.NET.Adapter/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("IVI.C.NET.Adapter")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("IVI.C.NET.Adapter")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("1c416bff-e5a0-41d9-9773-f39667a40b71")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.1")] 36 | -------------------------------------------------------------------------------- /IVI.C.NET.Adapter/Win32Interop/Win32LibInterop.cs: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------------------- 2 | // 3 | // Copyright Tom Lu 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | // 17 | //-------------------------------------------------------------------------------------------------- 18 | 19 | using System; 20 | using System.Collections.Generic; 21 | using System.Runtime.InteropServices; 22 | using System.Diagnostics; 23 | 24 | namespace IVI.C.NET.Adapter.Win32Interop 25 | { 26 | class Win32LibInterop 27 | { 28 | /// 29 | /// Function: HMODULE LoadLibrary(LPCTSTR lpFileName); 30 | /// 31 | /// The name of the module(DLL). 32 | /// If the function succeeds, the return value is a handle to the module. If the function fails, the return value is NULL. 33 | [DllImport("kernel32.dll", SetLastError = true)] 34 | public static extern IntPtr LoadLibrary(string lpFileName); 35 | 36 | /// 37 | /// Function: FARPROC GetProcAddress(HMODULE hModule, LPCWSTR lpProcName); 38 | /// 39 | /// A handle to the DLL module that contains the function or variable. 40 | /// The function or variable name, or the function's ordinal value. If this parameter is an ordinal value, it must be in the low-order word; the high-order word must be zero. 41 | /// If the function succeeds, the return value is the address of the exported function or variable. If the function fails, the return value is NULL. 42 | [DllImport("kernel32.dll", SetLastError = true)] 43 | public static extern IntPtr GetProcAddress(IntPtr hModule, string lpProcName); 44 | 45 | /// 46 | /// Function: BOOL FreeLibrary(HMODULE hModule); 47 | /// 48 | /// A handle to the loaded library module. 49 | /// If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. 50 | [DllImport("kernel32", EntryPoint = "FreeLibrary", SetLastError = true)] 51 | public static extern bool FreeLibrary(IntPtr hModule); 52 | 53 | 54 | /// 55 | /// Function: DWORD GetLastError(void); 56 | /// 57 | /// The return value is the calling thread's last-error code. 58 | [DllImport("kernel32")] 59 | public static extern uint GetLastError(); 60 | 61 | [DllImport("Kernel32.dll")] 62 | public extern static int FormatMessage(int flag, ref IntPtr source, int msgid, int langid, ref string buf, int size, ref IntPtr args); 63 | 64 | public static string GetLastErrorMessage() 65 | { 66 | int errCode = Marshal.GetLastWin32Error(); 67 | IntPtr tempptr = IntPtr.Zero; 68 | string msg = null; 69 | FormatMessage(0x1300, ref tempptr, errCode, 0, ref msg, 255, ref tempptr); 70 | return msg; 71 | } 72 | 73 | /// 74 | /// The function determines whether the current operating system is a 75 | /// 64-bit operating system. 76 | /// 77 | /// 78 | /// The function returns true if the operating system is 64-bit; 79 | /// otherwise, it returns false. 80 | /// 81 | public static bool IsWin64BitOS(OperatingSystem os) 82 | { 83 | if (IntPtr.Size == 8) 84 | // 64-bit programs run only on Win64 85 | return true; 86 | else// 32-bit programs run on both 32-bit and 64-bit Windows 87 | { // Detect whether the current process is a 32-bit process 88 | // running on a 64-bit system. 89 | return Is64BitProc(Process.GetCurrentProcess()); 90 | } 91 | } 92 | 93 | /// 94 | /// Checks if the process is 64 bit 95 | /// 96 | /// 97 | /// 98 | /// The function returns true if the process is 64-bit; 99 | /// otherwise, it returns false. 100 | /// 101 | public static bool Is64BitProc(System.Diagnostics.Process p) 102 | { 103 | // 32-bit programs run on both 32-bit and 64-bit Windows 104 | // Detect whether the current process is a 32-bit process 105 | // running on a 64-bit system. 106 | bool result; 107 | return ((DoesWin32MethodExist("kernel32.dll", "IsWow64Process") && IsWow64Process(p.Handle, out result)) && result); 108 | } 109 | 110 | /// 111 | /// The function determins whether a method exists in the export 112 | /// table of a certain module. 113 | /// 114 | /// The name of the module 115 | /// The name of the method 116 | /// 117 | /// The function returns true if the method specified by methodName 118 | /// exists in the export table of the module specified by moduleName. 119 | /// 120 | static bool DoesWin32MethodExist(string moduleName, string methodName) 121 | { 122 | IntPtr moduleHandle = GetModuleHandle(moduleName); 123 | if (moduleHandle == IntPtr.Zero) 124 | return false; 125 | return (GetProcAddress(moduleHandle, methodName) != IntPtr.Zero); 126 | } 127 | [DllImport("kernel32.dll")] 128 | static extern IntPtr GetCurrentProcess(); 129 | 130 | [DllImport("kernel32.dll", CharSet = CharSet.Auto)] 131 | static extern IntPtr GetModuleHandle(string moduleName); 132 | 133 | [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] 134 | [return: MarshalAs(UnmanagedType.Bool)] 135 | static extern bool IsWow64Process(IntPtr hProcess, out bool wow64Process); 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /IVI.C.NET.Adapter/_IVI.C.NET.Adapter.pfx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tom-Lu/IVI.C.NET.Adapter/09f8c5df4aa608ca7f129c04b5793edfef6a42d3/IVI.C.NET.Adapter/_IVI.C.NET.Adapter.pfx -------------------------------------------------------------------------------- /IVI.C.NET.Adapter/_IVI.C.NET.Adapter_nopwd.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tom-Lu/IVI.C.NET.Adapter/09f8c5df4aa608ca7f129c04b5793edfef6a42d3/IVI.C.NET.Adapter/_IVI.C.NET.Adapter_nopwd.snk -------------------------------------------------------------------------------- /NUnit/Logo.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tom-Lu/IVI.C.NET.Adapter/09f8c5df4aa608ca7f129c04b5793edfef6a42d3/NUnit/Logo.ico -------------------------------------------------------------------------------- /NUnit/license.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tom-Lu/IVI.C.NET.Adapter/09f8c5df4aa608ca7f129c04b5793edfef6a42d3/NUnit/license.txt -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # IVI.C.NET.Adapter 2 | 3 | IVI.C.NET.Adapter is an .NET assembly support using IVI-C driver from .NET application 4 | without interop with individual driver DLL. 5 | 6 | [![Class Diagram](https://github.com/Tom-Lu/IVI.C.NET.Adapter/blob/master/UML/Classdiagram.png)](https://github.com/Tom-Lu/IVI.C.NET.Adapter/blob/master/UML/Classdiagram.png) 7 | 8 | Currently following Ivi C driver been supported: 9 | 10 | - IviCounter 11 | - IviDCPwr 12 | - IviDigitizer 13 | - IviDmm 14 | - IviDownconverter 15 | - IviFgen 16 | - IviPwrMeter 17 | - IviRFSigGen 18 | - IviScope 19 | - IviSpecAn 20 | - IviSwtch 21 | - IviUpconverter 22 | 23 | Due to no definition about `IviACPwr` in IVI.NET Shared Components yet. So `IviACPwr` driver is 24 | not supported in current release. 25 | 26 | ## Getting Started Guide 27 | [Getting Started Guide](https://github.com/Tom-Lu/IVI.C.NET.Adapter/wiki/Getting-Started-Guide) 28 | 29 | ## Development Environment Set up 30 | 1. Install IVI Shared Components 31 | 2. Install IVI.NET Shared Components 32 | 3. Build Solution with Visual Studio 33 | 34 | [IVI Shared Components](http://www.ivifoundation.org/shared_components/Default.aspx) 35 | 36 | ## Test 37 | In order to successful run the tests with Nunit, you need install several Ivi drivers from 38 | Keysight(formerly Agilent). Those driver can be download from [Keysight](http://www.keysight.com/main/facet.jspx?t=80126.k.3&lc=chi&sm=g) 39 | or [National Instruments](http://www.ni.com/downloads/instrument-drivers). 40 | 41 | - Agilent Ag34401 42 | - Agilent AgE36xx 43 | - Agilent ag5313xni 44 | - Agilent agl453xdni 45 | - Agilent ag1000ni 46 | - Agilent agpsa 47 | - Agilent age1442a 48 | 49 | ## Ivi Versions 50 | - IVI Shared Components version 2.2.1 or greater. 51 | - IVI.NET Shared Components version 2.2.1 or greater. 52 | 53 | ## NOTICE: 54 | IVI.C.NET.Adapter only verified with few physical instruments, the concept seems working very well. 55 | Use at your own risk, the author will not response for any cost because of using IVI.C.NET.Adapter. -------------------------------------------------------------------------------- /UML/Classdiagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tom-Lu/IVI.C.NET.Adapter/09f8c5df4aa608ca7f129c04b5793edfef6a42d3/UML/Classdiagram.png --------------------------------------------------------------------------------