Skip to content

Commit

Permalink
Improve command-line interface
Browse files Browse the repository at this point in the history
- Show error explaining that --mapping is not yet implemented
- Rename --total-height to --thickness
- Improve error message and handling when no laser settings are available for this material-speed combination

Related: #704
  • Loading branch information
mgmax committed Mar 3, 2024
1 parent 734a6fc commit ce17a57
Showing 1 changed file with 41 additions and 7 deletions.
48 changes: 41 additions & 7 deletions src/main/java/de/thomas_oster/visicut/gui/VisicutApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
import de.thomas_oster.visicut.model.LaserProfile;
import de.thomas_oster.visicut.model.MaterialProfile;
import de.thomas_oster.visicut.model.PlfPart;
import de.thomas_oster.visicut.model.Raster3dProfile;
import de.thomas_oster.visicut.model.RasterProfile;
import de.thomas_oster.visicut.model.VectorProfile;
import de.thomas_oster.visicut.model.mapping.Mapping;
import java.awt.AWTEvent;
import java.awt.EventQueue;
Expand Down Expand Up @@ -288,14 +291,19 @@ else if ("--help".equals(s) || "-h".equals(s))
System.out.println(" --add (do not replace old file if VisiCut is already running)");
System.out.println(" --material <materialname e.g. \"Acrylic Glass 2mm\">");
System.out.println(" --laserdevice <laserdevice e.g. \"Epilog ZING @ Miltons Office\">");
System.out.println(" --mapping <mapping e.g. \"Cut\">");
System.out.println(" --total-height <Height in mm e.g. \"2.5\"> (only valid with --execute)");
System.out.println(" --mapping: <saved mapping e.g. \"Cut red\">");
System.out.println(" --thickness <Material thickness in mm e.g. \"2.5\"> (only valid with --execute)");
System.out.println(" --singleinstanceport <port> (Set port to check for running instances -- 0 to disable)");
System.out.println(" --basepath <path> \t Sets VisiCuts settings directory (default is $HOME/.visicut)");
System.out.println(" --gtkfilechooser (experimental)");
System.exit(0);
}
else if ("--total-height".equals(s))
else if ("--mapping".equals(s))
{
System.err.println("--mapping is not yet supported! https://github.com/t-oster/VisiCut/issues/704");
System.exit(1);
}
else if ("--thickness".equals(s))
{
height = Float.parseFloat(args[++i]);
}
Expand Down Expand Up @@ -427,7 +435,7 @@ public void newInstanceCreated(final String message)
{
if (!execute)
{
System.err.append("Total-height parameter takes only effect with --execute");
System.err.append("thickness parameter takes only effect with --execute");
}
model.setMaterialThickness(height);
}
Expand Down Expand Up @@ -486,8 +494,34 @@ public void newInstanceCreated(final String message)
List<LaserProperty> list = LaserPropertyManager.getInstance().getLaserProperties(model.getSelectedLaserDevice(), model.getMaterial(), ms.getProfile(), model.getMaterialThickness());
if (list == null)
{
System.err.println("Combination of Laserdevice, Material and Mapping is not supported");
System.exit(1);
// There are no saved laser settings for this device-material-thickness combination for this profile.
// Generate a dummy entry so that the driver doesn't crash.
// We only give a warning and not a fatal error because this warning
// can also be a "false positive":
// Example: If
// - your mapping contains engrave and cut
// - and the file only matches engrave
// - and you have no laserprofile (power/speed settings) for cut
// for this combination of material, device and thickness
// then you will get a warning about missing cut settings although
// this doesn't matter for your job.
System.err.println("Warning: Combination of Laserdevice (" + model.getSelectedLaserDevice() + "), Material (" + model.getMaterial() + "), thickness (" + model.getMaterialThickness() + ") and profile (" + ms.getProfile() + ") [from mapping] has no laser settings yet. If your file needs this, then please load the file in the VisiCut GUI and set and save the laser settings (speed, power, ...) for this combination.");
// TODO: deduplicate the following code with PropertiesPanel.getPropertyMap
list = new LinkedList<>();
if (p instanceof VectorProfile)
{
list.add(model.getSelectedLaserDevice().getLaserCutter().getLaserPropertyForVectorPart());
}
else if (p instanceof RasterProfile)
{
list.add(model.getSelectedLaserDevice().getLaserCutter().getLaserPropertyForRasterPart());
}
else if (p instanceof Raster3dProfile)
{
list.add(model.getSelectedLaserDevice().getLaserCutter().getLaserPropertyForRaster3dPart());
} else {
throw new RuntimeException("invalid profile type");
}
}
propmap.put(p, list);
}
Expand Down Expand Up @@ -515,7 +549,7 @@ public void taskChanged(Object source, String taskName)
catch (Exception ex)
{
Logger.getLogger(VisicutApp.class.getName()).log(Level.SEVERE, null, ex);
System.err.println("Job could not be executed: "+ex.getMessage());
System.err.println("Job could not be executed: "+ DialogHelper.getHumanReadableErrorMessage(ex));
System.exit(1);
}
System.out.println("Job was sucessfully sent.");
Expand Down

0 comments on commit ce17a57

Please sign in to comment.