Hallo liebe Community,
ich habe da ein Problem an dem nun schon einige Tage sitze. und es geht hier um eine Analyse App. Die funktioniert auch schon soweit wie sie es momentan soll.
jedoch habe ich das Problem das GUI sich beim zweiten Aufruf nicht mehr updated. Sprich nur die Steuerelemente. Aufgerufen wird die zweite Stage von der Primary stage:
hieröffnet sich dann ein Dialog in dem ich ein Datenfile auswählen kann. In diesem file sind einzelne xml strings hinterlegt:
Beim ersten Aufruf geht alles seinen normalen Gang:
Wenn ich das fenster jetzt schliesse und erneut aufrufe, reagieren die Steuerelemente nicht mehr sprich werden nicht upgedatet.
Ich kann aber nachvollziehen das der gesamte xml Parser durchlaufen wird, auch die Auswertung erfolgt. Schlussendlich werden auch die Daten in ein Excelsheet
geschrieben. Das funktioniert auch beim zweiten Aufruf. Nur die Steuerelemente aktualisieren sich nicht.
Hat da vielleicht jemand eine Idee?
Hier mal die Klasse die die zweite stage aufruft:
[CODE lang="java" title="Pere Form Klasse"]package performanceMonitoring;
import java.io.IOException;
import javafx.event.EventHandler;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import javafx.stage.WindowEvent;
public class PerformanceForm {
public AnchorPane root = new AnchorPane();
public void performanceForm () throws IOException {
root.setMaxWidth(600);
root.setMaxWidth(900);
Parent root = FXMLLoader.load(getClass().getResource("Performance.fxml"));
Scene scene = new Scene(root);
scene.getStylesheets().add(getClass().getResource("performance.css").toExternalForm());
Stage stage = new Stage(StageStyle.DECORATED);
stage.setTitle("");
stage.getIcons().add(new Image ("/img/ET.png"));
stage.setMaxHeight(1050);
stage.setMaxWidth(1920);
stage.setMaximized(true);
stage.setTitle("System Performance");
stage.centerOnScreen();
stage.setScene(scene);
stage.show();
stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
public void handle(WindowEvent we) {
stage.close();
}
});
}
}
[/CODE]
Hier ist mal die gesamte Controller Klasse:
[CODE lang="java" title="Controller Klasse"]package performanceMonitoring;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.sql.SQLException;
import java.text.DecimalFormat;
import java.util.ArrayList;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import application.ErrorHandling;
import application.Main;
import dbHandle.Systems;
import dbHandle.TABLE_Systems;
import javafx.application.Platform;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.concurrent.Task;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.chart.Axis;
import javafx.scene.chart.BarChart;
import javafx.scene.chart.CategoryAxis;
import javafx.scene.chart.LineChart;
import javafx.scene.chart.NumberAxis;
import javafx.scene.chart.StackedBarChart;
import javafx.scene.chart.XYChart;
import javafx.scene.control.Alert;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.ListView;
import javafx.scene.control.ProgressBar;
import javafx.scene.control.TabPane;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
public class PerformanceController {
@FXML Button btn_Home = new Button();
@FXML Button btn_Hardware = new Button();
@FXML Button btn_LFT = new Button();
@FXML Button btn_Volume = new Button();
@FXML Button btn_Scale = new Button();
@FXML Button btn_Gap = new Button();
@FXML Button btn_Barcode = new Button();
@FXML Button btn_VolumePerformance = new Button();
@FXML Button btn_VolumePosition= new Button();
@FXML Button btn_VolumeSize= new Button();
@FXML Label lbl_Site = new Label();
@FXML Label lbl_SystemID = new Label();
@FXML Label lbl_SystemName = new Label();
@FXML Label lbl_DatabaseName = new Label();
@FXML Label lbl_Progress = new Label();
@FXML Label lbl_VolumeCubic = new Label();
@FXML Label lbl_VolumeUnshaped = new Label();
@FXML Label lbl_VolumeNoShape = new Label();
@FXML Label lbl_VolumeOutsideFront = new Label();
@FXML Label lbl_VolumeOutsideBack = new Label();
@FXML Label lbl_VolumeOutsideLeft = new Label();
@FXML Label lbl_VolumeOutsideRight = new Label();
@FXML Label lbl_VolumeInside = new Label();
@FXML Label lbl_VolumeoutsideFrontBack = new Label();
@FXML Label lbl_VolumeoutsideLeftRight = new Label();
@FXML Label lbl_VolumeoutsideBottom = new Label();
@FXML Label lbl_VolumeoutsideNoObject = new Label();
@FXML ListView<String> lv_PerformanceWarnings = new ListView<String>();
@FXML ProgressBar pb_loadObjects = new ProgressBar();
@FXML AnchorPane ap_Objects = new AnchorPane();
@FXML TabPane tp_Performance = new TabPane();
@FXML TabPane tp_Volume = new TabPane();
@FXML Axis<String> speed_xAxis = new CategoryAxis();
@FXML Axis<Number> speed_yAxis = new NumberAxis();
@FXML LineChart<String, Number> lc_SpeedChart = new LineChart<String, Number>(speed_xAxis, speed_yAxis);
@FXML CategoryAxis barcodeCounter_xAxis = new CategoryAxis();
@FXML Axis<Number> barcodeCounter_yAxis = new NumberAxis();
@FXML BarChart<String, Number> bc_BarcodeCounter = new BarChart<String, Number>(barcodeCounter_xAxis, barcodeCounter_yAxis);
@FXML CategoryAxis objects1_xAxis = new CategoryAxis();
@FXML Axis<Number> objects1_yAxis = new NumberAxis();
@FXML StackedBarChart<String, Number> bc_Objects1 = new StackedBarChart<String, Number>(objects1_xAxis, objects1_yAxis);
@FXML CategoryAxis performance_xAxis = new CategoryAxis();
@FXML NumberAxis performance_yAxis = new NumberAxis();
@SuppressWarnings({ "unchecked", "rawtypes" })
@FXML StackedBarChart<String, Double> bc_Performance = new StackedBarChart(performance_xAxis, performance_yAxis);
public static String siteName = null;
public static String system_ID = null;
public static String system_Name = null;
public static String filename = null;
private static String sTimestamp = null;
private static Integer numberObjects = 0;
private static Integer validVolumeObjects = 0;
private static Integer validLFTObjects = 0;
private static Integer invalidLFTObjects = 0;
private static Integer lftRead= 0;
private static Integer validVMS = 0;
private static Integer invalidVMS = 0;
private static Integer validScale = 0;
private static Integer invalidScale = 0;
private static Integer cubicItem = 0;
private static Integer unshapedItem = 0;
private static Integer noshapeItem = 0;
private static Integer outsideFront = 0;
private static Integer outsideBack = 0;
private static Integer outsideleft = 0;
private static Integer outsideRight = 0;
private static Integer inside = 0;
private static Integer outsideFrontBack = 0;
private static Integer noItemDuringTrigger = 0;
private static Integer outsideLeftRight = 0;
private static Integer outsideBottom = 0;
private static Integer invalidScaleObject = 0;
private static Integer validScaleObject = 0;
private static Integer barcodeGoodRead = 0;
private static Integer barcodeCounter = 0;
private static Integer barcodeCounterValid = 0;
private static Integer barcodeInvalid = 0;
private static ObservableList<SortSpeed> sortSpeedList = FXCollections.observableArrayList();
private static DecimalFormat df = new DecimalFormat("0.00");
public static IntegerProperty evaluateLogfile = new SimpleIntegerProperty(0);
XYChart.Series<String, Number> speedObjects = new XYChart.Series<String, Number>();
XYChart.Series<String, Number> barcodeObjects = new XYChart.Series<String, Number>();
XYChart.Series<String, Number> allObjects = new XYChart.Series<String, Number>();
XYChart.Series<String, Number> invalidObjects = new XYChart.Series<String, Number>();
XYChart.Series<String, Double> performanceRead = new XYChart.Series<String, Double>();
XYChart.Series<String, Double> performanceNoread = new XYChart.Series<String, Double>();
//----------------------------------------------------------------------------------------------------------------
@SuppressWarnings({ "unchecked" })
@FXML
private void initialize() throws IOException{
fillheader();
pb_loadObjects.setStyle("-fx-accent: #ffffff;");
//speed chart
speedObjects.setName("Sort Speed");
speed_xAxis.setLabel("Objects");
speed_yAxis.setLabel("Sort Speed mm/s");
//speedObjects.getData().add(new XYChart.Data<String, Number>("0", 500));
//lc_SpeedChart.autosize();
lc_SpeedChart.setAnimated(false);
lc_SpeedChart.setTitle("Sort Speed Analyse");
lc_SpeedChart.getData().addAll(speedObjects);
// Performance Chart
performance_yAxis.setLabel("%");
performanceRead.setName("Valid reads");
performanceNoread.setName("Noread");
performanceRead.getData().add(new XYChart.Data<String, Double>("Barcode", 40.0));
performanceRead.getData().add(new XYChart.Data<String, Double>("LFT", 40.0));
performanceRead.getData().add(new XYChart.Data<String, Double>("LFT Valid", 40.0));
performanceRead.getData().add(new XYChart.Data<String, Double>("Volume", 40.0));
performanceRead.getData().add(new XYChart.Data<String, Double>("Volume Valid", 40.0));
performanceRead.getData().add(new XYChart.Data<String, Double>("Scale", 40.0));
performanceRead.getData().add(new XYChart.Data<String, Double>("Scale Valid", 40.0));
performanceNoread.getData().add(new XYChart.Data<String, Double>("Barcode", 20.0));
performanceNoread.getData().add(new XYChart.Data<String, Double>("LFT", 20.0));
performanceNoread.getData().add(new XYChart.Data<String, Double>("LFT Valid", 20.0));
performanceNoread.getData().add(new XYChart.Data<String, Double>("Volume", 20.0));
performanceNoread.getData().add(new XYChart.Data<String, Double>("Volume Valid", 20.0));
performanceNoread.getData().add(new XYChart.Data<String, Double>("Scale", 20.0));
performanceNoread.getData().add(new XYChart.Data<String, Double>("Scale Valid", 20.0));
bc_Performance.setAnimated(false);
bc_Performance.setTitle("System Performance");
bc_Performance .getData().addAll(performanceRead, performanceNoread);
// objects Chart
allObjects.setName("Valid Objects");
invalidObjects.setName("Out of Specification");
allObjects.getData().add(new XYChart.Data<String, Number>("Objects", 40));
allObjects.getData().add(new XYChart.Data<String, Number>("Valid", 20));
allObjects.getData().add(new XYChart.Data<String, Number>("LFT", 20));
allObjects.getData().add(new XYChart.Data<String, Number>("VMS", 20));
allObjects.getData().add(new XYChart.Data<String, Number>("Scale", 20));
invalidObjects.getData().add(new XYChart.Data<String, Number>("Objects", 0));
invalidObjects.getData().add(new XYChart.Data<String, Number>("Valid", 20));
invalidObjects.getData().add(new XYChart.Data<String, Number>("LFT", 20));
invalidObjects.getData().add(new XYChart.Data<String, Number>("VMS", 20));
invalidObjects.getData().add(new XYChart.Data<String, Number>("Scale", 20));
bc_Objects1.setAnimated(false);
bc_Objects1.setTitle("Object Evaluation");
bc_Objects1 .getData().addAll(allObjects, invalidObjects);
// Barcode Counter Chart
barcodeObjects.setName("Barcode Count");
barcodeObjects.getData().add(new XYChart.Data<String, Number>("Objects", 0));
barcodeObjects.getData().add(new XYChart.Data<String, Number>("Good Read", 0));
barcodeObjects.getData().add(new XYChart.Data<String, Number>("Code Counter (cc)", 0));
barcodeObjects.getData().add(new XYChart.Data<String, Number>("Valid Code Counter (vcc)", 0));
barcodeObjects.getData().add(new XYChart.Data<String, Number>("Invalid Codes", 0));
bc_BarcodeCounter.setAnimated(false);
bc_BarcodeCounter.setTitle("Barcode Counter");
bc_BarcodeCounter.getData().addAll(barcodeObjects);
evaluateLogfile.addListener( new ChangeListener<Number>() {
public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
if(evaluateLogfile.getValue() > 0) {
try {
xmlParser(filename, system_ID);
} catch (IOException | SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
evaluateLogfile.setValue(0);
}
} );
}
private void fillheader() {
lbl_Site.setText(siteName);
lbl_SystemID.setText(system_ID);
lbl_SystemName.setText(system_Name);
lbl_DatabaseName.setText(Main.DB_SITE_CONNECTION_STRING);
}
@SuppressWarnings("unchecked")
public void objectPerformance(Integer volume, Integer volumeNoread, Integer volumeNoreadValid, String systemID
) throws IOException, SQLException {
ObservableList<Systems> customSystems = FXCollections.observableArrayList();
customSystems.clear();
customSystems.addAll(TABLE_Systems.getSystembyID(systemID));
Platform.runLater(new Runnable() {
@Override
public void run() {
if(customSystems.get(0).getVol().toString().equals("true")){
double rate = 100.0/numberObjects * volume;
double noRate = 100.0/numberObjects * volumeNoread;
double volumeRate = 100.0/validVolumeObjects * volume;
double noVolumeRate = 100.0/validVolumeObjects * volumeNoreadValid;
performanceRead.getData().add(createVolumeValid("Volume", rate, volume));
performanceRead.getData().add(createVolumeValid("Volume Valid", volumeRate, volume));
performanceNoread.getData().add(createVolumeValid("Volume", noRate, volumeNoread));
performanceNoread.getData().add(createVolumeValid("Volume Valid", noVolumeRate, volumeNoreadValid));
}
bc_Performance.getData().clear();
bc_Performance.layout();
bc_Performance.getData().addAll(performanceRead, performanceNoread);
}
});
}
@SuppressWarnings({ "unchecked", "rawtypes" })
private XYChart.Data createVolumeValid(String objecttype, Double value, Integer objects) {
XYChart.Data data = new XYChart.Data(objecttype, value);
String text = df.format(value) + "%";
StackPane node = new StackPane();
Label label = new Label(text);
label.setFont(new Font("Arial", 12));
label.setTextFill(Color.web("#ffffff"));
Label label1 = new Label(objects.toString());
label1.setFont(new Font("Arial", 12));
label1.setTextFill(Color.web("#ffffff"));
VBox group = new VBox(label, label1);
group.setAlignment(Pos.CENTER);
StackPane.setAlignment(group, Pos.CENTER);
StackPane.setMargin(group, new Insets(20, 0, 5, 0));
node.getChildren().add(group);
data.setNode(node);
return data;
}
@SuppressWarnings("unchecked")
public void barcodeCounterChart(Integer objects, Integer gr, Integer cc, Integer vcc, Integer icc) throws IOException{
Platform.runLater(new Runnable() {
@Override
public void run() {
barcodeObjects.getData().add(createCodeCounter("Objects", objects));
barcodeObjects.getData().add(createCodeCounter("Good Read", gr));
barcodeObjects.getData().add(createCodeCounter("Code Counter (cc)", cc));
barcodeObjects.getData().add(createCodeCounter("Valid Code Counter (vcc)", vcc));
barcodeObjects.getData().add(createCodeCounter("Invalid Codes", icc));
bc_BarcodeCounter.getData().clear();
bc_BarcodeCounter.layout();
bc_BarcodeCounter.getData().addAll(barcodeObjects);
}
});
}
@SuppressWarnings({ "unchecked", "rawtypes" })
private XYChart.Data createCodeCounter(String objecttype, Integer value) {
XYChart.Data data = new XYChart.Data(objecttype, value);
double objects = 100.0/numberObjects * value;
String s = df.format(objects) + "%";
String text = value.toString();
StackPane node = new StackPane();
Label label = new Label(text);
label.setFont(new Font("Arial", 12));
label.setTextFill(Color.web("#ffffff"));
Label label1 = new Label(s);
label1.setFont(new Font("Arial", 12));
label1.setTextFill(Color.web("#ffffff"));
VBox group = new VBox(label, label1);
group.setAlignment(Pos.CENTER);
StackPane.setAlignment(group, Pos.BOTTOM_CENTER);
StackPane.setMargin(group, new Insets(20, 0, 5, 0));
node.getChildren().add(group);
data.setNode(node);
return data;
}
@SuppressWarnings("unchecked")
public void objectsChart(Integer objects, Integer valid, Integer invalid, Integer lft, Integer validLFT, Integer vms, Integer validVMS, Integer scale,
Integer validScale, String systemID) throws IOException, SQLException {
ObservableList<Systems> customSystems = FXCollections.observableArrayList();
customSystems.clear();
customSystems.addAll(TABLE_Systems.getSystembyID(systemID));
Platform.runLater(new Runnable() {
@Override
public void run() {
allObjects.getData().add(createData("Objects", objects));
allObjects.getData().add(createData("Valid", valid));
invalidObjects.getData().add((new XYChart.Data<String, Number>("Objects", 0)));
invalidObjects.getData().add(createData("Valid", invalid));
if(customSystems.get(0).getLFT().toString().equals("true")){
allObjects.getData().add(createData("LFT", lft));
invalidObjects.getData().add(createData("LFT", validLFT));
}
if(customSystems.get(0).getVol().toString().equals("true")){
allObjects.getData().add(createData("VMS", vms));
invalidObjects.getData().add(createData("VMS", validVMS));
}
if(customSystems.get(0).getWeight().toString().equals("true")){
allObjects.getData().add(createData("Scale", scale));
invalidObjects.getData().add(createData("Scale", validScale));
}
bc_Objects1.getData().clear();
bc_Objects1.layout();
bc_Objects1.getData().addAll(allObjects, invalidObjects);
}
});
}
@SuppressWarnings({ "unchecked", "rawtypes" })
private XYChart.Data createData(String objecttype, Integer value) {
XYChart.Data data = new XYChart.Data(objecttype, value);
double objects = 100.0/numberObjects * value;
String s = df.format(objects) + "%";
String text = value.toString();
StackPane node = new StackPane();
Label label = new Label(text);
label.setFont(new Font("Arial", 12));
label.setTextFill(Color.web("#ffffff"));
Label label1 = new Label(s);
label1.setFont(new Font("Arial", 12));
label1.setTextFill(Color.web("#ffffff"));
VBox group = new VBox(label, label1);
group.setAlignment(Pos.CENTER);
StackPane.setAlignment(group, Pos.BOTTOM_CENTER);
StackPane.setMargin(group, new Insets(20, 0, 5, 0));
node.getChildren().add(group);
data.setNode(node);
return data;
}
// Speed Chart
@SuppressWarnings("unchecked")
public void speedChart() throws IOException{
Integer lineCount = sortSpeedList.size();
Integer step = 1;
Integer value = 0;
if(lineCount > 100) {
step = 30;
}else if(lineCount > 1000) {
step = 30;
}else if(lineCount > 3000) {
step = 50;
}else if(lineCount > 5000) {
step = 100;
}
for (Integer b = 0; b < sortSpeedList.size(); b++) {
String s = sortSpeedList.get(b).getObject();
Integer i = sortSpeedList.get(b).getSpeed();
if(b.equals(value)){
value = value + step;
Platform.runLater(new Runnable() {
@Override
public void run() {
speedObjects.getData().add(new XYChart.Data<String, Number>(s, i));
lc_SpeedChart.getData().clear();
lc_SpeedChart.layout();
lc_SpeedChart.getData().addAll(speedObjects);
}
});
}
}
}
// Read Datafile ---------------------------------------------------------------------------------------------------------------------------------------------
@SuppressWarnings({ "unused", "unchecked" })
public void xmlParser(String filename, String systemID) throws IOException, SQLException {
System.out.println("called");
allObjects.getData().clear();
invalidObjects.getData().clear();
lv_PerformanceWarnings.getItems().clear();
ObservableList<Systems> customSystems = FXCollections.observableArrayList();
customSystems.clear();
customSystems.addAll(TABLE_Systems.getSystembyID(systemID));
String templateName = customSystems.get(0).getTemplate();
String sFileoutput = customSystems.get(0).getFileoutput();
String sSite = customSystems.get(0).getSite();
String sSystemID = customSystems.get(0).getSystemID();
String sName = customSystems.get(0).getName();
String lftSystem = customSystems.get(0).getLFT();
String volumeSystem = customSystems.get(0).getVol();
String scaleSystem = customSystems.get(0).getWeight();
System.out.println("before task");
sortSpeedList.clear();
// Create a background Task
Task<Void> task = new Task<Void>() {
@Override
protected Void call() throws Exception {
System.out.println("in task");
Integer objectCount = 0;
Integer invalidObjects = 0;
Integer volumeRead = 0;
Integer scaleRead = 0;
Integer lineCount = 0;
Integer lineCountSpeed = 0;
Integer sortSpeed = 0;
Integer sortSpeedOld = 0;
int fileLines = 0;
Boolean invalidObject = false;
Boolean warningVolumeReadingArea = false;
Boolean warningVolumeItemToSmall = false;
Boolean warningVolumeItemToBig= false;
Boolean warningInvalidCode= false;
Boolean lftGoodRead = false;
Boolean volumeGoodRead = false;
Boolean scaleGoodRead = false;
double linesread = 0.00;
try {
@SuppressWarnings("resource")
BufferedReader in = new BufferedReader(new FileReader(filename));
while ( in.readLine() != null ) {
fileLines++;
}
}
catch (Exception ex) {
ex.printStackTrace();
}
try (BufferedReader br = Files.newBufferedReader(Paths.get(filename))) {
// read line by line
String line;
while ((line = br.readLine()) != null) {
InputStream stream = new ByteArrayInputStream(line.getBytes());
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(stream);
doc.getDocumentElement().normalize();
String telegramType = doc.getDocumentElement().getNodeName();
if (telegramType.equals("objectdata")) { // Start of objectdata
NodeList nList = doc.getElementsByTagName("objectdata");
for (int i = 0; i < nList.getLength(); i++) {
Node nNode = nList.item(i);
if (nNode.getNodeType() == Node.ELEMENT_NODE) {
Element eElement = (Element) nNode;
sTimestamp = eElement.getElementsByTagName("timestamp").item(0).getTextContent();
}
}
// General Object data ------------------------------------------------------------------------------------------------
nList = doc.getElementsByTagName("general");
for (int i1 = 0; i1 < nList.getLength(); i1++) {
Node nNode = nList.item(i1);
//System.out.println("\nCurrent Element :" + nNode.getNodeName());
if (nNode.getNodeType() == Node.ELEMENT_NODE) {
Element eElement = (Element) nNode;
}
}
// Volume data ----------------------------------------------------------------------------------------------------------
nList = doc.getElementsByTagName("volumetric");
for (int i1 = 0; i1 < nList.getLength(); i1++) {
Node nNode = nList.item(i1);
//System.out.println("\nCurrent Element :" + nNode.getNodeName());
if (nNode.getNodeType() == Node.ELEMENT_NODE) {
Element eElement = (Element) nNode;
String OMS1 = eElement.getAttribute("oms1");
String OMS2 = eElement.getAttribute("oms2");
String OMS3 = eElement.getAttribute("oms3");
String volumeUnit = eElement.getElementsByTagName("size").item(0).getAttributes().getNamedItem("unit").toString();
String OLE = eElement.getElementsByTagName("size").item(0).getAttributes().getNamedItem("ole").getNodeValue();
String OWI = eElement.getElementsByTagName("size").item(0).getAttributes().getNamedItem("owi").getNodeValue();
String OHE = eElement.getElementsByTagName("size").item(0).getAttributes().getNamedItem("ohe").getNodeValue();
if((Integer.parseInt(OLE) > 1) && (Integer.parseInt(OWI) > 1) && (Integer.parseInt(OHE) >1) && (OMS1.equals("0000"))) {
volumeRead++;
volumeGoodRead = true;
}else {
volumeGoodRead = false;
}
//Item inside/outside reading area
String sArea = Character.toString(OMS2.charAt(3));
Integer iArea = Integer.parseInt(sArea);
switch (iArea) {
case 1: {
outsideFront++;
break;
}
case 2: {
outsideBack++;
break;
}
case 3: {
outsideFrontBack++;
break;
}
case 8: {
noItemDuringTrigger++;
break;
}
default: {
break;
}
}
String sArea1 = Character.toString(OMS2.charAt(6));
Integer iArea1 = Integer.parseInt(sArea1);
switch (iArea1) {
case 1: {
outsideRight++;
break;
}
case 4: {
outsideleft++;
break;
}
case 5: {
outsideLeftRight++;
break;
}
case 8: {
outsideBottom++;
break;
}
default: {
break;
}
}
if (iArea == 0 && iArea1 == 0) {
inside++;
}
if (iArea > 0 || iArea1 > 0) {
warningVolumeReadingArea = true;
}
// cubic or unshaped
String sCubic = Character.toString(OMS3.charAt(7));
if(sCubic.equals("1")) {
cubicItem++;
} else if(sCubic.equals("2")) {
unshapedItem++;
} else if (sCubic.equals("0")){
noshapeItem++;
}
String s = Character.toString(OMS1.charAt(1));
String s1 = Character.toString(OMS1.charAt(2)) + Character.toString(OMS1.charAt(3));
if(s.equals("1")) {
warningVolumeItemToBig = true;
}
if(s.equals("2")) {
warningVolumeItemToSmall = true;
}
if((s.equals("1")) || (s.equals("2")) || (s1.equals("11"))) {
invalidVMS++;
invalidObject = true;
}
}
}
// Weight data ----------------------------------------------------------------------------------------------------------
nList = doc.getElementsByTagName("scaledata");
for (int i1 = 0; i1 < nList.getLength(); i1++) {
Node nNode = nList.item(i1);
if (nNode.getNodeType() == Node.ELEMENT_NODE) {
Element eElement = (Element) nNode;
String OWS = eElement.getAttribute("ows");
String OWE_UNIT = eElement.getElementsByTagName("owe").item(0).getAttributes().getNamedItem("unit").getNodeValue();
String OWE = eElement.getElementsByTagName("value").item(0).getTextContent();
if(OWS.equals("0")) {
validScale++;
scaleGoodRead = true;
}else {
invalidScale++;
scaleGoodRead = false;
}
Integer i = Integer.parseInt(OWS);
if(PerformanceUtils.OWS(i) == true) {
invalidScaleObject++;
if (invalidObject == false){
invalidObject = true;
}
}
}
}
// Barcode Data
nList = doc.getElementsByTagName("barcode");
Integer cc = 0;
Integer vcc = 0;
String codeCounter = "0";
String validCodeCounter = "0";
String codeCondition = null;
for (int i1 = 0; i1 < nList.getLength(); i1++) {
Node nNode = nList.item(i1);
if (nNode.getNodeType() == Node.ELEMENT_NODE) {
Element eElement = (Element) nNode;
codeCounter = eElement.getAttribute("cc");
validCodeCounter = eElement.getAttribute("vcc");
//codeCondition = eElement.getElementsByTagName("condition").item(0).getTextContent();
if(validCodeCounter != null && validCodeCounter.length() != 0) {
vcc = Integer.parseInt(validCodeCounter);
barcodeGoodRead++;
barcodeCounterValid = barcodeCounterValid + vcc;
}
if(codeCounter != null && codeCounter.length() != 0) {
cc = Integer.parseInt(codeCounter);
barcodeCounter = barcodeCounter + cc;
}
}
}
nList = doc.getElementsByTagName("codeinvalid");
for (int i1 = 0; i1 < nList.getLength(); i1++) {
Node nNode = nList.item(i1);
if (nNode.getNodeType() == Node.ELEMENT_NODE) {
Element eElement = (Element) nNode;
String invalidID = eElement.getAttribute("id");
if(invalidID != null && invalidID.length() != 0) {
warningInvalidCode = true;
barcodeInvalid++;
}
}
}
// Sorterstate and Speed
nList = doc.getElementsByTagName("speed");
for (int i1 = 0; i1 < nList.getLength(); i1++) {
Node nNode = nList.item(i1);
if (nNode.getNodeType() == Node.ELEMENT_NODE) {
Element eElement = (Element) nNode;
String speedUnit = eElement.getAttribute("unit");
String conveyorSpeed = eElement.getElementsByTagName("value").item(0).getTextContent();
if(conveyorSpeed != null && conveyorSpeed.length() != 0) {
sortSpeed = Integer.parseInt(conveyorSpeed);
}
if(lineCount.equals(lineCountSpeed) || !sortSpeed.equals(sortSpeedOld)) {
sortSpeedOld = sortSpeed;
if(lineCount.equals(lineCountSpeed)){
lineCountSpeed = lineCountSpeed + 100;
}
sortSpeedList.add(new SortSpeed(lineCount.toString(), sortSpeed));
}
}
}
//LFT Good Read
if(volumeSystem.equals("true") && scaleSystem.equals("true")) {
if(volumeGoodRead == true && scaleGoodRead == true) {
lftGoodRead = true;
}
}
if(volumeSystem.equals("true") && scaleSystem.equals("false")) {
if(volumeGoodRead == true) {
lftGoodRead = true;
}
}
if(volumeSystem.equals("false") && scaleSystem.equals("false")) {
if(scaleGoodRead == true) {
lftGoodRead = true;
}
}
if(lftGoodRead == true) {
lftRead++;
}
lftGoodRead = false;
volumeGoodRead = false;
scaleGoodRead = false;
// Object counter
objectCount++;
// Valid VMS Objects
validVMS = objectCount - invalidVMS;
// Valid Scale Objects
validScaleObject = objectCount - invalidScaleObject;
// Valid LFT objects
if (invalidObject == true) {
invalidLFTObjects++;
}
validLFTObjects = objectCount - invalidLFTObjects;
// invalid object counter
if(invalidObject == true) {
invalidObjects++;
}
invalidObject = false;
//get Timestamp
Integer position = sTimestamp.indexOf("T");
String date = sTimestamp.substring(0, position);
// Increase line counter
lineCount++;
//updating progressbar
updateProgress(objectCount, fileLines);
} // end of objectdata
} // End of while loop --End of datafile -------------------------------------------------------------------------------------------
} catch (IOException | ParserConfigurationException | SAXException e) {
ErrorHandling error= new ErrorHandling();
try {
error.AlertBox("Exception Raised in xmlParser", "Exception", e.getMessage());
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
System.out.println("Data evaluation finished");
// get valid objects
Integer validObjects = objectCount - invalidObjects;
numberObjects = objectCount;
// Speed Chart
speedChart();
// Barcode Counter Chart
barcodeCounterChart(objectCount, barcodeGoodRead, barcodeCounter, barcodeCounterValid, barcodeInvalid);
// Object Chart
objectsChart(objectCount, validObjects, invalidObjects, validLFTObjects, invalidLFTObjects, validVMS, invalidVMS, validScaleObject, invalidScaleObject, systemID);
// Performance Chart
Integer volumeNoread = objectCount - volumeRead;
validVolumeObjects = objectCount - invalidVMS;
Integer volumeNoreadValid = volumeNoread - invalidVMS;
objectPerformance(volumeRead, volumeNoread, volumeNoreadValid, systemID);
// Volume Pages
Platform.runLater(new Runnable() {
public void run() {
lbl_VolumeCubic.setText(cubicItem.toString());
lbl_VolumeUnshaped.setText(unshapedItem.toString());
lbl_VolumeNoShape.setText(noshapeItem.toString());
lbl_VolumeOutsideFront.setText(outsideFront.toString());
lbl_VolumeOutsideBack.setText(outsideBack.toString());
lbl_VolumeOutsideLeft.setText(outsideleft.toString());
lbl_VolumeOutsideRight.setText(outsideRight.toString());
lbl_VolumeInside.setText(inside.toString());
lbl_VolumeoutsideFrontBack.setText(outsideFrontBack.toString());
lbl_VolumeoutsideLeftRight.setText(outsideLeftRight.toString());
lbl_VolumeoutsideBottom.setText(outsideBottom.toString());
lbl_VolumeoutsideNoObject.setText(noItemDuringTrigger.toString());
System.out.println("volume finished");
lbl_VolumeCubic.setText("hello");
}
});
// calculate read performance
// Barcode
double barcodeRate = 100.0/numberObjects * barcodeGoodRead;
double barcodeNoreadRate = 100.0 - barcodeRate;
//LFT Performance
double lftRate = 100.0/numberObjects * lftRead;
double noLFTRate = 100.0 - lftRate;
double lftValidRate = 100.0/validLFTObjects * lftRead;
double nolftValidRate = 100.0 - lftValidRate;
//Volume
double volumeRate = 100.0/numberObjects * volumeRead;
double noVolumeRate = 100.0/numberObjects * volumeNoread;
double volumeValidRate = 100.0/validVolumeObjects * volumeRead;
double noVolumeValidRate = 100.0 - volumeValidRate;
//Weight
double weightRate = 100.0/numberObjects * validScale;
double noWeightRate = 100.0/numberObjects * invalidScale;
double weightValidRate = 100.0/validScaleObject * validScale;
double noWeightValidRate = 100.0 - weightValidRate;
// add warnings
if (warningVolumeReadingArea == true) {
lv_PerformanceWarnings.getItems().add("Volume Performance: Items outside measuring area!");
}
if (warningVolumeItemToBig == true) {
lv_PerformanceWarnings.getItems().add("Volume Performance: Items outside Specification! Item to big");
}
if (warningVolumeItemToSmall == true) {
lv_PerformanceWarnings.getItems().add("Volume Performance: Items outside Specification! Item to small");
}
if (warningInvalidCode == true) {
lv_PerformanceWarnings.getItems().add("Barcode Performance: Invalid Barcodes found!");
}
// Add data to a list for the excel sheet
ArrayList<String> dataList = new ArrayList<>();
// Objectdata
dataList.add(objectCount.toString()); // Value 0
dataList.add(validObjects.toString()); // Value 1
dataList.add(invalidObjects.toString()); // Value 2
dataList.add(validLFTObjects.toString()); // Value 3
dataList.add(invalidLFTObjects.toString()); // Value 4
dataList.add(validVMS.toString()); // Value 5
dataList.add(invalidVMS.toString()); // Value 6
dataList.add(validScaleObject.toString()); // Value 7
dataList.add(invalidScaleObject.toString()); // Value 8
dataList.add(cubicItem.toString()); // Value 9
dataList.add(unshapedItem.toString()); // Value 10
dataList.add(noshapeItem.toString()); // Value 11
dataList.add(outsideFront.toString()); // Value 12
dataList.add(outsideBack.toString()); // Value 13
dataList.add(outsideFrontBack.toString()); // Value 14
dataList.add(noItemDuringTrigger.toString()); // Value 15
dataList.add(outsideRight.toString()); // Value 16
dataList.add(outsideleft.toString()); // Value 17
dataList.add(outsideLeftRight.toString()); // Value 18
dataList.add(outsideBottom.toString()); // Value 19
dataList.add(inside.toString()); // Value 20
dataList.add( String.format( "%.2f", barcodeRate )); // Value 21
dataList.add( String.format( "%.2f", barcodeNoreadRate )); // Value 22
dataList.add(String.format( "%.2f", lftRate)); // Value 23
dataList.add(String.format( "%.2f", noLFTRate)); // Value 24
dataList.add(String.format( "%.2f", lftValidRate)); // Value 25
dataList.add(String.format( "%.2f", nolftValidRate)); // Value 26
dataList.add(String.format( "%.2f", volumeRate )); // Value 27
dataList.add(String.format( "%.2f", noVolumeRate )); // Value 28
dataList.add(String.format( "%.2f", volumeValidRate )); // Value 39
dataList.add(String.format( "%.2f", noVolumeValidRate )); // Value 30
dataList.add(String.format( "%.2f", weightRate )); // Value 31
dataList.add(String.format( "%.2f", noWeightRate )); // Value 32
dataList.add(String.format( "%.2f", weightValidRate )); // Value 33
dataList.add(String.format( "%.2f", noWeightValidRate )); // Value 34
dataList.add(barcodeGoodRead.toString()); // Value 35
dataList.add(barcodeCounter.toString()); // Value 36
dataList.add(barcodeCounterValid.toString()); // Value 37
dataList.add(barcodeInvalid.toString()); // Value 38
if(templateName == null || templateName.equals("")) {
Platform.runLater(new Runnable() {
public void run() {
Alert alert = new Alert(Alert.AlertType.WARNING);
alert.setTitle("Template Error");
alert.setHeaderText("Template does not exists!");
alert.setContentText("No template found in database for this system!.");
alert.showAndWait();
}
});
}else {
SaveToExcel.datenSpeichern(dataList, templateName, sFileoutput, sSite, sSystemID, sName);
}
return null;
}
};
task.setOnFailed(wse -> {
wse.getSource().getException().printStackTrace();
});
lbl_Progress.setText("Import data from file:");
pb_loadObjects.progressProperty().bind(task.progressProperty());
new Thread(task).start();
}
@FXML
void btn_Home_Click(ActionEvent event) throws IOException {
tp_Performance.getSelectionModel().select(0);
}
@FXML
void btn_Hardware_click(ActionEvent event) throws IOException {
tp_Performance.getSelectionModel().select(1);
}
@FXML
void btn_LFT_Click(ActionEvent event) throws IOException {
tp_Performance.getSelectionModel().select(2);
}
@FXML
void btn_Volume_Click(ActionEvent event) throws IOException {
tp_Performance.getSelectionModel().select(3);
}
@FXML
void btn_Scale_Click(ActionEvent event) throws IOException {
tp_Performance.getSelectionModel().select(4);
}
@FXML
void btn_Gap_Click(ActionEvent event) throws IOException {
tp_Performance.getSelectionModel().select(5);
}
@FXML
void btn_Barcode_Click(ActionEvent event) throws IOException {
tp_Performance.getSelectionModel().select(6);
}
@FXML
void btn_VolumePerformance_Click(ActionEvent event) throws IOException {
tp_Volume.getSelectionModel().select(0);
}
@FXML
void btn_VolumePosition_Click(ActionEvent event) throws IOException {
tp_Volume.getSelectionModel().select(1);
}
@FXML
void btn_VolumeSize_Click(ActionEvent event) throws IOException {
tp_Volume.getSelectionModel().select(2);
}
}
[/CODE]
ich habe da ein Problem an dem nun schon einige Tage sitze. und es geht hier um eine Analyse App. Die funktioniert auch schon soweit wie sie es momentan soll.
jedoch habe ich das Problem das GUI sich beim zweiten Aufruf nicht mehr updated. Sprich nur die Steuerelemente. Aufgerufen wird die zweite Stage von der Primary stage:
hieröffnet sich dann ein Dialog in dem ich ein Datenfile auswählen kann. In diesem file sind einzelne xml strings hinterlegt:
Beim ersten Aufruf geht alles seinen normalen Gang:
Wenn ich das fenster jetzt schliesse und erneut aufrufe, reagieren die Steuerelemente nicht mehr sprich werden nicht upgedatet.
Ich kann aber nachvollziehen das der gesamte xml Parser durchlaufen wird, auch die Auswertung erfolgt. Schlussendlich werden auch die Daten in ein Excelsheet
geschrieben. Das funktioniert auch beim zweiten Aufruf. Nur die Steuerelemente aktualisieren sich nicht.
Hat da vielleicht jemand eine Idee?
Hier mal die Klasse die die zweite stage aufruft:
[CODE lang="java" title="Pere Form Klasse"]package performanceMonitoring;
import java.io.IOException;
import javafx.event.EventHandler;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import javafx.stage.WindowEvent;
public class PerformanceForm {
public AnchorPane root = new AnchorPane();
public void performanceForm () throws IOException {
root.setMaxWidth(600);
root.setMaxWidth(900);
Parent root = FXMLLoader.load(getClass().getResource("Performance.fxml"));
Scene scene = new Scene(root);
scene.getStylesheets().add(getClass().getResource("performance.css").toExternalForm());
Stage stage = new Stage(StageStyle.DECORATED);
stage.setTitle("");
stage.getIcons().add(new Image ("/img/ET.png"));
stage.setMaxHeight(1050);
stage.setMaxWidth(1920);
stage.setMaximized(true);
stage.setTitle("System Performance");
stage.centerOnScreen();
stage.setScene(scene);
stage.show();
stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
public void handle(WindowEvent we) {
stage.close();
}
});
}
}
[/CODE]
Hier ist mal die gesamte Controller Klasse:
[CODE lang="java" title="Controller Klasse"]package performanceMonitoring;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.sql.SQLException;
import java.text.DecimalFormat;
import java.util.ArrayList;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import application.ErrorHandling;
import application.Main;
import dbHandle.Systems;
import dbHandle.TABLE_Systems;
import javafx.application.Platform;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.concurrent.Task;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.chart.Axis;
import javafx.scene.chart.BarChart;
import javafx.scene.chart.CategoryAxis;
import javafx.scene.chart.LineChart;
import javafx.scene.chart.NumberAxis;
import javafx.scene.chart.StackedBarChart;
import javafx.scene.chart.XYChart;
import javafx.scene.control.Alert;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.ListView;
import javafx.scene.control.ProgressBar;
import javafx.scene.control.TabPane;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
public class PerformanceController {
@FXML Button btn_Home = new Button();
@FXML Button btn_Hardware = new Button();
@FXML Button btn_LFT = new Button();
@FXML Button btn_Volume = new Button();
@FXML Button btn_Scale = new Button();
@FXML Button btn_Gap = new Button();
@FXML Button btn_Barcode = new Button();
@FXML Button btn_VolumePerformance = new Button();
@FXML Button btn_VolumePosition= new Button();
@FXML Button btn_VolumeSize= new Button();
@FXML Label lbl_Site = new Label();
@FXML Label lbl_SystemID = new Label();
@FXML Label lbl_SystemName = new Label();
@FXML Label lbl_DatabaseName = new Label();
@FXML Label lbl_Progress = new Label();
@FXML Label lbl_VolumeCubic = new Label();
@FXML Label lbl_VolumeUnshaped = new Label();
@FXML Label lbl_VolumeNoShape = new Label();
@FXML Label lbl_VolumeOutsideFront = new Label();
@FXML Label lbl_VolumeOutsideBack = new Label();
@FXML Label lbl_VolumeOutsideLeft = new Label();
@FXML Label lbl_VolumeOutsideRight = new Label();
@FXML Label lbl_VolumeInside = new Label();
@FXML Label lbl_VolumeoutsideFrontBack = new Label();
@FXML Label lbl_VolumeoutsideLeftRight = new Label();
@FXML Label lbl_VolumeoutsideBottom = new Label();
@FXML Label lbl_VolumeoutsideNoObject = new Label();
@FXML ListView<String> lv_PerformanceWarnings = new ListView<String>();
@FXML ProgressBar pb_loadObjects = new ProgressBar();
@FXML AnchorPane ap_Objects = new AnchorPane();
@FXML TabPane tp_Performance = new TabPane();
@FXML TabPane tp_Volume = new TabPane();
@FXML Axis<String> speed_xAxis = new CategoryAxis();
@FXML Axis<Number> speed_yAxis = new NumberAxis();
@FXML LineChart<String, Number> lc_SpeedChart = new LineChart<String, Number>(speed_xAxis, speed_yAxis);
@FXML CategoryAxis barcodeCounter_xAxis = new CategoryAxis();
@FXML Axis<Number> barcodeCounter_yAxis = new NumberAxis();
@FXML BarChart<String, Number> bc_BarcodeCounter = new BarChart<String, Number>(barcodeCounter_xAxis, barcodeCounter_yAxis);
@FXML CategoryAxis objects1_xAxis = new CategoryAxis();
@FXML Axis<Number> objects1_yAxis = new NumberAxis();
@FXML StackedBarChart<String, Number> bc_Objects1 = new StackedBarChart<String, Number>(objects1_xAxis, objects1_yAxis);
@FXML CategoryAxis performance_xAxis = new CategoryAxis();
@FXML NumberAxis performance_yAxis = new NumberAxis();
@SuppressWarnings({ "unchecked", "rawtypes" })
@FXML StackedBarChart<String, Double> bc_Performance = new StackedBarChart(performance_xAxis, performance_yAxis);
public static String siteName = null;
public static String system_ID = null;
public static String system_Name = null;
public static String filename = null;
private static String sTimestamp = null;
private static Integer numberObjects = 0;
private static Integer validVolumeObjects = 0;
private static Integer validLFTObjects = 0;
private static Integer invalidLFTObjects = 0;
private static Integer lftRead= 0;
private static Integer validVMS = 0;
private static Integer invalidVMS = 0;
private static Integer validScale = 0;
private static Integer invalidScale = 0;
private static Integer cubicItem = 0;
private static Integer unshapedItem = 0;
private static Integer noshapeItem = 0;
private static Integer outsideFront = 0;
private static Integer outsideBack = 0;
private static Integer outsideleft = 0;
private static Integer outsideRight = 0;
private static Integer inside = 0;
private static Integer outsideFrontBack = 0;
private static Integer noItemDuringTrigger = 0;
private static Integer outsideLeftRight = 0;
private static Integer outsideBottom = 0;
private static Integer invalidScaleObject = 0;
private static Integer validScaleObject = 0;
private static Integer barcodeGoodRead = 0;
private static Integer barcodeCounter = 0;
private static Integer barcodeCounterValid = 0;
private static Integer barcodeInvalid = 0;
private static ObservableList<SortSpeed> sortSpeedList = FXCollections.observableArrayList();
private static DecimalFormat df = new DecimalFormat("0.00");
public static IntegerProperty evaluateLogfile = new SimpleIntegerProperty(0);
XYChart.Series<String, Number> speedObjects = new XYChart.Series<String, Number>();
XYChart.Series<String, Number> barcodeObjects = new XYChart.Series<String, Number>();
XYChart.Series<String, Number> allObjects = new XYChart.Series<String, Number>();
XYChart.Series<String, Number> invalidObjects = new XYChart.Series<String, Number>();
XYChart.Series<String, Double> performanceRead = new XYChart.Series<String, Double>();
XYChart.Series<String, Double> performanceNoread = new XYChart.Series<String, Double>();
//----------------------------------------------------------------------------------------------------------------
@SuppressWarnings({ "unchecked" })
@FXML
private void initialize() throws IOException{
fillheader();
pb_loadObjects.setStyle("-fx-accent: #ffffff;");
//speed chart
speedObjects.setName("Sort Speed");
speed_xAxis.setLabel("Objects");
speed_yAxis.setLabel("Sort Speed mm/s");
//speedObjects.getData().add(new XYChart.Data<String, Number>("0", 500));
//lc_SpeedChart.autosize();
lc_SpeedChart.setAnimated(false);
lc_SpeedChart.setTitle("Sort Speed Analyse");
lc_SpeedChart.getData().addAll(speedObjects);
// Performance Chart
performance_yAxis.setLabel("%");
performanceRead.setName("Valid reads");
performanceNoread.setName("Noread");
performanceRead.getData().add(new XYChart.Data<String, Double>("Barcode", 40.0));
performanceRead.getData().add(new XYChart.Data<String, Double>("LFT", 40.0));
performanceRead.getData().add(new XYChart.Data<String, Double>("LFT Valid", 40.0));
performanceRead.getData().add(new XYChart.Data<String, Double>("Volume", 40.0));
performanceRead.getData().add(new XYChart.Data<String, Double>("Volume Valid", 40.0));
performanceRead.getData().add(new XYChart.Data<String, Double>("Scale", 40.0));
performanceRead.getData().add(new XYChart.Data<String, Double>("Scale Valid", 40.0));
performanceNoread.getData().add(new XYChart.Data<String, Double>("Barcode", 20.0));
performanceNoread.getData().add(new XYChart.Data<String, Double>("LFT", 20.0));
performanceNoread.getData().add(new XYChart.Data<String, Double>("LFT Valid", 20.0));
performanceNoread.getData().add(new XYChart.Data<String, Double>("Volume", 20.0));
performanceNoread.getData().add(new XYChart.Data<String, Double>("Volume Valid", 20.0));
performanceNoread.getData().add(new XYChart.Data<String, Double>("Scale", 20.0));
performanceNoread.getData().add(new XYChart.Data<String, Double>("Scale Valid", 20.0));
bc_Performance.setAnimated(false);
bc_Performance.setTitle("System Performance");
bc_Performance .getData().addAll(performanceRead, performanceNoread);
// objects Chart
allObjects.setName("Valid Objects");
invalidObjects.setName("Out of Specification");
allObjects.getData().add(new XYChart.Data<String, Number>("Objects", 40));
allObjects.getData().add(new XYChart.Data<String, Number>("Valid", 20));
allObjects.getData().add(new XYChart.Data<String, Number>("LFT", 20));
allObjects.getData().add(new XYChart.Data<String, Number>("VMS", 20));
allObjects.getData().add(new XYChart.Data<String, Number>("Scale", 20));
invalidObjects.getData().add(new XYChart.Data<String, Number>("Objects", 0));
invalidObjects.getData().add(new XYChart.Data<String, Number>("Valid", 20));
invalidObjects.getData().add(new XYChart.Data<String, Number>("LFT", 20));
invalidObjects.getData().add(new XYChart.Data<String, Number>("VMS", 20));
invalidObjects.getData().add(new XYChart.Data<String, Number>("Scale", 20));
bc_Objects1.setAnimated(false);
bc_Objects1.setTitle("Object Evaluation");
bc_Objects1 .getData().addAll(allObjects, invalidObjects);
// Barcode Counter Chart
barcodeObjects.setName("Barcode Count");
barcodeObjects.getData().add(new XYChart.Data<String, Number>("Objects", 0));
barcodeObjects.getData().add(new XYChart.Data<String, Number>("Good Read", 0));
barcodeObjects.getData().add(new XYChart.Data<String, Number>("Code Counter (cc)", 0));
barcodeObjects.getData().add(new XYChart.Data<String, Number>("Valid Code Counter (vcc)", 0));
barcodeObjects.getData().add(new XYChart.Data<String, Number>("Invalid Codes", 0));
bc_BarcodeCounter.setAnimated(false);
bc_BarcodeCounter.setTitle("Barcode Counter");
bc_BarcodeCounter.getData().addAll(barcodeObjects);
evaluateLogfile.addListener( new ChangeListener<Number>() {
public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
if(evaluateLogfile.getValue() > 0) {
try {
xmlParser(filename, system_ID);
} catch (IOException | SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
evaluateLogfile.setValue(0);
}
} );
}
private void fillheader() {
lbl_Site.setText(siteName);
lbl_SystemID.setText(system_ID);
lbl_SystemName.setText(system_Name);
lbl_DatabaseName.setText(Main.DB_SITE_CONNECTION_STRING);
}
@SuppressWarnings("unchecked")
public void objectPerformance(Integer volume, Integer volumeNoread, Integer volumeNoreadValid, String systemID
) throws IOException, SQLException {
ObservableList<Systems> customSystems = FXCollections.observableArrayList();
customSystems.clear();
customSystems.addAll(TABLE_Systems.getSystembyID(systemID));
Platform.runLater(new Runnable() {
@Override
public void run() {
if(customSystems.get(0).getVol().toString().equals("true")){
double rate = 100.0/numberObjects * volume;
double noRate = 100.0/numberObjects * volumeNoread;
double volumeRate = 100.0/validVolumeObjects * volume;
double noVolumeRate = 100.0/validVolumeObjects * volumeNoreadValid;
performanceRead.getData().add(createVolumeValid("Volume", rate, volume));
performanceRead.getData().add(createVolumeValid("Volume Valid", volumeRate, volume));
performanceNoread.getData().add(createVolumeValid("Volume", noRate, volumeNoread));
performanceNoread.getData().add(createVolumeValid("Volume Valid", noVolumeRate, volumeNoreadValid));
}
bc_Performance.getData().clear();
bc_Performance.layout();
bc_Performance.getData().addAll(performanceRead, performanceNoread);
}
});
}
@SuppressWarnings({ "unchecked", "rawtypes" })
private XYChart.Data createVolumeValid(String objecttype, Double value, Integer objects) {
XYChart.Data data = new XYChart.Data(objecttype, value);
String text = df.format(value) + "%";
StackPane node = new StackPane();
Label label = new Label(text);
label.setFont(new Font("Arial", 12));
label.setTextFill(Color.web("#ffffff"));
Label label1 = new Label(objects.toString());
label1.setFont(new Font("Arial", 12));
label1.setTextFill(Color.web("#ffffff"));
VBox group = new VBox(label, label1);
group.setAlignment(Pos.CENTER);
StackPane.setAlignment(group, Pos.CENTER);
StackPane.setMargin(group, new Insets(20, 0, 5, 0));
node.getChildren().add(group);
data.setNode(node);
return data;
}
@SuppressWarnings("unchecked")
public void barcodeCounterChart(Integer objects, Integer gr, Integer cc, Integer vcc, Integer icc) throws IOException{
Platform.runLater(new Runnable() {
@Override
public void run() {
barcodeObjects.getData().add(createCodeCounter("Objects", objects));
barcodeObjects.getData().add(createCodeCounter("Good Read", gr));
barcodeObjects.getData().add(createCodeCounter("Code Counter (cc)", cc));
barcodeObjects.getData().add(createCodeCounter("Valid Code Counter (vcc)", vcc));
barcodeObjects.getData().add(createCodeCounter("Invalid Codes", icc));
bc_BarcodeCounter.getData().clear();
bc_BarcodeCounter.layout();
bc_BarcodeCounter.getData().addAll(barcodeObjects);
}
});
}
@SuppressWarnings({ "unchecked", "rawtypes" })
private XYChart.Data createCodeCounter(String objecttype, Integer value) {
XYChart.Data data = new XYChart.Data(objecttype, value);
double objects = 100.0/numberObjects * value;
String s = df.format(objects) + "%";
String text = value.toString();
StackPane node = new StackPane();
Label label = new Label(text);
label.setFont(new Font("Arial", 12));
label.setTextFill(Color.web("#ffffff"));
Label label1 = new Label(s);
label1.setFont(new Font("Arial", 12));
label1.setTextFill(Color.web("#ffffff"));
VBox group = new VBox(label, label1);
group.setAlignment(Pos.CENTER);
StackPane.setAlignment(group, Pos.BOTTOM_CENTER);
StackPane.setMargin(group, new Insets(20, 0, 5, 0));
node.getChildren().add(group);
data.setNode(node);
return data;
}
@SuppressWarnings("unchecked")
public void objectsChart(Integer objects, Integer valid, Integer invalid, Integer lft, Integer validLFT, Integer vms, Integer validVMS, Integer scale,
Integer validScale, String systemID) throws IOException, SQLException {
ObservableList<Systems> customSystems = FXCollections.observableArrayList();
customSystems.clear();
customSystems.addAll(TABLE_Systems.getSystembyID(systemID));
Platform.runLater(new Runnable() {
@Override
public void run() {
allObjects.getData().add(createData("Objects", objects));
allObjects.getData().add(createData("Valid", valid));
invalidObjects.getData().add((new XYChart.Data<String, Number>("Objects", 0)));
invalidObjects.getData().add(createData("Valid", invalid));
if(customSystems.get(0).getLFT().toString().equals("true")){
allObjects.getData().add(createData("LFT", lft));
invalidObjects.getData().add(createData("LFT", validLFT));
}
if(customSystems.get(0).getVol().toString().equals("true")){
allObjects.getData().add(createData("VMS", vms));
invalidObjects.getData().add(createData("VMS", validVMS));
}
if(customSystems.get(0).getWeight().toString().equals("true")){
allObjects.getData().add(createData("Scale", scale));
invalidObjects.getData().add(createData("Scale", validScale));
}
bc_Objects1.getData().clear();
bc_Objects1.layout();
bc_Objects1.getData().addAll(allObjects, invalidObjects);
}
});
}
@SuppressWarnings({ "unchecked", "rawtypes" })
private XYChart.Data createData(String objecttype, Integer value) {
XYChart.Data data = new XYChart.Data(objecttype, value);
double objects = 100.0/numberObjects * value;
String s = df.format(objects) + "%";
String text = value.toString();
StackPane node = new StackPane();
Label label = new Label(text);
label.setFont(new Font("Arial", 12));
label.setTextFill(Color.web("#ffffff"));
Label label1 = new Label(s);
label1.setFont(new Font("Arial", 12));
label1.setTextFill(Color.web("#ffffff"));
VBox group = new VBox(label, label1);
group.setAlignment(Pos.CENTER);
StackPane.setAlignment(group, Pos.BOTTOM_CENTER);
StackPane.setMargin(group, new Insets(20, 0, 5, 0));
node.getChildren().add(group);
data.setNode(node);
return data;
}
// Speed Chart
@SuppressWarnings("unchecked")
public void speedChart() throws IOException{
Integer lineCount = sortSpeedList.size();
Integer step = 1;
Integer value = 0;
if(lineCount > 100) {
step = 30;
}else if(lineCount > 1000) {
step = 30;
}else if(lineCount > 3000) {
step = 50;
}else if(lineCount > 5000) {
step = 100;
}
for (Integer b = 0; b < sortSpeedList.size(); b++) {
String s = sortSpeedList.get(b).getObject();
Integer i = sortSpeedList.get(b).getSpeed();
if(b.equals(value)){
value = value + step;
Platform.runLater(new Runnable() {
@Override
public void run() {
speedObjects.getData().add(new XYChart.Data<String, Number>(s, i));
lc_SpeedChart.getData().clear();
lc_SpeedChart.layout();
lc_SpeedChart.getData().addAll(speedObjects);
}
});
}
}
}
// Read Datafile ---------------------------------------------------------------------------------------------------------------------------------------------
@SuppressWarnings({ "unused", "unchecked" })
public void xmlParser(String filename, String systemID) throws IOException, SQLException {
System.out.println("called");
allObjects.getData().clear();
invalidObjects.getData().clear();
lv_PerformanceWarnings.getItems().clear();
ObservableList<Systems> customSystems = FXCollections.observableArrayList();
customSystems.clear();
customSystems.addAll(TABLE_Systems.getSystembyID(systemID));
String templateName = customSystems.get(0).getTemplate();
String sFileoutput = customSystems.get(0).getFileoutput();
String sSite = customSystems.get(0).getSite();
String sSystemID = customSystems.get(0).getSystemID();
String sName = customSystems.get(0).getName();
String lftSystem = customSystems.get(0).getLFT();
String volumeSystem = customSystems.get(0).getVol();
String scaleSystem = customSystems.get(0).getWeight();
System.out.println("before task");
sortSpeedList.clear();
// Create a background Task
Task<Void> task = new Task<Void>() {
@Override
protected Void call() throws Exception {
System.out.println("in task");
Integer objectCount = 0;
Integer invalidObjects = 0;
Integer volumeRead = 0;
Integer scaleRead = 0;
Integer lineCount = 0;
Integer lineCountSpeed = 0;
Integer sortSpeed = 0;
Integer sortSpeedOld = 0;
int fileLines = 0;
Boolean invalidObject = false;
Boolean warningVolumeReadingArea = false;
Boolean warningVolumeItemToSmall = false;
Boolean warningVolumeItemToBig= false;
Boolean warningInvalidCode= false;
Boolean lftGoodRead = false;
Boolean volumeGoodRead = false;
Boolean scaleGoodRead = false;
double linesread = 0.00;
try {
@SuppressWarnings("resource")
BufferedReader in = new BufferedReader(new FileReader(filename));
while ( in.readLine() != null ) {
fileLines++;
}
}
catch (Exception ex) {
ex.printStackTrace();
}
try (BufferedReader br = Files.newBufferedReader(Paths.get(filename))) {
// read line by line
String line;
while ((line = br.readLine()) != null) {
InputStream stream = new ByteArrayInputStream(line.getBytes());
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(stream);
doc.getDocumentElement().normalize();
String telegramType = doc.getDocumentElement().getNodeName();
if (telegramType.equals("objectdata")) { // Start of objectdata
NodeList nList = doc.getElementsByTagName("objectdata");
for (int i = 0; i < nList.getLength(); i++) {
Node nNode = nList.item(i);
if (nNode.getNodeType() == Node.ELEMENT_NODE) {
Element eElement = (Element) nNode;
sTimestamp = eElement.getElementsByTagName("timestamp").item(0).getTextContent();
}
}
// General Object data ------------------------------------------------------------------------------------------------
nList = doc.getElementsByTagName("general");
for (int i1 = 0; i1 < nList.getLength(); i1++) {
Node nNode = nList.item(i1);
//System.out.println("\nCurrent Element :" + nNode.getNodeName());
if (nNode.getNodeType() == Node.ELEMENT_NODE) {
Element eElement = (Element) nNode;
}
}
// Volume data ----------------------------------------------------------------------------------------------------------
nList = doc.getElementsByTagName("volumetric");
for (int i1 = 0; i1 < nList.getLength(); i1++) {
Node nNode = nList.item(i1);
//System.out.println("\nCurrent Element :" + nNode.getNodeName());
if (nNode.getNodeType() == Node.ELEMENT_NODE) {
Element eElement = (Element) nNode;
String OMS1 = eElement.getAttribute("oms1");
String OMS2 = eElement.getAttribute("oms2");
String OMS3 = eElement.getAttribute("oms3");
String volumeUnit = eElement.getElementsByTagName("size").item(0).getAttributes().getNamedItem("unit").toString();
String OLE = eElement.getElementsByTagName("size").item(0).getAttributes().getNamedItem("ole").getNodeValue();
String OWI = eElement.getElementsByTagName("size").item(0).getAttributes().getNamedItem("owi").getNodeValue();
String OHE = eElement.getElementsByTagName("size").item(0).getAttributes().getNamedItem("ohe").getNodeValue();
if((Integer.parseInt(OLE) > 1) && (Integer.parseInt(OWI) > 1) && (Integer.parseInt(OHE) >1) && (OMS1.equals("0000"))) {
volumeRead++;
volumeGoodRead = true;
}else {
volumeGoodRead = false;
}
//Item inside/outside reading area
String sArea = Character.toString(OMS2.charAt(3));
Integer iArea = Integer.parseInt(sArea);
switch (iArea) {
case 1: {
outsideFront++;
break;
}
case 2: {
outsideBack++;
break;
}
case 3: {
outsideFrontBack++;
break;
}
case 8: {
noItemDuringTrigger++;
break;
}
default: {
break;
}
}
String sArea1 = Character.toString(OMS2.charAt(6));
Integer iArea1 = Integer.parseInt(sArea1);
switch (iArea1) {
case 1: {
outsideRight++;
break;
}
case 4: {
outsideleft++;
break;
}
case 5: {
outsideLeftRight++;
break;
}
case 8: {
outsideBottom++;
break;
}
default: {
break;
}
}
if (iArea == 0 && iArea1 == 0) {
inside++;
}
if (iArea > 0 || iArea1 > 0) {
warningVolumeReadingArea = true;
}
// cubic or unshaped
String sCubic = Character.toString(OMS3.charAt(7));
if(sCubic.equals("1")) {
cubicItem++;
} else if(sCubic.equals("2")) {
unshapedItem++;
} else if (sCubic.equals("0")){
noshapeItem++;
}
String s = Character.toString(OMS1.charAt(1));
String s1 = Character.toString(OMS1.charAt(2)) + Character.toString(OMS1.charAt(3));
if(s.equals("1")) {
warningVolumeItemToBig = true;
}
if(s.equals("2")) {
warningVolumeItemToSmall = true;
}
if((s.equals("1")) || (s.equals("2")) || (s1.equals("11"))) {
invalidVMS++;
invalidObject = true;
}
}
}
// Weight data ----------------------------------------------------------------------------------------------------------
nList = doc.getElementsByTagName("scaledata");
for (int i1 = 0; i1 < nList.getLength(); i1++) {
Node nNode = nList.item(i1);
if (nNode.getNodeType() == Node.ELEMENT_NODE) {
Element eElement = (Element) nNode;
String OWS = eElement.getAttribute("ows");
String OWE_UNIT = eElement.getElementsByTagName("owe").item(0).getAttributes().getNamedItem("unit").getNodeValue();
String OWE = eElement.getElementsByTagName("value").item(0).getTextContent();
if(OWS.equals("0")) {
validScale++;
scaleGoodRead = true;
}else {
invalidScale++;
scaleGoodRead = false;
}
Integer i = Integer.parseInt(OWS);
if(PerformanceUtils.OWS(i) == true) {
invalidScaleObject++;
if (invalidObject == false){
invalidObject = true;
}
}
}
}
// Barcode Data
nList = doc.getElementsByTagName("barcode");
Integer cc = 0;
Integer vcc = 0;
String codeCounter = "0";
String validCodeCounter = "0";
String codeCondition = null;
for (int i1 = 0; i1 < nList.getLength(); i1++) {
Node nNode = nList.item(i1);
if (nNode.getNodeType() == Node.ELEMENT_NODE) {
Element eElement = (Element) nNode;
codeCounter = eElement.getAttribute("cc");
validCodeCounter = eElement.getAttribute("vcc");
//codeCondition = eElement.getElementsByTagName("condition").item(0).getTextContent();
if(validCodeCounter != null && validCodeCounter.length() != 0) {
vcc = Integer.parseInt(validCodeCounter);
barcodeGoodRead++;
barcodeCounterValid = barcodeCounterValid + vcc;
}
if(codeCounter != null && codeCounter.length() != 0) {
cc = Integer.parseInt(codeCounter);
barcodeCounter = barcodeCounter + cc;
}
}
}
nList = doc.getElementsByTagName("codeinvalid");
for (int i1 = 0; i1 < nList.getLength(); i1++) {
Node nNode = nList.item(i1);
if (nNode.getNodeType() == Node.ELEMENT_NODE) {
Element eElement = (Element) nNode;
String invalidID = eElement.getAttribute("id");
if(invalidID != null && invalidID.length() != 0) {
warningInvalidCode = true;
barcodeInvalid++;
}
}
}
// Sorterstate and Speed
nList = doc.getElementsByTagName("speed");
for (int i1 = 0; i1 < nList.getLength(); i1++) {
Node nNode = nList.item(i1);
if (nNode.getNodeType() == Node.ELEMENT_NODE) {
Element eElement = (Element) nNode;
String speedUnit = eElement.getAttribute("unit");
String conveyorSpeed = eElement.getElementsByTagName("value").item(0).getTextContent();
if(conveyorSpeed != null && conveyorSpeed.length() != 0) {
sortSpeed = Integer.parseInt(conveyorSpeed);
}
if(lineCount.equals(lineCountSpeed) || !sortSpeed.equals(sortSpeedOld)) {
sortSpeedOld = sortSpeed;
if(lineCount.equals(lineCountSpeed)){
lineCountSpeed = lineCountSpeed + 100;
}
sortSpeedList.add(new SortSpeed(lineCount.toString(), sortSpeed));
}
}
}
//LFT Good Read
if(volumeSystem.equals("true") && scaleSystem.equals("true")) {
if(volumeGoodRead == true && scaleGoodRead == true) {
lftGoodRead = true;
}
}
if(volumeSystem.equals("true") && scaleSystem.equals("false")) {
if(volumeGoodRead == true) {
lftGoodRead = true;
}
}
if(volumeSystem.equals("false") && scaleSystem.equals("false")) {
if(scaleGoodRead == true) {
lftGoodRead = true;
}
}
if(lftGoodRead == true) {
lftRead++;
}
lftGoodRead = false;
volumeGoodRead = false;
scaleGoodRead = false;
// Object counter
objectCount++;
// Valid VMS Objects
validVMS = objectCount - invalidVMS;
// Valid Scale Objects
validScaleObject = objectCount - invalidScaleObject;
// Valid LFT objects
if (invalidObject == true) {
invalidLFTObjects++;
}
validLFTObjects = objectCount - invalidLFTObjects;
// invalid object counter
if(invalidObject == true) {
invalidObjects++;
}
invalidObject = false;
//get Timestamp
Integer position = sTimestamp.indexOf("T");
String date = sTimestamp.substring(0, position);
// Increase line counter
lineCount++;
//updating progressbar
updateProgress(objectCount, fileLines);
} // end of objectdata
} // End of while loop --End of datafile -------------------------------------------------------------------------------------------
} catch (IOException | ParserConfigurationException | SAXException e) {
ErrorHandling error= new ErrorHandling();
try {
error.AlertBox("Exception Raised in xmlParser", "Exception", e.getMessage());
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
System.out.println("Data evaluation finished");
// get valid objects
Integer validObjects = objectCount - invalidObjects;
numberObjects = objectCount;
// Speed Chart
speedChart();
// Barcode Counter Chart
barcodeCounterChart(objectCount, barcodeGoodRead, barcodeCounter, barcodeCounterValid, barcodeInvalid);
// Object Chart
objectsChart(objectCount, validObjects, invalidObjects, validLFTObjects, invalidLFTObjects, validVMS, invalidVMS, validScaleObject, invalidScaleObject, systemID);
// Performance Chart
Integer volumeNoread = objectCount - volumeRead;
validVolumeObjects = objectCount - invalidVMS;
Integer volumeNoreadValid = volumeNoread - invalidVMS;
objectPerformance(volumeRead, volumeNoread, volumeNoreadValid, systemID);
// Volume Pages
Platform.runLater(new Runnable() {
public void run() {
lbl_VolumeCubic.setText(cubicItem.toString());
lbl_VolumeUnshaped.setText(unshapedItem.toString());
lbl_VolumeNoShape.setText(noshapeItem.toString());
lbl_VolumeOutsideFront.setText(outsideFront.toString());
lbl_VolumeOutsideBack.setText(outsideBack.toString());
lbl_VolumeOutsideLeft.setText(outsideleft.toString());
lbl_VolumeOutsideRight.setText(outsideRight.toString());
lbl_VolumeInside.setText(inside.toString());
lbl_VolumeoutsideFrontBack.setText(outsideFrontBack.toString());
lbl_VolumeoutsideLeftRight.setText(outsideLeftRight.toString());
lbl_VolumeoutsideBottom.setText(outsideBottom.toString());
lbl_VolumeoutsideNoObject.setText(noItemDuringTrigger.toString());
System.out.println("volume finished");
lbl_VolumeCubic.setText("hello");
}
});
// calculate read performance
// Barcode
double barcodeRate = 100.0/numberObjects * barcodeGoodRead;
double barcodeNoreadRate = 100.0 - barcodeRate;
//LFT Performance
double lftRate = 100.0/numberObjects * lftRead;
double noLFTRate = 100.0 - lftRate;
double lftValidRate = 100.0/validLFTObjects * lftRead;
double nolftValidRate = 100.0 - lftValidRate;
//Volume
double volumeRate = 100.0/numberObjects * volumeRead;
double noVolumeRate = 100.0/numberObjects * volumeNoread;
double volumeValidRate = 100.0/validVolumeObjects * volumeRead;
double noVolumeValidRate = 100.0 - volumeValidRate;
//Weight
double weightRate = 100.0/numberObjects * validScale;
double noWeightRate = 100.0/numberObjects * invalidScale;
double weightValidRate = 100.0/validScaleObject * validScale;
double noWeightValidRate = 100.0 - weightValidRate;
// add warnings
if (warningVolumeReadingArea == true) {
lv_PerformanceWarnings.getItems().add("Volume Performance: Items outside measuring area!");
}
if (warningVolumeItemToBig == true) {
lv_PerformanceWarnings.getItems().add("Volume Performance: Items outside Specification! Item to big");
}
if (warningVolumeItemToSmall == true) {
lv_PerformanceWarnings.getItems().add("Volume Performance: Items outside Specification! Item to small");
}
if (warningInvalidCode == true) {
lv_PerformanceWarnings.getItems().add("Barcode Performance: Invalid Barcodes found!");
}
// Add data to a list for the excel sheet
ArrayList<String> dataList = new ArrayList<>();
// Objectdata
dataList.add(objectCount.toString()); // Value 0
dataList.add(validObjects.toString()); // Value 1
dataList.add(invalidObjects.toString()); // Value 2
dataList.add(validLFTObjects.toString()); // Value 3
dataList.add(invalidLFTObjects.toString()); // Value 4
dataList.add(validVMS.toString()); // Value 5
dataList.add(invalidVMS.toString()); // Value 6
dataList.add(validScaleObject.toString()); // Value 7
dataList.add(invalidScaleObject.toString()); // Value 8
dataList.add(cubicItem.toString()); // Value 9
dataList.add(unshapedItem.toString()); // Value 10
dataList.add(noshapeItem.toString()); // Value 11
dataList.add(outsideFront.toString()); // Value 12
dataList.add(outsideBack.toString()); // Value 13
dataList.add(outsideFrontBack.toString()); // Value 14
dataList.add(noItemDuringTrigger.toString()); // Value 15
dataList.add(outsideRight.toString()); // Value 16
dataList.add(outsideleft.toString()); // Value 17
dataList.add(outsideLeftRight.toString()); // Value 18
dataList.add(outsideBottom.toString()); // Value 19
dataList.add(inside.toString()); // Value 20
dataList.add( String.format( "%.2f", barcodeRate )); // Value 21
dataList.add( String.format( "%.2f", barcodeNoreadRate )); // Value 22
dataList.add(String.format( "%.2f", lftRate)); // Value 23
dataList.add(String.format( "%.2f", noLFTRate)); // Value 24
dataList.add(String.format( "%.2f", lftValidRate)); // Value 25
dataList.add(String.format( "%.2f", nolftValidRate)); // Value 26
dataList.add(String.format( "%.2f", volumeRate )); // Value 27
dataList.add(String.format( "%.2f", noVolumeRate )); // Value 28
dataList.add(String.format( "%.2f", volumeValidRate )); // Value 39
dataList.add(String.format( "%.2f", noVolumeValidRate )); // Value 30
dataList.add(String.format( "%.2f", weightRate )); // Value 31
dataList.add(String.format( "%.2f", noWeightRate )); // Value 32
dataList.add(String.format( "%.2f", weightValidRate )); // Value 33
dataList.add(String.format( "%.2f", noWeightValidRate )); // Value 34
dataList.add(barcodeGoodRead.toString()); // Value 35
dataList.add(barcodeCounter.toString()); // Value 36
dataList.add(barcodeCounterValid.toString()); // Value 37
dataList.add(barcodeInvalid.toString()); // Value 38
if(templateName == null || templateName.equals("")) {
Platform.runLater(new Runnable() {
public void run() {
Alert alert = new Alert(Alert.AlertType.WARNING);
alert.setTitle("Template Error");
alert.setHeaderText("Template does not exists!");
alert.setContentText("No template found in database for this system!.");
alert.showAndWait();
}
});
}else {
SaveToExcel.datenSpeichern(dataList, templateName, sFileoutput, sSite, sSystemID, sName);
}
return null;
}
};
task.setOnFailed(wse -> {
wse.getSource().getException().printStackTrace();
});
lbl_Progress.setText("Import data from file:");
pb_loadObjects.progressProperty().bind(task.progressProperty());
new Thread(task).start();
}
@FXML
void btn_Home_Click(ActionEvent event) throws IOException {
tp_Performance.getSelectionModel().select(0);
}
@FXML
void btn_Hardware_click(ActionEvent event) throws IOException {
tp_Performance.getSelectionModel().select(1);
}
@FXML
void btn_LFT_Click(ActionEvent event) throws IOException {
tp_Performance.getSelectionModel().select(2);
}
@FXML
void btn_Volume_Click(ActionEvent event) throws IOException {
tp_Performance.getSelectionModel().select(3);
}
@FXML
void btn_Scale_Click(ActionEvent event) throws IOException {
tp_Performance.getSelectionModel().select(4);
}
@FXML
void btn_Gap_Click(ActionEvent event) throws IOException {
tp_Performance.getSelectionModel().select(5);
}
@FXML
void btn_Barcode_Click(ActionEvent event) throws IOException {
tp_Performance.getSelectionModel().select(6);
}
@FXML
void btn_VolumePerformance_Click(ActionEvent event) throws IOException {
tp_Volume.getSelectionModel().select(0);
}
@FXML
void btn_VolumePosition_Click(ActionEvent event) throws IOException {
tp_Volume.getSelectionModel().select(1);
}
@FXML
void btn_VolumeSize_Click(ActionEvent event) throws IOException {
tp_Volume.getSelectionModel().select(2);
}
}
[/CODE]