ADS-Zugriff via Win32 Application
Programmierbeispiel
static BOOLEAN writeContourParameters(
UNS16 channel_nr, UNS32 grid, REAL64 abs_error, REAL64 rel_error)
{
SGN32 result;
SGN32 idx_group = 0x20100 + channel_nr;
if ((channel_nr < 1) || (channel_nr > SYS_KANAL_MAX))
return FALSE;
result = AdsSyncWriteReq( &amsCom, // Ams address of ADS server
idx_group, // index group:
0x89, // index offset:
sizeof(grid), // count of bytes to read
&grid); // pointer to the client buffer
if (0 != result)
return FALSE;
result = AdsSyncWriteReq( &amsCom, // Ams address of ADS server
idx_group, // index group:
0x8c, // index offset:
sizeof(abs_error),// count of bytes to read
&abs_error); // pointer to the client buffer
if (0 != result)
return FALSE;
result = AdsSyncWriteReq( &amsCom, // Ams address of ADS server
idx_group, // index group:
0x8B, // index offset:
sizeof(rel_error),// count of bytes to read
&rel_error); // pointer to the client buffer
if (0 != result)
return FALSE;
return TRUE;
}
static BOOLEAN activateContourVisu( UNS16 channel_nr)
{
SGN32 result;
SGN32 idx_group = 0x20100 + channel_nr;
UNS32 execution_mode = SOLLKON;
if ((channel_nr < 1) || (channel_nr > SYS_KANAL_MAX))
return FALSE;
result = AdsSyncWriteReq( &amsCom, // Ams address of ADS server
idx_group, // index group:
0x3f, // index offset:
sizeof(execution_mode),
&execution_mode);
if (0 != result)
return FALSE;
return TRUE;
}
static BOOLEAN readContourData (
SOLLVISU_PDU_CHAN *p_visu_pdu, UNS16 channel_nr)
{
SGN32 result;
UNS32 count;
UNS32 fifo_count;
SGN32 idx_group = 0x20100 + channel_nr;
if ((channel_nr < 1) || (channel_nr > SYS_KANAL_MAX))
return FALSE;
// Read number of enties in visualisation output fifo
result = AdsSyncReadReqEx( &amsCom, // Ams address of ADS server
idx_group, // index group:
0x2001, // index offset:
sizeof(fifo_count),
&fifo_count,
&count);
if (0 != fifo_count)
{
// Data present, read via COM
result = AdsSyncReadReqEx( &amsCom, // Ams address of ADS server
idx_group, // index group:
0x2000, // index offset:
sizeof(*p_visu_pdu),
p_visu_pdu,
&count)
if (0 == result)
return TRUE;
}
return FALSE;
}