Attribute VB_Name = "Module1"
'/***********************************************************************/
'/*                                                                     */
'/*     ＩＦ＿５０  ＡＰＩ用ヘッダーファイル                            */
'/*                                                                     */
'/*     Copyright(c) 2012  TEXIO TECHNOLOGY CORPORATION                 */
'/***********************************************************************/

'IF_50用標準モジュール

Option Explicit
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
'********************************************************************************
'   構造体宣言
'********************************************************************************
'モニターデータ構造体
Public Type MONITOR_DATA
    Current As Double       '電流モニター値
    Voltage As Double       '電圧モニター値
    Wattage As Double       '電力モニター値
End Type

'放電負荷モード設定データ構造体
Public Type MODE_DATA
    Mode As Long         '放電負荷モード設定
    Reference As Long    'コントロールリファレンス設定
End Type
 
'スイッチング時間設定データ構造体
Public Type TIME_DATA
    Ta As Double        '時間ｔａ設定
    Tb As Double        '時間ｔｂ設定
End Type
 
'トラッキング設定データ構造体
Public Type TRACK_DATA
    Ch_A As Long        'CH-A
    Ch_B As Long        'CH-B
    Ch_C As Long        'CH-C
    Ch_D As Long        'CH-C
End Type

'アラームデータ構造体
Public Type ALARM_DATA
    Eta As Long         '外部アラーム
    Oha As Long         'オーバーヒートアラーム
    Ova_A As Long      'オーバーボルテージアラーム CH-A
    Ova_B As Long      'オーバーボルテージアラーム CH-B
    Ova_C As Long      'オーバーボルテージアラーム CH-C
    Ova_D As Long      'オーバーボルテージアラーム CH-C
    Oca_A As Long      'オーバーカーレントアラーム CH-A
    Oca_B As Long      'オーバーカーレントアラーム CH-B
    Oca_C As Long      'オーバーカーレントアラーム CH-C
    Oca_D As Long      'オーバーカーレントアラーム CH-C
    Ora_A As Long      'オーバーレンジアラーム CH-A
    Ora_B As Long      'オーバーレンジアラーム CH-B
    Ora_C As Long      'オーバーレンジアラーム CH-C
    Ora_D As Long      'オーバーレンジアラーム CH-C
End Type

'リミットデータ構造体
Public Type LIMIT_DATA
    Current_A As Long  '電流リミット CH-A
    Current_B As Long  '電流リミット CH-B
    Current_C As Long  '電流リミット CH-C
    Current_D As Long  '電流リミット CH-C
    Power_A As Long    '電力リミット CH-A
    Power_B As Long    '電力リミット CH-B
    Power_C As Long    '電力リミット CH-C
    Power_D As Long    '電力リミット CH-C
End Type

'ＣＨ実装データ構造体
Public Type CH_DATA
    Ch_A As Long        'CH-A
    Ch_B As Long        'CH-B
    Ch_C As Long        'CH-C
    Ch_D As Long        'CH-C
End Type


