changeset 119:f9fb17fb64cc

Add Sr frequency logging to disk and to Sr data logger
author Daniele Nicolodi <daniele.nicolodi@obspm.fr>
date Thu, 12 Sep 2013 18:01:49 +0200
parents 43b35f4aae78
children 84fb0796936b
files FXAnalyse.c FXAnalyse.h FXAnalyse.uir
diffstat 3 files changed, 119 insertions(+), 69 deletions(-) [+]
line wrap: on
line diff
--- a/FXAnalyse.c	Thu Sep 12 15:49:27 2013 +0200
+++ b/FXAnalyse.c	Thu Sep 12 18:01:49 2013 +0200
@@ -1,3 +1,4 @@
+#include <tcpsupp.h>
 #include <utility.h>
 #include <ansi_c.h>
 #include <cvirte.h>		
@@ -187,6 +188,12 @@
 
 #define MIN(x, y) (x) < (y) ? (x) : (y)
 
+// MJD functiom used by the Sr programs
+static inline double utc2mjd(double utc)
+{
+	return 15020.0 + utc / 86400.0;
+}
+
 void logmsg(const char *frmt, ...)
 {
 	char msg[1024];
@@ -213,6 +220,30 @@
 	SetCtrlVal(LoggingPanel, LOGGING_LOGGING, msg);
 }
 
+// Sr data logger
+int sendLogger(const char* id, double utc, double data)
+{
+	static unsigned int handle = 0;
+	char buffer[1024];
+
+	// try to connect and quit if unsuccessfull
+	if (handle == 0) {
+		if (ConnectToTCPServer(&handle, 3491, "145.238.204.146", NULL, NULL, 1) < 0) {
+			logmsg("Sr data logger connection error");
+			return -1;
+		}
+		logmsg("connected to Sr data logger");
+	}
+
+	snprintf(buffer, sizeof(buffer), "%s %.7f %.8f", id, utc2mjd(utc), data);
+	if (ClientTCPWrite(handle, buffer, strlen(buffer) + 1, 0) < 0) {
+		// try to reconnect and resend
+		handle = 0;
+		sendLogger(id, utc, data);
+	}
+	
+	return 0;
+}
 
 muParserHandle_t initMathParser() 
 {
@@ -1375,6 +1406,19 @@
 					writeData("C:\\Femto\\Results", "Hg", id, timestr, utc, Math3);
 				}
 				
