Browse Source

remove ur plugin stuff

Martin Kunz 6 years ago
parent
commit
68d2b0741b
26 changed files with 235 additions and 1385 deletions
  1. 1 1
      .idea/compiler.xml
  2. 1 1
      .idea/misc.xml
  3. 7 27
      pickorplaceswing.iml
  4. 44 326
      pom.xml
  5. 0 27
      src/main/java/at/acdp/urweb/Activator.java
  6. 10 5
      src/main/java/at/acdp/urweb/Main.java
  7. 0 61
      src/main/java/at/acdp/urweb/close/GripperCloseProgramNodeContribution.java
  8. 0 52
      src/main/java/at/acdp/urweb/close/GripperCloseProgramNodeService.java
  9. 0 25
      src/main/java/at/acdp/urweb/close/GripperCloseProgramNodeView.java
  10. 0 60
      src/main/java/at/acdp/urweb/open/GripperOpenProgramNodeContribution.java
  11. 0 49
      src/main/java/at/acdp/urweb/open/GripperOpenProgramNodeService.java
  12. 0 24
      src/main/java/at/acdp/urweb/open/GripperOpenProgramNodeView.java
  13. 0 162
      src/main/java/at/acdp/urweb/pickorplace/PickOrPlaceProgramNodeContribution.java
  14. 0 46
      src/main/java/at/acdp/urweb/pickorplace/PickOrPlaceProgramNodeService.java
  15. 0 109
      src/main/java/at/acdp/urweb/pickorplace/PickOrPlaceProgramNodeView.java
  16. 0 44
      src/main/java/at/acdp/urweb/pickorplace/Style.java
  17. 0 25
      src/main/java/at/acdp/urweb/pickorplace/TemplateType.java
  18. 0 24
      src/main/java/at/acdp/urweb/pickorplace/V3Style.java
  19. 0 24
      src/main/java/at/acdp/urweb/pickorplace/V5Style.java
  20. 12 0
      src/main/java/at/acdp/urweb/rtdeclient/RTDEClient.java
  21. 81 0
      src/main/java/at/acdp/urweb/sclient/SecondaryClient.java
  22. 54 0
      src/main/java/at/acdp/urweb/sclient/data/VersionMessage.java
  23. 1 6
      src/main/java/at/acdp/urweb/web/GetRobotRealtimeData.java
  24. 0 88
      src/main/java/at/acdp/urweb/web/RTDE.java
  25. 21 199
      src/main/java/at/acdp/urweb/web/WebServer.java
  26. 3 0
      webroot/index.html

+ 1 - 1
.idea/compiler.xml

@@ -10,7 +10,7 @@
       </profile>
     </annotationProcessing>
     <bytecodeTargetLevel>
-      <module name="pickorplaceswing" target="1.8" />
+      <module name="pickorplaceswing" target="11" />
     </bytecodeTargetLevel>
   </component>
 </project>

+ 1 - 1
.idea/misc.xml

@@ -10,7 +10,7 @@
       </list>
     </option>
   </component>
-  <component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="false" project-jdk-name="1.8" project-jdk-type="JavaSDK">
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="false" project-jdk-name="11" project-jdk-type="JavaSDK">
     <output url="file://$PROJECT_DIR$/out" />
   </component>
 </project>

File diff suppressed because it is too large
+ 7 - 27
pickorplaceswing.iml


+ 44 - 326
pom.xml

@@ -8,226 +8,80 @@
 	<artifactId>urweb</artifactId>
 	<version>1.0-SNAPSHOT</version>
 	<name>urweb</name>
-	<packaging>bundle</packaging>
-
+	<packaging>jar</packaging>
 	<properties>
-
-		<!--********************************************************************-->
-		<!--   Note: Update this section with relevant meta data                -->
-		<!--         that comes along with your URCap                           -->
-		<!--********************************************************************-->
-		<!--******************* BEGINNING OF URCAP META DATA *******************-->
-		<urcap.symbolicname>at.acdp.urweb</urcap.symbolicname>
-		<urcap.vendor>cdp</urcap.vendor>
-		<urcap.contactAddress>Seestadtstraße 27/10 1220 Wien</urcap.contactAddress>
-		<urcap.copyright>Copyright (C) 2018 Center for Digital Production GmbH</urcap.copyright>
-		<urcap.description>urweb description</urcap.description>
-		<urcap.licenseType>Commercial</urcap.licenseType>
-		<!--********************** END OF URCAP META DATA **********************-->
-		<!--********************************************************************-->
-
-		<!-- Host, username and password of the robot to be used when running "mvn install -Premote" -->
-		<urcap.install.host></urcap.install.host>
-		<urcap.install.username>root</urcap.install.username>
-		<urcap.install.password>easybot</urcap.install.password>
-
-		<!--Install path for the UR Sim-->
-		<ursim.home></ursim.home>
-
-		<!--Host and standard user/password for UR Sim running in a VM-->
-		<ursimvm.install.host></ursimvm.install.host>
-		<ursimvm.install.username>ur</ursimvm.install.username>
-		<ursimvm.install.password>easybot</ursimvm.install.password>
-
-
-		<embed-dep>*;scope=compile;type=!pom;inline=true</embed-dep>
-		<unpack-bundle>false</unpack-bundle>
-
+		<undertow.version>2.0.15.Final</undertow.version>
 	</properties>
-
 	<build>
 		<plugins>
 			<plugin>
-				<groupId>org.apache.maven.plugins</groupId>
-				<artifactId>maven-compiler-plugin</artifactId>
-				<version>3.6.0</version>
-				<configuration>
-					<source>1.8</source>
-					<target>1.8</target>
-				</configuration>
-			</plugin>
-			<plugin>
-				<artifactId>maven-jar-plugin</artifactId>
-				<version>3.1.0</version>
-				<configuration>
-					<archive>
-						<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
-					</archive>
-				</configuration>
-			</plugin>
-			<plugin>
-				<artifactId>maven-resources-plugin</artifactId>
-				<version>3.1.0</version>
+				<groupId>com.github.spotbugs</groupId>
+				<artifactId>spotbugs-maven-plugin</artifactId>
+				<version>3.1.8</version>
+				<dependencies>
+					<!-- overwrite dependency on spotbugs if you want to specify the version of spotbugs -->
+					<dependency>
+						<groupId>com.github.spotbugs</groupId>
+						<artifactId>spotbugs</artifactId>
+						<version>3.1.8</version>
+					</dependency>
+				</dependencies>
 			</plugin>
 			<plugin>
-				<groupId>org.apache.felix</groupId>
-				<artifactId>maven-bundle-plugin</artifactId>
-				<version>4.1.0</version>
-				<extensions>true</extensions>
-				<executions>
-					<execution>
-						<id>bundle-manifest</id>
-						<phase>process-classes</phase>
-						<goals>
-							<goal>manifest</goal>
-						</goals>
-					</execution>
-				</executions>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-compiler-plugin</artifactId>
+				<version>3.8.0</version>
 				<configuration>
-					<instructions>
-						<!--********** DO NOT MODIFY THE ENTRIES OF THIS SECTION **********-->
-						<Bundle-Category>URCap</Bundle-Category>
-						<Bundle-Activator>at.acdp.urweb.Activator</Bundle-Activator>
-						<Bundle-Vendor>${urcap.vendor}</Bundle-Vendor>
-						<Bundle-ContactAddress>${urcap.contactAddress}</Bundle-ContactAddress>
-						<Bundle-Copyright>${urcap.copyright}</Bundle-Copyright>
-						<Bundle-LicenseType>${urcap.licenseType}</Bundle-LicenseType>
-						<Bundle-Description>${urcap.description}</Bundle-Description>
-						<!--***************************************************************-->
-						<Import-Package>
-							com.ur.urcap.api*;version="[1.3.0,2.0.0)",
-							*
-						</Import-Package>
-						<Embed-Dependency>*;scope=compile;type=!pom;inline=true</Embed-Dependency>
-					</instructions>
+					<source>11</source>
+					<target>11</target>
+					<excludes>
+						<exclude>module-info.java</exclude>
+					</excludes>
 				</configuration>
 			</plugin>
 			<plugin>
 				<groupId>org.apache.maven.plugins</groupId>
