FESA3 Code Templates

C++ code templates for the 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).

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;
systrace
std::cout << "TRACE: " _ _FILE_ _ << ": " << _ _FUNCTION_ _ << ": Line " << _ _LINE_ _ << ": " << _ _DATE_ _ << " - " << _ _TIME_ _ << std::endl;

FESA Functionality

Name Purpose Result
deviceCollection iteration over device collection
<span style="font-size: 1em; line-height: 22px;">fesa::MultiplexingContext* pCtxt = pEvt->getMultiplexingContext();
</span><span style="font-size: 1em; line-height: 22px;">for (std::vector<Device*>::iterator itr = deviceCol_.begin(); itr != deviceCol_.end(); ++itr) </span><span style="font-size: 1em; line-height: 22px;">{</span><span style="font-size: 1em; line-height: 22px;"> 
 try</span><span style="font-size: 1em; line-height: 22px;"> {
</span><span style="font-size: 1em; line-height: 22px;"> Device* pDev = (*itr);
</span><span style="font-size: 1em; line-height: 22px;"> // perform an action with the device
</span><span style="font-size: 1em; line-height: 22px;"> pDev->myField.set(someValue,pCtxt);
</span><span style="font-size: 1em; line-height: 22px;"> }</span><span style="font-size: 1em; line-height: 22px;"> catch (fesa::FesaException& exception)</span><span style="font-size: 1em; line-height: 22px;"> {
</span><span style="line-height: 22px; font-size: 1em;"> }
</span><span style="font-size: 1em; line-height: 22px;">}</span>
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
 <span style="line-height: 22px;">uint32_t dim1;
</span><span style="line-height: 22px;">uint32_t index = 1;
</span><span style="line-height: 22px;">int32_t myDataRow[dim1];
</span><span style="line-height: 22px;">(*device)->my2DArray.setRow(myDataRow,index,dim1,pEvt->getMultiplexingContext());</span>
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());
throwRDAIOException throws an RDA IO exception to a client
std::string errorCategory = "MyCategory";
long errorCode = 4711;
std::string errorMessage = "Something went wrong!";
throw rdaIOError(errorCategory.c_str(), errorCode, errorMessage.c_str());
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);
throwRDABadParameterException throw RDA bad parameter exception
throw rdaBadParameter("");
throwRDATypeMismatchException throw RDA type mismatch exception
throw rdaTypeMismatch("");
throwRDATimeOutException throw RDA time out exception
throw rdaTimeOut("");
throwRDANoConnection throw RDA tno connection exception
throw rdaNoConnection("");
throwRDANoPermission throw RDA tno permission exception
throw rdaNoPermission("");

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)
 <span style="line-height: 22px;">// advanced method ( usage of self defined acquisition stamp )
</span><span style="line-height: 22px;">int64_t stamp = 12345678; //stamp should be in nanoseconds - UTC
</span><span style="line-height: 22px;">(*device)->acquisitionContext.insert(pCtxt,acquisitionStamp);</span>
     
     
-- SolveighMatthies - 17 May 2013
Topic revision: r6 - 03 Mar 2014, 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