// Path: e-paper-client-api/src/main/java/fr/romainmoreau/epaper/client/api/EPaperClient.java
// public interface EPaperClient extends Closeable {
// 	static final int WIDTH = 800;
// 
// 	static final int HEIGHT = 600;
// 
// 	void drawImage(int x, int y, InputStream inputStream) throws IOException, EPaperException;
// 
// 	void refreshAndUpdate() throws IOException, EPaperException;
// 
// 	void clear() throws IOException, EPaperException;
// 
// 	void drawPoint(int x, int y) throws IOException, EPaperException;
// 
// 	void drawLine(int x0, int y0, int x1, int y1) throws IOException, EPaperException;
// 
// 	void drawRectangle(int x0, int y0, int x1, int y1) throws IOException, EPaperException;
// 
// 	void drawTable(int x0, int y0, int x1, int y1, Table table) throws IOException, EPaperException;
// 
// 	void fillRectangle(int x0, int y0, int x1, int y1) throws IOException, EPaperException;
// 
// 	void displayText(int x, int y, String text) throws IOException, EPaperException;
// 
// 	void displayText(int x0, int y0, int x1, int y1, FontSize fontSize, int lineSpacing,
// 			HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment, String text)
// 			throws IOException, EPaperException;
// 
// 	DrawingColors getDrawingColors() throws IOException, EPaperException;
// 
// 	void setDrawingColors(DrawingColors drawingColors) throws IOException, EPaperException;
// 
// 	FontSize getFontSize() throws IOException, EPaperException;
// 
// 	void setFontSize(FontSize fontSize) throws IOException, EPaperException;
// 
// 	void setDisplayDirection(DisplayDirection displayDirection) throws IOException, EPaperException;
// 
// 	DisplayDirection getDisplayDirection() throws IOException, EPaperException;
// }
// 
// Path: e-paper-client-jserialcomm/src/main/java/fr/romainmoreau/epaper/client/jserialcomm/JSerialCommEPaperClient.java
// public class JSerialCommEPaperClient extends AbstractUARTEPaperClient {
// 	private SerialPort serialPort;
// 
// 	private byte[] response;
// 
// 	public JSerialCommEPaperClient(String portName, long timeout, long receiveTimeout) throws IOException {
// 		super(timeout, receiveTimeout);
// 		serialPort = SerialPort.getCommPort(portName);
// 		serialPort.setBaudRate(115200);
// 		serialPort.setNumDataBits(8);
// 		serialPort.setNumStopBits(ONE_STOP_BIT);
// 		serialPort.setParity(NO_PARITY);
// 		if (!serialPort.openPort()) {
// 			throw new IOException("Port not opened");
// 		}
// 	}
// 
// 	@Override
// 	public synchronized void close() throws IOException {
// 		if (!serialPort.closePort()) {
// 			throw new IOException("Port not closed");
// 		}
// 	}
// 
// 	@Override
// 	protected byte[] getResponse() {
// 		return response;
// 	}
// 
// 	@Override
// 	protected void sendCommand(Command command) throws IOException {
// 		response = null;
// 		int bytesWritten = serialPort.writeBytes(command.getFrame(), command.getFrame().length);
// 		if (bytesWritten != command.getFrame().length) {
// 			throw new IOException("Error writing bytes");
// 		}
// 	}
// 
// 	@Override
// 	protected void waitForResponse(long timeout, long receiveTimeout) {
// 		try {
// 			LocalDateTime start = LocalDateTime.now();
// 			byte[] readBytes = readBytes();
// 			while (readBytes == null) {
// 				wait(receiveTimeout);
// 				if (start.until(LocalDateTime.now(), ChronoUnit.MILLIS) >= timeout) {
// 					return;
// 				}
// 				readBytes = readBytes();
// 			}
// 			List<Byte> responseByteList = new ArrayList<>();
// 			for (int i = 0; i < readBytes.length; i++) {
// 				responseByteList.add(readBytes[i]);
// 			}
// 			while (readBytes != null) {
// 				wait(receiveTimeout);
// 				if (start.until(LocalDateTime.now(), ChronoUnit.MILLIS) >= timeout) {
// 					return;
// 				}
// 				readBytes = readBytes();
// 				if (readBytes != null) {
// 					for (int i = 0; i < readBytes.length; i++) {
// 						responseByteList.add(readBytes[i]);
// 					}
// 				}
// 			}
// 			byte[] responseBytes = new byte[responseByteList.size()];
// 			for (int i = 0; i < responseBytes.length; i++) {
// 				responseBytes[i] = responseByteList.get(i);
// 			}
// 			response = responseBytes;
// 		} catch (InterruptedException e) {
// 			throw new IllegalStateException(e);
// 		}
// 	}
// 
// 	private byte[] readBytes() {
// 		int bytesAvailable = serialPort.bytesAvailable();
// 		if (bytesAvailable == 0) {
// 			return null;
// 		} else if (bytesAvailable > 0) {
// 			byte[] bytes = new byte[bytesAvailable];
// 			if (serialPort.readBytes(bytes, bytes.length) == bytes.length) {
// 				return bytes;
// 			} else {
// 				throw new RuntimeException("Error reading bytes");
// 			}
// 		} else {
// 			throw new RuntimeException("Port not opened");
// 		}
// 	}
// }


import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
import org.springframework.context.annotation.Bean;
import fr.romainmoreau.epaper.client.api.EPaperClient;
import fr.romainmoreau.epaper.client.jserialcomm.JSerialCommEPaperClient;
package fr.romainmoreau.epaper.web.jserialcomm;




@SpringBootApplication(scanBasePackages = "fr.romainmoreau.epaper.web")
@ConfigurationPropertiesScan
public class JSerialCommEPaperApplication {
	private static final Logger LOGGER = LoggerFactory.getLogger(JSerialCommEPaperApplication.class);

	@Autowired
	private JSerialCommEPaperProperties ePaperProperties;

	@Bean
// Path: e-paper-client-api/src/main/java/fr/romainmoreau/epaper/client/api/EPaperClient.java
// public interface EPaperClient extends Closeable {
// 	static final int WIDTH = 800;
// 
// 	static final int HEIGHT = 600;
// 
// 	void drawImage(int x, int y, InputStream inputStream) throws IOException, EPaperException;
// 
// 	void refreshAndUpdate() throws IOException, EPaperException;
// 
// 	void clear() throws IOException, EPaperException;
// 
// 	void drawPoint(int x, int y) throws IOException, EPaperException;
// 
// 	void drawLine(int x0, int y0, int x1, int y1) throws IOException, EPaperException;
// 
// 	void drawRectangle(int x0, int y0, int x1, int y1) throws IOException, EPaperException;
// 
// 	void drawTable(int x0, int y0, int x1, int y1, Table table) throws IOException, EPaperException;
// 
// 	void fillRectangle(int x0, int y0, int x1, int y1) throws IOException, EPaperException;
// 
// 	void displayText(int x, int y, String text) throws IOException, EPaperException;
// 
// 	void displayText(int x0, int y0, int x1, int y1, FontSize fontSize, int lineSpacing,
// 			HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment, String text)
// 			throws IOException, EPaperException;
// 
// 	DrawingColors getDrawingColors() throws IOException, EPaperException;
// 
// 	void setDrawingColors(DrawingColors drawingColors) throws IOException, EPaperException;
// 
// 	FontSize getFontSize() throws IOException, EPaperException;
// 
// 	void setFontSize(FontSize fontSize) throws IOException, EPaperException;
// 
// 	void setDisplayDirection(DisplayDirection displayDirection) throws IOException, EPaperException;
// 
// 	DisplayDirection getDisplayDirection() throws IOException, EPaperException;
// }
// 
// Path: e-paper-client-jserialcomm/src/main/java/fr/romainmoreau/epaper/client/jserialcomm/JSerialCommEPaperClient.java
// public class JSerialCommEPaperClient extends AbstractUARTEPaperClient {
// 	private SerialPort serialPort;
// 
// 	private byte[] response;
// 
// 	public JSerialCommEPaperClient(String portName, long timeout, long receiveTimeout) throws IOException {
// 		super(timeout, receiveTimeout);
// 		serialPort = SerialPort.getCommPort(portName);
// 		serialPort.setBaudRate(115200);
// 		serialPort.setNumDataBits(8);
// 		serialPort.setNumStopBits(ONE_STOP_BIT);
// 		serialPort.setParity(NO_PARITY);
// 		if (!serialPort.openPort()) {
// 			throw new IOException("Port not opened");
// 		}
// 	}
// 
// 	@Override
// 	public synchronized void close() throws IOException {
// 		if (!serialPort.closePort()) {
// 			throw new IOException("Port not closed");
// 		}
// 	}
// 
// 	@Override
// 	protected byte[] getResponse() {
// 		return response;
// 	}
// 
// 	@Override
// 	protected void sendCommand(Command command) throws IOException {
// 		response = null;
// 		int bytesWritten = serialPort.writeBytes(command.getFrame(), command.getFrame().length);
// 		if (bytesWritten != command.getFrame().length) {
// 			throw new IOException("Error writing bytes");
// 		}
// 	}
// 
// 	@Override
// 	protected void waitForResponse(long timeout, long receiveTimeout) {
// 		try {
// 			LocalDateTime start = LocalDateTime.now();
// 			byte[] readBytes = readBytes();
// 			while (readBytes == null) {
// 				wait(receiveTimeout);
// 				if (start.until(LocalDateTime.now(), ChronoUnit.MILLIS) >= timeout) {
// 					return;
// 				}
// 				readBytes = readBytes();
// 			}
// 			List<Byte> responseByteList = new ArrayList<>();
// 			for (int i = 0; i < readBytes.length; i++) {
// 				responseByteList.add(readBytes[i]);
// 			}
// 			while (readBytes != null) {
// 				wait(receiveTimeout);
// 				if (start.until(LocalDateTime.now(), ChronoUnit.MILLIS) >= timeout) {
// 					return;
// 				}
// 				readBytes = readBytes();
// 				if (readBytes != null) {
// 					for (int i = 0; i < readBytes.length; i++) {
// 						responseByteList.add(readBytes[i]);
// 					}
// 				}
// 			}
// 			byte[] responseBytes = new byte[responseByteList.size()];
// 			for (int i = 0; i < responseBytes.length; i++) {
// 				responseBytes[i] = responseByteList.get(i);
// 			}
// 			response = responseBytes;
// 		} catch (InterruptedException e) {
// 			throw new IllegalStateException(e);
// 		}
// 	}
// 
// 	private byte[] readBytes() {
// 		int bytesAvailable = serialPort.bytesAvailable();
// 		if (bytesAvailable == 0) {
// 			return null;
// 		} else if (bytesAvailable > 0) {
// 			byte[] bytes = new byte[bytesAvailable];
// 			if (serialPort.readBytes(bytes, bytes.length) == bytes.length) {
// 				return bytes;
// 			} else {
// 				throw new RuntimeException("Error reading bytes");
// 			}
// 		} else {
// 			throw new RuntimeException("Port not opened");
// 		}
// 	}
// }


// Path: e-paper-web-jserialcomm/src/main/java/fr/romainmoreau/epaper/web/jserialcomm/JSerialCommEPaperApplication.java
import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
import org.springframework.context.annotation.Bean;
import fr.romainmoreau.epaper.client.api.EPaperClient;
import fr.romainmoreau.epaper.client.jserialcomm.JSerialCommEPaperClient;

package fr.romainmoreau.epaper.web.jserialcomm;




@SpringBootApplication(scanBasePackages = "fr.romainmoreau.epaper.web")
@ConfigurationPropertiesScan
public class JSerialCommEPaperApplication {
	private static final Logger LOGGER = LoggerFactory.getLogger(JSerialCommEPaperApplication.class);

	@Autowired
	private JSerialCommEPaperProperties ePaperProperties;

	@Bean
	public EPaperClient ePaperClient() throws IOException {