• Classes
  • Modules
  • Namespaces
  • Files
  • Related Pages
  • File List
  • File Members

baciMonitor_T.h

Go to the documentation of this file.
00001 #ifndef baciMonitor_T_H
00002 #define baciMonitor_T_H
00003 
00004 /*******************************************************************************
00005 * ALMA - Atacama Large Millimiter Array
00006 * (c) European Southern Observatory, 2003 
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, MA 02111-1307  USA
00021 *
00022 * "@(#) $Id: baciMonitor_T.h,v 1.107 2012/01/04 12:51:41 rtobar Exp $"
00023 *
00024 * who       when      what
00025 * --------  --------  ----------------------------------------------
00026 * oat 2003-01-21 added templates for Monitors
00027 */
00028 
00034 #ifndef __cplusplus
00035 #error This is a C++ include file and cannot be used from plain C
00036 #endif
00037 
00038 #include <acsutil.h>
00039 #include <ace/SString.h>
00040 #include <baci.h>
00041 #include <baciS.h>
00042 #include <logging.h>
00043 #include <baciRecovery.h>
00044 #include <baciRecoverableObject.h>
00045 #include <Basic_Types.h> // for ACE_UINT64_FORMAT_SPECIFIER_ASCII
00046 
00047 
00048 namespace baci {
00049 
00050 #ifdef MAKE_VXWORKS
00051 unsigned long long convString2LLU(char *);
00052 char *printLLUasString(unsigned long long); 
00053 #endif
00054 
00055 #ifdef MAKE_VXWORKS
00056 #define HEADER_PRINT_GET_OBJECT_STATE \
00057       ACE_OS::sprintf(buffer_p, "%s %s %lu %s %s %s %s %d %u %u", \
00058                       getName(), ior.in(), \
00059                       printLLUasString(tag), \
00060                       printLLUasString(bcb_p->getDescIn().normal_timeout), \
00061                       printLLUasString(monitor_mp->getTransmitTime()), \
00062                       monitor_mp->getTriggerTime(), \
00063                       valueTrigger.c_str(), \
00064                       monitor_mp->getUpdateMode(), monitor_mp->getTriggerOnValue(), \
00065                       monitor_mp->isSuspended());
00066 #else
00067 
00070 #define HEADER_PRINT_GET_OBJECT_STATE \
00071       ACE_OS::sprintf(buffer_p, "%s %s %lu %llu %llu %llu %s %d %u %u", \
00072                       getName(), ior.in(), tag, bcb_p->getDescIn().normal_timeout, \
00073                       monitor_mp->getTransmitTime(), monitor_mp->getTriggerTime(), \
00074                       valueTrigger.c_str(), \
00075                       monitor_mp->getUpdateMode(), monitor_mp->getTriggerOnValue(), \
00076                       monitor_mp->isSuspended());
00077 #endif
00078  
00079 #ifdef MAKE_VXWORKS
00080 #define IMPL_PRINT_GET_OBJECT_STATE \
00081       ACE_OS::sprintf(buffer_p, "%s %s %lu %s %s %s %d %u", \
00082                       getName(), ior.in(), \
00083                       printLLUasString(tag), \
00084                       printLLUasString(bcb_p->getDescIn().normal_timeout), \
00085                       monitor_mp->getTransmitTime(), \
00086                       printLLUasString(monitor_mp->getTriggerTime()), \
00087                       monitor_mp->getUpdateMode(), \
00088                       monitor_mp->isSuspended());
00089 #else
00090 
00093 #define IMPL_PRINT_GET_OBJECT_STATE \
00094       ACE_OS::sprintf(buffer_p, "%s %s %lu %llu %llu %llu %d %u", \
00095                       getName(), ior.in(), tag, bcb_p->getDescIn().normal_timeout, \
00096                       monitor_mp->getTransmitTime(), \
00097                       monitor_mp->getTriggerTime(), \
00098                       monitor_mp->getUpdateMode(), \
00099                       monitor_mp->isSuspended());
00100 #endif
00101 
00102 #ifdef MAKE_VXWORKS
00103 #define HEADER_SCAN_SET_OBJECT_STATE \
00104   char *tmpPtr1, *tmpPtr2, *tmpPtr3; \
00105   sscanf(state, "%s %s %lu %s %s %s %s %d %u %u", \
00106          cname, ior, &tag, \
00107          tmpPtr1, \
00108          tmpPtr2, \
00109          tmpPtr3, \
00110          valueTrigger, &mode, \
00111          &triggerOnValue, &isSuspended); \
00112   descIn.normal_timeout =  convString2LLU(tmpPtr1); \
00113   transmitTime = convString2LLU(tmpPtr2); \
00114   timeTrigger  = convString2LLU(tmpPtr3);
00115 #else
00116 
00119 #define HEADER_SCAN_SET_OBJECT_STATE \
00120   sscanf(state, "%s %s %lu "ACE_UINT64_FORMAT_SPECIFIER_ASCII" "ACE_UINT64_FORMAT_SPECIFIER_ASCII" "ACE_UINT64_FORMAT_SPECIFIER_ASCII" %s %d %u %u", \
00121          cname, ior, &tag, &descIn.normal_timeout, \
00122          &transmitTime, &timeTrigger, valueTrigger, &mode, \
00123          &triggerOnValue, &isSuspended);
00124 #endif
00125  
00126 #ifdef MAKE_VXWORKS
00127 #define IMPL_SCAN_SET_OBJECT_STATE \
00128   char *tmpPtr1, *tmpPtr2, *tmpPtr3; \
00129   sscanf(state, "%s %s %lu %s %s %s %d %u", \
00130          cname, ior, &tag, \
00131          tmpPtr1, \
00132          tmpPtr2, \
00133          tmpPtr3, \
00134          &mode, \
00135          &isSuspended); \
00136   descIn.normal_timeout =  convString2LLU(tmpPtr1); \
00137   transmitTime = convString2LLU(tmpPtr2); \
00138   timeTrigger  = convString2LLU(tmpPtr3);
00139 #else
00140 
00143 #define IMPL_SCAN_SET_OBJECT_STATE \
00144   sscanf(state, "%s %s %lu %llu %llu %llu %d %u", \
00145          cname, ior, &tag, &descIn.normal_timeout, \
00146          &transmitTime, &timeTrigger, &mode, \
00147          &isSuspended);
00148 #endif
00149 
00153 #define MAX_VALUE_LENGTH 500
00154 
00158 #define ACS_MONITOR_C class TCORBA, class TCORBA_out, class TCB, class TPOA, baci::BACIValue::Type TBACIValuetype
00159 
00162 #define ACS_MONITOR_T TCORBA, TCORBA_out, TCB, TPOA, TBACIValuetype
00163 
00167 #define ACS_MONITOR_SEQ(T,TCORBA)  TCORBA, TCORBA##_out, ACS::CB##T##Seq, POA_ACS::Monitor##T, baci::BACIValue::type_##T##Seq
00168 
00171 #define ACS_MONITOR(T,TCORBA)  TCORBA, TCORBA##_out, ACS::CB##T, POA_ACS::Monitor##T, baci::BACIValue::type_##T
00172 
00173 template <ACS_MONITOR_C>
00174 class baci_EXPORT Monitor: public virtual PortableServer::RefCountServantBase,
00175                        public TPOA,
00176                        public RecoverableObject,
00177                        public MonitorImplementator
00178 {
00179 public:
00180 
00181   Monitor(ACE_CString name,
00182           const ACS::TimeInterval& minTriggerTime,
00183           const baci::BACIValue& minTriggerValue,
00184           BACIProperty* property);
00185 
00186   Monitor(ACE_CString name,
00187           Callback_ptr callback_p, const CBDescIn& inDesc,
00188           const ACS::TimeInterval& triggerTime,
00189           const baci::BACIValue& triggerValue,
00190           const ACS::TimeInterval& minTriggerTime,
00191           const baci::BACIValue& minTriggerValue,
00192           BACIProperty* property,
00193           const ACS::TimeInterval& transmitTime = 0,
00194           const BACIMonitor::UpdateMode& updateMode=BACIMonitor::mumLast);
00195 
00196   virtual ~Monitor();
00197 
00198   virtual int initialization()
00199   {
00200         return initialization_m;
00201   }
00202 
00203   CORBA::Object_ptr getCORBAReference() const
00204   {
00205     return reference_mp;
00206   }
00207 
00208   BACIMonitor* getMonitor() const
00209   {
00210     return monitor_mp;
00211   }
00212 
00213   virtual int getId(void);
00214   virtual const char* getName(void);
00215   virtual const char* getObjectState(void);
00216   virtual void setObjectState(const char * state);
00217 
00218   virtual void setObjectState(const char * state,
00219                       const ACS::TimeInterval& minTriggerTime,
00220                       const baci::BACIValue& minTriggerValue,
00221                       BACIProperty * property);
00222 
00223 
00224   virtual void monitorDestroyed(void);
00225 
00226   virtual void monitorStateChanged(void);
00227 
00228 
00229   virtual void suspend ();
00230 
00231   virtual void resume ();
00232 
00233   virtual void destroy ();
00234 
00235   virtual void set_timer_trigger (ACS::TimeInterval timer);
00236 
00237   virtual void get_timer_trigger (ACS::TimeInterval_out timer);
00238 
00239   virtual void set_value_trigger (TCORBA delta, CORBA::Boolean enable);
00240   
00241   virtual void get_value_trigger (TCORBA_out delta, CORBA::Boolean_out enable);
00242 
00243   virtual void set_value_percent_trigger (CORBA::Double delta, CORBA::Boolean enable);
00244   
00245   virtual void get_value_percent_trigger (CORBA::Double_out delta, CORBA::Boolean_out enable);
00246 
00247   virtual ACS::Time start_time ();
00248 
00249 private:
00250  
00251   int initialization_m;
00252 
00253   BACIMonitor* monitor_mp;
00254 
00255   CORBA::Object_ptr reference_mp;
00256 
00260     void operator=(const Monitor&);
00261     
00265     Monitor(const Monitor&);
00266 
00267 };
00268 
00272 #define ACS_MONITOR_BASIC_C class TCORBA, class TCORBA_out, class TCB, class TPOA, baci::BACIValue::Type TBACIValuetype
00273 
00276 #define ACS_MONITOR_BASIC_T TCORBA, TCORBA_out, TCB, TPOA, TBACIValuetype
00277 
00278 template<ACS_MONITOR_BASIC_C>
00279 class baci_EXPORT MonitorBasic: public virtual PortableServer::RefCountServantBase,
00280                        public POA_ACS::Monitor,
00281                        public RecoverableObject,
00282                        public MonitorImplementator
00283 {
00284 
00285 public:
00286 
00287   MonitorBasic(ACE_CString name,
00288           const ACS::TimeInterval& minTriggerTime,
00289           const baci::BACIValue& minTriggerValue,
00290           BACIProperty* property);
00291 
00292   MonitorBasic(ACE_CString name,
00293           Callback_ptr callback_p, const CBDescIn& inDesc,
00294           const ACS::TimeInterval& triggerTime,
00295           const baci::BACIValue& triggerValue,
00296           const ACS::TimeInterval& minTriggerTime,
00297           const baci::BACIValue& minTriggerValue,
00298           BACIProperty* property,
00299           const ACS::TimeInterval& transmitTime = 0,
00300           const BACIMonitor::UpdateMode& updateMode=BACIMonitor::mumLast);
00301 
00302   virtual ~MonitorBasic();
00303 
00304   virtual int initialization()
00305   {
00306         return initialization_m;
00307   }
00308 
00309   CORBA::Object_ptr getCORBAReference() const
00310   {
00311     return reference_mp;
00312   }
00313 
00314   BACIMonitor* getMonitor() const
00315   {
00316     return monitor_mp;
00317   }
00318 
00319 
00320   virtual int getId(void);
00321   virtual const char* getName(void);
00322   virtual const char* getObjectState(void);
00323   virtual void setObjectState(const char * state);
00324 
00325   virtual void setObjectState(const char * state,
00326                       const ACS::TimeInterval& minTriggerTime,
00327                       BACIProperty * property);
00328 
00329 
00330   virtual void monitorDestroyed(void);
00331 
00332   virtual void monitorStateChanged(void);
00333 
00334 
00335   virtual void suspend ();
00336 
00337   virtual void resume ();
00338 
00339   virtual void destroy ();
00340 
00341   virtual void set_timer_trigger (ACS::TimeInterval timer);
00342 
00343   virtual void get_timer_trigger (ACS::TimeInterval_out timer);
00344 
00345   virtual ACS::Time start_time ();
00346 
00347 private:
00348 
00349   int initialization_m;
00350 
00351   BACIMonitor* monitor_mp;
00352 
00353   CORBA::Object_ptr reference_mp;
00354 
00358     void operator=(const MonitorBasic&);
00359     
00363     MonitorBasic(const MonitorBasic&);
00364 
00365 };
00366 
00367  }; 
00368 
00369 #endif   /* baciMonitorTempl_H */
00370 
00371 
00372 
00373 
00374 
00375 

Generated on Mon May 4 2015 08:27:42 for ACS-2015.4 C++ API by  doxygen 1.7.0