1 | <?php |
||
10 | class DmplBuilder |
||
11 | { |
||
12 | |||
13 | /** |
||
14 | * Generated DM/PL command instructions. |
||
15 | * |
||
16 | * @var array |
||
17 | */ |
||
18 | protected $instructions = []; |
||
19 | |||
20 | /** |
||
21 | * @var bool |
||
22 | */ |
||
23 | protected $cutOff = false; |
||
24 | |||
25 | /** |
||
26 | * @var bool |
||
27 | */ |
||
28 | protected $flipAxes = false; |
||
29 | |||
30 | /** |
||
31 | * @var mixed |
||
32 | */ |
||
33 | protected $measuringUnit = 'M'; |
||
34 | |||
35 | const KISS_CUT = 50; |
||
36 | const FLEXCUT_PEN = 6; |
||
37 | const REGULAR_PEN = 0; |
||
38 | const CUT_THROUGH = 100; |
||
39 | |||
40 | /** |
||
41 | * Adds a new plot of x and y to machine instructions. |
||
42 | * |
||
43 | * @param int $x |
||
44 | * @param int $y |
||
45 | * @return $this |
||
46 | */ |
||
47 | public function plot(int $x, int $y) |
||
53 | |||
54 | /** |
||
55 | * Changes the pen of the plotter. |
||
56 | * |
||
57 | * @param int $pen |
||
58 | * @return $this |
||
59 | */ |
||
60 | public function changePen(int $pen) |
||
68 | |||
69 | /** |
||
70 | * Compiles a string in DMPL format with machine instructions. |
||
71 | * |
||
72 | * @return string |
||
73 | */ |
||
74 | public function compileDmpl(): string |
||
82 | |||
83 | /** |
||
84 | * Pushes a command to the instructions. |
||
85 | * |
||
86 | * @param string $command |
||
87 | * @return $this |
||
88 | */ |
||
89 | public function pushCommand(string $command) |
||
95 | |||
96 | /** |
||
97 | * Lifts the pen up. |
||
98 | * |
||
99 | * @return $this |
||
100 | */ |
||
101 | public function penUp() |
||
105 | |||
106 | /** |
||
107 | * Pushes the pen down on paper. |
||
108 | * |
||
109 | * @return $this |
||
110 | */ |
||
111 | public function penDown() |
||
115 | |||
116 | /** |
||
117 | * Changes the plotter pen to use flexcut. |
||
118 | * |
||
119 | * @return $this |
||
120 | */ |
||
121 | public function flexCut() |
||
125 | |||
126 | /** |
||
127 | * Change to the regular plotter pen. |
||
128 | * |
||
129 | * @return $this |
||
130 | */ |
||
131 | public function regularCut() |
||
135 | |||
136 | /** |
||
137 | * Changes the pen pressure in gram. |
||
138 | * |
||
139 | * @param int $gramPressure |
||
140 | * @return $this |
||
141 | */ |
||
142 | public function pressure(int $gramPressure) |
||
146 | |||
147 | /** |
||
148 | * Specifies measuring unit. |
||
149 | * 1 selects 0.001 inch |
||
150 | * 5 selects 0.005 inch |
||
151 | * M selects 0.1 mm |
||
152 | * |
||
153 | * @param $unit |
||
154 | * @return $this |
||
155 | */ |
||
156 | public function setMeasuringUnit($unit) |
||
162 | |||
163 | /** |
||
164 | * Changes the plotter velocity. |
||
165 | * |
||
166 | * @param int $velocity |
||
167 | * @return $this |
||
168 | */ |
||
169 | public function velocity(int $velocity) |
||
173 | |||
174 | /** |
||
175 | * Flips the x, y coordinates. |
||
176 | * |
||
177 | * @return $this |
||
178 | */ |
||
179 | public function flipAxes() |
||
185 | |||
186 | /** |
||
187 | * Cuts off paper when a operation finishes. |
||
188 | * |
||
189 | * @return $this |
||
190 | */ |
||
191 | public function cutOff() |
||
197 | |||
198 | } |
||
199 |