annotate FXAnalyse.c @ 239:ec81395bf08d

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