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