-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcore.cpp
119 lines (106 loc) · 1.81 KB
/
core.cpp
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
#include "core.hh"
#include "gCodeFile.hh"
#include "gCommand.hh"
#include "cncState.hh"
#include "gCodeProcessor.hh"
#include "toolPath.hh"
#include "cncMachine.hh"
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main( void)
{
core a;
unsigned int uinp = 0;
while( uinp < 5)
{
uinp = a.getUInp();
a.prosInp( uinp);
}
return 0;
}
unsigned int core::getUInp()
{
unsigned int a = 0;
do
{
cout << "What to do?" << endl;
cout << "1 -Input g-Code-File" << endl;
cout << "2 -Print path" << endl;
cout << "3 -go Direction" << endl;
cout << "4 -go Path" << endl;
cout << "5 -exit" << endl;
cout << "Input: ";
cin >> a;
}while( a == 0 || a > 5);
return a;
}
void core::prosInp( unsigned int a)
{
switch( a)
{
case 1:
this->setGCodeFile();
break;
case 2:
this->printPath();
break;
case 3:
this->goDir();
break;
case 4:
this->driv.setPath( this->cM.getPathes());
this->driv.doTheJob();
break;
}
return;
}
void core::setGCodeFile()
{
string inp;
cout << "File: ";
cin >> inp;
this->cM.setFile( inp);
this->cM.createPath();
return;
}
void core::printPath()
{
vector<toolPath*>* path = this->cM.getPathes();
for( unsigned int i = 0; i < path->size(); i++)
{
for( int j = 0; j < path->at(i)->size(); j++)
{
cout << path->at(i)->at(j)->getX();
cout << "\t";
cout << path->at(i)->at(j)->getY();
cout << "\t";
cout << path->at(i)->at(j)->getZ();
cout << endl;
}
}
}
void core::goDir()
{
int dir = 0;
int steps = 0;
cout << "Which direction? (1,2,3): ";
cin >> dir;
cout << endl;
cout << "How many steps?: ";
cin >> steps;
cout << endl;
switch( dir)
{
case 1:
this->driv.goX( steps);
break;
case 2:
this->driv.goY( steps);
break;
case 3:
this->driv.goZ( steps);
break;
}
}