Browse Source

installation ip address also used for toolbar
toolbar buttons working
Separated ABS and REL nodes
converted programnode to swing

Martin Kunz 4 years ago
parent
commit
e36b25d0de

+ 5 - 5
pom.xml

@@ -17,7 +17,7 @@
 			<plugin>
 				<groupId>org.apache.maven.plugins</groupId>
 				<artifactId>maven-compiler-plugin</artifactId>
-				<version>3.8.0</version>
+				<version>3.8.1</version>
 				<configuration>
 					<source>11</source>
 					<target>11</target>
@@ -55,7 +55,7 @@
 			<plugin>
 				<groupId>org.apache.maven.plugins</groupId>
 				<artifactId>maven-jar-plugin</artifactId>
-				<version>3.1.1</version>
+				<version>3.1.2</version>
 				<configuration>
 					<archive>
 						<manifest>
@@ -77,17 +77,17 @@
         <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-api</artifactId>
-            <version>1.7.26</version>
+            <version>1.7.28</version>
         </dependency>
 		<dependency>
 			<groupId>com.digitalpetri.modbus</groupId>
 			<artifactId>modbus-master-tcp</artifactId>
-			<version>1.1.0</version>
+			<version>1.1.1</version>
 		</dependency>
         <dependency>
             <groupId>com.digitalpetri.modbus</groupId>
             <artifactId>modbus-slave-tcp</artifactId>
-            <version>1.1.0</version>
+            <version>1.1.1</version>
         </dependency>
 		<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->
 		<dependency>

+ 1 - 1
src/main/java/at/acdp/urweb/Main.java

