diff --git a/traffic_analyzer/master_app/src/main/java/me/yigitcolakoglu/master_app/fan.png b/MyCity/classes/production/main/me/yigitcolakoglu/master_app/fan.png
similarity index 100%
rename from traffic_analyzer/master_app/src/main/java/me/yigitcolakoglu/master_app/fan.png
rename to MyCity/classes/production/main/me/yigitcolakoglu/master_app/fan.png
diff --git a/MyCity/classes/production/main/me/yigitcolakoglu/master_app/ips.json b/MyCity/classes/production/main/me/yigitcolakoglu/master_app/ips.json
new file mode 100644
index 0000000..be4ac40
--- /dev/null
+++ b/MyCity/classes/production/main/me/yigitcolakoglu/master_app/ips.json
@@ -0,0 +1,5 @@
+{
+ "qr": "127.0.0.3",
+ "intersection": "127.0.0.1",
+ "ambulance": "127.0.0.1"
+}
\ No newline at end of file
diff --git a/MyCity/classes/production/main/me/yigitcolakoglu/master_app/userinfo.json b/MyCity/classes/production/main/me/yigitcolakoglu/master_app/userinfo.json
new file mode 100644
index 0000000..19c4e71
--- /dev/null
+++ b/MyCity/classes/production/main/me/yigitcolakoglu/master_app/userinfo.json
@@ -0,0 +1,12 @@
+{
+ "usernames": {
+ "qr": "admin",
+ "ambulance": "yigit",
+ "intersection": "admin"
+ },
+ "passwords": {
+ "qr": "admin",
+ "ambulance": "Ygtclksbl1",
+ "intersection": "admin"
+ }
+}
\ No newline at end of file
diff --git a/MyCity/ips.json b/MyCity/ips.json
new file mode 100644
index 0000000..af65ec2
--- /dev/null
+++ b/MyCity/ips.json
@@ -0,0 +1,5 @@
+{
+ "qr": "127.0.0.1",
+ "intersection": "127.0.0.1",
+ "ambulance": "127.0.0.1"
+}
\ No newline at end of file
diff --git a/bus_stop/control_card/control_card.ino b/bus_stop/control_card/control_card.ino
deleted file mode 100644
index 7761f9d..0000000
--- a/bus_stop/control_card/control_card.ino
+++ /dev/null
@@ -1,54 +0,0 @@
-int pins[] = {13,8,9,10,11,12};
-int light_pin = 0;
-
-void setup() {
-
- for(int i = 0; i<6; i++){
- pinMode(pins[i],OUTPUT);
- }
-
-}
-
-void loop() {
- while(Serial.read() != '/'){
- continue;
- }
- char prev = '!';
- char cur = '!';
- String data = "";
- while(Serial.read() != '/'){
- if(cur == '!' || prev != cur){
- prev = cur;
- data += cur;
- }
- cur = Serial.read()
- }
-
- for(int i = 0; i<2;i++){
- switch(data[i]){
-
- case "g":
- digitalWrite(pins[i*3],HIGH);
- digitalWrite(pins[(i*2)+1],LOW);
- digitalWrite(pins[(i*2)+2],LOW);
- break;
-
- case "y":
- digitalWrite(pins[i*3],LOW);
- digitalWrite(pins[(i*2)+1],HIGH);
- digitalWrite(pins[(i*2)+1],LOW);
- break;
-
- case "r":
- digitalWrite(pins[i*3],LOW);
- digitalWrite(pins[(i*2)+1],LOW);
- digitalWrite(pins[(i*2)+1],HIGH);
- break;
-
-
- }
- }
-
-
-
-}
diff --git a/bus_stop/qr_reader/starter.php b/bus_stop/qr_reader/starter.php
new file mode 100644
index 0000000..f4577aa
--- /dev/null
+++ b/bus_stop/qr_reader/starter.php
@@ -0,0 +1,17 @@
+ /dev/null 2>&1 &");
+}else{
+ echo "
+
+
+
+
+
+ ";
+}
+?>
\ No newline at end of file
diff --git a/master_app/.idea/compiler.xml b/master_app/.idea/compiler.xml
new file mode 100644
index 0000000..6232026
--- /dev/null
+++ b/master_app/.idea/compiler.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/master_app/.idea/encodings.xml b/master_app/.idea/encodings.xml
new file mode 100644
index 0000000..b26911b
--- /dev/null
+++ b/master_app/.idea/encodings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/master_app/.idea/libraries/Maven__com_hierynomus_sshj_0_27_0.xml b/master_app/.idea/libraries/Maven__com_hierynomus_sshj_0_27_0.xml
new file mode 100644
index 0000000..1d5aa46
--- /dev/null
+++ b/master_app/.idea/libraries/Maven__com_hierynomus_sshj_0_27_0.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/master_app/.idea/libraries/Maven__com_jcraft_jzlib_1_1_3.xml b/master_app/.idea/libraries/Maven__com_jcraft_jzlib_1_1_3.xml
new file mode 100644
index 0000000..897f365
--- /dev/null
+++ b/master_app/.idea/libraries/Maven__com_jcraft_jzlib_1_1_3.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/master_app/.idea/libraries/Maven__net_i2p_crypto_eddsa_0_2_0.xml b/master_app/.idea/libraries/Maven__net_i2p_crypto_eddsa_0_2_0.xml
new file mode 100644
index 0000000..2c74515
--- /dev/null
+++ b/master_app/.idea/libraries/Maven__net_i2p_crypto_eddsa_0_2_0.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/master_app/.idea/libraries/Maven__org_bouncycastle_bcpkix_jdk15on_1_60.xml b/master_app/.idea/libraries/Maven__org_bouncycastle_bcpkix_jdk15on_1_60.xml
new file mode 100644
index 0000000..3cc1493
--- /dev/null
+++ b/master_app/.idea/libraries/Maven__org_bouncycastle_bcpkix_jdk15on_1_60.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/master_app/.idea/libraries/Maven__org_bouncycastle_bcprov_jdk15on_1_60.xml b/master_app/.idea/libraries/Maven__org_bouncycastle_bcprov_jdk15on_1_60.xml
new file mode 100644
index 0000000..f6ca3ad
--- /dev/null
+++ b/master_app/.idea/libraries/Maven__org_bouncycastle_bcprov_jdk15on_1_60.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/master_app/.idea/libraries/Maven__org_json_json_20180813.xml b/master_app/.idea/libraries/Maven__org_json_json_20180813.xml
new file mode 100644
index 0000000..01c0a2e
--- /dev/null
+++ b/master_app/.idea/libraries/Maven__org_json_json_20180813.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/master_app/.idea/libraries/Maven__org_slf4j_slf4j_api_1_7_7.xml b/master_app/.idea/libraries/Maven__org_slf4j_slf4j_api_1_7_7.xml
new file mode 100644
index 0000000..1e67260
--- /dev/null
+++ b/master_app/.idea/libraries/Maven__org_slf4j_slf4j_api_1_7_7.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/master_app/.idea/misc.xml b/master_app/.idea/misc.xml
new file mode 100644
index 0000000..2545dc7
--- /dev/null
+++ b/master_app/.idea/misc.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/master_app/.idea/modules.xml b/master_app/.idea/modules.xml
new file mode 100644
index 0000000..397eb52
--- /dev/null
+++ b/master_app/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/master_app/.idea/uiDesigner.xml b/master_app/.idea/uiDesigner.xml
new file mode 100644
index 0000000..e96534f
--- /dev/null
+++ b/master_app/.idea/uiDesigner.xml
@@ -0,0 +1,124 @@
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+
\ No newline at end of file
diff --git a/master_app/.idea/vcs.xml b/master_app/.idea/vcs.xml
new file mode 100644
index 0000000..b2bdec2
--- /dev/null
+++ b/master_app/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/master_app/.idea/workspace.xml b/master_app/.idea/workspace.xml
new file mode 100644
index 0000000..f9b9589
--- /dev/null
+++ b/master_app/.idea/workspace.xml
@@ -0,0 +1,396 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1558719783811
+
+
+ 1558719783811
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ file://$PROJECT_DIR$/src/main/java/me/yigitcolakoglu/master_app/managementForm.java
+ 253
+
+
+
+
+ file://$PROJECT_DIR$/src/main/java/me/yigitcolakoglu/master_app/managementForm.java
+ 233
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Python 3.7
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/master_app/nbactions.xml b/master_app/nbactions.xml
new file mode 100644
index 0000000..7a67f63
--- /dev/null
+++ b/master_app/nbactions.xml
@@ -0,0 +1,49 @@
+
+
+
+ run
+
+ jar
+
+
+ process-classes
+ org.codehaus.mojo:exec-maven-plugin:1.5.0:exec
+
+
+ -classpath %classpath ${packageClassName} ips.json
+ java
+ /home/yigit/projects/MyCity/traffic_analyzer/master_app/src/main/java/me/yigitcolakoglu/master_app
+
+
+
+ debug
+
+ jar
+
+
+ process-classes
+ org.codehaus.mojo:exec-maven-plugin:1.5.0:exec
+
+
+ -agentlib:jdwp=transport=dt_socket,server=n,address=${jpda.address} -classpath %classpath ${packageClassName} ips.json
+ java
+ true
+ /home/yigit/projects/MyCity/traffic_analyzer/master_app/src/main/java/me/yigitcolakoglu/master_app
+
+
+
+ profile
+
+ jar
+
+
+ process-classes
+ org.codehaus.mojo:exec-maven-plugin:1.5.0:exec
+
+
+ -classpath %classpath ${packageClassName} ips.json
+ java
+ /home/yigit/projects/MyCity/traffic_analyzer/master_app/src/main/java/me/yigitcolakoglu/master_app
+
+
+
diff --git a/traffic_analyzer/master_app/pom.xml b/master_app/pom.xml
similarity index 82%
rename from traffic_analyzer/master_app/pom.xml
rename to master_app/pom.xml
index 76f39b2..1438ee1 100644
--- a/traffic_analyzer/master_app/pom.xml
+++ b/master_app/pom.xml
@@ -11,6 +11,11 @@
json
20180813
+
+ com.hierynomus
+ sshj
+ 0.27.0
+
UTF-8
diff --git a/traffic_analyzer/master_app/src/main/java/me/yigitcolakoglu/master_app/Main.java b/master_app/src/main/java/me/yigitcolakoglu/master_app/Main.java
similarity index 73%
rename from traffic_analyzer/master_app/src/main/java/me/yigitcolakoglu/master_app/Main.java
rename to master_app/src/main/java/me/yigitcolakoglu/master_app/Main.java
index 9c9f1c3..aba1b23 100644
--- a/traffic_analyzer/master_app/src/main/java/me/yigitcolakoglu/master_app/Main.java
+++ b/master_app/src/main/java/me/yigitcolakoglu/master_app/Main.java
@@ -5,17 +5,11 @@
*/
package me.yigitcolakoglu.master_app;
-/**
- *
- * @author yigit
- */
+
public class Main {
- /**
- * @param args the command line arguments
- */
+
public static void main(String[] args) {
- // TODO code application logic here
cameraForm form = new cameraForm();
form.setVisible(true);
diff --git a/traffic_analyzer/master_app/src/main/java/me/yigitcolakoglu/master_app/cameraForm.form b/master_app/src/main/java/me/yigitcolakoglu/master_app/cameraForm.form
similarity index 75%
rename from traffic_analyzer/master_app/src/main/java/me/yigitcolakoglu/master_app/cameraForm.form
rename to master_app/src/main/java/me/yigitcolakoglu/master_app/cameraForm.form
index 990b647..6de0ead 100644
--- a/traffic_analyzer/master_app/src/main/java/me/yigitcolakoglu/master_app/cameraForm.form
+++ b/master_app/src/main/java/me/yigitcolakoglu/master_app/cameraForm.form
@@ -41,27 +41,12 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
-
-
-
-
-
@@ -71,24 +56,50 @@
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
-
-
-
-
+
+
-
+
+
+
+
+
+
+
+
+
+
+
@@ -127,18 +138,21 @@
+
+
+
-
+
-
+
@@ -254,5 +268,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/traffic_analyzer/master_app/src/main/java/me/yigitcolakoglu/master_app/cameraForm.java b/master_app/src/main/java/me/yigitcolakoglu/master_app/cameraForm.java
similarity index 78%
rename from traffic_analyzer/master_app/src/main/java/me/yigitcolakoglu/master_app/cameraForm.java
rename to master_app/src/main/java/me/yigitcolakoglu/master_app/cameraForm.java
index dd4ea64..e628b2b 100644
--- a/traffic_analyzer/master_app/src/main/java/me/yigitcolakoglu/master_app/cameraForm.java
+++ b/master_app/src/main/java/me/yigitcolakoglu/master_app/cameraForm.java
@@ -61,6 +61,8 @@ public class cameraForm extends javax.swing.JFrame {
ambulance_button = new javax.swing.JButton();
intersection_button = new javax.swing.JButton();
bus_button = new javax.swing.JButton();
+ fps_label = new javax.swing.JLabel();
+ manage_button = new javax.swing.JButton();
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
@@ -103,7 +105,7 @@ public class cameraForm extends javax.swing.JFrame {
ram_temp.setText("40C");
- jLabel7.setIcon(new javax.swing.ImageIcon("/home/yigit/projects/MyCity/traffic_analyzer/master_app/src/main/java/me/yigitcolakoglu/master_app/fan.png")); // NOI18N
+ jLabel7.setIcon(new javax.swing.ImageIcon("/home/yigit/projects/MyCity/master_app/src/main/java/me/yigitcolakoglu/master_app/fan.png")); // NOI18N
jLabel7.setText("jLabel7");
fan_rpm.setFont(new java.awt.Font("Dialog", 1, 24)); // NOI18N
@@ -130,28 +132,27 @@ public class cameraForm extends javax.swing.JFrame {
}
});
+ fps_label.setFont(new java.awt.Font("Dialog", 1, 18)); // NOI18N
+ fps_label.setText("60 FPS");
+
+ manage_button.setText("Management");
+ manage_button.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ manage_buttonActionPerformed(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()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addContainerGap()
- .addComponent(camera_full_label, javax.swing.GroupLayout.PREFERRED_SIZE, 900, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGroup(layout.createSequentialGroup()
- .addGap(33, 33, 33)
- .addComponent(ambulance_button, javax.swing.GroupLayout.PREFERRED_SIZE, 247, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(217, 217, 217)
- .addComponent(intersection_button, javax.swing.GroupLayout.PREFERRED_SIZE, 248, javax.swing.GroupLayout.PREFERRED_SIZE)))
- .addGap(18, 18, 18)
+ .addContainerGap()
+ .addComponent(camera_full_label, javax.swing.GroupLayout.PREFERRED_SIZE, 900, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(camera_cut_label, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
- .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
- .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 131, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(fan_rpm, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
@@ -160,18 +161,38 @@ public class cameraForm extends javax.swing.JFrame {
.addComponent(jLabel6))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(gpu_usage)
- .addComponent(cpu_usage)
- .addComponent(ram_usage))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+ .addGroup(layout.createSequentialGroup()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(gpu_usage)
+ .addComponent(cpu_usage)
+ .addComponent(ram_usage))
+ .addGap(75, 75, 75)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
+ .addComponent(cpu_temp)
+ .addComponent(gpu_temp)
+ .addComponent(ram_temp)))
+ .addGroup(layout.createSequentialGroup()
+ .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)))
+ .addGap(10, 10, 10))
+ .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
+ .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 131, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(ram_temp)
- .addComponent(cpu_temp)
- .addComponent(gpu_temp)
- .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE))))
- .addComponent(bus_button, javax.swing.GroupLayout.PREFERRED_SIZE, 251, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addComponent(fps_label, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(fan_rpm, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ .addGroup(layout.createSequentialGroup()
+ .addGap(33, 33, 33)
+ .addComponent(ambulance_button, javax.swing.GroupLayout.PREFERRED_SIZE, 247, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addGap(115, 115, 115)
+ .addComponent(intersection_button, javax.swing.GroupLayout.PREFERRED_SIZE, 248, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addGap(113, 113, 113)
+ .addComponent(bus_button, javax.swing.GroupLayout.PREFERRED_SIZE, 251, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(manage_button, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addGap(34, 34, 34))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@@ -203,15 +224,18 @@ public class cameraForm extends javax.swing.JFrame {
.addGap(54, 54, 54)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel7)
- .addComponent(fan_rpm, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)))
+ .addComponent(fan_rpm, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(fps_label, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(camera_full_label, javax.swing.GroupLayout.PREFERRED_SIZE, 720, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(intersection_button, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(ambulance_button)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(ambulance_button)
- .addComponent(bus_button)))
- .addContainerGap(18, Short.MAX_VALUE))
+ .addComponent(bus_button)
+ .addComponent(manage_button)))
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
pack();
@@ -285,6 +309,12 @@ public class cameraForm extends javax.swing.JFrame {
});
running.start(); }//GEN-LAST:event_bus_buttonActionPerformed
+ private void manage_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_manage_buttonActionPerformed
+ managementForm settings = new managementForm();
+ settings.setVisible(true);
+ settings.initIp();
+ }//GEN-LAST:event_manage_buttonActionPerformed
+
/**
* @param args the command line arguments
*/
@@ -322,6 +352,7 @@ public class cameraForm extends javax.swing.JFrame {
}
public void onCreate(int port, String name) throws Exception{
+
this.camera_cut_label.setIcon(new ImageIcon());
this.camera_full_label.setIcon(new ImageIcon());
String fromClient = "";
@@ -336,10 +367,11 @@ public class cameraForm extends javax.swing.JFrame {
BufferedImage image = null;
byte[] imageByte;
int null_reps = 0;
-
+ int fps_sum = 0;
+ int reps = 0;
while(run) {
try{
-
+ long start = System.currentTimeMillis();
BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream()));
fromClient = in.readLine();
@@ -356,8 +388,8 @@ public class cameraForm extends javax.swing.JFrame {
image = ImageIO.read(bis);
bis.close();
JSONObject dims = json.getJSONObject("image_sizes");
- this.camera_cut_label.setIcon(new ImageIcon(resizeImage(image.getSubimage(dims.getInt("x"), dims.getInt("y"), dims.getInt("width"), dims.getInt("height")),300,300)));
this.camera_full_label.setIcon(new ImageIcon(resizeImage(image,900,720)));
+ this.camera_cut_label.setIcon(new ImageIcon(resizeImage(image.getSubimage(dims.getInt("x"), dims.getInt("y"), dims.getInt("width"), dims.getInt("height")),300,300)));
JSONObject data = json.optJSONObject("load");
this.gpu_temp.setText(data.getString("gpu_temp"));
this.gpu_usage.setText(data.getString("gpu_load"));
@@ -367,6 +399,14 @@ public class cameraForm extends javax.swing.JFrame {
this.ram_usage.setText(data.getString("mem_load"));
this.fan_rpm.setText(data.getString("fan_speed"));
null_reps=0;
+ long end = System.currentTimeMillis();
+ float sec = (end - start) / 1000F;
+ fps_sum += Math.round(1/sec);
+ reps+=1;
+ if(reps%10==0){
+ this.fps_label.setText(fps_sum/10 + " FPS");
+ fps_sum=0;
+ }
}
}else{
null_reps +=1;
@@ -375,15 +415,19 @@ public class cameraForm extends javax.swing.JFrame {
catch(Exception e){
System.out.println(fromClient);
System.out.println(e.toString());
+ null_reps+=1;
}
- if (null_reps >= 100000){
+ if (null_reps >= 100){
run = false;
System.out.println("socket closed");
}
}
server.close();
client.close();
+ this.camera_cut_label.setIcon(new ImageIcon());
+ this.camera_full_label.setIcon(new ImageIcon());
JOptionPane.showMessageDialog(this, name +" socket server down!");
+ running.stop();
}
@@ -408,6 +452,7 @@ public class cameraForm extends javax.swing.JFrame {
private javax.swing.JLabel cpu_temp;
private javax.swing.JLabel cpu_usage;
private javax.swing.JLabel fan_rpm;
+ private javax.swing.JLabel fps_label;
private javax.swing.JLabel gpu_temp;
private javax.swing.JLabel gpu_usage;
private javax.swing.JButton intersection_button;
@@ -419,6 +464,7 @@ public class cameraForm extends javax.swing.JFrame {
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JPanel jPanel1;
+ private javax.swing.JButton manage_button;
private javax.swing.JLabel ram_temp;
private javax.swing.JLabel ram_usage;
// End of variables declaration//GEN-END:variables
diff --git a/master_app/src/main/java/me/yigitcolakoglu/master_app/fan.png b/master_app/src/main/java/me/yigitcolakoglu/master_app/fan.png
new file mode 100644
index 0000000..994a115
Binary files /dev/null and b/master_app/src/main/java/me/yigitcolakoglu/master_app/fan.png differ
diff --git a/master_app/src/main/java/me/yigitcolakoglu/master_app/ips.json b/master_app/src/main/java/me/yigitcolakoglu/master_app/ips.json
new file mode 100644
index 0000000..efd4cca
--- /dev/null
+++ b/master_app/src/main/java/me/yigitcolakoglu/master_app/ips.json
@@ -0,0 +1,5 @@
+{
+ "qr": "127.0.0.3",
+ "intersection": "127.0.0.1",
+ "ambulance": "192.168.1.35"
+}
\ No newline at end of file
diff --git a/master_app/src/main/java/me/yigitcolakoglu/master_app/managementForm.form b/master_app/src/main/java/me/yigitcolakoglu/master_app/managementForm.form
new file mode 100644
index 0000000..e7670b0
--- /dev/null
+++ b/master_app/src/main/java/me/yigitcolakoglu/master_app/managementForm.form
@@ -0,0 +1,250 @@
+
+
+
diff --git a/master_app/src/main/java/me/yigitcolakoglu/master_app/managementForm.java b/master_app/src/main/java/me/yigitcolakoglu/master_app/managementForm.java
new file mode 100644
index 0000000..de14af0
--- /dev/null
+++ b/master_app/src/main/java/me/yigitcolakoglu/master_app/managementForm.java
@@ -0,0 +1,464 @@
+/*
+ * 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 me.yigitcolakoglu.master_app;
+
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.io.BufferedWriter;
+import java.io.FileInputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.Socket;
+import javax.swing.JFrame;
+import net.schmizz.sshj.SSHClient;
+import net.schmizz.sshj.connection.channel.direct.Session;
+import net.schmizz.sshj.transport.verification.PromiscuousVerifier;
+import org.json.JSONObject;
+
+/**
+ *
+ * @author yigit
+ */
+public class managementForm extends javax.swing.JFrame {
+
+ /**
+ * Creates new form managementForm
+ */
+ public managementForm() {
+ initComponents();
+ }
+ public final SSHClient ssh = new SSHClient();
+
+ private JSONObject ip_json;
+ private JSONObject usernames;
+ private JSONObject passwords;
+ private JSONObject commands = new JSONObject();
+ @SuppressWarnings("unchecked")
+ // //GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ jFrame1 = new javax.swing.JFrame();
+ jTextField2 = new javax.swing.JTextField();
+ jButton2 = new javax.swing.JButton();
+ jLabel2 = new javax.swing.JLabel();
+ jButton4 = new javax.swing.JButton();
+ ambulance_ip = new javax.swing.JTextField();
+ ambulance_start = new javax.swing.JButton();
+ ambulance_state = new javax.swing.JLabel();
+ intersection_start = new javax.swing.JButton();
+ intersection_ip = new javax.swing.JTextField();
+ qr_start = new javax.swing.JButton();
+ qr_ip = new javax.swing.JTextField();
+ intersection_state = new javax.swing.JLabel();
+ qr_state = new javax.swing.JLabel();
+ jLabel5 = new javax.swing.JLabel();
+ jLabel6 = new javax.swing.JLabel();
+ jLabel7 = new javax.swing.JLabel();
+ refresh_button = new javax.swing.JButton();
+
+ jFrame1.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
+
+ jTextField2.setText("127.0.0.1");
+ jTextField2.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ jTextField2ActionPerformed(evt);
+ }
+ });
+
+ jButton2.setText("Start Process");
+ jButton2.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ jButton2ActionPerformed(evt);
+ }
+ });
+
+ jLabel2.setText("Running");
+
+ javax.swing.GroupLayout jFrame1Layout = new javax.swing.GroupLayout(jFrame1.getContentPane());
+ jFrame1.getContentPane().setLayout(jFrame1Layout);
+ jFrame1Layout.setHorizontalGroup(
+ jFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(jFrame1Layout.createSequentialGroup()
+ .addContainerGap()
+ .addComponent(jButton2)
+ .addGap(18, 18, 18)
+ .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addGap(18, 18, 18)
+ .addComponent(jLabel2)
+ .addContainerGap(154, Short.MAX_VALUE))
+ );
+ jFrame1Layout.setVerticalGroup(
+ jFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(jFrame1Layout.createSequentialGroup()
+ .addGap(33, 33, 33)
+ .addGroup(jFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(jButton2)
+ .addComponent(jLabel2))
+ .addContainerGap(656, Short.MAX_VALUE))
+ );
+
+ jButton4.setText("jButton4");
+
+ setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
+
+ ambulance_ip.setText("127.0.0.1");
+ ambulance_ip.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ ambulance_ipActionPerformed(evt);
+ }
+ });
+
+ ambulance_start.setText("Start");
+ ambulance_start.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ ambulance_startActionPerformed(evt);
+ }
+ });
+
+ ambulance_state.setText("Running");
+
+ intersection_start.setText("Start");
+ intersection_start.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ intersection_startActionPerformed(evt);
+ }
+ });
+
+ intersection_ip.setText("127.0.0.1");
+ intersection_ip.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ intersection_ipActionPerformed(evt);
+ }
+ });
+
+ qr_start.setText("Start");
+ qr_start.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ qr_startActionPerformed(evt);
+ }
+ });
+
+ qr_ip.setText("127.0.0.1");
+
+ intersection_state.setText("Running");
+
+ qr_state.setText("Running");
+
+ jLabel5.setText("Ambulance:");
+
+ jLabel6.setText("Intersection:");
+
+ jLabel7.setText("QR Reader:");
+
+ refresh_button.setText("Refresh");
+ refresh_button.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ refresh_buttonActionPerformed(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()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addGap(16, 16, 16)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(jLabel6)
+ .addComponent(jLabel5, javax.swing.GroupLayout.Alignment.TRAILING)
+ .addComponent(jLabel7, javax.swing.GroupLayout.Alignment.TRAILING))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
+ .addGroup(layout.createSequentialGroup()
+ .addComponent(qr_start)
+ .addGap(18, 18, 18)
+ .addComponent(qr_ip))
+ .addGroup(layout.createSequentialGroup()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
+ .addComponent(intersection_start)
+ .addComponent(ambulance_start))
+ .addGap(18, 18, 18)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
+ .addComponent(ambulance_ip)
+ .addComponent(intersection_ip, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE))))
+ .addGap(18, 18, 18)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(ambulance_state)
+ .addComponent(intersection_state)
+ .addComponent(qr_state)))
+ .addGroup(layout.createSequentialGroup()
+ .addGap(152, 152, 152)
+ .addComponent(refresh_button)))
+ .addContainerGap(42, Short.MAX_VALUE))
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addGap(24, 24, 24)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(ambulance_ip, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(ambulance_start)
+ .addComponent(ambulance_state)
+ .addComponent(jLabel5))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(intersection_start)
+ .addComponent(intersection_ip, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(intersection_state)
+ .addComponent(jLabel6))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(qr_start)
+ .addComponent(qr_ip, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(qr_state)
+ .addComponent(jLabel7))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+ .addComponent(refresh_button)
+ .addContainerGap(12, Short.MAX_VALUE))
+ );
+
+ pack();
+ }// //GEN-END:initComponents
+
+ private void ambulance_ipActionPerformed(java.awt.event.ActionEvent evt) {
+
+ }//GEN-LAST:event_ambulance_ipActionPerformed
+ private void execSSH(String ip,String uname,String passwd, String cmd){
+ Session session = null;
+ try{
+ ssh.connect(ip, 22);
+ ssh.authPassword(uname, passwd);
+ session = ssh.startSession();
+ final Session.Command command = session.exec(cmd);
+ }catch(Exception e){
+ System.out.println(e.toString());
+ }finally {
+ try {
+ if (session != null) {
+ session.close();
+ }
+ ssh.disconnect();
+ } catch (IOException e) {
+ // Do Nothing
+ }
+ }
+ }
+ private void ambulance_startActionPerformed(java.awt.event.ActionEvent evt) {
+ execSSH(ambulance_ip.getText(),
+ usernames.getString("ambulance"),
+ passwords.getString("ambulance"),
+ commands.getString("ambulance"));
+ }
+
+ private void jTextField2ActionPerformed(java.awt.event.ActionEvent evt) {
+ // TODO add your handling code here:
+ }
+
+ private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
+ // TODO add your handling code here:
+ }
+
+ private void intersection_startActionPerformed(java.awt.event.ActionEvent evt) {
+ execSSH(ambulance_ip.getText(),
+ usernames.getString("intersection"),
+ passwords.getString("intersection"),
+ commands.getString("intersection"));
+ }
+
+ private void intersection_ipActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_intersection_ipActionPerformed
+ // TODO add your handling code here:
+ }//GEN-LAST:event_intersection_ipActionPerformed
+
+ private void qr_startActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_qr_startActionPerformed
+ execSSH(ambulance_ip.getText(),
+ usernames.getString("qr"),
+ passwords.getString("qr"),
+ commands.getString("qr"));
+ }//GEN-LAST:event_qr_startActionPerformed
+
+ private void refresh_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_refresh_buttonActionPerformed
+ checkState();
+ }//GEN-LAST:event_refresh_buttonActionPerformed
+
+
+ public static void main(String args[]) {
+ /* Set the Nimbus look and feel */
+ //
+ /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
+ * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
+ */
+ try {
+ for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
+ if ("Nimbus".equals(info.getName())) {
+ javax.swing.UIManager.setLookAndFeel(info.getClassName());
+ break;
+ }
+ }
+ } catch (ClassNotFoundException ex) {
+ java.util.logging.Logger.getLogger(managementForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+ } catch (InstantiationException ex) {
+ java.util.logging.Logger.getLogger(managementForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+ } catch (IllegalAccessException ex) {
+ java.util.logging.Logger.getLogger(managementForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+ } catch (javax.swing.UnsupportedLookAndFeelException ex) {
+ java.util.logging.Logger.getLogger(managementForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+ }
+ //
+
+ /* Create and display the form */
+ java.awt.EventQueue.invokeLater(new Runnable() {
+ public void run() {
+ new managementForm().setVisible(true);
+ }
+ });
+ }
+
+ public void initIp(){
+ this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+ commands.put("ambulance","speaker-test -t sine -f 1000 -l 1");
+ commands.put("intersection","echo 1");
+ commands.put("qr","echo 1");
+ FileInputStream in = null;
+ String ips = "";
+ String userdata = "";
+ try {
+ ssh.addHostKeyVerifier(new PromiscuousVerifier());
+ in = new FileInputStream("./ips.json");
+ int c;
+ while ((c = in.read()) != -1) {
+ ips += (char)c;
+ }
+
+ in = new FileInputStream("./userinfo.json");
+ while ((c = in.read()) != -1) {
+ userdata += (char)c;
+ }
+ usernames = new JSONObject(userdata).getJSONObject("usernames");
+ passwords = new JSONObject(userdata).getJSONObject("passwords");
+ ip_json = new JSONObject(ips);
+ ambulance_ip.setText(ip_json.getString("ambulance"));
+ intersection_ip.setText(ip_json.getString("intersection"));
+ qr_ip.setText(ip_json.getString("qr"));
+ }catch(Exception e){
+ System.out.println("[ERROR]: "+e.toString());
+ return;
+ }
+ checkState();
+ }
+
+ public void checkState(){
+ try{
+ boolean ip_correct = InetAddress.getByName(ambulance_ip.getText()).isReachable(1000);
+ if(!ip_correct){
+ throw new Exception("IP Not Reachable");
+ }
+ new Socket(ambulance_ip.getText(), 22).close();
+ ambulance_start.setEnabled(true);
+ }catch(Exception e){
+ System.out.println(e.toString());
+ ambulance_start.setEnabled(false);
+ }
+
+ try{
+ boolean ip_correct = InetAddress.getByName(ambulance_ip.getText()).isReachable(100);
+ if(!ip_correct){
+ throw new Exception("IP Not Reachable");
+ }
+ new Socket(ambulance_ip.getText(), 8385).close();
+ ambulance_state.setText("Running");
+ }catch(Exception e){
+ ambulance_state.setText("Not Running");
+ }
+
+ try{
+ boolean ip_correct = InetAddress.getByName(intersection_ip.getText()).isReachable(100);
+ if(!ip_correct){
+ throw new Exception("IP Not Reachable");
+ }
+ new Socket(intersection_ip.getText(), 22).close();
+ intersection_start.setEnabled(true);
+ }catch(Exception e){
+ intersection_start.setEnabled(false);
+ }
+
+ try{
+ boolean ip_correct = InetAddress.getByName(intersection_ip.getText()).isReachable(100);
+ if(!ip_correct){
+ throw new Exception("IP Not Reachable");
+ }
+ new Socket(intersection_ip.getText(), 8386).close();
+ intersection_state.setText("Running");
+ }catch(Exception e){
+ intersection_state.setText("Not Running");
+ }
+
+ try{
+ boolean ip_correct = InetAddress.getByName(qr_ip.getText()).isReachable(100);
+ if(!ip_correct){
+ throw new Exception("IP Not Reachable");
+ }
+ new Socket(qr_ip.getText(), 22).close();
+ qr_start.setEnabled(true);
+ }catch(Exception e){
+ qr_start.setEnabled(false);
+ }
+
+ try{
+ boolean ip_correct = InetAddress.getByName(qr_ip.getText()).isReachable(100);
+ if(!ip_correct){
+ throw new Exception("IP Not Reachable");
+ }
+ new Socket(qr_ip.getText(), 8385).close();
+ qr_state.setText("Running");
+ }catch(Exception e){
+ qr_state.setText("Not Running");
+ }
+
+
+ }
+
+ @Override
+ public void dispose(){
+ JSONObject contentJSON = new JSONObject();
+ contentJSON.put("ambulance", ambulance_ip.getText());
+ contentJSON.put("intersection", intersection_ip.getText());
+ contentJSON.put("qr", qr_ip.getText());
+ String fileContent = contentJSON.toString(4);
+ try{
+ BufferedWriter writer = new BufferedWriter(new FileWriter("./ips.json"));
+ writer.write(fileContent);
+ writer.close();
+ }catch(Exception er){
+ System.out.println("[ERROR]: "+er.toString());
+ }
+ super.dispose();
+ }
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JTextField ambulance_ip;
+ private javax.swing.JButton ambulance_start;
+ private javax.swing.JLabel ambulance_state;
+ private javax.swing.JTextField intersection_ip;
+ private javax.swing.JButton intersection_start;
+ private javax.swing.JLabel intersection_state;
+ private javax.swing.JButton jButton2;
+ private javax.swing.JButton jButton4;
+ private javax.swing.JFrame jFrame1;
+ private javax.swing.JLabel jLabel2;
+ private javax.swing.JLabel jLabel5;
+ private javax.swing.JLabel jLabel6;
+ private javax.swing.JLabel jLabel7;
+ private javax.swing.JTextField jTextField2;
+ private javax.swing.JTextField qr_ip;
+ private javax.swing.JButton qr_start;
+ private javax.swing.JLabel qr_state;
+ private javax.swing.JButton refresh_button;
+ // End of variables declaration//GEN-END:variables
+}
diff --git a/master_app/src/main/java/me/yigitcolakoglu/master_app/userinfo.json b/master_app/src/main/java/me/yigitcolakoglu/master_app/userinfo.json
new file mode 100644
index 0000000..19c4e71
--- /dev/null
+++ b/master_app/src/main/java/me/yigitcolakoglu/master_app/userinfo.json
@@ -0,0 +1,12 @@
+{
+ "usernames": {
+ "qr": "admin",
+ "ambulance": "yigit",
+ "intersection": "admin"
+ },
+ "passwords": {
+ "qr": "admin",
+ "ambulance": "Ygtclksbl1",
+ "intersection": "admin"
+ }
+}
\ No newline at end of file
diff --git a/master_app/target/classes/me/yigitcolakoglu/master_app/Main.class b/master_app/target/classes/me/yigitcolakoglu/master_app/Main.class
new file mode 100644
index 0000000..5f50643
Binary files /dev/null and b/master_app/target/classes/me/yigitcolakoglu/master_app/Main.class differ
diff --git a/master_app/target/classes/me/yigitcolakoglu/master_app/cameraForm$1.class b/master_app/target/classes/me/yigitcolakoglu/master_app/cameraForm$1.class
new file mode 100644
index 0000000..bbb0789
Binary files /dev/null and b/master_app/target/classes/me/yigitcolakoglu/master_app/cameraForm$1.class differ
diff --git a/master_app/target/classes/me/yigitcolakoglu/master_app/cameraForm$2.class b/master_app/target/classes/me/yigitcolakoglu/master_app/cameraForm$2.class
new file mode 100644
index 0000000..31b72af
Binary files /dev/null and b/master_app/target/classes/me/yigitcolakoglu/master_app/cameraForm$2.class differ
diff --git a/master_app/target/classes/me/yigitcolakoglu/master_app/cameraForm$3.class b/master_app/target/classes/me/yigitcolakoglu/master_app/cameraForm$3.class
new file mode 100644
index 0000000..1696e48
Binary files /dev/null and b/master_app/target/classes/me/yigitcolakoglu/master_app/cameraForm$3.class differ
diff --git a/master_app/target/classes/me/yigitcolakoglu/master_app/cameraForm$4.class b/master_app/target/classes/me/yigitcolakoglu/master_app/cameraForm$4.class
new file mode 100644
index 0000000..c8f4233
Binary files /dev/null and b/master_app/target/classes/me/yigitcolakoglu/master_app/cameraForm$4.class differ
diff --git a/master_app/target/classes/me/yigitcolakoglu/master_app/cameraForm$5.class b/master_app/target/classes/me/yigitcolakoglu/master_app/cameraForm$5.class
new file mode 100644
index 0000000..f503f76
Binary files /dev/null and b/master_app/target/classes/me/yigitcolakoglu/master_app/cameraForm$5.class differ
diff --git a/master_app/target/classes/me/yigitcolakoglu/master_app/cameraForm.class b/master_app/target/classes/me/yigitcolakoglu/master_app/cameraForm.class
new file mode 100644
index 0000000..00a5d2b
Binary files /dev/null and b/master_app/target/classes/me/yigitcolakoglu/master_app/cameraForm.class differ
diff --git a/master_app/target/classes/me/yigitcolakoglu/master_app/managementForm$1.class b/master_app/target/classes/me/yigitcolakoglu/master_app/managementForm$1.class
new file mode 100644
index 0000000..f1aa674
Binary files /dev/null and b/master_app/target/classes/me/yigitcolakoglu/master_app/managementForm$1.class differ
diff --git a/master_app/target/classes/me/yigitcolakoglu/master_app/managementForm$2.class b/master_app/target/classes/me/yigitcolakoglu/master_app/managementForm$2.class
new file mode 100644
index 0000000..5c6e97e
Binary files /dev/null and b/master_app/target/classes/me/yigitcolakoglu/master_app/managementForm$2.class differ
diff --git a/master_app/target/classes/me/yigitcolakoglu/master_app/managementForm$3.class b/master_app/target/classes/me/yigitcolakoglu/master_app/managementForm$3.class
new file mode 100644
index 0000000..fbd4df3
Binary files /dev/null and b/master_app/target/classes/me/yigitcolakoglu/master_app/managementForm$3.class differ
diff --git a/master_app/target/classes/me/yigitcolakoglu/master_app/managementForm$4.class b/master_app/target/classes/me/yigitcolakoglu/master_app/managementForm$4.class
new file mode 100644
index 0000000..ea4e612
Binary files /dev/null and b/master_app/target/classes/me/yigitcolakoglu/master_app/managementForm$4.class differ
diff --git a/master_app/target/classes/me/yigitcolakoglu/master_app/managementForm$5.class b/master_app/target/classes/me/yigitcolakoglu/master_app/managementForm$5.class
new file mode 100644
index 0000000..3387011
Binary files /dev/null and b/master_app/target/classes/me/yigitcolakoglu/master_app/managementForm$5.class differ
diff --git a/master_app/target/classes/me/yigitcolakoglu/master_app/managementForm$6.class b/master_app/target/classes/me/yigitcolakoglu/master_app/managementForm$6.class
new file mode 100644
index 0000000..8ef68c3
Binary files /dev/null and b/master_app/target/classes/me/yigitcolakoglu/master_app/managementForm$6.class differ
diff --git a/master_app/target/classes/me/yigitcolakoglu/master_app/managementForm$7.class b/master_app/target/classes/me/yigitcolakoglu/master_app/managementForm$7.class
new file mode 100644
index 0000000..5c699ac
Binary files /dev/null and b/master_app/target/classes/me/yigitcolakoglu/master_app/managementForm$7.class differ
diff --git a/master_app/target/classes/me/yigitcolakoglu/master_app/managementForm$8.class b/master_app/target/classes/me/yigitcolakoglu/master_app/managementForm$8.class
new file mode 100644
index 0000000..ff5972c
Binary files /dev/null and b/master_app/target/classes/me/yigitcolakoglu/master_app/managementForm$8.class differ
diff --git a/master_app/target/classes/me/yigitcolakoglu/master_app/managementForm$9.class b/master_app/target/classes/me/yigitcolakoglu/master_app/managementForm$9.class
new file mode 100644
index 0000000..8b1cd3e
Binary files /dev/null and b/master_app/target/classes/me/yigitcolakoglu/master_app/managementForm$9.class differ
diff --git a/master_app/target/classes/me/yigitcolakoglu/master_app/managementForm.class b/master_app/target/classes/me/yigitcolakoglu/master_app/managementForm.class
new file mode 100644
index 0000000..0989692
Binary files /dev/null and b/master_app/target/classes/me/yigitcolakoglu/master_app/managementForm.class differ
diff --git a/master_app/target/master_app-1.0-SNAPSHOT.jar b/master_app/target/master_app-1.0-SNAPSHOT.jar
new file mode 100644
index 0000000..a2f1840
Binary files /dev/null and b/master_app/target/master_app-1.0-SNAPSHOT.jar differ
diff --git a/master_app/target/maven-archiver/pom.properties b/master_app/target/maven-archiver/pom.properties
new file mode 100644
index 0000000..3e8e045
--- /dev/null
+++ b/master_app/target/maven-archiver/pom.properties
@@ -0,0 +1,5 @@
+#Generated by Maven
+#Fri May 24 18:58:10 EET 2019
+groupId=me.yigitcolakoglu
+artifactId=master_app
+version=1.0-SNAPSHOT
diff --git a/master_app/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/master_app/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
new file mode 100644
index 0000000..bd2a493
--- /dev/null
+++ b/master_app/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
@@ -0,0 +1,17 @@
+me/yigitcolakoglu/master_app/managementForm$4.class
+me/yigitcolakoglu/master_app/cameraForm$3.class
+me/yigitcolakoglu/master_app/cameraForm$2.class
+me/yigitcolakoglu/master_app/managementForm$3.class
+me/yigitcolakoglu/master_app/cameraForm$5.class
+me/yigitcolakoglu/master_app/Main.class
+me/yigitcolakoglu/master_app/managementForm$7.class
+me/yigitcolakoglu/master_app/cameraForm$1.class
+me/yigitcolakoglu/master_app/managementForm.class
+me/yigitcolakoglu/master_app/managementForm$1.class
+me/yigitcolakoglu/master_app/managementForm$2.class
+me/yigitcolakoglu/master_app/managementForm$8.class
+me/yigitcolakoglu/master_app/managementForm$6.class
+me/yigitcolakoglu/master_app/managementForm$9.class
+me/yigitcolakoglu/master_app/cameraForm$4.class
+me/yigitcolakoglu/master_app/managementForm$5.class
+me/yigitcolakoglu/master_app/cameraForm.class
diff --git a/master_app/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/master_app/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
new file mode 100644
index 0000000..ba9dad0
--- /dev/null
+++ b/master_app/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
@@ -0,0 +1,3 @@
+/home/yigit/projects/MyCity/traffic_analyzer/master_app/src/main/java/me/yigitcolakoglu/master_app/managementForm.java
+/home/yigit/projects/MyCity/traffic_analyzer/master_app/src/main/java/me/yigitcolakoglu/master_app/cameraForm.java
+/home/yigit/projects/MyCity/traffic_analyzer/master_app/src/main/java/me/yigitcolakoglu/master_app/Main.java
diff --git a/master_app/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/master_app/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst
new file mode 100644
index 0000000..e69de29
diff --git a/server_side/Chatbot/keywords.json b/server_side/Chatbot/keywords.json
deleted file mode 100644
index 4e68684..0000000
--- a/server_side/Chatbot/keywords.json
+++ /dev/null
@@ -1,25 +0,0 @@
-[
- {
- "1": ["weather","temparature","hot"]
- },
-
- {
- "1":{
- "url":"https://api.openweathermap.org/data/2.5/weather",
- "parameters": {"q": "GPE"},
- "defaults": {"q": "location"},
- "apikey": {"appid": "3b0dabc605b0ed0d411b6119846d1321"},
- "response": "json",
- "data_to_receive": {
- "name": {},
- "weather": [
- {
- "main": {}
- }
- ],
- "main": {"temp": {}}
- },
- "output_format": "Today in {name}, it is {temp} with {main}"
- }
- }
-]
\ No newline at end of file
diff --git a/server_side/Chatbot/main.py b/server_side/Chatbot/main.py
deleted file mode 100644
index 89e1d70..0000000
--- a/server_side/Chatbot/main.py
+++ /dev/null
@@ -1,121 +0,0 @@
-import json
-import requests
-from stanford_parser.parser import Parser
-import nltk
-import nltk.corpus as corpus
-
-def getData( searched, data, data_final ):
- if type( searched ) is dict:
- for key in searched:
- if len( searched[ key ] ) == 0:
- data_final[ key ] = data[ key ]
- else:
- getData( searched[ key ], data[ key ], data_final )
-
- elif type( searched ) is list:
- for key in range( len( searched ) ):
- if len( searched[ key ] ) == 0:
- data_final[ key ] = data[ key ]
- else:
- getData( searched[ key ], data[ key ], data_final )
-parser = Parser()
-while True:
- sentence = raw_input("You:")
-
- #Parse the input
- tokenized = nltk.word_tokenize( sentence )
- stop_words = set( corpus.stopwords.words( 'english' ) )
- cleaned = [ w for w in tokenized if w not in stop_words ]
- tagged = nltk.pos_tag( cleaned )
- named = nltk.ne_chunk( tagged )
- cleaned_sentence = " ".join( cleaned )
- dependencies = parser.parseToStanfordDependencies( cleaned_sentence )
- tupleResult = [ (rel, gov.text, dep.text) for rel, gov, dep in dependencies.dependencies ]
-
- #Read the files
- files = [open("user_details.json","r"),open('keywords.json', 'r'),open('predefined.json', 'r')]
- defaults = json.loads(files[0].read())
- keywords = json.loads( files[1 ].read() )
- predefined = json.loads(files[2].read())
-
- print("[TAGGED]: " + str( tagged ) + "\n")
- print("[SPECIAL]: " + str( named ) + "\n")
- print("[CLEAN]: " + str( cleaned_sentence ) + "\n")
- print("[DEPENDENCIES]: " + str( tupleResult ) + "\n")
-
- wp_word = ""
-
- for i in range( len( tagged ) ):
- if tagged[ i ][ 1 ] == "WP" or tagged[ i ][ 1 ] == "WRB" or tagged[ i ][ 1 ] == "WP$":
- wp_word = tagged[ i ][ 0 ]
-
- if sentence in predefined:
- print(predefined[sentence])
-
- else:
-
- if not wp_word == "":
- key = ""
- understood = False
- key_connect = ""
- for dep in tupleResult:
- if dep[2] == wp_word:
- key = dep[1]
-
- for dep in tupleResult:
- if dep[1]==key: key_connect=dep[2]
-
-
- for keyword_id in keywords[0 ]:
- if key in keywords[0 ][keyword_id ]:
- key = keyword_id
- understood = True
-
- if(understood):
- api_details = keywords[ 1 ][ key ]
- params = api_details[ "parameters" ]
-
- for i in named:
- for j in params:
- try:
- i.label()
- if i.label() == params[ j ]:
- params[j] = i[0]
- else:
- params[j] = defaults[api_details["defaults"][j]]
- except Exception:
- if i[0]==key_connect:
- params[j] = defaults[api_details["defaults"][j]]
-
-
-
- params[ api_details[ 'apikey' ].keys()[ 0 ] ] = api_details[ 'apikey' ][ api_details[ 'apikey' ].keys()[ 0 ] ]
- r = requests.get( url=api_details[ "url" ], params=params )
- data = r.json()
- data_final = {}
- getData(api_details[ "data_to_receive" ], data, data_final)
- out_format = api_details[ "output_format" ]
- out_final = ""
-
- isvar = False
- for let in out_format:
- if (let == "{"):
- var = ""
- isvar = True
- continue
- if not isvar:
- out_final += let
- else:
- if let == "}":
- out_final += str( data_final[ var ] )
- isvar = False
- else:
- var += let
-
- print ("[KEYWORD]: " + key + "\n")
- print ("[KEYWORD_ID]: " + key + "\n")
- print (out_final)
- else:
- print("Sorry, I didn't quite get that")
- else:
- print("Sorry, I didn't quite get that")
diff --git a/server_side/Chatbot/parser_test.py b/server_side/Chatbot/parser_test.py
deleted file mode 100644
index 115ed6f..0000000
--- a/server_side/Chatbot/parser_test.py
+++ /dev/null
@@ -1,86 +0,0 @@
-import unittest
-
-
-class TestCase(unittest.TestCase):
- @classmethod
- def setUpClass(self):
- from stanford_parser.parser import Parser
- self.parser = Parser()
-
- def testParse(self):
-
- dependencies = self.parser.parseToStanfordDependencies("Pick up the tire pallet.")
-
- tupleResult = [(rel, gov.text, dep.text) for rel, gov, dep in dependencies.dependencies]
- self.assertEqual(tupleResult, [('prt', 'Pick', 'up'),
- ('det', 'pallet', 'the'),
- ('nn', 'pallet', 'tire'),
- ('dobj', 'Pick', 'pallet')])
-
- self.assertEqual(dependencies.tagForTokenStandoff(gov), "VB")
- self.assertEqual(dependencies.tagForTokenStandoff(dep), "NN")
-
- def testParseRefexpNextTo(self):
- dependencies = self.parser.parseToStanfordDependencies("Pick up the tire pallet next to the truck.")
-
- tupleResult = [(rel, gov.text, dep.text) for rel, gov, dep in dependencies.dependencies]
-
-
- self.assertEqual(tupleResult,
- [('prt', 'Pick', 'up'),
- ('det', 'pallet', 'the'),
- ('nn', 'pallet', 'tire'),
- ('dobj', 'Pick', 'pallet'),
- ('det', 'truck', 'the'),
- ('prep_next_to', 'pallet', 'truck')])
-
-
- def testParseRefexpNear(self):
- dependencies =self.parser.parseToStanfordDependencies("Pick up the tire pallet near the truck.")
-
- tupleResult = [(rel, gov.text, dep.text) for rel, gov, dep in dependencies.dependencies]
- self.assertEqual(tupleResult,
- [('prt', 'Pick', 'up'),
- ('det', 'pallet', 'the'),
- ('nn', 'pallet', 'tire'),
- ('dobj', 'Pick', 'pallet'),
- ('det', 'truck', 'the'),
- ('prep_near', 'pallet', 'truck')])
-
-
-
- def testParseLong(self):
-
- # this sentence has a self dependency that the python code filters out.
- # between drop and drop.
- dependencies = self.parser.parseToStanfordDependencies("Grab the skid of tires right in front of you " +
- "and drop it off just in front and to the " +
- "right of the far skid of tires.")
-
- tupleResult = [(rel, gov.text, dep.text) for rel, gov, dep in dependencies.dependencies]
- self.assertEqual(tupleResult,
- [('det', 'skid', 'the'), ('dobj', 'Grab', 'skid'),
- ('prep_of', 'skid', 'tires'), ('dep', 'Grab', 'right'),
- ('prep_in', 'Grab', 'front'), ('prep_of', 'front', 'you'),
- ('conj_and', 'Grab', 'drop'), ('dobj', 'drop', 'it'), ('prt', 'drop', 'off'),
- ('advmod', 'drop', 'just'), ('prep_in', 'drop', 'front'), ('det', 'right', 'the'),
- ('prep_to', 'drop', 'right'), ('det', 'skid', 'the'), ('amod', 'skid', 'far'),
- ('prep_of', 'right', 'skid'), ('prep_of', 'skid', 'tires')])
-
-
-
- def testAllCaps(self):
- dependencies = self.parser.parseToStanfordDependencies("GO TO THE TIRE PALLET NEXT TO THE TRUCK.")
- tupleResult = [(rel, gov.text, dep.text) for rel, gov, dep in dependencies.dependencies]
- self.assertEqual(tupleResult,
- [('nn', 'PALLET', 'GO'),
- ('nn', 'PALLET', 'TO'),
- ('nn', 'PALLET', 'THE'),
- ('nn', 'PALLET', 'TIRE'),
- ('nsubj', 'NEXT', 'PALLET'),
- ('dep', 'NEXT', 'TO'),
- ('det', 'TRUCK', 'THE'),
- ('dobj', 'TO', 'TRUCK')])
-
-
-
diff --git a/server_side/Chatbot/predefined.json b/server_side/Chatbot/predefined.json
deleted file mode 100644
index a83d3b3..0000000
--- a/server_side/Chatbot/predefined.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "How are you?": "I am fine and you?",
- "I am fine too": "That is good to hear"
-}
\ No newline at end of file
diff --git a/server_side/Chatbot/train.py b/server_side/Chatbot/train.py
deleted file mode 100644
index 3ae037e..0000000
--- a/server_side/Chatbot/train.py
+++ /dev/null
@@ -1,72 +0,0 @@
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-from __future__ import unicode_literals
-
-import argparse
-import warnings
-
-from rasa_nlu.training_data import load_data
-from rasa_nlu import config
-from rasa_nlu.model import Trainer
-
-import rasa_core
-from rasa_core.agent import Agent
-from rasa_core.policies.keras_policy import KerasPolicy
-from rasa_core.policies.memoization import MemoizationPolicy
-
-
-def train_nlu():
- training_data = load_data('data/nlu-data.md')
- trainer = Trainer(config.load("nlu-config.yml"))
- trainer.train(training_data)
- model_directory = trainer.persist('models/nlu/', fixed_model_name="current")
- return model_directory
-
-
-def train_dialogue(
- domain_file="domain.yml",
- model_path="models/dialogue",
- training_data_file="data/stories.md"
-):
- agent = Agent(
- domain_file,
- policies=[MemoizationPolicy(max_history=3), KerasPolicy()]
- )
- training_data = agent.load_data(training_data_file)
- agent.train(
- training_data,
- epochs=400,
- batch_size=100,
- validation_split=0.2
- )
- agent.persist(model_path)
- return agent
-
-
-def train_all():
- model_directory = train_nlu()
- agent = train_dialogue()
- return [model_directory, agent]
-
-
-if __name__ == '__main__':
- warnings.filterwarnings(action='ignore', category=DeprecationWarning)
- rasa_core.utils.configure_colored_logging(loglevel="INFO")
-
- parser = argparse.ArgumentParser(
- description='starts the bot training')
-
- parser.add_argument(
- 'task',
- choices=["train-nlu", "train-dialogue", "train-all"],
- help="what the bot should do?")
- task = parser.parse_args().task
-
- # decide what to do based on first parameter of the script
- if task == "train-nlu":
- train_nlu()
- elif task == "train-dialogue":
- train_dialogue()
- elif task == "train-all":
- train_all()
\ No newline at end of file
diff --git a/server_side/Chatbot/user_details.json b/server_side/Chatbot/user_details.json
deleted file mode 100644
index 9962a72..0000000
--- a/server_side/Chatbot/user_details.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "location": "Ankara"
-}
\ No newline at end of file
diff --git a/traffic_analyzer/.idea/misc.xml b/traffic_analyzer/.idea/misc.xml
new file mode 100644
index 0000000..28a804d
--- /dev/null
+++ b/traffic_analyzer/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/traffic_analyzer/.idea/modules.xml b/traffic_analyzer/.idea/modules.xml
new file mode 100644
index 0000000..543b3a6
--- /dev/null
+++ b/traffic_analyzer/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/traffic_analyzer/.idea/serialmonitor_settings.xml b/traffic_analyzer/.idea/serialmonitor_settings.xml
new file mode 100644
index 0000000..b45564e
--- /dev/null
+++ b/traffic_analyzer/.idea/serialmonitor_settings.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/traffic_analyzer/.idea/vcs.xml b/traffic_analyzer/.idea/vcs.xml
new file mode 100644
index 0000000..6c0b863
--- /dev/null
+++ b/traffic_analyzer/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/traffic_analyzer/.idea/workspace.xml b/traffic_analyzer/.idea/workspace.xml
new file mode 100644
index 0000000..7e19771
--- /dev/null
+++ b/traffic_analyzer/.idea/workspace.xml
@@ -0,0 +1,141 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1558953924923
+
+
+ 1558953924923
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/traffic_analyzer/light_control/.idea/.name b/traffic_analyzer/light_control/.idea/.name
new file mode 100644
index 0000000..e998e5e
--- /dev/null
+++ b/traffic_analyzer/light_control/.idea/.name
@@ -0,0 +1 @@
+untitled_0
\ No newline at end of file
diff --git a/traffic_analyzer/light_control/.idea/misc.xml b/traffic_analyzer/light_control/.idea/misc.xml
new file mode 100644
index 0000000..8822db8
--- /dev/null
+++ b/traffic_analyzer/light_control/.idea/misc.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/traffic_analyzer/light_control/.idea/modules.xml b/traffic_analyzer/light_control/.idea/modules.xml
new file mode 100644
index 0000000..00a4dc4
--- /dev/null
+++ b/traffic_analyzer/light_control/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/traffic_analyzer/light_control/.idea/serialmonitor_settings.xml b/traffic_analyzer/light_control/.idea/serialmonitor_settings.xml
new file mode 100644
index 0000000..b45564e
--- /dev/null
+++ b/traffic_analyzer/light_control/.idea/serialmonitor_settings.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/traffic_analyzer/light_control/.idea/vcs.xml b/traffic_analyzer/light_control/.idea/vcs.xml
new file mode 100644
index 0000000..b2bdec2
--- /dev/null
+++ b/traffic_analyzer/light_control/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/traffic_analyzer/light_control/.idea/workspace.xml b/traffic_analyzer/light_control/.idea/workspace.xml
new file mode 100644
index 0000000..b36b37b
--- /dev/null
+++ b/traffic_analyzer/light_control/.idea/workspace.xml
@@ -0,0 +1,200 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1558953945551
+
+
+ 1558953945551
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/traffic_analyzer/light_control/light_control.ino b/traffic_analyzer/light_control/light_control.ino
new file mode 100644
index 0000000..67bc00a
--- /dev/null
+++ b/traffic_analyzer/light_control/light_control.ino
@@ -0,0 +1,190 @@
+#include
+#include
+
+#include // std::min
+
+#ifndef STASSID
+#define STASSID "ZyXEL5500bT5"
+#define STAPSK "eBusgxczl5"
+#endif
+
+/*
+ SWAP_PINS:
+ 0: use Serial1 for logging (legacy example)
+ 1: configure Hardware Serial port on RX:GPIO13 TX:GPIO15
+ and use SoftwareSerial for logging on
+ standard Serial pins RX:GPIO3 and TX:GPIO1
+*/
+
+#define SWAP_PINS 0
+
+/*
+ SERIAL_LOOPBACK
+ 0: normal serial operations
+ 1: RX-TX are internally connected (loopback)
+*/
+
+#define SERIAL_LOOPBACK 0
+
+#define BAUD_SERIAL 115200
+#define BAUD_LOGGER 115200
+#define RXBUFFERSIZE 1024
+
+////////////////////////////////////////////////////////////
+
+#if SERIAL_LOOPBACK
+#undef BAUD_SERIAL
+#define BAUD_SERIAL 3000000
+#include
+#endif
+
+#if SWAP_PINS
+#include
+SoftwareSerial* logger = nullptr;
+#else
+#define logger (&Serial1)
+#endif
+
+#define STACK_PROTECTOR 512 // bytes
+
+//how many clients should be able to telnet to this ESP8266
+#define MAX_SRV_CLIENTS 2
+const char* ssid = STASSID;
+const char* password = STAPSK;
+
+const int port = 23;
+
+WiFiServer server(port);
+WiFiClient serverClients[MAX_SRV_CLIENTS];
+
+void setup() {
+
+ Serial.begin(BAUD_SERIAL);
+ Serial.setRxBufferSize(RXBUFFERSIZE);
+
+#if SWAP_PINS
+ Serial.swap();
+ // Hardware serial is now on RX:GPIO13 TX:GPIO15
+ // use SoftwareSerial on regular RX(3)/TX(1) for logging
+ logger = new SoftwareSerial(3, 1);
+ logger->begin(BAUD_LOGGER);
+ logger->println("\n\nUsing SoftwareSerial for logging");
+#else
+ logger->begin(BAUD_LOGGER);
+ logger->println("\n\nUsing Serial1 for logging");
+#endif
+ logger->println(ESP.getFullVersion());
+ logger->printf("Serial baud: %d (8n1: %d KB/s)\n", BAUD_SERIAL, BAUD_SERIAL * 8 / 10 / 1024);
+ logger->printf("Serial receive buffer size: %d bytes\n", RXBUFFERSIZE);
+
+#if SERIAL_LOOPBACK
+ USC0(0) |= (1 << UCLBE); // incomplete HardwareSerial API
+ logger->println("Serial Internal Loopback enabled");
+#endif
+
+ WiFi.mode(WIFI_STA);
+ WiFi.begin(ssid, password);
+ logger->print("\nConnecting to ");
+ logger->println(ssid);
+ while (WiFi.status() != WL_CONNECTED) {
+ logger->print('.');
+ delay(500);
+ }
+ logger->println();
+ logger->print("connected, address=");
+ logger->println(WiFi.localIP());
+
+ //start server
+ server.begin();
+ server.setNoDelay(true);
+
+ logger->print("Ready! Use 'telnet ");
+ logger->print(WiFi.localIP());
+ logger->printf(" %d' to connect\n", port);
+}
+
+void loop() {
+ //check if there are any new clients
+ if (server.hasClient()) {
+ //find free/disconnected spot
+ int i;
+ for (i = 0; i < MAX_SRV_CLIENTS; i++)
+ if (!serverClients[i]) { // equivalent to !serverClients[i].connected()
+ serverClients[i] = server.available();
+ logger->print("New client: index ");
+ logger->print(i);
+ break;
+ }
+
+ //no free/disconnected spot so reject
+ if (i == MAX_SRV_CLIENTS) {
+ server.available().println("busy");
+ // hints: server.available() is a WiFiClient with short-term scope
+ // when out of scope, a WiFiClient will
+ // - flush() - all data will be sent
+ // - stop() - automatically too
+ logger->printf("server is busy with %d active connections\n", MAX_SRV_CLIENTS);
+ }
+ }
+
+ //check TCP clients for data
+#if 1
+ // Incredibly, this code is faster than the bufferred one below - #4620 is needed
+ // loopback/3000000baud average 348KB/s
+ for (int i = 0; i < MAX_SRV_CLIENTS; i++)
+ while (serverClients[i].available() && Serial.availableForWrite() > 0) {
+ // working char by char is not very efficient
+ Serial.write(serverClients[i].read());
+ }
+#else
+ // loopback/3000000baud average: 312KB/s
+ for (int i = 0; i < MAX_SRV_CLIENTS; i++)
+ while (serverClients[i].available() && Serial.availableForWrite() > 0) {
+ size_t maxToSerial = std::min(serverClients[i].available(), Serial.availableForWrite());
+ maxToSerial = std::min(maxToSerial, (size_t)STACK_PROTECTOR);
+ uint8_t buf[maxToSerial];
+ size_t tcp_got = serverClients[i].read(buf, maxToSerial);
+ size_t serial_sent = Serial.write(buf, tcp_got);
+ if (serial_sent != maxToSerial) {
+ logger->printf("len mismatch: available:%zd tcp-read:%zd serial-write:%zd\n", maxToSerial, tcp_got, serial_sent);
+ }
+ }
+#endif
+
+ // determine maximum output size "fair TCP use"
+ // client.availableForWrite() returns 0 when !client.connected()
+ size_t maxToTcp = 0;
+ for (int i = 0; i < MAX_SRV_CLIENTS; i++)
+ if (serverClients[i]) {
+ size_t afw = serverClients[i].availableForWrite();
+ if (afw) {
+ if (!maxToTcp) {
+ maxToTcp = afw;
+ } else {
+ maxToTcp = std::min(maxToTcp, afw);
+ }
+ } else {
+ // warn but ignore congested clients
+ logger->println("one client is congested");
+ }
+ }
+
+ //check UART for data
+ size_t len = std::min((size_t)Serial.available(), maxToTcp);
+ len = std::min(len, (size_t)STACK_PROTECTOR);
+ if (len) {
+ uint8_t sbuf[len];
+ size_t serial_got = Serial.readBytes(sbuf, len);
+ // push UART data to all connected telnet clients
+ for (int i = 0; i < MAX_SRV_CLIENTS; i++)
+ // if client.availableForWrite() was 0 (congested)
+ // and increased since then,
+ // ensure write space is sufficient:
+ if (serverClients[i].availableForWrite() >= serial_got) {
+ size_t tcp_sent = serverClients[i].write(sbuf, serial_got);
+ if (tcp_sent != len) {
+ logger->printf("len mismatch: available:%zd serial-read:%zd tcp-write:%zd\n", len, serial_got, tcp_sent);
+ }
+ }
+ }
+}
\ No newline at end of file