// V1.00: 21/04/2011: MB : Release
// V1.01: 23/08/2012: DB : Correction Fonction Close: Void->int
// V1.02: 31/10/2014: DB : Correction Fonction Pos: 'ref uint Data'  -> 'ref int Data'
// V1.03: 03/11/2014: DB : Suppression fonction Open, Correction retour fonction Version (void->int)
// V1.04: 05/05/2017: JT : Ajout fonctions latch


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

namespace WindowsFormsApplication1
{
    class TCUSB16IO
    {
        /***********************************************************************************************************************************************\
        *********************************************************** OPERATIONS DE BASE ******************************************************************
        \***********************************************************************************************************************************************/
        [DllImport("TCUSB16IO.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall, SetLastError = true, ExactSpelling = true)]
        public static extern int TCUSB16IO_Refresh(int NModule);
        [DllImport("TCUSB16IO.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall, SetLastError = true, ExactSpelling = true)]
        public static extern int TCUSB16IO_OpenN(int NModule, ref uint NumSerie);
        [DllImport("TCUSB16IO.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall, SetLastError = true, ExactSpelling = true)]
        public static extern int TCUSB16IO_OpenN_InitOutput(int NModule, ref uint NumSerie, byte Data);
		[DllImport("TCUSB16IO.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall, SetLastError = true, ExactSpelling = true)]
        public static extern int TCUSB16IO_Close(int NModule);
        [DllImport("TCUSB16IO.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall, SetLastError = true, ExactSpelling = true)]
        public static extern int TCUSB16IO_Input(int NModule, ref uint Data);
        [DllImport("TCUSB16IO.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall, SetLastError = true, ExactSpelling = true)]
        public static extern int TCUSB16IO_Output(int NModule, byte Data);
        /***********************************************************************************************************************************************\
        *********************************************************** OPERATIONS SUR BITS *****************************************************************
        \***********************************************************************************************************************************************/
        [DllImport("TCUSB16IO.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall, SetLastError = true, ExactSpelling = true)]
        public static extern int TCUSB16IO_BitInput(int NModule, int Entree);
        [DllImport("TCUSB16IO.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall, SetLastError = true, ExactSpelling = true)]
        public static extern void TCUSB16IO_BitOutput(int NModule, int Sortie, int etat);
        [DllImport("TCUSB16IO.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall, SetLastError = true, ExactSpelling = true)]
        public static extern int TCUSB16IO_BitReadBack(int NModule, int Sortie);
        [DllImport("TCUSB16IO.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall, SetLastError = true, ExactSpelling = true)]
        public static extern int TCUSB16IO_Counter(int NModule, int Entree, ref byte Data);
        [DllImport("TCUSB16IO.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall, SetLastError = true, ExactSpelling = true)]
        public static extern int TCUSB16IO_Config(int NModule, byte Data);
        [DllImport("TCUSB16IO.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall, SetLastError = true, ExactSpelling = true)]
        public static extern int TCUSB16IO_Pos(int NModule, ref int Data);
        [DllImport("TCUSB16IO.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall, SetLastError = true, ExactSpelling = true)]
        public static extern int TCUSB16IO_ResetPos(int NModule);
        [DllImport("TCUSB16IO.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall, SetLastError = true, ExactSpelling = true)]
        public static extern int TCUSB16IO_ConfigLatch(int NModule, byte Data);
        [DllImport("TCUSB16IO.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall, SetLastError = true, ExactSpelling = true)]
        public static extern int TCUSB16IO_Latch(int NModule, byte Latch, ref int Data);
        [DllImport("TCUSB16IO.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall, SetLastError = true, ExactSpelling = true)]
        public static extern int TCUSB16IO_WdgRun(int NModule);
        [DllImport("TCUSB16IO.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall, SetLastError = true, ExactSpelling = true)]
        public static extern void TCUSB16IO_WdgStop(int NModule);
        [DllImport("TCUSB16IO.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall, SetLastError = true, ExactSpelling = true)]
        public static extern void TCUSB16IO_WdgRearm(int NModule);
        [DllImport("TCUSB16IO.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall, SetLastError = true, ExactSpelling = true)]
        public static extern void TCUSB16IO_ResetPort(int NModule);
        [DllImport("TCUSB16IO.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall, SetLastError = true, ExactSpelling = true)]
        public static extern void TCUSB16IO_CyclePort(int NModule);
        [DllImport("TCUSB16IO.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall, SetLastError = true, ExactSpelling = true)]
        public static extern int TCUSB16IO_Version(int NModule, ref byte Data1, ref byte Data2);

        
    }
}
