-
Notifications
You must be signed in to change notification settings - Fork 2
/
vetrocdec.c
148 lines (123 loc) · 2.72 KB
/
vetrocdec.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#include <stdio.h>
#include <stdint.h>
#include "jlabdec.h"
#include "vetrocdec.h"
void
vetrocDataDecode(uint32_t data)
{
static uint32_t type_last = 15; /* initialize to type FILLER WORD */
static uint32_t time_last = 0;
static int new_type = 0;
int type_current = 0;
generic_data_word_t gword;
gword.raw = data;
if(gword.bf.data_type_defining) /* data type defining word */
{
new_type = 1;
type_current = gword.bf.data_type_tag;
}
else
{
new_type = 0;
type_current = type_last;
}
switch( type_current )
{
case 0: /* BLOCK HEADER */
{
block_header_t d; d.raw = data;
printf("%8X - BLOCK HEADER - slot = %d modID = %d n_evts = %d n_blk = %d\n",
d.raw,
d.bf.slot_number,
d.bf.module_ID,
d.bf.number_of_events_in_block,
d.bf.event_block_number);
break;
}
case 1: /* BLOCK TRAILER */
{
block_trailer_t d; d.raw = data;
printf("%8X - BLOCK TRAILER - slot = %d n_words = %d\n",
d.raw,
d.bf.slot_number,
d.bf.words_in_block);
break;
}
case 2: /* EVENT HEADER */
{
vetroc_event_header_t d; d.raw = data;
printf("%8X - EVENT HEADER 1 - trig num = %d\n",
d.raw,
d.bf.trigger_number);
break;
}
case 3: /* TRIGGER TIME */
{
if( new_type )
{
vetroc_trigger_time_1_t d; d.raw = data;
printf("%8X - TRIGGER TIME 1 - time = %08x\n",
d.raw,
(d.bf.T_D<<16) | (d.bf.T_E<<8) | (d.bf.T_F) );
time_last = 1;
}
else
{
vetroc_trigger_time_2_t d; d.raw = data;
if( time_last == 1 )
{
printf("%8X - TRIGGER TIME 2 - time = %08x\n",
d.raw,
(d.bf.T_A<<16) | (d.bf.T_B<<8) | (d.bf.T_C) );
}
else
printf("%8X - TRIGGER TIME - (ERROR)\n", data);
time_last = 0;
}
break;
}
case 8: /* PULSE TIME */
{
vetroc_pulse_time_t d; d.raw = data;
printf("%8X - PULSE TIME - edge = %d chan = %d time = %d\n",
d.raw,
d.bf.edge,
d.bf.channel,
d.bf.time);
break;
}
case 14: /* DATA NOT VALID (no data available) */
{
data_not_valid_t d; d.raw = data;
printf("%8X - DATA NOT VALID = %d\n",
d.raw,
d.bf.data_type_tag);
break;
}
case 15: /* FILLER WORD */
{
filler_word_t d; d.raw = data;
printf("%8X - FILLER WORD = %d\n",
d.raw,
d.bf.data_type_tag);
break;
}
case 4:
case 5:
case 6:
case 7:
case 9:
case 10:
case 11:
case 12:
case 13:
default:
{
printf("%8X - UNDEFINED TYPE = %d\n",
gword.raw,
gword.bf.data_type_tag);
break;
}
}
type_last = type_current; /* save type of current data word */
}