Skip to content

Commit

Permalink
fix 1526/224x
Browse files Browse the repository at this point in the history
  • Loading branch information
zxkmm committed Jun 5, 2023
1 parent f286357 commit bdb3f1f
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 26 deletions.
8 changes: 6 additions & 2 deletions src/Algo1527_2242.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ std::string Algo1527_2242::decode1527FromUrh(std::string stringOf1527WaveformFro
std::ostringstream ossCode;
std::string decoded1527 = "";
stringOf1527WaveformFromUrh = stringUnit.removeNonDesiredCharacters(stringOf1527WaveformFromUrh, "01");
// std::cout << "\n15$" + stringOf1527WaveformFromUrh + "$\n" << std::endl; //DBG
stringOf1527WaveformFromUrh = stringUnit.replaceMeaningless0WithSpace(stringOf1527WaveformFromUrh);
// std::cout << "\n17$" + stringOf1527WaveformFromUrh + "$\n" << std::endl; //DBG
stringOf1527WaveformFromUrh = " " + stringOf1527WaveformFromUrh + " ";
// std::cout << "\n19$" + stringOf1527WaveformFromUrh + "$\n" << std::endl; //DBG

//检测line这个字符串当中有多少个由空格分开的部分,如果由空格分开的部分小于25或者大于26,就提示异常
int count = 0;
Expand All @@ -21,11 +25,11 @@ std::string Algo1527_2242::decode1527FromUrh(std::string stringOf1527WaveformFro
count++;
}
}
if (count != 25) {
if (count != 26) {

decoded1527 =
"Error: you inputed too less or too many data, it could happen if the encoder is not 1527. the data you inputed has "
+ std::to_string(count) + " wave crest, but 1527 should be be 25 \n";
+ std::to_string(count - 1) + " wave crest, but 1527 should be be 25 \n";

return decoded1527;
}
Expand Down
52 changes: 28 additions & 24 deletions src/Interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,40 @@
#include "AlgoGeneral.h"

void Interface::outputAClearResult(std::string explainContent, std::string result, std::string ADFormat) {
// cout << explainContent << result << ADFormat << endl;
//detect how long the result is, then put the result into an int variable
unsigned long resultLength = result.length();
// std::cout << resultLength << std::endl; //DBG
//detect how long the explainContent is, then put the explainContent into an int variable
unsigned long explainContentLength = explainContent.length();
//out put spaces which is as long as explainContentLength
for (int i = 0; i < explainContentLength; i++) {
std::cout << " ";
}
std::cout << "";
//output spaces which is as long as resultLength
for (int i = 0; i < resultLength; i++) {
std::cout << "";
}
std::cout << "" << std::endl;
std::cout << explainContent << "" << result << "" << std::endl;
for (int i = 0; i < explainContentLength; i++) {
std::cout << " ";
}
std::cout << "";
for (int i = 0; i < resultLength; i++) {
std::cout << "";
}
std::cout << "" << std::endl;
//output spaces which is as long as explainContentLength
for (int i = 0; i < explainContentLength; i++) {
std::cout << " ";
if (resultLength < 80) {
for (int i = 0; i < explainContentLength; i++) {
std::cout << " ";
}
std::cout << "";
//output spaces which is as long as resultLength
for (int i = 0; i < resultLength; i++) {
std::cout << "";
}
std::cout << "" << std::endl;
std::cout << explainContent << "" << result << "" << std::endl;
for (int i = 0; i < explainContentLength; i++) {
std::cout << " ";
}
std::cout << "";
for (int i = 0; i < resultLength; i++) {
std::cout << "";
}
std::cout << "" << std::endl;
//output spaces which is as long as explainContentLength
for (int i = 0; i < explainContentLength; i++) {
std::cout << " ";
}
std::cout << " " + ADFormat;
std::cout << "\n";
} else {
std::cout << std::endl << result << std::endl;
}
std::cout << " " + ADFormat;
std::cout << "\n";
}

int Interface::mainMenu() {
Expand Down
1 change: 1 addition & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
int main() {
Interface interface;
if (interface.mainMenu() == 1) {
std::cout << "\nback to main menu\n";
interface.mainMenu();
}
return 0;
Expand Down

0 comments on commit bdb3f1f

Please sign in to comment.