XRServer.java 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. package at.acdp.urweb.web;
  2. import at.acdp.urweb.Main;
  3. import at.acdp.urweb.fhpp.Status;
  4. import com.nmote.xr.XRMethod;
  5. import java.util.concurrent.ExecutionException;
  6. public class XRServer {
  7. @XRMethod(value = "example.helloWorld", help = "Returns 'Helo ' + argument")
  8. public static String hello(Object s) {
  9. return "Hello '" + s + "'";
  10. }
  11. @XRMethod(value = "ref", help = "ref")
  12. public static String ref(String a, String b) {
  13. return "ref";
  14. }
  15. @XRMethod(value = "rel", help = "rel")
  16. public static void rel(String pos) {
  17. System.out.println("rel: "+pos);
  18. waitMC(true);
  19. Main.fhm.direktAuftrag(Integer.parseInt(pos),0,true);
  20. Main.fhm.direktAuftrag(Integer.parseInt(pos),1,true);
  21. waitMC(true);
  22. }
  23. @XRMethod(value = "abs", help = "abs")
  24. public static void abs(String pos) {
  25. System.out.println("abs: "+pos);
  26. waitMC(true);
  27. Main.fhm.direktAuftrag(Integer.parseInt(pos),0, false);
  28. Main.fhm.direktAuftrag(Integer.parseInt(pos),1, false);
  29. waitMC(true);
  30. }
  31. private static void waitMC(boolean what) {
  32. while(true) {
  33. Status s=Main.fhm.readStatus().join();
  34. System.out.println(s.mc);
  35. if(s.mc==what) break;
  36. }
  37. }
  38. @XRMethod(value = "status", help = "Returns status")
  39. public static String status() {
  40. var x=Main.fhm.readStatus();
  41. try {
  42. return x==null?"<null>":x.get().toString();
  43. } catch (Exception e) {
  44. e.printStackTrace();
  45. return e.toString();
  46. }
  47. }
  48. @XRMethod(value = "set_title", help = "Returns 'Helo ' + argument")
  49. public static String set_title(Object s) {
  50. return "Hello '" + s + "'";
  51. }
  52. @XRMethod(value = "get_title", help = "Returns 'Helo ' + argument")
  53. public static String get_title() {
  54. return "Hello";
  55. }
  56. @XRMethod(value = "get_message")
  57. public static String get_message(Object s) {
  58. return "asdfasdfas";
  59. }
  60. }