ngc 1.5.0
 
Loading...
Searching...
No Matches
ngcdcsSCA.hpp
Go to the documentation of this file.
1
8#ifndef ngcdcsSCA_H
9#define ngcdcsSCA_H
10
11
12#ifndef __cplusplus
13#error This is a C++ include file and cannot be used from plain C
14#endif
15
16#include <ngc/core/ngcbAddr.h>
17#include <ngc/core/ngcbMOD.hpp>
19
22
27 int addr; //< Start address
28 int *data; //< Register data
29 int len; //< Block length
30
33 if (this != &other)
34 {
35 addr = other.addr;
36 len = other.len;
37 data = (int *)malloc(len * sizeof(int));
38 if (data != NULL) memcpy(data, other.data, len * sizeof(int));
39 else len = 0;
40 }
41 return (*this);
42 }
43
46 addr = other.addr;
47 len = other.len;
48 data = (int *)malloc(len * sizeof(int));
49 if (data != NULL) memcpy(data, other.data, len * sizeof(int));
50 else len = 0;
51 }
52
54 ngcdcs_mc_block_t(int a, int n) {
55 addr = a;
56 data = (int *)malloc(n * sizeof(int));
57 if (data != NULL) len = n;
58 else len = 0;
59 }
60
63 if (data != NULL) free(data);
64 }
65};
66
67
71#define ngcdcsSCA_NUM_EXT_BIAS 20
72
76#define ngcdcsSCA_NUM_INT_BIAS 8
77
81#define ngcdcsSCA_NUM_BIAS (ngcdcsSCA_NUM_EXT_BIAS + ngcdcsSCA_NUM_INT_BIAS)
82
83/*
84 * Exposure modes
85 */
86#define ngcdcsSCA_MODE_RAMP 0x0 //< up-the-ramp
87#define ngcdcsSCA_MODE_FOWLER 0x1 //< fowler-mode
88
89/*
90 * Idle modes
91 */
92#define ngcdcsSCA_IDLE_SKIP 0x0 //< skip
93#define ngcdcsSCA_IDLE_RST 0x1 //< reset
94#define ngcdcsSCA_IDLE_RSTRD 0x2 //< reset-read
95
100 int nrst; //< Number of reset-frames (0x4000)
101 int nrd; //< Number of read-frames per group (0x4001)
102 int nrmp; //< Number of exposure ramps (0x4003)
103 int ngrp; //< Number of groups per ramp (0x4004)
104 int ndrop; //< Number of drop frames per group (0x4005)
105 int rowEndDelay; //< Extra pixels at end of row (0x4006)
106 int frameEndDelay; //< Extra rows at end of frame (0x4007)
107 int rstOut; //< Enable reset-frame data output (0x4002 bit0)
108 int clkDrop; //< Clock ASIC in drop-frames (0x4002 bit2)
109 int idleMode; //< Idle mode (None, Rst, RstRd) (0x4002 bit3-4)
110 int expMode; //< Fowler or up-the-ramp (0x4018)
111 unsigned int tFowlerExp; //< Fowler exposure time (0x400a + 65536 * 0x400b)
112 int enhancedClk; //< Enhanced clocking (0x4017 bit 0)
113 int globalReset; //< Global reset (0x4017 bit 1)
114 int nexp; //< Number of exposure ramps used
115 int nrst_x; //< Number of reset-frames changed
116 int nrd_x; //< Number of read-frames per group changed
117 int nrmp_x; //< Number of exposure ramps changed
118 int ngrp_x; //< Number of groups per ramp changed
119 int ndrop_x; //< Number of drop frames per group changed
120 int rowEndDelay_x; //< Extra pixels at end of row changed
121 int frameEndDelay_x; //< Extra rows at end of frame changed
122 int rstOut_x; //< Enable reset-frame data output changed
123 int clkDrop_x; //< Clock ASIC in drop-frames changed
124 int idleMode_x; //< Idle mode changed
125 int expMode_x; //< Fowler or up-the-ramp changed
126 int tFowlerExp_x; //< Fowler exposure time changed
127 int enhancedClk_x; //< Enhanced clocking changed
128 int globalReset_x; //< Global reset changed
129
132 nrst = 1;
133 nrd = 2;
134 nrmp = 1;
135 ngrp = 1;
136 ndrop = 0;
137 rowEndDelay = 2;
138 frameEndDelay = 0;
140 clkDrop = 1;
141 rstOut = 0;
143 tFowlerExp = 0;
144 nexp = nrmp;
145 enhancedClk = 0;
146 globalReset = 0;
147
148 nrst_x = 0; nrd_x = 0; nrmp_x = 0; ngrp_x = 0; ndrop_x = 0;
150 rstOut_x = 0; clkDrop_x = 0; idleMode_x = 0;
151 expMode_x = 0; tFowlerExp_x = 0;
153 }
154};
155
160 int cold; //< Detector is cold (0x4015)
161 int kTCRemove; //< Remove preamplifier kTC noise (0x4016 bit0)
162 int rowReset; //< Reset preamplifier once per row (0x4016 bit1)
163 int gain; //< Preamplifier gain (0x401a)
164 int cold_x; //< Detector is cold flag changed
165 int kTCRemove_x; //< Remove preamplifier kTC noise flag changed
166 int rowReset_x; //< Reset preamplifier once per row flag changed
167 int gain_x; //< Preamplifier gain changed
168
171 cold = 0;
172 kTCRemove = 1;
173 rowReset = 1;
174 gain = 12;
175 cold_x = 0; kTCRemove_x = 0; rowReset_x = 0; gain_x = 0;
176 }
177};
178
183{
184public:
186 explicit ngcdcsSCA(const ngcb_route_t &r);
187
189 ngcdcsSCA(ngcbIFC *ifc, const ngcb_route_t &r);
190
193
195 ngcdcsSCA(ngcbIFC *ifc, const ngcb_route_t &r, ngcbPARAM_LIST *p);
196
198 virtual ~ngcdcsSCA();
199
201 int id;
202
204 int flags;
205
207 char mcFile[256];
208
211
214
217
220
221
223 void Reset();
224
226 int Enable(int check = 1);
227
229 int Disable();
230
232 int Selftest();
233
234
235 /*
236 * ASIC register I/O
237 */
238
240 int Read(int addr, int *buffer, int size, int lw = -1);
241
243 int RdReg(int addr, int *value, int lw = -1);
244
246 int Write(int addr, int *buffer, int size);
247
249 int WrReg(int addr, int value);
250
251
252 /*
253 * Configuration and parameters
254 */
255
257 int UploadMcFile(const char *fileName);
258
260 int Reconfigure();
261
263 int PacketSize(int n);
264
266 int Delay(int n);
267
269 int Update();
270
272 int Window(ngcdcs_win_t w);
273
275 int ScaSetup(const char *key, const int *idx, const char *value, int *update,
276 int *handled = NULL);
277
279 int ScaStatus(const char *key, const int *idx, char *value,
280 int *handled = NULL);
281
282 /*
283 * Run-control
284 */
285
286 // Start clocking
287 int Start();
288
289 // Stop clocking
290 int Stop(int align, int force = 0);
291
292 /*
293 * Status
294 */
295
297 char *StatusString();
298
300 int Status(int *hwStat);
301
303 void NewStatus(int newStatus);
304
307 return ((status != ngcdcsSEQ_STAT_IDLE) &&
309 }
310
313
315 virtual int LookupCB(const char *name, char *value);
316
317
318 /*
319 * Sequencer setup
320 */
321
323 int LoadPrgFile(const char *name = NULL);
324
326 int ClearPrgFile();
327
329 int Preset(const char *key, const char *value, int *handled=NULL);
330
332 int Setup();
333
335 int NewSetup();
336
337
338 /*
339 * CLDC setup
340 */
341
343 int OutputEnable();
344
346 int OutputDisable();
347
349 int Snapshot();
350
352 int VoltageDC(int num, double volt, int rangeCheck=1);
353
355 int TelDC(int chan, double *volt);
356
358 int VSetup(int autoCtrl = 0);
359
361 char *VStatusString();
362
364 int LoadCfgFile(const char *fileName = NULL);
365
367 int SaveCfgFile(const char *fileName);
368
370 int Restore(const char *keyWord);
371
372protected:
373
374private:
376 void Init_();
377
379 int Initialize_();
380
382 char statStr_[32];
383
385 int online_;
386
387
388 /*
389 * Parameter list
390 */
391
393 ngcbPARAM_LIST *paramList_;
394
396 void UpdateParamList_();
397
399 void DetachParamList_();
400
402 int paramAttached_;
403
405 int dataIfc_;
406
407
408 /*
409 * Microcode
410 */
411
413 int LdCode_(const char *fileName);
414
416 int CodeLevel_();
417
419 int noReConf_;
420
421
422 /*
423 * Sequencer setup
424 */
425
427 ngcdcs_sca_exp_t expParam_;
428
430 int RdExp_();
431
433 int UploadSetup_();
434
436 int Setup_(ngcbPARAM_LIST *list);
437
439 void AddSeqIdx_(char *keyWord);
440
442 void DelSeqIdx_(char *keyWord);
443
445 void AddScaIdx_(char *keyWord);
446
448 void DelScaIdx_(char *keyWord);
449
451 int Lookup_(const char *, char *);
452
454 int LoadPrg_(const char *);
455
457 int Script_(const char *shell, const char *script, FILE *dbg,
458 ngcdcs_key_assign_t *defParam, int numDefParam,
459 ngcdcs_key_assign_t *newParam, int *numNewParam);
460
462 int GetFrameTime_();
463
465 void UpdateExpTime_();
466
468 double pixTime_;
469
471 double tRead_;
472
474 double tReset_;
475
477 int frameMode_;
478
479
480 /*
481 * CLDC setup
482 */
483
485 char vstatStr_[32];
486
488 int fileBufferLen_;
489
491 char fileBuffer_[ngcdcsCLDC_BUFSIZE];
492
494 int LoadCfg_(const char *restoreKey, const char *tmpFile);
495
497 void DefaultVoltages_();
498
500 int RdVolt_();
501
503 int Reg2Volt_(int chan, double *v, int force = 1);
504
506 int Volt2Reg_(int chan, double v);
507
509 double dcSave_[ngcbCLDC_MAX_DC];
510
512 void Mirror_(int addr, int *buffer, int size);
513
515 int useRegMirror_;
516
517
518 /*
519 * Preamplifier setup
520 */
521
523 ngcdcs_sca_pa_t paParam_;
524
526 int RdPreAmp_();
527
528};
529
530
531#endif
Definition ngcbIFC.hpp:760
Definition ngcbPARAM.hpp:201
int Start()
Start sequencer.
Definition ngcdcsSCA.cpp:655
int Reconfigure()
ASIC re-configure.
Definition ngcdcsSCA.cpp:440
int Disable()
Call-back at transition to not operational state.
Definition ngcdcsSCA.cpp:287
int ClearPrgFile()
Clear program file.
Definition ngcdcsScaPrg.cpp:29
int UploadMcFile(const char *fileName)
Upload micro-controller file.
Definition ngcdcsScaCfg.cpp:361
int VoltageDC(int num, double volt, int rangeCheck=1)
Set DC voltage.
Definition ngcdcsSCA.cpp:992
int LoadPrgFile(const char *name=NULL)
Load sequencer program file.
Definition ngcdcsScaPrg.cpp:65
int rxDelay
RX-delay (phase-shift in steps of 5 ns)
Definition ngcdcsSCA.hpp:213
int Preset(const char *key, const char *value, int *handled=NULL)
Parameter preset.
Definition ngcdcsScaSetup.cpp:165
int RdReg(int addr, int *value, int lw=-1)
Read register value.
Definition ngcdcsSCA.cpp:386
int flags
ASIC i/o-flags.
Definition ngcdcsSCA.hpp:204
int OutputDisable()
Disable output.
Definition ngcdcsSCA.cpp:908
int VSetup(int autoCtrl=0)
Apply voltage setup.
Definition ngcdcsSCA.cpp:1057
int WrReg(int addr, int value)
Write register value.
Definition ngcdcsSCA.cpp:425
int packetSize
Data packet size (in 32-bit words)
Definition ngcdcsSCA.hpp:210
int Window(ngcdcs_win_t w)
Apply read-out window.
Definition ngcdcsSCA.cpp:1079
int Delay(int n)
Set data delay (steps of 5 ns)
Definition ngcdcsSCA.cpp:631
int LoadCfgFile(const char *fileName=NULL)
Load voltage configuration.
Definition ngcdcsScaCfg.cpp:554
int Stop(int align, int force=0)
Stop sequencer.
Definition ngcdcsSCA.cpp:698
int SaveCfgFile(const char *fileName)
Save voltage configuration.
Definition ngcdcsScaCfg.cpp:1149
char * StatusString()
Get status string.
Definition ngcdcsSCA.cpp:831
int NewSetup()
New setup.
Definition ngcdcsScaSetup.cpp:415
virtual int LookupCB(const char *name, char *value)
Parameter lookup.
Definition ngcdcsScaPrg.cpp:174
void Reset()
Align software state after reset.
Definition ngcdcsSCA.cpp:836
char * VStatusString()
Get voltage status string.
Definition ngcdcsSCA.cpp:1052
int Read(int addr, int *buffer, int size, int lw=-1)
Read register buffer.
Definition ngcdcsSCA.cpp:355
virtual ~ngcdcsSCA()
Destructor.
Definition ngcdcsSCA.cpp:61
int OutputEnable()
Enable output.
Definition ngcdcsSCA.cpp:843
void NewStatus(int newStatus)
Set new soft status.
Definition ngcdcsSCA.cpp:745
ngcdcs_sca_pa_t paParam
ASIC preamplifier setup parameters.
Definition ngcdcsSCA.hpp:219
int Restore(const char *keyWord)
Restore keyword from the last loaded file.
Definition ngcdcsScaCfg.cpp:559
int Enable(int check=1)
Call-back at transition to operational state.
Definition ngcdcsSCA.cpp:144
int Update()
Read back all relevant values.
Definition ngcdcsScaCfg.cpp:525
int FailureState()
Check if in failure state.
Definition ngcdcsSCA.hpp:312
int Selftest()
Perform selftest.
Definition ngcdcsSCA.cpp:346
ngcdcsSCA(const ngcb_route_t &r)
Constructor with route.
Definition ngcdcsSCA.cpp:29
int Setup()
Upload current setup.
Definition ngcdcsScaSetup.cpp:435
int RunningState()
Check if in running state.
Definition ngcdcsSCA.hpp:306
int Snapshot()
Telemetry snapshot.
Definition ngcdcsSCA.cpp:974
int Status(int *hwStat)
Get status value.
Definition ngcdcsSCA.cpp:790
ngcdcs_sca_exp_t expParam
ASIC exposure setup parameters.
Definition ngcdcsSCA.hpp:216
int id
ASIC ID.
Definition ngcdcsSCA.hpp:201
int TelDC(int chan, double *volt)
Telemetry for DC-bias.
Definition ngcdcsSCA.cpp:1030
char mcFile[256]
Micro-controller file.
Definition ngcdcsSCA.hpp:207
int Write(int addr, int *buffer, int size)
Write register buffer.
Definition ngcdcsSCA.cpp:399
int ScaStatus(const char *key, const int *idx, char *value, int *handled=NULL)
Parameter status.
Definition ngcdcsScaStatus.cpp:27
int PacketSize(int n)
Set packet size.
Definition ngcdcsSCA.cpp:544
int ScaSetup(const char *key, const int *idx, const char *value, int *update, int *handled=NULL)
Parameter setup.
Definition ngcdcsScaSetup.cpp:27
int status
Soft state: idle, waiting, running or failure.
Definition ngcdcsSEQ.hpp:219
ngcdcsSEQ0(const ngcb_route_t &r, int nc, int nb)
Constructor with route, number of clocks and number of biases.
Definition ngcdcsSEQ.hpp:285
#define ngcbCLDC_MAX_DC
Definition ngcbAddr.h:334
#define ngcdcsCLDC_BUFSIZE
Definition ngcdcsCLDC.hpp:34
#define ngcdcsSCA_IDLE_RST
Definition ngcdcsSCA.hpp:93
#define ngcdcsSCA_MODE_RAMP
Definition ngcdcsSCA.hpp:86
#define ngcdcsSEQ_STAT_IDLE
Definition ngcdcsSEQ.hpp:41
#define ngcdcsSEQ_STAT_FAILURE
Definition ngcdcsSEQ.hpp:45
Definition ngcbIFC.hpp:78
Definition ngcdcsSEQ.hpp:146
int len
Definition ngcdcsSCA.hpp:29
ngcdcs_mc_block_t(int a, int n)
Constructor.
Definition ngcdcsSCA.hpp:54
~ngcdcs_mc_block_t()
Destructor.
Definition ngcdcsSCA.hpp:62
ngcdcs_mc_block_t(const ngcdcs_mc_block_t &other)
Copy constructor.
Definition ngcdcsSCA.hpp:45
ngcdcs_mc_block_t & operator=(const ngcdcs_mc_block_t &other)
Operator =.
Definition ngcdcsSCA.hpp:32
int * data
Definition ngcdcsSCA.hpp:28
int addr
Definition ngcdcsSCA.hpp:27
Definition ngcdcsSCA.hpp:99
unsigned int tFowlerExp
Definition ngcdcsSCA.hpp:111
int nrmp
Definition ngcdcsSCA.hpp:102
int tFowlerExp_x
Definition ngcdcsSCA.hpp:126
int clkDrop
Definition ngcdcsSCA.hpp:108
int enhancedClk_x
Definition ngcdcsSCA.hpp:127
int nrd
Definition ngcdcsSCA.hpp:101
int expMode_x
Definition ngcdcsSCA.hpp:125
int ndrop
Definition ngcdcsSCA.hpp:104
int rowEndDelay
Definition ngcdcsSCA.hpp:105
int frameEndDelay_x
Definition ngcdcsSCA.hpp:121
int rstOut
Definition ngcdcsSCA.hpp:107
int clkDrop_x
Definition ngcdcsSCA.hpp:123
int ndrop_x
Definition ngcdcsSCA.hpp:119
int expMode
Definition ngcdcsSCA.hpp:110
int ngrp_x
Definition ngcdcsSCA.hpp:118
int nrd_x
Definition ngcdcsSCA.hpp:116
int rstOut_x
Definition ngcdcsSCA.hpp:122
int idleMode_x
Definition ngcdcsSCA.hpp:124
int globalReset
Definition ngcdcsSCA.hpp:113
int nrst
Definition ngcdcsSCA.hpp:100
int enhancedClk
Definition ngcdcsSCA.hpp:112
int rowEndDelay_x
Definition ngcdcsSCA.hpp:120
int frameEndDelay
Definition ngcdcsSCA.hpp:106
int nrst_x
Definition ngcdcsSCA.hpp:115
int nexp
Definition ngcdcsSCA.hpp:114
int ngrp
Definition ngcdcsSCA.hpp:103
int idleMode
Definition ngcdcsSCA.hpp:109
ngcdcs_sca_exp_t()
Constructor.
Definition ngcdcsSCA.hpp:131
int nrmp_x
Definition ngcdcsSCA.hpp:117
int globalReset_x
Definition ngcdcsSCA.hpp:128
Definition ngcdcsSCA.hpp:159
int kTCRemove
Definition ngcdcsSCA.hpp:161
int gain
Definition ngcdcsSCA.hpp:163
ngcdcs_sca_pa_t()
Constructor.
Definition ngcdcsSCA.hpp:170
int cold
Definition ngcdcsSCA.hpp:160
int kTCRemove_x
Definition ngcdcsSCA.hpp:165
int rowReset_x
Definition ngcdcsSCA.hpp:166
int rowReset
Definition ngcdcsSCA.hpp:162
int gain_x
Definition ngcdcsSCA.hpp:167
int cold_x
Definition ngcdcsSCA.hpp:164
Definition ngcdcsSEQ.hpp:157