00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "typedefs.h"
00017 #include <stdio.h>
00018 #include <errno.h>
00019 #include <string.h>
00020 #include <memory.h>
00021 #include <sys/types.h>
00022 #include <ctype.h>
00023 #include "sbs_def.h"
00024 #include "sys_def.h"
00025 #include "ml_def.h"
00026 #include "s_daqst.h"
00027 #include "s_setup.h"
00028 #include "s_set_ml.h"
00029 #include "s_set_mo.h"
00030 #include "f_stccomm.h"
00031
00032 #define VERSION__DAQST 2
00033 #define VERSION__SETUP 1
00034 #define VERSION__SET_ML 1
00035 #define VERSION__SET_MO 1
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063 INTS4 f_ut_status_ini(s_daqst *ps_daqst)
00064 {
00065 if(ps_daqst == NULL) return -1;
00066
00067 ps_daqst->l_endian = 1;
00068 ps_daqst->l_version = VERSION__DAQST;
00069 ps_daqst->l_daqst_lw = sizeof(s_daqst)/4;
00070 ps_daqst->l_fix_lw = ((int)&ps_daqst->c_pname[0][0]-(int)ps_daqst)/4;
00071 ps_daqst->l_sys__n_max_procs = SYS__N_MAX_PROCS;
00072 ps_daqst->l_sbs__str_len_64 = SBS__STR_LEN_64;
00073 ps_daqst->l_sbs__n_trg_typ = SBS__N_TRG_TYP;
00074 ps_daqst->bh_daqst_initalized = 1;
00075
00076 return 0;
00077 }
00078
00079
00080
00081
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 INTS4 f_ut_status(s_daqst *ps_daqst, INTS4 l_tcp)
00108 {
00109 INTS4 l,l_status;
00110
00111 l = ps_daqst->l_fix_lw * 4 + ps_daqst->l_procs_run * ps_daqst->l_sbs__str_len_64;
00112
00113 l_status = f_stc_write (ps_daqst, l, l_tcp);
00114 return l_status;
00115 }
00116
00117
00118
00119
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 INTS4 f_ut_status_r(s_daqst *ps_daqst, INTS4 l_tcp)
00146 {
00147 INTS4 l_swap=0;
00148 INTS4 l_cmd;
00149 INTS4 i,k;
00150 INTS4 l_status;
00151 INTU4 *pc;
00152
00153 memset((void *)ps_daqst,0,sizeof(s_daqst));
00154 l_cmd=1;
00155 l_status = f_stc_write (&l_cmd,4,l_tcp); if (l_status != STC__SUCCESS) return(-1);
00156 l_status = f_stc_read (&ps_daqst->l_endian,28,l_tcp,-1); if (l_status != STC__SUCCESS) return(-1);
00157 if(ps_daqst->l_endian != 1) l_swap = 1;
00158 if(l_swap == 1) l_status = f_swaplw(&ps_daqst->l_endian,7,NULL);
00159 if(ps_daqst->l_version == 1)
00160 {
00161 if(ps_daqst->l_daqst_lw > 1000)
00162 {
00163 k=(ps_daqst->l_fix_lw-7)*4-16 * SBS__STR_LEN_64;
00164 l_status = f_stc_read (&ps_daqst->bh_daqst_initalized, k , l_tcp,-1);
00165 if(l_swap == 1) l_status = f_swaplw(&ps_daqst->bh_daqst_initalized, k/4,NULL);
00166
00167 l_status = f_stc_read (&ps_daqst->c_user, 16 * SBS__STR_LEN_64 , l_tcp,-1);
00168 }
00169 else
00170 {
00171 k = 17 + 5*ps_daqst->l_sys__n_max_procs + 3*ps_daqst->l_sbs__n_trg_typ + 16*ps_daqst->l_sbs__str_len_64/4;
00172 l_status = f_stc_read (&ps_daqst->bh_daqst_initalized,(ps_daqst->l_fix_lw-7-k)*4 , l_tcp,-1);
00173 l_status = f_stc_read (&ps_daqst->bl_n_trig[0], ps_daqst->l_sbs__n_trg_typ*4 , l_tcp,-1);
00174 l_status = f_stc_read (&ps_daqst->bl_n_si [0], ps_daqst->l_sbs__n_trg_typ*4 , l_tcp,-1);
00175 l_status = f_stc_read (&ps_daqst->bl_n_evt [0], ps_daqst->l_sbs__n_trg_typ*4 , l_tcp,-1);
00176 l_status = f_stc_read (&ps_daqst->bh_running[0], ps_daqst->l_sys__n_max_procs*4 , l_tcp,-1);
00177 l_status = f_stc_read (&ps_daqst->l_pid[0], ps_daqst->l_sys__n_max_procs*4 , l_tcp,-1);
00178 l_status = f_stc_read (&ps_daqst->l_type[0], ps_daqst->l_sys__n_max_procs*4 , l_tcp,-1);
00179 l_status = f_stc_read (&ps_daqst->l_pprio[0], ps_daqst->l_sys__n_max_procs*4 , l_tcp,-1);
00180 l_status = f_stc_read (&ps_daqst-> bh_pact[0], ps_daqst->l_sys__n_max_procs*4 , l_tcp,-1);
00181 l_status = f_stc_read (&ps_daqst->bh_verbose_flg, 17*4 , l_tcp,-1);
00182 k = 17 + 5*SYS__N_MAX_PROCS + 3*SBS__N_TRG_TYP + 55 -7;
00183 if(l_swap == 1) l_status = f_swaplw(&ps_daqst->bh_daqst_initalized,k,NULL);
00184 l_status = f_stc_read (&ps_daqst->c_user, 16 * SBS__STR_LEN_64 , l_tcp,-1);
00185 }
00186 }
00187 if(ps_daqst->l_version == 2)
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) l_status = f_swaplw(&ps_daqst->bh_daqst_initalized, (ps_daqst->l_fix_lw-7) - (16 * SBS__STR_LEN_64/4),NULL);
00191 }
00192
00193
00194 l_status = f_stc_read (&ps_daqst->c_pname[0], ps_daqst->l_procs_run * ps_daqst->l_sbs__str_len_64 , l_tcp,-1);
00195 return l_status;
00196 }
00197
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 INTS4 f_ut_setup_ini(s_setup *ps_setup)
00226 {
00227 if(ps_setup == NULL) return -1;
00228 ps_setup->l_endian = 1;
00229 ps_setup->l_version = VERSION__SETUP;
00230 ps_setup->bl_struc_len = sizeof(s_setup)/4;
00231 ps_setup->l_fix_lw = ((int)&ps_setup->lp_rem_mem_base[0]-(int)ps_setup)/4;
00232 ps_setup->bl_sbs__n_cr = SBS__N_CR;
00233 ps_setup->bl_sbs__n_trg_typ = SBS__N_TRG_TYP;
00234 return 0;
00235 }
00236
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 INTS4 f_ut_setup(s_setup *ps_setup, INTU4 *pl_o, INTS4 l_tcp)
00267 {
00268 INTS4 i,l,k,n=0,l_status;
00269 INTU4 *pl_count,*pl_s,*pl_size;
00270
00271 l_status = f_ut_setup_ini(ps_setup);
00272
00273
00274 l_status = f_stc_write (ps_setup, ps_setup->l_fix_lw*4, l_tcp);
00275 pl_count = pl_o++;
00276 pl_size = pl_o++;
00277 l = 0;
00278 for(i=0; i<ps_setup->bl_sbs__n_cr; i++)
00279 {
00280 if(ps_setup->bh_rd_flg[i] != 0)
00281 {
00282 n=0;
00283 l++;
00284 *pl_o++ = i; n++;
00285 *pl_o++ = (INTU4) ps_setup->lp_rem_mem_base[i]; n++;
00286 *pl_o++ = (INTU4) ps_setup->bl_rem_mem_off[i]; n++;
00287 *pl_o++ = (INTU4) ps_setup->bl_rem_mem_len[i]; n++;
00288 *pl_o++ = (INTU4) ps_setup->lp_rem_cam_base[i]; n++;
00289 *pl_o++ = (INTU4) ps_setup->bl_rem_cam_off[i]; n++;
00290 *pl_o++ = (INTU4) ps_setup->bl_rem_cam_len[i]; n++;
00291 *pl_o++ = (INTU4) ps_setup->lp_loc_mem_base[i]; n++;
00292 *pl_o++ = (INTU4) ps_setup->bl_loc_mem_len[i]; n++;
00293 *pl_o++ = (INTU4) ps_setup->lp_loc_pipe_base[i]; n++;
00294 *pl_o++ = (INTU4) ps_setup->bl_pipe_off[i]; n++;
00295 *pl_o++ = (INTU4) ps_setup->bl_pipe_seg_len[i]; n++;
00296 *pl_o++ = (INTU4) ps_setup->bl_pipe_len[i]; n++;
00297 *pl_o++ = (INTU4) ps_setup->bh_controller_id[i]; n++;
00298 *pl_o++ = (INTU4) ps_setup->bh_sy_asy_flg[i]; n++;
00299 *pl_o++ = (INTU4) ps_setup->bh_trig_stat_nr[i]; n++;
00300 *pl_o++ = (INTU4) ps_setup->bl_trig_cvt[i]; n++;
00301 *pl_o++ = (INTU4) ps_setup->bl_trig_fct[i]; n++;
00302 *pl_o++ = (INTU4) ps_setup->i_se_typ[i]; n++;
00303 *pl_o++ = (INTU4) ps_setup->i_se_subtyp[i]; n++;
00304 *pl_o++ = (INTU4) ps_setup->i_se_procid[i]; n++;
00305 *pl_o++ = (INTU4) ps_setup->bh_rd_flg[i]; n++;
00306 *pl_o++ = (INTU4) ps_setup->bl_init_tab_off[i]; n++;
00307 *pl_o++ = (INTU4) ps_setup->bi_init_tab_len[i]; n++;
00308 for(k=0;k<ps_setup->bl_sbs__n_trg_typ;k++)
00309 *pl_o++ = (INTU4) ps_setup->bl_max_se_len[i][k];
00310 for(k=0;k<ps_setup->bl_sbs__n_trg_typ;k++)
00311 *pl_o++ = (INTU4) ps_setup->bl_rd_tab_off[i][k];
00312 for(k=0;k<ps_setup->bl_sbs__n_trg_typ;k++)
00313 *pl_o++ = (INTU4) ps_setup->bi_rd_tab_len[i][k];
00314 n = n + 3 * ps_setup->bl_sbs__n_trg_typ;
00315 }
00316 }
00317 *pl_count=l;
00318 *pl_size=n;
00319 l = l * n + 2;
00320
00321 l_status = f_stc_write (pl_count, l * 4, l_tcp);
00322 return l_status;
00323 }
00324
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 INTS4 f_ut_setup_r(s_setup *ps_setup, INTS4 l_tcp)
00354 {
00355 INTS4 l_swap=0;
00356 INTS4 l_cmd;
00357 INTS4 i,k,l_items,l_size,l_crate;
00358 INTS4 *pl_b,*pl_o;
00359 INTS4 l_status;
00360
00361 memset(ps_setup,0,sizeof(s_setup));
00362 l_cmd=2;
00363 l_status = f_stc_write (&l_cmd,4,l_tcp); if (l_status != STC__SUCCESS) return(-1);
00364 l_status = f_stc_read (&ps_setup->l_endian,16,l_tcp,-1); if (l_status != STC__SUCCESS) return(-1);
00365 if(ps_setup->l_endian != 1) l_swap = 1;
00366 if(l_swap == 1) l_status = f_swaplw(&ps_setup->l_endian,4,NULL);
00367 if(ps_setup->l_version != VERSION__SETUP) return -1;
00368 l_status = f_stc_read (&ps_setup->bl_sbs__n_cr, (ps_setup->l_fix_lw-4)*4 , l_tcp,-1);
00369 l_status = f_stc_read (&l_items,4 , l_tcp,-1);
00370 l_status = f_stc_read (&l_size,4 , l_tcp,-1);
00371 if(l_swap == 1) l_status = f_swaplw(&ps_setup->bl_sbs__n_cr, (ps_setup->l_fix_lw-4),NULL);
00372 if(l_swap == 1) l_status = f_swaplw(&l_items,1,NULL);
00373 if(l_swap == 1) l_status = f_swaplw(&l_size,1,NULL);
00374 pl_b = (INTS4 *) malloc(l_size * l_items * 4);
00375 l_status = f_stc_read (pl_b,l_size * l_items * 4, l_tcp,-1);
00376 if(l_swap == 1) l_status = f_swaplw(pl_b,l_size * l_items,NULL);
00377
00378 pl_o = pl_b;
00379 for(i=0;i<l_items;i++)
00380 {
00381 l_crate = *pl_o++;
00382 ps_setup->lp_rem_mem_base[l_crate] = *pl_o++;
00383 ps_setup->bl_rem_mem_off[l_crate] = *pl_o++;
00384 ps_setup->bl_rem_mem_len[l_crate] = *pl_o++;
00385 ps_setup->lp_rem_cam_base[l_crate] = *pl_o++;
00386 ps_setup->bl_rem_cam_off[l_crate] = *pl_o++;
00387 ps_setup->bl_rem_cam_len[l_crate] = *pl_o++;
00388 ps_setup->lp_loc_mem_base[l_crate] = *pl_o++;
00389 ps_setup->bl_loc_mem_len[l_crate] = *pl_o++;
00390 ps_setup->lp_loc_pipe_base[l_crate] = *pl_o++;
00391 ps_setup->bl_pipe_off[l_crate] = *pl_o++;
00392 ps_setup->bl_pipe_seg_len[l_crate] = *pl_o++;
00393 ps_setup->bl_pipe_len[l_crate] = *pl_o++;
00394 ps_setup->bh_controller_id[l_crate] = *pl_o++;
00395 ps_setup->bh_sy_asy_flg[l_crate] = *pl_o++;
00396 ps_setup->bh_trig_stat_nr[l_crate] = *pl_o++;
00397 ps_setup->bl_trig_cvt[l_crate] = *pl_o++;
00398 ps_setup->bl_trig_fct[l_crate] = *pl_o++;
00399 ps_setup->i_se_typ[l_crate] = *pl_o++;
00400 ps_setup->i_se_subtyp[l_crate] = *pl_o++;
00401 ps_setup->i_se_procid[l_crate] = *pl_o++;
00402 ps_setup->bh_rd_flg[l_crate] = *pl_o++;
00403 ps_setup->bl_init_tab_off[l_crate] = *pl_o++;
00404 ps_setup->bi_init_tab_len[l_crate] = *pl_o++;
00405 for(k=0;k<ps_setup->bl_sbs__n_trg_typ;k++) ps_setup->bl_max_se_len[l_crate][k] = *pl_o++;
00406 for(k=0;k<ps_setup->bl_sbs__n_trg_typ;k++) ps_setup->bl_rd_tab_off[l_crate][k] = *pl_o++;
00407 for(k=0;k<ps_setup->bl_sbs__n_trg_typ;k++) ps_setup->bi_rd_tab_len[l_crate][k] = *pl_o++;
00408 }
00409 free(pl_b);
00410 return 0;
00411 }
00412
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 INTS4 f_ut_set_ml_ini(s_set_ml *ps_set_ml)
00441 {
00442 if(ps_set_ml == NULL) return -1;
00443 ps_set_ml->l_endian = 1;
00444 ps_set_ml->l_version = VERSION__SET_ML;
00445 ps_set_ml->l_set_ml_lw = sizeof(s_set_ml)/4;
00446 ps_set_ml->l_fix_lw = ((int)&ps_set_ml->c_rd_hostname[0][0]-(int)ps_set_ml)/4;
00447 ps_set_ml->l_ml__n_rd_pipe = ML__N_RD_PIPE;
00448 ps_set_ml->l_short_len = 16;
00449 ps_set_ml->l_long_len = 128;
00450 return 0;
00451 }
00452
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 INTS4 f_ut_set_ml(s_set_ml *ps_set_ml, INTU4 *pl_o, INTS4 l_tcp)
00483 {
00484 INTS4 i,l,k,n=0,l_status;
00485 INTU4 *pl_count,*pl_s,*pl_size;
00486
00487 l_status = f_ut_set_ml_ini(ps_set_ml);
00488
00489 pl_count = pl_o;
00490
00491 l_status = f_stc_write (ps_set_ml, ps_set_ml->l_fix_lw*4, l_tcp);
00492 l = 0;
00493 for(i=0; i<ps_set_ml->l_n_rd_pipe; i++)
00494 {
00495 l++;
00496 pl_s = (INTU4 *)&ps_set_ml->c_rd_hostname[i];
00497 for(k=0;k<ps_set_ml->l_short_len/4;k++)*pl_o++ = *pl_s++;
00498 pl_s = (INTU4 *)&ps_set_ml->c_sbs_setup_path[i];
00499 for(k=0;k<ps_set_ml->l_long_len/4;k++)*pl_o++ = *pl_s++;
00500 }
00501 l = l * (ps_set_ml->l_short_len + ps_set_ml->l_long_len);
00502
00503 l_status = f_stc_write (pl_count, l , l_tcp);
00504 return l_status;
00505 }
00506
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 INTS4 f_ut_set_ml_r(s_set_ml *ps_set_ml, INTS4 l_tcp)
00536 {
00537 INTS4 l_swap=0;
00538 INTS4 l_cmd;
00539 INTS4 i;
00540 INTS4 l_status;
00541
00542 l_cmd=3;
00543 l_status = f_stc_write (&l_cmd,4, l_tcp); if (l_status != STC__SUCCESS) return(-1);
00544 l_status = f_stc_read (&ps_set_ml->l_endian,16,l_tcp,-1); if (l_status != STC__SUCCESS) return(-1);
00545 if(ps_set_ml->l_endian != 1) l_swap = 1;
00546 if(l_swap == 1) l_status = f_swaplw(&ps_set_ml->l_endian,4,NULL);
00547 if(ps_set_ml->l_version != VERSION__SET_ML) return -1;
00548 l_status = f_stc_read (&ps_set_ml->l_ml__n_rd_pipe,(ps_set_ml->l_fix_lw-4)*4 , l_tcp,-1);
00549 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);
00550 for(i=0;i<ps_set_ml->l_n_rd_pipe;i++)
00551 {
00552 l_status = f_stc_read (&ps_set_ml->c_rd_hostname[i], ps_set_ml->l_short_len, l_tcp,-1);
00553 l_status = f_stc_read (&ps_set_ml->c_sbs_setup_path[i],ps_set_ml->l_long_len, l_tcp,-1);
00554 }
00555 return 0;
00556 }
00557
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 INTS4 f_ut_set_mo_ini(s_set_mo *ps_set_mo)
00585 {
00586 INTS4 i;
00587 if(ps_set_mo == NULL) return -1;
00588 ps_set_mo->l_endian = 1;
00589 ps_set_mo->l_version = VERSION__SET_MO;
00590 ps_set_mo->l_set_mo_lw = sizeof(s_set_mo)/4;
00591 ps_set_mo->l_swap_lw = ((int)&ps_set_mo->c_ds_hostname[0][0]-(int)ps_set_mo)/4;
00592 ps_set_mo->l_max_nodes = MO__N_NODE;
00593 ps_set_mo->l_no_senders = 0;
00594 ps_set_mo->l_no_receivers = 0;
00595 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++;
00596 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++;
00597 return 0;
00598 }
00599
00600
00601
00602
00603
00604
00605
00606
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621 INTS4 f_ut_set_mo(s_set_mo *ps_set_mo, INTS4 l_tcp)
00622 {
00623 INTS4 l,l_status;
00624
00625 l_status=f_ut_set_mo_ini(ps_set_mo);
00626 if(l_status != 0) return l_status;
00627 l_status = f_stc_write (ps_set_mo, ps_set_mo->l_set_mo_lw*4, l_tcp);
00628 return l_status;
00629 }
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642
00643
00644
00645
00646
00647
00648
00649
00650
00651
00652
00653
00654 INTS4 f_ut_set_mo_r(s_set_mo *ps_set_mo, INTS4 l_tcp)
00655 {
00656 INTS4 l_swap=0;
00657 INTS4 l_cmd;
00658 INTS4 l_status;
00659
00660 l_cmd=4;
00661 l_status = f_stc_write (&l_cmd,4, l_tcp); if (l_status != STC__SUCCESS) return(-1);
00662 l_status = f_stc_read (ps_set_mo,16,l_tcp,-1); if (l_status != STC__SUCCESS) return(-1);
00663 if(ps_set_mo->l_endian != 1) l_swap=1;
00664 if(l_swap) l_status = f_swaplw(ps_set_mo,4,NULL);
00665
00666 l_status = f_stc_read (&ps_set_mo->l_max_nodes,(ps_set_mo->l_set_mo_lw-4)*4, l_tcp,-1);
00667 if(l_swap) l_status = f_swaplw(&ps_set_mo->l_max_nodes,ps_set_mo->l_swap_lw-4,NULL);
00668
00669 return 0;
00670 }
00671
00672