use of com.willwinder.universalgcodesender.model.events.FileStateEvent 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.FileStateEvent 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.FileStateEvent in project Universal-G-Code-Sender by winder.
the class AutoLevelerTopComponent method UGSEvent.
@Override
public void UGSEvent(UGSEvent evt) {
if (evt instanceof ProbeEvent) {
if (!scanner.isCollectedAllProbe())
return;
Position probe = ((ProbeEvent) evt).getProbePosition();
Position offset = this.settings.getAutoLevelSettings().autoLevelProbeOffset;
if (probe.getUnits() == Units.UNKNOWN || offset.getUnits() == Units.UNKNOWN) {
System.out.println("Unknown units in autoleveler receiving probe.");
}
offset = offset.getPositionIn(probe.getUnits());
scanner.probeEvent(new Position(probe.x + offset.x, probe.y + offset.y, probe.z + offset.z, probe.getUnits()));
} else if (evt instanceof SettingChangedEvent) {
updateSettings();
} else if (evt instanceof FileStateEvent) {
applyToGcode.setEnabled(true);
}
}
Aggregations