Added ability to specify how many results will be returned
This commit is contained in:
parent
f72afb66e5
commit
f1237e0dc4
3 changed files with 29 additions and 15 deletions
|
@ -9,6 +9,7 @@ apiserver {
|
|||
TrainType = ""
|
||||
Station = ""
|
||||
FinalStop = ""
|
||||
maxjourneys = 1
|
||||
}
|
||||
monitor2 {
|
||||
Title = ""
|
||||
|
@ -16,6 +17,7 @@ apiserver {
|
|||
TrainType = ""
|
||||
Station = ""
|
||||
FinalStop = ""
|
||||
maxjourneys = 1
|
||||
}
|
||||
monitor3 {
|
||||
Title = ""
|
||||
|
@ -23,6 +25,7 @@ apiserver {
|
|||
TrainType = ""
|
||||
Station = ""
|
||||
FinalStop = ""
|
||||
maxjourneys = 1
|
||||
}
|
||||
monitor4 {
|
||||
Title = ""
|
||||
|
@ -30,6 +33,7 @@ apiserver {
|
|||
TrainType = ""
|
||||
Station = ""
|
||||
FinalStop = ""
|
||||
maxjourneys = 1
|
||||
}
|
||||
}
|
||||
}
|
|
@ -43,10 +43,10 @@ public class Main {
|
|||
}
|
||||
|
||||
private static void refresh() throws IOException {
|
||||
data.put(conf.getString("monitors.monitor1.DepartureTime"),check.getStatus(conf.getString("monitors.monitor1.Station"),conf.getString("monitors.monitor1.DepartureTime"), conf.getString("monitors.monitor1.FinalStop"),conf.getString("monitors.monitor1.TrainType")));
|
||||
data.put(conf.getString("monitors.monitor2.DepartureTime"),check.getStatus(conf.getString("monitors.monitor2.Station"),conf.getString("monitors.monitor2.DepartureTime"), conf.getString("monitors.monitor2.FinalStop"),conf.getString("monitors.monitor2.TrainType")));
|
||||
data.put(conf.getString("monitors.monitor3.DepartureTime"),check.getStatus(conf.getString("monitors.monitor3.Station"),conf.getString("monitors.monitor3.DepartureTime"), conf.getString("monitors.monitor3.FinalStop"),conf.getString("monitors.monitor3.TrainType")));
|
||||
data.put(conf.getString("monitors.monitor4.DepartureTime"),check.getStatus(conf.getString("monitors.monitor4.Station"),conf.getString("monitors.monitor4.DepartureTime"), conf.getString("monitors.monitor4.FinalStop"),conf.getString("monitors.monitor4.TrainType")));
|
||||
data.put(conf.getString("monitors.monitor1.DepartureTime"),check.getStatus(conf.getString("monitors.monitor1.Station"),conf.getString("monitors.monitor1.DepartureTime"), conf.getString("monitors.monitor1.FinalStop"),conf.getString("monitors.monitor1.TrainType"),String.valueOf(conf.getInt("monitors.monitor1.maxjourneys"))));
|
||||
data.put(conf.getString("monitors.monitor2.DepartureTime"),check.getStatus(conf.getString("monitors.monitor2.Station"),conf.getString("monitors.monitor2.DepartureTime"), conf.getString("monitors.monitor2.FinalStop"),conf.getString("monitors.monitor2.TrainType"),String.valueOf(conf.getInt("monitors.monitor2.maxjourneys"))));
|
||||
data.put(conf.getString("monitors.monitor3.DepartureTime"),check.getStatus(conf.getString("monitors.monitor3.Station"),conf.getString("monitors.monitor3.DepartureTime"), conf.getString("monitors.monitor3.FinalStop"),conf.getString("monitors.monitor3.TrainType"),String.valueOf(conf.getInt("monitors.monitor3.maxjourneys"))));
|
||||
data.put(conf.getString("monitors.monitor4.DepartureTime"),check.getStatus(conf.getString("monitors.monitor4.Station"),conf.getString("monitors.monitor4.DepartureTime"), conf.getString("monitors.monitor4.FinalStop"),conf.getString("monitors.monitor4.TrainType"),String.valueOf(conf.getInt("monitors.monitor4.maxjourneys"))));
|
||||
time = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
|
@ -69,6 +69,11 @@ public class Main {
|
|||
private static String createOutput(){
|
||||
JSONArray dat = new JSONArray();
|
||||
Date updatetime = new Date(time);
|
||||
JSONObject displays = new JSONObject();
|
||||
JSONArray display = new JSONArray();
|
||||
JSONObject refresh = new JSONObject();
|
||||
refresh.put("interval",conf.getInt("refreshTime"));
|
||||
dat.put(refresh);
|
||||
JSONObject monitor1 = new JSONObject();
|
||||
monitor1.put("label","Zug");
|
||||
JSONArray layout = new JSONArray();
|
||||
|
@ -95,36 +100,41 @@ public class Main {
|
|||
monitor1.put("labelColor","red");
|
||||
monitor1.put("color","red");
|
||||
monitor1.put("background","silver");
|
||||
dat.put(monitor1);
|
||||
display.put(monitor1);
|
||||
|
||||
JSONObject monitor2 = new JSONObject();
|
||||
monitor2.put("label",conf.getString("monitors.monitor1.Title"));
|
||||
monitor2.put("labelColor","green");
|
||||
monitor2.put("fullDraw",true);
|
||||
int zug1 = data.get(conf.getString("monitors.monitor1.DepartureTime"));
|
||||
makeLabel(monitor2, zug1);
|
||||
dat.put(monitor2);
|
||||
display.put(monitor2);
|
||||
|
||||
JSONObject monitor3 = new JSONObject();
|
||||
monitor3.put("label",conf.getString("monitors.monitor2.Title"));
|
||||
monitor3.put("labelColor","green");
|
||||
monitor3.put("fullDraw",true);
|
||||
int zug2 = data.get(conf.getString("monitors.monitor2.DepartureTime"));
|
||||
makeLabel(monitor3, zug2);
|
||||
dat.put(monitor3);
|
||||
display.put(monitor3);
|
||||
|
||||
JSONObject monitor4 = new JSONObject();
|
||||
monitor4.put("label",conf.getString("monitors.monitor3.Title"));
|
||||
monitor4.put("labelColor","green");
|
||||
monitor4.put("fullDraw",true);
|
||||
int zug3 = data.get(conf.getString("monitors.monitor3.DepartureTime"));
|
||||
makeLabel(monitor4, zug3);
|
||||
dat.put(monitor4);
|
||||
display.put(monitor4);
|
||||
|
||||
JSONObject monitor5 = new JSONObject();
|
||||
monitor5.put("label",conf.getString("monitors.monitor4.Title"));
|
||||
monitor5.put("labelColor","green");
|
||||
monitor5.put("fullDraw",true);
|
||||
int zug4 = data.get(conf.getString("monitors.monitor4.DepartureTime"));
|
||||
makeLabel(monitor5, zug4);
|
||||
dat.put(monitor5);
|
||||
|
||||
display.put(monitor5);
|
||||
displays.put("displays", display);
|
||||
dat.put(displays);
|
||||
return dat.toString();
|
||||
}
|
||||
|
||||
|
|
|
@ -24,10 +24,10 @@ public class OebbCheck {
|
|||
>0 is the delay in Minutes
|
||||
9999 means the Train has been cancelled
|
||||
*/
|
||||
public int getStatus(String Station, String Time, String FinalStop, String TrainType) throws IOException {
|
||||
public int getStatus(String Station, String Time, String FinalStop, String TrainType, String maxjourneys) throws IOException {
|
||||
JSONArray journeys;
|
||||
try {
|
||||
journeys = getData(Station, Time);
|
||||
journeys = getData(Station, Time, maxjourneys);
|
||||
} catch (URISyntaxException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
@ -48,8 +48,8 @@ public class OebbCheck {
|
|||
return -1;
|
||||
}
|
||||
|
||||
private static JSONArray getData(String Station, String Time) throws IOException, URISyntaxException {
|
||||
URL url = new URI("https://fahrplan.oebb.at/bin/stboard.exe/dn?L=vs_scotty.vs_liveticker&evaId=" + Station + "&boardType=dep&time="+ Time +"&productsFilter=1011110111011&additionalTime=0&maxJourneys=1&outputMode=tickerDataOnly&start=yes&selectDate=today").toURL();
|
||||
private static JSONArray getData(String Station, String Time, String maxjourneys) throws IOException, URISyntaxException {
|
||||
URL url = new URI("https://fahrplan.oebb.at/bin/stboard.exe/dn?L=vs_scotty.vs_liveticker&evaId=" + Station + "&boardType=dep&time="+ Time +"&productsFilter=1011110111011&additionalTime=0&maxJourneys=" + maxjourneys + "&outputMode=tickerDataOnly&start=yes&selectDate=today").toURL();
|
||||
HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
||||
con.setRequestMethod("GET");
|
||||
BufferedReader in = new BufferedReader(
|
||||
|
|
Loading…
Reference in a new issue