annotate Allan.c @ 175:e5ad3ed47d2c

Code cleanup
author Daniele Nicolodi <daniele.nicolodi@obspm.fr>
date Fri, 21 Feb 2014 18:38:44 +0100
parents be87c8e78266
children 920ff733b43b
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 <ansi_c.h>
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
2 #include <userint.h>
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
3
144
be87c8e78266 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 138
diff changeset
4 #include "utils.h"
135
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
5 #include "FXAllan.h"
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
6 #include "Allan.h"
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
7
135
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
8 #define DATAPOINT_COLOR VAL_RED
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
9 #define ERRORBAR_COLOR VAL_RED
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
10
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
11
135
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
12 static void Allan_Reset(Allan_Data * Instance);
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
13 static void Allan_Display(Allan_Data * Instance);
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
14
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
15
135
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
16 void Allan_InitPanel(Allan_Data * Instance, const char *title, double normalization, int parent, int control)
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
17 {
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
18 if ((Instance->AllanPanel = LoadPanel (0, "FXAllan.uir", ALLANPANEL)) < 0)
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
19 return;
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
20
135
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
21 Allan_Reset(Instance);
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
22 Instance->normalization = normalization;
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
23 Instance->autoscale = FALSE;
134
bd28161e5ac2 Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 103
diff changeset
24 Instance->active = TRUE;
bd28161e5ac2 Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 103
diff changeset
25 Instance->parent = parent;
bd28161e5ac2 Major code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 103
diff changeset
26 Instance->control = control;
135
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
27
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
28 SetPanelAttribute(Instance->AllanPanel, ATTR_TITLE, title);
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
29 SetPanelAttribute (Instance->AllanPanel, ATTR_CALLBACK_DATA, (void *)Instance);
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
30 DisplayPanel (Instance->AllanPanel);
135
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
31 SetCtrlVal(Instance->AllanPanel, ALLANPANEL_NORMALIZER, normalization);
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
32 }
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
33
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
34
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
35 void Allan_ClosePanel(Allan_Data * Instance)
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
36 {
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
37 Instance->active = FALSE;
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
38 SetCtrlVal(Instance->parent, Instance->control, FALSE);
138
02044ad2749a Coding style
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 137
diff changeset
39 DiscardPanel(Instance->AllanPanel);
135
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
40 }
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
41
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
42
135
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
43 void Allan_AddFrequency(Allan_Data * Instance, double Freq)
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
44 {
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
45 /* total number of points used. used to calculate the drift rate */
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
46 int N = 1 + Instance->BlocksNumber[0];
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
47 double Mean = Instance->Mean;
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
48 double Drift = Instance->Drift;
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
49
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
50 /* compute drift rate */
136
7b9cf3d4346e Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 135
diff changeset
51 if (N > 1)
135
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
52 Instance->Drift = (Drift * (N - 2) + 6 * (Freq - Mean) / N) / (N + 1);
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
53 Instance->Mean = (Mean * (N - 1) + Freq) / N;
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
54
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
55 /* compute allan deviation */
136
7b9cf3d4346e Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 135
diff changeset
56 for (int i = 0; i < ALLAN_NUM_DATAPOINTS; i++) {
135
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
57 Instance->CurrentAverage[i] = (Instance->CurrentAverage[i]*Instance->NbCurrentAverage[i] + Freq)
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
58 /(Instance->NbCurrentAverage[i]+1);
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
59 Instance->NbCurrentAverage[i] +=1;
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
60
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
61 if (Instance->NbCurrentAverage[i] >= pow(2,i) ) {
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
62 double CurrentMean = Instance->CurrentAverage[i];
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
63 double LastMean = Instance->LastMean[i];
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
64 N = Instance->BlocksNumber[i];
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
65 N++;
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
66 Instance->CurrentAverage[i] = 0;
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
67 Instance->NbCurrentAverage[i] = 0;
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
68 if (N > 1) {
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
69 Instance->AllanVar[i] = (Instance->AllanVar[i]*(N-2)
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
70 +0.5*pow(CurrentMean-LastMean,2))/(N-1) ;
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
71 }
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
72 Instance->LastMean[i] = CurrentMean;
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
73 Instance->BlocksNumber[i] = N;
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
74 }
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
75 }
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
76
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
77 Allan_Display(Instance);
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
78 }
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
79
135
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
80
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
81 /* private */
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
82
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
83 static void Allan_Reset(Allan_Data *Instance)
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
84 {
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
85 memset(Instance->AllanVar, 0, sizeof(Instance->AllanVar));
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
86 memset(Instance->LastMean, 0, sizeof(Instance->LastMean));
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
87 memset(Instance->BlocksNumber, 0, sizeof(Instance->BlocksNumber));
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
88 memset(Instance->CurrentAverage, 0, sizeof(Instance->CurrentAverage));
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
89 memset(Instance->NbCurrentAverage, 0, sizeof(Instance->NbCurrentAverage));
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
90 Instance->Drift = 0;
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
91 Instance->Mean = 0;
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
92 }
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
93
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
94
135
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
95 static void Allan_Display(Allan_Data *Instance)
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
96 {
138
02044ad2749a Coding style
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 137
diff changeset
97 double x[ALLAN_NUM_DATAPOINTS];
02044ad2749a Coding style
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 137
diff changeset
98 double y[ALLAN_NUM_DATAPOINTS];
02044ad2749a Coding style
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 137
diff changeset
99 double error;
02044ad2749a Coding style
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 137
diff changeset
100 int dedrift;
137
792ac7151f0f Fix Allan deviation linear drift contribution removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 136
diff changeset
101 int i;
135
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
102
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
103 GetCtrlVal(Instance->AllanPanel, ALLANPANEL_DEDRIFT, &dedrift);
136
7b9cf3d4346e Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 135
diff changeset
104 SetCtrlVal(Instance->AllanPanel, ALLANPANEL_DRIFT, Instance->Drift);
135
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
105
136
7b9cf3d4346e Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 135
diff changeset
106 for (i = 0; i < ALLAN_NUM_DATAPOINTS; i++) {
137
792ac7151f0f Fix Allan deviation linear drift contribution removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 136
diff changeset
107 if (Instance->AllanVar[i] == 0.0)
792ac7151f0f Fix Allan deviation linear drift contribution removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 136
diff changeset
108 break;
138
02044ad2749a Coding style
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 137
diff changeset
109 x[i] = pow(2, i);
137
792ac7151f0f Fix Allan deviation linear drift contribution removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 136
diff changeset
110 /* remove linear drift estimated contribution to the allan variance */
135
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
111 if (dedrift) {
138
02044ad2749a Coding style
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 137
diff changeset
112 double corr = 0.5 * (Instance->Drift * x[i]) * (Instance->Drift * x[i]);
137
792ac7151f0f Fix Allan deviation linear drift contribution removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 136
diff changeset
113 /* uncertainty in the estimate of the drift rate may over correct
792ac7151f0f Fix Allan deviation linear drift contribution removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 136
diff changeset
114 the estimated allan variance and result in a negative value. in
792ac7151f0f Fix Allan deviation linear drift contribution removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 136
diff changeset
115 this case we take the absolute value of the corrected value as
792ac7151f0f Fix Allan deviation linear drift contribution removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 136
diff changeset
116 the best estimator of the allan variance */
138
02044ad2749a Coding style
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 137
diff changeset
117 y[i] = sqrt(fabs(Instance->AllanVar[i] - corr)) / Instance->normalization;
135
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
118 } else {
138
02044ad2749a Coding style
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 137
diff changeset
119 y[i] = sqrt(Instance->AllanVar[i]) / Instance->normalization;
135
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
120 }
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
121 }
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
122
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
123 DeleteGraphPlot(Instance->AllanPanel, ALLANPANEL_ALLANPLOT, -1, VAL_IMMEDIATE_DRAW);
138
02044ad2749a Coding style
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 137
diff changeset
124 PlotXY(Instance->AllanPanel, ALLANPANEL_ALLANPLOT, x, y, ALLAN_NUM_DATAPOINTS,
135
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
125 VAL_DOUBLE, VAL_DOUBLE, VAL_SCATTER, VAL_SOLID_SQUARE, VAL_SOLID, 1, DATAPOINT_COLOR);
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
126
136
7b9cf3d4346e Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 135
diff changeset
127 for (i = 0; i < ALLAN_NUM_DATAPOINTS; i++) {
138
02044ad2749a Coding style
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 137
diff changeset
128 error = 1 / sqrt(Instance->BlocksNumber[i]);
02044ad2749a Coding style
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 137
diff changeset
129 PlotLine(Instance->AllanPanel, ALLANPANEL_ALLANPLOT,
02044ad2749a Coding style
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 137
diff changeset
130 x[i], y[i] * (1 - error), x[i], y[i] * (1 + error), ERRORBAR_COLOR);
135
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
131 }
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
132 }
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
133
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
134
135
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
135 /* callbacks */
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
136
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
137 int CVICALLBACK Allan_CB_Reset(int panel, int control, int event,
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
138 void *callbackData, int eventData1, int eventData2)
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
139 {
135
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
140 switch(event)
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
141 {
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
142 case EVENT_COMMIT:
135
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
143 Allan_Data *data;
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
144 GetPanelAttribute(panel, ATTR_CALLBACK_DATA, &data);
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
145 Allan_Reset(data);
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
146 break;
135
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
147 }
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
148 return 0;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
149 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
150
135
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
151
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
152 int CVICALLBACK Allan_CB_ChangeYLim (int panel, int control, int event,
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
153 void *callbackData, int eventData1, int eventData2)
135
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
154 {
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
155 switch (event)
135
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
156 {
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
157 case EVENT_COMMIT:
136
7b9cf3d4346e Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 135
diff changeset
158 int pmin, pmax;
7b9cf3d4346e Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 135
diff changeset
159 GetCtrlVal(panel, ALLANPANEL_MIN, &pmin);
7b9cf3d4346e Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 135
diff changeset
160 GetCtrlVal(panel, ALLANPANEL_MAX, &pmax);
7b9cf3d4346e Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 135
diff changeset
161 if (pmin < pmax) {
7b9cf3d4346e Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 135
diff changeset
162 SetAxisScalingMode(panel, ALLANPANEL_ALLANPLOT, VAL_LEFT_YAXIS, VAL_MANUAL, pow(10, pmin), pow(10, pmax));
7b9cf3d4346e Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 135
diff changeset
163 SetCtrlVal(panel, ALLANPANEL_CHECKBOX_AUTOSCALE, FALSE);
135
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
164 }
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
165 break;
135
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
166 }
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
167 return 0;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
168 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
169
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
170
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
171 int CVICALLBACK Allan_CB_ChangeAutoScale (int panel, int control, int event,
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
172 void *callbackData, int eventData1, int eventData2)
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
173 {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
174 switch (event)
135
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
175 {
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
176 case EVENT_COMMIT:
135
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
177 Allan_Data *data;
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
178 GetPanelAttribute(panel, ATTR_CALLBACK_DATA, &data);
136
7b9cf3d4346e Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 135
diff changeset
179 GetCtrlVal(panel, control, &(data->autoscale));
135
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
180 Allan_Display(data);
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
181 break;
135
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
182 }
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
183 return 0;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
184 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
185
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
186
135
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
187 int CVICALLBACK Allan_CB_ChangeNormalization (int panel, int control, int event,
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
188 void *callbackData, int eventData1, int eventData2)
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
189 {
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
190 switch (event)
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
191 {
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
192 case EVENT_COMMIT:
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
193 Allan_Data *data;
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
194 GetPanelAttribute(panel, ATTR_CALLBACK_DATA, &data);
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
195 GetCtrlVal(panel, control, &(data->normalization));
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
196 Allan_Display(data);
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
197 break;
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
198 }
135
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
199 return 0;
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
200 }
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
201
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
202
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
203 int CVICALLBACK CB_GeneralAllanPanel (int panel, int event, void *callbackData,
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
204 int eventData1, int eventData2)
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
205 {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
206 switch (event)
135
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
207 {
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
208 case EVENT_CLOSE:
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
209 Allan_Data *data;
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
210 GetPanelAttribute(panel, ATTR_CALLBACK_DATA, &data);
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
211 Allan_ClosePanel(data);
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
212 break;
135
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
213 }
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
214 return 0;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
215 }