ALMA Computing Group

acsexmplTestMemory.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: acsexmplTestMemory.cpp,v 1.88 2005/09/21 13:15:22 vwang Exp $" 00024 * 00025 * who when what 00026 * -------- -------- ---------------------------------------------- 00027 * david 2002-06-17 fixed client.init(argc,argv) 00028 * gchiozzi 2002-02-13 created 00029 */ 00030 00042 #include <acsutil.h> 00043 00044 #include <maciSimpleClient.h> 00045 #include <acsexmplMountC.h> 00046 #include <acsutil.h> 00047 00048 using namespace maci; 00049 00050 /* 00051 * The test main creates two loops that run in parallel threads 00052 */ 00053 int main(int argc, char **argv) 00054 { 00055 int repeat[3] = { 1, 1, 1 }; 00056 00057 /* 00058 * Checks command line arguments. 00059 * We need the name of the component to get in touch with. 00060 */ 00061 if (argc < 5) 00062 { 00063 ACS_SHORT_LOG((LM_INFO, "Usage: %s <Mount name> <# get_object> " 00064 "<# mount->actAz> <# get_sync> <options>", argv[0])); 00065 return -1; 00066 } 00067 00068 /* 00069 * Creates and initialyses the SimpleClient object 00070 */ 00071 SimpleClient client; 00072 00073 if (client.init(argc,argv) == 0) 00074 { 00075 ACE_DEBUG((LM_DEBUG,"Cannot init client")); 00076 return -1; 00077 } 00078 ACS_SHORT_LOG((LM_INFO, "Wellcome to %s!", argv[0])); 00079 ACS_SHORT_LOG((LM_INFO, "Login into maciManager!")); 00080 client.login(); 00081 00082 00083 00084 try 00085 { 00089 repeat[0] = atoi(argv[2]); 00090 repeat[1] = atoi(argv[3]); 00091 repeat[2] = atoi(argv[4]); 00092 00093 ACS_SHORT_LOG ((LM_INFO, "Command line options:")); 00094 ACS_SHORT_LOG ((LM_INFO, "\t# get_object : %d",repeat[0])); 00095 ACS_SHORT_LOG ((LM_INFO, "\t# mount->actAz: %d",repeat[1])); 00096 ACS_SHORT_LOG ((LM_INFO, "\t# get_sync : %d",repeat[2])); 00097 00098 00102 CORBA::Object_var object; 00103 MOUNT_ACS::Mount_var mDev; 00104 for(int i=0; i<repeat[0]; i++) 00105 { 00106 object = client.get_object(argv[1],"",true); 00107 00108 ACS_SHORT_LOG((LM_INFO,"Got object")); 00109 00110 if (CORBA::is_nil(object.in()) ) 00111 { 00112 ACS_SHORT_LOG ((LM_INFO, "Cannot get Object")); 00113 return -1; 00114 } 00115 00116 mDev = MOUNT_ACS::Mount::_narrow(object.in ()); 00117 00118 ACS_SHORT_LOG((LM_INFO, "MOUNT device narrowed")); 00119 if( CORBA::is_nil(mDev.in()) ) 00120 { 00121 ACS_SHORT_LOG((LM_INFO, "Failed to narrow Device :-(")); 00122 return -2; 00123 } 00124 ACS_SHORT_LOG((LM_INFO, "Device narrowed.")); 00125 } 00126 00127 00128 /* 00129 * Get a reference to the property 00130 */ 00131 00132 ACS::ROdouble_var ROactAz; 00133 for(int i=0; i<repeat[1]; i++) 00134 { 00135 ROactAz = mDev->actAz(); 00136 00137 ACS_SHORT_LOG((LM_INFO," Got property..")); 00138 } 00139 00140 /* 00141 * Now get its value 00142 */ 00143 ACSErr::Completion_var c; 00144 double actAz; 00145 for(int i=0; i<repeat[2]; i++) 00146 { 00147 actAz = ROactAz->get_sync(c); 00148 ACS_SHORT_LOG((LM_INFO," Property value = %6.3f",actAz)); 00149 } 00150 00151 /* 00152 * Now release the component 00153 */ 00154 ACS_SHORT_LOG((LM_INFO,"Releasing...")); 00155 client.manager()->release_component(client.handle(), argv[1]); 00156 00157 00158 } 00159 catch( CORBA::Exception &ex ) 00160 { 00161 ACE_PRINT_EXCEPTION (ex,"Error!"); 00162 return -1; 00163 } 00164 00165 ACS_SHORT_LOG((LM_INFO,"The end")); 00166 00167 return 0; 00168 } 00169 00170 00171 00172 00173 00174