SOM Software

Closed #312,#700,#704,#705,#706

ISSUE #707 - Time in Countdown is +1 investigate
This commit is contained in:
2017-09-06 11:06:16 +02:00
parent b969277877
commit ea054db0fe
7 changed files with 219 additions and 127 deletions
+1 -1
View File
@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>de.selfomat</groupId> <groupId>de.selfomat</groupId>
<artifactId>selfomat-single-user</artifactId> <artifactId>selfomat-single-user</artifactId>
<version>0.4.1.1-SNAPSHOT</version> <version>0.4.1.2-SNAPSHOT</version>
<scm> <scm>
<url>scm:git:http://192.168.100.78/git/selfomat-software.git</url> <url>scm:git:http://192.168.100.78/git/selfomat-software.git</url>
+6
View File
@@ -11,6 +11,7 @@ import javafx.scene.input.MouseEvent;
import javafx.scene.input.TouchEvent; import javafx.scene.input.TouchEvent;
import javafx.scene.layout.GridPane; import javafx.scene.layout.GridPane;
import javafx.scene.layout.StackPane; import javafx.scene.layout.StackPane;
import model.SOMConfig;
import model.SOMEvent; import model.SOMEvent;
import model.SOMImage; import model.SOMImage;
import model.SOMLayout; import model.SOMLayout;
@@ -249,6 +250,8 @@ public class PictureCtl {
} }
private void setPrintBtn() { private void setPrintBtn() {
if (SOMConfig.PRINTER == true) {
// get the button height & width // get the button height & width
int height = (SOMLayout.screenHeight / 4); int height = (SOMLayout.screenHeight / 4);
@@ -298,6 +301,9 @@ public class PictureCtl {
FilesWorker.print(); FilesWorker.print();
} }
}); });
}else {
printBtn.setVisible(false);
}
} }
private void setImage() { private void setImage() {
+7 -6
View File
@@ -12,15 +12,16 @@ public class Start extends SOMGUI {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
// Log the start // Log the start
System.out.println("Gestartet!"); System.out.println("-------------------");
System.out.println("WELCOME TO SELFOMAT");
// Start the UI System.out.println("-------------------");
launch(args);
// Set up the backend // Set up the backend
// get configuration // get configuration
SOMConfig config = SOMConfig.getInstance(); SOMConfig.getInstance();
config.readConfig();
// Start the UI
launch(args);
// get event instance // get event instance
SOMEvent event = SOMEvent.getInstance(); SOMEvent event = SOMEvent.getInstance();
+48 -71
View File
@@ -2,61 +2,76 @@ package model;
import workers.MachineWorker; import workers.MachineWorker;
import javax.xml.bind.JAXBContext; import java.io.*;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.File;
import java.nio.file.Files;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.Calendar;
@XmlRootElement(name = "Config")
public class SOMConfig { public class SOMConfig {
// important Paths // important Paths
@XmlElement(name = "PICTURES_PATH") public static File PICTURES_PATH = new File("images");
public static final File PICTURES_PATH = new File("images"); public static String UPLOAD_PATH = getEventPicDir();
@XmlElement(name = "UPLOAD_PATH")
public static final String UPLOAD_PATH = getEventPicDir();
// The Box's ID // The Box's ID
@XmlElement(name = "BOX_ID") public static String BOX_ID = MachineWorker.getHostName();
public static final String BOX_ID = MachineWorker.getHostName();
// Number of pictures in series mode // Number of pictures in series mode
@XmlElement(name = "SERIES_COUNTER") public static int SERIES_COUNTER;
public static final int SERIES_COUNTER = 4;
// Seconds before image is taken // Seconds before image is taken
@XmlElement(name = "COUNTDOWN_COUNTER") public static int COUNTDOWN_COUNTER;
public static final int COUNTDOWN_COUNTER = 4;
// Session has Printer support
public static boolean PRINTER;
// Images per Page in the Gallery // Images per Page in the Gallery
public static final int IMAGES_PER_PAGE = 9; public static final int IMAGES_PER_PAGE = 9;
// Limot of Parallel Uploads
public static final int PARALLEL_UPLOADS = 10; // Cloud
// Cloud Credentials public static String CLOUD_CREDENTIALS = "upload:geheim";
public static final String CLOUD_CREDENTIALS = "upload:geheim"; public static String CLOUD_ADDRESS = "https://cloud.selfomat.de/remote.php/webdav/";
// Limit of Parallel Uploads
public static int PARALLEL_UPLOADS;
// Make the Scaling Algorithm switchable // Make the Scaling Algorithm switchable
public static final int SCALING_GRAPHICS_2D = 0; public static final int SCALING_GRAPHICS_2D = 0;
public static final int SCALING_JAVAFX = 1; public static final int SCALING_JAVAFX = 1;
public static int SCALING_ALGORITHM = SCALING_GRAPHICS_2D;
public static final int SCALING_ALGORITHM = SCALING_GRAPHICS_2D;
public static final String CLOUD_ADDRESS = "https://cloud.selfomat.de/remote.php/webdav/";
// Path to configfile // Path to configfile
private static final File configfile = new File(("config/config.xml")); static final File configfile = new File(("config/config.xml"));
// Instance // Instance
// @XmlElement(name = "config")
private static SOMConfig config = null; private static SOMConfig config = null;
// Constructor // Constructor
private SOMConfig() { private SOMConfig() {
// TODO fix readConfig
// readConfig();
// get the default Displays' dimensions // get the default Displays' dimensions
System.out.println("Screen Dimensions: " + SOMLayout.screenWidth + "x" + SOMLayout.screenHeight);
System.out.println("Creating Configuration. Sreen Size: " + SOMLayout.screenWidth + "x" + SOMLayout.screenHeight);
// important Paths
PICTURES_PATH = new File("images");
UPLOAD_PATH = getEventPicDir();
// The Box's ID
BOX_ID = MachineWorker.getHostName();
// Number of pictures in series mode
SERIES_COUNTER = 4;
// Seconds before image is taken
COUNTDOWN_COUNTER = 4;
// Cloud
CLOUD_CREDENTIALS = "upload:geheim";
CLOUD_ADDRESS = "https://cloud.selfomat.de/remote.php/webdav/";
// Limit of Parallel Uploads
PARALLEL_UPLOADS = 3;
// Make the Scaling Algorithm switchable
SCALING_ALGORITHM = SCALING_GRAPHICS_2D;
} }
// Instance // Instance
@@ -64,6 +79,8 @@ public class SOMConfig {
// Singleton Pattern // Singleton Pattern
if (config == null) { if (config == null) {
config = new SOMConfig(); config = new SOMConfig();
SOMConfigFileHandler handler = new SOMConfigFileHandler();
handler.readConfig();
} }
return config; return config;
} }
@@ -87,47 +104,7 @@ public class SOMConfig {
return eventPicDir; return eventPicDir;
} }
// Write Config
private void writeConfig() {
try {
configfile.getParentFile().mkdirs();
JAXBContext jaxbContext = JAXBContext.newInstance(SOMConfig.class);
Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
// output pretty printed
jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
jaxbMarshaller.marshal(this, configfile);
jaxbMarshaller.marshal(this, System.out);
} catch (JAXBException e) {
e.printStackTrace();
}
}
// Read Config
public void readConfig() {
try {
if (Files.exists(configfile.toPath())) {
JAXBContext jaxbContext = JAXBContext
.newInstance(SOMConfig.class);
Unmarshaller jaxbUnmarshaller = jaxbContext
.createUnmarshaller();
config = (SOMConfig) jaxbUnmarshaller.unmarshal(configfile);
System.out.println();
} else {
this.writeConfig();
}
} catch (JAXBException e) {
e.printStackTrace();
}
}
// return the current Timestamp // return the current Timestamp
public long getCurrentTimestamp() { public long getCurrentTimestamp() {
@@ -0,0 +1,104 @@
package model;
import workers.MachineWorker;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.File;
import java.nio.file.Files;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
@XmlRootElement(name = "Config")
public class SOMConfigFileHandler {
@XmlElement
private int SERIES_COUNTER;
@XmlElement
private int COUNTDOWN_COUNTER;
@XmlElement
private boolean PRINTER;
// @XmlElement
// private String CLOUD_CREDENTIALS;
// @XmlElement
// private String CLOUD_ADDRESS;
@XmlElement
private int PARALLEL_UPLOADS;
@XmlElement
private int SCALING_ALGORITHM;
@XmlElement
private final File configfile;
// Constructor
SOMConfigFileHandler() {
// get the default Displays' dimensions
System.out.println("Configuration Handler.");
SERIES_COUNTER = SOMConfig.SERIES_COUNTER;
COUNTDOWN_COUNTER = SOMConfig.COUNTDOWN_COUNTER;
// CLOUD_CREDENTIALS = SOMConfig.CLOUD_CREDENTIALS;
// CLOUD_ADDRESS = SOMConfig.CLOUD_ADDRESS;
PARALLEL_UPLOADS = SOMConfig.PARALLEL_UPLOADS;
SCALING_ALGORITHM = SOMConfig.SCALING_ALGORITHM;
configfile = SOMConfig.configfile;
PRINTER = SOMConfig.PRINTER;
}
// Write Config
private void writeConfig() {
try {
// make all directories to specified path if tot existent before writing config
configfile.getParentFile().mkdirs();
// Create Marshaller
JAXBContext jaxbContext = JAXBContext.newInstance(SOMConfigFileHandler.class);
Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
// output pretty printed
jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
// Do the marshalling
jaxbMarshaller.marshal(this, configfile);
jaxbMarshaller.marshal(this, System.out);
} catch (JAXBException e) {
e.printStackTrace();
}
}
// Read Config
void readConfig() {
SOMConfigFileHandler retCFH = new SOMConfigFileHandler();
try {
if (Files.exists(configfile.toPath())) {
JAXBContext jc = JAXBContext.newInstance(SOMConfigFileHandler.class);
Unmarshaller unmarshaller = jc.createUnmarshaller();
System.out.println(configfile.toString());
retCFH = (SOMConfigFileHandler) unmarshaller.unmarshal(configfile);
} else {
writeConfig();
}
} catch (JAXBException e) {
e.printStackTrace();
}
SOMConfig.SERIES_COUNTER = retCFH.SERIES_COUNTER;
SOMConfig.COUNTDOWN_COUNTER = retCFH.COUNTDOWN_COUNTER;
// SOMConfig.CLOUD_CREDENTIALS = retCFH.CLOUD_CREDENTIALS;
// SOMConfig.CLOUD_ADDRESS = retCFH.CLOUD_ADDRESS;
SOMConfig.PARALLEL_UPLOADS = retCFH.PARALLEL_UPLOADS;
SOMConfig.SCALING_ALGORITHM = retCFH.SCALING_ALGORITHM;
SOMConfig.PRINTER = retCFH.PRINTER;
}
}
-2
View File
@@ -3,10 +3,8 @@
*/ */
package workers; package workers;
import com.sun.java.util.jar.pack.Package;
import model.SOMImage; import model.SOMImage;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
+13 -7
View File
@@ -123,7 +123,7 @@ public class FilesWorker {
builder.redirectErrorStream(true); builder.redirectErrorStream(true);
// launch capture! // launch print!
Process process = builder.start(); Process process = builder.start();
} catch (IOException e) { } catch (IOException e) {
@@ -229,14 +229,15 @@ public class FilesWorker {
List<File> limitpics = new ArrayList<File>(); List<File> limitpics = new ArrayList<File>();
for (File pic : pics for (File pic : pics
) { ) {
// Counter for queues files // Counter for all queued files over the whole upload process
queuedfiles++; queuedfiles++;
System.out.println("Queueing File " + pic.toString()); System.out.println("Queueing File " + pic.toString());
limitpics.add(pic); limitpics.add(pic);
if (limitpics.size() >= SOMConfig.PARALLEL_UPLOADS if ( // Check if the parallel Upload Limit is reached
// Upload even if limit is not reached limitpics.size() >= SOMConfig.PARALLEL_UPLOADS
// Upload even if limit is not reached if the pics are the last ones
|| (pics.size() - queuedfiles) < SOMConfig.PARALLEL_UPLOADS) { || (pics.size() - queuedfiles) < SOMConfig.PARALLEL_UPLOADS) {
System.out.println("Launch File upload"); System.out.println("Launch File upload");
@@ -244,9 +245,7 @@ public class FilesWorker {
System.out.println("Clear File Queue"); System.out.println("Clear File Queue");
limitpics.clear(); limitpics.clear();
} else if (queuedfiles == pics.size() && pics.size() != 0) { } else {
// reboot
new ProcessBuilder("reboot").start();
} }
} }
@@ -259,6 +258,11 @@ public class FilesWorker {
// Archive the Backup // Archive the Backup
archiveBackup(); archiveBackup();
// reboot
new File("reboot").mkdirs();
// new ProcessBuilder("sudo reboot").start();
} }
// Update the State fot previews and thumbs // Update the State fot previews and thumbs
@@ -366,6 +370,8 @@ public class FilesWorker {
System.out.println("process ended failing " + file); System.out.println("process ended failing " + file);
Thread.sleep(1000); Thread.sleep(1000);
return false; return false;
} }
} }