Merge remote-tracking branch 'origin/master'

This commit is contained in:
lukas-heiligenbrunner 2019-12-06 12:24:58 +01:00
commit f132ca9602
5 changed files with 35 additions and 38 deletions

View File

@ -1,7 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" /> <component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_13" project-jdk-name="13" project-jdk-type="JavaSDK"> <component name="JavaScriptSettings">
<option name="languageLevel" value="ES6" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="11" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" /> <output url="file://$PROJECT_DIR$/out" />
</component> </component>
</project> </project>

View File

@ -28,13 +28,14 @@ public class main {
Log.message("initial login to db"); Log.message("initial login to db");
new Thread(() -> { new Thread(() -> {
try { try {
JDCB.init("users", "kOpaIJUjkgb9ur6S", "wasteinformation","192.168.65.15",3306); JDCB.init("users", "kOpaIJUjkgb9ur6S", "wasteinformation", "192.168.65.15", 3306);
} catch (IOException e) { } catch (IOException e) {
//e.printStackTrace(); //e.printStackTrace();
Log.error("no connection to db"); Log.error("no connection to db");
} }
}).start(); }).start();
//startup web server //startup web server
Thread mythread = new Thread(() -> new Webserver().startserver()); Thread mythread = new Thread(() -> new Webserver().startserver());
mythread.start(); mythread.start();
@ -42,13 +43,11 @@ public class main {
//startup mqtt service //startup mqtt service
Log.message("starting mqtt service"); Log.message("starting mqtt service");
try{ try {
mqtt m = new mqtt(); mqtt m = new mqtt();
m.notifymessage(); m.notifymessage();
}catch (Exception e){ } catch (Exception e) {
e.printStackTrace(); Log.debug("An error was happened in the class mqtt");
} }
} }
} }

View File

@ -33,7 +33,7 @@ public class mqtt {
client.connect(connOpts); client.connect(connOpts);
} catch (MqttException e) { } catch (MqttException e) {
e.printStackTrace(); Log.error("Connection to the ESB was failes");
} }
mqttreceiver mr = new mqttreceiver(client); mqttreceiver mr = new mqttreceiver(client);
@ -56,7 +56,7 @@ public class mqtt {
try { try {
Database = JDCB.getInstance(); Database = JDCB.getInstance();
} catch (IOException e) { } catch (IOException e) {
//e.printStackTrace(); Log.error("No Connection to the databank");
} }
//new JDCB("placeuser", "eaL956R6yFItQVBl", "wasteinformation"); //new JDCB("placeuser", "eaL956R6yFItQVBl", "wasteinformation");
ResultSet result = Database.executeQuery(message); ResultSet result = Database.executeQuery(message);
@ -77,23 +77,22 @@ public class mqtt {
String tempyearnew = yearsplit[1]; String tempyearnew = yearsplit[1];
String newDate = parts[2] + "." + parts[1] + ".20" + tempyearnew; String newDate = parts[2] + "." + parts[1] + ".20" + tempyearnew;
String[] partstwo = date.split(" "); String[] partstwo = date.split(" ");
String Datetomorrow=nexDayDate(); String Datetomorrow = nexDayDate();
int abholtag; int abholtag;
if (partstwo[0].contains(newDate)||partstwo[0].contains(Datetomorrow)) { if (partstwo[0].contains(newDate) || partstwo[0].contains(Datetomorrow)) {
abholtag = 1; abholtag = 1;
transmitmessageAbfallart(clientidentify + "," + wastetyp + "," + abholtag); transmitmessageAbfallart(clientidentify + "," + wastetyp + "," + abholtag);
}else { } else {
abholtag=0; abholtag = 0;
transmitmessageAbfallart(clientidentify + "," + wastetyp + "," + abholtag); transmitmessageAbfallart(clientidentify + "," + wastetyp + "," + abholtag);
} }
} }
} }
} catch (SQLException e) { } catch (SQLException e) {
System.out.println("Exception"); Log.error("No data from databank");
e.printStackTrace();
} }
} }
@ -116,12 +115,9 @@ public class mqtt {
c.add(Calendar.DATE, 1); c.add(Calendar.DATE, 1);
Date currentDatePlusOne = c.getTime(); Date currentDatePlusOne = c.getTime();
String temp=dateFormat.format(currentDatePlusOne); String temp = dateFormat.format(currentDatePlusOne);
String split[]=temp.split("/"); String split[] = temp.split("/");
String newDate=split[2]+"."+split[1]+"."+split[0]; String newDate = split[2] + "." + split[1] + "." + split[0];
return newDate; return newDate;
} }
} }

View File

@ -27,12 +27,12 @@ public class mqttreceiver {
client.setCallback(new MqttCallback() { client.setCallback(new MqttCallback() {
@Override @Override
public void connectionLost(Throwable throwable) { public void connectionLost(Throwable throwable) {
Log.error("connection lost"); Log.error("connection lost");
} }
@Override @Override
public void messageArrived(String s, MqttMessage mqttMessage) throws Exception { public void messageArrived(String s, MqttMessage mqttMessage) throws Exception {
message =new String(mqttMessage.getPayload()); message = new String(mqttMessage.getPayload());
notifylisteners(message); notifylisteners(message);
} }
@ -45,7 +45,7 @@ Log.error("connection lost");
client.subscribe("TopicIn"); client.subscribe("TopicIn");
Log.debug("subscribed topic"); Log.debug("subscribed topic");
} catch (MqttException e) { } catch (MqttException e) {
e.printStackTrace(); Log.error("Connection to the ESB was failed");
} }
return message; return message;
} }

View File

@ -12,7 +12,7 @@ public class mqtttransmitter {
MqttClient client; MqttClient client;
public mqtttransmitter(MqttClient client) { public mqtttransmitter(MqttClient client) {
this.client=client; this.client = client;
} }
public void sendmessage(String temp) { public void sendmessage(String temp) {
@ -36,7 +36,6 @@ public class mqtttransmitter {
Log.debug("loc " + me.getLocalizedMessage()); Log.debug("loc " + me.getLocalizedMessage());
Log.debug("cause " + me.getCause()); Log.debug("cause " + me.getCause());
Log.debug("excep " + me); Log.debug("excep " + me);
me.printStackTrace();
} }
} }
} }