-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
113 changed files
with
1,233 additions
and
373 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4"> | ||
<component name="FacetManager"> | ||
<facet type="kotlin-language" name="Kotlin"> | ||
<configuration version="3" platform="JVM 1.8" useProjectSettings="false"> | ||
<compilerSettings /> | ||
<compilerArguments> | ||
<option name="jvmTarget" value="1.8" /> | ||
<option name="languageVersion" value="1.2" /> | ||
<option name="apiVersion" value="1.2" /> | ||
<option name="pluginOptions"> | ||
<array /> | ||
</option> | ||
<option name="pluginClasspaths"> | ||
<array /> | ||
</option> | ||
</compilerArguments> | ||
</configuration> | ||
</facet> | ||
</component> | ||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8"> | ||
<output url="file://$MODULE_DIR$/target/classes" /> | ||
<output-test url="file://$MODULE_DIR$/target/test-classes" /> | ||
<content url="file://$MODULE_DIR$"> | ||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" /> | ||
<sourceFolder url="file://$MODULE_DIR$/src/test/kotlin" isTestSource="true" /> | ||
<sourceFolder url="file://$MODULE_DIR$/src/main/kotlin" isTestSource="false" /> | ||
<excludeFolder url="file://$MODULE_DIR$/target" /> | ||
</content> | ||
<orderEntry type="inheritedJdk" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
<orderEntry type="module" module-name="iec61131lang" /> | ||
<orderEntry type="library" name="Maven: org.antlr:antlr4:4.7" level="project" /> | ||
<orderEntry type="library" name="Maven: org.antlr:antlr-runtime:3.5.2" level="project" /> | ||
<orderEntry type="library" name="Maven: org.antlr:ST4:4.0.8" level="project" /> | ||
<orderEntry type="library" name="Maven: org.abego.treelayout:org.abego.treelayout.core:1.0.3" level="project" /> | ||
<orderEntry type="library" name="Maven: org.glassfish:javax.json:1.0.4" level="project" /> | ||
<orderEntry type="library" name="Maven: com.ibm.icu:icu4j:58.2" level="project" /> | ||
<orderEntry type="module" module-name="smv-model" /> | ||
<orderEntry type="library" name="Maven: org.antlr:antlr4-runtime:4.7" level="project" /> | ||
<orderEntry type="module" module-name="iec-xml" /> | ||
<orderEntry type="library" name="Maven: org.jdom:jdom2:2.0.6" level="project" /> | ||
<orderEntry type="library" name="Maven: jaxen:jaxen:1.1.4" level="project" /> | ||
<orderEntry type="library" name="Maven: net.sf.jopt-simple:jopt-simple:4.9" level="project" /> | ||
<orderEntry type="module" module-name="iec-symbex" /> | ||
<orderEntry type="library" name="Maven: de.tu-dresden.inf.lat.jsexp:jsexp:0.2.2" level="project" /> | ||
<orderEntry type="library" name="Maven: org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.2.21" level="project" /> | ||
<orderEntry type="library" name="Maven: org.jetbrains.kotlin:kotlin-stdlib:1.2.21" level="project" /> | ||
<orderEntry type="library" name="Maven: org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.21" level="project" /> | ||
<orderEntry type="library" scope="TEST" name="Maven: org.jetbrains.kotlin:kotlin-test:1.2.21" level="project" /> | ||
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" /> | ||
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" /> | ||
<orderEntry type="library" name="Maven: org.jetbrains:annotations:15.0" level="project" /> | ||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.25" level="project" /> | ||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-simple:1.7.25" level="project" /> | ||
<orderEntry type="library" name="Maven: commons-io:commons-io:2.6" level="project" /> | ||
<orderEntry type="library" name="Maven: com.google.guava:guava:23.6-jre" level="project" /> | ||
<orderEntry type="library" name="Maven: com.google.code.findbugs:jsr305:1.3.9" level="project" /> | ||
<orderEntry type="library" name="Maven: org.checkerframework:checker-compat-qual:2.0.0" level="project" /> | ||
<orderEntry type="library" name="Maven: com.google.errorprone:error_prone_annotations:2.1.3" level="project" /> | ||
<orderEntry type="library" name="Maven: com.google.j2objc:j2objc-annotations:1.1" level="project" /> | ||
<orderEntry type="library" name="Maven: org.codehaus.mojo:animal-sniffer-annotations:1.14" level="project" /> | ||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.projectlombok:lombok:1.16.20" level="project" /> | ||
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.7" level="project" /> | ||
</component> | ||
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
<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"> | ||
<parent> | ||
<artifactId>verifaps-lib</artifactId> | ||
<groupId>edu.kit.iti.formal</groupId> | ||
<version>1.5.0-SNAPSHOT</version> | ||
<relativePath>..</relativePath> | ||
</parent> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<kotlin.version>1.2.21</kotlin.version> | ||
<dokka.version>0.9.15</dokka.version> | ||
<junit.version>4.12</junit.version> | ||
<kotlin.compiler.incremental>true</kotlin.compiler.incremental> | ||
<main.class>edu.kit.iti.formal.automation.rvt.rvtapp.App</main.class> | ||
</properties> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
<artifactId>frontend</artifactId> | ||
<packaging>jar</packaging> | ||
|
||
<name>frontend</name> | ||
<url>http://maven.apache.org</url> | ||
|
||
<repositories> | ||
<repository> | ||
<snapshots> | ||
<enabled>false</enabled> | ||
</snapshots> | ||
<id>central</id> | ||
<name>bintray</name> | ||
<url>http://jcenter.bintray.com</url> | ||
</repository> | ||
</repositories> | ||
<pluginRepositories> | ||
<pluginRepository> | ||
<id>jcenter</id> | ||
<name>JCenter</name> | ||
<url>https://jcenter.bintray.com/</url> | ||
</pluginRepository> | ||
</pluginRepositories> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>edu.kit.iti.formal</groupId> | ||
<artifactId>iec61131lang</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>edu.kit.iti.formal</groupId> | ||
<artifactId>smv-model</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>edu.kit.iti.formal</groupId> | ||
<artifactId>iec-xml</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>edu.kit.iti.formal</groupId> | ||
<artifactId>iec-symbex</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jetbrains.kotlin</groupId> | ||
<artifactId>kotlin-stdlib-jdk8</artifactId> | ||
<version>${kotlin.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jetbrains.kotlin</groupId> | ||
<artifactId>kotlin-test</artifactId> | ||
<version>${kotlin.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<sourceDirectory>src/main/kotlin</sourceDirectory> | ||
<testSourceDirectory>src/test/kotlin</testSourceDirectory> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.jetbrains.kotlin</groupId> | ||
<artifactId>kotlin-maven-plugin</artifactId> | ||
<version>${kotlin.version}</version> | ||
<executions> | ||
<execution> | ||
<id>compile</id> | ||
<phase>compile</phase> | ||
<goals> | ||
<goal>compile</goal> | ||
</goals> | ||
</execution> | ||
<execution> | ||
<id>test-compile</id> | ||
<phase>test-compile</phase> | ||
<goals> | ||
<goal>test-compile</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<jvmTarget>1.8</jvmTarget> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
132 changes: 132 additions & 0 deletions
132
frontend/src/main/kotlin/edu/kit/iti/formal/automation/SC11_rev.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
package edu.kit.iti.formal.automation | ||
|
||
import edu.kit.iti.formal.automation.plcopenxml.IECXMLFacade | ||
import edu.kit.iti.formal.automation.scope.Scope | ||
import edu.kit.iti.formal.automation.sfclang.ast.ActionDeclaration | ||
import edu.kit.iti.formal.automation.sfclang.ast.SFC2ST | ||
import edu.kit.iti.formal.automation.st.ast.FunctionBlockDeclaration | ||
import edu.kit.iti.formal.automation.st.ast.ProgramDeclaration | ||
import edu.kit.iti.formal.automation.st.ast.TypeDeclarations | ||
import edu.kit.iti.formal.automation.st.ast.VariableDeclaration | ||
import edu.kit.iti.formal.automation.visitors.Utils | ||
import org.jdom2.JDOMException | ||
import java.io.File | ||
import java.io.IOException | ||
|
||
/** | ||
* @author Alexander Weigl | ||
* @version 1 (25.02.18) | ||
*/ | ||
object SC11_rev { | ||
private val typeDecls = TypeDeclarations() | ||
|
||
@Throws(JDOMException::class, IOException::class) | ||
@JvmStatic | ||
fun main(args: Array<String>) { | ||
val start = System.currentTimeMillis() | ||
|
||
val f = "/home/weigl/Documents/IMPROVE/Papiere/at2018/data/case3/Scenario11_Final_rev.xml" | ||
val tles = IECXMLFacade.readPLCOpenXml(f) | ||
|
||
System.out.printf("// Reading Time: %d ms%n", System.currentTimeMillis() - start) | ||
|
||
File("SC11_rev.iec61131").writer().use { | ||
it.write(IEC61131Facade.print(tles)) | ||
} | ||
|
||
for (tle in tles) { | ||
if (tle is ProgramDeclaration) { | ||
removeShittySFCVars(tle.scope) | ||
translate(tle) | ||
} | ||
if (tle is FunctionBlockDeclaration) { | ||
translate(tle) | ||
removeShittySFCVars(tle.scope) | ||
} | ||
} | ||
|
||
tles.add(0, typeDecls); | ||
tles.addAll(IEC61131Facade.file(File("ton.st").absoluteFile)) | ||
IEC61131Facade.resolveDataTypes(tles) | ||
File("SC11_rev.st").writer().use { | ||
it.write(IEC61131Facade.print(tles)) | ||
} | ||
println(File("SC11_rev.st").absolutePath + " written!") | ||
|
||
|
||
val stles = SymbExFacade.simplify(tles) | ||
// we need to trick with the input/output variables | ||
Utils.findProgram(tles).scope.forEach { | ||
if (it.name.startsWith("Actuator_")) | ||
it.type = it.type or VariableDeclaration.OUTPUT | ||
if (it.name.startsWith("Sensor_")) | ||
it.type = it.type or VariableDeclaration.INPUT | ||
} | ||
|
||
File("SC11_rev.st0").writer().use { | ||
it.write(IEC61131Facade.print(stles, true)) | ||
} | ||
println(File("SC11_rev.st0").absolutePath + " written!") | ||
|
||
|
||
val smv = SymbExFacade.evaluateProgram( | ||
stles[1] as ProgramDeclaration?, | ||
stles[0] as TypeDeclarations?) | ||
|
||
File("SC12f.smv").writer().use { | ||
it.write(smv.toString()) | ||
} | ||
println(File("SC12f.smv").absolutePath + " written!") | ||
|
||
val stop = System.currentTimeMillis() | ||
System.out.printf("// Time: %d ms%n", stop - start) | ||
} | ||
|
||
private fun removeShittySFCVars(scope: Scope) { | ||
val s = arrayOf("SFCCurrentStep", "SFCEnableLimit", "SFCError", | ||
"SFCErrorAnalyzation", "SFCErrorAnalyzationTable", "SFCErrorPOU", | ||
"SFCErrorStep", "SFCInit", "SFCPause", "SFCQuitError", "SFCTip", | ||
"SFCTipMode", "SFCTrans") | ||
s.forEach { scope.asMap().remove(it) } | ||
} | ||
|
||
private fun translate(fbd: FunctionBlockDeclaration) { | ||
if (fbd.sfcBody != null) { | ||
val ss = SFC2ST(fbd.name, | ||
fbd.sfcBody.networks[0], | ||
fbd.scope | ||
) | ||
fbd.stBody = ss.get() | ||
typeDecls.add(ss.enumDecl) | ||
} | ||
translate(fbd.name, fbd.scope, fbd.actions.values) | ||
} | ||
|
||
private fun translate(name: String, scope: Scope, actions: Collection<ActionDeclaration>) { | ||
actions.forEach { a -> translate(name, scope, a) } | ||
} | ||
|
||
private fun translate(name: String, scope: Scope, a: ActionDeclaration) { | ||
if (a.sfcBody != null) { | ||
val ss = SFC2ST(name + "__" + a.name, | ||
a.sfcBody!!.networks[0], | ||
scope | ||
) | ||
a.stBody = ss.get() | ||
typeDecls.add(ss.enumDecl) | ||
} | ||
} | ||
|
||
private fun translate(pd: ProgramDeclaration) { | ||
if (pd.sfcBody != null) { | ||
val ss = SFC2ST(pd.programName, | ||
pd.sfcBody.networks[0], | ||
pd.scope | ||
) | ||
pd.stBody = ss.get() | ||
typeDecls.add(ss.enumDecl) | ||
} | ||
translate(pd.programName, pd.scope, pd.actions.values) | ||
|
||
} | ||
} |
Oops, something went wrong.