75 lines
1.6 KiB
C++
75 lines
1.6 KiB
C++
|
|
#include "gcode.h"
|
||
|
|
#include "../string_utils.h"
|
||
|
|
|
||
|
|
std::vector<int> iosender::ToIndices(iosender::AxisFlags flags) {
|
||
|
|
std::vector<int> result;
|
||
|
|
|
||
|
|
int i = 0, j = (int) flags;
|
||
|
|
while (j != 0) {
|
||
|
|
if ((j & 0x01) != 0)
|
||
|
|
result.push_back(i);
|
||
|
|
i++;
|
||
|
|
j >>= 1;
|
||
|
|
}
|
||
|
|
return result;
|
||
|
|
}
|
||
|
|
|
||
|
|
std::vector<int> iosender::ToIndices(iosender::IJKFlags flags) {
|
||
|
|
std::vector<int> result;
|
||
|
|
|
||
|
|
int i = 0, j = (int) flags;
|
||
|
|
while (j != 0) {
|
||
|
|
if ((j & 0x01) != 0)
|
||
|
|
result.push_back(i);
|
||
|
|
i++;
|
||
|
|
j >>= 1;
|
||
|
|
}
|
||
|
|
return result;
|
||
|
|
}
|
||
|
|
|
||
|
|
std::vector<int> iosender::ToIndices(iosender::ThreadingFlags flags) {
|
||
|
|
std::vector<int> result;
|
||
|
|
|
||
|
|
int i = 0, j = (int) flags;
|
||
|
|
while (j != 0) {
|
||
|
|
if ((j & 0x01) != 0)
|
||
|
|
result.push_back(i);
|
||
|
|
i++;
|
||
|
|
j >>= 1;
|
||
|
|
}
|
||
|
|
return result;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
std::string iosender::GCodeUtils::StripSpaces(std::string line) {
|
||
|
|
std::string s;
|
||
|
|
bool skip = true;
|
||
|
|
|
||
|
|
s = to_upper(line);
|
||
|
|
if (string_contains(s, "(MSG,")) {
|
||
|
|
s = "";
|
||
|
|
for (auto c: line) {
|
||
|
|
switch (c) {
|
||
|
|
case '(':
|
||
|
|
s += c;
|
||
|
|
skip = false;
|
||
|
|
break;
|
||
|
|
case ')':
|
||
|
|
skip = true;
|
||
|
|
s += c;
|
||
|
|
break;
|
||
|
|
case ' ':
|
||
|
|
if (!skip)
|
||
|
|
s += c;
|
||
|
|
break;
|
||
|
|
default:
|
||
|
|
s += c;
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
s = remove_spaces(line);
|
||
|
|
}
|
||
|
|
|
||
|
|
return s;
|
||
|
|
}
|