123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- package at.acdp.urweb.web;
- import at.acdp.urweb.Main;
- import at.acdp.urweb.fhpp.Status;
- import com.nmote.xr.XRMethod;
- 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 = "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);
- 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) {
- 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();
- if (s.mc == what) break;
- }
- logger.info("Got MC");
- }
- private static void checkPos(int pos) {
- }
- @XRMethod(value = "status", help = "Returns status")
- public static String status() {
- var x=Main.fhm.readStatus();
- try {
- return x==null?"<null>":x.get().toString();
- } catch (Exception e) {
- e.printStackTrace();
- return e.toString();
- }
- }
- }
|