372 {
380
381
385 rep_file[0] = 0;
396 single = 0;
400
401
403
404
405 for (
i = 1;
i < argc;
i++) {
406 if (strncmp(argv[
i],
"-x", 2) == 0) {
408 goto repusage;
409 if (strncmp(argv[++
i],
"online", 6) != 0) {
411 break;
412 }
413 }
414 }
415 if (rep_flag) {
416
418 for (
i = 1;
i < argc;
i++) {
419 if (argv[
i][0] ==
'-' && argv[
i][1] ==
'd')
421 else if (strncmp(argv[
i],
"-single", 7) == 0)
422 single = 1;
423 else if (strncmp(argv[
i],
"-j", 2) == 0)
425 else if (strncmp(argv[
i],
"-y", 2) == 0)
427 else if (argv[
i][0] ==
'-') {
428 if (
i + 1 >= argc || argv[
i + 1][0] ==
'-')
429 goto repusage;
430 if (strncmp(argv[
i],
"-t", 2) == 0) {
431 mstrlcpy(
str, argv[++
i],
sizeof(
str));
432 if (strncmp(
str,
"m", 1) == 0)
434 }
else if (strncmp(argv[
i],
"-b", 2) == 0)
436 else if (strncmp(argv[
i],
"-i", 2) == 0)
438 else if (strncmp(argv[
i],
"-k", 2) == 0)
440 else if (strncmp(argv[
i],
"-a", 2) == 0)
442 else if (strncmp(argv[
i],
"-m", 2) == 0) {
443 mstrlcpy(
str, argv[++
i],
sizeof(
str));
444 if (strncmp(
str,
"r", 1) == 0)
446 if (strncmp(
str,
"b", 1) == 0)
448 }
else if (strncmp(argv[
i],
"-w", 2) == 0) {
449 mstrlcpy(
str, argv[++
i],
sizeof(
str));
450 if (strncmp(
str,
"h", 1) == 0)
452 else if (strncmp(
str,
"r", 1) == 0)
454 else if (strncmp(
str,
"l", 1) == 0)
456 else if (strncmp(
str,
"e", 1) == 0)
458 else if (strncmp(
str,
"j", 1) == 0)
460 }
else if (strncmp(argv[
i],
"-f", 2) == 0) {
461 mstrlcpy(
str, argv[++
i],
sizeof(
str));
462 if (strncmp(
str,
"d", 1) == 0)
464 if (strncmp(
str,
"x", 1) == 0)
466 if (strncmp(
str,
"a", 1) == 0)
468 }
else if (strncmp(argv[
i],
"-r", 2) == 0)
469 bl = atoi(argv[++
i]);
470 else if (strncmp(argv[
i],
"-x", 2) == 0) {
472 goto repusage;
473 strcpy(rep_file, argv[++
i]);
474 } else {
475 repusage:
476 printf("mdump for replay -x file name : file to inspect\n");
477 printf(" -m mode : Display mode either Bank or raw\n");
478 printf(" -b bank name : search for bank name (case sensitive)\n");
479 printf(" -i evt_id (any) : event id from the FE\n");
480 printf(" -[single] : Request single bank only (to be used with -b)\n");
481 printf(" -y : Serial number consistency check(-i supported)\n");
482 printf(" -j : Display # of banks and bank name list only for all the event\n");
483 printf(" -k mask (any) : trigger_mask from FE setting\n");
484 printf(">>> -i and -k are valid for YBOS ONLY if EVID bank is present in the event\n");
485 printf(" -w what : [h]eader, [r]ecord, [l]ength\n");
486 printf(" [e]vent, [j]bank_list (same as -j)\n");
487 printf(">>> Header & Record are not supported for MIDAS as no physical record structure exists\n");
488 printf(" -f format (auto): data representation ([x]/[d]/[a]scii) def:bank header content\n");
489 printf(" -r # : skip event(MIDAS) to #\n");
490 printf(" -a bytes : max event size to support (defaults to %d bytes)\n",
492 return 0;
493 }
494 }
495 }
496 } else {
497
498 for (
i = 1;
i < argc;
i++) {
499 if (argv[
i][0] ==
'-' && argv[
i][1] ==
'd')
501 else if (strncmp(argv[
i],
"-s", 2) == 0)
503 else if (strncmp(argv[
i],
"-y", 2) == 0)
505 else if (strncmp(argv[
i],
"-j", 2) == 0)
507 else if (argv[
i][0] ==
'-') {
508 if (
i + 1 >= argc || argv[
i + 1][0] ==
'-')
510 else if (strncmp(argv[
i],
"-x", 2) == 0)
511 strncpy(rep_file, argv[++
i], 4);
512 else if (strncmp(argv[
i],
"-b", 2) == 0)
514 else if (strncmp(argv[
i],
"-l", 2) == 0)
516 else if (strncmp(argv[
i],
"-w", 2) == 0)
518 else if (strncmp(argv[
i],
"-m", 2) == 0) {
519 mstrlcpy(
str, argv[++
i],
sizeof(
str));
520 if (strncmp(
str,
"r", 1) == 0)
522 if (strncmp(
str,
"y", 1) == 0)
524 }
else if (strncmp(argv[
i],
"-g", 2) == 0) {
525 mstrlcpy(
str, argv[++
i],
sizeof(
str));
526 if (strncmp(
str,
"s", 1) == 0)
528 if (strncmp(
str,
"a", 1) == 0)
530 }
else if (strncmp(argv[
i],
"-f", 2) == 0) {
531 mstrlcpy(
str, argv[++
i],
sizeof(
str));
532 if (strncmp(
str,
"d", 1) == 0)
534 if (strncmp(
str,
"x", 1) == 0)
536 if (strncmp(
str,
"a", 1) == 0)
538 }
else if (strncmp(argv[
i],
"-i", 2) == 0)
540 else if (strncmp(argv[
i],
"-k", 2) == 0)
542 else if (strncmp(argv[
i],
"-z", 2) == 0)
543 strcpy(buf_name, argv[++
i]);
544 else if (strncmp(argv[
i],
"-t", 2) == 0) {
545 mstrlcpy(
str, argv[++
i],
sizeof(
str));
546 if (strncmp(
str,
"m", 1) == 0)
548 }
else if (strncmp(argv[
i],
"-h", 2) == 0)
550 else if (strncmp(argv[
i],
"-e", 2) == 0)
552 else {
554 printf("mdump for online -l # : display # events (look 1)\n");
555 printf
556 (" -f format (auto): data representation ([x]/[d]/[a]scii) def:bank header content\n");
557 printf
558 (" -w time : insert wait in [sec] between each display\n");
559 printf
560 (" -m mode : Display mode either Bank or raw\n");
561 printf
562 (" -j : Display # of banks and bank name list only for all the event\n");
563 printf
564 (" -b bank name : search for bank name (case sensitive)\n");
565 printf
566 (" -i evt_id (any) : event id from the FE\n");
567 printf
568 (" -k mask (any) : trigger_mask from FE setting\n");
569 printf
570 (" -g type : sampling mode either SOME or all)\n");
571 printf
572 (" -s : report buffer data rate and fill level\n");
573 printf
574 (" -s -d : for use with -s: also report all buffer clients and requests\n");
575 printf
576 (" -t type (auto) : Bank format (Midas/Ybos)\n");
577 printf
578 (" -x Source : Data source selection def:online (see -x -h)\n");
579 printf
580 (" -y : Serial number consistency check\n");
581 printf
582 (">>> in case of -y it is recommented to used -g all\n");
583 printf
584 (" -z buffer name : Midas buffer name default:[SYSTEM]\n");
585 printf
586 (" [-h Hostname] [-e Experiment]\n\n");
587 return 0;
588 }
589 }
590 }
591 }
592
593
594 if ((strstr(argv[0],
"mdump") == NULL))
openzip = 0;
else openzip = 1;
595
597
599 char *pext;
600 if ((pext = strrchr(rep_file, '.')) != 0) {
604 if ((pext = strchr(rep_file, '.')) != 0) {
605 if (strstr(pext + 1, "mid"))
607 } else {
608 printf("\n>>> data type (-t) should be set by hand in -x mode for tape <<< \n\n");
610 }
615 } else {
616 printf
617 ("\n>>> data type (-t) should be set by hand in -x mode for tape <<< \n\n");
619 }
620 }
621 }
622
623
624 if (rep_flag) {
626 return 0;
627 } else {
628
629 if (evt_display < 1 || evt_display > 9999) {
630 printf("mdump-F- <-display arg> out of range (1:9999)\n");
631 return -1;
632 }
633 }
634 if (dsp_time < 0 || dsp_time > 100) {
635 printf("mdump-F- <-delay arg> out of range (1:100)\n");
636 return -1;
637 }
638
639
641
642
645 return 1;
646
647#ifdef _DEBUG
649#endif
650
651
654 cm_msg(
MERROR,
"mdump",
"Cannot open buffer \"%s\", bm_open_buffer() status %d", buf_name,
status);
655 goto error;
656 }
657
659
660
662
663 start_time = 0;
665 printf("- MIDAS revision: %s -- Enter <!> to Exit ------- Midas Dump in Speed test mode ---\n",
667 else
668 printf(
"- MIDAS revision: %s -- Enter <!> to Exit ------- Midas Dump ---\n",
cm_get_revision());
669
670
672
673 {
675
677 char strtmp[256], equclient[256];
681 break;
685 mstrlcpy(
eq[l].Eqname,
key.
name,
sizeof(
eq[l].Eqname));
686
687
688 size = sizeof(equclient);
689 sprintf(strtmp,
"/equipment/%s/common/Frontend name",
key.
name);
691
692
693
694
695
696
697
699 sprintf(strtmp,
"/equipment/%s/common/event ID",
key.
name);
701
703 sprintf(strtmp,
"/equipment/%s/common/Trigger mask",
key.
name);
705
707 sprintf(strtmp,
"/equipment/%s/common/Format",
key.
name);
711 strcpy(
eq[l].Fmt,
"MIDAS");
714 strcpy(
eq[l].Fmt,
"FIXED");
715 } else {
718 strcpy(
eq[l].Fmt,
"UNKNOWN");
719 }
720 l++;
721 }
722 }
723
724
725
727 sprintf(
eq[l].Eqname,
"EBuilder");
728
729
730
731
732
733
734
737
740
745 strcpy(
eq[l].Fmt,
"MIDAS");
746 } else {
747 printf(
"Format unknown for Event Builder \"%s\"\n",
str);
748 goto error;
749 }
750 l++;
751 }
752
753
756 printf("ID\tMask\tFormat\tEq_name\n");
757 while (
eq.size() > 0 &&
eq[
i].fmt) {
758 printf(
"%d\t%d\t%s\t%s\n",
eq[
i].
id,
eq[
i].msk,
eq[
i].Fmt,
eq[
i].Eqname);
760 }
761 }
762 }
763
764 do {
768
771 double rate =
count / 1024.0 / 1024.0 / ((
stop_time - start_time) / 1000.0);
772
773
776 if (filled <= 0)
777 filled += buffer_header.
size;
778
779 int max_used = 0;
780 int max_used_client = 0;
782
784
785 printf("buffer name [%s], clients: %d, max: %d, size: %d, rp: %d, wp: %d, ine: %d, oute: %d\n",
794 );
795
799 if (used < 0)
800 used += buffer_header.
size;
801
803 if (used > max_used) {
804 max_used = used;
806 }
807 }
808
809 printf(" client %d: name [%s], pid: %d, port: %d, rp: %d, used: %d, max_req: %d, read_wait: %d, write_wait: %d, wake_up: %d, get_all: %d, active: %d, timeout: %d\n",
815 used,
823
826 printf(" request %d: id: %d, valid: %d, event_id: %d, trigger_mask: 0x%x, type: %d\n",
833 }
834 }
835 }
836 printf(
"buffer name [%s], ", buffer_header.
name);
837 printf(
"filled: %4.1f%%, ", 100 - 100.0 * filled / buffer_header.
size);
838 printf(
"used: %4.1f%% by [%s], ", 100.0 * max_used / buffer_header.
size,
840 printf("rate: %1.3f MiB/sec\n", rate);
841
844 }
845 }
846
847
848
849 ch = 0;
852 if (ch == -1)
853 ch = getchar();
854 if ((char) ch == '!')
855 break;
856 }
858
859 error:
860
862
864
865 return 1;
866}
INT bm_open_buffer(const char *buffer_name, INT buffer_size, INT *buffer_handle)
INT bm_request_event(HNDLE buffer_handle, short int event_id, short int trigger_mask, INT sampling_type, HNDLE *request_id, EVENT_HANDLER *func)
INT bm_set_cache_size(INT buffer_handle, size_t read_size, size_t write_size)
INT cm_yield(INT millisec)
INT cm_get_experiment_database(HNDLE *hDB, HNDLE *hKeyClient)
INT cm_connect_experiment(const char *host_name, const char *exp_name, const char *client_name, void(*func)(char *))
INT cm_disconnect_experiment(void)
INT cm_get_environment(char *host_name, int host_name_size, char *exp_name, int exp_name_size)
const char * cm_get_revision()
INT cm_set_watchdog_params(BOOL call_watchdog, DWORD timeout)
INT ss_getchar(BOOL reset)
INT cm_msg(INT message_type, const char *filename, INT line, const char *routine, const char *format,...)
INT cm_set_msg_print(INT system_mask, INT user_mask, int(*func)(const char *))
BOOL equal_ustring(const char *str1, const char *str2)
INT db_get_value(HNDLE hDB, HNDLE hKeyRoot, const char *key_name, void *data, INT *buf_size, DWORD type, BOOL create)
INT db_get_key(HNDLE hDB, HNDLE hKey, KEY *key)
INT db_find_key(HNDLE hDB, HNDLE hKey, const char *key_name, HNDLE *subhKey)
INT db_enum_key(HNDLE hDB, HNDLE hKey, INT idx, HNDLE *subkey_handle)
BOOL debug
debug printouts
char host_name[HOST_NAME_LENGTH]
void process_event(HNDLE hBuf, HNDLE request_id, EVENT_HEADER *pheader, void *pevent)
int replog(int data_fmt, char *rep_file, int bl, int action, int max_event_size)
char expt_name[NAME_LENGTH]
INT bm_get_buffer_info(INT buffer_handle, BUFFER_HEADER *buffer_header)
#define DEFAULT_MAX_EVENT_SIZE
#define DEFAULT_BUFFER_SIZE
#define EVENT_BUFFER_NAME
EVENT_REQUEST event_request[MAX_EVENT_REQUESTS]
BUFFER_CLIENT client[MAX_CLIENTS]