+				// write Sr frequency (Math4) to disk
+				GetCtrlVal(MainPanel, PANEL_CHECKBOX_MATH4SAVE, &save);
+				if (save) {
+					writeData(DATAFOLDER, "Sr", id, timestr, utc, Math4);
+				}
+				
+				// send Sr frequency (Math4) to Sr data logger
+				GetCtrlVal(MainPanel, PANEL_SR_LOGGER, &save);
+				if (save) {
+					sendLogger("FEMTO2", utc, Math4);
+				}
+				
+				
 				// write ExtraMath (Math5) to disk
 				GetCtrlVal(MainPanel, PANEL_CHECKBOX_MATH5SAVE, &save);
 				if (save) {
--- a/FXAnalyse.h	Thu Sep 12 15:49:27 2013 +0200
+++ b/FXAnalyse.h	Thu Sep 12 18:01:49 2013 +0200
@@ -81,75 +81,81 @@
 #define  PANEL_CHECKBOX_MATH5ALLAN        44      /* control type: radioButton, callback function: CB_OnAllanPlot */
 #define  PANEL_CHECKBOX_MATH3PLOT         45      /* control type: radioButton, callback function: CB_OnFreqPlot */
 #define  PANEL_CHECKBOX_MATH5SAVE         46      /* control type: radioButton, callback function: (none) */
-#define  PANEL_CHECKBOX_MATH4SAVE         47      /* control type: radioButton, callback function: (none) */
-#define  PANEL_CHECKBOX_MATH3ALLAN        48      /* control type: radioButton, callback function: CB_OnAllanPlot */
-#define  PANEL_MATHSTRING4                49      /* control type: string, callback function: CB_ChangeMath */
-#define  PANEL_TEXTMSG_17                 50      /* control type: textMsg, callback function: (none) */
-#define  PANEL_MATH2                      51      /* control type: numeric, callback function: (none) */
-#define  PANEL_SPLITTER_15                52      /* control type: splitter, callback function: (none) */
-#define  PANEL_SPLITTER_12                53      /* control type: splitter, callback function: (none) */
-#define  PANEL_CHECKBOX_MATH2PLOT         54      /* control type: radioButton, callback function: CB_OnFreqPlot */
-#define  PANEL_CHECKBOX_MATH3SAVE         55      /* control type: radioButton, callback function: (none) */
-#define  PANEL_CHECKBOX_MATH2SAVE         56      /* control type: radioButton, callback function: (none) */
-#define  PANEL_CHECKBOX_MATH2ALLAN        57      /* control type: radioButton, callback function: CB_OnAllanPlot */
-#define  PANEL_TEXTMSG_7                  58      /* control type: textMsg, callback function: (none) */
-#define  PANEL_MATHSTRING3                59      /* control type: string, callback function: CB_ChangeMath */
-#define  PANEL_MATH1                      60      /* control type: numeric, callback function: (none) */
-#define  PANEL_SPLITTER_6                 61      /* control type: splitter, callback function: (none) */
-#define  PANEL_TEXTMSG_18                 62      /* control type: textMsg, callback function: (none) */
-#define  PANEL_TEXTMSG_6                  63      /* control type: textMsg, callback function: (none) */
-#define  PANEL_TEXTMSG_8                  64      /* control type: textMsg, callback function: (none) */
-#define  PANEL_TEXTMSG_19                 65      /* control type: textMsg, callback function: (none) */
-#define  PANEL_MATHSTRING1                66      /* control type: string, callback function: CB_ChangeMath */
-#define  PANEL_TEXTMSG_9                  67      /* control type: textMsg, callback function: (none) */
-#define  PANEL_TEXTMSG_10                 68      /* control type: textMsg, callback function: (none) */
-#define  PANEL_MATHSTRING2                69      /* control type: string, callback function: CB_ChangeMath */
-#define  PANEL_TEXTMSG_16                 70      /* control type: textMsg, callback function: (none) */
-#define  PANEL_SPLITTER_11                71      /* control type: splitter, callback function: (none) */
-#define  PANEL_SPLITTER_16                72      /* control type: splitter, callback function: (none) */
-#define  PANEL_SPLITTER_9                 73      /* control type: splitter, callback function: (none) */
-#define  PANEL_SPLITTER_3                 74      /* control type: splitter, callback function: (none) */
-#define  PANEL_MINUS10KDDS1               75      /* control type: command, callback function: CB_OnMinus10k */
-#define  PANEL_MINUS10KDDS4               76      /* control type: command, callback function: CB_OnMinus10k */
-#define  PANEL_MINUS10KDDS3               77      /* control type: command, callback function: CB_OnMinus10k */
-#define  PANEL_MINUS10KDDS2               78      /* control type: command, callback function: CB_OnMinus10k */
-#define  PANEL_PLUS10KDDS4                79      /* control type: command, callback function: CB_OnPlus10k */
-#define  PANEL_PLUS10KDDS3                80      /* control type: command, callback function: CB_OnPlus10k */
-#define  PANEL_PLUS10KDDS1                81      /* control type: command, callback function: CB_OnPlus10k */
-#define  PANEL_PLUS10KDDS2                82      /* control type: command, callback function: CB_OnPlus10k */
-#define  PANEL_TEXTMSG_11                 83      /* control type: textMsg, callback function: (none) */
-#define  PANEL_MATHSTRING5                84      /* control type: textBox, callback function: CB_ChangeMath */
-#define  PANEL_SPLITTER_8                 85      /* control type: splitter, callback function: (none) */
-#define  PANEL_UTC                        86      /* control type: numeric, callback function: (none) */
-#define  PANEL_TIME                       87      /* control type: string, callback function: (none) */
-#define  PANEL_SPLITTER_14                88      /* control type: splitter, callback function: (none) */
-#define  PANEL_SPLITTER_13                89      /* control type: splitter, callback function: (none) */
-#define  PANEL_DDS4                       90      /* control type: numeric, callback function: CB_ChangeDDSOut */
-#define  PANEL_SPLITTER_2                 91      /* control type: splitter, callback function: (none) */
-#define  PANEL_DDS3                       92      /* control type: numeric, callback function: CB_ChangeDDSOut */
-#define  PANEL_N1CALCULUS                 93      /* control type: command, callback function: CB_OnNCalculus */
-#define  PANEL_FINDSIGN3                  94      /* control type: command, callback function: CB_OnFindSign */
-#define  PANEL_SIGN3                      95      /* control type: numeric, callback function: CB_Sign3 */
-#define  PANEL_FINDSIGN2                  96      /* control type: command, callback function: CB_OnFindSign */
-#define  PANEL_SIGN2                      97      /* control type: numeric, callback function: (none) */
-#define  PANEL_FINDSIGN1                  98      /* control type: command, callback function: CB_OnFindSign */
-#define  PANEL_SIGN1                      99      /* control type: numeric, callback function: (none) */
-#define  PANEL_FIND10K3                   100     /* control type: command, callback function: CB_OnFind275K */
-#define  PANEL_FIND275K2                  101     /* control type: command, callback function: CB_OnFind275K */
-#define  PANEL_RESETSLOPE                 102     /* control type: command, callback function: CB_OnResetSlope */
-#define  PANEL_CHECKBOX_STOPIFAUTODE      103     /* control type: radioButton, callback function: CB_OnStopSlopeCancellingOnUnlocked */
-#define  PANEL_CHECKBOX_RECENTER          104     /* control type: radioButton, callback function: CB_OnReCentering */
-#define  PANEL_CHECKBOX_KEEPSLOPE         105     /* control type: radioButton, callback function: CB_OnCROX */
-#define  PANEL_CHECKBOX_KEEP              106     /* control type: radioButton, callback function: CB_OnCROX */
-#define  PANEL_SLOPE_REFERENCE            107     /* control type: ring, callback function: CB_OnSlopeReference */
-#define  PANEL_ESTIMATE_N3                108     /* control type: command, callback function: CB_OnEstimateN */
-#define  PANEL_INVERT_SLOPE_SIGN          109     /* control type: radioButton, callback function: CB_InvertSlopeSign */
-#define  PANEL_MEASURE_SLOPE              110     /* control type: LED, callback function: CB_MeasureSlope */
-#define  PANEL_SLOPE_MEASURED             111     /* control type: numeric, callback function: (none) */
-#define  PANEL_RESET_DEDRIFT_DDS          112     /* control type: command, callback function: CB_ResetDedriftDDS */
-#define  PANEL_SHOWLOG                    113     /* control type: command, callback function: CB_ShowLog */
-#define  PANEL_SAVE_RAW_DATA              114     /* control type: radioButton, callback function: (none) */
-#define  PANEL_SAVE_DDS_FREQS             115     /* control type: radioButton, callback function: (none) */
+#define  PANEL_SR_LOGGER                  47      /* control type: radioButton, callback function: (none) */
+#define  PANEL_CHECKBOX_MATH4SAVE         48      /* control type: radioButton, callback function: (none) */
+#define  PANEL_CHECKBOX_MATH3ALLAN        49      /* control type: radioButton, callback function: CB_OnAllanPlot */
+#define  PANEL_MATHSTRING4                50      /* control type: string, callback function: CB_ChangeMath */
+#define  PANEL_TEXTMSG_17                 51      /* control type: textMsg, callback function: (none) */
+#define  PANEL_MATH2                      52      /* control type: numeric, callback function: (none) */
+#define  PANEL_SPLITTER_15                53      /* control type: splitter, callback function: (none) */
+#define  PANEL_SPLITTER_12                54      /* control type: splitter, callback function: (none) */
+#define  PANEL_CHECKBOX_MATH2PLOT         55      /* control type: radioButton, callback function: CB_OnFreqPlot */
+#define  PANEL_CHECKBOX_MATH3SAVE         56      /* control type: radioButton, callback function: (none) */
+#define  PANEL_CHECKBOX_MATH2SAVE         57      /* control type: radioButton, callback function: (none) */
+#define  PANEL_CHECKBOX_MATH2ALLAN        58      /* control type: radioButton, callback function: CB_OnAllanPlot */
+#define  PANEL_TEXTMSG_7                  59      /* control type: textMsg, callback function: (none) */
+#define  PANEL_MATHSTRING3                60      /* control type: string, callback function: CB_ChangeMath */
+#define  PANEL_MATH1                      61      /* control type: numeric, callback function: (none) */
+#define  PANEL_SPLITTER_6                 62      /* control type: splitter, callback function: (none) */
+#define  PANEL_TEXTMSG_18                 63      /* control type: textMsg, callback function: (none) */
+#define  PANEL_TEXTMSG_6                  64      /* control type: textMsg, callback function: (none) */
+#define  PANEL_TEXTMSG_8                  65      /* control type: textMsg, callback function: (none) */
+#define  PANEL_TEXTMSG_19                 66      /* control type: textMsg, callback function: (none) */
+#define  PANEL_MATHSTRING1                67      /* control type: string, callback function: CB_ChangeMath */
+#define  PANEL_TEXTMSG_9                  68      /* control type: textMsg, callback function: (none) */
+#define  PANEL_TEXTMSG_10                 69      /* control type: textMsg, callback function: (none) */
+#define  PANEL_MATHSTRING2                70      /* control type: string, callback function: CB_ChangeMath */
+#define  PANEL_TEXTMSG_16                 71      /* control type: textMsg, callback function: (none) */
+#define  PANEL_SPLITTER_11                72      /* control type: splitter, callback function: (none) */
+#define  PANEL_SPLITTER_16                73      /* control type: splitter, callback function: (none) */
+#define  PANEL_SPLITTER_9                 74      /* control type: splitter, callback function: (none) */
+#define  PANEL_SPLITTER_3                 75      /* control type: splitter, callback function: (none) */
+#define  PANEL_MINUS10KDDS1               76      /* control type: command, callback function: CB_OnMinus10k */
+#define  PANEL_MINUS10KDDS4               77      /* control type: command, callback function: CB_OnMinus10k */
+#define  PANEL_MINUS10KDDS3               78      /* control type: command, callback function: CB_OnMinus10k */
+#define  PANEL_MINUS10KDDS2               79      /* control type: command, callback function: CB_OnMinus10k */
+#define  PANEL_PLUS10KDDS4                80      /* control type: command, callback function: CB_OnPlus10k */
+#define  PANEL_PLUS10KDDS3                81      /* control type: command, callback function: CB_OnPlus10k */
+#define  PANEL_PLUS10KDDS1                82      /* control type: command, callback function: CB_OnPlus10k */
+#define  PANEL_PLUS10KDDS2                83      /* control type: command, callback function: CB_OnPlus10k */
+#define  PANEL_TEXTMSG_11                 84      /* control type: textMsg, callback function: (none) */
+#define  PANEL_MATHSTRING5                85      /* control type: textBox, callback function: CB_ChangeMath */
+#define  PANEL_SPLITTER_8                 86      /* control type: splitter, callback function: (none) */
+#define  PANEL_UTC                        87      /* control type: numeric, callback function: (none) */
+#define  PANEL_TIME                       88      /* control type: string, callback function: (none) */
+#define  PANEL_SPLITTER_14                89      /* control type: splitter, callback function: (none) */
+#define  PANEL_SPLITTER_13                90      /* control type: splitter, callback function: (none) */
+#define  PANEL_DDS4                       91      /* control type: numeric, callback function: CB_ChangeDDSOut */
+#define  PANEL_SPLITTER_2                 92      /* control type: splitter, callback function: (none) */
+#define  PANEL_DDS3                       93      /* control type: numeric, callback function: CB_ChangeDDSOut */
+#define  PANEL_N1CALCULUS                 94      /* control type: command, callback function: CB_OnNCalculus */
+#define  PANEL_FINDSIGN3                  95      /* control type: command, callback function: CB_OnFindSign */
+#define  PANEL_SIGN3                      96      /* control type: numeric, callback function: CB_Sign3 */
+#define  PANEL_FINDSIGN2                  97      /* control type: command, callback function: CB_OnFindSign */
+#define  PANEL_SIGN2                      98      /* control type: numeric, callback function: (none) */
+#define  PANEL_FINDSIGN1                  99      /* control type: command, callback function: CB_OnFindSign */
+#define  PANEL_SIGN1                      100     /* control type: numeric, callback function: (none) */
+#define  PANEL_FIND10K3                   101     /* control type: command, callback function: CB_OnFind275K */
+#define  PANEL_FIND275K2                  102     /* control type: command, callback function: CB_OnFind275K */
+#define  PANEL_RESETSLOPE                 103     /* control type: command, callback function: CB_OnResetSlope */
+#define  PANEL_CHECKBOX_STOPIFAUTODE      104     /* control type: radioButton, callback function: CB_OnStopSlopeCancellingOnUnlocked */
+#define  PANEL_CHECKBOX_RECENTER          105     /* control type: radioButton, callback function: CB_OnReCentering */
+#define  PANEL_CHECKBOX_KEEPSLOPE         106     /* control type: radioButton, callback function: CB_OnCROX */
+#define  PANEL_CHECKBOX_KEEP              107     /* control type: radioButton, callback function: CB_OnCROX */
+#define  PANEL_SLOPE_REFERENCE            108     /* control type: ring, callback function: CB_OnSlopeReference */
+#define  PANEL_ESTIMATE_N3                109     /* control type: command, callback function: CB_OnEstimateN */
+#define  PANEL_INVERT_SLOPE_SIGN          110     /* control type: radioButton, callback function: CB_InvertSlopeSign */
+#define  PANEL_MEASURE_SLOPE              111     /* control type: LED, callback function: CB_MeasureSlope */
+#define  PANEL_SLOPE_MEASURED             112     /* control type: numeric, callback function: (none) */
+#define  PANEL_RESET_DEDRIFT_DDS          113     /* control type: command, callback function: CB_ResetDedriftDDS */
+#define  PANEL_SHOWLOG                    114     /* control type: command, callback function: CB_ShowLog */
+#define  PANEL_SAVE_RAW_DATA              115     /* control type: radioButton, callback function: (none) */
+#define  PANEL_SAVE_DDS_FREQS             116     /* control type: radioButton, callback function: (none) */
+
+
+     /* Control Arrays: */
+
+          /* (no control arrays in the resource file) */
 
 
      /* Menu Bars, Menus, and Menu Items: */
Binary file FXAnalyse.uir has changed