try to make things work on 64 bit systems
Annotate for file src/pv/pv.h
2010-02-26 benjamin.fra 1 /* pv.h,v 1.3 2001/02/16 18:45:39 mrk Exp
2000-04-04 William 2 *
03:23:15 ' 3 * Definitions for EPICS sequencer message system-independent library (pv)
' 4 * (NB, "pv" = "process variable").
' 5 *
' 6 * This is a simple layer which is specifically designed to provide the
' 7 * facilities needed by the EPICS sequencer. Specific message systems are
' 8 * expected to inherit from the pv classes.
' 9 *
' 10 * William Lupton, W. M. Keck Observatory
' 11 */
' 12
' 13 #ifndef INCLpvh
' 14 #define INCLpvh
' 15
2011-04-06 ben.franksen 16 #include "shareLib.h" /* reset share lib defines */
18:59:29 ' 17 #include "epicsTypes.h" /* for thread ids */
2001-02-16 Marty 18 #include "epicsThread.h" /* for thread ids */
18:45:42 ' 19 #include "epicsMutex.h" /* for locks */
' 20 #include "epicsTime.h" /* for time stamps */
2000-04-04 William 21
03:23:15 ' 22 #include "pvAlarm.h" /* status and severity definitions */
' 23
' 24 /*
' 25 * Standard FALSE and TRUE macros
' 26 */
' 27 #ifndef FALSE
' 28 #define FALSE 0
' 29 #endif
' 30
' 31 #ifndef TRUE
' 32 #define TRUE 1
' 33 #endif
' 34
' 35 /*
' 36 * Magic number for validating structures / versions
' 37 */
' 38 #define PV_MAGIC 0xfeddead /* ...a sad tale of food poisoning? */
' 39
' 40 /*
' 41 * Enum for data types (very restricted set of types)
' 42 */
' 43 typedef enum {
' 44 pvTypeERROR = -1,
' 45 pvTypeCHAR = 0,
' 46 pvTypeSHORT = 1,
' 47 pvTypeLONG = 2,
' 48 pvTypeFLOAT = 3,
' 49 pvTypeDOUBLE = 4,
' 50 pvTypeSTRING = 5,
' 51 pvTypeTIME_CHAR = 6,
' 52 pvTypeTIME_SHORT = 7,
' 53 pvTypeTIME_LONG = 8,
' 54 pvTypeTIME_FLOAT = 9,
' 55 pvTypeTIME_DOUBLE = 10,
' 56 pvTypeTIME_STRING = 11
' 57 } pvType;
' 58
' 59 #define PV_SIMPLE(_type) ( (_type) <= pvTypeSTRING )
' 60
' 61 /*
' 62 * Value-related types (c.f. db_access.h)
' 63 */
2011-04-06 ben.franksen 64 typedef epicsInt8 pvChar;
18:59:29 ' 65 typedef epicsInt16 pvShort;
' 66 typedef epicsInt32 pvLong;
' 67 typedef epicsFloat32 pvFloat;
' 68 typedef epicsFloat64 pvDouble;
' 69 typedef char pvString[256]; /* use sizeof( pvString ) */
2000-04-04 William 70
03:23:15 ' 71 #define PV_TIME_XXX(_type) \
' 72 typedef struct { \
' 73 pvStat status; \
' 74 pvSevr severity; \
2001-02-16 Marty 75 epicsTimeStamp stamp; \
2000-04-04 William 76 pv##_type value[1]; \
03:23:15 ' 77 } pvTime##_type
' 78
' 79 PV_TIME_XXX( Char );
' 80 PV_TIME_XXX( Short );
' 81 PV_TIME_XXX( Long );
' 82 PV_TIME_XXX( Float );
' 83 PV_TIME_XXX( Double );
' 84 PV_TIME_XXX( String );
' 85
' 86 typedef union {
' 87 pvChar charVal[1];
' 88 pvShort shortVal[1];
' 89 pvLong longVal[1];
' 90 pvFloat floatVal[1];
' 91 pvDouble doubleVal[1];
' 92 pvString stringVal[1];
' 93 pvTimeChar timeCharVal;
' 94 pvTimeShort timeShortVal;
' 95 pvTimeLong timeLongVal;
' 96 pvTimeFloat timeFloatVal;
' 97 pvTimeDouble timeDoubleVal;
' 98 pvTimeString timeStringVal;
' 99 } pvValue;
' 100
' 101 #define PV_VALPTR(_type,_value) \
' 102 ( ( PV_SIMPLE(_type) ? ( void * ) ( _value ) : \
' 103 ( void * ) ( &_value->timeCharVal.value ) ) )
' 104
' 105 /*
' 106 * Connect (connect/disconnect and event (get, put and monitor) functions
' 107 */
' 108 typedef void (*pvConnFunc)( void *var, int connected );
' 109
' 110 typedef void (*pvEventFunc)( void *var, pvType type, int count,
' 111 pvValue *value, void *arg, pvStat status );
' 112
' 113 /*
' 114 * Most of the rest is C++. The C interface is at the bottom.
' 115 */
' 116 #ifdef __cplusplus
' 117
' 118 /*
' 119 * Forward references
' 120 */
' 121 class pvVariable;
' 122 class pvCallback;
' 123
' 124 ////////////////////////////////////////////////////////////////////////////////
' 125 /*
' 126 * System
' 127 *
' 128 * This is somewhat analogous to a cdevSystem object (CA has no equivalent)
' 129 */
' 130
' 131 class pvSystem {
' 132
' 133 public:
2000-04-14 Janet 134 epicsShareFunc pvSystem( int debug = 0 );
21:55:19 ' 135 epicsShareFunc virtual ~pvSystem();
2000-04-04 William 136
2000-04-14 Janet 137 epicsShareFunc inline pvSystem *getSystem() { return this; }
2000-04-04 William 138
2000-04-14 Janet 139 epicsShareFunc virtual pvStat attach() { return pvStatOK; }
21:55:19 ' 140 epicsShareFunc virtual pvStat flush() { return pvStatOK; }
' 141 epicsShareFunc virtual pvStat pend( double seconds = 0.0, int wait = FALSE ) = 0;
2000-04-04 William 142
2000-04-14 Janet 143 epicsShareFunc virtual pvVariable *newVariable( const char *name, pvConnFunc func = NULL,
2000-04-04 William 144 void *priv = NULL, int debug = 0 ) = 0;
03:23:15 ' 145
2000-04-14 Janet 146 epicsShareFunc void lock();
21:55:19 ' 147 epicsShareFunc void unlock();
2000-04-04 William 148
2000-04-14 Janet 149 epicsShareFunc inline int getMagic() const { return magic_; }
21:55:19 ' 150 epicsShareFunc inline void setDebug( int debug ) { debug_ = debug; }
' 151 epicsShareFunc inline int getDebug() const { return debug_; }
2000-04-04 William 152
2000-04-14 Janet 153 epicsShareFunc void setError( int status, pvSevr sevr, pvStat stat, const char *mess );
21:55:19 ' 154 epicsShareFunc inline int getStatus() const { return status_; }
' 155 epicsShareFunc inline pvSevr getSevr() const { return sevr_; }
' 156 epicsShareFunc inline pvStat getStat() const { return stat_; }
' 157 epicsShareFunc inline void setStatus( int status ) { status_ = status; }
' 158 epicsShareFunc inline void setStat( pvStat stat ) { stat_ = stat; }
' 159 epicsShareFunc inline char *getMess() const { return mess_?mess_:(char *)""; }
2000-04-04 William 160
03:23:15 ' 161 private:
' 162 int magic_; /* magic number (used for authentication) */
' 163 int debug_; /* debugging level (inherited by pvs) */
' 164
' 165 int status_; /* message system-specific status code */
' 166 pvSevr sevr_; /* severity */
' 167 pvStat stat_; /* status */
' 168 char *mess_; /* error message */
' 169
2001-02-16 Marty 170 epicsMutexId lock_; /* prevents more than one thread in library */
2000-04-04 William 171 };
03:23:15 ' 172
' 173 ////////////////////////////////////////////////////////////////////////////////
' 174 /*
' 175 * Process variable
' 176 *
' 177 * This is somewhat analogous to a cdevDevice object (or a CA channel)
' 178 */
' 179 class pvVariable {
' 180
' 181 public:
' 182 // private data is constructor argument so that it is guaranteed set
' 183 // before connection callback is invoked
2000-04-14 Janet 184 epicsShareFunc pvVariable( pvSystem *system, const char *name, pvConnFunc func = NULL,
2000-04-04 William 185 void *priv = NULL, int debug = 0 );
2000-04-14 Janet 186 epicsShareFunc virtual ~pvVariable();
2000-04-04 William 187
2000-04-14 Janet 188 epicsShareFunc virtual pvStat get( pvType type, int count, pvValue *value ) = 0;
21:55:19 ' 189 epicsShareFunc virtual pvStat getNoBlock( pvType type, int count, pvValue *value ) = 0;
' 190 epicsShareFunc virtual pvStat getCallback( pvType type, int count,
2000-04-04 William 191 pvEventFunc func, void *arg = NULL ) = 0;
2000-04-14 Janet 192 epicsShareFunc virtual pvStat put( pvType type, int count, pvValue *value ) = 0;
21:55:19 ' 193 epicsShareFunc virtual pvStat putNoBlock( pvType type, int count, pvValue *value ) = 0;
' 194 epicsShareFunc virtual pvStat putCallback( pvType type, int count, pvValue *value,
2000-04-04 William 195 pvEventFunc func, void *arg = NULL ) = 0;
2000-04-14 Janet 196 epicsShareFunc virtual pvStat monitorOn( pvType type, int count,
2000-04-04 William 197 pvEventFunc func, void *arg = NULL,
03:23:15 ' 198 pvCallback **pCallback = NULL ) = 0;
2000-04-14 Janet 199 epicsShareFunc virtual pvStat monitorOff( pvCallback *callback = NULL ) = 0;
2000-04-04 William 200
2000-04-14 Janet 201 epicsShareFunc virtual int getConnected() const = 0;
21:55:19 ' 202 epicsShareFunc virtual pvType getType() const = 0;
' 203 epicsShareFunc virtual int getCount() const = 0;
2000-04-04 William 204
2000-04-14 Janet 205 epicsShareFunc inline int getMagic() const { return magic_; }
21:55:19 ' 206 epicsShareFunc inline void setDebug( int debug ) { debug_ = debug; }
' 207 epicsShareFunc inline int getDebug() const { return debug_; }
' 208 epicsShareFunc inline pvConnFunc getFunc() const { return func_; }
2000-04-04 William 209
2000-04-14 Janet 210 epicsShareFunc inline pvSystem *getSystem() const { return system_; }
21:55:19 ' 211 epicsShareFunc inline char *getName() const { return name_; }
' 212 epicsShareFunc inline void setPrivate( void *priv ) { private_ = priv; }
' 213 epicsShareFunc inline void *getPrivate() const { return private_; }
2000-04-04 William 214
2000-04-14 Janet 215 epicsShareFunc void setError( int status, pvSevr sevr, pvStat stat, const char *mess );
21:55:19 ' 216 epicsShareFunc inline int getStatus() const { return status_; }
' 217 epicsShareFunc inline pvSevr getSevr() const { return sevr_; }
' 218 epicsShareFunc inline pvStat getStat() const { return stat_; }
' 219 epicsShareFunc inline void setStatus( int status ) { status_ = status; }
' 220 epicsShareFunc inline void setStat( pvStat stat ) { stat_ = stat; }
' 221 epicsShareFunc inline char *getMess() const { return mess_?mess_:(char *)""; }
2000-04-04 William 222
03:23:15 ' 223 private:
' 224 int magic_; /* magic number (used for authentication) */
' 225 int debug_; /* debugging level (inherited from system) */
' 226 pvConnFunc func_; /* connection state change function */
' 227
' 228 pvSystem *system_; /* associated system */
' 229 char *name_; /* variable name */
' 230 void *private_; /* client's private data */
' 231
' 232 int status_; /* message system-specific status code */
' 233 pvSevr sevr_; /* severity */
' 234 pvStat stat_; /* status */
' 235 char *mess_; /* error message */
' 236 };
' 237
' 238 ////////////////////////////////////////////////////////////////////////////////
' 239 /*
' 240 * Callback
' 241 *
' 242 * This is somewhat analogous to a cdevCallback object
' 243 */
' 244 class pvCallback {
' 245
' 246 public:
2000-04-14 Janet 247 epicsShareFunc pvCallback( pvVariable *variable, pvType type, int count,
2000-04-04 William 248 pvEventFunc func, void *arg, int debug = 0);
2000-04-14 Janet 249 epicsShareFunc ~pvCallback();
2000-04-04 William 250
2000-04-14 Janet 251 epicsShareFunc inline int getMagic() { return magic_; }
21:55:19 ' 252 epicsShareFunc inline void setDebug( int debug ) { debug_ = debug; }
' 253 epicsShareFunc inline int getDebug() { return debug_; }
2000-04-04 William 254
2000-04-14 Janet 255 epicsShareFunc inline pvVariable *getVariable() { return variable_; }
21:55:19 ' 256 epicsShareFunc inline pvType getType() { return type_; }
' 257 epicsShareFunc inline int getCount() { return count_; };
' 258 epicsShareFunc inline pvEventFunc getFunc() { return func_; };
' 259 epicsShareFunc inline void *getArg() { return arg_; };
' 260 epicsShareFunc inline void setPrivate( void *priv ) { private_ = priv; }
' 261 epicsShareFunc inline void *getPrivate() { return private_; }
2000-04-04 William 262
03:23:15 ' 263 private:
' 264 int magic_; /* magic number (used for authentication) */
' 265 int debug_; /* debugging level (inherited from variable) */
' 266
' 267 pvVariable *variable_; /* associated variable */
' 268 pvType type_; /* variable's native type */
' 269 int count_; /* variable's element count */
' 270 pvEventFunc func_; /* user's event function */
' 271 void *arg_; /* user's event function argument */
' 272 void *private_; /* message system's private data */
' 273 };
' 274
' 275 ////////////////////////////////////////////////////////////////////////////////
' 276 /*
' 277 * End of C++.
' 278 */
' 279 #endif /* __cplusplus */
' 280
' 281 /*
' 282 * C interface
' 283 */
' 284 #ifdef __cplusplus
' 285 extern "C" {
2000-04-14 Janet 286 epicsShareFunc pvSystem * epicsShareAPI newPvSystem( const char *name, int debug = 0 );
2000-04-04 William 287 #endif
03:23:15 ' 288
2000-04-14 Janet 289 epicsShareFunc pvStat epicsShareAPI pvSysCreate( const char *name, int debug, void **pSys );
21:55:19 ' 290 epicsShareFunc pvStat epicsShareAPI pvSysDestroy( void *sys );
' 291 epicsShareFunc pvStat epicsShareAPI pvSysFlush( void *sys );
' 292 epicsShareFunc pvStat epicsShareAPI pvSysPend( void *sys, double seconds, int wait );
' 293 epicsShareFunc pvStat epicsShareAPI pvSysLock( void *sys );
' 294 epicsShareFunc pvStat epicsShareAPI pvSysUnlock( void *sys );
' 295 epicsShareFunc pvStat epicsShareAPI pvSysAttach( void *sys );
' 296 epicsShareFunc int epicsShareAPI pvSysGetMagic( void *sys );
' 297 epicsShareFunc void epicsShareAPI pvSysSetDebug( void *sys, int debug );
' 298 epicsShareFunc int epicsShareAPI pvSysGetDebug( void *sys );
' 299 epicsShareFunc int epicsShareAPI pvSysGetStatus( void *sys );
' 300 epicsShareFunc pvSevr epicsShareAPI pvSysGetSevr( void *sys );
' 301 epicsShareFunc pvStat epicsShareAPI pvSysGetStat( void *sys );
' 302 epicsShareFunc char * epicsShareAPI pvSysGetMess( void *sys );
2000-04-04 William 303
2000-04-14 Janet 304 epicsShareFunc pvStat epicsShareAPI pvVarCreate( void *sys, const char *name, pvConnFunc func, void *priv,
2000-04-04 William 305 int debug, void **pVar );
2000-04-14 Janet 306 epicsShareFunc pvStat epicsShareAPI pvVarDestroy( void *var );
21:55:19 ' 307 epicsShareFunc pvStat epicsShareAPI pvVarGet( void *var, pvType type, int count, pvValue *value );
' 308 epicsShareFunc pvStat epicsShareAPI pvVarGetNoBlock( void *var, pvType type, int count, pvValue *value );
' 309 epicsShareFunc pvStat epicsShareAPI pvVarGetCallback( void *var, pvType type, int count,
2000-04-04 William 310 pvEventFunc func, void *arg );
2000-04-14 Janet 311 epicsShareFunc pvStat epicsShareAPI pvVarPut( void *var, pvType type, int count, pvValue *value );
21:55:19 ' 312 epicsShareFunc pvStat epicsShareAPI pvVarPutNoBlock( void *var, pvType type, int count, pvValue *value );
' 313 epicsShareFunc pvStat epicsShareAPI pvVarPutCallback( void *var, pvType type, int count, pvValue *value,
2000-04-04 William 314 pvEventFunc func, void *arg );
2000-04-14 Janet 315 epicsShareFunc pvStat epicsShareAPI pvVarMonitorOn( void *var, pvType type, int count,
2000-04-04 William 316 pvEventFunc func, void *arg, void **pId );
2000-04-14 Janet 317 epicsShareFunc pvStat epicsShareAPI pvVarMonitorOff( void *var, void *id );
21:55:19 ' 318 epicsShareFunc int epicsShareAPI pvVarGetMagic( void *var );
' 319 epicsShareFunc void epicsShareAPI pvVarSetDebug( void *var, int debug );
' 320 epicsShareFunc int epicsShareAPI pvVarGetDebug( void *var );
' 321 epicsShareFunc int epicsShareAPI pvVarGetConnected( void *var );
' 322 epicsShareFunc pvType epicsShareAPI pvVarGetType( void *var );
' 323 epicsShareFunc int epicsShareAPI pvVarGetCount( void *var );
' 324 epicsShareFunc char * epicsShareAPI pvVarGetName( void *var );
' 325 epicsShareFunc void epicsShareAPI pvVarSetPrivate( void *var, void *priv );
' 326 epicsShareFunc void * epicsShareAPI pvVarGetPrivate( void *var );
' 327 epicsShareFunc int epicsShareAPI pvVarGetStatus( void *var );
' 328 epicsShareFunc pvSevr epicsShareAPI pvVarGetSevr( void *var );
' 329 epicsShareFunc pvStat epicsShareAPI pvVarGetStat( void *var );
' 330 epicsShareFunc char * epicsShareAPI pvVarGetMess( void *var );
2000-04-04 William 331
03:23:15 ' 332 /*
' 333 * Time utilities
' 334 */
2000-04-14 Janet 335 epicsShareFunc int epicsShareAPI pvTimeGetCurrentDouble( double *pTime );
2000-04-04 William 336
03:23:15 ' 337 /*
' 338 * Misc utilities
' 339 */
2000-04-14 Janet 340 epicsShareFunc char * epicsShareAPI Strdup( const char *s );
21:55:19 ' 341 epicsShareFunc char * epicsShareAPI Strdcpy( char *dst, const char *src );
2000-04-04 William 342
03:23:15 ' 343 #ifdef __cplusplus
' 344 }
' 345 #endif
' 346
' 347 #endif /* INCLpvh */
' 348
' 349 /*
2010-02-26 benjamin.fra 350 * pv.h,v
13:39:43 ' 351 * Revision 1.3 2001/02/16 18:45:39 mrk
' 352 * changes for latest version of 3.14
' 353 *
2001-02-16 Marty 354 * Revision 1.2 2000/04/14 21:53:28 jba
18:45:42 ' 355 * Changes for win32 build.
' 356 *
2000-04-14 Janet 357 * Revision 1.1.1.1 2000/04/04 03:22:13 wlupton
21:55:19 ' 358 * first commit of seq-2-0-0
' 359 *
2000-04-04 William 360 * Revision 1.18 2000/03/31 23:00:42 wlupton
03:23:15 ' 361 * added default attach and flush implementations; added setStatus
' 362 *
' 363 * Revision 1.17 2000/03/29 01:58:48 wlupton
' 364 * split off pvAlarm.h; added pvVarGetName
' 365 *
' 366 * Revision 1.16 2000/03/18 04:00:25 wlupton
' 367 * converted to use new configure scheme
' 368 *
' 369 * Revision 1.15 2000/03/16 02:10:24 wlupton
' 370 * added newly-needed debug argument
' 371 *
' 372 * Revision 1.14 2000/03/07 09:27:39 wlupton
' 373 * drastically reduced use of references
' 374 *
' 375 * Revision 1.13 2000/03/07 08:46:29 wlupton
' 376 * created ktlKeyword class (works but a bit messy)
' 377 *
' 378 * Revision 1.12 2000/03/06 19:19:43 wlupton
' 379 * misc type conversion and error reporting mods
' 380 *
' 381 * Revision 1.11 2000/03/01 02:07:14 wlupton
' 382 * converted to use new OSI library
' 383 *
' 384 * Revision 1.10 2000/02/19 01:09:51 wlupton
' 385 * added PV_SIMPLE() and prototypes for var-level error info
' 386 *
' 387 * Revision 1.9 2000/02/16 02:31:44 wlupton
' 388 * merged in v1.9.5 changes
' 389 *
' 390 * Revision 1.8 1999/09/07 20:42:59 epics
' 391 * removed unnecessary comment
' 392 *
' 393 * Revision 1.7 1999/07/07 18:50:33 wlupton
' 394 * supported full mapping from EPICS status and severity to pvStat and pvSevr
' 395 *
' 396 * Revision 1.6 1999/07/01 20:50:18 wlupton
' 397 * Working under VxWorks
' 398 *
' 399 * Revision 1.5 1999/06/10 00:35:03 wlupton
' 400 * demo sequencer working with pvCa
' 401 *
' 402 * Revision 1.4 1999/06/08 19:21:43 wlupton
' 403 * CA version working; about to use in sequencer
' 404 *
' 405 * Revision 1.3 1999/06/08 03:25:21 wlupton
' 406 * nearly complete CA implementation
' 407 *
' 408 * Revision 1.2 1999/06/07 21:46:44 wlupton
' 409 * working with simple pvtest program
' 410 *
' 411 * Revision 1.1 1999/06/04 20:48:27 wlupton
' 412 * initial version of pv.h and pv.cc
' 413 *
' 414 */