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
+48 -71
View File
@@ -2,61 +2,76 @@ 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.io.*;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
@XmlRootElement(name = "Config")
public class SOMConfig {
// important Paths
@XmlElement(name = "PICTURES_PATH")
public static final File PICTURES_PATH = new File("images");
@XmlElement(name = "UPLOAD_PATH")
public static final String UPLOAD_PATH = getEventPicDir();
public static File PICTURES_PATH = new File("images");
public static String UPLOAD_PATH = getEventPicDir();
// The Box's ID
@XmlElement(name = "BOX_ID")
public static final String BOX_ID = MachineWorker.getHostName();
public static String BOX_ID = MachineWorker.getHostName();
// Number of pictures in series mode
@XmlElement(name = "SERIES_COUNTER")
public static final int SERIES_COUNTER = 4;
public static int SERIES_COUNTER;
// Seconds before image is taken
@XmlElement(name = "COUNTDOWN_COUNTER")
public static final int COUNTDOWN_COUNTER = 4;
public static int COUNTDOWN_COUNTER;
// Session has Printer support
public static boolean PRINTER;
// Images per Page in the Gallery
public static final int IMAGES_PER_PAGE = 9;
// Limot of Parallel Uploads
public static final int PARALLEL_UPLOADS = 10;
// Cloud Credentials
public static final String CLOUD_CREDENTIALS = "upload:geheim";
// Cloud
public static 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
public static final int SCALING_GRAPHICS_2D = 0;
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
private static final File configfile = new File(("config/config.xml"));
static final File configfile = new File(("config/config.xml"));
// Instance
// @XmlElement(name = "config")
private static SOMConfig config = null;
// Constructor
private SOMConfig() {
// TODO fix readConfig
// readConfig();
// 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
@@ -64,6 +79,8 @@ public class SOMConfig {
// Singleton Pattern
if (config == null) {
config = new SOMConfig();
SOMConfigFileHandler handler = new SOMConfigFileHandler();
handler.readConfig();
}
return config;
}
@@ -87,47 +104,7 @@ public class SOMConfig {
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
public long getCurrentTimestamp() {