Compare commits
9 Commits
f9f6e07696
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| c7f5083b17 | |||
| ba740cd87d | |||
| 68991fe061 | |||
| ec427a70b8 | |||
| df8e665e15 | |||
| cf2950907a | |||
| 8399f70285 | |||
| 63307e2deb | |||
| d0bfbd3f5c |
38
.idea/artifacts/ProtegeToAASMini_jar.xml
generated
Normal file
38
.idea/artifacts/ProtegeToAASMini_jar.xml
generated
Normal file
@@ -0,0 +1,38 @@
|
||||
<component name="ArtifactManager">
|
||||
<artifact type="jar" name="ProtegeToAASMini:jar">
|
||||
<output-path>$PROJECT_DIR$/out/artifacts/ProtegeToAASMini_jar</output-path>
|
||||
<root id="archive" name="ProtegeToAASMini.jar">
|
||||
<element id="module-output" name="ProtegeToAASMini" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/tinylog/tinylog/1.3.6/tinylog-1.3.6.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/slf4j/slf4j-simple/1.8.0-beta4/slf4j-simple-1.8.0-beta4.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/slf4j/slf4j-api/1.8.0-beta4/slf4j-api-1.8.0-beta4.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/projectlombok/lombok/1.18.34/lombok-1.18.34.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/com/google/code/gson/gson/2.11.0/gson-2.11.0.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/com/google/errorprone/error_prone_annotations/2.27.0/error_prone_annotations-2.27.0.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/../../../../../../apache-cxf/3.5.9/lib/cxf-manifest.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/io/javalin/javalin/4.6.8/javalin-4.6.8.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/slf4j/slf4j-api/1.7.36/slf4j-api-1.7.36.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/eclipse/jetty/jetty-server/9.4.51.v20230217/jetty-server-9.4.51.v20230217.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/javax/servlet/javax.servlet-api/3.1.0/javax.servlet-api-3.1.0.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/eclipse/jetty/jetty-http/9.4.51.v20230217/jetty-http-9.4.51.v20230217.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/eclipse/jetty/jetty-util/9.4.51.v20230217/jetty-util-9.4.51.v20230217.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/eclipse/jetty/jetty-io/9.4.51.v20230217/jetty-io-9.4.51.v20230217.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/eclipse/jetty/jetty-webapp/9.4.51.v20230217/jetty-webapp-9.4.51.v20230217.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/eclipse/jetty/jetty-xml/9.4.51.v20230217/jetty-xml-9.4.51.v20230217.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/eclipse/jetty/jetty-servlet/9.4.51.v20230217/jetty-servlet-9.4.51.v20230217.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/eclipse/jetty/jetty-security/9.4.51.v20230217/jetty-security-9.4.51.v20230217.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/eclipse/jetty/jetty-util-ajax/9.4.51.v20230217/jetty-util-ajax-9.4.51.v20230217.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/eclipse/jetty/websocket/websocket-server/9.4.51.v20230217/websocket-server-9.4.51.v20230217.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/eclipse/jetty/websocket/websocket-common/9.4.51.v20230217/websocket-common-9.4.51.v20230217.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/eclipse/jetty/websocket/websocket-api/9.4.51.v20230217/websocket-api-9.4.51.v20230217.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/eclipse/jetty/websocket/websocket-client/9.4.51.v20230217/websocket-client-9.4.51.v20230217.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/eclipse/jetty/jetty-client/9.4.51.v20230217/jetty-client-9.4.51.v20230217.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/eclipse/jetty/websocket/websocket-servlet/9.4.51.v20230217/websocket-servlet-9.4.51.v20230217.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.5.32/kotlin-stdlib-jdk8-1.5.32.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib/1.5.32/kotlin-stdlib-1.5.32.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/jetbrains/annotations/13.0/annotations-13.0.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-common/1.5.32/kotlin-stdlib-common-1.5.32.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-jdk7/1.5.32/kotlin-stdlib-jdk7-1.5.32.jar" path-in-jar="/" />
|
||||
</root>
|
||||
</artifact>
|
||||
</component>
|
||||
8
.idea/compiler.xml
generated
Normal file
8
.idea/compiler.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<annotationProcessing>
|
||||
<profile default="true" name="Default" enabled="true" />
|
||||
</annotationProcessing>
|
||||
</component>
|
||||
</project>
|
||||
14
.idea/deployment.xml
generated
Normal file
14
.idea/deployment.xml
generated
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="PublishConfigData" serverName="pi" remoteFilesAllowedToDisappearOnAutoupload="false">
|
||||
<serverData>
|
||||
<paths name="pi">
|
||||
<serverdata>
|
||||
<mappings>
|
||||
<mapping deploy="/ProtegeConnector" local="$PROJECT_DIR$" web="/" />
|
||||
</mappings>
|
||||
</serverdata>
|
||||
</paths>
|
||||
</serverData>
|
||||
</component>
|
||||
</project>
|
||||
44
.idea/libraries/io_javalin.xml
generated
44
.idea/libraries/io_javalin.xml
generated
@@ -1,28 +1,30 @@
|
||||
<component name="libraryTable">
|
||||
<library name="io.javalin" type="repository">
|
||||
<properties maven-id="io.javalin:javalin:6.3.0" />
|
||||
<properties maven-id="io.javalin:javalin:4.6.8" />
|
||||
<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$/io/javalin/javalin/4.6.8/javalin-4.6.8.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/slf4j/slf4j-api/1.7.36/slf4j-api-1.7.36.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/jetty-server/9.4.51.v20230217/jetty-server-9.4.51.v20230217.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/javax/servlet/javax.servlet-api/3.1.0/javax.servlet-api-3.1.0.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/jetty-http/9.4.51.v20230217/jetty-http-9.4.51.v20230217.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/jetty-util/9.4.51.v20230217/jetty-util-9.4.51.v20230217.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/jetty-io/9.4.51.v20230217/jetty-io-9.4.51.v20230217.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/jetty-webapp/9.4.51.v20230217/jetty-webapp-9.4.51.v20230217.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/jetty-xml/9.4.51.v20230217/jetty-xml-9.4.51.v20230217.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/jetty-servlet/9.4.51.v20230217/jetty-servlet-9.4.51.v20230217.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/jetty-security/9.4.51.v20230217/jetty-security-9.4.51.v20230217.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/jetty-util-ajax/9.4.51.v20230217/jetty-util-ajax-9.4.51.v20230217.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/websocket/websocket-server/9.4.51.v20230217/websocket-server-9.4.51.v20230217.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/websocket/websocket-common/9.4.51.v20230217/websocket-common-9.4.51.v20230217.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/websocket/websocket-api/9.4.51.v20230217/websocket-api-9.4.51.v20230217.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/websocket/websocket-client/9.4.51.v20230217/websocket-client-9.4.51.v20230217.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/jetty-client/9.4.51.v20230217/jetty-client-9.4.51.v20230217.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/eclipse/jetty/websocket/websocket-servlet/9.4.51.v20230217/websocket-servlet-9.4.51.v20230217.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.5.32/kotlin-stdlib-jdk8-1.5.32.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib/1.5.32/kotlin-stdlib-1.5.32.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!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-common/1.5.32/kotlin-stdlib-common-1.5.32.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-jdk7/1.5.32/kotlin-stdlib-jdk7-1.5.32.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
|
||||
11
.idea/libraries/slf4j_simple.xml
generated
Normal file
11
.idea/libraries/slf4j_simple.xml
generated
Normal file
@@ -0,0 +1,11 @@
|
||||
<component name="libraryTable">
|
||||
<library name="slf4j.simple" type="repository">
|
||||
<properties maven-id="org.slf4j:slf4j-simple:1.8.0-beta4" />
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/slf4j/slf4j-simple/1.8.0-beta4/slf4j-simple-1.8.0-beta4.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/slf4j/slf4j-api/1.8.0-beta4/slf4j-api-1.8.0-beta4.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</component>
|
||||
8
.idea/sshConfigs.xml
generated
Normal file
8
.idea/sshConfigs.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="SshConfigs">
|
||||
<configs>
|
||||
<sshConfig authType="PASSWORD" host="192.168.10.70" id="5e3c74ed-e990-4abc-bd0b-6feca476d448" port="22" nameFormat="DESCRIPTIVE" username="pi" useOpenSSHConfig="true" />
|
||||
</configs>
|
||||
</component>
|
||||
</project>
|
||||
14
.idea/webServers.xml
generated
Normal file
14
.idea/webServers.xml
generated
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="WebServers">
|
||||
<option name="servers">
|
||||
<webServer id="1b978483-d576-4e39-b6b8-3bb40d973f6b" name="pi">
|
||||
<fileTransfer rootFolder="/home/pi" accessType="SFTP" host="192.168.10.70" port="22" sshConfigId="5e3c74ed-e990-4abc-bd0b-6feca476d448" sshConfig="pi@192.168.10.70:22 password">
|
||||
<advancedOptions>
|
||||
<advancedOptions dataProtectionLevel="Private" keepAliveTimeout="0" passiveMode="true" shareSSLContext="true" />
|
||||
</advancedOptions>
|
||||
</fileTransfer>
|
||||
</webServer>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
34
Properties/simplelogger.properties
Normal file
34
Properties/simplelogger.properties
Normal file
@@ -0,0 +1,34 @@
|
||||
# SLF4J's SimpleLogger configuration file
|
||||
# Simple implementation of Logger that sends all enabled log messages, for all defined loggers, to System.err.
|
||||
|
||||
# Default logging detail level for all instances of SimpleLogger.
|
||||
# Must be one of ("trace", "debug", "info", "warn", or "error").
|
||||
# If not specified, defaults to "info".
|
||||
org.slf4j.simpleLogger.defaultLogLevel=warn
|
||||
|
||||
# Logging detail level for a SimpleLogger instance named "xxxxx".
|
||||
# Must be one of ("trace", "debug", "info", "warn", or "error").
|
||||
# If not specified, the default logging detail level is used.
|
||||
#org.slf4j.simpleLogger.log.xxxxx=
|
||||
|
||||
# Set to true if you want the current date and time to be included in output messages.
|
||||
# Default is false, and will output the number of milliseconds elapsed since startup.
|
||||
#org.slf4j.simpleLogger.showDateTime=false
|
||||
|
||||
# The date and time format to be used in the output messages.
|
||||
# The pattern describing the date and time format is the same that is used in java.text.SimpleDateFormat.
|
||||
# If the format is not specified or is invalid, the default format is used.
|
||||
# The default format is yyyy-MM-dd HH:mm:ss:SSS Z.
|
||||
#org.slf4j.simpleLogger.dateTimeFormat=yyyy-MM-dd HH:mm:ss:SSS Z
|
||||
|
||||
# Set to true if you want to output the current thread name.
|
||||
# Defaults to true.
|
||||
#org.slf4j.simpleLogger.showThreadName=true
|
||||
|
||||
# Set to true if you want the Logger instance name to be included in output messages.
|
||||
# Defaults to true.
|
||||
#org.slf4j.simpleLogger.showLogName=true
|
||||
|
||||
# Set to true if you want the last component of the name to be included in output messages.
|
||||
# Defaults to false.
|
||||
#org.slf4j.simpleLogger.showShortLogName=false
|
||||
9
Properties/tinylog.properties
Normal file
9
Properties/tinylog.properties
Normal file
@@ -0,0 +1,9 @@
|
||||
//writer = rolling file
|
||||
writer=console
|
||||
writer.file=logs/{date:yyyy-MM-dd}.log
|
||||
writer.format={date:yyyy-MM-dd HH:mm:ss} {level}: {class}.{method}() {message}
|
||||
writer.policies=daily
|
||||
writer.buffered=true
|
||||
writer.charset=UTF-8
|
||||
writer.level=info
|
||||
writer.append=true
|
||||
@@ -5,6 +5,7 @@
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/Web" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/Properties" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
@@ -21,5 +22,6 @@
|
||||
<orderEntry type="library" name="io.javalin" level="project" />
|
||||
<orderEntry type="library" name="projectlombok.lombok" level="project" />
|
||||
<orderEntry type="library" name="google.code.gson" level="project" />
|
||||
<orderEntry type="library" name="slf4j.simple" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
3
Web/META-INF/MANIFEST.MF
Normal file
3
Web/META-INF/MANIFEST.MF
Normal file
@@ -0,0 +1,3 @@
|
||||
Manifest-Version: 1.0
|
||||
Main-Class: Main
|
||||
|
||||
@@ -4,11 +4,16 @@ import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.Socket;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
|
||||
@SuppressWarnings({"FieldCanBeLocal", "UnusedReturnValue"})
|
||||
public class AASMini {
|
||||
private final String targetIP;
|
||||
private final int targetPort;
|
||||
private final int msgId = 1;
|
||||
private final String zones = "Zone_1,Zone_2,Zone_3,Zone_4";
|
||||
private Socket socket;
|
||||
|
||||
/**
|
||||
@@ -19,8 +24,10 @@ public class AASMini {
|
||||
public AASMini(String ip , int port){
|
||||
this.targetIP = ip;
|
||||
this.targetPort = port;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if the AAS Mini is connected
|
||||
* @return true if connected, false otherwise
|
||||
@@ -66,7 +73,37 @@ public class AASMini {
|
||||
socket = null;
|
||||
}
|
||||
|
||||
//TODO protocol untuk kirim data ke AAS Mini
|
||||
private String ConvertToString(byte[] data){
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (byte b : data){
|
||||
if (b>0x1F && b<0x7F)
|
||||
sb.append((char)b);
|
||||
else break;
|
||||
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public void SendPlatNoToAAS(String platNo){
|
||||
|
||||
String protocol = "BROADCAST;"+msgId+";IND;$PLATNOMOR$="+platNo+";"+zones;
|
||||
byte[] data = protocol.getBytes();
|
||||
byte[] rplyData = SendAndReceive(data);
|
||||
if (rplyData!=null && rplyData.length>0){
|
||||
String rplyInStr = ConvertToString(rplyData);
|
||||
Logger.info("Response from AAS : {}", rplyInStr);
|
||||
String[] rply = rplyInStr.split(";");
|
||||
if (rply.length ==2){
|
||||
if (rply[0].equals("BROADCAST")){
|
||||
if (rply[1].equals("OK")){
|
||||
Logger.info("Success sending data to AAS!");
|
||||
}else Logger.info("Failed sending data to AAS!");
|
||||
}else Logger.info("Wrong format answer!");
|
||||
}else Logger.info("Wrong size answer");
|
||||
} else Logger.info("SendAndReceive return null");
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Send data to AAS Mini and receive response
|
||||
@@ -81,9 +118,7 @@ public class AASMini {
|
||||
byte[] buffer = new byte[1024];
|
||||
int read = socket.getInputStream().read(buffer);
|
||||
if (read>0){
|
||||
byte[] result = new byte[read];
|
||||
System.arraycopy(buffer, 0, result, 0, read);
|
||||
return result;
|
||||
return buffer;
|
||||
}
|
||||
} catch (Exception e){
|
||||
Logger.error("Failed to send data to {}:{}, Error : {}", targetIP, targetPort, e.getMessage());
|
||||
@@ -93,10 +128,10 @@ public class AASMini {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* Send data to AAS Mini
|
||||
* @param data Data to be sent
|
||||
*/
|
||||
|
||||
private void SendData(byte[] data){
|
||||
if (IsConnected()){
|
||||
if (data!=null && data.length>0){
|
||||
@@ -108,4 +143,5 @@ public class AASMini {
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -4,34 +4,35 @@ import Web.WebResponse;
|
||||
import Web.WebServer;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
|
||||
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 String aasIP = "localhost";
|
||||
private static int aasPort = 5000;
|
||||
private static int webPort = 8080;
|
||||
private final static String currentDirectory = System.getProperty("user.dir");
|
||||
|
||||
public static void main(String[] args) {
|
||||
ExtractFile("tinylog.properties");
|
||||
ExtractFile("simplelogger.properties");
|
||||
GetArguments(args);
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
|
||||
System.out.println("Shutting down...");
|
||||
if (aas!=null) aas.Disconnect();
|
||||
Logger.info("Shutting down...");
|
||||
if (protegeGX!=null) protegeGX.Disconnect();
|
||||
if (web!=null) web.Stop();
|
||||
}));
|
||||
|
||||
System.out.println("Protege to AAS Mini Connector");
|
||||
Logger.info("Protege to AAS Mini Connector");
|
||||
|
||||
protegeGX = new ProtegeGX();
|
||||
protegeGX.setOnCardRead(data -> {
|
||||
Logger.info(data);
|
||||
if (aas!=null && aas.IsConnected()){
|
||||
// send something to AAS
|
||||
}
|
||||
});
|
||||
protegeGX = new ProtegeGX(5004);
|
||||
protegeGX.setOnCardRead(data -> SendPlatNomor(data.LastName));
|
||||
|
||||
aas = new AASMini(aasIP, aasPort);
|
||||
aas.Connect();
|
||||
|
||||
web = new WebServer();
|
||||
web.Start(webPort);
|
||||
@@ -47,6 +48,35 @@ public class Main {
|
||||
WebResponse response = new WebResponse();
|
||||
return response;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private static void SendPlatNomor(String platNomor){
|
||||
if (aas!=null){
|
||||
if (aas.Connect()){
|
||||
aas.SendPlatNoToAAS(platNomor);
|
||||
aas.Disconnect();
|
||||
} else Logger.error("Failed to connect to AAS Mini");
|
||||
} else Logger.error("AAS Mini is not created");
|
||||
|
||||
}
|
||||
|
||||
private static void ExtractFile(String filename){
|
||||
File target = new File(currentDirectory,filename);
|
||||
if (target.isFile()) {
|
||||
Logger.info("File {} already exists", filename);
|
||||
return;
|
||||
}
|
||||
|
||||
try{
|
||||
InputStream in = Main.class.getResourceAsStream("/"+filename);
|
||||
if (in!=null){
|
||||
Files.copy(in, target.toPath());
|
||||
Logger.info("File {} extracted", filename);
|
||||
} else throw new Exception("File not found");
|
||||
} catch (Exception e){
|
||||
Logger.error("Failed to extract file {}, Message : {}", filename, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private static void GetArguments(String[] args){
|
||||
|
||||
@@ -1,12 +1,43 @@
|
||||
package ProtegeGX;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class ProtegeData {
|
||||
public String ReaderID;
|
||||
public String CardID;
|
||||
public String Description;
|
||||
public String FirstName;
|
||||
public String LastName;
|
||||
public String CardNumber;
|
||||
public int UserNode;
|
||||
public String DoorName;
|
||||
public int DoorNode;
|
||||
public String FieldTime;
|
||||
public String LoggedTime;
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return "ReaderID = " + ReaderID + ", CardID = " + CardID + ", Description = " + Description;
|
||||
return String.format("FirstName: %s\nLastName: %s\nCardNumber: %s\nUserNode: %d\nDoorName: %s\nDoorNode: %d\nFieldTime: %s\nLoggedTime: %s", FirstName, LastName, CardNumber, UserNode, DoorName, DoorNode, FieldTime, LoggedTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* create EventData object from string data using Regex
|
||||
* @param data string data
|
||||
* @return EventData object if valid, or null if invalid
|
||||
*/
|
||||
public static ProtegeData Parse(String data){
|
||||
final String regex = "<Description>User (\\w*) (\\w*) \\(([:0-9]*)\\) \\(UN(\\d+)\\).*?To (.*?) \\(DR(\\d+)\\).*?</Description>.*?<FieldTime>(.*?)</FieldTime>.*?<LoggedTime>(.*?)</LoggedTime>";
|
||||
final Pattern pattern = Pattern.compile(regex, Pattern.DOTALL);
|
||||
final java.util.regex.Matcher matcher = pattern.matcher(data);
|
||||
if (matcher.find()){
|
||||
ProtegeData event = new ProtegeData();
|
||||
event.FirstName = matcher.group(1);
|
||||
event.LastName = matcher.group(2);
|
||||
event.CardNumber = matcher.group(3);
|
||||
event.UserNode = Integer.parseInt(matcher.group(4));
|
||||
event.DoorName = matcher.group(5);
|
||||
event.DoorNode = Integer.parseInt(matcher.group(6));
|
||||
event.FieldTime = matcher.group(7);
|
||||
event.LoggedTime = matcher.group(8);
|
||||
return event;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +1,87 @@
|
||||
package ProtegeGX;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class ProtegeGX {
|
||||
@Setter private Consumer<ProtegeData> onCardRead;
|
||||
private ServerSocket serverSocket;
|
||||
@Getter private boolean running ;
|
||||
|
||||
private void updateCardRead(ProtegeData data){
|
||||
if (onCardRead!=null) onCardRead.accept(data);
|
||||
private void UpdateCardData(String data){
|
||||
if (data!=null && !data.isEmpty()){
|
||||
ProtegeData cardData = ProtegeData.Parse(data);
|
||||
if (cardData!=null){
|
||||
Logger.info("Card data: "+cardData);
|
||||
if (onCardRead!=null){
|
||||
onCardRead.accept(cardData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ProtegeGX(){
|
||||
System.out.println("ProtegeGX Constructor");
|
||||
//TODO belum ada codingan, tunggu apache cxf jar nya
|
||||
}
|
||||
|
||||
public void Disconnect(){
|
||||
//TODO belum ada codingan, tunggu apache cxf jar nya
|
||||
|
||||
|
||||
public ProtegeGX(int localport) {
|
||||
running = false;
|
||||
try{
|
||||
serverSocket = new ServerSocket(localport);
|
||||
running = true;
|
||||
Logger.info("ProtegeGX server started on port "+localport);
|
||||
// Thread untuk serverSocket accept client
|
||||
new Thread(()->{
|
||||
while(running){
|
||||
try {
|
||||
Socket client = serverSocket.accept();
|
||||
// Thread untuk komunikasi dengan client
|
||||
new Thread(()->{
|
||||
try {
|
||||
Logger.info("Client connected: "+client.getInetAddress().getHostAddress());
|
||||
InputStream in = client.getInputStream();
|
||||
while(running){
|
||||
byte[] buffer = new byte[1024];
|
||||
int bytesRead = in.read(buffer);
|
||||
if (bytesRead>0){
|
||||
String data = new String(buffer, 0, bytesRead);
|
||||
//Logger.info("Data received: "+data);
|
||||
UpdateCardData(data);
|
||||
}
|
||||
}
|
||||
client.close();
|
||||
Logger.info("Client disconnected: "+client.getInetAddress().getHostAddress());
|
||||
} catch (IOException e) {
|
||||
Logger.error("Failed to read data from client: "+e.getMessage());
|
||||
}
|
||||
|
||||
}).start();
|
||||
} catch (IOException e) {
|
||||
Logger.error("Failed to accept client connection: "+e.getMessage());
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
} catch (Exception e){
|
||||
Logger.error("Failed to create server socket: "+e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void Disconnect() {
|
||||
running = false;
|
||||
if (serverSocket!=null){
|
||||
try{
|
||||
serverSocket.close();
|
||||
Logger.info("ProtegeGX server stopped");
|
||||
} catch (Exception e){
|
||||
Logger.error("Failed to close server socket: "+e.getMessage());
|
||||
}
|
||||
}
|
||||
serverSocket = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,11 @@ package Web;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import io.javalin.Javalin;
|
||||
import io.javalin.core.util.JavalinLogger;
|
||||
import io.javalin.http.staticfiles.Location;
|
||||
import io.javalin.jetty.JettyUtil;
|
||||
import lombok.Setter;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
@@ -30,15 +34,15 @@ public class WebServer {
|
||||
|
||||
Javalin app;
|
||||
public WebServer(){
|
||||
JettyUtil.disableJettyLogger();
|
||||
JavalinLogger.enabled = false;
|
||||
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
|
||||
get(ctx -> ctx.result("AAS Mini API"));
|
||||
post(ctx -> {
|
||||
config.addStaticFiles("/Web", Location.CLASSPATH);
|
||||
});
|
||||
app.get("/", ctx -> ctx.result("Hello World"));
|
||||
app.get("/aasmini", ctx -> ctx.result("AAS Mini API"));
|
||||
app.get("/protegegx", ctx -> ctx.result("ProtegeGX API"));
|
||||
app.post("/aasmini", ctx ->{
|
||||
try{
|
||||
WebRequest request = gson.fromJson(ctx.body(), WebRequest.class);
|
||||
WebResponse response = ProcessAAS(request);
|
||||
@@ -53,12 +57,7 @@ public class WebServer {
|
||||
ctx.result("Exception: "+e.getMessage());
|
||||
}
|
||||
});
|
||||
});
|
||||
// API for ProtegeGX
|
||||
path("protegegx", ()->{
|
||||
//TODO implement API for ProtegeGX
|
||||
get(ctx -> ctx.result("ProtegeGX API"));
|
||||
post(ctx -> {
|
||||
app.post("/protegegx", ctx ->{
|
||||
try{
|
||||
WebRequest request = gson.fromJson(ctx.body(), WebRequest.class);
|
||||
WebResponse response = ProcessProtegeGX(request);
|
||||
@@ -73,9 +72,6 @@ public class WebServer {
|
||||
ctx.result("Exception: "+e.getMessage());
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public void Start(int listenport){
|
||||
|
||||
Reference in New Issue
Block a user