Mercurial > hg > fxanalyse
comparison FXAnalyse.c @ 136:7b9cf3d4346e
Code cleanup
author | Daniele Nicolodi <daniele.nicolodi@obspm.fr> |
---|---|
date | Wed, 22 Jan 2014 12:29:58 +0100 |
parents | 77539f2597b1 |
children | e04123ab79ef |
comparison
equal
deleted
inserted
replaced
135:77539f2597b1 | 136:7b9cf3d4346e |
---|---|
75 .normalization = __normalization, \ | 75 .normalization = __normalization, \ |
76 .control = PANEL_ADEV_ ## __channel \ | 76 .control = PANEL_ADEV_ ## __channel \ |
77 } | 77 } |
78 | 78 |
79 | 79 |
80 int adev_toggle(struct adev *adev) | 80 static int adev_toggle(struct adev *adev) |
81 { | 81 { |
82 if (adev->allan.active) | 82 if (adev->allan.active) |
83 Allan_ClosePanel(&(adev->allan)); | 83 Allan_ClosePanel(&(adev->allan)); |
84 else | 84 else |
85 Allan_InitPanel(&(adev->allan), adev->title, | 85 Allan_InitPanel(&(adev->allan), adev->title, |
86 adev->normalization, MainPanel, adev->control); | 86 adev->normalization, MainPanel, adev->control); |
87 return adev->allan.active; | 87 return adev->allan.active; |
88 } | 88 } |
89 | 89 |
90 | 90 |
91 void adev_update(struct adev *adev) | 91 static inline void adev_update(struct adev *adev) |
92 { | 92 { |
93 if (adev->allan.active) | 93 if (adev->allan.active) |
94 Allan_AddFrequency(&(adev->allan), *(adev->data)); | 94 Allan_AddFrequency(&(adev->allan), *(adev->data)); |
95 } | 95 } |
96 | 96 |
127 .max = __max, \ | 127 .max = __max, \ |
128 .control = PANEL_PLOT_ ## __channel \ | 128 .control = PANEL_PLOT_ ## __channel \ |
129 } | 129 } |
130 | 130 |
131 | 131 |
132 int plot_toggle(struct plot *plot) | 132 static int plot_toggle(struct plot *plot) |
133 { | 133 { |
134 if (plot->plot.active) | 134 if (plot->plot.active) |
135 Plot_ClosePanel(&(plot->plot)); | 135 Plot_ClosePanel(&(plot->plot)); |
136 else | 136 else |
137 Plot_InitPanel(&(plot->plot), plot->title, | 137 Plot_InitPanel(&(plot->plot), plot->title, |
138 plot->min, plot->max, MainPanel, plot->control); | 138 plot->min, plot->max, MainPanel, plot->control); |
139 return plot->plot.active; | 139 return plot->plot.active; |
140 } | 140 } |
141 | 141 |
142 | 142 |
143 void plot_update(struct plot *plot) | 143 static inline void plot_update(struct plot *plot) |
144 { | 144 { |
145 if (plot->plot.active) | 145 if (plot->plot.active) |
146 Plot_AddFrequency(&(plot->plot), *(plot->data)); | 146 Plot_AddFrequency(&(plot->plot), *(plot->data)); |
147 } | 147 } |
148 | 148 |
1351 | 1351 |
1352 // recenter | 1352 // recenter |
1353 if (recenter.enabled) | 1353 if (recenter.enabled) |
1354 { | 1354 { |
1355 if (recenter.t0 == 0.0) { | 1355 if (recenter.t0 == 0.0) { |
1356 recenter.t0 = utc; | 1356 |
1357 rollmean_zero(&rollmean_ch2, ROLLMEAN_N_OBS); | |
1358 rollmean_zero(&rollmean_ch3, ROLLMEAN_N_OBS); | |
1359 rollmean_zero(&rollmean_ch4, ROLLMEAN_N_OBS); | |
1360 } | 1357 } |
1361 | 1358 |
1362 rollmean_accumulate(&rollmean_ch2, Ch2); | 1359 rollmean_accumulate(&rollmean_ch2, Ch2); |
1363 rollmean_accumulate(&rollmean_ch3, Ch3); | 1360 rollmean_accumulate(&rollmean_ch3, Ch3); |
1364 rollmean_accumulate(&rollmean_ch4, Ch4); | 1361 rollmean_accumulate(&rollmean_ch4, Ch4); |
1501 } | 1498 } |
1502 | 1499 |
1503 int CVICALLBACK CB_ChangeDDSOut (int panel, int control, int event, | 1500 int CVICALLBACK CB_ChangeDDSOut (int panel, int control, int event, |
1504 void *callbackData, int eventData1, int eventData2) | 1501 void *callbackData, int eventData1, int eventData2) |
1505 { | 1502 { |
1506 double frequency ; | |
1507 | |
1508 switch (event) { | 1503 switch (event) { |
1509 case EVENT_COMMIT: | 1504 case EVENT_COMMIT: |
1505 double frequency; | |
1510 GetCtrlVal(MainPanel, control, &frequency); | 1506 GetCtrlVal(MainPanel, control, &frequency); |
1511 | |
1512 switch (control) { | 1507 switch (control) { |
1513 case PANEL_DDS1: | 1508 case PANEL_DDS1: |
1514 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, frequency); | 1509 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, frequency); |
1515 break; | 1510 break; |
1516 case PANEL_DDS2: | 1511 case PANEL_DDS2: |
1521 break; | 1516 break; |
1522 case PANEL_DDS4: | 1517 case PANEL_DDS4: |
1523 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 4, frequency); | 1518 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 4, frequency); |
1524 break; | 1519 break; |
1525 } | 1520 } |
1521 break; | |
1526 } | 1522 } |
1527 return 0; | 1523 return 0; |
1528 } | 1524 } |
1529 | 1525 |
1530 int CVICALLBACK CB_ChangeDDSStep (int panel, int control, int event, | 1526 int CVICALLBACK CB_ChangeDDSStep (int panel, int control, int event, |
1531 void *callbackData, int eventData1, int eventData2) | 1527 void *callbackData, int eventData1, int eventData2) |
1532 { | 1528 { |
1533 double Step ; | 1529 switch (event) |
1534 | 1530 { |
1535 switch (event) | 1531 case EVENT_COMMIT: |
1536 { | 1532 double step; |
1537 case EVENT_COMMIT: | 1533 GetCtrlVal(panel, control, &step); |
1538 GetCtrlVal(MainPanel, control, &Step); | 1534 switch (control) |
1539 if (control==PANEL_DDS1STEP) { SetCtrlAttribute(panel, PANEL_DDS1, ATTR_INCR_VALUE, Step); } | 1535 { |
1540 if (control==PANEL_DDS2STEP) { SetCtrlAttribute(panel, PANEL_DDS2, ATTR_INCR_VALUE, Step); } | 1536 case PANEL_DDS1STEP: |
1541 if (control==PANEL_DDS3STEP) { SetCtrlAttribute(panel, PANEL_DDS3, ATTR_INCR_VALUE, Step); } | 1537 SetCtrlAttribute(panel, PANEL_DDS1, ATTR_INCR_VALUE, step); |
1542 if (control==PANEL_DDS4STEP) { SetCtrlAttribute(panel, PANEL_DDS4, ATTR_INCR_VALUE, Step); } | 1538 break; |
1543 break; | 1539 case PANEL_DDS2STEP: |
1544 case EVENT_RIGHT_CLICK: | 1540 SetCtrlAttribute(panel, PANEL_DDS2, ATTR_INCR_VALUE, step); |
1545 | 1541 break; |
1546 break; | 1542 case PANEL_DDS3STEP: |
1547 | 1543 SetCtrlAttribute(panel, PANEL_DDS3, ATTR_INCR_VALUE, step); |
1548 } | 1544 break; |
1545 case PANEL_DDS4STEP: | |
1546 SetCtrlAttribute(panel, PANEL_DDS4, ATTR_INCR_VALUE, step); | |
1547 break; | |
1548 } | |
1549 break; | |
1550 } | |
1549 return 0; | 1551 return 0; |
1550 } | 1552 } |
1551 | 1553 |
1552 int CVICALLBACK CB_ChangeMath (int panel, int control, int event, | 1554 int CVICALLBACK CB_ChangeMath (int panel, int control, int event, |
1553 void *callbackData, int eventData1, int eventData2) | 1555 void *callbackData, int eventData1, int eventData2) |
1587 int CVICALLBACK CB_ChangeN (int panel, int control, int event, | 1589 int CVICALLBACK CB_ChangeN (int panel, int control, int event, |
1588 void *callbackData, int eventData1, int eventData2) | 1590 void *callbackData, int eventData1, int eventData2) |
1589 { | 1591 { |
1590 | 1592 |
1591 switch (event) | 1593 switch (event) |
1592 { | 1594 { |
1593 case EVENT_COMMIT: | 1595 case EVENT_COMMIT: |
1594 if (control==PANEL_N1CHOICE) GetCtrlVal(MainPanel, control, &N1) ; | 1596 switch (control) |
1595 if (control==PANEL_N2CHOICE) GetCtrlVal(MainPanel, control, &N2) ; | 1597 { |
1596 if (control==PANEL_N3CHOICE) GetCtrlVal(MainPanel, control, &N3) ; | 1598 case PANEL_N1CHOICE: |
1597 break; | 1599 GetCtrlVal(panel, control, &N1); |
1598 } | 1600 break; |
1601 case PANEL_N2CHOICE: | |
1602 GetCtrlVal(panel, control, &N2); | |
1603 break; | |
1604 case PANEL_N3CHOICE: | |
1605 GetCtrlVal(panel, control, &N3); | |
1606 break; | |
1607 } | |
1608 break; | |
1609 } | |
1599 return 0; | 1610 return 0; |
1600 } | 1611 } |
1601 | 1612 |
1602 int CVICALLBACK CB_OnPlus10k (int panel, int control, int event, | 1613 int CVICALLBACK CB_OnPlus10k (int panel, int control, int event, |
1603 void *callbackData, int eventData1, int eventData2) | 1614 void *callbackData, int eventData1, int eventData2) |
1985 { | 1996 { |
1986 switch (event) | 1997 switch (event) |
1987 { | 1998 { |
1988 case EVENT_COMMIT: | 1999 case EVENT_COMMIT: |
1989 switch (control) { | 2000 switch (control) { |
1990 | |
1991 case PANEL_CHECKBOX_CORRFREQU: | |
1992 // enable frequency correction | |
1993 // GetCtrlVal(MainPanel, PANEL_CHECKBOX_CORRFREQU, &FrequCorrec); | |
1994 break; | |
1995 | |
1996 case PANEL_CHECKBOX_KEEP: | 2001 case PANEL_CHECKBOX_KEEP: |
1997 // keep current dedrifting frequency when dedrifting is disabled | 2002 // keep current dedrifting frequency when dedrifting is disabled |
1998 GetCtrlVal(MainPanel, PANEL_CHECKBOX_KEEP, &dedrift.keep_freq); | 2003 GetCtrlVal(MainPanel, PANEL_CHECKBOX_KEEP, &dedrift.keep_freq); |
1999 break; | 2004 break; |
2000 | |
2001 case PANEL_CHECKBOX_KEEPSLOPE: | 2005 case PANEL_CHECKBOX_KEEPSLOPE: |
2002 // keep current dedrifting slope when dedrifting is disabled | 2006 // keep current dedrifting slope when dedrifting is disabled |
2003 GetCtrlVal(MainPanel, PANEL_CHECKBOX_KEEPSLOPE, &dedrift.keep_slope); | 2007 GetCtrlVal(MainPanel, PANEL_CHECKBOX_KEEPSLOPE, &dedrift.keep_slope); |
2004 break; | 2008 break; |
2005 } | 2009 } |
2015 { | 2019 { |
2016 switch (event) | 2020 switch (event) |
2017 { | 2021 { |
2018 case EVENT_COMMIT: | 2022 case EVENT_COMMIT: |
2019 GetCtrlVal(panel, control, &recenter.enabled); | 2023 GetCtrlVal(panel, control, &recenter.enabled); |
2020 recenter.t0 = 0.0; | 2024 recenter.t0 = utc; |
2025 rollmean_zero(&rollmean_ch2, ROLLMEAN_N_OBS); | |
2026 rollmean_zero(&rollmean_ch3, ROLLMEAN_N_OBS); | |
2027 rollmean_zero(&rollmean_ch4, ROLLMEAN_N_OBS); | |
2021 break; | 2028 break; |
2022 } | 2029 } |
2023 return 0; | 2030 return 0; |
2024 } | 2031 } |
2025 | 2032 |
2063 // be prepared to support more N estimates for different beat notes | 2070 // be prepared to support more N estimates for different beat notes |
2064 switch (control) | 2071 switch (control) |
2065 { | 2072 { |
2066 case PANEL_ESTIMATE_N3: | 2073 case PANEL_ESTIMATE_N3: |
2067 GetPanelAttribute(EstimateN3Panel, ATTR_VISIBLE , &visible); | 2074 GetPanelAttribute(EstimateN3Panel, ATTR_VISIBLE , &visible); |
2068 if (! visible) { | 2075 if (! visible) |
2069 DisplayPanel(EstimateN3Panel); | 2076 DisplayPanel(EstimateN3Panel); |
2070 } | |
2071 // set current frep | 2077 // set current frep |
2072 SetCtrlVal(EstimateN3Panel, ESTIMATEN3_FREP, 250e6 + Math1); | 2078 SetCtrlVal(EstimateN3Panel, ESTIMATEN3_FREP, 250e6 + Math1); |
2073 // default wavelenght for Sr cavity | 2079 // default wavelenght for Sr cavity |
2074 GetCtrlVal(EstimateN3Panel, ESTIMATEN3_WAVELENGTH, &wl); | 2080 GetCtrlVal(EstimateN3Panel, ESTIMATEN3_WAVELENGTH, &wl); |
2075 if (wl == 0.0) | 2081 if (wl == 0.0) |