fix path for JAR
This commit is contained in:
parent
2acbad0ef1
commit
8652123986
@ -24,7 +24,7 @@ public class DatabaseConnector implements DataPointListener {
|
|||||||
private boolean initialized = false; // Boolean to know if the database connector is initialized
|
private boolean initialized = false; // Boolean to know if the database connector is initialized
|
||||||
private final TimeManager _timeManager = new TimeManager(3); // Time manager to manage the time of the data points
|
private final TimeManager _timeManager = new TimeManager(3); // Time manager to manage the time of the data points
|
||||||
private long _timestamp = 0; // Timestamp of the data points
|
private long _timestamp = 0; // Timestamp of the data points
|
||||||
String default_token = System.getenv("SECRET_TOKEN"); // Token to access the InfluxDB server
|
public static String token = System.getenv("SECRET_TOKEN"); // Token to access the InfluxDB server
|
||||||
public static String url = null; // URL of the InfluxDB server
|
public static String url = null; // URL of the InfluxDB server
|
||||||
public static String org = null; // Organization of the InfluxDB server
|
public static String org = null; // Organization of the InfluxDB server
|
||||||
public static String bucket = null; // Bucket of the InfluxDB server
|
public static String bucket = null; // Bucket of the InfluxDB server
|
||||||
@ -38,7 +38,8 @@ public class DatabaseConnector implements DataPointListener {
|
|||||||
*/
|
*/
|
||||||
private DatabaseConnector (){
|
private DatabaseConnector (){
|
||||||
// Read the config.properties file
|
// Read the config.properties file
|
||||||
try (InputStream input = Files.newInputStream(Paths.get("src/config.properties"))) {
|
/*
|
||||||
|
try (InputStream input = Files.newInputStream(Paths.get("config.properties"))) {
|
||||||
properties.load(input);
|
properties.load(input);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -54,6 +55,7 @@ public class DatabaseConnector implements DataPointListener {
|
|||||||
if (bucket == null){
|
if (bucket == null){
|
||||||
bucket = properties.getProperty("DB.BUCKET");
|
bucket = properties.getProperty("DB.BUCKET");
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// Subscribe to the update of DataPoints
|
// Subscribe to the update of DataPoints
|
||||||
DataPointListener.subscribeUpdate(this);
|
DataPointListener.subscribeUpdate(this);
|
||||||
@ -79,9 +81,11 @@ public class DatabaseConnector implements DataPointListener {
|
|||||||
String fullURL;
|
String fullURL;
|
||||||
try{
|
try{
|
||||||
if(urlForWrite == null){
|
if(urlForWrite == null){
|
||||||
|
/*
|
||||||
if(url == null){
|
if(url == null){
|
||||||
url = properties.getProperty("DB.URL");
|
url = properties.getProperty("DB.URL");
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
fullURL = url + "/api/v2/write?org=" + org + "&bucket=" + bucket;
|
fullURL = url + "/api/v2/write?org=" + org + "&bucket=" + bucket;
|
||||||
Utility.pDebug("URL: " + fullURL);
|
Utility.pDebug("URL: " + fullURL);
|
||||||
urlForWrite = new URL(fullURL);
|
urlForWrite = new URL(fullURL);
|
||||||
@ -102,7 +106,7 @@ public class DatabaseConnector implements DataPointListener {
|
|||||||
// Create the connection to the database
|
// Create the connection to the database
|
||||||
con = (HttpURLConnection) urlForDelete.openConnection();
|
con = (HttpURLConnection) urlForDelete.openConnection();
|
||||||
con.setRequestMethod("POST");
|
con.setRequestMethod("POST");
|
||||||
con.setRequestProperty("Authorization", "Token " + default_token);
|
con.setRequestProperty("Authorization", "Token " + token);
|
||||||
con.setRequestProperty("Content-Type", "text/plain");
|
con.setRequestProperty("Content-Type", "text/plain");
|
||||||
con.setRequestProperty("Accept", "application/json");
|
con.setRequestProperty("Accept", "application/json");
|
||||||
con.setDoOutput(true);
|
con.setDoOutput(true);
|
||||||
@ -152,7 +156,7 @@ public class DatabaseConnector implements DataPointListener {
|
|||||||
if(con == null){
|
if(con == null){
|
||||||
con = (HttpURLConnection) urlForWrite.openConnection();
|
con = (HttpURLConnection) urlForWrite.openConnection();
|
||||||
con.setRequestMethod("POST");
|
con.setRequestMethod("POST");
|
||||||
con.setRequestProperty("Authorization", "Token " + default_token);
|
con.setRequestProperty("Authorization", "Token " + token);
|
||||||
con.setRequestProperty("Content-Type", "application/json");
|
con.setRequestProperty("Content-Type", "application/json");
|
||||||
con.setDoOutput(true);
|
con.setDoOutput(true);
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,8 @@ public class FieldConnector implements DataPointListener {
|
|||||||
*/
|
*/
|
||||||
public static void createRegister(String pathToFile){
|
public static void createRegister(String pathToFile){
|
||||||
try{
|
try{
|
||||||
BufferedReader csvFile = new BufferedReader(new FileReader(pathToFile));
|
//BufferedReader csvFile = new BufferedReader(new FileReader(pathToFile));
|
||||||
|
BufferedReader csvFile = Utility.fileParser(null, "ModbusMap.csv");
|
||||||
csvFile.readLine();
|
csvFile.readLine();
|
||||||
|
|
||||||
while(csvFile.ready()){
|
while(csvFile.ready()){
|
||||||
|
Reference in New Issue
Block a user