Example implementation
- Last UpdatedApr 24, 2025
- 1 minute read
extern "C" __declspec(dllexport) void batchTrackPipelineFinalize(pipelineslot plslot, int nroute)
{
pipeline* pPipeline;
internaltime curtime;
if (!(pPipeline = (pipeline*)bt_get_rec(DATABASE_PIPELINE, plslot)))
{
cpu_debug(CPU_DEBUG_ERROR, "Could not get pipeline record %d", plslot);
return;
}
cpu_debug(CPU_DEBUG_INFO, "Loaded pipeline %d", (int)plslot);
tivnow(&curtime);
char alarmMessage[] = "Executing BatchTracking Plugin Function";
EventSpoolObj battrkEvent;
EVENTSPOOLER_SEND_ALARM(battrkEvent, OPEVENT_APP_ALARM, APPLICATION_ALM,pPipeline->flag.testmode, ALMINH_NONE, get_spooler(pPipeline->group, SPL_MSG), &curtime, "pipeline", pPipeline->name, pPipeline->description, 0, pPipeline->group, alarmMessage, NULL, NULL, SEVERITY_SUCCESS,COLOR_GREEN, pPipeline->dataset, OAS_TRUE);
// Alarm - ignore inhibit flag because this is a serious condition.
addDBalarm("pipeline", DATABASE_PIPELINE, pPipeline->name, plslot, "", 0, pPipeline->description, pPipeline->group, "PipelineLoaded", alarmMessage, (void**)&pPipeline, &pPipeline->flag, false, true, SEVERITY_SUCCESS, 0, true, 0L, getHostName(), pPipeline->dataset, OAS_TRUE);
RealTimeTable rtTable;
RealTimeRecord rtRecord;
rtTable.Bind("pipeline");
rtRecord.BindTable(rtTable);
if (!rtTable.AttachInsteadOfLock(REQ_SAFE_READ))
{
cpu_debug(CPU_DEBUG_ERROR, "Unable to attach pipeline table");
return;
}
if (!rtRecord.BindRecordNumber(plslot))
{
cpu_debug(CPU_DEBUG_ERROR, "Unable to bind pipeline %d", (int)plslot);
rtTable.DetachInsteadOfUnLock();
return;
}
if (!rtRecord.AttachInsteadOfLock(REQ_SAFE_WRITE))
{
cpu_debug(CPU_DEBUG_ERROR, "Unable to attach pipeline %d", (int)plslot);
rtTable.DetachInsteadOfUnLock();
return;
}
char newDescription[] = "Testing Extension succeeded";
cpu_debug(CPU_DEBUG_INFO, "Updating pipeline %d description from '%s' to '%s'",
rtRecord.ReadString("description"), newDescription);
rtRecord.WriteString("description", newDescription);
rtRecord.DetachInsteadOfUnLock();
rtTable.DetachInsteadOfUnLock();
}
Note: The AVEVA Pipeline Operations for Liquids Software Development Kit (SDK) contains a pre-prepared project that includes the example code shown.