annotate Allan.c @ 231:c10236b5a3e9

Show Plot and Allan windows in the taskbar
author Daniele Nicolodi <daniele.nicolodi@obspm.fr>
date Mon, 27 Oct 2014 18:03:35 +0100
parents ddc8c47db3df
children
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);
219
ddc8c47db3df Fix allan deviation plot
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 214
diff changeset
29 SetPanelAttribute(Instance->AllanPanel, ATTR_CALLBACK_DATA, (void *)Instance);
ddc8c47db3df Fix allan deviation plot
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 214
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++) {
138
02044ad2749a Coding style
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 137
diff changeset
107 x[i] = pow(2, i);
219
ddc8c47db3df Fix allan deviation plot
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 214
diff changeset
108
ddc8c47db3df Fix allan deviation plot
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 214
diff changeset
109 if (Instance->AllanVar[i] == 0.0) {
ddc8c47db3df Fix allan deviation plot
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 214
diff changeset
110 y[i] = 0.0;
ddc8c47db3df Fix allan deviation plot
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 214
diff changeset
111 continue;
ddc8c47db3df Fix allan deviation plot
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 214
diff changeset
112 }
ddc8c47db3df Fix allan deviation plot
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 214
diff changeset
113
137
792ac7151f0f Fix Allan deviation linear drift contribution removal
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 136
diff changeset
114 /* remove linear drift estimated contribution to the allan variance */
135
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
115 if (dedrift) {
138
02044ad2749a Coding style
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 137
diff changeset
116 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
117 /* 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
118 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
119 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
120 the best estimator of the allan variance */
138
02044ad2749a Coding style
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 137
diff changeset
121 y[i] = sqrt(fabs(Instance->AllanVar[i] - corr)) / Instance->normalization;
135
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
122 } else {
138
02044ad2749a Coding style
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 137
diff changeset
123 y[i] = sqrt(Instance->AllanVar[i]) / Instance->normalization;
135
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
124 }
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
125 }
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
126
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
127 DeleteGraphPlot(Instance->AllanPanel, ALLANPANEL_ALLANPLOT, -1, VAL_IMMEDIATE_DRAW);
138
02044ad2749a Coding style
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 137
diff changeset
128 PlotXY(Instance->AllanPanel, ALLANPANEL_ALLANPLOT, x, y, ALLAN_NUM_DATAPOINTS,
135
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
129 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
130
214
920ff733b43b Fix Allan deviation plot
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 144
diff changeset
131 for (i = 0; (i < ALLAN_NUM_DATAPOINTS) & (Instance->BlocksNumber[i] > 0); i++) {
138
02044ad2749a Coding style
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 137
diff changeset
132 error = 1 / sqrt(Instance->BlocksNumber[i]);
02044ad2749a Coding style
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 137
diff changeset
133 PlotLine(Instance->AllanPanel, ALLANPANEL_ALLANPLOT,
02044ad2749a Coding style
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 137
diff changeset
134 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
135 }
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
136 }
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
137
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
138
135
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
139 /* callbacks */
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
140
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
141 int CVICALLBACK Allan_CB_Reset(int panel, int control, int event,
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
142 void *callbackData, int eventData1, int eventData2)
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
143 {
135
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
144 switch(event)
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
145 {
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
146 case EVENT_COMMIT:
135
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
147 Allan_Data *data;
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
148 GetPanelAttribute(panel, ATTR_CALLBACK_DATA, &data);
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
149 Allan_Reset(data);
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
150 break;
135
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
151 }
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
152 return 0;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
153 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
154
135
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
155
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
156 int CVICALLBACK Allan_CB_ChangeYLim (int panel, int control, int event,
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
157 void *callbackData, int eventData1, int eventData2)
135
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
158 {
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
159 switch (event)
135
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
160 {
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
161 case EVENT_COMMIT:
136
7b9cf3d4346e Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 135
diff changeset
162 int pmin, pmax;
7b9cf3d4346e Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 135
diff changeset
163 GetCtrlVal(panel, ALLANPANEL_MIN, &pmin);
7b9cf3d4346e Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 135
diff changeset
164 GetCtrlVal(panel, ALLANPANEL_MAX, &pmax);
7b9cf3d4346e Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 135
diff changeset
165 if (pmin < pmax) {
7b9cf3d4346e Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 135
diff changeset
166 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
167 SetCtrlVal(panel, ALLANPANEL_CHECKBOX_AUTOSCALE, FALSE);
135
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
168 }
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
169 break;
135
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
170 }
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
171 return 0;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
172 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
173
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
174
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
175 int CVICALLBACK Allan_CB_ChangeAutoScale (int panel, int control, int event,
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
176 void *callbackData, int eventData1, int eventData2)
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
177 {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
178 switch (event)
135
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
179 {
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
180 case EVENT_COMMIT:
135
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
181 Allan_Data *data;
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
182 GetPanelAttribute(panel, ATTR_CALLBACK_DATA, &data);
136
7b9cf3d4346e Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 135
diff changeset
183 GetCtrlVal(panel, control, &(data->autoscale));
135
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
184 Allan_Display(data);
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
185 break;
135
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
186 }
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
187 return 0;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
188 }
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
189
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
190
135
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
191 int CVICALLBACK Allan_CB_ChangeNormalization (int panel, int control, int event,
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
192 void *callbackData, int eventData1, int eventData2)
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
193 {
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
194 switch (event)
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
195 {
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
196 case EVENT_COMMIT:
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
197 Allan_Data *data;
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
198 GetPanelAttribute(panel, ATTR_CALLBACK_DATA, &data);
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
199 GetCtrlVal(panel, control, &(data->normalization));
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
200 Allan_Display(data);
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
201 break;
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
202 }
135
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
203 return 0;
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
204 }
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
205
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
206
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
207 int CVICALLBACK CB_GeneralAllanPanel (int panel, int event, void *callbackData,
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
208 int eventData1, int eventData2)
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
209 {
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
210 switch (event)
135
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
211 {
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
212 case EVENT_CLOSE:
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
213 Allan_Data *data;
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
214 GetPanelAttribute(panel, ATTR_CALLBACK_DATA, &data);
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
215 Allan_ClosePanel(data);
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
216 break;
135
77539f2597b1 Code cleanup
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents: 134
diff changeset
217 }
0
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
218 return 0;
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff changeset
219 }