'********************************************************************************
'   ＡＰＩ宣言
'********************************************************************************
Declare Function LW_DeviceOpen Lib "IF_50" (ByVal Class As Long, ByVal BoardAdrs As Long, ByVal PcAdrs As Long, ByVal SysAdrs As Long) As Long
Declare Function LW_DeviceClose Lib "IF_50" (ByVal DeviceId As Long) As Long
Declare Function LW_DeviceRefresh Lib "IF_50" (ByVal DeviceId As Long) As Long
Declare Function LW_SetTimeOut Lib "IF_50" (ByVal DeviceId As Long, ByVal Time As Long) As Long
Declare Function LW_SetMainInput Lib "IF_50" (ByVal DeviceId As Long, ByVal Flag As Long) As Long
Declare Function LW_GetMainInput Lib "IF_50" (ByVal DeviceId As Long) As Long
Declare Function LW_SetInputSelect Lib "IF_50" (ByVal DeviceId As Long, ByVal CH As Long, ByVal Flag As Long) As Long
Declare Function LW_GetInputSelect Lib "IF_50" (ByVal DeviceId As Long, ByVal CH As Long) As Long
Declare Function LW_SetPresetNumber Lib "IF_50" (ByVal DeviceId As Long, ByVal Preset As Long) As Long
Declare Function LW_GetPresetNumber Lib "IF_50" (ByVal DeviceId As Long) As Long
Declare Function LW_SavePreset Lib "IF_50" (ByVal DeviceId As Long, ByVal Src As Long, ByVal Dest As Long) As Long
Declare Function LW_GetMonitor Lib "IF_50" (ByVal DeviceId As Long, ByVal CH As Long, ByRef Monitor As MONITOR_DATA) As Long
Declare Function LW_SetMonitorSelect Lib "IF_50" (ByVal DeviceId As Long, ByVal Flag As Long) As Long
Declare Function LW_GetMonitorSelect Lib "IF_50" (ByVal DeviceId As Long) As Long
Declare Function LW_SetDisplaySelect Lib "IF_50" (ByVal DeviceId As Long, ByVal CH As Long) As Long
Declare Function LW_GetDisplaySelect Lib "IF_50" (ByVal DeviceId As Long) As Long
Declare Function LW_SetLoadMode Lib "IF_50" (ByVal DeviceId As Long, ByVal Preset As Long, ByVal CH As Long, ByVal Mode As Long, ByVal Ref As Long) As Long
Declare Function LW_GetLoadMode Lib "IF_50" (ByVal DeviceId As Long, ByVal Preset As Long, ByVal CH As Long, ByRef ModeData As MODE_DATA) As Long
Declare Function LW_SetLoadValue Lib "IF_50" (ByVal DeviceId As Long, ByVal Preset As Long, ByVal CH As Long, ByVal Data As Double) As Long
Declare Function LW_GetLoadValue Lib "IF_50" (ByVal DeviceId As Long, ByVal Preset As Long, ByVal CH As Long, ByRef Data As Double) As Long
Declare Function LW_SetSiemensValue Lib "IF_50" (ByVal DeviceId As Long, ByVal Preset As Long, ByVal CH As Long, ByVal Data As Long) As Long
Declare Function LW_GetSiemensValue Lib "IF_50" (ByVal DeviceId As Long, ByVal Preset As Long, ByVal CH As Long, ByRef Data As Long) As Long
Declare Function LW_SetCurrentLimit Lib "IF_50" (ByVal DeviceId As Long, ByVal Preset As Long, ByVal CH As Long, ByVal Data As Double) As Long
Declare Function LW_GetCurrentLimit Lib "IF_50" (ByVal DeviceId As Long, ByVal Preset As Long, ByVal CH As Long, ByRef Data As Double) As Long
Declare Function LW_SaveLoadValue Lib "IF_50" (ByVal DeviceId As Long, ByVal Preset As Long, ByVal CH As Long) As Long
Declare Function LW_SaveCurrentLimit Lib "IF_50" (ByVal DeviceId As Long, ByVal Preset As Long, ByVal CH As Long) As Long
Declare Function LW_SaveMemoryData Lib "IF_50" (ByVal DeviceId As Long, ByVal Object As Long) As Long
Declare Function LW_SetSwSelect Lib "IF_50" (ByVal DeviceId As Long, ByVal CH As Long, ByVal Flag As Long) As Long
Declare Function LW_GetSwSelect Lib "IF_50" (ByVal DeviceId As Long, ByVal CH As Long) As Long
Declare Function LW_SetSwFreq Lib "IF_50" (ByVal DeviceId As Long, ByVal Freq As Long) As Long
Declare Function LW_GetSwFreq Lib "IF_50" (ByVal DeviceId As Long, ByRef Freq As Long) As Long
Declare Function LW_SetSwDuty Lib "IF_50" (ByVal DeviceId As Long, ByVal Duty As Long) As Long
Declare Function LW_GetSwDuty Lib "IF_50" (ByVal DeviceId As Long, ByRef Duty As Long) As Long
Declare Function LW_SetSwTime Lib "IF_50" (ByVal DeviceId As Long, ByVal Ta As Double, ByVal Tb As Double) As Long
Declare Function LW_GetSwTime Lib "IF_50" (ByVal DeviceId As Long, ByRef Time As TIME_DATA) As Long
Declare Function LW_SetSwMethod Lib "IF_50" (ByVal DeviceId As Long, ByVal Flag As Long) As Long
Declare Function LW_GetSwMethod Lib "IF_50" (ByVal DeviceId As Long) As Long
Declare Function LW_SetDelayFunction Lib "IF_50" (ByVal DeviceId As Long, ByVal Flag As Long) As Long
Declare Function LW_GetDelayFunction Lib "IF_50" (ByVal DeviceId As Long) As Long
Declare Function LW_SetDelayTime Lib "IF_50" (ByVal DeviceId As Long, ByVal CH As Long, ByVal Time As Double) As Long
Declare Function LW_GetDelayTime Lib "IF_50" (ByVal DeviceId As Long, ByVal CH As Long, ByRef Time As Double) As Long
Declare Function LW_SetTrackFunction Lib "IF_50" (ByVal DeviceId As Long, ByVal Flag As Long) As Long
Declare Function LW_GetTrackFunction Lib "IF_50" (ByVal DeviceId As Long) As Long
Declare Function LW_SetTrackDirection Lib "IF_50" (ByVal DeviceId As Long, ByVal ChA As Long, ByVal ChB As Long, ByVal ChC As Long, ByVal ChD As Long) As Long
Declare Function LW_GetTrackDirection Lib "IF_50" (ByVal DeviceId As Long, ByRef Track As TRACK_DATA) As Long
Declare Function LW_SetTrackMode Lib "IF_50" (ByVal DeviceId As Long, ByVal Mode As Long) As Long
Declare Function LW_GetTrackMode Lib "IF_50" (ByVal DeviceId As Long) As Long
Declare Function LW_SetTrackValue Lib "IF_50" (ByVal DeviceId As Long, ByVal Data As Double) As Long
Declare Function LW_GetTrackValue Lib "IF_50" (ByVal DeviceId As Long, ByRef Data As Double) As Long
Declare Function LW_ResetAlarm Lib "IF_50" (ByVal DeviceId As Long) As Long
Declare Function LW_GetAlarm Lib "IF_50" (ByVal DeviceId As Long, ByRef Alarm As ALARM_DATA) As Long
Declare Function LW_GetLimit Lib "IF_50" (ByVal DeviceId As Long, ByRef Limit As LIMIT_DATA) As Long
Declare Function LW_SetOperationTimeOut Lib "IF_50" (ByVal DeviceId As Long, ByVal Time As Long) As Long
Declare Function LW_GetOperationTimeOut Lib "IF_50" (ByVal DeviceId As Long) As Long
Declare Function LW_SetLocal Lib "IF_50" (ByVal DeviceId As Long) As Long
Declare Function LW_SetLocalLockOut Lib "IF_50" (ByVal DeviceId As Long, ByVal Flag As Long) As Long
Declare Function LW_GetLocalLockOut Lib "IF_50" (ByVal DeviceId As Long) As Long
Declare Function LW_GetIdNumber Lib "IF_50" (ByVal DeviceId As Long) As Long
Declare Function LW_GetChExist Lib "IF_50" (ByVal DeviceId As Long, ByRef ChData As CH_DATA) As Long

