help | logout
RSP_giveGraphData

RSP_giveGraphData

Name

RSP_giveGraphData -- Send graph data to RSPD.

Synopsis

int RSP_giveGraphData(RSP_moduleBackend *mod, RSP_graphReturnData *graphData);

Description

This function copies the address of graphData to an internal structure. When RSP_postMessage() is called, the data pointed to by the given address will be sent to the RSPD. The RSP_graphReturnData structure contains three elements, for graph type, graph key name, and graph data. The data structure is defined as follows:

typedef struct _RSP_graphReturnData
{
	int iType;
	char* szKey;
	char* szData;
} RSP_graphReturnData;
				

All three elements should be set. RSP_giveGraphData can be called as many times as you like, for each different piece of graph data. The same data structure can be used and changed each time, as interally a copy is made of the argument. iType can be any of the following values:

  • GRAPH_NONE

  • GRAPH_TIME - szData is a string containing a number representing seconds

  • GRAPH_SMALLTIME - szData is a string containing a number representing microseconds (millionths of a second)

  • GRAPH_BIGSIZE - szData is a string containing a number representing megabytes

  • GRAPH_SMALLSIZE - szData is a string containing a number representing bytes

  • GRAPH_PERCENT - szData is a string containing a floating point number between 0 and 1

  • GRAPH_BOOL - szData is "0" or "1"

  • GRAPH_MISC - szData is of a type not defined above

The reason for having different data types is that when graph data is saved an analyzed in the future, conversions can be made on types that are known. This makes graphs easier to read and avoids unusually large or small numbers (for example, bytes in the millions, where megabytes would make more sense). In cases where data is of a type not defined above, use the type GRAPH_MISC. The data will still be saved, but conversions in the future will not be possible.

Note that when one of the predefined types is being used, often the convert functions can be useful. They can, for example, take a string like "10 MB" and convert it into the appropriate number of bytes as a string. This could then be passed directly into an RSP_graphReturnData structure. There is a convert function for each time above. Please refer to them for more information.

Returns

This function returns -1 if an error occurred, and 0 otherwise.

Error Conditions

If an error occurs, -1 will be returned and rsp_error will be set to the following error code:

  • RSP_INVALID_ARGS

  • RSP_LOW_MEM