
#include "Lc4hsLink.h"

// LCICLink.c to dynamically bind with Loadcell.dll

BOOL (WINAPI* Lc4hsSetup)(HWND hWnd, LPSTR DeviceName, BOOL CheckAddress);
HANDLE (WINAPI* Lc4hsOpen)(LPSTR DeviceName);
BOOL (WINAPI* Lc4hsInit)(HANDLE Card);
BOOL (WINAPI* Lc4hsFinish)(HANDLE Card);
BOOL (WINAPI* Lc4hsGetCardStatus)(HANDLE Card, BOOL *CardStatus);
BOOL (WINAPI* Lc4hsGetCardVersion)(HANDLE Card, DWORD *CardVersion);
BOOL (WINAPI* Lc4hsGetChannelStatus4)(HANDLE Card, BOOL *Status);
BOOL (WINAPI* Lc4hsGetChannelStatus)(HANDLE Card, DWORD Channel, BOOL *Status);
BOOL (WINAPI* Lc4hsGetZeroAD4)(HANDLE Card, DWORD *ZeroAD);
BOOL (WINAPI* Lc4hsGetZeroAD)(HANDLE Card, DWORD Channel, DWORD *ZeroAD);
BOOL (WINAPI* Lc4hsGetCurrentWeight4)(HANDLE Card, FLOAT *CurrentWeight);
BOOL (WINAPI* Lc4hsGetCurrentWeight)(HANDLE Card, DWORD Channel, FLOAT *CurrentWeight);
BOOL (WINAPI* Lc4hsPollCurrentWeight4)(HANDLE Card, FLOAT *CurrentWeight);
BOOL (WINAPI* Lc4hsPollCurrentWeight)(HANDLE Card, DWORD Channel, FLOAT *CurrentWeight);
BOOL (WINAPI* Lc4hsGetCurrentAD4)(HANDLE Card, DWORD *CurrentAD);
BOOL (WINAPI* Lc4hsGetCurrentAD)(HANDLE Card, DWORD Channel, DWORD *CurrentAD);
BOOL (WINAPI* Lc4hsPollCurrentAD4)(HANDLE Card, DWORD *CurrentAD);
BOOL (WINAPI* Lc4hsPollCurrentAD)(HANDLE Card, DWORD Channel, DWORD *CurrentAD);
DWORD (WINAPI* Lc4hsGetDigitalOutput)(HANDLE Card, DWORD BitNo, BOOL *Value);
BOOL (WINAPI* Lc4hsSetDigitalOutput)(HANDLE Card, DWORD BitNo, BOOL Value);
BOOL (WINAPI* Lc4hsGetDigitalInput)(HANDLE Card, DWORD BitNo, BOOL *Value);
BOOL (WINAPI* Lc4hsReadIO)(HANDLE Card, DWORD *IOData);
BOOL (WINAPI* Lc4hsGetErrorMsg)(DWORD Code, LPSTR lpBuffer, DWORD nSize);


HINSTANCE LoadLc4hsLibrary(void) {
	HINSTANCE Instance;
   Instance = LoadLibrary("Lc4hs");
   if (Instance) {
      (PVOID)Lc4hsSetup = GetProcAddress(Instance, "Lc4hsSetup");
      (PVOID)Lc4hsOpen = GetProcAddress(Instance, "Lc4hsOpen");
      (PVOID)Lc4hsInit = GetProcAddress(Instance, "Lc4hsInit");
      (PVOID)Lc4hsFinish = GetProcAddress(Instance, "Lc4hsFinish");
      (PVOID)Lc4hsGetCardStatus = GetProcAddress(Instance, "Lc4hsGetCardStatus");
      (PVOID)Lc4hsGetCardVersion = GetProcAddress(Instance, "Lc4hsGetCardVersion");
      (PVOID)Lc4hsGetChannelStatus4 = GetProcAddress(Instance, "Lc4hsGetChannelStatus4");
      (PVOID)Lc4hsGetChannelStatus = GetProcAddress(Instance, "Lc4hsGetChannelStatus");
      (PVOID)Lc4hsGetZeroAD4 = GetProcAddress(Instance, "Lc4hsGetZeroAD4");
      (PVOID)Lc4hsGetZeroAD = GetProcAddress(Instance, "Lc4hsGetZeroAD");
      (PVOID)Lc4hsGetCurrentWeight4 = GetProcAddress(Instance, "Lc4hsGetCurrentWeight4");
      (PVOID)Lc4hsGetCurrentWeight = GetProcAddress(Instance, "Lc4hsGetCurrentWeight");
      (PVOID)Lc4hsPollCurrentWeight4 = GetProcAddress(Instance, "Lc4hsPollCurrentWeight4");
      (PVOID)Lc4hsPollCurrentWeight = GetProcAddress(Instance, "Lc4hsPollCurrentWeight");
      (PVOID)Lc4hsGetCurrentAD4 = GetProcAddress(Instance, "Lc4hsGetCurrentAD4");
      (PVOID)Lc4hsGetCurrentAD = GetProcAddress(Instance, "Lc4hsGetCurrentAD");
      (PVOID)Lc4hsPollCurrentAD4 = GetProcAddress(Instance, "Lc4hsPollCurrentAD4");
      (PVOID)Lc4hsPollCurrentAD = GetProcAddress(Instance, "Lc4hsPollCurrentAD");
      (PVOID)Lc4hsGetDigitalOutput = GetProcAddress(Instance, "Lc4hsGetDigitalOutput");
      (PVOID)Lc4hsSetDigitalOutput = GetProcAddress(Instance, "Lc4hsSetDigitalOutput");
      (PVOID)Lc4hsGetDigitalInput = GetProcAddress(Instance, "Lc4hsGetDigitalInput");
      (PVOID)Lc4hsReadIO = GetProcAddress(Instance, "Lc4hsReadIO");
      (PVOID)Lc4hsGetErrorMsg = GetProcAddress(Instance, "Lc4hsGetErrorMsg");
   }
   return Instance;
}

VOID UnloadLc4hsLibrary(HINSTANCE Instance) {
	FreeLibrary(Instance);
}