-				<artifactId>maven-antrun-plugin</artifactId>
+				<artifactId>maven-shade-plugin</artifactId>
+				<version>3.2.1</version>
 				<executions>
 					<execution>
-						<id>server-copy</id>
+						<phase>package</phase>
 						<goals>
-							<goal>run</goal>
+							<goal>shade</goal>
 						</goals>
-						<phase>install</phase>
 						<configuration>
-							<tasks>
-								<echo message="Pushing to host..." />
-								<scp file="target/${project.build.finalName}.jar" port="22" trust="true"
-									 todir="root:easybot@192.168.20.130:/programs/urweb.urcap"/>
-							</tasks>
+							<minimizeJar>true</minimizeJar>
 						</configuration>
 					</execution>
 				</executions>
-				<dependencies>
-					<dependency>
-						<groupId>org.apache.ant</groupId>
-						<artifactId>ant-jsch</artifactId>
-						<version>1.10.5</version>
-					</dependency>
-					<dependency>
-						<groupId>com.jcraft</groupId>
-						<artifactId>jsch</artifactId>
-						<version>0.1.54</version>
-					</dependency>
-					<dependency>
-						<groupId>commons-net</groupId>
-						<artifactId>commons-net</artifactId>
-						<version>3.6</version>
-					</dependency>
-					<dependency>
-						<groupId>ant</groupId>
-						<artifactId>ant-commons-net</artifactId>
-						<version>1.6.5</version>
-					</dependency>
-				</dependencies>
 			</plugin>
-
-			<!--<plugin>-->
-				<!--<groupId>org.codehaus.mojo</groupId>-->
-				<!--<artifactId>exec-maven-plugin</artifactId>-->
-				<!--<version>1.1</version>-->
-				<!--<executions>-->
-					<!--&lt;!&ndash; generate URCap package after compiling &ndash;&gt;-->
-					<!--<execution>-->
-						<!--<id>package-urcap</id>-->
-						<!--<phase>package</phase>-->
-						<!--<goals>-->
-							<!--<goal>exec</goal>-->
-						<!--</goals>-->
-						<!--<configuration>-->
-							<!--<executable>cp</executable>-->
-							<!--<commandlineArgs>target/${project.build.finalName}.jar target/${project.build.finalName}.urcap</commandlineArgs>-->
-							<!--<workingDirectory>.</workingDirectory>-->
-						<!--</configuration>-->
-					<!--</execution>-->
-				<!--</executions>-->
-			<!--</plugin>-->
 			<plugin>
-				<artifactId>maven-assembly-plugin</artifactId>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-jar-plugin</artifactId>
+				<version>3.1.0</version>
 				<configuration>
-					<descriptors>
-						<descriptor>assembly.xml</descriptor>
-					</descriptors>
+					<archive>
+						<manifest>
+							<addClasspath>true</addClasspath>
+							<mainClass>at.acdp.urweb.Main</mainClass>
+						</manifest>
+					</archive>
 				</configuration>
-				<executions>
-					<execution>
-						<phase>package</phase>
-						<goals>
-							<goal>single</goal>
-						</goals>
-					</execution>
-				</executions>
 			</plugin>
 		</plugins>
-		<extensions>
-			<extension>
-				<groupId>org.apache.maven.wagon</groupId>
-				<artifactId>wagon-ssh</artifactId>
-				<version>3.2.0</version>
-			</extension>
-		</extensions>
 	</build>
 
 	<dependencies>
-		<dependency>
-			<groupId>org.osgi</groupId>
-			<artifactId>org.osgi.core</artifactId>
-			<version>4.3.1</version>
-			<scope>provided</scope>
-		</dependency>
-		<dependency>
-			<groupId>com.ur.urcap</groupId>
-			<artifactId>api</artifactId>
-			<version>1.3.0</version>
-			<scope>provided</scope>
-		</dependency>
-
-		<dependency>
-			<artifactId>nanohttpd</artifactId>
-			<groupId>org.nanohttpd</groupId>
-			<version>2.3.2-SNAPSHOT</version>
-		</dependency>
-		<dependency>
-			<artifactId>nanohttpd-websocket</artifactId>
-			<groupId>org.nanohttpd</groupId>
-			<version>2.3.2-SNAPSHOT</version>
-		</dependency>
-
-		<dependency>
-			<artifactId>nanohttpd-webserver</artifactId>
-			<groupId>org.nanohttpd</groupId>
-			<version>2.3.2-SNAPSHOT</version>
-		</dependency>
-
 		<dependency>
 			<groupId>com.eclipsesource.minimal-json</groupId>
 			<artifactId>minimal-json</artifactId>
 			<version>0.9.5</version>
 		</dependency>
-
+		<dependency>
+			<groupId>io.undertow</groupId>
+			<artifactId>undertow-core</artifactId>
+			<version>${undertow.version}</version>
+		</dependency>
 		<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->
 		<dependency>
 			<groupId>org.junit.jupiter</groupId>
@@ -235,152 +89,16 @@
 			<version>5.3.1</version>
 			<scope>test</scope>
 		</dependency>
-		<dependency>
-			<groupId>org.nanohttpd</groupId>
-			<artifactId>nanohttpd-nanolets</artifactId>
-			<version>2.3.2-SNAPSHOT</version>
-		</dependency>
 		<dependency>
 			<groupId>org.slf4j</groupId>
 			<artifactId>slf4j-api</artifactId>
 			<version>1.7.25</version>
 		</dependency>
+		<!-- https://mvnrepository.com/artifact/ch.qos.logback/logback-classic -->
 		<dependency>
-			<groupId>org.slf4j</groupId>
-			<artifactId>slf4j-jdk14</artifactId>
-			<version>1.7.25</version>
+			<groupId>ch.qos.logback</groupId>
+			<artifactId>logback-classic</artifactId>
+			<version>1.2.3</version>
 		</dependency>
-
-
 	</dependencies>
