KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > JSci > astro > telescope > LX200Server


1 /**
2 * Java LX200Server class.
3 * Copyright (C) 1999-2001 Mark Hale
4 */

5
6 package JSci.astro.telescope;
7
8 import java.io.*;
9 import java.rmi.*;
10 import java.rmi.registry.*;
11 import java.rmi.server.UnicastRemoteObject JavaDoc;
12
13 public final class LX200Server extends UnicastRemoteObject JavaDoc implements LX200Remote {
14         private final LX200 lx200;
15
16         public static void main(String JavaDoc arg[]) {
17                 if(arg.length!=2) {
18                         System.out.println("Usage: LX200Server <com port> <remote name>");
19                         return;
20                 }
21                 System.setSecurityManager(new RMISecurityManager());
22                 try {
23                         Registry localRegistry=LocateRegistry.createRegistry(Registry.REGISTRY_PORT);
24                         localRegistry.rebind(arg[1],new LX200Server(new LX200(arg[0])));
25                 } catch(IOException e) {
26                         e.printStackTrace();
27                 }
28         }
29         /**
30         * Constructs a telescope server.
31         * @param telescope the telescope to serve.
32         */

33         public LX200Server(LX200 telescope) throws RemoteException {
34                 lx200=telescope;
35         }
36         public void setFocusRate(int rate) throws IOException, RemoteException {
37                 lx200.setFocusRate(rate);
38         }
39         public void startFocus(int direction) throws IOException, RemoteException {
40                 lx200.startFocus(direction);
41         }
42         public void stopFocus() throws IOException, RemoteException {
43                 lx200.stopFocus();
44         }
45         public void setSlewRate(int rate) throws IOException, RemoteException {
46                 lx200.setSlewRate(rate);
47         }
48         public void startSlew(int direction) throws IOException, RemoteException {
49                 lx200.startSlew(direction);
50         }
51         public void stopSlew(int direction) throws IOException, RemoteException {
52                 lx200.stopSlew(direction);
53         }
54         public String JavaDoc getRA() throws IOException, RemoteException {
55                 return lx200.getRA();
56         }
57         public String JavaDoc getDec() throws IOException, RemoteException {
58                 return lx200.getDec();
59         }
60         public void setObjectCoords(String JavaDoc ra,String JavaDoc dec) throws IOException, RemoteException {
61                 lx200.setObjectCoords(ra,dec);
62         }
63         public int slewToObject() throws IOException, RemoteException {
64                 return lx200.slewToObject();
65         }
66         public void syncCoords() throws IOException, RemoteException {
67                 lx200.syncCoords();
68         }
69 }
70
71
Popular Tags