Rockwell Automation 1747-PCINT API Software for 1746 I/O User Manual
Page 34
3–8
Developing Applications
Publication 1747-6.5.3 June 1998
/*
** Read switch position
*/
retcode = OC_GetSwitchPosition( Handle, &swpos );
if ( retcode != SUCCESS )
{
printf( ”\nERROR: OC_GetSwitchPosition failed: %d\n”, retcode );
Ioexit( 1 );
}
printf( ”\n\n Switch position: ” );
switch( swpos )
{
case SWITCH_TOP:
printf( ”Top \n” );
break;
case SWITCH_BOTTOM:
printf( ”Bottom \n” );
break;
case SWITCH_MIDDLE:
printf( ”Middle \n” );
break;
}
delay( 3000 );
/*
** Read auto-config
*/
retcode = OC_GetIOConfiguration( Handle, &OCcfg );
if ( retcode != SUCCESS )
{
printf( ”\nERROR: OC_GetIOConfiguration failed: %d\n”, retcode );
Ioexit( 1 );
}
/*
** Display rack configuration
*/
slots = OCcfg.Rack1Size + OCcfg.Rack2Size + OCcfg.Rack3Size;
if ( slots > 31 )
slots = 31;
printf( ”\n\n Chassis configuration ” );
for ( i=1; i < slots; i++ )
{
if ( OCcfg.SlotCfg[i].type != 0xff )
printf( ”\n Slot %2d: Type %2d, Mix %3d %s”,
i, OCcfg.SlotCfg[i].type, OCcfg.SlotCfg[i].mix,
OCcfg.SlotCfg[i].Name );
else
printf( ”\n Slot %2d: %s”, i, OCcfg.SlotCfg[i].Name );
/* Find digital input card */
if ( OCcfg.SlotCfg[i].mix < 8 && !input_found )
{
input_found = 1;
input_slot = i;
}
/* Find digital output card */
if ( (OCcfg.SlotCfg[i].mix > 7) && (OCcfg.SlotCfg[i].mix < 32) && !output_found )
{
output_found = 1;
output_slot = i;
}
}
delay( 3000 );