⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 remoteclient2.java

📁 Pioneer2机器人远程控制程序
💻 JAVA
字号:
package abrobot.abmobilerobot.clinet;

/**
 * <p>Title: GOPDR</p>
 * <p>Description: General Open Platform for Distributed Robot</p>
 * <p>Copyright: Copyright (c) 2003</p>
 * <p>Company: SJTU</p>
 * @author Hou Xueqiao
 * @version 1.01
 */

import abrobot.*;
import java.rmi.RMISecurityManager;
import net.jini.discovery.LookupDiscovery;
import net.jini.discovery.DiscoveryListener;
import net.jini.discovery.DiscoveryEvent;
import net.jini.core.lookup.ServiceRegistrar;
import net.jini.core.lookup.ServiceTemplate;
public class RemoteClient2 implements DiscoveryListener {
  public String msg=new String();

    public static void main(String argv[]) {
        new RemoteClient2();

        // stay around long enough to receive replies
        try {
            Thread.currentThread().sleep(100000L);
        } catch(java.lang.InterruptedException e) {
            // do nothing
        }
    }

    public RemoteClient2() {
        System.setSecurityManager(new RMISecurityManager());

        LookupDiscovery discover = null;
        try {
            discover = new LookupDiscovery(LookupDiscovery.ALL_GROUPS);
        } catch(Exception e) {
            System.err.println(e.toString());
            System.exit(1);
        }

        discover.addDiscoveryListener(this);

    }

    public void discovered(DiscoveryEvent evt) {

        ServiceRegistrar[] registrars = evt.getRegistrars();
        Class [] classes = new Class[] {AbRobotInterface.class};
        AbRobotInterface Robot = null;
        ServiceTemplate template = new ServiceTemplate(null, classes,
                                                       null);

        for (int n = 0; n < registrars.length; n++) {
            System.out.println("Service found");
            ServiceRegistrar registrar = registrars[n];
            try {
                Robot = (AbRobotInterface) registrar.lookup(template);
            } catch(java.rmi.RemoteException e) {
                e.printStackTrace();
                continue;
            }
            if (Robot == null) {
                System.out.println("Robot null");
                continue;
            }

            // Use the service to classify a few file types
           try{
             System.out.println(Robot.Properties().getProperty("Tag"));
            } catch(java.rmi.RemoteException e) {
                System.err.println(e.toString());
                continue;
            }
            // success
            System.exit(0);
        }
    }



    public void discarded(DiscoveryEvent evt) {
        // empty
    }
 // TestFileClassifier


}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -