diff FXAnalyse.c @ 237:a41c872bce48

Enforce the number of counter channels when writing data to disk
author Daniele Nicolodi <daniele.nicolodi@obspm.fr>
date Thu, 29 Jan 2015 18:25:48 +0100
parents 95572be109a4
children 78fdba868884
line wrap: on
line diff
--- a/FXAnalyse.c	Thu Jan 29 18:24:53 2015 +0100
+++ b/FXAnalyse.c	Thu Jan 29 18:25:48 2015 +0100
@@ -455,13 +455,15 @@
 	}
 
 struct datafile datafiles[] = {
-     DATAFILE("Raw", event.data, 4, PANEL_SAVE_RAW, TRUE),
-     DATAFILE("DDS", ad9912.frequency, 4, PANEL_SAVE_DDS, FALSE),
-     DATAFILE("Lo", &Math2, 1, PANEL_SAVE_LO, FALSE),
-     DATAFILE("Hg", &Math3, 1, PANEL_SAVE_HG, FALSE),
-     DATAFILE("Sr", &Math4, 1, PANEL_SAVE_SR, FALSE),
-     DATAFILE("Ex", &Math5, 1, PANEL_SAVE_EXTRA, FALSE),
-     { NULL, }
+	// set the counter channels number to zero. it will
+	// be updated when the configuration file is read
+	DATAFILE("Raw", event.data, 0, PANEL_SAVE_RAW, TRUE),
+	DATAFILE("DDS", ad9912.frequency, 4, PANEL_SAVE_DDS, FALSE),
+	DATAFILE("Lo", &Math2, 1, PANEL_SAVE_LO, FALSE),
+	DATAFILE("Hg", &Math3, 1, PANEL_SAVE_HG, FALSE),
+	DATAFILE("Sr", &Math4, 1, PANEL_SAVE_SR, FALSE),
+	DATAFILE("Ex", &Math5, 1, PANEL_SAVE_EXTRA, FALSE),
+	{ NULL, }
 };
 
 
@@ -562,6 +564,7 @@
 int main (int argc, char *argv[])
 {
 	int rv;
+	int nchan;
 	double frequency;
 	char expr[1024];
 	char host[256];
@@ -583,6 +586,13 @@
 	IniText configuration = Ini_New(TRUE);
 	Ini_ReadFromFile(configuration, path);
 
+	// KK counter channel number
+	rv = Ini_GetInt(configuration, "KK", "nchan", &nchan);
+	if (rv < 1)
+		nchan = 4;
+	// update number of channels to save to disk
+	datafiles[0].nchan = nchan;
+	
 	// data folder
 	rv = Ini_GetStringCopy(configuration, "data", "folder", &datafolder);
 	if (rv > 0) {
@@ -607,7 +617,7 @@
 		logmessage(ERROR, "ad9956 init erorr=%d", -rv);
 	ad9956_set_w(&ad9956, dedrift.fDDS, dedrift.applied);
 	
-	// ad9912 configuration parameters
+	// AD9912 configuration parameters
 	rv = Ini_GetStringIntoBuffer(configuration, "AD9912", "host", host, sizeof(host));
 	if (! rv)
 		return -1;