01: /**
02: * Java LX200Server class.
03: * Copyright (C) 1999-2001 Mark Hale
04: */package JSci.astro.telescope;
05:
06: import java.io.*;
07: import java.rmi.*;
08: import java.rmi.registry.*;
09: import java.rmi.server.UnicastRemoteObject;
10:
11: public final class LX200Server extends UnicastRemoteObject implements
12: LX200Remote {
13: private final LX200 lx200;
14:
15: public static void main(String arg[]) {
16: if (arg.length != 2) {
17: System.out
18: .println("Usage: LX200Server <com port> <remote name>");
19: return;
20: }
21: System.setSecurityManager(new RMISecurityManager());
22: try {
23: Registry localRegistry = LocateRegistry
24: .createRegistry(Registry.REGISTRY_PORT);
25: localRegistry.rebind(arg[1], new LX200Server(new LX200(
26: arg[0])));
27: } catch (IOException e) {
28: e.printStackTrace();
29: }
30: }
31:
32: /**
33: * Constructs a telescope server.
34: * @param telescope the telescope to serve.
35: */
36: public LX200Server(LX200 telescope) throws RemoteException {
37: lx200 = telescope;
38: }
39:
40: public void setFocusRate(int rate) throws IOException,
41: RemoteException {
42: lx200.setFocusRate(rate);
43: }
44:
45: public void startFocus(int direction) throws IOException,
46: RemoteException {
47: lx200.startFocus(direction);
48: }
49:
50: public void stopFocus() throws IOException, RemoteException {
51: lx200.stopFocus();
52: }
53:
54: public void setSlewRate(int rate) throws IOException,
55: RemoteException {
56: lx200.setSlewRate(rate);
57: }
58:
59: public void startSlew(int direction) throws IOException,
60: RemoteException {
61: lx200.startSlew(direction);
62: }
63:
64: public void stopSlew(int direction) throws IOException,
65: RemoteException {
66: lx200.stopSlew(direction);
67: }
68:
69: public String getRA() throws IOException, RemoteException {
70: return lx200.getRA();
71: }
72:
73: public String getDec() throws IOException, RemoteException {
74: return lx200.getDec();
75: }
76:
77: public void setObjectCoords(String ra, String dec)
78: throws IOException, RemoteException {
79: lx200.setObjectCoords(ra, dec);
80: }
81:
82: public int slewToObject() throws IOException, RemoteException {
83: return lx200.slewToObject();
84: }
85:
86: public void syncCoords() throws IOException, RemoteException {
87: lx200.syncCoords();
88: }
89: }
|