FESA3 Code Templates

C++ code templates for efficient developers can be used to type frequently used code faster within the Eclipse IDE. The FESA3 plug-in provides numerous C++ code templates to help speed up typing.

Usage

Start typing the name of the code template and press CTRL+SPACE, a list of the matching available code templates will be displayed.

Please note that the inserted code may not fit in everywhere and is not adapted to the surrounding variable names, it will have to be adapted manually (e.g. names of fields, variables, types etc).

If the code templates are not displayed when typing CTRL+SPACE please configure the preferences, keyword for searching the preferences: code completion.

Logging

Name Result
logt
LOG_TRACE_IF( logger, "" );
logd
LOG_DEBUG_IF( logger, "" );
logi
LOG_INFO_IF( logger, "" );
logw
LOG_WARNING_IF( logger, "" );
loge
LOG_ERROR_IF( logger, "" );

Console Output

Name Result
sysout
std::cout << " " << std::endl;
syserr
std::cerr << " " << std::endl;
systrace
std::cout << "TRACE: " _ _FILE_ _ << ": " << _ _FUNCTION_ _ << ": Line " << _ _LINE_ _ << std::endl;

FESA Functionality

Name Purpose Result
deviceCollection iteration over device collection
fesa::MultiplexingContext* pCtxt = pEvt->getMultiplexingContext();
for (std::vector<Device*>::iterator itr = deviceCol_.begin(); itr != deviceCol_.end(); ++itr) {
try {
Device* pDev = (*itr);
// perform an action with the device
pDev->myField.set(someValue,pCtxt);
} catch (fesa::FesaException& exception) {
}
}
getGlobalDevice retrieve the global device
GlobalDevice* globalDev = !DeviceFactory::getInstance()->getGlobalDevice();
getIntField retrieve an int32 value
int32_t myData = (*device)->myField.get(pEvt->getMultiplexingContext());
setIntField set a field's value
(*device)->myField.set(myData, pEvt->getMultiplexingContext());
getIntArray retrieve an int32 array
uint32_t dim;
const int32_t* myData = (*device)->myArrayField.get(dim, pEvt->getMultiplexingContext());
setIntArray set an in32 array
uint32_t sizeOfmyData = 4;
int32_t myData[sizeOfmyData];
myData[1] = 15;
(*device)->myArrayField.set(myData, sizeOfmyData, pEvt->getMultiplexingContext());
get2DIntArray retrieve an 2D int32 array
uint32_t dim1;
uint32_t dim2;
const int32_t** myDataAll = (*device)->my2DArray.get(dim1, dim2, pEvt->getMultiplexingContext());
set2DIntArrayRow set a row in an 2D int32 array
uint32_t dim1;
uint32_t index = 1;
int32_t myDataRow[dim1];
(*device)->my2DArray.setRow(myDataRow, index, dim1, pEvt->getMultiplexingContext());
set2DIntArrayColumn set a column in an 2D int32 array
uint32_t dim2;
uint32_t index = 1;
int32_t myDataColumn[dim2];
(*device)->my2DArray.setColumn(myDataColumn, index, dim2, pEvt->getMultiplexingContext());
throwFESAException throws a FESA exception to a client
std::string errorMessage = "Something went wrong here!";
std::string errorCode = "4711";
// errorCategory should use "FESACLASS_" as prefix and the class name
std::string errorCategory = "FESACLASS_MyFesaClassName";
throw fesa::FesaException(errorMessage, __FILE__, __LINE__, errorCode, errorCategory);

GSI specific Code Templates

Name Purpose Result
reportGSIError Report an error by using GSI's error collection field
std::string errorMessage= "Put in your error message here";
int32_t errorCode= 4711;
(*device)->error_collection.addError(errorCode, errorMessage, pEvt->getMultiplexingContext(), *device);
multiplexingContextSimple Fill the GSI-Multiplexing-context-field (simple)
// simple method (cyclestamp, cyclename and acquisitionstamp are obtained from MultiplexingContext if available)
(*device)->acquisitionContext.insert(pCtxt);
multiplexingContextAdvanced Fill the GSI-Multiplexing-context-field (advanced)
// advanced method ( usage of self defined acquisition stamp )
int64_t stamp = 12345678; //stamp should be in nanoseconds - UTC
(*device)->acquisitionContext.insert(pCtxt, acquisitionStamp);
condition Provide the line required to throw a GSI condition
// throw value of generated condition header in FESACLASS/src/FESACLASS/Common
throw CONDITION(__FILE__, __LINE__, FESACLASS_CONDITION_X, "");
Topic revision: r1 - 22 Jun 2017, SolveighMatthies
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback