//                           UNCLASSIFIED
/*-------------------------------------------------------------------------
RAYTHEON PROPRIETARY: THIS DOCUMENT CONTAINS DATA OR INFORMATION
PROPRIETARY TO RAYTHEON COMPANY AND IS RESTRICTED TO USE ONLY BY PERSONS
AUTHORIZED BY RAYTHEON COMPANY IN WRITING TO USE IT. DISCLOSURE TO
UNAUTHORIZED PERSONS WOULD LIKELY CAUSE SUBSTANTIAL COMPETITIVE HARM TO
RAYTHEON COMPANY'S BUSINESS POSITION. NEITHER SAID DOCUMENT NOR ITS
CONTENTS SHALL BE FURNISHED OR DISCLOSED TO OR COPIED OR USED BY PERSONS
OUTSIDE RAYTHEON COMPANY WITHOUT THE EXPRESS WRITTEN APPROVAL OF RAYTHEON
COMPANY.

THIS PROPRIETARY NOTICE IS NOT APPLICABLE IF DELIVERED TO THE U.S.
GOVERNMENT.

UNPUBLISHED WORK - COPYRIGHT RAYTHEON COMPANY.
-------------------------------------------------------------------------*/

using System.Runtime.InteropServices;
using s32 = System.Int32;
using s16 = System.Int16;
using s8 = System.Byte;
using u32 = System.UInt32;
using u16 = System.UInt16;
using f64 = System.Double;
using ZT_ERROR = System.Int32;
using ZT_RSRC_NAME = System.String;
using ZT_HANDLE = System.IntPtr;

namespace Raytheon.Instruments
{
   /// <summary>
   /// InterOp interface to ZtScope Instrument Driver
   /// </summary>
   public class ScopeZtMNativeMethods
   {
      const string DLL_LOCATION = @"C:\Program Files (x86)\ZTEC Instruments\MClass\bin\ZtScopeM.dll";

      /*****************************************************************************/
      /*= Non-SCPI Function Prototypes ============================================*/
      /*****************************************************************************/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_num_of_chan(ZT_HANDLE instr_handle,
                                              [MarshalAs(UnmanagedType.I4)]out s32 input_channels,
                                              [MarshalAs(UnmanagedType.I4)]out s32 calc_channels,
                                              [MarshalAs(UnmanagedType.I4)]out s32 ref_channels);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_chassis_type(ZT_HANDLE instr_handle,
                                               s8[] chassis_type);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_card(ZT_RSRC_NAME resource_name,
                                       [MarshalAs(UnmanagedType.U2)]out u16 comm_bus,
                                       u32 count);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_initialize(ZT_RSRC_NAME resource_name,
                                             s32 id_query,
                                             s32 reset,
                                             [MarshalAs(UnmanagedType.SysInt)]out ZT_HANDLE instr_handle);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_initialize_dual(ZT_RSRC_NAME primary_resource_name,
                                                  ZT_RSRC_NAME secondary_resource_name,
                                                  [MarshalAs(UnmanagedType.SysInt)]out ZT_HANDLE instr_handle);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_init(ZT_RSRC_NAME resource_name,
                                       s32 id_query,
                                       s32 reset,
                                       u16 comm_bus,
                                       [MarshalAs(UnmanagedType.U4)]out u32 model_number,
                                       [MarshalAs(UnmanagedType.SysInt)]out ZT_HANDLE instr_handle);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_close(ZT_HANDLE instr_handle);

      /*****************************************************************************/
      /*= SCPI Function Prototypes ================================================*/
      /*****************************************************************************/
      /***************************************************************/
      /* Lone & Group Function Prototypes                            */
      /***************************************************************/
      /*** Configure ***/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_auto_setup(ZT_HANDLE instr_handle);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_memory_clear(ZT_HANDLE instr_handle);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_channel_enable(ZT_HANDLE instr_handle,
                                                 s32 channel,
                                                 s32 state);

      /** Horizontal **/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_horizontal(ZT_HANDLE instr_handle,
                                             u32 sample_points,
                                             f64 sample_time,
                                             f64 offset_time);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_horizontal_offset_reference(ZT_HANDLE instr_handle,
                                                              f64 offset_reference);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_horizontal_range_increment(ZT_HANDLE instr_handle,
                                                             s32 steps,
                                                             u32 nom_points,
                                                             [MarshalAs(UnmanagedType.U4)]out u32 actual_nom_points,
                                                             [MarshalAs(UnmanagedType.I4)]out s32 interpolating);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_horizontal_next_sample_rate(ZT_HANDLE instr_handle,
                                                              [MarshalAs(UnmanagedType.R8)]out f64 sample_rate,
                                                              s32 inc_type,
                                                               [MarshalAs(UnmanagedType.R8)]out f64 next_rate);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_input_delay(ZT_HANDLE instr_handle,
                                              s32 channel,
                                              f64 delay);

      /* Sample Clock */
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_clock_divider(ZT_HANDLE instr_handle,
                                                u32 divider);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_clock_source(ZT_HANDLE instr_handle,
                                               s32 source);

      /** Vertical **/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_vertical(ZT_HANDLE instr_handle,
                                   s32 channel,
                                   f64 range,
                                   f64 offset,
                                   s32 coupling,
                                   f64 impedance,
                                   s32 lowpass_filter,
                                   f64 attenuation);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_input_range_increment(ZT_HANDLE instr_handle,
                                                  s32 channel,
                                                  s32 steps);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_input_position(ZT_HANDLE instr_handle,
                                         s32 channel,
                                         f64 position);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_input_protection_state(ZT_HANDLE instr_handle,
                                                 s32 channel,
                                                 s32 prot_state);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_input_center_tap_state(ZT_HANDLE instr_handle,
                                                 s32 channel,
                                                 s32 state);

      /** Acquisition **/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_acquisition(ZT_HANDLE instr_handle,
                                      s32 acquire_type,
                                      s32 acquire_count,
                                      s32 initiate_continuously,
                                      s32 trigger_mode);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_average_view(ZT_HANDLE instr_handle,
                                       s32 view);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_envelope_view(ZT_HANDLE instr_handle,
                                        s32 view);

      /** Trigger **/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_arm(ZT_HANDLE instr_handle,
                              s32 arm_source,
                              s32 arm_polarity,
                              f64 level);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_trigger(ZT_HANDLE instr_handle,
                                  s32 trigger_source,
                                  f64 level,
                                  s32 slope);

      /* Advanced Trigger */
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_soft_trigger_a(ZT_HANDLE instr_handle);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_trigger_holdoff(ZT_HANDLE instr_handle,
                                          f64 holdoff,
                                          s32 event_count);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_trigger_pulse_width(ZT_HANDLE instr_handle,
                                              s32 source,
                                              f64 level,
                                              s32 type,
                                              f64 lower_limit,
                                              f64 upper_limit);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_trigger_pattern(ZT_HANDLE instr_handle,
                                          s32 pattern_mask,
                                          s32 pattern_truth);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_trigger_video(ZT_HANDLE instr_handle,
                                        s32 source,
                                        f64 level,
                                        s32 standard,
                                        s32 field,
                                        s32 line,
                                        s32 level_mode);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_trigger_glitch_limit(ZT_HANDLE instr_handle,
                                               f64 limit);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_trigger_b(ZT_HANDLE instr_handle,
                                    s32 state,
                                    s32 trigger_source,
                                    f64 level,
                                    s32 slope);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_trigger_b_holdoff(ZT_HANDLE instr_handle,
                                            f64 holdoff);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_trigger_b_event_count(ZT_HANDLE instr_handle,
                                                s32 event_count);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_trigger_noise_rejection_state(ZT_HANDLE instr_handle,
                                                       s32 trigger_source,
                                                       s32 state);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_input_external(ZT_HANDLE instr_handle,
                                        f64 level,
                                        f64 impedance);

      /** Fiducial **/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_fiducial_state(ZT_HANDLE instr_handle,
                                         s32 channel,
                                         s32 state);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_fiducial_source(ZT_HANDLE instr_handle,
                                          s32 source);

      /** Output **/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_output_external(ZT_HANDLE instr_handle,
                                          s32 state,
                                          s32 source,
                                          s32 polarity,
                                          s32 pulse_mode,
                                          f64 pulse_period);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_output_trigger(ZT_HANDLE instr_handle,
                                         s32 trigger_output,
                                         s32 state,
                                         s32 source,
                                         s32 polarity);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_output_trigger_mode(ZT_HANDLE instr_handle,
                                              s32 trigger_output,
                                              s32 mode);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_output_event_time(ZT_HANDLE instr_handle,
                                            f64 seconds);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_output_reference_oscillator(ZT_HANDLE instr_handle,
                                                      s32 state,
                                                      s32 reference_source);

      /** Segment **/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_segment_view(ZT_HANDLE instr_handle,
                                       s32 segment_number);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_segment_mode(ZT_HANDLE instr_handle,
                                       s32 memory_mode);

