/[PAMELA software]/quicklook/dataToXML/Data/compilationInfo/src/INFN/loganalizer.c
ViewVC logotype

Contents of /quicklook/dataToXML/Data/compilationInfo/src/INFN/loganalizer.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (show annotations) (download) (vendor branch)
Tue Apr 25 09:00:20 2006 UTC (18 years, 7 months ago) by kusanagi
Branch: MAIN
CVS Tags: dataToXML1_02/01, dataToXML1_02/00, dataToXML1_03/00, dataToXML1_03/01, dataToXML1_00/00, firstRelease, dataToXML1_01/00, dataToXML1_03_02, HEAD
Changes since 1.1: +0 -0 lines
File MIME type: text/plain
These program extract in an XML format the info contained into the ROOT files generated by YODA from the PAMELA data. To visualize the XML files in a more human readable format a collection of XSL files are given in the Data subfolder.

1
2 #define TEST_I
3 #define LOGANALIZER
4
5
6 #define HA_EVENT_00 0
7 #define HA_EVENT_01 1
8 #define HA_EVENT_02 2
9 #define HA_EVENT_03 3
10 #define HA_EVENT_04 4
11 #define HA_EVENT_05 5
12 #define HA_EVENT_06 6
13 #define HA_EVENT_07 7
14 #define HA_EVENT_08 8
15 #define HA_EVENT_09 9
16 #define HA_EVENT_10 10
17 #define HA_EVENT_11 11
18 #define HA_EVENT_12 12
19 #define HA_EVENT_13 13
20 #define HA_EVENT_14 14
21 #define HA_EVENT_15 15
22
23 typedef unsigned char UBYTE;
24 typedef unsigned short int UWORD;
25 typedef unsigned long int UDWORD;
26
27
28 //#include <src/HKManager/HistoryArea/HA_HistoryArea_p.h>
29 #include <src/INFN/LU_LogUtility_INFN.h>
30 #include <sys/types.h>
31 #include <unistd.h>
32 //#include <src/INFN/loganalizer_auto.c>
33
34 #include <stdio.h>
35
36
37 unsigned short swap(unsigned short x) {
38 unsigned char *p=(unsigned char*)&x;
39 unsigned char h;
40 h=*p;
41 p++;
42 return h << 8 | *p;
43 }
44
45 int ReadByte() {
46 int b=getchar();
47 // printf("\nReceived char: %d 0x%X '%c'",b,b,(unsigned char)b);
48 return b;
49 }
50
51 #define UBYTE unsigned char
52 #define UWORD unsigned short int
53
54
55 int main(void) {
56 int status=0;
57 int b;
58 int pid;
59 int len;
60 UBYTE EntryType;
61 static unsigned char buf[1024],str[100],str2[100];
62 unsigned int Report,Value;
63 unsigned int entry;
64 unsigned char code,stop;
65 unsigned int time,i;
66 unsigned int rep1,rep2,rep3,line,fileid;
67 /* look for the magic sequence 0xFAFEDEFA, to start logging: */
68 status=0;
69 while(status != 4) {
70 b=ReadByte();
71 if(b == EOF)
72 exit(120);
73 switch(status) {
74 case 0:
75 if(b == 0xFA)
76 status=1;
77 break;
78 case 1:
79 if ( b== 0xFE)
80 status=2;
81 break;
82 case 2:
83 if (b==0xDE)
84 status=3;
85 break;
86 case 3:
87 if (b==0xFA)
88 status=4;
89 break;
90 }
91 //putc(b);
92 putchar(b);
93 // printf("\nReceived char: %d 0x%X '%c' NewStatus %d",b,b,(unsigned char)b,status);
94 }
95 /* start logging: */
96 pid=getpid();
97 stop = 0;
98 printf("\n*************** Log Analizer Started as PID %d : ******************\n",pid);
99 while((b=ReadByte()) != EOF && !stop) {
100 len=b;
101 #ifdef VERBOSE
102 printf("-> len: %d\n",len);
103 #endif
104 for(i=0;i<len;i++)
105 if((b=ReadByte()) != EOF)
106 buf[i]=(unsigned char)b;
107 else
108 exit(1);
109 #ifdef VERBOSE
110 for(i=0;i<len;i++)
111 printf(" - %2d: %5d 0x%4X\n",i,buf[i],buf[i]);
112 printf("\n\n");
113 #endif
114 EntryType = buf[0] >> 4;
115
116 entry =EntryType;
117 code =buf[1];
118
119 time = *(UWORD*)(&buf[2]);
120 time = time << 16;
121 time |= *(UWORD*)(&buf[4]);
122
123 rep1 =0;
124 rep2 =0;
125 rep3 =0;
126
127 switch( EntryType ) {
128 case HA_EVENT_04:
129 sprintf(str,"");
130 break;
131 case HA_EVENT_00:
132 Report = swap( ((UWORD*)(buf))[3] );
133 sprintf(str,"StateMode: %d 0x%X - ModeDetails : %d 0x%X",code,code,Report,Report);
134 break;
135 case HA_EVENT_02:
136 Report = swap( ((UWORD*)(buf))[3] );
137 sprintf(str,"mcmd Type: %d - Report: %d 0x%X",code,Report,Report,Value,Value);
138 break;
139 case HA_EVENT_03:
140 Value = swap( ((UWORD*)(buf))[3] );
141 sprintf(str,"CmdName: %d 0x%X - Value: %d 0x%X",code,code,Value,Value);
142 break;
143 case HA_EVENT_05:
144 line = swap( ((UWORD*)(buf))[3] );
145 rep1 = swap( ((UWORD*)(buf))[4] );
146 LU_GetSourceInfo(str2,code,line);
147 sprintf(str,"INFN SW: FileID: %d Info1: %6d 0x%x [%s]",code,rep1,rep1,str2);
148 break;
149 case HA_EVENT_06:
150 rep1 = swap( ((UWORD*)(buf))[3] );
151 sprintf(str,"Info (Word 3): %10d 0x%x",rep1,rep1);
152 break;
153
154 case HA_EVENT_10:
155 rep1 = swap ( ((UWORD*)(buf))[3] );
156 rep2 = swap ( ((UWORD*)(buf))[4] );
157 sprintf(str,"SwOrigin: %d 0x%X R1: %10d %x - R2: %10d 0x%x ",code,code,rep1,rep1,rep2,rep2);
158 break;
159
160 case HA_EVENT_11:
161 rep1 = swap( ((UWORD*)(buf))[3] );
162 rep2 = swap( ((UWORD*)(buf))[4] );
163 rep3 = swap( ((UWORD*)(buf))[5] );
164 sprintf(str,"HwOrigin: %d 0x%X - R1: %10d 0x%x - R2: %10d 0x%x - R3: %10d %x ",code,code,rep1,rep1,rep2,rep2,rep3,rep3);
165 break;
166 default:
167 sprintf(str,"ENTRY TYPE NOT RECOGNIZED BY LOG-ANALIZER");
168 stop=1;
169 break;
170 }
171
172 printf("Type %2d - OBT: %5u - %s\n",entry,time,str);
173
174 }
175 return stop;
176 }

  ViewVC Help
Powered by ViewVC 1.1.23