ALMA Computing Group

acsexmplAmsSeqImpl.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: acsexmplAmsSeqImpl.cpp,v 1.112 2008/10/09 08:41:11 cparedes Exp $" 00024 * 00025 * who when what 00026 * -------- -------- ---------------------------------------------- 00027 * david 2002-08-13 changed instances of getCOB() to m_cob 00028 * david 2002-08-08 made SETCOEFF_ACTION a const static instead of a define 00029 * naoj 2002-04-14 created 00030 */ 00031 00032 #include <acsexmplAmsSeqImpl.h> 00033 #include <ACSErrTypeOK.h> 00034 00035 ACE_RCSID(acsexmpl, acsexmplAmsSeqImpl, "$Id: acsexmplAmsSeqImpl.cpp,v 1.112 2008/10/09 08:41:11 cparedes Exp $") 00036 using namespace baci; 00037 00039 // AMS 00041 00042 AmsTestSeq::AmsTestSeq( 00043 const ACE_CString &name, 00044 maci::ContainerServices * containerServices) : 00045 CharacteristicComponentImpl(name, containerServices), 00046 m_RWdoubleSeqPM_p(0), 00047 m_ROdoubleSeqPM_p(0) 00048 { 00049 ACS_TRACE("::AmsTestSeq::AmsTestSeq"); 00050 00051 // Create the Properties 00052 // the property's name must be composed of the server's name and the 00053 // property name. 00054 m_RWdoubleSeqPM_p = new RWdoubleSeq(name+":RWdoubleSeqPM", getComponent()); 00055 // if this property wasn't created properly, we destroy it and all 00056 // of this component's previous properties 00057 CHARACTERISTIC_COMPONENT_PROPERTY(RWdoubleSeqPM, m_RWdoubleSeqPM_p); 00058 00059 m_ROdoubleSeqPM_p = new ROdoubleSeq(name+":ROdoubleSeqPM", getComponent()); 00060 CHARACTERISTIC_COMPONENT_PROPERTY(ROdoubleSeqPM, m_ROdoubleSeqPM_p); 00061 } 00063 void 00064 AmsTestSeq::execute() 00065 { 00066 ACS::Time timestamp; 00067 00068 // Set default values to properties 00069 // N.B. number of elements never mean to be fixed to 12, just an exmample. 00070 ACS::doubleSeq_var initialCoeffValue = new ACS::doubleSeq; 00071 initialCoeffValue->length(12); 00072 for( int i = 0 ; i < 12 ; i++) 00073 { 00074 initialCoeffValue[i]=static_cast<double>(i); 00075 } 00076 // set_sync is used to RW properties while getDevIO() must be used for RO properties 00077 m_RWdoubleSeqPM_p->set_sync(initialCoeffValue.in()); 00078 m_ROdoubleSeqPM_p->getDevIO()->write(initialCoeffValue.in(), timestamp); 00079 00080 } 00082 00083 AmsTestSeq::~AmsTestSeq() 00084 { 00085 ACS_TRACE("::AmsTestSeq::~AmsTestSeq"); 00086 00087 // This is in principle not necessary, since is done in cleanUp() 00088 // but we keep it here just to make sure it is done in any case, 00089 // also is cleanUp() is for any reason not called or if the 00090 // developer forgets to call the parent's class cleanUp(). 00091 if (getComponent() != 0) 00092 { 00093 ACS_DEBUG_PARAM("::AmsTestSeq::~AmsTestSeq", "Destroying %s...", getComponent()->getName()); 00094 } 00095 00096 // properties 00097 if (m_RWdoubleSeqPM_p != 0) 00098 { 00099 m_RWdoubleSeqPM_p->destroy(); 00100 m_RWdoubleSeqPM_p=0; 00101 } 00102 if (m_ROdoubleSeqPM_p != 0) 00103 { 00104 m_ROdoubleSeqPM_p->destroy(); 00105 m_ROdoubleSeqPM_p=0; 00106 } 00107 00108 ACS_DEBUG("::AmsTestSeq::~AmsTestSeq", "Properties destroyed"); 00109 } 00110 /* ----------------------------------------------------------------*/ 00111 /* --------------------- [ CORBA interface ] ----------------------*/ 00112 /* ----------------------------------------------------------------*/ 00113 void 00114 AmsTestSeq::setCoeff () 00115 { 00116 ACS::Time timestamp; 00117 ACSErr::Completion_var completion; 00118 00119 try 00120 { 00121 ACS_DEBUG_PARAM("::AmsTestSeq::setCoeffAction", "%s", getComponent()->getName()); 00122 ACS_SHORT_LOG( ( LM_INFO, "setCoeffAction!" ) ); 00123 00127 /* Just synchronously reading the value of PM */ 00128 ACS::doubleSeq_var valValue = m_RWdoubleSeqPM_p->get_sync(completion.out()); 00129 if (valValue.ptr() == 0) 00130 { 00131 ACS_SHORT_LOG((LM_INFO,"acsexmplAmsSeq: .. null value returned.")); 00132 } 00133 else 00134 { 00135 ACS_SHORT_LOG((LM_INFO,"acsexmplAmsSeq: .. final value is (length %u):", valValue->length())); 00136 m_ROdoubleSeqPM_p->getDevIO()->write(valValue.in(), timestamp); 00137 } 00138 } 00139 catch(...) 00140 { 00141 ACS_SHORT_LOG((LM_ERROR,"::AmsTestSeq::setCoeffAction")); 00142 } 00143 } 00145 ACS::RWdoubleSeq_ptr 00146 AmsTestSeq::RWdoubleSeqPM () 00147 { 00148 if (m_RWdoubleSeqPM_p == 0) 00149 { 00150 return ACS::RWdoubleSeq::_nil(); 00151 } 00152 00153 ACS::RWdoubleSeq_var prop = ACS::RWdoubleSeq::_narrow(m_RWdoubleSeqPM_p->getCORBAReference()); 00154 return prop._retn(); 00155 } 00157 ACS::ROdoubleSeq_ptr 00158 AmsTestSeq::ROdoubleSeqPM () 00159 { 00160 if (m_ROdoubleSeqPM_p == 0) 00161 { 00162 return ACS::ROdoubleSeq::_nil(); 00163 } 00164 00165 ACS::ROdoubleSeq_var prop = ACS::ROdoubleSeq::_narrow(m_ROdoubleSeqPM_p->getCORBAReference()); 00166 return prop._retn(); 00167 } 00169 // MACI DLL support functions 00171 #include <maciACSComponentDefines.h> 00172 MACI_DLL_SUPPORT_FUNCTIONS(AmsTestSeq) 00173 00174 00175