      /*** Calculate ***/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calculate_immediate(ZT_HANDLE instr_handle,
                                              s32 calc_channel);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calc_channel_enable(ZT_HANDLE instr_handle,
                                              s32 calc_channel,
                                              s32 state);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calc_channel_format(ZT_HANDLE instr_handle,
                                              s32 calc_channel,
                                              s32 format);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calculate_function(ZT_HANDLE instr_handle,
                                             s32 calculation_channel,
                                             s32 operation,
                                             s32 source1,
                                             s32 source2,
                                             s32 range_offset_mode,
                                             f64 range,
                                             f64 offset);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calculate_position(ZT_HANDLE instr_handle,
                                             s32 calculation_channel,
                                             f64 position);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calculate_fft(ZT_HANDLE instr_handle,
                                        s32 calculation_channel,
                                        s32 source,
                                        s32 window);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calculate_time_transform(ZT_HANDLE instr_handle,
                                                   s32 calculation_channel,
                                                   s32 source,
                                                   s32 points);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calculate_limit_test(ZT_HANDLE instr_handle,
                                               s32 calculation_channel,
                                               s32 source,
                                               s32 measurement,
                                               f64 lower_limit,
                                               f64 upper_limit,
                                               u32 count);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calculate_mask_test(ZT_HANDLE instr_handle,
                                              s32 calculation_channel,
                                              s32 source,
                                              s32 lower_reference,
                                              s32 upper_reference,
                                              u32 count);

      /** Advanced Limit Test **/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calculate_limit_test_clear(ZT_HANDLE instr_handle,
                                                     s32 calculation_channel);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calculate_limit_test_event(ZT_HANDLE instr_handle,
                                                     [MarshalAs(UnmanagedType.I4)]out s32 limit_event_state);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calculate_limit_test_fail(ZT_HANDLE instr_handle,
                                                    s32 calculation_channel,
                                                    [MarshalAs(UnmanagedType.I4)]out s32 fail_state);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calculate_limit_test_report(ZT_HANDLE instr_handle,
                                                      s32 calculation_channel,
                                                      [MarshalAs(UnmanagedType.U4)]out u32 count,
                                                      [MarshalAs(UnmanagedType.U4)]out u32 fail,
                                                      [MarshalAs(UnmanagedType.R8)]out f64 min,
                                                      [MarshalAs(UnmanagedType.R8)]out f64 max,
                                                      [MarshalAs(UnmanagedType.R8)]out f64 average,
                                                      [MarshalAs(UnmanagedType.R8)]out f64 std_dev,
                                                      [MarshalAs(UnmanagedType.R8)]out f64 last);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calculate_mask_test_method(ZT_HANDLE instr_handle,
                                                     s32 calculation_channel,
                                                     s32 method);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calculate_mask_test_gate(ZT_HANDLE instr_handle,
                                                   s32 calculation_channel,
                                                   s32 gate_type,
                                                   f64 start,
                                                   f64 stop);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calculate_mask_test_vertical_offset(ZT_HANDLE instr_handle,
                                                              f64 offset);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calculate_mask_test_horizontal_offset(ZT_HANDLE instr_handle,
                                                                f64 offset);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calculate_mask_test_generate_masks(ZT_HANDLE instr_handle,
                                                             s32 calculation_channel,
                                                             [MarshalAs(UnmanagedType.I4)]out s32 result);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calculate_measurement(ZT_HANDLE instr_handle,
                                                s32 calculation_channel,
                                                s32 source,
                                                s32 type);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calculate_measure_clear(ZT_HANDLE instr_handle,
                                                  s32 calculation_channel);

      /*** Reference ***/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_reference_enable(ZT_HANDLE instr_handle,
                                           s32 reference_channel,
                                           s32 state);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_reference_range(ZT_HANDLE instr_handle,
                                          s32 reference_channel,
                                          f64 range);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_reference_position(ZT_HANDLE instr_handle,
                                          s32 reference_channel,
                                          f64 position);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_reference_offset(ZT_HANDLE instr_handle,
                                           s32 reference_channel,
                                           f64 offset);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_reference_format(ZT_HANDLE instr_handle,
                                           s32 reference_channel,
                                           s32 format);

      /*** Measurement ***/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_measure_status(ZT_HANDLE instr_handle,
                                         s32 state);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_measure_immediate(ZT_HANDLE instr_handle,
                                            s32 measurement,
                                            s32 source,
                                            [MarshalAs(UnmanagedType.R8)]out f64 result);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_measure_immediate_status(ZT_HANDLE instr_handle,
                                                   s32 measurement,
                                                   s32 source,
                                                   [MarshalAs(UnmanagedType.R8)]out f64 result,
                                                   [MarshalAs(UnmanagedType.U2)]out u16 status);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_measure_nth_maximum(ZT_HANDLE instr_handle,
                                              s32 number);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_measure_method(ZT_HANDLE instr_handle,
                                         s32 method,
                                         s32 gate_type,
                                         f64 gate_start,
                                         f64 gate_stop,
                                         s32 edge_number);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_measure_reference(ZT_HANDLE instr_handle,
                                            s32 reference_method,
                                            f64 low_reference,
                                            f64 mid_reference,
                                            f64 high_reference);

      /** Measurement Lists **/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_measure_list_enable(ZT_HANDLE instr_handle,
                                              s32 list_number,
                                              s32 state);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_measure_list_report(ZT_HANDLE instr_handle,
                                              s32 list_number,
                                              [MarshalAs(UnmanagedType.R8)]out f64 result);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_measure_list_report_status(ZT_HANDLE instr_handle,
                                                     s32 list_number,
                                                     [MarshalAs(UnmanagedType.R8)]out f64 result,
                                                     [MarshalAs(UnmanagedType.U2)]out u16 status);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_measure_list_measurement(ZT_HANDLE instr_handle,
                                                   s32 list_number,
                                                   s32 meas_number,
                                                   s32 source,
                                                   s32 measurement);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_measure_list_clear(ZT_HANDLE instr_handle,
                                             s32 list_number);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_measure_list_measurement_clear(ZT_HANDLE instr_handle,
                                                         s32 list_number,
                                                         s32 measurement_number);

      /** Cursors **/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_cursors_source(ZT_HANDLE instr_handle,
                                         s32 source);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_cursors(ZT_HANDLE instr_handle,
                                  f64 cursor1_time,
                                  f64 cursor1_magnitude,
                                  f64 cursor2_time,
                                  f64 cursor2_magnitude);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_cursors_snap(ZT_HANDLE instr_handle,
                                       s32 state);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_measure_cursors(ZT_HANDLE instr_handle,
                                          [MarshalAs(UnmanagedType.R8)]out f64 cursor1_time,
                                          [MarshalAs(UnmanagedType.R8)]out f64 cursor1_magnitude,
                                          [MarshalAs(UnmanagedType.R8)]out f64 cursor2_time,
                                          [MarshalAs(UnmanagedType.R8)]out f64 cursor2_magnitude,
                                          [MarshalAs(UnmanagedType.R8)]out f64 delta_time,
                                          [MarshalAs(UnmanagedType.R8)]out f64 delta_magnitude);

      /*** Operate ***/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_abort(ZT_HANDLE instr_handle);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_capture_waveform(ZT_HANDLE instr_handle,
                                           s32 timeout);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_initiate(ZT_HANDLE instr_handle);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_soft_arm(ZT_HANDLE instr_handle,
                                   s32 arm_state);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_soft_trigger(ZT_HANDLE instr_handle);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_trigger_timestamp(ZT_HANDLE instr_handle,
                                            [MarshalAs(UnmanagedType.R8)]out f64 time_stamp);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_arm_state_query(ZT_HANDLE instr_handle,
                                          [MarshalAs(UnmanagedType.I4)]out s32 state);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_capture_complete_query(ZT_HANDLE instr_handle,
                                                 [MarshalAs(UnmanagedType.I4)]out s32 state);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_trigger_event_query(ZT_HANDLE instr_handle,
                                              [MarshalAs(UnmanagedType.I4)]out s32 state);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_auto_synch(ZT_HANDLE instr_handle);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_auto_zoom(ZT_HANDLE instr_handle,
                                    f64 start,
                                    f64 stop);

      /*** Waveform ***/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_read_waveform(ZT_HANDLE instr_handle,
                                        s32 source,
                                        f64[] waveform,
                                        f64[] time_array,
                                        s32 transfer_type);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_download_record(ZT_HANDLE instr_handle,
                                          s32 source,
                                          u32 points,
                                          f64 start_time,
                                          f64 stop_time,
                                          out s16[] waveform,
                                          //void* waveform,
                                          s32 transfer_type);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_read_waveform_preamble(ZT_HANDLE instr_handle,
                                                 s32 source,
                                                 [MarshalAs(UnmanagedType.I4)]out s32 type,
                                                 [MarshalAs(UnmanagedType.U4)]out u32 points,
                                                 [MarshalAs(UnmanagedType.I4)]out s32 acquisition_count,
                                                 [MarshalAs(UnmanagedType.R8)]out f64 time_interval,
                                                 [MarshalAs(UnmanagedType.R8)]out f64 time_offset,
                                                 [MarshalAs(UnmanagedType.R8)]out f64 voltage_interval,
                                                 [MarshalAs(UnmanagedType.R8)]out f64 voltage_offset);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_store_reference_waveform(ZT_HANDLE instr_handle,
                                                   s32 reference_channel,
                                                   s32 source);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_load_waveform(ZT_HANDLE instr_handle,
                                        s32 ref_channel,
                                        f64[] waveform,
                                        s32 type,
                                        u32 points,
                                        s32 count,
                                        s32 transfer_type,
                                        f64 time_interval,
                                        f64 time_offset,
                                        f64 voltage_interval,
                                        f64 voltage_offset);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_upload_record(ZT_HANDLE instr_handle,
                                        s32 ref_channel,
                                        f64[] waveform, //void* waveform,
                                        s32 type,
                                        u32 points,
                                        s32 count,
                                        s32 transfer_type,
                                        f64 time_interval,
                                        f64 time_offset,
                                        f64 voltage_interval,
                                        f64 voltage_offset);

