using System;

using System.Runtime.InteropServices;

using System.Text;

internal sealed class visa32

{

    public const int VI_SPEC_VERSION = 4194304;

    #region - Resource Template Functions and Operations ----------------------------

    [DllImportAttribute("VISA32.DLL", EntryPoint = "#141", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]

    public static extern int viOpenDefaultRM(out int sesn);

    [DllImportAttribute("VISA32.DLL", EntryPoint = "#128", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]

    public static extern int viGetDefaultRM(out int sesn);

    [DllImportAttribute("VISA32.DLL", EntryPoint = "#129", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]

    public static extern int viFindRint sesn, string expr, out int vi, out int retCount, StringBuilder desc);< /span>

    [DllImportAttribute("VISA32.DLL", EntryPoint = "#130", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]

    public static extern int viFindNext(int vi, StringBuilder desc);

    [DllImportAttribute("VISA32.DLL", EntryPoint = "#146", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]

    public static extern int viParseRint sesn, string desc, ref short intfType, ref short intfNum);< /span>

    [DllImportAttribute("VISA32.DLL", EntryPoint = "#147", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]

    public static extern int viParseRsrcEx(int sesn, string desc, ref short intfType, ref short intfNum, StringBuilder rsrcClass, StringBuilder expandedUnaliasedName, StringBuilder aliasIfExists);

    [DllImportAttribute("VISA32.DLL", EntryPoint = "#131", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]

    public static extern int viOpen(int sesn, string viDesc, int mode, int timeout, out int vi);

    [DllImportAttribute("VISA32.DLL", EntryPoint = "#132", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]

    public static extern int viClose(int vi);

    #region viGetAttribute Overloads

    [DllImportAttribute("VISA32.DLL", EntryPoint = "#133", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]

    public static extern int viGetAttribute(int vi, int attrName, out byte attrValue);

    [DllImportAttribute("VISA32.DLL", EntryPoint = "#133", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]

    public static extern int viGetAttribute(int vi, int attrName, out short attrValue);

    [DllImportAttribute("VISA32.DLL", EntryPoint = "#133", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]

    public static extern int viGetAttribute(int vi, int attrName, out int attrValue);

    [DllImportAttribute("VISA32.DLL", EntryPoint = "#133", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]

    public static extern int viGetAttribute(int vi, int attrName, StringBuilder attrValue);

    #endregion

    #region viSetAttribute Overloads

    [DllImportAttribute("VISA32.DLL", EntryPoint = "#134", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]

    public static extern int viSetAttribute(int vi, int attrName, byte attrValue);

    [DllImportAttribute("VISA32.DLL", EntryPoint = "#134", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]

    public static extern int viSetAttribute(int vi, int attrName, short attrValue);

    [DllImportAttribute("VISA32.DLL", EntryPoint = "#134", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]

    public static extern int viSetAttribute(int vi, int attrName, int attrValue);

    #endregion

    [DllImportAttribute("VISA32.DLL", EntryPoint = "#142", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]

    public static extern int viStatusDesc(int vi, int status, StringBuilder desc);

    [DllImportAttribute("VISA32.DLL", EntryPoint = "#143", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]

    public static extern int viTerminate(int vi, short degree, int jobId);

    [DllImportAttribute("VISA32.DLL", EntryPoint = "#144", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]

    public static extern int viLock(int vi, int lockType, int timeout, string requestedKey, StringBuilder accessKey);

    [DllImportAttribute("VISA32.DLL", EntryPoint = "#145", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]

    public static extern int viUnlock(int vi);

    [DllImportAttribute("VISA32.DLL", EntryPoint = "#135", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]

    public static extern int viEnableEvent(int vi, int eventType, short mechanism, int context);

    [DllImportAttribute("VISA32.DLL", EntryPoint = "#136", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]

    public static extern int viDisableEvent(int vi, int eventType, short mechanism);

    [DllImportAttribute("VISA32.DLL", EntryPoint = "#137", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]

    public static extern int viDiscardEvents(int vi, int eventType, short mechanism);

    [DllImportAttribute("VISA32.DLL", EntryPoint = "#138", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]

    public static extern int viWaitOnEvent(int vi, int inEventType, int timeout, ref int outEventType, ref int outEventContext);

    [DllImportAttribute("VISA32.DLL", EntryPoint = "#139", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]

    public static extern int viInstallHandler(int vi, int eventType, object handler, int UserHandle);

    [DllImportAttribute("VISA32.DLL", EntryPoint = "#140", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]

    public static extern int viUninstallHandler(int vi, int eventType, object handler, int userHandle);

    #endregion

    #region - Basic I/O Operations --------------------------------------------------

    [DllImportAttribute("VISA32.DLL", EntryPoint = "#256", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]

    public static extern int viRead(int vi, byte[] buffer, int count, out int retCount);

    [DllImportAttribute("VISA32.DLL", EntryPoint = "#277", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]

    public static extern int viReadAsync(int vi, byte[] buffer, int count, out int jobId);

    [DllImportAttribute("VISA32.DLL", EntryPoint = "#219", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]

    public static extern int viReadToFile(int vi, string filename, int count, ref int retCount);

    [DllImportAttribute("VISA32.DLL", EntryPoint = "#257", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]

    public static extern int viWrite(int vi, byte[] buffer, int count, out int retCount);

    [DllImportAttribute("VISA32.DLL", EntryPoint = "#278", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]

    public static extern int viWriteAsync(int vi, byte[] buffer, int count, out int jobId);