Project

General

Profile

DocDBTables.txt

Kyle Hazelwood, 01/15/2015 11:59 AM

 
1
PA4187 DB Tables
2
1. Table pa4187_lines:
3
2. Table pa4187_correctors:
4

    
5
1. Table pa4187_lines:
6

    
7
-- sql create
8
create table pa4187_lines (
9
line_name 	char(24),
10
line		int,
11
ring		int,
12
num_turns	int,
13
stepcut_h	int,
14
stepcut_v	int,
15
mode		int,
16
eye_radius	real,
17
tune_h		real,
18
tune_v		real,
19
wait_evt		int,
20
companion_line	int
21
)
22
create unique clustered index idx1 on pa4187_lines(line)
23

    
24
-- DB records
25
1> select * from pa4187_lines
26
2> go
27
 line_name                line        ring        num_turns   stepcut_h
28
         stepcut_v   mode        eye_radius
29
         tune_h                      tune_v                      wait_evt
30
         companion_line
31
 ------------------------ ----------- ----------- ----------- -----------
32
         ----------- ----------- ---------------------------
33
         --------------------------- --------------------------- -----------
34
         --------------
35
 BO->MI line 10                     6           0          30          50
36
                  50          21                    4.000000
37
                            0.410000                    0.440000          35
38
                      0
39
 RR->MI line  9                     7           0          30          50
40
                  50          21                    3.000000
41
                            0.420000                    0.430000          35
42
                      0
43
 BO->RR line  8                     8           1          30          50
44
                  50           2                    3.000000
45
                            0.420000                    0.430000         225
46
                      0
47

    
48
(3 rows affected)
49

    
50
-- pa struct  for pa4187_lines: LINE_PARS_STRUCT
51
typedef struct {
52
   char		line_name[LINE_NAME_LEN+2];
53
   int		line;
54
   int		ring;
55
   int		num_turns;
56
   int		stepcut[2];
57
   int		mode;
58
   float		eye_radius;
59
   float		tune[2];
60
   int		wait_evt;
61
   int		companion_line;
62
 }  __attribute__((packed)) /* Added by the PACKINATOR(tm) */ LINE_PARS_STRUCT;
63

    
64

    
65

    
66
2. Table pa4187_correctors:
67

    
68
-- sql create 
69
create table pa4187_correctors (
70
line	      	int	not null,
71
plane	      	int	not null,
72
ced_s		real    not null,
73
ced_name	char(8) not null,
74
dio_name		char(8) not null,
75
dio_offset	int	not null,
76
minimum		real	not null,
77
maximum		real	not null,
78
useflag	      	int	not null
79
)
80
go
81
create unique clustered index idx1 on pa4187_correctors(line,plane,ced_s)
82

    
83
-- DB records for line id# = 6,7,8
84

    
85
1> select * from pa4187_correctors where line=6
86
2> go
87
 line        plane       ced_s                       ced_name dio_name
88
         dio_offset  minimum                     maximum
89
         useflag
90
 ----------- ----------- --------------------------- -------- --------
91
         ----------- --------------------------- ---------------------------
92
         -----------
93
           6           0                    1.000000 I:HT850D I:HT850D
94
                   0                   -6.000000                    6.000000
95
                   1
96
           6           0                    2.000000 I:HT852D I:HT852D
97
                   0                   -6.000000                    6.000000
98
                   1
99
           6           0                    3.000000 I:LAM10  I:LAM10
100
                   0                   -5.000000                    4.900000
101
                   0
102
           6           1                    0.500000 I:VT849D I:VT849D
103
                   0                   -6.000000                    6.000000
104
                   1
105
           6           1                    1.500000 I:VT851D I:VT851D
106
                   0                   -6.000000                    6.000000
107
                   1
108
           6           1                    2.500000 I:KPS103 I:KPS103
109
                   0                   -5.000000                    4.900000
110
                   0
111

    
112
(6 rows affected)
113
1> select * from pa4187_correctors where line=7
114
2> go
115
 line        plane       ced_s                       ced_name dio_name
116
         dio_offset  minimum                     maximum
117
         useflag
118
 ----------- ----------- --------------------------- -------- --------
119
         ----------- --------------------------- ---------------------------
120
         -----------
