First commit

This commit is contained in:
2024-11-15 11:28:42 +07:00
parent c9794d0e30
commit e0e2eb7529
5 changed files with 98 additions and 9 deletions

30
.idea/libraries/io_javalin.xml generated Normal file
View File

@@ -0,0 +1,30 @@
<component name="libraryTable">
<library name="io.javalin" type="repository">
<properties maven-id="io.javalin:javalin:6.3.0" />
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/io/javalin/javalin/6.3.0/javalin-6.3.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/slf4j/slf4j-api/2.0.16/slf4j-api-2.0.16.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/jetty-server/11.0.23/jetty-server-11.0.23.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/jetty-http/11.0.23/jetty-http-11.0.23.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/jetty-util/11.0.23/jetty-util-11.0.23.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/jetty-io/11.0.23/jetty-io-11.0.23.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/toolchain/jetty-jakarta-servlet-api/5.0.2/jetty-jakarta-servlet-api-5.0.2.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/websocket/websocket-jetty-server/11.0.23/websocket-jetty-server-11.0.23.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/jetty-servlet/11.0.23/jetty-servlet-11.0.23.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/jetty-security/11.0.23/jetty-security-11.0.23.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/jetty-webapp/11.0.23/jetty-webapp-11.0.23.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/jetty-xml/11.0.23/jetty-xml-11.0.23.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/websocket/websocket-jetty-api/11.0.23/websocket-jetty-api-11.0.23.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/websocket/websocket-jetty-common/11.0.23/websocket-jetty-common-11.0.23.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/websocket/websocket-core-common/11.0.23/websocket-core-common-11.0.23.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/websocket/websocket-servlet/11.0.23/websocket-servlet-11.0.23.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/websocket/websocket-core-server/11.0.23/websocket-core-server-11.0.23.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.9.25/kotlin-stdlib-jdk8-1.9.25.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib/1.9.25/kotlin-stdlib-1.9.25.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/annotations/13.0/annotations-13.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-jdk7/1.9.25/kotlin-stdlib-jdk7-1.9.25.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

4
.idea/misc.xml generated
View File

@@ -1,5 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="PWA">
<option name="enabled" value="true" />
<option name="wasEnabledAtLeastOnce" value="true" />
</component>
<component name="ProjectInspectionProfilesVisibleTreeState">
<entry key="Project Default">
<profile-state>

View File

@@ -3,6 +3,7 @@
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/Web" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
@@ -17,5 +18,6 @@
</library>
</orderEntry>
<orderEntry type="library" name="tinylog" level="project" />
<orderEntry type="library" name="io.javalin" level="project" />
</component>
</module>

View File

@@ -1,20 +1,22 @@
import AASMini.AASMini;
import ProtegeGX.ProtegeGX;
import Web.WebServer;
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 = 8080;
private static int aasPort = 5000;
private static int webPort = 8080;
public static void main(String[] args) {
Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {
System.out.println("Shutting down...");
if (aas!=null) aas.Disconnect();
if (protegeGX!=null) protegeGX.Disconnect();
}
});
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");
@@ -22,5 +24,22 @@ public class Main {
aas = new AASMini(aasIP, aasPort);
aas.Connect();
web = new WebServer();
web.Start(webPort);
}
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));
}
}
}
}

34
src/Web/WebServer.java Normal file
View File

@@ -0,0 +1,34 @@
package Web;
import io.javalin.Javalin;
import static io.javalin.apibuilder.ApiBuilder.path;
public class WebServer {
Javalin app;
public WebServer(){
app = Javalin.create(config -> {
config.useVirtualThreads = true;
config.staticFiles.add("/Web");
config.router.apiBuilder(()->{
// API for AAS Mini
path("aasmini", ()->{
//TODO implement API for AAS Mini
});
// API for ProtegeGX
path("protegegx", ()->{
//TODO implement API for ProtegeGX
});
});
});
}
public void Start(int listenport){
app.start(listenport);
}
public void Stop(){
app.stop();
}
}