Converted from RDB Functions.doc
The RDB (Remote Database) is the PowerTek Real-Time Database that DIF uses to publish engine data to the test automation system.
short RDBConnect(char *machinename)
Connects the process to the given machine's database. A machinename of "" connects to the local machine. This is the first call a process must make to use the rest of the RDB functions.
Returns: -1 = FAIL, 0 = SUCCESS
Example:
short result = RDBConnect("");
short RDBGetHandle(char *channelname, char *fieldname, short *typereturn, int *handle)
Gets a handle to a field in the database. Once the handle is received, RDBWrite and RDBRead can be used to change or access its value.
Returns: -1 = FAIL, 0 = SUCCESS
Example (float value):
short RDBstatus = 0, fieldtype;
int handle;
float *scaledValue = NULL;
float value = 2.5f;
char strvariable[13] = { 0 };
strcpy(strvariable, "EC1_FLOATVAL");
scaledValue = &value;
if (RDBGetHandle(strvariable, "Raw Value", &fieldtype, &handle) == 0) {
RDBstatus = RDBWrite(handle, (void *)scaledValue, sizeof(float));
}
short RDBWrite(int handle, void *value, short bufferlength)
Uses a handle obtained from RDBGetHandle to write a new value into the database. Can write strings or floats.
Returns: -1 = FAIL, 0 = SUCCESS
Example (string value):
short RDBstatus = 0, fieldtype;
int handle;
char scaledValue[12] = { 0 }, strvariable[14] = { 0 };
strcpy(scaledValue, "Test String");
strcpy(strvariable, "EC1_STRINGVAL");
if (RDBGetHandle(strvariable, "String Value", &fieldtype, &handle) == 0) {
RDBstatus = RDBWrite(handle, (void *)scaledValue, strlen(scaledValue) + 1);
}
short RDBRead(int handle, void *returnvalue, short *bufferlengthreturned, short bufferlength)
Uses a handle obtained from RDBGetHandle to read a value from the database. Used to read floats.
Returns: -1 = FAIL, 0 = SUCCESS
Example:
short retVal = 0, fieldtype;
int handle;
float value = 0.0f;
short valLen = sizeof(value);
char strvariable[13] = { 0 };
strcpy(strvariable, "EC1_FLOATVAL");
if (RDBGetHandle(strvariable, "Raw Value", &fieldtype, &handle) == 0) {
retVal = RDBRead(handle, &value, &valLen, 4);
}
short RDBWriteMany(int *handles, void *bufferreturn, int numhandles,
short fieldsize, short *numfieldswritten)
Same as RDBWrite except takes an array of handles and values. All fields being written must be the same size. Used for bulk float writes.
Returns: -1 = FAIL, 0 = SUCCESS
Example:
short NumWritten = 0;
int m_nHandles[20], m_nParams = 20;
float m_fValues[20] = { 0.0f, ... };
// Get handles first
GetTheHandles(&m_nHandles);
PTResult = RDBWriteMany(&m_nHandles[0], &m_fValues[0], m_nParams,
sizeof(float), &NumWritten);
short RDBDisconnect()
Called before your process exits.
Returns: -1 = FAIL, 0 = SUCCESS
Example:
short result = RDBDisconnect();
1. RDBConnect("") // Connect to local database
2. RDBGetHandle(name, field, ...) // Get handles for each channel
3. Loop:
- RDBRead(handle, ...) // Read values
- RDBWrite(handle, ...) // Write values
- RDBWriteMany(handles, ...) // Bulk write
4. RDBDisconnect() // Clean up
Functions are provided by RemoteDB.dll (loaded dynamically by DIF at startup).