// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (C) Production Robots Engineering Ltd
// martin@prel.co.uk
//
//
//  MODULE:   Lc4hs.h
//
//  PURPOSE:
//	Contains declarations for use by applications and other DLLs that
//	will implicitly link to Lc4hs.dll with Lc4hs.lib. To Explictly
//	link use Lc4hsLink.h & Lc4hsLink.c


#ifndef INC_LC4HS_H
#define INC_LC4HS_H

#include <windows.h>

#ifdef __cplusplus

#define DLLIMPORT extern "C" __declspec(dllimport)

#else

#define DLLIMPORT __declspec(dllimport)

#endif

DLLIMPORT BOOL WINAPI Lc4hsSetup(HWND hWnd, LPSTR DeviceName, BOOL CheckAddress);
/*	This function opens the configuration dialog for the device
	named by DeviceName e.g 'LC4HS1', 'LC4HS2', 'LC4HS3' etc.. 
	hWnd is the dialogs parent window (may be NULL). Returns 
	true if configuration changed (user clicks OK) else FALSE.
	Use this function to edit config data stored in the registry.
	If CheckAddress is true, the selected address will be checked
	before dialog is closed.
*/

DLLIMPORT HANDLE WINAPI Lc4hsOpen(LPSTR DeviceName);
/*	DeviceName = 'LC4HS1', 'LC4HS2', 'LC4HS3' etc..
	Returns File handle for subsequent use as 'Card' parameter
	to other API functions. Returns INVALID_FILE_HANDLE if
	fails. Call GetLastError for more info
*/

/*	For the following functions the Card parameter is a file handle
	returned by a successful call to Lc4hsOpen.

	Return Values:
	All the following functions return TRUE if the call proceeds without an
	error, otherwise FALSE. If the call returns FALSE then call GetLastError
	for an extended error code.
*/

DLLIMPORT BOOL WINAPI Lc4hsInit(HANDLE Card);
/*	Initialises card. Returns TRUE if OK otherwise FALSE.
	Call GetLastError for error information. This function
	will return TRUE and do nothing if card already initialised.
*/

DLLIMPORT BOOL WINAPI Lc4hsFinish(HANDLE Card);
/*    Finalises card. Does nothing if card not initialised.
*/

DLLIMPORT BOOL WINAPI Lc4hsGetCardStatus(HANDLE Card, BOOL *CardStatus);
/*	CardStatus points to single BOOL. Set TRUE if card initialised,
	otherwise FALSE.
*/

DLLIMPORT BOOL WINAPI Lc4hsGetCardVersion(HANDLE Card, DWORD *CardVersion);
/*	CardVersion points to single DWORD which receives card version number.
*/

DLLIMPORT BOOL WINAPI Lc4hsGetChannelStatus4(HANDLE Card, BOOL *Status);

DLLIMPORT BOOL WINAPI Lc4hsGetChannelStatus(HANDLE Card, DWORD Channel, BOOL *Status);
/*	Status points to array of 4 BOOL.
	Sets the value of Status[N] TRUE if channel N is calibrated, otherwise
	FALSE
*/

DLLIMPORT BOOL WINAPI Lc4hsGetZeroAD4(HANDLE Card, DWORD *ZeroAD);
/*	ZeroAD points to array of 4 DWORDs
*/

DLLIMPORT BOOL WINAPI Lc4hsGetZeroAD(HANDLE Card, DWORD Channel, DWORD *ZeroAD);

DLLIMPORT BOOL WINAPI Lc4hsGetCurrentWeight4(HANDLE Card, FLOAT *CurrentWeight);
/*	This function requests an A/D update from the card then waits for the
	result. The current weight value for all four channels is returned via
	the CurrentWeight parameter which must point to array of 4 FLOAT
*/

DLLIMPORT BOOL WINAPI Lc4hsGetCurrentWeight(HANDLE Card, DWORD Channel, FLOAT *CurrentWeight);

DLLIMPORT BOOL WINAPI Lc4hsPollCurrentWeight4(HANDLE Card, FLOAT *CurrentWeight);
/*	This function reads the current weight value from the card without first
	requesting an A/D update. The function then requests an update and returns
	immediately without waiting. Data for all four channels is returned via the
	CurrentWeight parameter which must point to array of 4 FLOAT
*/

DLLIMPORT BOOL WINAPI Lc4hsPollCurrentWeight(HANDLE Card, DWORD Channel, FLOAT *CurrentWeight);

DLLIMPORT BOOL WINAPI Lc4hsGetCurrentAD4(HANDLE Card, DWORD *CurrentAD);
/*	This function requests an A/D update from the card then waits for the
	result. The A/D value for all four channels is returned via the CurrentAD
	parameter which must point to array of 4 DWORD
*/

DLLIMPORT BOOL WINAPI Lc4hsGetCurrentAD(HANDLE Card, DWORD Channel, DWORD *CurrentAD);

DLLIMPORT BOOL WINAPI Lc4hsPollCurrentAD4(HANDLE Card, DWORD *CurrentAD);
/*	This function reads the current weight value from the card without first
	requesting an A/D update. The function then requests an update and returns
	immediately without waiting. The A/D value for all four channels is
	returned via the CurrentAD parameter which must point to array of 4 WORD
*/

DLLIMPORT BOOL WINAPI Lc4hsPollCurrentAD(HANDLE Card, DWORD Channel, DWORD *CurrentAD);

DLLIMPORT DWORD WINAPI Lc4hsGetDigitalOutput(HANDLE Card, DWORD BitNo, BOOL *Value);
/*	Value points to a single BOOL which is set true if bit number BitNo is set in
	the	digital output register.
*/

DLLIMPORT BOOL WINAPI Lc4hsSetDigitalOutput(HANDLE Card, DWORD BitNo, BOOL Value);
/*	Bit number BitNo is switched ON if Value is TRUE otherwise switched OFF.
*/	

DLLIMPORT BOOL WINAPI Lc4hsGetDigitalInput(HANDLE Card, DWORD BitNo, BOOL *Value);
/*	Value points to a single BOOL which is set true if bit number BitNo is set in
	the	digital input register.
*/

DLLIMPORT BOOL WINAPI Lc4hsReadIO(HANDLE Card, DWORD *IOData);
/*  Use this function to read the state of all outputs and inputs at once.
	Low Byte of IOData contains outputs, High byte contains inputs
*/

DLLIMPORT BOOL WINAPI Lc4hsGetErrorMsg(DWORD Code, LPSTR lpBuffer, DWORD nSize);
/*  Converts an LCIC specific error code (returned by GetLastError) into a string
	Returns TRUE if code recognised, otherwise FALSE. If this function returns
	FALSE then this might be a standard Windows Error Code. See FormatMessage
*/

#endif  // INC_LC4HS_H