-
-	<profiles>
-		<profile>
-			<id>remote</id>
-			<build>
-				<plugins>
-					<plugin>
-						<groupId>org.codehaus.mojo</groupId>
-						<artifactId>exec-maven-plugin</artifactId>
-						<version>1.1</version>
-						<executions>
-							<execution>
-								<id>remote-install-urcap</id>
-								<phase>install</phase>
-								<goals>
-									<goal>exec</goal>
-								</goals>
-								<configuration>
-									<executable>sshpass</executable>
-									<commandlineArgs>-p ${urcap.install.password} scp -o StrictHostKeyChecking=no target/${project.build.finalName}.jar ${urcap.install.username}@${urcap.install.host}:/root/.urcaps/${urcap.symbolicname}.jar</commandlineArgs>
-									<workingDirectory>.</workingDirectory>
-								</configuration>
-							</execution>
-							<execution>
-								<id>remote-restart-ui</id>
-								<phase>install</phase>
-								<goals>
-									<goal>exec</goal>
-								</goals>
-								<configuration>
-									<executable>sshpass</executable>
-									<commandlineArgs>-p ${urcap.install.password} ssh ${urcap.install.username}@${urcap.install.host} pkill java</commandlineArgs>
-									<workingDirectory>.</workingDirectory>
-								</configuration>
-							</execution>
-						</executions>
-					</plugin>
-				</plugins>
-			</build>
-		</profile>
-		<profile>
-			<id>local</id>
-			<build>
-				<plugins>
-					<plugin>
-						<groupId>org.codehaus.mojo</groupId>
-						<artifactId>exec-maven-plugin</artifactId>
-						<version>1.1</version>
-						<executions>
-							<execution>
-								<id>local-install-urcap</id>
-								<phase>install</phase>
-								<goals>
-									<goal>exec</goal>
-								</goals>
-								<configuration>
-									<executable>cp</executable>
-									<commandlineArgs>target/${project.build.finalName}.jar ${user.home}/.urcaps/${urcap.symbolicname}.jar</commandlineArgs>
-									<workingDirectory>.</workingDirectory>
-								</configuration>
-							</execution>
-						</executions>
-					</plugin>
-				</plugins>
-			</build>
-		</profile>
-		<profile>
-			<id>ursim</id>
-			<build>
-				<plugins>
-					<plugin>
-						<groupId>org.codehaus.mojo</groupId>
-						<artifactId>exec-maven-plugin</artifactId>
-						<version>1.1</version>
-						<executions>
-							<execution>
-								<id>ursim-install-urcap</id>
-								<phase>install</phase>
-								<goals>
-									<goal>exec</goal>
-								</goals>
-								<configuration>
-									<executable>cp</executable>
-									<commandlineArgs>target/${project.build.finalName}.jar ${ursim.home}/.urcaps/${urcap.symbolicname}.jar</commandlineArgs>
-									<workingDirectory>.</workingDirectory>
-								</configuration>
-							</execution>
-						</executions>
-					</plugin>
-				</plugins>
-			</build>
-		</profile>
-		<profile>
-			<id>ursimvm</id>
-			<build>
-				<plugins>
-					<plugin>
-						<groupId>org.codehaus.mojo</groupId>
-						<artifactId>exec-maven-plugin</artifactId>
-						<version>1.1</version>
-						<executions>
-							<execution>
-								<id>ursimvm-install-urcap</id>
-								<phase>install</phase>
-								<goals>
-									<goal>exec</goal>
-								</goals>
-								<configuration>
-									<executable>sshpass</executable>
-									<commandlineArgs>-p ${ursimvm.install.password} scp -o StrictHostKeyChecking=no target/${project.build.finalName}.jar ${ursimvm.install.username}@${ursimvm.install.host}:/home/ur/ursim-current/.urcaps/${urcap.symbolicname}.jar</commandlineArgs>
-									<workingDirectory>.</workingDirectory>
-								</configuration>
-							</execution>
-						</executions>
-					</plugin>
-				</plugins>
-			</build>
-		</profile>
-	</profiles>
-
-	<repositories>
-		<repository>
-			<id>sonatype-snapshots</id>
-			<url>https://oss.sonatype.org/content/repositories/snapshots</url>
-			<snapshots>
-				<enabled>true</enabled>
-			</snapshots>
-		</repository>
-	</repositories>
-
 </project>

+ 0 - 27
src/main/java/at/acdp/urweb/Activator.java

@@ -1,27 +0,0 @@
-package at.acdp.urweb;
-
-import at.acdp.urweb.close.GripperCloseProgramNodeService;
-import at.acdp.urweb.open.GripperOpenProgramNodeService;
-import at.acdp.urweb.pickorplace.PickOrPlaceProgramNodeService;
-import at.acdp.urweb.web.WebServer;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-
-import com.ur.urcap.api.contribution.program.swing.SwingProgramNodeService;
-
-public class Activator implements BundleActivator {
-
-	@Override
-	public void start(final BundleContext context) throws Exception {
-		context.registerService(SwingProgramNodeService.class, new PickOrPlaceProgramNodeService(), null);
-		context.registerService(SwingProgramNodeService.class, new GripperOpenProgramNodeService(), null);
-		context.registerService(SwingProgramNodeService.class, new GripperCloseProgramNodeService(), null);
-		new WebServer(8080, true).start();
-	}
-
-	@Override
-	public void stop(BundleContext context) throws Exception {
-
-	}
-
-}

+ 10 - 5
src/main/java/at/acdp/urweb/Main.java

@@ -1,7 +1,6 @@
 package at.acdp.urweb;
 
-import at.acdp.urweb.web.GetRobotRealtimeData;
-import at.acdp.urweb.web.RTDE;
+import at.acdp.urweb.sclient.SecondaryClient;
 import at.acdp.urweb.web.WebServer;
 
 import java.io.IOException;
