Browse Source

rel fahrt funktioniert

Martin Kunz 4 years ago
parent
commit
d5585e19ad

+ 3 - 3
src/main/java/at/acdp/urweb/fhpp/FHMaster.java

@@ -79,7 +79,7 @@ public class FHMaster {
         f.join();
     }
 
-    public void direktAuftrag(int pos, int start) {
+    public void direktAuftrag(int pos, int start, boolean relative) {
         byte ccon=0x0;
         ccon|=(1<<0); // Enable drive
         ccon|=(1<<1); // !Stop
@@ -104,7 +104,7 @@ public class FHMaster {
         cpos|=(0<<7); //  Reserved
 
         byte cdir=0x0;
-        cdir|=(1<<0); //  relative(0), absolute(1)
+        cdir|=((relative==true?1:0) <<0); //  relative(1), absolute(0)
         cdir|= (0<<1| 0<<2); //absolute/relative
                                 // 0,0 Positionsregelung
                                 // 0,1 Kraftbetrieb
@@ -116,7 +116,7 @@ public class FHMaster {
         cdir|=(0<<6);   // Function Group Kurvenscheibenfunktion (0=nein)
         cdir|=(0<<7);   // 0 = normal; 1=kurvenscheibenfunktion
 
-        byte sbyte4=5; // Geschw, in % vom Basiswert (PNU540
+        byte sbyte4=20; // Geschw, in % vom Basiswert (PNU540
         byte sbyte8= (byte)(pos& 0xff);
         byte sbyte7= (byte)(pos>>8 & 0xff);
         byte sbyte6= (byte)(pos>>16 & 0xff);

+ 26 - 5
src/main/java/at/acdp/urweb/web/XRServer.java

@@ -1,6 +1,7 @@
 package at.acdp.urweb.web;
 
 import at.acdp.urweb.Main;
+import at.acdp.urweb.fhpp.Status;
 import com.nmote.xr.XRMethod;
 
 import java.util.concurrent.ExecutionException;
@@ -17,11 +18,31 @@ public class XRServer {
         return "ref";
     }
 
-    @XRMethod(value = "pos", help = "pos")
-    public static void pos(String pos) {
-       //Main.fhm.prepare();
-       Main.fhm.direktAuftrag(Integer.parseInt(pos),0);
-       Main.fhm.direktAuftrag(Integer.parseInt(pos),1);
+    @XRMethod(value = "rel", help = "rel")
+    public static void rel(String pos) {
+        System.out.println("rel: "+pos);
+        waitMC(true);
+        Main.fhm.direktAuftrag(Integer.parseInt(pos),0,true);
+        Main.fhm.direktAuftrag(Integer.parseInt(pos),1,true);
+        waitMC(true);
+    }
+
+    @XRMethod(value = "abs", help = "abs")
+    public static void abs(String pos) {
+        System.out.println("abs: "+pos);
+        waitMC(true);
+        Main.fhm.direktAuftrag(Integer.parseInt(pos),0, false);
+        Main.fhm.direktAuftrag(Integer.parseInt(pos),1, false);
+        waitMC(true);
+    }
+
+    private static void waitMC(boolean what) {
+        while(true) {
+            Status s=Main.fhm.readStatus().join();
+            System.out.println(s.mc);
+            if(s.mc==what) break;
+        }
+
     }
 
     @XRMethod(value = "status", help = "Returns status")