use of com.willwinder.universalgcodesender.types.GcodeCommand in project Universal-G-Code-Sender by winder.
the class BufferedCommunicator method streamCommands.
/**
* Streams anything in the command buffer to the comm port.
* Synchronized to prevent commands from sending out of order.
*/
@Override
public synchronized void streamCommands() {
// If there are no commands to send, exit.
if (this.getNextCommand() == null) {
logger.log(Level.INFO, "There are no more commands to stream");
return;
}
// OR We are in single command mode and there are no active commands.
while (this.getNextCommand() != null && !isPaused() && CommUtils.checkRoomInBuffer(this.sentBufferSize, this.getNextCommand().getCommandString(), this.getBufferSize()) && allowMoreCommands()) {
GcodeCommand command = this.getNextCommand();
if (command.getCommandString().isEmpty()) {
dispatchListenerEvents(COMMAND_SKIPPED, command);
nextCommand = null;
continue;
}
String commandString = command.getCommandString().trim();
this.activeCommandList.add(command);
this.sentBufferSize += (commandString.length() + 1);
// Command already has a newline attached.
this.sendMessageToConsoleListener(">>> " + commandString + "\n");
try {
this.sendingCommand(commandString);
conn.sendStringToComm(commandString + "\n");
dispatchListenerEvents(COMMAND_SENT, command);
nextCommand = null;
} catch (Exception e) {
e.printStackTrace();
System.exit(-1);
}
}
}
use of com.willwinder.universalgcodesender.types.GcodeCommand in project Universal-G-Code-Sender by winder.
the class GrblController method viewParserState.
@Override
public void viewParserState() throws Exception {
if (this.isCommOpen()) {
String gcode = GrblUtils.getViewParserStateCommand(this.grblVersion, this.grblVersionLetter);
if (!"".equals(gcode)) {
GcodeCommand command = createCommand(gcode);
this.sendCommandImmediately(command);
return;
}
}
// Throw exception
super.viewParserState();
}
use of com.willwinder.universalgcodesender.types.GcodeCommand in project Universal-G-Code-Sender by winder.
the class GrblController method performHomingCycle.
/**
* Sends the version specific homing cycle to the machine.
*/
@Override
public void performHomingCycle() throws Exception {
if (this.isCommOpen()) {
String gcode = GrblUtils.getHomingCommand(this.grblVersion, this.grblVersionLetter);
if (!"".equals(gcode)) {
GcodeCommand command = createCommand(gcode);
this.sendCommandImmediately(command);
return;
}
}
// Throw exception
super.performHomingCycle();
}
use of com.willwinder.universalgcodesender.types.GcodeCommand in project Universal-G-Code-Sender by winder.
the class GrblController method resetCoordinatesToZero.
@Override
public void resetCoordinatesToZero() throws Exception {
if (this.isCommOpen()) {
String gcode = GrblUtils.getResetCoordsToZeroCommand(this.grblVersion, this.grblVersionLetter);
if (!"".equals(gcode)) {
GcodeCommand command = createCommand(gcode);
this.sendCommandImmediately(command);
return;
}
}
// Throw exception
super.resetCoordinatesToZero();
}
use of com.willwinder.universalgcodesender.types.GcodeCommand in project Universal-G-Code-Sender by winder.
the class GrblController method returnToHome.
@Override
public void returnToHome() throws Exception {
if (this.isCommOpen()) {
ArrayList<String> commands = GrblUtils.getReturnToHomeCommands(this.grblVersion, this.grblVersionLetter, this.controllerStatus.getWorkCoord().z);
if (!commands.isEmpty()) {
Iterator<String> iter = commands.iterator();
// Perform the homing commands
while (iter.hasNext()) {
String gcode = iter.next();
GcodeCommand command = createCommand(gcode);
this.sendCommandImmediately(command);
}
return;
}
restoreParserModalState();
}
// Throw exception
super.returnToHome();
}
Aggregations