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
00089 template <class T>
00090 class CDBconverter
00091 {
00092 public:
00093 static void convertValue(const char *str, T& v)
00094 {
00095 std::istringstream is(str);
00096 (istream&) is >> v;
00097 if (!is)
00098 throw cdbErrType::WrongCDBDataTypeExImpl(__FILE__, __LINE__, "CDBconverter::converterValue");
00099 }
00100 };
00101
00102 template<>
00103 class CDBconverter<ACE_CString>
00104 {
00105 public:
00106 static void convertValue(const char *s, ACE_CString& v)
00107 {
00108 v = (const char*)s;
00109 }
00110 };
00111
00117 template<ACS_P_C>
00118 class baci_EXPORT PcommonImpl: public virtual POA_SK,
00119 public CharacteristicModelImpl,
00120 public PropertyImplementator,
00121 public ActionImplementator
00122 {
00123
00124
00125 public:
00131 PcommonImpl(const ACE_CString& name, BACIComponent *component_p, DevIO<TM> *devIO, bool flagdeldevIO);
00132
00136 virtual ~PcommonImpl();
00137
00138
00139
00140
00141
00142
00143
00144 virtual int initialization() { return initialization_m; }
00145
00150 CORBA::Object_ptr getCORBAReference() const { return reference_mp; }
00151
00155 BACIProperty* getProperty() const { return property_mp; }
00156
00157 virtual void publishNow();
00158
00165 virtual void destroy();
00166
00170 DevIO<TM>* getDevIO() const { return devIO_mp; }
00171
00172
00173
00174
00175 virtual ActionRequest getValueAction(BACIComponent* component_p,
00176 int callbackID,
00177 const CBDescIn& descIn,
00178 BACIValue* value,
00179 Completion& completion,
00180 CBDescOut& descOut);
00181
00182
00183
00184
00202 virtual ActionRequest invokeAction(int function,
00203 BACIComponent* component_p,
00204 const int &callbackID,
00205 const CBDescIn& descIn,
00206 BACIValue* value,
00207 Completion& completion,
00208 CBDescOut& descOut);
00209
00210
00211
00219 virtual void getValue(BACIProperty* property,
00220 BACIValue* value,
00221 Completion &completion,
00222 CBDescOut& descOut);
00223
00224
00225
00226
00227
00228
00229
00230 virtual char * name ();
00231
00232 virtual char * characteristic_component_name ();
00233
00234
00235
00236
00237
00238
00239
00240
00241 virtual CORBA::Boolean initialize_devio ();
00242
00243 virtual char * description ();
00244
00245 virtual char * format ();
00246
00247 virtual char * units ();
00248
00249 virtual ACS::pattern resolution ();
00250
00251
00252
00253 virtual ACS::TimeInterval default_timer_trigger ();
00254
00255 virtual ACS::TimeInterval min_timer_trigger ();
00256
00257 virtual TS default_value ();
00258
00259 virtual T get_sync (ACSErr::Completion_out c);
00260
00261 virtual void get_async (TCB *cb,
00262 const ACS::CBDescIn & desc);
00263
00264 virtual CORBA::Long get_history (CORBA::Long n_last_values,
00265 TSeq_out vs,
00266 ACS::TimeSeq_out ts);
00267
00268 virtual TMonitor* create_monitor (TCB*cb,
00269 const ACS::CBDescIn & desc);
00270
00271 virtual TMonitor* create_postponed_monitor (ACS::Time start_time,
00272 TCB *cb,
00273 const ACS::CBDescIn & desc);
00274
00275 protected:
00276
00282 virtual bool readCharacteristics();
00283
00284
00285
00286 void addValueToHistory(ACS::Time time, TM &value);
00287
00289 BACIProperty* property_mp;
00290
00291 DevIO<TM> *devIO_mp;
00292 bool deldevIO_m;
00293 TM value_m;
00294
00296 int initialization_m;
00297
00310 typedef ActionRequest (PcommonImpl<ACS_P_TL>::*ActionFunction)(BACIComponent* component_p,
00311 int callbackID,
00312 const CBDescIn& descIn,
00313 BACIValue* value,
00314 ACSErr::Completion& completion,
00315 CBDescOut& descOut);
00318
00319 bool destroyed_m;
00320
00322 CORBA::Object_ptr reference_mp;
00323
00325 TM historyValue_m[HISTORY_SIZE];
00326
00328 ACS::Time historyTime_m[HISTORY_SIZE];
00329
00331 int historyStart_m;
00332
00334 bool historyTurnaround_m;
00335
00339
00340 bool initializeDevIO_m;
00341
00342 ACE_CString description_m;
00343 ACE_CString format_m;
00344 ACE_CString units_m;
00345 ACS::pattern resolution_m;
00346
00347
00348 TSM defaultValue_m;
00349 ACS::TimeInterval defaultTimerTrig_m;
00350 ACS::TimeInterval minTimerTrig_m;
00351
00352 private:
00356 void operator=(const PcommonImpl&);
00357
00361 PcommonImpl(const PcommonImpl&);
00362 };
00363
00364
00365
00366 };
00367
00368 #endif
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391