Libraries
cmd_api_r3/cmd_api_r3_main.c
#include <stdio.h>
//
// NOTE: This example requires that a POIC command destination is activated
// to work properly.
//
// This example shows how to use several of the Release 3 Compatible
// ANSI-C functions.
//
int main()
{
int ret_value;
double dbl_value;
POIC_Command_System_Status status;
//
// Get the command system status for a POIC destination and check to see if the user
// is enabled.
//
ret_value = GetPOICCommandSystemStatus( "POIC", &status );
if( ret_value )
printf( "Error %d when attempting to get the command system status.\n", ret_value );
else
{
if( status.user_enabled )
printf( "User is enabled.\n" );
else
printf( "User is disabled.\n" );
}
//
// Update a command field for a local command.
//
ret_value = UpdateNumericFieldValue( COMMAND_FIELD, // update a command field
"POIC", // at this destination
"LOAD_PARAMETER", // command name
"WORD04", // field name
12.5 ); // new value
if( ret_value )
printf( "Error %d when updating numeric field.\n", ret_value );
else
{
// Get the value back...just because you can.
ret_value = GetNumericFieldValue( COMMAND_FIELD, // get a command field
"POIC", // from this destination
"LOAD_PARAMETER", // command name
"WORD04", // field name
&dbl_value ); // the value
if( ret_value )
printf( "Error %d when retrieving number field value.\n", ret_value );
else
printf( "Value is %lf.\n", dbl_value );
}
//
// Now can send the local copy of the command to the destination.
//
ret_value = BuildAndUplinkCommand( "POIC", // where to send the command
"LOAD_PARAMETER" ); // the command to send
if( ret_value )
printf( "Error %d when attempting to build and uplink a command.\n", ret_value );
else
printf( "Command successfully sent.\n" );
//
// You can also update the destination database and uplink their copy of the
// command.
//
ret_value = UpdatePOICDatabase( COMMAND_FIELD, // always this value for POIC
"POIC", // where it's going
"LOAD_PARAMETER" ); // the command to update
if( ret_value )
printf( "Error %d when updating the POIC database.\n", ret_value );
else
{
ret_value = UplinkPOICCommand( "POIC", // where to send the request
"LOAD_PARAMETER" ); // command to uplink
if( ret_value )
printf( "Error %d when requesting command uplink.\n", ret_value );
else
printf( "Updated and uplinked the command from the POIC database.\n" );
}
return 0;
}