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