// ---------------------------
// (c) Copyright 2001
// The parvus Corporation
// 396 Ironwood Drive
// Salt Lake City, UT 84115
// Tel:      (801) 483-1533
// Fax:      (801) 483-1523
// Web:      www.parvus.com
// Email:    parvus@parvus.com
// ---------------------------

// ===============================
// prvvc_EnvFan.cpp
// for EnvFan board
// ===============================

//   ----------------
//   Revision History:
//   ----------------
//
//   01-01-2002 PRM - V1.00.00 release
//

#include "stdafx.h"
#include <windows.h>
#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <stdlib.h>

#include "prvapp_EnvFan.h"

// -------------------------------
// Global Variables
// The following are defined in prvapp_EnvFan.h 
// and declared in prvdrv_app.c
// -------------------------------
//extern int darray[30][2];
//extern int darray_end;
//extern int *test_num;

// --------------
// main() program
// --------------
void main(void)
{	
	int i;
	char c;
	FILE *fp;
	int result;

	// ---------------
	// Open the Driver
	// ---------------
	vbapp_Open(0);

	//------------------
	// Do file IO
	//------------------
	
	/* Open for read (will fail if file "data.txt" does not exist) */
	if( (fp  = fopen( "prv_.ini", "r" )) == NULL ) {
		printf( "Factory settings are being used.\n" );
		/* so use defaults								*/
		//Set_Defaults();
		vbapp_FactoryCfg();
		vbapp_LedOff();			//turn led off so you know you're talking 
								//to the board
		return;
	}
	else {
		/* Load global array to be used by vb_Init */
		i = 0;
		printf( "The file 'prv_EnvFan.ini' was opened\n" );
		result = fscanf( fp, "%i %c %i", &darray[i][0], &c, &darray[i][1]);
		while ( result != EOF) {
			i++;
			result = fscanf( fp, "%i %c %i", &darray[i][0], &c, &darray[i][1]);
		}
		darray_end = i;
		//printf(" darray_end = %i \n",darray_end);
	}

	//vbapp_Init();		//init EnvFan board
	vbapp_LedOff();			//turn led off so you know you're talking 
							//to the board
//ExitProgram:
	vbapp_Close();
}

