Project

General

Profile

doc_DBtables.txt

Kyle Hazelwood, 01/15/2015 12:01 PM

 
1
1. Data base tables:
2
#define Q_HDR_TABLE "wu.pa4208_q_hdr"
3
#define Q_SLOT_TABLE "wu.pa4208_q_slot"
4
#define CCALI_SLOT_TABLE "wu.chro_cali_slot"
5
#define GEN_PAR_NAME "wu.pa4208_gen_pars"
6
wu.pa4208_tune_pars
7
wu.pa4208_chro_pars
8
#define C453_CONFIG_TABLE "wu.pa4208_453_conf"
9

    
10

    
11
2. The shared DB tables pa4208_q_hdr, pa4208_q_slot.
12
hdr table: pa4208_q_hdr
13
create table pa4208_q_hdr (
14
tid		int		not null,
15
cyc		int		not null,
16
fid		int		not null,
17
date_saved    	int		not null,
18
date_sent       	int		not null,
19
title		char(40)		not null
20
)
21
create unique clustered index idx0 on pa4208_q_hdr(tid,cyc,fid)
22
id = tid*1000000 + cyc*100 + fid, and x */
23

    
24
Slot table: pa4208_q_slot
25
go
26
create table pa4208_q_slot (
27
id		int		not null,
28
x      		real		not null,
29
y1       		real		not null,
30
y2       		real		not null
31
)
32
go
33
create unique clustered index idx0 on pa4208_q_slot(id,x)
34

    
35
	- Q_STRUCT(Q_HDR_STRUCT+Q_SLOT_STRUCT) 
36
	- Each file consistes of one hdr rec and a number of slot recs.
37

    
38
	There are 5 tabels(4 for tune and 1 for chromaticity control) that use 
39
	the same DB records' structures using 'tid' in hdr to identify what table, 
40
	and using 'id' column  in slot rec to identify which table hdr the 
41
	slot data 	belong to.  A group of routines provide DB service. 
42

    
43
- real sample:
44
1> select * from pa4208_q_hdr where tid=1 and fid=2 and cyc=225
45
2> go
46
 tid         cyc         fid         date_saved  date_sent
47
         title
48
 ----------- ----------- ----------- ----------- -----------
49
         ----------------------------------------
50
           1         225           2  1315315536  1320735707
51
         start-up file, 0 delta tunes.
52

    
53
(1 row affected)
54

    
55
id = tid*1000000 + cyc*100 + fid = 1022502
56

    
57
1> select * from pa4208_q_slot where id=1022502
58
2> go
59
 id          x                           y1
60
         y2
61
 ----------- --------------------------- ---------------------------
62
         ---------------------------
63
     1022502                    0.001000                    0.020601
64
                            0.069500
65

    
66
(1 row affected)
67
3. hdr and slot rec structs:
68
typedef struct {
69
   int			tid;
70
   int			cyc;
71
   int			fid;
72
   int			date_saved;
73
   int			date_sent;
74
   char			title[TITLE_LEN];
75
}  __attribute__((packed)) /*Added by the PACKINATOR(tm)*/ Q_HDR_STRUCT;
76

    
77
typedef struct {
78
   int			id;
79
   float		x;
80
   float		dq[2];
81
}  __attribute__((packed)) /*Added by the PACKINATOR(tm)*/ Q_SLOT_STRUCT;
82

    
83
typedef struct {
84
   Q_HDR_STRUCT		hdr;
85
   Q_SLOT_STRUCT	slot[MAX_NUM_TUNE_SLOTS];
86
   int			num_slots;
87
} __attribute__((packed)) /* Added by the PACKINATOR(tm) */ Q_STRUCT;
88

    
89
4. 'tid' identify the 5 tables:
90
#define Q_TID_OP 1
91
#define Q_TID_P_COMP 2
92
#define Q_TID_PDOT_COMP 3
93
#define Q_TID_BEAM_COMP 4
94
#define C_TID_OP 11
95
 
96
  tid = 	1(op-tune) 	- x[t],dq[dq.h,dq.v]
97
         	2(p comp), 	- x[p],dq[dq.h,dq.v] 
98
         	3(pdot comp), 	- x[pdot],dq[dq.h,dq.v] 
99
         	4(beam comp), 	- x[x*E13],dq[dq.h,dq.v] 
100
	11(op-chro),    	- x[t],dq[ch.h,ch.v]
