65 lines
2.0 KiB
Java
65 lines
2.0 KiB
Java
import AASMini.AASMini;
|
|
import ProtegeGX.ProtegeGX;
|
|
import Web.WebResponse;
|
|
import Web.WebServer;
|
|
import org.pmw.tinylog.Logger;
|
|
|
|
public class Main {
|
|
private static AASMini aas;
|
|
private static ProtegeGX protegeGX;
|
|
private static WebServer web;
|
|
private static String aasIP = "192.168.10.10";
|
|
private static int aasPort = 5000;
|
|
private static int webPort = 8080;
|
|
public static void main(String[] args) {
|
|
GetArguments(args);
|
|
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
|
|
System.out.println("Shutting down...");
|
|
if (aas!=null) aas.Disconnect();
|
|
if (protegeGX!=null) protegeGX.Disconnect();
|
|
if (web!=null) web.Stop();
|
|
}));
|
|
|
|
System.out.println("Protege to AAS Mini Connector");
|
|
|
|
protegeGX = new ProtegeGX();
|
|
protegeGX.setOnCardRead(data -> {
|
|
Logger.info(data);
|
|
if (aas!=null && aas.IsConnected()){
|
|
// send something to AAS
|
|
}
|
|
});
|
|
|
|
aas = new AASMini(aasIP, aasPort);
|
|
aas.Connect();
|
|
|
|
web = new WebServer();
|
|
web.Start(webPort);
|
|
web.setAasAPI(request -> {
|
|
Logger.info(request);
|
|
// TODO Do something with AAS
|
|
WebResponse response = new WebResponse();
|
|
return response;
|
|
});
|
|
web.setProtegeGXAPI(request -> {
|
|
Logger.info(request);
|
|
// TODO Do something with ProtegeGX
|
|
WebResponse response = new WebResponse();
|
|
return response;
|
|
});
|
|
}
|
|
|
|
private static void GetArguments(String[] args){
|
|
for(String arg: args){
|
|
if (arg.startsWith("-aasip=")){
|
|
aasIP = arg.substring(7);
|
|
}
|
|
if (arg.startsWith("-aasport=")){
|
|
aasPort = Integer.parseInt(arg.substring(9));
|
|
}
|
|
if (arg.startsWith("-webport=")){
|
|
webPort = Integer.parseInt(arg.substring(9));
|
|
}
|
|
}
|
|
}
|
|
} |