Attribute VB_Name = "modDeclarations"
Option Explicit

Const ADDRESS_MIN = 1
Const ADDRESS_MAX = 255

Const MIN_FREQ As Double = 10000000#
Const MAX_FREQ As Double = 10000000000#

Const MIN_AVERAGES As Long = 1
Const MAX_AVERAGES As Long = 100000
Const MAX_PK_PLS_CRIT As Double = 200#
Const MIN_PK_PLS_CRIT As Double = 0.001       ' must be greater than 0.0
Const MAX_OFFSET As Double = 200#
Const MIN_OFFSET As Double = -200#

Const FIRST_REG_INDEX As Long = 0
Const LAST_REG_INDEX As Long = 19
Const NUM_SAVE_RECALL_STATES As Long = 20
Const MAX_NUMBER_OF_SENSORS As Long = 16
Const MAX_NUM_RESP_PTS As Long = 201
Const DEFAULT_TRIG_TIMEOUT As Long = 3000     ' 3 seconds for default trigger timeout
Const MAX_TRIGGER_TIMEOUE As Long = 30000     ' 30 seconds is max timeout
Const DEFAULT_FREQ As Double = 1000000000#
Const DEFAULT_AVERAGES As Long = 75
Const DEFAULT_PULSE_CRIT As Double = 3#
Const DEFAULT_RCDR_1V_LEVEL As Double = 10#
Const DEFAULT_RCDR_0V_LEVEL As Double = -20#
Const MIN_DC_PER_CENT As Double = 0.001
Const MAX_DC_PER_CENT As Double = 100#
Const MIN_DC_DECIMAL As Double = 0.00001
Const MAX_DC_DECIMAL As Double = 1#

Public Enum MODEL_NUMBER    ' Enumeration of model numbers
    LBUknwn = -1
    LB4xxA = 0
    LB478A = 1
    LB479A = 2
    LB480A = 3
End Enum

Public Enum PWR_UNITS
    DBM = 0                 ' dBm
    DBW = 1                 ' dBW
    DBKW = 2                ' dBkW
    DBUV = 3                ' dBuV
    W = 4                   ' Watts
    V = 5                   ' Volts
    DBREL = 6               ' dB Relative
End Enum

Public Enum FEATURE_STATE
    ST_OFF = 0              'disable or turn the feature off
    ST_ON = 1               'enable or turn the feature on
End Enum

Public Enum LIMIT_STYLE
    LIMITS_OFF = 0          'disable limits
    SINGLE_SIDED = 1        'use single sided limits in pass/fail evaluation
    DOUBLE_SIDED = 2        'use double sided limits in pass/fail evaluation
End Enum

Public Enum SS_RULE
    PASS_LT = 0             ' Pass if measured value less than
    PASS_LTE = 1            ' Pass if measured value less than or equal
    PASS_GT = 2             ' Pass if measured value greater than
    PASS_GTE = 3            ' Pass if measured value greater than or equal
End Enum

Public Enum DS_RULE
    PASS_BETWEEN_EXC = 0    ' Pass if measured value is greater than the lower limit and less than the upper limit
    PASS_BETWEEN_INC = 1    ' Pass if measured value is equal to or greater than the lower limit and equal to or less than the upper limit
    PASS_OUTSIDE_EXC = 2    ' Pass if measured value is less than the lower limit OR greater than the upper limit
    PASS_OUTSIDE_INC = 3    ' Pass if measured value is equal to or greater than the upper limit OR equal to or less than the lower limit
End Enum

Public Enum PASS_FAIL_RESULT
    PASS = 0                    ' pass measured value within limits
    FAIL_LOW = 1                ' failed measured value too low
    FAIL_HIGH = 2               ' failed measured value too high
    FAIL_BETWEEN_LIMIT_EXC = 3  ' failed between limits
    FAIL_BETWEEN_LIMIT_INC = 4  ' failed between limits
    NO_DETERMINATION = 5        ' no determination made possible reasons include but are
                                ' not limited to the following reasons:
                                '      - limits are not enabled
                                '      - limits are not specified
                                '      - valid measurement not made (timeout?)
End Enum

Public Enum SVC_WTY_OPTS
    NO_SVC_WTY_OPT = 0          'no service options
    CW03 = 1                    'calibration and warranty repair service option
    C03 = 2                     'calibration service option
    W03 = 3                     'warranty repair service option
