annotate FXAnalyse.c @ 160:f609fb29536b

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