Kaynağa Gözat

starting implementation

Wilfried Klaas 6 yıl önce
ebeveyn
işleme
7d86cd65d6
23 değiştirilmiş dosya ile 1148 ekleme ve 592 silme
  1. BIN
      mcs.keystore
  2. 189 160
      pom.xml
  3. 0 19
      src/main/java/de/mcs/tools/sps/emulator/EmulatorInput.java
  4. 0 33
      src/main/java/de/mcs/tools/sps/emulator/EmulatorInternals.java
  5. 0 24
      src/main/java/de/mcs/tools/sps/emulator/EmulatorOutput.java
  6. 0 36
      src/main/java/de/mcs/tools/sps/emulator/SPSCommand.java
  7. 0 40
      src/main/java/de/mcs/tools/sps/emulator/SPSCommandData.java
  8. 0 100
      src/main/java/de/mcs/tools/sps/emulator/SPSCommandDataImpl.java
  9. 0 78
      src/main/java/de/mcs/tools/sps/emulator/SPSCommandImpl.java
  10. 0 88
      src/main/java/de/mcs/tools/sps/emulator/SPSEmulator.java
  11. 0 14
      src/main/java/de/mcs/tools/sps/emulator/TOutputCallback.java
  12. 44 0
      src/main/java/de/mcs/tools/sps/emulator/WebEmulatorApplication.java
  13. 55 0
      src/main/java/de/mcs/tools/sps/emulator/WebEmulatorConfiguration.java
  14. 75 0
      src/main/java/de/mcs/tools/sps/emulator/model/CommandModel.java
  15. 30 0
      src/main/java/de/mcs/tools/sps/emulator/model/Hardware.java
  16. 167 0
      src/main/java/de/mcs/tools/sps/emulator/model/InputModel.java
  17. 151 0
      src/main/java/de/mcs/tools/sps/emulator/model/OutputModel.java
  18. 109 0
      src/main/java/de/mcs/tools/sps/emulator/model/ProgramModel.java
  19. 118 0
      src/main/java/de/mcs/tools/sps/emulator/model/WebSessionModel.java
  20. 119 0
      src/main/java/de/mcs/tools/sps/emulator/model/WorkingModel.java
  21. 18 0
      src/main/java/de/mcs/tools/sps/emulator/resources/EmulatorResource.java
  22. 8 0
      src/main/resources/config.yml
  23. 65 0
      src/test/java/de/mcs/tools/sps/emulator/model/testWebSessionModel.java

BIN
mcs.keystore


+ 189 - 160
pom.xml

@@ -1,102 +1,101 @@
-<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>de.mcs.tools.sps</groupId>
-	<artifactId>SPSEmulator</artifactId>
-	<version>0.2.0</version>
-	<name>${project.groupId}:${project.artifactId}</name>
-	<url>http://www.wk-music.de</url>
-	<description>SPS Emulator wirtten in java.</description>
-	<licenses>
-		<license>
-			<name>The Apache License, Version 2.0</name>
-			<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
-		</license>
-	</licenses>
+<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>de.mcs.tools.sps</groupId>
+  <artifactId>SPSEmulator</artifactId>
+  <version>0.2.0</version>
+  <name>${project.groupId}:${project.artifactId}</name>
+  <url>http://www.wk-music.de</url>
+  <description>SPS Emulator wirtten in java.</description>
+  <licenses>
+    <license>
+      <name>The Apache License, Version 2.0</name>
+      <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
+    </license>
+  </licenses>
 
-	<developers>
-		<developer>
-			<name>Wilfried Klaas</name>
-			<email>w.klaas@gmx.de</email>
-			<organization>MCS</organization>
-			<organizationUrl>http://www.wk-music.de</organizationUrl>
-		</developer>
-	</developers>
+  <developers>
+    <developer>
+      <name>Wilfried Klaas</name>
+      <email>w.klaas@gmx.de</email>
+      <organization>MCS</organization>
+      <organizationUrl>http://www.wk-music.de</organizationUrl>
+    </developer>
+  </developers>
 