End Enum

Public Enum CONN_TYPES
    NOT_SET = 0                 '
    SMA_F = 1                   'SMA female
    SMA_M = 2                   'SMA male
    TNC_F = 3                   'TNC female
    TNC_M = 4                   'TNC male
    N_TYPE_F = 5                'N-Type female
    N_TYPE_M = 6                'N-Type male
End Enum

Public Enum HDWE_OPT_VAL        'Used for recorder out, trigger in/out, filters and best match hardware options
    OPT_OFF = 0
    OPT_ON = 1
End Enum

Public Type SDByte
    DeviceIndex As Long
    DeviceAddress As Long
    SerialNumber(0 To 6) As Byte
End Type

Public Type SensorDescrption
    DeviceIndex As Long
    DeviceAddress As Long
    SerialNumber As String
End Type

Public Type ResponsePoints
    Frequency As Double
    Amplitude As Double
End Type

Public Type SensorState
    frequency_Hz As Double                  ' 10MHz to 10 GHz
    CWReference As Double                   ' reference used for relative CW measurements (alwasy in dB)
    PlsRefPusle As Double                   ' reference used for relative pulse measurements - pusle power reference
    PlsRefPeak As Double                    ' reference used for relative pulse measurements - peak power reference
    PlsRefAvg As Double                     ' reference used for relative pulse measurements - average power reference
    PlsRefDC As Double                      ' reference used for relative pulse measurements - duty cycle reference
    pulseCriteria_dB As Double              ' default is 3dB below peak
    offset_dB As Double                     ' offset in dB
    dutyCycle As Double                     ' 0.0 to 1.00
    recorderOutLevel_0V As Double           ' level (in recorderOutUnits) at which 0VDC will appear at the recorder out port
    recorderOutLevel_1V As Double           ' level (in recorderOutUnits) at which 1VDC will appear at the recorder out port
    singleSidedLimit As Double              ' in singleSidedLimitUnits
    lowerDoubleSidedLimit As Double         ' in doubleSidedLimitUnits
    upperDoubleSidedLimit As Double         ' in doubleSidedLimitUnits
    
    averages As Long                        ' 1...10000
    ttl_triggerTimeOut_mSec As Long         ' 1,000 to 30,000 msec (1 to 30 seconds)
    pwrUnits As PWR_UNITS                   ' dBm, dBW, dBkW, dBuV, W, V, dBRel
    CWRefUnits As PWR_UNITS                 ' dBm, dBW, dBkW, dBuV, W, V - previous units used in a db CW Rel measurement
    PlsRefUnits As PWR_UNITS                ' dBm, dBW, dBkW, dBuV, W, V - previous units used in a db Pls Rel measurement
    singleSidedLimitUnits As PWR_UNITS      ' dBm, dBW, dBkW, dBuV, W, V, dBRel
    doubleSidedLimitUnits As PWR_UNITS      ' dBm, dBW, dBkW, dBuV, W, V, dBRel
    recorderOutUnits As PWR_UNITS           ' dBm, dBW, dBkW, dBuV, W, V
    antiAlisEnabled As FEATURE_STATE        ' Off or On
    offsetEnabled As FEATURE_STATE          ' Off or On
    responseEnabled As FEATURE_STATE        ' Off or On
    dutyCycleEnabled As FEATURE_STATE       ' Off or On
    autoPulseEnabled As FEATURE_STATE       ' Off or On
    ttl_triggerInEnabled As FEATURE_STATE   ' Off or On
    ttl_triggerInInvert As FEATURE_STATE    ' Off or On
    ttl_triggerOutEnabled  As FEATURE_STATE  ' Off or On
    ttl_triggerOutInvert As FEATURE_STATE   ' Off or On
    recorderOutEnabled As FEATURE_STATE     ' Off or On
    limitsEnabled As LIMIT_STYLE            ' Off, Single Sided, Double Sided
    ssLimitRule As SS_RULE                  ' see enum
    dsLimitsRule As DS_RULE                 ' see enum
    numResponsePts As Long                  ' 0...201
    responsePts(201) As ResponsePoints      ' frequency, amplitude pairs SORTED BY FREQUENCY!!!!
End Type

Public m_sd(16) As SensorDescrption

