changeset 170:a4fcebb5941b

Make data folder configurable in configuration file
author Daniele Nicolodi <daniele.nicolodi@obspm.fr>
date Fri, 14 Feb 2014 16:58:19 +0100
parents 97112b45b838
children 7d0c8319c496
files FXAnalyse.c
diffstat 1 files changed, 18 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/FXAnalyse.c	Fri Feb 14 16:58:19 2014 +0100
+++ b/FXAnalyse.c	Fri Feb 14 16:58:19 2014 +0100
@@ -22,14 +22,18 @@
 #include "logging.h"
 
 
-#define DATAFOLDER "Z:\\Measures-2014"
-
 #define FREP_STEP_SIZE 50000.0
-
 #define SPEED_OF_LIGHT 299792458.0 // m/s
 #define SR_WAVELENGTH  698.4460    // nm
 #define HG_WAVELENGTH 1062.4000    // nm
 
+// select which data provider to use
+#ifdef NDEBUG
+#define DataProvider KKDataProvider
+#else
+#define DataProvider FakeDataProvider
+#endif
+
 
 // data acquisition status
 int acquiring;
@@ -38,12 +42,6 @@
 // data provider thread
 CmtThreadFunctionID dataProviderThread;
 
-// select which data provider to use
-#ifdef NDEBUG
-#define DataProvider KKDataProvider
-#else
-#define DataProvider FakeDataProvider
-#endif
 
 struct event event;
 double utc;
@@ -269,6 +267,8 @@
 
 
 // data loggging
+static char *datafolder;
+
 struct datafile {
 	char *name;
 	double *data;
@@ -328,7 +328,7 @@
 static inline void datafile_append(struct datafile *d, char *id, char *timestr)
 {
 	if (d->write)
-		write_data(DATAFOLDER, d->name, id, timestr, utc, d->data, d->nchan);
+		write_data(datafolder, d->name, id, timestr, utc, d->data, d->nchan);
 }
 
 
@@ -400,6 +400,14 @@
 	IniText configuration = Ini_New(TRUE);
 	Ini_ReadFromFile(configuration, path);
 
+	// data folder
+	rv = Ini_GetStringCopy(configuration, "data", "folder", &datafolder);
+	if (rv <= 0) {
+		logmessage(ERROR, "data folder not configured in %s", path);
+		// do not allow to start the acquisition
+		SetCtrlAttribute(MainPanel, PANEL_STARTBUTTON, ATTR_DIMMED, TRUE);
+	}
+	
 	// get AD9956 configuration parameters
 	char host[256];
 	int port;