-	<properties>
-		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-		<timestamp>${maven.build.timestamp}</timestamp>
-		<maven.build.timestamp.format>dd.mm.yyyy HH:mm</maven.build.timestamp.format>
-		<jackson.version>2.8.5</jackson.version>
-	</properties>
-	<build>
-		<plugins>
-			<plugin>
-				<artifactId>maven-compiler-plugin</artifactId>
-				<version>3.3</version>
-				<configuration>
-					<source>1.8</source>
-					<target>1.8</target>
-				</configuration>
-			</plugin>
-			<plugin>
-				<groupId>org.apache.maven.plugins</groupId>
-				<artifactId>maven-surefire-plugin</artifactId>
-				<version>2.19.1</version>
-				<dependencies>
-					<dependency>
-						<groupId>org.junit.platform</groupId>
-						<artifactId>junit-platform-surefire-provider</artifactId>
-						<version>1.1.0</version>
-					</dependency>
-					<dependency>
-						<groupId>org.junit.jupiter</groupId>
-						<artifactId>junit-jupiter-engine</artifactId>
-						<version>5.1.0</version>
-					</dependency>
-				</dependencies>
-				<configuration>
-					<skipTests>true</skipTests>
-				</configuration>
-			</plugin>
-			<plugin>
-				<groupId>org.apache.maven.plugins</groupId>
-				<artifactId>maven-jar-plugin</artifactId>
-				<version>2.6</version>
-				<configuration>
-					<archive>
-						<manifest>
-							<mainClass>de.mcs.tools.sps.SPSAssembler</mainClass>
-							<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
-							<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
-						</manifest>
-						<manifestEntries>
-							<Build-Time>${maven.build.timestamp}</Build-Time>
-							<Application-Name>SPSTools</Application-Name>
-							<Application-Update-Id>72</Application-Update-Id>
-							<Application-Update-Url>http\://wkla.no-ip.biz/downloader/version.php?ID\=73</Application-Update-Url>
-							<Application-Url>http\://wkla.no-ip.biz/</Application-Url>
-							<Implementation-Vendor>MCS, Media Computer Software</Implementation-Vendor>
-						</manifestEntries>
-					</archive>
-				</configuration>
-			</plugin>
-			<plugin>
-				<groupId>org.apache.maven.plugins</groupId>
-				<artifactId>maven-shade-plugin</artifactId>
-				<version>2.4.1</version>
-				<executions>
-					<execution>
-						<phase>package</phase>
-						<goals>
-							<goal>shade</goal>
-						</goals>
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <timestamp>${maven.build.timestamp}</timestamp>
+    <maven.build.timestamp.format>dd.mm.yyyy HH:mm</maven.build.timestamp.format>
+    <jackson.version>2.9.6</jackson.version>
+  </properties>
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>3.3</version>
+        <configuration>
+          <source>1.8</source>
+          <target>1.8</target>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <version>2.19.1</version>
+        <dependencies>
+          <dependency>
+            <groupId>org.junit.platform</groupId>
+            <artifactId>junit-platform-surefire-provider</artifactId>
+            <version>1.1.0</version>
+          </dependency>
+          <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-engine</artifactId>
+            <version>5.1.0</version>
+          </dependency>
+        </dependencies>
+        <configuration>
+          <skipTests>true</skipTests>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jar-plugin</artifactId>
+        <version>2.6</version>
+        <configuration>
+          <archive>
+            <manifest>
+              <mainClass>de.mcs.tools.sps.SPSAssembler</mainClass>
+              <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
+              <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
+            </manifest>
+            <manifestEntries>
+              <Build-Time>${maven.build.timestamp}</Build-Time>
+              <Application-Name>SPSTools</Application-Name>
+              <Application-Update-Id>72</Application-Update-Id>
+              <Application-Update-Url>http\://wkla.no-ip.biz/downloader/version.php?ID\=73</Application-Update-Url>
+              <Application-Url>http\://wkla.no-ip.biz/</Application-Url>
+              <Implementation-Vendor>MCS, Media Computer Software</Implementation-Vendor>
+            </manifestEntries>
+          </archive>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-shade-plugin</artifactId>
+        <version>2.4.1</version>
+        <executions>
+          <execution>
+            <phase>package</phase>
+            <goals>
+              <goal>shade</goal>
+            </goals>
 						<!-- <configuration> <transformers> <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> 
 							<mainClass></mainClass> </transformer> </transformers> </configuration> -->
-					</execution>
-				</executions>
-			</plugin>
+          </execution>
+        </executions>
+      </plugin>
 			<!-- <plugin> <groupId>com.akathist.maven.plugins.launch4j</groupId> <artifactId>launch4j-maven-plugin</artifactId> 
 				<version>1.7.24</version> <executions> <execution> <id>l4j-clui</id> <phase>package</phase> 
 				<goals> <goal>launch4j</goal> </goals> <configuration> <dontWrapJar>false</dontWrapJar> 
@@ -111,69 +110,99 @@
 				<productName>${project.name}</productName> <companyName>MCS</companyName> 
 				<internalName>MCSSPSTools</internalName> <originalFilename>MCSSPSTools.exe</originalFilename> 
 				</versionInfo> </configuration> </execution> </executions> </plugin> -->
