ngc 1.4.0
 
Loading...
Searching...
No Matches
ngcdcsSCA.hpp
Go to the documentation of this file.
1
7#ifndef ngcdcsSCA_H
8#define ngcdcsSCA_H
9
10
11#ifndef __cplusplus
12#error This is a C++ include file and cannot be used from plain C
13#endif
14
15#include <ngc/core/ngcbAddr.h>
16#include <ngc/core/ngcbMOD.hpp>
18
21
26 int addr; //< Start address
27 int *data; //< Register data
28 int len; //< Block length
29
32 if (this != &other)
33 {
34 addr = other.addr;
35 len = other.len;
36 data = (int *)malloc(len * sizeof(int));
37 if (data != NULL) memcpy(data, other.data, len * sizeof(int));
38 else len = 0;
39 }
40 return (*this);
41 }
42
45 addr = other.addr;
46 len = other.len;
47 data = (int *)malloc(len * sizeof(int));
48 if (data != NULL) memcpy(data, other.data, len * sizeof(int));
49 else len = 0;
50 }
51
53 ngcdcs_mc_block_t(int a, int n) {
54 addr = a;
55 data = (int *)malloc(n * sizeof(int));
56 if (data != NULL) len = n;
57 else len = 0;
58 }
59
62 if (data != NULL) free(data);
63 }
64};
65
66
70#define ngcdcsSCA_NUM_EXT_BIAS 20
71
75#define ngcdcsSCA_NUM_INT_BIAS 8
76
80#define ngcdcsSCA_NUM_BIAS (ngcdcsSCA_NUM_EXT_BIAS + ngcdcsSCA_NUM_INT_BIAS)
81
82/*
83 * Exposure modes
84 */
85#define ngcdcsSCA_MODE_RAMP 0x0 //< up-the-ramp
86#define ngcdcsSCA_MODE_FOWLER 0x1 //< fowler-mode
87
88/*
89 * Idle modes
90 */
91#define ngcdcsSCA_IDLE_SKIP 0x0 //< skip
92#define ngcdcsSCA_IDLE_RST 0x1 //< reset
93#define ngcdcsSCA_IDLE_RSTRD 0x2 //< reset-read
94
99 int nrst; //< Number of reset-frames (0x4000)
100 int nrd; //< Number of read-frames per group (0x4001)
101 int nrmp; //< Number of exposure ramps (0x4003)
102 int ngrp; //< Number of groups per ramp (0x4004)
103 int ndrop; //< Number of drop frames per group (0x4005)
104 int rowEndDelay; //< Extra pixels at end of row (0x4006)
105 int frameEndDelay; //< Extra rows at end of frame (0x4007)
106 int rstOut; //< Enable reset-frame data output (0x4002 bit0)
107 int clkDrop; //< Clock ASIC in drop-frames (0x4002 bit2)
108 int idleMode; //< Idle mode (None, Rst, RstRd) (0x4002 bit3-4)
109 int expMode; //< Fowler or up-the-ramp (0x4018)
110 unsigned int tFowlerExp; //< Fowler exposure time (0x400a + 65536 * 0x400b)
111 int enhancedClk; //< Enhanced clocking (0x4017 bit 0)
112 int globalReset; //< Global reset (0x4017 bit 1)
113 int nexp; //< Number of exposure ramps used
114 int nrst_x; //< Number of reset-frames changed
115 int nrd_x; //< Number of read-frames per group changed
116 int nrmp_x; //< Number of exposure ramps changed
117 int ngrp_x; //< Number of groups per ramp changed
118 int ndrop_x; //< Number of drop frames per group changed
119 int rowEndDelay_x; //< Extra pixels at end of row changed
120 int frameEndDelay_x; //< Extra rows at end of frame changed
121 int rstOut_x; //< Enable reset-frame data output changed
122 int clkDrop_x; //< Clock ASIC in drop-frames changed
123 int idleMode_x; //< Idle mode changed
124 int expMode_x; //< Fowler or up-the-ramp changed
125 int tFowlerExp_x; //< Fowler exposure time changed
126 int enhancedClk_x; //< Enhanced clocking changed
127 int globalReset_x; //< Global reset changed
128
131 nrst = 1;
132 nrd = 2;
133 nrmp = 1;
134 ngrp = 1;
135 ndrop = 0;
136 rowEndDelay = 2;
137 frameEndDelay = 0;
139 clkDrop = 1;
140 rstOut = 0;
142 tFowlerExp = 0;
143 nexp = nrmp;
144 enhancedClk = 0;
145 globalReset = 0;
146
147 nrst_x = 0; nrd_x = 0; nrmp_x = 0; ngrp_x = 0; ndrop_x = 0;
149 rstOut_x = 0; clkDrop_x = 0; idleMode_x = 0;
150 expMode_x = 0; tFowlerExp_x = 0;
152 }
153};
154
159 int cold; //< Detector is cold (0x4015)
160 int kTCRemove; //< Remove preamplifier kTC noise (0x4016 bit0)
161 int rowReset; //< Reset preamplifier once per row (0x4016 bit1)
162 int gain; //< Preamplifier gain (0x401a)
163 int cold_x; //< Detector is cold flag changed
164 int kTCRemove_x; //< Remove preamplifier kTC noise flag changed
165 int rowReset_x; //< Reset preamplifier once per row flag changed
166 int gain_x; //< Preamplifier gain changed
167
170 cold = 0;
171 kTCRemove = 1;
172 rowReset = 1;
173 gain = 12;
174 cold_x = 0; kTCRemove_x = 0; rowReset_x = 0; gain_x = 0;
175 }
176};
177
182{
183public:
185 explicit ngcdcsSCA(const ngcb_route_t &r);
186
188 ngcdcsSCA(ngcbIFC *ifc, const ngcb_route_t &r);
189
192
194 ngcdcsSCA(ngcbIFC *ifc, const ngcb_route_t &r, ngcbPARAM_LIST *p);
195
197 virtual ~ngcdcsSCA();
198
200 int id;
201
203 int flags;
204
206 char mcFile[256];
207
210
213
216
219
220
222 void Reset();
223
225 int Enable(int check = 1);
226
228 int Disable();
229
231 int Selftest();
232
233
234 /*
235 * ASIC register I/O
236 */
237
239 int Read(int addr, int *buffer, int size, int lw = -1);
240
242 int RdReg(int addr, int *value, int lw = -1);
243
245 int Write(int addr, int *buffer, int size);
246
248 int WrReg(int addr, int value);
249
250
251 /*
252 * Configuration and parameters
253 */
254
256 int UploadMcFile(const char *fileName);
257
259 int Reconfigure();
260
262 int PacketSize(int n);
263
265 int Delay(int n);
266
268 int Update();
269
271 int Window(ngcdcs_win_t w);
272
274 int ScaSetup(const char *key, const int *idx, const char *value, int *update,
275 int *handled = NULL);
276
278 int ScaStatus(const char *key, const int *idx, char *value,
279 int *handled = NULL);
280
281 /*
282 * Run-control
283 */
284
285 // Start clocking
286 int Start();
287
288 // Stop clocking
289 int Stop(int align, int force = 0);
290
291 /*
292 * Status
293 */
294
296 char *StatusString();
297
299 int Status(int *hwStat);
300
302 void NewStatus(int newStatus);
303
306 return ((status != ngcdcsSEQ_STAT_IDLE) &&
308 }
309
312
314 virtual int LookupCB(const char *name, char *value);
315
316
317 /*
318 * Sequencer setup
319 */
320
322 int LoadPrgFile(const char *name = NULL);
323
325 int ClearPrgFile();
326
328 int Preset(const char *key, const char *value, int *handled=NULL);
329
331 int Setup();
332
334 int NewSetup();
335
336
337 /*
338 * CLDC setup
339 */
340
342 int OutputEnable();
343
345 int OutputDisable();
346
348 int Snapshot();
349
351 int VoltageDC(int num, double volt, int rangeCheck=1);
352
354 int TelDC(int chan, double *volt);
355
357 int VSetup(int autoCtrl = 0);
358
360 char *VStatusString();
361
363 int LoadCfgFile(const char *fileName = NULL);
364
366 int SaveCfgFile(const char *fileName);
367
369 int Restore(const char *keyWord);
370
371protected:
372
373private:
375 void Init_();
376
378 int Initialize_();
379
381 char statStr_[32];
382
384 int online_;
385
386
387 /*
388 * Parameter list
389 */
390
392 ngcbPARAM_LIST *paramList_;
393
395 void UpdateParamList_();
396
398 void DetachParamList_();
399
401 int paramAttached_;
402
404 int dataIfc_;
405
406
407 /*
408 * Microcode
409 */
410
412 int LdCode_(const char *fileName);
413
415 int CodeLevel_();
416
418 int noReConf_;
419
420
421 /*
422 * Sequencer setup
423 */
424
426 ngcdcs_sca_exp_t expParam_;
427
429 int RdExp_();
430
432 int UploadSetup_();
433
435 int Setup_(ngcbPARAM_LIST *list);
436
438 void AddSeqIdx_(char *keyWord);
439
441 void DelSeqIdx_(char *keyWord);
442
444 void AddScaIdx_(char *keyWord);
445
447 void DelScaIdx_(char *keyWord);
448
450 int Lookup_(const char *, char *);
451
453 int LoadPrg_(const char *);
454
456 int Script_(const char *shell, const char *script, FILE *dbg,
457 ngcdcs_key_assign_t *defParam, int numDefParam,
458 ngcdcs_key_assign_t *newParam, int *numNewParam);
459
461 int GetFrameTime_();
462
464 void UpdateExpTime_();
465
467 double pixTime_;
468
470 double tRead_;
471
473 double tReset_;
474
476 int frameMode_;
477
478
479 /*
480 * CLDC setup
481 */
482
484 char vstatStr_[32];
485
487 int fileBufferLen_;
488
490 char fileBuffer_[ngcdcsCLDC_BUFSIZE];
491
493 int LoadCfg_(const char *restoreKey, const char *tmpFile);
494
496 void DefaultVoltages_();
497
499 int RdVolt_();
500
502 int Reg2Volt_(int chan, double *v, int force = 1);
503
505 int Volt2Reg_(int chan, double v);
506
508 double dcSave_[ngcbCLDC_MAX_DC];
509
511 void Mirror_(int addr, int *buffer, int size);
512
514 int useRegMirror_;
515
516
517 /*
518 * Preamplifier setup
519 */
520
522 ngcdcs_sca_pa_t paParam_;
523
525 int RdPreAmp_();
526
527};
528
529
530#endif
Definition ngcbIFC.hpp:754
Definition ngcbPARAM.hpp:200
int Start()
Start sequencer.
Definition ngcdcsSCA.cpp:654
int Reconfigure()
ASIC re-configure.
Definition ngcdcsSCA.cpp:439
int Disable()
Call-back at transition to not operational state.
Definition ngcdcsSCA.cpp:286
int ClearPrgFile()
Clear program file.
Definition ngcdcsScaPrg.cpp:28
int UploadMcFile(const char *fileName)
Upload micro-controller file.
Definition ngcdcsScaCfg.cpp:360
int VoltageDC(int num, double volt, int rangeCheck=1)
Set DC voltage.
Definition ngcdcsSCA.cpp:991
int LoadPrgFile(const char *name=NULL)
Load sequencer program file.
Definition ngcdcsScaPrg.cpp:55
int rxDelay
RX-delay (phase-shift in steps of 5 ns)
Definition ngcdcsSCA.hpp:212
int Preset(const char *key, const char *value, int *handled=NULL)
Parameter preset.
Definition ngcdcsScaSetup.cpp:164
int RdReg(int addr, int *value, int lw=-1)
Read register value.
Definition ngcdcsSCA.cpp:385
int flags
ASIC i/o-flags.
Definition ngcdcsSCA.hpp:203
int OutputDisable()
Disable output.
Definition ngcdcsSCA.cpp:907
int VSetup(int autoCtrl=0)
Apply voltage setup.
Definition ngcdcsSCA.cpp:1056
int WrReg(int addr, int value)
Write register value.
Definition ngcdcsSCA.cpp:424
int packetSize
Data packet size (in 32-bit words)
Definition ngcdcsSCA.hpp:209
int Window(ngcdcs_win_t w)
Apply read-out window.
Definition ngcdcsSCA.cpp:1078
int Delay(int n)
Set data delay (steps of 5 ns)
Definition ngcdcsSCA.cpp:630
int LoadCfgFile(const char *fileName=NULL)
Load voltage configuration.
Definition ngcdcsScaCfg.cpp:553
int Stop(int align, int force=0)
Stop sequencer.
Definition ngcdcsSCA.cpp:697
int SaveCfgFile(const char *fileName)
Save voltage configuration.
Definition ngcdcsScaCfg.cpp:1148
char * StatusString()
Get status string.
Definition ngcdcsSCA.cpp:830
int NewSetup()
New setup.
Definition ngcdcsScaSetup.cpp:414
virtual int LookupCB(const char *name, char *value)
Parameter lookup.
Definition ngcdcsScaPrg.cpp:163
void Reset()
Align software state after reset.
Definition ngcdcsSCA.cpp:835
char * VStatusString()
Get voltage status string.
Definition ngcdcsSCA.cpp:1051
int Read(int addr, int *buffer, int size, int lw=-1)
Read register buffer.
Definition ngcdcsSCA.cpp:354
virtual ~ngcdcsSCA()
Destructor.
Definition ngcdcsSCA.cpp:60
int OutputEnable()
Enable output.
Definition ngcdcsSCA.cpp:842
void NewStatus(int newStatus)
Set new soft status.
Definition ngcdcsSCA.cpp:744
ngcdcs_sca_pa_t paParam
ASIC preamplifier setup parameters.
Definition ngcdcsSCA.hpp:218
int Restore(const char *keyWord)
Restore keyword from the last loaded file.
Definition ngcdcsScaCfg.cpp:558
int Enable(int check=1)
Call-back at transition to operational state.
Definition ngcdcsSCA.cpp:143
int Update()
Read back all relevant values.
Definition ngcdcsScaCfg.cpp:524
int FailureState()
Check if in failure state.
Definition ngcdcsSCA.hpp:311
int Selftest()
Perform selftest.
Definition ngcdcsSCA.cpp:345
ngcdcsSCA(const ngcb_route_t &r)
Constructor with route.
Definition ngcdcsSCA.cpp:28
int Setup()
Upload current setup.
Definition ngcdcsScaSetup.cpp:434
int RunningState()
Check if in running state.
Definition ngcdcsSCA.hpp:305
int Snapshot()
Telemetry snapshot.
Definition ngcdcsSCA.cpp:973
int Status(int *hwStat)
Get status value.
Definition ngcdcsSCA.cpp:789
ngcdcs_sca_exp_t expParam
ASIC exposure setup parameters.
Definition ngcdcsSCA.hpp:215
int id
ASIC ID.
Definition ngcdcsSCA.hpp:200
int TelDC(int chan, double *volt)
Telemetry for DC-bias.
Definition ngcdcsSCA.cpp:1029
char mcFile[256]
Micro-controller file.
Definition ngcdcsSCA.hpp:206
int Write(int addr, int *buffer, int size)
Write register buffer.
Definition ngcdcsSCA.cpp:398
int ScaStatus(const char *key, const int *idx, char *value, int *handled=NULL)
Parameter status.
Definition ngcdcsScaStatus.cpp:26
int PacketSize(int n)
Set packet size.
Definition ngcdcsSCA.cpp:543
int ScaSetup(const char *key, const int *idx, const char *value, int *update, int *handled=NULL)
Parameter setup.
Definition ngcdcsScaSetup.cpp:26
int status
Soft state: idle, waiting, running or failure.
Definition ngcdcsSEQ.hpp:215
ngcdcsSEQ0(const ngcb_route_t &r, int nc, int nb)
Constructor with route, number of clocks and number of biases.
Definition ngcdcsSEQ.hpp:278
#define ngcbCLDC_MAX_DC
Definition ngcbAddr.h:333
#define ngcdcsCLDC_BUFSIZE
Definition ngcdcsCLDC.hpp:33
#define ngcdcsSCA_IDLE_RST
Definition ngcdcsSCA.hpp:92
#define ngcdcsSCA_MODE_RAMP
Definition ngcdcsSCA.hpp:85
#define ngcdcsSEQ_STAT_IDLE
Definition ngcdcsSEQ.hpp:40
#define ngcdcsSEQ_STAT_FAILURE
Definition ngcdcsSEQ.hpp:44
Definition ngcbIFC.hpp:72
Definition ngcdcsSEQ.hpp:145
int len
Definition ngcdcsSCA.hpp:28
ngcdcs_mc_block_t(int a, int n)
Constructor.
Definition ngcdcsSCA.hpp:53
~ngcdcs_mc_block_t()
Destructor.
Definition ngcdcsSCA.hpp:61
ngcdcs_mc_block_t(const ngcdcs_mc_block_t &other)
Copy constructor.
Definition ngcdcsSCA.hpp:44
ngcdcs_mc_block_t & operator=(const ngcdcs_mc_block_t &other)
Operator =.
Definition ngcdcsSCA.hpp:31
int * data
Definition ngcdcsSCA.hpp:27
int addr
Definition ngcdcsSCA.hpp:26
Definition ngcdcsSCA.hpp:98
unsigned int tFowlerExp
Definition ngcdcsSCA.hpp:110
int nrmp
Definition ngcdcsSCA.hpp:101
int tFowlerExp_x
Definition ngcdcsSCA.hpp:125
int clkDrop
Definition ngcdcsSCA.hpp:107
int enhancedClk_x
Definition ngcdcsSCA.hpp:126
int nrd
Definition ngcdcsSCA.hpp:100
int expMode_x
Definition ngcdcsSCA.hpp:124
int ndrop
Definition ngcdcsSCA.hpp:103
int rowEndDelay
Definition ngcdcsSCA.hpp:104
int frameEndDelay_x
Definition ngcdcsSCA.hpp:120
int rstOut
Definition ngcdcsSCA.hpp:106
int clkDrop_x
Definition ngcdcsSCA.hpp:122
int ndrop_x
Definition ngcdcsSCA.hpp:118
int expMode
Definition ngcdcsSCA.hpp:109
int ngrp_x
Definition ngcdcsSCA.hpp:117
int nrd_x
Definition ngcdcsSCA.hpp:115
int rstOut_x
Definition ngcdcsSCA.hpp:121
int idleMode_x
Definition ngcdcsSCA.hpp:123
int globalReset
Definition ngcdcsSCA.hpp:112
int nrst
Definition ngcdcsSCA.hpp:99
int enhancedClk
Definition ngcdcsSCA.hpp:111
int rowEndDelay_x
Definition ngcdcsSCA.hpp:119
int frameEndDelay
Definition ngcdcsSCA.hpp:105
int nrst_x
Definition ngcdcsSCA.hpp:114
int nexp
Definition ngcdcsSCA.hpp:113
int ngrp
Definition ngcdcsSCA.hpp:102
int idleMode
Definition ngcdcsSCA.hpp:108
ngcdcs_sca_exp_t()
Constructor.
Definition ngcdcsSCA.hpp:130
int nrmp_x
Definition ngcdcsSCA.hpp:116
int globalReset_x
Definition ngcdcsSCA.hpp:127
Definition ngcdcsSCA.hpp:158
int kTCRemove
Definition ngcdcsSCA.hpp:160
int gain
Definition ngcdcsSCA.hpp:162
ngcdcs_sca_pa_t()
Constructor.
Definition ngcdcsSCA.hpp:169
int cold
Definition ngcdcsSCA.hpp:159
int kTCRemove_x
Definition ngcdcsSCA.hpp:164
int rowReset_x
Definition ngcdcsSCA.hpp:165
int rowReset
Definition ngcdcsSCA.hpp:161
int gain_x
Definition ngcdcsSCA.hpp:166
int cold_x
Definition ngcdcsSCA.hpp:163
Definition ngcdcsSEQ.hpp:156