00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "typedefs.h"
00015 #include <stdlib.h>
00016 #include <stdio.h>
00017 #include <errno.h>
00018 #include <ctype.h>
00019 #include <string.h>
00020 #include "f_ut_wild.h"
00021 #include "f_his_hist.h"
00022 #include "f_radware.h"
00023
00024 main(argc,argv)
00025 int argc;
00026 char *argv[];
00027 {
00028 s_his_head *ps_his_head,*ps_his_head_dir;
00029 INTS4 i_j,ii,l_status,l_port,l_int;
00030 INTS4 l_size,l_histos=0;
00031 INTS4 *pl_all,*pl_dir,*pl_l;
00032 REAL4 *pr,*pr_l;
00033 CHARS *pc;
00034 CHARS c_server[32];
00035 CHARS c_histo[32];
00036 CHARS c_base[32];
00037 CHARS c_access[32];
00038 CHARS c_file[128];
00039
00040 if(argc < 7)
00041 {
00042 printf("node port|6009 base password \"histogram\" [-print|-dir|-rad]\n");
00043 exit(0);
00044 }
00045 l_port=atol(argv[2]);
00046 strcpy(c_server,argv[1]);
00047 strcpy(c_access,argv[4]);
00048 strcpy(c_base,argv[3]);
00049 strcpy(c_histo,argv[5]);
00050
00051 pl_all=NULL;
00052
00053 if(strstr(argv[6],"-d") != NULL)
00054 {
00055 printf("Get directory %s from server %s [%d] pass=*** base=%s\n",
00056 c_histo,c_server,l_port,c_base);
00057 ps_his_head_dir=NULL;
00058 pl_dir=NULL;
00059 l_status = f_his_getdir(c_server,l_port,c_base,c_access,c_histo,(INTS4 **)&pl_dir,(INTS4 **)&l_histos);
00060 if(l_status == COMM__SUCCESS)
00061 {
00062 printf("Histograms: %d, slot size: %d b, Total: %d b\n",
00063 l_histos,sizeof(s_his_head),l_histos*sizeof(s_his_head));
00064 ps_his_head_dir = (s_his_head *)pl_dir;
00065 for(i_j=0;i_j<l_histos;i_j++)
00066 {
00067 if(f_ut_wild(ps_his_head_dir->c_name,c_histo)==0)
00068 printf("%-31s %s %8d %8d\n",
00069 ps_his_head_dir->c_name,ps_his_head_dir->c_dtype,ps_his_head_dir->l_bins_1,ps_his_head_dir->l_bins_2);
00070 ps_his_head_dir++;
00071 }
00072 } else printf("Error %d\n",l_status);
00073 exit(0);
00074 }
00075
00076 printf("Lookup histograms %s at server %s [%d] pass=*** base=%s\n",
00077 c_histo,c_server,l_port,c_base);
00078 ps_his_head_dir=NULL;
00079 pl_dir=NULL;
00080 l_status = f_his_getdir(c_server,l_port,c_base,c_access,c_histo,(INTS4 **)&pl_dir,(INTS4 **)&l_histos);
00081 if(l_status != COMM__SUCCESS)
00082 {
00083 printf("Error %d getting histograms %s\n",l_status,c_histo);
00084 exit(0);
00085 }
00086 ps_his_head_dir = (s_his_head *)pl_dir;
00087 for(i_j=0;i_j<l_histos;i_j++)
00088 {
00089 if(f_ut_wild(ps_his_head_dir->c_name,c_histo)==0)
00090 {
00091 ps_his_head=NULL;
00092 pl_all=NULL;
00093 l_status = f_his_gethis(c_server,l_port,c_base,c_access,ps_his_head_dir->c_name,
00094 (s_his_head **)&ps_his_head,(INTS4 **)&pl_all,(INTS4 **)&l_size);
00095 if(l_status != COMM__SUCCESS)
00096 {
00097 printf("Error %d getting histogram %s\n",l_status,ps_his_head_dir->c_name);
00098 exit(0);
00099 }
00100
00101
00102 pl_l = pl_all;
00103 pr_l =(REAL4 *)pl_all;
00104 if(ps_his_head->c_dtype == 'i') l_int=1; else l_int=0;
00105
00106
00107 if(strstr(argv[6],"-p") != NULL)
00108 {
00109 printf("Histogram %s\n",ps_his_head_dir->c_name);
00110 printf(" channels: %10d, total: %10d [b], %s %8d %8d\n",
00111 ps_his_head->l_bins_1*ps_his_head->l_bins_2,l_size,
00112 ps_his_head->c_dtype,ps_his_head->l_bins_1,ps_his_head->l_bins_2);
00113
00114 if(ps_his_head->l_bins_2 == 1)
00115 {
00116 for (i_j = 0; i_j < (ps_his_head->l_bins_1 - ps_his_head->l_bins_1 % 6); i_j += 6)
00117 {
00118 if(l_int) printf("%7d:%9d %9d %9d %9d %9d %9d\n",
00119 i_j + 1,*pl_l,*(pl_l+1),*(pl_l+2),*(pl_l+3),*(pl_l+4),*(pl_l+5));
00120 else printf("%7d:%11.4g %11.4g %11.4g %11.4g %11.4g %11.4g\n",
00121 i_j + 1,*pr_l,*(pr_l+1),*(pr_l+2),*(pr_l+3),*(pr_l+4),*(pr_l+5));
00122 pl_l+=6;
00123 pr_l+=6;
00124 }
00125 if ((ps_his_head->l_bins_1 % 6))
00126 {
00127 printf("%7d:",i_j + 1);
00128 for (i_j = ps_his_head->l_bins_1 - ps_his_head->l_bins_1 % 6; i_j < ps_his_head->l_bins_1; i_j++)
00129 {
00130 if(l_int) printf("%9d ", *pl_l);
00131 else printf("%11.4g ", *pr_l);
00132 pl_l++;
00133 pr_l++;
00134 }
00135 printf("\n");
00136 }}else printf("2d Histograms %s not supported\n",ps_his_head_dir->c_name);
00137 }
00138
00139 if(strstr(argv[6],"-r") != NULL)
00140 {
00141 if(argc == 8)strcpy(c_file,argv[7]);
00142 else strcpy(c_file,"rad_");
00143 strcat(c_file,ps_his_head_dir->c_name);
00144 pc=c_file;
00145 for(ii=0;ii<strlen(c_file);ii++)
00146 {
00147 if(*pc == '/')*pc='-';
00148 if(*pc == '(')*pc='[';
00149 if(*pc == ')')*pc=']';
00150 if(*pc == ' ')*pc='_';
00151 pc++;
00152 }
00153 strcat(c_file,".spe");
00154 if(ps_his_head->l_bins_2 == 1)
00155 {
00156 if(l_int == 0)
00157 {
00158 pr=(REAL4 *) malloc(ps_his_head->l_bins_1*4);
00159 pr_l=pr;
00160 for(ii=0;ii<ps_his_head->l_bins_1;ii++)*pr++=(REAL4)*pl_l++;
00161 }
00162 l_status=f_radware_out1d(c_file,ps_his_head->c_name,pr_l,ps_his_head->l_bins_1,0);
00163 if(l_status == 0)printf("Radware histogram %s written to file %s.\n",ps_his_head_dir->c_name,c_file);
00164 else printf("Radware histogram %s NOT written to file %s, ERROR!\n",ps_his_head_dir->c_name,c_file);
00165 if(l_int == 0)free(pr_l);
00166 } else printf("2d Histograms %s not supported\n",ps_his_head_dir->c_name);
00167 }
00168 free(pl_all);
00169 }
00170 ps_his_head_dir++;
00171 }
00172 }
00173