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