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>
<groupId>de.selfomat</groupId>
<artifactId>selfomat-single-user</artifactId>
<version>0.4.1.1-SNAPSHOT</version>
<version>0.4.1.2-SNAPSHOT</version>
<scm>
<url>scm:git:http://192.168.100.78/git/selfomat-software.git</url>
+46 -40
View File
@@ -11,6 +11,7 @@ import javafx.scene.input.MouseEvent;
import javafx.scene.input.TouchEvent;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.StackPane;
import model.SOMConfig;
import model.SOMEvent;
import model.SOMImage;
import model.SOMLayout;
@@ -249,55 +250,60 @@ public class PictureCtl {
}
private void setPrintBtn() {
// get the button height & width
int height = (SOMLayout.screenHeight / 4);
// set the Button height & width
printBtn.setPrefSize(height, height);
if (SOMConfig.PRINTER == true) {
// get the button height & width
int height = (SOMLayout.screenHeight / 4);
// Make it a circle
printBtn.setBackground(SOMLayout.getTransparentBG10rounded(height / 2));
// set the Button height & width
printBtn.setPrefSize(height, height);
//Set Text Color
printBtn.setTextFill(SOMLayout.WHITE);
printBtn.setText(null);
// Make it a circle
printBtn.setBackground(SOMLayout.getTransparentBG10rounded(height / 2));
// Set Image
ImageView imageView = new ImageView(SOMLayout.PRINT_IMAGE);
//Set Text Color
printBtn.setTextFill(SOMLayout.WHITE);
printBtn.setText(null);
printBtn.setGraphic(imageView);
// Set Image
ImageView imageView = new ImageView(SOMLayout.PRINT_IMAGE);
// Set Mouse Press Action
printBtn.setOnMousePressed(new EventHandler<MouseEvent>() {
public void handle(MouseEvent event) {
// Feedback
printBtn.setBackground(SOMLayout.getTransparentBG20rounded(SOMLayout.screenHeight / 4));
printBtn.setGraphic(imageView);
// Set Mouse Press Action
printBtn.setOnMousePressed(new EventHandler<MouseEvent>() {
public void handle(MouseEvent event) {
// Feedback
printBtn.setBackground(SOMLayout.getTransparentBG20rounded(SOMLayout.screenHeight / 4));
}
});
// Check if active
if (numberOfImages == 0) {
printBtn.setDisable(true);
} else {
printBtn.setDisable(false);
}
});
// Check if active
if (numberOfImages == 0) {
printBtn.setDisable(true);
} else {
printBtn.setDisable(false);
// Set Mouse Release Action
printBtn.setOnMouseReleased(new EventHandler<MouseEvent>() {
public void handle(MouseEvent event) {
// Feedback
printBtn.setBackground(SOMLayout.getTransparentBG10rounded(SOMLayout.screenHeight / 4));
// Action
action();
}
// Action Performed
private void action() {
FilesWorker.print();
}
});
}else {
printBtn.setVisible(false);
}
// Set Mouse Release Action
printBtn.setOnMouseReleased(new EventHandler<MouseEvent>() {
public void handle(MouseEvent event) {
// Feedback
printBtn.setBackground(SOMLayout.getTransparentBG10rounded(SOMLayout.screenHeight / 4));
// Action
action();
}
// Action Performed
private void action() {
FilesWorker.print();
}
});
}
private void setImage() {
+7 -6
View File
@@ -12,15 +12,16 @@ public class Start extends SOMGUI {
public static void main(String[] args) throws Exception {
// Log the start
System.out.println("Gestartet!");
// Start the UI
launch(args);
System.out.println("-------------------");
System.out.println("WELCOME TO SELFOMAT");
System.out.println("-------------------");
// Set up the backend
// get configuration
SOMConfig config = SOMConfig.getInstance();
config.readConfig();
SOMConfig.getInstance();
// Start the UI
launch(args);
// get event instance
SOMEvent event = SOMEvent.getInstance();
+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() {
@@ -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;
import com.sun.java.util.jar.pack.Package;
import model.SOMImage;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
+13 -7
View File
@@ -123,7 +123,7 @@ public class FilesWorker {
builder.redirectErrorStream(true);
// launch capture!
// launch print!
Process process = builder.start();
} catch (IOException e) {
@@ -229,14 +229,15 @@ public class FilesWorker {
List<File> limitpics = new ArrayList<File>();
for (File pic : pics
) {
// Counter for queues files
// Counter for all queued files over the whole upload process
queuedfiles++;
System.out.println("Queueing File " + pic.toString());
limitpics.add(pic);
if (limitpics.size() >= SOMConfig.PARALLEL_UPLOADS
// Upload even if limit is not reached
if ( // Check if the parallel Upload Limit is 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) {
System.out.println("Launch File upload");
@@ -244,9 +245,7 @@ public class FilesWorker {
System.out.println("Clear File Queue");
limitpics.clear();
} else if (queuedfiles == pics.size() && pics.size() != 0) {
// reboot
new ProcessBuilder("reboot").start();
} else {
}
}
@@ -259,6 +258,11 @@ public class FilesWorker {
// Archive the Backup
archiveBackup();
// reboot
new File("reboot").mkdirs();
// new ProcessBuilder("sudo reboot").start();
}
// Update the State fot previews and thumbs
@@ -366,6 +370,8 @@ public class FilesWorker {
System.out.println("process ended failing " + file);
Thread.sleep(1000);
return false;
}
}