Rockwell Automation 1747-PCIS API Software - Open Controller User Manual
Page 48

Publication 1747-UM002A-US-P - June 2000
3-16 Developing Applications
/* Download the configuration to the scanner */
if (SUCCESS != (rc = OC_DownloadIOConfiguration(OChandle, &OCcfg)))
{
printf("\nERROR: OC_DownloadIOConfiguration failed: %d\n", rc);
Ioexit(1);
}
/* Set output update mode to always */
if (SUCCESS != (rc = OC_SetOutputUpdateMode(OChandle, OUTUPD_ALWAYS)))
{
printf("\nERROR: OC_SetOutputUpdateMode failed: %d\n", rc);
Ioexit(1);
}
/* Set scan time to 5ms, periodic scan mode */
if (SUCCESS != (rc = OC_SetScanTime(OChandle, SCAN_PERIODIC, 20)))
{
printf("\nERROR: OC_SetScanTime failed: %d\n", rc);
Ioexit(1);
}
/* Goto Scan Mode */
if (SUCCESS != (rc = OC_SetScanMode(OChandle, SCAN_RUN)))
{
printf("\nERROR: OC_SetScanMode failed: %d\n", rc);
Ioexit(1);
}
/* Turn on User LED 1 */
if (SUCCESS != (rc = OC_SetUserLEDState(OChandle, 1, LED_GREEN_SOLID)))
{
printf("\nERROR: OC_SetUserLEDState failed: %d\n", rc);
Ioexit(1);
}
/* Read word 0 of IB32 module */
if ( IB32slot != 0 )
{ if (SUCCESS != (rc = OC_ReadInputImage(OChandle, NULL, IB32slot, 0,
1, &wData)))
{
printf("\nERROR: OC_ReadInputImage failed: %d\n", rc);
Ioexit(1);
} }
/* Write the data read to word 2 of BAS module M0 file */
wLen = 1; if ( BASslot != 0 )
{
if (SUCCESS != (rc = OC_WriteModuleFile(OChandle, FILTYP_M0, &wData,
BASslot, 2, wLen)))
{
printf("\nERROR: OC_WriteModuleFile failed: %d\n", rc);
Ioexit(1);
}
}
/* Close the scanner before exiting */
OC_CloseScanner(OChandle);
return(0);
} /* end main()*/
Configure the
scanner.
Control scanner
operation.
Scan I/O