import javax.swing.JOptionPane;

/* TODO list :
 *  - import -> execute actions
 *  - textfields to tweak delays (+ button set to default)
 *  - clean Interface class
 */

public class Main {
	
	public static void main(String[] args) throws InterruptedException {
		String serialPort = null;
		try {
			serialPort = SerialPortChooserDialog.showSerialPortChooserDialog();
		} catch (NoSerialPortException e) {
			JOptionPane.showMessageDialog(null, "No serial port available !", "Error", JOptionPane.ERROR_MESSAGE);
			System.exit(-1);
		}
		if(serialPort == null) System.exit(-1);

		final SerialCom serialCom = new SerialCom(serialPort);
		// arduino need time before accepting serial data
		Thread.sleep(1000);
		
		ActionList actionList = new ActionList(serialCom);
		Interface i = new Interface(actionList, new Runnable() {
			@Override
			public void run() {
				serialCom.close();
			}
		});
		i.setVisible(true);
	}
}