'==============================
'GENERAL QUERIES
'------------------------------
Public Declare Function LB_SensorCnt Lib "LB_API2.dll" () _
                            As Long
Public Declare Function LB_SensorList Lib "LB_API2.dll" ( _
                            ByRef sd As SDByte, _
                            ByVal cnt As Long) _
                            As Long

'==============================
'SET/GET ADDRESS
'------------------------------
Public Declare Function LB_GetAddress_SN _
                            Lib "LB_API2.dll" ( _
                            ByVal sn As String) _
                            As Long
Public Declare Function LB_GetAddress_Idx _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long) _
                            As Long
Public Declare Function LB_SetAddress_SN _
                            Lib "LB_API2.dll" ( _
                            ByVal sn As String, _
                            ByVal addr As Long) _
                            As Long
Public Declare Function LB_SetAddress_Idx _
                            Lib "LB_API2.dll" ( _
                            ByVal idx As Long, _
                            ByVal addr As Long) _
                            As Long
Public Declare Function LB_ChangeAddress _
                            Lib "LB_API2.dll" ( _
                            ByVal currentAddr As Long, _
                            ByVal newAddr As Long) _
                            As Long

'==============================
'ADDRESS CONFLICTS
'------------------------------
Public Declare Function LB_AddressConflictExists _
                            Lib "LB_API2.dll" () _
                            As Long
Public Declare Function LB_WillAddressConflict _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long) _
                            As Long

'==============================
'MODEL NUMBER
'------------------------------
Public Declare Function LB_GetModelNumber_SN _
                            Lib "LB_API2.dll" ( _
                            ByVal sn As String, _
                            ByRef modelNumber As MODEL_NUMBER) _
                            As Long
Public Declare Function LB_GetModelNumber_Idx _
                            Lib "LB_API2.dll" ( _
                            ByVal idx As Long, _
                            ByRef modelNumber As MODEL_NUMBER) _
                            As Long
Public Declare Function LB_GetModelNumber_Addr _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByRef modelNumber As MODEL_NUMBER) _
                            As Long

'==============================
'QUERY ABOUT SENSOR
'------------------------------
Public Declare Function LB_IsSensorConnected_SN _
                            Lib "LB_API2.dll" ( _
                            ByVal sn As String) _
                            As Long
Public Declare Function LB_IsSensorConnected_Addr _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long) _
                            As Long

'==============================
'SERIAL NUMBER
'------------------------------
Public Declare Function LB_GetSerNo_Idx _
                            Lib "LB_API2.dll" ( _
                            ByVal idx As Long, _
                            ByVal sn As String) _
                            As Long
Public Declare Function LB_GetSerNo_Addr _
                            Lib "LB_API2.dll" ( _
                            ByVal address As Long, _
                            ByVal sn As String) _
                            As Long

'==============================
'INDEX
'------------------------------
Public Declare Function LB_GetIndex_SN _
                            Lib "LB_API2.dll" ( _
                            ByVal sn As String) _
                            As Long
Public Declare Function LB_GetIndex_Addr Lib "LB_API2.dll" ( _
                            ByVal addr As Long) _
                            As Long

'==============================
'BLINK LED
'------------------------------
Public Declare Function LB_BlinkLED_SN _
                            Lib "LB_API2.dll" ( _
                            ByVal sn As String) _
                            As Long
Public Declare Function LB_BlinkLED_Idx _
                            Lib "LB_API2.dll" ( _
                            ByVal idx As Long) _
                            As Long
Public Declare Function LB_BlinkLED_Addr _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long) _
                            As Long

'==============================
'INITIALIZE SENSOR
'------------------------------
Public Declare Function LB_InitializeSensor_SN _
                            Lib "LB_API2.dll" ( _
                            ByVal sn As String) _
                            As Long
Public Declare Function LB_InitializeSensor_Idx _
                            Lib "LB_API2.dll" ( _
                            ByVal idx As Long) _
                            As Long
Public Declare Function LB_InitializeSensor_Addr _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long) _
                            As Long

'==============================
'MEASUREMENTS
'------------------------------
Public Declare Function LB_MeasureCW _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByRef CW As Double) As Long
Public Declare Function LB_MeasurePulse _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByRef pulse As Double, _
                            ByRef peak As Double, _
                            ByRef average As Double, _
                            ByRef dutyCycle As Double) As Long
Public Declare Function LB_MeasureCW_PF _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByRef CW As Double, _
                            ByRef pf As PASS_FAIL_RESULT) _
                            As Long
Public Declare Function LB_MeasurePulse_PF _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByRef pulse As Double, _
                            ByRef peak As Double, _
                            ByRef average As Double, _
                            ByRef dutyCycle As Double, _
                            ByRef pf As PASS_FAIL_RESULT) _
                            As Long
                        
'==============================
'FREQUENCY (FOR CORRECTION)
'------------------------------
Public Declare Function LB_SetFrequency _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByVal value As Double) _
                            As Long
Public Declare Function LB_GetFrequency Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByRef value As Double) _
                            As Long

'==============================
'AVERAGING
'------------------------------
Public Declare Function LB_GetAverages _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByRef value As Long) _
                            As Long
Public Declare Function LB_SetAverages _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByVal value As Long) _
                            As Long

'==============================
'PULSE MEAUREMENT CRITERIA
'------------------------------
Public Declare Function LB_SetAutoPulseEnabled _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByVal state As FEATURE_STATE) _
                            As Long
Public Declare Function LB_GetAutoPulseEnabled _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByRef state As FEATURE_STATE) _
                            As Long
Public Declare Function LB_SetPulseCriteria _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByVal val As Double) _
                            As Long
Public Declare Function LB_GetPulseCriteria _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByRef val As Double) _
                            As Long

'==============================
'OFFSET
'------------------------------
Public Declare Function LB_SetOffsetEnabled _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByVal state As FEATURE_STATE) _
                            As Long
Public Declare Function LB_GetOffsetEnabled _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByRef state As FEATURE_STATE) _
                            As Long
Public Declare Function LB_SetOffset _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByVal val As Double) _
                            As Long
Public Declare Function LB_GetOffset _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByRef val As Double) _
                            As Long

Public Declare Function LB_SetResponse _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByRef pts As ResponsePoints, _
                            ByVal numPts As Long) _
                            As Long
Public Declare Function LB_GetResponse _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByRef pts As ResponsePoints, _
                            ByRef numPts As Long) _
                            As Long
Public Declare Function LB_SetResponseEnabled _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByVal st As FEATURE_STATE) _
                            As Long
Public Declare Function LB_GetResponseEnabled _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByRef st As FEATURE_STATE) _
                            As Long


'==============================
'DUTY CYCLE
'------------------------------
Public Declare Function LB_SetDutyCycleEnabled _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByVal state As FEATURE_STATE) _
                            As Long
Public Declare Function LB_GetDutyCycleEnabled _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByRef state As FEATURE_STATE) _
                            As Long
Public Declare Function LB_SetDutyCyclePerCent _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByVal val As Double) _
                            As Long
Public Declare Function LB_GetDutyCyclePerCent _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByRef val As Double) _
                            As Long

'==============================
'UNITS
'------------------------------
Public Declare Function LB_SetMeasurementPowerUnits _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByVal units As PWR_UNITS) _
                            As Long
Public Declare Function LB_GetMeasurementPowerUnits _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByRef units As PWR_UNITS) _
                            As Long

'==============================
'SET/GET MEASUREMENT REFERENCES
'------------------------------
Public Declare Function LB_SetCWReference _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByVal Ref As Double, _
                            ByVal units As PWR_UNITS) _
                            As Long
Public Declare Function LB_SetPulseReference _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByVal pulseRef As Double, _
                            ByVal peakRef As Double, _
                            ByVal averageRef As Double, _
                            ByVal dutyCycleRef As Double, _
                            ByVal units As PWR_UNITS) _
                            As Long
Public Declare Function LB_GetCWReference _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByRef relRef As Double, _
                            ByRef units As PWR_UNITS) _
                            As Long
Public Declare Function LB_GetPulseReference _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByRef pulseRef As Double, _
                            ByRef peakRef As Double, _
                            ByRef averageRef As Double, _
                            ByRef dutyCycleRef As Double, _
                            ByRef units As PWR_UNITS) _
                            As Long

