Added support for .ses and .scr file exports with command line
This commit is contained in:
parent
7aa430893d
commit
8eabae5723
|
@ -29,6 +29,8 @@ import eu.mihosoft.freerouting.logger.FRLogger;
|
||||||
|
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
import javax.swing.UnsupportedLookAndFeelException;
|
import javax.swing.UnsupportedLookAndFeelException;
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -112,32 +114,44 @@ public class MainApplication extends javax.swing.JFrame
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void autorouterAborted() {
|
public void autorouterAborted() {
|
||||||
if ((startupOptions.design_output_filename != null) && (startupOptions.design_output_filename.toLowerCase().endsWith(".dsn"))) {
|
ExportBoardToFile(startupOptions.design_output_filename);
|
||||||
ExportBoardToDSNFile();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void autorouterFinished() {
|
public void autorouterFinished() {
|
||||||
if ((startupOptions.design_output_filename != null) && (startupOptions.design_output_filename.toLowerCase().endsWith(".dsn"))) {
|
ExportBoardToFile(startupOptions.design_output_filename);
|
||||||
ExportBoardToDSNFile();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ExportBoardToDSNFile()
|
private void ExportBoardToFile(String filename) {
|
||||||
{
|
if ((filename != null)
|
||||||
FRLogger.logger.info("Saving '"+startupOptions.design_output_filename+"'...");
|
&& ((filename.toLowerCase().endsWith(".dsn"))
|
||||||
try
|
|| (filename.toLowerCase().endsWith(".ses"))
|
||||||
{
|
|| (filename.toLowerCase().endsWith(".scr")))) {
|
||||||
String filename_only = new File(startupOptions.design_output_filename).getName();
|
|
||||||
String design_name = filename_only.substring(0, filename_only.length() - 4);
|
|
||||||
|
|
||||||
java.io.OutputStream output_stream = new java.io.FileOutputStream(startupOptions.design_output_filename);
|
FRLogger.logger.info("Saving '" + filename + "'...");
|
||||||
new_frame.board_panel.board_handling.export_to_dsn_file(output_stream, design_name, false);
|
try {
|
||||||
Runtime.getRuntime().exit(0);
|
String filename_only = new File(filename).getName();
|
||||||
} catch (Exception e)
|
String design_name = filename_only.substring(0, filename_only.length() - 4);
|
||||||
{
|
|
||||||
FRLogger.logger.error(e);
|
java.io.OutputStream output_stream = new java.io.FileOutputStream(filename);
|
||||||
|
|
||||||
|
if (filename.toLowerCase().endsWith(".dsn")) {
|
||||||
|
new_frame.board_panel.board_handling.export_to_dsn_file(output_stream, design_name, false);
|
||||||
|
} else if (filename.toLowerCase().endsWith(".ses")) {
|
||||||
|
new_frame.board_panel.board_handling.export_specctra_session_file(design_name, output_stream);
|
||||||
|
} else if (filename.toLowerCase().endsWith(".scr")) {
|
||||||
|
java.io.ByteArrayOutputStream session_output_stream = new ByteArrayOutputStream();
|
||||||
|
new_frame.board_panel.board_handling.export_specctra_session_file(filename, session_output_stream);
|
||||||
|
java.io.InputStream input_stream = new ByteArrayInputStream(session_output_stream.toByteArray());
|
||||||
|
new_frame.board_panel.board_handling.export_eagle_session_file(input_stream, output_stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
Runtime.getRuntime().exit(0);
|
||||||
|
} catch (Exception e) {
|
||||||
|
FRLogger.logger.error(e);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
FRLogger.logger.error("Couldn't export board to '" + filename + "'.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue