// 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-jaxb-api/src/main/java/fr/romainmoreau/epaper/jaxb/api/Command.java
// public interface Command {
// 	void execute(EPaperClient ePaperClient) throws IOException, EPaperException;
// }
// 
// Path: e-paper-jaxb-api/src/main/java/fr/romainmoreau/epaper/jaxb/api/Commands.java
// @XmlRootElement
// public class Commands {
// 	private List<Command> commands;
// 
// 	@XmlElements({ @XmlElement(name = "clear", type = Clear.class),
// 			@XmlElement(name = "setDrawingColors", type = SetDrawingColors.class),
// 			@XmlElement(name = "setDisplayDirection", type = SetDisplayDirection.class),
// 			@XmlElement(name = "setFontSize", type = SetFontSize.class),
// 			@XmlElement(name = "drawLine", type = DrawLine.class),
// 			@XmlElement(name = "drawRectangle", type = DrawRectangle.class),
// 			@XmlElement(name = "drawPoint", type = DrawPoint.class),
// 			@XmlElement(name = "drawTable", type = DrawTable.class),
// 			@XmlElement(name = "fillRectangle", type = FillRectangle.class),
// 			@XmlElement(name = "displayText", type = DisplayText.class),
// 			@XmlElement(name = "displayTextRectangle", type = DisplayTextRectangle.class),
// 			@XmlElement(name = "refreshAndUpdate", type = RefreshAndUpdate.class) })
// 	public List<Command> getCommands() {
// 		return commands;
// 	}
// 
// 	public void setCommands(List<Command> commands) {
// 		this.commands = commands;
// 	}
// }


import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import fr.romainmoreau.epaper.client.api.EPaperClient;
import fr.romainmoreau.epaper.jaxb.api.Command;
import fr.romainmoreau.epaper.jaxb.api.Commands;
	private volatile boolean stop;

	public EPaperWorker() {
		thread = new Thread(this::run, "e-paper");
		commandsQueue = new LinkedBlockingQueue<>();
	}

	@PostConstruct
	private void postConstruct() {
		thread.start();
	}

	@PreDestroy
	private void preDestroy() {
		commandsQueue.clear();
		stop = true;
		thread.interrupt();
	}

	public boolean offer(final Commands commands) {
		return commandsQueue.offer(commands);
	}

	private void run() {
		LOGGER.info("e-paper thread started");
		do {
			try {
				Commands commands = commandsQueue.take();
				if (commands != null && commands.getCommands() != null) {
					for (Command command : commands.getCommands()) {
// 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-jaxb-api/src/main/java/fr/romainmoreau/epaper/jaxb/api/Command.java
// public interface Command {
// 	void execute(EPaperClient ePaperClient) throws IOException, EPaperException;
// }
// 
// Path: e-paper-jaxb-api/src/main/java/fr/romainmoreau/epaper/jaxb/api/Commands.java
// @XmlRootElement
// public class Commands {
// 	private List<Command> commands;
// 
// 	@XmlElements({ @XmlElement(name = "clear", type = Clear.class),
// 			@XmlElement(name = "setDrawingColors", type = SetDrawingColors.class),
// 			@XmlElement(name = "setDisplayDirection", type = SetDisplayDirection.class),
// 			@XmlElement(name = "setFontSize", type = SetFontSize.class),
// 			@XmlElement(name = "drawLine", type = DrawLine.class),
// 			@XmlElement(name = "drawRectangle", type = DrawRectangle.class),
// 			@XmlElement(name = "drawPoint", type = DrawPoint.class),
// 			@XmlElement(name = "drawTable", type = DrawTable.class),
// 			@XmlElement(name = "fillRectangle", type = FillRectangle.class),
// 			@XmlElement(name = "displayText", type = DisplayText.class),
// 			@XmlElement(name = "displayTextRectangle", type = DisplayTextRectangle.class),
// 			@XmlElement(name = "refreshAndUpdate", type = RefreshAndUpdate.class) })
// 	public List<Command> getCommands() {
// 		return commands;
// 	}
// 
// 	public void setCommands(List<Command> commands) {
// 		this.commands = commands;
// 	}
// }


// Path: e-paper-web-common/src/main/java/fr/romainmoreau/epaper/web/common/EPaperWorker.java
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import fr.romainmoreau.epaper.client.api.EPaperClient;
import fr.romainmoreau.epaper.jaxb.api.Command;
import fr.romainmoreau.epaper.jaxb.api.Commands;

	private volatile boolean stop;

	public EPaperWorker() {
		thread = new Thread(this::run, "e-paper");
		commandsQueue = new LinkedBlockingQueue<>();
	}

	@PostConstruct
	private void postConstruct() {
		thread.start();
	}

	@PreDestroy
	private void preDestroy() {
		commandsQueue.clear();
		stop = true;
		thread.interrupt();
	}

	public boolean offer(final Commands commands) {
		return commandsQueue.offer(commands);
	}

	private void run() {
		LOGGER.info("e-paper thread started");
		do {
			try {
				Commands commands = commandsQueue.take();
				if (commands != null && commands.getCommands() != null) {
					for (Command command : commands.getCommands()) {
						try {