ALMA Computing Group

MountConsumer.java

Go to the documentation of this file.
00001 /*
00002  *    ALMA - Atacama Large Millimiter Array
00003  *   (c) Associated Universities Inc., 2002 
00004  *    (c) European Southern Observatory, 2002
00005  *    Copyright by ESO (in the framework of the ALMA collaboration),
00006  *    All rights reserved
00007  *
00008  *    This library is free software; you can redistribute it and/or
00009  *    modify it under the terms of the GNU Lesser General Public
00010  *    License as published by the Free Software Foundation; either
00011  *    version 2.1 of the License, or (at your option) any later version.
00012  *
00013  *    This library is distributed in the hope that it will be useful,
00014  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016  *    Lesser General Public License for more details.
00017  *
00018  *    You should have received a copy of the GNU Lesser General Public
00019  *    License along with this library; if not, write to the Free Software
00020  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
00021  *    MA 02111-1307  USA
00022  *
00023  * MountConsumer.java
00024  *
00025  * Created on March 12, 2003, 2:33 PM
00026  */
00028 package alma.ACSCOURSE_MOUNT;
00030 import alma.acs.nc.Consumer;
00031 import alma.acs.container.ContainerServices;
00032 import alma.acs.component.client.ComponentClient;
00034 
00039 public class MountConsumer extends Consumer
00040 {
00042     public MountConsumer(ContainerServices cServices)
00043         throws alma.acs.exceptions.AcsJException
00044     {
00045         super(MOUNT_CHANNEL.value, cServices);
00046         
00047         //Subscribe to an event type and provide a reference to a class capable
00048         //of processing the event (see receive method).
00049         addSubscription(MountEventData.class, this);
00050     }    
00052 
00058     public void receive(MountEventData joe)
00059         {
00060             System.out.println("The commanded Az/El received by this consumer are:" + 
00061                                joe.Azimuth + 
00062                                "," + 
00063                                joe.Elevation);
00064         }
00066 
00069     public static void main(String[] args)
00070         {
00071         try
00072             {
00073             //Setup an ACS Java client. This has little to do with the NC API
00074             String managerLoc = System.getProperty("ACS.manager");
00075             if (managerLoc == null)
00076                 {
00077                 System.out.println("Java property 'ACS.manager' must be set to the corbaloc of the ACS manager!");
00078                 System.exit(-1);
00079                 }
00080             String clientName = "MountConsumerClient";
00081             ComponentClient myClient = new ComponentClient(null, managerLoc, clientName);
00082             
00083             //Create the consumer using the ACS Java client's container services.
00084             MountConsumer joe = new MountConsumer(myClient.getContainerServices());
00085             
00086             //After consumerReady() is invoked, processEvent(...) is invoked
00087             //by the channel.  That is, we have no control over when
00088             //that method is called.
00089             joe.consumerReady();
00090             System.out.println("Waiting for events...");
00091 
00092             //Wait a while for some events
00093             Thread.sleep(50000);
00094 
00095             //Disconnect from the channel
00096             joe.disconnect();
00097 
00098             //Must cleanly disconnect the client
00099             myClient.tearDown();
00100         }
00101         catch(Exception e)
00102         {
00103             e.printStackTrace(System.err);
00104         }
00105         System.out.println("Done...");
00106     }
00108 }