      /** Advanced Waveform **/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_format_data(ZT_HANDLE instr_handle,
                                      s32 format_type,
                                      s32 length);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_format_precision(ZT_HANDLE instr_handle,
                                           u16 mantissa,
                                           u16 exponent);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_interpolation(ZT_HANDLE instr_handle,
                                        s32 format);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_interleaving(ZT_HANDLE instr_handle,
                                       [MarshalAs(UnmanagedType.I4)]out s32 interleaving);

      /*** Utilities ***/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_device_clear(ZT_HANDLE instr_handle);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_errors(ZT_HANDLE instr_handle,
                                 out s32 number_of_errors,
                                 s32[] errors);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_error_count(ZT_HANDLE instr_handle,
                                      [MarshalAs(UnmanagedType.I4)]out s32 number_of_errors);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_error_next(ZT_HANDLE instr_handle,
                                      [MarshalAs(UnmanagedType.I4)]out s32 error_code);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_error_report(ZT_HANDLE instr_handle,
                                       [MarshalAs(UnmanagedType.I1)]out s8 report);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern void ztscopeM_error_description(s32 code, s8[] description);
      //s8 description[]);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_operation_complete(ZT_HANDLE instr_handle,
                                             [MarshalAs(UnmanagedType.I4)]out s32 state);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_wait_operation_complete(ZT_HANDLE instr_handle);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_enable_operation_complete(ZT_HANDLE instr_handle);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_reset(ZT_HANDLE instr_handle);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_save_recall_state(ZT_HANDLE instr_handle,
                                            s32 state,
                                            s32 state_number);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_undo(ZT_HANDLE instr_handle);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_self_test(ZT_HANDLE instr_handle,
                                    [MarshalAs(UnmanagedType.I4)]out s32 self_test_status);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_self_test_dual(ZT_HANDLE instr_handle,
                                         [MarshalAs(UnmanagedType.I4)]out s32 primary_self_test_status,
                                         [MarshalAs(UnmanagedType.I4)]out s32 secondary_self_test_status);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_test_count(ZT_HANDLE instr_handle,
                                     s32 test_log,
                                     [MarshalAs(UnmanagedType.I4)]out s32 number_of_reports);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_test_report(ZT_HANDLE instr_handle,
                                      s32 test_log,
                                      [MarshalAs(UnmanagedType.I1)]out s8 report);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_initiate_query(ZT_HANDLE instr_handle,
                                         [MarshalAs(UnmanagedType.I4)]out s32 initiated);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_temperature(ZT_HANDLE instr_handle,
                                      [MarshalAs(UnmanagedType.R8)]out f64 temperature);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_temperature_dual(ZT_HANDLE instr_handle,
                                          [MarshalAs(UnmanagedType.R8)]out f64 primary_temperature,
                                          [MarshalAs(UnmanagedType.R8)]out f64 secondary_temperature);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_versions(ZT_HANDLE instr_handle,
                                   s8[] id,
                                   s8[] driver_rev,
                                   s32[] configuration);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_accessory_id(ZT_HANDLE instr_handle,
                                       s32 channel,
                                       [MarshalAs(UnmanagedType.I1)]out s8 id_string);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_clear_status(ZT_HANDLE instr_handle);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_status_preset(ZT_HANDLE instr_handle);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_status(ZT_HANDLE instr_handle,
                                 s32 register_type,
                                 [MarshalAs(UnmanagedType.I4)]out s32 status_register,
                                 [MarshalAs(UnmanagedType.I4)]out s32 frequency_register,
                                 [MarshalAs(UnmanagedType.I4)]out s32 test_register,
                                 [MarshalAs(UnmanagedType.I4)]out s32 operation_register,
                                 [MarshalAs(UnmanagedType.I4)]out s32 standard_register,
                                 [MarshalAs(UnmanagedType.I4)]out s32 questionable_register,
                                 [MarshalAs(UnmanagedType.I4)]out s32 voltage_register,
                                 [MarshalAs(UnmanagedType.I4)]out s32 calibration_register,
                                 [MarshalAs(UnmanagedType.I4)]out s32 dig1_register,
                                 [MarshalAs(UnmanagedType.I4)]out s32 dig2_register);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_event_status_enable(ZT_HANDLE instr_handle,
                                              s32 status_register,
                                              s32 frequency_register,
                                              s32 test_register,
                                              s32 operation_register,
                                              s32 standard_register,
                                              s32 questionable_register,
                                              s32 voltage_register,
                                              s32 calibration_register,
                                              s32 dig1_register,
                                              s32 dig2_register);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_system_restore(ZT_HANDLE instr_handle,
                                         u16 state);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_memory(ZT_HANDLE instr_handle,
                                 [MarshalAs(UnmanagedType.I4)]out s32 bytes);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_reference_oscillator_frequency(ZT_HANDLE instr_handle,
                                                         [MarshalAs(UnmanagedType.R8)]out f64 frequency);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_identification_led(ZT_HANDLE instr_handle,
                                             s32 state);

      /** Calibrate **/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calibrate(ZT_HANDLE instr_handle,
                                    [MarshalAs(UnmanagedType.I4)]out s32 result);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calibrate_automatic(ZT_HANDLE instr_handle,
                                              s32 type);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calibrate_date(ZT_HANDLE instr_handle,
                                         [MarshalAs(UnmanagedType.U2)]out u16 month,
                                         [MarshalAs(UnmanagedType.U2)]out u16 day,
                                         [MarshalAs(UnmanagedType.U2)]out u16 year);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calibrate_save(ZT_HANDLE instr_handle);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calibrate_restore(ZT_HANDLE instr_handle);

      /* Defaults*/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calibrate_default(ZT_HANDLE instr_handle);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calibrate_external_default(ZT_HANDLE instr_handle);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calibrate_reference_oscillator_default(ZT_HANDLE instr_handle);

      /* Set*/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calibrate_adc_set_code(ZT_HANDLE instr_handle,
                                                 s32 input_channel,
                                                 u16 gain_code);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calibrate_delay_code(ZT_HANDLE instr_handle,
                                               s32 input_channel,
                                               s16 del_code);

      /* Adjust*/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calibrate_gain_adjust(ZT_HANDLE instr_handle,
                                                s32 input_channel,
                                                f64 range,
                                                f64 impedance,
                                                s32 filter,
                                                f64 frac_error);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calibrate_external_adjust(ZT_HANDLE instr_handle,
                                                    f64 frac_error);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calibrate_reference_oscillator_adjust(ZT_HANDLE instr_handle,
                                                               s32 clk_error);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calibrate_impedance_adjust(ZT_HANDLE instr_handle,
                                                    s32 input_channel,
                                                    f64 frac_error);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calibrate_input_adjust(ZT_HANDLE instr_handle,
                                                 s32 input_channel,
                                                 f64 frac_error);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calibrate_range_adjust(ZT_HANDLE instr_handle,
                                                 s32 input_channel,
                                                 f64 frac_error);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calibrate_trigger_gain_adjust(ZT_HANDLE instr_handle,
                                                        s32 input_channel,
                                                        f64 frac_error);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calibrate_trigger_zero_adjust(ZT_HANDLE instr_handle,
                                                        s32 input_channel,
                                                        f64 zero_error);

