ALMA Computing Group

EventSupplierImpl.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 * ncTestCompImpl.java 00024 * 00025 * Created on April 11, 2003, 2:21 PM 00026 */ 00027 package alma.demo.EventSupplierImpl; 00028 00029 import java.util.logging.Level; 00030 00031 import alma.ACSErrTypeCommon.CouldntPerformActionEx; 00032 import alma.ACSErrTypeCommon.wrappers.AcsJCouldntPerformActionEx; 00033 import alma.FRIDGE.TemperatureStatus; 00034 import alma.FRIDGE.temperatureDataBlockEvent; 00035 import alma.FRIDGE.FridgeControlPackage.NestedFridgeEvent; 00036 import alma.acs.component.ComponentImplBase; 00037 import alma.acs.component.ComponentLifecycleException; 00038 import alma.acs.container.ContainerServices; 00039 import alma.acs.nc.SimpleSupplier; 00040 import alma.demo.SupplierCompOperations; 00041 00042 00047 public class EventSupplierImpl extends ComponentImplBase implements SupplierCompOperations 00048 { 00049 private SimpleSupplier m_supplier; 00050 00054 public void initialize(ContainerServices containerServices) throws ComponentLifecycleException 00055 { 00056 super.initialize(containerServices); 00057 00058 try { 00059 // Instantiate our supplier 00060 m_supplier = new SimpleSupplier(alma.FRIDGE.CHANNELNAME_FRIDGE.value, //the channel's name 00061 m_containerServices); 00062 } 00063 catch (Exception e) { 00064 throw new ComponentLifecycleException("failed to create SimpleSupplier for channel " + alma.FRIDGE.CHANNELNAME_FRIDGE.value, e); 00065 } 00066 } 00067 00071 public void cleanUp() 00072 { 00073 m_supplier.disconnect(); 00074 } 00075 00076 00080 public void sendEvents(short param) throws CouldntPerformActionEx 00081 { 00082 m_logger.info("Now sending " + param + " temperatureDataBlockEvent events..."); 00083 try { 00084 temperatureDataBlockEvent t_block = new temperatureDataBlockEvent(3.14F, TemperatureStatus.ATREF); 00085 for(short i=0; i<param; i++) 00086 { 00087 m_supplier.publishEvent(t_block); 00088 } 00089 } 00090 catch(Throwable thr) { 00091 m_logger.log(Level.WARNING, "failed to send temperatureDataBlockEvent. Will not try again."); 00092 throw (new AcsJCouldntPerformActionEx(thr)).toCouldntPerformActionEx(); 00093 } 00094 } 00095 00096 public void sendEventsSpecial(NestedFridgeEvent[] eventData) throws CouldntPerformActionEx { 00097 try { 00098 m_logger.info("Now sending " + eventData.length + " NestedFridgeEvent events..."); 00099 for (NestedFridgeEvent event : eventData) { 00100 m_supplier.publishEvent(event); 00101 } 00102 } 00103 catch(Throwable thr) { 00104 m_logger.log(Level.WARNING, "failed to send NestedFridgeEvent. Will not try again."); 00105 throw (new AcsJCouldntPerformActionEx(thr)).toCouldntPerformActionEx(); 00106 } 00107 } 00108 }