00001
00002
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
00028
00029
00030
00031
00032 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00033
00034 #ifdef OS_WINNT
00035 #include <io.h>
00036 #include <time.h>
00037 #endif
00038 #include <fcntl.h>
00039 #include <stdlib.h>
00040 #include <stdio.h>
00041 #include <string.h>
00042 #include <sys/stat.h>
00043 #include <sys/types.h>
00044
00045 #ifndef EXPRT
00046 #define EXPRT
00047 #endif
00048
00049
00050 #endif
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061 #ifdef YBOS_VERSION_3_3
00062 #define YBOS_PHYREC_SIZE 8190
00063 #else
00064 #define YBOS_PHYREC_SIZE 8192
00065 #endif
00066 #define YBOS_HEADER_LENGTH 4
00067 #define YBOS_BUFFER_SIZE 3*(YBOS_PHYREC_SIZE<<2) + MAX_EVENT_SIZE + 128
00068
00069 #define YB_BANKLIST_MAX 32
00070
00071 #define YB_STRING_BANKLIST_MAX YB_BANKLIST_MAX * 4
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081 #define YB_SUCCESS 1
00082 #define YB_EVENT_NOT_SWAPPED 2
00083 #define YB_DONE 2
00084 #define YB_WRONG_BANK_TYPE -100
00085 #define YB_BANK_NOT_FOUND -101
00086 #define YB_SWAP_ERROR -102
00087 #define YB_NOMORE_SLOT -103
00088 #define YB_UNKNOWN_FORMAT -104
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100 #define H_BLOCK_SIZE 0
00101 #define H_BLOCK_NUM 1
00102 #define H_HEAD_LEN 2
00103 #define H_START 3
00104
00105
00106
00107 #define D_RECORD 1
00108 #define D_HEADER 2
00109 #define D_EVTLEN 3
00110
00111
00112
00113 #define YB_COMPLETE 1
00114 #define YB_INCOMPLETE 2
00115 #define YB_NO_RECOVER -1
00116 #define YB_NO_RUN 0
00117 #define YB_ADD_RUN 1
00118
00119
00120
00121 #define DSP_RAW 1
00122 #define DSP_RAW_SINGLE 2
00123 #define DSP_BANK 3
00124 #define DSP_BANK_SINGLE 4
00125
00126
00127
00128 #define DSP_UNK 0
00129 #define DSP_DEC 1
00130 #define DSP_HEX 2
00131 #define DSP_ASC 3
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144 #define SWAP_D2WORD(_d2w) {\
00145 WORD _tmp2; \
00146 _tmp2 = *((WORD *)(_d2w)); \
00147 *((WORD *)(_d2w)) = *(((WORD *)(_d2w))+1); \
00148 *(((WORD *)(_d2w))+1) = _tmp2; \
00149 }
00150
00151
00152 #ifdef CHAOS_EVID_FMT
00153 extern chaos;
00154 #endif
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210 #if (!defined (EVID_TRINAT) && !defined (EVID_CHAOS) && !defined (EVID_TWIST))
00211 #define EVID_TRINAT
00212 #endif
00213
00214 #if defined(EVID_TRINAT)
00215 #define YBOS_EVID_EVENT_ID(e) *((WORD *)(e)+1)
00216 #define YBOS_EVID_TRIGGER_MASK(e) *((WORD *)(e)+0)
00217 #define YBOS_EVID_SERIAL(e) *((DWORD *)(e)+1)
00218 #define YBOS_EVID_TIME(e) *((DWORD *)(e)+2)
00219 #define YBOS_EVID_RUN_NUMBER(e) *((DWORD *)(e)+3)
00220 #define YBOS_EVID_EVENT_NB(e) *((DWORD *)(e)+1)
00221 #elif defined(EVID_CHAOS)
00222 #define YBOS_EVID_EVENT_ID(e) *((WORD *)(e)+3)
00223 #define YBOS_EVID_TRIGGER_MASK(e) *((WORD *)(e)+2)
00224 #define YBOS_EVID_SERIAL(e) *((DWORD *)(e)+2)
00225 #define YBOS_EVID_TIME(e) *((DWORD *)(e)+3)
00226 #define YBOS_EVID_RUN_NUMBER(e) *((DWORD *)(e)+4)
00227 #define YBOS_EVID_EVENT_NB(e) *((DWORD *)(e)+0)
00228 #elif defined(EVID_TWIST)
00229 #define YBOS_EVID_EVENT_ID(e) *((WORD *)(e)+1)
00230 #define YBOS_EVID_TRIGGER_MASK(e) *((WORD *)(e)+0)
00231 #define YBOS_EVID_SERIAL(e) *((DWORD *)(e)+1)
00232 #define YBOS_EVID_TIME(e) *((DWORD *)(e)+2)
00233 #define YBOS_EVID_RUN_NUMBER(e) *((DWORD *)(e)+3)
00234 #define YBOS_EVID_EVENT_NB(e) *((DWORD *)(e)+1)
00235
00236 #endif
00237
00238
00239
00240
00241 #define YBOS_EVID_BANK(__a, __b, __c, __d, __e) {\
00242 DWORD * pbuf;\
00243 ybk_create(__a, "EVID", I4_BKTYPE, &pbuf);\
00244 *(pbuf)++ = (DWORD)__b;\
00245 *(pbuf)++ = (DWORD)__c;\
00246 *(pbuf)++ = (DWORD)__d;\
00247 *(pbuf)++ = (DWORD)ss_millitime();\
00248 *(pbuf)++ = (DWORD)__e;\
00249 ybk_close(__a, pbuf);\
00250 }
00251
00252
00253
00254
00255 #define MIDAS_EVID_BANK(__a, __b, __c, __d, __e) {\
00256 DWORD * pbuf;\
00257 bk_create(__a, "EVID", TID_DWORD, &pbuf);\
00258 *(pbuf)++ = (DWORD)__b;\
00259 *(pbuf)++ = (DWORD)__c;\
00260 *(pbuf)++ = (DWORD)__d;\
00261 *(pbuf)++ = (DWORD)ss_millitime();\
00262 *(pbuf)++ = (DWORD)__e;\
00263 bk_close(__a, pbuf);\
00264 }
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277 #define I2_BKTYPE 1
00278 #define A1_BKTYPE 2
00279 #define I4_BKTYPE 3
00280 #define F4_BKTYPE 4
00281 #define D8_BKTYPE 5
00282 #define I1_BKTYPE 8
00283 #define MAX_BKTYPE I1_BKTYPE+1
00284
00285
00286
00287
00288
00289 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00290
00291
00292
00293 typedef struct {
00294 DWORD *ptop;
00295 DWORD *pbuf;
00296 DWORD *pwrt;
00297 DWORD *pbot;
00298 DWORD *pend;
00299 DWORD reco;
00300 DWORD recn;
00301 } YBOS_INFO;
00302
00303
00304
00305 typedef struct {
00306 DWORD rec_size;
00307 DWORD header_length;
00308 DWORD rec_num;
00309 DWORD offset;
00310
00311 } YBOS_PHYSREC_HEADER;
00312
00313
00314
00315 typedef struct {
00316 DWORD name;
00317 DWORD number;
00318 DWORD index;
00319 DWORD length;
00320 DWORD type;
00321 } YBOS_BANK_HEADER;
00322
00323
00324
00325 #define MAX_FILE_PATH 128
00326 #define MAX_FRAG_SIZE 2000
00327 #define MAX_YM_FILE 8
00328 #define NLINE 8
00329
00330
00331
00332 typedef struct {
00333 INT file_ID;
00334 INT size;
00335 INT fragment_size;
00336 INT total_fragment;
00337 INT current_fragment;
00338 INT current_read_byte;
00339 INT run_number;
00340 INT spare;
00341 } YM_CFILE;
00342
00343
00344
00345 typedef struct {
00346 char path[MAX_FILE_PATH];
00347 } YM_PFILE;
00348
00349
00350
00351 typedef struct {
00352 INT fHandle;
00353 INT file_ID;
00354 INT current_fragment;
00355 INT current_read_byte;
00356 char path[MAX_FILE_PATH];
00357 } R_YM_FILE;
00358
00359
00360
00361
00362 #ifdef __cplusplus
00363 extern "C" {
00364 #endif
00365
00366 INT EXPRT yb_file_recompose(void *pevt, INT fmt, char *svpath, INT file_mode);
00367 INT EXPRT feodb_file_dump(EQUIPMENT * eqp, char *eqpname, char *pevent,
00368 INT run_number, char *path);
00369
00370 void EXPRT yb_any_bank_display(void *pmbh, void *pbk, INT fmt,
00371 INT dsp_mode, INT dsp_fmt);
00372 void EXPRT yb_any_event_display(void *pevt, INT data_fmt, INT dsp_mode, INT dsp_fmt, char * bn);
00373 INT EXPRT yb_any_all_info_display(INT what);
00374 INT EXPRT yb_any_physrec_display(INT data_fmt);
00375
00376 INT EXPRT yb_any_physrec_skip(INT data_fmt, INT bl);
00377 INT EXPRT yb_any_physrec_get(INT data_fmt, void **prec, DWORD * psize);
00378 INT EXPRT yb_any_file_rclose(INT data_fmt);
00379 INT EXPRT yb_any_file_ropen(char *infile, INT data_fmt);
00380 INT EXPRT yb_any_file_wopen(INT type, INT data_fmt, char *filename, INT * hDev);
00381 INT EXPRT yb_any_file_wclose(INT handle, INT type, INT data_fmt);
00382 INT EXPRT yb_any_log_write(INT handle, INT data_fmt, INT type,
00383 void *prec, DWORD nbytes);
00384 INT EXPRT yb_any_event_swap(INT data_fmt, void *pevent);
00385 INT EXPRT yb_any_event_get(INT data_fmt, void **pevent, DWORD * psize);
00386
00387
00388 void EXPRT ybk_init(DWORD * pevent);
00389 void EXPRT ybk_create(DWORD * pevent, char *bkname, DWORD btype, void *pbkdat);
00390 INT EXPRT ybk_close(DWORD * pevent, void *pbkdat);
00391 INT EXPRT ybk_size(DWORD * pevent);
00392 INT EXPRT ybk_list(DWORD * pevent, char *bklist);
00393 INT EXPRT ybk_locate(DWORD * pevent, char *bkname, void *pdata);
00394 INT EXPRT ybk_find(DWORD * pevent, char *bkname, DWORD * bklength,
00395 DWORD * bktype, void **pbkdata);
00396 void EXPRT ybk_create_chaos(DWORD * pevent, char *bname, DWORD btype, void *pbkdat);
00397 INT EXPRT ybk_iterate(DWORD * pevent, YBOS_BANK_HEADER ** pybkh, void **pdata);
00398 INT EXPRT ybk_close_chaos(DWORD * pevent, DWORD btype, void *pbkdat);
00399
00400 #ifdef INCLUDE_LOGGING
00401 INT EXPRT ybos_log_open(LOG_CHN * log_chn, INT run_number);
00402 INT EXPRT ybos_write(LOG_CHN * log_chn, EVENT_HEADER * pevent, INT evt_size);
00403 INT EXPRT ybos_log_close(LOG_CHN * log_chn, INT run_number);
00404 #endif
00405
00406 INT EXPRT ybos_event_get(DWORD ** plrl, DWORD * size);
00407 INT EXPRT ybos_get_tid_size(INT tid);
00408
00409 #ifdef __cplusplus
00410 }
00411 #endif
00412
00413
00414
00415 #endif
00416
00417
00418