      /* Query */
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calibrate_automatic_query(ZT_HANDLE instr_handle,
                                                    [MarshalAs(UnmanagedType.I4)]out s32 result);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calibrate_adc_data_query(ZT_HANDLE instr_handle,
                                                   s32 interleave,
                                                   [MarshalAs(UnmanagedType.U2)]out u16 i_zero_code,
                                                   [MarshalAs(UnmanagedType.U2)]out u16 i_gain_code,
                                                   [MarshalAs(UnmanagedType.U2)]out u16 q_zero_code,
                                                   [MarshalAs(UnmanagedType.U2)]out u16 q_gain_code);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calibrate_adc_table_data_query(ZT_HANDLE instr_handle,
                                                         s32 input_channel,
                                                         s32 table_index,
                                                         [MarshalAs(UnmanagedType.U2)]out u16 scale_factor,
                                                         [MarshalAs(UnmanagedType.U2)]out u16 adc_code);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calibrate_gain_data_query(ZT_HANDLE instr_handle,
                                                    s32 input_channel,
                                                    f64 range,
                                                    f64 impedance,
                                                    s32 filter,
                                                    [MarshalAs(UnmanagedType.U2)]out u16 gain_code);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calibrate_offset_data_query(ZT_HANDLE instr_handle,
                                                      s32 input_channel,
                                                      f64 range,
                                                      f64 impedance,
                                                      s32 filter,
                                                      [MarshalAs(UnmanagedType.U2)]out u16 zero_code,
                                                      [MarshalAs(UnmanagedType.U2)]out u16 gain_code);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calibrate_poffset_data_query(ZT_HANDLE instr_handle,
                                                       s32 input_channel,
                                                       [MarshalAs(UnmanagedType.U2)]out u16 zero_code);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calibrate_trigger_data_query(ZT_HANDLE instr_handle,
                                                       s32 input_channel,
                                                       [MarshalAs(UnmanagedType.U2)]out u16 zero_code,
                                                       [MarshalAs(UnmanagedType.U2)]out u16 gain_code);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calibrate_external_data_query(ZT_HANDLE instr_handle,
                                                        [MarshalAs(UnmanagedType.U2)]out u16 zero_code,
                                                        [MarshalAs(UnmanagedType.U2)]out u16 gain_code);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calibrate_reference_oscillator_data_query(ZT_HANDLE instr_handle,
                                                                    [MarshalAs(UnmanagedType.U2)]out u16 vcxo_code);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calibrate_reference_frequency_query(ZT_HANDLE instr_handle,
                                                              [MarshalAs(UnmanagedType.U4)]out u32 ref_frequency);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calibrate_impedance_data_query(ZT_HANDLE instr_handle,
                                                        s32 input_channel,
                                                        [MarshalAs(UnmanagedType.U2)]out u16 gain_code);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calibrate_input_data_query(ZT_HANDLE instr_handle,
                                                     s32 input_channel,
                                                     [MarshalAs(UnmanagedType.U2)]out u16 path_offset_code,
                                                     [MarshalAs(UnmanagedType.U2)]out u16 path_gain_code);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calibrate_range_data_query(ZT_HANDLE instr_handle,
                                                     s32 input_channel,
                                                     [MarshalAs(UnmanagedType.U2)]out u16 zero_code,
                                                     [MarshalAs(UnmanagedType.U2)]out u16 gain_code);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calibrate_delay_code_query(ZT_HANDLE instr_handle,
                                                     s32 input_channel,
                                                     [MarshalAs(UnmanagedType.I2)]out s16 del_code);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calibrate_skew_query(ZT_HANDLE instr_handle,
                                              s16[] align_score);

      /**************************************/
      /**********  Read back  ****************/

      /*** Configure ***/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_channel_query(ZT_HANDLE instr_handle,
                                        s32 channel,
                                        [MarshalAs(UnmanagedType.I4)]out s32 state);

      /**  Horizontal **/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_horizontal_query(ZT_HANDLE instr_handle,
                                           [MarshalAs(UnmanagedType.U4)]out u32 sample_points,
                                           [MarshalAs(UnmanagedType.R8)]out f64 sample_time,
                                           [MarshalAs(UnmanagedType.R8)]out f64 offset_time);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_horizontal_offset_reference_query(ZT_HANDLE instr_handle,
                                                            [MarshalAs(UnmanagedType.R8)]out f64 offset_reference);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_horizontal_sample_rate_query(ZT_HANDLE instr_handle,
                                                       [MarshalAs(UnmanagedType.R8)]out f64 sample_rate);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_horizontal_interval_query(ZT_HANDLE instr_handle,
                                                    [MarshalAs(UnmanagedType.R8)]out f64 interval);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_input_delay_query(ZT_HANDLE instr_handle,
                                            s32 channel,
                                            [MarshalAs(UnmanagedType.R8)]out f64 delay);

      /* Sample Clock */
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_clock_divider_query(ZT_HANDLE instr_handle,
                                              [MarshalAs(UnmanagedType.U4)]out u32 divider);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_clock_source_query(ZT_HANDLE instr_handle,
                                             [MarshalAs(UnmanagedType.I4)]out s32 source);

      /** Vertical **/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_vertical_query(ZT_HANDLE instr_handle,
                                         s32 channel,
                                         [MarshalAs(UnmanagedType.R8)]out f64 range,
                                         [MarshalAs(UnmanagedType.R8)]out f64 offset,
                                         [MarshalAs(UnmanagedType.I4)]out s32 coupling,
                                         [MarshalAs(UnmanagedType.R8)]out f64 impedance,
                                         [MarshalAs(UnmanagedType.I4)]out s32 lowpass_filter,
                                         [MarshalAs(UnmanagedType.R8)]out f64 attenuation);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_input_position_query(ZT_HANDLE instr_handle,
                                               s32 channel,
                                               [MarshalAs(UnmanagedType.R8)]out f64 position);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_input_protection_state_query(ZT_HANDLE instr_handle,
                                                       s32 channel,
                                                       [MarshalAs(UnmanagedType.I4)]out s32 prot_state);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_input_center_tap_state_query(ZT_HANDLE instr_handle,
                                                       s32 channel,
                                                       [MarshalAs(UnmanagedType.I4)]out s32 state);

      /** Acquisition **/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_acquisition_query(ZT_HANDLE instr_handle,
                                            [MarshalAs(UnmanagedType.I4)]out s32 acquire_type,
                                            [MarshalAs(UnmanagedType.I4)]out s32 acquire_count,
                                            [MarshalAs(UnmanagedType.I4)]out s32 initiate_continuously,
                                            [MarshalAs(UnmanagedType.I4)]out s32 trigger_mode);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_average_view_query(ZT_HANDLE instr_handle,
                                             [MarshalAs(UnmanagedType.I4)]out s32 view);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_envelope_view_query(ZT_HANDLE instr_handle,
                                              [MarshalAs(UnmanagedType.I4)]out s32 view);

      /** Trigger **/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_arm_query(ZT_HANDLE instr_handle,
                                    [MarshalAs(UnmanagedType.I4)]out s32 arm_source,
                                    [MarshalAs(UnmanagedType.I4)]out s32 arm_polarity,
                                    [MarshalAs(UnmanagedType.R8)]out f64 level);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_trigger_query(ZT_HANDLE instr_handle,
                                        [MarshalAs(UnmanagedType.I4)]out s32 trigger_source,
                                        [MarshalAs(UnmanagedType.R8)]out f64 level,
                                        [MarshalAs(UnmanagedType.I4)]out s32 slope,
                                        [MarshalAs(UnmanagedType.I4)]out s32 type);

      /* Advanced Trigger */
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_trigger_holdoff_query(ZT_HANDLE instr_handle,
                                                [MarshalAs(UnmanagedType.R8)]out f64 holdoff,
                                                [MarshalAs(UnmanagedType.I4)]out s32 event_count);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_trigger_analog_location_query(ZT_HANDLE instr_handle,
                                                        [MarshalAs(UnmanagedType.R8)]out f64 trigger_location);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_trigger_pulse_width_query(ZT_HANDLE instr_handle,
                                                    [MarshalAs(UnmanagedType.I4)]out s32 source,
                                                    [MarshalAs(UnmanagedType.R8)]out f64 level,
                                                    [MarshalAs(UnmanagedType.I4)]out s32 type,
                                                    [MarshalAs(UnmanagedType.R8)]out f64 lower_limit,
                                                    [MarshalAs(UnmanagedType.R8)]out f64 upper_limit);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_trigger_pattern_query(ZT_HANDLE instr_handle,
                                                [MarshalAs(UnmanagedType.I4)]out s32 pattern_mask,
                                                [MarshalAs(UnmanagedType.I4)]out s32 pattern_truth,
                                                [MarshalAs(UnmanagedType.I4)]out s32 type);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_trigger_video_query(ZT_HANDLE instr_handle,
                                              [MarshalAs(UnmanagedType.I4)]out s32 source,
                                              [MarshalAs(UnmanagedType.R8)]out f64 level,
                                              [MarshalAs(UnmanagedType.I4)]out s32 standard,
                                              [MarshalAs(UnmanagedType.I4)]out s32 field,
                                              [MarshalAs(UnmanagedType.I4)]out s32 line,
                                              [MarshalAs(UnmanagedType.I4)]out s32 type);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_trigger_glitch_limit_query(ZT_HANDLE instr_handle,
                                                     [MarshalAs(UnmanagedType.R8)]out f64 limit);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_trigger_b_query(ZT_HANDLE instr_handle,
                                          [MarshalAs(UnmanagedType.I4)]out s32 state,
                                          [MarshalAs(UnmanagedType.I4)]out s32 trigger_source,
                                          [MarshalAs(UnmanagedType.R8)]out f64 level,
                                          [MarshalAs(UnmanagedType.I4)]out s32 slope);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_trigger_b_holdoff_query(ZT_HANDLE instr_handle,
                                                  [MarshalAs(UnmanagedType.R8)]out f64 holdoff);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_trigger_b_event_count_query(ZT_HANDLE instr_handle,
                                                      [MarshalAs(UnmanagedType.I4)]out s32 event_count);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_trigger_noise_rejection_state_query(ZT_HANDLE instr_handle,
                                                             s32 trigger_source,
                                                             [MarshalAs(UnmanagedType.I4)]out s32 state);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_input_external_query(ZT_HANDLE instr_handle,
                                               [MarshalAs(UnmanagedType.R8)]out f64 level,
                                               [MarshalAs(UnmanagedType.R8)]out f64 impedance);

      /** Fiducial **/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_fiducial_state_query(ZT_HANDLE instr_handle,
                                               s32 channel,
                                               [MarshalAs(UnmanagedType.I4)]out s32 state);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_fiducial_source_query(ZT_HANDLE instr_handle,
                                                [MarshalAs(UnmanagedType.I4)]out s32 source);

