annotate FXAnalyse.c @ 228:5e69d9abbbf2

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