Mercurial > hg > fxanalyse
annotate FXAnalyse.c @ 217:fefe921a9784
Use DDS4 for shifting Sr beatnote frequency to 10 kHz
author | Daniele Nicolodi <daniele.nicolodi@obspm.fr> |
---|---|
date | Tue, 15 Apr 2014 13:35:07 +0200 |
parents | 72fafb670eaf |
children | 28a4ff70fe48 |
rev | line source |
---|---|
119
f9fb17fb64cc
Add Sr frequency logging to disk and to Sr data logger
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
118
diff
changeset
|
1 #include <tcpsupp.h> |
0 | 2 #include <utility.h> |
3 #include <ansi_c.h> | |
183
791ca26fee6a
Rewrite data writing to file
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
180
diff
changeset
|
4 #include <lowlvlio.h> |
0 | 5 #include <cvirte.h> |
6 #include <userint.h> | |
7 #include <formatio.h> | |
166 | 8 #include <inifile.h> |
0 | 9 #include <string.h> |
10 | |
11 #include "FXAnalyse.h" | |
12 #include "Plot.h" | |
13 #include "Allan.h" | |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
14 #include "ad9912.h" |
209
11a88d389705
Adapt to new AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
205
diff
changeset
|
15 #include "ad9956.h" |
0 | 16 #include "muParserDLL.h" |
144 | 17 #include "utils.h" |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
18 #include "stat.h" |
166 | 19 #include "future.h" |
144 | 20 #include "data-provider.h" |
169
97112b45b838
Get Sr data logger parameters from configuration file. Code reorganization.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
168
diff
changeset
|
21 #include "sr-data-logger.h" |
97112b45b838
Get Sr data logger parameters from configuration file. Code reorganization.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
168
diff
changeset
|
22 #include "config.h" |
97112b45b838
Get Sr data logger parameters from configuration file. Code reorganization.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
168
diff
changeset
|
23 #include "logging.h" |
0 | 24 |
166 | 25 |
109
2a9f8a811d87
Fix N3 measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
105
diff
changeset
|
26 #define FREP_STEP_SIZE 50000.0 |
160
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
27 #define SPEED_OF_LIGHT 299792458.0 // m/s |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
28 #define SR_WAVELENGTH 698.4460 // nm |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
29 #define HG_WAVELENGTH 1062.4000 // nm |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
30 |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
31 |
170
a4fcebb5941b
Make data folder configurable in configuration file
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
169
diff
changeset
|
32 // select which data provider to use |
a4fcebb5941b
Make data folder configurable in configuration file
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
169
diff
changeset
|
33 #ifdef NDEBUG |
a4fcebb5941b
Make data folder configurable in configuration file
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
169
diff
changeset
|
34 #define DataProvider KKDataProvider |
a4fcebb5941b
Make data folder configurable in configuration file
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
169
diff
changeset
|
35 #else |
a4fcebb5941b
Make data folder configurable in configuration file
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
169
diff
changeset
|
36 #define DataProvider FakeDataProvider |
a4fcebb5941b
Make data folder configurable in configuration file
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
169
diff
changeset
|
37 #endif |
a4fcebb5941b
Make data folder configurable in configuration file
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
169
diff
changeset
|
38 |
166 | 39 |
88
9b7588cd4013
Move data acquisition into separate thread
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
87
diff
changeset
|
40 // data acquisition status |
9b7588cd4013
Move data acquisition into separate thread
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
87
diff
changeset
|
41 int acquiring; |
9b7588cd4013
Move data acquisition into separate thread
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
87
diff
changeset
|
42 // data queue |
9b7588cd4013
Move data acquisition into separate thread
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
87
diff
changeset
|
43 CmtTSQHandle dataQueue; |
9b7588cd4013
Move data acquisition into separate thread
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
87
diff
changeset
|
44 // data provider thread |
9b7588cd4013
Move data acquisition into separate thread
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
87
diff
changeset
|
45 CmtThreadFunctionID dataProviderThread; |
0 | 46 |
88
9b7588cd4013
Move data acquisition into separate thread
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
87
diff
changeset
|
47 |
142
fd085d61e4ca
Rework data logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
140
diff
changeset
|
48 struct event event; |
88
9b7588cd4013
Move data acquisition into separate thread
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
87
diff
changeset
|
49 double utc; |
37 | 50 double Ch1, Ch2, Ch3, Ch4; |
51 double Math1, Math2, Math3, Math4, Math5; | |
135 | 52 double N1, N2, N3; |
166 | 53 double Ndiv = 8.0; |
54 double Sign1 = 1.0, Sign2 = 1.0, Sign3 = 0.0; | |
168 | 55 void *MathParser1, *MathParser2, *MathParser3, *MathParser4, *MathParser5; |
56 | |
0 | 57 |
134
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
58 // panels |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
59 static int MainPanel; |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
60 static int CalcNPanel; |
160
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
61 static int EstimateNPanel; |
134
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
62 |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
63 |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
64 struct adev { |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
65 Allan_Data allan; |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
66 double *data; |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
67 const char *title; |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
68 double normalization; |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
69 int control; |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
70 }; |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
71 |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
72 |
161
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
73 #define ADEV(__channel, __normalization) \ |
134
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
74 { \ |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
75 .data = & ## __channel, \ |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
76 .title = #__channel, \ |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
77 .normalization = __normalization, \ |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
78 .control = PANEL_ADEV_ ## __channel \ |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
79 } |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
80 |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
81 |
136 | 82 static int adev_toggle(struct adev *adev) |
134
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
83 { |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
84 if (adev->allan.active) |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
85 Allan_ClosePanel(&(adev->allan)); |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
86 else |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
87 Allan_InitPanel(&(adev->allan), adev->title, |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
88 adev->normalization, MainPanel, adev->control); |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
89 return adev->allan.active; |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
90 } |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
91 |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
92 |
136 | 93 static inline void adev_update(struct adev *adev) |
134
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
94 { |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
95 if (adev->allan.active) |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
96 Allan_AddFrequency(&(adev->allan), *(adev->data)); |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
97 } |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
98 |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
99 |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
100 struct adev adevs[] = { |
161
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
101 ADEV(Ch1, 1.84e12), |
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
102 ADEV(Ch2, 10.0e3), |
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
103 ADEV(Ch3, 429.228e12), |
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
104 ADEV(Ch4, 275.0e3), |
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
105 ADEV(Math1, 250.0e6), |
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
106 ADEV(Math2, 194.395e12), |
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
107 ADEV(Math3, 282.143e12), |
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
108 ADEV(Math4, 429.228e12), |
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
109 ADEV(Math5, 1.0), |
134
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
110 { NULL } |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
111 }; |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
112 |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
113 |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
114 struct plot { |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
115 Plot_Data plot; |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
116 double *data; |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
117 const char *title; |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
118 double min; |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
119 double max; |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
120 int control; |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
121 }; |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
122 |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
123 |
161
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
124 #define PLOT(__channel, __min, __max) \ |
134
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
125 { \ |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
126 .data = & ## __channel, \ |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
127 .title = #__channel, \ |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
128 .min = __min, \ |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
129 .max = __max, \ |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
130 .control = PANEL_PLOT_ ## __channel \ |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
131 } |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
132 |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
133 |
136 | 134 static int plot_toggle(struct plot *plot) |
134
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
135 { |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
136 if (plot->plot.active) |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
137 Plot_ClosePanel(&(plot->plot)); |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
138 else |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
139 Plot_InitPanel(&(plot->plot), plot->title, |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
140 plot->min, plot->max, MainPanel, plot->control); |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
141 return plot->plot.active; |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
142 } |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
143 |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
144 |
136 | 145 static inline void plot_update(struct plot *plot) |
134
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
146 { |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
147 if (plot->plot.active) |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
148 Plot_AddFrequency(&(plot->plot), *(plot->data)); |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
149 } |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
150 |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
151 struct plot plots[] = { |
161
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
152 PLOT(Ch1, 54.999e6, 55.001e6), |
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
153 PLOT(Ch2, 0.0, 0.0), |
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
154 PLOT(Ch3, 0.0, 0.0), |
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
155 PLOT(Ch4, 0.0, 0.0), |
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
156 PLOT(Math1, 0.0, 0.0), |
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
157 PLOT(Math2, 0.0, 0.0), |
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
158 PLOT(Math3, 0.0, 0.0), |
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
159 PLOT(Math4, 0.0, 0.0), |
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
160 PLOT(Math5, 0.0, 0.0), |
134
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
161 { NULL } |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
162 }; |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
163 |
0 | 164 |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
165 struct ad9956 ad9956; |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
166 struct ad9912 ad9912; |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
167 |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
168 |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
169 static inline int ad9912_set_frequency_w(struct ad9912 *d, unsigned c, double f) |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
170 { |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
171 int r = ad9912_set_frequency(d, c, f); |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
172 if (r) |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
173 logmessage(ERROR, "ad9912 set frequency channel=%d error=%d", c, -r); |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
174 return r; |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
175 } |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
176 |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
177 |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
178 static inline int ad9912_ramp_frequency_w(struct ad9912 *d, unsigned c, double f, double s) |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
179 { |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
180 int r = ad9912_ramp_frequency(d, c, f, s); |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
181 if (r) |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
182 logmessage(ERROR, "ad9912 ramp frequency channel=%d error=%d", c, -r); |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
183 return r; |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
184 } |
0 | 185 |
186 | |
209
11a88d389705
Adapt to new AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
205
diff
changeset
|
187 static inline int ad9956_set_sweep_rate_w(struct ad9956 *d, double s) |
11a88d389705
Adapt to new AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
205
diff
changeset
|
188 { |
11a88d389705
Adapt to new AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
205
diff
changeset
|
189 int r = ad9956_set_sweep_rate(d, s); |
11a88d389705
Adapt to new AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
205
diff
changeset
|
190 if (r) |
11a88d389705
Adapt to new AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
205
diff
changeset
|
191 logmessage(ERROR, "ad9956 set sweep rate error=%d", -r); |
11a88d389705
Adapt to new AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
205
diff
changeset
|
192 return r; |
11a88d389705
Adapt to new AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
205
diff
changeset
|
193 } |
11a88d389705
Adapt to new AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
205
diff
changeset
|
194 |
11a88d389705
Adapt to new AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
205
diff
changeset
|
195 |
11a88d389705
Adapt to new AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
205
diff
changeset
|
196 static int ad9956_set_w(struct ad9956 *d, double f, double s) |
11a88d389705
Adapt to new AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
205
diff
changeset
|
197 { |
11a88d389705
Adapt to new AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
205
diff
changeset
|
198 int r; |
11a88d389705
Adapt to new AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
205
diff
changeset
|
199 |
11a88d389705
Adapt to new AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
205
diff
changeset
|
200 r = ad9956_sweep_stop(d); |
11a88d389705
Adapt to new AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
205
diff
changeset
|
201 if (r) { |
11a88d389705
Adapt to new AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
205
diff
changeset
|
202 logmessage(ERROR, "ad9956 sweep stop error=%d", -r); |
11a88d389705
Adapt to new AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
205
diff
changeset
|
203 return r; |
11a88d389705
Adapt to new AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
205
diff
changeset
|
204 } |
11a88d389705
Adapt to new AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
205
diff
changeset
|
205 |
11a88d389705
Adapt to new AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
205
diff
changeset
|
206 r = ad9956_set_frequency(d, f); |
11a88d389705
Adapt to new AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
205
diff
changeset
|
207 if (r) { |
11a88d389705
Adapt to new AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
205
diff
changeset
|
208 logmessage(ERROR, "ad9956 set frequency error=%d", -r); |
11a88d389705
Adapt to new AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
205
diff
changeset
|
209 return r; |
11a88d389705
Adapt to new AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
205
diff
changeset
|
210 } |
11a88d389705
Adapt to new AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
205
diff
changeset
|
211 |
11a88d389705
Adapt to new AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
205
diff
changeset
|
212 r = ad9956_set_sweep_rate(d, s); |
11a88d389705
Adapt to new AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
205
diff
changeset
|
213 if (r) { |
11a88d389705
Adapt to new AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
205
diff
changeset
|
214 logmessage(ERROR, "ad9956 set sweep rate error=%d", -r); |
11a88d389705
Adapt to new AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
205
diff
changeset
|
215 return r; |
11a88d389705
Adapt to new AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
205
diff
changeset
|
216 } |
11a88d389705
Adapt to new AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
205
diff
changeset
|
217 |
11a88d389705
Adapt to new AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
205
diff
changeset
|
218 r = ad9956_sweep_start(d); |
11a88d389705
Adapt to new AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
205
diff
changeset
|
219 if (r) { |
11a88d389705
Adapt to new AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
205
diff
changeset
|
220 logmessage(ERROR, "ad9956 sweep start error=%d", -r); |
11a88d389705
Adapt to new AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
205
diff
changeset
|
221 return r; |
11a88d389705
Adapt to new AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
205
diff
changeset
|
222 } |
11a88d389705
Adapt to new AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
205
diff
changeset
|
223 |
11a88d389705
Adapt to new AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
205
diff
changeset
|
224 return 0; |
11a88d389705
Adapt to new AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
205
diff
changeset
|
225 } |
11a88d389705
Adapt to new AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
205
diff
changeset
|
226 |
11a88d389705
Adapt to new AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
205
diff
changeset
|
227 |
84
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
228 enum { |
161
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
229 LO = 1, |
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
230 HG = 2, |
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
231 SR = 4, |
84
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
232 }; |
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
233 |
17
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
234 enum { |
26
4bb197635664
Cleanup N1 measurement code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
25
diff
changeset
|
235 N_MEASUREMENT_NONE, |
4bb197635664
Cleanup N1 measurement code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
25
diff
changeset
|
236 N_MEASUREMENT_INIT, |
4bb197635664
Cleanup N1 measurement code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
25
diff
changeset
|
237 N_MEASUREMENT_SLOPE, |
4bb197635664
Cleanup N1 measurement code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
25
diff
changeset
|
238 N_MEASUREMENT_ADJUST_FREQ_PLUS, |
4bb197635664
Cleanup N1 measurement code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
25
diff
changeset
|
239 N_MEASUREMENT_FREP_PLUS, |
4bb197635664
Cleanup N1 measurement code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
25
diff
changeset
|
240 N_MEASUREMENT_ADJUST_FREQ_MINUS, |
4bb197635664
Cleanup N1 measurement code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
25
diff
changeset
|
241 N_MEASUREMENT_FREP_MINUS, |
4bb197635664
Cleanup N1 measurement code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
25
diff
changeset
|
242 }; |
4bb197635664
Cleanup N1 measurement code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
25
diff
changeset
|
243 |
84
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
244 int Measuring_1 = N_MEASUREMENT_NONE; |
199
111610d871af
Show error state in main user inteface panel
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
198
diff
changeset
|
245 int Measuring_2 = N_MEASUREMENT_NONE; |
84
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
246 int Measuring_3 = N_MEASUREMENT_NONE; |
0 | 247 |
160
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
248 int nobs = 0; |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
249 int settling = 0; |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
250 |
217
fefe921a9784
Use DDS4 for shifting Sr beatnote frequency to 10 kHz
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
216
diff
changeset
|
251 double f0_DDS1 = 110000000.0, f0_DDS2, f0_DDS3, f0_DDS4, df_DDS3; |
158
9154291658ef
Simplify DDS frequency juggling in N measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
156
diff
changeset
|
252 |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
253 double SlopeTime1 = 40.0, DeltaT_1 = 40.0, delta_f_lock_1 = 500e3; |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
254 double SlopeTime2 = 40.0, DeltaT_2 = 40.0, delta_f_lock_2 = 500e3; |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
255 double SlopeTime3 = 40.0, DeltaT_3 = 40.0, delta_f_lock_3 = 500e3; |
0 | 256 |
160
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
257 double t1, t2, t3; |
156
4ab8099a18e2
Add beatnote frequency drift correction to N3 measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
155
diff
changeset
|
258 double f_rep_slope, f_beat_slope; |
115
23f8b7b2b63a
Use DDS1 to change frep in the measurement of N3. Improve some variable names
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
114
diff
changeset
|
259 double f_rep_plus, f_rep_minus; |
159 | 260 double f_beat_plus, f_beat_minus; |
162 | 261 double N_measured; |
0 | 262 |
17
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
263 double Frequencystep1=10000.0, tbegin1=0.0, Frepbefore1=0.0, Frequency1=0.0; |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
264 double Frequencystep2=10.0, tbegin2=0.0, Frepbefore2=0.0, Ch2before=0.0, Frequency2=0.0; |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
265 double Frequencystep3=100000.0, tbegin3=0.0, Frepbefore3=0.0, Frequency3=0.0; |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
266 |
144 | 267 int Getsign1=FALSE,Getsign2=FALSE,Getsign3=FALSE; |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
268 |
159 | 269 struct stat stat_math1, stat_ch2, stat_ch3, freq; |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
270 struct rollmean rollmean_ch1, rollmean_ch2, rollmean_ch3, rollmean_ch4; |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
271 |
0 | 272 |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
273 // dedrift |
161
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
274 enum { |
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
275 DEDRIFT_REFERENCE_MICROWAVE = 0, |
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
276 DEDRIFT_REFERENCE_HG = 1, |
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
277 }; |
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
278 |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
279 struct dedrift { |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
280 int enabled; // dedrift enabled |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
281 int reference; // reference frequency |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
282 int invert; // invert applied slope sign |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
283 int doubleslope; // double applied slope |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
284 int keep_freq; // keep current frequency value when dedrift is disabled |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
285 int keep_slope; // keep current slope value when dedrift is disabled |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
286 double freq0; // DDS center frequency |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
287 double threshold; // maximum allowed frequency change |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
288 double applied; // currently applied slope |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
289 double interval; // measurement duration |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
290 double t0; // beginning of currrent measurement interval |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
291 }; |
0 | 292 |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
293 struct dedrift dedrift = { |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
294 .enabled = FALSE, |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
295 .reference = DEDRIFT_REFERENCE_MICROWAVE, |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
296 .invert = FALSE, |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
297 .doubleslope = FALSE, |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
298 .keep_freq = TRUE, |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
299 .keep_slope = TRUE, |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
300 .freq0 = 70e6, |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
301 .threshold = 100.0, |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
302 .applied = 0.0, |
158
9154291658ef
Simplify DDS frequency juggling in N measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
156
diff
changeset
|
303 .interval = 30.0, |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
304 .t0 = 0.0 |
2
bd7501b65f56
Implement reference selection (microwave or Hg cavity) for slope cancelling
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
1
diff
changeset
|
305 }; |
0 | 306 |
307 | |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
308 // recenter |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
309 struct recenter { |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
310 int enabled; // recenter enabled |
144 | 311 int lo; // recenter microwave beatnote |
312 int sr; // recenter Sr beatnote | |
313 int hg; // recenter Hg beatnote | |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
314 double interval; // interval |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
315 double t0; // beginning of current interval |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
316 }; |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
317 |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
318 struct recenter recenter = { |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
319 .enabled = FALSE, |
144 | 320 .lo = FALSE, |
321 .sr = FALSE, | |
322 .hg = FALSE, | |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
323 .interval = 1800.0, |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
324 .t0 = 0.0 |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
325 }; |
0 | 326 |
327 | |
142
fd085d61e4ca
Rework data logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
140
diff
changeset
|
328 // data loggging |
170
a4fcebb5941b
Make data folder configurable in configuration file
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
169
diff
changeset
|
329 static char *datafolder; |
a4fcebb5941b
Make data folder configurable in configuration file
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
169
diff
changeset
|
330 |
142
fd085d61e4ca
Rework data logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
140
diff
changeset
|
331 struct datafile { |
fd085d61e4ca
Rework data logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
140
diff
changeset
|
332 char *name; |
fd085d61e4ca
Rework data logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
140
diff
changeset
|
333 double *data; |
fd085d61e4ca
Rework data logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
140
diff
changeset
|
334 int nchan; |
fd085d61e4ca
Rework data logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
140
diff
changeset
|
335 int control; |
fd085d61e4ca
Rework data logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
140
diff
changeset
|
336 int write; |
fd085d61e4ca
Rework data logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
140
diff
changeset
|
337 }; |
fd085d61e4ca
Rework data logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
140
diff
changeset
|
338 |
161
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
339 #define DATAFILE(__name, __data, __nchan, __control, __write) \ |
168 | 340 { \ |
341 .name = __name, \ | |
342 .data = __data, \ | |
343 .nchan = __nchan, \ | |
344 .control = __control, \ | |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
345 .write = __write, \ |
168 | 346 } |
142
fd085d61e4ca
Rework data logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
140
diff
changeset
|
347 |
fd085d61e4ca
Rework data logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
140
diff
changeset
|
348 struct datafile datafiles[] = { |
161
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
349 DATAFILE("Raw", event.data, 4, PANEL_SAVE_RAW, TRUE), |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
350 DATAFILE("DDS", ad9912.frequency, 4, PANEL_SAVE_DDS, FALSE), |
161
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
351 DATAFILE("Lo", &Math2, 1, PANEL_SAVE_LO, FALSE), |
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
352 DATAFILE("Hg", &Math3, 1, PANEL_SAVE_HG, FALSE), |
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
353 DATAFILE("Sr", &Math4, 1, PANEL_SAVE_SR, FALSE), |
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
354 DATAFILE("Ex", &Math5, 1, PANEL_SAVE_EXTRA, FALSE), |
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
355 { NULL, } |
142
fd085d61e4ca
Rework data logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
140
diff
changeset
|
356 }; |
fd085d61e4ca
Rework data logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
140
diff
changeset
|
357 |
fd085d61e4ca
Rework data logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
140
diff
changeset
|
358 |
fd085d61e4ca
Rework data logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
140
diff
changeset
|
359 static void write_data(const char *folder, const char *name, const char *id, |
fd085d61e4ca
Rework data logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
140
diff
changeset
|
360 const char *timestr, double utc, double *v, int nchan) |
fd085d61e4ca
Rework data logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
140
diff
changeset
|
361 { |
183
791ca26fee6a
Rewrite data writing to file
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
180
diff
changeset
|
362 int i, fd, len; |
142
fd085d61e4ca
Rework data logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
140
diff
changeset
|
363 char line[1024]; |
fd085d61e4ca
Rework data logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
140
diff
changeset
|
364 char filename[FILENAME_MAX]; |
fd085d61e4ca
Rework data logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
140
diff
changeset
|
365 |
fd085d61e4ca
Rework data logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
140
diff
changeset
|
366 // construct filename in the form folder\\id-name.txt |
fd085d61e4ca
Rework data logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
140
diff
changeset
|
367 snprintf(filename, sizeof(filename), "%s\\%s-%s.txt", folder, id, name); |
fd085d61e4ca
Rework data logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
140
diff
changeset
|
368 |
186
89e092681ba7
Fix data file creation permissions
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
184
diff
changeset
|
369 fd = open(filename, O_CREAT|O_WRONLY|O_APPEND, 00744); |
183
791ca26fee6a
Rewrite data writing to file
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
180
diff
changeset
|
370 if (fd < 0) { |
791ca26fee6a
Rewrite data writing to file
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
180
diff
changeset
|
371 logmessage(ERROR, "open data file %s: %s", filename, strerror(errno)); |
791ca26fee6a
Rewrite data writing to file
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
180
diff
changeset
|
372 return; |
142
fd085d61e4ca
Rework data logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
140
diff
changeset
|
373 } |
183
791ca26fee6a
Rewrite data writing to file
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
180
diff
changeset
|
374 |
791ca26fee6a
Rewrite data writing to file
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
180
diff
changeset
|
375 // timestamp |
791ca26fee6a
Rewrite data writing to file
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
180
diff
changeset
|
376 len = snprintf(line, sizeof(line), "%s\t%.3f", timestr, utc); |
791ca26fee6a
Rewrite data writing to file
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
180
diff
changeset
|
377 |
791ca26fee6a
Rewrite data writing to file
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
180
diff
changeset
|
378 // data channels |
791ca26fee6a
Rewrite data writing to file
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
180
diff
changeset
|
379 for (i = 0; i < nchan; i++) |
187
a5c70eae1e0b
Change data logging to 16 digits precision
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
186
diff
changeset
|
380 len += snprintf(line + len, sizeof(line) - len, "\t%.16e", v[i]); |
183
791ca26fee6a
Rewrite data writing to file
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
180
diff
changeset
|
381 |
791ca26fee6a
Rewrite data writing to file
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
180
diff
changeset
|
382 // newline |
791ca26fee6a
Rewrite data writing to file
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
180
diff
changeset
|
383 line[len++] = '\r'; |
791ca26fee6a
Rewrite data writing to file
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
180
diff
changeset
|
384 line[len++] = '\n'; |
791ca26fee6a
Rewrite data writing to file
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
180
diff
changeset
|
385 |
791ca26fee6a
Rewrite data writing to file
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
180
diff
changeset
|
386 // write to file |
791ca26fee6a
Rewrite data writing to file
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
180
diff
changeset
|
387 write(fd, line, len); |
791ca26fee6a
Rewrite data writing to file
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
180
diff
changeset
|
388 |
791ca26fee6a
Rewrite data writing to file
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
180
diff
changeset
|
389 close(fd); |
142
fd085d61e4ca
Rework data logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
140
diff
changeset
|
390 } |
fd085d61e4ca
Rework data logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
140
diff
changeset
|
391 |
fd085d61e4ca
Rework data logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
140
diff
changeset
|
392 |
fd085d61e4ca
Rework data logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
140
diff
changeset
|
393 static inline void datafile_append(struct datafile *d, char *id, char *timestr) |
fd085d61e4ca
Rework data logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
140
diff
changeset
|
394 { |
fd085d61e4ca
Rework data logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
140
diff
changeset
|
395 if (d->write) |
170
a4fcebb5941b
Make data folder configurable in configuration file
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
169
diff
changeset
|
396 write_data(datafolder, d->name, id, timestr, utc, d->data, d->nchan); |
142
fd085d61e4ca
Rework data logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
140
diff
changeset
|
397 } |
fd085d61e4ca
Rework data logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
140
diff
changeset
|
398 |
fd085d61e4ca
Rework data logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
140
diff
changeset
|
399 |
169
97112b45b838
Get Sr data logger parameters from configuration file. Code reorganization.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
168
diff
changeset
|
400 static struct datalogger datalogger; |
73
1dfaf5ef0352
Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
70
diff
changeset
|
401 |
142
fd085d61e4ca
Rework data logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
140
diff
changeset
|
402 |
199
111610d871af
Show error state in main user inteface panel
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
198
diff
changeset
|
403 static void onerror(int level, const char *msg) |
111610d871af
Show error state in main user inteface panel
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
198
diff
changeset
|
404 { |
111610d871af
Show error state in main user inteface panel
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
198
diff
changeset
|
405 SetCtrlVal(MainPanel, PANEL_ERROR, 1); |
111610d871af
Show error state in main user inteface panel
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
198
diff
changeset
|
406 } |
111610d871af
Show error state in main user inteface panel
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
198
diff
changeset
|
407 |
111610d871af
Show error state in main user inteface panel
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
198
diff
changeset
|
408 |
111610d871af
Show error state in main user inteface panel
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
198
diff
changeset
|
409 static void * muParserNew() |
0 | 410 { |
168 | 411 void *parser = mupCreate(); |
166 | 412 |
52
30146cc6cd77
Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
51
diff
changeset
|
413 mupDefineOprtChars(parser, "abcdefghijklmnopqrstuvwxyzµ" |
30146cc6cd77
Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
51
diff
changeset
|
414 "ABCDEFGHIJKLMNOPQRSTUVWXYZ" |
30146cc6cd77
Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
51
diff
changeset
|
415 "+-*^/?<>=#!$%&|~'_"); |
166 | 416 |
52
30146cc6cd77
Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
51
diff
changeset
|
417 mupDefineVar(parser, "Ch1", &Ch1); |
30146cc6cd77
Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
51
diff
changeset
|
418 mupDefineVar(parser, "Ch2", &Ch2); |
30146cc6cd77
Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
51
diff
changeset
|
419 mupDefineVar(parser, "Ch3", &Ch3); |
30146cc6cd77
Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
51
diff
changeset
|
420 mupDefineVar(parser, "Ch4", &Ch4); |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
421 mupDefineVar(parser, "DDS1", &(ad9912.frequency[0])); |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
422 mupDefineVar(parser, "DDS2", &(ad9912.frequency[1])); |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
423 mupDefineVar(parser, "DDS3", &(ad9912.frequency[2])); |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
424 mupDefineVar(parser, "DDS4", &(ad9912.frequency[3])); |
52
30146cc6cd77
Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
51
diff
changeset
|
425 mupDefineVar(parser, "N1", &N1); |
30146cc6cd77
Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
51
diff
changeset
|
426 mupDefineVar(parser, "N2", &N2); |
30146cc6cd77
Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
51
diff
changeset
|
427 mupDefineVar(parser, "N3", &N3); |
125
37535873ee83
Rename variables from SigneX to SignX
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
124
diff
changeset
|
428 mupDefineVar(parser, "Sign1", &Sign1); |
37535873ee83
Rename variables from SigneX to SignX
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
124
diff
changeset
|
429 mupDefineVar(parser, "Sign2", &Sign2); |
37535873ee83
Rename variables from SigneX to SignX
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
124
diff
changeset
|
430 mupDefineVar(parser, "Sign3", &Sign3); |
109
2a9f8a811d87
Fix N3 measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
105
diff
changeset
|
431 mupDefineVar(parser, "Ndiv", &Ndiv); |
174
d96f0b04f7fe
Make DDS addres configurable in configuration file. Modernize AD9912 driver.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
170
diff
changeset
|
432 |
52
30146cc6cd77
Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
51
diff
changeset
|
433 mupDefinePostfixOprt(parser, "P", &Peta, 1); |
30146cc6cd77
Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
51
diff
changeset
|
434 mupDefinePostfixOprt(parser, "T", &Tera, 1); |
30146cc6cd77
Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
51
diff
changeset
|
435 mupDefinePostfixOprt(parser, "G", &Giga, 1); |
30146cc6cd77
Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
51
diff
changeset
|
436 mupDefinePostfixOprt(parser, "M", &Mega, 1); |
30146cc6cd77
Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
51
diff
changeset
|
437 mupDefinePostfixOprt(parser, "k", &kilo, 1); |
30146cc6cd77
Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
51
diff
changeset
|
438 mupDefinePostfixOprt(parser, "m", &milli, 1); |
30146cc6cd77
Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
51
diff
changeset
|
439 mupDefinePostfixOprt(parser, "u", µ, 1); |
30146cc6cd77
Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
51
diff
changeset
|
440 mupDefinePostfixOprt(parser, "µ", µ, 1); |
30146cc6cd77
Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
51
diff
changeset
|
441 mupDefinePostfixOprt(parser, "n", &nano, 1); |
30146cc6cd77
Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
51
diff
changeset
|
442 mupDefinePostfixOprt(parser, "p", &pico, 1); |
30146cc6cd77
Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
51
diff
changeset
|
443 mupDefinePostfixOprt(parser, "f", &femto, 1); |
30146cc6cd77
Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
51
diff
changeset
|
444 |
30146cc6cd77
Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
51
diff
changeset
|
445 return parser; |
0 | 446 } |
447 | |
46
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
448 |
88
9b7588cd4013
Move data acquisition into separate thread
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
87
diff
changeset
|
449 void CVICALLBACK DataAvailableCB (CmtTSQHandle queueHandle, unsigned int event, |
9b7588cd4013
Move data acquisition into separate thread
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
87
diff
changeset
|
450 int value, void *callbackData); |
9b7588cd4013
Move data acquisition into separate thread
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
87
diff
changeset
|
451 |
9b7588cd4013
Move data acquisition into separate thread
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
87
diff
changeset
|
452 |
0 | 453 int main (int argc, char *argv[]) |
454 { | |
164
211ea3950310
Read AD9956 configuration from configuration file
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
162
diff
changeset
|
455 int rv; |
52
30146cc6cd77
Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
51
diff
changeset
|
456 double frequency; |
30146cc6cd77
Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
51
diff
changeset
|
457 char expr[1024]; |
174
d96f0b04f7fe
Make DDS addres configurable in configuration file. Modernize AD9912 driver.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
170
diff
changeset
|
458 char host[256]; |
d96f0b04f7fe
Make DDS addres configurable in configuration file. Modernize AD9912 driver.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
170
diff
changeset
|
459 double clock; |
166 | 460 |
461 if ((MainPanel = LoadPanel (0, "FXAnalyse.uir", PANEL)) < 0) | |
52
30146cc6cd77
Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
51
diff
changeset
|
462 return -1; |
84
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
463 if ((CalcNPanel = LoadPanel (MainPanel, "FXAnalyse.uir", CALCN)) < 0) |
0 | 464 return -1; |
160
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
465 if ((EstimateNPanel = LoadPanel (MainPanel, "FXAnalyse.uir", ESTIMATEN)) < 0) |
17
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
466 return -1; |
164
211ea3950310
Read AD9956 configuration from configuration file
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
162
diff
changeset
|
467 |
169
97112b45b838
Get Sr data logger parameters from configuration file. Code reorganization.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
168
diff
changeset
|
468 // logging |
199
111610d871af
Show error state in main user inteface panel
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
198
diff
changeset
|
469 logger_init(&onerror); |
169
97112b45b838
Get Sr data logger parameters from configuration file. Code reorganization.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
168
diff
changeset
|
470 |
166 | 471 // load configuration file |
169
97112b45b838
Get Sr data logger parameters from configuration file. Code reorganization.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
168
diff
changeset
|
472 char path[MAX_PATHNAME_LEN]; |
97112b45b838
Get Sr data logger parameters from configuration file. Code reorganization.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
168
diff
changeset
|
473 GetIniFilePath(path); |
164
211ea3950310
Read AD9956 configuration from configuration file
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
162
diff
changeset
|
474 IniText configuration = Ini_New(TRUE); |
169
97112b45b838
Get Sr data logger parameters from configuration file. Code reorganization.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
168
diff
changeset
|
475 Ini_ReadFromFile(configuration, path); |
164
211ea3950310
Read AD9956 configuration from configuration file
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
162
diff
changeset
|
476 |
170
a4fcebb5941b
Make data folder configurable in configuration file
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
169
diff
changeset
|
477 // data folder |
a4fcebb5941b
Make data folder configurable in configuration file
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
169
diff
changeset
|
478 rv = Ini_GetStringCopy(configuration, "data", "folder", &datafolder); |
174
d96f0b04f7fe
Make DDS addres configurable in configuration file. Modernize AD9912 driver.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
170
diff
changeset
|
479 if (rv > 0) { |
d96f0b04f7fe
Make DDS addres configurable in configuration file. Modernize AD9912 driver.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
170
diff
changeset
|
480 logmessage(INFO, "writing data files in %s", datafolder); |
d96f0b04f7fe
Make DDS addres configurable in configuration file. Modernize AD9912 driver.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
170
diff
changeset
|
481 } else { |
170
a4fcebb5941b
Make data folder configurable in configuration file
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
169
diff
changeset
|
482 logmessage(ERROR, "data folder not configured in %s", path); |
a4fcebb5941b
Make data folder configurable in configuration file
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
169
diff
changeset
|
483 // do not allow to start the acquisition |
a4fcebb5941b
Make data folder configurable in configuration file
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
169
diff
changeset
|
484 SetCtrlAttribute(MainPanel, PANEL_STARTBUTTON, ATTR_DIMMED, TRUE); |
a4fcebb5941b
Make data folder configurable in configuration file
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
169
diff
changeset
|
485 } |
a4fcebb5941b
Make data folder configurable in configuration file
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
169
diff
changeset
|
486 |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
487 // ad9956 configuration parameters |
166 | 488 rv = Ini_GetStringIntoBuffer(configuration, "AD9956", "host", host, sizeof(host)); |
164
211ea3950310
Read AD9956 configuration from configuration file
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
162
diff
changeset
|
489 if (! rv) |
211ea3950310
Read AD9956 configuration from configuration file
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
162
diff
changeset
|
490 return -1; |
211ea3950310
Read AD9956 configuration from configuration file
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
162
diff
changeset
|
491 rv = Ini_GetDouble(configuration, "AD9956", "clock", &clock); |
211ea3950310
Read AD9956 configuration from configuration file
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
162
diff
changeset
|
492 if (! rv) |
211ea3950310
Read AD9956 configuration from configuration file
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
162
diff
changeset
|
493 return -1; |
211ea3950310
Read AD9956 configuration from configuration file
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
162
diff
changeset
|
494 |
209
11a88d389705
Adapt to new AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
205
diff
changeset
|
495 // initialize AD9956 dedrift DDS |
11a88d389705
Adapt to new AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
205
diff
changeset
|
496 rv = ad9956_init(&ad9956, host, clock); |
11a88d389705
Adapt to new AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
205
diff
changeset
|
497 if (rv) |
11a88d389705
Adapt to new AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
205
diff
changeset
|
498 logmessage(ERROR, "ad9956 init erorr=%d", -rv); |
216
72fafb670eaf
Set AD9956 frequency and sweep rate at startup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
209
diff
changeset
|
499 ad9956_set_w(&ad9956, dedrift.freq0, dedrift.applied); |
164
211ea3950310
Read AD9956 configuration from configuration file
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
162
diff
changeset
|
500 |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
501 // ad9912 configuration parameters |
174
d96f0b04f7fe
Make DDS addres configurable in configuration file. Modernize AD9912 driver.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
170
diff
changeset
|
502 rv = Ini_GetStringIntoBuffer(configuration, "AD9912", "host", host, sizeof(host)); |
d96f0b04f7fe
Make DDS addres configurable in configuration file. Modernize AD9912 driver.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
170
diff
changeset
|
503 if (! rv) |
d96f0b04f7fe
Make DDS addres configurable in configuration file. Modernize AD9912 driver.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
170
diff
changeset
|
504 return -1; |
d96f0b04f7fe
Make DDS addres configurable in configuration file. Modernize AD9912 driver.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
170
diff
changeset
|
505 rv = Ini_GetDouble(configuration, "AD9912", "clock", &clock); |
d96f0b04f7fe
Make DDS addres configurable in configuration file. Modernize AD9912 driver.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
170
diff
changeset
|
506 if (! rv) |
d96f0b04f7fe
Make DDS addres configurable in configuration file. Modernize AD9912 driver.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
170
diff
changeset
|
507 return -1; |
d96f0b04f7fe
Make DDS addres configurable in configuration file. Modernize AD9912 driver.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
170
diff
changeset
|
508 |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
509 // initialize AD9912 DDS box |
199
111610d871af
Show error state in main user inteface panel
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
198
diff
changeset
|
510 rv = ad9912_init(&ad9912, host, clock); |
111610d871af
Show error state in main user inteface panel
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
198
diff
changeset
|
511 if (rv) |
111610d871af
Show error state in main user inteface panel
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
198
diff
changeset
|
512 logmessage(ERROR, "ad9912 init erorr=%d", -rv); |
111610d871af
Show error state in main user inteface panel
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
198
diff
changeset
|
513 |
52
30146cc6cd77
Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
51
diff
changeset
|
514 GetCtrlVal(MainPanel, PANEL_DDS1, &frequency); |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
515 ad9912_set_frequency_w(&ad9912, 0, frequency); |
52
30146cc6cd77
Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
51
diff
changeset
|
516 GetCtrlVal(MainPanel, PANEL_DDS2, &frequency); |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
517 ad9912_set_frequency_w(&ad9912, 1, frequency); |
52
30146cc6cd77
Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
51
diff
changeset
|
518 GetCtrlVal(MainPanel, PANEL_DDS3, &frequency); |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
519 ad9912_set_frequency_w(&ad9912, 2, frequency); |
52
30146cc6cd77
Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
51
diff
changeset
|
520 GetCtrlVal(MainPanel, PANEL_DDS4, &frequency); |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
521 ad9912_set_frequency_w(&ad9912, 3, frequency); |
0 | 522 |
174
d96f0b04f7fe
Make DDS addres configurable in configuration file. Modernize AD9912 driver.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
170
diff
changeset
|
523 // dispose configuration |
d96f0b04f7fe
Make DDS addres configurable in configuration file. Modernize AD9912 driver.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
170
diff
changeset
|
524 Ini_Dispose(configuration); |
d96f0b04f7fe
Make DDS addres configurable in configuration file. Modernize AD9912 driver.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
170
diff
changeset
|
525 |
d96f0b04f7fe
Make DDS addres configurable in configuration file. Modernize AD9912 driver.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
170
diff
changeset
|
526 // Sr data logger |
d96f0b04f7fe
Make DDS addres configurable in configuration file. Modernize AD9912 driver.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
170
diff
changeset
|
527 sr_datalogger_init(&datalogger); |
d96f0b04f7fe
Make DDS addres configurable in configuration file. Modernize AD9912 driver.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
170
diff
changeset
|
528 |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
529 GetCtrlVal(MainPanel, PANEL_N1, &N1); |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
530 GetCtrlVal(MainPanel, PANEL_N2, &N2); |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
531 GetCtrlVal(MainPanel, PANEL_N3, &N3); |
166 | 532 |
168 | 533 MathParser1 = muParserNew(); |
52
30146cc6cd77
Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
51
diff
changeset
|
534 GetCtrlVal(MainPanel, PANEL_MATHSTRING1, expr); |
30146cc6cd77
Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
51
diff
changeset
|
535 mupSetExpr(MathParser1, expr); |
0 | 536 |
168 | 537 MathParser2 = muParserNew(); |
52
30146cc6cd77
Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
51
diff
changeset
|
538 mupDefineVar(MathParser2, "Math1", &Math1); |
30146cc6cd77
Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
51
diff
changeset
|
539 GetCtrlVal(MainPanel, PANEL_MATHSTRING2, expr); |
30146cc6cd77
Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
51
diff
changeset
|
540 mupSetExpr(MathParser2, expr); |
0 | 541 |
168 | 542 MathParser3 = muParserNew(); |
52
30146cc6cd77
Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
51
diff
changeset
|
543 mupDefineVar(MathParser3, "Math1", &Math1); |
30146cc6cd77
Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
51
diff
changeset
|
544 mupDefineVar(MathParser3, "Math2", &Math2); |
30146cc6cd77
Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
51
diff
changeset
|
545 GetCtrlVal(MainPanel, PANEL_MATHSTRING3, expr); |
30146cc6cd77
Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
51
diff
changeset
|
546 mupSetExpr(MathParser3, expr); |
0 | 547 |
168 | 548 MathParser4 = muParserNew(); |
52
30146cc6cd77
Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
51
diff
changeset
|
549 mupDefineVar(MathParser4, "Math1", &Math1); |
30146cc6cd77
Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
51
diff
changeset
|
550 mupDefineVar(MathParser4, "Math2", &Math2); |
30146cc6cd77
Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
51
diff
changeset
|
551 mupDefineVar(MathParser4, "Math3", &Math3); |
30146cc6cd77
Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
51
diff
changeset
|
552 GetCtrlVal(MainPanel, PANEL_MATHSTRING4, expr); |
30146cc6cd77
Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
51
diff
changeset
|
553 mupSetExpr(MathParser4, expr); |
0 | 554 |
168 | 555 MathParser5 = muParserNew(); |
52
30146cc6cd77
Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
51
diff
changeset
|
556 mupDefineVar(MathParser5, "Math1", &Math1); |
30146cc6cd77
Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
51
diff
changeset
|
557 mupDefineVar(MathParser5, "Math2", &Math2); |
30146cc6cd77
Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
51
diff
changeset
|
558 mupDefineVar(MathParser5, "Math3", &Math3); |
30146cc6cd77
Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
51
diff
changeset
|
559 mupDefineVar(MathParser5, "Math4", &Math4); |
30146cc6cd77
Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
51
diff
changeset
|
560 GetCtrlVal(MainPanel, PANEL_MATHSTRING5, expr); |
30146cc6cd77
Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
51
diff
changeset
|
561 mupSetExpr(MathParser5, expr); |
166 | 562 |
88
9b7588cd4013
Move data acquisition into separate thread
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
87
diff
changeset
|
563 // data queue |
91
4102fe614df2
Fix timestamping. Cleanup data providers
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
89
diff
changeset
|
564 CmtNewTSQ(128, sizeof(struct event), 0, &dataQueue); |
88
9b7588cd4013
Move data acquisition into separate thread
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
87
diff
changeset
|
565 |
9b7588cd4013
Move data acquisition into separate thread
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
87
diff
changeset
|
566 // register callback to execute when data will be in the data queue |
91
4102fe614df2
Fix timestamping. Cleanup data providers
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
89
diff
changeset
|
567 CmtInstallTSQCallback(dataQueue, EVENT_TSQ_ITEMS_IN_QUEUE, 1, |
88
9b7588cd4013
Move data acquisition into separate thread
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
87
diff
changeset
|
568 DataAvailableCB, NULL, CmtGetCurrentThreadID(), NULL); |
9b7588cd4013
Move data acquisition into separate thread
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
87
diff
changeset
|
569 |
9b7588cd4013
Move data acquisition into separate thread
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
87
diff
changeset
|
570 DisplayPanel(MainPanel); |
0 | 571 |
52
30146cc6cd77
Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
51
diff
changeset
|
572 RunUserInterface(); |
0 | 573 |
52
30146cc6cd77
Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
51
diff
changeset
|
574 DiscardPanel(MainPanel); |
0 | 575 return 0; |
576 } | |
577 | |
578 int CVICALLBACK QuitCallback (int panel, int control, int event, | |
579 void *callbackData, int eventData1, int eventData2) | |
580 { | |
581 switch (event) | |
40
50544ecfcfc7
Handle application quit just once
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
39
diff
changeset
|
582 { |
0 | 583 case EVENT_COMMIT: |
52
30146cc6cd77
Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
51
diff
changeset
|
584 QuitUserInterface(0); |
0 | 585 break; |
40
50544ecfcfc7
Handle application quit just once
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
39
diff
changeset
|
586 } |
0 | 587 return 0; |
588 } | |
589 | |
84
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
590 int CVICALLBACK CB_OnEventMain(int panel, int event, |
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
591 void *callbackData, int eventData1, int eventData2) |
0 | 592 { |
161
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
593 int control, index; |
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
594 double step; |
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
595 |
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
596 #define do_arrow(__DDS, __STEP) \ |
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
597 do { \ |
166 | 598 GetCtrlIndex(panel, __STEP, &index); \ |
161
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
599 if ((eventData1 == VAL_RIGHT_ARROW_VKEY) && (index < 14)) \ |
166 | 600 SetCtrlIndex(panel, __STEP, index + 1); \ |
161
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
601 if ((eventData1 == VAL_LEFT_ARROW_VKEY) && (index > 0)) \ |
166 | 602 SetCtrlIndex(panel, __STEP, index - 1); \ |
603 GetCtrlVal(panel, __STEP, &step); \ | |
604 SetCtrlAttribute(panel, __DDS, ATTR_INCR_VALUE, step); \ | |
161
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
605 } while (0) |
0 | 606 |
607 switch (event) { | |
608 case EVENT_KEYPRESS: | |
161
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
609 /* key code */ |
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
610 switch (eventData1) { |
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
611 case VAL_RIGHT_ARROW_VKEY: |
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
612 case VAL_LEFT_ARROW_VKEY: |
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
613 control = GetActiveCtrl(panel); |
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
614 switch (control) { |
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
615 case PANEL_DDS1: |
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
616 case PANEL_DDS1STEP: |
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
617 do_arrow(PANEL_DDS1, PANEL_DDS1STEP); |
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
618 break; |
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
619 case PANEL_DDS2: |
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
620 case PANEL_DDS2STEP: |
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
621 do_arrow(PANEL_DDS2, PANEL_DDS2STEP); |
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
622 break; |
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
623 case PANEL_DDS3: |
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
624 case PANEL_DDS3STEP: |
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
625 do_arrow(PANEL_DDS3, PANEL_DDS3STEP); |
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
626 break; |
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
627 case PANEL_DDS4: |
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
628 case PANEL_DDS4STEP: |
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
629 do_arrow(PANEL_DDS4, PANEL_DDS4STEP); |
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
630 break; |
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
631 } |
0 | 632 break; |
633 case VAL_F2_VKEY : | |
166 | 634 SetActiveCtrl(panel, PANEL_DDS1); |
0 | 635 break; |
636 case VAL_F3_VKEY : | |
166 | 637 SetActiveCtrl(panel, PANEL_DDS2); |
0 | 638 break; |
639 case VAL_F4_VKEY : | |
166 | 640 SetActiveCtrl(panel, PANEL_DDS3); |
0 | 641 break; |
642 case VAL_F5_VKEY : | |
166 | 643 SetActiveCtrl(panel, PANEL_DDS4); |
0 | 644 break; |
161
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
645 } |
0 | 646 break; |
647 } | |
648 return 0; | |
649 } | |
650 | |
651 int CVICALLBACK CB_OnStart (int panel, int control, int event, | |
652 void *callbackData, int eventData1, int eventData2) | |
653 { | |
654 switch (event) | |
20
3a7f088d4960
Get rid of unused variables. Some minor coding style improvements
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
17
diff
changeset
|
655 { |
0 | 656 case EVENT_COMMIT: |
88
9b7588cd4013
Move data acquisition into separate thread
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
87
diff
changeset
|
657 if (acquiring) |
9b7588cd4013
Move data acquisition into separate thread
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
87
diff
changeset
|
658 break; |
169
97112b45b838
Get Sr data logger parameters from configuration file. Code reorganization.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
168
diff
changeset
|
659 |
166 | 660 logmsg("start"); |
105
29b1aa89a34c
Disable the Start button when data acquisition thread is running
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
97
diff
changeset
|
661 SetCtrlAttribute(panel, PANEL_STARTBUTTON, ATTR_DIMMED, TRUE); |
88
9b7588cd4013
Move data acquisition into separate thread
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
87
diff
changeset
|
662 acquiring = 1; |
82
47860259afe2
Implement logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
80
diff
changeset
|
663 |
88
9b7588cd4013
Move data acquisition into separate thread
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
87
diff
changeset
|
664 // start data provider thread |
9b7588cd4013
Move data acquisition into separate thread
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
87
diff
changeset
|
665 CmtScheduleThreadPoolFunctionAdv( |
9b7588cd4013
Move data acquisition into separate thread
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
87
diff
changeset
|
666 DEFAULT_THREAD_POOL_HANDLE, DataProvider, NULL, |
9b7588cd4013
Move data acquisition into separate thread
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
87
diff
changeset
|
667 THREAD_PRIORITY_HIGHEST, NULL, 0, NULL, 0, &dataProviderThread); |
9b7588cd4013
Move data acquisition into separate thread
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
87
diff
changeset
|
668 |
0 | 669 break; |
82
47860259afe2
Implement logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
80
diff
changeset
|
670 } |
0 | 671 return 0; |
672 } | |
673 | |
674 int CVICALLBACK CB_OnStop (int panel, int control, int event, | |
675 void *callbackData, int eventData1, int eventData2) | |
676 { | |
52
30146cc6cd77
Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
51
diff
changeset
|
677 switch (event) { |
0 | 678 case EVENT_COMMIT: |
88
9b7588cd4013
Move data acquisition into separate thread
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
87
diff
changeset
|
679 if (! acquiring) |
9b7588cd4013
Move data acquisition into separate thread
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
87
diff
changeset
|
680 break; |
9b7588cd4013
Move data acquisition into separate thread
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
87
diff
changeset
|
681 |
166 | 682 logmsg("stop"); |
88
9b7588cd4013
Move data acquisition into separate thread
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
87
diff
changeset
|
683 acquiring = 0; |
166 | 684 |
88
9b7588cd4013
Move data acquisition into separate thread
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
87
diff
changeset
|
685 // wait for data provider thread to terminate |
9b7588cd4013
Move data acquisition into separate thread
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
87
diff
changeset
|
686 CmtWaitForThreadPoolFunctionCompletion( |
9b7588cd4013
Move data acquisition into separate thread
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
87
diff
changeset
|
687 DEFAULT_THREAD_POOL_HANDLE, dataProviderThread, |
9b7588cd4013
Move data acquisition into separate thread
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
87
diff
changeset
|
688 OPT_TP_PROCESS_EVENTS_WHILE_WAITING); |
9b7588cd4013
Move data acquisition into separate thread
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
87
diff
changeset
|
689 CmtReleaseThreadPoolFunctionID( |
9b7588cd4013
Move data acquisition into separate thread
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
87
diff
changeset
|
690 DEFAULT_THREAD_POOL_HANDLE, dataProviderThread); |
166 | 691 |
105
29b1aa89a34c
Disable the Start button when data acquisition thread is running
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
97
diff
changeset
|
692 SetCtrlAttribute(panel, PANEL_STARTBUTTON, ATTR_DIMMED, FALSE); |
29b1aa89a34c
Disable the Start button when data acquisition thread is running
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
97
diff
changeset
|
693 |
0 | 694 break; |
52
30146cc6cd77
Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
51
diff
changeset
|
695 } |
0 | 696 return 0; |
697 } | |
698 | |
91
4102fe614df2
Fix timestamping. Cleanup data providers
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
89
diff
changeset
|
699 void CVICALLBACK DataAvailableCB (CmtTSQHandle queueHandle, unsigned int ev, |
88
9b7588cd4013
Move data acquisition into separate thread
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
87
diff
changeset
|
700 int value, void *callbackData) |
0 | 701 { |
88
9b7588cd4013
Move data acquisition into separate thread
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
87
diff
changeset
|
702 int read; |
0 | 703 |
91
4102fe614df2
Fix timestamping. Cleanup data providers
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
89
diff
changeset
|
704 switch (ev) { |
88
9b7588cd4013
Move data acquisition into separate thread
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
87
diff
changeset
|
705 case EVENT_TSQ_ITEMS_IN_QUEUE: |
124
bdfc61a8ebee
Add thousands separator to important numeric displays
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
123
diff
changeset
|
706 // read data from the data queue |
91
4102fe614df2
Fix timestamping. Cleanup data providers
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
89
diff
changeset
|
707 while (value > 0) { |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
708 |
91
4102fe614df2
Fix timestamping. Cleanup data providers
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
89
diff
changeset
|
709 read = CmtReadTSQData(queueHandle, &event, 1, TSQ_INFINITE_TIMEOUT, 0); |
4102fe614df2
Fix timestamping. Cleanup data providers
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
89
diff
changeset
|
710 if (read != 1) |
88
9b7588cd4013
Move data acquisition into separate thread
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
87
diff
changeset
|
711 logmsg("Error!"); |
9b7588cd4013
Move data acquisition into separate thread
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
87
diff
changeset
|
712 value = value - read; |
9b7588cd4013
Move data acquisition into separate thread
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
87
diff
changeset
|
713 |
91
4102fe614df2
Fix timestamping. Cleanup data providers
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
89
diff
changeset
|
714 utc = event.time.tv_sec + event.time.tv_usec * 1e-6; |
4102fe614df2
Fix timestamping. Cleanup data providers
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
89
diff
changeset
|
715 Ch1 = event.data[0]; |
4102fe614df2
Fix timestamping. Cleanup data providers
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
89
diff
changeset
|
716 Ch2 = event.data[1]; |
4102fe614df2
Fix timestamping. Cleanup data providers
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
89
diff
changeset
|
717 Ch3 = event.data[2]; |
4102fe614df2
Fix timestamping. Cleanup data providers
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
89
diff
changeset
|
718 Ch4 = event.data[3]; |
124
bdfc61a8ebee
Add thousands separator to important numeric displays
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
123
diff
changeset
|
719 |
bdfc61a8ebee
Add thousands separator to important numeric displays
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
123
diff
changeset
|
720 // update display |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
721 SetCtrlVal(MainPanel, PANEL_UTC, utc); |
124
bdfc61a8ebee
Add thousands separator to important numeric displays
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
123
diff
changeset
|
722 SetCtrlVal(MainPanel, PANEL_CH1, Ch1); |
bdfc61a8ebee
Add thousands separator to important numeric displays
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
123
diff
changeset
|
723 SetCtrlVal(MainPanel, PANEL_CH2, Ch2); |
bdfc61a8ebee
Add thousands separator to important numeric displays
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
123
diff
changeset
|
724 SetCtrlVal(MainPanel, PANEL_CH3, Ch3); |
bdfc61a8ebee
Add thousands separator to important numeric displays
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
123
diff
changeset
|
725 SetCtrlVal(MainPanel, PANEL_CH4, Ch4); |
166 | 726 |
124
bdfc61a8ebee
Add thousands separator to important numeric displays
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
123
diff
changeset
|
727 // compute |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
728 Math1 = mupEval(MathParser1); |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
729 Math2 = mupEval(MathParser2); |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
730 Math3 = mupEval(MathParser3); |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
731 Math4 = mupEval(MathParser4); |
124
bdfc61a8ebee
Add thousands separator to important numeric displays
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
123
diff
changeset
|
732 Math5 = mupEval(MathParser5); |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
733 |
124
bdfc61a8ebee
Add thousands separator to important numeric displays
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
123
diff
changeset
|
734 // update display. numeric controllers do not format values |
bdfc61a8ebee
Add thousands separator to important numeric displays
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
123
diff
changeset
|
735 // with a thousands separator: use string controllers and a |
bdfc61a8ebee
Add thousands separator to important numeric displays
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
123
diff
changeset
|
736 // custom formatting function |
bdfc61a8ebee
Add thousands separator to important numeric displays
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
123
diff
changeset
|
737 char buffer[256]; |
158
9154291658ef
Simplify DDS frequency juggling in N measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
156
diff
changeset
|
738 SetCtrlVal(MainPanel, PANEL_MATH1, thousands(buffer, sizeof(buffer), "%.6f", Math1)); |
9154291658ef
Simplify DDS frequency juggling in N measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
156
diff
changeset
|
739 SetCtrlVal(MainPanel, PANEL_MATH2, thousands(buffer, sizeof(buffer), "%.3f", Math2)); |
9154291658ef
Simplify DDS frequency juggling in N measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
156
diff
changeset
|
740 SetCtrlVal(MainPanel, PANEL_MATH3, thousands(buffer, sizeof(buffer), "%.3f", Math3)); |
9154291658ef
Simplify DDS frequency juggling in N measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
156
diff
changeset
|
741 SetCtrlVal(MainPanel, PANEL_MATH4, thousands(buffer, sizeof(buffer), "%.3f", Math4)); |
9154291658ef
Simplify DDS frequency juggling in N measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
156
diff
changeset
|
742 SetCtrlVal(MainPanel, PANEL_MATH5, thousands(buffer, sizeof(buffer), "%.3f", Math5)); |
166 | 743 |
134
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
744 // update timeseries plots |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
745 for (struct plot *plot = plots; plot->data; plot++) |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
746 plot_update(plot); |
0 | 747 |
134
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
748 // update allan deviation plots |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
749 for (struct adev *adev = adevs; adev->data; adev++) |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
750 adev_update(adev); |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
751 |
159 | 752 // N measurement |
753 | |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
754 switch (Measuring_1) { |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
755 |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
756 case N_MEASUREMENT_NONE: |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
757 // not measuring |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
758 break; |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
759 |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
760 case N_MEASUREMENT_INIT: |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
761 // initialization step |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
762 |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
763 // set DDS1 to nominal frequency |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
764 ad9912_set_frequency_w(&ad9912, 0, f0_DDS1); |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
765 SetCtrlVal(MainPanel, PANEL_DDS1, ad9912.frequency[0]); |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
766 |
160
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
767 // record current DDS frequencies |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
768 f0_DDS2 = ad9912.frequency[1]; |
160
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
769 |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
770 t1 = utc; |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
771 t2 = t3 = 0.0; |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
772 nobs = 0; |
73
1dfaf5ef0352
Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
70
diff
changeset
|
773 stat_zero(&stat_math1); |
160
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
774 f_rep_plus = f_rep_minus = 0.0; |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
775 |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
776 // next step |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
777 Measuring_1 += 1; |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
778 break; |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
779 |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
780 case N_MEASUREMENT_SLOPE: |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
781 // slope measurement |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
782 |
73
1dfaf5ef0352
Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
70
diff
changeset
|
783 stat_accumulate(&stat_math1, Math1); |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
784 |
160
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
785 if ((utc - t1) > SlopeTime1) { |
159 | 786 f_rep_slope = stat_math1.slope; |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
787 |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
788 // frep positive step |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
789 ad9912_ramp_frequency_w(&ad9912, 0, f0_DDS1 + delta_f_lock_1, FREP_STEP_SIZE); |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
790 SetCtrlVal(MainPanel, PANEL_DDS1, ad9912.frequency[0]); |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
791 |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
792 // allow counter to settle |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
793 settling = 3; |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
794 |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
795 // next step |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
796 Measuring_1 += 1; |
46
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
797 } |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
798 break; |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
799 |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
800 case N_MEASUREMENT_ADJUST_FREQ_PLUS: |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
801 case N_MEASUREMENT_ADJUST_FREQ_MINUS: |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
802 // adjust DDS frequency to keep beatnote within the bandpass filter |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
803 |
159 | 804 if (settling-- > 0) |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
805 break; |
0 | 806 |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
807 double fDDS2 = ad9912.frequency[1]; |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
808 ad9912_set_frequency_w(&ad9912, 1, fDDS2 + 275000 - Ch4); |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
809 SetCtrlVal(MainPanel, PANEL_DDS2, ad9912.frequency[1]); |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
810 |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
811 // allow counter to settle |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
812 settling = 3; |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
813 |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
814 // next step |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
815 Measuring_1 += 1; |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
816 break; |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
817 |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
818 case N_MEASUREMENT_FREP_PLUS: |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
819 // frep positive step |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
820 |
159 | 821 if (settling-- > 0) |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
822 break; |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
823 |
160
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
824 if (t2 == 0.0) |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
825 t2 = utc; |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
826 |
160
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
827 f_rep_plus += Math1 - f_rep_slope * (utc - t2); |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
828 nobs += 1; |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
829 |
160
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
830 if ((utc - t2) > DeltaT_1) { |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
831 f_rep_plus = f_rep_plus / nobs; |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
832 nobs = 0; |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
833 |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
834 // frep negative step |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
835 ad9912_ramp_frequency_w(&ad9912, 0, f0_DDS1 - delta_f_lock_1, FREP_STEP_SIZE); |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
836 SetCtrlVal(MainPanel, PANEL_DDS1, ad9912.frequency[0]); |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
837 |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
838 // allow counter to settle |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
839 settling = 3; |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
840 |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
841 // next step |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
842 Measuring_1 += 1; |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
843 } |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
844 break; |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
845 |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
846 case N_MEASUREMENT_FREP_MINUS: |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
847 // frep negative step |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
848 |
159 | 849 if (settling-- > 0) |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
850 break; |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
851 |
160
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
852 if (t3 == 0.0) |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
853 t3 = utc; |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
854 |
160
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
855 f_rep_minus += Math1 - f_rep_slope * (utc - t2); |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
856 nobs += 1; |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
857 |
160
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
858 if ((utc - t3) > DeltaT_1) { |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
859 f_rep_minus = f_rep_minus / nobs; |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
860 nobs = 0; |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
861 |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
862 // compute N1 |
159 | 863 double delta_f_rep = f_rep_minus - f_rep_plus; |
162 | 864 N_measured = Sign1 * 2 * Ndiv * delta_f_lock_1 / delta_f_rep; |
865 SetCtrlVal(CalcNPanel, CALCN_N, N_measured); | |
0 | 866 |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
867 // back to nominal frep |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
868 ad9912_ramp_frequency_w(&ad9912, 0, f0_DDS1, FREP_STEP_SIZE); |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
869 ad9912_set_frequency_w(&ad9912, 1, f0_DDS2); |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
870 SetCtrlVal(MainPanel, PANEL_DDS1, ad9912.frequency[0]); |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
871 SetCtrlVal(MainPanel, PANEL_DDS2, ad9912.frequency[1]); |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
872 |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
873 // done |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
874 Measuring_1 = N_MEASUREMENT_NONE; |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
875 } |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
876 break; |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
877 } |
46
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
878 |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
879 switch (Measuring_2) { |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
880 |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
881 case N_MEASUREMENT_NONE: |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
882 // not measuring |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
883 break; |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
884 |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
885 case N_MEASUREMENT_INIT: |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
886 // initialization step |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
887 |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
888 // set DDS1 to nominal frequency |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
889 ad9912_set_frequency_w(&ad9912, 0, f0_DDS1); |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
890 SetCtrlVal(MainPanel, PANEL_DDS1, ad9912.frequency[0]); |
0 | 891 |
160
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
892 // record current DDS frequencies |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
893 f0_DDS2 = ad9912.frequency[1]; |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
894 f0_DDS3 = ad9912.frequency[2]; |
160
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
895 |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
896 t1 = utc; |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
897 t2 = t3 = 0.0; |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
898 nobs = 0; |
73
1dfaf5ef0352
Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
70
diff
changeset
|
899 stat_zero(&stat_math1); |
1dfaf5ef0352
Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
70
diff
changeset
|
900 stat_zero(&stat_ch2); |
160
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
901 f_rep_plus = f_rep_minus = 0.0; |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
902 f_beat_plus = f_beat_minus = 0.0; |
46
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
903 |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
904 // next step |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
905 Measuring_2 += 1; |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
906 break; |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
907 |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
908 case N_MEASUREMENT_SLOPE: |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
909 // slope measurement |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
910 |
73
1dfaf5ef0352
Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
70
diff
changeset
|
911 stat_accumulate(&stat_math1, Math1); |
1dfaf5ef0352
Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
70
diff
changeset
|
912 stat_accumulate(&stat_ch2, Ch2); |
46
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
913 |
160
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
914 if ((utc - t1) > SlopeTime2) { |
159 | 915 f_rep_slope = stat_math1.slope; |
916 f_beat_slope = stat_ch2.slope; | |
46
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
917 |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
918 // frep positive step |
159 | 919 double fDDS1 = f0_DDS1 + delta_f_lock_2; |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
920 ad9912_ramp_frequency_w(&ad9912, 0, fDDS1, FREP_STEP_SIZE); |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
921 SetCtrlVal(MainPanel, PANEL_DDS1, ad9912.frequency[0]); |
62
53dbce5f0745
Further simplification
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
61
diff
changeset
|
922 |
61
37075b60408b
Fix N2 measurement after cleanup. Further simplification
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
60
diff
changeset
|
923 // adjust DDS3 to keep beatnote within the bandpass filter. prediction |
160
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
924 double fDDS3 = f0_DDS3 + Sign1 * Sign2 * N2/N1 * Ndiv * delta_f_lock_2; |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
925 df_DDS3 = fDDS3 - ad9912.frequency[2]; |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
926 ad9912_set_frequency_w(&ad9912, 2, fDDS3); |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
927 SetCtrlVal(MainPanel, PANEL_DDS3, ad9912.frequency[2]); |
46
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
928 |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
929 // allow counter to settle |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
930 settling = 3; |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
931 |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
932 // next step |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
933 Measuring_2 += 1; |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
934 } |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
935 break; |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
936 |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
937 case N_MEASUREMENT_ADJUST_FREQ_PLUS: |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
938 case N_MEASUREMENT_ADJUST_FREQ_MINUS: |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
939 // adjust DDS frequency to keep beatnote within the bandpass filter |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
940 |
159 | 941 if (settling-- > 0) |
46
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
942 break; |
61
37075b60408b
Fix N2 measurement after cleanup. Further simplification
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
60
diff
changeset
|
943 |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
944 double fDDS2 = ad9912.frequency[1] + 275000 - Ch4; |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
945 ad9912_set_frequency_w(&ad9912, 1, fDDS2); |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
946 SetCtrlVal(MainPanel, PANEL_DDS2, ad9912.frequency[1]); |
46
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
947 |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
948 double fDDS3 = ad9912.frequency[2] + 10000 - Ch2; |
162 | 949 df_DDS3 = df_DDS3 + 10000 - Ch2; |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
950 ad9912_set_frequency_w(&ad9912, 2, fDDS3); |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
951 SetCtrlVal(MainPanel, PANEL_DDS3, ad9912.frequency[2]); |
46
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
952 |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
953 // allow counter to settle |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
954 settling = 3; |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
955 |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
956 // next step |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
957 Measuring_2 += 1; |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
958 break; |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
959 |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
960 case N_MEASUREMENT_FREP_PLUS: |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
961 // frep positive step |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
962 |
159 | 963 if (settling-- > 0) |
46
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
964 break; |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
965 |
160
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
966 if (t2 == 0.0) |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
967 t2 = utc; |
46
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
968 |
160
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
969 f_rep_plus += Math1 + 250000000 - f_rep_slope * (utc - t2); |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
970 f_beat_plus += Ch2 - f_beat_slope * (utc - t2); |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
971 nobs += 1; |
46
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
972 |
160
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
973 if ((utc - t2) > DeltaT_2) { |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
974 f_rep_plus = f_rep_plus / nobs; |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
975 f_beat_plus = f_beat_plus / nobs; |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
976 nobs = 0; |
46
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
977 |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
978 // negative frequency step |
159 | 979 double fDDS1 = f0_DDS1 - delta_f_lock_2; |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
980 ad9912_ramp_frequency_w(&ad9912, 0, fDDS1, FREP_STEP_SIZE); |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
981 SetCtrlVal(MainPanel, PANEL_DDS1, ad9912.frequency[0]); |
62
53dbce5f0745
Further simplification
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
61
diff
changeset
|
982 |
53dbce5f0745
Further simplification
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
61
diff
changeset
|
983 // adjust DDS3 to keep beatnote within the bandpass filter. prediction |
160
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
984 double fDDS3 = f0_DDS3 - Sign1 * Sign2 * N2/N1 * Ndiv * delta_f_lock_2; |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
985 df_DDS3 = fDDS3 - ad9912.frequency[2]; |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
986 ad9912_set_frequency_w(&ad9912, 2, fDDS3); |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
987 SetCtrlVal(MainPanel, PANEL_DDS3, ad9912.frequency[2]); |
17
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
988 |
46
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
989 // allow counter to settle |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
990 settling = 3; |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
991 |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
992 // next step |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
993 Measuring_2 += 1; |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
994 } |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
995 break; |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
996 |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
997 case N_MEASUREMENT_FREP_MINUS: |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
998 // frep negative step |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
999 |
159 | 1000 if (settling-- > 0) |
46
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
1001 break; |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
1002 |
160
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1003 if (t3 == 0.0) |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1004 t3 = utc; |
46
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
1005 |
160
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1006 f_rep_minus += Math1 + 250000000 - f_rep_slope * (utc - t2); |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1007 f_beat_minus += Ch2 + f_beat_slope * (utc - t2); |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1008 nobs += 1; |
46
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
1009 |
160
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1010 if ((utc -t3) > DeltaT_2) { |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1011 f_rep_minus = f_rep_minus / nobs; |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1012 f_beat_minus = f_beat_minus / nobs; |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1013 nobs = 0; |
46
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
1014 |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
1015 // compute N2 |
161
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
1016 double delta_f_rep_m = f_rep_minus - f_rep_plus; |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1017 double delta_f_rep = Sign1 * Ndiv * 2.0 * delta_f_lock_2 / N1; |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1018 double delta = delta_f_rep_m - delta_f_rep; |
161
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
1019 |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1020 logmsg("delta frep: measured=%e expected=%e difference=%e rel=%e", |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1021 delta_f_rep_m, delta_f_rep, delta, delta / delta_f_rep); |
161
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
1022 |
162 | 1023 N_measured = -Sign2 * (df_DDS3 + f_beat_minus - f_beat_plus) / delta_f_rep; |
1024 SetCtrlVal(CalcNPanel, CALCN_N, N_measured); | |
46
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
1025 |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
1026 // back to nominal frequency |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1027 ad9912_ramp_frequency_w(&ad9912, 0, f0_DDS1, FREP_STEP_SIZE); |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1028 ad9912_set_frequency_w(&ad9912, 1, f0_DDS2); |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1029 ad9912_set_frequency_w(&ad9912, 2, f0_DDS3); |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1030 SetCtrlVal(MainPanel, PANEL_DDS1, ad9912.frequency[0]); |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1031 SetCtrlVal(MainPanel, PANEL_DDS2, ad9912.frequency[1]); |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1032 SetCtrlVal(MainPanel, PANEL_DDS3, ad9912.frequency[2]); |
46
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
1033 |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
1034 // done |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
1035 Measuring_2 = N_MEASUREMENT_NONE; |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
1036 } |
6503feae1809
Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
44
diff
changeset
|
1037 break; |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1038 } |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1039 |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1040 switch (Measuring_3) { |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1041 |
47
1d3cd8260cbb
Uniform N3 measurement code to N1 and N2
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
46
diff
changeset
|
1042 case N_MEASUREMENT_NONE: |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1043 // not measuring N3 |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1044 break; |
0 | 1045 |
47
1d3cd8260cbb
Uniform N3 measurement code to N1 and N2
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
46
diff
changeset
|
1046 case N_MEASUREMENT_INIT: |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1047 // init |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1048 |
160
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1049 // set DDS1 to nominal frequency |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1050 ad9912_set_frequency_w(&ad9912, 0, f0_DDS1); |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1051 SetCtrlVal(MainPanel, PANEL_DDS1, ad9912.frequency[0]); |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1052 |
160
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1053 // record current DDS frequencies |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1054 f0_DDS2 = ad9912.frequency[1]; |
217
fefe921a9784
Use DDS4 for shifting Sr beatnote frequency to 10 kHz
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
216
diff
changeset
|
1055 f0_DDS4 = ad9912.frequency[3]; |
160
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1056 |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1057 t1 = utc; |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1058 t2 = t3 = 0.0; |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1059 nobs = 0; |
118
43b35f4aae78
Fix N3 measurement. Simply frequnecy ramping functions.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
117
diff
changeset
|
1060 stat_zero(&stat_math1); |
156
4ab8099a18e2
Add beatnote frequency drift correction to N3 measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
155
diff
changeset
|
1061 stat_zero(&stat_ch3); |
115
23f8b7b2b63a
Use DDS1 to change frep in the measurement of N3. Improve some variable names
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
114
diff
changeset
|
1062 f_rep_plus = f_rep_minus = 0.0; |
159 | 1063 f_beat_plus = f_beat_minus = 0.0; |
73
1dfaf5ef0352
Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
70
diff
changeset
|
1064 |
47
1d3cd8260cbb
Uniform N3 measurement code to N1 and N2
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
46
diff
changeset
|
1065 // next step |
1d3cd8260cbb
Uniform N3 measurement code to N1 and N2
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
46
diff
changeset
|
1066 Measuring_3 += 1; |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1067 break; |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1068 |
47
1d3cd8260cbb
Uniform N3 measurement code to N1 and N2
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
46
diff
changeset
|
1069 case N_MEASUREMENT_SLOPE: |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1070 // slope measurement |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1071 |
159 | 1072 if (settling-- > 0) |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1073 break; |
0 | 1074 |
118
43b35f4aae78
Fix N3 measurement. Simply frequnecy ramping functions.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
117
diff
changeset
|
1075 stat_accumulate(&stat_math1, Math1); |
156
4ab8099a18e2
Add beatnote frequency drift correction to N3 measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
155
diff
changeset
|
1076 stat_accumulate(&stat_ch3, Ch3); |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1077 |
160
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1078 if (utc - t1 > SlopeTime3) { |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1079 // slope measurement |
118
43b35f4aae78
Fix N3 measurement. Simply frequnecy ramping functions.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
117
diff
changeset
|
1080 f_rep_slope = stat_math1.slope; |
160
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1081 f_beat_slope = stat_ch3.slope; |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1082 |
156
4ab8099a18e2
Add beatnote frequency drift correction to N3 measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
155
diff
changeset
|
1083 logmsg("f_rep_slope=%e Hz/s", f_rep_slope); |
4ab8099a18e2
Add beatnote frequency drift correction to N3 measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
155
diff
changeset
|
1084 logmsg("f_beat_slope=%e Hz/s", f_rep_slope); |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1085 |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1086 // frep positive step |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1087 ad9912_ramp_frequency_w(&ad9912, 0, f0_DDS1 + delta_f_lock_3, FREP_STEP_SIZE); |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1088 SetCtrlVal(MainPanel, PANEL_DDS1, ad9912.frequency[0]); |
158
9154291658ef
Simplify DDS frequency juggling in N measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
156
diff
changeset
|
1089 |
9154291658ef
Simplify DDS frequency juggling in N measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
156
diff
changeset
|
1090 // adjust DDS3 to keep beatnote within the bandpass filter |
217
fefe921a9784
Use DDS4 for shifting Sr beatnote frequency to 10 kHz
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
216
diff
changeset
|
1091 double fDDS4 = f0_DDS4 + Sign1 * Sign3 * N3/N1 * Ndiv * delta_f_lock_3; |
fefe921a9784
Use DDS4 for shifting Sr beatnote frequency to 10 kHz
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
216
diff
changeset
|
1092 ad9912_set_frequency_w(&ad9912, 3, fDDS4); |
fefe921a9784
Use DDS4 for shifting Sr beatnote frequency to 10 kHz
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
216
diff
changeset
|
1093 SetCtrlVal(MainPanel, PANEL_DDS4, ad9912.frequency[3]); |
47
1d3cd8260cbb
Uniform N3 measurement code to N1 and N2
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
46
diff
changeset
|
1094 |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1095 // allow counter to settle |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1096 settling = 3; |
47
1d3cd8260cbb
Uniform N3 measurement code to N1 and N2
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
46
diff
changeset
|
1097 |
1d3cd8260cbb
Uniform N3 measurement code to N1 and N2
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
46
diff
changeset
|
1098 // next step |
1d3cd8260cbb
Uniform N3 measurement code to N1 and N2
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
46
diff
changeset
|
1099 Measuring_3 += 1; |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1100 } |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1101 break; |
47
1d3cd8260cbb
Uniform N3 measurement code to N1 and N2
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
46
diff
changeset
|
1102 |
1d3cd8260cbb
Uniform N3 measurement code to N1 and N2
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
46
diff
changeset
|
1103 case N_MEASUREMENT_ADJUST_FREQ_PLUS: |
1d3cd8260cbb
Uniform N3 measurement code to N1 and N2
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
46
diff
changeset
|
1104 case N_MEASUREMENT_ADJUST_FREQ_MINUS: |
1d3cd8260cbb
Uniform N3 measurement code to N1 and N2
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
46
diff
changeset
|
1105 // adjust DDS frequency to keep beatnote within the bandpass filter |
1d3cd8260cbb
Uniform N3 measurement code to N1 and N2
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
46
diff
changeset
|
1106 |
159 | 1107 if (settling-- > 0) |
109
2a9f8a811d87
Fix N3 measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
105
diff
changeset
|
1108 break; |
2a9f8a811d87
Fix N3 measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
105
diff
changeset
|
1109 |
2a9f8a811d87
Fix N3 measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
105
diff
changeset
|
1110 // adjust DDS frequency to keep 55 MHz tracker oscillator locked |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1111 double fDDS2 = ad9912.frequency[1] + 275000 - Ch4; |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1112 ad9912_set_frequency_w(&ad9912, 1, fDDS2); |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1113 SetCtrlVal(MainPanel, PANEL_DDS2, ad9912.frequency[1]); |
109
2a9f8a811d87
Fix N3 measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
105
diff
changeset
|
1114 |
2a9f8a811d87
Fix N3 measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
105
diff
changeset
|
1115 // allow counter to settle |
2a9f8a811d87
Fix N3 measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
105
diff
changeset
|
1116 settling = 3; |
2a9f8a811d87
Fix N3 measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
105
diff
changeset
|
1117 |
47
1d3cd8260cbb
Uniform N3 measurement code to N1 and N2
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
46
diff
changeset
|
1118 // next step |
1d3cd8260cbb
Uniform N3 measurement code to N1 and N2
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
46
diff
changeset
|
1119 Measuring_3 += 1; |
1d3cd8260cbb
Uniform N3 measurement code to N1 and N2
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
46
diff
changeset
|
1120 break; |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1121 |
47
1d3cd8260cbb
Uniform N3 measurement code to N1 and N2
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
46
diff
changeset
|
1122 case N_MEASUREMENT_FREP_PLUS: |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1123 // frep positive step |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1124 |
159 | 1125 if (settling-- > 0) |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1126 break; |
160
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1127 |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1128 if (t2 == 0.0) |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1129 t2 = utc; |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1130 |
160
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1131 f_rep_plus += Math1 + 250000000 - f_rep_slope * (utc - t2); |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1132 f_beat_plus += Ch3 - f_beat_slope * (utc - t2); |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1133 nobs += 1; |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1134 |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1135 if (utc - t2 > DeltaT_3) { |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1136 f_rep_plus = f_rep_plus / nobs; |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1137 f_beat_plus = f_beat_plus / nobs; |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1138 nobs = 0; |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1139 |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1140 // frep negative step |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1141 ad9912_ramp_frequency_w(&ad9912, 0, f0_DDS1 - delta_f_lock_3, FREP_STEP_SIZE); |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1142 SetCtrlVal(MainPanel, PANEL_DDS1, ad9912.frequency[0]); |
158
9154291658ef
Simplify DDS frequency juggling in N measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
156
diff
changeset
|
1143 |
9154291658ef
Simplify DDS frequency juggling in N measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
156
diff
changeset
|
1144 // adjust DDS3 to keep beatnote within the bandpass filter |
217
fefe921a9784
Use DDS4 for shifting Sr beatnote frequency to 10 kHz
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
216
diff
changeset
|
1145 double fDDS4 = f0_DDS4 - Sign1 * Sign3 * N3/N1 * Ndiv * delta_f_lock_3; |
fefe921a9784
Use DDS4 for shifting Sr beatnote frequency to 10 kHz
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
216
diff
changeset
|
1146 ad9912_set_frequency_w(&ad9912, 3, fDDS4); |
fefe921a9784
Use DDS4 for shifting Sr beatnote frequency to 10 kHz
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
216
diff
changeset
|
1147 SetCtrlVal(MainPanel, PANEL_DDS4, ad9912.frequency[3]); |
47
1d3cd8260cbb
Uniform N3 measurement code to N1 and N2
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
46
diff
changeset
|
1148 |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1149 // allow counter to settle |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1150 settling = 3; |
47
1d3cd8260cbb
Uniform N3 measurement code to N1 and N2
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
46
diff
changeset
|
1151 |
1d3cd8260cbb
Uniform N3 measurement code to N1 and N2
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
46
diff
changeset
|
1152 // next step |
1d3cd8260cbb
Uniform N3 measurement code to N1 and N2
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
46
diff
changeset
|
1153 Measuring_3 += 1; |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1154 } |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1155 break; |
118
43b35f4aae78
Fix N3 measurement. Simply frequnecy ramping functions.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
117
diff
changeset
|
1156 |
47
1d3cd8260cbb
Uniform N3 measurement code to N1 and N2
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
46
diff
changeset
|
1157 case N_MEASUREMENT_FREP_MINUS: |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1158 // frep negative step |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1159 |
159 | 1160 if (settling-- > 0) |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1161 break; |
0 | 1162 |
160
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1163 if (t3 == 0.0) |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1164 t3 = utc; |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1165 |
160
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1166 f_rep_minus += Math1 + 250000000 - f_rep_slope * (utc - t2); |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1167 f_beat_minus += Ch3 - f_beat_slope * (utc - t2); |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1168 nobs += 1; |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1169 |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1170 if (utc - t3 > DeltaT_3) { |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1171 f_rep_minus = f_rep_minus / nobs; |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1172 f_beat_minus = f_beat_minus / nobs; |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1173 nobs = 0; |
111
8bdd7e38715f
Fix N3 measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
109
diff
changeset
|
1174 |
8bdd7e38715f
Fix N3 measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
109
diff
changeset
|
1175 // check delta frep |
118
43b35f4aae78
Fix N3 measurement. Simply frequnecy ramping functions.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
117
diff
changeset
|
1176 double delta_f_rep_m = f_rep_plus - f_rep_minus; |
159 | 1177 double delta_f_rep = Sign1 * Ndiv * 2.0 * delta_f_lock_3 / N1; |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1178 double delta = delta_f_rep_m - delta_f_rep; |
161
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
1179 |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1180 logmsg("delta frep: measured=%e expected=%e difference=%e rel=%e", |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1181 delta_f_rep_m, delta_f_rep, delta, delta / delta_f_rep); |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1182 |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1183 // compute N3 |
159 | 1184 double delta_f_beat = f_beat_plus - f_beat_minus + 2.0 * Sign1 * Sign3 * N3/N1 * Ndiv * delta_f_lock_3; |
1185 double delta_f_beat_expected = delta_f_rep * N3; | |
161
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
1186 |
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
1187 logmsg("delta fbeat: measured=%e expected=%e difference=%e", |
159 | 1188 delta_f_beat, delta_f_beat_expected, delta_f_beat - delta_f_beat_expected); |
161
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
1189 |
162 | 1190 N_measured = delta_f_beat / delta_f_rep; |
1191 SetCtrlVal(CalcNPanel, CALCN_N, N_measured); | |
161
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
1192 |
162 | 1193 logmsg("measured N3=%.3f", N_measured); |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1194 |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1195 // back to nominal frep |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1196 ad9912_ramp_frequency_w(&ad9912, 0, f0_DDS1, FREP_STEP_SIZE); |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1197 ad9912_set_frequency_w(&ad9912, 1, f0_DDS2); |
217
fefe921a9784
Use DDS4 for shifting Sr beatnote frequency to 10 kHz
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
216
diff
changeset
|
1198 ad9912_set_frequency_w(&ad9912, 3, f0_DDS4); |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1199 SetCtrlVal(MainPanel, PANEL_DDS1, ad9912.frequency[0]); |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1200 SetCtrlVal(MainPanel, PANEL_DDS2, ad9912.frequency[1]); |
217
fefe921a9784
Use DDS4 for shifting Sr beatnote frequency to 10 kHz
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
216
diff
changeset
|
1201 SetCtrlVal(MainPanel, PANEL_DDS4, ad9912.frequency[3]); |
47
1d3cd8260cbb
Uniform N3 measurement code to N1 and N2
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
46
diff
changeset
|
1202 |
1d3cd8260cbb
Uniform N3 measurement code to N1 and N2
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
46
diff
changeset
|
1203 // done |
1d3cd8260cbb
Uniform N3 measurement code to N1 and N2
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
46
diff
changeset
|
1204 Measuring_3 = N_MEASUREMENT_NONE; |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1205 } |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1206 break; |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1207 } |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1208 |
125
37535873ee83
Rename variables from SigneX to SignX
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
124
diff
changeset
|
1209 // beatnote sign determination |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1210 |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1211 if (Getsign1 == TRUE) { |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1212 if (utc > tbegin1+2) { |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1213 if (Math1 > Frepbefore1) |
125
37535873ee83
Rename variables from SigneX to SignX
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
124
diff
changeset
|
1214 Sign1 = -1.0; |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1215 else |
125
37535873ee83
Rename variables from SigneX to SignX
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
124
diff
changeset
|
1216 Sign1 = +1.0; |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1217 ad9912_set_frequency_w(&ad9912, 0, Frequency1); |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1218 Getsign1 = FALSE; |
125
37535873ee83
Rename variables from SigneX to SignX
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
124
diff
changeset
|
1219 SetCtrlVal(MainPanel, PANEL_SIGN1, Sign1); |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1220 } |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1221 } |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1222 if (Getsign2 == TRUE) { |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1223 if (utc > tbegin2+2){ |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1224 if (Math1 > Frepbefore2) { |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1225 if (Ch2 > Ch2before) |
125
37535873ee83
Rename variables from SigneX to SignX
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
124
diff
changeset
|
1226 Sign2 = +1.0; |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1227 else |
125
37535873ee83
Rename variables from SigneX to SignX
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
124
diff
changeset
|
1228 Sign2 = -1.0; |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1229 } else { |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1230 if (Ch2 > Ch2before) |
125
37535873ee83
Rename variables from SigneX to SignX
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
124
diff
changeset
|
1231 Sign2 = -1.0; |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1232 else |
125
37535873ee83
Rename variables from SigneX to SignX
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
124
diff
changeset
|
1233 Sign2 = +1.0; |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1234 } |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1235 ad9912_set_frequency_w(&ad9912, 0, Frequency2); |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1236 Getsign2 = FALSE; |
125
37535873ee83
Rename variables from SigneX to SignX
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
124
diff
changeset
|
1237 SetCtrlVal(MainPanel, PANEL_SIGN2, Sign2); |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1238 } |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1239 } |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1240 if (Getsign3 == TRUE) { |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1241 if (utc > tbegin3+2){ |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1242 if (Ch3 > Frepbefore3) |
125
37535873ee83
Rename variables from SigneX to SignX
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
124
diff
changeset
|
1243 Sign3 = -1.0; |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1244 else |
125
37535873ee83
Rename variables from SigneX to SignX
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
124
diff
changeset
|
1245 Sign3 = +1.0; |
217
fefe921a9784
Use DDS4 for shifting Sr beatnote frequency to 10 kHz
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
216
diff
changeset
|
1246 ad9912_set_frequency_w(&ad9912, 0, Frequency3); |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1247 Getsign3 = FALSE; |
125
37535873ee83
Rename variables from SigneX to SignX
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
124
diff
changeset
|
1248 SetCtrlVal(MainPanel, PANEL_SIGN3, Sign3); |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1249 } |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1250 } |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1251 |
70
a945f2b7bef6
Fix slope measurement again
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
69
diff
changeset
|
1252 // select reference |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1253 double f = 0.0; |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1254 switch (dedrift.reference) { |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1255 case DEDRIFT_REFERENCE_MICROWAVE: |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1256 f = Math2; |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1257 break; |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1258 case DEDRIFT_REFERENCE_HG: |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1259 f = Ch2 * 1062.5 / 1542.2; |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1260 break; |
70
a945f2b7bef6
Fix slope measurement again
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
69
diff
changeset
|
1261 } |
a945f2b7bef6
Fix slope measurement again
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
69
diff
changeset
|
1262 |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1263 // stop dedrift if the comb is not locked |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1264 if ((dedrift.enabled) |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1265 & (dedrift.threshold != 0.0) |
73
1dfaf5ef0352
Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
70
diff
changeset
|
1266 & (freq.previous != 0.0) |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1267 & (fabs(f - freq.previous) > dedrift.threshold)) { |
56
6e73fb3d94fa
Simplyfy slope measurement code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
55
diff
changeset
|
1268 |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1269 if (! dedrift.keep_slope) { |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1270 dedrift.applied = 0.0; |
209
11a88d389705
Adapt to new AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
205
diff
changeset
|
1271 ad9956_set_sweep_rate_w(&ad9956, dedrift.applied); |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1272 SetCtrlVal(MainPanel, PANEL_SLOPE_APPLIED, dedrift.applied); |
70
a945f2b7bef6
Fix slope measurement again
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
69
diff
changeset
|
1273 } |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1274 if (! dedrift.keep_freq) { |
209
11a88d389705
Adapt to new AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
205
diff
changeset
|
1275 ad9956_set_w(&ad9956, dedrift.freq0, dedrift.applied); |
56
6e73fb3d94fa
Simplyfy slope measurement code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
55
diff
changeset
|
1276 } |
73
1dfaf5ef0352
Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
70
diff
changeset
|
1277 |
1dfaf5ef0352
Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
70
diff
changeset
|
1278 stat_zero(&freq); |
1dfaf5ef0352
Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
70
diff
changeset
|
1279 SetCtrlVal(MainPanel, PANEL_SLOPE_MEASURED, freq.slope); |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1280 dedrift.enabled = FALSE; |
70
a945f2b7bef6
Fix slope measurement again
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
69
diff
changeset
|
1281 SetCtrlVal(MainPanel, PANEL_MEASURE_SLOPE, 0); |
a945f2b7bef6
Fix slope measurement again
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
69
diff
changeset
|
1282 } |
a945f2b7bef6
Fix slope measurement again
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
69
diff
changeset
|
1283 |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1284 // dedrifting |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1285 if (dedrift.enabled) |
70
a945f2b7bef6
Fix slope measurement again
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
69
diff
changeset
|
1286 { |
56
6e73fb3d94fa
Simplyfy slope measurement code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
55
diff
changeset
|
1287 // update slope measurement |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1288 stat_accumulate(&freq, f); |
73
1dfaf5ef0352
Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
70
diff
changeset
|
1289 |
60
cd7b5903f168
Display measured slope
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
59
diff
changeset
|
1290 // update indicator |
73
1dfaf5ef0352
Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
70
diff
changeset
|
1291 SetCtrlVal(MainPanel, PANEL_SLOPE_MEASURED, freq.slope); |
56
6e73fb3d94fa
Simplyfy slope measurement code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
55
diff
changeset
|
1292 |
6e73fb3d94fa
Simplyfy slope measurement code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
55
diff
changeset
|
1293 // update applied slope |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1294 if ((utc - dedrift.t0) > dedrift.interval) { |
0 | 1295 |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1296 if (dedrift.invert) |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1297 dedrift.applied -= freq.slope; |
52
30146cc6cd77
Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
51
diff
changeset
|
1298 else |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1299 dedrift.applied += freq.slope; |
0 | 1300 |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1301 SetCtrlVal(MainPanel, PANEL_SLOPE_APPLIED, dedrift.applied); |
0 | 1302 |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1303 if (dedrift.doubleslope) |
209
11a88d389705
Adapt to new AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
205
diff
changeset
|
1304 ad9956_set_sweep_rate_w(&ad9956, 2 * dedrift.applied); |
123
35861fe64d14
Allow to set dedrift DDS central frequency. Add option to double applied slope.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
122
diff
changeset
|
1305 else |
209
11a88d389705
Adapt to new AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
205
diff
changeset
|
1306 ad9956_set_sweep_rate_w(&ad9956, dedrift.applied); |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1307 |
140
3f7eef731ccc
Adjust log messages
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
139
diff
changeset
|
1308 logmsg("dedrift update: adjustment=%+3e slope=%+3e", freq.slope, dedrift.applied); |
82
47860259afe2
Implement logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
80
diff
changeset
|
1309 |
73
1dfaf5ef0352
Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
70
diff
changeset
|
1310 stat_zero(&freq); |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1311 dedrift.t0 = utc; |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1312 } |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1313 } |
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1314 |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1315 // recenter |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1316 if (recenter.enabled) |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1317 { |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1318 rollmean_accumulate(&rollmean_ch2, Ch2); |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1319 rollmean_accumulate(&rollmean_ch3, Ch3); |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1320 rollmean_accumulate(&rollmean_ch4, Ch4); |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1321 |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1322 if ((utc - recenter.t0) > recenter.interval) { |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1323 |
144 | 1324 if (recenter.lo) { |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1325 // adjust DDS2 frequency to keep Ch4 reading at 275 kHz |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1326 double freq = ad9912.frequency[1]; |
139 | 1327 double adj = 275000.0 - rollmean_ch4.mean; |
1328 freq = freq + adj; | |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1329 ad9912_set_frequency_w(&ad9912, 1, freq); |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1330 SetCtrlVal(MainPanel, PANEL_DDS2, ad9912.frequency[1]); |
140
3f7eef731ccc
Adjust log messages
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
139
diff
changeset
|
1331 logmsg("recenter ch4 to 275 kHz: DDS2 adjustment=%+3e", adj); |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1332 } |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1333 |
144 | 1334 if (recenter.hg) { |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1335 // adjust DDS3 frequency to keep Ch2 reading at 10 kHz |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1336 double freq = ad9912.frequency[2]; |
139 | 1337 double adj = 10000 - rollmean_ch2.mean; |
1338 freq = freq + adj; | |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1339 ad9912_set_frequency_w(&ad9912, 2, freq); |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1340 SetCtrlVal(MainPanel, PANEL_DDS3, ad9912.frequency[2]); |
140
3f7eef731ccc
Adjust log messages
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
139
diff
changeset
|
1341 logmsg("recenter Hg beatnote (ch2) to 10 kHz: DDS3 adjustment=%+3e", adj); |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1342 } |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1343 |
144 | 1344 if (recenter.sr) { |
217
fefe921a9784
Use DDS4 for shifting Sr beatnote frequency to 10 kHz
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
216
diff
changeset
|
1345 // adjust DDS4 frequency to keep Ch3 reading at 10 kHz |
fefe921a9784
Use DDS4 for shifting Sr beatnote frequency to 10 kHz
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
216
diff
changeset
|
1346 double freq = ad9912.frequency[3]; |
139 | 1347 double adj = 10000 - rollmean_ch3.mean; |
1348 freq = freq + adj; | |
217
fefe921a9784
Use DDS4 for shifting Sr beatnote frequency to 10 kHz
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
216
diff
changeset
|
1349 ad9912_set_frequency_w(&ad9912, 3, freq); |
fefe921a9784
Use DDS4 for shifting Sr beatnote frequency to 10 kHz
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
216
diff
changeset
|
1350 SetCtrlVal(MainPanel, PANEL_DDS4, ad9912.frequency[3]); |
fefe921a9784
Use DDS4 for shifting Sr beatnote frequency to 10 kHz
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
216
diff
changeset
|
1351 logmsg("recenter Sr beatnote (ch3) to 10 kHz: DDS4 adjustment=%+3e", adj); |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1352 } |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1353 |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1354 recenter.t0 = utc; |
139 | 1355 rollmean_zero(&rollmean_ch2); |
1356 rollmean_zero(&rollmean_ch3); | |
1357 rollmean_zero(&rollmean_ch4); | |
52
30146cc6cd77
Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
51
diff
changeset
|
1358 } |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1359 } |
158
9154291658ef
Simplify DDS frequency juggling in N measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
156
diff
changeset
|
1360 |
91
4102fe614df2
Fix timestamping. Cleanup data providers
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
89
diff
changeset
|
1361 // local time |
4102fe614df2
Fix timestamping. Cleanup data providers
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
89
diff
changeset
|
1362 struct tm *ltime = localtime(&event.time.tv_sec); |
4102fe614df2
Fix timestamping. Cleanup data providers
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
89
diff
changeset
|
1363 // round to milliseconds |
4102fe614df2
Fix timestamping. Cleanup data providers
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
89
diff
changeset
|
1364 int msec = round(event.time.tv_usec / 1000.0); |
4102fe614df2
Fix timestamping. Cleanup data providers
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
89
diff
changeset
|
1365 while (msec >= 1000) { |
4102fe614df2
Fix timestamping. Cleanup data providers
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
89
diff
changeset
|
1366 ltime->tm_sec += 1; |
4102fe614df2
Fix timestamping. Cleanup data providers
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
89
diff
changeset
|
1367 msec -= 1000; |
4102fe614df2
Fix timestamping. Cleanup data providers
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
89
diff
changeset
|
1368 } |
4102fe614df2
Fix timestamping. Cleanup data providers
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
89
diff
changeset
|
1369 // format local time |
4102fe614df2
Fix timestamping. Cleanup data providers
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
89
diff
changeset
|
1370 char timestr[24]; |
4102fe614df2
Fix timestamping. Cleanup data providers
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
89
diff
changeset
|
1371 int len = strftime(timestr, sizeof(timestr), "%d/%m/%Y %H:%M:%S", ltime); |
4102fe614df2
Fix timestamping. Cleanup data providers
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
89
diff
changeset
|
1372 snprintf(timestr + len, sizeof(timestr) - len, ".%03d", msec); |
4102fe614df2
Fix timestamping. Cleanup data providers
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
89
diff
changeset
|
1373 // display local time |
4102fe614df2
Fix timestamping. Cleanup data providers
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
89
diff
changeset
|
1374 SetCtrlVal(MainPanel, PANEL_TIME, timestr); |
88
9b7588cd4013
Move data acquisition into separate thread
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
87
diff
changeset
|
1375 |
91
4102fe614df2
Fix timestamping. Cleanup data providers
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
89
diff
changeset
|
1376 // run id derived from current local date in the form YYMMDD |
76
5e0c314528bf
Refactor data writing to disk. Implement dayly chunking to separate files
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
75
diff
changeset
|
1377 char id[7]; |
91
4102fe614df2
Fix timestamping. Cleanup data providers
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
89
diff
changeset
|
1378 strftime(id, sizeof(id), "%y%m%d", ltime); |
88
9b7588cd4013
Move data acquisition into separate thread
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
87
diff
changeset
|
1379 |
142
fd085d61e4ca
Rework data logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
140
diff
changeset
|
1380 // write datafiles |
fd085d61e4ca
Rework data logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
140
diff
changeset
|
1381 for (struct datafile *d = datafiles; d->data; d++) |
fd085d61e4ca
Rework data logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
140
diff
changeset
|
1382 datafile_append(d, id, timestr); |
119
f9fb17fb64cc
Add Sr frequency logging to disk and to Sr data logger
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
118
diff
changeset
|
1383 |
f9fb17fb64cc
Add Sr frequency logging to disk and to Sr data logger
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
118
diff
changeset
|
1384 // send Sr frequency (Math4) to Sr data logger |
169
97112b45b838
Get Sr data logger parameters from configuration file. Code reorganization.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
168
diff
changeset
|
1385 sr_datalogger_send(&datalogger, utc, Math4); |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1386 } |
0 | 1387 break; |
44
2e37910b28bc
Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
43
diff
changeset
|
1388 } |
0 | 1389 } |
1390 | |
1391 int CVICALLBACK CB_OnFreqPlot (int panel, int control, int event, | |
1392 void *callbackData, int eventData1, int eventData2) | |
1393 { | |
134
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
1394 switch (event) |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
1395 { |
0 | 1396 case EVENT_COMMIT: |
134
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
1397 for (struct plot *plot = plots; plot->data; plot++) { |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
1398 if (plot->control == control) |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
1399 plot_toggle(plot); |
0 | 1400 } |
1401 break; | |
52
30146cc6cd77
Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
51
diff
changeset
|
1402 } |
0 | 1403 return 0; |
1404 } | |
1405 | |
1406 int CVICALLBACK CB_OnAllanPlot (int panel, int control, int event, | |
1407 void *callbackData, int eventData1, int eventData2) | |
1408 { | |
1409 switch (event) | |
134
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
1410 { |
0 | 1411 case EVENT_COMMIT: |
134
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
1412 for (struct adev *adev = adevs; adev->data; adev++) { |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
1413 if (adev->control == control) |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
1414 adev_toggle(adev); |
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
1415 } |
0 | 1416 break; |
134
bd28161e5ac2
Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
133
diff
changeset
|
1417 } |
0 | 1418 return 0; |
1419 } | |
1420 | |
1421 int CVICALLBACK CB_ChangeDDSOut (int panel, int control, int event, | |
1422 void *callbackData, int eventData1, int eventData2) | |
1423 { | |
28
1e4ecf64b485
Remove references to unused DDSBes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
27
diff
changeset
|
1424 switch (event) { |
0 | 1425 case EVENT_COMMIT: |
136 | 1426 double frequency; |
28
1e4ecf64b485
Remove references to unused DDSBes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
27
diff
changeset
|
1427 GetCtrlVal(MainPanel, control, &frequency); |
1e4ecf64b485
Remove references to unused DDSBes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
27
diff
changeset
|
1428 switch (control) { |
1e4ecf64b485
Remove references to unused DDSBes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
27
diff
changeset
|
1429 case PANEL_DDS1: |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1430 ad9912_set_frequency_w(&ad9912, 0, frequency); |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1431 SetCtrlVal(MainPanel, PANEL_DDS1, ad9912.frequency[0]); |
28
1e4ecf64b485
Remove references to unused DDSBes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
27
diff
changeset
|
1432 break; |
1e4ecf64b485
Remove references to unused DDSBes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
27
diff
changeset
|
1433 case PANEL_DDS2: |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1434 ad9912_set_frequency_w(&ad9912, 1, frequency); |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1435 SetCtrlVal(MainPanel, PANEL_DDS2, ad9912.frequency[1]); |
28
1e4ecf64b485
Remove references to unused DDSBes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
27
diff
changeset
|
1436 break; |
1e4ecf64b485
Remove references to unused DDSBes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
27
diff
changeset
|
1437 case PANEL_DDS3: |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1438 ad9912_set_frequency_w(&ad9912, 2, frequency); |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1439 SetCtrlVal(MainPanel, PANEL_DDS3, ad9912.frequency[2]); |
28
1e4ecf64b485
Remove references to unused DDSBes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
27
diff
changeset
|
1440 break; |
1e4ecf64b485
Remove references to unused DDSBes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
27
diff
changeset
|
1441 case PANEL_DDS4: |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1442 ad9912_set_frequency_w(&ad9912, 3, frequency); |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1443 SetCtrlVal(MainPanel, PANEL_DDS4, ad9912.frequency[3]); |
28
1e4ecf64b485
Remove references to unused DDSBes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
27
diff
changeset
|
1444 break; |
1e4ecf64b485
Remove references to unused DDSBes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
27
diff
changeset
|
1445 } |
136 | 1446 break; |
28
1e4ecf64b485
Remove references to unused DDSBes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
27
diff
changeset
|
1447 } |
0 | 1448 return 0; |
1449 } | |
1450 | |
1451 int CVICALLBACK CB_ChangeDDSStep (int panel, int control, int event, | |
1452 void *callbackData, int eventData1, int eventData2) | |
1453 { | |
1454 switch (event) | |
136 | 1455 { |
0 | 1456 case EVENT_COMMIT: |
136 | 1457 double step; |
1458 GetCtrlVal(panel, control, &step); | |
1459 switch (control) | |
1460 { | |
1461 case PANEL_DDS1STEP: | |
1462 SetCtrlAttribute(panel, PANEL_DDS1, ATTR_INCR_VALUE, step); | |
1463 break; | |
1464 case PANEL_DDS2STEP: | |
1465 SetCtrlAttribute(panel, PANEL_DDS2, ATTR_INCR_VALUE, step); | |
1466 break; | |
1467 case PANEL_DDS3STEP: | |
1468 SetCtrlAttribute(panel, PANEL_DDS3, ATTR_INCR_VALUE, step); | |
1469 break; | |
1470 case PANEL_DDS4STEP: | |
1471 SetCtrlAttribute(panel, PANEL_DDS4, ATTR_INCR_VALUE, step); | |
1472 break; | |
1473 } | |
0 | 1474 break; |
136 | 1475 } |
0 | 1476 return 0; |
1477 } | |
1478 | |
1479 int CVICALLBACK CB_ChangeMath (int panel, int control, int event, | |
1480 void *callbackData, int eventData1, int eventData2) | |
1481 { | |
24
b838371c7a91
Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
23
diff
changeset
|
1482 int len; |
b838371c7a91
Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
23
diff
changeset
|
1483 char *string; |
0 | 1484 |
1485 switch (event) | |
1486 { | |
1487 case EVENT_COMMIT: | |
24
b838371c7a91
Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
23
diff
changeset
|
1488 GetCtrlAttribute(panel, control, ATTR_STRING_TEXT_LENGTH, &len); |
b838371c7a91
Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
23
diff
changeset
|
1489 string = (char *)malloc(sizeof(char) * (len + 1)); |
b838371c7a91
Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
23
diff
changeset
|
1490 GetCtrlVal(panel, control, string); |
b838371c7a91
Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
23
diff
changeset
|
1491 switch (control) { |
b838371c7a91
Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
23
diff
changeset
|
1492 case PANEL_MATHSTRING1: |
b838371c7a91
Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
23
diff
changeset
|
1493 mupSetExpr(MathParser1, string); |
b838371c7a91
Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
23
diff
changeset
|
1494 break; |
b838371c7a91
Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
23
diff
changeset
|
1495 case PANEL_MATHSTRING2: |
b838371c7a91
Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
23
diff
changeset
|
1496 mupSetExpr(MathParser2, string); |
b838371c7a91
Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
23
diff
changeset
|
1497 break; |
b838371c7a91
Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
23
diff
changeset
|
1498 case PANEL_MATHSTRING3: |
b838371c7a91
Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
23
diff
changeset
|
1499 mupSetExpr(MathParser3, string); |
b838371c7a91
Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
23
diff
changeset
|
1500 break; |
b838371c7a91
Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
23
diff
changeset
|
1501 case PANEL_MATHSTRING4: |
b838371c7a91
Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
23
diff
changeset
|
1502 mupSetExpr(MathParser4, string); |
b838371c7a91
Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
23
diff
changeset
|
1503 break; |
b838371c7a91
Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
23
diff
changeset
|
1504 case PANEL_MATHSTRING5: |
b838371c7a91
Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
23
diff
changeset
|
1505 mupSetExpr(MathParser5, string); |
b838371c7a91
Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
23
diff
changeset
|
1506 break; |
b838371c7a91
Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
23
diff
changeset
|
1507 } |
b838371c7a91
Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
23
diff
changeset
|
1508 free(string); |
0 | 1509 break; |
1510 } | |
1511 return 0; | |
1512 } | |
1513 | |
1514 int CVICALLBACK CB_ChangeN (int panel, int control, int event, | |
1515 void *callbackData, int eventData1, int eventData2) | |
1516 { | |
1517 switch (event) | |
136 | 1518 { |
0 | 1519 case EVENT_COMMIT: |
136 | 1520 switch (control) |
1521 { | |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1522 case PANEL_N1: |
136 | 1523 GetCtrlVal(panel, control, &N1); |
1524 break; | |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1525 case PANEL_N2: |
136 | 1526 GetCtrlVal(panel, control, &N2); |
1527 break; | |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1528 case PANEL_N3: |
136 | 1529 GetCtrlVal(panel, control, &N3); |
1530 break; | |
1531 } | |
0 | 1532 break; |
136 | 1533 } |
0 | 1534 return 0; |
1535 } | |
1536 | |
17
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1537 int CVICALLBACK CB_OnAcceptN (int panel, int control, int event, |
0 | 1538 void *callbackData, int eventData1, int eventData2) |
1539 { | |
160
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1540 int measure; |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1541 |
84
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1542 switch (event) { |
0 | 1543 case EVENT_COMMIT: |
160
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1544 GetPanelAttribute(panel, ATTR_CALLBACK_DATA, &measure); |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1545 switch (measure) { |
161
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
1546 case LO: |
162 | 1547 N1 = round(N_measured); |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1548 SetCtrlVal(MainPanel, PANEL_N1, N1); |
84
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1549 break; |
161
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
1550 case HG: |
162 | 1551 N2 = round(N_measured); |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1552 SetCtrlVal(MainPanel, PANEL_N2, N2); |
84
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1553 break; |
161
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
1554 case SR: |
162 | 1555 N3 = round(N_measured); |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1556 SetCtrlVal(MainPanel, PANEL_N3, N3); |
84
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1557 break; |
17
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1558 } |
0 | 1559 break; |
17
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1560 } |
0 | 1561 return 0; |
1562 } | |
1563 | |
1564 int CVICALLBACK CB_OnNCalculus (int panel, int control, int event, | |
1565 void *callbackData, int eventData1, int eventData2) | |
1566 { | |
84
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1567 int visible; |
0 | 1568 |
84
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1569 switch (event) { |
0 | 1570 case EVENT_COMMIT: |
84
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1571 switch (control) { |
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1572 case PANEL_N1CALCULUS: |
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1573 GetPanelAttribute(CalcNPanel, ATTR_VISIBLE, &visible); |
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1574 if (! visible) { |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1575 SetPanelAttribute(CalcNPanel, ATTR_CALLBACK_DATA, LO); |
158
9154291658ef
Simplify DDS frequency juggling in N measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
156
diff
changeset
|
1576 SetPanelAttribute(CalcNPanel, ATTR_TITLE, "Measure N_Lo"); |
84
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1577 SetCtrlVal(CalcNPanel, CALCN_INTEGRATIONTIME, DeltaT_1); |
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1578 SetCtrlVal(CalcNPanel, CALCN_SLOPETIME, SlopeTime1); |
159 | 1579 SetCtrlVal(CalcNPanel, CALCN_DELTAFREQ, delta_f_lock_1 / 1000.0); |
132
fbd72d87b4dc
Support graceful intrerruption of N3 measurement. Minor user interface fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
130
diff
changeset
|
1580 SetCtrlVal(CalcNPanel, CALCN_N, 0.0); |
84
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1581 DisplayPanel(CalcNPanel); |
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1582 } |
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1583 break; |
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1584 case PANEL_N2CALCULUS: |
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1585 GetPanelAttribute(CalcNPanel, ATTR_VISIBLE, &visible); |
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1586 if (! visible) { |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1587 SetPanelAttribute(CalcNPanel, ATTR_CALLBACK_DATA, HG); |
158
9154291658ef
Simplify DDS frequency juggling in N measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
156
diff
changeset
|
1588 SetPanelAttribute(CalcNPanel, ATTR_TITLE, "Measure N_Hg"); |
84
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1589 SetCtrlVal(CalcNPanel, CALCN_INTEGRATIONTIME, DeltaT_2); |
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1590 SetCtrlVal(CalcNPanel, CALCN_SLOPETIME, SlopeTime2); |
159 | 1591 SetCtrlVal(CalcNPanel, CALCN_DELTAFREQ, delta_f_lock_2 / 1000.0); |
132
fbd72d87b4dc
Support graceful intrerruption of N3 measurement. Minor user interface fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
130
diff
changeset
|
1592 SetCtrlVal(CalcNPanel, CALCN_N, 0.0); |
84
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1593 DisplayPanel(CalcNPanel); |
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1594 } |
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1595 break; |
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1596 case PANEL_N3CALCULUS: |
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1597 GetPanelAttribute(CalcNPanel, ATTR_VISIBLE, &visible); |
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1598 if (! visible) { |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1599 SetPanelAttribute(CalcNPanel, ATTR_CALLBACK_DATA, SR); |
158
9154291658ef
Simplify DDS frequency juggling in N measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
156
diff
changeset
|
1600 SetPanelAttribute(CalcNPanel, ATTR_TITLE, "Measure N_Sr"); |
84
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1601 SetCtrlVal(CalcNPanel, CALCN_INTEGRATIONTIME, DeltaT_3); |
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1602 SetCtrlVal(CalcNPanel, CALCN_SLOPETIME, SlopeTime3); |
159 | 1603 SetCtrlVal(CalcNPanel, CALCN_DELTAFREQ, delta_f_lock_3 / 1000.0); |
132
fbd72d87b4dc
Support graceful intrerruption of N3 measurement. Minor user interface fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
130
diff
changeset
|
1604 SetCtrlVal(CalcNPanel, CALCN_N, 0.0); |
84
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1605 DisplayPanel(CalcNPanel); |
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1606 } |
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1607 break; |
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1608 } |
0 | 1609 break; |
84
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1610 } |
0 | 1611 return 0; |
1612 } | |
1613 | |
1614 int CVICALLBACK CB_OnStartNCalculus (int panel, int control, int event, | |
1615 void *callbackData, int eventData1, int eventData2) | |
1616 { | |
160
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1617 int measuring; |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1618 |
84
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1619 switch (event) { |
0 | 1620 case EVENT_COMMIT: |
160
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1621 GetPanelAttribute(panel, ATTR_CALLBACK_DATA, &measuring); |
84
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1622 switch (measuring) { |
161
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
1623 case LO: |
84
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1624 GetCtrlVal(CalcNPanel, CALCN_INTEGRATIONTIME, &DeltaT_1); |
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1625 GetCtrlVal(CalcNPanel, CALCN_SLOPETIME, &SlopeTime1); |
159 | 1626 GetCtrlVal(CalcNPanel, CALCN_DELTAFREQ, &delta_f_lock_1); |
1627 // convert from kHz to Hz | |
1628 delta_f_lock_1 = delta_f_lock_1 * 1000.0; | |
84
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1629 Measuring_1 = TRUE; |
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1630 break; |
161
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
1631 case HG: |
84
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1632 GetCtrlVal(CalcNPanel, CALCN_INTEGRATIONTIME, &DeltaT_2); |
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1633 GetCtrlVal(CalcNPanel, CALCN_SLOPETIME, &SlopeTime2); |
159 | 1634 GetCtrlVal(CalcNPanel, CALCN_DELTAFREQ, &delta_f_lock_2); |
1635 // convert from kHz to Hz | |
1636 delta_f_lock_2 = delta_f_lock_2 * 1000.0; | |
84
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1637 Measuring_2 = TRUE; |
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1638 break; |
161
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
1639 case SR: |
84
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1640 GetCtrlVal(CalcNPanel, CALCN_INTEGRATIONTIME, &DeltaT_3); |
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1641 GetCtrlVal(CalcNPanel, CALCN_SLOPETIME, &SlopeTime3); |
159 | 1642 GetCtrlVal(CalcNPanel, CALCN_DELTAFREQ, &delta_f_lock_3); |
1643 // convert from kHz to Hz | |
1644 delta_f_lock_3 = delta_f_lock_3 * 1000.0; | |
84
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1645 Measuring_3 = TRUE; |
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1646 break; |
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1647 } |
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1648 break; |
17
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1649 } |
0 | 1650 return 0; |
1651 } | |
1652 | |
1653 int CVICALLBACK CB_OnNStop (int panel, int control, int event, | |
1654 void *callbackData, int eventData1, int eventData2) | |
1655 { | |
160
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1656 int measuring; |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1657 |
17
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1658 switch (event) { |
0 | 1659 case EVENT_COMMIT: |
84
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1660 HidePanel(CalcNPanel); |
160
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1661 GetPanelAttribute(panel, ATTR_CALLBACK_DATA, &measuring); |
84
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1662 switch (measuring) { |
161
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
1663 case LO: |
84
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1664 Measuring_1 = FALSE; |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1665 ad9912_ramp_frequency_w(&ad9912, 0, f0_DDS1, FREP_STEP_SIZE); |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1666 ad9912_set_frequency_w(&ad9912, 1, f0_DDS2); |
84
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1667 break; |
161
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
1668 case HG: |
84
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1669 Measuring_2 = FALSE; |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1670 ad9912_ramp_frequency_w(&ad9912, 0, f0_DDS1, FREP_STEP_SIZE); |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1671 ad9912_set_frequency_w(&ad9912, 1, f0_DDS2); |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1672 ad9912_set_frequency_w(&ad9912, 2, f0_DDS3); |
84
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1673 break; |
161
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
1674 case SR: |
84
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1675 Measuring_3 = FALSE; |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1676 ad9912_ramp_frequency_w(&ad9912, 0, f0_DDS1, FREP_STEP_SIZE); |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1677 ad9912_set_frequency_w(&ad9912, 1, f0_DDS2); |
217
fefe921a9784
Use DDS4 for shifting Sr beatnote frequency to 10 kHz
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
216
diff
changeset
|
1678 ad9912_set_frequency_w(&ad9912, 3, f0_DDS4); |
84
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1679 break; |
0 | 1680 } |
158
9154291658ef
Simplify DDS frequency juggling in N measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
156
diff
changeset
|
1681 |
9154291658ef
Simplify DDS frequency juggling in N measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
156
diff
changeset
|
1682 // update DDS frequencies display |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1683 SetCtrlVal(MainPanel, PANEL_DDS1, ad9912.frequency[0]); |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1684 SetCtrlVal(MainPanel, PANEL_DDS2, ad9912.frequency[1]); |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1685 SetCtrlVal(MainPanel, PANEL_DDS3, ad9912.frequency[2]); |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1686 SetCtrlVal(MainPanel, PANEL_DDS4, ad9912.frequency[3]); |
158
9154291658ef
Simplify DDS frequency juggling in N measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
156
diff
changeset
|
1687 |
0 | 1688 break; |
17
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1689 } |
0 | 1690 return 0; |
1691 } | |
1692 | |
1693 int CVICALLBACK CB_OnFindSign (int panel, int control, int event, | |
17
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1694 void *callbackData, int eventData1, int eventData2) |
0 | 1695 { |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1696 switch (event) |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1697 { |
0 | 1698 case EVENT_COMMIT: |
17
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1699 switch (control) |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1700 { |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1701 case PANEL_FINDSIGN1: |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1702 tbegin1 = utc; |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1703 Frepbefore1 = Math1; |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1704 GetCtrlVal(MainPanel, PANEL_DDS1, &Frequency1) ; |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1705 SetCtrlVal(MainPanel, PANEL_DDS1, Frequency1+Frequencystep1) ; |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1706 ad9912_set_frequency_w(&ad9912, 0, Frequency1+Frequencystep1); |
17
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1707 Getsign1 = TRUE; |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1708 break; |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1709 case PANEL_FINDSIGN2: |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1710 tbegin2 = utc; |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1711 Frepbefore2 = Math1; |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1712 Ch2before = Ch2; |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1713 GetCtrlVal(MainPanel, PANEL_DDS1, &Frequency2) ; |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1714 SetCtrlVal(MainPanel, PANEL_DDS1, Frequency2+Frequencystep2) ; |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1715 ad9912_set_frequency_w(&ad9912, 0, Frequency2+Frequencystep2); |
17
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1716 Getsign2 = TRUE; |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1717 break; |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1718 case PANEL_FINDSIGN3: |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1719 tbegin3 = utc; |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1720 Frepbefore3 = Math1; |
205
31093786d41d
Fix Sr beatnote sign detection
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
199
diff
changeset
|
1721 GetCtrlVal(MainPanel, PANEL_DDS1, &Frequency3) ; |
31093786d41d
Fix Sr beatnote sign detection
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
199
diff
changeset
|
1722 SetCtrlVal(MainPanel, PANEL_DDS1, Frequency3+Frequencystep3) ; |
31093786d41d
Fix Sr beatnote sign detection
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
199
diff
changeset
|
1723 ad9912_set_frequency_w(&ad9912, 0, Frequency3+Frequencystep3); |
17
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1724 Getsign3 = TRUE; |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1725 break; |
0 | 1726 } |
1727 break; | |
17
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1728 } |
0 | 1729 return 0; |
17
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1730 } |
0 | 1731 |
217
fefe921a9784
Use DDS4 for shifting Sr beatnote frequency to 10 kHz
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
216
diff
changeset
|
1732 int CVICALLBACK CB_AdjustDDSFreq (int panel, int control, int event, |
0 | 1733 void *callbackData, int eventData1, int eventData2) |
42 | 1734 { |
1735 double frequency; | |
0 | 1736 switch (event) |
42 | 1737 { |
0 | 1738 case EVENT_COMMIT: |
42 | 1739 switch (control) |
1740 { | |
217
fefe921a9784
Use DDS4 for shifting Sr beatnote frequency to 10 kHz
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
216
diff
changeset
|
1741 case PANEL_ADJUST_DDS2: |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1742 frequency = ad9912.frequency[1] + 275000 - Ch4; |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1743 ad9912_set_frequency_w(&ad9912, 1, frequency); |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1744 SetCtrlVal(MainPanel, PANEL_DDS2, ad9912.frequency[1]); |
42 | 1745 break; |
217
fefe921a9784
Use DDS4 for shifting Sr beatnote frequency to 10 kHz
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
216
diff
changeset
|
1746 case PANEL_ADJUST_DDS3: |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1747 frequency = ad9912.frequency[2] + 10000 - Ch2; |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1748 ad9912_set_frequency_w(&ad9912, 2, frequency); |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1749 SetCtrlVal(MainPanel, PANEL_DDS3, ad9912.frequency[2]); |
42 | 1750 break; |
217
fefe921a9784
Use DDS4 for shifting Sr beatnote frequency to 10 kHz
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
216
diff
changeset
|
1751 case PANEL_ADJUST_DDS4: |
fefe921a9784
Use DDS4 for shifting Sr beatnote frequency to 10 kHz
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
216
diff
changeset
|
1752 frequency = ad9912.frequency[3] + 10000 - Ch3; |
fefe921a9784
Use DDS4 for shifting Sr beatnote frequency to 10 kHz
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
216
diff
changeset
|
1753 ad9912_set_frequency_w(&ad9912, 3, frequency); |
fefe921a9784
Use DDS4 for shifting Sr beatnote frequency to 10 kHz
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
216
diff
changeset
|
1754 SetCtrlVal(MainPanel, PANEL_DDS4, ad9912.frequency[3]); |
fefe921a9784
Use DDS4 for shifting Sr beatnote frequency to 10 kHz
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
216
diff
changeset
|
1755 break; |
42 | 1756 } |
1757 break; | |
1758 } | |
0 | 1759 return 0; |
42 | 1760 } |
0 | 1761 |
144 | 1762 int CVICALLBACK CB_OnChangeNdiv (int panel, int control, int event, |
0 | 1763 void *callbackData, int eventData1, int eventData2) |
1764 { | |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1765 switch (event) |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1766 { |
0 | 1767 case EVENT_COMMIT: |
84
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1768 GetCtrlVal(MainPanel, PANEL_CHANGENDIV, &Ndiv); |
158
9154291658ef
Simplify DDS frequency juggling in N measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
156
diff
changeset
|
1769 f0_DDS1 = 880000000.0 / Ndiv; |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1770 ad9912_set_frequency_w(&ad9912, 0, f0_DDS1); |
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1771 SetCtrlVal(MainPanel, PANEL_DDS1, ad9912.frequency[0]); |
0 | 1772 break; |
84
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
1773 } |
0 | 1774 return 0; |
1775 } | |
1776 | |
144 | 1777 int CVICALLBACK CB_MeasureSlope (int panel, int control, int event, |
0 | 1778 void *callbackData, int eventData1, int eventData2) |
1779 { | |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1780 switch (event) |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1781 { |
0 | 1782 case EVENT_COMMIT: |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1783 GetCtrlVal(panel, control, &dedrift.enabled); |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1784 if (dedrift.enabled) { |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1785 dedrift.t0 = utc; |
73
1dfaf5ef0352
Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
70
diff
changeset
|
1786 stat_zero(&freq); |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1787 logmsg("dedrift start"); |
33 | 1788 } else { |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1789 if (! dedrift.keep_slope) { |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1790 dedrift.applied = 0.0; |
209
11a88d389705
Adapt to new AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
205
diff
changeset
|
1791 ad9956_set_sweep_rate_w(&ad9956, dedrift.applied); |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1792 SetCtrlVal(MainPanel, PANEL_SLOPE_APPLIED, dedrift.applied); |
70
a945f2b7bef6
Fix slope measurement again
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
69
diff
changeset
|
1793 } |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1794 if (! dedrift.keep_freq) { |
209
11a88d389705
Adapt to new AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
205
diff
changeset
|
1795 ad9956_set_w(&ad9956, dedrift.freq0, dedrift.applied); |
70
a945f2b7bef6
Fix slope measurement again
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
69
diff
changeset
|
1796 } |
73
1dfaf5ef0352
Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
70
diff
changeset
|
1797 stat_zero(&freq); |
1dfaf5ef0352
Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
70
diff
changeset
|
1798 SetCtrlVal(panel, PANEL_SLOPE_MEASURED, freq.slope); |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1799 logmsg("dedrift stop"); |
33 | 1800 } |
0 | 1801 break; |
33 | 1802 } |
0 | 1803 return 0; |
1804 } | |
1805 | |
14
783407954cdf
Minor code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
10
diff
changeset
|
1806 int CVICALLBACK CB_OnResetSlope (int panel, int control, int event, |
783407954cdf
Minor code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
10
diff
changeset
|
1807 void *callbackData, int eventData1, int eventData2) |
0 | 1808 { |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1809 switch (event) |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1810 { |
0 | 1811 case EVENT_COMMIT: |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1812 dedrift.applied = 0.0; |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1813 SetCtrlVal(panel, PANEL_SLOPE_APPLIED, dedrift.applied); |
209
11a88d389705
Adapt to new AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
205
diff
changeset
|
1814 ad9956_set_w(&ad9956, dedrift.freq0, dedrift.applied); |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1815 logmsg("dedrift reset"); |
0 | 1816 break; |
14
783407954cdf
Minor code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
10
diff
changeset
|
1817 } |
0 | 1818 return 0; |
1819 } | |
1820 | |
14
783407954cdf
Minor code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
10
diff
changeset
|
1821 int CVICALLBACK CB_ChangeSlopeTime (int panel, int control, int event, |
783407954cdf
Minor code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
10
diff
changeset
|
1822 void *callbackData, int eventData1, int eventData2) |
0 | 1823 { |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1824 switch (event) |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1825 { |
0 | 1826 case EVENT_COMMIT: |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1827 GetCtrlVal(MainPanel, PANEL_SLOPETIME, &dedrift.interval); |
0 | 1828 break; |
14
783407954cdf
Minor code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
10
diff
changeset
|
1829 } |
0 | 1830 return 0; |
1831 } | |
1832 | |
1833 int CVICALLBACK CB_OnCROX (int panel, int control, int event, | |
1834 void *callbackData, int eventData1, int eventData2) | |
1835 { | |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1836 switch (event) |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1837 { |
0 | 1838 case EVENT_COMMIT: |
34
1e4b8ba97faf
Cleanup code handling dedrifing options
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
33
diff
changeset
|
1839 switch (control) { |
1e4b8ba97faf
Cleanup code handling dedrifing options
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
33
diff
changeset
|
1840 case PANEL_CHECKBOX_KEEP: |
1e4b8ba97faf
Cleanup code handling dedrifing options
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
33
diff
changeset
|
1841 // keep current dedrifting frequency when dedrifting is disabled |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1842 GetCtrlVal(MainPanel, PANEL_CHECKBOX_KEEP, &dedrift.keep_freq); |
34
1e4b8ba97faf
Cleanup code handling dedrifing options
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
33
diff
changeset
|
1843 break; |
1e4b8ba97faf
Cleanup code handling dedrifing options
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
33
diff
changeset
|
1844 case PANEL_CHECKBOX_KEEPSLOPE: |
1e4b8ba97faf
Cleanup code handling dedrifing options
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
33
diff
changeset
|
1845 // keep current dedrifting slope when dedrifting is disabled |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1846 GetCtrlVal(MainPanel, PANEL_CHECKBOX_KEEPSLOPE, &dedrift.keep_slope); |
34
1e4b8ba97faf
Cleanup code handling dedrifing options
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
33
diff
changeset
|
1847 break; |
0 | 1848 } |
1849 break; | |
34
1e4b8ba97faf
Cleanup code handling dedrifing options
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
33
diff
changeset
|
1850 } |
0 | 1851 return 0; |
1852 } | |
1853 | |
139 | 1854 int CVICALLBACK CB_RecenterEnable (int panel, int control, int event, |
0 | 1855 void *callbackData, int eventData1, int eventData2) |
1856 { | |
1857 switch (event) | |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1858 { |
0 | 1859 case EVENT_COMMIT: |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1860 GetCtrlVal(panel, control, &recenter.enabled); |
136 | 1861 recenter.t0 = utc; |
139 | 1862 rollmean_zero(&rollmean_ch2); |
1863 rollmean_zero(&rollmean_ch3); | |
1864 rollmean_zero(&rollmean_ch4); | |
0 | 1865 break; |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1866 } |
0 | 1867 return 0; |
1868 } | |
1869 | |
56
6e73fb3d94fa
Simplyfy slope measurement code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
55
diff
changeset
|
1870 int CVICALLBACK CB_OnStopSlopeCancellingOnUnlocked (int panel, int control, int event, |
0 | 1871 void *callbackData, int eventData1, int eventData2) |
1872 { | |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1873 int value; |
0 | 1874 switch (event) |
20
3a7f088d4960
Get rid of unused variables. Some minor coding style improvements
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
17
diff
changeset
|
1875 { |
0 | 1876 case EVENT_COMMIT: |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1877 GetCtrlVal(MainPanel, PANEL_CHECKBOX_STOPIFAUTODE, &value); |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1878 dedrift.threshold = value ? 100.0 : 0.0; |
20
3a7f088d4960
Get rid of unused variables. Some minor coding style improvements
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
17
diff
changeset
|
1879 break; |
3a7f088d4960
Get rid of unused variables. Some minor coding style improvements
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
17
diff
changeset
|
1880 } |
0 | 1881 return 0; |
1882 } | |
2
bd7501b65f56
Implement reference selection (microwave or Hg cavity) for slope cancelling
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
1
diff
changeset
|
1883 |
17
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1884 int CVICALLBACK CB_OnSlopeReference (int panel, int control, int event, |
2
bd7501b65f56
Implement reference selection (microwave or Hg cavity) for slope cancelling
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
1
diff
changeset
|
1885 void *callbackData, int eventData1, int eventData2) |
bd7501b65f56
Implement reference selection (microwave or Hg cavity) for slope cancelling
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
1
diff
changeset
|
1886 { |
bd7501b65f56
Implement reference selection (microwave or Hg cavity) for slope cancelling
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
1
diff
changeset
|
1887 switch (event) |
bd7501b65f56
Implement reference selection (microwave or Hg cavity) for slope cancelling
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
1
diff
changeset
|
1888 { |
bd7501b65f56
Implement reference selection (microwave or Hg cavity) for slope cancelling
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
1
diff
changeset
|
1889 case EVENT_COMMIT: |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1890 GetCtrlVal(MainPanel, PANEL_SLOPE_REFERENCE, &dedrift.reference); |
2
bd7501b65f56
Implement reference selection (microwave or Hg cavity) for slope cancelling
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
1
diff
changeset
|
1891 break; |
bd7501b65f56
Implement reference selection (microwave or Hg cavity) for slope cancelling
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
1
diff
changeset
|
1892 } |
bd7501b65f56
Implement reference selection (microwave or Hg cavity) for slope cancelling
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
1
diff
changeset
|
1893 return 0; |
bd7501b65f56
Implement reference selection (microwave or Hg cavity) for slope cancelling
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
1
diff
changeset
|
1894 } |
17
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1895 |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1896 int CVICALLBACK CB_OnEstimateN (int panel, int control, int event, |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1897 void *callbackData, int eventData1, int eventData2) |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1898 { |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1899 int visible; |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1900 |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1901 switch (event) |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1902 { |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1903 case EVENT_COMMIT: |
160
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1904 // reset N estimate |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1905 SetCtrlVal(EstimateNPanel, ESTIMATEN_N, 0.0); |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1906 // set current frep |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1907 SetCtrlVal(EstimateNPanel, ESTIMATEN_FREP, 250e6 + Math1); |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1908 switch (control) { |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1909 case PANEL_ESTIMATE_N2: |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1910 SetCtrlVal(EstimateNPanel, ESTIMATEN_WAVELENGTH, HG_WAVELENGTH); |
178
03dcca7e5ba4
Fix N estimate interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
174
diff
changeset
|
1911 SetPanelAttribute(EstimateNPanel, ATTR_TITLE, "Estimate N_Hg"); |
03dcca7e5ba4
Fix N estimate interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
174
diff
changeset
|
1912 SetPanelAttribute(EstimateNPanel, ATTR_CALLBACK_DATA, HG); |
160
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1913 break; |
17
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1914 case PANEL_ESTIMATE_N3: |
160
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1915 SetCtrlVal(EstimateNPanel, ESTIMATEN_WAVELENGTH, SR_WAVELENGTH); |
178
03dcca7e5ba4
Fix N estimate interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
174
diff
changeset
|
1916 SetPanelAttribute(EstimateNPanel, ATTR_TITLE, "Estimate N_Sr"); |
03dcca7e5ba4
Fix N estimate interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
174
diff
changeset
|
1917 SetPanelAttribute(EstimateNPanel, ATTR_CALLBACK_DATA, SR); |
17
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1918 break; |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1919 } |
178
03dcca7e5ba4
Fix N estimate interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
174
diff
changeset
|
1920 GetPanelAttribute(EstimateNPanel, ATTR_VISIBLE , &visible); |
03dcca7e5ba4
Fix N estimate interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
174
diff
changeset
|
1921 if (! visible) |
03dcca7e5ba4
Fix N estimate interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
174
diff
changeset
|
1922 DisplayPanel(EstimateNPanel); |
17
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1923 break; |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1924 } |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1925 return 0; |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1926 } |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1927 |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1928 int CVICALLBACK CB_OnNEstimateCancel (int panel, int control, int event, |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1929 void *callbackData, int eventData1, int eventData2) |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1930 { |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1931 int visible; |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1932 |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1933 switch (event) |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1934 { |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1935 case EVENT_COMMIT: |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1936 GetPanelAttribute(panel, ATTR_VISIBLE, &visible); |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1937 if (visible) |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1938 HidePanel(panel); |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1939 break; |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1940 } |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1941 return 0; |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1942 } |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1943 |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1944 int CVICALLBACK CB_OnNEstimateSet (int panel, int control, int event, |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1945 void *callbackData, int eventData1, int eventData2) |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1946 { |
160
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1947 int estimate; |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1948 |
17
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1949 switch (event) |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1950 { |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1951 case EVENT_COMMIT: |
160
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1952 GetPanelAttribute(panel, ATTR_CALLBACK_DATA, &estimate); |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1953 switch (estimate) { |
161
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
1954 case HG: |
160
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1955 GetCtrlVal(panel, ESTIMATEN_N, &N2); |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1956 SetCtrlVal(MainPanel, PANEL_N2, N2); |
160
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1957 break; |
161
6ee23cb3d6bb
Coding style fixes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
160
diff
changeset
|
1958 case SR: |
160
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1959 GetCtrlVal(panel, ESTIMATEN_N, &N3); |
196
87dae6d62a61
New AD9912 client code to communicate with improved server code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
187
diff
changeset
|
1960 SetCtrlVal(MainPanel, PANEL_N3, N3); |
160
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1961 break; |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1962 } |
17
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1963 HidePanel(panel); |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1964 break; |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1965 } |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1966 return 0; |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1967 } |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1968 |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1969 int CVICALLBACK CB_OnNEstimate (int panel, int control, int event, |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1970 void *callbackData, int eventData1, int eventData2) |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1971 { |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1972 double frep, wl, N; |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1973 |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1974 switch (event) |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1975 { |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1976 case EVENT_COMMIT: |
160
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1977 GetCtrlVal(panel, ESTIMATEN_FREP, &frep); |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1978 GetCtrlVal(panel, ESTIMATEN_WAVELENGTH, &wl); |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1979 N = round(SPEED_OF_LIGHT / wl / 1e-9 / frep); |
f609fb29536b
Simplification and code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
159
diff
changeset
|
1980 SetCtrlVal(panel, ESTIMATEN_N, N); |
17
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1981 break; |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1982 } |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1983 return 0; |
9cadd12e7722
Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
14
diff
changeset
|
1984 } |
30
56095062acd4
Allow manual setting of frequency dedrifting rate
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
29
diff
changeset
|
1985 |
56095062acd4
Allow manual setting of frequency dedrifting rate
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
29
diff
changeset
|
1986 int CVICALLBACK CB_SetSlope (int panel, int control, int event, |
56095062acd4
Allow manual setting of frequency dedrifting rate
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
29
diff
changeset
|
1987 void *callbackData, int eventData1, int eventData2) |
56095062acd4
Allow manual setting of frequency dedrifting rate
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
29
diff
changeset
|
1988 { |
56095062acd4
Allow manual setting of frequency dedrifting rate
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
29
diff
changeset
|
1989 switch (event) |
56095062acd4
Allow manual setting of frequency dedrifting rate
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
29
diff
changeset
|
1990 { |
56095062acd4
Allow manual setting of frequency dedrifting rate
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
29
diff
changeset
|
1991 case EVENT_COMMIT: |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
1992 GetCtrlVal(panel, control, &dedrift.applied); |
209
11a88d389705
Adapt to new AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
205
diff
changeset
|
1993 ad9956_set_sweep_rate_w(&ad9956, dedrift.applied); |
30
56095062acd4
Allow manual setting of frequency dedrifting rate
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
29
diff
changeset
|
1994 break; |
56095062acd4
Allow manual setting of frequency dedrifting rate
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
29
diff
changeset
|
1995 } |
56095062acd4
Allow manual setting of frequency dedrifting rate
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
29
diff
changeset
|
1996 return 0; |
56095062acd4
Allow manual setting of frequency dedrifting rate
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
29
diff
changeset
|
1997 } |
39
2e1b3148d6e6
Add setting to invert the sign of the measured slope on dedrifting
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
37
diff
changeset
|
1998 |
2e1b3148d6e6
Add setting to invert the sign of the measured slope on dedrifting
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
37
diff
changeset
|
1999 int CVICALLBACK CB_InvertSlopeSign (int panel, int control, int event, |
2e1b3148d6e6
Add setting to invert the sign of the measured slope on dedrifting
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
37
diff
changeset
|
2000 void *callbackData, int eventData1, int eventData2) |
2e1b3148d6e6
Add setting to invert the sign of the measured slope on dedrifting
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
37
diff
changeset
|
2001 { |
2e1b3148d6e6
Add setting to invert the sign of the measured slope on dedrifting
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
37
diff
changeset
|
2002 switch (event) |
2e1b3148d6e6
Add setting to invert the sign of the measured slope on dedrifting
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
37
diff
changeset
|
2003 { |
2e1b3148d6e6
Add setting to invert the sign of the measured slope on dedrifting
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
37
diff
changeset
|
2004 case EVENT_COMMIT: |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
2005 GetCtrlVal(panel, control, &dedrift.invert); |
39
2e1b3148d6e6
Add setting to invert the sign of the measured slope on dedrifting
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
37
diff
changeset
|
2006 break; |
2e1b3148d6e6
Add setting to invert the sign of the measured slope on dedrifting
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
37
diff
changeset
|
2007 } |
2e1b3148d6e6
Add setting to invert the sign of the measured slope on dedrifting
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
37
diff
changeset
|
2008 return 0; |
2e1b3148d6e6
Add setting to invert the sign of the measured slope on dedrifting
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
37
diff
changeset
|
2009 } |
48
70980f27e1a4
Simplify dedrifting interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
47
diff
changeset
|
2010 |
80
46fe62febcd0
Add dedrifting DDS reset functionality
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
79
diff
changeset
|
2011 int CVICALLBACK CB_ResetDedriftDDS (int panel, int control, int event, |
46fe62febcd0
Add dedrifting DDS reset functionality
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
79
diff
changeset
|
2012 void *callbackData, int eventData1, int eventData2) |
46fe62febcd0
Add dedrifting DDS reset functionality
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
79
diff
changeset
|
2013 { |
46fe62febcd0
Add dedrifting DDS reset functionality
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
79
diff
changeset
|
2014 switch (event) |
46fe62febcd0
Add dedrifting DDS reset functionality
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
79
diff
changeset
|
2015 { |
46fe62febcd0
Add dedrifting DDS reset functionality
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
79
diff
changeset
|
2016 case EVENT_COMMIT: |
46fe62febcd0
Add dedrifting DDS reset functionality
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
79
diff
changeset
|
2017 // stop slope measurement and reset slope |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
2018 dedrift.enabled = FALSE; |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
2019 SetCtrlVal(panel, PANEL_MEASURE_SLOPE, 0); |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
2020 dedrift.applied = 0.0; |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
2021 SetCtrlVal(panel, PANEL_SLOPE_APPLIED, dedrift.applied); |
80
46fe62febcd0
Add dedrifting DDS reset functionality
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
79
diff
changeset
|
2022 // reset DDS |
209
11a88d389705
Adapt to new AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
205
diff
changeset
|
2023 ad9956_set_w(&ad9956, dedrift.freq0, dedrift.applied); |
80
46fe62febcd0
Add dedrifting DDS reset functionality
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
79
diff
changeset
|
2024 break; |
46fe62febcd0
Add dedrifting DDS reset functionality
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
79
diff
changeset
|
2025 } |
46fe62febcd0
Add dedrifting DDS reset functionality
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
79
diff
changeset
|
2026 return 0; |
46fe62febcd0
Add dedrifting DDS reset functionality
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
79
diff
changeset
|
2027 } |
46fe62febcd0
Add dedrifting DDS reset functionality
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
79
diff
changeset
|
2028 |
84
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
2029 int CVICALLBACK CB_ShowLog (int panel, int control, int event, |
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
2030 void *callbackData, int eventData1, int eventData2) |
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
2031 { |
122
bdd3ec3c212e
Improve user interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
121
diff
changeset
|
2032 int visible; |
84
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
2033 switch (event) |
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
2034 { |
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
2035 case EVENT_COMMIT: |
199
111610d871af
Show error state in main user inteface panel
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
198
diff
changeset
|
2036 GetCtrlVal(panel, control, &visible); |
169
97112b45b838
Get Sr data logger parameters from configuration file. Code reorganization.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
168
diff
changeset
|
2037 logger_panel_visible(visible); |
84
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
2038 break; |
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
2039 } |
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
2040 return 0; |
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
2041 } |
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
2042 |
199
111610d871af
Show error state in main user inteface panel
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
198
diff
changeset
|
2043 int CVICALLBACK CB_ShowError (int panel, int control, int event, |
111610d871af
Show error state in main user inteface panel
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
198
diff
changeset
|
2044 void *callbackData, int eventData1, int eventData2) |
111610d871af
Show error state in main user inteface panel
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
198
diff
changeset
|
2045 { |
111610d871af
Show error state in main user inteface panel
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
198
diff
changeset
|
2046 switch (event) |
111610d871af
Show error state in main user inteface panel
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
198
diff
changeset
|
2047 { |
111610d871af
Show error state in main user inteface panel
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
198
diff
changeset
|
2048 case EVENT_COMMIT: |
111610d871af
Show error state in main user inteface panel
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
198
diff
changeset
|
2049 logger_panel_visible(TRUE); |
111610d871af
Show error state in main user inteface panel
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
198
diff
changeset
|
2050 SetCtrlVal(panel, control, FALSE); |
111610d871af
Show error state in main user inteface panel
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
198
diff
changeset
|
2051 SetCtrlVal(panel, PANEL_SHOWLOG, TRUE); |
111610d871af
Show error state in main user inteface panel
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
198
diff
changeset
|
2052 break; |
111610d871af
Show error state in main user inteface panel
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
198
diff
changeset
|
2053 } |
111610d871af
Show error state in main user inteface panel
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
198
diff
changeset
|
2054 return 0; |
111610d871af
Show error state in main user inteface panel
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
198
diff
changeset
|
2055 } |
111610d871af
Show error state in main user inteface panel
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
198
diff
changeset
|
2056 |
84
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
2057 int CVICALLBACK CB_OnLoggingPanelEvent(int panel, int event, |
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
2058 void *callbackData, int eventData1, int eventData2) |
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
2059 { |
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
2060 switch (event) |
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
2061 { |
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
2062 case EVENT_CLOSE: |
169
97112b45b838
Get Sr data logger parameters from configuration file. Code reorganization.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
168
diff
changeset
|
2063 logger_panel_visible(0); |
122
bdd3ec3c212e
Improve user interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
121
diff
changeset
|
2064 SetCtrlVal(MainPanel, PANEL_SHOWLOG, 0); |
84
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
2065 break; |
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
2066 } |
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
2067 return 0; |
c03263186dd7
Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
82
diff
changeset
|
2068 } |
109
2a9f8a811d87
Fix N3 measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
105
diff
changeset
|
2069 |
198
5cac684eb12e
Fix manual beatnote sign setting
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
196
diff
changeset
|
2070 int CVICALLBACK CB_BeatnoteSign (int panel, int control, int event, |
109
2a9f8a811d87
Fix N3 measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
105
diff
changeset
|
2071 void *callbackData, int eventData1, int eventData2) |
2a9f8a811d87
Fix N3 measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
105
diff
changeset
|
2072 { |
2a9f8a811d87
Fix N3 measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
105
diff
changeset
|
2073 switch (event) |
2a9f8a811d87
Fix N3 measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
105
diff
changeset
|
2074 { |
2a9f8a811d87
Fix N3 measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
105
diff
changeset
|
2075 case EVENT_COMMIT: |
198
5cac684eb12e
Fix manual beatnote sign setting
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
196
diff
changeset
|
2076 switch(control) { |
5cac684eb12e
Fix manual beatnote sign setting
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
196
diff
changeset
|
2077 case PANEL_SIGN1: |
5cac684eb12e
Fix manual beatnote sign setting
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
196
diff
changeset
|
2078 GetCtrlVal(panel, control, &Sign1); |
5cac684eb12e
Fix manual beatnote sign setting
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
196
diff
changeset
|
2079 break; |
5cac684eb12e
Fix manual beatnote sign setting
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
196
diff
changeset
|
2080 case PANEL_SIGN2: |
5cac684eb12e
Fix manual beatnote sign setting
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
196
diff
changeset
|
2081 GetCtrlVal(panel, control, &Sign2); |
5cac684eb12e
Fix manual beatnote sign setting
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
196
diff
changeset
|
2082 break; |
5cac684eb12e
Fix manual beatnote sign setting
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
196
diff
changeset
|
2083 case PANEL_SIGN3: |
5cac684eb12e
Fix manual beatnote sign setting
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
196
diff
changeset
|
2084 GetCtrlVal(panel, control, &Sign3); |
5cac684eb12e
Fix manual beatnote sign setting
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
196
diff
changeset
|
2085 break; |
5cac684eb12e
Fix manual beatnote sign setting
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
196
diff
changeset
|
2086 } |
109
2a9f8a811d87
Fix N3 measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
105
diff
changeset
|
2087 break; |
2a9f8a811d87
Fix N3 measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
105
diff
changeset
|
2088 } |
2a9f8a811d87
Fix N3 measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
105
diff
changeset
|
2089 return 0; |
2a9f8a811d87
Fix N3 measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
105
diff
changeset
|
2090 } |
123
35861fe64d14
Allow to set dedrift DDS central frequency. Add option to double applied slope.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
122
diff
changeset
|
2091 |
35861fe64d14
Allow to set dedrift DDS central frequency. Add option to double applied slope.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
122
diff
changeset
|
2092 int CVICALLBACK CB_SlopeX2 (int panel, int control, int event, |
35861fe64d14
Allow to set dedrift DDS central frequency. Add option to double applied slope.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
122
diff
changeset
|
2093 void *callbackData, int eventData1, int eventData2) |
35861fe64d14
Allow to set dedrift DDS central frequency. Add option to double applied slope.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
122
diff
changeset
|
2094 { |
35861fe64d14
Allow to set dedrift DDS central frequency. Add option to double applied slope.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
122
diff
changeset
|
2095 switch (event) |
35861fe64d14
Allow to set dedrift DDS central frequency. Add option to double applied slope.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
122
diff
changeset
|
2096 { |
35861fe64d14
Allow to set dedrift DDS central frequency. Add option to double applied slope.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
122
diff
changeset
|
2097 case EVENT_COMMIT: |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
2098 GetCtrlVal(panel, control, &dedrift.doubleslope); |
123
35861fe64d14
Allow to set dedrift DDS central frequency. Add option to double applied slope.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
122
diff
changeset
|
2099 break; |
35861fe64d14
Allow to set dedrift DDS central frequency. Add option to double applied slope.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
122
diff
changeset
|
2100 } |
35861fe64d14
Allow to set dedrift DDS central frequency. Add option to double applied slope.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
122
diff
changeset
|
2101 return 0; |
35861fe64d14
Allow to set dedrift DDS central frequency. Add option to double applied slope.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
122
diff
changeset
|
2102 } |
35861fe64d14
Allow to set dedrift DDS central frequency. Add option to double applied slope.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
122
diff
changeset
|
2103 |
142
fd085d61e4ca
Rework data logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
140
diff
changeset
|
2104 int CVICALLBACK CB_SaveData (int panel, int control, int event, |
fd085d61e4ca
Rework data logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
140
diff
changeset
|
2105 void *callbackData, int eventData1, int eventData2) |
fd085d61e4ca
Rework data logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
140
diff
changeset
|
2106 { |
fd085d61e4ca
Rework data logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
140
diff
changeset
|
2107 switch (event) |
fd085d61e4ca
Rework data logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
140
diff
changeset
|
2108 { |
fd085d61e4ca
Rework data logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
140
diff
changeset
|
2109 case EVENT_COMMIT: |
fd085d61e4ca
Rework data logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
140
diff
changeset
|
2110 for (struct datafile *d = datafiles; d->data; d++) { |
fd085d61e4ca
Rework data logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
140
diff
changeset
|
2111 if (d->control == control) |
fd085d61e4ca
Rework data logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
140
diff
changeset
|
2112 GetCtrlVal(panel, control, &(d->write)); |
fd085d61e4ca
Rework data logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
140
diff
changeset
|
2113 } |
fd085d61e4ca
Rework data logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
140
diff
changeset
|
2114 break; |
fd085d61e4ca
Rework data logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
140
diff
changeset
|
2115 } |
fd085d61e4ca
Rework data logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
140
diff
changeset
|
2116 return 0; |
fd085d61e4ca
Rework data logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
140
diff
changeset
|
2117 } |
fd085d61e4ca
Rework data logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
140
diff
changeset
|
2118 |
fd085d61e4ca
Rework data logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
140
diff
changeset
|
2119 |
139 | 2120 int CVICALLBACK CB_RecenterInterval (int panel, int control, int event, |
2121 void *callbackData, int eventData1, int eventData2) | |
2122 { | |
2123 switch (event) | |
2124 { | |
2125 case EVENT_COMMIT: | |
2126 GetCtrlVal(panel, control, &recenter.interval); | |
2127 break; | |
2128 } | |
2129 return 0; | |
2130 } | |
2131 | |
2132 int CVICALLBACK CB_RecenterChannel (int panel, int control, int event, | |
2133 void *callbackData, int eventData1, int eventData2) | |
2134 { | |
2135 switch (event) | |
2136 { | |
2137 case EVENT_COMMIT: | |
2138 switch (control) | |
2139 { | |
2140 case PANEL_RECENTER_LO: | |
144 | 2141 GetCtrlVal(panel, control, &recenter.lo); |
139 | 2142 break; |
2143 case PANEL_RECENTER_HG: | |
144 | 2144 GetCtrlVal(panel, control, &recenter.hg); |
139 | 2145 break; |
2146 case PANEL_RECENTER_SR: | |
144 | 2147 GetCtrlVal(panel, control, &recenter.sr); |
139 | 2148 break; |
2149 } | |
2150 break; | |
2151 } | |
2152 return 0; | |
2153 } | |
144 | 2154 |
2155 int CVICALLBACK CB_SrDatalogger (int panel, int control, int event, | |
2156 void *callbackData, int eventData1, int eventData2) | |
2157 { | |
2158 switch (event) | |
2159 { | |
2160 case EVENT_COMMIT: | |
169
97112b45b838
Get Sr data logger parameters from configuration file. Code reorganization.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
168
diff
changeset
|
2161 GetCtrlVal(panel, control, &datalogger.enabled); |
144 | 2162 break; |
2163 } | |
2164 return 0; | |
2165 } | |
217
fefe921a9784
Use DDS4 for shifting Sr beatnote frequency to 10 kHz
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
216
diff
changeset
|
2166 |
123
35861fe64d14
Allow to set dedrift DDS central frequency. Add option to double applied slope.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
122
diff
changeset
|
2167 int CVICALLBACK CB_DedriftDDSFreq (int panel, int control, int event, |
35861fe64d14
Allow to set dedrift DDS central frequency. Add option to double applied slope.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
122
diff
changeset
|
2168 void *callbackData, int eventData1, int eventData2) |
35861fe64d14
Allow to set dedrift DDS central frequency. Add option to double applied slope.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
122
diff
changeset
|
2169 { |
35861fe64d14
Allow to set dedrift DDS central frequency. Add option to double applied slope.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
122
diff
changeset
|
2170 switch (event) |
35861fe64d14
Allow to set dedrift DDS central frequency. Add option to double applied slope.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
122
diff
changeset
|
2171 { |
35861fe64d14
Allow to set dedrift DDS central frequency. Add option to double applied slope.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
122
diff
changeset
|
2172 case EVENT_COMMIT: |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
132
diff
changeset
|
2173 GetCtrlVal(panel, control, &dedrift.freq0); |
209
11a88d389705
Adapt to new AD9956 interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
205
diff
changeset
|
2174 ad9956_set_w(&ad9956, dedrift.freq0, dedrift.applied); |
123
35861fe64d14
Allow to set dedrift DDS central frequency. Add option to double applied slope.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
122
diff
changeset
|
2175 break; |
35861fe64d14
Allow to set dedrift DDS central frequency. Add option to double applied slope.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
122
diff
changeset
|
2176 } |
35861fe64d14
Allow to set dedrift DDS central frequency. Add option to double applied slope.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
122
diff
changeset
|
2177 return 0; |
35861fe64d14
Allow to set dedrift DDS central frequency. Add option to double applied slope.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
122
diff
changeset
|
2178 } |