gccDppConsole Test C++ SDK  20170920
DPP C++ Console Demonstration
DeviceIO/AsciiCmdUtilities.cpp
Go to the documentation of this file.
00001 #include "AsciiCmdUtilities.h"
00002 
00003 CAsciiCmdUtilities::CAsciiCmdUtilities(void)
00004 {
00005 }
00006 
00007 CAsciiCmdUtilities::~CAsciiCmdUtilities(void)
00008 {
00009 }
00010 
00011 string CAsciiCmdUtilities::MakeUpper(string StdString)
00012 {
00013   const int length = (int)StdString.length();
00014   for(int i=0; i<length ; ++i)
00015   {
00016     StdString[i] = std::toupper(StdString[i]);
00017   }
00018   return StdString;
00019 }
00020 
00021 string CAsciiCmdUtilities::RemWhitespace(string strLine)
00022 {
00023         unsigned int idxCh;
00024         string strCh;
00025         string strNoWSp;
00026         
00027         strNoWSp = "";
00028         if (strLine.find_first_of(Whitespace, 0) == std::string::npos) {                // string has no whitespace
00029                 return strLine;
00030         } else {                        // remove whitespace
00031                 for (idxCh=0;idxCh<strLine.length();idxCh++) {
00032                         strCh = strLine.substr(idxCh,1);
00033                         if (strCh.find_first_of(Whitespace, 0) == std::string::npos) {          // char is not whitespace
00034                                 strNoWSp += strCh;
00035                         }
00036                 }
00037                 return strNoWSp;
00038         }
00039 }
00040 
00041 //read and format [DP5 Configuration File]
00042 string CAsciiCmdUtilities::GetDP5CfgStr(string strFilename)
00043 {
00044         FILE *txtFile;
00045         char chLine[LINE_MAX];
00046         string strCfg;
00047         string strLine;
00048         long lPos;
00049         char ch;
00050         bool bCfgSection;
00051         int iCmpCfg;
00052         long lPosCfg;
00053         stringex strfn;
00054 
00055         bCfgSection = false;
00056         iCmpCfg = 1;
00057         if (( txtFile = fopen(strFilename.c_str(), "r")) == NULL) {  // Can't open input file
00058                 return "";
00059         }
00060         strCfg = "";
00061         while((fgets(chLine, LINE_MAX, txtFile)) != NULL) {
00062                 strLine = strfn.Format("%s",chLine);
00063                 lPosCfg = (long)strLine.find('[');                              // find a section (-1=not found,0=section found,>0=undefined)
00064                 if (lPosCfg == 0) {                                                             // Locate DP5 Configuration Section
00065                         iCmpCfg = (long)strLine.find("[DP5 Configuration File]");
00066                         if (iCmpCfg == 0) {                                                     // Configuration Section Found
00067                                 bCfgSection = true;
00068                         } else {                                                                        // Non-Configuration Section Found
00069                                 bCfgSection = false;
00070                         }
00071                 }
00072                 if (bCfgSection) {                                                              // Save Configuration Section Only
00073                         strLine = MakeUpper(strLine);                           // make all uppercase
00074                         lPos = (long)strLine.find(';');                         // find the delimiter (-1=not found,0=commented line)
00075                         if (lPos > 0) {                                                         // if has delimiter that is not first char
00076                                 strLine = strLine.substr(0,lPos + 1);   // remove string right of delimiter
00077                                 ch = strLine.at(0);                                     
00078                                 if ((ch >= 'A') && (ch <= 'Z')) {               // if is valid value
00079                                         strLine = RemWhitespace(strLine);       // remove whitespace in command sequence
00080                                         if (strLine.length() > 1) {                     // check if command w/delimiter left
00081                                                 strCfg += strLine;                              // add to command string
00082                                         }
00083                                 }
00084                         }
00085                 }
00086                 strLine = "";
00087         }
00088         fclose(txtFile);
00089         if (strCfg.length() > 0) {
00090                 return strCfg;
00091         } else {
00092                 return "";
00093         }
00094 }
00095 
00096 //read and format [DP5 SCA Configuration]
00097 string CAsciiCmdUtilities::GetDP5ScaStr(string strFilename)
00098 {
00099         FILE *txtFile;
00100         char chLine[LINE_MAX];
00101         string strCfg;
00102         string strLine;
00103         long lPos;
00104         char ch;
00105         bool bCfgSection;
00106         int iCmpCfg;
00107         long lPosCfg;
00108         stringex strfn;
00109         char chScaOld;
00110         char chSCA;
00111         int iScaBytes;
00112         string strScaIdx;
00113         string strScaCmd = "";
00114 
00115         bCfgSection = false;
00116         iCmpCfg = 1;
00117         if (( txtFile = fopen(strFilename.c_str(), "r")) == NULL) {  // Can't open input file
00118                 return "";
00119         }
00120         chScaOld = '0';
00121         chSCA = '9';
00122         strCfg = "";
00123         while((fgets(chLine, LINE_MAX, txtFile)) != NULL) {
00124                 strLine = strfn.Format("%s",chLine);
00125                 lPosCfg = (long)strLine.find('[');                              // find a section (-1=not found,0=section found,>0=undefined)
00126                 if (lPosCfg == 0) {                                                             // Locate DP5 Configuration Section
00127                         iCmpCfg = (long)strLine.find("[DP5 SCA Configuration]");
00128                         if (iCmpCfg == 0) {                                                     // Configuration Section Found
00129                                 bCfgSection = true;
00130                         } else {                                                                        // Non-Configuration Section Found
00131                                 bCfgSection = false;
00132                         }
00133                 }
00134                 if (bCfgSection) {                                                              // Save Configuration Section Only
00135                         strLine = MakeUpper(strLine);                           // make all uppercase
00136                         lPos = (long)strLine.find(';');                         // find the delimiter (-1=not found,0=commented line)
00137                         if (lPos > 0) {                                                         // if has delimiter that is not first char
00138                                 strLine = strLine.substr(0,lPos + 1);   // remove string right of delimiter
00139                                 ch = strLine.at(0);                                     
00140                                 if ((ch >= 'A') && (ch <= 'Z')) {               // if is valid value
00141                                         strLine = RemWhitespace(strLine);       // remove whitespace in command sequence
00142                                         if (strLine.length() > 1) {                     // check if command w/delimiter left
00143                                                 //strCfg += strLine;                            // add to command string
00144                                                 //strcat(strCfg,chLine);                                // add to command string
00145                                                 chSCA = strLine.at(4);                          // determine SCA Index
00146                                                 // remove index from SCA Command to create DPP ASCII Command format
00147                                                 if ((chSCA > '0') && (chSCA < '9')) {
00148                                                         if (chSCA != chScaOld) {                // Is same as current index?
00149                                                                 chScaOld = chSCA;                       // if no, save current index
00150                                                                 // insert index command into string (SCAI=%c;)
00151                                                                 strScaIdx = strfn.Format("SCAI=%c;",chSCA);
00152                                                                 strCfg += strScaIdx;                            // add sca index command to string
00153                                                                 strScaIdx = "";
00154                                                         }
00155                                                         strScaCmd = strLine.substr(0,4);
00156                                                         for (iScaBytes=5;iScaBytes<=lPos;iScaBytes++) { 
00157                                                                 strScaCmd += strLine.at(iScaBytes);
00158                                                         }
00159                                                         strCfg += strScaCmd;                            // add to command string
00160                                                 } else {        // no index to remove, cmd was saved with SCAI command
00161                                                         strCfg += strLine;                                      // add to command string
00162                                                 }
00163                                         }
00164                                 }
00165                         }
00166                 }
00167                 strLine = "";
00168         }
00169         fclose(txtFile);
00170         if (strCfg.length() > 0) {
00171                 return strCfg;
00172         } else {
00173                 return "";
00174         }
00175 }
00176 
00177 string CAsciiCmdUtilities::CreateResTestReadBackCmd(bool bSendCoarseFineGain, int DppType)
00178 {
00179         string strCfg("");
00180     bool isINOF;
00181 
00182     isINOF = (DppType != dppDP5G) && (DppType != dppTB5);
00183         strCfg = "";
00184         strCfg += "CLCK=?;";
00185         strCfg += "TPEA=?;";
00186         if (bSendCoarseFineGain) { strCfg += "GAIF=?;"; }
00187         if (!bSendCoarseFineGain) { strCfg += "GAIN=?;"; }
00188         strCfg += "RESL=?;";
00189         strCfg += "TFLA=?;";
00190         strCfg += "TPFA=?;";
00191         strCfg += "PURE=?;";
00192         strCfg += "RTDE=?;";
00193         strCfg += "MCAS=?;";
00194         strCfg += "MCAC=?;";
00195         strCfg += "SOFF=?;";
00196         strCfg += "AINP=?;";
00197         if (isINOF) { strCfg += "INOF=?;"; }
00198         if (bSendCoarseFineGain) { strCfg += "GAIA=?;"; }
00199         return strCfg;
00200 }
00201 
00202 string CAsciiCmdUtilities::CreateFullReadBackCmd(bool PC5_PRESENT, int DppType, bool isDP5_RevDxGains, unsigned char DPP_ECO)
00203 {
00204         string strCfg("");
00205     bool isHVSE;
00206     bool isPAPS;
00207     bool isTECS;
00208     bool isVOLU;
00209         bool isCON1;
00210         bool isCON2;
00211     bool isINOF;
00212     bool isBOOT;
00213         bool isGATE;
00214     bool isPAPZ;
00215         bool isSCTC;
00216         bool isDP5_DxK=false;
00217         bool isDP5_DxL=false;
00218 
00219         if (DppType == dppMCA8000D) {
00220                 strCfg = CreateFullReadBackCmdMCA8000D(DppType);
00221                 return strCfg;
00222         }
00223 
00224         // DP5 Rev Dx K,L needs PAPZ
00225         if ((DppType == dppDP5) && isDP5_RevDxGains) {
00226                 if ((DPP_ECO & 0x0F) == 0x0A) {
00227                         isDP5_DxK = true;
00228                 }
00229                 if ((DPP_ECO & 0x0F) == 0x0B) {
00230                         isDP5_DxL = true;
00231                 }
00232         }
00233 
00234     isHVSE = (((DppType != dppPX5) && PC5_PRESENT) || DppType == dppPX5);
00235     isPAPS = (DppType != dppDP5G) && (DppType != dppTB5);
00236     isTECS = (((DppType == dppDP5) && PC5_PRESENT) || (DppType == dppPX5) || (DppType == dppDP5X));
00237     isVOLU = (DppType == dppPX5);
00238     isCON1 = ((DppType != dppDP5) && (DppType != dppDP5X));
00239     isCON2 = ((DppType != dppDP5) && (DppType != dppDP5X));
00240     isINOF = (DppType != dppDP5G) && (DppType != dppTB5);
00241     isSCTC = (DppType == dppDP5G) || (DppType == dppTB5);
00242     isBOOT = ((DppType == dppDP5) || (DppType == dppDP5X));
00243         isGATE = ((DppType == dppDP5) || (DppType == dppDP5X));
00244         isPAPZ = (DppType == dppPX5) || isDP5_DxK || isDP5_DxL;
00245 
00246         strCfg = "";
00247         strCfg += "RESC=?;";
00248         strCfg += "CLCK=?;";
00249         strCfg += "TPEA=?;";
00250         strCfg += "GAIF=?;";
00251         strCfg += "GAIN=?;";
00252         strCfg += "RESL=?;";
00253         strCfg += "TFLA=?;";
00254         strCfg += "TPFA=?;";
00255         strCfg += "PURE=?;";
00256         if (isSCTC) { strCfg += "SCTC=?;"; }
00257         strCfg += "RTDE=?;";
00258         strCfg += "MCAS=?;";
00259         strCfg += "MCAC=?;";
00260         strCfg += "SOFF=?;";
00261         strCfg += "AINP=?;";
00262         if (isINOF) { strCfg += "INOF=?;"; }
00263         strCfg += "GAIA=?;";
00264         strCfg += "CUSP=?;";
00265         strCfg += "PDMD=?;";
00266         strCfg += "THSL=?;";
00267         strCfg += "TLLD=?;";
00268         strCfg += "THFA=?;";
00269         strCfg += "DACO=?;";
00270         strCfg += "DACF=?;";
00271         strCfg += "RTDS=?;";
00272         strCfg += "RTDT=?;";
00273         strCfg += "BLRM=?;";
00274         strCfg += "BLRD=?;";
00275         strCfg += "BLRU=?;";
00276         if (isGATE) { strCfg += "GATE=?;"; }
00277         strCfg += "AUO1=?;";
00278         strCfg += "PRET=?;";
00279         strCfg += "PRER=?;";
00280         strCfg += "PREC=?;";
00281         strCfg += "PRCL=?;";
00282         strCfg += "PRCH=?;";
00283         if (isHVSE) { strCfg += "HVSE=?;"; }
00284         if (isTECS) { strCfg += "TECS=?;"; }
00285         if (isPAPZ) { strCfg += "PAPZ=?;"; }
00286         if (isPAPS) { strCfg += "PAPS=?;"; }
00287         strCfg += "SCOE=?;";
00288         strCfg += "SCOT=?;";
00289         strCfg += "SCOG=?;";
00290         strCfg += "MCSL=?;";
00291         strCfg += "MCSH=?;";
00292         strCfg += "MCST=?;";
00293         strCfg += "AUO2=?;";
00294         strCfg += "TPMO=?;";
00295         strCfg += "GPED=?;";
00296         strCfg += "GPIN=?;";
00297         strCfg += "GPME=?;";
00298         strCfg += "GPGA=?;";
00299         strCfg += "GPMC=?;";
00300         strCfg += "MCAE=?;";
00301         if (isVOLU) { strCfg += "VOLU=?;"; }
00302         if (isCON1) { strCfg += "CON1=?;"; }
00303         if (isCON2) { strCfg += "CON2=?;"; }
00304         if (isBOOT) { strCfg += "BOOT=?;"; }
00305         return strCfg;
00306 }
00307 
00308 string CAsciiCmdUtilities::CreateFullReadBackCmdMCA8000D(int DppType)
00309 {
00310         string strCfg("");
00311 
00312         if (DppType == dppMCA8000D) {
00313                 strCfg += "RESC=?;";
00314                 strCfg += "PURE=?;";
00315                 strCfg += "MCAS=?;";
00316                 strCfg += "MCAC=?;";
00317                 strCfg += "SOFF=?;";
00318                 strCfg += "GAIA=?;";
00319                 strCfg += "PDMD=?;";
00320                 strCfg += "THSL=?;";
00321                 strCfg += "TLLD=?;";
00322                 strCfg += "GATE=?;";
00323                 strCfg += "AUO1=?;";
00324                 //strCfg += "PRET=?;";
00325                 strCfg += "PRER=?;";
00326                 strCfg += "PREL=?;";
00327                 strCfg += "PREC=?;";
00328                 strCfg += "PRCL=?;";
00329                 strCfg += "PRCH=?;";
00330                 strCfg += "SCOE=?;";
00331                 strCfg += "SCOT=?;";
00332                 strCfg += "SCOG=?;";
00333                 strCfg += "MCSL=?;";
00334                 strCfg += "MCSH=?;";
00335                 strCfg += "MCST=?;";
00336                 strCfg += "AUO2=?;";
00337                 strCfg += "GPED=?;";
00338                 strCfg += "GPIN=?;";
00339                 strCfg += "GPME=?;";
00340                 strCfg += "GPGA=?;";
00341                 strCfg += "GPMC=?;";
00342                 strCfg += "MCAE=?;";
00343                 //strCfg += "VOLU=?;";
00344                 //strCfg += "CON1=?;";
00345                 //strCfg += "CON2=?;";
00346                 strCfg += "PDMD=?;";
00347         }
00348         return strCfg;
00349 }
00350 
00351 string CAsciiCmdUtilities::RemoveCmd(string strCmd, string strCfgData)
00352 {
00353         int iStart,iEnd,iCmd;
00354         string strNew;
00355 
00356         strNew = "";
00357         if (strCfgData.length() < 7) { return strCfgData; }     // no data
00358         if (strCmd.length() != 4) {     return strCfgData; }            // bad command
00359         iCmd = (int)strCfgData.find(strCmd+"=",0);
00360         if (iCmd == -1) { return strCfgData; }                                          // cmd not found
00361         iStart = iCmd;
00362         iEnd = (int)strCfgData.find(";",iCmd);
00363         if (iEnd == -1) { return strCfgData; }                                          // end not found
00364         if (iEnd <= iStart) { return strCfgData; }                                      // unknown error
00365         strNew = strCfgData.substr(0,iStart) + strCfgData.substr(iEnd+1);
00366         return strNew;
00367 }
00368 
00370 string CAsciiCmdUtilities::RemoveCmdByDeviceType(string strCfgDataIn, bool PC5_PRESENT, int DppType, bool isDP5_RevDxGains, unsigned char DPP_ECO)
00371 {
00372         string strCfgData;
00373     bool isHVSE;
00374     bool isPAPS;
00375     bool isTECS;
00376     bool isVOLU;
00377         bool isCON1;
00378         bool isCON2;
00379     bool isINOF;
00380     bool isBOOT;
00381         bool isGATE;
00382         bool isPAPZ;
00383         bool isSCTC;
00384         bool isPREL;
00385         bool isDP5_DxK=false;
00386         bool isDP5_DxL=false;
00387 
00388         strCfgData = strCfgDataIn;
00389         if (DppType == dppMCA8000D) {
00390                 strCfgData = Remove_MCA8000D_Cmds(strCfgData,DppType);
00391                 return strCfgData;
00392         }
00393 
00394         // DP5 Rev Dx K,L needs PAPZ
00395         if ((DppType == dppDP5) && isDP5_RevDxGains) {
00396                 if ((DPP_ECO & 0x0F) == 0x0A) {
00397                         isDP5_DxK = true;
00398                 }
00399                 if ((DPP_ECO & 0x0F) == 0x0B) {
00400                         isDP5_DxL = true;
00401                 }
00402         }
00403 
00404     isHVSE = (((DppType != dppPX5) && PC5_PRESENT) || DppType == dppPX5);
00405     isPAPS = (DppType != dppDP5G) && (DppType != dppTB5);
00406     isTECS = (((DppType == dppDP5) && PC5_PRESENT) || (DppType == dppPX5) || (DppType == dppDP5X));
00407     isVOLU = (DppType == dppPX5);
00408     isCON1 = ((DppType != dppDP5) && (DppType != dppDP5X));
00409     isCON2 = ((DppType != dppDP5) && (DppType != dppDP5X));
00410     isINOF = (DppType != dppDP5G) && (DppType != dppTB5);
00411         isSCTC = (DppType == dppDP5G) || (DppType == dppTB5);
00412     isBOOT = ((DppType == dppDP5) || (DppType == dppDP5X));
00413         isGATE = ((DppType == dppDP5) || (DppType == dppDP5X));
00414         isPAPZ = (DppType == dppPX5) || isDP5_DxK || isDP5_DxL;
00415         isPREL = (DppType == dppMCA8000D);
00416         if (!isHVSE) { strCfgData = RemoveCmd("HVSE", strCfgData); }  //High Voltage Bias
00417         if (!isPAPS) { strCfgData = RemoveCmd("PAPS", strCfgData); }  //Preamp Voltage
00418         if (!isTECS) { strCfgData = RemoveCmd("TECS", strCfgData); }  //Cooler Temperature
00419         if (!isVOLU) { strCfgData = RemoveCmd("VOLU", strCfgData); }  //px5 speaker
00420         if (!isCON1) { strCfgData = RemoveCmd("CON1", strCfgData); }  //connector 1
00421         if (!isCON2) { strCfgData = RemoveCmd("CON2", strCfgData); }  //connector 2
00422         if (!isINOF) { strCfgData = RemoveCmd("INOF", strCfgData); }  //input offset
00423         if (!isBOOT) { strCfgData = RemoveCmd("BOOT", strCfgData); }  //PC5 On At StartUp
00424         if (!isGATE) { strCfgData = RemoveCmd("GATE", strCfgData); }  //Gate input
00425         if (!isPAPZ) { strCfgData = RemoveCmd("PAPZ", strCfgData); }  //Pole-Zero
00426         if (!isSCTC) { strCfgData = RemoveCmd("SCTC", strCfgData); }  //Scintillator Time Constant
00427         if (!isPREL) { strCfgData = RemoveCmd("PREL", strCfgData); }  //Preset Live Time
00428         return strCfgData;
00429 }
00430 
00432 string CAsciiCmdUtilities::RemoveCmdByDeviceTypeDP5DxK(string strCfgDataIn, bool PC5_PRESENT, int DppType)
00433 {
00434         string strCfgData;
00435     bool isHVSE;
00436     bool isPAPS;
00437     bool isTECS;
00438     bool isVOLU;
00439         bool isCON1;
00440         bool isCON2;
00441     bool isINOF;
00442     bool isBOOT;
00443         bool isGATE;
00444         bool isPAPZ;
00445         bool isSCTC;
00446         bool isPREL;
00447 
00448         strCfgData = strCfgDataIn;
00449         //if (DppType == dppMCA8000D) {
00450         //      strCfgData = Remove_MCA8000D_Cmds(strCfgData,DppType);
00451         //      return strCfgData;
00452         //}
00453     isHVSE = (((DppType != dppPX5) && PC5_PRESENT) || DppType == dppPX5);
00454     isPAPS = (DppType != dppDP5G) && (DppType != dppTB5);
00455     isTECS = (((DppType == dppDP5) && PC5_PRESENT) || (DppType == dppPX5) || (DppType == dppDP5X));
00456     isVOLU = (DppType == dppPX5);
00457     isCON1 = ((DppType != dppDP5) && (DppType != dppDP5X));
00458     isCON2 = ((DppType != dppDP5) && (DppType != dppDP5X));
00459     isINOF = (DppType != dppDP5G) && (DppType != dppTB5);
00460         isSCTC = (DppType == dppDP5G) || (DppType == dppTB5);
00461     isBOOT = ((DppType == dppDP5) || (DppType == dppDP5X));
00462         isGATE = ((DppType == dppDP5) || (DppType == dppDP5X));
00463         //isPAPZ = (DppType == dppPX5);         // DP5 Rev Dx K,L needs PAPZ
00464         isPAPZ = true;                                                  // DP5 Rev Dx K,L needs PAPZ
00465         isPREL = (DppType == dppMCA8000D);
00466         if (!isHVSE) { strCfgData = RemoveCmd("HVSE", strCfgData); }  //High Voltage Bias
00467         if (!isPAPS) { strCfgData = RemoveCmd("PAPS", strCfgData); }  //Preamp Voltage
00468         if (!isTECS) { strCfgData = RemoveCmd("TECS", strCfgData); }  //Cooler Temperature
00469         if (!isVOLU) { strCfgData = RemoveCmd("VOLU", strCfgData); }  //px5 speaker
00470         if (!isCON1) { strCfgData = RemoveCmd("CON1", strCfgData); }  //connector 1
00471         if (!isCON2) { strCfgData = RemoveCmd("CON2", strCfgData); }  //connector 2
00472         if (!isINOF) { strCfgData = RemoveCmd("INOF", strCfgData); }  //input offset
00473         if (!isBOOT) { strCfgData = RemoveCmd("BOOT", strCfgData); }  //PC5 On At StartUp
00474         if (!isGATE) { strCfgData = RemoveCmd("GATE", strCfgData); }  //Gate input
00475         if (!isPAPZ) { strCfgData = RemoveCmd("PAPZ", strCfgData); }  //Pole-Zero
00476         if (!isSCTC) { strCfgData = RemoveCmd("SCTC", strCfgData); }  //Scintillator Time Constant
00477         if (!isPREL) { strCfgData = RemoveCmd("PREL", strCfgData); }  //Preset Live Time
00478         return strCfgData;
00479 }
00480 
00482 string CAsciiCmdUtilities::Remove_MCA8000D_Cmds(string strCfgDataIn, int DppType)
00483 {
00484         string strCfgData;
00485         
00486         strCfgData = strCfgDataIn;
00487         if (DppType == dppMCA8000D) {
00488                 strCfgData = RemoveCmd("CLCK", strCfgData);
00489                 strCfgData = RemoveCmd("TPEA", strCfgData);
00490                 strCfgData = RemoveCmd("GAIF", strCfgData);
00491                 strCfgData = RemoveCmd("GAIN", strCfgData);
00492                 strCfgData = RemoveCmd("RESL", strCfgData);
00493                 strCfgData = RemoveCmd("TFLA", strCfgData);
00494                 strCfgData = RemoveCmd("TPFA", strCfgData);
00495                 //strCfgData = RemoveCmd("PURE", strCfgData);
00496                 strCfgData = RemoveCmd("RTDE", strCfgData);
00497                 strCfgData = RemoveCmd("AINP", strCfgData);
00498                 strCfgData = RemoveCmd("INOF", strCfgData);
00499                 strCfgData = RemoveCmd("CUSP", strCfgData);
00500                 strCfgData = RemoveCmd("THFA", strCfgData);
00501                 strCfgData = RemoveCmd("DACO", strCfgData);
00502                 strCfgData = RemoveCmd("DACF", strCfgData);
00503                 strCfgData = RemoveCmd("RTDS", strCfgData);
00504                 strCfgData = RemoveCmd("RTDT", strCfgData);
00505                 strCfgData = RemoveCmd("BLRM", strCfgData);
00506                 strCfgData = RemoveCmd("BLRD", strCfgData);
00507                 strCfgData = RemoveCmd("BLRU", strCfgData);
00508                 strCfgData = RemoveCmd("PRET", strCfgData);
00509                 strCfgData = RemoveCmd("HVSE", strCfgData);
00510                 strCfgData = RemoveCmd("TECS", strCfgData);
00511                 strCfgData = RemoveCmd("PAPZ", strCfgData);
00512                 strCfgData = RemoveCmd("PAPS", strCfgData);
00513                 strCfgData = RemoveCmd("TPMO", strCfgData);
00514                 strCfgData = RemoveCmd("SCAH", strCfgData);
00515                 strCfgData = RemoveCmd("SCAI", strCfgData);
00516                 strCfgData = RemoveCmd("SCAL", strCfgData);
00517                 strCfgData = RemoveCmd("SCAO", strCfgData);
00518                 strCfgData = RemoveCmd("SCAW", strCfgData);
00519                 strCfgData = RemoveCmd("BOOT", strCfgData);
00520 
00521                 // added to list late, recheck at later date 20120817
00522                 strCfgData = RemoveCmd("CON1", strCfgData);
00523                 strCfgData = RemoveCmd("CON2", strCfgData);
00524 
00525                 // not implemented as of 20120817, will be implemented at some time
00526                 strCfgData = RemoveCmd("VOLU", strCfgData);      
00527         }
00528         return strCfgData;
00529 }
00530 
00531 // replaces all occurrences of substring in string
00532 std::string CAsciiCmdUtilities::ReplaceCmdText(std::string strInTextIn, std::string strFrom, std::string strTo)
00533 {
00534         std::string strReplaceText;
00535         std::string strInText; 
00536         std::string strOutText; 
00537         int lFromLen; 
00538         int lMatchPos; 
00539 
00540         strInText = strInTextIn;
00541         strOutText = "";
00542         lFromLen = (int)strFrom.length();
00543         while (strInText.length()>0) {
00544                 lMatchPos = (1+(int)strInText.find(strFrom));
00545                 if (lMatchPos==0) {
00546                         strOutText = strOutText+strInText;
00547                         strInText = "";
00548                 } else {
00549                         strOutText = strOutText+strInText.substr(0,lMatchPos-1)+strTo;
00550                         strInText = std::string(strInText).substr(lMatchPos+lFromLen-1);
00551                 }
00552         }
00553         strReplaceText = strOutText;
00554         return strReplaceText;
00555 }
00556 
00557 // breaks ASCII Command string into two chuncks, returns split position
00558 int CAsciiCmdUtilities::GetCmdChunk(std::string strCmd)
00559 {
00560         int GetCmdChunk = 0;
00561         int idxCfg; 
00562         int lChunk; 
00563         int lEnd; 
00564         GetCmdChunk = 0;
00565         lChunk = 0;
00566         lEnd = 0;
00567         for(idxCfg=1; idxCfg<=(int)strCmd.length();idxCfg++) {
00568                 lChunk = (int)(1+strCmd.find(";", lEnd));
00569                 if ((lChunk==0) || (lChunk>512)) {
00570                         break;
00571                 }
00572                 lEnd = lChunk;
00573         }
00574         GetCmdChunk = lEnd;
00575         return GetCmdChunk;
00576 }
00577 
00578 bool CAsciiCmdUtilities::CopyAsciiData(unsigned char Data[], string strCfg, long lLen)
00579 {
00580         long idxData;
00581         const char *c_str1 = strCfg.c_str();
00582 
00583         if (lLen > 0) {
00584                 for(idxData=0;idxData<lLen;idxData++) {
00585                         Data[idxData] = c_str1[idxData];
00586                 }
00587                 return true;
00588         } else {
00589                 return false;
00590         }
00591         return false;
00592 }