annotate FXAnalyse.c @ 84:c03263186dd7

Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
author Daniele Nicolodi <daniele.nicolodi@obspm.fr>
date Wed, 20 Mar 2013 16:36:36 +0100
parents 47860259afe2
children 6ac1d3de1ae2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1 #include <utility.h>
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
2 #include <ansi_c.h>
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
3 #include <cvirte.h>
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
4 #include <userint.h>
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
5 #include <formatio.h>
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
6 #include <string.h>
17
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
7 #include <future.h>
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
8
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
9 #include "YLCStuff.h"
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
10 #include "FXAnalyse.h"
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
11 #include "Plot.h"
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
12 #include "Allan.h"
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
13 #include "DDSBes.h"
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
14 #include "DDS4xAD9912.h"
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
15 #include "DDS_Fox.h"
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
16 #include "muParserDLL.h"
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
17
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
18 #define FXLINELENGTH 123
24
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
19 #define LOGFILEPATH "C:\\Femto\\Software\\FXQE80"
79
930acf691aa4 Update data logging folder to "z:\Measures-2013"
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 78
diff changeset
20 #define DATAFOLDER "Z:\\Measures-2013"
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
21
29
585c60175bd5 Cleanup AD9956 DDS parameters setting code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 28
diff changeset
22 #define DEDRIFT_DDS_FREQUENCY 70000000
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
23
37
5e81800fe354 Cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 35
diff changeset
24 // panel handling stuff
84
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
25 static PanelHandle MainPanel;
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
26 static PanelHandle CalcNPanel;
17
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
27 static PanelHandle EstimateN3Panel;
84
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
28 static PanelHandle LoggingPanel;
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
29
25
fde495ba28d2 Correct DDS3 frequency adjustement on N3 measurement. Cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 24
diff changeset
30 char LogFileName[MAX_PATHNAME_LEN];
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
31
24
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
32 double utc = 0;
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
33 double mjd = 0;
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
34
37
5e81800fe354 Cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 35
diff changeset
35 double Ch1, Ch2, Ch3, Ch4;
5e81800fe354 Cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 35
diff changeset
36 double Math1, Math2, Math3, Math4, Math5;
5e81800fe354 Cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 35
diff changeset
37 double N1, N2, N3, N4;
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
38
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
39 Plot_Data PlotCh1, PlotCh2, PlotCh3, PlotCh4, PlotMath1, PlotMath2, PlotMath3, PlotMath4, PlotMath5 ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
40 Allan_Data AllanCh1, AllanCh2, AllanCh3, AllanCh4, AllanMath1, AllanMath2, AllanMath3, AllanMath4, AllanMath5 ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
41
29
585c60175bd5 Cleanup AD9956 DDS parameters setting code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 28
diff changeset
42 // 1xAD9956 DDS box
585c60175bd5 Cleanup AD9956 DDS parameters setting code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 28
diff changeset
43 DDSParameter DDS1xAD9956;
585c60175bd5 Cleanup AD9956 DDS parameters setting code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 28
diff changeset
44 // 4xAD9912 DDS box
585c60175bd5 Cleanup AD9956 DDS parameters setting code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 28
diff changeset
45 DDS4xAD9912_Data DDS4xAD9912;
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
46
37
5e81800fe354 Cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 35
diff changeset
47 muParserHandle_t MathParser1, MathParser2, MathParser3, MathParser4, MathParser5;
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
48
37
5e81800fe354 Cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 35
diff changeset
49 int Acquiring = FALSE;
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
50
37
5e81800fe354 Cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 35
diff changeset
51 long OldLogFilePtr = 0;
5e81800fe354 Cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 35
diff changeset
52 double Ndiv = 8.0;
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
53
84
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
54 int settling = 0;
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
55
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
56 enum {
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
57 MEASURING_N_NONE,
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
58 MEASURING_N_Lo,
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
59 MEASURING_N_Hg,
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
60 MEASURING_N_Sr,
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
61 };
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
62
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
63 int measuring = MEASURING_N_NONE;
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
64
17
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
65 enum {
26
4bb197635664 Cleanup N1 measurement code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 25
diff changeset
66 N_MEASUREMENT_NONE,
4bb197635664 Cleanup N1 measurement code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 25
diff changeset
67 N_MEASUREMENT_INIT,
4bb197635664 Cleanup N1 measurement code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 25
diff changeset
68 N_MEASUREMENT_SLOPE,
4bb197635664 Cleanup N1 measurement code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 25
diff changeset
69 N_MEASUREMENT_ADJUST_FREQ_PLUS,
4bb197635664 Cleanup N1 measurement code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 25
diff changeset
70 N_MEASUREMENT_FREP_PLUS,
4bb197635664 Cleanup N1 measurement code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 25
diff changeset
71 N_MEASUREMENT_ADJUST_FREQ_MINUS,
4bb197635664 Cleanup N1 measurement code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 25
diff changeset
72 N_MEASUREMENT_FREP_MINUS,
4bb197635664 Cleanup N1 measurement code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 25
diff changeset
73 };
4bb197635664 Cleanup N1 measurement code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 25
diff changeset
74
84
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
75 int Measuring_1 = N_MEASUREMENT_NONE;
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
76 int Measuring_2 = N_MEASUREMENT_NONE;
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
77 int Measuring_3 = N_MEASUREMENT_NONE;
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
78
62
53dbce5f0745 Further simplification
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 61
diff changeset
79 double FrequDDS1=110000000.0, FrequDDS4=110000000.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
80 double Slope_1=0.0, Slope_2=0.0, Slope_3=0.0, Beatslope_2=0.0;
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
81 double SlopeTime1=40.0, SlopeTime2=40.0, SlopeTime3=40.0;
73
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
82 double Ch4Slope = 0.0;
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
83
17
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
84 double N_1=0.0, N_2=0.0, N_3=0.0;
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
85 double DeltaT_1=20.0, DeltakHz_1=500.0, t1_1=0.0, t2_1=0.0, t3_1=0.0, Frepplus_1=0.0, Frepminus_1=0.0;
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
86 double DeltaT_2=20.0, DeltakHz_2=500.0, t1_2=0.0, t2_2=0.0, t3_2=0.0, Frepplus_2=0.0, Frepminus_2=0.0;
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
87 double DeltaT_3=20.0, DeltakHz_3=500.0, t1_3=0.0, t2_3=0.0, t3_3=0.0, Frepplus_3=0.0, Frepminus_3=0.0;
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
88
24
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
89 int n_1=0, n_2=0, n_3=0;
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
90
61
37075b60408b Fix N2 measurement after cleanup. Further simplification
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 60
diff changeset
91 double FrequencyDDSBesInit = 0.0;
37075b60408b Fix N2 measurement after cleanup. Further simplification
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 60
diff changeset
92 double FrequencyDDS3Init = 0.0;
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
93
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
94 double DeltaDDS3=0.0,Delta10K_Plus=0.0,Delta10K_Minus=0.0;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
95 double Nu1=0.0, Nu2= 200000-147000+282143746.557455e6;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
96
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
97 double Step1=800000.0,Step2=800000.0;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
98
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
99 double Ch4Plus=0.0,Ch4Minus=0.0;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
100
17
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
101 double Frequencystep1=10000.0, tbegin1=0.0, Frepbefore1=0.0, Frequency1=0.0;
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
102 double Frequencystep2=10.0, tbegin2=0.0, Frepbefore2=0.0, Ch2before=0.0, Frequency2=0.0;
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
103 double Frequencystep3=100000.0, tbegin3=0.0, Frepbefore3=0.0, Frequency3=0.0;
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
104
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
105 volatile bool Getsign1=FALSE,Getsign2=FALSE,Getsign3=FALSE;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
106 double Signe1=1.0,Signe2=1.0,Signe3=0.0;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
107
37
5e81800fe354 Cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 35
diff changeset
108 // slope cancelling
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
109
37
5e81800fe354 Cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 35
diff changeset
110 int SlopeMeasuring = FALSE;
56
6e73fb3d94fa Simplyfy slope measurement code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 55
diff changeset
111 int StopSlopeCancellingOnUnlocked = TRUE;
37
5e81800fe354 Cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 35
diff changeset
112 double TimetoSlope = 60.0;
5e81800fe354 Cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 35
diff changeset
113 double SlopeMeasuringTimeBegin = 0.0;
73
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
114 double appliedSlope = 0.0; // currently applied frequency dedrifiting slope
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
115
24
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
116 double limitotakoff=70.0;
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
117
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
118 int ratio=10; //Recentre la frequence tous les ratios
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
119
37
5e81800fe354 Cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 35
diff changeset
120 int FrequCorrec = FALSE, KeepFrequ = TRUE, KeepSlope = TRUE;
5e81800fe354 Cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 35
diff changeset
121 int Nratio = -1;
1
a6fb5d3d0ec0 Indentation
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 0
diff changeset
122 double MoyMath2 = 0.0, CenterFrequencyCh2 = 0.0;
37
5e81800fe354 Cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 35
diff changeset
123 int CenterFrequencyCh2ToDetermine = FALSE;
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
124
2
bd7501b65f56 Implement reference selection (microwave or Hg cavity) for slope cancelling
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 1
diff changeset
125 enum {
bd7501b65f56 Implement reference selection (microwave or Hg cavity) for slope cancelling
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 1
diff changeset
126 SLOPE_REFERENCE_MICROWAVE = 0,
bd7501b65f56 Implement reference selection (microwave or Hg cavity) for slope cancelling
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 1
diff changeset
127 SLOPE_REFERENCE_HG_CAVITY = 1,
bd7501b65f56 Implement reference selection (microwave or Hg cavity) for slope cancelling
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 1
diff changeset
128 };
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
129
39
2e1b3148d6e6 Add setting to invert the sign of the measured slope on dedrifting
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 37
diff changeset
130 int invertSlopeSign = 0;
2
bd7501b65f56 Implement reference selection (microwave or Hg cavity) for slope cancelling
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 1
diff changeset
131 int slopeReference = SLOPE_REFERENCE_MICROWAVE;
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
132
52
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
133 int KeepCentering = FALSE;
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
134 double Timetorecenter275K = 3600.0 * 10;
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
135 double Timetorecenter10K = 3600.0 * 3;
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
136 double CenteringTimeBegin275K = 0.0;
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
137 double CenteringTimeBegin10K = 0.0;
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
138
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
139
73
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
140 struct stat {
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
141 int samples;
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
142 double mean;
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
143 double slope;
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
144 double previous;
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
145 };
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
146
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
147 void stat_zero(struct stat *s)
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
148 {
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
149 s->samples = 0;
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
150 s->mean = 0.0;
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
151 s->slope = 0.0;
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
152 s->previous = 0.0;
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
153 }
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
154
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
155 void stat_accumulate(struct stat *s, double value)
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
156 {
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
157 s->samples += 1;
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
158
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
159 if (s->samples > 1)
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
160 s->slope = (s->slope * (s->samples - 2) + 6 * (value - s->mean) / s->samples) / (s->samples + 1);
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
161
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
162 s->mean = ((s->samples - 1) * s->mean + value) / s->samples;
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
163
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
164 s->previous = value;
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
165 }
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
166
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
167 struct stat stat_math1, stat_ch2, stat_ch4, freq;
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
168
82
47860259afe2 Implement logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 80
diff changeset
169 #define MIN(x, y) (x) < (y) ? (x) : (y)
47860259afe2 Implement logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 80
diff changeset
170
47860259afe2 Implement logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 80
diff changeset
171 void logmsg(const char *frmt, ...)
47860259afe2 Implement logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 80
diff changeset
172 {
47860259afe2 Implement logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 80
diff changeset
173 char msg[1024];
47860259afe2 Implement logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 80
diff changeset
174 int len = 0;
47860259afe2 Implement logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 80
diff changeset
175
47860259afe2 Implement logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 80
diff changeset
176 // timestamp
47860259afe2 Implement logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 80
diff changeset
177 len += sprintf(msg, "%014.3f ", utc);
47860259afe2 Implement logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 80
diff changeset
178 time_t now = time(NULL);
47860259afe2 Implement logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 80
diff changeset
179 struct tm *t = localtime(&now);
47860259afe2 Implement logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 80
diff changeset
180 len += strftime(msg + len, sizeof(msg) - len, "%d-%m-%Y %H:%M:%S ", t);
47860259afe2 Implement logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 80
diff changeset
181
47860259afe2 Implement logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 80
diff changeset
182 // message
47860259afe2 Implement logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 80
diff changeset
183 va_list args;
47860259afe2 Implement logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 80
diff changeset
184 va_start(args, frmt);
47860259afe2 Implement logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 80
diff changeset
185 len += vsnprintf(msg + len, sizeof(msg) - len, frmt, args);
47860259afe2 Implement logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 80
diff changeset
186 va_end(args);
47860259afe2 Implement logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 80
diff changeset
187
47860259afe2 Implement logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 80
diff changeset
188 // add newline
47860259afe2 Implement logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 80
diff changeset
189 len = MIN(len, sizeof(msg) - 2);
47860259afe2 Implement logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 80
diff changeset
190 msg[len] = '\n';
47860259afe2 Implement logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 80
diff changeset
191 msg[len + 1] = '\0';
47860259afe2 Implement logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 80
diff changeset
192
47860259afe2 Implement logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 80
diff changeset
193 // display message
84
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
194 SetCtrlVal(LoggingPanel, LOGGING_LOGGING, msg);
82
47860259afe2 Implement logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 80
diff changeset
195 }
47860259afe2 Implement logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 80
diff changeset
196
73
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
197
52
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
198 muParserHandle_t initMathParser()
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
199 {
52
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
200 muParserHandle_t parser = mupCreate();
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
201 mupDefineOprtChars(parser, "abcdefghijklmnopqrstuvwxyzµ"
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
202 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
203 "+-*^/?<>=#!$%&|~'_");
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
204 mupDefineVar(parser, "UTC", &utc);
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
205 mupDefineVar(parser, "MJD", &mjd);
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
206 mupDefineVar(parser, "Ch1", &Ch1);
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
207 mupDefineVar(parser, "Ch2", &Ch2);
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
208 mupDefineVar(parser, "Ch3", &Ch3);
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
209 mupDefineVar(parser, "Ch4", &Ch4);
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
210 mupDefineVar(parser, "DDS1", &(DDS4xAD9912.Frequency1));
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
211 mupDefineVar(parser, "DDS2", &(DDS4xAD9912.Frequency2));
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
212 mupDefineVar(parser, "DDS3", &(DDS4xAD9912.Frequency3));
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
213 mupDefineVar(parser, "DDS4", &(DDS4xAD9912.Frequency4));
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
214 mupDefineVar(parser, "N1", &N1);
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
215 mupDefineVar(parser, "N2", &N2);
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
216 mupDefineVar(parser, "N3", &N3);
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
217 mupDefineVar(parser, "Nu1", &Nu1);
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
218 mupDefineVar(parser, "Nu2", &Nu2);
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
219 mupDefineVar(parser, "DeltaDDS3", &DeltaDDS3);
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
220 mupDefineVar(parser, "Signe1", &Signe1);
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
221 mupDefineVar(parser, "Signe2", &Signe2);
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
222 mupDefineVar(parser, "Ndiv", &Ndiv);
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
223 mupDefinePostfixOprt(parser, "P", &Peta, 1);
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
224 mupDefinePostfixOprt(parser, "T", &Tera, 1);
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
225 mupDefinePostfixOprt(parser, "G", &Giga, 1);
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
226 mupDefinePostfixOprt(parser, "M", &Mega, 1);
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
227 mupDefinePostfixOprt(parser, "k", &kilo, 1);
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
228 mupDefinePostfixOprt(parser, "m", &milli, 1);
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
229 mupDefinePostfixOprt(parser, "u", &micro, 1);
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
230 mupDefinePostfixOprt(parser, "µ", &micro, 1);
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
231 mupDefinePostfixOprt(parser, "n", &nano, 1);
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
232 mupDefinePostfixOprt(parser, "p", &pico, 1);
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
233 mupDefinePostfixOprt(parser, "f", &femto, 1);
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
234
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
235 return parser;
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
236 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
237
46
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
238
76
5e0c314528bf Refactor data writing to disk. Implement dayly chunking to separate files
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 75
diff changeset
239 void writeData(char *folder, char *name, char *id, char *date, char *time, double utc, double value)
5e0c314528bf Refactor data writing to disk. Implement dayly chunking to separate files
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 75
diff changeset
240 {
5e0c314528bf Refactor data writing to disk. Implement dayly chunking to separate files
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 75
diff changeset
241 char line[1024];
5e0c314528bf Refactor data writing to disk. Implement dayly chunking to separate files
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 75
diff changeset
242 char filename[FILENAME_MAX];
5e0c314528bf Refactor data writing to disk. Implement dayly chunking to separate files
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 75
diff changeset
243
5e0c314528bf Refactor data writing to disk. Implement dayly chunking to separate files
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 75
diff changeset
244 // construct filename in the form folder\\id-name.txt
5e0c314528bf Refactor data writing to disk. Implement dayly chunking to separate files
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 75
diff changeset
245 snprintf(filename, sizeof(filename), "%s\\%s-%s.txt", folder, id, name);
5e0c314528bf Refactor data writing to disk. Implement dayly chunking to separate files
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 75
diff changeset
246
78
3aa1f1c18961 Fix data logging to disc. Shorten file names
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 76
diff changeset
247 int fd = OpenFile(filename, VAL_WRITE_ONLY, VAL_APPEND, VAL_ASCII);
76
5e0c314528bf Refactor data writing to disk. Implement dayly chunking to separate files
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 75
diff changeset
248 Fmt(line, "%s\t%s\t%f[p3]\t%f[p3]", date, time, utc, value);
5e0c314528bf Refactor data writing to disk. Implement dayly chunking to separate files
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 75
diff changeset
249 WriteLine(fd, line, -1);
5e0c314528bf Refactor data writing to disk. Implement dayly chunking to separate files
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 75
diff changeset
250 CloseFile(fd);
5e0c314528bf Refactor data writing to disk. Implement dayly chunking to separate files
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 75
diff changeset
251 }
5e0c314528bf Refactor data writing to disk. Implement dayly chunking to separate files
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 75
diff changeset
252
5e0c314528bf Refactor data writing to disk. Implement dayly chunking to separate files
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 75
diff changeset
253
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
254 int main (int argc, char *argv[])
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
255 {
52
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
256 double frequency;
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
257 char expr[1024];
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
258
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
259 if (InitCVIRTE (0, argv, 0) == 0)
52
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
260 return -1;
78
3aa1f1c18961 Fix data logging to disc. Shorten file names
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 76
diff changeset
261
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
262 if ((MainPanel = LoadPanel (0, "FXAnalyse.uir", PANEL)) < 0)
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
263 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
264 if ((CalcNPanel = LoadPanel (MainPanel, "FXAnalyse.uir", CALCN)) < 0)
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
265 return -1;
17
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
266 if ((EstimateN3Panel = LoadPanel (MainPanel, "FXAnalyse.uir", ESTIMATEN3)) < 0)
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
267 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
268 if ((LoggingPanel = LoadPanel (0, "FXAnalyse.uir", LOGGING)) < 0)
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
269 return -1;
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
270
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
271 DisplayPanel (MainPanel);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
272
29
585c60175bd5 Cleanup AD9956 DDS parameters setting code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 28
diff changeset
273 // initialize 4x AD9959 DDS box
52
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
274 DDS4xAD9912_Reset(&DDS4xAD9912);
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
275 GetCtrlVal(MainPanel, PANEL_DDS1, &frequency);
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
276 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, frequency);
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
277 GetCtrlVal(MainPanel, PANEL_DDS2, &frequency);
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
278 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, frequency);
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
279 GetCtrlVal(MainPanel, PANEL_DDS3, &frequency);
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
280 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, frequency);
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
281 GetCtrlVal(MainPanel, PANEL_DDS4, &frequency);
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
282 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 4, frequency);
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
283
29
585c60175bd5 Cleanup AD9956 DDS parameters setting code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 28
diff changeset
284 // initialyze 1x AD9956 DDS box
69
94cb4b29bb47 Use cleaned up AD9956 DDS driver functionalities
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 67
diff changeset
285 DDSFox_Initialize(&DDS1xAD9956, "145.238.205.58", 6665, DEDRIFT_DDS_FREQUENCY);
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
286
52
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
287 Ch1 = Ch2 = Ch3 = Ch4 = 0.0;
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
288
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
289 GetCtrlVal(MainPanel, PANEL_N1CHOICE, &N1);
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
290 GetCtrlVal(MainPanel, PANEL_N2CHOICE, &N2);
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
291 GetCtrlVal(MainPanel, PANEL_N3CHOICE, &N3);
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
292
52
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
293 MathParser1 = initMathParser();
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
294 GetCtrlVal(MainPanel, PANEL_MATHSTRING1, expr);
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
295 mupSetExpr(MathParser1, expr);
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
296
52
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
297 MathParser2 = initMathParser();
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
298 mupDefineVar(MathParser2, "Math1", &Math1);
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
299 mupDefineVar(MathParser2, "DDS", &(DDS4xAD9912.Frequency1));
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
300 GetCtrlVal(MainPanel, PANEL_MATHSTRING2, expr);
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
301 mupSetExpr(MathParser2, expr);
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
302
52
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
303 MathParser3 = initMathParser();
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
304 mupDefineVar(MathParser3, "Math1", &Math1);
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
305 mupDefineVar(MathParser3, "Math2", &Math2);
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
306 mupDefineVar(MathParser3, "DDS", &(DDS4xAD9912.Frequency2));
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
307 GetCtrlVal(MainPanel, PANEL_MATHSTRING3, expr);
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
308 mupSetExpr(MathParser3, expr);
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
309
52
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
310 MathParser4 = initMathParser();
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
311 mupDefineVar(MathParser4, "Math1", &Math1);
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
312 mupDefineVar(MathParser4, "Math2", &Math2);
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
313 mupDefineVar(MathParser4, "Math3", &Math3);
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
314 GetCtrlVal(MainPanel, PANEL_MATHSTRING4, expr);
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
315 mupSetExpr(MathParser4, expr);
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
316
52
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
317 MathParser5 = initMathParser();
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
318 mupDefineVar(MathParser5, "Math1", &Math1);
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
319 mupDefineVar(MathParser5, "Math2", &Math2);
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
320 mupDefineVar(MathParser5, "Math3", &Math3);
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
321 mupDefineVar(MathParser5, "Math4", &Math4);
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
322 GetCtrlVal(MainPanel, PANEL_MATHSTRING5, expr);
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
323 mupSetExpr(MathParser5, expr);
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
324
52
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
325 RunUserInterface();
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
326
52
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
327 DiscardPanel(MainPanel);
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
328 return 0;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
329 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
330
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
331
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
332 void OnCloseViewPanel(int panel){
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
333
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
334 if (panel==PlotCh1.PlotPanel) { SetCtrlVal(MainPanel,PANEL_CHECKBOX_FREQ1PLOT, FALSE) ; } ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
335 if (panel==PlotCh2.PlotPanel) { SetCtrlVal(MainPanel,PANEL_CHECKBOX_FREQ2PLOT, FALSE) ; } ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
336 if (panel==PlotCh3.PlotPanel) { SetCtrlVal(MainPanel,PANEL_CHECKBOX_FREQ3PLOT, FALSE) ; } ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
337 if (panel==PlotCh4.PlotPanel) { SetCtrlVal(MainPanel,PANEL_CHECKBOX_FREQ4PLOT, FALSE) ; } ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
338 if (panel==PlotMath1.PlotPanel) { SetCtrlVal(MainPanel,PANEL_CHECKBOX_MATH1PLOT, FALSE) ; } ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
339 if (panel==PlotMath2.PlotPanel) { SetCtrlVal(MainPanel,PANEL_CHECKBOX_MATH2PLOT, FALSE) ; } ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
340 if (panel==PlotMath3.PlotPanel) { SetCtrlVal(MainPanel,PANEL_CHECKBOX_MATH3PLOT, FALSE) ; } ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
341 if (panel==PlotMath4.PlotPanel) { SetCtrlVal(MainPanel,PANEL_CHECKBOX_MATH4PLOT, FALSE) ; } ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
342 if (panel==PlotMath5.PlotPanel) { SetCtrlVal(MainPanel,PANEL_CHECKBOX_MATH5PLOT, FALSE) ; } ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
343
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
344 if (panel==AllanCh1.AllanPanel) { SetCtrlVal(MainPanel,PANEL_CHECKBOX_FREQ1ALLAN, FALSE) ; } ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
345 if (panel==AllanCh2.AllanPanel) { SetCtrlVal(MainPanel,PANEL_CHECKBOX_FREQ2ALLAN, FALSE) ; } ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
346 if (panel==AllanCh3.AllanPanel) { SetCtrlVal(MainPanel,PANEL_CHECKBOX_FREQ3ALLAN, FALSE) ; } ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
347 if (panel==AllanCh4.AllanPanel) { SetCtrlVal(MainPanel,PANEL_CHECKBOX_FREQ4ALLAN, FALSE) ; } ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
348 if (panel==AllanMath1.AllanPanel) { SetCtrlVal(MainPanel,PANEL_CHECKBOX_MATH1ALLAN, FALSE) ; } ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
349 if (panel==AllanMath2.AllanPanel) { SetCtrlVal(MainPanel,PANEL_CHECKBOX_MATH2ALLAN, FALSE) ; } ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
350 if (panel==AllanMath3.AllanPanel) { SetCtrlVal(MainPanel,PANEL_CHECKBOX_MATH3ALLAN, FALSE) ; } ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
351 if (panel==AllanMath4.AllanPanel) { SetCtrlVal(MainPanel,PANEL_CHECKBOX_MATH4ALLAN, FALSE) ; } ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
352 if (panel==AllanMath5.AllanPanel) { SetCtrlVal(MainPanel,PANEL_CHECKBOX_MATH5ALLAN, FALSE) ; } ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
353
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
354 return ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
355 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
356
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
357 int CVICALLBACK QuitCallback (int panel, int control, int event,
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
358 void *callbackData, int eventData1, int eventData2)
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
359 {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
360 switch (event)
40
50544ecfcfc7 Handle application quit just once
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 39
diff changeset
361 {
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
362 case EVENT_COMMIT:
52
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
363 QuitUserInterface(0);
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
364 mupRelease(MathParser1);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
365 mupRelease(MathParser2);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
366 mupRelease(MathParser3);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
367 mupRelease(MathParser4);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
368 mupRelease(MathParser5);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
369 break;
40
50544ecfcfc7 Handle application quit just once
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 39
diff changeset
370 }
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
371 return 0;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
372 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
373
84
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
374 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
375 void *callbackData, int eventData1, int eventData2)
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
376 {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
377 int ActiveControl ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
378 int StepIndex ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
379 double Step ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
380
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
381 switch (event) {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
382 case EVENT_KEYPRESS:
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
383 switch (eventData1) // ie the code of the key which has been stroke
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
384 {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
385 case VAL_RIGHT_ARROW_VKEY :
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
386 ActiveControl = GetActiveCtrl(panel);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
387 if (ActiveControl==PANEL_DDS1 || ActiveControl==PANEL_DDS1STEP) {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
388 GetCtrlIndex(MainPanel, PANEL_DDS1STEP, &StepIndex);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
389 if (StepIndex<14){
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
390 SetCtrlIndex(MainPanel, PANEL_DDS1STEP, ++StepIndex) ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
391 GetCtrlVal(MainPanel, PANEL_DDS1STEP, &Step);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
392 SetCtrlAttribute(MainPanel, PANEL_DDS1, ATTR_INCR_VALUE, Step) ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
393 };
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
394 };
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
395 if (ActiveControl==PANEL_DDS2 || ActiveControl==PANEL_DDS2STEP) {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
396 GetCtrlIndex(MainPanel, PANEL_DDS2STEP, &StepIndex);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
397 if (StepIndex<14){
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
398 SetCtrlIndex(MainPanel, PANEL_DDS2STEP, ++StepIndex) ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
399 GetCtrlVal(MainPanel, PANEL_DDS2STEP, &Step);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
400 SetCtrlAttribute(MainPanel, PANEL_DDS2, ATTR_INCR_VALUE, Step) ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
401 };
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
402 };
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
403 if (ActiveControl==PANEL_DDS3|| ActiveControl==PANEL_DDS3STEP) {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
404 GetCtrlIndex(MainPanel, PANEL_DDS3STEP, &StepIndex);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
405 if (StepIndex<14){
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
406 SetCtrlIndex(MainPanel, PANEL_DDS3STEP, ++StepIndex) ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
407 GetCtrlVal(MainPanel, PANEL_DDS3STEP, &Step);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
408 SetCtrlAttribute(MainPanel, PANEL_DDS3, ATTR_INCR_VALUE, Step) ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
409 };
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
410 };
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
411 if (ActiveControl==PANEL_DDS4|| ActiveControl==PANEL_DDS4STEP) {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
412 GetCtrlIndex(MainPanel, PANEL_DDS4STEP, &StepIndex);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
413 if (StepIndex<14){
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
414 SetCtrlIndex(MainPanel, PANEL_DDS4STEP, ++StepIndex) ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
415 GetCtrlVal(MainPanel, PANEL_DDS4STEP, &Step);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
416 SetCtrlAttribute(MainPanel, PANEL_DDS4, ATTR_INCR_VALUE, Step) ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
417 };
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
418 };
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
419 break;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
420 case VAL_LEFT_ARROW_VKEY :
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
421 ActiveControl = GetActiveCtrl(panel);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
422 if (ActiveControl==PANEL_DDS1 || ActiveControl==PANEL_DDS1STEP) {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
423 GetCtrlIndex(MainPanel, PANEL_DDS1STEP, &StepIndex);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
424 if (StepIndex>0){
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
425 SetCtrlIndex(MainPanel, PANEL_DDS1STEP, --StepIndex) ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
426 GetCtrlVal(MainPanel, PANEL_DDS1STEP, &Step);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
427 SetCtrlAttribute(MainPanel, PANEL_DDS1, ATTR_INCR_VALUE, Step) ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
428 };
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
429 };
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
430 if (ActiveControl==PANEL_DDS2 || ActiveControl==PANEL_DDS2STEP) {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
431 GetCtrlIndex(MainPanel, PANEL_DDS2STEP, &StepIndex);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
432 if (StepIndex>0){
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
433 SetCtrlIndex(MainPanel, PANEL_DDS2STEP, --StepIndex) ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
434 GetCtrlVal(MainPanel, PANEL_DDS2STEP, &Step);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
435 SetCtrlAttribute(MainPanel, PANEL_DDS2, ATTR_INCR_VALUE, Step) ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
436 };
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
437 };
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
438 if (ActiveControl==PANEL_DDS3 || ActiveControl==PANEL_DDS3STEP) {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
439 GetCtrlIndex(MainPanel, PANEL_DDS3STEP, &StepIndex);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
440 if (StepIndex>0){
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
441 SetCtrlIndex(MainPanel, PANEL_DDS3STEP, --StepIndex) ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
442 GetCtrlVal(MainPanel, PANEL_DDS3STEP, &Step);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
443 SetCtrlAttribute(MainPanel, PANEL_DDS3, ATTR_INCR_VALUE, Step) ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
444 };
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
445 };
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
446 if (ActiveControl==PANEL_DDS4 || ActiveControl==PANEL_DDS4STEP) {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
447 GetCtrlIndex(MainPanel, PANEL_DDS4STEP, &StepIndex);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
448 if (StepIndex>0){
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
449 SetCtrlIndex(MainPanel, PANEL_DDS4STEP, --StepIndex) ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
450 GetCtrlVal(MainPanel, PANEL_DDS4STEP, &Step);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
451 SetCtrlAttribute(MainPanel, PANEL_DDS4, ATTR_INCR_VALUE, Step) ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
452 };
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
453 };
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
454 break;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
455 case VAL_F2_VKEY :
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
456 SetActiveCtrl(MainPanel, PANEL_DDS1);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
457 break;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
458 case VAL_F3_VKEY :
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
459 SetActiveCtrl(MainPanel, PANEL_DDS2);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
460 break;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
461 case VAL_F4_VKEY :
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
462 SetActiveCtrl(MainPanel, PANEL_DDS3);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
463 break;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
464 case VAL_F5_VKEY :
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
465 SetActiveCtrl(MainPanel, PANEL_DDS4);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
466 break;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
467 };
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
468 break;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
469
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
470 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
471 return 0;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
472 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
473
25
fde495ba28d2 Correct DDS3 frequency adjustement on N3 measurement. Cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 24
diff changeset
474
fde495ba28d2 Correct DDS3 frequency adjustement on N3 measurement. Cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 24
diff changeset
475 void CurrentFileName(char *fname)
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
476 {
25
fde495ba28d2 Correct DDS3 frequency adjustement on N3 measurement. Cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 24
diff changeset
477 char day[3], month[3], year[3];
fde495ba28d2 Correct DDS3 frequency adjustement on N3 measurement. Cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 24
diff changeset
478 char *date = DateStr();
fde495ba28d2 Correct DDS3 frequency adjustement on N3 measurement. Cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 24
diff changeset
479 Scan(date, "%s>%s[w2]-%s[w2]-20%s[w2]", month, day, year);
fde495ba28d2 Correct DDS3 frequency adjustement on N3 measurement. Cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 24
diff changeset
480 Fmt(fname, "%s<%s\\%s%s%s_Frequ.txt", LOGFILEPATH, year, month, day);
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
481 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
482
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
483
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
484 int CVICALLBACK CB_OnStart (int panel, int control, int event,
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
485 void *callbackData, int eventData1, int eventData2)
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
486 {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
487 switch (event)
20
3a7f088d4960 Get rid of unused variables. Some minor coding style improvements
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 17
diff changeset
488 {
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
489 case EVENT_COMMIT:
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
490 if (Acquiring) {
20
3a7f088d4960 Get rid of unused variables. Some minor coding style improvements
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 17
diff changeset
491 PlotCh1.IndexPoint = 0;
3a7f088d4960 Get rid of unused variables. Some minor coding style improvements
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 17
diff changeset
492 PlotCh2.IndexPoint = 0;
3a7f088d4960 Get rid of unused variables. Some minor coding style improvements
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 17
diff changeset
493 PlotCh3.IndexPoint = 0;
3a7f088d4960 Get rid of unused variables. Some minor coding style improvements
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 17
diff changeset
494 PlotCh4.IndexPoint = 0;
3a7f088d4960 Get rid of unused variables. Some minor coding style improvements
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 17
diff changeset
495 PlotMath1.IndexPoint = 0;
3a7f088d4960 Get rid of unused variables. Some minor coding style improvements
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 17
diff changeset
496 PlotMath2.IndexPoint = 0;
3a7f088d4960 Get rid of unused variables. Some minor coding style improvements
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 17
diff changeset
497 PlotMath3.IndexPoint = 0;
3a7f088d4960 Get rid of unused variables. Some minor coding style improvements
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 17
diff changeset
498 PlotMath4.IndexPoint = 0;
3a7f088d4960 Get rid of unused variables. Some minor coding style improvements
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 17
diff changeset
499 PlotMath5.IndexPoint = 0;
3a7f088d4960 Get rid of unused variables. Some minor coding style improvements
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 17
diff changeset
500 Allan_Reset(&AllanCh1);
3a7f088d4960 Get rid of unused variables. Some minor coding style improvements
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 17
diff changeset
501 Allan_Reset(&AllanCh2);
3a7f088d4960 Get rid of unused variables. Some minor coding style improvements
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 17
diff changeset
502 Allan_Reset(&AllanCh3);
3a7f088d4960 Get rid of unused variables. Some minor coding style improvements
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 17
diff changeset
503 Allan_Reset(&AllanCh4);
3a7f088d4960 Get rid of unused variables. Some minor coding style improvements
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 17
diff changeset
504 Allan_Reset(&AllanMath1);
3a7f088d4960 Get rid of unused variables. Some minor coding style improvements
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 17
diff changeset
505 Allan_Reset(&AllanMath2);
3a7f088d4960 Get rid of unused variables. Some minor coding style improvements
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 17
diff changeset
506 Allan_Reset(&AllanMath3);
3a7f088d4960 Get rid of unused variables. Some minor coding style improvements
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 17
diff changeset
507 Allan_Reset(&AllanMath4);
3a7f088d4960 Get rid of unused variables. Some minor coding style improvements
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 17
diff changeset
508 Allan_Reset(&AllanMath5);
3a7f088d4960 Get rid of unused variables. Some minor coding style improvements
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 17
diff changeset
509 }
3a7f088d4960 Get rid of unused variables. Some minor coding style improvements
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 17
diff changeset
510 Acquiring = TRUE;
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
511 SetCtrlAttribute(MainPanel, PANEL_STARTBUTTON, ATTR_LABEL_TEXT, "__RESET");
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
512
25
fde495ba28d2 Correct DDS3 frequency adjustement on N3 measurement. Cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 24
diff changeset
513 CurrentFileName(LogFileName);
20
3a7f088d4960 Get rid of unused variables. Some minor coding style improvements
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 17
diff changeset
514 GetFileInfo(LogFileName, &OldLogFilePtr);
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
515 OldLogFilePtr -= OldLogFilePtr%FXLINELENGTH + FXLINELENGTH - 2;
82
47860259afe2 Implement logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 80
diff changeset
516
47860259afe2 Implement logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 80
diff changeset
517 logmsg("Start");
47860259afe2 Implement logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 80
diff changeset
518
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
519 break;
82
47860259afe2 Implement logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 80
diff changeset
520 }
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
521 return 0;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
522 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
523
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
524 int CVICALLBACK CB_OnStop (int panel, int control, int event,
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
525 void *callbackData, int eventData1, int eventData2)
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
526 {
52
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
527 switch (event) {
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
528 case EVENT_COMMIT:
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
529 Acquiring = FALSE ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
530 SetCtrlAttribute(MainPanel, PANEL_STARTBUTTON, ATTR_LABEL_TEXT, "__START");
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
531 break;
52
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
532 }
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
533 return 0;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
534 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
535
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
536 int CVICALLBACK CB_OnTimer (int panel, int control, int event,
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
537 void *callbackData, int eventData1, int eventData2)
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
538 {
76
5e0c314528bf Refactor data writing to disk. Implement dayly chunking to separate files
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 75
diff changeset
539 int LogFile;
20
3a7f088d4960 Get rid of unused variables. Some minor coding style improvements
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 17
diff changeset
540 long LogFileSize;
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
541 char LineBuffer[FXLINELENGTH+10] = "\r\n_1 ";
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
542
20
3a7f088d4960 Get rid of unused variables. Some minor coding style improvements
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 17
diff changeset
543 char TimeTag[] = "100103 000000.000"; // K+K time tag meaning here 2010 january the 3rd at 00:00:00.000
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
544 char Date[] = "03/01/2010" ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
545 char Time[] = "00:00:00.000" ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
546 char Year[] = "2010";
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
547 char ShortYear[] = "10"; // the last 2 digits of calendar year only
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
548 char Month[] = "01";
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
549 char Day[] = "03";
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
550 char Hour[] = "00";
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
551 char Min[] = "00" ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
552 char Sec[] = "00.000";
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
553 struct tm LocalTime ;
20
3a7f088d4960 Get rid of unused variables. Some minor coding style improvements
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 17
diff changeset
554 time_t utcTime;
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
555
20
3a7f088d4960 Get rid of unused variables. Some minor coding style improvements
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 17
diff changeset
556 int BoxChecked = FALSE;
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
557
56
6e73fb3d94fa Simplyfy slope measurement code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 55
diff changeset
558 switch (event) {
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
559 case EVENT_TIMER_TICK:
44
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
560 if (! Acquiring)
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
561 break;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
562
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
563 GetFileInfo(LogFileName, &LogFileSize);
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
564
44
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
565 if (LogFileSize > OldLogFilePtr+2*FXLINELENGTH-2) { // if a complete newline has been written
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
566
44
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
567 SuspendTimerCallbacks();
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
568
44
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
569 // Open Log file and get to the beginning of newly completed line
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
570 LogFile = OpenFile(LogFileName, VAL_READ_ONLY, VAL_OPEN_AS_IS, VAL_ASCII);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
571 OldLogFilePtr += FXLINELENGTH;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
572 SetFilePtr(LogFile, OldLogFilePtr, 0);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
573
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
574 // return the last complete string from the log file and scan it for date and time information
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
575
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
576 // first, the time tag, and store it in various formats
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
577 ReadFile(LogFile, TimeTag, 17);
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
578
44
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
579 CopyBytes(Date,0,TimeTag,4,2);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
580 CopyBytes(Date,3,TimeTag,2,2);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
581 CopyBytes(Date,8,TimeTag,0,2);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
582 CopyBytes(Time,0,TimeTag,7,2);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
583 CopyBytes(Time,3,TimeTag,9,2);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
584 CopyBytes(Time,6,TimeTag,11,6);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
585 SetCtrlVal(MainPanel, PANEL_DATE, Date);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
586 SetCtrlVal(MainPanel, PANEL_TIME, Time);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
587
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
588 CopyBytes(Year,2,TimeTag,0,2); // first 2 bytes of year string remains "20"
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
589 CopyBytes(ShortYear,0,TimeTag,0,2);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
590 CopyBytes(Month,0,TimeTag,2,2);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
591 CopyBytes(Day,0,TimeTag,4,2);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
592 CopyBytes(Hour,0,TimeTag,7,2);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
593 CopyBytes(Min,0,TimeTag,9,2);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
594 CopyBytes(Sec,0,TimeTag,11,6);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
595 Fmt(&LocalTime.tm_year, "%d<%s", Year);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
596 Fmt(&LocalTime.tm_mon, "%d<%s", Month);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
597 Fmt(&LocalTime.tm_mday, "%d<%s", Day);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
598 Fmt(&LocalTime.tm_hour, "%d<%s", Hour);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
599 Fmt(&LocalTime.tm_min, "%d<%s", Min);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
600 Fmt(&LocalTime.tm_sec, "%d<%s", "00"); // special case to handle non integer number of UTC seconds
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
601 LocalTime.tm_hour += 0;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
602 LocalTime.tm_min -= 0;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
603 LocalTime.tm_sec -= 0;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
604 LocalTime.tm_mon -= 1; // january is month 0 for tm struct
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
605 LocalTime.tm_year -= 1900; // year is number of years since 1900 for tm struct
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
606 LocalTime.tm_isdst = -1; // daylight saving flag MUST be set to -1 (unallocated is bugging and +1 is making 1 hour error in summer)
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
607 utcTime = mktime (&LocalTime);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
608 utc = (double) utcTime + strtod(Sec,NULL);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
609 mjd=utc/86400.; //nb de jours depuis l'origine d'UTC (01/01/1900 à 00h00 GMT)
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
610 mjd+=15020; //date MJD de la date origine d'UTC
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
611 SetCtrlVal(MainPanel, PANEL_UTC, utc);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
612 SetCtrlVal(MainPanel, PANEL_MJD, mjd);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
613
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
614 // scan the line for counters's channels information
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
615
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
616 ReadLine(LogFile, LineBuffer, FXLINELENGTH+9);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
617 CloseFile(LogFile);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
618
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
619 Scan(LineBuffer, "%f%f%f%f", &Ch1, &Ch2, &Ch3, &Ch4);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
620 Ch1 = 1000*Ch1;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
621 Ch2 = 1000*Ch2;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
622 Ch3 = 1000*Ch3;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
623 Ch4 = 1000*Ch4;
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
624
44
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
625 SetCtrlVal(MainPanel, PANEL_FREQ1, Ch1);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
626 SetCtrlVal(MainPanel, PANEL_FREQ2, Ch2);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
627 SetCtrlVal(MainPanel, PANEL_FREQ3, Ch3);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
628 SetCtrlVal(MainPanel, PANEL_FREQ4, Ch4);
54
73e23c879d6e Do not update beatnote sign indicators at each time tick
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 53
diff changeset
629
46
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
630 SetCtrlVal(MainPanel, PANEL_CENTERFREQUENCY, CenterFrequencyCh2);
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
631
44
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
632 // Treat data
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
633
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
634 Math1 = mupEval(MathParser1);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
635 SetCtrlVal(MainPanel,PANEL_MATH1, Math1);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
636
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
637 Math2 = mupEval(MathParser2);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
638 SetCtrlVal(MainPanel,PANEL_MATH2, Math2);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
639
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
640 Math3 = mupEval(MathParser3);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
641 SetCtrlVal(MainPanel,PANEL_MATH3, Math3);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
642
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
643 Math4 = mupEval(MathParser4);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
644 SetCtrlVal(MainPanel,PANEL_MATH4, Math4);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
645
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
646 Math5 = mupEval(MathParser5);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
647 SetCtrlVal(MainPanel,PANEL_MATH5, Math5);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
648
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
649 // Plot Data and calculus if required
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
650
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
651 GetCtrlVal(MainPanel, PANEL_CHECKBOX_FREQ1PLOT, &BoxChecked);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
652 if (BoxChecked) {
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
653 Plot_AddFrequency(&PlotCh1, Ch1);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
654 }
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
655 GetCtrlVal(MainPanel, PANEL_CHECKBOX_FREQ1ALLAN, &BoxChecked);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
656 if (BoxChecked) {
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
657 Allan_AddFrequency(&AllanCh1, Ch1);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
658 }
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
659
44
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
660 GetCtrlVal(MainPanel, PANEL_CHECKBOX_FREQ2PLOT, &BoxChecked);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
661 if (BoxChecked) {
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
662 Plot_AddFrequency(&PlotCh2, Ch2);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
663 }
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
664 GetCtrlVal(MainPanel, PANEL_CHECKBOX_FREQ2ALLAN, &BoxChecked);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
665 if (BoxChecked) {
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
666 Allan_AddFrequency(&AllanCh2, Ch2);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
667 }
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
668
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
669 GetCtrlVal(MainPanel, PANEL_CHECKBOX_FREQ3PLOT, &BoxChecked);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
670 if (BoxChecked) {
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
671 Plot_AddFrequency(&PlotCh3, Ch3);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
672 }
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
673 GetCtrlVal(MainPanel, PANEL_CHECKBOX_FREQ3ALLAN, &BoxChecked);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
674 if (BoxChecked) {
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
675 Allan_AddFrequency(&AllanCh3, Ch3);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
676 }
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
677
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
678 GetCtrlVal(MainPanel, PANEL_CHECKBOX_FREQ4PLOT, &BoxChecked);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
679 if (BoxChecked) {
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
680 Plot_AddFrequency(&PlotCh4, Ch4);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
681 }
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
682 GetCtrlVal(MainPanel, PANEL_CHECKBOX_FREQ4ALLAN, &BoxChecked);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
683 if (BoxChecked) {
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
684 Allan_AddFrequency(&AllanCh4, Ch4);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
685 }
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
686
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
687 GetCtrlVal(MainPanel, PANEL_CHECKBOX_MATH1PLOT, &BoxChecked);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
688 if (BoxChecked) {
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
689 Plot_AddFrequency(&PlotMath1, Math1);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
690 }
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
691 GetCtrlVal(MainPanel, PANEL_CHECKBOX_MATH1ALLAN, &BoxChecked);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
692 if (BoxChecked) {
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
693 Allan_AddFrequency(&AllanMath1, Math1);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
694 }
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
695
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
696 GetCtrlVal(MainPanel, PANEL_CHECKBOX_MATH2PLOT, &BoxChecked);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
697 if (BoxChecked) {
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
698 Plot_AddFrequency(&PlotMath2, Math2);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
699 }
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
700 GetCtrlVal(MainPanel, PANEL_CHECKBOX_MATH2ALLAN, &BoxChecked);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
701 if (BoxChecked) {
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
702 Allan_AddFrequency(&AllanMath2, Math2);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
703 }
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
704
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
705 GetCtrlVal(MainPanel, PANEL_CHECKBOX_MATH3PLOT, &BoxChecked);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
706 if (BoxChecked) {
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
707 Plot_AddFrequency(&PlotMath3, Math3);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
708 }
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
709 GetCtrlVal(MainPanel, PANEL_CHECKBOX_MATH3ALLAN, &BoxChecked);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
710 if (BoxChecked) {
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
711 Allan_AddFrequency(&AllanMath3, Math3);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
712 }
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
713
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
714 GetCtrlVal(MainPanel, PANEL_CHECKBOX_MATH4PLOT, &BoxChecked);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
715 if (BoxChecked) {
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
716 Plot_AddFrequency(&PlotMath4, Math4);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
717 }
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
718 GetCtrlVal(MainPanel, PANEL_CHECKBOX_MATH4ALLAN, &BoxChecked);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
719 if (BoxChecked) {
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
720 Allan_AddFrequency(&AllanMath4, Math4);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
721 }
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
722
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
723 GetCtrlVal(MainPanel, PANEL_CHECKBOX_MATH5PLOT, &BoxChecked);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
724 if (BoxChecked) {
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
725 Plot_AddFrequency(&PlotMath5, Math5);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
726 }
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
727 GetCtrlVal(MainPanel, PANEL_CHECKBOX_MATH5ALLAN, &BoxChecked);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
728 if (BoxChecked) {
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
729 Allan_AddFrequency(&AllanMath5, Math5);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
730 }
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
731
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
732 // Calcul de N
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
733
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
734 switch (Measuring_1) {
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
735
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
736 case N_MEASUREMENT_NONE:
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
737 // not measuring
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
738 break;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
739
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
740 case N_MEASUREMENT_INIT:
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
741 // initialization step
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
742
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
743 // set DDS1 to nominal frequency
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
744 SetCtrlVal(MainPanel, PANEL_DDS1, FrequDDS1);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
745 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, FrequDDS1);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
746
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
747 GetCtrlVal(MainPanel, PANEL_DDS2, &FrequencyDDSBesInit);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
748 t2_1 = t3_1 = 0.0;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
749 t1_1 = utc;
73
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
750
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
751 stat_zero(&stat_math1);
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
752 stat_zero(&stat_ch4);
44
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
753
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
754 // next step
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
755 Measuring_1 += 1;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
756 break;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
757
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
758 case N_MEASUREMENT_SLOPE:
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
759 // slope measurement
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
760
73
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
761 stat_accumulate(&stat_math1, Math1);
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
762 stat_accumulate(&stat_ch4, Ch4);
44
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
763
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
764 if ((utc - t1_1) > SlopeTime1) {
73
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
765 Slope_1 = stat_math1.slope;
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
766 Ch4Slope = stat_ch4.slope;
84
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
767 SetCtrlVal(CalcNPanel, CALCN_SLOPE, Slope_1);
44
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
768
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
769 // frep positive step
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
770 DDS4xAD9912_FrequencyRampe(&DDS4xAD9912,1, FrequDDS1,(FrequDDS1+DeltakHz_1*1000), Step1/Ndiv);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
771 SetCtrlVal(MainPanel, PANEL_DDS1, (FrequDDS1+DeltakHz_1*1000));
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
772 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, (FrequDDS1+DeltakHz_1*1000));
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
773
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
774 // allow counter to settle
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
775 settling = 3;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
776
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
777 // next step
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
778 Measuring_1 += 1;
46
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
779 }
44
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
780 break;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
781
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
782 case N_MEASUREMENT_ADJUST_FREQ_PLUS:
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
783 case N_MEASUREMENT_ADJUST_FREQ_MINUS:
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
784 // 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
785
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
786 if (settling > 0) {
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
787 settling--;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
788 break;
26
4bb197635664 Cleanup N1 measurement code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 25
diff changeset
789 }
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
790
44
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
791 double fDDS2;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
792 GetCtrlVal(MainPanel, PANEL_DDS2, &fDDS2);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
793 fDDS2 += 275000 - Ch4;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
794 SetCtrlVal(MainPanel, PANEL_DDS2, fDDS2);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
795 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, fDDS2);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
796
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
797 // allow counter to settle
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
798 settling = 3;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
799
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
800 // next step
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
801 Measuring_1 += 1;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
802 break;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
803
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
804 case N_MEASUREMENT_FREP_PLUS:
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
805 // frep positive step
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
806
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
807 if (settling > 0) {
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
808 settling--;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
809 break;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
810 }
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
811
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
812 if (t2_1 == 0.0)
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
813 t2_1 = utc;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
814
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
815 Frepplus_1 = Frepplus_1 + Math1 - Slope_1 * (utc - t2_1);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
816 Ch4Plus = Ch4Plus + Ch4 - Ch4Slope * (utc - t2_1);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
817 n_1 += 1;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
818
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
819 if ((utc - t2_1) > DeltaT_1) {
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
820 Frepplus_1 = Frepplus_1 / n_1;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
821 Ch4Plus = Ch4Plus / n_1;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
822 n_1 = 0;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
823
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
824 // frep negative step
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
825 DDS4xAD9912_FrequencyRampe(&DDS4xAD9912,1, (FrequDDS1+DeltakHz_1*1000),(FrequDDS1-DeltakHz_1*1000), Step1/Ndiv);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
826 SetCtrlVal(MainPanel, PANEL_DDS1, (FrequDDS1-DeltakHz_1*1000));
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
827 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, (FrequDDS1-DeltakHz_1*1000));
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
828
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
829 // allow counter to settle
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
830 settling = 3;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
831
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
832 // next step
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
833 Measuring_1 += 1;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
834 }
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
835 break;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
836
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
837 case N_MEASUREMENT_FREP_MINUS:
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
838 // frep negative step
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
839
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
840 if (settling > 0) {
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
841 settling--;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
842 break;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
843 }
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
844
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
845 if (t3_1 == 0.0)
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
846 t3_1 = utc;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
847
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
848 Frepminus_1 = Frepminus_1 + Math1 - Slope_1 * (utc - t3_1);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
849 Ch4Minus = Ch4Minus + Ch4 - Ch4Slope * (utc - t3_1);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
850 n_1 += 1;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
851
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
852 if ((utc - t3_1) > DeltaT_1) {
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
853 Frepminus_1 = Frepminus_1 / n_1;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
854 Ch4Minus = Ch4Minus / n_1;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
855 n_1 = 0;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
856
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
857 // compute N1
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
858 N_1 = Signe1 * (2*Ndiv * DeltakHz_1 * 1000)/(Frepminus_1 - Frepplus_1 - Slope_1 * (t3_1 - t2_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
859 SetCtrlVal(CalcNPanel, CALCN_N, N_1);
44
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
860
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
861 t1_1 = 0.0;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
862 t2_1 = 0.0;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
863 t3_1 = 0.0;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
864 Frepminus_1 = 0.0;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
865 Frepplus_1 = 0.0;
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
866
44
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
867 // back to nominal frep
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
868 DDS4xAD9912_FrequencyRampe(&DDS4xAD9912, 1, FrequDDS1-DeltakHz_1*1000,FrequDDS1, Step1/Ndiv );
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
869 SetCtrlVal(MainPanel, PANEL_DDS1, FrequDDS1);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
870 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, FrequDDS1);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
871 SetCtrlVal(MainPanel, PANEL_DDS2, FrequencyDDSBesInit);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
872 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, FrequencyDDSBesInit);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
873
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
874 // done
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
875 Measuring_1 = N_MEASUREMENT_NONE;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
876 }
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
877 break;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
878 }
46
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
879
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
880 switch (Measuring_2) {
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
881
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
882 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
883 // not measuring
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
884 break;
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
885
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
886 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
887 // initialization step
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
888
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
889 // set DDS1 to nominal frequency
44
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
890 SetCtrlVal(MainPanel, PANEL_DDS1, FrequDDS1);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
891 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, FrequDDS1);
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
892
44
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
893 GetCtrlVal(MainPanel, PANEL_DDS2, &FrequencyDDSBesInit);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
894 GetCtrlVal(MainPanel, PANEL_DDS3, &FrequencyDDS3Init);
46
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
895 t1_2 = utc;
73
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
896
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
897 stat_zero(&stat_math1);
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
898 stat_zero(&stat_ch2);
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
899
46
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
900 Nu1 = N1 * (250000000 + Math1);
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
901
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
902 // next step
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
903 Measuring_2 += 1;
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
904 break;
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
905
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
906 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
907 // slope measurement
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
908
73
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
909 stat_accumulate(&stat_math1, Math1);
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
910 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
911
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
912 if ((utc - t1_2) > SlopeTime2) {
73
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
913 Slope_2 = stat_math1.slope;
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
914 Beatslope_2 = stat_ch2.slope;
84
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
915 SetCtrlVal(CalcNPanel, CALCN_SLOPE, Beatslope_2);
46
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
916
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
917 // frep positive step
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
918 double fDDS1 = FrequDDS1 + DeltakHz_2 * 1000;
61
37075b60408b Fix N2 measurement after cleanup. Further simplification
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 60
diff changeset
919 printf("fDDS1 = %g\n", fDDS1);
46
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
920 DDS4xAD9912_FrequencyRampe(&DDS4xAD9912,1, FrequDDS1, fDDS1, Step2/Ndiv);
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
921 SetCtrlVal(MainPanel, PANEL_DDS1, fDDS1);
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
922 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, fDDS1);
62
53dbce5f0745 Further simplification
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 61
diff changeset
923
61
37075b60408b Fix N2 measurement after cleanup. Further simplification
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 60
diff changeset
924 // adjust DDS3 to keep beatnote within the bandpass filter. prediction
62
53dbce5f0745 Further simplification
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 61
diff changeset
925 double fDDS3 = FrequencyDDS3Init - DeltakHz_2*1000*(-Signe1/Signe2)*Ndiv*(Nu2)/(Nu1) - Beatslope_2*(utc-t1_2);
53dbce5f0745 Further simplification
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 61
diff changeset
926 DeltaDDS3 = fDDS3 - DDS4xAD9912.Frequency3;
61
37075b60408b Fix N2 measurement after cleanup. Further simplification
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 60
diff changeset
927 printf("deltaDDS3 = %g\n", DeltaDDS3);
62
53dbce5f0745 Further simplification
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 61
diff changeset
928 SetCtrlVal(MainPanel, PANEL_DDS3, fDDS3);
53dbce5f0745 Further simplification
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 61
diff changeset
929 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, fDDS3);
46
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
930
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
931 // 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
932 settling = 3;
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
933
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
934 // next step
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
935 Measuring_2 += 1;
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
936 }
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
937 break;
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
938
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
939 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
940 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
941 // 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
942
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
943 if (settling > 0) {
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
944 settling--;
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
945 break;
44
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
946 }
61
37075b60408b Fix N2 measurement after cleanup. Further simplification
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 60
diff changeset
947
37075b60408b Fix N2 measurement after cleanup. Further simplification
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 60
diff changeset
948 double fDDS2 = DDS4xAD9912.Frequency2 + 275000 - Ch4;
37075b60408b Fix N2 measurement after cleanup. Further simplification
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 60
diff changeset
949 SetCtrlVal(MainPanel, PANEL_DDS2, fDDS2);
37075b60408b Fix N2 measurement after cleanup. Further simplification
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 60
diff changeset
950 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, fDDS2);
46
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
951
61
37075b60408b Fix N2 measurement after cleanup. Further simplification
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 60
diff changeset
952 double fDDS3 = DDS4xAD9912.Frequency3 + 10000 - Ch2;
37075b60408b Fix N2 measurement after cleanup. Further simplification
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 60
diff changeset
953 DeltaDDS3 = DeltaDDS3 + 10000 - Ch2;
37075b60408b Fix N2 measurement after cleanup. Further simplification
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 60
diff changeset
954 SetCtrlVal(MainPanel, PANEL_DDS3, fDDS3);
37075b60408b Fix N2 measurement after cleanup. Further simplification
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 60
diff changeset
955 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, fDDS3);
46
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
956
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
957 // 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
958 settling = 3;
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
959
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
960 // next step
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
961 Measuring_2 += 1;
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
962 break;
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
963
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
964 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
965 // frep positive step
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
966
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
967 if (settling > 0) {
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
968 settling--;
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
969 break;
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
970 }
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
971
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
972 if (t2_1 == 0.0)
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
973 t2_1 = utc;
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
974
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
975 Frepplus_2 = Frepplus_2 + Math1 + 250000000 - Slope_2 * (utc - t2_2);
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
976 Delta10K_Plus = Delta10K_Plus + 10000 - (Ch2 - Beatslope_2 * (utc - t2_2));
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
977 n_2 += 1;
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
978
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
979 if ((utc - t2_2) > DeltaT_2) {
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
980 Frepplus_2 = Frepplus_2 / n_2;
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
981 Delta10K_Plus = Delta10K_Plus / n_2;
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
982 n_2 = 0;
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
983
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
984 // negative frequency step
62
53dbce5f0745 Further simplification
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 61
diff changeset
985 double fDDS1 = FrequDDS1 - DeltakHz_2 * 1000;
53dbce5f0745 Further simplification
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 61
diff changeset
986 DDS4xAD9912_FrequencyRampe(&DDS4xAD9912, 1, DDS4xAD9912.Frequency1, fDDS1, Step2/Ndiv);
53dbce5f0745 Further simplification
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 61
diff changeset
987 SetCtrlVal(MainPanel, PANEL_DDS1, fDDS1);
53dbce5f0745 Further simplification
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 61
diff changeset
988 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, fDDS1);
53dbce5f0745 Further simplification
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 61
diff changeset
989
53dbce5f0745 Further simplification
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 61
diff changeset
990 // adjust DDS3 to keep beatnote within the bandpass filter. prediction
53dbce5f0745 Further simplification
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 61
diff changeset
991 double fDDS3 = FrequencyDDS3Init + DeltakHz_2*1000*(-Signe1/Signe2)*Ndiv*(Nu2)/(Nu1);
61
37075b60408b Fix N2 measurement after cleanup. Further simplification
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 60
diff changeset
992 DeltaDDS3 = fDDS3 - DDS4xAD9912.Frequency3;
37075b60408b Fix N2 measurement after cleanup. Further simplification
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 60
diff changeset
993 SetCtrlVal(MainPanel, PANEL_DDS3, fDDS3);
37075b60408b Fix N2 measurement after cleanup. Further simplification
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 60
diff changeset
994 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, fDDS3);
17
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
995
46
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
996 // 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
997 settling = 3;
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
998
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
999 // next step
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
1000 Measuring_2 += 1;
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
1001 }
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
1002 break;
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
1003
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
1004 case N_MEASUREMENT_FREP_MINUS:
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
1005 // frep negative step
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
1006
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
1007 if (settling > 0) {
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
1008 settling--;
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
1009 break;
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1010 }
46
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
1011
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
1012 if (t3_1 == 0.0)
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
1013 t3_1 = utc;
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
1014
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
1015 Frepminus_2 = Frepminus_2 + Math1 + 250000000 - Slope_2 * (utc - t3_2);
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
1016 Delta10K_Minus= Delta10K_Minus + 10000 - (Ch2 - Beatslope_2 * (utc - t3_2));
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
1017 n_2 += 1;
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
1018
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
1019 if ((utc -t3_2) > DeltaT_2) {
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
1020 Frepminus_2 = Frepminus_2 / n_2;
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
1021 Delta10K_Minus = Delta10K_Minus / n_2;
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
1022 n_2 = 0;
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
1023
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
1024 // compute N2
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
1025 N_2 = (Signe2)*(-DeltaDDS3+Delta10K_Plus-Delta10K_Minus-Beatslope_2*(t3_2-t2_2) )/(Frepminus_2-Frepplus_2-Slope_2*(t3_2-t2_2));
84
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1026 SetCtrlVal(CalcNPanel, CALCN_N, N_2);
46
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
1027
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
1028 // back to nominal frequency
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
1029 DDS4xAD9912_FrequencyRampe (&DDS4xAD9912, 1, FrequDDS1-DeltakHz_2*1000,FrequDDS1, Step2/Ndiv );
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
1030 SetCtrlVal(MainPanel, PANEL_DDS1, FrequDDS1);
62
53dbce5f0745 Further simplification
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 61
diff changeset
1031 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, FrequDDS1);
46
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
1032 SetCtrlVal(MainPanel, PANEL_DDS2, FrequencyDDSBesInit);
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
1033 DDS4xAD9912_SetFrequency (&DDS4xAD9912, 2, FrequencyDDSBesInit );
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
1034 SetCtrlVal(MainPanel, PANEL_DDS3, FrequencyDDS3Init-Beatslope_2*(utc-t1_2));
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
1035 DDS4xAD9912_SetFrequency (&DDS4xAD9912, 3, FrequencyDDS3Init-Beatslope_2*(utc-t1_2) );
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
1036
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
1037 t1_2 = 0.0;
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
1038 t2_2 = 0.0;
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
1039 t3_2 = 0.0;
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
1040 Frepminus_2 = 0.0;
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
1041 Frepplus_2 = 0.0;
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
1042 Delta10K_Minus = 0.0;
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
1043 Delta10K_Plus = 0.0;
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
1044
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
1045 // done
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
1046 Measuring_2 = N_MEASUREMENT_NONE;
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
1047 }
6503feae1809 Cleanup. Convert N2 measurement logic to state machine like structure
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 44
diff changeset
1048 break;
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
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1051 switch (Measuring_3) {
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1052
47
1d3cd8260cbb Uniform N3 measurement code to N1 and N2
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 46
diff changeset
1053 case N_MEASUREMENT_NONE:
44
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1054 // not measuring N3
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1055 break;
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1056
47
1d3cd8260cbb Uniform N3 measurement code to N1 and N2
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 46
diff changeset
1057 case N_MEASUREMENT_INIT:
44
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1058 // init
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1059
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1060 SetCtrlVal(MainPanel, PANEL_DDS4, FrequDDS4);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1061 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 4, FrequDDS4);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1062 settling = 3;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1063
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1064 t1_3 = utc;
73
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
1065 stat_zero(&stat_ch2);
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
1066
44
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1067 // record current DDS3 frequency
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1068 GetCtrlVal(MainPanel, PANEL_DDS3, &FrequencyDDS3Init);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1069
47
1d3cd8260cbb Uniform N3 measurement code to N1 and N2
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 46
diff changeset
1070 // next step
1d3cd8260cbb Uniform N3 measurement code to N1 and N2
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 46
diff changeset
1071 Measuring_3 += 1;
44
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1072 break;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1073
47
1d3cd8260cbb Uniform N3 measurement code to N1 and N2
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 46
diff changeset
1074 case N_MEASUREMENT_SLOPE:
44
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1075 // slope measurement
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1076
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1077 if (settling > 0) {
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1078 settling--;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1079 break;
24
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1080 }
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1081
73
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
1082 stat_accumulate(&stat_ch2, Ch2);
44
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1083
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1084 if (utc - t1_3 > SlopeTime3) {
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1085 // slope measurement
73
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
1086 Slope_3 = stat_ch2.slope;
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 t2_3 = utc;
73
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
1089 stat_zero(&stat_ch2);
44
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1090
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1091 // frep positive step
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1092 SetCtrlVal(MainPanel, PANEL_DDS4, FrequDDS4 + DeltakHz_3 * 1000);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1093 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 4, FrequDDS4 + DeltakHz_3 * 1000);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1094 // compensate with DDS3 to keep measured beatnote in counter box range
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1095 double fDDS3 = FrequencyDDS3Init + N3/N1 * Ndiv * DeltakHz_3 * 1000;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1096 SetCtrlVal(MainPanel, PANEL_DDS3, fDDS3);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1097 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, fDDS3);
47
1d3cd8260cbb Uniform N3 measurement code to N1 and N2
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 46
diff changeset
1098
44
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1099 // allow counter to settle
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1100 settling = 3;
47
1d3cd8260cbb Uniform N3 measurement code to N1 and N2
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 46
diff changeset
1101
1d3cd8260cbb Uniform N3 measurement code to N1 and N2
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 46
diff changeset
1102 // next step
1d3cd8260cbb Uniform N3 measurement code to N1 and N2
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 46
diff changeset
1103 Measuring_3 += 1;
44
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1104 }
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1105 break;
47
1d3cd8260cbb Uniform N3 measurement code to N1 and N2
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 46
diff changeset
1106
1d3cd8260cbb Uniform N3 measurement code to N1 and N2
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 46
diff changeset
1107 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
1108 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
1109 // 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
1110
1d3cd8260cbb Uniform N3 measurement code to N1 and N2
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 46
diff changeset
1111 // next step
1d3cd8260cbb Uniform N3 measurement code to N1 and N2
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 46
diff changeset
1112 Measuring_3 += 1;
1d3cd8260cbb Uniform N3 measurement code to N1 and N2
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 46
diff changeset
1113 break;
44
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1114
47
1d3cd8260cbb Uniform N3 measurement code to N1 and N2
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 46
diff changeset
1115 case N_MEASUREMENT_FREP_PLUS:
44
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1116 // frep positive step
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1117
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1118 if (settling > 0) {
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1119 settling--;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1120 break;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1121 }
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1122
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1123 n_3++;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1124 Frepplus_3 += Ch2 - Slope_3 * (utc - t2_3);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1125
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1126 if (utc - t2_3 > DeltaT_3) {
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1127 // positive step measurement
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1128 Frepplus_3 = Frepplus_3 / n_3;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1129
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1130 n_3 = 0;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1131 t3_3 = utc;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1132
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1133 // frep negative step
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1134 SetCtrlVal(MainPanel, PANEL_DDS4, FrequDDS4 - DeltakHz_3 * 1000);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1135 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 4, FrequDDS4 - DeltakHz_3 * 1000);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1136 // compensate with DDS3 to keep measured beatnote in counter box range
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1137 double fDDS3 = FrequencyDDS3Init - N3/N1 * Ndiv * DeltakHz_3 * 1000;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1138 SetCtrlVal(MainPanel, PANEL_DDS3, fDDS3);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1139 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, fDDS3);
47
1d3cd8260cbb Uniform N3 measurement code to N1 and N2
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 46
diff changeset
1140
44
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1141 // allow counter to settle
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1142 settling = 3;
47
1d3cd8260cbb Uniform N3 measurement code to N1 and N2
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 46
diff changeset
1143
1d3cd8260cbb Uniform N3 measurement code to N1 and N2
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 46
diff changeset
1144 // next step
1d3cd8260cbb Uniform N3 measurement code to N1 and N2
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 46
diff changeset
1145 Measuring_3 += 1;
44
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1146 }
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1147 break;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1148
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1149
47
1d3cd8260cbb Uniform N3 measurement code to N1 and N2
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 46
diff changeset
1150 case N_MEASUREMENT_FREP_MINUS:
44
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1151 // frep negative step
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1152
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1153 if (settling > 0) {
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1154 settling--;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1155 break;
24
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1156 }
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1157
44
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1158 n_3++;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1159 Frepminus_3 += Ch2 - Slope_3 * (utc - t3_3);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1160
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1161 if (utc - t3_3 > DeltaT_3) {
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1162 // positive step measurement
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1163 Frepminus_3 = Frepminus_3 / n_3;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1164
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1165 // compute N3
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1166 N_3 = 1000.0 * DeltakHz_3 / (Frepplus_3 - Frepminus_3 + (2 * N3/N1 * Ndiv * DeltakHz_3 * 1000));
84
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1167 SetCtrlVal(CalcNPanel, CALCN_N, N_3);
44
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1168
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1169 t1_3=0.0;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1170 t2_3=0.0;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1171 t3_3=0.0;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1172 n_3 = 0;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1173 Frepminus_3 = 0.0;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1174 Frepplus_3 = 0.0;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1175
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1176 // back to nominal frep
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1177 SetCtrlVal(MainPanel, PANEL_DDS4, FrequDDS4);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1178 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 4, FrequDDS4);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1179 // back to initial DDS3 frequency
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1180 SetCtrlVal(MainPanel, PANEL_DDS3, FrequencyDDS3Init);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1181 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, FrequencyDDS3Init);
47
1d3cd8260cbb Uniform N3 measurement code to N1 and N2
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 46
diff changeset
1182
1d3cd8260cbb Uniform N3 measurement code to N1 and N2
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 46
diff changeset
1183 // done
1d3cd8260cbb Uniform N3 measurement code to N1 and N2
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 46
diff changeset
1184 Measuring_3 = N_MEASUREMENT_NONE;
44
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1185 }
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1186 break;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1187 }
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1188
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1189 // Calcul du signe de fb
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1190
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1191 if (Getsign1 == TRUE) {
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1192 if (utc > tbegin1+2) {
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1193 if (Math1 > Frepbefore1)
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1194 Signe1 = -1.0;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1195 else
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1196 Signe1 = +1.0;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1197 SetCtrlVal(MainPanel, PANEL_DDS1, Frequency1);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1198 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, Frequency1);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1199 Getsign1 = FALSE;
54
73e23c879d6e Do not update beatnote sign indicators at each time tick
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 53
diff changeset
1200 SetCtrlVal(MainPanel, PANEL_SIGN1, Signe1);
44
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1201 }
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1202 }
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1203 if (Getsign2 == TRUE) {
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1204 if (utc > tbegin2+2){
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1205 if (Math1 > Frepbefore2) {
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1206 if (Ch2 > Ch2before)
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1207 Signe2 = +1.0;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1208 else
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1209 Signe2 = -1.0;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1210 } else {
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1211 if (Ch2 > Ch2before)
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1212 Signe2 = -1.0;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1213 else
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1214 Signe2 = +1.0;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1215 }
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1216 SetCtrlVal(MainPanel, PANEL_DDS1, Frequency2);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1217 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, Frequency2);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1218 Getsign2 = FALSE;
54
73e23c879d6e Do not update beatnote sign indicators at each time tick
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 53
diff changeset
1219 SetCtrlVal(MainPanel, PANEL_SIGN2, Signe2);
44
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1220 }
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1221 }
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1222 if (Getsign3 == TRUE) {
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1223 if (utc > tbegin3+2){
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1224 if (Ch3 > Frepbefore3)
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1225 Signe3 = -1.0;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1226 else
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1227 Signe3 = +1.0;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1228 SetCtrlVal(MainPanel, PANEL_DDS3, Frequency3);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1229 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 4, Frequency3);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1230 Getsign3 = FALSE;
54
73e23c879d6e Do not update beatnote sign indicators at each time tick
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 53
diff changeset
1231 SetCtrlVal(MainPanel, PANEL_SIGN3, Signe3);
44
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1232 }
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1233 }
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1234
70
a945f2b7bef6 Fix slope measurement again
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 69
diff changeset
1235 // select reference
73
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
1236 double current = 0.0;
70
a945f2b7bef6 Fix slope measurement again
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 69
diff changeset
1237 switch (slopeReference) {
44
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1238 case SLOPE_REFERENCE_MICROWAVE:
73
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
1239 current = Math2;
44
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1240 break;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1241 case SLOPE_REFERENCE_HG_CAVITY:
73
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
1242 current = Ch2 * 1062.5 / 1542.2;
44
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1243 break;
70
a945f2b7bef6 Fix slope measurement again
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 69
diff changeset
1244 }
a945f2b7bef6 Fix slope measurement again
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 69
diff changeset
1245
a945f2b7bef6 Fix slope measurement again
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 69
diff changeset
1246 // stop slope cancelling if the comb is not locked
a945f2b7bef6 Fix slope measurement again
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 69
diff changeset
1247 if (SlopeMeasuring & StopSlopeCancellingOnUnlocked
73
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
1248 & (freq.previous != 0.0)
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
1249 & (fabs(current - freq.previous) > limitotakoff)) {
56
6e73fb3d94fa Simplyfy slope measurement code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 55
diff changeset
1250
70
a945f2b7bef6 Fix slope measurement again
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 69
diff changeset
1251 if (! KeepSlope) {
a945f2b7bef6 Fix slope measurement again
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 69
diff changeset
1252 appliedSlope = 0.0;
a945f2b7bef6 Fix slope measurement again
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 69
diff changeset
1253 DDSFox_SetSweepRate(&DDS1xAD9956, appliedSlope);
66
aa125ad6e842 Clarify variables names in dedrifting code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 65
diff changeset
1254 SetCtrlVal(MainPanel, PANEL_SLOPE_APPLIED, appliedSlope);
70
a945f2b7bef6 Fix slope measurement again
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 69
diff changeset
1255 }
a945f2b7bef6 Fix slope measurement again
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 69
diff changeset
1256 if (! KeepFrequ) {
a945f2b7bef6 Fix slope measurement again
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 69
diff changeset
1257 DDSFox_Set(&DDS1xAD9956, DEDRIFT_DDS_FREQUENCY, appliedSlope);
56
6e73fb3d94fa Simplyfy slope measurement code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 55
diff changeset
1258 }
73
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
1259
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
1260 stat_zero(&freq);
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
1261 SetCtrlVal(MainPanel, PANEL_SLOPE_MEASURED, freq.slope);
70
a945f2b7bef6 Fix slope measurement again
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 69
diff changeset
1262 SlopeMeasuring = FALSE;
a945f2b7bef6 Fix slope measurement again
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 69
diff changeset
1263 SetCtrlVal(MainPanel, PANEL_MEASURE_SLOPE, 0);
a945f2b7bef6 Fix slope measurement again
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 69
diff changeset
1264 }
a945f2b7bef6 Fix slope measurement again
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 69
diff changeset
1265
a945f2b7bef6 Fix slope measurement again
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 69
diff changeset
1266 // slope measurement
a945f2b7bef6 Fix slope measurement again
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 69
diff changeset
1267 if (SlopeMeasuring)
a945f2b7bef6 Fix slope measurement again
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 69
diff changeset
1268 {
56
6e73fb3d94fa Simplyfy slope measurement code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 55
diff changeset
1269 // update slope measurement
73
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
1270 stat_accumulate(&freq, current);
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
1271
60
cd7b5903f168 Display measured slope
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 59
diff changeset
1272 // update indicator
73
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
1273 SetCtrlVal(MainPanel, PANEL_SLOPE_MEASURED, freq.slope);
56
6e73fb3d94fa Simplyfy slope measurement code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 55
diff changeset
1274
6e73fb3d94fa Simplyfy slope measurement code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 55
diff changeset
1275 // update applied slope
6e73fb3d94fa Simplyfy slope measurement code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 55
diff changeset
1276 if ((utc - SlopeMeasuringTimeBegin) > TimetoSlope) {
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1277
52
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
1278 if (invertSlopeSign)
73
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
1279 appliedSlope = appliedSlope - freq.slope;
52
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
1280 else
73
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
1281 appliedSlope = appliedSlope + freq.slope;
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1282
56
6e73fb3d94fa Simplyfy slope measurement code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 55
diff changeset
1283 if (FrequCorrec) {
6e73fb3d94fa Simplyfy slope measurement code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 55
diff changeset
1284 // proportional correction
6e73fb3d94fa Simplyfy slope measurement code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 55
diff changeset
1285
6e73fb3d94fa Simplyfy slope measurement code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 55
diff changeset
1286 Nratio += 1;
6e73fb3d94fa Simplyfy slope measurement code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 55
diff changeset
1287 if (Nratio >= 1) {
73
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
1288 MoyMath2 = MoyMath2 + freq.mean;
56
6e73fb3d94fa Simplyfy slope measurement code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 55
diff changeset
1289 }
6e73fb3d94fa Simplyfy slope measurement code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 55
diff changeset
1290 if (Nratio == 1 && CenterFrequencyCh2ToDetermine == TRUE) {
6e73fb3d94fa Simplyfy slope measurement code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 55
diff changeset
1291 CenterFrequencyCh2 = MoyMath2;
6e73fb3d94fa Simplyfy slope measurement code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 55
diff changeset
1292 CenterFrequencyCh2ToDetermine = FALSE;
6e73fb3d94fa Simplyfy slope measurement code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 55
diff changeset
1293 }
6e73fb3d94fa Simplyfy slope measurement code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 55
diff changeset
1294 if (Nratio == ratio) {
55
54add101fdca Cleanup. Remove unnecessary global variable
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 54
diff changeset
1295 double correction = (MoyMath2/ratio-CenterFrequencyCh2)/TimetoSlope;
66
aa125ad6e842 Clarify variables names in dedrifting code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 65
diff changeset
1296 appliedSlope = appliedSlope + correction;
56
6e73fb3d94fa Simplyfy slope measurement code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 55
diff changeset
1297 Nratio = 0;
6e73fb3d94fa Simplyfy slope measurement code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 55
diff changeset
1298 MoyMath2 = 0.0;
44
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1299 }
24
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1300 }
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1301
66
aa125ad6e842 Clarify variables names in dedrifting code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 65
diff changeset
1302 SetCtrlVal(MainPanel, PANEL_SLOPE_APPLIED, appliedSlope);
aa125ad6e842 Clarify variables names in dedrifting code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 65
diff changeset
1303 DDSFox_SetSweepRate(&DDS1xAD9956, appliedSlope);
44
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1304
82
47860259afe2 Implement logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 80
diff changeset
1305 logmsg("Slope correction update (%+6g) %6g", freq.slope, appliedSlope);
47860259afe2 Implement logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 80
diff changeset
1306
73
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
1307 stat_zero(&freq);
44
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1308 SlopeMeasuringTimeBegin = utc;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1309 }
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1310 }
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1311
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1312 // re-centering
52
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
1313 if (KeepCentering) {
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
1314 if ((utc - CenteringTimeBegin275K) > Timetorecenter275K && CenteringTimeBegin275K > 10) {
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
1315 double frequency;
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
1316 GetCtrlVal(MainPanel, PANEL_DDS2, &frequency);
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
1317 // adjust DDS2 frequency to keep Ch4 reading around 275000
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
1318 frequency = frequency + 275000 - Ch4;
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
1319 SetCtrlVal(MainPanel, PANEL_DDS2, frequency);
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
1320 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, frequency);
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
1321 CenteringTimeBegin275K = utc;
44
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1322 }
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1323
52
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
1324 if ((utc - CenteringTimeBegin10K) > Timetorecenter10K && CenteringTimeBegin10K > 10) {
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
1325 double frequency;
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
1326 GetCtrlVal(MainPanel, PANEL_DDS3, &frequency);
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
1327 // adjust DDS3 frequency to keep Ch2 reading around 10000
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
1328 frequency = frequency + 10000 - Ch2;
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
1329 SetCtrlVal(MainPanel, PANEL_DDS3, frequency);
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
1330 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, frequency);
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
1331 CenteringTimeBegin10K = utc;
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
1332 }
44
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1333 }
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1334
76
5e0c314528bf Refactor data writing to disk. Implement dayly chunking to separate files
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 75
diff changeset
1335 int save;
5e0c314528bf Refactor data writing to disk. Implement dayly chunking to separate files
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 75
diff changeset
1336 // run id derived from current date in the form YYMMDD
5e0c314528bf Refactor data writing to disk. Implement dayly chunking to separate files
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 75
diff changeset
1337 char id[7];
5e0c314528bf Refactor data writing to disk. Implement dayly chunking to separate files
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 75
diff changeset
1338 snprintf(id, sizeof(id), "%2s%2s%2s", ShortYear, Month, Day);
5e0c314528bf Refactor data writing to disk. Implement dayly chunking to separate files
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 75
diff changeset
1339
5e0c314528bf Refactor data writing to disk. Implement dayly chunking to separate files
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 75
diff changeset
1340 // write LO frequency (Math2) to disk
5e0c314528bf Refactor data writing to disk. Implement dayly chunking to separate files
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 75
diff changeset
1341 GetCtrlVal(MainPanel, PANEL_CHECKBOX_MATH2SAVE, &save);
5e0c314528bf Refactor data writing to disk. Implement dayly chunking to separate files
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 75
diff changeset
1342 if (save) {
78
3aa1f1c18961 Fix data logging to disc. Shorten file names
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 76
diff changeset
1343 writeData(DATAFOLDER, "Lo", id, Date, Time, utc, Math2);
76
5e0c314528bf Refactor data writing to disk. Implement dayly chunking to separate files
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 75
diff changeset
1344 writeData("C:\\Femto\\Results", "OptCavity", id, Date, Time, utc, Math2);
44
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1345 }
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1346
76
5e0c314528bf Refactor data writing to disk. Implement dayly chunking to separate files
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 75
diff changeset
1347 // write Hg frequency (Math3) to disk
5e0c314528bf Refactor data writing to disk. Implement dayly chunking to separate files
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 75
diff changeset
1348 GetCtrlVal(MainPanel, PANEL_CHECKBOX_MATH3SAVE, &save);
5e0c314528bf Refactor data writing to disk. Implement dayly chunking to separate files
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 75
diff changeset
1349 if (save) {
78
3aa1f1c18961 Fix data logging to disc. Shorten file names
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 76
diff changeset
1350 writeData(DATAFOLDER, "Hg", id, Date, Time, utc, Math3);
76
5e0c314528bf Refactor data writing to disk. Implement dayly chunking to separate files
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 75
diff changeset
1351 writeData("C:\\Femto\\Results", "HgCavity", id, Date, Time, utc, Math3);
44
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1352 }
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1353
76
5e0c314528bf Refactor data writing to disk. Implement dayly chunking to separate files
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 75
diff changeset
1354 // write ExtraMath (Math5) to disk
5e0c314528bf Refactor data writing to disk. Implement dayly chunking to separate files
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 75
diff changeset
1355 GetCtrlVal(MainPanel, PANEL_CHECKBOX_MATH5SAVE, &save);
5e0c314528bf Refactor data writing to disk. Implement dayly chunking to separate files
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 75
diff changeset
1356 if (save) {
78
3aa1f1c18961 Fix data logging to disc. Shorten file names
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 76
diff changeset
1357 writeData(DATAFOLDER, "Ex", id, Date, Time, utc, Math5);
44
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1358 }
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1359
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1360 // Special case to handle change of day at next second
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1361 if ( LocalTime.tm_hour==23 && LocalTime.tm_min==59 && strtod(Sec,NULL)>=58 ) {
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1362 Acquiring = FALSE;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1363 do {
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1364 Delay(5.1);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1365 CurrentFileName(LogFileName);
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1366 } while (!GetFileInfo(LogFileName, &OldLogFilePtr));
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1367 Acquiring = TRUE;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1368 OldLogFilePtr = 2;
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1369 }
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1370
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1371 ResumeTimerCallbacks();
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1372
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1373 }
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1374 break;
44
2e37910b28bc Simplify logic and reindent
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 43
diff changeset
1375 }
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1376 return 0;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1377 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1378
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1379
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1380 int CVICALLBACK CB_OnFreqPlot (int panel, int control, int event,
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1381 void *callbackData, int eventData1, int eventData2)
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1382 {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1383 int BoxChecked ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1384 Plot_Data * pPlot = NULL;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1385 char PlotTitle[] = "Ch? Frequency Plot" ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1386 double PlotMin = 10e6 ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1387 double PlotMax = 65e6 ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1388
52
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
1389 switch (event) {
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1390 case EVENT_COMMIT:
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1391
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1392 GetCtrlVal(MainPanel, control, &BoxChecked);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1393 switch (control) {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1394 case PANEL_CHECKBOX_FREQ1PLOT :
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1395 pPlot = &PlotCh1 ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1396 Fmt(PlotTitle, "Ch1 Frequency Plot") ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1397 PlotMin = 54.999e6 ; PlotMax = 55.001e6 ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1398 break ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1399 case PANEL_CHECKBOX_FREQ2PLOT :
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1400 pPlot = &PlotCh2 ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1401 Fmt(PlotTitle, "Ch2 Frequency Plot") ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1402 PlotMin = 8.0e3 ; PlotMax = 12.0e3 ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1403 break ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1404 case PANEL_CHECKBOX_FREQ3PLOT :
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1405 pPlot = &PlotCh3 ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1406 Fmt(PlotTitle, "Ch3 Frequency Plot") ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1407 PlotMin = 8.0e3 ; PlotMax = 12.0e3 ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1408 break ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1409 case PANEL_CHECKBOX_FREQ4PLOT :
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1410 pPlot = &PlotCh4 ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1411 Fmt(PlotTitle, "Ch4 Frequency Plot") ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1412 break ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1413 case PANEL_CHECKBOX_MATH1PLOT :
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1414 pPlot = &PlotMath1 ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1415 Fmt(PlotTitle, "Math1 Plot") ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1416 PlotMin = 765.0e6 ; PlotMax = 775.0e6 ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1417 break ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1418 case PANEL_CHECKBOX_MATH2PLOT :
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1419 pPlot = &PlotMath2 ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1420 Fmt(PlotTitle, "Math2 Plot") ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1421 PlotMin = -1.0e9 ; PlotMax = 1.0e9 ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1422 break ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1423 case PANEL_CHECKBOX_MATH3PLOT :
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1424 pPlot = &PlotMath3 ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1425 Fmt(PlotTitle, "Math3 Plot") ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1426 PlotMin = -1.0e9 ; PlotMax = 1.0e9 ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1427 break ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1428 case PANEL_CHECKBOX_MATH4PLOT :
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1429 pPlot = &PlotMath4 ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1430 Fmt(PlotTitle, "Math4 Plot") ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1431 PlotMin = -1.0e9 ; PlotMax = 1.0e9 ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1432 break ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1433 case PANEL_CHECKBOX_MATH5PLOT :
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1434 pPlot = &PlotMath5 ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1435 Fmt(PlotTitle, "Math5 Plot") ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1436 PlotMin = -1.0e9 ; PlotMax = 1.0e9 ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1437 break ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1438 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1439
52
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
1440 if (BoxChecked)
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
1441 Plot_InitPanel(pPlot, PlotTitle, PlotMin, PlotMax, &OnCloseViewPanel);
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
1442 else
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
1443 Plot_ClosePanel(pPlot);
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1444 break;
52
30146cc6cd77 Cleanup. Remove some C abominations
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 51
diff changeset
1445 }
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1446 return 0;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1447 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1448
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1449
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1450 int CVICALLBACK CB_OnAllanPlot (int panel, int control, int event,
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1451 void *callbackData, int eventData1, int eventData2)
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1452 {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1453 int BoxChecked ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1454 Allan_Data * pAllan = NULL;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1455 char AllanTitle[] = "Ch? Allan Deviation " ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1456 double Normalizer = 300e12 ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1457
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1458 switch (event)
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1459 {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1460 case EVENT_COMMIT:
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1461
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1462 GetCtrlVal(MainPanel, control, &BoxChecked);
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1463 switch (control) {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1464 case PANEL_CHECKBOX_FREQ1ALLAN :
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1465 pAllan = &AllanCh1 ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1466 Fmt(AllanTitle, "Ch1 Allan Deviation") ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1467 Normalizer = 1.84e12 ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1468 break ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1469 case PANEL_CHECKBOX_FREQ2ALLAN :
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1470 pAllan = &AllanCh2 ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1471 Fmt(AllanTitle, "Ch2 Allan Deviation") ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1472 Normalizer = 10.e3 ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1473 break ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1474 case PANEL_CHECKBOX_FREQ3ALLAN :
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1475 pAllan = &AllanCh3 ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1476 Fmt(AllanTitle, "Ch3 Allan Deviation") ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1477 Normalizer = 429.228e12 ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1478 break ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1479 case PANEL_CHECKBOX_FREQ4ALLAN :
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1480 pAllan = &AllanCh4 ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1481 Fmt(AllanTitle, "Ch4 Allan Deviation") ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1482 Normalizer = 275.0e3 ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1483 break ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1484 case PANEL_CHECKBOX_MATH1ALLAN :
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1485 pAllan = &AllanMath1 ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1486 Fmt(AllanTitle, "Math1 Allan Deviation") ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1487 Normalizer = 250.0e6 ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1488 break ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1489 case PANEL_CHECKBOX_MATH2ALLAN :
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1490 pAllan = &AllanMath2 ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1491 Fmt(AllanTitle, "Math2 Allan Deviation") ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1492 Normalizer = 194.395e12 ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1493 break ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1494 case PANEL_CHECKBOX_MATH3ALLAN :
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1495 pAllan = &AllanMath3 ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1496 Fmt(AllanTitle, "Math3 Allan Deviation") ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1497 Normalizer = 282.143e12 ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1498 break ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1499 case PANEL_CHECKBOX_MATH4ALLAN :
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1500 pAllan = &AllanMath4 ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1501 Fmt(AllanTitle, "Math4 Allan Deviation") ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1502 Normalizer = 429.228e12 ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1503 break ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1504 case PANEL_CHECKBOX_MATH5ALLAN :
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1505 pAllan = &AllanMath5 ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1506 Fmt(AllanTitle, "Math5 Allan Deviation") ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1507 Normalizer = 429.228e12 ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1508 break ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1509 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1510
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1511 if (BoxChecked) {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1512 Allan_InitPanel(pAllan, AllanTitle, Normalizer, &OnCloseViewPanel) ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1513 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1514 else {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1515 Allan_ClosePanel(pAllan) ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1516 } ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1517 break;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1518
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1519 case EVENT_RIGHT_CLICK:
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1520
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1521 break;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1522
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1523 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1524 return 0;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1525 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1526
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1527 int CVICALLBACK CB_ChangeDDSOut (int panel, int control, int event,
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1528 void *callbackData, int eventData1, int eventData2)
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1529 {
28
1e4ecf64b485 Remove references to unused DDSBes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 27
diff changeset
1530 double frequency ;
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1531
28
1e4ecf64b485 Remove references to unused DDSBes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 27
diff changeset
1532 switch (event) {
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1533 case EVENT_COMMIT:
28
1e4ecf64b485 Remove references to unused DDSBes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 27
diff changeset
1534 GetCtrlVal(MainPanel, control, &frequency);
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1535
28
1e4ecf64b485 Remove references to unused DDSBes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 27
diff changeset
1536 switch (control) {
1e4ecf64b485 Remove references to unused DDSBes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 27
diff changeset
1537 case PANEL_DDS1:
1e4ecf64b485 Remove references to unused DDSBes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 27
diff changeset
1538 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, frequency);
1e4ecf64b485 Remove references to unused DDSBes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 27
diff changeset
1539 break;
1e4ecf64b485 Remove references to unused DDSBes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 27
diff changeset
1540 case PANEL_DDS2:
1e4ecf64b485 Remove references to unused DDSBes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 27
diff changeset
1541 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, frequency);
1e4ecf64b485 Remove references to unused DDSBes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 27
diff changeset
1542 break;
1e4ecf64b485 Remove references to unused DDSBes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 27
diff changeset
1543 case PANEL_DDS3:
1e4ecf64b485 Remove references to unused DDSBes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 27
diff changeset
1544 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, frequency);
1e4ecf64b485 Remove references to unused DDSBes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 27
diff changeset
1545 break;
1e4ecf64b485 Remove references to unused DDSBes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 27
diff changeset
1546 case PANEL_DDS4:
1e4ecf64b485 Remove references to unused DDSBes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 27
diff changeset
1547 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 4, frequency);
1e4ecf64b485 Remove references to unused DDSBes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 27
diff changeset
1548 break;
1e4ecf64b485 Remove references to unused DDSBes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 27
diff changeset
1549 }
1e4ecf64b485 Remove references to unused DDSBes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 27
diff changeset
1550 }
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1551 return 0;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1552 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1553
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1554 int CVICALLBACK CB_ChangeDDSStep (int panel, int control, int event,
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1555 void *callbackData, int eventData1, int eventData2)
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1556 {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1557 double Step ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1558
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1559 switch (event)
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1560 {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1561 case EVENT_COMMIT:
28
1e4ecf64b485 Remove references to unused DDSBes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 27
diff changeset
1562 GetCtrlVal(MainPanel, control, &Step);
1e4ecf64b485 Remove references to unused DDSBes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 27
diff changeset
1563 if (control==PANEL_DDS1STEP) { SetCtrlAttribute(panel, PANEL_DDS1, ATTR_INCR_VALUE, Step); }
1e4ecf64b485 Remove references to unused DDSBes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 27
diff changeset
1564 if (control==PANEL_DDS2STEP) { SetCtrlAttribute(panel, PANEL_DDS2, ATTR_INCR_VALUE, Step); }
1e4ecf64b485 Remove references to unused DDSBes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 27
diff changeset
1565 if (control==PANEL_DDS3STEP) { SetCtrlAttribute(panel, PANEL_DDS3, ATTR_INCR_VALUE, Step); }
1e4ecf64b485 Remove references to unused DDSBes
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 27
diff changeset
1566 if (control==PANEL_DDS4STEP) { SetCtrlAttribute(panel, PANEL_DDS4, ATTR_INCR_VALUE, Step); }
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1567 break;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1568 case EVENT_RIGHT_CLICK:
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1569
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1570 break;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1571
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1572 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1573 return 0;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1574 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1575
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1576 int CVICALLBACK CB_ChangeMath (int panel, int control, int event,
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1577 void *callbackData, int eventData1, int eventData2)
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1578 {
24
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1579 int len;
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1580 char *string;
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1581
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1582 switch (event)
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1583 {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1584 case EVENT_COMMIT:
24
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1585 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
1586 string = (char *)malloc(sizeof(char) * (len + 1));
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1587 GetCtrlVal(panel, control, string);
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1588 switch (control) {
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1589 case PANEL_MATHSTRING1:
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1590 mupSetExpr(MathParser1, string);
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1591 break;
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1592 case PANEL_MATHSTRING2:
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1593 mupSetExpr(MathParser2, string);
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1594 break;
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1595 case PANEL_MATHSTRING3:
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1596 mupSetExpr(MathParser3, string);
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1597 break;
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1598 case PANEL_MATHSTRING4:
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1599 mupSetExpr(MathParser4, string);
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1600 break;
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1601 case PANEL_MATHSTRING5:
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1602 mupSetExpr(MathParser5, string);
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1603 break;
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1604 }
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1605 free(string);
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1606 break;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1607 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1608 return 0;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1609 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1610
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1611 int CVICALLBACK CB_ChangeN (int panel, int control, int event,
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1612 void *callbackData, int eventData1, int eventData2)
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1613 {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1614
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1615 switch (event)
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1616 {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1617 case EVENT_COMMIT:
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1618 if (control==PANEL_N1CHOICE) GetCtrlVal(MainPanel, control, &N1) ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1619 if (control==PANEL_N2CHOICE) GetCtrlVal(MainPanel, control, &N2) ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1620 if (control==PANEL_N3CHOICE) GetCtrlVal(MainPanel, control, &N3) ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1621 break;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1622 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1623 return 0;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1624 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1625
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1626 int CVICALLBACK CB_OnPlus10k (int panel, int control, int event,
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1627 void *callbackData, int eventData1, int eventData2)
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1628 {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1629 double Frequency ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1630
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1631 switch (event)
24
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1632 {
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1633 case EVENT_COMMIT:
24
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1634 switch (control)
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1635 {
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1636 case PANEL_PLUS10KDDS1:
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1637 GetCtrlVal(MainPanel, PANEL_DDS1, &Frequency);
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1638 Frequency += 10000.0;
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1639 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, Frequency);
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1640 SetCtrlVal(MainPanel, PANEL_DDS1, Frequency);
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1641 break;
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1642 case PANEL_PLUS10KDDS2:
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1643 GetCtrlVal(MainPanel, PANEL_DDS2, &Frequency);
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1644 Frequency += 10000.0;
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1645 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, Frequency);
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1646 SetCtrlVal(MainPanel, PANEL_DDS2, Frequency);
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1647 break;
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1648 case PANEL_PLUS10KDDS3:
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1649 GetCtrlVal(MainPanel, PANEL_DDS3, &Frequency);
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1650 Frequency += 10000.0;
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1651 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, Frequency);
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1652 SetCtrlVal(MainPanel, PANEL_DDS3, Frequency);
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1653 break;
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1654 case PANEL_PLUS10KDDS4:
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1655 GetCtrlVal(MainPanel, PANEL_DDS4, &Frequency);
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1656 Frequency += 10000.0;
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1657 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 4, Frequency);
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1658 SetCtrlVal(MainPanel, PANEL_DDS4, Frequency);
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1659 break;
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1660 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1661 break;
24
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1662 }
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1663 return 0;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1664 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1665
24
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1666
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1667 int CVICALLBACK CB_OnMinus10k (int panel, int control, int event,
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1668 void *callbackData, int eventData1, int eventData2)
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1669 {
24
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1670 double Frequency;
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1671
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1672 switch (event)
24
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1673 {
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1674 case EVENT_COMMIT:
24
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1675 switch (control)
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1676 {
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1677 case PANEL_MINUS10KDDS1:
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1678 GetCtrlVal(MainPanel, PANEL_DDS1, &Frequency);
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1679 Frequency -= 10000.0;
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1680 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, Frequency);
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1681 SetCtrlVal(MainPanel, PANEL_DDS1, Frequency);
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1682 break;
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1683 case PANEL_MINUS10KDDS2:
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1684 GetCtrlVal(MainPanel, PANEL_DDS2, &Frequency);
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1685 Frequency -= 10000.0;
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1686 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, Frequency);
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1687 SetCtrlVal(MainPanel, PANEL_DDS2, Frequency);
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1688 break;
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1689 case PANEL_MINUS10KDDS3:
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1690 GetCtrlVal(MainPanel, PANEL_DDS3, &Frequency);
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1691 Frequency -= 10000.0;
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1692 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, Frequency);
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1693 SetCtrlVal(MainPanel, PANEL_DDS3, Frequency);
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1694 break;
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1695 case PANEL_MINUS10KDDS4:
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1696 GetCtrlVal(MainPanel, PANEL_DDS4, &Frequency);
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1697 Frequency -= 10000.0;
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1698 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 4, Frequency);
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1699 SetCtrlVal(MainPanel, PANEL_DDS4, Frequency);
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1700 break;
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1701 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1702 break;
24
b838371c7a91 Code cleanup and dead code removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 23
diff changeset
1703 }
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1704 return 0;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1705 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1706
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1707
17
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
1708 int CVICALLBACK CB_OnAcceptN (int panel, int control, int event,
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1709 void *callbackData, int eventData1, int eventData2)
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1710 {
84
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1711 switch (event) {
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1712 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
1713 switch (measuring) {
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1714 case MEASURING_N_Lo:
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1715 N1 = round(N_1);
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1716 SetCtrlVal(MainPanel, PANEL_N1CHOICE, N1);
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1717 break;
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1718 case MEASURING_N_Hg:
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1719 N2 = round(N_2);
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1720 SetCtrlVal(MainPanel, PANEL_N2CHOICE, N2);
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1721 break;
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1722 case MEASURING_N_Sr:
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1723 N3 = round(N_3);
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1724 SetCtrlVal(MainPanel, PANEL_N3CHOICE, N3);
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1725 break;
17
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
1726 }
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1727 break;
17
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
1728 }
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1729 return 0;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1730 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1731
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1732
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1733 int CVICALLBACK CB_OnNCalculus (int panel, int control, int event,
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1734 void *callbackData, int eventData1, int eventData2)
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1735 {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
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 int visible;
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1738
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 (event) {
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1740 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
1741 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
1742 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
1743 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
1744 if (! visible) {
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1745 measuring = MEASURING_N_Lo;
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1746 SetCtrlVal(CalcNPanel, CALCN_INTEGRATIONTIME, DeltaT_1);
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1747 SetCtrlVal(CalcNPanel, CALCN_SLOPETIME, SlopeTime1);
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1748 SetCtrlVal(CalcNPanel, CALCN_DELTAFREQ, DeltakHz_1);
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1749 SetPanelAttribute(CalcNPanel, ATTR_TITLE, "Calculate N_Lo");
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1750 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
1751 }
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1752 break;
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1753 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
1754 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
1755 if (! visible) {
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1756 measuring = MEASURING_N_Hg;
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1757 SetCtrlVal(CalcNPanel, CALCN_INTEGRATIONTIME, DeltaT_2);
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1758 SetCtrlVal(CalcNPanel, CALCN_SLOPETIME, SlopeTime2);
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1759 SetCtrlVal(CalcNPanel, CALCN_DELTAFREQ, DeltakHz_2);
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1760 SetPanelAttribute(CalcNPanel, ATTR_TITLE, "Calculate N_Hg");
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) {
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1767 measuring = MEASURING_N_Sr;
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1768 SetCtrlVal(CalcNPanel, CALCN_INTEGRATIONTIME, DeltaT_3);
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1769 SetCtrlVal(CalcNPanel, CALCN_SLOPETIME, SlopeTime3);
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1770 SetCtrlVal(CalcNPanel, CALCN_DELTAFREQ, DeltakHz_3);
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1771 SetPanelAttribute(CalcNPanel, ATTR_TITLE, "Calculate N_Sr");
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1772 DisplayPanel(CalcNPanel);
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1773 }
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1774 break;
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1775 }
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1776 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
1777 }
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1778 return 0;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1779 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1780
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1781
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1782 int CVICALLBACK CB_OnStartNCalculus (int panel, int control, int event,
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1783 void *callbackData, int eventData1, int eventData2)
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1784 {
84
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1785 switch (event) {
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1786 case EVENT_COMMIT:
84
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1787 switch (measuring) {
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1788 case MEASURING_N_Lo:
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1789 GetCtrlVal(CalcNPanel, CALCN_INTEGRATIONTIME, &DeltaT_1);
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1790 GetCtrlVal(CalcNPanel, CALCN_SLOPETIME, &SlopeTime1);
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1791 GetCtrlVal(CalcNPanel, CALCN_DELTAFREQ, &DeltakHz_1);
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1792 Measuring_1 = TRUE;
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1793 break;
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1794 case MEASURING_N_Hg:
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1795 GetCtrlVal(CalcNPanel, CALCN_INTEGRATIONTIME, &DeltaT_2);
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1796 GetCtrlVal(CalcNPanel, CALCN_SLOPETIME, &SlopeTime2);
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1797 GetCtrlVal(CalcNPanel, CALCN_DELTAFREQ, &DeltakHz_2);
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1798 Measuring_2 = TRUE;
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1799 break;
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1800 case MEASURING_N_Sr:
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1801 GetCtrlVal(CalcNPanel, CALCN_INTEGRATIONTIME, &DeltaT_3);
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1802 GetCtrlVal(CalcNPanel, CALCN_SLOPETIME, &SlopeTime3);
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1803 GetCtrlVal(CalcNPanel, CALCN_DELTAFREQ, &DeltakHz_3);
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1804 Measuring_3 = TRUE;
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1805 break;
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1806 }
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1807 break;
17
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
1808 }
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1809 return 0;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1810 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1811
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1812
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1813
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1814 int CVICALLBACK CB_OnNStop (int panel, int control, int event,
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1815 void *callbackData, int eventData1, int eventData2)
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1816 {
17
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
1817 switch (event) {
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1818 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
1819 HidePanel(CalcNPanel);
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1820 switch (measuring) {
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1821 case MEASURING_N_Lo:
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1822 Measuring_1 = FALSE;
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1823 SetCtrlVal(MainPanel, PANEL_DDS1, FrequDDS1);
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1824 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, FrequDDS1);
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1825 SetCtrlVal(MainPanel, PANEL_DDS2, FrequencyDDSBesInit);
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1826 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, FrequencyDDSBesInit);
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1827 break;
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1828 case MEASURING_N_Hg:
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1829 Measuring_2 = FALSE;
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1830 SetCtrlVal(MainPanel, PANEL_DDS1, FrequDDS1);
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1831 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, FrequDDS1);
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1832 SetCtrlVal(MainPanel, PANEL_DDS2, FrequencyDDSBesInit);
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1833 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, FrequencyDDSBesInit);
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1834 SetCtrlVal(MainPanel, PANEL_DDS3, FrequencyDDS3Init);
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1835 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, FrequencyDDS3Init);
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1836 break;
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1837 case MEASURING_N_Sr:
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1838 Measuring_3 = FALSE;
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;
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1840 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1841 break;
17
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
1842 }
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1843 return 0;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1844 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1845
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1846
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1847 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
1848 void *callbackData, int eventData1, int eventData2)
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1849 {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1850
17
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
1851 switch (event) {
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1852 case EVENT_COMMIT:
17
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
1853 switch (control)
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
1854 {
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
1855 case PANEL_FINDSIGN1:
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
1856 tbegin1 = utc;
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
1857 Frepbefore1 = Math1;
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
1858 GetCtrlVal(MainPanel, PANEL_DDS1, &Frequency1) ;
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
1859 SetCtrlVal(MainPanel, PANEL_DDS1, Frequency1+Frequencystep1) ;
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
1860 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, Frequency1+Frequencystep1);
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
1861 Getsign1 = TRUE;
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
1862 break;
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
1863 case PANEL_FINDSIGN2:
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
1864 tbegin2 = utc;
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
1865 Frepbefore2 = Math1;
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
1866 Ch2before = Ch2;
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
1867 GetCtrlVal(MainPanel, PANEL_DDS1, &Frequency2) ;
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
1868 SetCtrlVal(MainPanel, PANEL_DDS1, Frequency2+Frequencystep2) ;
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
1869 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, Frequency2+Frequencystep2);
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
1870 Getsign2 = TRUE;
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
1871 break;
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
1872 case PANEL_FINDSIGN3:
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
1873 tbegin3 = utc;
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
1874 Frepbefore3 = Math1;
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
1875 GetCtrlVal(MainPanel, PANEL_DDS4, &Frequency3) ;
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
1876 SetCtrlVal(MainPanel, PANEL_DDS4, Frequency3+Frequencystep3) ;
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
1877 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 4, Frequency3+Frequencystep3);
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
1878 Getsign3 = TRUE;
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
1879 break;
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1880 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1881 break;
17
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
1882 }
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1883 return 0;
17
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
1884 }
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1885
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1886
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1887 int CVICALLBACK CB_OnFind275K (int panel, int control, int event,
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1888 void *callbackData, int eventData1, int eventData2)
42
dcc305411dcc Cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 40
diff changeset
1889 {
dcc305411dcc Cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 40
diff changeset
1890 double frequency;
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1891
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1892 switch (event)
42
dcc305411dcc Cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 40
diff changeset
1893 {
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1894 case EVENT_COMMIT:
42
dcc305411dcc Cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 40
diff changeset
1895 switch (control)
dcc305411dcc Cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 40
diff changeset
1896 {
dcc305411dcc Cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 40
diff changeset
1897 case PANEL_FIND275K2:
dcc305411dcc Cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 40
diff changeset
1898 GetCtrlVal(MainPanel, PANEL_DDS2, &frequency);
dcc305411dcc Cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 40
diff changeset
1899 frequency = frequency + 275000 - Ch4;
dcc305411dcc Cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 40
diff changeset
1900 SetCtrlVal(MainPanel, PANEL_DDS2, frequency) ;
dcc305411dcc Cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 40
diff changeset
1901 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, frequency);
dcc305411dcc Cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 40
diff changeset
1902 break;
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1903
42
dcc305411dcc Cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 40
diff changeset
1904 case PANEL_FIND10K3:
dcc305411dcc Cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 40
diff changeset
1905 GetCtrlVal(MainPanel, PANEL_DDS3, &frequency);
dcc305411dcc Cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 40
diff changeset
1906 frequency = frequency + 10000 - Ch2;
dcc305411dcc Cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 40
diff changeset
1907 SetCtrlVal(MainPanel, PANEL_DDS3, frequency);
dcc305411dcc Cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 40
diff changeset
1908 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, frequency);
dcc305411dcc Cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 40
diff changeset
1909 break;
dcc305411dcc Cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 40
diff changeset
1910 }
dcc305411dcc Cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 40
diff changeset
1911 break;
dcc305411dcc Cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 40
diff changeset
1912 }
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1913 return 0;
42
dcc305411dcc Cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 40
diff changeset
1914 }
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1915
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1916
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1917 int CVICALLBACK CB_OnChangeNdiv (int panel, int control, int event,
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1918 void *callbackData, int eventData1, int eventData2)
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1919 {
84
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1920 switch (event) {
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1921 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
1922 GetCtrlVal(MainPanel, PANEL_CHANGENDIV, &Ndiv);
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1923 FrequDDS1 = 880000000.0 / Ndiv;
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1924 SetCtrlVal(MainPanel, PANEL_DDS1, FrequDDS1);
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
1925 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, FrequDDS1);
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1926 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
1927 }
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1928 return 0;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1929 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1930
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1931
48
70980f27e1a4 Simplify dedrifting interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 47
diff changeset
1932 int CVICALLBACK CB_MeasureSlope (int panel, int control, int event,
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1933 void *callbackData, int eventData1, int eventData2)
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1934 {
70
a945f2b7bef6 Fix slope measurement again
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 69
diff changeset
1935 switch (event) {
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1936 case EVENT_COMMIT:
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1937
70
a945f2b7bef6 Fix slope measurement again
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 69
diff changeset
1938 GetCtrlVal(panel, control, &SlopeMeasuring);
a945f2b7bef6 Fix slope measurement again
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 69
diff changeset
1939 if (SlopeMeasuring) {
35
914e0f16b19a Update displayed dedrifting slope when it is modified and not at each timer tick
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 34
diff changeset
1940
914e0f16b19a Update displayed dedrifting slope when it is modified and not at each timer tick
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 34
diff changeset
1941 SlopeMeasuringTimeBegin = utc;
70
a945f2b7bef6 Fix slope measurement again
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 69
diff changeset
1942
73
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
1943 stat_zero(&freq);
35
914e0f16b19a Update displayed dedrifting slope when it is modified and not at each timer tick
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 34
diff changeset
1944
914e0f16b19a Update displayed dedrifting slope when it is modified and not at each timer tick
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 34
diff changeset
1945 Nratio = -1;
70
a945f2b7bef6 Fix slope measurement again
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 69
diff changeset
1946 MoyMath2 = 0.0;
35
914e0f16b19a Update displayed dedrifting slope when it is modified and not at each timer tick
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 34
diff changeset
1947 CenterFrequencyCh2ToDetermine = TRUE ;
914e0f16b19a Update displayed dedrifting slope when it is modified and not at each timer tick
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 34
diff changeset
1948 CenterFrequencyCh2 = 0.0;
33
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 32
diff changeset
1949
82
47860259afe2 Implement logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 80
diff changeset
1950 logmsg("Start slope measurement");
47860259afe2 Implement logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 80
diff changeset
1951
33
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 32
diff changeset
1952 } else {
70
a945f2b7bef6 Fix slope measurement again
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 69
diff changeset
1953 if (! KeepSlope) {
66
aa125ad6e842 Clarify variables names in dedrifting code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 65
diff changeset
1954 appliedSlope = 0.0;
70
a945f2b7bef6 Fix slope measurement again
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 69
diff changeset
1955 DDSFox_SetSweepRate(&DDS1xAD9956, appliedSlope);
a945f2b7bef6 Fix slope measurement again
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 69
diff changeset
1956 SetCtrlVal(MainPanel, PANEL_SLOPE_APPLIED, appliedSlope);
a945f2b7bef6 Fix slope measurement again
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 69
diff changeset
1957 }
a945f2b7bef6 Fix slope measurement again
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 69
diff changeset
1958 if (! KeepFrequ) {
a945f2b7bef6 Fix slope measurement again
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 69
diff changeset
1959 DDSFox_Set(&DDS1xAD9956, DEDRIFT_DDS_FREQUENCY, appliedSlope);
a945f2b7bef6 Fix slope measurement again
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 69
diff changeset
1960 }
73
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
1961 stat_zero(&freq);
1dfaf5ef0352 Refactor mean and slope measurement
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 70
diff changeset
1962 SetCtrlVal(panel, PANEL_SLOPE_MEASURED, freq.slope);
82
47860259afe2 Implement logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 80
diff changeset
1963
47860259afe2 Implement logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 80
diff changeset
1964 logmsg("Stop slope measurement");
33
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 32
diff changeset
1965 }
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1966 break;
33
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 32
diff changeset
1967 }
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1968 return 0;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1969 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1970
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1971
14
783407954cdf Minor code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 10
diff changeset
1972 int CVICALLBACK CB_OnResetSlope (int panel, int control, int event,
783407954cdf Minor code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 10
diff changeset
1973 void *callbackData, int eventData1, int eventData2)
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1974 {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1975
14
783407954cdf Minor code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 10
diff changeset
1976 switch (event) {
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1977 case EVENT_COMMIT:
14
783407954cdf Minor code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 10
diff changeset
1978 CenterFrequencyCh2 = 0.0;
783407954cdf Minor code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 10
diff changeset
1979 MoyMath2 = 0.0;
783407954cdf Minor code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 10
diff changeset
1980 Nratio = -1;
783407954cdf Minor code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 10
diff changeset
1981 CenterFrequencyCh2ToDetermine = TRUE ;
66
aa125ad6e842 Clarify variables names in dedrifting code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 65
diff changeset
1982 appliedSlope = 0.0;
aa125ad6e842 Clarify variables names in dedrifting code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 65
diff changeset
1983 SetCtrlVal(panel, PANEL_SLOPE_APPLIED, appliedSlope);
aa125ad6e842 Clarify variables names in dedrifting code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 65
diff changeset
1984 DDSFox_Set(&DDS1xAD9956, DEDRIFT_DDS_FREQUENCY, appliedSlope);
82
47860259afe2 Implement logging
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 80
diff changeset
1985 logmsg("Reset slope measurement");
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1986 break;
14
783407954cdf Minor code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 10
diff changeset
1987 }
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1988 return 0;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1989 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1990
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1991
14
783407954cdf Minor code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 10
diff changeset
1992 int CVICALLBACK CB_ChangeSlopeTime (int panel, int control, int event,
783407954cdf Minor code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 10
diff changeset
1993 void *callbackData, int eventData1, int eventData2)
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1994 {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1995
14
783407954cdf Minor code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 10
diff changeset
1996 switch (event) {
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1997 case EVENT_COMMIT:
14
783407954cdf Minor code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 10
diff changeset
1998 GetCtrlVal(MainPanel, PANEL_SLOPETIME, &TimetoSlope);
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
1999 break;
14
783407954cdf Minor code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 10
diff changeset
2000 }
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
2001 return 0;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
2002 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
2003
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
2004
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
2005 int CVICALLBACK CB_OnCROX (int panel, int control, int event,
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
2006 void *callbackData, int eventData1, int eventData2)
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
2007 {
34
1e4b8ba97faf Cleanup code handling dedrifing options
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 33
diff changeset
2008 switch (event) {
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
2009 case EVENT_COMMIT:
34
1e4b8ba97faf Cleanup code handling dedrifing options
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 33
diff changeset
2010 switch (control) {
1e4b8ba97faf Cleanup code handling dedrifing options
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 33
diff changeset
2011
1e4b8ba97faf Cleanup code handling dedrifing options
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 33
diff changeset
2012 case PANEL_CHECKBOX_CORRFREQU:
1e4b8ba97faf Cleanup code handling dedrifing options
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 33
diff changeset
2013 // enable frequency correction
1e4b8ba97faf Cleanup code handling dedrifing options
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 33
diff changeset
2014 GetCtrlVal(MainPanel, PANEL_CHECKBOX_CORRFREQU, &FrequCorrec);
1e4b8ba97faf Cleanup code handling dedrifing options
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 33
diff changeset
2015 break;
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
2016
34
1e4b8ba97faf Cleanup code handling dedrifing options
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 33
diff changeset
2017 case PANEL_CHECKBOX_KEEP:
1e4b8ba97faf Cleanup code handling dedrifing options
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 33
diff changeset
2018 // keep current dedrifting frequency when dedrifting is disabled
1e4b8ba97faf Cleanup code handling dedrifing options
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 33
diff changeset
2019 GetCtrlVal(MainPanel, PANEL_CHECKBOX_KEEP, &KeepFrequ);
1e4b8ba97faf Cleanup code handling dedrifing options
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 33
diff changeset
2020 break;
1e4b8ba97faf Cleanup code handling dedrifing options
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 33
diff changeset
2021
1e4b8ba97faf Cleanup code handling dedrifing options
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 33
diff changeset
2022 case PANEL_CHECKBOX_KEEPSLOPE:
1e4b8ba97faf Cleanup code handling dedrifing options
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 33
diff changeset
2023 // keep current dedrifting slope when dedrifting is disabled
1e4b8ba97faf Cleanup code handling dedrifing options
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 33
diff changeset
2024 GetCtrlVal(MainPanel, PANEL_CHECKBOX_KEEPSLOPE, &KeepSlope);
1e4b8ba97faf Cleanup code handling dedrifing options
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 33
diff changeset
2025 break;
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
2026 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
2027 break;
34
1e4b8ba97faf Cleanup code handling dedrifing options
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 33
diff changeset
2028 }
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
2029 return 0;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
2030 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
2031
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
2032
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
2033
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
2034 int CVICALLBACK CB_OnReCentering (int panel, int control, int event,
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
2035 void *callbackData, int eventData1, int eventData2)
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
2036 {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
2037 bool BoxChecked = FALSE;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
2038
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
2039 switch (event)
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
2040 {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
2041 case EVENT_COMMIT:
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
2042
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
2043 if (control== PANEL_CHECKBOX_RECENTER)
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
2044 {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
2045 GetCtrlVal(MainPanel, PANEL_CHECKBOX_RECENTER, &BoxChecked) ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
2046 if (BoxChecked) {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
2047 KeepCentering=TRUE ;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
2048 CenteringTimeBegin275K=utc;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
2049 CenteringTimeBegin10K=utc;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
2050 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
2051 else {KeepCentering=FALSE ;}
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
2052
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
2053 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
2054
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
2055
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
2056 break;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
2057
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
2058 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
2059 return 0;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
2060 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
2061
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
2062
56
6e73fb3d94fa Simplyfy slope measurement code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 55
diff changeset
2063 int CVICALLBACK CB_OnStopSlopeCancellingOnUnlocked (int panel, int control, int event,
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
2064 void *callbackData, int eventData1, int eventData2)
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
2065 {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
2066 switch (event)
20
3a7f088d4960 Get rid of unused variables. Some minor coding style improvements
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 17
diff changeset
2067 {
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
2068 case EVENT_COMMIT:
56
6e73fb3d94fa Simplyfy slope measurement code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 55
diff changeset
2069 GetCtrlVal(MainPanel, PANEL_CHECKBOX_STOPIFAUTODE, &StopSlopeCancellingOnUnlocked);
20
3a7f088d4960 Get rid of unused variables. Some minor coding style improvements
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 17
diff changeset
2070 break;
3a7f088d4960 Get rid of unused variables. Some minor coding style improvements
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 17
diff changeset
2071 }
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
2072 return 0;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
2073 }
2
bd7501b65f56 Implement reference selection (microwave or Hg cavity) for slope cancelling
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 1
diff changeset
2074
17
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2075 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
2076 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
2077 {
bd7501b65f56 Implement reference selection (microwave or Hg cavity) for slope cancelling
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 1
diff changeset
2078 switch (event)
bd7501b65f56 Implement reference selection (microwave or Hg cavity) for slope cancelling
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 1
diff changeset
2079 {
bd7501b65f56 Implement reference selection (microwave or Hg cavity) for slope cancelling
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 1
diff changeset
2080 case EVENT_COMMIT:
bd7501b65f56 Implement reference selection (microwave or Hg cavity) for slope cancelling
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 1
diff changeset
2081 GetCtrlVal(MainPanel, PANEL_SLOPE_REFERENCE, &slopeReference);
bd7501b65f56 Implement reference selection (microwave or Hg cavity) for slope cancelling
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 1
diff changeset
2082 break;
bd7501b65f56 Implement reference selection (microwave or Hg cavity) for slope cancelling
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 1
diff changeset
2083 }
bd7501b65f56 Implement reference selection (microwave or Hg cavity) for slope cancelling
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 1
diff changeset
2084 return 0;
bd7501b65f56 Implement reference selection (microwave or Hg cavity) for slope cancelling
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 1
diff changeset
2085 }
17
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2086
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2087
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2088 int CVICALLBACK CB_OnEstimateN (int panel, int control, int event,
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2089 void *callbackData, int eventData1, int eventData2)
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2090 {
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2091 int visible;
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2092 double wl;
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2093
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2094 switch (event)
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2095 {
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2096 case EVENT_COMMIT:
64
d6efe6fe6eb3 Style fix
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 62
diff changeset
2097 // be prepared to support more N estimates for different beat notes
17
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2098 switch (control)
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2099 {
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2100 case PANEL_ESTIMATE_N3:
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2101 GetPanelAttribute(EstimateN3Panel, ATTR_VISIBLE , &visible);
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2102 if (! visible) {
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2103 DisplayPanel(EstimateN3Panel);
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2104 }
64
d6efe6fe6eb3 Style fix
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 62
diff changeset
2105 // set current frep
17
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2106 SetCtrlVal(EstimateN3Panel, ESTIMATEN3_FREP, 250e6 + Math1);
64
d6efe6fe6eb3 Style fix
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 62
diff changeset
2107 // default wavelenght for Sr cavity
17
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2108 GetCtrlVal(EstimateN3Panel, ESTIMATEN3_WAVELENGTH, &wl);
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2109 if (wl == 0.0)
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2110 SetCtrlVal(EstimateN3Panel, ESTIMATEN3_WAVELENGTH, 698.50);
64
d6efe6fe6eb3 Style fix
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 62
diff changeset
2111 // reset N3 estimate
17
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2112 SetCtrlVal(EstimateN3Panel, ESTIMATEN3_N, 0.0);
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2113 break;
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2114 }
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2115 break;
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2116 }
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2117
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2118 return 0;
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2119 }
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2120
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2121 int CVICALLBACK CB_OnNEstimateCancel (int panel, int control, int event,
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2122 void *callbackData, int eventData1, int eventData2)
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2123 {
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2124 int visible;
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2125
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2126 switch (event)
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2127 {
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2128 case EVENT_COMMIT:
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2129 GetPanelAttribute(panel, ATTR_VISIBLE, &visible);
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2130 if (visible)
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2131 HidePanel(panel);
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2132 break;
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2133 }
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2134 return 0;
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2135 }
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2136
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2137 int CVICALLBACK CB_OnNEstimateSet (int panel, int control, int event,
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2138 void *callbackData, int eventData1, int eventData2)
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2139 {
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2140 switch (event)
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2141 {
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2142 case EVENT_COMMIT:
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2143 GetCtrlVal(panel, ESTIMATEN3_N, &N3);
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2144 SetCtrlVal(MainPanel, PANEL_N3CHOICE, N3);
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2145 HidePanel(panel);
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2146 break;
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2147 }
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2148 return 0;
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2149 }
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2150
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2151 int CVICALLBACK CB_OnNEstimate (int panel, int control, int event,
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2152 void *callbackData, int eventData1, int eventData2)
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2153 {
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2154 double frep, wl, N;
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2155
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2156 switch (event)
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2157 {
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2158 case EVENT_COMMIT:
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2159 GetCtrlVal(panel, ESTIMATEN3_FREP, &frep);
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2160 GetCtrlVal(panel, ESTIMATEN3_WAVELENGTH, &wl);
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2161 N = round(299792458.0 / wl / 1e-9 / frep);
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2162 SetCtrlVal(panel, ESTIMATEN3_N, N);
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2163 break;
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2164 }
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2165 return 0;
9cadd12e7722 Implement N3 measurement. Large code cleanup.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 14
diff changeset
2166 }
30
56095062acd4 Allow manual setting of frequency dedrifting rate
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 29
diff changeset
2167
56095062acd4 Allow manual setting of frequency dedrifting rate
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 29
diff changeset
2168 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
2169 void *callbackData, int eventData1, int eventData2)
56095062acd4 Allow manual setting of frequency dedrifting rate
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 29
diff changeset
2170 {
56095062acd4 Allow manual setting of frequency dedrifting rate
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 29
diff changeset
2171 switch (event)
56095062acd4 Allow manual setting of frequency dedrifting rate
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 29
diff changeset
2172 {
56095062acd4 Allow manual setting of frequency dedrifting rate
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 29
diff changeset
2173 case EVENT_COMMIT:
66
aa125ad6e842 Clarify variables names in dedrifting code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 65
diff changeset
2174 GetCtrlVal(panel, control, &appliedSlope);
aa125ad6e842 Clarify variables names in dedrifting code
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 65
diff changeset
2175 DDSFox_SetSweepRate(&DDS1xAD9956, appliedSlope);
30
56095062acd4 Allow manual setting of frequency dedrifting rate
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 29
diff changeset
2176 break;
56095062acd4 Allow manual setting of frequency dedrifting rate
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 29
diff changeset
2177 }
56095062acd4 Allow manual setting of frequency dedrifting rate
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 29
diff changeset
2178 return 0;
56095062acd4 Allow manual setting of frequency dedrifting rate
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 29
diff changeset
2179 }
39
2e1b3148d6e6 Add setting to invert the sign of the measured slope on dedrifting
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 37
diff changeset
2180
2e1b3148d6e6 Add setting to invert the sign of the measured slope on dedrifting
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 37
diff changeset
2181 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
2182 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
2183 {
2e1b3148d6e6 Add setting to invert the sign of the measured slope on dedrifting
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 37
diff changeset
2184 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
2185 {
2e1b3148d6e6 Add setting to invert the sign of the measured slope on dedrifting
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 37
diff changeset
2186 case EVENT_COMMIT:
2e1b3148d6e6 Add setting to invert the sign of the measured slope on dedrifting
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 37
diff changeset
2187 GetCtrlVal(panel, control, &invertSlopeSign);
2e1b3148d6e6 Add setting to invert the sign of the measured slope on dedrifting
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 37
diff changeset
2188 break;
2e1b3148d6e6 Add setting to invert the sign of the measured slope on dedrifting
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 37
diff changeset
2189 }
2e1b3148d6e6 Add setting to invert the sign of the measured slope on dedrifting
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 37
diff changeset
2190 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
2191 }
48
70980f27e1a4 Simplify dedrifting interface
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 47
diff changeset
2192
80
46fe62febcd0 Add dedrifting DDS reset functionality
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 79
diff changeset
2193 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
2194 void *callbackData, int eventData1, int eventData2)
46fe62febcd0 Add dedrifting DDS reset functionality
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 79
diff changeset
2195 {
46fe62febcd0 Add dedrifting DDS reset functionality
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 79
diff changeset
2196 switch (event)
46fe62febcd0 Add dedrifting DDS reset functionality
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 79
diff changeset
2197 {
46fe62febcd0 Add dedrifting DDS reset functionality
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 79
diff changeset
2198 case EVENT_COMMIT:
46fe62febcd0 Add dedrifting DDS reset functionality
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 79
diff changeset
2199 // stop slope measurement and reset slope
46fe62febcd0 Add dedrifting DDS reset functionality
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 79
diff changeset
2200 SlopeMeasuring = 0;
46fe62febcd0 Add dedrifting DDS reset functionality
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 79
diff changeset
2201 SetCtrlVal(panel, PANEL_MEASURE_SLOPE, SlopeMeasuring);
46fe62febcd0 Add dedrifting DDS reset functionality
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 79
diff changeset
2202 CenterFrequencyCh2 = 0.0;
46fe62febcd0 Add dedrifting DDS reset functionality
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 79
diff changeset
2203 MoyMath2 = 0.0;
46fe62febcd0 Add dedrifting DDS reset functionality
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 79
diff changeset
2204 Nratio = -1;
46fe62febcd0 Add dedrifting DDS reset functionality
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 79
diff changeset
2205 CenterFrequencyCh2ToDetermine = TRUE ;
46fe62febcd0 Add dedrifting DDS reset functionality
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 79
diff changeset
2206 appliedSlope = 0.0;
46fe62febcd0 Add dedrifting DDS reset functionality
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 79
diff changeset
2207 SetCtrlVal(panel, PANEL_SLOPE_APPLIED, appliedSlope);
46fe62febcd0 Add dedrifting DDS reset functionality
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 79
diff changeset
2208 // reset DDS
46fe62febcd0 Add dedrifting DDS reset functionality
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 79
diff changeset
2209 DDSFox_Reset(&DDS1xAD9956);
46fe62febcd0 Add dedrifting DDS reset functionality
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 79
diff changeset
2210 DDSFox_SetProfile(&DDS1xAD9956);
46fe62febcd0 Add dedrifting DDS reset functionality
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 79
diff changeset
2211 DDSFox_SetDiv(&DDS1xAD9956, 1);
46fe62febcd0 Add dedrifting DDS reset functionality
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 79
diff changeset
2212 DDSFox_Set(&DDS1xAD9956, DEDRIFT_DDS_FREQUENCY, appliedSlope);
46fe62febcd0 Add dedrifting DDS reset functionality
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 79
diff changeset
2213 break;
46fe62febcd0 Add dedrifting DDS reset functionality
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 79
diff changeset
2214 }
46fe62febcd0 Add dedrifting DDS reset functionality
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 79
diff changeset
2215 return 0;
46fe62febcd0 Add dedrifting DDS reset functionality
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 79
diff changeset
2216 }
46fe62febcd0 Add dedrifting DDS reset functionality
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 79
diff changeset
2217
84
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
2218 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
2219 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
2220 {
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
2221 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
2222 {
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
2223 case EVENT_COMMIT:
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
2224 SetPanelAttribute(LoggingPanel, ATTR_VISIBLE, 1);
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
2225 break;
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
2226 }
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
2227 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
2228 }
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
2229
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
2230 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
2231 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
2232 {
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
2233 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
2234 {
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
2235 case EVENT_CLOSE:
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
2236 SetPanelAttribute(LoggingPanel, ATTR_VISIBLE, 0);
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
2237 break;
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
2238 }
c03263186dd7 Rework and cleanup N measurement panels handling. Move logs to dedicated panel.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 82
diff changeset
2239 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
2240 }