diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..838458f
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+/dist/
\ No newline at end of file
diff --git a/build.xml b/build.xml
old mode 100644
new mode 100755
diff --git a/build/built-jar.properties b/build/built-jar.properties
old mode 100644
new mode 100755
index d863663..6c01d54
--- a/build/built-jar.properties
+++ b/build/built-jar.properties
@@ -1,4 +1,4 @@
-#Wed, 18 Dec 2013 22:55:13 +0000
-
-
-/Users/samc/Desktop/CM3033=
+#Thu, 19 Dec 2013 19:48:40 +0000
+
+
+H\:\\CM_3033\\Java\\CM3033-marina=
diff --git a/build/classes/CM3033Tests/Client.class b/build/classes/CM3033Tests/Client.class
old mode 100644
new mode 100755
index 59a9fb2..dac38dc
Binary files a/build/classes/CM3033Tests/Client.class and b/build/classes/CM3033Tests/Client.class differ
diff --git a/build/classes/CM3033Tests/ClientApp$1.class b/build/classes/CM3033Tests/ClientApp$1.class
old mode 100644
new mode 100755
index 85e9c61..314f79f
Binary files a/build/classes/CM3033Tests/ClientApp$1.class and b/build/classes/CM3033Tests/ClientApp$1.class differ
diff --git a/build/classes/CM3033Tests/ClientApp$2.class b/build/classes/CM3033Tests/ClientApp$2.class
old mode 100644
new mode 100755
index 0ac65a0..053c860
Binary files a/build/classes/CM3033Tests/ClientApp$2.class and b/build/classes/CM3033Tests/ClientApp$2.class differ
diff --git a/build/classes/CM3033Tests/ClientApp$3.class b/build/classes/CM3033Tests/ClientApp$3.class
old mode 100644
new mode 100755
index 333c4b3..24aa883
Binary files a/build/classes/CM3033Tests/ClientApp$3.class and b/build/classes/CM3033Tests/ClientApp$3.class differ
diff --git a/build/classes/CM3033Tests/ClientApp$4.class b/build/classes/CM3033Tests/ClientApp$4.class
old mode 100644
new mode 100755
index f2600b2..dd60787
Binary files a/build/classes/CM3033Tests/ClientApp$4.class and b/build/classes/CM3033Tests/ClientApp$4.class differ
diff --git a/build/classes/CM3033Tests/ClientApp$5.class b/build/classes/CM3033Tests/ClientApp$5.class
old mode 100644
new mode 100755
index 5b75a58..aa3b5dd
Binary files a/build/classes/CM3033Tests/ClientApp$5.class and b/build/classes/CM3033Tests/ClientApp$5.class differ
diff --git a/build/classes/CM3033Tests/ClientApp$6.class b/build/classes/CM3033Tests/ClientApp$6.class
old mode 100644
new mode 100755
index 020ff1b..c2ff8d0
Binary files a/build/classes/CM3033Tests/ClientApp$6.class and b/build/classes/CM3033Tests/ClientApp$6.class differ
diff --git a/build/classes/CM3033Tests/ClientApp.class b/build/classes/CM3033Tests/ClientApp.class
old mode 100644
new mode 100755
index 4e0bcd7..a221e4b
Binary files a/build/classes/CM3033Tests/ClientApp.class and b/build/classes/CM3033Tests/ClientApp.class differ
diff --git a/build/classes/CM3033Tests/DataShare.class b/build/classes/CM3033Tests/DataShare.class
new file mode 100755
index 0000000..d10c57b
Binary files /dev/null and b/build/classes/CM3033Tests/DataShare.class differ
diff --git a/build/classes/CM3033Tests/Server.class b/build/classes/CM3033Tests/Server.class
old mode 100644
new mode 100755
index 4a11730..a6dc405
Binary files a/build/classes/CM3033Tests/Server.class and b/build/classes/CM3033Tests/Server.class differ
diff --git a/build/classes/CM3033Tests/ServerApp$1.class b/build/classes/CM3033Tests/ServerApp$1.class
new file mode 100755
index 0000000..a2e0edc
Binary files /dev/null and b/build/classes/CM3033Tests/ServerApp$1.class differ
diff --git a/build/classes/CM3033Tests/ServerApp$2.class b/build/classes/CM3033Tests/ServerApp$2.class
new file mode 100755
index 0000000..cfcc4a4
Binary files /dev/null and b/build/classes/CM3033Tests/ServerApp$2.class differ
diff --git a/build/classes/CM3033Tests/ServerApp.class b/build/classes/CM3033Tests/ServerApp.class
new file mode 100755
index 0000000..fd67fad
Binary files /dev/null and b/build/classes/CM3033Tests/ServerApp.class differ
diff --git a/build/classes/CM3033Tests/StartServer.class b/build/classes/CM3033Tests/StartServer.class
old mode 100644
new mode 100755
index dcdc212..540210b
Binary files a/build/classes/CM3033Tests/StartServer.class and b/build/classes/CM3033Tests/StartServer.class differ
diff --git a/build/classes/CM3033Tests/Test1.class b/build/classes/CM3033Tests/Test1.class
deleted file mode 100644
index f43fc8d..0000000
Binary files a/build/classes/CM3033Tests/Test1.class and /dev/null differ
diff --git a/build/classes/CM3033Tests/TestClientStart.class b/build/classes/CM3033Tests/TestClientStart.class
old mode 100644
new mode 100755
index 1e18af2..489fc85
Binary files a/build/classes/CM3033Tests/TestClientStart.class and b/build/classes/CM3033Tests/TestClientStart.class differ
diff --git a/build/classes/cm3033/lab2/ex3/Alarm.class b/build/classes/cm3033/lab2/ex3/Alarm.class
deleted file mode 100644
index 2a876b4..0000000
Binary files a/build/classes/cm3033/lab2/ex3/Alarm.class and /dev/null differ
diff --git a/build/classes/cm3033/lab2/ex3/Client.class b/build/classes/cm3033/lab2/ex3/Client.class
deleted file mode 100644
index a59ed1b..0000000
Binary files a/build/classes/cm3033/lab2/ex3/Client.class and /dev/null differ
diff --git a/build/classes/cm3033/lab2/ex3/ClientApp$1.class b/build/classes/cm3033/lab2/ex3/ClientApp$1.class
deleted file mode 100644
index abb0395..0000000
Binary files a/build/classes/cm3033/lab2/ex3/ClientApp$1.class and /dev/null differ
diff --git a/build/classes/cm3033/lab2/ex3/ClientApp$2.class b/build/classes/cm3033/lab2/ex3/ClientApp$2.class
deleted file mode 100644
index a12efde..0000000
Binary files a/build/classes/cm3033/lab2/ex3/ClientApp$2.class and /dev/null differ
diff --git a/build/classes/cm3033/lab2/ex3/ClientApp$3.class b/build/classes/cm3033/lab2/ex3/ClientApp$3.class
deleted file mode 100644
index 0b9c789..0000000
Binary files a/build/classes/cm3033/lab2/ex3/ClientApp$3.class and /dev/null differ
diff --git a/build/classes/cm3033/lab2/ex3/ClientApp$4.class b/build/classes/cm3033/lab2/ex3/ClientApp$4.class
deleted file mode 100644
index 6bcdfe3..0000000
Binary files a/build/classes/cm3033/lab2/ex3/ClientApp$4.class and /dev/null differ
diff --git a/build/classes/cm3033/lab2/ex3/ClientApp$5.class b/build/classes/cm3033/lab2/ex3/ClientApp$5.class
deleted file mode 100644
index 0759413..0000000
Binary files a/build/classes/cm3033/lab2/ex3/ClientApp$5.class and /dev/null differ
diff --git a/build/classes/cm3033/lab2/ex3/ClientApp$6.class b/build/classes/cm3033/lab2/ex3/ClientApp$6.class
deleted file mode 100644
index 08e6aec..0000000
Binary files a/build/classes/cm3033/lab2/ex3/ClientApp$6.class and /dev/null differ
diff --git a/build/classes/cm3033/lab2/ex3/ClientApp$7.class b/build/classes/cm3033/lab2/ex3/ClientApp$7.class
deleted file mode 100644
index b032c01..0000000
Binary files a/build/classes/cm3033/lab2/ex3/ClientApp$7.class and /dev/null differ
diff --git a/build/classes/cm3033/lab2/ex3/ClientApp.class b/build/classes/cm3033/lab2/ex3/ClientApp.class
deleted file mode 100644
index d7f8445..0000000
Binary files a/build/classes/cm3033/lab2/ex3/ClientApp.class and /dev/null differ
diff --git a/build/classes/cm3033/lab2/ex3/HeartBeat.class b/build/classes/cm3033/lab2/ex3/HeartBeat.class
deleted file mode 100644
index ecb77fa..0000000
Binary files a/build/classes/cm3033/lab2/ex3/HeartBeat.class and /dev/null differ
diff --git a/build/classes/cm3033/lab2/ex3/MainAppEx3.class b/build/classes/cm3033/lab2/ex3/MainAppEx3.class
deleted file mode 100644
index e1ea1a0..0000000
Binary files a/build/classes/cm3033/lab2/ex3/MainAppEx3.class and /dev/null differ
diff --git a/build/classes/cm3033/lab2/ex3/Server.class b/build/classes/cm3033/lab2/ex3/Server.class
deleted file mode 100644
index 820339c..0000000
Binary files a/build/classes/cm3033/lab2/ex3/Server.class and /dev/null differ
diff --git a/build/classes/cm3033/lab2/ex3/ServerApp$1.class b/build/classes/cm3033/lab2/ex3/ServerApp$1.class
deleted file mode 100644
index f16ec60..0000000
Binary files a/build/classes/cm3033/lab2/ex3/ServerApp$1.class and /dev/null differ
diff --git a/build/classes/cm3033/lab2/ex3/ServerApp$2.class b/build/classes/cm3033/lab2/ex3/ServerApp$2.class
deleted file mode 100644
index bb2be91..0000000
Binary files a/build/classes/cm3033/lab2/ex3/ServerApp$2.class and /dev/null differ
diff --git a/build/classes/cm3033/lab2/ex3/ServerApp.class b/build/classes/cm3033/lab2/ex3/ServerApp.class
deleted file mode 100644
index 164ec8f..0000000
Binary files a/build/classes/cm3033/lab2/ex3/ServerApp.class and /dev/null differ
diff --git a/manifest.mf b/manifest.mf
old mode 100644
new mode 100755
diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml
old mode 100644
new mode 100755
diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties
old mode 100644
new mode 100755
diff --git a/nbproject/private/private.properties b/nbproject/private/private.properties
old mode 100644
new mode 100755
index 94991e0..56acf35
--- a/nbproject/private/private.properties
+++ b/nbproject/private/private.properties
@@ -1 +1 @@
-user.properties.file=/Users/samc/Library/Application Support/NetBeans/7.4/build.properties
+user.properties.file=C:\\TEMP\\netbeans-settings\\build.properties
diff --git a/nbproject/private/private.xml b/nbproject/private/private.xml
old mode 100644
new mode 100755
index b90240a..b00184c
--- a/nbproject/private/private.xml
+++ b/nbproject/private/private.xml
@@ -3,10 +3,11 @@
- file:/Users/samc/Desktop/CM3033/src/CM3033Tests/StartServer.java
- file:/Users/samc/Desktop/CM3033/src/CM3033Tests/TestClientStart.java
- file:/Users/samc/Desktop/CM3033/src/CM3033Tests/Server.java
- file:/Users/samc/Desktop/CM3033/src/CM3033Tests/Test1.java
+ file:/C:/Users/Mazzy/Documents/GitHub/CM3033/src/CM3033Tests/Client.java
+ file:/C:/Users/Mazzy/Documents/GitHub/CM3033/src/CM3033Tests/ClientApp.java
+ file:/C:/Users/Mazzy/Documents/GitHub/CM3033/src/CM3033Tests/Server.java
+ file:/C:/Users/Mazzy/Documents/GitHub/CM3033/src/CM3033Tests/StartServer.java
+ file:/C:/Users/Mazzy/Documents/GitHub/CM3033/src/CM3033Tests/TestClientStart.java
diff --git a/nbproject/project.properties b/nbproject/project.properties
old mode 100644
new mode 100755
index 6c77b5b..c057382
--- a/nbproject/project.properties
+++ b/nbproject/project.properties
@@ -51,7 +51,7 @@ javadoc.splitindex=true
javadoc.use=true
javadoc.version=false
javadoc.windowtitle=
-main.class=cm3033.lab2.ex3.MainAppEx3
+main.class=CM3033Tests.StartServer
manifest.file=manifest.mf
meta.inf.dir=${src.dir}/META-INF
mkdist.disabled=false
diff --git a/nbproject/project.xml b/nbproject/project.xml
old mode 100644
new mode 100755
diff --git a/src/CM3033Tests/Client.java b/src/CM3033Tests/Client.java
old mode 100644
new mode 100755
index 802a69f..d7afe99
--- a/src/CM3033Tests/Client.java
+++ b/src/CM3033Tests/Client.java
@@ -99,6 +99,7 @@ public void run() {
if (!sendStr.equals(oldSendStr)) {
// Send the message
sendMessage(sendStr);
+ sendMessage("BPM:200"); //for the testing purposes
// Set the sent message record
oldSendStr = sendStr;
// Take 1 from message count as one has been sent
diff --git a/src/CM3033Tests/ClientApp.form b/src/CM3033Tests/ClientApp.form
old mode 100644
new mode 100755
diff --git a/src/CM3033Tests/ClientApp.java b/src/CM3033Tests/ClientApp.java
old mode 100644
new mode 100755
diff --git a/src/CM3033Tests/DataShare.java b/src/CM3033Tests/DataShare.java
old mode 100644
new mode 100755
diff --git a/src/CM3033Tests/MyRejectedExecutionHandlerImpl.java b/src/CM3033Tests/MyRejectedExecutionHandlerImpl.java
new file mode 100755
index 0000000..c2172e1
--- /dev/null
+++ b/src/CM3033Tests/MyRejectedExecutionHandlerImpl.java
@@ -0,0 +1,22 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package CM3033Tests;
+
+import java.util.concurrent.RejectedExecutionHandler;
+import java.util.concurrent.ThreadPoolExecutor;
+
+/**
+ *
+ * @author 1014481
+ */
+public class MyRejectedExecutionHandlerImpl implements RejectedExecutionHandler {
+ @Override
+ public void rejectedExecution(Runnable runnable,
+ ThreadPoolExecutor executor)
+ {
+ System.out.println(runnable.toString() + " : I've been rejected ! ");
+ }
+}
+
diff --git a/src/CM3033Tests/Server.java b/src/CM3033Tests/Server.java
old mode 100644
new mode 100755
index c16bf03..ebb3eef
--- a/src/CM3033Tests/Server.java
+++ b/src/CM3033Tests/Server.java
@@ -19,20 +19,26 @@ public class Server implements Runnable {
// store the incoming connection
private Socket incoming;
private int number;
+ private ServerApp serverApp;
// Create the server using the passed incoming code
- public Server(Socket incoming, int no) {
+ public Server(Socket incoming, int no, ServerApp serverApp) {
// Set this's incoming to the passed on
this.incoming = incoming;
this.number = no;
+ this.serverApp = serverApp; //@ MS
+
}
-
+
@Override
public void run() {
+
try {
+ //serverApp.setVisible(true); //@ MS
// Configure the listener/sender
BufferedReader in = new BufferedReader(new InputStreamReader(incoming.getInputStream()));
PrintWriter out = new PrintWriter(incoming.getOutputStream(), true /* auto flush */);
+
// Once connected, let the user know so by printing the details
out.println(number + " You are connected to "
+ incoming.getLocalAddress().getHostName()
@@ -42,7 +48,12 @@ public void run() {
System.out.println(incoming.getLocalAddress().getHostName() + " Connected " + number);
// A boolean to store a while variable
boolean finished = false;
+ int bpm = 0;
while (!finished) {
+ bpm++;
+ serverApp.updateBPM(number, bpm);
+ serverApp.updateConnected(number);
+
// if the listener is ready
if (in.ready()) {
// create a String to store the sent data
@@ -50,10 +61,11 @@ public void run() {
// If the string is not null
if (str != null) {
// Send the receive value back to the client
- out.println("Recieved: " + str);
+ out.println("Received: " + str);
// Print the recieve value
- System.out.println("Recieved: " + str);
+ System.out.println("Receieved: " + str);
// If the string is bye
+ //processInput(str);
if (str.trim().equals("BYE")) {
// Print that machine is disconnecting
System.out.println(incoming.getLocalAddress().getHostName() + " Disconnected");
@@ -64,6 +76,7 @@ public void run() {
}
}
// Disconnect the client
+ serverApp.disconnect(number);
incoming.close();
} catch (IOException e) {
System.out.println(e);
diff --git a/src/CM3033Tests/ServerApp.form b/src/CM3033Tests/ServerApp.form
new file mode 100755
index 0000000..f243f7d
--- /dev/null
+++ b/src/CM3033Tests/ServerApp.form
@@ -0,0 +1,903 @@
+
+
+
diff --git a/src/CM3033Tests/ServerApp.java b/src/CM3033Tests/ServerApp.java
new file mode 100755
index 0000000..7f43cce
--- /dev/null
+++ b/src/CM3033Tests/ServerApp.java
@@ -0,0 +1,909 @@
+package CM3033Tests;
+
+import java.awt.Component;
+import java.io.IOException;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import javax.swing.JOptionPane;
+
+/**
+ *
+ * @author Marina Shchukina 1014481
+ * @rgu.ac.uk
+ */
+public class ServerApp extends javax.swing.JFrame implements Runnable {
+
+ ////////////////////////////
+ ////// VARIABLES ///////
+ ////////////////////////////
+ // variable to store the maxLimit and minLimit
+ private int highValue, lowValue;
+ // variables to store the oldMaxLimit and oldMinLimit
+ private int oldHighValue = highValue, oldLowValue = lowValue;
+ // A date format template
+ final DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
+ // A calendar to store the time of now and the time the application was started
+ Calendar now = null, start = Calendar.getInstance();
+ // Variable to store the Shared Data class
+ DataShare dataShare;
+
+ ////////////////////////////
+ ////// CONSTRUCTOR ///////
+ ////////////////////////////
+ public ServerApp() throws IOException {
+ // Initialise the components
+ initComponents();
+
+ // set the data share to that passed to this class
+ //dataShare = ds2;
+
+ // Reset the max and min value dropdowns
+ //maxValue.removeAllItems();
+ //minValue.removeAllItems();
+
+ // Add the options to the max/min
+ /*maxValue.addItem(40);
+ maxValue.addItem(60);
+ maxValue.addItem(80);
+ maxValue.addItem(100);
+ maxValue.addItem(120);
+ maxValue.addItem(140);
+ maxValue.addItem(160);
+ maxValue.addItem(180);
+ maxValue.addItem(200);
+ minValue.addItem(20);
+ minValue.addItem(40);
+ minValue.addItem(60);
+ minValue.addItem(80);
+ minValue.addItem(100);
+ minValue.addItem(120);
+ minValue.addItem(140);
+ minValue.addItem(160);
+ minValue.addItem(180);*/
+
+ }
+
+ /**
+ * This method is called from within the constructor to initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is always
+ * regenerated by the Form Editor.
+ */
+ @SuppressWarnings("unchecked")
+ // //GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ topPanel = new javax.swing.JPanel();
+ jSeparator2 = new javax.swing.JSeparator();
+ jLabel1 = new javax.swing.JLabel();
+ jCheckBox1 = new javax.swing.JCheckBox();
+ jCheckBox2 = new javax.swing.JCheckBox();
+ jCheckBox3 = new javax.swing.JCheckBox();
+ jCheckBox4 = new javax.swing.JCheckBox();
+ Connection1 = new javax.swing.JPanel();
+ bpmLabel1 = new javax.swing.JLabel();
+ bpmValue1 = new javax.swing.JLabel();
+ lastUpdateLabel1 = new javax.swing.JLabel();
+ lastUpdateValue1 = new javax.swing.JTextField();
+ maxLabel1 = new javax.swing.JLabel();
+ minLabel1 = new javax.swing.JLabel();
+ maxValue1 = new javax.swing.JLabel();
+ minValue1 = new javax.swing.JLabel();
+ alarmLog1 = new javax.swing.JScrollPane();
+ Connection2 = new javax.swing.JPanel();
+ bpmLabel2 = new javax.swing.JLabel();
+ bpmValue2 = new javax.swing.JLabel();
+ lastUpdateLabel2 = new javax.swing.JLabel();
+ lastUpdateValue2 = new javax.swing.JTextField();
+ maxLabel2 = new javax.swing.JLabel();
+ minLabel2 = new javax.swing.JLabel();
+ maxValue2 = new javax.swing.JLabel();
+ minValue2 = new javax.swing.JLabel();
+ alarmLog2 = new javax.swing.JScrollPane();
+ Connection3 = new javax.swing.JPanel();
+ bpmLabel3 = new javax.swing.JLabel();
+ bpmValue3 = new javax.swing.JLabel();
+ lastUpdateLabel3 = new javax.swing.JLabel();
+ lastUpdateValue3 = new javax.swing.JTextField();
+ maxLabel3 = new javax.swing.JLabel();
+ minLabel3 = new javax.swing.JLabel();
+ maxValue3 = new javax.swing.JLabel();
+ minValue3 = new javax.swing.JLabel();
+ alarmLog3 = new javax.swing.JScrollPane();
+ Connection4 = new javax.swing.JPanel();
+ bpmLabel4 = new javax.swing.JLabel();
+ bpmValue4 = new javax.swing.JLabel();
+ lastUpdateLabel4 = new javax.swing.JLabel();
+ lastUpdateValue4 = new javax.swing.JTextField();
+ maxLabel4 = new javax.swing.JLabel();
+ minLabel4 = new javax.swing.JLabel();
+ maxValue4 = new javax.swing.JLabel();
+ minValue4 = new javax.swing.JLabel();
+ alarmLog4 = new javax.swing.JScrollPane();
+ alarmButtons = new javax.swing.JPanel();
+ jButton1 = new javax.swing.JButton();
+ jButton2 = new javax.swing.JButton();
+ jButton3 = new javax.swing.JButton();
+ jButton4 = new javax.swing.JButton();
+ elapsedTimeValue = new javax.swing.JLabel();
+ currentTimeValue = new javax.swing.JLabel();
+ elapsedTime = new javax.swing.JLabel();
+ jScrollPane1 = new javax.swing.JScrollPane();
+ currentTime = new javax.swing.JLabel();
+
+ setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
+
+ jLabel1.setText("Connections");
+
+ jCheckBox1.setText("Patient 1");
+ jCheckBox1.setEnabled(false);
+ jCheckBox1.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ jCheckBox1ActionPerformed(evt);
+ }
+ });
+
+ jCheckBox2.setText("Patient 2");
+ jCheckBox2.setEnabled(false);
+ jCheckBox2.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ jCheckBox2ActionPerformed(evt);
+ }
+ });
+
+ jCheckBox3.setText("Patient 3");
+ jCheckBox3.setEnabled(false);
+ jCheckBox3.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ jCheckBox3ActionPerformed(evt);
+ }
+ });
+
+ jCheckBox4.setText("Patient 4");
+ jCheckBox4.setEnabled(false);
+ jCheckBox4.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ jCheckBox4ActionPerformed(evt);
+ }
+ });
+
+ javax.swing.GroupLayout topPanelLayout = new javax.swing.GroupLayout(topPanel);
+ topPanel.setLayout(topPanelLayout);
+ topPanelLayout.setHorizontalGroup(
+ topPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(topPanelLayout.createSequentialGroup()
+ .addGroup(topPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
+ .addGroup(topPanelLayout.createSequentialGroup()
+ .addContainerGap()
+ .addComponent(jLabel1)
+ .addGap(18, 18, 18)
+ .addComponent(jCheckBox1)
+ .addGap(29, 29, 29)
+ .addComponent(jCheckBox2)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(jCheckBox3)
+ .addGap(39, 39, 39)
+ .addComponent(jCheckBox4)
+ .addGap(198, 198, 198))
+ .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 681, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addGap(0, 0, Short.MAX_VALUE))
+ );
+ topPanelLayout.setVerticalGroup(
+ topPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(topPanelLayout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(topPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(jLabel1)
+ .addComponent(jCheckBox1)
+ .addComponent(jCheckBox2)
+ .addComponent(jCheckBox3)
+ .addComponent(jCheckBox4))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 14, Short.MAX_VALUE)
+ .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE))
+ );
+
+ Connection1.setBorder(javax.swing.BorderFactory.createTitledBorder(""));
+ Connection1.setName("Patient 1"); // NOI18N
+
+ bpmLabel1.setFont(new java.awt.Font("Arial", 1, 15)); // NOI18N
+ bpmLabel1.setText("Patient's 1 BPM:");
+
+ bpmValue1.setFont(new java.awt.Font("Arial", 0, 20)); // NOI18N
+ bpmValue1.setForeground(new java.awt.Color(45, 2, 208));
+ bpmValue1.setText("Not Connected");
+
+ lastUpdateLabel1.setFont(new java.awt.Font("Arial", 1, 15)); // NOI18N
+ lastUpdateLabel1.setText("Last update:");
+
+ lastUpdateValue1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
+ lastUpdateValue1.setEnabled(false);
+
+ maxLabel1.setFont(new java.awt.Font("Arial", 1, 15)); // NOI18N
+ maxLabel1.setText("Max:");
+
+ minLabel1.setFont(new java.awt.Font("Arial", 1, 15)); // NOI18N
+ minLabel1.setText("Min:");
+
+ maxValue1.setFont(new java.awt.Font("Arial", 0, 15)); // NOI18N
+ maxValue1.setText("60");
+
+ minValue1.setFont(new java.awt.Font("Arial", 0, 15)); // NOI18N
+ minValue1.setText("120");
+
+ alarmLog1.setToolTipText("");
+ alarmLog1.setAutoscrolls(true);
+ alarmLog1.setFont(new java.awt.Font("Arial", 0, 15)); // NOI18N
+ alarmLog1.setName("Alarm Log"); // NOI18N
+
+ javax.swing.GroupLayout Connection1Layout = new javax.swing.GroupLayout(Connection1);
+ Connection1.setLayout(Connection1Layout);
+ Connection1Layout.setHorizontalGroup(
+ Connection1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, Connection1Layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(Connection1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
+ .addComponent(alarmLog1)
+ .addGroup(javax.swing.GroupLayout.Alignment.LEADING, Connection1Layout.createSequentialGroup()
+ .addComponent(maxLabel1)
+ .addGap(28, 28, 28)
+ .addComponent(maxValue1)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(minLabel1)
+ .addGap(18, 18, 18)
+ .addComponent(minValue1))
+ .addGroup(javax.swing.GroupLayout.Alignment.LEADING, Connection1Layout.createSequentialGroup()
+ .addComponent(bpmLabel1)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(bpmValue1))
+ .addGroup(javax.swing.GroupLayout.Alignment.LEADING, Connection1Layout.createSequentialGroup()
+ .addComponent(lastUpdateLabel1)
+ .addGap(6, 6, 6)
+ .addComponent(lastUpdateValue1, javax.swing.GroupLayout.DEFAULT_SIZE, 276, Short.MAX_VALUE)))
+ .addContainerGap())
+ );
+ Connection1Layout.setVerticalGroup(
+ Connection1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(Connection1Layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(Connection1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(bpmLabel1)
+ .addComponent(bpmValue1))
+ .addGap(11, 11, 11)
+ .addGroup(Connection1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(lastUpdateLabel1)
+ .addComponent(lastUpdateValue1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addGap(22, 22, 22)
+ .addGroup(Connection1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(Connection1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(maxLabel1)
+ .addComponent(maxValue1))
+ .addGroup(Connection1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(minLabel1)
+ .addComponent(minValue1)))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+ .addComponent(alarmLog1, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addContainerGap(20, Short.MAX_VALUE))
+ );
+
+ alarmLog1.getAccessibleContext().setAccessibleName("Alarm log");
+
+ Connection2.setBorder(javax.swing.BorderFactory.createTitledBorder(""));
+ Connection2.setName("Patient 1"); // NOI18N
+
+ bpmLabel2.setFont(new java.awt.Font("Arial", 1, 15)); // NOI18N
+ bpmLabel2.setText("Patient's 2 BPM:");
+
+ bpmValue2.setFont(new java.awt.Font("Arial", 0, 20)); // NOI18N
+ bpmValue2.setForeground(new java.awt.Color(45, 2, 208));
+ bpmValue2.setText("Not Connected");
+
+ lastUpdateLabel2.setFont(new java.awt.Font("Arial", 1, 15)); // NOI18N
+ lastUpdateLabel2.setText("Last update:");
+
+ lastUpdateValue2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
+ lastUpdateValue2.setEnabled(false);
+
+ maxLabel2.setFont(new java.awt.Font("Arial", 1, 15)); // NOI18N
+ maxLabel2.setText("Max:");
+
+ minLabel2.setFont(new java.awt.Font("Arial", 1, 15)); // NOI18N
+ minLabel2.setText("Min:");
+
+ maxValue2.setFont(new java.awt.Font("Arial", 0, 15)); // NOI18N
+ maxValue2.setText("60");
+
+ minValue2.setFont(new java.awt.Font("Arial", 0, 15)); // NOI18N
+ minValue2.setText("120");
+
+ alarmLog2.setToolTipText("");
+ alarmLog2.setAutoscrolls(true);
+ alarmLog2.setFont(new java.awt.Font("Arial", 0, 15)); // NOI18N
+ alarmLog2.setName("Alarm Log"); // NOI18N
+
+ javax.swing.GroupLayout Connection2Layout = new javax.swing.GroupLayout(Connection2);
+ Connection2.setLayout(Connection2Layout);
+ Connection2Layout.setHorizontalGroup(
+ Connection2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, Connection2Layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(Connection2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
+ .addComponent(alarmLog2)
+ .addGroup(javax.swing.GroupLayout.Alignment.LEADING, Connection2Layout.createSequentialGroup()
+ .addComponent(maxLabel2)
+ .addGap(28, 28, 28)
+ .addComponent(maxValue2)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(minLabel2)
+ .addGap(18, 18, 18)
+ .addComponent(minValue2))
+ .addGroup(javax.swing.GroupLayout.Alignment.LEADING, Connection2Layout.createSequentialGroup()
+ .addComponent(bpmLabel2)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(bpmValue2))
+ .addGroup(javax.swing.GroupLayout.Alignment.LEADING, Connection2Layout.createSequentialGroup()
+ .addComponent(lastUpdateLabel2)
+ .addGap(6, 6, 6)
+ .addComponent(lastUpdateValue2, javax.swing.GroupLayout.DEFAULT_SIZE, 294, Short.MAX_VALUE)))
+ .addContainerGap())
+ );
+ Connection2Layout.setVerticalGroup(
+ Connection2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(Connection2Layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(Connection2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(bpmLabel2)
+ .addComponent(bpmValue2))
+ .addGap(11, 11, 11)
+ .addGroup(Connection2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(lastUpdateLabel2)
+ .addComponent(lastUpdateValue2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addGap(22, 22, 22)
+ .addGroup(Connection2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(Connection2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(maxLabel2)
+ .addComponent(maxValue2))
+ .addGroup(Connection2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(minLabel2)
+ .addComponent(minValue2)))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+ .addComponent(alarmLog2, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ );
+
+ Connection3.setBorder(javax.swing.BorderFactory.createTitledBorder(""));
+ Connection3.setName("Patient 1"); // NOI18N
+
+ bpmLabel3.setFont(new java.awt.Font("Arial", 1, 15)); // NOI18N
+ bpmLabel3.setText("Patient's 3 BPM:");
+
+ bpmValue3.setFont(new java.awt.Font("Arial", 0, 20)); // NOI18N
+ bpmValue3.setForeground(new java.awt.Color(45, 2, 208));
+ bpmValue3.setText("Not Connected");
+
+ lastUpdateLabel3.setFont(new java.awt.Font("Arial", 1, 15)); // NOI18N
+ lastUpdateLabel3.setText("Last update:");
+
+ lastUpdateValue3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
+ lastUpdateValue3.setEnabled(false);
+ lastUpdateValue3.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ lastUpdateValue3ActionPerformed(evt);
+ }
+ });
+
+ maxLabel3.setFont(new java.awt.Font("Arial", 1, 15)); // NOI18N
+ maxLabel3.setText("Max:");
+
+ minLabel3.setFont(new java.awt.Font("Arial", 1, 15)); // NOI18N
+ minLabel3.setText("Min:");
+
+ maxValue3.setFont(new java.awt.Font("Arial", 0, 15)); // NOI18N
+ maxValue3.setText("60");
+
+ minValue3.setFont(new java.awt.Font("Arial", 0, 15)); // NOI18N
+ minValue3.setText("120");
+
+ alarmLog3.setToolTipText("");
+ alarmLog3.setAutoscrolls(true);
+ alarmLog3.setFont(new java.awt.Font("Arial", 0, 15)); // NOI18N
+ alarmLog3.setName("Alarm Log"); // NOI18N
+
+ javax.swing.GroupLayout Connection3Layout = new javax.swing.GroupLayout(Connection3);
+ Connection3.setLayout(Connection3Layout);
+ Connection3Layout.setHorizontalGroup(
+ Connection3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, Connection3Layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(Connection3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
+ .addComponent(alarmLog3)
+ .addGroup(javax.swing.GroupLayout.Alignment.LEADING, Connection3Layout.createSequentialGroup()
+ .addComponent(maxLabel3)
+ .addGap(28, 28, 28)
+ .addComponent(maxValue3)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(minLabel3)
+ .addGap(18, 18, 18)
+ .addComponent(minValue3))
+ .addGroup(javax.swing.GroupLayout.Alignment.LEADING, Connection3Layout.createSequentialGroup()
+ .addComponent(bpmLabel3)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(bpmValue3))
+ .addGroup(javax.swing.GroupLayout.Alignment.LEADING, Connection3Layout.createSequentialGroup()
+ .addComponent(lastUpdateLabel3)
+ .addGap(6, 6, 6)
+ .addComponent(lastUpdateValue3, javax.swing.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE)))
+ .addContainerGap())
+ );
+ Connection3Layout.setVerticalGroup(
+ Connection3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(Connection3Layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(Connection3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(bpmLabel3)
+ .addComponent(bpmValue3))
+ .addGap(11, 11, 11)
+ .addGroup(Connection3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(lastUpdateLabel3)
+ .addComponent(lastUpdateValue3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addGap(22, 22, 22)
+ .addGroup(Connection3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(Connection3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(maxLabel3)
+ .addComponent(maxValue3))
+ .addGroup(Connection3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(minLabel3)
+ .addComponent(minValue3)))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+ .addComponent(alarmLog3, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addContainerGap(20, Short.MAX_VALUE))
+ );
+
+ Connection4.setBorder(javax.swing.BorderFactory.createTitledBorder(""));
+ Connection4.setName("Patient 1"); // NOI18N
+
+ bpmLabel4.setFont(new java.awt.Font("Arial", 1, 15)); // NOI18N
+ bpmLabel4.setText("Patient's 4 BPM:");
+
+ bpmValue4.setFont(new java.awt.Font("Arial", 0, 20)); // NOI18N
+ bpmValue4.setForeground(new java.awt.Color(45, 2, 208));
+ bpmValue4.setText("Not Connected");
+
+ lastUpdateLabel4.setFont(new java.awt.Font("Arial", 1, 15)); // NOI18N
+ lastUpdateLabel4.setText("Last update:");
+
+ lastUpdateValue4.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
+ lastUpdateValue4.setEnabled(false);
+
+ maxLabel4.setFont(new java.awt.Font("Arial", 1, 15)); // NOI18N
+ maxLabel4.setText("Max:");
+
+ minLabel4.setFont(new java.awt.Font("Arial", 1, 15)); // NOI18N
+ minLabel4.setText("Min:");
+
+ maxValue4.setFont(new java.awt.Font("Arial", 0, 15)); // NOI18N
+ maxValue4.setText("60");
+
+ minValue4.setFont(new java.awt.Font("Arial", 0, 15)); // NOI18N
+ minValue4.setText("120");
+
+ alarmLog4.setToolTipText("");
+ alarmLog4.setAutoscrolls(true);
+ alarmLog4.setFont(new java.awt.Font("Arial", 0, 15)); // NOI18N
+ alarmLog4.setName("Alarm Log"); // NOI18N
+
+ javax.swing.GroupLayout Connection4Layout = new javax.swing.GroupLayout(Connection4);
+ Connection4.setLayout(Connection4Layout);
+ Connection4Layout.setHorizontalGroup(
+ Connection4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, Connection4Layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(Connection4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
+ .addComponent(alarmLog4)
+ .addGroup(javax.swing.GroupLayout.Alignment.LEADING, Connection4Layout.createSequentialGroup()
+ .addComponent(maxLabel4)
+ .addGap(28, 28, 28)
+ .addComponent(maxValue4)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(minLabel4)
+ .addGap(18, 18, 18)
+ .addComponent(minValue4))
+ .addGroup(javax.swing.GroupLayout.Alignment.LEADING, Connection4Layout.createSequentialGroup()
+ .addComponent(bpmLabel4)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(bpmValue4))
+ .addGroup(javax.swing.GroupLayout.Alignment.LEADING, Connection4Layout.createSequentialGroup()
+ .addComponent(lastUpdateLabel4)
+ .addGap(6, 6, 6)
+ .addComponent(lastUpdateValue4, javax.swing.GroupLayout.DEFAULT_SIZE, 276, Short.MAX_VALUE)))
+ .addContainerGap())
+ );
+ Connection4Layout.setVerticalGroup(
+ Connection4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(Connection4Layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(Connection4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(bpmLabel4)
+ .addComponent(bpmValue4))
+ .addGap(11, 11, 11)
+ .addGroup(Connection4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(lastUpdateLabel4)
+ .addComponent(lastUpdateValue4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addGap(22, 22, 22)
+ .addGroup(Connection4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(Connection4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(maxLabel4)
+ .addComponent(maxValue4))
+ .addGroup(Connection4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(minLabel4)
+ .addComponent(minValue4)))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+ .addComponent(alarmLog4, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ );
+
+ jButton1.setText("Turn off alarm 1");
+
+ jButton2.setText("Turn off alarm 2");
+
+ jButton3.setText("Turn off alarm 3");
+ jButton3.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ jButton3ActionPerformed(evt);
+ }
+ });
+
+ jButton4.setText("Turn off alarm 4");
+ jButton4.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ jButton4ActionPerformed(evt);
+ }
+ });
+
+ javax.swing.GroupLayout alarmButtonsLayout = new javax.swing.GroupLayout(alarmButtons);
+ alarmButtons.setLayout(alarmButtonsLayout);
+ alarmButtonsLayout.setHorizontalGroup(
+ alarmButtonsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(alarmButtonsLayout.createSequentialGroup()
+ .addGap(30, 30, 30)
+ .addComponent(jButton1)
+ .addGap(108, 108, 108)
+ .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addGap(98, 98, 98)
+ .addComponent(jButton3)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 92, Short.MAX_VALUE)
+ .addComponent(jButton4)
+ .addGap(27, 27, 27))
+ );
+ alarmButtonsLayout.setVerticalGroup(
+ alarmButtonsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(alarmButtonsLayout.createSequentialGroup()
+ .addGap(32, 32, 32)
+ .addGroup(alarmButtonsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(jButton1)
+ .addComponent(jButton2)
+ .addComponent(jButton4)
+ .addComponent(jButton3))
+ .addContainerGap(63, Short.MAX_VALUE))
+ );
+
+ elapsedTimeValue.setText("00:00:00");
+
+ currentTimeValue.setText("00:00:00");
+
+ elapsedTime.setText("Elapsed Time:");
+
+ currentTime.setText("Current Time:");
+ jScrollPane1.setViewportView(currentTime);
+
+ javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
+ getContentPane().setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
+ .addGap(27, 27, 27)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
+ .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
+ .addComponent(topPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addGap(37, 37, 37)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
+ .addGroup(layout.createSequentialGroup()
+ .addComponent(elapsedTime)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(elapsedTimeValue))
+ .addGroup(layout.createSequentialGroup()
+ .addGap(0, 0, Short.MAX_VALUE)
+ .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addGap(35, 35, 35)
+ .addComponent(currentTimeValue)))
+ .addGap(18, 18, 18))
+ .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
+ .addComponent(alarmButtons, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addGap(0, 0, Short.MAX_VALUE))
+ .addGroup(layout.createSequentialGroup()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(Connection3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(Connection1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(Connection2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(Connection4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
+ .addGap(19, 19, 19))
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(topPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
+ .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(currentTimeValue))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(elapsedTime)
+ .addComponent(elapsedTimeValue))))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 34, Short.MAX_VALUE)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(Connection1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(Connection2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 210, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(Connection4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(Connection3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+ .addComponent(alarmButtons, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addContainerGap())
+ );
+
+ pack();
+ }// //GEN-END:initComponents
+
+ private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
+ // TODO add your handling code here:
+ }//GEN-LAST:event_jButton3ActionPerformed
+
+ private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
+ // TODO add your handling code here:
+ }//GEN-LAST:event_jButton4ActionPerformed
+
+ private void lastUpdateValue3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_lastUpdateValue3ActionPerformed
+ // TODO add your handling code here:
+ }//GEN-LAST:event_lastUpdateValue3ActionPerformed
+
+ private void jCheckBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox1ActionPerformed
+ // TODO add your handling code here:
+ }//GEN-LAST:event_jCheckBox1ActionPerformed
+
+ private void jCheckBox3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox3ActionPerformed
+ // TODO add your handling code here:
+ }//GEN-LAST:event_jCheckBox3ActionPerformed
+
+ private void jCheckBox2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox2ActionPerformed
+ // TODO add your handling code here:
+ }//GEN-LAST:event_jCheckBox2ActionPerformed
+
+ private void jCheckBox4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox4ActionPerformed
+ // TODO add your handling code here:
+ }//GEN-LAST:event_jCheckBox4ActionPerformed
+
+ // A method to update the time
+ public void updateTime() {
+ // set the now calander
+ now = Calendar.getInstance();
+ // get the time from the now calander
+ Date time = now.getTime();
+ // Set the time label to the selected time
+ currentTimeValue.setText(dateFormat.format(time));
+ // Set the elapsed variable to the current time minus the start time.
+ elapsedTimeValue.setText(dateFormat.format((time.getTime() - start.getTimeInMillis() - 3600000)));
+ }
+ // The method to test dropdowns
+ /*private void testDropDowns(String v) {
+ // if both max values and max strings have been initiated
+ if (maxValue.getSelectedItem() != null && maxValue.getSelectedItem().toString() != null) {
+ // if both max values and max strings have been initiated
+ if (minValue.getSelectedItem() != null && minValue.getSelectedItem().toString() != null) {
+ // Set highvalue to the value from the relative drop down
+ highValue = Integer.parseInt(maxValue.getSelectedItem().toString());
+ // Set highvalue to the value from the relative drop down
+ lowValue = Integer.parseInt(minValue.getSelectedItem().toString());
+ // If the high value is lower or equal to the min
+ if (highValue <= lowValue) {
+ switch (v) {
+ case "max":
+ // If max, set the max to the old value
+ maxValue.setSelectedItem(oldHighValue);
+ // break
+ break;
+ case "min":
+ // if min, set the min to the old value
+ minValue.setSelectedItem(oldLowValue);
+ // break
+ break;
+ }
+ // Create a frame to display the error message
+ Component frame = null;
+ // Show the error for the dropdown
+ JOptionPane.showMessageDialog(frame, "The \"Max Value\" must be more than the \"Min Value\"!");
+ } else {
+ // Else valid change
+ switch (v) {
+ case "max":
+ // set the oldMax to the new max
+ oldHighValue = highValue;
+ case "min":
+ // set the oldMin to the new min
+ oldLowValue = lowValue;
+ }
+ // Set the data share maxmin to the relevant value
+ dataShare.setMaxMin(highValue + "," + lowValue);
+ }
+ }
+ }
+ }*/
+ // A method to the configure if the client is connected or not.
+ /*public void setConnection(boolean connected) {
+ if (!connected) {
+ // If connected, disable the dropdowns
+ maxValue.setEnabled(false);
+ minValue.setEnabled(false);
+ // Set the mode lable to remote
+ opModeValue.setText("Remote");
+ // change the connect button to disconnect
+ connectionButton.setText("Disconnect");
+ } else {
+ // Set the mode label to local
+ opModeValue.setText("Local");
+ // set the disconnect button to connect
+ connectionButton.setText("Connect");
+ // enable both the dropdowns
+ maxValue.setEnabled(true);
+ minValue.setEnabled(true);
+ }
+ }*/
+ // A method to alter the text in the scrollable text box
+ /*public void alterText(String text) {
+ // Display the time the message was posted to the text area as well as the text passed
+ now = Calendar.getInstance();
+ textSpace.append(dateFormat.format(now.getTime()) + " | " + text + "\n");
+ }*/
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JPanel Connection1;
+ private javax.swing.JPanel Connection2;
+ private javax.swing.JPanel Connection3;
+ private javax.swing.JPanel Connection4;
+ private javax.swing.JPanel alarmButtons;
+ private javax.swing.JScrollPane alarmLog1;
+ private javax.swing.JScrollPane alarmLog2;
+ private javax.swing.JScrollPane alarmLog3;
+ private javax.swing.JScrollPane alarmLog4;
+ private javax.swing.JLabel bpmLabel1;
+ private javax.swing.JLabel bpmLabel2;
+ private javax.swing.JLabel bpmLabel3;
+ private javax.swing.JLabel bpmLabel4;
+ private javax.swing.JLabel bpmValue1;
+ private javax.swing.JLabel bpmValue2;
+ private javax.swing.JLabel bpmValue3;
+ private javax.swing.JLabel bpmValue4;
+ private javax.swing.JLabel currentTime;
+ private javax.swing.JLabel currentTimeValue;
+ private javax.swing.JLabel elapsedTime;
+ private javax.swing.JLabel elapsedTimeValue;
+ private javax.swing.JButton jButton1;
+ private javax.swing.JButton jButton2;
+ private javax.swing.JButton jButton3;
+ private javax.swing.JButton jButton4;
+ private javax.swing.JCheckBox jCheckBox1;
+ private javax.swing.JCheckBox jCheckBox2;
+ private javax.swing.JCheckBox jCheckBox3;
+ private javax.swing.JCheckBox jCheckBox4;
+ private javax.swing.JLabel jLabel1;
+ private javax.swing.JScrollPane jScrollPane1;
+ private javax.swing.JSeparator jSeparator2;
+ private javax.swing.JLabel lastUpdateLabel1;
+ private javax.swing.JLabel lastUpdateLabel2;
+ private javax.swing.JLabel lastUpdateLabel3;
+ private javax.swing.JLabel lastUpdateLabel4;
+ private javax.swing.JTextField lastUpdateValue1;
+ private javax.swing.JTextField lastUpdateValue2;
+ private javax.swing.JTextField lastUpdateValue3;
+ private javax.swing.JTextField lastUpdateValue4;
+ private javax.swing.JLabel maxLabel1;
+ private javax.swing.JLabel maxLabel2;
+ private javax.swing.JLabel maxLabel3;
+ private javax.swing.JLabel maxLabel4;
+ private javax.swing.JLabel maxValue1;
+ private javax.swing.JLabel maxValue2;
+ private javax.swing.JLabel maxValue3;
+ private javax.swing.JLabel maxValue4;
+ private javax.swing.JLabel minLabel1;
+ private javax.swing.JLabel minLabel2;
+ private javax.swing.JLabel minLabel3;
+ private javax.swing.JLabel minLabel4;
+ private javax.swing.JLabel minValue1;
+ private javax.swing.JLabel minValue2;
+ private javax.swing.JLabel minValue3;
+ private javax.swing.JLabel minValue4;
+ private javax.swing.JPanel topPanel;
+ // End of variables declaration//GEN-END:variables
+
+ public void updateConnected(int frameNo) {
+ switch (frameNo) {
+ case 1:
+
+ jCheckBox1.setSelected(true);
+ break;
+ case 2:
+
+ jCheckBox2.setSelected(true);
+ break;
+ case 3:
+
+ jCheckBox3.setSelected(true);
+ break;
+ case 4:
+
+ jCheckBox4.setSelected(true);
+ break;
+ default:
+ break;
+ }
+ }
+
+ public void disconnect(int frameNo) {
+ switch (frameNo) {
+ case 1:
+ jCheckBox1.setSelected(false);
+ bpmValue1.setText("Not connected");
+ break;
+ case 2:
+ jCheckBox2.setSelected(false);
+ bpmValue2.setText("Not connected");
+ break;
+ case 3:
+ jCheckBox3.setSelected(false);
+ bpmValue3.setText("Not connected");
+ break;
+ case 4:
+ jCheckBox4.setSelected(false);
+ bpmValue4.setText("Not connected");
+ break;
+ default:
+ break;
+ }
+ }
+
+ public void updateBPM(int frameNo, int bpm) {
+ switch (frameNo) {
+ case 1:
+ bpmValue1.setText("" + bpm);
+ break;
+ case 2:
+ bpmValue2.setText("" + bpm);
+ break;
+ case 3:
+ bpmValue3.setText("" + bpm);
+ break;
+ case 4:
+ bpmValue4.setText("" + bpm);
+ break;
+ default:
+ break;
+ }
+ }
+
+ public void updateMaxMin(int frameNo, int max, int min) {
+ }
+
+ @Override
+ public void run() {
+ // Show the GUI
+ setVisible(true);
+ // Update the time in near real time
+ while (true) {
+ updateTime();
+ }
+ }
+}
diff --git a/src/CM3033Tests/StartServer.java b/src/CM3033Tests/StartServer.java
old mode 100644
new mode 100755
index 4bb7c26..750a7b8
--- a/src/CM3033Tests/StartServer.java
+++ b/src/CM3033Tests/StartServer.java
@@ -1,13 +1,10 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
package CM3033Tests;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
@@ -15,18 +12,29 @@
*
* @author Sam Cusson 1006286
*/
+
public class StartServer {
+
- public static void main(String[] args) {
+ public static void main(String[] args) throws IOException {
// Set the thread size
int tpSize = 4;
+ int count = 1; //@MS
+
+ RejectedExecutionHandler executionHandler = new MyRejectedExecutionHandlerImpl();
// Start the thread pool
ThreadPoolExecutor pool = new ThreadPoolExecutor(
tpSize,
tpSize,
50000L,
TimeUnit.MILLISECONDS,
- new LinkedBlockingQueue());
+ new LinkedBlockingQueue(),
+ executionHandler
+ );
+
+ ServerApp serverApp = new ServerApp(); //@MS
+ Thread serverGUI = new Thread(serverApp); //@MS
+
try {
// Try start the server on port 8189
ServerSocket socketServer = new ServerSocket(8189);
@@ -34,13 +42,15 @@ public static void main(String[] args) {
System.out.println("Server>Waiting For Clients...");
// listen for a connection request on SocketServer
// incoming is the connection socket
+ serverGUI.start(); //@MS
for (;;) {
- // Accecpt the requested connection if there are less than 4 active threads
+ // Acccept the requested connection if there are less than 4 active threads
Socket incoming = socketServer.accept();
// Start a server instance using the incoming conncetion
- pool.execute(new Server(incoming,pool.getPoolSize()));
-
+ pool.execute(new Server(incoming, count, serverApp));
+ count++;
+
}
} catch (IOException e) {
System.out.println(e);
diff --git a/src/CM3033Tests/TestClientStart.java b/src/CM3033Tests/TestClientStart.java
old mode 100644
new mode 100755
diff --git a/src/cm3033/lab2/ex3/Alarm.java b/src/cm3033/lab2/ex3/Alarm.java
deleted file mode 100644
index 7ab5f74..0000000
--- a/src/cm3033/lab2/ex3/Alarm.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-package cm3033.lab2.ex3;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-import javax.swing.JOptionPane;
-
-/**
- *
- * @author Florin Mazilu 1114040
- */
-//alarm class
-public class Alarm {
-//int to determine the high and low tresholds for the alarm
-
- int low, high;
-//boolean to determin if its active and if it's too high or too low
- boolean isActive;
- boolean ishigh;
- //String that stores what the alarm was
- String alarm;
- //for logging when an alarm is started and stopped
- final DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
- Calendar start = Calendar.getInstance();
- Calendar stop = null;
- String s;
-//constructor
-
- public Alarm(int low, int high) {
- isActive = false;
- ishigh = false;
- this.low = low;
- this.high = high;
- alarm = "";
- }
-//activate the alarm
-
- public void activate() {
- isActive = true;
- }
-//deactivate alarm
-
- public void deactivate() {
- stop = Calendar.getInstance();
- Date time = stop.getTime();
- s = dateFormat.format(time);
- isActive = false;
- }
-//check if alarm is active
-
- public boolean active() {
- return isActive;
- }
-//check if the value is between the treshold
-
- public void check(int bpm) {
- //check if it's to high
- if (bpm > high) {
- activate();
- ishigh = true;
- } //check if it's to low
- else if (bpm < low) {
- ishigh = false;
- activate();
- } else {
-
- deactivate();
- }
- //pop up's with the alarm
- if (active()
- && ishigh) {
- JOptionPane.showMessageDialog(null, "ALERT: HEART BEAT TOO HIGH");
- deactivate();
- alarm = "ALERT: HEART BEAT TOO HIGH, stopped at :" + s;
- } else if (active()
- && !ishigh) {
- JOptionPane.showMessageDialog(null, "ALERT: HEART BEAT TOO LOW");
- deactivate();
- alarm = "ALERT: HEART BEAT TOO LOW, stopped at :" + s;
- }
- }
-//check how long it has been since the last response
-
- public void timeout(Calendar start, Calendar current) {
- if (start.compareTo(current) > 30000) {
- JOptionPane.showMessageDialog(null, "ALERT: NO RESPONSE FOR 30 SECONDS");
- alarm = "ALERT: NO RESPONSE FOR 30 SECONDS";
- }
- }
-//get the alarm string
-
- public String info() {
- return alarm;
- }
-
-//setters for the high and low values
- public void setLow(int low) {
- this.low = low;
- }
-
- public void setHigh(int high) {
- this.high = high;
- }
-
-}
diff --git a/src/cm3033/lab2/ex3/Client.java b/src/cm3033/lab2/ex3/Client.java
deleted file mode 100644
index 446e48a..0000000
--- a/src/cm3033/lab2/ex3/Client.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-package cm3033.lab2.ex3;
-
-import java.awt.Component;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.PrintWriter;
-import java.net.Socket;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import javax.swing.JOptionPane;
-
-/**
- *
- * @author samc
- */
-public class Client implements Runnable {
-
- Socket requestSocket;
- PrintWriter out;
- BufferedReader in;
- boolean connected;
- String recievedStr = "";
- ClientApp ca;
- String sendStr = "MaxMin:null";
- String oldSendStr = sendStr;
- int test = 0;
- Component frame = null;
-
- public static void main(String args[]) throws IOException {
- Client client = new Client();
- client.run();
- }
-
- @Override
- public void run() {
- try {
- ca = new ClientApp();
- ca.setVisible(true);
- ca.setConnection(false);
-
- while (ca.running) {
- try {
- ca.updateTime();
-
- if (ca.connect) {
- if (!connected) {
- String ip = JOptionPane.showInputDialog("input ip address");
- if (ip != null) {
- ca.alterText("Connecting...");
- requestSocket = new Socket(ip, 8189);
- System.out.println("Client>Connected to "
- + requestSocket.getLocalAddress().getHostName()
- + " on port " + requestSocket.getLocalPort());
- ca.setConnection(true);
- connected = true;
- ca.alterText("Connected to " + requestSocket.getLocalAddress().getHostName()
- + " on port " + requestSocket.getLocalPort());
- out = new PrintWriter(requestSocket.getOutputStream(), true /* auto flush */);
- in = new BufferedReader(new InputStreamReader(requestSocket.getInputStream()));
- sendStr = "MaxMin:" + ca.getMaxMin();
- sendMessage(sendStr);
- oldSendStr = sendStr;
- test = 0;
- test--;
-
- if (in.ready()) {
- recievedStr = in.readLine();
- if (recievedStr != null) {
- System.out.println("Server>" + recievedStr);
- test++;
- System.out.println("test=" + test);
- }
- }
-
- sendStr = "MaxMin:" + ca.getMaxMin();
- if (!sendStr.equals(oldSendStr)) {
- sendMessage(sendStr);
- oldSendStr = sendStr;
- test--;
- System.out.println("test=" + test);
-
- if (test < 1) {
- System.out.println("test=" + test);
- sendMessage("BYE");
- ca.setConnection(false);
- if (ca.running) {
- ca.alterText("Server Timeout!");
- } else {
- System.exit(0);
- }
- }
- }
- } else {
- ca.connect = false;
- ca.setConnection(false);
- JOptionPane.showMessageDialog(frame, "Please enter a valid IP.");
- }
- }
- } else if (connected) {
- ca.setConnection(false);
- System.out.println("Disconnecting");
- sendMessage("BYE");
- ca.alterText("Disconnected");
- connected = false;
- }
- } catch (IOException ex) {
- System.out.println(ex.toString());
- ca.connect = false;
- JOptionPane.showMessageDialog(frame, "Connection Failed");
- ca.alterText("Connection Failed");
- ca.setConnection(false);
- }
- }
- } catch (IOException ex) {
- System.out.println(ex.toString());
- }
- }
-
- private void sendMessage(String msg) {
- out.println(msg);
- System.out.println("Client>" + msg);
- }
-}
diff --git a/src/cm3033/lab2/ex3/ClientApp.form b/src/cm3033/lab2/ex3/ClientApp.form
deleted file mode 100644
index ffab166..0000000
--- a/src/cm3033/lab2/ex3/ClientApp.form
+++ /dev/null
@@ -1,309 +0,0 @@
-
-
-
diff --git a/src/cm3033/lab2/ex3/ClientApp.java b/src/cm3033/lab2/ex3/ClientApp.java
deleted file mode 100644
index f527ef1..0000000
--- a/src/cm3033/lab2/ex3/ClientApp.java
+++ /dev/null
@@ -1,451 +0,0 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-package cm3033.lab2.ex3;
-
-import java.awt.Component;
-import java.io.IOException;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import javax.swing.JOptionPane;
-
-/**
- *
- * @author Florin
- */
-
-public class ClientApp extends javax.swing.JFrame implements Runnable {
-
- public volatile String text;
- private int highValue, lowValue;
- private int oldHighValue = highValue, oldLowValue = lowValue;
- private String highLowValue;
- final DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
- Calendar now = null, start = Calendar.getInstance();
- boolean running = true;
- boolean connect = false;
- Alarm a;
- HeartBeat hb;
- int heartbeatValue;
-
- public ClientApp() throws IOException {
- initComponents();
- textSpace.setEditable(false);
- //sendButton.setVisible(false);
- text = "";
- maxValue.removeAllItems();
- minValue.removeAllItems();
-
- maxValue.addItem(40);
- maxValue.addItem(60);
- maxValue.addItem(80);
- maxValue.addItem(100);
- maxValue.addItem(120);
- maxValue.addItem(140);
- maxValue.addItem(160);
- maxValue.addItem(180);
- maxValue.addItem(200);
-
- minValue.addItem(20);
- minValue.addItem(40);
- minValue.addItem(60);
- minValue.addItem(80);
- minValue.addItem(100);
- minValue.addItem(120);
- minValue.addItem(140);
- minValue.addItem(160);
- minValue.addItem(180);
- a = new Alarm(Integer.parseInt(maxValue.getSelectedItem().toString()), Integer.parseInt(minValue.getSelectedItem().toString()));
- hb = new HeartBeat(Integer.parseInt(maxValue.getSelectedItem().toString()));
-
- }
-
- /**
- * This method is called from within the constructor to initialize the form.
- * WARNING: Do NOT modify this code. The content of this method is always
- * regenerated by the Form Editor.
- */
- @SuppressWarnings("unchecked")
- // //GEN-BEGIN:initComponents
- private void initComponents() {
-
- maxLabel = new javax.swing.JLabel();
- minLabel = new javax.swing.JLabel();
- currentTime = new javax.swing.JLabel();
- elapsedTime = new javax.swing.JLabel();
- maxValue = new javax.swing.JComboBox();
- minValue = new javax.swing.JComboBox();
- bpmLabel = new javax.swing.JLabel();
- opModeLabel = new javax.swing.JLabel();
- connectionButton = new javax.swing.JButton();
- jScrollPane1 = new javax.swing.JScrollPane();
- textSpace = new javax.swing.JTextArea();
- bpmValue = new javax.swing.JLabel();
- opModeValue = new javax.swing.JLabel();
- currentTimeValue = new javax.swing.JLabel();
- elapsedTimeValue = new javax.swing.JLabel();
- sendBPM = new javax.swing.JButton();
- jLabel1 = new javax.swing.JLabel();
- jMenuBar1 = new javax.swing.JMenuBar();
- menuExit = new javax.swing.JMenu();
- resetMenu = new javax.swing.JMenuItem();
- conectionsLeft = new javax.swing.JMenuItem();
- jSeparator1 = new javax.swing.JPopupMenu.Separator();
- exit = new javax.swing.JMenuItem();
-
- setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
-
- maxLabel.setText("Max:");
-
- minLabel.setText("Min");
-
- currentTime.setText("Current Time:");
-
- elapsedTime.setText("Elapsed Time:");
-
- maxValue.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
- maxValue.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- maxValueActionPerformed(evt);
- }
- });
-
- minValue.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
- minValue.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- minValueActionPerformed(evt);
- }
- });
-
- bpmLabel.setFont(new java.awt.Font("Lucida Grande", 0, 24)); // NOI18N
- bpmLabel.setText("BPM:");
-
- opModeLabel.setText("Operating Mode:");
-
- connectionButton.setText("Connect");
- connectionButton.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- connectionButtonActionPerformed(evt);
- }
- });
-
- textSpace.setColumns(20);
- textSpace.setRows(5);
- jScrollPane1.setViewportView(textSpace);
-
- bpmValue.setFont(new java.awt.Font("Lucida Grande", 0, 24)); // NOI18N
- bpmValue.setText("200");
-
- opModeValue.setText("Local");
-
- currentTimeValue.setText("00:00:00");
-
- elapsedTimeValue.setText("00:00:00");
-
- sendBPM.setText("Send ");
- sendBPM.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- sendBPMActionPerformed(evt);
- }
- });
-
- jLabel1.setText("Send new Heart Beat value");
-
- menuExit.setText("File");
-
- resetMenu.setText("Reset");
- resetMenu.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- resetMenuActionPerformed(evt);
- }
- });
- menuExit.add(resetMenu);
-
- conectionsLeft.setText("Conections Left");
- conectionsLeft.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- conectionsLeftActionPerformed(evt);
- }
- });
- menuExit.add(conectionsLeft);
- menuExit.add(jSeparator1);
-
- exit.setText("EXIT");
- exit.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- exitActionPerformed(evt);
- }
- });
- menuExit.add(exit);
-
- jMenuBar1.add(menuExit);
-
- setJMenuBar(jMenuBar1);
-
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
- getContentPane().setLayout(layout);
- layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addContainerGap()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jScrollPane1)
- .addGroup(layout.createSequentialGroup()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addComponent(opModeLabel)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(opModeValue, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGroup(layout.createSequentialGroup()
- .addComponent(minLabel)
- .addGap(13, 13, 13)
- .addComponent(minValue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(12, 12, 12)
- .addComponent(connectionButton)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 46, Short.MAX_VALUE)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(currentTime, javax.swing.GroupLayout.Alignment.TRAILING)
- .addComponent(elapsedTime, javax.swing.GroupLayout.Alignment.TRAILING))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(currentTimeValue)
- .addComponent(elapsedTimeValue, javax.swing.GroupLayout.Alignment.TRAILING)))
- .addGroup(layout.createSequentialGroup()
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(bpmLabel)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(bpmValue)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(maxLabel)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(maxValue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))))
- .addContainerGap())
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
- .addComponent(jLabel1)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(sendBPM)
- .addGap(168, 168, 168))))
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(17, 17, 17)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(currentTime)
- .addComponent(currentTimeValue))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(elapsedTime)
- .addComponent(elapsedTimeValue)))
- .addGroup(layout.createSequentialGroup()
- .addGap(8, 8, 8)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(opModeLabel)
- .addComponent(connectionButton)
- .addComponent(opModeValue))))
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(32, 32, 32)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(maxLabel)
- .addComponent(maxValue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
- .addGroup(layout.createSequentialGroup()
- .addGap(33, 33, 33)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(minLabel)
- .addComponent(minValue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
- .addGroup(layout.createSequentialGroup()
- .addGap(18, 18, 18)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(bpmLabel)
- .addComponent(bpmValue))))
- .addGap(30, 30, 30)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(sendBPM)
- .addComponent(jLabel1))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 157, Short.MAX_VALUE)
- .addContainerGap())
- );
-
- pack();
- }// //GEN-END:initComponents
-
- private void exitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitActionPerformed
- running = false;
- }//GEN-LAST:event_exitActionPerformed
-
- private void conectionsLeftActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_conectionsLeftActionPerformed
- hb.isAutomatic();
- try {
- int temp = hb.getRandom();
- a.check(temp);
- if (a.alarm != null) {
- alterText(a.info());
- a.alarm = null;
- } else {
- alterText(hb.genTime(temp));
- }
- } catch (InterruptedException ex) {
- Logger.getLogger(ClientApp.class.getName()).log(Level.SEVERE, null, ex);
- }
- }//GEN-LAST:event_conectionsLeftActionPerformed
-
- private void resetMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_resetMenuActionPerformed
- textSpace.setText(null);
- }//GEN-LAST:event_resetMenuActionPerformed
-
- private void connectionButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_connectionButtonActionPerformed
- if (!connect) {
- setConnection(!connect);
- alterText("Min set to: " + lowValue + "\tMax set to: " + highValue);
- } else {
- setConnection(!connect);
- }
-
-
- }//GEN-LAST:event_connectionButtonActionPerformed
-
- private void minValueActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_minValueActionPerformed
- testDropDowns("min");
- }//GEN-LAST:event_minValueActionPerformed
-
- private void maxValueActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_maxValueActionPerformed
- testDropDowns("max");
- }//GEN-LAST:event_maxValueActionPerformed
-//send a user inputted BPM
- private void sendBPMActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sendBPMActionPerformed
- try {
- //set the high and low value of the BPM for the alarm
- a.setHigh(Integer.parseInt(maxValue.getSelectedItem().toString()));
- a.setLow(Integer.parseInt(minValue.getSelectedItem().toString()));
- //create a random bpm based on the user input
- heartbeatValue = hb.getRandom();
- updateBpm(String.valueOf(heartbeatValue));
- //check with the alarm if the value is between the high and low
- a.check(heartbeatValue);
- } catch (InterruptedException ex) {
- Logger.getLogger(ClientApp.class.getName()).log(Level.SEVERE, null, ex);
- }
- //log the alarm if it is triggered
- if (a.alarm != null) {
- alterText(a.info());
- a.alarm = null;
- }
-
- }//GEN-LAST:event_sendBPMActionPerformed
-
- public void updateTime() {
- now = Calendar.getInstance();
- Date time = now.getTime();
- currentTimeValue.setText(dateFormat.format(time));
- elapsedTimeValue.setText(dateFormat.format((time.getTime() - start.getTimeInMillis() - 3600000)));
- }
-
- private void testDropDowns(String v) {
- if (maxValue.getSelectedItem() != null && maxValue.getSelectedItem().toString() != null) {
- if (minValue.getSelectedItem() != null && minValue.getSelectedItem().toString() != null) {
- highValue = Integer.parseInt(maxValue.getSelectedItem().toString());
- lowValue = Integer.parseInt(minValue.getSelectedItem().toString());
- if (highValue <= lowValue) {
- switch (v) {
- case "max":
- maxValue.setSelectedItem(oldHighValue);
- break;
- case "min":
- minValue.setSelectedItem(oldLowValue);
- break;
- }
- Component frame = null;
- JOptionPane.showMessageDialog(frame, "The \"Max Value\" must be more than the \"Min Value\"!");
- } else {
- switch (v) {
- case "max":
- oldHighValue = highValue;
- break;
- case "min":
- oldLowValue = lowValue;
- break;
- }
- highLowValue = highValue + "," + lowValue;
- }
- }
- }
- }
-
- public String getMaxMin() {
- return highLowValue;
- }
-
- public void setConnection(boolean connected) {
- if (connected) {
- connect = true;
- maxValue.setEnabled(false);
- minValue.setEnabled(false);
- opModeValue.setText("Remote");
- connectionButton.setText("Disconnect");
- } else {
- opModeValue.setText("Local");
- connectionButton.setText("Connect");
- connect = false;
- maxValue.setEnabled(true);
- minValue.setEnabled(true);
- }
- }
-
- public void alterText(String text) {
- now = Calendar.getInstance();
- textSpace.append(dateFormat.format(now.getTime()) + " | " + text + "\n");
- }
-//update the bpm text with the value recieved from the heartbeat class
-
- public void updateBpm(String bpm) {
- bpmValue.setText(bpm);
- }
-
- public int getHb() {
- return heartbeatValue;
- }
- // Variables declaration - do not modify//GEN-BEGIN:variables
- private javax.swing.JLabel bpmLabel;
- private javax.swing.JLabel bpmValue;
- private javax.swing.JMenuItem conectionsLeft;
- private javax.swing.JButton connectionButton;
- private javax.swing.JLabel currentTime;
- private javax.swing.JLabel currentTimeValue;
- private javax.swing.JLabel elapsedTime;
- private javax.swing.JLabel elapsedTimeValue;
- private javax.swing.JMenuItem exit;
- private javax.swing.JLabel jLabel1;
- private javax.swing.JMenuBar jMenuBar1;
- private javax.swing.JScrollPane jScrollPane1;
- private javax.swing.JPopupMenu.Separator jSeparator1;
- private javax.swing.JLabel maxLabel;
- private javax.swing.JComboBox maxValue;
- private javax.swing.JMenu menuExit;
- private javax.swing.JLabel minLabel;
- private javax.swing.JComboBox minValue;
- private javax.swing.JLabel opModeLabel;
- private javax.swing.JLabel opModeValue;
- private javax.swing.JMenuItem resetMenu;
- private javax.swing.JButton sendBPM;
- private javax.swing.JTextArea textSpace;
- // End of variables declaration//GEN-END:variables
-
- @Override
- public void run() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
-}
diff --git a/src/cm3033/lab2/ex3/HeartBeat.java b/src/cm3033/lab2/ex3/HeartBeat.java
deleted file mode 100644
index b8625a5..0000000
--- a/src/cm3033/lab2/ex3/HeartBeat.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-package cm3033.lab2.ex3;
-
-import java.util.Random;
-import javax.swing.JOptionPane;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-
-/**
- *
- * @author Florin Mazilu 1114040
- */
-public class HeartBeat {
-//create a random for the BPM
-
- private Random r;
- //set a max value that the BPM can be
- private int max;
- //returns the automatic bpm
- private int autoBPM;
-
- //boolean that decides if the bpm should be user inputted or automatic
- private boolean automatic = false;
- //gen date time for logging when a BPM is automaticly generated
- private final DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
- private Calendar start = null;
-
- //constructor
- public HeartBeat(int max) {
- r = new Random();
- this.max = max;
- }
-//set automatic true
-
- public void isAutomatic() {
- automatic = true;
- }
-
- public String genTime(int rand) throws InterruptedException {
- start = Calendar.getInstance();
- Date time = start.getTime();
- String str = "BPM generated : " + rand + ", generated at :" + dateFormat.format(time);
- return str;
- }
-//generate a random integer between 0 and the max value
-
- public int getRandom() throws InterruptedException {
- //generate a temp value for the random;
- int temp = 0;
- if (automatic) {
- temp = r.nextInt(max);
- } else { //if the input is not automatic prompt the user for an input and a random number between 0-10 for variation
- //user validation for using only numbers
- boolean isValid = false;
- //checks for the numbers being between 0 and 999
- String check1 = "[0-9]";
- String check2 = "[0-9]{0,9}";
- String check3 = "[0-9]{0,9}[0-9]";
- while (!isValid) {
- String str = JOptionPane.showInputDialog("Insert Next Heart Beat value(only numbers between 1-300)");
- if (str != null) {
- if (str.matches(check1) || str.matches(check2) || str.matches(check3)) {
- temp = Integer.parseInt(str) + r.nextInt(10);
- //check for the values to be between 0-300 as there will never be a bpm that high
- if (temp > 0 && temp < 300) {
- isValid = true;
- } else {
- JOptionPane.showMessageDialog(null, "Please only use values lower than 300");
- }
- } else {
- JOptionPane.showMessageDialog(null, "Please only use numerical values");
-
- }
- }
- }
- }
- return temp;
- }
-
-}
diff --git a/src/cm3033/lab2/ex3/MainAppEx3.java b/src/cm3033/lab2/ex3/MainAppEx3.java
deleted file mode 100644
index ff89076..0000000
--- a/src/cm3033/lab2/ex3/MainAppEx3.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-package cm3033.lab2.ex3;
-
-import java.io.IOException;
-import java.net.ServerSocket;
-import java.net.Socket;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
-
-/**
- *
- * @author David
- */
-public class MainAppEx3 {
-
- public static void main(String[] args) {
- int tpSize = 5;
- ServerApp sv = new ServerApp();
- sv.setVisible(true);
- ThreadPoolExecutor pool = new ThreadPoolExecutor(
- tpSize,
- tpSize,
- 50000L,
- TimeUnit.MILLISECONDS,
- new LinkedBlockingQueue());
- try {
- ServerSocket s = new ServerSocket(8189);
- System.out.println("Server>Waiting For Clients...");
- // listen for a connection request on server socket s
- // incoming is the connection socket
- for (;;) {
- Socket incoming = s.accept();
- pool.execute(new Server(incoming, sv));
- }
- } catch (IOException e) {
- System.out.println(e);
- }
- pool.shutdown();
- }
-}
diff --git a/src/cm3033/lab2/ex3/Server.java b/src/cm3033/lab2/ex3/Server.java
deleted file mode 100644
index 6511307..0000000
--- a/src/cm3033/lab2/ex3/Server.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-package cm3033.lab2.ex3;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.PrintWriter;
-import java.net.Socket;
-
-/**
- *
- * @author David
- */
-public class Server implements Runnable {
-
- private Socket incoming;
- ServerApp sv;
-
- public Server(Socket incoming, ServerApp sv) {
- this.incoming = incoming;
- this.sv = sv;
- sv.setVisible(true);
- }
-
- @Override
- public void run() {
- try {
- String s;
- // set up streams for bidirectional transfer
- // across connection socket
- BufferedReader in = new BufferedReader(new InputStreamReader(incoming.getInputStream()));
- PrintWriter out = new PrintWriter(incoming.getOutputStream(), true /* auto flush */);
- out.println("You are connected to "
- + incoming.getLocalAddress().getHostName()
- + " on port " + incoming.getLocalPort()
- );
- out.println("Type BYE to quit");
- System.out.println(incoming.getLocalAddress().getHostName() + " Connected");
- s = incoming.getLocalAddress().getHostName() + " Connected" + "\n";
- sv.appendText(s);
- boolean done = false;
- while (!done) {
- String str = in.readLine();
- if (str == null) {
- done = true;
- } else {
- out.println("Recieved: " + str);
- if (str.trim().equals("BYE")) {
- System.out.println(incoming.getLocalAddress().getHostName() + " Disconnected");
- s = incoming.getLocalAddress().getHostName() + " Disconnected" + "\n";
- sv.appendText(s);
- done = true;
- }
- }
- }
- incoming.close();
- } catch (IOException e) {
- System.out.println(e);
- }
- }
-}
diff --git a/src/cm3033/lab2/ex3/ServerApp.form b/src/cm3033/lab2/ex3/ServerApp.form
deleted file mode 100644
index 63e15db..0000000
--- a/src/cm3033/lab2/ex3/ServerApp.form
+++ /dev/null
@@ -1,177 +0,0 @@
-
-
-
diff --git a/src/cm3033/lab2/ex3/ServerApp.java b/src/cm3033/lab2/ex3/ServerApp.java
deleted file mode 100644
index 10f4e0e..0000000
--- a/src/cm3033/lab2/ex3/ServerApp.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-package cm3033.lab2.ex3;
-
-/**
- *
- * @author Mazzy
- */
-public class ServerApp extends javax.swing.JFrame {
-
- /**
- * Creates new form ServerApp
- */
- public ServerApp() {
- initComponents();
- }
-
- public void con(int count) {
- if (count == 1) {
- con1.setSelected(true);
- }
- if (count == 3) {
- con3.setSelected(true);
- }
- if (count == 4) {
- con4.setSelected(true);
- }
- if (count == 2) {
- con2.setSelected(true);
- }
-
- }
-
- public void setCount(int Count) {
- con(Count);
- }
-
- public void appendText(String s) {
- jTextArea1.append(s);
- }
-
- /**
- * This method is called from within the constructor to initialize the form.
- * WARNING: Do NOT modify this code. The content of this method is always
- * regenerated by the Form Editor.
- */
- @SuppressWarnings("unchecked")
- // //GEN-BEGIN:initComponents
- private void initComponents() {
-
- jScrollPane1 = new javax.swing.JScrollPane();
- jTextArea1 = new javax.swing.JTextArea();
- jLabel1 = new javax.swing.JLabel();
- jLabel2 = new javax.swing.JLabel();
- jLabel3 = new javax.swing.JLabel();
- jLabel4 = new javax.swing.JLabel();
- con1 = new javax.swing.JCheckBox();
- con2 = new javax.swing.JCheckBox();
- jSeparator1 = new javax.swing.JSeparator();
- jSeparator2 = new javax.swing.JSeparator();
- con3 = new javax.swing.JCheckBox();
- jSeparator3 = new javax.swing.JSeparator();
- con4 = new javax.swing.JCheckBox();
-
- setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
-
- jTextArea1.setColumns(20);
- jTextArea1.setRows(5);
- jScrollPane1.setViewportView(jTextArea1);
-
- jLabel1.setText("Client 1");
-
- jLabel2.setText("Client 2");
-
- jLabel3.setText("Client 3");
-
- jLabel4.setText("Client 4");
-
- con1.setText("Connected");
- con1.setEnabled(false);
-
- con2.setText("Connected");
- con2.setEnabled(false);
-
- con3.setText("Connected");
- con3.setEnabled(false);
- con3.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- con3ActionPerformed(evt);
- }
- });
-
- con4.setText("Connected");
- con4.setEnabled(false);
- con4.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- con4ActionPerformed(evt);
- }
- });
-
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
- getContentPane().setLayout(layout);
- layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(80, 80, 80)
- .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 251, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(0, 0, Short.MAX_VALUE))
- .addGroup(layout.createSequentialGroup()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(30, 30, 30)
- .addComponent(jLabel1))
- .addGroup(layout.createSequentialGroup()
- .addGap(20, 20, 20)
- .addComponent(con1)))
- .addGap(0, 0, 0)
- .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 9, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(0, 0, 0)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jLabel2)
- .addComponent(con2))
- .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 9, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jLabel3)
- .addGroup(layout.createSequentialGroup()
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(con3)))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, 9, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jLabel4)
- .addGroup(layout.createSequentialGroup()
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(con4)))
- .addContainerGap())
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
- .addGroup(layout.createSequentialGroup()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jLabel1)
- .addComponent(jLabel2)
- .addComponent(jLabel3)
- .addComponent(jLabel4))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(con1)
- .addComponent(con2, javax.swing.GroupLayout.Alignment.TRAILING))
- .addComponent(con3, javax.swing.GroupLayout.Alignment.TRAILING))
- .addComponent(con4, javax.swing.GroupLayout.Alignment.TRAILING)))
- .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 26, Short.MAX_VALUE)
- .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 392, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addContainerGap())
- );
-
- pack();
- }// //GEN-END:initComponents
-
- private void con3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_con3ActionPerformed
- // TODO add your handling code here:
- }//GEN-LAST:event_con3ActionPerformed
-
- private void con4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_con4ActionPerformed
- // TODO add your handling code here:
- }//GEN-LAST:event_con4ActionPerformed
-
-
- // Variables declaration - do not modify//GEN-BEGIN:variables
- private javax.swing.JCheckBox con1;
- private javax.swing.JCheckBox con2;
- private javax.swing.JCheckBox con3;
- private javax.swing.JCheckBox con4;
- private javax.swing.JLabel jLabel1;
- private javax.swing.JLabel jLabel2;
- private javax.swing.JLabel jLabel3;
- private javax.swing.JLabel jLabel4;
- private javax.swing.JScrollPane jScrollPane1;
- private javax.swing.JSeparator jSeparator1;
- private javax.swing.JSeparator jSeparator2;
- private javax.swing.JSeparator jSeparator3;
- private javax.swing.JTextArea jTextArea1;
- // End of variables declaration//GEN-END:variables
-}