'==============================
'SET/GET ANTI-ALIASING
'------------------------------
Public Declare Function LB_SetAntiAliasingEnabled _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByVal st As FEATURE_STATE) _
                            As Long
Public Declare Function LB_GetAntiAliasingEnabled _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByRef st As FEATURE_STATE) _
                            As Long

'==============================
'SET/GET TTL TRIGGER IN
'------------------------------
Public Declare Function LB_SetTTLTriggerInEnabled _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByVal st As FEATURE_STATE) _
                            As Long
Public Declare Function LB_SetTTLTriggerInInverted _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByVal st As FEATURE_STATE) _
                            As Long
Public Declare Function LB_SetTTLTriggerInTimeOut _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByVal timeOut As Long) _
                            As Long
Public Declare Function LB_GetTTLTriggerInEnabled _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByRef st As FEATURE_STATE) _
                            As Long
Public Declare Function LB_GetTTLTriggerInInverted _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByRef st As FEATURE_STATE) _
                            As Long
Public Declare Function LB_GetTTLTriggerInTimeOut _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByRef timeOut As Long) _
                            As Long

'==============================
'SET/GET TTL TRIGGER OUT
'------------------------------
Public Declare Function LB_SetTTLTriggerOutEnabled _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByVal st As FEATURE_STATE) _
                            As Long
Public Declare Function LB_SetTTLTriggerOutInverted _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByVal st As FEATURE_STATE) _
                            As Long
Public Declare Function LB_GetTTLTriggerOutEnabled _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByRef st As FEATURE_STATE) _
                            As Long
Public Declare Function LB_GetTTLTriggerOutInverted _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByRef st As FEATURE_STATE) _
                            As Long


'==============================
'SET/GET RECORDER OUTPUT
'------------------------------
Public Declare Function LB_SetRecorderOutSetup _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByVal val_0_V As Double, _
                            ByVal val_1_V As Double, _
                            ByVal units As PWR_UNITS) _
                            As Long
Public Declare Function LB_GetRecorderOutSetup _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByRef val_0_V As Double, _
                            ByRef val_1_V As Double, _
                            ByRef units As PWR_UNITS) _
                            As Long
Public Declare Function LB_SetRecorderOutEnabled _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByVal st As FEATURE_STATE) _
                            As Long
Public Declare Function LB_GetRecorderOutEnabled _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByRef st As FEATURE_STATE) _
                            As Long

'==============================
'SET/GET LIMITS
'------------------------------
Public Declare Function LB_SetLimitEnabled _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByVal lmtStyle As LIMIT_STYLE) _
                            As Long
Public Declare Function LB_SetSingleSidedLimit _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByVal val As Double, _
                            ByVal units As PWR_UNITS, _
                            ByVal passFail As SS_RULE) _
                            As Long
Public Declare Function LB_SetDoubleSidedLimit _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByVal lowerVal As Double, _
                            ByVal upperVal As Double, _
                            ByVal units As PWR_UNITS, _
                            ByVal passFail As DS_RULE) _
                            As Long
Public Declare Function LB_GetLimitEnabled _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByRef lmtStyle As LIMIT_STYLE) _
                            As Long
Public Declare Function LB_GetSingleSidedLimit _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByRef val As Double, _
                            ByRef units As PWR_UNITS, _
                            ByRef passFail As SS_RULE) _
                            As Long
Public Declare Function LB_GetDoubleSidedLimit _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByRef lowerVal As Double, _
                            ByRef upperVal As Double, _
                            ByRef units As PWR_UNITS, _
                            ByRef passFail As DS_RULE) _
                            As Long


'==============================
'SET/GET OPTIONS & DATES
'------------------------------
Public Declare Function LB_SetCalDueDate _
                            Lib "LB_API2.dll" ( _
                            ByVal sn As String, _
                            ByVal year As Long, _
                            ByVal month As Long, _
                            ByVal day As Long) _
                            As Long
Public Declare Function LB_GetCalDueDate _
                            Lib "LB_API2.dll" ( _
                            ByVal sn As String, _
                            ByRef day As Long, _
                            ByRef month As Long, _
                            ByRef day As Long) _
                            As Long
Public Declare Function LB_SetCalOptExpDate _
                            Lib "LB_API2.dll" ( _
                            ByVal sn As String, _
                            ByVal pw As Long, _
                            ByVal year As Long, _
                            ByVal month As Long, _
                            ByVal day As Long) _
                            As Long