@@ -21,7 +21,7 @@ public class Main {
             logger.error("Server exited", e);
         }
         try {
-            fhm.start();
+            fhm.start(app);
         } catch (Exception e) {
             logger.error("failed.", e);
             picocli.CommandLine.usage(new Params(), System.out);

+ 5 - 19
src/main/java/at/acdp/urweb/Params.java

@@ -1,28 +1,14 @@
 package at.acdp.urweb;
 
 public class Params {
-    @picocli.CommandLine.Option(names = { "-p", "--port" }, description = "HTTP Server port", required = true)
+    @picocli.CommandLine.Option(names = { "-p", "--port" }, description = "HTTP Server port", defaultValue = "8080")
     public int port = 8080;
 
-    @picocli.CommandLine.Option(names = { "-w", "--webroot" }, description = "Use webroot from filesystem", defaultValue = "")
-    public String webroot = "";
+    @picocli.CommandLine.Option(names = { "-aip", "--axisip" }, description = "Axis ip address", defaultValue = "127.0.0.1")
+    public String axisIP = "127.0.0.1";
 
-    @picocli.CommandLine.Option(names = { "-rip", "--robotip" }, description = "Robot ip address", defaultValue = "")
-    public String robotIP = "";
+    @picocli.CommandLine.Option(names = { "-ap", "--axisport" }, description = "Axis modbus port", defaultValue = "502")
+    public int axisPort = 502;
 
-    @picocli.CommandLine.Option(names = { "-rp", "--robotport" }, description = "Robot tcp port", defaultValue = "30001")
-    public int robotPort = 30001;
-
-    @picocli.CommandLine.Option(names = { "-rt", "--rtport" }, description = "rtde tcp port", defaultValue = "30004")
-    public int rtPort;
-
-    @picocli.CommandLine.Option(names = {"--sshUsername"}, description = "ssh username", defaultValue = "root")
-    public String sshUsername;
-
-    @picocli.CommandLine.Option(names = {"--sshPassword"}, description = "ssh password", defaultValue = "easybot")
-    public String sshPassword;
-
-    @picocli.CommandLine.Option(names = {"--sshPort"}, description = "ssh port", defaultValue = "22")
-    public String sshPort;
 }
 

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

@@ -6,6 +6,7 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.*;
 
+import at.acdp.urweb.Params;
 import com.digitalpetri.modbus.codec.Modbus;
 import com.digitalpetri.modbus.master.ModbusTcpMaster;
 import com.digitalpetri.modbus.master.ModbusTcpMasterConfig;
@@ -16,37 +17,22 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class FHMaster {
+    private final Logger logger = LoggerFactory.getLogger(getClass());
     public static int posfaktorNum=1;
     public static int posfaktorDiv=1;
     private ModbusTcpMaster master;
 
-
-
-    public static void main(String[] args) {
-        try {
-            new FHMaster().start();
-        } catch (InterruptedException e) {
-            e.printStackTrace();
-        }
-    }
-    private final Logger logger = LoggerFactory.getLogger(getClass());
     private final ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();
     private volatile boolean started = false;
     public FHMaster() {
     }
 
-    public void start() throws InterruptedException {
+    public void start(Params app) throws InterruptedException {
         started = true;
-        ModbusTcpMasterConfig config = new ModbusTcpMasterConfig.Builder("10.0.31.14")
-                .setPort(502)
+        ModbusTcpMasterConfig config = new ModbusTcpMasterConfig.Builder(app.axisIP)
+                .setPort(app.axisPort)
                 .build();
         master = new ModbusTcpMaster(config);
-        // var f=master.connect()
-      //          .whenComplete((result, ex) -> bereitschaft(master))
-      //          .whenComplete((result, ex) -> direktAuftrag(master,100));
-
-
-
         while(true) {
             Thread.sleep(1000);
             readStatus();
@@ -118,9 +104,9 @@ public class FHMaster {
 
         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);
-        byte sbyte5= (byte)(pos>>24 & 0xff);
+        byte sbyte7= (byte)((pos>>8) & 0xff);
+        byte sbyte6= (byte)((pos>>16) & 0xff);
+        byte sbyte5= (byte)((pos>>24) & 0xff);
 
         send(new byte[]{ccon,
                         cpos,
@@ -174,5 +160,4 @@ public class FHMaster {
     public void stop() {
         started = false;
     }
-
 }

+ 17 - 25
src/main/java/at/acdp/urweb/web/XRServer.java

@@ -1,47 +1,54 @@
 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;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class XRServer {
+    private final static Logger logger = LoggerFactory.getLogger(XRServer.class);
 
     @XRMethod(value = "example.helloWorld", help = "Returns 'Helo ' + argument")
     public static String hello(Object s) {
         return "Hello '" + s + "'";
     }
 
-    @XRMethod(value = "ref", help = "ref")
+    @XRMethod(value = "ref2", help = "ref")
     public static String ref(String a, String b) {
         return "ref";
     }
 
     @XRMethod(value = "rel", help = "rel")
     public static void rel(String pos) {
+        logger.info("Relative to {} Begin", pos);
         System.out.println("rel: "+pos);
-        waitMC(true);
         Main.fhm.direktAuftrag(Integer.parseInt(pos),0,true);
+        waitMC(true);
         Main.fhm.direktAuftrag(Integer.parseInt(pos),1,true);
         waitMC(true);
+        logger.info("Relative to {} End", pos);
     }
 
     @XRMethod(value = "abs", help = "abs")
     public static void abs(String pos) {
-        System.out.println("abs: "+pos);
-        waitMC(true);
+        logger.info("Absolute to {} Begin", pos);
         Main.fhm.direktAuftrag(Integer.parseInt(pos),0, false);
+        waitMC(true);
         Main.fhm.direktAuftrag(Integer.parseInt(pos),1, false);
         waitMC(true);
+        logger.info("Absolute to {} End", pos);
     }
 
     private static void waitMC(boolean what) {
+        logger.info("Waiting for MC");
         while(true) {
-            Status s=Main.fhm.readStatus().join();
-            System.out.println(s.mc);
-            if(s.mc==what) break;
+            Status s = Main.fhm.readStatus().join();
+            if (s.mc == what) break;
         }
+        logger.info("Got MC");
+    }
+
+    private static void checkPos(int pos) {
 
     }
 
@@ -55,19 +62,4 @@ public class XRServer {
             return e.toString();
         }
     }
-
-    @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";
-    }
 }