00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef CMS_HH
00015 #define CMS_HH
00016
00017 #include "rcs_defs.hh"
00018
00019
00020 #ifdef EXTERN_C_STD_HEADERS
00021 extern "C"
00022 {
00023 #endif
00024
00025 #ifndef UNDER_CE
00026 #include <stddef.h>
00027 #endif
00028
00029
00030 #ifdef EXTERN_C_STD_HEADERS
00031 }
00032 #endif
00033
00034 #include "cms_cfg.hh"
00035 #include "linklist.hh"
00036 #include "physmem.hh"
00037 #include "posemath.h"
00038
00039
00040
00041
00042 enum CMS_STATUS
00043 {
00044
00045 CMS_MISC_ERROR = -1,
00046 CMS_UPDATE_ERROR = -2,
00047 CMS_INTERNAL_ACCESS_ERROR = -3,
00048 CMS_NO_MASTER_ERROR = -4,
00049
00050 CMS_CONFIG_ERROR = -5,
00051 CMS_TIMED_OUT = -6,
00052 CMS_QUEUE_FULL = -7,
00053
00054
00055 CMS_CREATE_ERROR = -8,
00056 CMS_PERMISSIONS_ERROR = -9,
00057 CMS_NO_SERVER_ERROR = -10,
00058 CMS_RESOURCE_CONFLICT_ERROR = -11,
00059 CMS_NO_IMPLEMENTATION_ERROR = -12,
00060 CMS_INSUFFICIENT_SPACE_ERROR = -13,
00061 CMS_LIBRARY_UNAVAILABLE_ERROR = -14,
00062 CMS_SERVER_SIDE_ERROR = -15,
00063 CMS_NO_BLOCKING_SEM_ERROR = -16,
00064
00065
00066 CMS_STATUS_NOT_SET = 0,
00067 CMS_READ_OLD = 1,
00068 CMS_READ_OK = 2,
00069 CMS_WRITE_OK = 3,
00070 CMS_WRITE_WAS_BLOCKED = 4,
00071
00072 CMS_CLEAR_OK = 5,
00073 CMS_CLOSED = 6
00074 };
00075
00076
00077 enum CMSMODE
00078 {
00079 CMS_NOT_A_MODE = 0,
00080 CMS_ENCODE,
00081 CMS_DECODE,
00082 CMS_RAW_OUT,
00083 CMS_RAW_IN,
00084 CMS_READ,
00085 CMS_WRITE
00086 };
00087
00088 typedef long int CMSID;
00089
00090
00091 enum CMS_INTERNAL_ACCESS_TYPE
00092 {
00093 CMS_ZERO_ACCESS = 0,
00094 CMS_READ_ACCESS,
00095 CMS_CHECK_IF_READ_ACCESS,
00096 CMS_PEEK_ACCESS,
00097 CMS_WRITE_ACCESS,
00098 CMS_WRITE_IF_READ_ACCESS,
00099 CMS_CLEAR_ACCESS,
00100 CMS_GET_MSG_COUNT_ACCESS,
00101 CMS_GET_DIAG_INFO_ACCESS
00102 };
00103
00104
00105 enum CMS_BUFFERTYPE
00106 {
00107 CMS_SHMEM_TYPE,
00108 CMS_GLOBMEM_TYPE,
00109 CMS_PHANTOM_BUFFER,
00110 CMS_LOCMEM_TYPE,
00111 CMS_FILEMEM_TYPE,
00112 CMS_BBDMEM_TYPE,
00113 CMS_RTLMEM_TYPE
00114 };
00115
00116
00117 enum CMS_PROCESSTYPE
00118 {
00119 CMS_REMOTE_TYPE,
00120 CMS_LOCAL_TYPE,
00121 CMS_PHANTOM_USER,
00122 CMS_AUTO_TYPE
00123 };
00124
00125 enum CMS_REMOTE_PORT_TYPE
00126 {
00127 CMS_NO_REMOTE_PORT_TYPE = 0,
00128 CMS_RPC_REMOTE_PORT_TYPE,
00129 CMS_TTY_REMOTE_PORT_TYPE,
00130 CMS_TCP_REMOTE_PORT_TYPE,
00131 CMS_STCP_REMOTE_PORT_TYPE,
00132 CMS_UDP_REMOTE_PORT_TYPE
00133 };
00134
00135
00136
00137 struct RCS_EXPORT CMS_HEADER
00138 {
00139 long was_read;
00140
00141 long write_id;
00142 long in_buffer_size;
00143 };
00144
00145 class RCS_EXPORT CMS_DIAG_PROC_INFO;
00146 class RCS_EXPORT CMS_DIAG_HEADER;
00147 class RCS_EXPORT CMS_DIAGNOSTICS_INFO;
00148
00149 struct RCS_EXPORT CMS_QUEUING_HEADER
00150 {
00151 long head;
00152 long tail;
00153 long queue_length;
00154 long end_queue_space;
00155 long write_id;
00156 };
00157
00158 enum CMS_NEUTRAL_ENCODING_METHOD
00159 {
00160 CMS_NO_ENCODING,
00161 CMS_XDR_ENCODING,
00162 CMS_ASCII_ENCODING,
00163 CMS_DISPLAY_ASCII_ENCODING
00164 };
00165
00166
00167 class RCS_EXPORT CMS;
00168 class RCS_EXPORT CMS_UPDATER;
00169
00170
00171 class RCS_EXPORT CMS
00172 {
00173 public:
00174 void *operator new (size_t);
00175 void operator delete (void *);
00176
00177 public:
00178
00179 CMS (long size);
00180 CMS (char *bufline, char *procline, int set_to_server = 0);
00181 virtual ~ CMS ();
00182
00183
00184 virtual CMS_STATUS clear ();
00185 virtual int check_if_read ();
00186 virtual int get_msg_count ();
00187 virtual int check_if_transfers_complete ();
00188 virtual CMS_STATUS read ();
00189 virtual CMS_STATUS blocking_read (double _timeout);
00190 virtual CMS_STATUS peek ();
00191 virtual CMS_STATUS write (void *user_data);
00192 virtual CMS_STATUS write_if_read (void *user_data);
00193 virtual int login (const char *name, const char *passwd);
00194 virtual void reconnect ();
00195 virtual void disconnect ();
00196
00197
00198 virtual CMS_STATUS main_access (void *_local);
00199
00200
00201 void rewind ();
00202 int get_encoded_msg_size ();
00203
00204
00205 void set_mode (CMSMODE im);
00206
00207
00208 void set_temp_updater (CMS_NEUTRAL_ENCODING_METHOD);
00209
00210
00211 void restore_normal_updater ();
00212
00213
00214
00215
00216
00217 CMS_STATUS internal_access (PHYSMEM_HANDLE * _global, void *_local);
00218 CMS_STATUS internal_access (void *_global, long global_size, void *_local);
00219 CMS_STATUS internal_clear ();
00220 int check_if_read_raw ();
00221 int check_if_read_encoded ();
00222 int get_msg_count_raw ();
00223 int get_msg_count_encoded ();
00224 CMS_STATUS read_raw ();
00225 CMS_STATUS read_encoded ();
00226 CMS_STATUS peek_raw ();
00227 CMS_STATUS peek_encoded ();
00228 CMS_STATUS write_raw (void *user_data);
00229 CMS_STATUS write_encoded ();
00230 CMS_STATUS write_if_read_raw (void *user_data);
00231 CMS_STATUS write_if_read_encoded ();
00232 int queue_check_if_read_raw ();
00233 int queue_check_if_read_encoded ();
00234 CMS_STATUS queue_read_raw ();
00235 CMS_STATUS queue_read_encoded ();
00236 CMS_STATUS queue_peek_raw ();
00237 CMS_STATUS queue_peek_encoded ();
00238 CMS_STATUS queue_write_raw (void *user_data);
00239 CMS_STATUS queue_write_encoded ();
00240 CMS_STATUS queue_write_if_read_raw (void *user_data);
00241 CMS_STATUS queue_write_if_read_encoded ();
00242 virtual void clean_buffers ();
00243
00244
00245
00246
00247
00248 CMS_STATUS update (char &x);
00249 CMS_STATUS update (unsigned char &x);
00250 CMS_STATUS update (short int &x);
00251 CMS_STATUS update (unsigned short int &x);
00252 CMS_STATUS update (int &x);
00253 CMS_STATUS update (unsigned int &x);
00254 CMS_STATUS update (long int &x);
00255 CMS_STATUS update (unsigned long int &x);
00256 CMS_STATUS update (float &x);
00257 CMS_STATUS update (double &x);
00258 CMS_STATUS update (long double &x);
00259 CMS_STATUS update (char *x, unsigned int len);
00260 CMS_STATUS update (unsigned char *x, unsigned int len);
00261 CMS_STATUS update (short *x, unsigned int len);
00262 CMS_STATUS update (unsigned short *x, unsigned int len);
00263 CMS_STATUS update (int *x, unsigned int len);
00264 CMS_STATUS update (unsigned int *x, unsigned int len);
00265 CMS_STATUS update (long *x, unsigned int len);
00266 CMS_STATUS update (unsigned long *x, unsigned int len);
00267 CMS_STATUS update (float *x, unsigned int len);
00268 CMS_STATUS update (double *x, unsigned int len);
00269 CMS_STATUS update (long double *x, unsigned int len);
00270
00271
00272
00273
00274
00275 CMS_STATUS update (PM_CARTESIAN & x);
00276 CMS_STATUS update (PM_SPHERICAL & x);
00277 CMS_STATUS update (PM_CYLINDRICAL & x);
00278
00279
00280 CMS_STATUS update (PM_ROTATION_VECTOR & x);
00281 CMS_STATUS update (PM_ROTATION_MATRIX & x);
00282 CMS_STATUS update (PM_QUATERNION & x);
00283 CMS_STATUS update (PM_EULER_ZYZ & x);
00284 CMS_STATUS update (PM_EULER_ZYX & x);
00285 CMS_STATUS update (PM_RPY & x);
00286
00287
00288 CMS_STATUS update (PM_POSE & x);
00289 CMS_STATUS update (PM_HOMOGENEOUS & x);
00290
00291
00292
00293 CMS_STATUS update (PM_CARTESIAN * x, int n);
00294 CMS_STATUS update (PM_SPHERICAL * x, int n);
00295 CMS_STATUS update (PM_CYLINDRICAL * x, int n);
00296
00297
00298 CMS_STATUS update (PM_ROTATION_VECTOR * x, int n);
00299 CMS_STATUS update (PM_ROTATION_MATRIX * x, int n);
00300 CMS_STATUS update (PM_QUATERNION * x, int n);
00301 CMS_STATUS update (PM_EULER_ZYZ * x, int n);
00302 CMS_STATUS update (PM_EULER_ZYX * x, int n);
00303 CMS_STATUS update (PM_RPY * x, int n);
00304
00305
00306 CMS_STATUS update (PM_POSE * x, int n);
00307 CMS_STATUS update (PM_HOMOGENEOUS * x, int n);
00308
00309
00310 #ifdef CMS_SUPPORT_POINTERS
00311 virtual CMS_STATUS update_ptr (int (*update_ptr_func) (void *, CMS *),
00312 void **x, long xsize);
00313 virtual CMS_STATUS set_pointer_buffer (char *buf, long size);
00314 #endif
00315
00316 int fatal_error_occurred;
00317 int consecutive_timeouts;
00318 CMS_HEADER header;
00319 int queuing_enabled;
00320 CMS_QUEUING_HEADER queuing_header;
00321 CMSMODE mode;
00322 long size;
00323 long max_message_size;
00324
00325 long max_encoded_message_size;
00326 long guaranteed_message_space;
00327
00328 int neutral;
00329
00330 CMS_STATUS status;
00331 void set_cms_status (CMS_STATUS);
00332 int spawn_server;
00333
00334
00335 void *encoded_data;
00336 int using_external_encoded_data;
00337 void set_encoded_data (void *, long _encoded_data_size);
00338 void *data;
00339 void *subdiv_data;
00340
00341
00342 char BufferName[CMS_CONFIG_LINELEN];
00343 char BufferHost[CMS_CONFIG_LINELEN];
00344 char ProcessName[CMS_CONFIG_LINELEN];
00345 char BufferLine[CMS_CONFIG_LINELEN];
00346 char ProcessLine[CMS_CONFIG_LINELEN];
00347 char ProcessHost[CMS_CONFIG_LINELEN];
00348 char buflineupper[CMS_CONFIG_LINELEN];
00349 char proclineupper[CMS_CONFIG_LINELEN];
00350 char PermissionString[CMS_CONFIG_LINELEN];
00351 int is_local_master;
00352 int force_raw;
00353 int split_buffer;
00354
00355
00356 char toggle_bit;
00357 int first_read_done;
00358 int first_write_done;
00359 int write_permission_flag;
00360 int read_permission_flag;
00361 unsigned long rpc_program_number;
00362 int tcp_port_number;
00363 int stcp_port_number;
00364 int udp_port_number;
00365 long buffer_number;
00366 int delete_totally;
00367 long total_messages_missed;
00368 long messages_missed_on_last_read;
00369 char RCS_HUGE *format_low_ptr;
00370 char RCS_HUGE *format_high_ptr;
00371 long format_size;
00372 int check_pointer (char RCS_HUGE * ptr, long bytes);
00373 int isserver;
00374 int is_phantom;
00375 CMS_BUFFERTYPE BufferType;
00376 CMS_PROCESSTYPE ProcessType;
00377 CMS_REMOTE_PORT_TYPE remote_port_type;
00378 int pointer_check_disabled;
00379
00380 CMSID in_buffer_id;
00381 void *encoded_header;
00382 void *encoded_queuing_header;
00383 long encoded_header_size;
00384 long encoded_queuing_header_size;
00385
00386
00387 int encode_header ();
00388 int decode_header ();
00389 int encode_queuing_header ();
00390 int decode_queuing_header ();
00391
00392 CMS_NEUTRAL_ENCODING_METHOD neutral_encoding_method;
00393 CMS_NEUTRAL_ENCODING_METHOD temp_updater_encoding_method;
00394
00395 public:
00396
00397 CMS_INTERNAL_ACCESS_TYPE internal_access_type;
00398 PHYSMEM_HANDLE *handle_to_global_data;
00399 PHYSMEM_HANDLE *dummy_handle;
00400 int write_just_completed;
00401 CMSMODE read_mode;
00402 CMSMODE write_mode;
00403 int read_updater_mode;
00404 int write_updater_mode;
00405 CMSMODE last_im;
00406
00407
00408
00409 CMS_STATUS check_id (CMSID id);
00410 friend class CMS_SERVER;
00411 friend class CMS_SERVER_HANDLER;
00412 public:
00413 double timeout;
00414 long connection_number;
00415 long total_connections;
00416 CMS_UPDATER *updater;
00417 CMS_UPDATER *normal_updater;
00418 CMS_UPDATER *temp_updater;
00419
00420 private:
00421 unsigned long encode_state;
00422 unsigned long decode_state;
00423 void open (void);
00424 static int number_of_cms_objects;
00425
00426
00427 public:
00428 long sizeof_message_header;
00429 double blocking_timeout;
00430 double min_compatible_version;
00431 int confirm_write;
00432 int disable_final_write_raw_for_dma;
00433 virtual const char *status_string (int);
00434
00435 int total_subdivisions;
00436 int current_subdivision;
00437 long subdiv_size;
00438 int set_subdivision (int _subdiv);
00439 long encoded_data_size;
00440 long enc_max_size;
00441 long enable_diagnostics;
00442 CMS_DIAG_PROC_INFO *dpi;
00443 virtual CMS_DIAG_PROC_INFO *get_diag_proc_info ();
00444 virtual void set_diag_proc_info (CMS_DIAG_PROC_INFO *);
00445 virtual void setup_diag_proc_info ();
00446 virtual void calculate_and_store_diag_info (PHYSMEM_HANDLE * _handle,
00447 void *);
00448 virtual void internal_retrieve_diag_info (PHYSMEM_HANDLE * _handle, void *);
00449 CMS_DIAGNOSTICS_INFO *di;
00450 virtual CMS_DIAGNOSTICS_INFO *get_diagnostics_info ();
00451 int first_diag_store;
00452 double pre_op_total_bytes_moved;
00453 double time_bias;
00454 int skip_area;
00455 unsigned long half_offset;
00456 long half_size;
00457 int fast_mode;
00458 long size_without_diagnostics;
00459 int disable_diag_store;
00460 long diag_offset;
00461 int last_id_side0;
00462 int last_id_side1;
00463 int use_autokey_for_connection_number;
00464
00465
00466 private:
00467 CMS (CMS & cms);
00468
00469 };
00470
00471 class CMS_HOST_ALIAS_ENTRY
00472 {
00473 public:
00474 char host[64];
00475 char alias[64];
00476 };
00477
00478
00479 extern RCS_LINKED_LIST *cmsHostAliases;
00480
00481 enum CMS_CONNECTION_MODE
00482 {
00483 CMS_NORMAL_CONNECTION_MODE = 0,
00484 CMS_FORCE_LOCAL_CONNECTION_MODE = 1,
00485 CMS_FORCE_REMOTE_CONNECTION_MODE = 2
00486 };
00487
00488 extern CMS_CONNECTION_MODE cms_connection_mode;
00489
00490
00491 extern char *cms_check_for_host_alias (char *in);
00492 extern int cms_encoded_data_explosion_factor;
00493 extern int cms_print_queue_free_space;
00494 extern int cms_print_queue_full_messages;
00495
00496
00497 #endif