- Timestamp:
- Mar 23, 2015, 12:24:04 PM (10 years ago)
- Location:
- trunk/SpanCPTComponent
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SpanCPTComponent/CPTComponent.cpp
r59 r78 57 57 58 58 //decoding 59 currentDataFrame =""; 60 currentRoadtime = 0; 61 currentTimerange = 0; 59 currentDataFrame_ =""; 62 60 63 61 frameToDecode = ""; … … 89 87 setPortCOM( xmlParameters().getProperty("port").toLatin1() ); 90 88 91 if (!xmlParameters().getProperty(" isRecording()").isNull()) {92 setRecording ( (xmlParameters().getProperty(" isRecording()") == "true" ? true : false) );89 if (!xmlParameters().getProperty("recording").isNull()) { 90 setRecording ( (xmlParameters().getProperty("recording") == "true" ? true : false) ); 93 91 } 94 92 if (!xmlParameters().getProperty("verbose").isNull()) { … … 148 146 149 147 // get the frame and remove it in the list 150 FRAME * currentFrame = serialPort-> firstFrame();148 FRAME * currentFrame = serialPort->getNextFrame(); 151 149 152 150 char * currentDataFrame = new char[currentFrame->length]; … … 154 152 currentDataFrameLength_ = currentFrame->length; 155 153 currentRoadtime_ = currentFrame->t; 156 157 serialPort->removeFirstFrame(); 154 155 // free memory 156 delete currentFrame; 158 157 159 158 setState(ComponentBase::MONITOR_OK); … … 174 173 memcpy(buffer, currentDataFrame, currentDataFrameLength_); 175 174 buffer[currentDataFrameLength_] = '\0'; // add a \0 to convert for the conversion in QString 176 177 currentDataFrame = buffer; 178 currentRoadtime = currentRoadtime_;179 currentTimerange = currentRoadtime_;175 currentDataFrame_ = QString::fromAscii(buffer); 176 177 delete[] buffer; 178 delete[] currentDataFrame; 180 179 181 180 analyzeFrame(); … … 319 318 frameToDecode = ""; 320 319 } 321 delete[] buffer;322 delete[] currentDataFrame;323 320 324 321 memcpy(mAllFramesBuffer, allFramesBuffer, AllFramesSize); … … 436 433 //} 437 434 438 currentDataFrame = restOfFrame + currentDataFrame;435 currentDataFrame_ = restOfFrame + currentDataFrame_; 439 436 restOfFrame = ""; 440 437 441 if (currentDataFrame .indexOf(QRegExp("[$#%]"),0)!=-1) {442 sofIdx_ = currentDataFrame .indexOf(QRegExp("[$#%]"),0);438 if (currentDataFrame_.indexOf(QRegExp("[$#%]"),0)!=-1) { 439 sofIdx_ = currentDataFrame_.indexOf(QRegExp("[$#%]"),0); 443 440 startOfFrame = true; 444 timeOfFrameToDecode = currentRoadtime ;445 446 if (currentDataFrame .indexOf("\n",sofIdx_)!=-1) {447 eofIdx_ = currentDataFrame .indexOf("\n",sofIdx_);441 timeOfFrameToDecode = currentRoadtime_; 442 443 if (currentDataFrame_.indexOf("\n",sofIdx_)!=-1) { 444 eofIdx_ = currentDataFrame_.indexOf("\n",sofIdx_); 448 445 endOfFrame = true; 449 timerangeOfFrameToDecode = currentTimerange ;446 timerangeOfFrameToDecode = currentTimerange_; 450 447 } 451 448 else 452 restOfFrame = currentDataFrame ;449 restOfFrame = currentDataFrame_; 453 450 } 454 451 else 455 restOfFrame = currentDataFrame ;452 restOfFrame = currentDataFrame_; 456 453 457 454 if ( (startOfFrame) && (endOfFrame) ) … … 459 456 newFrameToDecode = true; 460 457 for (int i=sofIdx_;i<eofIdx_;i++) 461 frameToDecode +=currentDataFrame .at(i);462 for (int j=eofIdx_+1; j<currentDataFrame .size(); j++)463 restOfFrame +=currentDataFrame .at(j);458 frameToDecode +=currentDataFrame_.at(i); 459 for (int j=eofIdx_+1; j<currentDataFrame_.size(); j++) 460 restOfFrame +=currentDataFrame_.at(j); 464 461 if (mVerbose) { 465 462 LOG_DEBUG("[Frame:] " << frameToDecode); -
trunk/SpanCPTComponent/CPTComponent.h
r59 r78 84 84 #endif 85 85 86 road_time_t currentRoadtime_; 87 road_timerange_t currentTimerange_; 88 int currentDataFrameLength_; 86 87 89 88 90 89 bool mVerbose; … … 111 110 112 111 //Decoding 113 QString currentDataFrame; 114 road_time_t currentRoadtime; 115 road_timerange_t currentTimerange; 112 QString currentDataFrame_; 113 road_time_t currentRoadtime_; 114 road_timerange_t currentTimerange_; 115 int currentDataFrameLength_; 116 116 117 117 QString frameToDecode;
Note:
See TracChangeset
for help on using the changeset viewer.