Skip to content

Commit

Permalink
Merge pull request #60 from LuisValentim1/GeradorPhFix
Browse files Browse the repository at this point in the history
Valores de ph mais relevantes, update de documentação
  • Loading branch information
renanaferreira authored Jan 11, 2021
2 parents 0c211d5 + feb37c5 commit f20da5f
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ public static void main(String[] args) throws InterruptedException, IOException{
//Adicionar todos os valores de pH à base de dados
for(int i = 0; i<monitoresPH.size(); i++) {
for(int z = 0; z<monitoresPH.get(i).getValues().size(); z++) {
//Curl em windows
// String com = "curl -X POST -H \"Content-Type: application/json\" -d \"{\\\"sensorId\\\" : \\\" " + Integer.toString(monitoresPH.get(i).getId()) + " \\\", \\\"value\\\" : \\\" " + Double.toString(monitoresPH.get(i).getValues().get(z)) + " \\\"}\" http://localhost:8080/api/test/phmeasures";
// String com = "curl -X POST -H \"Content-Type: application/json\" -d \'{\"sensorId\" : \" " + Integer.toString(monitoresPH.get(i).getId()) + " \", \"value\" : \" " + Double.toString(monitoresPH.get(i).getValues().get(z)) + " \"}\' http://localhost:8080/api/test/phmeasures"; //Se estiver a correr em linux
// curl -X POST -H "Content-Type: application/json" -d '{"sensorId" : "4", "value" : "7.6"}' http://localhost:8080/api/test/phmeasures
// String com = "curl -X POST -H \"Content-Type: application/json\" -d \'{\"sensorId\" : \"" + Integer.toString(monitoresPH.get(i).getId()) + "\", \"value\" : \"" + Double.toString(monitoresPH.get(i).getValues().get(z)) +"\"}\' \"http://localhost:8080/api/test/phmeasures\"";

//Curl em Linux
String[] com = {"curl", "-X", "POST", "-H", "Content-Type: application/json", "-d", "{\"sensorId\" : \"" + Integer.toString(monitoresPH.get(i).getId()) + "\", \"value\" : \"" + Double.toString(monitoresPH.get(i).getValues().get(z)) +"\"}", "http://localhost:8080/api/test/phmeasures"};
try {
pr = rt.exec(com);
Expand All @@ -99,9 +99,10 @@ public static void main(String[] args) throws InterruptedException, IOException{
//Adicionar todos os valores de humidade à base de dados
for(int i = 0; i<monitoresHum.size(); i++) {
for(int z = 0; z<monitoresHum.get(i).getValues().size(); z++) {
//Curl em windows
// String com = "curl -X POST -H \"Content-Type: application/json\" -d \"{\\\"sensorId\\\" : \\\" " + Integer.toString(monitoresHum.get(i).getId()) + " \\\", \\\"value\\\" : \\\" " + Integer.toString(monitoresHum.get(i).getValues().get(z)) + " \\\"}\" http://localhost:8080/api/test/hummeasures";
// String com = "curl -X POST -H \"Content-Type: application/json\" -d \'{\"sensorId\" : \" " + Integer.toString(monitoresHum.get(i).getId()) + " \", \"value\" : \" " + Double.toString(monitoresHum.get(i).getValues().get(z)) + " \"}\' http://localhost:8080/api/test/hummeasures"; //Se estiver a correr em linux
// String com = "curl -X POST -H \"Content-Type: application/json\" -d \'{\"sensorId\" : \"" + Integer.toString(monitoresHum.get(i).getId()) + "\", \"value\" : \"" + Double.toString(monitoresHum.get(i).getValues().get(z)) +"\"}\' \"http://localhost:8080/api/test/hummeasures\"";

//Curl em Linux
String[] com = {"curl", "-X", "POST", "-H", "Content-Type: application/json", "-d", "{\"sensorId\" : \"" + Integer.toString(monitoresHum.get(i).getId()) + "\", \"value\" : \"" + Double.toString(monitoresHum.get(i).getValues().get(z)) +"\"}", "http://localhost:8080/api/test/hummeasures"};
try {
pr = rt.exec(com);
Expand All @@ -120,8 +121,11 @@ public static void main(String[] args) throws InterruptedException, IOException{
String mode = p.getMode();
if(mode == "Low") {
p.generateAcidicSoil(1/regs_per_day);
// Curl em windows
// String com = "curl -X POST -H \"Content-Type: application/json\" -d \"{\\\"sensorId\\\" : \\\" " + Integer.toString(p.getId()) + " \\\", \\\"value\\\" : \\\" " + Double.toString(p.getValues().get(p.getValues().size()-1)) + " \\\"}\" http://localhost:8080/api/test/phmeasures";
String com = "curl -X POST -H \"Content-Type: application/json\" -d \'{\"sensorId\" : \" " + Integer.toString(p.getId()) + " \", \"value\" : \" " + Double.toString(p.getValues().get(p.getValues().size()-1)) + " \"}\' http://localhost:8080/api/test/phmeasures"; //Se estiver a correr em linux

//Curl em linux
String[] com = {"curl -X POST -H \"Content-Type: application/json\" -d \'{\"sensorId\" : \" " + Integer.toString(p.getId()) + " \", \"value\" : \" " + Double.toString(p.getValues().get(p.getValues().size()-1)) + " \"}\' http://localhost:8080/api/test/phmeasures"};

try {
pr = rt.exec(com);
Expand All @@ -131,8 +135,12 @@ public static void main(String[] args) throws InterruptedException, IOException{
}
if(mode == "Medium") {
p.generateNeutralSoil(1/regs_per_day);

// Curl em windows
// String com = "curl -X POST -H \"Content-Type: application/json\" -d \"{\\\"sensorId\\\" : \\\" " + Integer.toString(p.getId()) + " \\\", \\\"value\\\" : \\\" " + Double.toString(p.getValues().get(p.getValues().size()-1)) + " \\\"}\" http://localhost:8080/api/test/phmeasures";
String com = "curl -X POST -H \"Content-Type: application/json\" -d \'{\"sensorId\" : \" " + Integer.toString(p.getId()) + " \", \"value\" : \" " + Double.toString(p.getValues().get(p.getValues().size()-1)) + " \"}\' http://localhost:8080/api/test/phmeasures"; //Se estiver a correr em linux

//Curl em linux
String[] com = {"curl -X POST -H \"Content-Type: application/json\" -d \'{\"sensorId\" : \" " + Integer.toString(p.getId()) + " \", \"value\" : \" " + Double.toString(p.getValues().get(p.getValues().size()-1)) + " \"}\' http://localhost:8080/api/test/phmeasures"};
try {
pr = rt.exec(com);
}catch(Exception e) {
Expand All @@ -141,8 +149,12 @@ public static void main(String[] args) throws InterruptedException, IOException{
}
if(mode == "High") {
p.generateBasicSoil(1/regs_per_day);

// Curl em windows
// String com = "curl -X POST -H \"Content-Type: application/json\" -d \"{\\\"sensorId\\\" : \\\" " + Integer.toString(p.getId()) + " \\\", \\\"value\\\" : \\\" " + Double.toString(p.getValues().get(p.getValues().size()-1)) + " \\\"}\" http://localhost:8080/api/test/phmeasures";
String com = "curl -X POST -H \"Content-Type: application/json\" -d \'{\"sensorId\" : \" " + Integer.toString(p.getId()) + " \", \"value\" : \" " + Double.toString(p.getValues().get(p.getValues().size()-1)) + " \"}\' http://localhost:8080/api/test/phmeasures"; //Se estiver a correr em linux

//Curl em linux
String[] com = {"curl -X POST -H \"Content-Type: application/json\" -d \'{\"sensorId\" : \" " + Integer.toString(p.getId()) + " \", \"value\" : \" " + Double.toString(p.getValues().get(p.getValues().size()-1)) + " \"}\' http://localhost:8080/api/test/phmeasures"};
try {
pr = rt.exec(com);
}catch(Exception e) {
Expand All @@ -157,8 +169,12 @@ public static void main(String[] args) throws InterruptedException, IOException{
String mode = h.getMode();
if(mode == "Low") {
h.generateDrySoil(1/regs_per_day);

// Curl em windows
// String com = "curl -X POST -H \"Content-Type: application/json\" -d \"{\\\"sensorId\\\" : \\\" " + Integer.toString(h.getId()) + " \\\", \\\"value\\\" : \\\" " + Integer.toString(h.getValues().get(h.getValues().size()-1)) + " \\\"}\" http://localhost:8080/api/test/hummeasures";
String com = "curl -X POST -H \"Content-Type: application/json\" -d \'{\"sensorId\" : \" " + Integer.toString(h.getId()) + " \", \"value\" : \" " + Integer.toString(h.getValues().get(h.getValues().size()-1)) + " \"}\' http://localhost:8080/api/test/phmeasures"; //Se estiver a correr em linux

//Curl em linux
String[] com = {"curl -X POST -H \"Content-Type: application/json\" -d \'{\"sensorId\" : \" " + Integer.toString(h.getId()) + " \", \"value\" : \" " + Integer.toString(h.getValues().get(h.getValues().size()-1)) + " \"}\' http://localhost:8080/api/test/phmeasures"};
try {
pr = rt.exec(com);
}catch(Exception e) {
Expand All @@ -167,8 +183,12 @@ public static void main(String[] args) throws InterruptedException, IOException{
}
if(mode == "Medium") {
h.generateNeutralSoil(1/regs_per_day);

// Curl em windows
// String com = "curl -X POST -H \"Content-Type: application/json\" -d \"{\\\"sensorId\\\" : \\\" " + Integer.toString(h.getId()) + " \\\", \\\"value\\\" : \\\" " + Integer.toString(h.getValues().get(h.getValues().size()-1)) + " \\\"}\" http://localhost:8080/api/test/hummeasures";
String com = "curl -X POST -H \"Content-Type: application/json\" -d \'{\"sensorId\" : \" " + Integer.toString(h.getId()) + " \", \"value\" : \" " + Integer.toString(h.getValues().get(h.getValues().size()-1)) + " \"}\' http://localhost:8080/api/test/phmeasures"; //Se estiver a correr em linux

//Curl em linux
String[] com = {"curl -X POST -H \"Content-Type: application/json\" -d \'{\"sensorId\" : \" " + Integer.toString(h.getId()) + " \", \"value\" : \" " + Integer.toString(h.getValues().get(h.getValues().size()-1)) + " \"}\' http://localhost:8080/api/test/phmeasures"};
try {
pr = rt.exec(com);
}catch(Exception e) {
Expand All @@ -177,8 +197,12 @@ public static void main(String[] args) throws InterruptedException, IOException{
}
if(mode == "High") {
h.generateMoistSoil(1/regs_per_day);

//Curl em windows
// String com = "curl -X POST -H \"Content-Type: application/json\" -d \"{\\\"sensorId\\\" : \\\" " + Integer.toString(h.getId()) + " \\\", \\\"value\\\" : \\\" " + Integer.toString(h.getValues().get(h.getValues().size()-1)) + " \\\"}\" http://localhost:8080/api/test/hummeasures";
String com = "curl -X POST -H \"Content-Type: application/json\" -d \'{\"sensorId\" : \" " + Integer.toString(h.getId()) + " \", \"value\" : \" " + Integer.toString(h.getValues().get(h.getValues().size()-1)) + " \"}\' http://localhost:8080/api/test/phmeasures"; //Se estiver a correr em linux

//Curl em linux
String[] com = {"curl -X POST -H \"Content-Type: application/json\" -d \'{\"sensorId\" : \" " + Integer.toString(h.getId()) + " \", \"value\" : \" " + Integer.toString(h.getValues().get(h.getValues().size()-1)) + " \"}\' http://localhost:8080/api/test/phmeasures"};
try {
pr = rt.exec(com);
}catch(Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public MonitorPH(int given_id, String mode, int freq, int instant) { //instant
public void generateAcidicSoil(int days) {
if(days>0) {
for(int i = 0; i<this.reg_freq*days; i++) {
double value = getRandomDoubleInRange(0,7);
double value = getRandomDoubleInRange(4,6);
this.values.add(value);
}
}
Expand All @@ -38,7 +38,7 @@ public void generateAcidicSoil(int days) {
public void generateNeutralSoil(int days) {
if(days>0) {
for(int i = 0; i<this.reg_freq*days; i++) {
double value = getRandomNumberUsingInts(4,10);
double value = getRandomNumberUsingInts(6,8);
this.values.add(value);
}
}
Expand All @@ -47,7 +47,7 @@ public void generateNeutralSoil(int days) {
public void generateBasicSoil(int days) {
if(days>0) {
for(int i = 0; i<this.reg_freq*days; i++) {
double value = getRandomNumberUsingInts(7,14);
double value = getRandomNumberUsingInts(7,9);
this.values.add(value);
}
}
Expand Down

0 comments on commit f20da5f

Please sign in to comment.