-		</plugins>
-	</build>
-	<dependencies>
-		<dependency>
-			<groupId>net.sourceforge.jmeasurement2</groupId>
-			<artifactId>MCSUtils</artifactId>
-			<version>1.0.152</version>
-		</dependency>
-		<dependency>
-			<groupId>org.junit.jupiter</groupId>
-			<artifactId>junit-jupiter-api</artifactId>
-			<version>5.1.0</version>
-			<scope>test</scope>
-		</dependency>
-		<dependency>
-			<groupId>commons-io</groupId>
-			<artifactId>commons-io</artifactId>
-			<version>2.5</version>
-		</dependency>
-		<dependency>
-			<groupId>net.sourceforge.jmeasurement2</groupId>
-			<artifactId>JMeasurement</artifactId>
-			<version>1.1.225</version>
-		</dependency>
-		<dependency>
-			<groupId>com.fasterxml.jackson.core</groupId>
-			<artifactId>jackson-core</artifactId>
-			<version>${jackson.version}</version>
-		</dependency>
-		<dependency>
-			<groupId>com.fasterxml.jackson.core</groupId>
-			<artifactId>jackson-annotations</artifactId>
-			<version>${jackson.version}</version>
-		</dependency>
-		<dependency>
-			<groupId>com.fasterxml.jackson.core</groupId>
-			<artifactId>jackson-databind</artifactId>
-			<version>${jackson.version}</version>
-		</dependency>
-		<dependency>
-			<groupId>com.fasterxml.jackson.dataformat</groupId>
-			<artifactId>jackson-dataformat-yaml</artifactId>
-			<version>${jackson.version}</version>
-		</dependency>
-		<dependency>
-			<groupId>log4j</groupId>
-			<artifactId>log4j</artifactId>
-			<version>1.2.17</version>
-		</dependency>
-		<dependency>
-			<groupId>com.martiansoftware</groupId>
-			<artifactId>jsap</artifactId>
-			<version>2.1</version>
-		</dependency>
-		<dependency>
-			<groupId>org.apache.commons</groupId>
-			<artifactId>commons-lang3</artifactId>
-			<version>3.4</version>
-		</dependency>
-		<dependency>
-			<groupId>org.reflections</groupId>
-			<artifactId>reflections</artifactId>
-			<version>0.9.10</version>
-		</dependency>
-	</dependencies>
+    </plugins>
+  </build>
+  <dependencies>
+    <dependency>
+      <groupId>net.sourceforge.jmeasurement2</groupId>
+      <artifactId>MCSUtils</artifactId>
+      <version>1.0.152</version>
+    </dependency>
+    <dependency>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter-api</artifactId>
+      <version>5.1.0</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>commons-io</groupId>
+      <artifactId>commons-io</artifactId>
+      <version>2.5</version>
+    </dependency>
+    <dependency>
+      <groupId>net.sourceforge.jmeasurement2</groupId>
+      <artifactId>JMeasurement</artifactId>
+      <version>1.1.225</version>
+    </dependency>
+    <dependency>
+      <groupId>com.fasterxml.jackson.core</groupId>
+      <artifactId>jackson-core</artifactId>
+      <version>${jackson.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>com.fasterxml.jackson.core</groupId>
+      <artifactId>jackson-annotations</artifactId>
+      <version>${jackson.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>com.fasterxml.jackson.core</groupId>
+      <artifactId>jackson-databind</artifactId>
+      <version>${jackson.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>com.fasterxml.jackson.dataformat</groupId>
+      <artifactId>jackson-dataformat-yaml</artifactId>
+      <version>${jackson.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>log4j</groupId>
+      <artifactId>log4j</artifactId>
+      <version>1.2.17</version>
+    </dependency>
+    <dependency>
+      <groupId>com.martiansoftware</groupId>
+      <artifactId>jsap</artifactId>
+      <version>2.1</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-lang3</artifactId>
+      <version>3.4</version>
+    </dependency>
+    <dependency>
+      <groupId>org.reflections</groupId>
+      <artifactId>reflections</artifactId>
+      <version>0.9.10</version>
+    </dependency>
+    <dependency>
+      <groupId>io.dropwizard</groupId>
+      <artifactId>dropwizard-core</artifactId>
+      <version>1.3.8</version>
+    </dependency>
+    <dependency>
+      <groupId>javax.xml.bind</groupId>
+      <artifactId>jaxb-api</artifactId>
+      <version>2.3.0</version>
+    </dependency>
+    <dependency>
+      <groupId>com.sun.xml.bind</groupId>
+      <artifactId>jaxb-impl</artifactId>
+      <version>2.3.0</version>
+    </dependency>
+    <dependency>
+      <groupId>org.glassfish.jaxb</groupId>
+      <artifactId>jaxb-runtime</artifactId>
+      <version>2.3.0</version>
+    </dependency>
+    <dependency>
+      <groupId>javax.activation</groupId>
+      <artifactId>activation</artifactId>
+      <version>1.1.1</version>
+    </dependency>
+    <dependency>
+      <groupId>com.google.guava</groupId>
+      <artifactId>guava</artifactId>
+      <version>27.0.1-jre</version>
+    </dependency>
+  </dependencies>
 </project>

+ 0 - 19
src/main/java/de/mcs/tools/sps/emulator/EmulatorInput.java

@@ -1,19 +0,0 @@
-package de.mcs.tools.sps.emulator;
-
-public interface EmulatorInput {
-
-  byte getInput();
-
-  void setInput(byte data);
-
-  void reset();
-
-  void setFeature(String name, byte value);
-
-  byte getFeature(String name);
-
-  void setFeature(String name, boolean value);
-
-  boolean getFeatureAsBool(String name);
-
-}

+ 0 - 33
src/main/java/de/mcs/tools/sps/emulator/EmulatorInternals.java

@@ -1,33 +0,0 @@
-/**
- * 
- */
-package de.mcs.tools.sps.emulator;
-
-/**
- * This interface is for getting the emualtor internal
- * 
- * @author w.klaas
- *
- */
-public interface EmulatorInternals {
-
-  void reset();
-
-  int getAddress();
-
-  void incAddress(int i);
-
-  void setDelay(long l);
-
-  long getDelay();
-
-  void setRegister(String register, byte data);
-
-  byte getRegister(String register);
-
-  void setAddress(int i);
-
-  void pushRtrAddress();
-
-  void popRtrAddress();
-}

+ 0 - 24
src/main/java/de/mcs/tools/sps/emulator/EmulatorOutput.java

@@ -1,24 +0,0 @@
-/**
- * 
- */
-package de.mcs.tools.sps.emulator;
-
-/**
- * this is the interface of all Emulatoroutputs
- * 
- * @author w.klaas
- *
- */
-public interface EmulatorOutput {
-
-  void reset();
-
-  byte getOutput();
-
-  byte getFeature(String name);
-
-  void setFeature(String name, byte register);
-
-  void setOutput(byte data);
-
-}

+ 0 - 36
src/main/java/de/mcs/tools/sps/emulator/SPSCommand.java

@@ -1,36 +0,0 @@
-/**
- * 
- */
-package de.mcs.tools.sps.emulator;
-
-import java.util.List;
-
-/**
- * a single Command for the emulator
- * 
- * @author w.klaas
- *
- */
-public interface SPSCommand {
-
-  /**
-   * @return the name of this command
-   */
-  String getName();
-
-  /**
-   * @return the short Mnemonic
-   */
-  String getMnemonic();
-
-  /**
-   * @return the byte code for this command
-   */
-  byte getCommandByte();
-
-  /**
-   * @return a lsit of all supported datas of this command
-   */
-  List<SPSCommandData> getCommandDatas();
-
-}

+ 0 - 40
src/main/java/de/mcs/tools/sps/emulator/SPSCommandData.java

@@ -1,40 +0,0 @@
-/**
- * 
- */
-package de.mcs.tools.sps.emulator;
-
-/**
- * a single command data for the emulator
- * 
- * @author w.klaas
- *
- */
-public interface SPSCommandData {
-
-  /**
-   * 
-   * @return the command this data belongs to
-   */
-  SPSCommand getCommand();
-
-  /**
-   * @return the name of this command
-   */
-  String getName();
-
-  /**
-   * @return the short Mnemonic
-   */
-  String getMnemonic();
-
-  /**
-   * @return the byte code for this command and data
-   */
-  byte getCommandByte();
-
-  /**
-   * here the work should be done
-   */
-  EmulatorOutput doWork(EmulatorInput input, EmulatorInternals internals, EmulatorOutput output);
-
-}

+ 0 - 100
src/main/java/de/mcs/tools/sps/emulator/SPSCommandDataImpl.java

@@ -1,100 +0,0 @@
-/**
- * 
- */
-package de.mcs.tools.sps.emulator;
-
-/**
- * @author w.klaas
- *
- */
-public abstract class SPSCommandDataImpl implements SPSCommandData {
-
-  String name;
-  String mnemonic;
-  byte cmdByte;
-  SPSCommand command;
-
-  public SPSCommandDataImpl() {
-  }
-
-  @Override
-  public SPSCommand getCommand() {
-    return command;
-  }
-
-  @Override
-  public String getName() {
-    return name;
-  }
-
-  @Override
-  public String getMnemonic() {
-    return mnemonic;
-  }
-
-  /**
-   * @return the cmdByte
-   */
-  @Override
-  public byte getCommandByte() {
-    return cmdByte;
-  }
-
-  /**
-   * @param cmdByte
-   *          the cmdByte to set
-   * @return this instance
-   */
-  public SPSCommandDataImpl setCommandByte(byte cmdByte) {
-    this.cmdByte = cmdByte;
-    return this;
-  }
-
-  /**
-   * @param name
-   *          the name to set
-   * @return this instance
-   */
-  public SPSCommandDataImpl setName(String name) {
-    this.name = name;
-    return this;
-  }
-
-  /**
-   * @param mnemonic
-   *          the mnemonic to set
-   * @return this instance
-   */
-  public SPSCommandDataImpl setMnemonic(String mnemonic) {
-    this.mnemonic = mnemonic;
-    return this;
-  }
-
-  /**
-   * @param command
-   *          the command to set
-   * @return this instance
-   */
-  public SPSCommandDataImpl setCommand(SPSCommand command) {
-    this.command = command;
-    return this;
-  }
-
-  /**
-   * @param command
-   *          the command to set
-   * @return this instance
-   */
-  public byte getData() {
-    return (byte) (getCommandByte() & (byte) 0x0F);
-  }
-
-  @Override
-  public String toString() {
-    return String.format("%s (%s): %.2X", getMnemonic(), getName(), getCommandByte());
-  }
-
-  @Override
-  public abstract EmulatorOutput doWork(EmulatorInput input, EmulatorInternals internals, EmulatorOutput output);
-
-}

+ 0 - 78
src/main/java/de/mcs/tools/sps/emulator/SPSCommandImpl.java

@@ -1,78 +0,0 @@
-/**
- * 
- */
-package de.mcs.tools.sps.emulator;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author w.klaas
- *
- */
-public class SPSCommandImpl implements SPSCommand {
-
-  String name;
-  String mnemonic;
-  byte cmdByte;
-  List<SPSCommandData> datas = new ArrayList<>();
-
-  /**
-   * 
-   */
-  public SPSCommandImpl() {
-  }
-
-  @Override
-  public String getName() {
-    return name;
-  }
-
-  @Override
-  public String getMnemonic() {
-    return mnemonic;
-  }
-
-  @Override
-  public byte getCommandByte() {
-    return cmdByte;
-  }
-
-  @Override
-  public List<SPSCommandData> getCommandDatas() {
-    return datas;
-  }
-
-  /**
-   * @param cmdByte
-   *          the cmdByte to set
-   */
-  public SPSCommandImpl setCommandByte(byte cmdByte) {
-    this.cmdByte = cmdByte;
-    return this;
-  }
-
-  /**
-   * @param name
-   *          the name to set
-   */
-  public SPSCommandImpl setName(String name) {
-    this.name = name;
-    return this;
-  }
-
-  /**
-   * @param mnemonic
-   *          the mnemonic to set
-   * @return
-   */
-  public SPSCommandImpl setMnemonic(String mnemonic) {
-    this.mnemonic = mnemonic;
-    return this;
-  }
-
-  @Override
-  public String toString() {
-    return String.format("%s (%s): %.2X", getMnemonic(), getName(), getCommandByte());
-  }
-}

+ 0 - 88
src/main/java/de/mcs/tools/sps/emulator/SPSEmulator.java

@@ -1,88 +0,0 @@
-/**
- * 
- */
-package de.mcs.tools.sps.emulator;
-
-import java.util.List;
-
-import de.mcs.tools.sps.emulator.exceptions.WrongProgramSizeException;
-
-/**
- * @author w.klaas
- *
- */
-public interface SPSEmulator {
-
-  /**
-   * returning all commands supported by this emulator
-   * 
-   * @return lsit of all supported commands
-   */
-  List<SPSCommand> getCommands();
-
-  /**
-   * @return the size of the internal program area
-   */
-  int getProgramSize();
-
-  /**
-   * loading a program into the emulator
-   * 
-   * @param program
-   *          to load
-   * @throws WrongProgramSizeException
-   */
-  void loadProgram(byte[] program) throws WrongProgramSizeException;
-
-  /**
-   * starting the program with or without debug mode
-   * 
-   * @param debug
-   *          if debug = <code>true</code> than the program will stop on every step, otherwise only the callbacks will
-   *          be called
-   */
-  void startProgram(boolean debug);
-
-  /**
-   * adding a callback for the outputs of the emulator
-   * 
-   * @param callback
-   */
-  void addCallback(TOutputCallback callback);
-
-  /**
-   * do the next step of the program
-   */
-  void nextStep();
-
-  /**
-   * sps emulator is active
-   * 
-   * @return
-   */
-  boolean isActive();
-
-  /**
-   * stop the actual process
-   */
-  void stop();
-
-  /**
-   * setting the input for the emulator
-   * 
-   * @param input
-   */
-  void setEmulatorInput(EmulatorInput input);
-
-  EmulatorInput getEmulatorInput();
-
-  /**
-   * 
-   * @return the actual emulator internals
-   */
-  EmulatorInternals getEmulatorInternals();
-
-  EmulatorOutput getEmulatorOutput();
-
-  SPSCommandData getCommandData(byte command);
-}

+ 0 - 14
src/main/java/de/mcs/tools/sps/emulator/TOutputCallback.java

@@ -1,14 +0,0 @@
-/**
- * 
- */
-package de.mcs.tools.sps.emulator;
-
-/**
- * Interface for the callbacks on the emulator
- * 
- * @author w.klaas
- *
- */
-public interface TOutputCallback {
-  void onOutput(EmulatorOutput output);
-}

+ 44 - 0
src/main/java/de/mcs/tools/sps/emulator/WebEmulatorApplication.java

@@ -0,0 +1,44 @@
+/**
+ * MCS Media Computer Software
+ * Copyright 2019 by Wilfried Klaas
+ * Project: SPSEmulator
+ * File: WebEmulatorApp.java
+ * EMail: W.Klaas@gmx.de
+ * Created: 29.01.2019 wklaa_000
+ * 
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>
+ */
+package de.mcs.tools.sps.emulator;
+
+import de.mcs.tools.sps.emulator.resources.EmulatorResource;
+import io.dropwizard.Application;
+import io.dropwizard.setup.Environment;
+
+/**
+ * @author wklaa_000
+ *
+ */
+public class WebEmulatorApplication extends Application<WebEmulatorConfiguration> {
+
+  public static void main(String[] args) throws Exception {
+    new WebEmulatorApplication().run(args);
+  }
+
+  @Override
+  public void run(WebEmulatorConfiguration configuration, Environment environment) throws Exception {
+    final EmulatorResource resource = new EmulatorResource();
+    environment.jersey().register(resource);
+  }
+
+}

+ 55 - 0
src/main/java/de/mcs/tools/sps/emulator/WebEmulatorConfiguration.java

@@ -0,0 +1,55 @@
+/**
+ * MCS Media Computer Software
+ * Copyright 2019 by Wilfried Klaas
+ * Project: SPSEmulator
+ * File: WebÊmulatorConfiguration.java
+ * EMail: W.Klaas@gmx.de
+ * Created: 29.01.2019 wklaa_000
+ * 
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>
+ */
+package de.mcs.tools.sps.emulator;
+
+import org.hibernate.validator.constraints.NotEmpty;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import io.dropwizard.Configuration;
+
+/**
+ * @author wklaa_000
+ *
+ */
+public class WebEmulatorConfiguration extends Configuration {
+
+  @NotEmpty
+  private String nodename;
+
+  /**
+   * @return the nodename
+   */
+  @JsonProperty
+  public String getNodename() {
+    return nodename;
+  }
+
+  /**
+   * @param nodename
+   *          the nodename to set
+   */
+  @JsonProperty
+  public void setNodename(String nodename) {
+    this.nodename = nodename;
+  }
+}

+ 75 - 0
src/main/java/de/mcs/tools/sps/emulator/model/CommandModel.java

@@ -0,0 +1,75 @@
+package de.mcs.tools.sps.emulator.model;
+
+import java.util.HashSet;
+import java.util.Set;
+
+public class CommandModel {
+
+  private enum COMMAND {
+    START, STOP, NEXT, RESET, NN
+  };
+
+  private Set<COMMAND> availableCommands;
+  private COMMAND actualCommand;
+
+  public CommandModel() {
+    setActualCommand(COMMAND.NN);
+    setAvailableCommands(new HashSet<>());
+    evaluateAvailableCommands(getActualCommand());
+  }
+
+  private void evaluateAvailableCommands(COMMAND command) {
+    getAvailableCommands().clear();
+    switch (command) {
+    case START:
+      getAvailableCommands().add(COMMAND.NEXT);
+      getAvailableCommands().add(COMMAND.STOP);
+      getAvailableCommands().add(COMMAND.RESET);
+      break;
+    case STOP:
+      getAvailableCommands().add(COMMAND.START);
+      getAvailableCommands().add(COMMAND.RESET);
+      break;
+    case NEXT:
+      getAvailableCommands().add(COMMAND.STOP);
+      getAvailableCommands().add(COMMAND.RESET);
+      break;
+    case RESET:
+    case NN:
+      getAvailableCommands().add(COMMAND.START);
+      break;
+    default:
+      break;
+    }
+  }
+
+  /**
+   * @return the availableCommands
+   */
+  public Set<COMMAND> getAvailableCommands() {
+    return availableCommands;
+  }
+
+  /**
+   * @param availableCommands
+   *          the availableCommands to set
+   */
+  public void setAvailableCommands(Set<COMMAND> availableCommands) {
+    this.availableCommands = availableCommands;
+  }
+
+  /**
+   * @return the actualCommand
+   */
+  public COMMAND getActualCommand() {
+    return actualCommand;
+  }
+
+  /**
+   * @param actualCommand
+   *          the actualCommand to set
+   */
+  public void setActualCommand(COMMAND actualCommand) {
+    this.actualCommand = actualCommand;
+  }
+}

+ 30 - 0
src/main/java/de/mcs/tools/sps/emulator/model/Hardware.java

@@ -0,0 +1,30 @@
+/**
+ * MCS Media Computer Software
+ * Copyright 2019 by Wilfried Klaas
+ * Project: SPSEmulator
+ * File: Hardware.java
+ * EMail: W.Klaas@gmx.de
+ * Created: 29.01.2019 wklaa_000
+ * 
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>
+ */
+package de.mcs.tools.sps.emulator.model;
+
+/**
+ * @author wklaa_000
+ *
+ */
+public enum Hardware {
+  HOLTEK, ATMEGA8, ARDUINOSPS, TINYSPS
+}

+ 167 - 0
src/main/java/de/mcs/tools/sps/emulator/model/InputModel.java

@@ -0,0 +1,167 @@
+package de.mcs.tools.sps.emulator.model;
+
+public class InputModel {
+
+  boolean input1;
+  boolean input2;
+  boolean input3;
+  boolean input4;
+
+  boolean sel;
+  boolean prg;
+
+  byte adc1;
+  byte adc2;
+  byte rc1;
+  byte rc2;
+
+  /**
+   * @return the input1
+   */
+  public boolean isInput1() {
+    return input1;
+  }
+
+  /**
+   * @param input1
+   *          the input1 to set
+   */
+  public void setInput1(boolean input1) {
+    this.input1 = input1;
+  }
+
+  /**
+   * @return the input2
+   */
+  public boolean isInput2() {
+    return input2;
+  }
+
+  /**
+   * @param input2
+   *          the input2 to set
+   */
+  public void setInput2(boolean input2) {
+    this.input2 = input2;
+  }
+
+  /**
+   * @return the input3
+   */
+  public boolean isInput3() {
+    return input3;
+  }
+
+  /**
+   * @param input3
+   *          the input3 to set
+   */
+  public void setInput3(boolean input3) {
+    this.input3 = input3;
+  }
+
+  /**
+   * @return the input4
+   */
+  public boolean isInput4() {
+    return input4;
+  }
+
+  /**
+   * @param input4
+   *          the input4 to set
+   */
+  public void setInput4(boolean input4) {
+    this.input4 = input4;
+  }
+
+  /**
+   * @return the sel
+   */
+  public boolean isSel() {
+    return sel;
+  }
+
+  /**
+   * @param sel
+   *          the sel to set
+   */
+  public void setSel(boolean sel) {
+    this.sel = sel;
+  }
+
+  /**
+   * @return the prg
+   */
+  public boolean isPrg() {
+    return prg;
+  }
+
+  /**
+   * @param prg
+   *          the prg to set
+   */
+  public void setPrg(boolean prg) {
+    this.prg = prg;
+  }
+
+  /**
+   * @return the adc1
+   */
+  public byte getAdc1() {
+    return adc1;
+  }
+
+  /**
+   * @param adc1
+   *          the adc1 to set
+   */
+  public void setAdc1(byte adc1) {
+    this.adc1 = adc1;
+  }
+
+  /**
+   * @return the adc2
+   */
+  public byte getAdc2() {
+    return adc2;
+  }
+
+  /**
+   * @param adc2
+   *          the adc2 to set
+   */
+  public void setAdc2(byte adc2) {
+    this.adc2 = adc2;
+  }
+
+  /**
+   * @return the rc1
+   */
+  public byte getRc1() {
+    return rc1;
+  }
+
+  /**
+   * @param rc1
+   *          the rc1 to set
+   */
+  public void setRc1(byte rc1) {
+    this.rc1 = rc1;
+  }
+
+  /**
+   * @return the rc2
+   */
+  public byte getRc2() {
+    return rc2;
+  }
+
+  /**
+   * @param rc2
+   *          the rc2 to set
+   */
+  public void setRc2(byte rc2) {
+    this.rc2 = rc2;
+  }
+}

+ 151 - 0
src/main/java/de/mcs/tools/sps/emulator/model/OutputModel.java

@@ -0,0 +1,151 @@
+package de.mcs.tools.sps.emulator.model;
+
+public class OutputModel {
+
+  boolean output1;
+  boolean output2;
+  boolean output3;
+  boolean output4;
+
+  byte pwm1;
+  byte pwm2;
+  byte servo1;
+  byte servo2;
+
+  byte tone;
+
+  /**
+   * @return the output1
+   */
+  public boolean isOutput1() {
+    return output1;
+  }
+
+  /**
+   * @param output1
+   *          the output1 to set
+   */
+  public void setOutput1(boolean output1) {
+    this.output1 = output1;
+  }
+
+  /**
+   * @return the output2
+   */
+  public boolean isOutput2() {
+    return output2;
+  }
+
+  /**
+   * @param output2
+   *          the output2 to set
+   */
+  public void setOutput2(boolean output2) {
+    this.output2 = output2;
+  }
+
+  /**
+   * @return the output3
+   */
+  public boolean isOutput3() {
+    return output3;
+  }
+
+  /**
+   * @param output3
+   *          the output3 to set
+   */
+  public void setOutput3(boolean output3) {
+    this.output3 = output3;
+  }
+
+  /**
+   * @return the output4
+   */
+  public boolean isOutput4() {
+    return output4;
+  }
+
+  /**
+   * @param output4
+   *          the output4 to set
+   */
+  public void setOutput4(boolean output4) {
+    this.output4 = output4;
+  }
+
+  /**
+   * @return the pwm1
+   */
+  public byte getPwm1() {
+    return pwm1;
+  }
+
+  /**
+   * @param pwm1
+   *          the pwm1 to set
+   */
+  public void setPwm1(byte pwm1) {
+    this.pwm1 = pwm1;
+  }
+
+  /**
+   * @return the pwm2
+   */
+  public byte getPwm2() {
+    return pwm2;
+  }
+
+  /**
+   * @param pwm2
+   *          the pwm2 to set
+   */
+  public void setPwm2(byte pwm2) {
+    this.pwm2 = pwm2;
+  }
+
+  /**
+   * @return the servo1
+   */
+  public byte getServo1() {
+    return servo1;
+  }
+
+  /**
+   * @param servo1
+   *          the servo1 to set
+   */
+  public void setServo1(byte servo1) {
+    this.servo1 = servo1;
+  }
+
+  /**
+   * @return the servo2
+   */
+  public byte getServo2() {
+    return servo2;
+  }
+
+  /**
+   * @param servo2
+   *          the servo2 to set
+   */
+  public void setServo2(byte servo2) {
+    this.servo2 = servo2;
+  }
+
+  /**
+   * @return the tone
+   */
+  public byte getTone() {
+    return tone;
+  }
+
+  /**
+   * @param tone
+   *          the tone to set
+   */
+  public void setTone(byte tone) {
+    this.tone = tone;
+  }
+}

+ 109 - 0
src/main/java/de/mcs/tools/sps/emulator/model/ProgramModel.java

@@ -0,0 +1,109 @@
+package de.mcs.tools.sps.emulator.model;
+
+import java.io.UnsupportedEncodingException;
+import java.util.Arrays;
+
+import org.apache.commons.lang3.StringUtils;
+
+import de.mcs.utils.SHA256Utils;
+
+public class ProgramModel {
+
+  private Hardware hardware;
+  private String[] source;
+  private String hash;
+  private byte[] bin;
+  private boolean modified;
+
+  public ProgramModel() {
+    hardware = Hardware.HOLTEK;
+    modified = false;
+  }
+
+  /**
+   * @return the source
+   */
+  public String[] getSource() {
+    return source;
+  }
+
+  /**
+   * @param source
+   *          the source to set
+   */
+  public void setSource(String[] source) {
+    this.source = source;
+    String sourceStr = Arrays.toString(source);
+    try {
+      String newHash = SHA256Utils.shaBytesToString(SHA256Utils.shaBytes(sourceStr.getBytes("UTF-8")));
+      if (StringUtils.isEmpty(hash)) {
+        this.hash = newHash;
+        this.setModified(false);
+      } else {
+        this.setModified(true);
+      }
+    } catch (UnsupportedEncodingException e) {
+      e.printStackTrace();
+    }
+  }
+
+  /**
+   * @return the hash
+   */
+  public String getHash() {
+    return hash;
+  }
+
+  /**
+   * @param hash
+   *          the hash to set
+   */
+  public void setHash(String hash) {
+    this.hash = hash;
+  }
+
+  /**
+   * @return the bin
+   */
+  public byte[] getBin() {
+    return bin;
+  }
+
+  /**
+   * @param bin
+   *          the bin to set
+   */
+  public void setBin(byte[] bin) {
+    this.bin = bin;
+  }
+
+  /**
+   * @return the hardware
+   */
+  public Hardware getHardware() {
+    return hardware;
+  }
+
+  /**
+   * @param hardware
+   *          the hardware to set
+   */
+  public void setHardware(Hardware hardware) {
+    this.hardware = hardware;
+  }
+
+  /**
+   * @return the modified
+   */
+  public boolean isModified() {
+    return modified;
+  }
+
+  /**
+   * @param modified
+   *          the modified to set
+   */
+  public void setModified(boolean modified) {
+    this.modified = modified;
+  }
+}

+ 118 - 0
src/main/java/de/mcs/tools/sps/emulator/model/WebSessionModel.java

@@ -0,0 +1,118 @@
+/**
+ * MCS Media Computer Software
+ * Copyright 2019 by Wilfried Klaas
+ * Project: SPSEmulator
+ * File: WebSessionModel.java
+ * EMail: W.Klaas@gmx.de
+ * Created: 29.01.2019 wklaa_000
+ * 
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>
+ */
+package de.mcs.tools.sps.emulator.model;
+
+/**
+ * @author wklaa_000
+ *
+ */
+public class WebSessionModel {
+
+  private ProgramModel program;
+  private CommandModel command;
+  private InputModel input;
+  private OutputModel output;
+  private WorkingModel work;
+
+  public WebSessionModel() {
+    program = new ProgramModel();
+    command = new CommandModel();
+    input = new InputModel();
+    output = new OutputModel();
+    work = new WorkingModel();
+  }
+
+  /**
+   * @return the input
+   */
+  public InputModel getInput() {
+    return input;
+  }
+
+  /**
+   * @param input
+   *          the input to set
+   */
+  public void setInput(InputModel input) {
+    this.input = input;
+  }
+
+  /**
+   * @return the output
+   */
+  public OutputModel getOutput() {
+    return output;
+  }
+
+  /**
+   * @param output
+   *          the output to set
+   */
+  public void setOutput(OutputModel output) {
+    this.output = output;
+  }
+
+  /**
+   * @return the work
+   */
+  public WorkingModel getWork() {
+    return work;
+  }
+
+  /**
+   * @param work
+   *          the work to set
+   */
+  public void setWork(WorkingModel work) {
+    this.work = work;
+  }
+
+  /**
+   * @return the program
+   */
+  public ProgramModel getProgram() {
+    return program;
+  }
+
+  /**
+   * @param program
+   *          the program to set
+   */
+  public void setProgram(ProgramModel program) {
+    this.program = program;
+  }
+
+  /**
+   * @return the command
+   */
+  public CommandModel getCommand() {
+    return command;
+  }
+
+  /**
+   * @param command
+   *          the command to set
+   */
+  public void setCommand(CommandModel command) {
+    this.command = command;
+  }
+}

+ 119 - 0
src/main/java/de/mcs/tools/sps/emulator/model/WorkingModel.java

@@ -0,0 +1,119 @@
+package de.mcs.tools.sps.emulator.model;
+
+public class WorkingModel {
+
+  byte registerA;
+  byte registerB;
+  byte registerC;
+  byte registerD;
+
+  byte page;
+  short raddress;
+  short address;
+
+  /**
+   * @return the registerA
+   */
+  public byte getRegisterA() {
+    return registerA;
+  }
+
+  /**
+   * @param registerA
+   *          the registerA to set
+   */
+  public void setRegisterA(byte registerA) {
+    this.registerA = registerA;
+  }
+
+  /**
+   * @return the registerB
+   */
+  public byte getRegisterB() {
+    return registerB;
+  }
+
+  /**
+   * @param registerB
+   *          the registerB to set
+   */
+  public void setRegisterB(byte registerB) {
+    this.registerB = registerB;
+  }
+
+  /**
+   * @return the registerC
+   */
+  public byte getRegisterC() {
+    return registerC;
+  }
+
+  /**
+   * @param registerC
+   *          the registerC to set
+   */
+  public void setRegisterC(byte registerC) {
+    this.registerC = registerC;
+  }
+
+  /**
+   * @return the registerD
+   */
+  public byte getRegisterD() {
+    return registerD;
+  }
+
+  /**
+   * @param registerD
+   *          the registerD to set
+   */
+  public void setRegisterD(byte registerD) {
+    this.registerD = registerD;
+  }
+
+  /**
+   * @return the page
+   */
+  public byte getPage() {
+    return page;
+  }
+
+  /**
+   * @param page
+   *          the page to set
+   */
+  public void setPage(byte page) {
+    this.page = page;
+  }
+
+  /**
+   * @return the raddress
+   */
+  public short getRaddress() {
+    return raddress;
+  }
+
+  /**
+   * @param raddress
+   *          the raddress to set
+   */
+  public void setRaddress(short raddress) {
+    this.raddress = raddress;
+  }
+
+  /**
+   * @return the address
+   */
+  public short getAddress() {
+    return address;
+  }
+
+  /**
+   * @param address
+   *          the address to set
+   */
+  public void setAddress(short address) {
+    this.address = address;
+  }
+
+}

+ 18 - 0
src/main/java/de/mcs/tools/sps/emulator/resources/EmulatorResource.java

@@ -0,0 +1,18 @@
+package de.mcs.tools.sps.emulator.resources;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import de.mcs.tools.sps.emulator.model.WebSessionModel;
+
+@Path("/emulator")
+@Produces(MediaType.APPLICATION_JSON)
+public class EmulatorResource {
+
+  @GET
+  public WebSessionModel getSession() {
+    return new WebSessionModel();
+  }
+}

+ 8 - 0
src/main/resources/config.yml

@@ -0,0 +1,8 @@
+nodename: node
+server:
+  applicationConnectors:
+    - type: https
+      port: 8443
+      keyStorePath: mcs.keystore
+      keyStorePassword: mcskey
+      validateCerts: false

+ 65 - 0
src/test/java/de/mcs/tools/sps/emulator/model/testWebSessionModel.java

@@ -0,0 +1,65 @@
+/**
+ * MCS Media Computer Software
+ * Copyright 2019 by Wilfried Klaas
+ * Project: SPSEmulator
+ * File: testWebSessionModel.java
+ * EMail: W.Klaas@gmx.de
+ * Created: 29.01.2019 wklaa_000
+ * 
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>
+ */
+package de.mcs.tools.sps.emulator.model;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.util.List;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import de.mcs.utils.JacksonUtils;
+
+/**
+ * @author wklaa_000
+ *
+ */
+class testWebSessionModel {
+
+  /**
+   * @throws java.lang.Exception
+   */
+  @BeforeEach
+  void setUp() throws Exception {
+  }
+
+  @Test
+  void test() throws IOException {
+    WebSessionModel webSessionModel = new WebSessionModel();
+
+    List<String> allLines = Files.readAllLines(new File("examples/Blink.tps").toPath());
+    webSessionModel.getProgram().setSource(allLines.toArray(new String[0]));
+
+    String modelJson = JacksonUtils.getJsonMapper().writeValueAsString(webSessionModel);
+    System.out.println(modelJson);
+    System.out.printf("size: %d\r\n", modelJson.length());
+
+    WebSessionModel sessionModel = JacksonUtils.getJsonMapper().readValue(modelJson, WebSessionModel.class);
+
+    String newModelJson = JacksonUtils.getJsonMapper().writeValueAsString(sessionModel);
+    System.out.println(newModelJson);
+    System.out.printf("size: %d\r\n", newModelJson.length());
+  }
+
+}