Skip to content

Commit

Permalink
commit1
Browse files Browse the repository at this point in the history
  • Loading branch information
tainfante committed Nov 2, 2017
1 parent eafc268 commit 1bda5a5
Show file tree
Hide file tree
Showing 18 changed files with 239 additions and 303 deletions.
263 changes: 136 additions & 127 deletions .idea/workspace.xml

Large diffs are not rendered by default.

Binary file not shown.
Binary file modified out/production/RealTimeSerialPlotter/application/Main.class
Binary file not shown.
Binary file not shown.
14 changes: 14 additions & 0 deletions out/production/RealTimeSerialPlotter/mainwindow/chart.fxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<AnchorPane xmlns="http://javafx.com/javafx"
xmlns:fx="http://javafx.com/fxml"
fx:controller="mainwindow.Chart"
prefHeight="400.0" prefWidth="600.0">

</AnchorPane>
19 changes: 19 additions & 0 deletions out/production/RealTimeSerialPlotter/mainwindow/comport.fxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<HBox layoutY="27.0" prefHeight="25.0" prefWidth="600.0" xmlns="http://javafx.com/javafx"
xmlns:fx="http://javafx.com/fxml"
fx:controller="mainwindow.COMPort">
<children>
<Label prefHeight="25.0" prefWidth="65.0" text="COM Port" />
<ChoiceBox prefWidth="150.0" />
<Label prefHeight="29.0" prefWidth="55.0" text="Baudrate" />
<ChoiceBox prefWidth="150.0" />
<Button mnemonicParsing="false" text="Connect" />
</children>
</HBox>
13 changes: 8 additions & 5 deletions out/production/RealTimeSerialPlotter/mainwindow/mainwindow.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.Pane?>

<Pane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.121" xmlns:fx="http://javafx.com/fxml/1">
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.121" xmlns:fx="http://javafx.com/fxml/1">
<children>
<MenuBar layoutY="2.0" prefHeight="25.0" prefWidth="600.0">
<menus>
Expand All @@ -46,7 +45,7 @@
</Menu>
</menus>
</MenuBar>
<TabPane layoutY="51.0" prefHeight="351.0" prefWidth="600.0" tabClosingPolicy="UNAVAILABLE">
<TabPane layoutY="76.0" prefHeight="326.0" prefWidth="600.0" tabClosingPolicy="UNAVAILABLE">
<tabs>
<Tab text="Chart">
<content>
Expand Down Expand Up @@ -91,7 +90,7 @@
</children></AnchorPane>
</content>
</Tab>
<Tab text="Data">
<Tab text="Export">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" />
</content>
Expand All @@ -109,5 +108,9 @@
<ProgressBar prefHeight="25.0" prefWidth="200.0" progress="0.0" />
<Label prefHeight="25.0" prefWidth="348.0" text="Label" />
</children></HBox>
<HBox layoutY="52.0" prefHeight="25.0" prefWidth="600.0" >
<fx:include source="comport.fxml"/>

</HBox>
</children>
</Pane>
</AnchorPane>
Binary file not shown.
Binary file not shown.
30 changes: 0 additions & 30 deletions out/production/RealTimeSerialPlotter/mainwindow/settings.fxml

This file was deleted.

93 changes: 17 additions & 76 deletions src/application/Main.java
Original file line number Diff line number Diff line change
@@ -1,82 +1,23 @@
package application;

