// V1.00: 21/04/2011: MB : Release
// V1.01: 23/08/2012: DB : Correction Fonction Close: Void->int
// V1.02: 08/10/2014: MB : Création de la version x64 - Convention d'appel stcall-> cdecl
// V1.03: 31/10/2014: DB : Correction fonction Pos: 'ref uint Data' en 'ref int Data'
//                                             AnaIn:  'ref ushort Data' en 'ref short Data'
//                                             AnaOut: 'ref ushort Data' en 'ref short Data'  


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

namespace Test_TCUSB18A
{
    class TCUSB18A
    {
       /***********************************************************************************************************************************************\
       *********************************************************** OPERATIONS DE BASE ******************************************************************
       \***********************************************************************************************************************************************/
        [DllImport("TCUSB18Ax64.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl, SetLastError = true, ExactSpelling = true)]
        public static extern int TCUSB18A_Refresh(int NModule);
        [DllImport("TCUSB18Ax64.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl, SetLastError = true, ExactSpelling = true)]
        public static extern int TCUSB18A_OpenN(int NModule, ref uint NumSerie);
        [DllImport("TCUSB18Ax64.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl, SetLastError = true, ExactSpelling = true)]
        public static extern int TCUSB18A_Close(int NModule);
        [DllImport("TCUSB18Ax64.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl, SetLastError = true, ExactSpelling = true)]
        public static extern int TCUSB18A_Input(int NModule, ref uint Data);
        [DllImport("TCUSB18Ax64.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl, SetLastError = true, ExactSpelling = true)]
        public static extern int TCUSB18A_Output(int NModule, byte Data);
        /***********************************************************************************************************************************************\
        *********************************************************** OPERATIONS SUR BITS *****************************************************************
        \***********************************************************************************************************************************************/
        [DllImport("TCUSB18Ax64.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl, SetLastError = true, ExactSpelling = true)]
        public static extern int TCUSB18A_BitInput(int NModule, int Entree, ref byte Data);
        [DllImport("TCUSB18Ax64.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl, SetLastError = true, ExactSpelling = true)]
        public static extern int TCUSB18A_BitOutput(int NModule, int Sortie, int etat);
        [DllImport("TCUSB18Ax64.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl, SetLastError = true, ExactSpelling = true)]
        public static extern int TCUSB18A_BitReadBack(int NModule, int Sortie, ref byte Data);
        [DllImport("TCUSB18Ax64.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl, SetLastError = true, ExactSpelling = true)]
        public static extern int TCUSB18A_Counter(int NModule, int Entree, ref byte Data);
        [DllImport("TCUSB18Ax64.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl, SetLastError = true, ExactSpelling = true)]
        public static extern int TCUSB18A_Config(int NModule, byte Data);
        [DllImport("TCUSB18Ax64.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl, SetLastError = true, ExactSpelling = true)]
        public static extern int TCUSB18A_Pos(int NModule, ref int Data);
        [DllImport("TCUSB18Ax64.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl, SetLastError = true, ExactSpelling = true)]
        public static extern int TCUSB18A_ResetPos(int NModule);
        [DllImport("TCUSB18Ax64.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl, SetLastError = true, ExactSpelling = true)]
        public static extern int TCUSB18A_WdgRun(int NModule);
        [DllImport("TCUSB18Ax64.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl, SetLastError = true, ExactSpelling = true)]
        public static extern int TCUSB18A_WdgStop(int NModule);
        [DllImport("TCUSB18Ax64.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl, SetLastError = true, ExactSpelling = true)]
        public static extern int TCUSB18A_WdgRearm(int NModule);
        [DllImport("TCUSB18Ax64.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl, SetLastError = true, ExactSpelling = true)]
        public static extern int TCUSB18A_ResetPort(int NModule);
        [DllImport("TCUSB18Ax64.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl, SetLastError = true, ExactSpelling = true)]
        public static extern int TCUSB18A_CyclePort(int NModule);
        [DllImport("TCUSB18Ax64.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl, SetLastError = true, ExactSpelling = true)]
        public static extern int TCUSB18A_Version(int NModule, ref byte Data1, ref byte Data2);
        /***********************************************************************************************************************************************\
        ********************************************************** OPERATIONS ANALOGIQUE ****************************************************************
        \***********************************************************************************************************************************************/
        [DllImport("TCUSB18Ax64.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl, SetLastError = true, ExactSpelling = true)]
        public static extern int TCUSB18A_AnaIn(int NModule, byte Voie, ref short Data);
        [DllImport("TCUSB18Ax64.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl, SetLastError = true, ExactSpelling = true)]
        public static extern int TCUSB18A_AnaInVolts(int NModule, byte Voie, ref double Data);
        [DllImport("TCUSB18Ax64.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl, SetLastError = true, ExactSpelling = true)]
        public static extern int TCUSB18A_AnaInmA(int NModule, byte Voie, ref double Data);
        [DllImport("TCUSB18Ax64.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl, SetLastError = true, ExactSpelling = true)]
        public static extern int TCUSB18A_AnaOut(int NModule, byte Voie, short Data);
        [DllImport("TCUSB18Ax64.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl, SetLastError = true, ExactSpelling = true)]
        public static extern int TCUSB18A_AnaOutVolts(int NModule, byte Voie, double Data);
    }
}
