00001 #ifndef _baciPcommonImpl_T_H_
00002 #define _baciPcommonImpl_T_H_
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00037 #ifndef __cplusplus
00038 #error This is a C++ include file and cannot be used from plain C
00039 #endif
00040
00041 #include "baciDB.h"
00042 #include <acsutil.h>
00043 #include <baci.h>
00044 #include <baciS.h>
00045 #include <baciCORBA.h>
00046 #include <baciCORBAMem.h>
00047 #include <baciEvent.h>
00048 #include <baciDevIOMem.h>
00049 #include <baciCharacteristicModelImpl.h>
00050 #include <ACSErrTypeCommon.h>
00051 #include <ACSErrTypeDevIO.h>
00052 #include <baciErrTypeProperty.h>
00053 #include <baciErrTypeDevIO.h>
00054
00060 #define HISTORY_SIZE 32
00061
00064
00068 #define ACS_P_T(T, TC) TC, ACS::CB##T, ACS::T##Seq, ACS::T##Seq_out, ACS::Monitor##T, baci::Monitor##T,TC, TC, TC
00069
00070
00071
00072
00076 #define ACS_P_TL T, TCB, TSeq, TSeq_out, TMonitor, TMonitorImpl, TM, TS, TSM, POA_SK
00077
00081 #define ACS_P_C class T, class TCB, class TSeq, class TSeq_out, class TMonitor, class TMonitorImpl, class TM, class TS, class TSM, class POA_SK
00082
00083
00084 namespace baci {
00085
00086
00093 class CheckDevIOValue
00094 {
00095 public:
00096 CheckDevIOValue(const ACE_CString& n){ propName_m = n;}
00097
00098 template <class T>
00099 void checkValue(T value);
00100 private:
00101 ACE_CString propName_m;
00102 };
00103
00107 template <class T>
00108 class CDBconverter
00109 {
00110 public:
00111 static void convertValue(const char *str, T& v)
00112 {
00113 std::istringstream is(str);
00114 (istream&) is >> v;
00115 if (!is)
00116 throw cdbErrType::WrongCDBDataTypeExImpl(__FILE__, __LINE__, "CDBconverter::converterValue");
00117 }
00118 };
00119
00120 template<>
00121 class CDBconverter<ACE_CString>
00122 {
00123 public:
00124 static void convertValue(const char *s, ACE_CString& v)
00125 {
00126 v = (const char*)s;
00127 }
00128 };
00129
00130 template<>
00131 class CDBconverter<CORBA::Boolean>
00132 {
00133 public:
00134 static void convertValue(const char *str, CORBA::Boolean& v)
00135 {
00136 std::istringstream is(str);
00137 (istream&) is >> v;
00138 if (!is) {
00139 std::istringstream is2(str);
00140 (istream&) is2 >> std::boolalpha >> v;
00141 if(!is2)
00142 throw cdbErrType::WrongCDBDataTypeExImpl(__FILE__, __LINE__, "CDBconverter::converterValue");
00143 }
00144
00145 }
00146 };
00147
00153 template<ACS_P_C>
00154 class baci_EXPORT PcommonImpl: public virtual POA_SK,
00155 public CharacteristicModelImpl,
00156 public PropertyImplementator,
00157 public ActionImplementator
00158 {
00159
00160
00161 public:
00167 PcommonImpl(const ACE_CString& name, BACIComponent *component_p, DevIO<TM> *devIO, bool flagdeldevIO);
00168
00172 virtual ~PcommonImpl();
00173
00174
00175
00176
00177
00178
00179
00180 virtual int initialization() { return initialization_m; }
00181
00186 CORBA::Object_ptr getCORBAReference() const { return reference_mp; }
00187
00191 BACIProperty* getProperty() const { return property_mp; }
00192
00193 virtual void publishNow();
00194
00201 virtual void destroy();
00202
00206 DevIO<TM>* getDevIO() const { return devIO_mp; }
00207
00208
00209
00210
00211 virtual ActionRequest getValueAction(BACIComponent* component_p,
00212 int callbackID,
00213 const CBDescIn& descIn,
00214 BACIValue* value,
00215 Completion& completion,
00216 CBDescOut& descOut);
00217
00218
00219
00220
00238 virtual ActionRequest invokeAction(int function,
00239 BACIComponent* component_p,
00240 const int &callbackID,
00241 const CBDescIn& descIn,
00242 BACIValue* value,
00243 Completion& completion,
00244 CBDescOut& descOut);
00245
00246
00247
00255 virtual void getValue(BACIProperty* property,
00256 BACIValue* value,
00257 Completion &completion,
00258 CBDescOut& descOut);
00259
00260
00261
00262
00263
00264
00265
00266 virtual char * name ();
00267
00268 virtual char * characteristic_component_name ();
00269
00270
00271
00272
00273
00274
00275
00276
00277 virtual CORBA::Boolean initialize_devio ();
00278
00279 virtual char * description ();
00280
00281 virtual char * format ();
00282
00283 virtual char * units ();
00284
00285 virtual ACS::pattern resolution ();
00286
00287 virtual void publish_now();
00288
00289
00290
00291 virtual ACS::TimeInterval default_timer_trigger ();
00292
00293 virtual ACS::TimeInterval min_timer_trigger ();
00294
00295 virtual TS default_value ();
00296
00297 virtual T get_sync (ACSErr::Completion_out c);
00298
00299 virtual void get_async (TCB *cb,
00300 const ACS::CBDescIn & desc);
00301
00302 virtual CORBA::Long get_history (CORBA::Long n_last_values,
00303 TSeq_out vs,
00304 ACS::TimeSeq_out ts);
00305
00306 virtual TMonitor* create_monitor (TCB*cb,
00307 const ACS::CBDescIn & desc);
00308
00309 virtual TMonitor* create_postponed_monitor (ACS::Time start_time,
00310 TCB *cb,
00311 const ACS::CBDescIn & desc);
00312
00313 protected:
00314
00320 virtual bool readCharacteristics();
00321
00322
00323
00324 void addValueToHistory(ACS::Time time, TM &value);
00325
00326
00328 CheckDevIOValue checkDevIOValue_m;
00329
00331 BACIProperty* property_mp;
00332
00333 DevIO<TM> *devIO_mp;
00334 bool deldevIO_m;
00335 TM value_m;
00336
00338 int initialization_m;
00339
00352 typedef ActionRequest (PcommonImpl<ACS_P_TL>::*ActionFunction)(BACIComponent* component_p,
00353 int callbackID,
00354 const CBDescIn& descIn,
00355 BACIValue* value,
00356 ACSErr::Completion& completion,
00357 CBDescOut& descOut);
00360
00361 bool destroyed_m;
00362
00364 CORBA::Object_ptr reference_mp;
00365
00367 TM historyValue_m[HISTORY_SIZE];
00368
00370 ACS::Time historyTime_m[HISTORY_SIZE];
00371
00373 int historyStart_m;
00374
00376 bool historyTurnaround_m;
00377
00381
00382 bool initializeDevIO_m;
00383
00384 ACE_CString description_m;
00385 ACE_CString format_m;
00386 ACE_CString units_m;
00387 ACS::pattern resolution_m;
00388
00389
00390 TSM defaultValue_m;
00391 ACS::TimeInterval defaultTimerTrig_m;
00392 ACS::TimeInterval minTimerTrig_m;
00393
00394 private:
00398 void operator=(const PcommonImpl&);
00399
00403 PcommonImpl(const PcommonImpl&);
00404 };
00405
00406
00407
00408 };
00409
00410 #endif
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433