Exemple #1
0
  @Override
  protected void init(NodeMainExecutor nodeMainExecutor) {
    // TODO Auto-generated method stub
    String host = InetAddressFactory.newNonLoopback().getHostName();
    NodeConfiguration nodeConfiguration = NodeConfiguration.newPublic(host, getMasterUri());

    // Execute the location node
    sensorNode = new AndroidPhoneSensorNode();
    nodeMainExecutor.execute(sensorNode, nodeConfiguration);
  }
 @Override
 protected void init(NodeMainExecutor nodeMainExecutor) {
   // talker = new Talker("TALKING");
   NodeConfiguration nodeConfiguration =
       NodeConfiguration.newPublic(InetAddressFactory.newNonLoopback().getHostAddress());
   // At this point, the user has already been prompted to either enter the URI
   // of a master to use or to start a master locally.
   nodeConfiguration.setMasterUri(getMasterUri());
   // nodeMainExecutor.execute(talker, nodeConfiguration);
   // The RosTextView is also a NodeMain that must be executed in order to
   // start displaying incoming messages.
   nodeMainExecutor.execute(rosTextView, nodeConfiguration);
 }
    @Override
    public void run() {
      try {
        // Check if the concert exists by looking for concert name parameter
        // getParam throws when it can't find the parameter.
        ParameterClient paramClient =
            new ParameterClient(
                NodeIdentifier.forNameAndUri("/concert_checker", concertUri.toString()),
                concertUri);
        String name = (String) paramClient.getParam(GraphName.of(CONCERT_NAME_PARAM)).getResult();
        Log.i("ConcertRemocon", "Concert " + name + " found; retrieve additional information");

        NodeMainExecutorService nodeMainExecutorService = new NodeMainExecutorService();
        NodeConfiguration nodeConfiguration =
            NodeConfiguration.newPublic(
                InetAddressFactory.newNonLoopback().getHostAddress(), concertUri);

        // Check for the concert information topic
        ListenerNode<concert_msgs.ConcertInfo> readInfoTopic =
            new ListenerNode(CONCERT_INFO_TOPIC, concert_msgs.ConcertInfo._TYPE);
        nodeMainExecutorService.execute(
            readInfoTopic, nodeConfiguration.setNodeName("read_info_node"));
        readInfoTopic.waitForResponse();

        concert_msgs.ConcertInfo concertInfo = readInfoTopic.getLastMessage();

        String concertName = concertInfo.getName();
        String concertDesc = concertInfo.getDescription();
        rocon_std_msgs.Icon concertIcon = concertInfo.getIcon();

        if (name.equals(concertName) == false)
          Log.w(
              "ConcertRemocon", "Concert names from parameter and topic differs; we use the later");

        // Check for the concert roles topic
        ListenerNode<concert_msgs.Roles> readRolesTopic =
            new ListenerNode(CONCERT_ROLES_TOPIC, concert_msgs.Roles._TYPE);
        nodeMainExecutorService.execute(
            readRolesTopic, nodeConfiguration.setNodeName("concert_roles_node"));
        readRolesTopic.waitForResponse();

        nodeMainExecutorService.shutdownNodeMain(readInfoTopic);
        nodeMainExecutorService.shutdownNodeMain(readRolesTopic);

        // configure concert description
        Date timeLastSeen = new Date();
        ConcertDescription description =
            new ConcertDescription(masterId, concertName, concertDesc, concertIcon, timeLastSeen);
        Log.i("ConcertRemocon", "Concert is available");
        description.setConnectionStatus(ConcertDescription.OK);
        description.setUserRoles(readRolesTopic.getLastMessage());
        foundConcertCallback.receive(description);
        return;
      } catch (RuntimeException e) {
        // thrown if concert could not be found in the getParam call (from
        // java.net.ConnectException)
        Log.w(
            "ConcertRemocon", "could not find concert [" + concertUri + "][" + e.toString() + "]");
        failureCallback.handleFailure(e.toString());
      } catch (Throwable e) {
        Log.w(
            "ConcertRemocon",
            "exception while creating node in concert checker for URI " + concertUri,
            e);
        failureCallback.handleFailure(e.toString());
      }
    }