Mercurial > hg > fxanalyse
comparison 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 |
comparison
equal
deleted
inserted
replaced
83:b7810db29c12 | 84:c03263186dd7 |
---|---|
20 #define DATAFOLDER "Z:\\Measures-2013" | 20 #define DATAFOLDER "Z:\\Measures-2013" |
21 | 21 |
22 #define DEDRIFT_DDS_FREQUENCY 70000000 | 22 #define DEDRIFT_DDS_FREQUENCY 70000000 |
23 | 23 |
24 // panel handling stuff | 24 // panel handling stuff |
25 static PanelHandle MainPanel ; | 25 static PanelHandle MainPanel; |
26 static PanelHandle CalcN1Panel ; | 26 static PanelHandle CalcNPanel; |
27 static PanelHandle CalcN2Panel ; | |
28 static PanelHandle CalcN3Panel ; | |
29 static PanelHandle EstimateN3Panel; | 27 static PanelHandle EstimateN3Panel; |
28 static PanelHandle LoggingPanel; | |
30 | 29 |
31 char LogFileName[MAX_PATHNAME_LEN]; | 30 char LogFileName[MAX_PATHNAME_LEN]; |
32 | 31 |
33 double utc = 0; | 32 double utc = 0; |
34 double mjd = 0; | 33 double mjd = 0; |
49 | 48 |
50 int Acquiring = FALSE; | 49 int Acquiring = FALSE; |
51 | 50 |
52 long OldLogFilePtr = 0; | 51 long OldLogFilePtr = 0; |
53 double Ndiv = 8.0; | 52 double Ndiv = 8.0; |
53 | |
54 int settling = 0; | |
55 | |
56 enum { | |
57 MEASURING_N_NONE, | |
58 MEASURING_N_Lo, | |
59 MEASURING_N_Hg, | |
60 MEASURING_N_Sr, | |
61 }; | |
62 | |
63 int measuring = MEASURING_N_NONE; | |
54 | 64 |
55 enum { | 65 enum { |
56 N_MEASUREMENT_NONE, | 66 N_MEASUREMENT_NONE, |
57 N_MEASUREMENT_INIT, | 67 N_MEASUREMENT_INIT, |
58 N_MEASUREMENT_SLOPE, | 68 N_MEASUREMENT_SLOPE, |
60 N_MEASUREMENT_FREP_PLUS, | 70 N_MEASUREMENT_FREP_PLUS, |
61 N_MEASUREMENT_ADJUST_FREQ_MINUS, | 71 N_MEASUREMENT_ADJUST_FREQ_MINUS, |
62 N_MEASUREMENT_FREP_MINUS, | 72 N_MEASUREMENT_FREP_MINUS, |
63 }; | 73 }; |
64 | 74 |
65 int settling = 0; | 75 int Measuring_1 = N_MEASUREMENT_NONE; |
66 | 76 int Measuring_2 = N_MEASUREMENT_NONE; |
67 int Measuring_1 = FALSE; | 77 int Measuring_3 = N_MEASUREMENT_NONE; |
68 int Measuring_2 = FALSE; | |
69 int Measuring_3 = FALSE; | |
70 | 78 |
71 double FrequDDS1=110000000.0, FrequDDS4=110000000.0; | 79 double FrequDDS1=110000000.0, FrequDDS4=110000000.0; |
72 double Slope_1=0.0,Slope_2=0.0,Slope_3=0.0,Beatslope_2=0.0; | 80 double Slope_1=0.0, Slope_2=0.0, Slope_3=0.0, Beatslope_2=0.0; |
73 double SlopeTime1=40.0, SlopeTime2=40.0; SlopeTime3=40.0; | 81 double SlopeTime1=40.0, SlopeTime2=40.0, SlopeTime3=40.0; |
74 double Ch4Slope = 0.0; | 82 double Ch4Slope = 0.0; |
75 | 83 |
76 double N_1=0.0, N_2=0.0, N_3=0.0; | 84 double N_1=0.0, N_2=0.0, N_3=0.0; |
77 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; | 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; |
78 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; | 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; |
181 len = MIN(len, sizeof(msg) - 2); | 189 len = MIN(len, sizeof(msg) - 2); |
182 msg[len] = '\n'; | 190 msg[len] = '\n'; |
183 msg[len + 1] = '\0'; | 191 msg[len + 1] = '\0'; |
184 | 192 |
185 // display message | 193 // display message |
186 SetCtrlVal(MainPanel, PANEL_LOGGING, msg); | 194 SetCtrlVal(LoggingPanel, LOGGING_LOGGING, msg); |
187 } | 195 } |
188 | 196 |
189 | 197 |
190 muParserHandle_t initMathParser() | 198 muParserHandle_t initMathParser() |
191 { | 199 { |
251 if (InitCVIRTE (0, argv, 0) == 0) | 259 if (InitCVIRTE (0, argv, 0) == 0) |
252 return -1; | 260 return -1; |
253 | 261 |
254 if ((MainPanel = LoadPanel (0, "FXAnalyse.uir", PANEL)) < 0) | 262 if ((MainPanel = LoadPanel (0, "FXAnalyse.uir", PANEL)) < 0) |
255 return -1; | 263 return -1; |
256 if ((CalcN1Panel = LoadPanel (0, "FXAnalyse.uir", CALCN1)) < 0) | 264 if ((CalcNPanel = LoadPanel (MainPanel, "FXAnalyse.uir", CALCN)) < 0) |
257 return -1; | |
258 if ((CalcN2Panel = LoadPanel (0, "FXAnalyse.uir", CALCN2)) < 0) | |
259 return -1; | |
260 if ((CalcN3Panel = LoadPanel (0, "FXAnalyse.uir", CALCN3)) < 0) | |
261 return -1; | 265 return -1; |
262 if ((EstimateN3Panel = LoadPanel (MainPanel, "FXAnalyse.uir", ESTIMATEN3)) < 0) | 266 if ((EstimateN3Panel = LoadPanel (MainPanel, "FXAnalyse.uir", ESTIMATEN3)) < 0) |
267 return -1; | |
268 if ((LoggingPanel = LoadPanel (0, "FXAnalyse.uir", LOGGING)) < 0) | |
263 return -1; | 269 return -1; |
264 | 270 |
265 DisplayPanel (MainPanel); | 271 DisplayPanel (MainPanel); |
266 | 272 |
267 // initialize 4x AD9959 DDS box | 273 // initialize 4x AD9959 DDS box |
363 break; | 369 break; |
364 } | 370 } |
365 return 0; | 371 return 0; |
366 } | 372 } |
367 | 373 |
368 int CVICALLBACK CB_OnEventMain(int panel, int event, void *callbackData, int eventData1, int eventData2) | 374 int CVICALLBACK CB_OnEventMain(int panel, int event, |
375 void *callbackData, int eventData1, int eventData2) | |
369 { | 376 { |
370 int ActiveControl ; | 377 int ActiveControl ; |
371 int StepIndex ; | 378 int StepIndex ; |
372 double Step ; | 379 double Step ; |
373 | 380 |
755 stat_accumulate(&stat_ch4, Ch4); | 762 stat_accumulate(&stat_ch4, Ch4); |
756 | 763 |
757 if ((utc - t1_1) > SlopeTime1) { | 764 if ((utc - t1_1) > SlopeTime1) { |
758 Slope_1 = stat_math1.slope; | 765 Slope_1 = stat_math1.slope; |
759 Ch4Slope = stat_ch4.slope; | 766 Ch4Slope = stat_ch4.slope; |
760 SetCtrlVal(CalcN1Panel, CALCN1_SLOPE, Slope_1); | 767 SetCtrlVal(CalcNPanel, CALCN_SLOPE, Slope_1); |
761 | 768 |
762 // frep positive step | 769 // frep positive step |
763 DDS4xAD9912_FrequencyRampe(&DDS4xAD9912,1, FrequDDS1,(FrequDDS1+DeltakHz_1*1000), Step1/Ndiv); | 770 DDS4xAD9912_FrequencyRampe(&DDS4xAD9912,1, FrequDDS1,(FrequDDS1+DeltakHz_1*1000), Step1/Ndiv); |
764 SetCtrlVal(MainPanel, PANEL_DDS1, (FrequDDS1+DeltakHz_1*1000)); | 771 SetCtrlVal(MainPanel, PANEL_DDS1, (FrequDDS1+DeltakHz_1*1000)); |
765 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, (FrequDDS1+DeltakHz_1*1000)); | 772 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, (FrequDDS1+DeltakHz_1*1000)); |
847 Ch4Minus = Ch4Minus / n_1; | 854 Ch4Minus = Ch4Minus / n_1; |
848 n_1 = 0; | 855 n_1 = 0; |
849 | 856 |
850 // compute N1 | 857 // compute N1 |
851 N_1 = Signe1 * (2*Ndiv * DeltakHz_1 * 1000)/(Frepminus_1 - Frepplus_1 - Slope_1 * (t3_1 - t2_1)); | 858 N_1 = Signe1 * (2*Ndiv * DeltakHz_1 * 1000)/(Frepminus_1 - Frepplus_1 - Slope_1 * (t3_1 - t2_1)); |
852 SetCtrlVal(CalcN1Panel, CALCN1_N, N_1); | 859 SetCtrlVal(CalcNPanel, CALCN_N, N_1); |
853 | 860 |
854 t1_1 = 0.0; | 861 t1_1 = 0.0; |
855 t2_1 = 0.0; | 862 t2_1 = 0.0; |
856 t3_1 = 0.0; | 863 t3_1 = 0.0; |
857 Frepminus_1 = 0.0; | 864 Frepminus_1 = 0.0; |
903 stat_accumulate(&stat_ch2, Ch2); | 910 stat_accumulate(&stat_ch2, Ch2); |
904 | 911 |
905 if ((utc - t1_2) > SlopeTime2) { | 912 if ((utc - t1_2) > SlopeTime2) { |
906 Slope_2 = stat_math1.slope; | 913 Slope_2 = stat_math1.slope; |
907 Beatslope_2 = stat_ch2.slope; | 914 Beatslope_2 = stat_ch2.slope; |
908 SetCtrlVal(CalcN2Panel, CALCN2_SLOPE, Beatslope_2); | 915 SetCtrlVal(CalcNPanel, CALCN_SLOPE, Beatslope_2); |
909 | 916 |
910 // frep positive step | 917 // frep positive step |
911 double fDDS1 = FrequDDS1 + DeltakHz_2 * 1000; | 918 double fDDS1 = FrequDDS1 + DeltakHz_2 * 1000; |
912 printf("fDDS1 = %g\n", fDDS1); | 919 printf("fDDS1 = %g\n", fDDS1); |
913 DDS4xAD9912_FrequencyRampe(&DDS4xAD9912,1, FrequDDS1, fDDS1, Step2/Ndiv); | 920 DDS4xAD9912_FrequencyRampe(&DDS4xAD9912,1, FrequDDS1, fDDS1, Step2/Ndiv); |
1014 Delta10K_Minus = Delta10K_Minus / n_2; | 1021 Delta10K_Minus = Delta10K_Minus / n_2; |
1015 n_2 = 0; | 1022 n_2 = 0; |
1016 | 1023 |
1017 // compute N2 | 1024 // compute N2 |
1018 N_2 = (Signe2)*(-DeltaDDS3+Delta10K_Plus-Delta10K_Minus-Beatslope_2*(t3_2-t2_2) )/(Frepminus_2-Frepplus_2-Slope_2*(t3_2-t2_2)); | 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)); |
1019 SetCtrlVal(CalcN2Panel, CALCN2_N, N_2); | 1026 SetCtrlVal(CalcNPanel, CALCN_N, N_2); |
1020 | 1027 |
1021 // back to nominal frequency | 1028 // back to nominal frequency |
1022 DDS4xAD9912_FrequencyRampe (&DDS4xAD9912, 1, FrequDDS1-DeltakHz_2*1000,FrequDDS1, Step2/Ndiv ); | 1029 DDS4xAD9912_FrequencyRampe (&DDS4xAD9912, 1, FrequDDS1-DeltakHz_2*1000,FrequDDS1, Step2/Ndiv ); |
1023 SetCtrlVal(MainPanel, PANEL_DDS1, FrequDDS1); | 1030 SetCtrlVal(MainPanel, PANEL_DDS1, FrequDDS1); |
1024 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, FrequDDS1); | 1031 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, FrequDDS1); |
1155 // positive step measurement | 1162 // positive step measurement |
1156 Frepminus_3 = Frepminus_3 / n_3; | 1163 Frepminus_3 = Frepminus_3 / n_3; |
1157 | 1164 |
1158 // compute N3 | 1165 // compute N3 |
1159 N_3 = 1000.0 * DeltakHz_3 / (Frepplus_3 - Frepminus_3 + (2 * N3/N1 * Ndiv * DeltakHz_3 * 1000)); | 1166 N_3 = 1000.0 * DeltakHz_3 / (Frepplus_3 - Frepminus_3 + (2 * N3/N1 * Ndiv * DeltakHz_3 * 1000)); |
1160 SetCtrlVal(CalcN3Panel, CALCN3_N, N_3); | 1167 SetCtrlVal(CalcNPanel, CALCN_N, N_3); |
1161 | 1168 |
1162 t1_3=0.0; | 1169 t1_3=0.0; |
1163 t2_3=0.0; | 1170 t2_3=0.0; |
1164 t3_3=0.0; | 1171 t3_3=0.0; |
1165 n_3 = 0; | 1172 n_3 = 0; |
1699 | 1706 |
1700 | 1707 |
1701 int CVICALLBACK CB_OnAcceptN (int panel, int control, int event, | 1708 int CVICALLBACK CB_OnAcceptN (int panel, int control, int event, |
1702 void *callbackData, int eventData1, int eventData2) | 1709 void *callbackData, int eventData1, int eventData2) |
1703 { | 1710 { |
1704 switch (event) | 1711 switch (event) { |
1705 { | 1712 case EVENT_COMMIT: |
1706 case EVENT_COMMIT: | 1713 switch (measuring) { |
1707 if (panel == CalcN1Panel) { | 1714 case MEASURING_N_Lo: |
1708 N1 = round(N_1); | 1715 N1 = round(N_1); |
1709 SetCtrlVal(MainPanel, PANEL_N1CHOICE, N1); | 1716 SetCtrlVal(MainPanel, PANEL_N1CHOICE, N1); |
1717 break; | |
1718 case MEASURING_N_Hg: | |
1719 N2 = round(N_2); | |
1720 SetCtrlVal(MainPanel, PANEL_N2CHOICE, N2); | |
1721 break; | |
1722 case MEASURING_N_Sr: | |
1723 N3 = round(N_3); | |
1724 SetCtrlVal(MainPanel, PANEL_N3CHOICE, N3); | |
1725 break; | |
1726 } | |
1727 break; | |
1728 } | |
1729 return 0; | |
1730 } | |
1731 | |
1732 | |
1733 int CVICALLBACK CB_OnNCalculus (int panel, int control, int event, | |
1734 void *callbackData, int eventData1, int eventData2) | |
1735 { | |
1736 | |
1737 int visible; | |
1738 | |
1739 switch (event) { | |
1740 case EVENT_COMMIT: | |
1741 switch (control) { | |
1742 case PANEL_N1CALCULUS: | |
1743 GetPanelAttribute(CalcNPanel, ATTR_VISIBLE, &visible); | |
1744 if (! visible) { | |
1745 measuring = MEASURING_N_Lo; | |
1746 SetCtrlVal(CalcNPanel, CALCN_INTEGRATIONTIME, DeltaT_1); | |
1747 SetCtrlVal(CalcNPanel, CALCN_SLOPETIME, SlopeTime1); | |
1748 SetCtrlVal(CalcNPanel, CALCN_DELTAFREQ, DeltakHz_1); | |
1749 SetPanelAttribute(CalcNPanel, ATTR_TITLE, "Calculate N_Lo"); | |
1750 DisplayPanel(CalcNPanel); | |
1751 } | |
1752 break; | |
1753 case PANEL_N2CALCULUS: | |
1754 GetPanelAttribute(CalcNPanel, ATTR_VISIBLE, &visible); | |
1755 if (! visible) { | |
1756 measuring = MEASURING_N_Hg; | |
1757 SetCtrlVal(CalcNPanel, CALCN_INTEGRATIONTIME, DeltaT_2); | |
1758 SetCtrlVal(CalcNPanel, CALCN_SLOPETIME, SlopeTime2); | |
1759 SetCtrlVal(CalcNPanel, CALCN_DELTAFREQ, DeltakHz_2); | |
1760 SetPanelAttribute(CalcNPanel, ATTR_TITLE, "Calculate N_Hg"); | |
1761 DisplayPanel(CalcNPanel); | |
1762 } | |
1763 break; | |
1764 case PANEL_N3CALCULUS: | |
1765 GetPanelAttribute(CalcNPanel, ATTR_VISIBLE, &visible); | |
1766 if (! visible) { | |
1767 measuring = MEASURING_N_Sr; | |
1768 SetCtrlVal(CalcNPanel, CALCN_INTEGRATIONTIME, DeltaT_3); | |
1769 SetCtrlVal(CalcNPanel, CALCN_SLOPETIME, SlopeTime3); | |
1770 SetCtrlVal(CalcNPanel, CALCN_DELTAFREQ, DeltakHz_3); | |
1771 SetPanelAttribute(CalcNPanel, ATTR_TITLE, "Calculate N_Sr"); | |
1772 DisplayPanel(CalcNPanel); | |
1773 } | |
1774 break; | |
1710 } | 1775 } |
1711 if (panel == CalcN2Panel) { | 1776 break; |
1712 N2 = round(N_2); | 1777 } |
1713 SetCtrlVal(MainPanel, PANEL_N2CHOICE, N2); | 1778 return 0; |
1779 } | |
1780 | |
1781 | |
1782 int CVICALLBACK CB_OnStartNCalculus (int panel, int control, int event, | |
1783 void *callbackData, int eventData1, int eventData2) | |
1784 { | |
1785 switch (event) { | |
1786 case EVENT_COMMIT: | |
1787 switch (measuring) { | |
1788 case MEASURING_N_Lo: | |
1789 GetCtrlVal(CalcNPanel, CALCN_INTEGRATIONTIME, &DeltaT_1); | |
1790 GetCtrlVal(CalcNPanel, CALCN_SLOPETIME, &SlopeTime1); | |
1791 GetCtrlVal(CalcNPanel, CALCN_DELTAFREQ, &DeltakHz_1); | |
1792 Measuring_1 = TRUE; | |
1793 break; | |
1794 case MEASURING_N_Hg: | |
1795 GetCtrlVal(CalcNPanel, CALCN_INTEGRATIONTIME, &DeltaT_2); | |
1796 GetCtrlVal(CalcNPanel, CALCN_SLOPETIME, &SlopeTime2); | |
1797 GetCtrlVal(CalcNPanel, CALCN_DELTAFREQ, &DeltakHz_2); | |
1798 Measuring_2 = TRUE; | |
1799 break; | |
1800 case MEASURING_N_Sr: | |
1801 GetCtrlVal(CalcNPanel, CALCN_INTEGRATIONTIME, &DeltaT_3); | |
1802 GetCtrlVal(CalcNPanel, CALCN_SLOPETIME, &SlopeTime3); | |
1803 GetCtrlVal(CalcNPanel, CALCN_DELTAFREQ, &DeltakHz_3); | |
1804 Measuring_3 = TRUE; | |
1805 break; | |
1714 } | 1806 } |
1715 if (panel == CalcN3Panel) { | 1807 break; |
1716 N3 = round(N_3); | 1808 } |
1717 SetCtrlVal(MainPanel, PANEL_N3CHOICE, N3); | |
1718 } | |
1719 break; | |
1720 } | |
1721 return 0; | |
1722 } | |
1723 | |
1724 | |
1725 int CVICALLBACK CB_OnNCalculus (int panel, int control, int event, | |
1726 void *callbackData, int eventData1, int eventData2) | |
1727 { | |
1728 | |
1729 int PanelIsVisible, PanelTop, PanelLeft, PanelWidth ; | |
1730 | |
1731 switch (event) | |
1732 { | |
1733 case EVENT_COMMIT: | |
1734 | |
1735 if (control==PANEL_N1CALCULUS){ | |
1736 GetPanelAttribute (CalcN1Panel, ATTR_VISIBLE , &PanelIsVisible); | |
1737 if (PanelIsVisible) { | |
1738 } | |
1739 else { | |
1740 GetPanelAttribute (MainPanel, ATTR_TOP, &PanelTop) ; | |
1741 GetPanelAttribute (MainPanel, ATTR_LEFT, &PanelLeft) ; | |
1742 GetPanelAttribute (MainPanel, ATTR_WIDTH, &PanelWidth) ; | |
1743 SetPanelAttribute (CalcN1Panel, ATTR_TOP, PanelTop+170 ) ; | |
1744 SetPanelAttribute (CalcN1Panel, ATTR_LEFT, PanelLeft+PanelWidth+4 ) ; | |
1745 DisplayPanel(CalcN1Panel) ; | |
1746 } | |
1747 } | |
1748 if (control==PANEL_N2CALCULUS){ | |
1749 GetPanelAttribute (CalcN2Panel, ATTR_VISIBLE , &PanelIsVisible); | |
1750 if (PanelIsVisible) { | |
1751 } | |
1752 else { | |
1753 GetPanelAttribute (MainPanel, ATTR_TOP, &PanelTop) ; | |
1754 GetPanelAttribute (MainPanel, ATTR_LEFT, &PanelLeft) ; | |
1755 GetPanelAttribute (MainPanel, ATTR_WIDTH, &PanelWidth) ; | |
1756 SetPanelAttribute (CalcN2Panel, ATTR_TOP, PanelTop+310 ) ; | |
1757 SetPanelAttribute (CalcN2Panel, ATTR_LEFT, PanelLeft+PanelWidth+4 ) ; | |
1758 DisplayPanel(CalcN2Panel) ; | |
1759 } | |
1760 } | |
1761 if (control==PANEL_N3CALCULUS){ | |
1762 GetPanelAttribute (CalcN3Panel, ATTR_VISIBLE , &PanelIsVisible); | |
1763 if (PanelIsVisible) { | |
1764 } | |
1765 else { | |
1766 GetPanelAttribute (MainPanel, ATTR_TOP, &PanelTop) ; | |
1767 GetPanelAttribute (MainPanel, ATTR_LEFT, &PanelLeft) ; | |
1768 GetPanelAttribute (MainPanel, ATTR_WIDTH, &PanelWidth) ; | |
1769 SetPanelAttribute (CalcN3Panel, ATTR_TOP, PanelTop+480 ) ; | |
1770 SetPanelAttribute (CalcN3Panel, ATTR_LEFT, PanelLeft+PanelWidth+4 ) ; | |
1771 DisplayPanel(CalcN3Panel) ; | |
1772 } | |
1773 } | |
1774 break; | |
1775 } | |
1776 | |
1777 return 0; | |
1778 } | |
1779 | |
1780 | |
1781 int CVICALLBACK CB_OnStartNCalculus (int panel, int control, int event, | |
1782 void *callbackData, int eventData1, int eventData2) | |
1783 { | |
1784 | |
1785 switch (event) | |
1786 { | |
1787 case EVENT_COMMIT: | |
1788 if (panel == CalcN1Panel) | |
1789 Measuring_1 = TRUE; | |
1790 if (panel == CalcN2Panel) | |
1791 Measuring_2 = TRUE; | |
1792 if (panel == CalcN3Panel) | |
1793 Measuring_3 = TRUE; | |
1794 break; | |
1795 } | |
1796 | |
1797 return 0; | 1809 return 0; |
1798 } | 1810 } |
1799 | 1811 |
1800 | 1812 |
1801 | 1813 |
1802 int CVICALLBACK CB_OnNStop (int panel, int control, int event, | 1814 int CVICALLBACK CB_OnNStop (int panel, int control, int event, |
1803 void *callbackData, int eventData1, int eventData2) | 1815 void *callbackData, int eventData1, int eventData2) |
1804 { | 1816 { |
1805 int PanelIsVisible; | |
1806 | |
1807 switch (event) | |
1808 { | |
1809 case EVENT_COMMIT: | |
1810 if (panel == CalcN1Panel) { | |
1811 GetPanelAttribute (CalcN1Panel, ATTR_VISIBLE, &PanelIsVisible); | |
1812 if (PanelIsVisible) | |
1813 HidePanel(CalcN1Panel); | |
1814 | |
1815 Measuring_1 = FALSE; | |
1816 | |
1817 SetCtrlVal(MainPanel, PANEL_DDS1, FrequDDS1) ; | |
1818 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, FrequDDS1); | |
1819 SetCtrlVal(MainPanel, PANEL_DDS2, FrequencyDDSBesInit) ; | |
1820 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, FrequencyDDSBesInit); | |
1821 } | |
1822 if (panel == CalcN2Panel) { | |
1823 GetPanelAttribute (CalcN2Panel, ATTR_VISIBLE, &PanelIsVisible); | |
1824 if (PanelIsVisible) | |
1825 HidePanel(CalcN2Panel); | |
1826 | |
1827 Measuring_2 = FALSE; | |
1828 | |
1829 SetCtrlVal(MainPanel, PANEL_DDS1, FrequDDS1) ; | |
1830 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, FrequDDS1); | |
1831 SetCtrlVal(MainPanel, PANEL_DDS2, FrequencyDDSBesInit) ; | |
1832 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, FrequencyDDSBesInit); | |
1833 SetCtrlVal(MainPanel, PANEL_DDS3, FrequencyDDS3Init) ; | |
1834 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, FrequencyDDS3Init); | |
1835 } | |
1836 if (panel == CalcN3Panel) { | |
1837 GetPanelAttribute (CalcN3Panel, ATTR_VISIBLE, &PanelIsVisible); | |
1838 if (PanelIsVisible) | |
1839 HidePanel(CalcN3Panel); | |
1840 | |
1841 Measuring_3 = FALSE; | |
1842 } | |
1843 break; | |
1844 } | |
1845 return 0; | |
1846 } | |
1847 | |
1848 | |
1849 int CVICALLBACK CB_OnIntegrationTime (int panel, int control, int event, | |
1850 void *callbackData, int eventData1, int eventData2) | |
1851 { | |
1852 double Time ; | |
1853 | |
1854 switch (event) { | 1817 switch (event) { |
1855 case EVENT_COMMIT: | 1818 case EVENT_COMMIT: |
1856 if (panel == CalcN1Panel) { | 1819 HidePanel(CalcNPanel); |
1857 GetCtrlVal(CalcN1Panel, CALCN1_INTEGRATIONTIME, &Time) ; | 1820 switch (measuring) { |
1858 DeltaT_1=Time; | 1821 case MEASURING_N_Lo: |
1859 } | 1822 Measuring_1 = FALSE; |
1860 if (panel == CalcN2Panel) { | 1823 SetCtrlVal(MainPanel, PANEL_DDS1, FrequDDS1); |
1861 GetCtrlVal(CalcN2Panel, CALCN2_INTEGRATIONTIME, &Time) ; | 1824 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, FrequDDS1); |
1862 DeltaT_2=Time; | 1825 SetCtrlVal(MainPanel, PANEL_DDS2, FrequencyDDSBesInit); |
1863 } | 1826 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, FrequencyDDSBesInit); |
1864 if (panel == CalcN3Panel) { | 1827 break; |
1865 GetCtrlVal(CalcN3Panel, CALCN3_INTEGRATIONTIME, &Time) ; | 1828 case MEASURING_N_Hg: |
1866 DeltaT_3=Time; | 1829 Measuring_2 = FALSE; |
1867 } | 1830 SetCtrlVal(MainPanel, PANEL_DDS1, FrequDDS1); |
1868 break; | 1831 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, FrequDDS1); |
1869 } | 1832 SetCtrlVal(MainPanel, PANEL_DDS2, FrequencyDDSBesInit); |
1870 return 0; | 1833 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 2, FrequencyDDSBesInit); |
1871 } | 1834 SetCtrlVal(MainPanel, PANEL_DDS3, FrequencyDDS3Init); |
1872 | 1835 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 3, FrequencyDDS3Init); |
1873 | 1836 break; |
1874 int CVICALLBACK CB_OnDeltaFreq (int panel, int control, int event, | 1837 case MEASURING_N_Sr: |
1875 void *callbackData, int eventData1, int eventData2) | 1838 Measuring_3 = FALSE; |
1876 { | 1839 break; |
1877 double Frequ ; | |
1878 | |
1879 switch (event) | |
1880 { | |
1881 case EVENT_COMMIT: | |
1882 if (panel == CalcN1Panel) { | |
1883 GetCtrlVal(CalcN1Panel, CALCN1_DELTAFREQ, &Frequ); | |
1884 DeltakHz_1 = Frequ; | |
1885 } | |
1886 if (panel == CalcN2Panel) { | |
1887 GetCtrlVal(CalcN2Panel, CALCN2_DELTAFREQ, &Frequ) ; | |
1888 DeltakHz_2=Frequ; | |
1889 } | |
1890 if (panel == CalcN3Panel) { | |
1891 GetCtrlVal(CalcN3Panel, CALCN3_DELTAFREQ, &Frequ) ; | |
1892 DeltakHz_3=Frequ; | |
1893 } | 1840 } |
1894 break; | 1841 break; |
1895 } | 1842 } |
1896 return 0; | 1843 return 0; |
1897 } | 1844 } |
1965 } | 1912 } |
1966 return 0; | 1913 return 0; |
1967 } | 1914 } |
1968 | 1915 |
1969 | 1916 |
1970 int CVICALLBACK CB_OnSlopeTime (int panel, int control, int event, | |
1971 void *callbackData, int eventData1, int eventData2) | |
1972 { | |
1973 double Time ; | |
1974 | |
1975 switch (event) | |
1976 { | |
1977 case EVENT_COMMIT: | |
1978 if (panel == CalcN1Panel) { | |
1979 GetCtrlVal(CalcN1Panel, CALCN1_SLOPETIME, &Time); | |
1980 SlopeTime1=Time; | |
1981 } | |
1982 if (panel == CalcN2Panel) { | |
1983 GetCtrlVal(CalcN2Panel, CALCN2_SLOPETIME, &Time); | |
1984 SlopeTime2=Time; | |
1985 } | |
1986 if (panel == CalcN3Panel) { | |
1987 GetCtrlVal(CalcN3Panel, CALCN3_SLOPETIME, &Time); | |
1988 SlopeTime3=Time; | |
1989 } | |
1990 break; | |
1991 } | |
1992 return 0; | |
1993 } | |
1994 | |
1995 | |
1996 int CVICALLBACK CB_OnChangeNdiv (int panel, int control, int event, | 1917 int CVICALLBACK CB_OnChangeNdiv (int panel, int control, int event, |
1997 void *callbackData, int eventData1, int eventData2) | 1918 void *callbackData, int eventData1, int eventData2) |
1998 { | 1919 { |
1999 double NewN ; | 1920 switch (event) { |
2000 | 1921 case EVENT_COMMIT: |
2001 switch (event) | 1922 GetCtrlVal(MainPanel, PANEL_CHANGENDIV, &Ndiv); |
2002 { | 1923 FrequDDS1 = 880000000.0 / Ndiv; |
2003 case EVENT_COMMIT: | 1924 SetCtrlVal(MainPanel, PANEL_DDS1, FrequDDS1); |
2004 if (control==PANEL_CHANGENDIV){ | 1925 DDS4xAD9912_SetFrequency(&DDS4xAD9912, 1, FrequDDS1); |
2005 GetCtrlVal(MainPanel, PANEL_CHANGENDIV, &NewN) ; | 1926 break; |
2006 Ndiv=NewN; | 1927 } |
2007 FrequDDS1=880000000.0/Ndiv; | |
2008 DeltakHz_1=1800.0*8/Ndiv; | |
2009 DeltakHz_2=1500.0*8/Ndiv; | |
2010 SetCtrlVal(MainPanel, PANEL_DDS1, FrequDDS1) ; | |
2011 DDS4xAD9912_SetFrequency(&DDS4xAD9912,1,FrequDDS1); | |
2012 SetCtrlVal(CalcN1Panel, CALCN1_DELTAFREQ, DeltakHz_1) ; | |
2013 SetCtrlVal(CalcN2Panel, CALCN2_DELTAFREQ, DeltakHz_2) ; | |
2014 } | |
2015 | |
2016 break; | |
2017 | |
2018 } | |
2019 return 0; | 1928 return 0; |
2020 } | 1929 } |
2021 | 1930 |
2022 | 1931 |
2023 int CVICALLBACK CB_MeasureSlope (int panel, int control, int event, | 1932 int CVICALLBACK CB_MeasureSlope (int panel, int control, int event, |
2304 break; | 2213 break; |
2305 } | 2214 } |
2306 return 0; | 2215 return 0; |
2307 } | 2216 } |
2308 | 2217 |
2218 int CVICALLBACK CB_ShowLog (int panel, int control, int event, | |
2219 void *callbackData, int eventData1, int eventData2) | |
2220 { | |
2221 switch (event) | |
2222 { | |
2223 case EVENT_COMMIT: | |
2224 SetPanelAttribute(LoggingPanel, ATTR_VISIBLE, 1); | |
2225 break; | |
2226 } | |
2227 return 0; | |
2228 } | |
2229 | |
2230 int CVICALLBACK CB_OnLoggingPanelEvent(int panel, int event, | |
2231 void *callbackData, int eventData1, int eventData2) | |
2232 { | |
2233 switch (event) | |
2234 { | |
2235 case EVENT_CLOSE: | |
2236 SetPanelAttribute(LoggingPanel, ATTR_VISIBLE, 0); | |
2237 break; | |
2238 } | |
2239 return 0; | |
2240 } |