'********************************************************************************
'   定数宣言
'********************************************************************************
'デバイス種別
Global Const GPIB = 1       'ＧＰＩＢ
Global Const USB = 2        'ＵＳＢ

'エラーフラグ
Global Const DEV_ERR = -1   'デバイスエラー
Global Const TO_ERR = -2    'タイムアウトエラー
Global Const PAR_ERR = -3   'パラメータエラー
Global Const RCV_ERR = -4   '受信エラー

'制御フラグ
Global Const XOFF = 0       'ＯＦＦ
Global Const XON = 1        'ＯＮ

'表示切り替えフラグ
Global Const VOLT = 0       '電流／電圧表示
Global Const WATT = 1       '電流／電力表示

'ＣＨ設定値
Global Const Ch_A = 1       'CH-A
Global Const Ch_B = 2       'CH-B
Global Const Ch_C = 3       'CH-C
Global Const Ch_D = 4       'CH-C

'プリセット設定値
Global Const PR_1 = 1       'プリセット番号１
Global Const PR_2 = 2       'プリセット番号２
Global Const PR_3 = 3       'プリセット番号３
Global Const PR_4 = 4       'プリセット番号４

'放電負荷モード設定値
Global Const M_CCH = 1      'ＣＣモード、電流レンジ「Ｈ」
Global Const M_CCL = 2      'ＣＣモード、電流レンジ「Ｌ」
Global Const M_CRH = 3      'ＣＲモード、電流レンジ「Ｈ」
Global Const M_CRL = 4      'ＣＲモード、電流レンジ「Ｌ」
Global Const M_CVH = 5      'ＣＶモード、電流レンジ「Ｈ」
Global Const M_CVL = 6      'ＣＶモード、電流レンジ「Ｌ」
Global Const M_CPHL = 7     'ＣＰモード、電流レンジ「Ｈ」、電圧レンジ「Ｌ」
Global Const M_CPHH = 8     'ＣＰモード、電流レンジ「Ｈ」、電圧レンジ「Ｈ」
Global Const M_CPLL = 9     'ＣＰモード、電流レンジ「Ｌ」、電圧レンジ「Ｌ」
Global Const M_CPLH = 10    'ＣＰモード、電流レンジ「Ｌ」、電圧レンジ「Ｈ」
Global Const M_SHORT = 11   'ショートモード

'コントロールリファレンス設定値
Global Const REF_IN = 0     '内部電圧コントロール
Global Const REF_EXT = 1    '外部電圧コントロール

'保存対象データ設定値
Global Const OBJ_FREQ = 1   'ＳＷ周波数
Global Const OBJ_DUTY = 2   'ＳＷデューティ
Global Const OBJ_TAB = 3    'ＳＷ時間ｔａ、ｔｂ
Global Const OBJ_DELAY = 4  'ディレイ時間
Global Const OBJ_TRACK = 5  'トラッキング設定

'スイッチング方法設定値
Global Const SW_FREQ = 0    '周波数＆デューティ
Global Const SW_TAB = 1     '時間ｔａ＆ｔｂ

'トラッキング方向設定値
Global Const TRC_NO = 0     'トラッキング無し
Global Const TRC_PLUS = 1   '「＋」トラッキング
Global Const TRC_MINUS = 2  '「−」トラッキング

'トラッキングモード設定値
Global Const TRC_PERCENT = 0    '％トラッキングモード
Global Const TRC_ABS = 1        '絶対値トラッキングモード

'ローカルロックアウト設定値
Global Const LOCK_FREE = 0  '解除可能
Global Const LOCK_OUT = 1   '解除不可

