Browse Source

subpackage parsing wip

Martin Kunz 5 years ago
parent
commit
6df480b21e

+ 6 - 13
src/main/java/at/acdp/urweb/sclient/SecondaryClient.java

@@ -34,7 +34,7 @@ public class SecondaryClient {
         return vm;
     }
 
-    public void readReply(CountDataInputStream di) throws IOException {
+    public int readReply(CountDataInputStream di, boolean isSub) throws IOException {
         int beforeCount=di.getCount();
         int size = di.readInt(); //4
         int pType = di.readByte() & 0xff; //+1=5
@@ -91,8 +91,6 @@ public class SecondaryClient {
                 var tci=readToolCommInfo(di, size);
                 log.info(tci.toString());
                 break;
-
-
             default:
                 log.warn("unknown ptype: "+pType+", size: "+size);
                 byte[] pack=new byte[size-5];
@@ -103,6 +101,7 @@ public class SecondaryClient {
         if(diff!=0) {
             log.warn("size mismatch: " +diff + "package type: "+pType);
         }
+        return size;
     }
 
     private MasterBoardData readMasterBoardData(CountDataInputStream di, int size) throws IOException {
@@ -164,15 +163,9 @@ public class SecondaryClient {
     }
 
     void readRobotState(CountDataInputStream di, int size) throws IOException {
-        long ts = di.readLong();
-        char source = (char) (di.readByte() & 0xFF);
-        char robotMessageType = (char) (di.readByte() & 0xFF);
-        switch (robotMessageType) {
-            default:
-                log.info("unknown msg: " + (int)robotMessageType);
-                byte[] buf = new byte[size - 10];
-                di.readFully(buf);
-        }
+        int remaining=size-5;
+        while(remaining>0)
+            remaining-=readReply(di, true);
     }
 
     CartesianInfo readCartesianInfo(CountDataInputStream di, int size) throws IOException {
@@ -229,6 +222,6 @@ public class SecondaryClient {
     }
 
     public void readPackage() throws IOException {
-        readReply(in);
+        readReply(in, false);
     }
 }

+ 0 - 1
src/main/resources/webroot/index.html

@@ -4,7 +4,6 @@ jo!
 <form action="/cmd">
     cmd:<br>
     <input type="text" name="cmd" value=""><br>
-
     <input type="submit" value="Submit">
 </form>
 </html>

+ 33 - 0
webroot/css/style.css

@@ -0,0 +1,33 @@
+Edit in JSFiddle
+Result
+HTML
+JavaScript
+CSS
+html, body, #editor {
+    margin: 0;
+    height: 100%;
+    font-family: 'Helvetica Neue', Arial, sans-serif;
+    color: #333;
+}
+
+textarea, #editor div {
+    display: inline-block;
+    vertical-align: top;
+    box-sizing: border-box;
+    padding: 0 20px;
+}
+
+textarea {
+    border: none;
+    border-right: 1px solid #ccc;
+    resize: none;
+    outline: none;
+    background-color: #f6f6f6;
+    font-size: 14px;
+    font-family: 'Monaco', courier, monospace;
+    padding: 20px;
+}
+
+code {
+    color: #f66;
+}

+ 41 - 6
webroot/index.html

@@ -1,7 +1,42 @@
-<html>
-<form action="/cmd" method="post">
-    cmd:<br>
-    <input type="text" name="cmd" value=""><br>
-    <input type="submit" value="Submit">
-</form>
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="utf-8">
+    <title>Vue.js markdown editor example</title>
+    <link rel="stylesheet" href="css/style.css">
+    <script src="https://unpkg.com/lodash@4.16.0"></script>
+    <!-- Delete ".min" for console warnings in development -->
+    <script src="js/vue.js"></script>
+</head>
+<body>
+
+<div id="app">
+    <textarea v-model="input" cols="80" rows="20"></textarea>
+    <button v-on:click="send">send</button>
+    <div v-html="compiledMarkdown"></div>
+</div>
+
+<script>
+    new Vue({
+        el: '#app',
+        data: {
+            input: '// 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'
+        },
+        methods: {
+            send: function (event) {
+                fetch('/cmd', {method: "POST", body: this.input})
+                    .then(function(response) {
+                        return response;
+                    });
+            },
+            update: _.debounce(function (e) {
+                this.input = e.target.value
+            }, 300)
+        }
+    })
+</script>
+
+</body>
 </html>

File diff suppressed because it is too large
+ 11059 - 0
webroot/js/vue.js


File diff suppressed because it is too large
+ 6 - 0
webroot/js/vue.min.js