121
           7           0                    1.000000 R:HT902  R:HT902G
122
                   0                   -6.000000                    6.000000
123
                   1
124
           7           0                    2.000000 R:HT904  R:HT904G
125
                   0                   -6.000000                    6.000000
126
                   1
127
           7           0                    3.000000 R:HT906  R:HT906G
128
                   0                   -5.000000                    4.900000
129
                   0
130
           7           1                    0.500000 R:VT901  R:VT901G
131
                   0                   -6.000000                    6.000000
132
                   1
133
           7           1                    1.500000 R:VT903  R:VT903G
134
                   0                   -6.000000                    6.000000
135
                   1
136
           7           1                    2.500000 R:VT905  R:VT905G
137
                   0                   -5.000000                    4.900000
138
                   0
139

    
140
(6 rows affected)
141
1> select * from pa4187_correctors where line=8
142
2> go
143
 line        plane       ced_s                       ced_name dio_name
144
         dio_offset  minimum                     maximum
145
         useflag
146
 ----------- ----------- --------------------------- -------- --------
147
         ----------- --------------------------- ---------------------------
148
         -----------
149
           8           0                    1.000000 R:HT850  R:HT850G
150
                   0                   -6.000000                    6.000000
151
                   1
152
           8           0                    2.000000 R:HT852  R:HT852G
153
                   0                   -6.000000                    6.000000
154
                   1
155
           8           0                    3.000000 R:HT854  R:HT854G
156
                   0                   -5.000000                    4.900000
157
                   0
158
           8           1                    0.500000 R:VT849  R:VT849G
159
                   0                   -6.000000                    6.000000
160
                   1
161
           8           1                    1.500000 R:VT851  R:VT851G
162
                   0                   -6.000000                    6.000000
163
                   1
164
           8           1                    2.500000 R:VT853  R:VT853G
165
                   0                   -5.000000                    4.900000
166
                   0
167

    
168
(6 rows affected)
169

    
170

    
171
Storage for pa4187_correctors: CED_STRUCT 
172
typedef struct {
173
  int			line; /* injection,..*/
174
  int 			plane;
175
  float			ced_s;
176
  char			ced_name[8];
177
  char			dio_name[8];
178
  int			dio_offset;
179
  float			minimum;
180
  float			maximum;
181
  int			useflag;
182
 } __attribute__((packed)) /* Added by the PACKINATOR(tm) */ CED_STRUCT;
183

    
184
3. Table pa4187_cali_bpm(blt)
185
-- for calibration data
186

    
187
-- sql create
188
create table pa4187_cali_bpm (
189
line	      	int	not null,
190
ced_name	char(8) not null,
191
fid		int	not null,
192
data_id		int	not null,
193
plane	      	int	not null,
194
date		int	not null,
195
ced_s		real    not null,
196
ced_setting	real	not null,
197
tbt_src		int 	not null,
198
tbt_name	char(8) not null,
199
r1  real,	r2 real,  	r3 real,  	r4 real,  	r5 real,  
200
r6  real,  	r7 real,  	r8 real,  	r9 real,  	r10 real,  
201
f1  real,	f2 real,  	f3 real,  	f4 real,  	f5 real,  
202
f6  real,  	f7 real,  	f8 real,  	f9 real,  	f10 real,  
203
f11 real,  	f12 real,  	f13 real,  	f14 real,  	f15 real,  
204
f16 real,  	f17 real,  	f18 real,  	f19 real,  	f20 real,  
205
f21 real,  	f22 real,  	f23 real,  	f24 real,  	f25 real,  
206
f26 real,  	f27 real,  	f28 real,  	f29 real,  	f30 real,  
207
f31 real,  	f32 real,  	f33 real,  	f34 real,  	f35 real,  
208
f36 real,  	f37 real,  	f38 real,  	f39 real,  	f40 real  
209
)
210
go
211
create unique clustered index idx1 on 
212

    
213
-- sample records. data_id=0 for rec of one set of tbt data for one setting.
214
   a series of recs after processed produce a record with data_id=1 that
215
   holds result of calibration for the dipole.
216
 
217
1> select * from pa4187_cali_bpm where line=8 and ced_name='R:ht850'
218
2> go
219
 line        ced_name fid         data_id     plane       date
