Exemplo n.º 1
0
 public Octopus() {
   NewConfig newC = new NewConfig();
   if (Constants.get() == null) {
     Constants.init(newC.getConstants());
   }
   initFromSpec(newC.getEnvironment());
 }
Exemplo n.º 2
0
  public String env_message(String theMessage) {
    EnvironmentMessages theMessageObject;
    try {
      theMessageObject = EnvironmentMessageParser.parseMessage(theMessage);
    } catch (NotAnRLVizMessageException e) {
      System.err.println("Someone sent Octopus a message that wasn't RL-Viz compatible");
      return "I only respond to RL-Viz messages!";
    }

    if (theMessageObject.canHandleAutomatically(this)) {
      String theResponseString = theMessageObject.handleAutomatically(this);
      return theResponseString;
    }

    //		If it wasn't handled automatically, maybe its a custom Mountain Car Message
    if (theMessageObject.getTheMessageType()
        == rlVizLib.messaging.environment.EnvMessageType.kEnvCustom.id()) {

      String theCustomType = theMessageObject.getPayLoad();
      AbstractResponse theResponse = null;
      if (theCustomType.equals("GETOCTSTATE")) {
        theResponse = new OctopusStateResponse(arm.getCompartments());
      }
      if (theCustomType.equals("GETOCTCOREDATA")) {
        theResponse = new OctopusCoreDataResponse(targets, Constants.get().getSurfaceLevel());
      }
      if (theResponse != null) {
        return theResponse.makeStringResponse();
      }
    }
    System.err.println(
        "We need some code written in Env Message for Octopus.. unknown request received: "
            + theMessage);
    Thread.dumpStack();
    return null;
  }