annotate FXAnalyse.c @ 209:11a88d389705

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