'------------------------------------------------------------
'            TUSB-S03CN2ドライバ操作用標準モジュール
'            2012/02/07
'            株式会社タートル工業
'-----------Copyright (C) 2012 Turtle Industry Co., Ltd.-----
Option Strict Off
Option Explicit On
Imports System.Runtime.InteropServices
Module TUSBS01CN2
    <DllImport("TUSBSCN2.DLL", CallingConvention:=CallingConvention.Cdecl)> _
    Function Tusbs03cn2_Device_Open(ByVal id As Short) As Short
    End Function
    <DllImport("TUSBSCN2.DLL", CallingConvention:=CallingConvention.Cdecl)> _
    Sub Tusbs03cn2_Device_Close(ByVal id As Short)
    End Sub
    <DllImport("TUSBSCN2.DLL", CallingConvention:=CallingConvention.Cdecl)> _
    Function Tusbs03cn2_Counter_Read(ByVal id As Short, _
                                     ByVal ch As Byte, _
                                     ByRef xData As Integer, _
                                     ByRef Valid As Byte) As Short
    End Function
    <DllImport("TUSBSCN2.DLL", CallingConvention:=CallingConvention.Cdecl)> _
    Function Tusbs03cn2_Ext_Input_Set(ByVal id As Short, _
                                      ByVal ch As Byte, _
                                      ByVal UpDown As Byte) As Short
    End Function
    <DllImport("TUSBSCN2.DLL", CallingConvention:=CallingConvention.Cdecl)> _
    Function Tusbs03cn2_Counter_Mode(ByVal id As Short, _
                                     ByVal ch As Byte, _
                                     ByVal mode As Byte) As Short
    End Function
    <DllImport("TUSBSCN2.DLL", CallingConvention:=CallingConvention.Cdecl)> _
    Function Tusbs03cn2_Gate_Time(ByVal id As Short, _
                                     ByVal ch As Byte, _
                                     ByVal time As Byte) As Short
    End Function
    <DllImport("TUSBSCN2.DLL", CallingConvention:=CallingConvention.Cdecl)> _
    Function Tusbs03cn2_Cnt_Clock_Set(ByVal id As Short, _
                                     ByVal ch As Byte, _
                                     ByVal clk As Byte) As Short
    End Function
    <DllImport("TUSBSCN2.DLL", CallingConvention:=CallingConvention.Cdecl)> _
    Function Tusbs03cn2_Divider_Set(ByVal id As Short, _
                                     ByVal ch As Byte, _
                                     ByVal div As Byte) As Short
    End Function

    Function Tusbs03cn2_GetErrMessage(ByVal retcode As Short) As String
        Select Case retcode
            Case 0
                Return "正常終了しました"
            Case 1
                Return "ID番号が不正です"
            Case 2
                Return "ドライバがインストールされていません"
            Case 3
                Return "すでにデバイスはオープンされています"
            Case 4
                Return "接続されている台数が多すぎます"
            Case 5
                Return "オープンできませんでした"
            Case 6
                Return "デバイスがみつかりません"
            Case 7
                Return "オープンされていません"
            Case 8
                Return "パラメータエラー"
            Case 9
                Return "USB通信エラーです"
            Case Else
                Return "不明なエラーです"
        End Select
    End Function
End Module