Public Declare Function LB_GetCalOptExpDate _
                            Lib "LB_API2.dll" ( _
                            ByVal sn As String, _
                            ByRef day As Long, _
                            ByRef month As Long, _
                            ByRef day As Long) _
                            As Long
Public Declare Function LB_SetWtyOptExpDate _
                            Lib "LB_API2.dll" ( _
                            ByVal sn As String, _
                            ByVal pw As Long, _
                            ByVal year As Long, _
                            ByVal month As Long, _
                            ByVal day As Long) _
                            As Long
Public Declare Function LB_GetWtyOptExpDate _
                            Lib "LB_API2.dll" ( _
                            ByVal sn As String, _
                            ByRef day As Long, _
                            ByRef month As Long, _
                            ByRef day As Long) _
                            As Long
Public Declare Function LB_SetConnectorOption _
                            Lib "LB_API2.dll" ( _
                            ByVal sn As String, _
                            ByVal pw As Long, _
                            ByVal optVal As Long) _
                            As Long
Public Declare Function LB_GetConnectorOption _
                            Lib "LB_API2.dll" ( _
                            ByVal sn As String, _
                            ByRef val As Long) _
                            As Long
Public Declare Function LB_SetCalAndWtyOption _
                            Lib "LB_API2.dll" ( _
                            ByVal sn As String, _
                            ByVal pw As Long, _
                            ByVal optVal As Long) _
                            As Long
Public Declare Function LB_GetCalAndWtyOption _
                            Lib "LB_API2.dll" ( _
                            ByVal sn As String, _
                            ByRef optVal As Long) _
                            As Long
Public Declare Function LB_SetRecorderOutOption _
                            Lib "LB_API2.dll" ( _
                            ByVal sn As String, _
                            ByVal pw As Long, _
                            ByVal optVal As Long) _
                            As Long
Public Declare Function LB_GetRecorderOutOption _
                            Lib "LB_API2.dll" ( _
                            ByVal sn As String, _
                            ByRef optVal As Long) _
                            As Long
Public Declare Function LB_SetBestMatchOpt _
                            Lib "LB_API2.dll" ( _
                            ByVal sn As String, _
                            ByVal pw As Long, _
                            ByVal optVal As Long) _
                            As Long
Public Declare Function LB_GetBestMatchOpt _
                            Lib "LB_API2.dll" ( _
                            ByVal sn As String, _
                            ByRef optVal As Long) _
                            As Long
Public Declare Function LB_SetTriggerOpt _
                            Lib "LB_API2.dll" ( _
                            ByVal sn As String, _
                            ByVal pw As Long, _
                            ByVal optVal As Long) _
                            As Long
Public Declare Function LB_GetTriggerOpt _
                            Lib "LB_API2.dll" ( _
                            ByVal sn As String, _
                            ByRef optVal As Long) _
                            As Long
Public Declare Function LB_SetFilterOpt _
                            Lib "LB_API2.dll" ( _
                            ByVal sn As String, _
                            ByVal pw As Long, _
                            ByVal optVal As Long) _
                            As Long
Public Declare Function LB_GetFilterOpt _
                            Lib "LB_API2.dll" ( _
                            ByVal sn As String, _
                            ByRef optVal As Long) _
                            As Long


'==============================
'STORE RECALL REGISTERS
'------------------------------
Public Declare Function LB_SetCurrentState _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByRef state As SensorState) _
                            As Long
Public Declare Function LB_SetRegState _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByVal regIdx As Long, _
                            ByRef state As SensorState) _
                            As Long
Public Declare Function LB_GetCurrentState _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByRef state As SensorState) _
                            As Long
Public Declare Function LB_GetRegState _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByVal regIdx As Long, _
                            ByRef state As SensorState) _
                            As Long
Public Declare Function LB_Store _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByVal regIdx As Long) _
                            As Long
Public Declare Function LB_Recall _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long, _
                            ByVal regIdx As Long) _
                            As Long
Public Declare Function LB_ResetCurrentState _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long) _
                            As Long
Public Declare Function LB_ResetRegStates _
                            Lib "LB_API2.dll" ( _
                            ByVal addr As Long) _
                            As Long

