Martin Kunz 4 years ago
parent
commit
cff911bde5

BIN
docs/fhpp/CMMP-AS-M3-C-HP_2012-05_760337d1.pdf


BIN
docs/fhpp/CMM_-FHPP_2010-11b_555695d1.pdf


BIN
docs/fhpp/Modbus on CMMP_AS_M3_M0.pdf


BIN
docs/fhpp/Modbus_Register.pdf


BIN
docs/mechanical/CMMO-ST_DE.PDF


BIN
docs/mechanical/EGC-HD-TB_DE.PDF


BIN
docs/mechanical/NEBU_DE.PDF


BIN
docs/mechanical/SIES-8M_DE.PDF


+ 15 - 18
pom.xml

@@ -14,19 +14,6 @@
 	</properties>
 	<build>
 		<plugins>
-			<plugin>
-				<groupId>com.github.spotbugs</groupId>
-				<artifactId>spotbugs-maven-plugin</artifactId>
-				<version>3.1.12</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.12</version>
-					</dependency>
-				</dependencies>
-			</plugin>
 			<plugin>
 				<groupId>org.apache.maven.plugins</groupId>
 				<artifactId>maven-compiler-plugin</artifactId>
@@ -82,15 +69,25 @@
 	</build>
 
 	<dependencies>
-        <dependency>
-            <groupId>com.sparkjava</groupId>
-            <artifactId>spark-core</artifactId>
-            <version>2.9.0</version>
-        </dependency>
+		<dependency>
+			<groupId>com.nmote.xr</groupId>
+			<artifactId>nmote-xr</artifactId>
+			<version>2.2.0</version>
+		</dependency>
         <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-api</artifactId>
             <version>1.7.26</version>
+        </dependency>
+		<dependency>
+			<groupId>com.digitalpetri.modbus</groupId>
+			<artifactId>modbus-master-tcp</artifactId>
+			<version>1.1.0</version>
+		</dependency>
+        <dependency>
+            <groupId>com.digitalpetri.modbus</groupId>
+            <artifactId>modbus-slave-tcp</artifactId>
+            <version>1.1.0</version>
         </dependency>
 		<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->
 		<dependency>

+ 11 - 3
src/main/java/at/acdp/urweb/Main.java

@@ -1,22 +1,30 @@
 package at.acdp.urweb;
 
