Pump_CAPI_Init.cpp

The following example shows how to get a valid pump handle from the pump library and how to properly setup and configure pump parameters.

//============================================================================
// INCLUDES
//============================================================================
//===========================================================================
// STATIC DATA
//===========================================================================
static dev_hdl hPump1; ///< stores pump handle
//===========================================================================
// Pump initialisation
//===========================================================================
TErrCode InitPump(void)
{
TErrCode Result;
long Retval;
// Get a pump handle for the pump that is registered with the name
// Nemesys1_Pump
hPump1 = LCP_LookupPumpByName("Nemesys1_Pump");
if (hPump1 <= 0)
{
// handle error properly here
return -ERR_NOENT;
}
// Now we check if the pump is in a fault state. We need to clear the fault
// state first, before we can enable the pump drive
Retval = LCP_IsInFaultState(hPump1);
if (1 == Retval)
{
Result = LCP_ClearFault(hPump1);
if (Result != ERR_NOERR)
{
// handle error properly here
return Result;
}
}
// Now we enable the pump drive. Enabling the pump means, power
// will be applied to power stage of the pump drive units.
Result = LCP_Enable(hPump1);
if (Result != ERR_NOERR)
{
// handle error properly here
return Result;
}
// Now we check, if initializing the position sensing system is required.
// If it is required, then we restore the previously saved position
// counter value. If we do not have a saved position counter value
// then we need to execute a reference move via LCP_SyringePumpCalibrate().
if (!Result)
{
int SavedPositionCounterValue = 0;
//
// load saved position counter value from file here
// ...
// Now we restore the previously saved position counter value of the pumps
// drive units
Result = LCP_RestoreDrivePosCnt(hPump1, SavedPositionCounterValue);
if (Result != ERR_NOERR)
{
// handle error properly here
return Result;
}
}
// Now we setup volume and flow SI units - or we restore the values saved
// to file previously. We would like to use milliliters as volume unit and
// milliliters / second as flow unit
// Now we configure the syringe parameters of the syringe that is currently
// mounted on our syringe pump device - we use a syringe with 2 mm innder
// diameter and 60 mm piston stroke.
Result = LCP_SetSyringeParam(hPump1, 2, 60);
if (Result != ERR_NOERR)
{
// handle error properly here
return Result;
}
// now the pump is properly initialized and we can start dosing
return Result;
}