
#include "LCICLink.h"

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

BOOL (WINAPI* LCICClose)(HANDLE);
HANDLE (WINAPI* LCICOpen)(LPSTR);
BOOL (WINAPI* LCICInit)(HANDLE);
BOOL (WINAPI* LCICDone)(HANDLE);
BOOL (WINAPI* LCICRead)(HANDLE, PFLOAT);
BOOL (WINAPI* LCICPoll)(HANDLE, PFLOAT);
BOOL (WINAPI* LCICReadDigitalOutputs)(HANDLE, PDWORD);
BOOL (WINAPI* LCICWriteDigitalOutputs)(HANDLE, DWORD);
BOOL (WINAPI* LCICReadDigitalInputs)(HANDLE, PDWORD);
BOOL (WINAPI* LCICSetup)(HWND, LPSTR);
BOOL (WINAPI* SpeakerClick)(HANDLE);

HINSTANCE LoadLoadcellLibrary(void) {
	HINSTANCE Instance;
   Instance = LoadLibrary("Loadcell");
   if (Instance) {
      (PVOID)LCICOpen = GetProcAddress(Instance, "LCICOpen");
      (PVOID)LCICClose = GetProcAddress(Instance, "LCICClose");
      (PVOID)LCICInit = GetProcAddress(Instance, "LCICInit");
      (PVOID)LCICDone = GetProcAddress(Instance, "LCICDone");
      (PVOID)LCICRead = GetProcAddress(Instance, "LCICRead");
      (PVOID)LCICPoll = GetProcAddress(Instance, "LCICPoll");
      (PVOID)LCICReadDigitalOutputs = GetProcAddress(Instance, "LCICReadDigitalOutputs");
      (PVOID)LCICWriteDigitalOutputs = GetProcAddress(Instance, "LCICWriteDigitalOutputs");
      (PVOID)LCICReadDigitalInputs = GetProcAddress(Instance, "LCICReadDigitalInputs");
      (PVOID)LCICSetup = GetProcAddress(Instance, "LCICSetup");
      (PVOID)SpeakerClick = GetProcAddress(Instance, "SpeakerClick");
   }
   return Instance;
}

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

