/* Test with I-8024 AO Module and I-8017H AI Module at Slot 01 and 02 of LinCon seperately
   
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2, or (at your option)
   any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software Foundation,
   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
    
   File level history (record changes for this file here.)

   i8kaio.c
   
   v1.0 2017.4.18 by Winson
  
*/
#include<stdio.h>
#include<stdlib.h>
#include "msw.h"
#include "i9017_15.h"
	
int main()
{
	int slot, channel, wRetVal, gain, type;
	float fAi = 0;

	printf("Select Slot:");
	scanf("%d",&slot);
	printf("Input signal: \n0. Differential \n1. Single-ended\n");
	scanf("%d",&type);
	printf("Select channel:");
	scanf("%d",&channel);
	printf("Select gain:");
	scanf("%d",&gain);

	wRetVal = Open_Slot(slot);
	if (wRetVal > 0) {
		printf("open Slot failed!\n");
		return (-1);
	}

	wRetVal = I9017_15_Init(slot);
	if(wRetVal == -1)
		printf("Slot%d doesn't have I-9017-15 device\n", slot);
	I9017_15_SetSingleEnd(slot, type);	//second parameter 0 -> Differential, 1 -> Single-ended
	I9017_15_ReadAI(slot,channel,gain,&fAi);

	printf("\nI-9017-15 Analog input %f\n",fAi);

	Close_Slot(slot);
	return 0;
}
