-
Notifications
You must be signed in to change notification settings - Fork 0
/
FakeDriver.cpp
90 lines (77 loc) · 1.28 KB
/
FakeDriver.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
#include "FakeDriver.hh"
#include <unistd.h>
FakeDriver::FakeDriver():
tP{NULL},
currX{0},
currY{0},
currZ{0},
xPin{0},
xDir{1},
yPin{2},
yDir{3},
zPin{4},
zDir{5},
xPos{true},
yPos{true},
zPos{true}
{
}
void FakeDriver::progress( short x, short y, short z)
{
usleep( 1000);
}
void FakeDriver::setPath( vector<toolPath*>* p)
{
this->tP = p;
this->currX = p->at(0)->at(0)->getX();
this->currY = p->at(0)->at(0)->getY();
this->currZ = p->at(0)->at(0)->getZ();
}
void FakeDriver::doTheJob()
{
int x = 0;
int y = 0;
int z = 0;
toolPath* p;
for( unsigned int i = 0; i < this->tP->size(); i++)
{
p = this->tP->at(i);
for( int j = 0; j < p->size(); j++)
{
x = p->at(j)->getX();
y = p->at(j)->getY();
z = p->at(j)->getZ();
this->progress( x - currX, y - currY, z - currZ);
currX = x;
currY = y;
currZ = z;
}
}
}
void FakeDriver::goX( int i)
{
int dir = 1;
if( i < 0) dir = -1;
for( int j = 0; j != i; j += dir)
{
this->progress( dir, 0, 0);
}
}
void FakeDriver::goY( int i)
{
int dir = 1;
if( i < 0) dir = -1;
for( int j = 0; j != i; j += dir)
{
this->progress( 0, dir, 0);
}
}
void FakeDriver::goZ( int i)
{
int dir = 1;
if( i < 0) dir = -1;
for( int j = 0; j != i; j += dir)
{
this->progress( 0, 0, dir);
}
}