Documentation

xPCGetSignals

Return vector of signal values

Prototype

int xPCGetSignals(int port, int numSignals, const int *signals, 
double *values);

Arguments

port

Enter the value returned by the function xPCOpenTcpIpPort.

numSignals

Enter the number of signals to be acquired (that is, the number of values in signals).

signals

Enter the list of signal numbers to be acquired.

values

Returned values are stored in the double array values.

Return

If the function completes execution without detecting an error, it returns 0. If the function detects an error, it returns -1.

Description

The xPCGetSignals function is the vector version of the function xPCGetSignal. This function returns the values of a vector of signals (up to 1000) as fast as it can acquire them. The function acquires some signal values in one time step and later signals in another. To acquire signal values within one time step, define a scope of type SCTYPE_HOST and use xPCScGetData. xPCGetSignal does the same thing for a single signal, and could be used multiple times to achieve the same result. However, the xPCGetSignals function is faster, and the signal values are more likely to be spaced closely together. The signals are converted to doubles regardless of the actual data type of the signal.

For signals, store the list you provide in an integer array. Get the signal numbers with the function xPCGetSignalIdx.

Example

To reference signal vector data rather than scalar values, pass a vector of indices for the signal data. For example:

/**********************************************************/ 
 
/* Assume a signal of width 10, with the blockpath 
* mySubsys/mySignal and the signal index s1. 
*/ 
 
int i; 
int sigId[10]; 
double sigVal[10]; /* Signal values are stored here */ 
 
/* Get the ID of the first signal */ 
sigId[0] = xPCGetSignalIdx(port, "mySubsys/mySignal/s1"); 
 
if (sigId[0] == -1) { 
/* Handle error */ 
} 
 
for (i = 1; i < 10; i++) { 
     sigId[i] = sigId[0] + i; 
} 
 
xPCGetSignals(port, 10, sigId, sigVal); 
/* If no error, sigVal should have the signal values */ 
 
/***********************************************************/

To get the signals repeatedly, repeat the call to xPCGetSignals. If you do not change sigID, call xPCGetSignalIdx only once.

Introduced before R2006a

Was this topic helpful?