220
         ced_s                       ced_setting                 tbt_src
221
         tbt_name r1                          r2
222
         r3                          r4
223
         r5                          r6
224
         r7                          r8
225
         r9                          r10
226
         f1                          f2
227
         f3                          f4
228
         f5                          f6
229
         f7                          f8
230
         f9                          f10
231
         f11                         f12
232
         f13                         f14
233
         f15                         f16
234
         f17                         f18
235
         f19                         f20
236
         f21                         f22
237
         f23                         f24
238
         f25                         f26
239
         f27                         f28
240
         f29                         f30
241
         f31                         f32
242
         f33                         f34
243
         f35                         f36
244
         f37                         f38
245
         f39                         f40
246
 ----------- -------- ----------- ----------- ----------- -----------
247
         --------------------------- --------------------------- -----------
248
         -------- --------------------------- ---------------------------
249
         --------------------------- ---------------------------
250
         --------------------------- ---------------------------
251
         --------------------------- ---------------------------
252
         --------------------------- ---------------------------
253
         --------------------------- ---------------------------
254
         --------------------------- ---------------------------
255
         --------------------------- ---------------------------
256
         --------------------------- ---------------------------
257
         --------------------------- ---------------------------
258
         --------------------------- ---------------------------
259
         --------------------------- ---------------------------
260
         --------------------------- ---------------------------
261
         --------------------------- ---------------------------
262
         --------------------------- ---------------------------
263
         --------------------------- ---------------------------
264
         --------------------------- ---------------------------
265
         --------------------------- ---------------------------
266
         --------------------------- ---------------------------
267
         --------------------------- ---------------------------
268
         --------------------------- ---------------------------
269
         --------------------------- ---------------------------
270
         --------------------------- ---------------------------
271
         --------------------------- ---------------------------
272
         --------------------------- ---------------------------
273
           8 R:HT850            1           0           0  1316871490
274
                            1.000000                    2.359497           0
275
         H404                        0.420000                    4.821085
276
                            0.516894                    0.260275
277
                            0.000000                   29.000000
278
                           50.000000                    0.411799
279
                            0.000000                    0.000000
280
                            1.360065                   -8.002910
281
                            0.820659                   -5.003255
282
                           -3.820680                   -0.434429
283
                           -7.150721                    1.047108
284
                           -6.113286                   -2.010870
285
                           -2.037544                   -5.697692
286
                            0.306848                   -6.148330
287
                           -1.380575                   -3.063148
288
                           -4.900157                   -0.086461
289
                           -6.423852                   -0.390873
290
                           -4.163718                   -3.656176
291
                           -1.010011                   -5.983443
292
                            0.407548                   -5.479784
293
                           -2.137244                   -2.341741
294
                           -4.686654                   -0.120846
295
                           -5.841559                   -1.017291
296
                           -3.190540                   -4.046553
297
                           -0.529971                   -5.212045
298
                           -1.040325                   -4.470656
299
                           -2.783878                   -2.186990
300
           8 R:HT850            1           0           0  1316871426
301
                            1.000000                    2.459473           0
302
         H404                        0.420000                    3.954957
303
                            0.472682                    0.202615
304
                            0.000000                   29.000000
305
                           54.000000                    0.411799
306
                            0.000000                    0.000000
307
                            0.565942                   -7.074426
308
                            0.096275                   -4.497373
309
                           -3.645123                   -0.855678
310
                           -6.505571                    0.367977
311
                           -5.418589                   -2.386360
312
                           -1.916240                   -5.371580
313
                           -0.149432                   -5.579356
314
                           -1.654176                   -2.875052
315
                           -4.639553                   -0.270234
316
                           -5.922184                   -1.007739
317
                           -3.840606                   -3.473056
318
                           -1.169949                   -5.601840
319
                           -0.043229                   -4.946449
320
                           -2.481952                   -2.304410
321
                           -4.612419                   -0.772942
322
                           -4.988147                   -1.386630
323
                           -3.372552                   -3.846738
324
                           -1.699000                   -4.601432
325
                           -1.705196                   -4.016390
326
                           -2.568624                   -1.646758
327

    
328
            8 R:HT850            1           1           0  1316871490
329
                            1.000000                    2.859375           0
