OSDN Git Service

記録パス設定 記録CH設定 ファイル書込タイミング
[scilog/scilog.git] / conf.c
diff --git a/conf.c b/conf.c
index da6e9af..ce7fc5e 100644 (file)
--- a/conf.c
+++ b/conf.c
@@ -6,33 +6,88 @@
 
 #include "conf.h"
 #include "debug_print.h"
+#include "ad_ring.h"
+
+// ミューテックス
+static pthread_mutex_t mutex_conf = PTHREAD_MUTEX_INITIALIZER;
 
 //
-/**** Station ID ***************************************************
+/**** 記録周波数 ***************************************************
 */
-#define        SID_MAX 16
-static char    gsid[SID_MAX + 1];
+// 50,25,10,5,2,1
+static int     freq;
 
-// ミューテックス
-static pthread_mutex_t mutex_sid = PTHREAD_MUTEX_INITIALIZER;
+void conf_freq_set(int f)
+{
+pthread_mutex_lock(&mutex_conf);
+       freq = f;
+pthread_mutex_unlock(&mutex_conf);
+}
+int conf_freq_get(void)
+{
+       int     f;
+pthread_mutex_lock(&mutex_conf);
+       f = freq;
+pthread_mutex_unlock(&mutex_conf);
+       return f;
+}
+//
+/**** Gain ***************************************************
+*/
+/*
+       0=1/8, 1=1/4, 2=1/2, 3=1, 4=2, 5=4
+       6=8, 7=16, 8=32, 9=64, 10=128
+*/
+static int     gain;
 
-void sid_set(char *s)
+void conf_gain_set(int f)
 {
-pthread_mutex_lock(&mutex_sid);
-       strncpy(gsid, s, SID_MAX);
-       gsid[SID_MAX] = 0;
-pthread_mutex_unlock(&mutex_sid);
+pthread_mutex_lock(&mutex_conf);
+       gain = f;
+pthread_mutex_unlock(&mutex_conf);
 }
-void sid_get(char *s)
+int conf_gain_get(void)
+{
+       int     f;
+pthread_mutex_lock(&mutex_conf);
+       f = gain;
+pthread_mutex_unlock(&mutex_conf);
+       return f;
+}
+
+/**** Linux時刻セット ***************************************************
+*/
+// 1=ON
+static int linux_time_set;
+void conf_linux_time_set_set(int val)
 {
-pthread_mutex_lock(&mutex_sid);
-       strncpy(s, gsid, SID_MAX);
-       s[SID_MAX] = 0;
-pthread_mutex_unlock(&mutex_sid);
+       linux_time_set = val;
 }
-char *sid_getp(void)
+int conf_linux_time_set_get(void)
 {
-       return gsid;
+       return linux_time_set;
+}
+
+// 記録パス
+static char    recpath[CONF_RECPATH_MAX];
+void conf_recpath_set(char *s)
+{
+       strncpy(recpath, s, sizeof(recpath));
+}
+char* conf_recpath_getp(void)
+{
+       return recpath;
+}
+
+// 記録CH
+static int     recchnum;
+void conf_recchn_set(int chn)
+{
+       recchnum = chn;
+}
+int conf_recchn_get(void)
+{
+       return recchnum;
 }
 
 //
@@ -126,7 +181,10 @@ int conf_read(void)
 {
        FILE    *fp;
        char    buf[256];
-       char    buf2[256];
+//     char    buf2[256];
+       char    buf2[CONF_RECPATH_MAX];
+       int     f;
+       int     val;
 
        fp = fopen(CONF_FILE, "rt");
        if (fp == NULL) {
@@ -141,11 +199,32 @@ int conf_read(void)
                trim_space(buf);
                PDEBUG(buf);
                PDEBUG("\n");
-               // Station ID
-               if (sscanf(buf, "sid = %s", buf2) == 1) {
-                       sid_set(buf2);
-                       syslog(LOG_INFO, "sid=%s", sid_getp());
+               // 記録周波数
+               if (sscanf(buf, "freq = %d", &f) == 1) {
+                       conf_freq_set(f);
+                       syslog(LOG_INFO, "freq=%d", conf_freq_get());
+               } 
+               // Gain
+               if (sscanf(buf, "gain = %d", &f) == 1) {
+                       conf_gain_set(f);
+                       syslog(LOG_INFO, "gain=%d", conf_gain_get());
                } 
+               // Linux時刻セット
+               if (sscanf(buf, "linux_time_set = %d", &val) == 1) {
+                       conf_linux_time_set_set(val);
+                       syslog(LOG_INFO, "linux_time_set=%d", conf_linux_time_set_get());
+               } 
+               // 記録パス
+               if (sscanf(buf, "rec_path = %s", buf2) == 1) {
+                       trim_space(buf2);
+                       conf_recpath_set(buf2);
+                       syslog(LOG_INFO, "rec_path=%s", conf_recpath_getp());
+               } 
+               // 記録CH
+               if (sscanf(buf, "rec_chn = %d", &f) == 1) {
+                       if (f < 1 || f > AD_CHNUM) f = AD_CHNUM;
+                       conf_recchn_set(f);
+               }
        }
        fclose(fp);
        return 0;