diff --git a/src/main/java/ch/hevs/isi/MinecraftController.java b/src/main/java/ch/hevs/isi/MinecraftController.java index 2aec9fd..62a064d 100644 --- a/src/main/java/ch/hevs/isi/MinecraftController.java +++ b/src/main/java/ch/hevs/isi/MinecraftController.java @@ -23,14 +23,15 @@ public class MinecraftController { System.out.println(); System.out.println("In development mode, just add to your running configuration the needed parameters (see usage below)."); System.out.println("In running mode, the application's usage is the following:"); - System.out.println("java MinecraftController [-modbus4j] [-keepAlive]"); + System.out.println("java MinecraftController [-erasedb]"); System.out.println("where:"); - System.out.println("- : The complete URL of the InfluxDB server, including the protocol (http or https)..."); + System.out.println("- : The complete URL of the InfluxDB server, including the protocol (http or https)..."); System.out.println(" Example: https://influx.sdi.hevs.ch"); - System.out.println("- : The name of the Influx DB to use. For this project, this name is the name of the group you've been affected to. (SInXX)"); - System.out.println("- : The IP address of the Minecraft ModbusTCP server (default value: localhost)"); - System.out.println("- : The port number of the Minecraft ModbusTCP server (default value: 1502)"); + System.out.println("- : The name of the Influx DB to use. For this project, this name is the name of the group you've been affected to. (SInXX)"); + System.out.println("- : The user's name to use to access the DB. It's also your group's name. (SInXX)"); + System.out.println("- : The Token to use to access the DB."); + System.out.println("- : The IP address of the Minecraft ModbusTCP server (default value: localhost)"); + System.out.println("- : The port number of the Minecraft ModbusTCP server (default value: 1502)"); System.out.println("- [-eraseDB]: Optional parameter! If set, the application will erase the previous data in InfluxDB..."); System.out.println(); System.exit(1); @@ -45,6 +46,7 @@ public class MinecraftController { String dbName = "labo"; String dbUserName = "root"; String dbPassword = "root"; + String dbToken = "super-token"; String modbusTcpHost = "localhost"; int modbusTcpPort = 1502; @@ -53,7 +55,7 @@ public class MinecraftController { String[] parameters = null; // If there is only one number given as parameter, construct the parameters according the group number. - if (args.length >= 5) { + if (args.length >= 6) { parameters = args; // Decode parameters for influxDB @@ -67,10 +69,11 @@ public class MinecraftController { dbName = parameters[1]; dbUserName = parameters[2]; dbPassword = Utility.md5sum(dbUserName); + dbToken = parameters[3]; // Decode parameters for Modbus TCP - modbusTcpHost = parameters[3]; - modbusTcpPort = Integer.parseInt(parameters[4]); + modbusTcpHost = parameters[4]; + modbusTcpPort = Integer.parseInt(parameters[5]); for (int i = 5; i < args.length; i++) { if (parameters[i].compareToIgnoreCase("-erasedb") == 0) { @@ -84,11 +87,13 @@ public class MinecraftController { // ------------------------------------ /DO NOT CHANGE THE FOLLOWING LINES ------------------------------------- // Read the config.properties file - try (InputStream input = new FileInputStream("src/config.properties")) { + /* + try (InputStream input = new FileInputStream("config.properties")) { properties.load(input); } catch (Exception e) { e.printStackTrace(); } + */ // Initialize the database connector if(dbName != null){ @@ -97,21 +102,25 @@ public class MinecraftController { if(dbUserName != null){ DatabaseConnector.bucket = dbUserName; } + + DatabaseConnector.token = dbToken; if((dbProtocol != null) && (dbHostName != null)){ DatabaseConnector.url = dbProtocol+ "://" + dbHostName; - Utility.pDebug("Database URL: " + DatabaseConnector.url); - Utility.pDebug("Config: " + properties.getProperty("DB.URL")); DatabaseConnector.getMySelf().initialize(DatabaseConnector.url); System.out.println("Database is running on " + DatabaseConnector.url); } // Initialize the Modbus TCP connector - FieldConnector.getMySelf().initialize(modbusTcpHost, modbusTcpPort,"src/main/resources/ModbusMap.csv"); + FieldConnector.getMySelf().initialize(modbusTcpHost, modbusTcpPort,"ModbusMap.csv"); System.out.println("Field is running on " + modbusTcpHost + ":" + modbusTcpPort); // Initialize the web server + /* String host = properties.getProperty("WEB.URL"); int port = Integer.parseInt(properties.getProperty("WEB.PORT")); + */ + String host = "localhost"; + int port = 8888; WebConnector.getMySelf().initialize(host, port); System.out.println("Web server is running on " + host + ":" + port);