import gnu.io.CommPortIdentifier;
import gnu.io.SerialPort;
import gnu.io.SerialPortEvent;
import gnu.io.SerialPortEventListener;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main implements SerialPortEventListener {
SerialPort serialPort;
// Na windowsie domyślnie posługujemy się portem COM3
private static final String PORT_NAME = "COM3";

private BufferedReader input;

/** Milliseconds to block while waiting for port open */
private static final int TIME_OUT = 2000;
/** Default bits per second for COM port. */
private static final int DATA_RATE = 9600;

public void initialize() {
CommPortIdentifier portId;
try {
portId = CommPortIdentifier.getPortIdentifier(PORT_NAME);

// otwieramy i konfigurujemy port
serialPort = (SerialPort) portId.open(this.getClass().getName(),
TIME_OUT);
serialPort.setSerialPortParams(DATA_RATE, SerialPort.DATABITS_8,
SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);

// strumień wejścia
input = new BufferedReader(new InputStreamReader(
serialPort.getInputStream()));

// dodajemy słuchaczy zdarzeń
serialPort.addEventListener(this);
serialPort.notifyOnDataAvailable(true);
} catch (Exception e) {
System.err.println(e.toString());
}
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class Main extends Application {

@Override
public void start(Stage primaryStage) throws Exception{
Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));
primaryStage.setTitle("Hello World");
primaryStage.setScene(new Scene(root, 300, 275));
primaryStage.show();
}

public synchronized void close() {
if (serialPort != null) {
serialPort.removeEventListener();
serialPort.close();
}
}

/**
* Metoda nasłuchuje na dane na wskazanym porcie i wyświetla je w konsoli
*/
public synchronized void serialEvent(SerialPortEvent oEvent) {
if (oEvent.getEventType() == SerialPortEvent.DATA_AVAILABLE) {
try {
String inputLine = input.readLine();
System.out.println(inputLine);
} catch (Exception e) {
System.err.println(e.toString());
}
}
}

public static void main(String[] args) throws Exception {
Main main = new Main();
main.initialize();
Thread t = new Thread() {
public void run() {
try {
Thread.sleep(1000000);
main.close();
} catch (InterruptedException ie) {
}
}
};
t.start();
System.out.println("Started");
public static void main(String[] args) {
launch(args);
}
}
}
4 changes: 4 additions & 0 deletions src/mainwindow/Chart.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package mainwindow;

public class Chart {
}
14 changes: 14 additions & 0 deletions src/mainwindow/chart.fxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<AnchorPane xmlns="http://javafx.com/javafx"
xmlns:fx="http://javafx.com/fxml"
fx:controller="mainwindow.Chart"
prefHeight="400.0" prefWidth="600.0">

</AnchorPane>
19 changes: 19 additions & 0 deletions src/mainwindow/comport.fxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<HBox layoutY="27.0" prefHeight="25.0" prefWidth="600.0" xmlns="http://javafx.com/javafx"
xmlns:fx="http://javafx.com/fxml"
fx:controller="mainwindow.COMPort">
<children>
<Label prefHeight="25.0" prefWidth="65.0" text="COM Port" />
<ChoiceBox prefWidth="150.0" />
<Label prefHeight="29.0" prefWidth="55.0" text="Baudrate" />
<ChoiceBox prefWidth="150.0" />
<Button mnemonicParsing="false" text="Connect" />
</children>
</HBox>
13 changes: 8 additions & 5 deletions src/mainwindow/mainwindow.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.Pane?>

<Pane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.121" xmlns:fx="http://javafx.com/fxml/1">
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.121" xmlns:fx="http://javafx.com/fxml/1">
<children>
<MenuBar layoutY="2.0" prefHeight="25.0" prefWidth="600.0">
<menus>
Expand All @@ -46,7 +45,7 @@
</Menu>
</menus>
</MenuBar>
<TabPane layoutY="51.0" prefHeight="351.0" prefWidth="600.0" tabClosingPolicy="UNAVAILABLE">
<TabPane layoutY="76.0" prefHeight="326.0" prefWidth="600.0" tabClosingPolicy="UNAVAILABLE">
<tabs>
<Tab text="Chart">
<content>
Expand Down Expand Up @@ -91,7 +90,7 @@
</children></AnchorPane>
</content>
</Tab>
<Tab text="Data">
<Tab text="Export">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" />
</content>
Expand All @@ -109,5 +108,9 @@
<ProgressBar prefHeight="25.0" prefWidth="200.0" progress="0.0" />
<Label prefHeight="25.0" prefWidth="348.0" text="Label" />
</children></HBox>
<HBox layoutY="52.0" prefHeight="25.0" prefWidth="600.0" >
<fx:include source="comport.fxml"/>

</HBox>
</children>
</Pane>
</AnchorPane>
6 changes: 0 additions & 6 deletions src/mainwindow/portSettings.java

This file was deleted.

30 changes: 0 additions & 30 deletions src/mainwindow/settings.fxml

This file was deleted.

24 changes: 0 additions & 24 deletions src/mainwindow/settings.java

This file was deleted.

0 comments on commit 1bda5a5

Please sign in to comment.