new release

This commit is contained in:
2018-12-14 15:54:11 +01:00
parent 52fe50f14a
commit b09186294d
92 changed files with 399194 additions and 269837 deletions
+82 -75
View File
@@ -1,5 +1,5 @@
///
/// \file helper.cc
/// \file helper.cpp
/// \author Jan Chrin, PSI
/// \date Release: February 2015
/// \version CAFE 1.0.0
@@ -20,28 +20,29 @@ using namespace std;
* \param pv input: process variable name
* \param pvStripped output: process variable name stripped of forward and trailing spaces
*/
void Helper::removeLeadingAndTrailingSpacesDbrString(const char * pv, char pvStripped[MAX_STRING_SIZE]) {
void Helper::removeLeadingAndTrailingSpacesDbrString(const char * pv, char pvStripped[MAX_STRING_SIZE])
{
#define __METHOD__ "Helper::removeLeadingAndTrailingSpacesDbrString(const char * pv, char[MAX_STRING_SIZE])"
// Remove leading and trailing blanks
std::string pvS=pv;
// Remove leading and trailing blanks
std::string pvS=pv;
size_t found1 = pvS.find_first_not_of(" ");
size_t found2 = pvS.find_last_not_of (" ");
size_t found1 = pvS.find_first_not_of(" ");
size_t found2 = pvS.find_last_not_of (" ");
if (found1!=std::string::npos && found2 !=std::string::npos) {
if (found1!=std::string::npos && found2 !=std::string::npos) {
size_t found21 = std::min((int)((found2+1)-found1), (int) (MAX_STRING_SIZE-1));
size_t length = pvS.copy(pvStripped,found21,found1);
size_t found21 = std::min((int)((found2+1)-found1), (int) (MAX_STRING_SIZE-1));
size_t length = pvS.copy(pvStripped,found21,found1);
pvStripped[length]='\0'; //required
pvStripped[length]='\0'; //required
}
else {
std::strcpy(pvStripped,"");
}
else {
std::strcpy(pvStripped,"");
}
}
return;
return;
#undef __METHOD__
}
@@ -51,28 +52,29 @@ void Helper::removeLeadingAndTrailingSpacesDbrString(const char * pv, char pvStr
* \param pv input: process variable name
* \param pvStripped output: process variable name stripped of forward and trailing spaces
*/
void Helper::removeLeadingAndTrailingSpacesPseudo(const char * pv, char pvStripped[PVGROUP_PSEUDO_SIZE]) {
void Helper::removeLeadingAndTrailingSpacesPseudo(const char * pv, char pvStripped[PVGROUP_PSEUDO_SIZE])
{
#define __METHOD__ "Helper::removeLeadingAndTrailingSpacesPseudo(const char * pv, char[PVGROUP_PSEUDO_SIZE])"
// Remove leading and trailing blanks
std::string pvS=pv;
// Remove leading and trailing blanks
std::string pvS=pv;
size_t found1 = pvS.find_first_not_of(" ");
size_t found2 = pvS.find_last_not_of (" ");
size_t found1 = pvS.find_first_not_of(" ");
size_t found2 = pvS.find_last_not_of (" ");
if (found1!=std::string::npos && found2 !=std::string::npos) {
if (found1!=std::string::npos && found2 !=std::string::npos) {
size_t found21 = std::min((int)((found2+1)-found1), (int) (PVGROUP_PSEUDO_SIZE-1));
size_t length = pvS.copy(pvStripped,found21,found1);
size_t found21 = std::min((int)((found2+1)-found1), (int) (PVGROUP_PSEUDO_SIZE-1));
size_t length = pvS.copy(pvStripped,found21,found1);
pvStripped[length]='\0'; //required
pvStripped[length]='\0'; //required
}
else {
std::strcpy(pvStripped,"isEmpty");
}
else {
std::strcpy(pvStripped,"isEmpty");
}
}
return;
return;
#undef __METHOD__
}
@@ -82,7 +84,8 @@ void Helper::removeLeadingAndTrailingSpacesPseudo(const char * pv, char pvStripp
* \param pv input: process variable name
* \param pvStripped output: process variable name stripped of forward and trailing spaces
*/
void Helper::removeLeadingAndTrailingSpaces(const char * pv, char pvStripped[PVNAME_SIZE]) {
void Helper::removeLeadingAndTrailingSpaces(const char * pv, char pvStripped[PVNAME_SIZE])
{
#define __METHOD__ "Helper::removeLeadingAndTrailingSpaces(const char * pv, char[PVNAME_SIZE])"
// Remove leading and trailing blanks
std::string pvS=pv;
@@ -92,7 +95,7 @@ void Helper::removeLeadingAndTrailingSpaces(const char * pv, char pvStripped[PVN
if (found1!=std::string::npos && found2 !=std::string::npos) {
size_t found21 = std::min((int)((found2+1)-found1), (int) (PVNAME_SIZE-1));
size_t found21 = std::min((int)((found2+1)-found1), (int) (PVNAME_SIZE-1));
size_t length = pvS.copy(pvStripped,found21,found1);
pvStripped[length]='\0'; //required
@@ -116,13 +119,14 @@ void Helper::removeLeadingAndTrailingSpaces(const char * pv, char pvStripped[PVN
* \param ghs input: size of gs (group handle set)
* \return unique identifier
*/
unsigned int Helper::convertToUniqueNumber(const char * pv, ca_client_context * ccc, unsigned int ghs) {
unsigned int Helper::convertToUniqueNumber(const char * pv, ca_client_context * ccc, unsigned int ghs)
{
#define __METHOD__ "Helper::convertToUniqueNumber(const char * pv, ca_client_context * ccc, unsigned int ghs)"
std::string myString=pv;
char s[12];
sprintf(s,"%ld", (unsigned long) ccc);
sprintf(s,"%lu", (unsigned long) ccc);
unsigned int numberPV = 0;
@@ -133,28 +137,28 @@ unsigned int Helper::convertToUniqueNumber(const char * pv, ca_client_context *
numberContext = atoi(s);
unsigned int intValueIs=0;
unsigned int intValueIs=0;
unsigned int iL=0;
for (unsigned int i=0; i< myString.size(); i++) {
intValueIs= (unsigned int) myString[i];
ld=1;
if ( (intValueIs >47 && intValueIs < 58) ||
(intValueIs >64 && intValueIs < 91) ||
(intValueIs >97 && intValueIs < 123) ) {
dpow=pow((float) 42, (int) iL%4);
ld = static_cast<unsigned int>(dpow);
++iL;
}
else {
iL=0;
}
numberPV += (intValueIs*ld*(i+1));
intValueIs= (unsigned int) myString[i];
ld=1;
if ( (intValueIs >47 && intValueIs < 58) ||
(intValueIs >64 && intValueIs < 91) ||
(intValueIs >97 && intValueIs < 123) ) {
dpow=pow((float) 42, (int) iL%4);
ld = static_cast<unsigned int>(dpow);
++iL;
}
else {
iL=0;
}
numberPV += (intValueIs*ld*(i+1));
}
unsigned int final=(numberPV+numberContext+((ghs+1)*10000+ghs));
@@ -169,13 +173,14 @@ unsigned int Helper::convertToUniqueNumber(const char * pv, ca_client_context *
* \param ccc input: current context
* \return unique identifier
*/
unsigned int Helper::convertToUniqueNumber(const char * pv, ca_client_context * ccc) {
unsigned int Helper::convertToUniqueNumber(const char * pv, ca_client_context * ccc)
{
#define __METHOD__ "Helper::convertToUniqueNumber(const char * pv, ca_client_context * ccc)"
std::string myString=pv;
char s[12];
sprintf(s,"%ld", (unsigned long) ccc);
sprintf(s,"%lu", (unsigned long) ccc);
unsigned int numberPV = 0;
unsigned int numberContext =0 ;
@@ -185,29 +190,29 @@ unsigned int Helper::convertToUniqueNumber(const char * pv, ca_client_context *
numberContext = atoi(s);
unsigned int intValueIs=0;
unsigned int intValueIs=0;
unsigned int iL=0;
for (unsigned int i=0; i< myString.size(); i++) {
intValueIs= (unsigned int) myString[i];
ld=1;
if ( (intValueIs >47 && intValueIs < 58) ||
(intValueIs >64 && intValueIs < 91) ||
(intValueIs >97 && intValueIs < 123) ) {
dpow=pow((float)42, (int)iL%4);
ld = static_cast<unsigned int>(dpow);
++iL;
}
else {
iL=0;
}
numberPV += (intValueIs*ld*(i+1));
for (unsigned int i=0; i< myString.size(); i++) {
intValueIs= (unsigned int) myString[i];
ld=1;
if ( (intValueIs >47 && intValueIs < 58) ||
(intValueIs >64 && intValueIs < 91) ||
(intValueIs >97 && intValueIs < 123) ) {
dpow=pow((float)42, (int)iL%4);
ld = static_cast<unsigned int>(dpow);
++iL;
}
else {
iL=0;
}
numberPV += (intValueIs*ld*(i+1));
}
return (numberPV+numberContext);
#undef __METHOD__
}
@@ -219,7 +224,8 @@ unsigned int Helper::convertToUniqueNumber(const char * pv, ca_client_context *
* \param _chtype input: channel type
* \return CAFENUM::DBR_TYPE
*/
CAFENUM::DBR_TYPE Helper::convertToCAFEDbrTypeClass(const chtype _chtype) const {
CAFENUM::DBR_TYPE Helper::convertToCAFEDbrTypeClass(const chtype _chtype) const
{
#define __METHOD__ "Helper::convertToCAFEDbrTypeClass(const chtype _chtype)"
if (_chtype>=DBR_STRING && _chtype <= DBR_DOUBLE) {
@@ -259,7 +265,8 @@ CAFENUM::DBR_TYPE Helper::convertToCAFEDbrTypeClass(const chtype _chtype) const
* \param nChar input: size of array
* \return std:string The concatinated string
*/
std::string Helper::concatToString(dbr_char_t * inpChar, unsigned int nChar){
std::string Helper::concatToString(dbr_char_t * inpChar, unsigned int nChar)
{
std::string psWF = "";