-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgCommand.cpp
More file actions
128 lines (101 loc) · 1.65 KB
/
gCommand.cpp
File metadata and controls
128 lines (101 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#include "gCommand.hh"
#include <string>
#include <iostream>
gCommand::gCommand( unsigned int g)
{
if( g > 3 ) throw gCodeValueException( g);
this->G = g;
}
gCommand::gCommand( unsigned int g, unsigned int n)
{
if( g > 3 ) throw gCodeValueException( g);
this->G = g;
this->N = n;
}
gCommand::~gCommand()
{
}
int gCommand::setX( double x)
{
this->X = x;
return 1;
}
int gCommand::setY( double x)
{
this->Y = x;
return 1;
}
int gCommand::setZ( double x)
{
this->Z = x;
return 1;
}
int gCommand::setI( double x)
{
this->I = x;
return 1;
}
int gCommand::setJ( double x)
{
this->J = x;
return 1;
}
int gCommand::setN( unsigned int x)
{
this->N = x;
return 1;
}
unsigned int gCommand::getN()
{
return this->N;
}
unsigned int gCommand::getG()
{
return this->G;
}
double gCommand::getX()
{
return this->X;
}
double gCommand::getY()
{
return this->Y;
}
double gCommand::getZ()
{
return this->Z;
}
double gCommand::getI()
{
return this->I;
}
double gCommand::getJ()
{
return this->J;
}
string gCommand::toString()
{
string str = "G: " + to_string(this->G);
str += " X: " + to_string(this->X);
str += " Y: " + to_string(this->Y);
str += " Z: " + to_string(this->Z);
str += " N: " + to_string(this->N);
str += " I: " + to_string(this->I);
str += " J: " + to_string(this->J);
return str;
}
gCodeValueException::gCodeValueException( unsigned int i):
exception(),
i(i)
{
}
gCodeValueException::~gCodeValueException()
{
}
const char* gCodeValueException::what() const throw()
{
string str = " is not a valied G-Code command (atleast for us (in the moment)).";
str = to_string( i) + str;
cout << str << endl;
return str.c_str();
}