101

    
102
5. The id(key) to slot records.
103
id = tid * 1000000 + cyc * 100 + fid,  merely a key in DB.
104

    
105

    
106
--------------------------------------------------------------------------
107

    
108
For chro calibration data file there is its own DB table: chro_cali_slot
109
It has only slot records, no hdr rec:
110
   
111
typedef struct {
112
   int			fid;
113
   float			i[2];
114
   float			ch[2];
115
   int			fit_flg[2];
116
 }  __attribute__((packed)) /*Added by the PACKINATOR(tm)*/ CCALI_SLOT_STRUCT;
117

    
118
-------------------------------------------------------------------
119
/* pgm parameters */
120

    
121
typedef struct {
122
  int			job;
123
  int			cns;
124
  int			cnsslot;
125
  int			evt;
126
  int			set_64_slots;
127
  int			test_c453;
128
}  __attribute__((packed)) /* Added by the PACKINATOR(tm) */ PGM_PAR_STRUCT;
129

    
130
/* tune parameters. the same data names are used in DB*/
131
Table: pa4208_tune_pars
132
create table pa4208_tune_pars (
133
bare_q_h      	real		not null,
134
bare_q_v      	real		not null,
135
oq_grp_0      	int		not null,
136
oq_grp_1      	int		not null,
137
oq_tgh_0      	int		not null,
138
oq_tgh_1      	int		not null,
139
oq_share_0      real		not null,
140
oq_share_1      real		not null,
141
p_grp		int		not null,
142
p_tgh		int		not null,
143
p_mdat		int		not null,
144
pdot_grp	int		not null,
145
pdot_tgh	int		not null,
146
pdot_mdat	int		not null,
147
beam_grp	int		not null,
148
beam_tgh	int		not null,
149
beam_mdat	int		not null,
150
beam_rate_h	real		not null,
151
beam_rate_v	real		not null
152
)
153

    
154
typedef struct {
155
   float	bare_q_h; 	/* design q.h when trombone at 0 currents */
156
   float	bare_q_v; 	/* design q.v when trombone at 0 currents */
157
   int		oq_grp_0;	/* qt grp 0 used for op-tune */ 
158
   int		oq_grp_1;	/* qt grp 1 used for op-tune */
159
   int		oq_tgh_0;	/* table of qt grp 0  for op-tune */
160
   int		oq_tgh_1;	/* table of qt grp 1  for op-tune */
161
   float	oq_share_0;	/* qt grp 0 share of op-tune */
162
   float	oq_share_1;	/* qt grp 1 share of op-tune */
163
   int		p_grp;		/* qt grp used for p-comp */
164
   int		p_tgh;		/* table used for p-comp */
165
   int		p_mdat;		/* MDAT used for p-comp */
166
   int		pdot_grp;	/* qt grp used for pdot-comp */
167
   int		pdot_tgh;	/* table used for pdot-comp */
168
   int		pdot_mdat;	/* MDAT used for pdot-comp */
169
   int		beam_grp;	/* qt grp used for beam-comp */
170
   int		beam_tgh;	/* table used for beam-comp */
171
   int		beam_mdat;	/* MDAT used for beam-comp */
172
   float	beam_rate_h;	/* beam-comp rate in h */
173
   float	beam_rate_v;	/* beam-comp rate in v */
174
} __attribute__((packed)) /* Added by the PACKINATOR(tm) */ TUNE_PAR_STRUCT;  
175

    
176
/* chro parameters. the same data names are used in DB */
177

    
178
typedef struct
179
{
180
   float   	ch_max_h;   	/* maximum ch.h can be specified */ 
181
   float   	ch_max_v;   	/* maximum ch.v can be specified */
182
   float   	ch_min_h;   	/* minimum ch.h can be specified */
183
   float   	ch_min_v;   	/* minimum ch.v can be specified */
184
   float   	ch2i_h_a;   	/* ch2i slope.h */
185
   float   	ch2i_h_b;   	/* ch2i intercept.h */
186
   float   	ch2i_h_c;   	/* spare */
187
   float   	ch2i_v_a;   	/* ch2i slope.v */
188
   float   	ch2i_v_b;   	/* ch2i intercept.v */
189
   float   	ch2i_v_c;   	/* spare */
190
} __attribute__((packed)) /* Added by the PACKINATOR(tm) */ CHRO_PAR_STRUCT;  
191