@@ -13,9 +12,15 @@ public class Main {
         try {
             new WebServer(8080,true).start();
             //GetRobotRealtimeData rd=new GetRobotRealtimeData("192.168.20.107", 30003);
-            RTDE rde=new RTDE("192.168.20.107", 30002);
-            Thread t=new Thread(rde);
-            t.start();
+            SecondaryClient rde=new SecondaryClient("192.168.20.107", 30002);
+            rde.connect();
+
+            //rde.writeCmd("set_digital_out(1,True)\n");
+
+
+            // rde.writeCmd("set_digital_out(2,True)\n");
+            // rde.writeCmd("movej([-1.95,-1.58,-1.16,-1.15,-1.55,1.25], a=1.0, v=0.1)\n");
+            //rde.writeCmd("freedrive_mode()\n");
 
         } catch (IOException e) {
             e.printStackTrace();

+ 0 - 61
src/main/java/at/acdp/urweb/close/GripperCloseProgramNodeContribution.java

@@ -1,61 +0,0 @@
-package at.acdp.urweb.close;
-
-import com.ur.urcap.api.contribution.ProgramNodeContribution;
-import com.ur.urcap.api.contribution.program.ProgramAPIProvider;
-import com.ur.urcap.api.domain.ProgramAPI;
-import com.ur.urcap.api.domain.program.ProgramModel;
-import com.ur.urcap.api.domain.program.nodes.ProgramNodeFactory;
-import com.ur.urcap.api.domain.program.structure.TreeNode;
-import com.ur.urcap.api.domain.program.structure.TreeStructureException;
-import com.ur.urcap.api.domain.script.ScriptWriter;
-
-public class GripperCloseProgramNodeContribution implements ProgramNodeContribution {
-
-	private final ProgramAPIProvider apiProvider;
-
-	GripperCloseProgramNodeContribution(ProgramAPIProvider apiProvider) {
-		this.apiProvider = apiProvider;
-		createSubtree();
-	}
-
-	@Override
-	public String getTitle() {
-		return "Gripper Close";
-	}
-
-	@Override
-	public void openView() {
-	}
-
-	@Override
-	public void closeView() {
-	}
-
-	@Override
-	public boolean isDefined() {
-		return true;
-	}
-
-	@Override
-	public void generateScript(ScriptWriter writer) {
-		// Place script for closing gripper here
-		writer.writeChildren();
-	}
-
-	private void createSubtree() {
-		ProgramAPI programAPI = apiProvider.getProgramAPI();
-		ProgramModel programModel = programAPI.getProgramModel();
-		ProgramNodeFactory nf = programModel.getProgramNodeFactory();
-		TreeNode root = programModel.getRootTreeNode(this);
-
-		try {
-			root.addChild(nf.createCommentNode().setComment("Add your nodes here"));
-			root.addChild(nf.createSetNode());
-			root.addChild(nf.createWaitNode());
-		} catch (TreeStructureException e) {
-			e.printStackTrace();
-			// See e.getMessage() for explanation
-		}
-	}
-
-}

+ 0 - 52
src/main/java/at/acdp/urweb/close/GripperCloseProgramNodeService.java

@@ -1,52 +0,0 @@
-package at.acdp.urweb.close;
-
-import java.util.Locale;
-
-import at.acdp.urweb.pickorplace.Style;
-import at.acdp.urweb.pickorplace.V3Style;
-import at.acdp.urweb.pickorplace.V5Style;
-import com.ur.urcap.api.contribution.ViewAPIProvider;
-import com.ur.urcap.api.contribution.program.ContributionConfiguration;
-import com.ur.urcap.api.contribution.program.CreationContext;
-import com.ur.urcap.api.contribution.program.ProgramAPIProvider;
-import com.ur.urcap.api.contribution.program.swing.SwingProgramNodeService;
-import com.ur.urcap.api.domain.SystemAPI;
-import com.ur.urcap.api.domain.data.DataModel;
-
-public class GripperCloseProgramNodeService
-		implements SwingProgramNodeService<GripperCloseProgramNodeContribution, GripperCloseProgramNodeView> {
-
-	public GripperCloseProgramNodeService() {
-	}
-
-	@Override
-	public String getTitle(Locale locale) {
-		return "Gripper Close";
-	}
-
-	@Override
-	public String getId() {
-		return "GripperProgramNode";
-	}
-
-	@Override
-	public void configureContribution(ContributionConfiguration configuration) {
-		configuration.setDeprecated(false);
-		configuration.setUserInsertable(false);
-		configuration.setChildrenAllowed(true);
-	}
-
-	@Override
-	public GripperCloseProgramNodeView createView(ViewAPIProvider apiProvider) {
-		SystemAPI systemAPI = apiProvider.getSystemAPI();
-		Style style = systemAPI.getSoftwareVersion().getMajorVersion() >= 5 ? new V5Style() : new V3Style();
-		return new GripperCloseProgramNodeView(style);
-	}
-
-	@Override
-	public GripperCloseProgramNodeContribution createNode(ProgramAPIProvider apiProvider,
-			GripperCloseProgramNodeView view, DataModel model, CreationContext context) {
-		return new GripperCloseProgramNodeContribution(apiProvider);
-	}
-
-}

+ 0 - 25
src/main/java/at/acdp/urweb/close/GripperCloseProgramNodeView.java

@@ -1,25 +0,0 @@
-package at.acdp.urweb.close;
-
-import javax.swing.BoxLayout;
-import javax.swing.JPanel;
-
-import at.acdp.urweb.pickorplace.Style;
-import com.ur.urcap.api.contribution.ContributionProvider;
-import com.ur.urcap.api.contribution.program.swing.SwingProgramNodeView;
-
-public class GripperCloseProgramNodeView implements SwingProgramNodeView<GripperCloseProgramNodeContribution> {
-
-	private final Style style;
-
-	GripperCloseProgramNodeView(Style style) {
-		this.style = style;
-	}
-
-	@Override
-	public void buildUI(JPanel panel, ContributionProvider<GripperCloseProgramNodeContribution> provider) {
-		panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
-		panel.add(style.createVerticalSpacing());
-		panel.add(style.createInfo("Closing of the gripper is specified in this subtree."));
-	}
-
-}

+ 0 - 60
src/main/java/at/acdp/urweb/open/GripperOpenProgramNodeContribution.java

@@ -1,60 +0,0 @@
-package at.acdp.urweb.open;
-
-import com.ur.urcap.api.contribution.ProgramNodeContribution;
-import com.ur.urcap.api.contribution.program.ProgramAPIProvider;
-import com.ur.urcap.api.domain.ProgramAPI;
-import com.ur.urcap.api.domain.program.ProgramModel;
-import com.ur.urcap.api.domain.program.nodes.ProgramNodeFactory;
-import com.ur.urcap.api.domain.program.structure.TreeNode;
-import com.ur.urcap.api.domain.program.structure.TreeStructureException;
-import com.ur.urcap.api.domain.script.ScriptWriter;
-
-public class GripperOpenProgramNodeContribution implements ProgramNodeContribution {
-	private final ProgramAPIProvider apiProvider;
-
-	GripperOpenProgramNodeContribution(ProgramAPIProvider apiProvider) {
-		this.apiProvider = apiProvider;
-		createSubtree();
-	}
-
-	@Override
-	public String getTitle() {
-		return "Gripper Open";
-	}
-
-	@Override
-	public void openView() {
-	}
-
-	@Override
-	public void closeView() {
-	}
-
-	@Override
-	public boolean isDefined() {
-		return true;
-	}
-
-	@Override
-	public void generateScript(ScriptWriter writer) {
-		// Place script for opening gripper here
-		writer.writeChildren();
-	}
-
-	private void createSubtree() {
-		ProgramAPI programAPI = apiProvider.getProgramAPI();
-		ProgramModel programModel = programAPI.getProgramModel();
-		ProgramNodeFactory nf = programModel.getProgramNodeFactory();
-		TreeNode root = programModel.getRootTreeNode(this);
-
-		try {
-			root.addChild(nf.createCommentNode().setComment("Add your nodes here"));
-			root.addChild(nf.createSetNode());
-			root.addChild(nf.createWaitNode());
-		} catch (TreeStructureException e) {
-			e.printStackTrace();
-			// See e.getMessage() for explanation
-		}
-	}
-
-}

+ 0 - 49
src/main/java/at/acdp/urweb/open/GripperOpenProgramNodeService.java

@@ -1,49 +0,0 @@
-package at.acdp.urweb.open;
-
-import java.util.Locale;
-
-import at.acdp.urweb.pickorplace.Style;
-import at.acdp.urweb.pickorplace.V3Style;
-import at.acdp.urweb.pickorplace.V5Style;
-import com.ur.urcap.api.contribution.ViewAPIProvider;
-import com.ur.urcap.api.contribution.program.ContributionConfiguration;
-import com.ur.urcap.api.contribution.program.CreationContext;
-import com.ur.urcap.api.contribution.program.ProgramAPIProvider;
-import com.ur.urcap.api.contribution.program.swing.SwingProgramNodeService;
-import com.ur.urcap.api.domain.SystemAPI;
-import com.ur.urcap.api.domain.data.DataModel;
-
-public class GripperOpenProgramNodeService
-		implements SwingProgramNodeService<GripperOpenProgramNodeContribution, GripperOpenProgramNodeView> {
-
-	@Override
-	public String getTitle(Locale locale) {
-		return "Gripper Open";
-	}
-
-	@Override
-	public String getId() {
-		return "GripperOpenProgramNode";
-	}
-
-	@Override
-	public void configureContribution(ContributionConfiguration configuration) {
-		configuration.setDeprecated(false);
-		configuration.setUserInsertable(false);
-		configuration.setChildrenAllowed(true);
-	}
-
-	@Override
-	public GripperOpenProgramNodeView createView(ViewAPIProvider apiProvider) {
-		SystemAPI systemAPI = apiProvider.getSystemAPI();
-		Style style = systemAPI.getSoftwareVersion().getMajorVersion() >= 5 ? new V5Style() : new V3Style();
-		return new GripperOpenProgramNodeView(style);
-	}
-
-	@Override
-	public GripperOpenProgramNodeContribution createNode(ProgramAPIProvider apiProvider,
-			GripperOpenProgramNodeView view, DataModel model, CreationContext context) {
-		return new GripperOpenProgramNodeContribution(apiProvider);
-	}
-
-}

+ 0 - 24
src/main/java/at/acdp/urweb/open/GripperOpenProgramNodeView.java

@@ -1,24 +0,0 @@
-package at.acdp.urweb.open;
-
-import javax.swing.BoxLayout;
-import javax.swing.JPanel;
-
-import at.acdp.urweb.pickorplace.Style;
-import com.ur.urcap.api.contribution.ContributionProvider;
-import com.ur.urcap.api.contribution.program.swing.SwingProgramNodeView;
-
-public class GripperOpenProgramNodeView implements SwingProgramNodeView<GripperOpenProgramNodeContribution> {
-
-	private final Style style;
-
-	GripperOpenProgramNodeView(Style style) {
-		this.style = style;
-	}
-
-	@Override
-	public void buildUI(JPanel panel, ContributionProvider<GripperOpenProgramNodeContribution> provider) {
-		panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
-		panel.add(style.createVerticalSpacing());
-		panel.add(style.createInfo("Opening of the gripper is specified in this subtree."));
-	}
-}

+ 0 - 162
src/main/java/at/acdp/urweb/pickorplace/PickOrPlaceProgramNodeContribution.java

@@ -1,162 +0,0 @@
-package at.acdp.urweb.pickorplace;
-
-import com.ur.urcap.api.contribution.ProgramNodeContribution;
-import com.ur.urcap.api.contribution.program.CreationContext;
-import com.ur.urcap.api.contribution.program.CreationContext.NodeCreationType;
-import com.ur.urcap.api.contribution.program.ProgramAPIProvider;
-import com.ur.urcap.api.domain.ProgramAPI;
-import com.ur.urcap.api.domain.data.DataModel;
-import com.ur.urcap.api.domain.program.ProgramModel;
-import com.ur.urcap.api.domain.program.nodes.ProgramNodeFactory;
-import com.ur.urcap.api.domain.program.structure.TreeNode;
-import com.ur.urcap.api.domain.program.structure.TreeStructureException;
-import com.ur.urcap.api.domain.script.ScriptWriter;
-import com.ur.urcap.api.domain.undoredo.UndoableChanges;
-import at.acdp.urweb.close.GripperCloseProgramNodeService;
-import at.acdp.urweb.open.GripperOpenProgramNodeService;
-
-public class PickOrPlaceProgramNodeContribution implements ProgramNodeContribution {
-
-	private static final String TEMPLATE_KEY = "templateType";
-
-	private final ProgramAPIProvider apiProvider;
-	private final PickOrPlaceProgramNodeView view;
-	private final DataModel model;
-
-	public PickOrPlaceProgramNodeContribution(ProgramAPIProvider apiProvider, PickOrPlaceProgramNodeView view,
-			DataModel model, CreationContext context) {
-		this.apiProvider = apiProvider;
-		this.view = view;
-		this.model = model;
-		lockChildSequence(apiProvider);
-		if (context.getNodeCreationType() == NodeCreationType.NEW) {
-			this.setModel(TemplateType.EMPTY.getName());
-		}
-	}
-
-	@Override
-	public String getTitle() {
-		return getTemplateType().getName();
-	}
-
-	@Override
-	public void openView() {
-		this.view.update(this);
-	}
-
-	@Override
-	public void closeView() {
-	}
-
-	@Override
-	public boolean isDefined() {
-		return true;
-	}
-
-	@Override
-	public void generateScript(ScriptWriter writer) {
-		writer.writeChildren();
-	}
-
-	private void setModel(final String variable) {
-		model.set(TEMPLATE_KEY, variable);
-	}
-
-	public void reset() {
-		apiProvider.getProgramAPI().getUndoRedoManager().recordChanges(new UndoableChanges() {
-			@Override
-			public void executeChanges() {
-				setModel(TemplateType.EMPTY.getName());
-				clearSubtree();
-				view.update(PickOrPlaceProgramNodeContribution.this);
-			}
-		});
-	}
-
-	public void createPick() {
-		apiProvider.getProgramAPI().getUndoRedoManager().recordChanges(new UndoableChanges() {
-			@Override
-			public void executeChanges() {
-				setModel(TemplateType.PICK.getName());
-				createSubtree(TemplateType.PICK);
-				view.update(PickOrPlaceProgramNodeContribution.this);
-			}
-		});
-	}
-
-	public void createPlace() {
-		apiProvider.getProgramAPI().getUndoRedoManager().recordChanges(new UndoableChanges() {
-			@Override
-			public void executeChanges() {
-				setModel(TemplateType.PLACE.getName());
-				createSubtree(TemplateType.PLACE);
-				view.update(PickOrPlaceProgramNodeContribution.this);
-			}
-		});
-	}
-
-	public TemplateType getTemplateType() {
-		String templateTypeName = model.get(TEMPLATE_KEY, TemplateType.EMPTY.getName());
-		return TemplateType.valueOfByName(templateTypeName);
-	}
-
-	private void clearSubtree() {
-		ProgramAPI programAPI = apiProvider.getProgramAPI();
-		ProgramModel programModel = programAPI.getProgramModel();
-
-		TreeNode tree = programModel.getRootTreeNode(this);
-		int size = childrenCount();
-		try {
-			for (int i = 0; i < size; i++) {
-				tree.removeChild(tree.getChildren().get(0));
-			}
-		} catch (TreeStructureException e) {
-			e.printStackTrace();
-			// See e.getMessage() for explanation
-		}
-	}
-
-	private int childrenCount() {
-		ProgramAPI programAPI = apiProvider.getProgramAPI();
-		ProgramModel programModel = programAPI.getProgramModel();
-		return programModel.getRootTreeNode(this).getChildren().size();
-	}
-
-	private void createSubtree(TemplateType template) {
-		ProgramAPI programAPI = apiProvider.getProgramAPI();
-		ProgramModel programModel = programAPI.getProgramModel();
-		ProgramNodeFactory nf = programModel.getProgramNodeFactory();
-		TreeNode root = programModel.getRootTreeNode(this);
-		try {
-			root.addChild(nf.createMoveNode());
-			addGripper(template, root, nf);
-
-			TreeNode folderRetract = root.addChild(nf.createFolderNode());
-			folderRetract.addChild(nf.createCommentNode().setComment("Please customize your functionality here"));
-		} catch (TreeStructureException e) {
-			e.printStackTrace();
-			// See e.getMessage() for explanation
-		}
-	}
-
-	private void addGripper(TemplateType template, TreeNode root, ProgramNodeFactory nf) throws TreeStructureException {
-		switch (template) {
-		case PICK:
-			root.addChild(nf.createURCapProgramNode(GripperCloseProgramNodeService.class));
-			break;
-		case PLACE:
-			root.addChild(nf.createURCapProgramNode(GripperOpenProgramNodeService.class));
-			break;
-		default:
-			break;
-		}
-	}
-
-	private void lockChildSequence(ProgramAPIProvider apiProvider) {
-		ProgramAPI programAPI = apiProvider.getProgramAPI();
-		ProgramModel programModel = programAPI.getProgramModel();
-		TreeNode root = programModel.getRootTreeNode(this);
-		root.setChildSequenceLocked(true);
-	}
-
-}

+ 0 - 46
src/main/java/at/acdp/urweb/pickorplace/PickOrPlaceProgramNodeService.java

@@ -1,46 +0,0 @@
-package at.acdp.urweb.pickorplace;
-
-import java.util.Locale;
-
-import com.ur.urcap.api.contribution.ViewAPIProvider;
-import com.ur.urcap.api.contribution.program.ContributionConfiguration;
-import com.ur.urcap.api.contribution.program.CreationContext;
-import com.ur.urcap.api.contribution.program.ProgramAPIProvider;
-import com.ur.urcap.api.contribution.program.swing.SwingProgramNodeService;
-import com.ur.urcap.api.domain.SystemAPI;
-import com.ur.urcap.api.domain.data.DataModel;
-
-public class PickOrPlaceProgramNodeService
-		implements SwingProgramNodeService<PickOrPlaceProgramNodeContribution, PickOrPlaceProgramNodeView> {
-
-	@Override
-	public String getId() {
-		return "PickOrPlaceProgramNode";
-	}
-
-	@Override
-	public String getTitle(Locale locale) {
-		return "Pick or Place Swing";
-	}
-
-	@Override
-	public void configureContribution(ContributionConfiguration configuration) {
-		configuration.setDeprecated(false);
-		configuration.setChildrenAllowed(true);
-		configuration.setUserInsertable(true);
-	}
-
-	@Override
-	public PickOrPlaceProgramNodeView createView(ViewAPIProvider apiProvider) {
-		SystemAPI systemAPI = apiProvider.getSystemAPI();
-		Style style = systemAPI.getSoftwareVersion().getMajorVersion() >= 5 ? new V5Style() : new V3Style();
-		return new PickOrPlaceProgramNodeView(style);
-	}
-
-	@Override
-	public PickOrPlaceProgramNodeContribution createNode(ProgramAPIProvider apiProvider,
-			PickOrPlaceProgramNodeView view, DataModel model, CreationContext context) {
-		return new PickOrPlaceProgramNodeContribution(apiProvider, view, model, context);
-	}
-
-}

+ 0 - 109
src/main/java/at/acdp/urweb/pickorplace/PickOrPlaceProgramNodeView.java

@@ -1,109 +0,0 @@
-package at.acdp.urweb.pickorplace;
-
-import java.awt.*;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-
-import javax.swing.Box;
-import javax.swing.BoxLayout;
-import javax.swing.JButton;
-import javax.swing.JPanel;
-
-import com.ur.urcap.api.contribution.ContributionProvider;
-import com.ur.urcap.api.contribution.program.swing.SwingProgramNodeView;
-
-public class PickOrPlaceProgramNodeView implements SwingProgramNodeView<PickOrPlaceProgramNodeContribution> {
-
-	private final Style style;
-
-	private JButton placeButton;
-	private JButton pickButton;
-	private JButton resetButton;
-
-	public PickOrPlaceProgramNodeView(Style style) {
-		this.style = style;
-	}
-
-	@Override
-	public void buildUI(final JPanel panel, final ContributionProvider<PickOrPlaceProgramNodeContribution> provider) {
-		panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
-		panel.add(createMakeSection(provider));
-		panel.add(createResetSection(provider));
-	}
-
-	private Component createMakeSection(final ContributionProvider<PickOrPlaceProgramNodeContribution> provider) {
-		Box section = style.createSection(BoxLayout.PAGE_AXIS);
-
-		Box infoSection = style.createSection(BoxLayout.PAGE_AXIS);
-		infoSection.add(style.createInfo("Choose Pick or Place:"));
-		infoSection.add(style.createVerticalSpacing());
-		section.add(infoSection);
-
-		Box buttonSection = style.createSection(BoxLayout.LINE_AXIS);
-		buttonSection.add(style.createHorizontalIndent());
-		this.pickButton = style.createButton("Pick");
-		this.pickButton.addActionListener(new ActionListener() {
-			@Override
-			public void actionPerformed(ActionEvent e) {
-				provider.get().createPick();
-			}
-		});
-		buttonSection.add(pickButton, FlowLayout.LEFT);
-
-		buttonSection.add(style.createHorizontalSpacing());
-		this.placeButton = style.createButton("Place");
-		this.placeButton.addActionListener(new ActionListener() {
-			@Override
-			public void actionPerformed(ActionEvent e) {
-				provider.get().createPlace();
-			}
-		});
-		buttonSection.add(placeButton);
-
-		section.add(buttonSection);
-		return section;
-	}
-
-	private Component createResetSection(final ContributionProvider<PickOrPlaceProgramNodeContribution> provider) {
-		Box section = style.createSection(BoxLayout.PAGE_AXIS);
-
-		section.add(style.createVerticalSpacing());
-
-		Box infoSection = style.createSection(BoxLayout.PAGE_AXIS);
-		infoSection.add(style.createVerticalSpacing());
-		infoSection.add(style.createInfo("Tap the button to reset your selection."));
-		infoSection.add(style.createVerticalSpacing());
-		infoSection.add(style.createInfo("This removes the program tree and clears all configuration data."));
-		infoSection.add(style.createVerticalSpacing());
-		section.add(infoSection);
-
-		Box buttonSection = style.createSection(BoxLayout.LINE_AXIS);
-		buttonSection.add(style.createHorizontalIndent());
-		this.resetButton = style.createButton("Reset");
-		this.resetButton.addActionListener(new ActionListener() {
-			@Override
-			public void actionPerformed(ActionEvent e) {
-				provider.get().reset();
-			}
-		});
-		buttonSection.add(this.resetButton, FlowLayout.LEFT);
-		section.add(buttonSection);
-
-		return section;
-	}
-
-	void update(PickOrPlaceProgramNodeContribution contribution) {
-		TemplateType templateType = contribution.getTemplateType();
-
-		if (templateType == TemplateType.EMPTY) {
-			pickButton.setEnabled(true);
-			placeButton.setEnabled(true);
-			resetButton.setEnabled(false);
-		} else {
-			pickButton.setEnabled(false);
-			placeButton.setEnabled(false);
-			resetButton.setEnabled(true);
-		}
-	}
-
-}

+ 0 - 44
src/main/java/at/acdp/urweb/pickorplace/Style.java

@@ -1,44 +0,0 @@
-package at.acdp.urweb.pickorplace;
-
-import javax.swing.*;
-import java.awt.*;
-
-public abstract class Style {
-
-	protected abstract int getHorizontalSpacing();
-
-	protected abstract int getVerticalSpacing();
-
-	protected abstract int getHorizontalIndent();
-
-	public Box createInfo(String text) {
-		Box infoBox = Box.createHorizontalBox();
-		infoBox.setAlignmentX(Component.LEFT_ALIGNMENT);
-		infoBox.add(new JLabel(text));
-		return infoBox;
-	}
-
-	public Component createHorizontalSpacing() {
-		return Box.createRigidArea(new Dimension(getHorizontalSpacing(), 0));
-	}
-
-	public Component createHorizontalIndent() {
-		return Box.createRigidArea(new Dimension(getHorizontalIndent(), 0));
-	}
-
-	public Component createVerticalSpacing() {
-		return Box.createRigidArea(new Dimension(0, getVerticalSpacing()));
-	}
-
-	public JButton createButton(String text) {
-		return new JButton(text);
-	}
-
-	public Box createSection(int axis) {
-		Box panel = new Box(axis);
-		panel.setAlignmentX(Component.LEFT_ALIGNMENT);
-		panel.setAlignmentY(Component.TOP_ALIGNMENT);
-		return panel;
-	}
-
-}

+ 0 - 25
src/main/java/at/acdp/urweb/pickorplace/TemplateType.java

@@ -1,25 +0,0 @@
-package at.acdp.urweb.pickorplace;
-
-public enum TemplateType {
-
-	EMPTY("Pick or Place Swing"), PICK("Pick"), PLACE("Place");
-
-	private final String name;
-
-	TemplateType(final String name) {
-		this.name = name;
-	}
-
-	public final String getName() {
-		return name;
-	}
-
-	public static TemplateType valueOfByName(String name) {
-		if (PICK.name.equals(name)) {
-			return PICK;
-		} else if (PLACE.name.equals(name)) {
-			return PLACE;
-		}
-		return EMPTY;
-	}
-}

+ 0 - 24
src/main/java/at/acdp/urweb/pickorplace/V3Style.java

@@ -1,24 +0,0 @@
-package at.acdp.urweb.pickorplace;
-
-public class V3Style extends Style {
-
-	private static final int HORIZONTAL_SPACING = 5;
-	private static final int VERTICAL_SPACING = 15;
-	private static final int HORIZONTAL_INDENT = 20;
-
-	@Override
-	protected int getHorizontalSpacing() {
-		return HORIZONTAL_SPACING;
-	}
-
-	@Override
-	protected int getVerticalSpacing() {
-		return VERTICAL_SPACING;
-	}
-
-	@Override
-	protected int getHorizontalIndent() {
-		return HORIZONTAL_INDENT;
-	}
-
-}

+ 0 - 24
src/main/java/at/acdp/urweb/pickorplace/V5Style.java

@@ -1,24 +0,0 @@
-package at.acdp.urweb.pickorplace;
-
-public class V5Style extends Style {
-
-	private static final int HORIZONTAL_SPACING = 10;
-	private static final int VERTICAL_SPACING = 15;
-	private static final int HORIZONTAL_INDENT = 20;
-
-	@Override
-	protected int getHorizontalSpacing() {
-		return HORIZONTAL_SPACING;
-	}
-
-	@Override
-	protected int getVerticalSpacing() {
-		return VERTICAL_SPACING;
-	}
-
-	@Override
-	protected int getHorizontalIndent() {
-		return HORIZONTAL_INDENT;
-	}
-
-}

+ 12 - 0
src/main/java/at/acdp/urweb/rtdeclient/RTDEClient.java

@@ -0,0 +1,12 @@
+package at.acdp.urweb.rtdeclient;
+
+public class RTDEClient {
+    private final String ip;
+    private final int port;
+
+    public RTDEClient(String ip, int port) {
+        this.ip = ip;
+        this.port = port;
+    }
+
+}

+ 81 - 0
src/main/java/at/acdp/urweb/sclient/SecondaryClient.java

@@ -0,0 +1,81 @@
+package at.acdp.urweb.sclient;
+
+import at.acdp.urweb.sclient.data.VersionMessage;
+
+import java.io.*;
+import java.net.Socket;
+import java.nio.charset.StandardCharsets;
+
+public class SecondaryClient {
+
+    private final String ip;
+    private final int port;
+    private volatile boolean _running = true;
+    private Socket rt;
+    private OutputStream os;
+    private DataInputStream in;
+
+    public SecondaryClient(String ip, int port) {
+        this.ip = ip;
+        this.port = port;
+    }
+
+    public void connect() throws IOException {
+        this.rt = new Socket(ip, port);
+        this.os = rt.getOutputStream();
+        this.in = new DataInputStream(rt.getInputStream());
+        VersionMessage vm = new VersionMessage();
+        vm.readVersionMessage(in);
+        System.out.println(vm);
+        readReply(in);
+    }
+
+    private void readReply(DataInputStream di) throws IOException {
+        int size=di.readInt();
+        int mType= di.readByte() &0xff;
+        switch (mType) {
+            case 20:
+                long ts=di.readLong();
+                byte source=di.readByte();
+                int robotMessageType=di.readByte() & 0xff;
+                switch(robotMessageType) {
+                    default:
+                        System.out.println("rtype: " +robotMessageType);
+                        int x=di.available();
+                        byte[] buf=new byte[size-15];
+                        di.read(buf);
+                        System.out.println(buf);
+                }
+                break;
+            case 16:
+                System.out.println("16 msg" + mType);
+
+                int remaining=size-5;
+                while (remaining >0) {
+                    int sublength = in.readInt();
+                    remaining-=sublength;
+                    System.out.println("sublength: " + sublength);
+                    int subType = in.readByte();
+                    System.out.println("subtype: " + subType);
+                    byte[] res = new byte[sublength - 5];
+                    in.read(res);
+                }
+                break;
+            default:
+                System.out.println("unknown msg" + mType);
+                byte[] buf=new byte[size];
+                di.read(buf);
+        }
+    }
+
+    public void writeCmd(String cmd) {
+        try {
+            System.out.println("send cmd:" + cmd);
+            os.write(cmd.getBytes(StandardCharsets.UTF_8));
+            readReply(in);
+
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+}

+ 54 - 0
src/main/java/at/acdp/urweb/sclient/data/VersionMessage.java

@@ -0,0 +1,54 @@
+package at.acdp.urweb.sclient.data;
+
+import java.io.DataInputStream;
+import java.io.IOException;
+
+public class VersionMessage {
+
+
+    public int msgType;
+    public long tstamp;
+    public int source;
+    public int robotMsgType;
+    public String name;
+    public int majorVersion;
+    public int minorVersion;
+    public int bugFixVersion;
+    public int buildNumber;
+    public String buildDate;
+
+    public void readVersionMessage(DataInputStream in) throws IOException {
+        int msgSize = in.readInt();
+        msgType = in.readByte() & 0xff;
+        tstamp = in.readLong();
+        source = in.readByte();
+        robotMsgType = in.readByte();
+        int projectNameSize = in.readByte() & 0xff;
+        byte[] nameBytes = new byte[projectNameSize];
+        in.read(nameBytes);
+        name = new String(nameBytes);
+        majorVersion = in.readByte() & 0xff;
+        minorVersion = in.readByte() & 0xff;
+        bugFixVersion = in.readInt();
+        buildNumber = in.readInt();
+        byte[] buildDateBytes = new byte[msgSize - (16 + projectNameSize + 10)];
+        in.read(buildDateBytes);
+        buildDate = new String(buildDateBytes);
+    }
+
+    @Override
+    public String toString() {
+        return "VersionMessage{" +
+                "msgType=" + msgType +
+                ", tstamp=" + tstamp +
+                ", source=" + source +
+                ", robotMsgType=" + robotMsgType +
+                ", name='" + name + '\'' +
+                ", majorVersion=" + majorVersion +
+                ", minorVersion=" + minorVersion +
+                ", bugFixVersion=" + bugFixVersion +
+                ", buildNumber=" + buildNumber +
+                ", buildDate='" + buildDate + '\'' +
+                '}';
+    }
+}

+ 1 - 6
src/main/java/at/acdp/urweb/web/GetRobotRealtimeData.java

@@ -29,11 +29,9 @@ public class GetRobotRealtimeData implements Runnable {
     private void readSocket() throws IOException {
         try(Socket rt = new Socket(ip, port);){
             rt.setSoTimeout(1000);
-
             if (rt.isConnected()){
                 System.out.println("Connected to UR Realtime Client");
             }
-
             DataInputStream in = new DataInputStream(rt.getInputStream());
             while(true) {
                 int length = in.readInt();
@@ -46,7 +44,6 @@ public class GetRobotRealtimeData implements Runnable {
                 }
             }
         }
-
     }
 
     @Override
@@ -58,8 +55,6 @@ public class GetRobotRealtimeData implements Runnable {
                 e.printStackTrace();
             }
         }
-
-
     }
 
     /*
@@ -145,7 +140,7 @@ public class GetRobotRealtimeData implements Runnable {
      */
     public String[] getJointStatus(double[] rtm){
         // Create a map binding message code to state message
-        // According to Excel sheet client interface specification
+        // According to Excel sheet sclient interface specification
         Map<Double, String> jointStates = new HashMap<Double, String>();
         jointStates.put((double) 236, "SHUTTING_DOWN");
         jointStates.put((double) 237, "DUAL_CALIB_MODE");

+ 0 - 88
src/main/java/at/acdp/urweb/web/RTDE.java

@@ -1,88 +0,0 @@
-package at.acdp.urweb.web;
-import java.io.*;
-import java.net.Socket;
-import java.nio.charset.StandardCharsets;
-import java.util.HashMap;
-import java.util.Map;
-
-public class RTDE implements Runnable {
-
-    private final String ip;
-    private final int port;
-    private volatile boolean _running=true;
-    private Socket rt;
-    private OutputStream os;
-    private DataInputStream in;
-
-    public RTDE(String ip, int port) {
-        this.ip=ip;
-        this.port=port;
-    }
-    private void connect() throws IOException {
-        this.rt = new Socket(ip, port);
-        this.os=rt.getOutputStream();
-        this.in=new DataInputStream(rt.getInputStream());
-        readVersionMessage();
-    }
-
-    private void readVersionMessage() throws IOException {
-        int msgSize=in.readInt();
-        int msgType=in.readByte()&0xff;
-        long tstamp=in.readLong();
-        byte source=in.readByte();
-        byte robotMsgType=in.readByte();
-        byte projectNameSize=in.readByte();
-        byte[] name=new byte[projectNameSize];
-        in.read(name);
-        String nameS=new String(name);
-        int  majorVersion=in.readByte() & 0xff;
-        int  minorVersion=in.readByte() & 0xff;
-        int bugFixVersion=in.readInt();
-        int buildNumber=in.readInt();
-        byte[] buildDateB=new byte[msgSize-(16+projectNameSize+10)];
-        in.read(buildDateB);
-        String buildDate=new String(buildDateB);
-
-
-
-    }
-
-    private void writeCmd(String cmd) {
-        try {
-            System.out.println("send cmd:"+cmd);
-            os.write(cmd.getBytes(StandardCharsets.UTF_8));
-            int length=in.readInt();
-            System.out.println("len: "+length);
-            byte[] buf=new byte[length];
-            //in.read(buf);
-            int mType = in.readByte() & 0xff;
-            System.out.println("mtype: "+mType);
-            while(true) {
-                int sublength=in.readInt();
-                System.out.println("sublength: " + sublength);
-
-                int subType = in.readByte();
-                System.out.println("subtype: "+subType);
-                byte[] res=new byte[sublength-5];
-                in.read(res);
-
-
-            }
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-    }
-
-    @Override
-    public void run() {
-            try {
-                connect();
-                writeCmd("set_digital_out(1,True)\n");
-                writeCmd("set_digital_out(2,True)\n");
-                writeCmd("movej([-1.95,-1.58,-1.16,-1.15,-1.55,1.18], a=1.0, v=0.1)\n");
-
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
-    }
-}

+ 21 - 199
src/main/java/at/acdp/urweb/web/WebServer.java

@@ -1,208 +1,30 @@
 package at.acdp.urweb.web;
 
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.IOException;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.util.Base64;
-import java.util.Map;
-import java.util.Timer;
-import java.util.concurrent.atomic.AtomicLong;
-import java.util.logging.Logger;
-
-import com.eclipsesource.json.Json;
-import com.eclipsesource.json.JsonArray;
-import org.nanohttpd.protocols.http.IHTTPSession;
-import org.nanohttpd.protocols.http.response.IStatus;
-import org.nanohttpd.protocols.http.response.Response;
-import org.nanohttpd.protocols.http.response.Status;
-import org.nanohttpd.protocols.websockets.CloseCode;
-import org.nanohttpd.protocols.websockets.WebSocket;
-import org.nanohttpd.protocols.websockets.WebSocketFrame;
-import org.nanohttpd.router.RouterNanoHTTPD;
-import org.nanohttpd.util.IHandler;
+import java.nio.file.Paths;
+import io.undertow.Handlers;
+import io.undertow.Undertow;
+import io.undertow.server.handlers.resource.PathResourceManager;
 import org.slf4j.LoggerFactory;
 
-/**
- * @author Paul S. Hawke (paul.hawke@gmail.com) On: 4/23/14 at 10:31 PM
- */
-public class WebServer extends RouterNanoHTTPD{
-    private final static org.slf4j.Logger logger = LoggerFactory.getLogger(WebServer.class);
+import static io.undertow.Handlers.resource;
 
-    /**
-     * logger to log to.
-     */
-    private static final Logger LOG = Logger.getLogger(WebServer.class.getName());
-    private java.util.Timer t=new Timer();
-    private final boolean debug;
+public class WebServer {
+    private final static org.slf4j.Logger logger = LoggerFactory.getLogger(WebServer.class);
+    private final int port;
+    private Undertow server;
 
     public WebServer(int port, boolean debug) {
-        super(port);
-        this.debug = debug;
-        this.addHTTPInterceptor(new WebServer.Interceptor());
-        addMappings();
-    }
-
-    @Override
-    public void addMappings() {
-        super.addMappings();
-        addRoute("/user/:id", BlockHandler.class);
-        addRoute("/interface", UriResponder.class); // this will cause an error
-        addRoute("/toBeDeleted", String.class);
-        removeRoute("/toBeDeleted");
-
-        addRoute("/static(.)+", MyHandler.class, new File("webroot/").getAbsoluteFile());
-        //addRoute("/", StaticPageTestHandler.class, new File("webroot/index.html").getAbsoluteFile());
-    }
-    protected WebSocket openWebSocket(IHTTPSession handshake) {
-        return new MyWebSocket(this, handshake);
-    }
-
-    private static class MyWebSocket extends WebSocket {
-        private final WebServer server;
-
-        public MyWebSocket(WebServer server, IHTTPSession handshakeRequest) {
-            super(handshakeRequest);
-            this.server = server;
-        }
-
-        @Override
-        protected void onOpen() {
-            logger.info(String.format("client connected: %s",getHandshakeRequest().getRemoteIpAddress().toString()));
-        }
-
-        @Override
-        protected void onClose(CloseCode code, String reason, boolean initiatedByRemote) {
-            if (server.debug) {
-                System.out.println("C [" + (initiatedByRemote ? "Remote" : "Self") + "] " + (code != null ? code : "UnknownCloseCode[" + code + "]")
-                        + (reason != null && !reason.isEmpty() ? ": " + reason : ""));
-            }
-        }
-
-        @Override
-        protected void onMessage(WebSocketFrame message) {
-            try {
-                message.setUnmasked();
-                sendFrame(message);
-            } catch (IOException e) {
-                throw new RuntimeException(e);
-            }
-        }
-
-        @Override
-        protected void onPong(WebSocketFrame pong) {
-            if (server.debug) {
-                System.out.println("P " + pong);
-            }
-        }
-
-        @Override
-        protected void onException(IOException exception) {
-            logger.warn("exception occured", exception);
-        }
-
-        @Override
-        protected void debugFrameReceived(WebSocketFrame frame) {
-            if (server.debug) {
-                System.out.println("R " + frame);
-            }
-        }
-
-        @Override
-        protected void debugFrameSent(WebSocketFrame frame) {
-            if (server.debug) {
-                System.out.println("S " + frame);
-            }
-        }
-    }
-
-    public static String makeAcceptKey(String key) throws NoSuchAlgorithmException {
-        MessageDigest md = MessageDigest.getInstance("SHA-1");
-        String text = key + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
-        md.update(text.getBytes(), 0, text.length());
-        byte[] sha1hash = md.digest();
-        Base64.Encoder b64encoder = Base64.getEncoder();
-        return b64encoder.encodeToString(sha1hash);
-    }
-
-    private boolean isWebSocketConnectionHeader(Map<String, String> headers) {
-        String connection = (String)headers.get("connection");
-        return connection != null && connection.toLowerCase().contains("Upgrade".toLowerCase());
-    }
-
-    protected boolean isWebsocketRequested(IHTTPSession session) {
-        Map<String, String> headers = session.getHeaders();
-        String upgrade = (String)headers.get("upgrade");
-        boolean isCorrectConnection = this.isWebSocketConnectionHeader(headers);
-        boolean isUpgrade = "websocket".equalsIgnoreCase(upgrade);
-        return isUpgrade && isCorrectConnection;
-    }
-
-    public Response handleWebSocket(IHTTPSession session) {
-        Map<String, String> headers = session.getHeaders();
-        if (this.isWebsocketRequested(session)) {
-            if (!"13".equalsIgnoreCase((String)headers.get("sec-websocket-version"))) {
-                return Response.newFixedLengthResponse(Status.BAD_REQUEST, "text/plain", "Invalid Websocket-Version " + (String)headers.get("sec-websocket-version"));
-            } else if (!headers.containsKey("sec-websocket-key")) {
-                return Response.newFixedLengthResponse(Status.BAD_REQUEST, "text/plain", "Missing Websocket-Key");
-            } else {
-                WebSocket webSocket = this.openWebSocket(session);
-                Response handshakeResponse = webSocket.getHandshakeResponse();
-
-                try {
-                    handshakeResponse.addHeader("sec-websocket-accept", makeAcceptKey((String)headers.get("sec-websocket-key")));
-                } catch (NoSuchAlgorithmException var6) {
-                    return Response.newFixedLengthResponse(Status.INTERNAL_ERROR, "text/plain", "The SHA-1 Algorithm required for websockets is not available on the server.");
-                }
-
-                if (headers.containsKey("sec-websocket-protocol")) {
-                    handshakeResponse.addHeader("sec-websocket-protocol", ((String)headers.get("sec-websocket-protocol")).split(",")[0]);
-                }
-
-                return handshakeResponse;
-            }
-        } else {
-            return null;
-        }
-    }
-
-    protected final class Interceptor implements IHandler<IHTTPSession, Response> {
-        public Interceptor() {
-        }
-        public Response handle(IHTTPSession input) {
-            return WebServer.this.handleWebSocket(input);
-        }
-    }
-
-    public static class BlockHandler extends DefaultHandler {
-        @Override
-        public String getMimeType() {
-            return MIME_PLAINTEXT;
-        }
-
-        @Override
-        public String getText() {
-            return "not implemented";
-        }
-
-        @Override
-        public IStatus getStatus() {
-            return Status.OK;
-        }
-
-        @Override
-        public Response get(UriResource uriResource, Map<String, String> urlParams, IHTTPSession session) {
-            JsonArray blocks = Json.array();
-            return Response.newFixedLengthResponse(blocks.toString());
-        }
-    }
-
-    public static class MyHandler extends StaticPageHandler{
-        @Override
-        protected BufferedInputStream fileToInputStream(File fileOrdirectory) throws IOException {
-
-            return new BufferedInputStream(this.getClass().getResourceAsStream(fileOrdirectory.toString()));
-        }
+        this.port = port;
+    }
+
+    public void start() {
+        Undertow.Builder builder = Undertow.builder();
+        builder.addHttpListener(port, "0.0.0.0");
+        builder.setHandler(Handlers.routing()
+                .get("/*", resource(new PathResourceManager(Paths.get("webroot"), 100))
+                        .setDirectoryListingEnabled(true))
+        );
+        server=builder.build();
+        server.start();
     }
 }

+ 3 - 0
webroot/index.html

@@ -0,0 +1,3 @@
+<html>
+huhu
+</html>