Add refresh flag to make refresh every time (and at startup)
rodzic
26fdae0710
commit
425aae7475
|
@ -323,14 +323,22 @@ public class DataCollector implements Runnable {
|
|||
}
|
||||
|
||||
public void refresh() {
|
||||
if(rs_col_thread != null)
|
||||
if(rs_col_thread != null) {
|
||||
rs_col.refresh();
|
||||
rs_col_thread.interrupt();
|
||||
if(sh_col_thread != null)
|
||||
}
|
||||
if(sh_col_thread != null) {
|
||||
sh_col.refresh();
|
||||
sh_col_thread.interrupt();
|
||||
if(lc_col_thread != null)
|
||||
}
|
||||
if(lc_col_thread != null) {
|
||||
lc_col.refresh();
|
||||
lc_col_thread.interrupt();
|
||||
if(elapi_thread != null)
|
||||
}
|
||||
if(elapi_thread != null) {
|
||||
elapi.refresh();
|
||||
elapi_thread.interrupt();
|
||||
}
|
||||
}
|
||||
|
||||
public void onResume() {
|
||||
|
|
|
@ -14,11 +14,13 @@ public class ElevationApi implements Runnable {
|
|||
public int alt = 0;
|
||||
|
||||
public volatile boolean pause = false;
|
||||
public volatile boolean refresh = false;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
while (true) {
|
||||
try {
|
||||
refresh = false;
|
||||
URL url = new URL("https://api.open-meteo.com/v1/elevation?latitude=" + lat + "&longitude=" + lon);
|
||||
HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
|
||||
try {
|
||||
|
@ -40,11 +42,16 @@ public class ElevationApi implements Runnable {
|
|||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
do {
|
||||
Thread.sleep(30000);
|
||||
} while (pause);
|
||||
if (!refresh) {
|
||||
do {
|
||||
Thread.sleep(30000);
|
||||
} while (pause);
|
||||
}
|
||||
} catch (InterruptedException ignored) {}
|
||||
boolean ignored = Thread.interrupted();
|
||||
}
|
||||
}
|
||||
public void refresh() {
|
||||
refresh = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ public class LocalServerCollector implements Runnable {
|
|||
private int terrain_alt = 0;
|
||||
|
||||
private volatile boolean stop = false;
|
||||
private volatile boolean refresh_flag;
|
||||
|
||||
public LocalServerCollector() {}
|
||||
|
||||
|
@ -79,14 +80,18 @@ public class LocalServerCollector implements Runnable {
|
|||
prediction = new ArrayList<>();
|
||||
last_decoded = 0;
|
||||
status = Status.RED;
|
||||
refresh_flag = false;
|
||||
|
||||
while (!stop) {
|
||||
refresh_flag = false;
|
||||
getData();
|
||||
generatePrediction();
|
||||
|
||||
try {
|
||||
Thread.sleep(500);
|
||||
} catch (InterruptedException ignored) {}
|
||||
if (!refresh_flag) {
|
||||
try {
|
||||
Thread.sleep(500);
|
||||
} catch (InterruptedException ignored) {}
|
||||
}
|
||||
boolean ignored = Thread.interrupted();
|
||||
}
|
||||
System.out.println("lcexit");
|
||||
|
@ -224,4 +229,8 @@ public class LocalServerCollector implements Runnable {
|
|||
stop = true;
|
||||
disable();
|
||||
}
|
||||
|
||||
public void refresh() {
|
||||
refresh_flag = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,9 @@ public class RadiosondyCollector implements Runnable {
|
|||
public volatile long last_decoded;
|
||||
|
||||
private ArrayList<String> sonde_entries = null;
|
||||
private HashSet<String> sonde_notifications = new HashSet<>();
|
||||
private final HashSet<String> sonde_notifications = new HashSet<>();
|
||||
|
||||
private volatile boolean refresh_flag;
|
||||
|
||||
|
||||
private String sondeName = null;
|
||||
|
@ -61,20 +63,30 @@ public class RadiosondyCollector implements Runnable {
|
|||
track = new ArrayList<>();
|
||||
prediction = new ArrayList<>();
|
||||
pred_point = null;
|
||||
|
||||
refresh_flag = false;
|
||||
|
||||
int i = 0;
|
||||
while (!stop) {
|
||||
if(refresh_flag)
|
||||
i = 0;
|
||||
refresh_flag = false;
|
||||
|
||||
if (!archive)
|
||||
downloadFlyingMapData();
|
||||
|
||||
if ((i++)%3 == 0) {
|
||||
downloadPrediction();
|
||||
if (archive)
|
||||
downloadArchive();
|
||||
}
|
||||
try {
|
||||
Thread.sleep(15000);
|
||||
} catch (InterruptedException ignored) {}
|
||||
|
||||
if (!refresh_flag) { // interrupt can be 'consumed' at http requests, don't sleep on refresh in that case
|
||||
try {
|
||||
Thread.sleep(15000);
|
||||
} catch (InterruptedException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
boolean ignored = Thread.interrupted();
|
||||
}
|
||||
}
|
||||
|
@ -367,4 +379,8 @@ public class RadiosondyCollector implements Runnable {
|
|||
});
|
||||
updateThread.start();
|
||||
}
|
||||
|
||||
public void refresh() {
|
||||
refresh_flag = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ public class SondeHubCollector implements Runnable {
|
|||
|
||||
private ArrayList<String> sonde_entries = null;
|
||||
private volatile boolean stop = false;
|
||||
private volatile boolean refresh_flag;
|
||||
|
||||
|
||||
@Override
|
||||
|
@ -45,12 +46,17 @@ public class SondeHubCollector implements Runnable {
|
|||
pred_point = null;
|
||||
lastSonde = null;
|
||||
track = new ArrayList<>();
|
||||
refresh_flag = false;
|
||||
|
||||
while (!stop) {
|
||||
refresh_flag = false;
|
||||
downloadPrediction();
|
||||
try {
|
||||
Thread.sleep(30000);
|
||||
} catch (InterruptedException ignored) {}
|
||||
|
||||
if (!refresh_flag) {
|
||||
try {
|
||||
Thread.sleep(30000);
|
||||
} catch (InterruptedException ignored) {}
|
||||
}
|
||||
boolean ignored = Thread.interrupted();
|
||||
}
|
||||
}
|
||||
|
@ -203,4 +209,7 @@ public class SondeHubCollector implements Runnable {
|
|||
updateThread.start();
|
||||
}
|
||||
|
||||
public void refresh() {
|
||||
refresh_flag = true;
|
||||
}
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue