use of com.willwinder.universalgcodesender.model.events.CommandEvent in project Universal-G-Code-Sender by winder.
the class ProgressBarPrinter method UGSEvent.
@Override
public void UGSEvent(UGSEvent event) {
if (event instanceof FileStateEvent) {
FileStateEvent fileStateEvent = (FileStateEvent) event;
if (fileStateEvent.getFileState() == FileState.FILE_LOADED) {
pb = new ProgressBarBuilder().setStyle(ProgressBarStyle.UNICODE_BLOCK).setInitialMax(100).setTaskName(backend.getGcodeFile().getName()).setPrintStream(System.out).build();
} else if (fileStateEvent.getFileState() == FileState.FILE_STREAM_COMPLETE) {
if (pb != null) {
pb.maxHint(backend.getNumRows());
pb.stepTo(backend.getNumCompletedRows());
pb.close();
pb = null;
}
}
} else if (event instanceof ControllerStateEvent && pb != null) {
ControllerStateEvent controllerStateEvent = (ControllerStateEvent) event;
if (controllerStateEvent.getState() == ControllerState.HOLD) {
pb.setExtraMessage("[PAUSED] 'ENTER' to resume");
} else {
pb.setExtraMessage("[" + controllerStateEvent.getState() + "]");
}
} else if (event instanceof CommandEvent) {
if (pb != null) {
pb.maxHint(backend.getNumRows());
pb.stepTo(backend.getNumCompletedRows());
}
}
}
use of com.willwinder.universalgcodesender.model.events.CommandEvent in project Universal-G-Code-Sender by winder.
the class SendStatusPanel method UGSEvent.
@Override
public void UGSEvent(com.willwinder.universalgcodesender.model.UGSEvent evt) {
// Look for a send beginning.
if (evt instanceof ControllerStateEvent && ((ControllerStateEvent) evt).getState() == ControllerState.RUN) {
if (backend.isSendingFile()) {
beginSend();
}
} else // On file loaded event, reset the rows.
if (evt instanceof FileStateEvent) {
FileStateEvent fileStateEvent = (FileStateEvent) evt;
if (fileStateEvent.getFileState() == FILE_LOADED) {
resetSentRowLabels();
} else if (fileStateEvent.getFileState() == FILE_STREAM_COMPLETE) {
update();
endSend();
}
} else if (evt instanceof CommandEvent) {
CommandEvent commandEvent = ((CommandEvent) evt);
GcodeCommand command = commandEvent.getCommand();
if ((commandEvent.getCommandEventType() == CommandEventType.COMMAND_SENT || commandEvent.getCommandEventType() == CommandEventType.COMMAND_SKIPPED) && command.hasComment()) {
latestCommentValueLabel.setText(command.getComment());
}
}
}
use of com.willwinder.universalgcodesender.model.events.CommandEvent in project Universal-G-Code-Sender by winder.
the class ContinuousJogWorker method UGSEvent.
@Override
public void UGSEvent(UGSEvent event) {
if (event instanceof CommandEvent && ((CommandEvent) event).getCommandEventType() == CommandEventType.COMMAND_COMPLETE) {
GcodeCommand command = ((CommandEvent) event).getCommand();
isWaitingForCommandComplete = false;
if (command.isError()) {
stop();
if (future != null) {
future.cancel(false);
}
}
}
}
use of com.willwinder.universalgcodesender.model.events.CommandEvent in project Universal-G-Code-Sender by winder.
the class ProcessedLinePrinter method UGSEvent.
@Override
public void UGSEvent(UGSEvent event) {
if (event instanceof CommandEvent) {
CommandEvent commandEvent = ((CommandEvent) event);
GcodeCommand command = commandEvent.getCommand();
if (commandEvent.getCommandEventType() == CommandEventType.COMMAND_COMPLETE) {
onCommandComplete(command);
} else if (commandEvent.getCommandEventType() == CommandEventType.COMMAND_SENT) {
onCommandSent(command);
} else if (commandEvent.getCommandEventType() == CommandEventType.COMMAND_SKIPPED) {
onCommandSkipped(command);
}
} else if (event instanceof AlarmEvent) {
System.err.println("Alarm: " + ((AlarmEvent) event).getAlarm().name());
}
}
Aggregations