using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; namespace pac_i8048WNet { public class pac8048W { public delegate int PAC_CALLBACK_FUNC(); private class ICPDAS { [DllImport("pac_i8048W.dll", EntryPoint = "pac_i8048W_GetLibVersion")] public extern static short pac_i8048W_GetLibVersion(); [DllImport("pac_i8048W.dll", EntryPoint = "pac_i8048W_GetLibDate")] public extern static void pac_i8048W_GetLibDate(byte[] libDate); [DllImport("pac_i8048W.dll", EntryPoint = "pac_i8048W_Init")] public extern static int pac_i8048W_Init(int slot); [DllImport("pac_i8048W.dll", EntryPoint = "pac_i8048W_UnFreezeINT")] public extern static void pac_i8048W_UnFreezeINT(int Slot, int Channel); [DllImport("pac_i8048W.dll", EntryPoint = "pac_i8048W_InstallISR")] public extern static void pac_i8048W_InstallISR(int Slot, PAC_CALLBACK_FUNC f, int Priority); [DllImport("pac_i8048W.dll", EntryPoint = "pac_i8048W_Read_RisingEvent")] public extern static int pac_i8048W_Read_RisingEvent(int Slot, int Channel); [DllImport("pac_i8048W.dll", EntryPoint = "pac_i8048W_Read_FallingEvent")] public extern static int pac_i8048W_Read_FallingEvent(int Slot, int Channel); [DllImport("pac_i8048W.dll", EntryPoint = "pac_i8048W_Read_RisingEventCount")] public extern static uint pac_i8048W_Read_RisingEventCount(int Slot, int Channel); [DllImport("pac_i8048W.dll", EntryPoint = "pac_i8048W_Read_FallingEventCount")] public extern static uint pac_i8048W_Read_FallingEventCount(int Slot, int Channel); [DllImport("pac_i8048W.dll", EntryPoint = "pac_i8048W_Clear_RisingEventCount")] public extern static uint pac_i8048W_Clear_RisingEventCount(int Slot, int Channel); [DllImport("pac_i8048W.dll", EntryPoint = "pac_i8048W_Clear_FallingEventCount")] public extern static uint pac_i8048W_Clear_FallingEventCount(int Slot, int Channel); [DllImport("pac_i8048W.dll", EntryPoint = "pac_i8048W_Set_RisingReg")] public extern static void pac_i8048W_Set_RisingReg(int Slot, int Channel, int Enable); [DllImport("pac_i8048W.dll", EntryPoint = "pac_i8048W_Set_FallingReg")] public extern static void pac_i8048W_Set_FallingReg(int Slot, int Channel, int Enable); [DllImport("pac_i8048W.dll", EntryPoint = "pac_i8048W_Read_RisingReg")] public extern static int pac_i8048W_Read_RisingReg(int Slot, int Channel); [DllImport("pac_i8048W.dll", EntryPoint = "pac_i8048W_Read_FallingReg")] public extern static int pac_i8048W_Read_FallingReg(int Slot, int Channel); [DllImport("pac_i8048W.dll", EntryPoint = "pac_i8048W_DI_ALL")] public extern static int pac_i8048W_DI_ALL(int Slot); [DllImport("pac_i8048W.dll", EntryPoint = "pac_i8048W_DI_Ch")] public extern static int pac_i8048W_DI_Ch(int Slot, int Channel); } /// /// Get DLL version /// public static short LibVersion() { return ICPDAS.pac_i8048W_GetLibVersion(); } public static string LibDate() { byte[] libdate=new byte [32]; ICPDAS.pac_i8048W_GetLibDate(libdate); return Encoding.ASCII.GetString(libdate, 0, libdate.Length); } public static int Init(int slot) { return ICPDAS.pac_i8048W_Init(slot); } public static void UnFreezeINT(int slot, int channel) { ICPDAS.pac_i8048W_UnFreezeINT(slot,channel); } public static void InstallISR(int slot,PAC_CALLBACK_FUNC f,int priority) { ICPDAS.pac_i8048W_InstallISR(slot, f, priority); } public static int Read_RisingEvent(int slot,int channel) { return ICPDAS.pac_i8048W_Read_RisingEvent(slot, channel); } public static int Read_FallingEvent(int slot,int channel) { return ICPDAS.pac_i8048W_Read_FallingEvent(slot, channel); } public static uint Read_RisingEventCount(int slot,int channel) { return ICPDAS.pac_i8048W_Read_RisingEventCount(slot, channel); } public static uint Read_FallingEventCount(int slot, int channel) { return ICPDAS.pac_i8048W_Read_FallingEventCount(slot, channel); } public static uint Clear_RisingEventCount(int slot, int channel) { return ICPDAS.pac_i8048W_Clear_RisingEventCount(slot, channel); } public static uint Clear_FallingEventCount(int slot, int channel) { return ICPDAS.pac_i8048W_Clear_FallingEventCount(slot, channel); } public static void Set_RisingReg(int slot, int channel, int enable) { ICPDAS.pac_i8048W_Set_RisingReg(slot, channel,enable); } public static void Set_FallingReg(int slot, int channel, int enable) { ICPDAS.pac_i8048W_Set_FallingReg(slot, channel, enable); } public static int Read_RisingReg(int slot, int channel) { return ICPDAS.pac_i8048W_Read_RisingReg(slot, channel); } public static int Read_FallingReg(int slot, int channel) { return ICPDAS.pac_i8048W_Read_FallingReg(slot, channel); } public static int DI_ALL(int slot) { return ICPDAS.pac_i8048W_DI_ALL(slot); } public static int DI_Ch(int slot, int channel) { return ICPDAS.pac_i8048W_DI_Ch(slot,channel); } } }