-
-
Notifications
You must be signed in to change notification settings - Fork 823
Expand file tree
/
Copy pathIController.java
More file actions
231 lines (196 loc) · 7.52 KB
/
Copy pathIController.java
File metadata and controls
231 lines (196 loc) · 7.52 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
/*
Copyright 2015-2018 Will Winder
This file is part of Universal Gcode Sender (UGS).
UGS is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
UGS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with UGS. If not, see <http://www.gnu.org/licenses/>.
*/
package com.willwinder.universalgcodesender;
import com.willwinder.universalgcodesender.connection.ConnectionDriver;
import com.willwinder.universalgcodesender.gcode.GcodeState;
import com.willwinder.universalgcodesender.listeners.ControllerListener;
import com.willwinder.universalgcodesender.listeners.ControllerStatus;
import com.willwinder.universalgcodesender.model.Overrides;
import com.willwinder.universalgcodesender.model.Position;
import com.willwinder.universalgcodesender.model.UGSEvent.ControlState;
import com.willwinder.universalgcodesender.model.UnitUtils;
import com.willwinder.universalgcodesender.model.UnitUtils.Units;
import com.willwinder.universalgcodesender.firmware.IFirmwareSettings;
import com.willwinder.universalgcodesender.model.Axis;
import com.willwinder.universalgcodesender.services.MessageService;
import com.willwinder.universalgcodesender.types.GcodeCommand;
import com.willwinder.universalgcodesender.utils.GcodeStreamReader;
import java.io.File;
import java.util.Optional;
/**
*
* @author will
*/
public interface IController {
/**
* Adds listener for observing controller events such as connection status,
* file send status and machine status
*
* @param listener the listener to observe the controller
*/
void addListener(ControllerListener listener);
/**
* Removes a listener for this controller
*
* @param listener to be removed
*/
void removeListener(ControllerListener listener);
/**
* Assigns a message service to be used for writing messages to the console
*
* @param messageService the central message service
*/
void setMessageService(MessageService messageService);
/*
Actions
*/
void performHomingCycle() throws Exception;
void returnToHome() throws Exception;
void resetCoordinatesToZero() throws Exception;
void resetCoordinateToZero(final Axis coord) throws Exception;
/**
* Sets the work position for a given axis to the position
*
* @param axis the axis to change
* @param position the new position to set
* @throws Exception if assigning the new position gave an error
*/
void setWorkPosition(Axis axis, double position) throws Exception;
void killAlarmLock() throws Exception;
void toggleCheckMode() throws Exception;
void viewParserState() throws Exception;
void issueSoftReset() throws Exception;
/**
* Jogs the machine in the direction specified by vector dirX,
* dirY, dirZ given the direction as 1, 0 or -1. The distance is specified by stepSize in the given units.
*
* @param dirX if the jogging should happen in X-direction, possible values are 1, 0 or -1
* @param dirY if the jogging should happen in Y-direction, possible values are 1, 0 or -1
* @param dirZ if the jogging should happen in Z-direction, possible values are 1, 0 or -1
* @param stepSize how long should we jog and is given in mm or inches
* @param feedRate how fast should we jog in the direction
* @param units the units of the stepSize and feed rate
* @throws Exception if something went wrong when jogging
*/
void jogMachine(int dirX, int dirY, int dirZ,
double stepSize, double feedRate, Units units) throws Exception;
/**
* Jogs the machine to the given position. The feed rate is given in the same units / minute.
*
* @param position the position to move to
* @param feedRate the feed rate using the units in the position.
*/
void jogMachineTo(Position position, double feedRate) throws Exception;
/**
* Probe control
*/
void probe(String axis, double feedRate, double distance, UnitUtils.Units units) throws Exception;
void offsetTool(String axis, double offset, UnitUtils.Units units) throws Exception;
/*
Overrides
*/
void sendOverrideCommand(Overrides command) throws Exception;
/*
Behavior
*/
void setSingleStepMode(boolean enabled);
boolean getSingleStepMode();
void setSingleBlockMode(boolean enabled);
boolean getSingleBlockMode();
void setStatusUpdatesEnabled(boolean enabled);
boolean getStatusUpdatesEnabled();
void setStatusUpdateRate(int rate);
int getStatusUpdateRate();
long getJobLengthEstimate(File gcodeFile);
/*
Serial
*/
Boolean openCommPort(ConnectionDriver connectionDriver, String port, int portRate) throws Exception;
Boolean closeCommPort() throws Exception;
Boolean isCommOpen();
/*
Stream information
*/
Boolean isReadyToReceiveCommands() throws Exception;
Boolean isReadyToStreamFile() throws Exception;
Boolean isStreaming();
long getSendDuration();
int rowsInSend();
int rowsSent();
int rowsCompleted();
int rowsRemaining();
Optional<GcodeCommand> getActiveCommand();
GcodeState getCurrentGcodeState();
/*
Stream control
*/
void beginStreaming() throws Exception;
void pauseStreaming() throws Exception;
void resumeStreaming() throws Exception;
Boolean isPaused();
Boolean isIdle();
void cancelSend() throws Exception;
ControlState getControlState();
/**
* In case a controller reset is detected.
*/
void resetBuffers();
/**
* Indicator to abstract GUIBackend implementation that the contract class
* will handle ALL state change events. When this returns true it means
* things like completing the final command in a stream will not
* automatically re-enable buttons.
*/
Boolean handlesAllStateChangeEvents();
/*
Stream content
*/
GcodeCommand createCommand(String gcode) throws Exception;
void sendCommandImmediately(GcodeCommand cmd) throws Exception;
void queueCommand(GcodeCommand cmd) throws Exception;
void queueStream(GcodeStreamReader r);
/**
* Cancel the running command and clear the command queue.
*/
void cancelCommands();
void restoreParserModalState();
void updateParserModalState(GcodeCommand command);
AbstractCommunicator getCommunicator();
/**
* Returns the capabilities that is supported by the controller
*
* @return the supported capabilities for the controller.
*/
Capabilities getCapabilities();
/**
* Fetches the firmware settings for the controller that can be used for
* both querying and changing its settings.
*
* @return the firmware settings for the controller.
*/
IFirmwareSettings getFirmwareSettings();
/**
* When connected this will return the controller firmware version.
*
* @return a version string
*/
String getFirmwareVersion();
/**
* Returns the controller status. This method may never return null.
*
* @return the current controller status
*/
ControllerStatus getControllerStatus();
}