#include <windows.h>
#include <v_lib.h>

#define REF_LEN	15

/*
 * Force
 */
static vec_t F_data[REF_LEN] =
{
	0,
	460,
	1000,
	1500,
	3000,
	5000,
	10000,
	15000,
	20000,
	25000,
	30000,
	35000,
	40000,
	45000,
	50000
};

static vector_t Fvect = {REF_LEN, F_data};

/*
 * Deformation of the tensile machine
 */
static vec_t D_data[REF_LEN] =
{
	0,
	0.105,
	0.196,
	0.2548,
	0.4018,
	0.551,
	0.895,
	1.205,
	1.49,
	1.745,
	2.005,
	2.26,
	2.495,
	2.735,
	2.99
};

static vector_t Dvect = {REF_LEN, D_data};

vhandle_t F2D = LIBV_INVALID_HANDLE;

/*
 * Main routine to call from MS Excel
 */
double V_GLOBAL DforF(double F)
{
	return cspInterpolate(F2D,F);
}

BOOL WINAPI EntryPoint(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved)
{
	switch(fdwReason)
	{
		case DLL_PROCESS_ATTACH:
			F2D = cspCreate(&Fvect,&Dvect);
			break;
		case DLL_PROCESS_DETACH:
			cspDestroy(F2D);
			break;
	}
	return TRUE;
}
