00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "typedefs.h"
00021 #include <stdlib.h>
00022 #include <stdio.h>
00023 #include <errno.h>
00024 #include <string.h>
00025 #include <memory.h>
00026 #include <sys/types.h>
00027 #include <ctype.h>
00028 #include "sbs_def.h"
00029 #include "sys_def.h"
00030 #include "ml_def.h"
00031 #include "s_daqst.h"
00032 #include "s_setup.h"
00033 #include "s_set_ml.h"
00034 #include "s_set_mo.h"
00035 #include "f_stccomm.h"
00036
00037 #define VERSION__DAQST 2
00038 #define VERSION__SETUP 1
00039 #define VERSION__SET_ML 1
00040 #define VERSION__SET_MO 1
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068 INTS4 f_ut_status_ini(s_daqst *ps_daqst)
00069 {
00070 if(ps_daqst == NULL) return -1;
00071
00072 ps_daqst->l_endian = 1;
00073 ps_daqst->l_version = VERSION__DAQST;
00074 ps_daqst->l_daqst_lw = sizeof(s_daqst)/4;
00075 ps_daqst->l_fix_lw = ((long)&ps_daqst->c_pname[0][0]-(long)ps_daqst)/4;
00076 ps_daqst->l_sys__n_max_procs = SYS__N_MAX_PROCS;
00077 ps_daqst->l_sbs__str_len_64 = SBS__STR_LEN_64;
00078 ps_daqst->l_sbs__n_trg_typ = SBS__N_TRG_TYP;
00079 ps_daqst->bh_daqst_initalized = 1;
00080
00081 return 0;
00082 }
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112 INTS4 f_ut_status(s_daqst *ps_daqst, INTS4 l_tcp)
00113 {
00114 INTS4 l,l_status;
00115
00116 l = ps_daqst->l_fix_lw * 4 + ps_daqst->l_procs_run * ps_daqst->l_sbs__str_len_64;
00117
00118 l_status = f_stc_write (ps_daqst, l, l_tcp);
00119 return l_status;
00120 }
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150 INTS4 f_ut_status_r(s_daqst *ps_daqst, INTS4 l_tcp)
00151 {
00152 INTS4 l_swap=0, len_64, n_trg, max_proc;
00153 INTS4 l_cmd;
00154 INTS4 i,k;
00155 INTS4 l_status;
00156 INTU4 *pc;
00157
00158 memset((void *)ps_daqst,0,sizeof(s_daqst));
00159 l_cmd=1;
00160 l_status = f_stc_write (&l_cmd,4,l_tcp); if (l_status != STC__SUCCESS) return(-1);
00161 l_status = f_stc_read (&ps_daqst->l_endian,28,l_tcp,-1); if (l_status != STC__SUCCESS) return(-1);
00162 if(ps_daqst->l_endian != 1) l_swap = 1;
00163 if(l_swap == 1) l_status = f_swaplw(&ps_daqst->l_endian,7,NULL);
00164 len_64=ps_daqst->l_sbs__str_len_64;
00165 n_trg=ps_daqst->l_sbs__n_trg_typ;
00166 max_proc=ps_daqst->l_sys__n_max_procs;
00167 if(ps_daqst->l_version == 1)
00168 {
00169
00170 return(-1);
00171 }
00172
00173 if(ps_daqst->l_version == 2)
00174 {
00175 k=(48+n_trg*3)*4;
00176 l_status = f_stc_read (&ps_daqst->bh_daqst_initalized, k , l_tcp,-1);
00177 k=(24+max_proc*5)*4;
00178 l_status = f_stc_read (&ps_daqst->bh_running[0], k , l_tcp,-1);
00179 k=len_64*15;
00180 l_status = f_stc_read (&ps_daqst->c_user[0], k , l_tcp,-1);
00181 l_status = f_stc_read (&ps_daqst->c_out_chan[0], len_64 , l_tcp,-1);
00182 ps_daqst->l_fix_lw += n_trg*3 + 212 + len_64/4*3;
00183 if(l_swap == 1)
00184 l_status = f_swaplw(&ps_daqst->bh_daqst_initalized, (ps_daqst->l_fix_lw-7) - (19 * len_64/4),NULL);
00185 }
00186
00187 if((ps_daqst->l_version == 51) || (ps_daqst->l_version == 62))
00188 {
00189 l_status = f_stc_read (&ps_daqst->bh_daqst_initalized, (ps_daqst->l_fix_lw-7)*4 , l_tcp,-1);
00190 if(l_swap == 1)
00191 l_status = f_swaplw(&ps_daqst->bh_daqst_initalized, (ps_daqst->l_fix_lw-7) - (19 * len_64/4),NULL);
00192 }
00193
00194
00195
00196 l_status = f_stc_read (&ps_daqst->c_pname[0], ps_daqst->l_procs_run * len_64 -1, l_tcp,-1);
00197 return l_status;
00198 }
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227 INTS4 f_ut_setup_ini(s_setup *ps_setup)
00228 {
00229 if(ps_setup == NULL) return -1;
00230 ps_setup->l_endian = 1;
00231 ps_setup->l_version = VERSION__SETUP;
00232 ps_setup->bl_struc_len = sizeof(s_setup)/4;
00233 ps_setup->l_fix_lw = ((long)&ps_setup->lp_rem_mem_base[0]-(long)ps_setup)/4;
00234 ps_setup->bl_sbs__n_cr = SBS__N_CR;
00235 ps_setup->bl_sbs__n_trg_typ = SBS__N_TRG_TYP;
00236 return 0;
00237 }
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268 INTS4 f_ut_setup(s_setup *ps_setup, INTU4 *pl_o, INTS4 l_tcp)
00269 {
00270 INTS4 i,l,k,n=0,l_status;
00271 INTU4 *pl_count,*pl_s,*pl_size;
00272
00273 l_status = f_ut_setup_ini(ps_setup);
00274
00275
00276 l_status = f_stc_write (ps_setup, ps_setup->l_fix_lw*4, l_tcp);
00277 pl_count = pl_o++;
00278 pl_size = pl_o++;
00279 l = 0;
00280 for(i=0; i<ps_setup->bl_sbs__n_cr; i++)
00281 {
00282 if(ps_setup->bh_rd_flg[i] != 0)
00283 {
00284 n=0;
00285 l++;
00286 *pl_o++ = i; n++;
00287 *pl_o++ = (INTU4) ps_setup->lp_rem_mem_base[i]; n++;
00288 *pl_o++ = (INTU4) ps_setup->bl_rem_mem_off[i]; n++;
00289 *pl_o++ = (INTU4) ps_setup->bl_rem_mem_len[i]; n++;
00290 *pl_o++ = (INTU4) ps_setup->lp_rem_cam_base[i]; n++;
00291 *pl_o++ = (INTU4) ps_setup->bl_rem_cam_off[i]; n++;
00292 *pl_o++ = (INTU4) ps_setup->bl_rem_cam_len[i]; n++;
00293 *pl_o++ = (INTU4) ps_setup->lp_loc_mem_base[i]; n++;
00294 *pl_o++ = (INTU4) ps_setup->bl_loc_mem_len[i]; n++;
00295 *pl_o++ = (INTU4) ps_setup->lp_loc_pipe_base[i]; n++;
00296 *pl_o++ = (INTU4) ps_setup->bl_pipe_off[i]; n++;
00297 *pl_o++ = (INTU4) ps_setup->bl_pipe_seg_len[i]; n++;
00298 *pl_o++ = (INTU4) ps_setup->bl_pipe_len[i]; n++;
00299 *pl_o++ = (INTU4) ps_setup->bh_controller_id[i]; n++;
00300 *pl_o++ = (INTU4) ps_setup->bh_sy_asy_flg[i]; n++;
00301 *pl_o++ = (INTU4) ps_setup->bh_trig_stat_nr[i]; n++;
00302 *pl_o++ = (INTU4) ps_setup->bl_trig_cvt[i]; n++;
00303 *pl_o++ = (INTU4) ps_setup->bl_trig_fct[i]; n++;
00304 *pl_o++ = (INTU4) ps_setup->i_se_typ[i]; n++;
00305 *pl_o++ = (INTU4) ps_setup->i_se_subtyp[i]; n++;
00306 *pl_o++ = (INTU4) ps_setup->i_se_procid[i]; n++;
00307 *pl_o++ = (INTU4) ps_setup->bh_rd_flg[i]; n++;
00308 *pl_o++ = (INTU4) ps_setup->bl_init_tab_off[i]; n++;
00309 *pl_o++ = (INTU4) ps_setup->bi_init_tab_len[i]; n++;
00310 for(k=0;k<ps_setup->bl_sbs__n_trg_typ;k++)
00311 *pl_o++ = (INTU4) ps_setup->bl_max_se_len[i][k];
00312 for(k=0;k<ps_setup->bl_sbs__n_trg_typ;k++)
00313 *pl_o++ = (INTU4) ps_setup->bl_rd_tab_off[i][k];
00314 for(k=0;k<ps_setup->bl_sbs__n_trg_typ;k++)
00315 *pl_o++ = (INTU4) ps_setup->bi_rd_tab_len[i][k];
00316 n = n + 3 * ps_setup->bl_sbs__n_trg_typ;
00317 }
00318 }
00319 *pl_count=l;
00320 *pl_size=n;
00321 l = l * n + 2;
00322
00323 l_status = f_stc_write (pl_count, l * 4, l_tcp);
00324 return l_status;
00325 }
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355 INTS4 f_ut_setup_r(s_setup *ps_setup, INTS4 l_tcp)
00356 {
00357 INTS4 l_swap=0;
00358 INTS4 l_cmd;
00359 INTS4 i,k,l_items,l_size,l_crate;
00360 INTS4 *pl_b,*pl_o;
00361 INTS4 l_status;
00362
00363 memset(ps_setup,0,sizeof(s_setup));
00364 l_cmd=2;
00365 l_status = f_stc_write (&l_cmd,4,l_tcp); if (l_status != STC__SUCCESS) return(-1);
00366 l_status = f_stc_read (&ps_setup->l_endian,16,l_tcp,-1); if (l_status != STC__SUCCESS) return(-1);
00367 if(ps_setup->l_endian != 1) l_swap = 1;
00368 if(l_swap == 1) l_status = f_swaplw(&ps_setup->l_endian,4,NULL);
00369 if(ps_setup->l_version != VERSION__SETUP) return -1;
00370 l_status = f_stc_read (&ps_setup->bl_sbs__n_cr, (ps_setup->l_fix_lw-4)*4 , l_tcp,-1);
00371 l_status = f_stc_read (&l_items,4 , l_tcp,-1);
00372 l_status = f_stc_read (&l_size,4 , l_tcp,-1);
00373 if(l_swap == 1) l_status = f_swaplw(&ps_setup->bl_sbs__n_cr, (ps_setup->l_fix_lw-4),NULL);
00374 if(l_swap == 1) l_status = f_swaplw(&l_items,1,NULL);
00375 if(l_swap == 1) l_status = f_swaplw(&l_size,1,NULL);
00376 pl_b = (INTS4 *) malloc(l_size * l_items * 4);
00377 l_status = f_stc_read (pl_b,l_size * l_items * 4, l_tcp,-1);
00378 if(l_swap == 1) l_status = f_swaplw(pl_b,l_size * l_items,NULL);
00379
00380 pl_o = pl_b;
00381 for(i=0;i<l_items;i++)
00382 {
00383 l_crate = *pl_o++;
00384 ps_setup->lp_rem_mem_base[l_crate] = *pl_o++;
00385 ps_setup->bl_rem_mem_off[l_crate] = *pl_o++;
00386 ps_setup->bl_rem_mem_len[l_crate] = *pl_o++;
00387 ps_setup->lp_rem_cam_base[l_crate] = *pl_o++;
00388 ps_setup->bl_rem_cam_off[l_crate] = *pl_o++;
00389 ps_setup->bl_rem_cam_len[l_crate] = *pl_o++;
00390 ps_setup->lp_loc_mem_base[l_crate] = *pl_o++;
00391 ps_setup->bl_loc_mem_len[l_crate] = *pl_o++;
00392 ps_setup->lp_loc_pipe_base[l_crate] = *pl_o++;
00393 ps_setup->bl_pipe_off[l_crate] = *pl_o++;
00394 ps_setup->bl_pipe_seg_len[l_crate] = *pl_o++;
00395 ps_setup->bl_pipe_len[l_crate] = *pl_o++;
00396 ps_setup->bh_controller_id[l_crate] = *pl_o++;
00397 ps_setup->bh_sy_asy_flg[l_crate] = *pl_o++;
00398 ps_setup->bh_trig_stat_nr[l_crate] = *pl_o++;
00399 ps_setup->bl_trig_cvt[l_crate] = *pl_o++;
00400 ps_setup->bl_trig_fct[l_crate] = *pl_o++;
00401 ps_setup->i_se_typ[l_crate] = *pl_o++;
00402 ps_setup->i_se_subtyp[l_crate] = *pl_o++;
00403 ps_setup->i_se_procid[l_crate] = *pl_o++;
00404 ps_setup->bh_rd_flg[l_crate] = *pl_o++;
00405 ps_setup->bl_init_tab_off[l_crate] = *pl_o++;
00406 ps_setup->bi_init_tab_len[l_crate] = *pl_o++;
00407 for(k=0;k<ps_setup->bl_sbs__n_trg_typ;k++) ps_setup->bl_max_se_len[l_crate][k] = *pl_o++;
00408 for(k=0;k<ps_setup->bl_sbs__n_trg_typ;k++) ps_setup->bl_rd_tab_off[l_crate][k] = *pl_o++;
00409 for(k=0;k<ps_setup->bl_sbs__n_trg_typ;k++) ps_setup->bi_rd_tab_len[l_crate][k] = *pl_o++;
00410 }
00411 free(pl_b);
00412 return 0;
00413 }
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442 INTS4 f_ut_set_ml_ini(s_set_ml *ps_set_ml)
00443 {
00444 if(ps_set_ml == NULL) return -1;
00445 ps_set_ml->l_endian = 1;
00446 ps_set_ml->l_version = VERSION__SET_ML;
00447 ps_set_ml->l_set_ml_lw = sizeof(s_set_ml)/4;
00448 ps_set_ml->l_fix_lw = ((long)&ps_set_ml->c_rd_hostname[0][0]-(long)ps_set_ml)/4;
00449 ps_set_ml->l_ml__n_rd_pipe = ML__N_RD_PIPE;
00450 ps_set_ml->l_short_len = 16;
00451 ps_set_ml->l_long_len = 128;
00452 return 0;
00453 }
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484 INTS4 f_ut_set_ml(s_set_ml *ps_set_ml, INTU4 *pl_o, INTS4 l_tcp)
00485 {
00486 INTS4 i,l,k,n=0,l_status;
00487 INTU4 *pl_count,*pl_s,*pl_size;
00488
00489 l_status = f_ut_set_ml_ini(ps_set_ml);
00490
00491 pl_count = pl_o;
00492
00493 l_status = f_stc_write (ps_set_ml, ps_set_ml->l_fix_lw*4, l_tcp);
00494 l = 0;
00495 for(i=0; i<ps_set_ml->l_n_rd_pipe; i++)
00496 {
00497 l++;
00498 pl_s = (INTU4 *)&ps_set_ml->c_rd_hostname[i];
00499 for(k=0;k<ps_set_ml->l_short_len/4;k++)*pl_o++ = *pl_s++;
00500 pl_s = (INTU4 *)&ps_set_ml->c_sbs_setup_path[i];
00501 for(k=0;k<ps_set_ml->l_long_len/4;k++)*pl_o++ = *pl_s++;
00502 }
00503 l = l * (ps_set_ml->l_short_len + ps_set_ml->l_long_len);
00504
00505 l_status = f_stc_write (pl_count, l , l_tcp);
00506 return l_status;
00507 }
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533
00534
00535
00536
00537 INTS4 f_ut_set_ml_r(s_set_ml *ps_set_ml, INTS4 l_tcp)
00538 {
00539 INTS4 l_swap=0;
00540 INTS4 l_cmd;
00541 INTS4 i;
00542 INTS4 l_status;
00543
00544 l_cmd=3;
00545 l_status = f_stc_write (&l_cmd,4, l_tcp); if (l_status != STC__SUCCESS) return(-1);
00546 l_status = f_stc_read (&ps_set_ml->l_endian,16,l_tcp,-1); if (l_status != STC__SUCCESS) return(-1);
00547 if(ps_set_ml->l_endian != 1) l_swap = 1;
00548 if(l_swap == 1) l_status = f_swaplw(&ps_set_ml->l_endian,4,NULL);
00549 if(ps_set_ml->l_version != VERSION__SET_ML) return -1;
00550 l_status = f_stc_read (&ps_set_ml->l_ml__n_rd_pipe,(ps_set_ml->l_fix_lw-4)*4 , l_tcp,-1);
00551 if(l_swap == 1) l_status = f_swaplw(&ps_set_ml->l_ml__n_rd_pipe,(ps_set_ml->l_fix_lw-4)-4,NULL);
00552 for(i=0;i<ps_set_ml->l_n_rd_pipe;i++)
00553 {
00554 l_status = f_stc_read (&ps_set_ml->c_rd_hostname[i], ps_set_ml->l_short_len, l_tcp,-1);
00555 l_status = f_stc_read (&ps_set_ml->c_sbs_setup_path[i],ps_set_ml->l_long_len, l_tcp,-1);
00556 }
00557 return 0;
00558 }
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586 INTS4 f_ut_set_mo_ini(s_set_mo *ps_set_mo)
00587 {
00588 INTS4 i;
00589 if(ps_set_mo == NULL) return -1;
00590 ps_set_mo->l_endian = 1;
00591 ps_set_mo->l_version = VERSION__SET_MO;
00592 ps_set_mo->l_set_mo_lw = sizeof(s_set_mo)/4;
00593 ps_set_mo->l_swap_lw = ((long)&ps_set_mo->c_ds_hostname[0][0]-(long)ps_set_mo)/4;
00594 ps_set_mo->l_max_nodes = MO__N_NODE;
00595 ps_set_mo->l_no_senders = 0;
00596 ps_set_mo->l_no_receivers = 0;
00597 for(i=0;i<MO__N_NODE;i++)if(strlen(&ps_set_mo->c_ds_hostname[i][0]) > 0) ps_set_mo->l_no_senders++;
00598 for(i=0;i<MO__N_NODE;i++)if(strlen(&ps_set_mo->c_dr_hostname[i][0]) > 0) ps_set_mo->l_no_receivers++;
00599 return 0;
00600 }
00601
00602
00603
00604
00605
00606
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623 INTS4 f_ut_set_mo(s_set_mo *ps_set_mo, INTS4 l_tcp)
00624 {
00625 INTS4 l,l_status;
00626
00627 l_status=f_ut_set_mo_ini(ps_set_mo);
00628 if(l_status != 0) return l_status;
00629 l_status = f_stc_write (ps_set_mo, ps_set_mo->l_set_mo_lw*4, l_tcp);
00630 return l_status;
00631 }
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642
00643
00644
00645
00646
00647
00648
00649
00650
00651
00652
00653
00654
00655
00656 INTS4 f_ut_set_mo_r(s_set_mo *ps_set_mo, INTS4 l_tcp)
00657 {
00658 INTS4 l_swap=0;
00659 INTS4 l_cmd;
00660 INTS4 l_status;
00661
00662 l_cmd=4;
00663 l_status = f_stc_write (&l_cmd,4, l_tcp); if (l_status != STC__SUCCESS) return(-1);
00664 l_status = f_stc_read (ps_set_mo,16,l_tcp,-1); if (l_status != STC__SUCCESS) return(-1);
00665 if(ps_set_mo->l_endian != 1) l_swap=1;
00666 if(l_swap) l_status = f_swaplw(ps_set_mo,4,NULL);
00667
00668 l_status = f_stc_read (&ps_set_mo->l_max_nodes,(ps_set_mo->l_set_mo_lw-4)*4, l_tcp,-1);
00669 if(l_swap) l_status = f_swaplw(&ps_set_mo->l_max_nodes,ps_set_mo->l_swap_lw-4,NULL);
00670
00671 return 0;
00672 }