330
         H404                        0.420000                    4.821085
331
                            0.516894                    0.260275
332
                            0.000000                   29.000000
333
                           50.000000                    0.411799
334
                            0.000000                    0.000000
335
                           26.153053                   -8.926666
336
                            2.368675                    0.539260
337
                            2.335531                   -0.000505
338
                            0.000000                    0.000000
339
                            0.000000                    0.000000
340
                            0.000000                    0.000000
341
                            0.000000                    0.000000
342
                            0.000000                    0.000000
343
                            0.000000                    0.000000
344
                            0.000000                    0.000000
345
                            0.000000                    0.000000
346
                            0.000000                    0.000000
347
                            0.000000                    0.000000
348
                            0.000000                    0.000000
349
                            0.000000                    0.000000
350
                            0.000000                    0.000000
351
                            0.000000                    0.000000
352
                            0.000000                    0.000000
353
                            0.000000                    0.000000
354
                            0.000000                    0.000000
355

    
356
(12 rows affected)
357
1>
358

    
359
pa4187_cali_bpm(line,ced_name,tbt_src,tbt_name,fid,data_id,ced_setting)
360

    
361
1> select * from pa4187_cali_bpm where line=22
362
2> go
363
 line        ced_name fid         data_id     plane       date
364
         ced_s                ced_setting          tbt_src     tbt_name
365
         r1                   r2                   r3
366
         r4                   r5                   r6
367
         r7                   r8                   r9
368
         r10                  f1                   f2
369
         f3                   f4                   f5
370
         f6                   f7                   f8
371
         f9                   f10                  f11
372
         f12                  f13                  f14
373
         f15                  f16                  f17
374
         f18                  f19                  f20
375
         f21                  f22                  f23
376
         f24                  f25                  f26
377
         f27                  f28                  f29
378
         f30                  f31                  f32
379
         f33                  f34                  f35
380
         f36                  f37                  f38
381
         f39                  f40
382
fid: start 1, default
383
data_id: 0 raw,multiple records; 1 processed,single
384
tbt_src: tbt source type; 0 bpm,1 blt
385
tbt_name: tbt source name, 'SPLD' if blt(labview)
386

    
387
pa struct for pa4187_cali_bpm: CALI_DATA_STRUCT
388

    
389
- symbols defined to accecc data in struct
390

    
391
#define BCALI_DATA_SIZE 10
392

    
393
#define CALIFID_DEF 1
394
#define READ_OPT_RAW 0
395
#define READ_OPT_FITTED 1
396
#define TCALI_RAW 0
397
#define TCALI_PRO 1
398

    
399

    
400
#define MAX_NUM_TBT_TURNS 40
401
#define MAX_NUM_TBT_PARS 10
402
#define TBT_PAR_FIT_TUNE_MEASURED 0
403
#define TBT_PAR_FIT_AMPL 1
404
#define TBT_PAR_FIT_PHASE 2
405
#define TBT_PAR_FIT_RMS 3
406
#define TBT_PAR_FIT_START 4
407
#define TBT_PAR_FIT_END 5
408
#define TBT_PAR_FIT_DECAY 6
409
#define TBT_PAR_FIT_TUNE 7
410
#define BLT_FITTED_DATA 1
411
#define BLT_FITTED_DATA_LEN 6
412

    
413
typedef struct {
414
  CALI_HDR_STRUCT	hdr;
415
  float			par[MAX_NUM_TBT_PARS];
416
  float			dat[MAX_NUM_TBT_TURNS];
417
 } __attribute__((packed)) /* Added by the PACKINATOR(tm) */ CALI_DATA_STRUCT;
418

    
419
typedef struct {
420
  int			line; /* injection,..*/
421
  char			ced_name[8];
422
  int			fid;
423
  int			data_id;      /* 0=flash,1=closed,2 slope,3 sigma */
424
  int 			plane;
425
  int			date;
426
  float			ced_s;   /* ed s value as ordering par */
427
  float			ced_setting;
428
  int			tbt_src;
429
  char			tbt_name[8];
430
 } __attribute__((packed)) /* Added by the PACKINATOR(tm) */ CALI_HDR_STRUCT;