      /** Output **/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_output_external_query(ZT_HANDLE instr_handle,
                                                [MarshalAs(UnmanagedType.I4)]out s32 state,
                                                [MarshalAs(UnmanagedType.I4)]out s32 source,
                                                [MarshalAs(UnmanagedType.I4)]out s32 polarity,
                                                [MarshalAs(UnmanagedType.I4)]out s32 pulse_mode,
                                                [MarshalAs(UnmanagedType.R8)]out f64 pulse_period);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_output_event_time_query(ZT_HANDLE instr_handle,
                                                  [MarshalAs(UnmanagedType.R8)]out f64 seconds);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_output_trigger_query(ZT_HANDLE instr_handle,
                                               s32 trigger_output,
                                               [MarshalAs(UnmanagedType.I4)]out s32 state,
                                               [MarshalAs(UnmanagedType.I4)]out s32 source,
                                               [MarshalAs(UnmanagedType.I4)]out s32 polarity);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_output_trigger_mode_query(ZT_HANDLE instr_handle,
                                                      s32 trigger_output,
                                                      [MarshalAs(UnmanagedType.I4)]out s32 mode);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_input_trigger_query(ZT_HANDLE instr_handle,
                                              s32 trigger_output,
                                              [MarshalAs(UnmanagedType.I4)]out s32 state);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_output_reference_oscillator_query(ZT_HANDLE instr_handle,
                                                            [MarshalAs(UnmanagedType.I4)]out s32 state,
                                                            [MarshalAs(UnmanagedType.I4)]out s32 reference_source);

      /** Segment **/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_segment_view_query(ZT_HANDLE instr_handle,
                                             [MarshalAs(UnmanagedType.I4)]out s32 segment_number);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_segment_mode_query(ZT_HANDLE instr_handle,
                                             [MarshalAs(UnmanagedType.I4)]out s32 memory_mode);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_segment_count_query(ZT_HANDLE instr_handle,
                                              [MarshalAs(UnmanagedType.I4)]out s32 segments);

      /*** Calculate ***/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calc_channel_query(ZT_HANDLE instr_handle,
                                             s32 channel,
                                             [MarshalAs(UnmanagedType.I4)]out s32 state);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calc_channel_format_query(ZT_HANDLE instr_handle,
                                                    s32 channel,
                                                    [MarshalAs(UnmanagedType.I4)]out s32 format);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calculate_function_query(ZT_HANDLE instr_handle,
                                                   s32 calculation_channel,
                                                   [MarshalAs(UnmanagedType.I4)]out s32 operation,
                                                   [MarshalAs(UnmanagedType.I4)]out s32 source1,
                                                   [MarshalAs(UnmanagedType.I4)]out s32 source2,
                                                   [MarshalAs(UnmanagedType.R8)]out f64 range,
                                                   [MarshalAs(UnmanagedType.R8)]out f64 offset);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calculate_position_query(ZT_HANDLE instr_handle,
                                                   s32 calculation_channel,
                                                   [MarshalAs(UnmanagedType.R8)]out f64 position);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calculate_fft_query(ZT_HANDLE instr_handle,
                                              s32 calculation_channel,
                                              [MarshalAs(UnmanagedType.I4)]out s32 source,
                                              [MarshalAs(UnmanagedType.I4)]out s32 window);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calculate_time_transform_query(ZT_HANDLE instr_handle,
                                                         s32 calculation_channel,
                                                         [MarshalAs(UnmanagedType.I4)]out s32 source,
                                                         [MarshalAs(UnmanagedType.I4)]out s32 points);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calculate_limit_test_query(ZT_HANDLE instr_handle,
                                                     s32 calculation_channel,
                                                     [MarshalAs(UnmanagedType.I4)]out s32 source,
                                                     [MarshalAs(UnmanagedType.I4)]out s32 measurement,
                                                     [MarshalAs(UnmanagedType.R8)]out f64 lower_limit,
                                                     [MarshalAs(UnmanagedType.R8)]out f64 upper_limit,
                                                     [MarshalAs(UnmanagedType.U4)]out u32 count);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calculate_mask_test_query(ZT_HANDLE instr_handle,
                                                    s32 calculation_channel,
                                                    [MarshalAs(UnmanagedType.I4)]out s32 source,
                                                    [MarshalAs(UnmanagedType.I4)]out s32 lower_reference,
                                                    [MarshalAs(UnmanagedType.I4)]out s32 upper_reference,
                                                    [MarshalAs(UnmanagedType.U4)]out u32 count);

      /* Advanced Limit Test */
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calculate_mask_test_method_query(ZT_HANDLE instr_handle,
                                                           s32 calculation_channel,
                                                           [MarshalAs(UnmanagedType.I4)]out s32 method);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calculate_mask_test_gate_query(ZT_HANDLE instr_handle,
                                                         s32 calculation_channel,
                                                         s32 gate_type,
                                                         [MarshalAs(UnmanagedType.R8)]out f64 start,
                                                         [MarshalAs(UnmanagedType.R8)]out f64 stop);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calculate_mask_test_vertical_offset_query(ZT_HANDLE instr_handle,
                                                                    [MarshalAs(UnmanagedType.R8)]out f64 offset);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calculate_mask_test_horizontal_offset_query(ZT_HANDLE instr_handle,
                                                                      [MarshalAs(UnmanagedType.R8)]out f64 offset);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_calculate_measurement_query(ZT_HANDLE instr_handle,
                                                      s32 calculation_channel,
                                                      [MarshalAs(UnmanagedType.I4)]out s32 source,
                                                      [MarshalAs(UnmanagedType.I4)]out s32 type);

      /*** Reference ***/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_reference_query(ZT_HANDLE instr_handle,
                                          s32 reference_channel,
                                          [MarshalAs(UnmanagedType.I4)]out s32 state);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_reference_range_query(ZT_HANDLE instr_handle,
                                                s32 reference_channel,
                                                [MarshalAs(UnmanagedType.R8)]out f64 range);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_reference_position_query(ZT_HANDLE instr_handle,
                                                   s32 reference_channel,
                                                   [MarshalAs(UnmanagedType.R8)]out f64 position);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_reference_offset_query(ZT_HANDLE instr_handle,
                                                 s32 reference_channel,
                                                 [MarshalAs(UnmanagedType.R8)]out f64 offset);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_reference_format_query(ZT_HANDLE instr_handle,
                                                s32 reference_channel,
                                                [MarshalAs(UnmanagedType.I4)]out s32 format);

      /*** Measurement ***/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_measure_status_query(ZT_HANDLE instr_handle,
                                               [MarshalAs(UnmanagedType.I4)]out s32 state);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_measurement_query(ZT_HANDLE instr_handle,
                                            [MarshalAs(UnmanagedType.I4)]out s32 method,
                                            [MarshalAs(UnmanagedType.R8)]out f64 gate_start_time,
                                            [MarshalAs(UnmanagedType.R8)]out f64 gate_stop_time,
                                            [MarshalAs(UnmanagedType.U4)]out u32 gate_start_points,
                                            [MarshalAs(UnmanagedType.U4)]out u32 gate_stop_points,
                                            [MarshalAs(UnmanagedType.R8)]out f64 gate_start_freq,
                                            [MarshalAs(UnmanagedType.R8)]out f64 gate_stop_freq,
                                            [MarshalAs(UnmanagedType.I4)]out s32 edge_number,
                                            [MarshalAs(UnmanagedType.I4)]out s32 reference_method,
                                            [MarshalAs(UnmanagedType.R8)]out f64 low_reference,
                                            [MarshalAs(UnmanagedType.R8)]out f64 mid_reference,
                                            [MarshalAs(UnmanagedType.R8)]out f64 high_reference);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_measure_nth_maximum_query(ZT_HANDLE instr_handle,
                                                    [MarshalAs(UnmanagedType.I4)]out s32 number);

      /** Measurement Lists **/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_measure_list_query(ZT_HANDLE instr_handle,
                                             s32 list_number,
                                             [MarshalAs(UnmanagedType.I4)]out s32 state);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_measure_list_measurement_query(ZT_HANDLE instr_handle,
                                                         s32 list_number,
                                                         s32 meas_number,
                                                         [MarshalAs(UnmanagedType.I4)]out s32 source,
                                                         [MarshalAs(UnmanagedType.I4)]out s32 measurement);

      /** Cursors **/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_cursors_source_query(ZT_HANDLE instr_handle,
                                               [MarshalAs(UnmanagedType.I4)]out s32 source);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_cursors_snap_query(ZT_HANDLE instr_handle,
                                             [MarshalAs(UnmanagedType.I4)]out s32 state);

      /*** Operate ***/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_auto_zoom_query(ZT_HANDLE instr_handle,
                                          [MarshalAs(UnmanagedType.R8)]out f64 start,
                                          [MarshalAs(UnmanagedType.R8)]out f64 stop);

      /*** Waveform ***/

      /** Advanced Waveform **/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_format_data_query(ZT_HANDLE instr_handle,
                                            [MarshalAs(UnmanagedType.I4)]out s32 format_type,
                                            [MarshalAs(UnmanagedType.I4)]out s32 length);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_format_precision_query(ZT_HANDLE instr_handle,
                                                 [MarshalAs(UnmanagedType.U2)]out u16 mantissa,
                                                 [MarshalAs(UnmanagedType.U2)]out u16 exponent);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_interpolation_query(ZT_HANDLE instr_handle,
                                              [MarshalAs(UnmanagedType.I4)]out s32 format);

