-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
239 additions
and
303 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
14 changes: 14 additions & 0 deletions
14
out/production/RealTimeSerialPlotter/mainwindow/chart.fxml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
19
out/production/RealTimeSerialPlotter/mainwindow/comport.fxml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file removed
BIN
-204 Bytes
out/production/RealTimeSerialPlotter/mainwindow/portSettings.class
Binary file not shown.
Binary file not shown.
30 changes: 0 additions & 30 deletions
30
out/production/RealTimeSerialPlotter/mainwindow/settings.fxml
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package mainwindow; | ||
|
||
public class Chart { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.