431

    
432

    
433
-----------------------------------------------------
434

    
435
savf package for closure data saving:
436

    
437
#ifdef TIT_LEN
438
#undef TIT_LEN
439
#endif
440
#define TIT_LEN 32
441
#define SF_DAT_LEN 128
442

    
443
typedef struct {
444
  char		title[TIT_LEN];
445
  int		id;
446
  int		date;
447
  int		length;
448
 }  __attribute__((packed)) /* Added by the PACKINATOR(tm) */ SF_HDR_REC_STRUCT;
449
table name: cl_log_hdr_bpm(blt) - title, id = BO->RR line  8, 8
450
typedef struct {
451
  int		id;
452
  int		date;
453
  int		rec_id;
454
  float		dat[SF_DAT_LEN];
455
 }  __attribute__((packed)) /* Added by the PACKINATOR(tm) */ SF_DAT_REC_STRUCT;
456
table name: cl_log_real_bpm
457
example:
458

    
459
1> select * from cl_log_hdr_bpm where id=8 and date=1316423956
460
2> go
461
 title                            id          date        length
462
 -------------------------------- ----------- ----------- -----------
463
 BO->RR line  8                             8  1316423956           0
464

    
465
(1 row affected)
466
1> select * from cl_log_real_bpm where id=8 and date=1316423956
467
2> go
468
 id          date        rec_id      f0 - 127
469
         f1                          f2
470
         ---------------------------
471
           8  1316423956  1316423956                  225.000000
472
                            0.000000                    0.000000
473
                            2.081216                    1.219651
474
                            2.089324                    2.352937
475
                            5.662076                    3.693718
476
                            7.292950                    3.564213
477
                            6.124883                    5.361715
478
                            4.191740                    6.691816
479
                            3.815026                    6.354032
480
                            4.777052                    4.834116
481
                            6.328297                    3.616919
482
                            6.591923                    4.540035
483
                            5.058516                    5.696149
484
                            3.762272                    6.204570
485
                            4.018957                    5.120627
486
                            5.096181                    4.314499
487
                            5.801710                    4.204407
488
                            5.415218                    4.631732
489
                            4.341615                    5.404829
490
                            3.815787                    5.509065
491
                            4.557820                    4.975491
492
                            4.734690                    4.203851
493
                          999.000000                  999.000000
494
                          999.000000                  999.000000
495
                           -8.271114                   -7.160667
496
                           -6.480898                   -8.445275
497
                           -6.831185                   -6.645922
498
                           -8.602509                   -6.401356
499
                           -7.195747                   -8.085158
500
                           -6.463275                   -7.679450
501
                           -7.558105                   -6.837236
502
                           -7.597878                   -7.422530
503
                           -7.036052                   -7.448541
504
                           -7.462993                   -6.912925
505
                           -7.694888                   -7.378394
506
                           -6.963849                   -7.812184
507
                           -7.009545                   -7.266975
508
                           -7.774332                   -6.986961
509
                           -7.699433                   -7.566890
510
                           -7.298961                   -7.328400
511
                           -7.125653                   -7.117476
512
                           -7.403735                   -7.745275
513
                           -7.357403                   -7.373350
514
                           -7.307137                   -7.326241
515
                            0.210392                    0.342478
516
                            0.000000                    0.000000
517
                            0.000000                    0.000000
518
                            0.000000                    0.000000
519
                            0.000000                    0.000000
520
                            0.000000                    0.000000
521
                            0.000000                    0.000000
522
                            0.000000                    0.000000
523
                            0.000000                    0.000000
524
                            0.000000                    0.000000
525
                            0.000000                    0.000000
526
                            0.000000                    0.000000
527
                            0.000000                    0.000000
528
                            0.000000                    0.000000
529
                            0.000000                    0.000000
530
                            0.000000                    0.000000
531
                            0.000000                    0.000000
532
                            0.000000                    0.000000
533
                            0.000000                    0.000000
534
                            0.000000                    0.000000
535
                            0.000000
536

    
537
(1 row affected)
538
----------------------------
539

    
540
typedef struct { in log data structure program
541
  SF_HDR_REC_STRUCT 	hdr;
542
  float			*dat;
543
 }  __attribute__((packed)) /* Added by the PACKINATOR(tm) */ SF_STRUCT;
544