      /*** Utilities ***/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_event_status_enable_query(ZT_HANDLE instr_handle,
                                                    [MarshalAs(UnmanagedType.I4)]out s32 status_register,
                                                    [MarshalAs(UnmanagedType.I4)]out s32 frequency_register,
                                                    [MarshalAs(UnmanagedType.I4)]out s32 test_register,
                                                    [MarshalAs(UnmanagedType.I4)]out s32 operation_register,
                                                    [MarshalAs(UnmanagedType.I4)]out s32 standard_register,
                                                    [MarshalAs(UnmanagedType.I4)]out s32 questionable_register,
                                                    [MarshalAs(UnmanagedType.I4)]out s32 voltage_register,
                                                    [MarshalAs(UnmanagedType.I4)]out s32 calibration_register,
                                                    [MarshalAs(UnmanagedType.I4)]out s32 dig1_register,
                                                    [MarshalAs(UnmanagedType.I4)]out s32 dig2_register);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_system_restore_query(ZT_HANDLE instr_handle,
                                               [MarshalAs(UnmanagedType.U2)]out u16 state);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_identification_led_query(ZT_HANDLE instr_handle,
                                                   [MarshalAs(UnmanagedType.I4)]out s32 state);

      /***************************************************************/
      /* Single Function Prototypes                                  */
      /***************************************************************/

      /*** Configure ***/
      /** Horizontal **/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_horizontal_points(ZT_HANDLE instr_handle,
                                                   u32 sample_points);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_horizontal_time(ZT_HANDLE instr_handle,
                                                 f64 time);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_horizontal_offset_time(ZT_HANDLE instr_handle,
                                                        f64 offset_time);

      /** Vertical **/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_input_range(ZT_HANDLE instr_handle,
                                             s32 channel,
                                             f64 range);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_input_offset(ZT_HANDLE instr_handle,
                                              s32 channel,
                                              f64 offset);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_input_coupling(ZT_HANDLE instr_handle,
                                                s32 channel,
                                                s32 coupling);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_input_impedance(ZT_HANDLE instr_handle,
                                                 s32 channel,
                                                 f64 impedance);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_input_filter(ZT_HANDLE instr_handle,
                                              s32 channel,
                                              s32 lowpass_filter);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_input_attenuation(ZT_HANDLE instr_handle,
                                                   s32 channel,
                                                   f64 attenuation);

      /** Acquisition **/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_acquisition_type(ZT_HANDLE instr_handle,
                                                  s32 acquire_type);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_acquisition_count(ZT_HANDLE instr_handle,
                                                   s32 acquire_count);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_acquisition_continuous(ZT_HANDLE instr_handle,
                                                        s32 initiate_continuously);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_trigger_mode(ZT_HANDLE instr_handle,
                                              s32 trigger_mode);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_acquisition_average(ZT_HANDLE instr_handle,
                                                     s32 state);

      /** Trigger **/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_arm_source(ZT_HANDLE instr_handle,
                                            s32 arm_source);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_arm_polarity(ZT_HANDLE instr_handle,
                                              s32 arm_polarity);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_trigger_source(ZT_HANDLE instr_handle,
                                                s32 trigger_source);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_trigger_level(ZT_HANDLE instr_handle,
                                               s32 trigger_source,
                                               f64 level);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_trigger_slope(ZT_HANDLE instr_handle,
                                               s32 slope);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_trigger_holdoff(ZT_HANDLE instr_handle,
                                                 f64 holdoff);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_trigger_event_count(ZT_HANDLE instr_handle,
                                                     s32 event_count);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_trigger_type(ZT_HANDLE instr_handle,
                                              s32 trigger_type);

      /* Advanced Trigger */
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_trigger_impedance(ZT_HANDLE instr_handle,
                                                   f64 impedance);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_trigger_pulse_width_lower_limit(ZT_HANDLE instr_handle,
                                                                 f64 lower_limit);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_trigger_pulse_width_upper_limit(ZT_HANDLE instr_handle,
                                                                 f64 upper_limit);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_trigger_pattern_mask(ZT_HANDLE instr_handle,
                                                      s32 pattern_mask);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_trigger_pattern_truth(ZT_HANDLE instr_handle,
                                                       s32 pattern_truth);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_trigger_video_standard(ZT_HANDLE instr_handle,
                                                        s32 standard);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_trigger_video_field(ZT_HANDLE instr_handle,
                                                     s32 field);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_trigger_video_line(ZT_HANDLE instr_handle,
                                                    s32 line);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_trigger_b_enable(ZT_HANDLE instr_handle,
                                                  s32 state);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_trigger_b_source(ZT_HANDLE instr_handle,
                                                  s32 trigger_source);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_trigger_b_slope(ZT_HANDLE instr_handle,
                                                 s32 slope);

      /** Output **/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_output_external_enable(ZT_HANDLE instr_handle,
                                                        s32 state);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_output_external_source(ZT_HANDLE instr_handle,
                                                        s32 source);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_output_external_polarity(ZT_HANDLE instr_handle,
                                                          s32 polarity);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_output_external_pulse_mode(ZT_HANDLE instr_handle,
                                                            s32 mode);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_output_external_pulse_period(ZT_HANDLE instr_handle,
                                                              f64 pulse_period);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_output_trigger_enable(ZT_HANDLE instr_handle,
                                                       s32 trigger_output,
                                                       s32 state);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_output_trigger_source(ZT_HANDLE instr_handle,
                                                       s32 trigger_output,
                                                       s32 source);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_output_trigger_polarity(ZT_HANDLE instr_handle,
                                                         s32 trigger_output,
                                                         s32 polarity);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_output_reference_oscillator_enable(ZT_HANDLE instr_handle,
                                                                    s32 state);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_reference_oscillator_source(ZT_HANDLE instr_handle,
                                                             s32 reference_source);

      /*** Calculate ***/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_calculate_function(ZT_HANDLE instr_handle,
                                                    s32 calculation_channel,
                                                    s32 operation,
                                                    s32 source1,
                                                    s32 source2);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_calculate_range(ZT_HANDLE instr_handle,
                                                 s32 calculation_channel,
                                                 f64 range);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_calculate_offset(ZT_HANDLE instr_handle,
                                                  s32 calculation_channel,
                                                  f64 offset);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_calculate_fft(ZT_HANDLE instr_handle,
                                               s32 calculation_channel,
                                               s32 source);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_calculate_fft_window(ZT_HANDLE instr_handle,
                                                      s32 calculation_channel,
                                                      s32 window);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_calculate_time_transform(ZT_HANDLE instr_handle,
                                                          s32 calculation_channel,
                                                          s32 source);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_calculate_time_transform_points(ZT_HANDLE instr_handle,
                                                                 s32 calculation_channel,
                                                                 s32 points);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_calculate_limit_test(ZT_HANDLE instr_handle,
                                                      s32 calculation_channel,
                                                      s32 source);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_calculate_limit_test_measurement(ZT_HANDLE instr_handle,
                                                                  s32 calculation_channel,
                                                                  s32 measurement);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_calculate_limit_test_lower_limit(ZT_HANDLE instr_handle,
                                                                  s32 calculation_channel,
                                                                  f64 lower_limit);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_calculate_limit_test_upper_limit(ZT_HANDLE instr_handle,
                                                                  s32 calculation_channel,
                                                                  f64 upper_limit);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_calculate_mask_test_lower_reference(ZT_HANDLE instr_handle,
                                                                      s32 calculation_channel,
                                                                      s32 lower_reference);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_calculate_mask_test_upper_reference(ZT_HANDLE instr_handle,
                                                                     s32 calculation_channel,
                                                                     s32 upper_reference);

      /** Advanced Limit Test **/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_calculate_mask_test_gate_cursors(ZT_HANDLE instr_handle,
                                                                  s32 calculation_channel);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_calculate_mask_test_gate_time(ZT_HANDLE instr_handle,
                                                               s32 calculation_channel,
                                                               f64 start,
                                                               f64 stop);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_calculate_mask_test_gate_points(ZT_HANDLE instr_handle,
                                                                 s32 calculation_channel,
                                                                 u32 start,
                                                                 u32 stop);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_calculate_mask_test_gate_frequency(ZT_HANDLE instr_handle,
                                                                    s32 calculation_channel,
                                                                    f64 start,
                                                                    f64 stop);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_calculate_limit_number(ZT_HANDLE instr_handle,
                                                        u32 count);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_calculate_measure_source(ZT_HANDLE instr_handle,
                                                          s32 calculation_channel,
                                                          s32 source);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_calculate_measure_type(ZT_HANDLE instr_handle,
                                                        s32 calculation_channel,
                                                        s32 type);

      /*** Measurement ***/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_measure_method(ZT_HANDLE instr_handle,
                                                s32 method);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_measure_gate_time(ZT_HANDLE instr_handle,
                                                   f64 gate_start,
                                                   f64 gate_stop);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_measure_gate_points(ZT_HANDLE instr_handle,
                                                     u32 gate_start,
                                                     u32 gate_stop);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_measure_gate_frequency(ZT_HANDLE instr_handle,
                                                        f64 gate_start,
                                                        f64 gate_stop);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_measure_gate_cursors(ZT_HANDLE instr_handle);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_measure_edge_number(ZT_HANDLE instr_handle,
                                                     s32 edge_number);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_measure_reference_method(ZT_HANDLE instr_handle,
                                                          s32 reference_method);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_measure_reference(ZT_HANDLE instr_handle,
                                                   f64 low_reference,
                                                   f64 mid_reference,
                                                   f64 high_reference);

