inserted logger
This commit is contained in:
@@ -13,6 +13,7 @@ tasp@tasp:tecs/ dmc@dmc:tecs/ hrpt@hrpt:tecs/ \
|
|||||||
morpheus@morpheus:tecs/ sans@sans:tecs/ sans2@sans2:tecs/ \
|
morpheus@morpheus:tecs/ sans@sans:tecs/ sans2@sans2:tecs/ \
|
||||||
type@darwin \
|
type@darwin \
|
||||||
macosx=/afs/psi.ch/project/sinq/mac_os/stow/tecs/bin/ \
|
macosx=/afs/psi.ch/project/sinq/mac_os/stow/tecs/bin/ \
|
||||||
|
admin@ldmprep1:bin/ admin@ldmprep2:bin/ \
|
||||||
)
|
)
|
||||||
|
|
||||||
set dests=""
|
set dests=""
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
LIBR_OBJ =coc_util.o myc_err.o myc_str.o myc_buf.o myc_time.o
|
LIBR_OBJ =coc_util.o myc_err.o myc_str.o myc_buf.o myc_time.o
|
||||||
SERV_OBJ =tecs.o coc_server.o tecs_lsc.o tecs_serial.o coc_logfile.o \
|
SERV_OBJ =tecs.o coc_server.o tecs_lsc.o tecs_serial.o coc_logfile.o \
|
||||||
tecs_data.o $(LIBR_OBJ)
|
tecs_data.o tecs_logger.o $(LIBR_OBJ)
|
||||||
CLI_OBJ =tecs_cli.o coc_client.o $(LIBR_OBJ)
|
CLI_OBJ =tecs_cli.o coc_client.o $(LIBR_OBJ)
|
||||||
TCLI_OBJ =sys_getenv.o sys_env.o myc_tmp.o sys_cmdpar.o \
|
TCLI_OBJ =sys_getenv.o sys_env.o myc_tmp.o sys_cmdpar.o \
|
||||||
sys_date.o sys_wait.o sys_lun.o sys_rdline.o \
|
sys_date.o sys_wait.o sys_lun.o sys_rdline.o \
|
||||||
|
|||||||
43
tecs/tecs.c
43
tecs/tecs.c
@@ -5,6 +5,9 @@
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
#include "myc_mem.h"
|
#include "myc_mem.h"
|
||||||
#include "myc_err.h"
|
#include "myc_err.h"
|
||||||
#include "coc_util.h"
|
#include "coc_util.h"
|
||||||
@@ -14,6 +17,7 @@
|
|||||||
#include "myc_time.h"
|
#include "myc_time.h"
|
||||||
#include "tecs_lsc.h"
|
#include "tecs_lsc.h"
|
||||||
#include "tecs_data.h"
|
#include "tecs_data.h"
|
||||||
|
#include "logger.h"
|
||||||
|
|
||||||
/* --- non ANSI signal --- */
|
/* --- non ANSI signal --- */
|
||||||
#ifndef SIGPIPE
|
#ifndef SIGPIPE
|
||||||
@@ -28,6 +32,7 @@
|
|||||||
static SerChannel *ser=NULL;
|
static SerChannel *ser=NULL;
|
||||||
static char binDir[256]="";
|
static char binDir[256]="";
|
||||||
static char logDir[256]="";
|
static char logDir[256]="";
|
||||||
|
static char loggerDir[256]="";
|
||||||
static int logIt=0, use_stdout=0;
|
static int logIt=0, use_stdout=0;
|
||||||
static char serverId[32]="tecs";
|
static char serverId[32]="tecs";
|
||||||
static int msecTmo=5000;
|
static int msecTmo=5000;
|
||||||
@@ -170,7 +175,7 @@ static int
|
|||||||
lockAlarm,
|
lockAlarm,
|
||||||
cntError;
|
cntError;
|
||||||
|
|
||||||
int tim, rdTim; /* actual time, read Time */
|
static int tim, rdTim; /* actual time, read Time */
|
||||||
|
|
||||||
static int decod[8]={21,20,17,16,5,4,1,0}; /* for code conversion */
|
static int decod[8]={21,20,17,16,5,4,1,0}; /* for code conversion */
|
||||||
|
|
||||||
@@ -2777,7 +2782,6 @@ int LogfileHdl(int mode, void *base, int fd) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int ExecuteRequest(void) {
|
int ExecuteRequest(void) {
|
||||||
if (readTemp) ERR_I(ReadTemp());
|
if (readTemp) ERR_I(ReadTemp());
|
||||||
ERR_I(CocCallHandlers());
|
ERR_I(CocCallHandlers());
|
||||||
@@ -3003,6 +3007,7 @@ int main(int argc, char *argv[]) {
|
|||||||
CocDefStr(serverId, RW); CocHdl(LogfileHdl);
|
CocDefStr(serverId, RW); CocHdl(LogfileHdl);
|
||||||
CocDefInt(logIt, RW); CocHdl(LogfileHdl);
|
CocDefInt(logIt, RW); CocHdl(LogfileHdl);
|
||||||
CocDefStr(logDir, RW); CocHdl(LogfileHdl);
|
CocDefStr(logDir, RW); CocHdl(LogfileHdl);
|
||||||
|
CocDefStr(loggerDir, RW);
|
||||||
CocDefStr(binDir, RW);
|
CocDefStr(binDir, RW);
|
||||||
|
|
||||||
logfileOut(LOG_MAIN ,"%s ", argv[0]);
|
logfileOut(LOG_MAIN ,"%s ", argv[0]);
|
||||||
@@ -3029,6 +3034,9 @@ int main(int argc, char *argv[]) {
|
|||||||
} else if ('d'==opt) {
|
} else if ('d'==opt) {
|
||||||
i++;
|
i++;
|
||||||
str_copy(logDir, argv[i]);
|
str_copy(logDir, argv[i]);
|
||||||
|
} else if ('m'==opt) {
|
||||||
|
i++;
|
||||||
|
str_copy(loggerDir, argv[i]);
|
||||||
} else if ('t'==opt) {
|
} else if ('t'==opt) {
|
||||||
i++;
|
i++;
|
||||||
msecTmo=atoi(argv[i]);
|
msecTmo=atoi(argv[i]);
|
||||||
@@ -3064,9 +3072,36 @@ int main(int argc, char *argv[]) {
|
|||||||
str_copy(statusBuf, "starting up");
|
str_copy(statusBuf, "starting up");
|
||||||
logfileStatusBuf(statusBuf);
|
logfileStatusBuf(statusBuf);
|
||||||
|
|
||||||
str_copy(buf, logDir);
|
if (logDir[0] == '/') {
|
||||||
str_append(buf, serverId);
|
str_copy(buf, logDir);
|
||||||
|
} else {
|
||||||
|
getcwd(buf, sizeof buf);
|
||||||
|
str_append(buf, "/");
|
||||||
|
ERR_I(str_append(buf, logDir));
|
||||||
|
}
|
||||||
|
ERR_I(str_append(buf, serverId));
|
||||||
|
if (strcmp(serverId, "tecs") != 0) {
|
||||||
|
ERR_I(str_append(buf, "/tecs"));
|
||||||
|
}
|
||||||
logfile=logfileInit(buf, logIt, use_stdout, logIt && use_stdout);
|
logfile=logfileInit(buf, logIt, use_stdout, logIt && use_stdout);
|
||||||
|
|
||||||
|
if (loggerDir[0] != '\0') {
|
||||||
|
if (loggerDir[0] == '/') {
|
||||||
|
str_copy(buf, loggerDir);
|
||||||
|
} else {
|
||||||
|
getcwd(buf, sizeof buf);
|
||||||
|
str_append(buf, "/");
|
||||||
|
ERR_I(str_append(buf, loggerDir));
|
||||||
|
}
|
||||||
|
if (strcmp(serverId, "tecs") != 0) {
|
||||||
|
ERR_I(str_append(buf, serverId));
|
||||||
|
mkdir(buf, S_IRWXU+S_IRGRP+S_IXGRP+S_IROTH+S_IXOTH);
|
||||||
|
/* do not check return value */
|
||||||
|
}
|
||||||
|
str_copy(loggerDir, buf);
|
||||||
|
LoggerSetDir(loggerDir);
|
||||||
|
}
|
||||||
|
|
||||||
CocDefStr(logfile, RD);
|
CocDefStr(logfile, RD);
|
||||||
logfileOut(LOG_MAIN ,"\n");
|
logfileOut(LOG_MAIN ,"\n");
|
||||||
logfileWrite(logMask);
|
logfileWrite(logMask);
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include "myc_time.h"
|
#include "myc_time.h"
|
||||||
#include "coc_logfile.h"
|
#include "coc_logfile.h"
|
||||||
#include "tecs_data.h"
|
#include "tecs_data.h"
|
||||||
|
#include "logger.h"
|
||||||
|
|
||||||
#define RUN_SIZE 1024
|
#define RUN_SIZE 1024
|
||||||
#define SET_LEN 1024
|
#define SET_LEN 1024
|
||||||
@@ -34,6 +35,7 @@ typedef struct _Set {
|
|||||||
float *var;
|
float *var;
|
||||||
Run *runs;
|
Run *runs;
|
||||||
Summary sum;
|
Summary sum;
|
||||||
|
Logger *log;
|
||||||
} Set;
|
} Set;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -125,6 +127,7 @@ Set *CreateSet(Base *base, char *name, float *var, int step, int lifetime, int s
|
|||||||
s->start = start;
|
s->start = start;
|
||||||
s->step = step;
|
s->step = step;
|
||||||
s->var = var;
|
s->var = var;
|
||||||
|
s->log = LoggerMake(name, step, 0);
|
||||||
ResetSum(&s->sum);
|
ResetSum(&s->sum);
|
||||||
return s;
|
return s;
|
||||||
OnError:
|
OnError:
|
||||||
@@ -267,7 +270,8 @@ int DataPut(DataSet *set, int time, float value) {
|
|||||||
|
|
||||||
int DataPutAll(DataBase *base, int time) {
|
int DataPutAll(DataBase *base, int time) {
|
||||||
Set *s;
|
Set *s;
|
||||||
|
char value[32];
|
||||||
|
|
||||||
if (base == NULL) {
|
if (base == NULL) {
|
||||||
s=database.head;
|
s=database.head;
|
||||||
} else {
|
} else {
|
||||||
@@ -276,6 +280,14 @@ int DataPutAll(DataBase *base, int time) {
|
|||||||
while (s!=NULL) {
|
while (s!=NULL) {
|
||||||
if (s->var!=NULL) {
|
if (s->var!=NULL) {
|
||||||
ERR_I(Put(s, time, *s->var));
|
ERR_I(Put(s, time, *s->var));
|
||||||
|
if (s->log != NULL) {
|
||||||
|
if (*s->var == DATA_UNDEF) {
|
||||||
|
value[0]='\0';
|
||||||
|
} else {
|
||||||
|
snprintf(value, sizeof value, "%.5g", *s->var);
|
||||||
|
}
|
||||||
|
LoggerWrite(s->log, mycUnixTime(time), s->step, value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
s=s->next;
|
s=s->next;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user