using System; using System.Text; namespace OpenTap; /// /// Collection of all visa functions. /// public struct VisaFunctions { /// /// Event handler for visa events. /// public delegate int ViEventHandler(int vi, int eventType, int context, int userHandle); /// /// This function returns a session to the Default Resource Manager resource. /// This function must be called before any VISA functions can be invoked. /// The first call to this function initializes the VISA system, including the Default Resource Manager resource, and also returns a session to that resource. /// Subsequent calls to this function return unique sessions to the same Default Resource Manager resource. /// /// Unique logical identifier to a Default Resource Manager session. /// https://helpfiles.keysight.com/IO_Libraries_Suite/English/IOLS_Linux/VISA/Content/visa/viOpenDefaultRM.htm public delegate int ViOpenDefaultRmDelegate(out int sesn); /// public ViOpenDefaultRmDelegate ViOpenDefaultRmRef; /// /// This function queries a VISA system to locate the resources associated with a specified interface. /// This function matches the value specified in the expr parameter with the resources available for a particular interface. /// On successful completion, it returns the first resource found in the list and returns a count to indicate if there were more resources found that match the value specified in the expr parameter. /// /// Resource Manager session (should always be the Default Resource Manager for VISA returned from viOpenDefaultRM). /// This expression sets the criteria to search an interface or all interfaces for existing devices. /// Returns a handle identifying this search session. This handle will be used as an input in viFindNext. /// Number of matches. /// Returns a string identifying the location of a device. Strings can then be passed to viOpen to establish a session to the given device. /// https://helpfiles.keysight.com/IO_Libraries_Suite/English/IOLS_Linux/VISA/Content/visa/viFindRsrc.htm public delegate int ViFindRsrcDelegate(int sesn, string expr, out int findList, out int retCount, StringBuilder desc); /// public ViFindRsrcDelegate ViFindRsrcRef; /// /// This function returns the next resource found in the list created by viFindRsrc. /// The list is referenced by the handle that was returned by viFindRsrc. /// /// Describes a find list. This parameter must be created by viFindRsrc. /// Returns a string identifying location of a device. Strings can be passed to viOpen to establish a session to the device. /// https://helpfiles.keysight.com/IO_Libraries_Suite/English/IOLS_Linux/VISA/Content/visa/viFindNext.htm public delegate int ViFindNextDelegate(int findList, StringBuilder desc); /// public ViFindNextDelegate ViFindNextRef; /// /// Parse a resource string to get the interface information. /// This operation parses a resource string to verify its validity. /// It should succeed for all strings returned by viFindRsrc and recognized by viOpen. /// This operation is useful if you want to know what interface a given resource descriptor would use without actually opening a session to it. /// /// Resource Manager session (should always be the Default Resource Manager for VISA returned from ). /// Unique symbolic name (VISA address or VISA alias) of a resource. /// Interface type of the given resource string. /// Board number of the interface of the given resource string. /// https://helpfiles.keysight.com/IO_Libraries_Suite/English/IOLS_Linux/VISA/Content/visa/viParseRsrc.htm public delegate int ViParseRsrcDelegate(int sesn, string desc, ref short intfType, ref short intfNum); /// public ViParseRsrcDelegate ViParseRsrcRef; /// /// This function parses a resource string to get extended interface information. /// It should succeed for all strings returned by viFindRsrc and recognized by viOpen. /// This operation is useful if you want to know what interface a given VISA address (resource descriptor) would use without actually opening a session to it. /// /// Resource Manager session (should always be the Default Resource Manager for VISA returned from ). /// Unique symbolic name of a resource. /// Interface type of the given resource string. /// Board number of the interface of the given resource string. /// Specifies the resource class (for example, “INSTR”) of the given resource string, as defined in VISA Resource Classes. /// This is the expanded version of the given resource string. The format should be similar to the VISA-defined canonical resource name. /// Specifies the user-defined alias for the given resource string, if a VISA implementation allows aliases and an alias exists for the given resource string. /// https://helpfiles.keysight.com/IO_Libraries_Suite/English/IOLS_Linux/VISA/Content/visa/viParseRsrcEx.htm public delegate int ViParseRsrcExDelegate(int sesn, string desc, ref short intfType, ref short intfNum, StringBuilder rsrcClass, StringBuilder expandedUnaliasedName, StringBuilder aliasIfExists); /// public ViParseRsrcExDelegate ViParseRsrcExRef; /// /// This function opens a session to the specified device. It returns a session identifier that can be used to call any other functions to that device. /// /// Resource Manager session (should always be the Default Resource Manager for VISA returned from ). /// Unique symbolic name (VISA address) of a resource. Can also be a VISA alias (defined in the Keysight Connection Expert utility). /// /// Specifies the modes by which the resource is to be accessed. /// The value VI_EXCLUSIVE_LOCK is used to acquire an exclusive lock immediately upon opening a session. /// If a lock cannot be acquired, the session is closed and an error is returned. /// The VI_LOAD_CONFIG value is used to configure attributes specified by some external configuration utility. /// If this value is not used, the session uses the default values provided by this specification. /// Multiple access modes can be used simultaneously by specifying a "bit-wise OR" of the values. (Must use VI_NULL in VISA 1.0.) /// /// /// If the accessMode parameter requires a lock, /// this parameter specifies the absolute time period (in milliseconds) that the resource waits to get unlocked before this operation returns an error. /// Otherwise, this parameter is ignored. (Must use VI_NULL in VISA 1.0.) /// Note: The timeout parameter affects ONLY the LOCK; it does not impact the overall viOpen command timing. /// /// Unique logical identifier reference to a session. /// https://helpfiles.keysight.com/IO_Libraries_Suite/English/IOLS_Linux/VISA/Content/visa/viOpen.htm public delegate int ViOpenDelegate(int sesn, string viDesc, int accessMode, int timeout, out int vi); /// public ViOpenDelegate ViOpenRef; /// /// This function closes the specified resource manager session, device session, find list (returned from the viFindRsrc function), /// or event context (returned from the viWaitOnEvent function, or passed to an event handler). /// In this process, all the data structures that had been allocated for the specified vi are freed. /// /// Unique logical identifier to a session, event, or find list. /// https://helpfiles.keysight.com/IO_Libraries_Suite/English/IOLS_Linux/VISA/Content/visa/viClose.htm public delegate int ViCloseDelegate(int vi); /// public ViCloseDelegate ViCloseRef; /// /// This function retrieves the state of an attribute for the specified session. /// /// Unique logical identifier to a session, event, or find list. /// Resource attribute for which the state query is made. /// /// The state of the queried attribute for a specified resource. /// The interpretation of the returned value is defined by the individual resource. /// Note that you must allocate space for character strings returned. /// /// https://helpfiles.keysight.com/IO_Libraries_Suite/English/IOLS_Linux/VISA/Content/visa/viGetAttribute.htm public delegate int ViGetAttributeBDelegate(int vi, int attrName, out byte attrValue); /// public ViGetAttributeBDelegate ViGetAttribute1Ref; /// public delegate int ViGetAttributeSbDelegate(int vi, int attrName, StringBuilder attrValue); /// public ViGetAttributeSbDelegate ViGetAttribute2Ref; /// public delegate int ViGetAttributeIDelegate(int vi, int attrName, out int attrValue); /// public ViGetAttributeIDelegate ViGetAttribute3Ref; /// /// This function sets the state of an attribute for the specified session. /// The viSetAttribute operation is used to modify the state of an attribute for the specified session, event, or find list. /// /// Unique logical identifier to a session, event, or find list. /// Resource attribute for which the state is modified. /// The state of the attribute to be set for the specified resource. The interpretation of the individual attribute value is defined by the resource. /// https://helpfiles.keysight.com/IO_Libraries_Suite/English/IOLS_Linux/VISA/Content/visa/viSetAttribute.htm public delegate int ViSetAttributeBDelegate(int vi, int attrName, byte attrValue); /// public ViSetAttributeBDelegate ViSetAttribute1Ref; /// public delegate int ViSetAttributeIDelegate(int vi, int attrName, int attrValue); /// public ViSetAttributeIDelegate ViSetAttribute2Ref; /// /// This function returns a user-readable string that describes the status code passed to the function. /// If a status code cannot be interpreted by the session, viStatusDesc returns the warning VI_WARN_UNKNOWN_STATUS. /// /// Unique logical identifier to a session, event, or find list. /// Status code to interpret. /// The user-readable string interpretation of the status code passed to the function. Must be at least 256 characters to receive output. /// https://helpfiles.keysight.com/IO_Libraries_Suite/English/IOLS_Linux/VISA/Content/visa/viStatusDesc.htm public delegate int ViStatusDescDelegate(int vi, int status, StringBuilder desc); /// public ViStatusDescDelegate ViStatusDescRef; /// /// This function enables notification of an event identified by the eventType parameter for mechanisms specified in the mechanism parameter. /// The specified session can be enabled to queue events by specifying VI_QUEUE. /// /// Unique logical identifier to a session. /// Logical event identifier. /// /// Specifies event handling mechanisms to be enabled. /// The queuing mechanism is enabled by VI_QUEUE, and the callback mechanism is enabled by VI_HNDLR or VI_SUSPEND_HNDLR. /// It is possible to enable both mechanisms simultaneously by specifying "bit-wise OR" of VI_QUEUE and one of the two mode values for the callback mechanism. /// /// VI_NULL (Not used for VISA 1.0.) /// https://helpfiles.keysight.com/IO_Libraries_Suite/English/IOLS_Linux/VISA/Content/visa/viEnableEvent.htm public delegate int ViEnableEventDelegate(int vi, int eventType, short mechanism, int context); /// public ViEnableEventDelegate ViEnableEventRef; /// /// This function disables servicing of an event identified by the eventType parameter for the mechanisms specified in the mechanism parameter. /// Specifying VI_ALL_ENABLED_EVENTS for the eventType parameter allows a session to stop receiving all events. /// The session can stop receiving queued events by specifying VI_QUEUE. /// Applications can stop receiving callback events by specifying either VI_HNDLR or VI_SUSPEND_HNDLR. /// Specifying VI_ALL_MECH disables both the queuing and callback mechanisms. /// viDisableEvent prevents new event occurrences from being added to the queue(s). /// However, event occurrences already existing in the queue(s) are not discarded. /// /// Unique logical identifier to a session. /// Logical event identifier. /// /// Specifies event handling mechanisms to be disabled. The queuing mechanism is disabled by specifying VI_QUEUE. /// The callback mechanism is disabled by specifying VI_HNDLR or VI_SUSPEND_HNDLR. /// It is possible to disable both mechanisms simultaneously by specifying VI_ALL_MECH. /// /// https://helpfiles.keysight.com/IO_Libraries_Suite/English/IOLS_Linux/VISA/Content/visa/viDisableEvent.htm public delegate int ViDisableEventDelegate(int vi, int eventType, short mechanism); /// public ViDisableEventDelegate ViDisableEventRef; /// /// This function allows applications to install handlers on sessions for event callbacks. /// The handler specified in the handler parameter is installed along with previously installed handlers for the specified event. /// Applications can specify a value in the userHandle parameter that is passed to the handler on its invocation. /// /// Unique logical identifier to a session. /// Logical event identifier. /// Interpreted as a valid reference to a handler to be installed by an application. /// A value specified by an application that can be used for identifying handlers uniquely for an event type. /// https://helpfiles.keysight.com/IO_Libraries_Suite/English/IOLS_Linux/VISA/Content/visa/viInstallHandler.htm public delegate int ViInstallHandlerDelegate(int vi, int eventType, ViEventHandler handler, int userHandle); /// public ViInstallHandlerDelegate ViInstallHandlerRef; /// /// This function allows applications to uninstall handlers for events on sessions. /// Applications should also specify the value in the userHandle parameter that was passed to viInstallHandler while installing the handler. /// VISA identifies handlers uniquely using the handler reference and the userHandle. /// All the handlers or which the handler reference and the userHandle matches are uninstalled. /// /// Unique logical identifier to a session. /// Logical event identifier. /// Interpreted as a valid reference to a handler to be uninstalled by an application. /// A value specified by an application that can be used for identifying handlers uniquely in a session for an event. /// https://helpfiles.keysight.com/IO_Libraries_Suite/English/IOLS_Linux/VISA/Content/visa/viUninstallHandler.htm public delegate int ViUninstallHandlerDelegate(int vi, int eventType, ViEventHandler handler, int userHandle); /// public ViUninstallHandlerDelegate ViUninstallHandlerRef; /// /// This function waits for an occurrence of the specified event for a given session. /// In particular, this function suspends execution of an application thread and waits for an event inEventType for at least the time period specified by timeout. /// /// Unique logical identifier to a session. /// Logical identifier of the event(s) to wait for. /// /// Absolute time period in time units that the resource shall wait for a specified event to occur before returning the time elapsed error. /// The time unit is in milliseconds. /// /// Logical identifier of the event actually received. /// A handle specifying the unique occurrence of an event. /// https://helpfiles.keysight.com/IO_Libraries_Suite/English/IOLS_Linux/VISA/Content/visa/viWaitOnEvent.htm public delegate int ViWaitOnEventDelegate(int vi, int eventType, int timeout, out int outEventType, IntPtr outContext); /// public ViWaitOnEventDelegate ViWaitOnEventRef; /// /// This function synchronously transfers data from a device. /// The data that is read is stored in the buffer represented by buf. /// This function returns only when the transfer terminates. /// Only one synchronous read function can occur at any one time. /// /// Unique logical identifier to a session. /// Represents the location of a buffer to receive data from device. /// Number of bytes to be read. /// Represents the location of an integer that will be set to the number of bytes actually transferred. /// https://helpfiles.keysight.com/IO_Libraries_Suite/English/IOLS_Linux/VISA/Content/visa/viRead.htm public delegate int ViReadDelegate(int vi, ArraySegment buffer, int count, out int retCount); /// public ViReadDelegate ViReadRef; /// /// This function synchronously transfers data to a device. The data to be written is in the buffer represented by buf. This function returns only when the transfer terminates. Only one synchronous write function can occur at any one time. If you pass VI_NULL as the retCount parameter to the viWrite operation, the number of bytes transferred will not be returned. This may be useful if it is important to know only whether the operation succeeded or failed. /// /// Unique logical identifier of a session. /// Represents the location of a data block to be sent to device. /// Specifies number of bytes to be written. /// Represents the location of an integer that will be set to the number of bytes actually transferred. /// https://helpfiles.keysight.com/IO_Libraries_Suite/English/IOLS_Linux/VISA/Content/visa/viWrite.htm public delegate int ViWriteDelegate(int vi, ArraySegment buffer, int count, out int retCount); /// public ViWriteDelegate ViWriteRef; /// /// Read a status byte of the service request. /// This operation reads a service request status from a service requester (the message-based device). /// For example, on the IEEE 488.2 interface, the message is read by polling devices. /// For other types of interfaces, a message is sent in response to a service request to retrieve status information. /// /// Unique logical identifier to the session. /// Service request status byte. /// https://helpfiles.keysight.com/IO_Libraries_Suite/English/IOLS_Linux/VISA/Content/visa/viReadSTB.htm public delegate int ViReadStbDelegate(int vi, ref short status); /// public ViReadStbDelegate ViReadStbRef; /// /// Clear a device. This operation performs an IEEE 488.1-style clear of the device. /// /// Unique logical identifier to a session. public delegate int ViClearDelegate(int vi); /// public ViClearDelegate ViClearRef; /// /// This function is used to obtain a lock on the specified resource. /// The caller can specify the type of lock requested (exclusive or shared lock) and the length of time the operation will suspend while waiting to acquire the lock before timing out. /// This function can also be used for sharing and nesting locks. /// /// Unique logical identifier to a session. /// Specifies the type of lock requested, which can be VI_EXCLUSIVE_LOCK or VI_SHARED_LOCK. /// /// Absolute time period (in milliseconds) that a resource waits to get unlocked by the locking session before returning this operation with an error. /// VI_TMO_IMMEDIATE and VI_TMO_INFINITE are also valid values. /// /// /// This parameter is not used and should be set to VI_NULL when lockType is VI_EXCLUSIVE_LOCK (exclusive lock). /// When trying to lock the resource as VI_SHARED_LOCK (shared lock), a session can either set it to VI_NULL so that VISA generates an accessKey for the session, or the session can suggest an accessKey to use for the shared lock. /// /// /// This parameter should be set to VI_NULL when lockType is VI_EXCLUSIVE_LOCK (exclusive lock). /// When trying to lock the resource as VI_SHARED_LOCK (shared lock), the resource returns a unique access key for the lock if the operation succeeds. /// This accessKey can then be passed to other sessions to share the lock. /// /// https://helpfiles.keysight.com/IO_Libraries_Suite/English/IOLS_Linux/VISA/Content/visa/viLock.htm public delegate int ViLockDelegate(int vi, int lockType, int timeout, string requestedKey, StringBuilder accessKey); /// public ViLockDelegate ViLockRef; /// /// This function is used to relinquish a lock previously obtained using the function. /// /// Unique logical identifier to a session. /// https://helpfiles.keysight.com/IO_Libraries_Suite/English/IOLS_Linux/VISA/Content/visa/viUnlock.htm public delegate int ViUnlockDelegate(int vi); /// public ViUnlockDelegate ViUnlockRef; }