      /** Cursors **/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_cursor_time(ZT_HANDLE instr_handle,
                                             s32 cursor,
                                             f64 time);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_cursor_magnitude(ZT_HANDLE instr_handle,
                                                  s32 cursor,
                                                  f64 magnitude);

      /*** Operate ***/
      /*** Waveform ***/

      /*** Utilities ***/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_save_state(ZT_HANDLE instr_handle,
                                     s32 state_number);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_recall_state(ZT_HANDLE instr_handle,
                                       s32 state_number);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
      public static extern ZT_ERROR ztscopeM_idn(ZT_HANDLE instr_handle, s8[] id);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_idn_dual(ZT_HANDLE instr_handle,
                                  s8[] primary_id,
                                  s8[] secondary_id);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_driver_rev(ZT_HANDLE instr_handle, s8[] driver_rev);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_config(ZT_HANDLE instr_handle,
                                 s32[] configuration);

      /** Register Enable **/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_status_register_enable(ZT_HANDLE instr_handle,
                                                        s32 state);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_standard_register_enable(ZT_HANDLE instr_handle,
                                                          s32 state);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_frequency_register_enable(ZT_HANDLE instr_handle,
                                                           s32 state);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_test_register_enable(ZT_HANDLE instr_handle,
                                                      s32 state);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_operation_register_enable(ZT_HANDLE instr_handle,
                                                           s32 state);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_questionable_register_enable(ZT_HANDLE instr_handle,
                                                              s32 state);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_voltage_register_enable(ZT_HANDLE instr_handle,
                                                         s32 state);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_calibration_register_enable(ZT_HANDLE instr_handle,
                                                             s32 state);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_digitizer_register_enable(ZT_HANDLE instr_handle,
                                                           s32 digitizer,
                                                           s32 state);

      /** Register Query **/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_status_register_query(ZT_HANDLE instr_handle,
                                                       [MarshalAs(UnmanagedType.I4)]out s32 status_register);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_standard_register_query(ZT_HANDLE instr_handle,
                                                         [MarshalAs(UnmanagedType.I4)]out s32 standard_register);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_frequency_register_query(ZT_HANDLE instr_handle,
                                                          [MarshalAs(UnmanagedType.I4)]out s32 frequency_register);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_test_register_query(ZT_HANDLE instr_handle,
                                                     [MarshalAs(UnmanagedType.I4)]out s32 test_register);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_operation_register_query(ZT_HANDLE instr_handle,
                                                          [MarshalAs(UnmanagedType.I4)]out s32 operation_register);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_questionable_register_query(ZT_HANDLE instr_handle,
                                                             [MarshalAs(UnmanagedType.I4)]out s32 questionable_register);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_voltage_register_query(ZT_HANDLE instr_handle,
                                                        [MarshalAs(UnmanagedType.I4)]out s32 voltage_register);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_calibration_register_query(ZT_HANDLE instr_handle,
                                                            [MarshalAs(UnmanagedType.I4)]out s32 calibration_register);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_digitizer_register_query(ZT_HANDLE instr_handle,
                                                          s32 digitizer,
                                                          [MarshalAs(UnmanagedType.I4)]out s32 digitizer_register);

      /** Register Condition Query **/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_frequency_register_condition_query(ZT_HANDLE instr_handle,
                                                                    [MarshalAs(UnmanagedType.I4)]out s32 frequency_register);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_test_register_condition_query(ZT_HANDLE instr_handle,
                                                               [MarshalAs(UnmanagedType.I4)]out s32 test_register);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_operation_register_condition_query(ZT_HANDLE instr_handle,
                                                                    [MarshalAs(UnmanagedType.I4)]out s32 operation_register);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_questionable_register_condition_query(ZT_HANDLE instr_handle,
                                                                       [MarshalAs(UnmanagedType.I4)]out s32 questionable_register);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_voltage_register_condition_query(ZT_HANDLE instr_handle,
                                                                  [MarshalAs(UnmanagedType.I4)]out s32 voltage_register);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_calibration_register_condition_query(ZT_HANDLE instr_handle,
                                                                      [MarshalAs(UnmanagedType.I4)]out s32 calibration_register);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_digitizer_register_condition_query(ZT_HANDLE instr_handle,
                                                                    s32 digitizer,
                                                                    [MarshalAs(UnmanagedType.I4)]out s32 digitizer_register);

      /******* Read back ********/
      /*** Configure ***/
      /** Horizontal **/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_horizontal_points_query(ZT_HANDLE instr_handle,
                                                         [MarshalAs(UnmanagedType.U4)]out u32 sample_points);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_horizontal_time_query(ZT_HANDLE instr_handle,
                                                       [MarshalAs(UnmanagedType.R8)]out f64 time);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_horizontal_offset_time_query(ZT_HANDLE instr_handle,
                                                              [MarshalAs(UnmanagedType.R8)]out f64 offset_time);

      /** Vertical **/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_input_range_query(ZT_HANDLE instr_handle,
                                                   s32 channel,
                                                   [MarshalAs(UnmanagedType.R8)]out f64 range);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_input_offset_query(ZT_HANDLE instr_handle,
                                                    s32 channel,
                                                    [MarshalAs(UnmanagedType.R8)]out f64 offset);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_input_coupling_query(ZT_HANDLE instr_handle,
                                                      s32 channel,
                                                      [MarshalAs(UnmanagedType.I4)]out s32 coupling);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_input_impedance_query(ZT_HANDLE instr_handle,
                                                       s32 channel,
                                                       [MarshalAs(UnmanagedType.R8)]out f64 impedance);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_input_filter_query(ZT_HANDLE instr_handle,
                                                    s32 channel,
                                                    [MarshalAs(UnmanagedType.I4)]out s32 lowpass_filter);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_input_attenuation_query(ZT_HANDLE instr_handle,
                                                         s32 channel,
                                                         [MarshalAs(UnmanagedType.R8)]out f64 attenuation);

      /** Acquisition **/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_acquisition_type_query(ZT_HANDLE instr_handle,
                                                        [MarshalAs(UnmanagedType.I4)]out s32 acquire_type);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_acquisition_count_query(ZT_HANDLE instr_handle,
                                                         [MarshalAs(UnmanagedType.I4)]out s32 acquire_count);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_acquisition_continuous_query(ZT_HANDLE instr_handle,
                                                              [MarshalAs(UnmanagedType.I4)]out s32 initiate_continuously);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_trigger_mode_query(ZT_HANDLE instr_handle,
                                                    [MarshalAs(UnmanagedType.I4)]out s32 trigger_mode);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_acquisition_average_query(ZT_HANDLE instr_handle,
                                                           [MarshalAs(UnmanagedType.I4)]out s32 aver_state);

      /** Trigger **/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_arm_source_query(ZT_HANDLE instr_handle,
                                                  [MarshalAs(UnmanagedType.I4)]out s32 arm_source);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_arm_polarity_query(ZT_HANDLE instr_handle,
                                                    [MarshalAs(UnmanagedType.I4)]out s32 arm_polarity);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_trigger_source_query(ZT_HANDLE instr_handle,
                                                      [MarshalAs(UnmanagedType.I4)]out s32 trigger_source);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_trigger_level_query(ZT_HANDLE instr_handle,
                                                     s32 source,
                                                     [MarshalAs(UnmanagedType.R8)]out f64 level);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_trigger_slope_query(ZT_HANDLE instr_handle,
                                                     [MarshalAs(UnmanagedType.I4)]out s32 slope);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_trigger_type_query(ZT_HANDLE instr_handle,
                                                    [MarshalAs(UnmanagedType.I4)]out s32 type);

      /* Advanced Trigger */
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_trigger_holdoff_query(ZT_HANDLE instr_handle,
                                                       [MarshalAs(UnmanagedType.R8)]out f64 holdoff);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_trigger_event_count_query(ZT_HANDLE instr_handle,
                                                           [MarshalAs(UnmanagedType.I4)]out s32 event_count);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_trigger_impedance_query(ZT_HANDLE instr_handle,
                                                         [MarshalAs(UnmanagedType.R8)]out f64 impedance);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_trigger_pulse_width_lower_limit_query(ZT_HANDLE instr_handle,
                                                                       [MarshalAs(UnmanagedType.R8)]out f64 lower_limit);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_trigger_pulse_width_upper_limit_query(ZT_HANDLE instr_handle,
                                                                       [MarshalAs(UnmanagedType.R8)]out f64 upper_limit);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_trigger_pattern_mask_query(ZT_HANDLE instr_handle,
                                                            [MarshalAs(UnmanagedType.I4)]out s32 pattern_mask);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_trigger_pattern_truth_query(ZT_HANDLE instr_handle,
                                                             [MarshalAs(UnmanagedType.I4)]out s32 pattern_truth);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_trigger_video_standard_query(ZT_HANDLE instr_handle,
                                                              [MarshalAs(UnmanagedType.I4)]out s32 standard);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_trigger_video_field_query(ZT_HANDLE instr_handle,
                                                           [MarshalAs(UnmanagedType.I4)]out s32 field);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_trigger_video_line_query(ZT_HANDLE instr_handle,
                                                          [MarshalAs(UnmanagedType.I4)]out s32 line);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_trigger_b_state_query(ZT_HANDLE instr_handle,
                                                       [MarshalAs(UnmanagedType.I4)]out s32 state);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_trigger_b_source_query(ZT_HANDLE instr_handle,
                                                        [MarshalAs(UnmanagedType.I4)]out s32 trigger_source);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_trigger_b_slope_query(ZT_HANDLE instr_handle,
                                                       [MarshalAs(UnmanagedType.I4)]out s32 slope);