-import at.acdp.urweb.web.WebServer;
+import at.acdp.urweb.fhpp.FHPP;
+import at.acdp.urweb.web.XRServer;
+import com.nmote.nanohttp.NanoServer;
+import com.nmote.xr.XR;
 import org.slf4j.LoggerFactory;
 
 public class Main {
     private final static org.slf4j.Logger logger = LoggerFactory.getLogger(Main.class);
-
     public static void main(String[] args) {
         Params app = null;
         try {
             app = picocli.CommandLine.populateCommand(new Params(), args);
+
+            var a=new FHPP();
+            a.connect();
         } catch (Exception e) {
             logger.error("failed.", e);
             picocli.CommandLine.usage(new Params(), System.out);
             System.exit(1);
         }
         try {
-            new WebServer(app).start();
+            //new WebServer(app).start();
+            NanoServer server = new NanoServer(app.port);
+            server.add(XR.server(XRServer.class));
+            server.start();
         } catch (Exception e) {
             logger.error("Server exited", e);
         }

+ 33 - 0
src/main/java/at/acdp/urweb/fhpp/FHPP.java

@@ -0,0 +1,33 @@
+package at.acdp.urweb.fhpp;
+
+import com.digitalpetri.modbus.master.ModbusTcpMaster;
+import com.digitalpetri.modbus.master.ModbusTcpMasterConfig;
+import com.digitalpetri.modbus.requests.ReadHoldingRegistersRequest;
+import com.digitalpetri.modbus.responses.ReadHoldingRegistersResponse;
+import io.netty.buffer.ByteBufUtil;
+import io.netty.util.ReferenceCountUtil;
+
+import java.util.concurrent.CompletableFuture;
+
+public class FHPP {
+
+    public FHPP() {
+
+    }
+
+    public void connect() {
+        ModbusTcpMasterConfig config = new ModbusTcpMasterConfig.Builder("localhost").build();
+        ModbusTcpMaster master = new ModbusTcpMaster(config);
+
+        master.connect();
+
+        CompletableFuture<ReadHoldingRegistersResponse> future =
+                master.sendRequest(new ReadHoldingRegistersRequest(0, 10), 0);
+
+        future.thenAccept(response -> {
+            System.out.println("Response: " + ByteBufUtil.hexDump(response.getRegisters()));
+
+            ReferenceCountUtil.release(response);
+        });
+    }
+}

+ 0 - 107
src/main/java/at/acdp/urweb/web/WebServer.java

@@ -1,107 +0,0 @@
-package at.acdp.urweb.web;
-
-import at.acdp.urweb.Params;
-import at.acdp.urweb.RobotCommand;
-import at.acdp.urweb.URBot;
-import at.acdp.urweb.rt.GetRobotRealtimeData;
-import at.acdp.urweb.sclient.URLog;
-import com.eclipsesource.json.JsonArray;
-import net.schmizz.sshj.SSHClient;
-import net.schmizz.sshj.xfer.FileSystemFile;
-import org.slf4j.LoggerFactory;
-
-import static spark.Spark.*;
-
-public class WebServer {
-    private final static org.slf4j.Logger logger = LoggerFactory.getLogger(WebServer.class);
-    private URBot urbot;
-    private final Params params;
-    private GetRobotRealtimeData rtbot;
-
-    public WebServer(Params params) {
-        this.params = params;
-    }
-
-    public void start() {
-        this.urbot=new URBot(params.robotIP, params.robotPort);
-        this.urbot.start();
-        // this.rtbot=new GetRobotRealtimeData(params.robotIP, params.rtPort);
-        // this.rtbot.start();
-        port(params.port);
-        if (!params.webroot.isEmpty())
-            staticFileLocation(params.webroot);
-        else
-            staticFiles.location("/webroot");
-
-        post("/cmd", (req, res) -> {
-            var cmd=req.queryParams("script");
-            if(cmd==null)
-                cmd=req.body();
-            RobotCommand rc=new RobotCommand(cmd);
-            rc.cpeeCallback = req.headers("CPEE-CALLBACK");
-            rc.cpeeCallbackId = req.headers("CPEE-CALLBACK-ID");
-            rc.cpeeInstanceURL = req.headers("CPEE-INSTANCE-URL");
-            if (Boolean.valueOf(req.queryParams("callback"))) {
-                res.header("CPEE-CALLBACK", "true");
-                rc.doCpeeCallback = true;
-            }
-            urbot.sendCmd(rc);
-            return "";
-        });
-
-        post("/freedrive",  (req, res) -> {
-                urbot.sendFreedrive(1);
-                return "";
-        });
-        post("/digital/:which", (req, res) -> {
-            int which=Integer.parseInt(req.params("which"));
-            boolean val = Boolean.valueOf(new String(req.raw().getInputStream().readAllBytes()));
-            urbot.setDigital(which, val);
-            return "";
-        });
-        get("/digital/:which", (req, res) -> {
-            int which=Integer.parseInt(req.params("which"));
-            boolean d=urbot.getDigital(which);
-            res.body(String.valueOf(d));
-            return "";
-        });
-        get("/log/:from",  (req, res) -> {
-            int from=Integer.parseInt(req.params("from"));
-            from=Integer.max(0,from);
-            var r = URLog.get(from);
-            return r.toJSON();
-        });
-        get("/cmdq",  (req, res) -> {
-            JsonArray jsa=new JsonArray();
-            for(var c:urbot.getCmdq()) {
-                jsa.add(c.toJSON());
-            }
-            return jsa.toString();
-        });
-        get("/running",  (req, res) -> {
-            var rc=urbot.getRunningScript();
-            if(rc.isPresent()) {
-                return rc.get().toJSON();
-            }
-            return "[{}]";
-        });
-        get("/files/:path",  (req, res) -> {
-            String path=req.params("from");
-            SSHClient ssh = new SSHClient();
-            // ssh.useCompression(); // Can lead to significant speedup (needs JZlib in classpath)
-            ssh.loadKnownHosts();
-            ssh.connect(params.robotIP, params.robotPort);
-            try {
-                ssh.authPublickey(System.getProperty(params.sshUsername));
-                ssh.newSCPFileTransfer().download(path, new FileSystemFile("C:\\tmp\\"));
-
-            }catch (Exception e) {
-                logger.warn("",e);
-
-            } finally{
-                ssh.disconnect();
-            }
-            return "[{}]";
-        });
-    }
-}

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

@@ -0,0 +1,27 @@
+package at.acdp.urweb.web;
+
+import com.nmote.xr.XRMethod;
+
+public class XRServer {
+
+    @XRMethod(value = "example.helloWorld", help = "Returns 'Helo ' + argument")
+    public static String hello(Object s) {
+        return "Hello '" + s + "'";
+    }
+
+
+    @XRMethod(value = "set_title", help = "Returns 'Helo ' + argument")
+    public static String set_title(Object s) {
+        return "Hello '" + s + "'";
+    }
+
+    @XRMethod(value = "get_title", help = "Returns 'Helo ' + argument")
+    public static String get_title() {
+        return "Hello";
+    }
+
+    @XRMethod(value = "get_message")
+    public static String get_message(Object s) {
+        return "asdfasdfas";
+    }
+}