Rockwell-automation 1747-PCIS API Software - Open Controller Instrukcja Użytkownika Strona 42

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 174
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 41
Publication 1747-UM002A-US-P - June 2000
3-10 Developing Applications
/*
** Read first Input word
*/
retcode = OC_ReadInputImage( Handle, NULL, input_slot, 0, 1, &wData );
if ( retcode != SUCCESS )
{
printf( ”\nERROR: OC_ReadInputImage failed: %d\n”, retcode );
Ioexit( 1 );
}
printf( ”\n\n First input image data word --> 0x%04x \n”, wData );
delay( 3000 );
/*
** Write to the first Output word
*/
printf( ”\n\n Incrementing first discrete output word. \n” );
for ( wData=0; wData < 256; wData++)
{
retcode = OC_WriteOutputImage( Handle, NULL, output_slot, 0, 1,
&wData );
if ( retcode != SUCCESS )
{
printf(”\nERROR: OC_WriteOutputImage failed: %d\n”,
retcode);
Ioexit(1);
}
delay ( 10 );
}
/*
** Must always close the scanner before exiting
*/
OC_CloseScanner( Handle );
printf( ”\n\n Program is done! \n\n” );
} /* end main() */
/************************************************************************
*
* Name: Ioexit
*
* Description:
*
* Common error handling routine. This routine displays any
* extended error and exits the program.
*
* Arguments:
* retcode : int ( input )
* This error code is passed to the exit() routine.
*
* External effects:
* The program is terminated.
*
* Return value:
* none
*
************************************************************************/
void Ioexit( int retcode )
{
OCEXTERR exterr;
char *msg;
if (OC_GetExtendedError(Handle, &exterr) == SUCCESS)
{
if ( exterr.ErrorCode != 0 )
{
Scan I/O
Przeglądanie stron 41
1 2 ... 37 38 39 40 41 42 43 44 45 46 47 ... 173 174

Komentarze do niniejszej Instrukcji

Brak uwag