      /** Output **/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_output_external_state_query(ZT_HANDLE instr_handle,
                                                             [MarshalAs(UnmanagedType.I4)]out s32 state);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_output_external_source_query(ZT_HANDLE instr_handle,
                                                              [MarshalAs(UnmanagedType.I4)]out s32 source);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_output_external_polarity_query(ZT_HANDLE instr_handle,
                                                                [MarshalAs(UnmanagedType.I4)]out s32 polarity);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_output_external_pulse_mode_query(ZT_HANDLE instr_handle,
                                                                  [MarshalAs(UnmanagedType.I4)]out s32 mode);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_output_external_pulse_period_query(ZT_HANDLE instr_handle,
                                                                    [MarshalAs(UnmanagedType.R8)]out f64 pulse_period);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_output_trigger_state_query(ZT_HANDLE instr_handle,
                                                            s32 trigger_output,
                                                            [MarshalAs(UnmanagedType.I4)]out s32 state);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_output_trigger_source_query(ZT_HANDLE instr_handle,
                                                             s32 trigger_output,
                                                             [MarshalAs(UnmanagedType.I4)]out s32 source);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_output_trigger_polarity_query(ZT_HANDLE instr_handle,
                                                               s32 trigger_output,
                                                               [MarshalAs(UnmanagedType.I4)]out s32 polarity);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_output_reference_oscillator_query(ZT_HANDLE instr_handle,
                                                                   [MarshalAs(UnmanagedType.I4)]out s32 state);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_reference_oscillator_source_query(ZT_HANDLE instr_handle,
                                                                   [MarshalAs(UnmanagedType.I4)]out s32 reference_source);

      /*** Calculate ***/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_calculate_function_query(ZT_HANDLE instr_handle,
                                                          s32 calculation_channel,
                                                          [MarshalAs(UnmanagedType.I4)]out s32 operation,
                                                          [MarshalAs(UnmanagedType.I4)]out s32 source1,
                                                          [MarshalAs(UnmanagedType.I4)]out s32 source2);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_calculate_range_query(ZT_HANDLE instr_handle,
                                                       s32 calculation_channel,
                                                       [MarshalAs(UnmanagedType.R8)]out f64 range);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_calculate_offset_query(ZT_HANDLE instr_handle,
                                                        s32 calculation_channel,
                                                        [MarshalAs(UnmanagedType.R8)]out f64 offset);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_calculate_fft_window_query(ZT_HANDLE instr_handle,
                                                            s32 calculation_channel,
                                                            [MarshalAs(UnmanagedType.I4)]out s32 window);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_calculate_time_transform_points_query(ZT_HANDLE instr_handle,
                                                                       s32 calculation_channel,
                                                                       [MarshalAs(UnmanagedType.I4)]out s32 points);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_calculate_limit_test_measurement_query(ZT_HANDLE instr_handle,
                                                                        s32 calculation_channel,
                                                                        [MarshalAs(UnmanagedType.I4)]out s32 measurement);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_calculate_limit_test_lower_limit_query(ZT_HANDLE instr_handle,
                                                                        s32 calculation_channel,
                                                                        [MarshalAs(UnmanagedType.R8)]out f64 lower_limit);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_calculate_limit_test_upper_limit_query(ZT_HANDLE instr_handle,
                                                                        s32 calculation_channel,
                                                                        [MarshalAs(UnmanagedType.R8)]out f64 upper_limit);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_calculate_mask_test_lower_reference_query(ZT_HANDLE instr_handle,
                                                                           s32 calculation_channel,
                                                                           [MarshalAs(UnmanagedType.I4)]out s32 lower_reference);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_calculate_mask_test_upper_reference_query(ZT_HANDLE instr_handle,
                                                                           s32 calculation_channel,
                                                                           [MarshalAs(UnmanagedType.I4)]out s32 upper_reference);

      /** Advanced Limit Test **/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_calculate_mask_test_gate_time_query(ZT_HANDLE instr_handle,
                                                                     s32 calculation_channel,
                                                                     [MarshalAs(UnmanagedType.R8)]out f64 start,
                                                                     [MarshalAs(UnmanagedType.R8)]out f64 stop);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_calculate_mask_test_gate_points_query(ZT_HANDLE instr_handle,
                                                                       s32 calculation_channel,
                                                                       [MarshalAs(UnmanagedType.U4)]out u32 start,
                                                                       [MarshalAs(UnmanagedType.U4)]out u32 stop);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_calculate_mask_test_gate_frequency_query(ZT_HANDLE instr_handle,
                                                                          s32 calculation_channel,
                                                                          [MarshalAs(UnmanagedType.R8)]out f64 start,
                                                                          [MarshalAs(UnmanagedType.R8)]out f64 stop);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_calculate_limit_number_query(ZT_HANDLE instr_handle,
                                                              [MarshalAs(UnmanagedType.U4)]out u32 count);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_calculate_measure_source_query(ZT_HANDLE instr_handle,
                                                                s32 calculation_channel,
                                                                [MarshalAs(UnmanagedType.I4)]out s32 source);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_calculate_measure_type_query(ZT_HANDLE instr_handle,
                                                              s32 calculation_channel,
                                                              [MarshalAs(UnmanagedType.I4)]out s32 type);

      /*** Measurement ***/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_measure_method_query(ZT_HANDLE instr_handle,
                                                      [MarshalAs(UnmanagedType.I4)]out s32 method);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_measure_gate_time_query(ZT_HANDLE instr_handle,
                                                         [MarshalAs(UnmanagedType.R8)]out f64 gate_start_time,
                                                         [MarshalAs(UnmanagedType.R8)]out f64 gate_stop_time);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_measure_gate_points_query(ZT_HANDLE instr_handle,
                                                           [MarshalAs(UnmanagedType.U4)]out u32 gate_start_points,
                                                           [MarshalAs(UnmanagedType.U4)]out u32 gate_stop_points);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_measure_gate_frequency_query(ZT_HANDLE instr_handle,
                                                              [MarshalAs(UnmanagedType.R8)]out f64 gate_start_freq,
                                                              [MarshalAs(UnmanagedType.R8)]out f64 gate_stop_freq);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_measure_edge_number_query(ZT_HANDLE instr_handle,
                                                           [MarshalAs(UnmanagedType.I4)]out s32 edge_number);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_measure_reference_method_query(ZT_HANDLE instr_handle,
                                                                [MarshalAs(UnmanagedType.I4)]out s32 reference_method);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_measure_reference_query(ZT_HANDLE instr_handle,
                                                         [MarshalAs(UnmanagedType.R8)]out f64 low_reference,
                                                         [MarshalAs(UnmanagedType.R8)]out f64 mid_reference,
                                                         [MarshalAs(UnmanagedType.R8)]out f64 high_reference);

      /** Cursors **/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_cursor_time_query(ZT_HANDLE instr_handle,
                                                   s32 cursor,
                                                   [MarshalAs(UnmanagedType.R8)]out f64 time);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_cursor_magnitude_query(ZT_HANDLE instr_handle,
                                                        s32 cursor,
                                                        [MarshalAs(UnmanagedType.R8)]out f64 magnitude);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_cursor_time_delta(ZT_HANDLE instr_handle,
                                                   [MarshalAs(UnmanagedType.R8)]out f64 delta_time);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_cursor_magnitude_delta(ZT_HANDLE instr_handle,
                                                        [MarshalAs(UnmanagedType.R8)]out f64 delta_magnitude);

      /**Utilities**/
      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_status_register_enable_query(ZT_HANDLE instr_handle,
                                                              [MarshalAs(UnmanagedType.I4)]out s32 state);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_standard_register_enable_query(ZT_HANDLE instr_handle,
                                                                [MarshalAs(UnmanagedType.I4)]out s32 state);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_frequency_register_enable_query(ZT_HANDLE instr_handle,
                                                                 [MarshalAs(UnmanagedType.I4)]out s32 state);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_test_register_enable_query(ZT_HANDLE instr_handle,
                                                            [MarshalAs(UnmanagedType.I4)]out s32 state);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_operation_register_enable_query(ZT_HANDLE instr_handle,
                                                                 [MarshalAs(UnmanagedType.I4)]out s32 state);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_questionable_register_enable_query(ZT_HANDLE instr_handle,
                                                                    [MarshalAs(UnmanagedType.I4)]out s32 state);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_voltage_register_enable_query(ZT_HANDLE instr_handle,
                                                               [MarshalAs(UnmanagedType.I4)]out s32 state);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_calibration_register_enable_query(ZT_HANDLE instr_handle,
                                                                   [MarshalAs(UnmanagedType.I4)]out s32 state);

      [DllImport(DLL_LOCATION, CallingConvention = CallingConvention.Cdecl)]
      public static extern ZT_ERROR ztscopeM_single_digitizer_register_enable_query(ZT_HANDLE instr_handle,
                                                                 s32 digitizer,
                                                                 [MarshalAs(UnmanagedType.I4)]out s32 state);
   }
}