// i8172W_FR_2054DIO.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include #include "pac_i8172W.h" #pragma comment(lib,"pac_i8172W.lib") static int slotIndex=-1; int main(int argc, char* argv[]) { int slot = -1,iRet=0; int diData,group,i,channel,mode,status,port,doData,bitVal; for(slot=0;slot<8;slot++) { if(pac_i8172W_Init(slot)==0) { slotIndex=slot; break; } } if(slotIndex==-1) { printf("There is no i8172W at Backplane\n"); getchar(); return -1; } else { printf("There is an i8172W at slot %d\n",slotIndex); } printf("Please input the port number of i-8172W 0 or 1:"); scanf("%d",&port); printf("\nPlease input the group index of FR-2054 0~7 :"); scanf("%d",&group); printf("\nPlease select operation mode:\n"); printf("0. Write single channel output \n"); printf("1. Write multi channel output \n"); printf("2. Read single channel input \n"); printf("3. Read all channel input \n"); printf("\Input operation mode:\n"); scanf("%d",&mode); switch(mode) { // for FRNet Output mode, group will be 0 ~ 7 case 0: printf("\nPlease input channel number(0~7):"); scanf("%d",&bitVal); printf("\nPlease input status(0.OFF, 1.ON ):"); scanf("%d",&status); pac_i8172W_DIO_WriteDOBit(slotIndex,port,group,bitVal,status); break; case 1: printf("\nEnter DO Data 0 ~ 0xff :"); scanf("%X",&doData); pac_i8172W_DIO_WriteDOGroup(slotIndex,port,group,doData & 0xff); break; case 2: diData=pac_i8172W_DIO_ReadDIGroup(slotIndex,port,group + 8); printf("DIdata %X\n\r",diData); break; // for input mode, group will be 8 ~ 15 case 3: printf("\nPlease select DI channel number:"); scanf("%d",&channel); iRet=pac_i8172W_DIO_ReadDIBit(slotIndex,port,group + 8,channel); if(iRet) printf("\nThe Channel %d is on.",channel); else printf("\nThe Channel %d is off.",channel); break; } getchar(); return 0; }