use of com.willwinder.universalgcodesender.types.GcodeCommand in project Universal-G-Code-Sender by winder.
the class AbstractController method offsetTool.
@Override
public void offsetTool(String axis, double offset, UnitUtils.Units units) throws Exception {
logger.log(Level.INFO, "Probe offset.");
String offsetPattern = "G43.1 %s%s";
String offsetCommand = String.format(offsetPattern, axis, formatter.format(offset * scaleUnits(units, MM)));
GcodeCommand state = createCommand("G21 G90");
state.setTemporaryParserModalChange(true);
this.sendCommandImmediately(state);
this.sendCommandImmediately(createCommand(offsetCommand));
restoreParserModalState();
}
use of com.willwinder.universalgcodesender.types.GcodeCommand in project Universal-G-Code-Sender by winder.
the class AbstractController method probe.
@Override
public void probe(String axis, double feedRate, double distance, UnitUtils.Units units) throws Exception {
logger.log(Level.INFO, "Probing.");
String probePattern = "G38.2 %s%s F%s";
double unitScale = scaleUnits(units, MM);
String probeCommand = String.format(probePattern, axis, formatter.format(distance * unitScale), formatter.format(feedRate * unitScale));
GcodeCommand state = createCommand("G21 G91 G49");
state.setTemporaryParserModalChange(true);
GcodeCommand probe = createCommand(probeCommand);
probe.setTemporaryParserModalChange(true);
this.sendCommandImmediately(state);
this.sendCommandImmediately(probe);
restoreParserModalState();
}
use of com.willwinder.universalgcodesender.types.GcodeCommand in project Universal-G-Code-Sender by winder.
the class AbstractController method restoreParserModalState.
@Override
public void restoreParserModalState() {
StringBuilder cmd = new StringBuilder();
if (getDistanceModeCode() != null) {
cmd.append(getDistanceModeCode()).append(" ");
}
if (getUnitsCode() != null) {
cmd.append(getUnitsCode()).append(" ");
}
try {
GcodeCommand command = createCommand(cmd.toString());
command.setTemporaryParserModalChange(true);
sendCommandImmediately(command);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of com.willwinder.universalgcodesender.types.GcodeCommand in project Universal-G-Code-Sender by winder.
the class BufferedCommunicator method responseMessage.
/**
* Processes message from GRBL. This should only be called from the
* connection object.
* @param response
*/
@Override
public void responseMessage(String response) {
// Send this information back up to the Controller.
dispatchListenerEvents(SerialCommunicatorEvent.RAW_RESPONSE, response);
// Pause if there was an error and if there are more commands queued
if (processedCommandIsError(response) && (// No cached command
nextCommand != null || // No more commands (except for the one being popped further down)
(activeCommandList.size() > 1) || // No more rows in stream
(commandStream != null && commandStream.getNumRowsRemaining() > 0) || (commandBuffer != null && commandBuffer.size() > 0))) {
// No commands in buffer
pauseSend();
dispatchListenerEvents(PAUSED, "");
}
// Keep the data flow going in case of an "ok" or an "error".
if (processedCommand(response)) {
// Pop the front of the active list.
if (this.activeCommandList != null && this.activeCommandList.size() > 0) {
GcodeCommand command = this.activeCommandList.pop();
this.sentBufferSize -= (command.getCommandString().length() + 1);
if (!isPaused()) {
this.streamCommands();
}
}
}
}
use of com.willwinder.universalgcodesender.types.GcodeCommand in project Universal-G-Code-Sender by winder.
the class BufferedCommunicator method activeCommandSummary.
@Override
public String activeCommandSummary() {
StringBuilder sb = new StringBuilder();
String comma = "";
for (GcodeCommand gc : activeCommandList) {
sb.append(comma).append(gc.getCommandString());
comma = ", ";
}
if (commandStream != null) {
sb.append(comma).append(commandStream.getNumRowsRemaining()).append(" streaming commands.");
}
return sb.toString();
}
Aggregations