Main.java 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package at.acdp.urweb;
  2. import at.acdp.urweb.fhpp.FHMaster;
  3. import at.acdp.urweb.fhpp.FHMasterSim;
  4. import at.acdp.urweb.fhpp.IFHMaster;
  5. import at.acdp.urweb.rtde.RTDEClient;
  6. import at.acdp.urweb.rtde.packets.*;
  7. import at.acdp.urweb.web.FestoXRServer;
  8. import com.nmote.nanohttp.NanoServer;
  9. import com.nmote.xr.HTTPServerEndpoint;
  10. import com.nmote.xr.XR;
  11. import org.slf4j.LoggerFactory;
  12. public class Main {
  13. private final static org.slf4j.Logger logger = LoggerFactory.getLogger(Main.class);
  14. public static IFHMaster fhm=new FHMaster();
  15. public static void main(String[] args) {
  16. Params app = null;
  17. try {
  18. app = picocli.CommandLine.populateCommand(new Params(), args);
  19. if(app==null) {
  20. System.exit(1);
  21. }
  22. NanoServer server = new NanoServer("http://0.0.0.0:" + app.port);
  23. RTDEClient r=new RTDEClient("127.0.0.1", 30004);
  24. var so=new RtdeSetupOutputs()
  25. .addVariable("timestamp")
  26. .addVariable("robot_mode")
  27. .addVariable("safety_mode") //
  28. .addVariable("safety_status")
  29. .addVariable("target_speed_fraction")
  30. .addVariable("runtime_state")
  31. .addVariable("speed_scaling");
  32. r.start(so);
  33. PosThread p=new PosThread(r, fhm);
  34. p.start();
  35. FestoXRServer fxrs = new FestoXRServer(r);
  36. HTTPServerEndpoint xrs = XR.server(fxrs, FestoXRServer.class);
  37. server.add(xrs);
  38. server.start();
  39. while(true) {
  40. try {
  41. fhm.start(app);
  42. }
  43. catch (Exception e) {
  44. logger.warn("modbus failed", e);
  45. }
  46. }
  47. } catch (Exception e) {
  48. logger.error("Server exited", e);
  49. }
  50. }
  51. }