Пример #1
0
  private void closePopup() {
    if (this.hpC) {
      this.hpE.beG();
      this.hpC = false;

      MQ.WK().WN();
    }
  }
  public void run() {

    try {
      final Connection conn = MQ.createConnection();
      final Channel channel = MQ.createChannel(conn);
      BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));

      System.out.println(String.format("Subscribbed to topic '%s'. Exit with ENTER", MONITOR_KEY));

      // create a queue for this program
      final AMQP.Queue.DeclareOk queue = channel.queueDeclare();
      System.out.println("Create queue " + queue.getQueue());

      // bind the queue to all routing keys that match MONITOR_KEY
      channel.queueBind(queue.getQueue(), Config.EXCHANGE_NAME, MONITOR_KEY);
      System.out.println(
          String.format(
              "Bound queue %s to all keys that match '%s' on exchange %s",
              queue.getQueue(), MONITOR_KEY, Config.EXCHANGE_NAME));

      boolean noAck = false;

      // ask the server to notify us of new message and do not send ack message automatically
      // WARNING: This code is called from the thread that does the communication with the
      // server so sufficient locking is required. Also do not use any blocking calls to
      // the server such as queueDeclare, txCommit, or basicCancel. Basicly only "basicAck"
      // should be called here!!!
      channel.basicConsume(
          queue.getQueue(),
          noAck,
          new DefaultConsumer(channel) {
            @Override
            public void handleDelivery(
                String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body)
                throws IOException {
              // get the delivery tag to ack that we processed the message successfully
              long deliveryTag = envelope.getDeliveryTag();

              // properties.getTimestamp() contains the timestamp
              // that the sender added when the message was published. This
              // time is the time on the sender and NOT the time on the
              // AMQP server. This implies that clients are possibly out of
              // sync!
              System.out.println(
                  String.format(
                      "@%d: %s -> %s",
                      properties.getTimestamp().getTime(),
                      envelope.getRoutingKey(),
                      new String(body)));

              mp.parse(envelope.getRoutingKey(), new String(body));

              System.out.println(envelope.getRoutingKey());
              System.out.println("bericht: " + new String(body));

              // send an ack to the server so it can remove the message from
              // the queue.
              channel.basicAck(deliveryTag, false);
            }

            //				private void parse(String routingKey, String body) {
            //					System.out.println(routingKey);
            //					if(!body.contains("start")){
            //					Robot robot_temp = controller.getRobotFromIdentifier(routingKey.split("_")[1]);
            //					if(robot_temp!=null)
            //					robot_temp.setPose(0.0, (int)Double.parseDouble(body.split("_")[0]),
            // (int)Double.parseDouble(body.split("_")[1]));
            //					}
            //				}
          });

      // wait here until a newline is entered
      stdin.readLine();

      channel.close();
      conn.close();
    } catch (IOException e) {
      e.printStackTrace(System.err);
    }
  }
Пример #3
0
  private void cdN() {
    if (!this.hpC) {
      Or localOr = this.hpE.getPrefSize();
      int i = localOr.width;
      int j = localOr.height;

      int k = getDisplayX();

      int n = getDisplayY();

      bsP localbsP = bsP.getInstance();

      aFG localaFG1 = this.aWn;
      aFG localaFG2 = this.drn;

      int i1 = getDisplayY() + localaFG1.iP(getHeight()) - localaFG2.iP(j);

      if ((i1 < 0) || (i1 > localbsP.getAppearance().getContentHeight() - j)) {
        localaFG1 = localaFG1.aSd();
        localaFG2 = localaFG2.aSd();
      }

      i1 = getDisplayY() + localaFG1.iP(getHeight()) - localaFG2.iP(j);

      i1 = Math.max(0, Math.min(i1, localbsP.getAppearance().getContentHeight() - j));

      if ((n - j < 0) && (n + getHeight() + j > localbsP.getHeight())) {
        j = n;
        i1 = 0;
      }

      int m = k + localaFG1.iO(getWidth()) - localaFG2.iO(i);

      if ((m < 0) || (m > localbsP.getAppearance().getContentWidth() - i)) {
        localaFG1 = localaFG1.aSc();
        localaFG2 = localaFG2.aSc();
      }

      m = getDisplayX() + localaFG1.iO(getWidth()) - localaFG2.iO(i);

      m = Math.max(0, Math.min(m, localbsP.getAppearance().getContentWidth() - i));

      if ((k - i < 0) && (k + getWidth() + i > localbsP.getWidth())) {
        i = k;
        m = 0;
      }

      this.hpE.setSizeToPrefSize();
      i = Math.max(this.hpE.getWidth(), i);
      j = Math.max(this.hpE.getHeight(), j);

      this.hpE.setSize(i, j);

      this.hpE.setPosition(m, i1);
      this.hpE.setNonBlocking(false);

      localbsP.getLayeredContainer().b(this.hpE, 30000);

      this.hpC = true;
      this.hpD = true;

      MQ.WK().WM();
    }
  }