ALMA Computing Group

acsexmplLampImpl.cpp

Go to the documentation of this file.
00001 /******************************************************************************* 00002 * ALMA - Atacama Large Millimiter Array 00003 * (c) European Southern Observatory, 2002 00004 * Copyright by ESO (in the framework of the ALMA collaboration) 00005 * and Cosylab 2002, All rights reserved 00006 * 00007 * This library is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public 00009 * License as published by the Free Software Foundation; either 00010 * version 2.1 of the License, or (at your option) any later version. 00011 * 00012 * This library is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with this library; if not, write to the Free Software 00019 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00020 * 00021 * 00022 * 00023 * "@(#) $Id: acsexmplLampImpl.cpp,v 1.101 2008/10/01 04:30:47 cparedes Exp $" 00024 * 00025 * who when what 00026 * -------- -------- ---------------------------------------------- 00027 * acaproni 2004-04-06 Use of smart pointer for properties 00028 * david 2002-08-08 changed defines to const static int's 00029 * david 2002-06-16 added a few comments and deleted RESET_ACTION define 00030 * almamgr 2002-04-07 Removed poa parameter from call to ConstructorEpilogue() 00031 * blopez 2002-04-05 Modified for ACSDO usage. Header removed. 00032 * almamgr 2002-01-22 Replaced old include files with new axsexmpl... files 00033 * msekoran 2001-07-06 improved error handling 00034 * msekoran 2001-03-10 integrated with new BACI; ALMA coding convention used 00035 * gchiozzi 2001-02-15 Added real implementation for method descriptor() 00036 * gchiozzi 2001-02-15 Added body of get_interface() method for Object Explorer 00037 * gchiozzi 2001-02-15 created standard header 00038 */ 00039 00040 00041 #include <baciDB.h> 00042 #include <acsexmplLampImpl.h> 00043 00047 const static int ON_ACTION = 0; 00048 const static int OFF_ACTION = 1; 00049 00050 ACE_RCSID(acsexmpl, acsexmplLampImpl, "$Id: acsexmplLampImpl.cpp,v 1.101 2008/10/01 04:30:47 cparedes Exp $") 00051 using namespace baci; 00052 00054 // Lamp 00056 00057 Lamp::Lamp( 00058 const ACE_CString &name, 00059 maci::ContainerServices * containerServices) : 00060 CharacteristicComponentImpl(name, containerServices), 00061 m_brightness_sp(new RWdouble(name+":brightness", getComponent()),this) 00062 { 00063 00064 ACS_TRACE("::Lamp::Lamp"); 00065 00066 } 00067 00068 Lamp::~Lamp() 00069 { 00070 00071 ACS_TRACE("::Lamp::~Lamp"); 00072 00073 } 00074 00075 /* --------------- [ Action implementator interface ] -------------- */ 00076 00077 ActionRequest 00078 Lamp::invokeAction (int function, 00079 BACIComponent *cob_p, 00080 const int &callbackID, 00081 const CBDescIn &descIn, 00082 BACIValue *value_p, 00083 Completion &completion, 00084 CBDescOut &descOut) 00085 { 00086 00087 // better implementation with array is possible 00088 switch (function) 00089 { 00090 case ON_ACTION: 00091 { 00092 return onAction(cob_p, callbackID, descIn, value_p, completion, descOut); 00093 } 00094 case OFF_ACTION: 00095 { 00096 return offAction(cob_p, callbackID, descIn, value_p, completion, descOut); 00097 } 00098 default: 00099 { 00100 return reqDestroy; 00101 } 00102 } 00103 } 00104 00105 /* ------------------ [ Action implementations ] ----------------- */ 00106 00108 ActionRequest 00109 Lamp::onAction (BACIComponent *cob_p, 00110 const int &callbackID, 00111 const CBDescIn &descIn, 00112 BACIValue *value_p, 00113 Completion &completion, 00114 CBDescOut &descOut) 00115 { 00116 ACS_DEBUG_PARAM("::Lamp::onAction", "%s", getComponent()->getName()); 00117 00118 DBConnector::writeCommand(getComponent()->getName(), "on", getStringifiedTimeStamp()); 00119 00120 completion = ACSErrTypeOK::ACSErrOKCompletion(); 00121 00122 // complete action requesting done invocation, 00123 // otherwise return reqInvokeWorking and set descOut.estimated_timeout 00124 return reqInvokeDone; 00125 } 00126 00127 00128 00130 ActionRequest 00131 Lamp::offAction (BACIComponent *cob_p, 00132 const int &callbackID, 00133 const CBDescIn &descIn, 00134 BACIValue *value_p, 00135 Completion &completion, 00136 CBDescOut &descOut) 00137 { 00138 ACS_DEBUG_PARAM("::Lamp::offAction", "%s", getComponent()->getName()); 00139 00140 DBConnector::writeCommand(getComponent()->getName(), "off", getStringifiedTimeStamp()); 00141 00142 completion = ACSErrTypeOK::ACSErrOKCompletion(); 00143 00144 // complete action requesting done invakation, 00145 // otherwise return reqInvokeWorking and set descOut.estimated_timeout 00146 return reqInvokeDone; 00147 } 00148 00149 /* --------------------- [ CORBA interface ] ----------------------*/ 00150 00151 void 00152 Lamp::on (ACS::CBvoid_ptr cb, 00153 const ACS::CBDescIn &desc 00154 ) 00155 { 00156 //registers the action to the BACI and returns control immediately 00157 getComponent()->registerAction(BACIValue::type_null, cb, desc, this, ON_ACTION); 00158 } 00159 00160 void 00161 Lamp::off (ACS::CBvoid_ptr cb, 00162 const ACS::CBDescIn &desc 00163 ) 00164 { 00165 //registers the action to the BACI and returns control immediately 00166 getComponent()->registerAction(BACIValue::type_null, cb, desc, this, OFF_ACTION); 00167 } 00168 00169 ACS::RWdouble_ptr 00170 Lamp::brightness () 00171 { 00172 if (m_brightness_sp == 0) 00173 { 00174 return ACS::RWdouble::_nil(); 00175 } 00176 00177 ACS::RWdouble_var prop = ACS::RWdouble::_narrow(m_brightness_sp->getCORBAReference()); 00178 return prop._retn(); 00179 } 00180 00181 00182 /* --------------- [ MACI DLL support functions ] -----------------*/ 00183 #include <maciACSComponentDefines.h> 00184 MACI_DLL_SUPPORT_FUNCTIONS(Lamp) 00185 /* ----------------------------------------------------------------*/ 00186