Skip to content

Commit

Permalink
Merge pull request #4 from blackwiz4rd/master
Browse files Browse the repository at this point in the history
 Grammar created at start and pom.xml for compiling
  • Loading branch information
FlUxIuS authored May 2, 2021
2 parents 83a98ad + 594aed8 commit d3c3747
Show file tree
Hide file tree
Showing 15 changed files with 260 additions and 157 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target/
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,31 @@ This tool is based on [RISE V2G shared library](https://github.com/V2GClarity/RI

A release is available with a compiled Java Runtime binary there: https://github.com/FlUxIuS/V2Gdecoder/releases

## How to compile or execute
Install maven.

To compile:

```mvn compile assembly:single```

To execute:

```java -jar target/V2Gdecoder-jar-with-dependencies.jar```

If you wish to update risev2g version to something >1.2.6:

```
git clone https://github.com/V2GClarity/RISE-V2G/
cd RISE-V2G/RISE-V2G-PARENT
mvn install
```

Now copy RISE-V2G-Shared in our project:

```cp RISE-V2G/RISE-V2G-Shared/target/rise-v2g-shared-1.2.6.jar src/lib/com.v2gclarity.risev2g/```

Be aware that you might have to do some changes to the code.

## How to use

V2Gdecoder supports many methods to encode XML/decode EXI data as follows:
Expand Down
113 changes: 113 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.fluxlus.V2Gdecoder</groupId>
<artifactId>V2Gdecoder</artifactId>
<version>1.0-SNAPSHOT</version>

<name>V2Gdecoder</name>
<url>https://github.com/FlUxIuS/V2Gdecoder</url>

<packaging>jar</packaging> <!-- new -->
<description>V2Gdecoder description. </description>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>

<repositories>
<repository>
<id>project-local-repo</id>
<url>file://${project.basedir}/src/lib/</url>
</repository>
</repositories>

<dependencies>
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.14.0</version>
</dependency>
<dependency>
<groupId>com.v2gclarity.risev2g</groupId>
<artifactId>rise-v2g-shared</artifactId>
<version>1.2.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.siemens.ct.exi/exificient -->
<dependency>
<groupId>com.siemens.ct.exi</groupId>
<artifactId>exificient</artifactId>
<version>1.0.4</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-cli/commons-cli -->
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.4</version>
</dependency>
</dependencies>

<build>
<finalName>V2Gdecoder</finalName> <!-- added now-->
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>com.fluxlus.V2Gdecoder.V2Gdecoder</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
<!-- <plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin> -->
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<!-- https://mvnrepository.com/artifact/com.siemens.ct.exi/exificient-core -->
</plugins>
</pluginManagement>
</build>
</project>
6 changes: 0 additions & 6 deletions src/META-INF/MANIFEST.MF

This file was deleted.

17 changes: 0 additions & 17 deletions src/META-INF/maven/com.v2gclarity.risev2g/rise-v2g-shared/.project

This file was deleted.

This file was deleted.

59 changes: 0 additions & 59 deletions src/META-INF/maven/com.v2gclarity.risev2g/rise-v2g-shared/pom.xml

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import server.MultiThreadedServer;
package com.fluxlus.V2Gdecoder;

import com.fluxlus.V2Gdecoder.server.MultiThreadedServer;
import java.io.IOException;
import org.apache.commons.cli.*;
import org.xml.sax.SAXException;
import com.siemens.ct.exi.exceptions.EXIException;
import dataprocess.*;
import com.siemens.ct.exi.core.exceptions.EXIException;
import com.siemens.ct.exi.core.grammars.Grammars;
import com.siemens.ct.exi.grammars.GrammarFactory;
import com.v2gclarity.risev2g.shared.enumerations.GlobalValues;
import com.fluxlus.V2Gdecoder.dataprocess.*;

/*
* Copyright (C) V2Gdecoder by FlUxIuS (Sebastien Dudek)
Expand Down Expand Up @@ -51,7 +56,27 @@ public static void main(String[] args) throws IOException, SAXException, EXIExce
//String outputFilePath = cmd.getOptionValue("output"); /* TODO: custom output file */
decodeMode dmode = decodeMode.STRTOSTR;
String result = null;


/* Initialize grammars */
Grammars[] grammars = {null, null, null};

/* BOTTLENECK: slow operation */
try {
grammars[0] = GrammarFactory.newInstance().createGrammars("." + GlobalValues.SCHEMA_PATH_MSG_DEF.toString());
} catch (EXIException e) {
e.printStackTrace();
}
try {
grammars[1] = GrammarFactory.newInstance().createGrammars("." + GlobalValues.SCHEMA_PATH_APP_PROTOCOL.toString());
} catch (EXIException e) {
e.printStackTrace();
}
try {
grammars[2] = GrammarFactory.newInstance().createGrammars("." + GlobalValues.SCHEMA_PATH_XMLDSIG.toString());
} catch (EXIException e) {
e.printStackTrace();
}

if (cmd.hasOption("xml"))
{ // We wan to encode a XML input
if (cmd.hasOption("file"))
Expand All @@ -64,7 +89,7 @@ public static void main(String[] args) throws IOException, SAXException, EXIExce
if (cmd.hasOption("output"))
dmode = decodeMode.STRTOSTR;
}
result = dataprocess.Xml2Exi(inputFilePath, dmode);
result = dataprocess.fuzzyExiEncoder(inputFilePath, dmode, grammars);
if (!cmd.hasOption("output"))
System.out.println(result);
} else if (cmd.hasOption("exi")) { // We wan to decode an EXI input
Expand All @@ -78,13 +103,13 @@ public static void main(String[] args) throws IOException, SAXException, EXIExce
if (cmd.hasOption("output"))
dmode = decodeMode.STRTOFILE;
}
result = dataprocess.fuzzyExiDecoded(inputFilePath, dmode);
result = dataprocess.fuzzyExiDecoded(inputFilePath, dmode, grammars);
if (!cmd.hasOption("output"))
{ // output in stdout
System.out.println(result);
}
} else if (cmd.hasOption("web")) { // run a encoder/decoder service on port TCP 9000
MultiThreadedServer server = new MultiThreadedServer(9000);
MultiThreadedServer server = new MultiThreadedServer(9000, grammars);
new Thread(server).start();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package binascii;
package com.fluxlus.V2Gdecoder.binascii;

/*
* code from: https://github.com/EverythingMe/inbloom/blob/master/java/src/main/java/me/everything/inbloom/BinAscii.java
Expand Down
Loading

0 comments on commit d3c3747

Please # to comment.