new vers.
This commit is contained in:
@ -649,13 +649,15 @@ int CocHandleRequests(int tmo_msec, int fd) {
|
|||||||
void CocCloseServer() {
|
void CocCloseServer() {
|
||||||
CocClient *cl, *cl0;
|
CocClient *cl, *cl0;
|
||||||
|
|
||||||
cl=cList->next;
|
if (cList) {
|
||||||
while (cl!=NULL) {
|
cl=cList->next;
|
||||||
close(cl->fd);
|
while (cl!=NULL) {
|
||||||
cl0=cl;
|
close(cl->fd);
|
||||||
cl=cl->next;
|
cl0=cl;
|
||||||
FREE(cl0);
|
cl=cl->next;
|
||||||
|
FREE(cl0);
|
||||||
|
}
|
||||||
|
FREE(cList);
|
||||||
}
|
}
|
||||||
FREE(cList);
|
|
||||||
close(mainFd);
|
close(mainFd);
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ static Instrument list[]={
|
|||||||
{ "DMC", "pc4629.psi.ch", 9753, "dmc" , 1},
|
{ "DMC", "pc4629.psi.ch", 9753, "dmc" , 1},
|
||||||
{ "MORPHEUS", "pc4120.psi.ch", 9753, "morpheus" , 1},
|
{ "MORPHEUS", "pc4120.psi.ch", 9753, "morpheus" , 1},
|
||||||
{ "SANS", "pc4122.psi.ch", 9753, "sans" , 1},
|
{ "SANS", "pc4122.psi.ch", 9753, "sans" , 1},
|
||||||
{ "SANS2", "sans2.psi.ch", 9753, "SANS2" , 1},
|
{ "SANS2", "sans2.psi.ch", 9753, "sans2" , 1},
|
||||||
{ "HRPT", "pc4630.psi.ch", 9753, "hrpt" , 1},
|
{ "HRPT", "pc4630.psi.ch", 9753, "hrpt" , 1},
|
||||||
{ "TRICS", "trics.psi.ch", 9753, "trics" , 1},
|
{ "TRICS", "trics.psi.ch", 9753, "trics" , 1},
|
||||||
{ "AMOR", "amor.psi.ch", 9753, "amor" , 1},
|
{ "AMOR", "amor.psi.ch", 9753, "amor" , 1},
|
||||||
|
@ -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 logger_tecs.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 \
|
||||||
@ -71,6 +71,9 @@ keep_running: keep_running.c
|
|||||||
six: six.c term.o sys_select.o libtecsl.a
|
six: six.c term.o sys_select.o libtecsl.a
|
||||||
$(CC) $(CFLAGS) -o $@ $Q $(FORTIFYOBJ)
|
$(CC) $(CFLAGS) -o $@ $Q $(FORTIFYOBJ)
|
||||||
|
|
||||||
|
tt: tt.c term.o sys_select.o libtecsl.a
|
||||||
|
$(CC) $(CFLAGS) -o $@ $Q $(FORTIFYOBJ)
|
||||||
|
|
||||||
rexstart: rstart.c myc_str.o myc_err.o instr_hosts.o
|
rexstart: rstart.c myc_str.o myc_err.o instr_hosts.o
|
||||||
$(CC) $(CFLAGS) -o $@ $Q $(FORTIFYOBJ)
|
$(CC) $(CFLAGS) -o $@ $Q $(FORTIFYOBJ)
|
||||||
@ echo "$(PWD)/rstart"
|
@ echo "$(PWD)/rstart"
|
||||||
|
@ -35,6 +35,10 @@ int mycNow(void) {
|
|||||||
return (int)(now-my_base);
|
return (int)(now-my_base);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
time_t mycUnixTime(int myTime) {
|
||||||
|
return myTime+my_base;
|
||||||
|
}
|
||||||
|
|
||||||
int mycMsecSince(int since) {
|
int mycMsecSince(int since) {
|
||||||
#if __VMS
|
#if __VMS
|
||||||
struct timeb now;
|
struct timeb now;
|
||||||
|
@ -29,6 +29,8 @@ int mycTime(int date);
|
|||||||
if day, month or year is undefined (zero)
|
if day, month or year is undefined (zero)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
time_t mycUnixTime(int myTime);
|
||||||
|
|
||||||
/* the following subroutines are to be called from FORTRAN
|
/* the following subroutines are to be called from FORTRAN
|
||||||
|
|
||||||
integer function myc_now()
|
integer function myc_now()
|
||||||
|
@ -34,7 +34,7 @@ void sys_keys_off(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int sys_select_or_key(fd_set *mask, int msecTmo, char *key) {
|
int sys_select_or_key(fd_set *mask, int msecTmo, int *key) {
|
||||||
int fd, iret, fd1, chr;
|
int fd, iret, fd1, chr;
|
||||||
struct timeval tmo, tmo0={0,0};
|
struct timeval tmo, tmo0={0,0};
|
||||||
fd_set rmask;
|
fd_set rmask;
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
||||||
int sys_select_or_key(fd_set *mask, int msecTmo, char *key);
|
int sys_select_or_key(fd_set *mask, int msecTmo, int *key);
|
||||||
/*
|
/*
|
||||||
wait for read event on sockets included in mask or from keyboard or a timeout
|
wait for read event on sockets included in mask or from keyboard or a timeout
|
||||||
result is negative for timeout,
|
result is negative for timeout,
|
||||||
|
21
tecs/tecs.c
21
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
|
||||||
@ -170,7 +174,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 */
|
||||||
|
|
||||||
@ -2840,6 +2844,7 @@ int main(int argc, char *argv[]) {
|
|||||||
int i, iret;
|
int i, iret;
|
||||||
char *inistr;
|
char *inistr;
|
||||||
char buf[256], opt;
|
char buf[256], opt;
|
||||||
|
char loggerDir[256];
|
||||||
|
|
||||||
signal(SIGPIPE, ignore_forever);
|
signal(SIGPIPE, ignore_forever);
|
||||||
|
|
||||||
@ -3060,8 +3065,18 @@ 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));
|
||||||
|
ERR_I(str_copy(loggerDir, buf));
|
||||||
|
mkdir(loggerDir, S_IRWXU+S_IRGRP+S_IXGRP+S_IROTH+S_IXOTH);
|
||||||
|
/* do not check return value */
|
||||||
|
LoggerSetDir(loggerDir);
|
||||||
logfile=logfileInit(buf, logIt, use_stdout, logIt && use_stdout);
|
logfile=logfileInit(buf, logIt, use_stdout, logIt && use_stdout);
|
||||||
CocDefStr(logfile, RD);
|
CocDefStr(logfile, RD);
|
||||||
logfileOut(LOG_MAIN ,"\n");
|
logfileOut(LOG_MAIN ,"\n");
|
||||||
|
@ -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);
|
||||||
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,10 @@ 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) {
|
||||||
|
snprintf(value, sizeof value, "%f", *s->var);
|
||||||
|
LoggerWrite(s->log, mycUnixTime(time), s->step, value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
s=s->next;
|
s=s->next;
|
||||||
}
|
}
|
||||||
|
16
tecs/term.h
16
tecs/term.h
@ -9,7 +9,7 @@ void term_reg_socket(int socket);
|
|||||||
void term_unr_socket(int socket);
|
void term_unr_socket(int socket);
|
||||||
/* unregister socket */
|
/* unregister socket */
|
||||||
|
|
||||||
int term_raw_key(char *key, int msecTmo);
|
int term_raw_key(int *key, int msecTmo);
|
||||||
|
|
||||||
int term_wait_socket(int socket, int msecTmo);
|
int term_wait_socket(int socket, int msecTmo);
|
||||||
/* wait for a read event on socket or timeout
|
/* wait for a read event on socket or timeout
|
||||||
@ -18,14 +18,14 @@ int term_wait_socket(int socket, int msecTmo);
|
|||||||
or 0 for timeout
|
or 0 for timeout
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int term_get_key(char *key, int msecTmo);
|
int term_get_key(int *key, int msecTmo);
|
||||||
|
|
||||||
void term_clear(void);
|
void term_clear(void);
|
||||||
|
|
||||||
int term_get_line(char *buf, int size, int *pos, char *prompt, fd_set *mask);
|
int term_get_line(char *buf, int size, int *pos, char *prompt, fd_set *mask);
|
||||||
|
|
||||||
FILE *term_open_pref(char *head, char *mode);
|
FILE *term_open_pref(int temp, char *head, char *mode);
|
||||||
/* open a user specific preferences file */
|
/* open a user specific preferences or temporary file */
|
||||||
|
|
||||||
char *term_fgets(char *buf, int size, FILE *fil);
|
char *term_fgets(char *buf, int size, FILE *fil);
|
||||||
/* fgets without newline */
|
/* fgets without newline */
|
||||||
@ -38,4 +38,12 @@ void term_save_hist(int trimlast);
|
|||||||
|
|
||||||
void term_off(void);
|
void term_off(void);
|
||||||
|
|
||||||
|
void term_define_key(char *cmd, int keyArg);
|
||||||
|
|
||||||
|
void term_save_keys(FILE *fil, void (*out)(char *));
|
||||||
|
/* save keys on file */
|
||||||
|
|
||||||
|
void term_load_keys(FILE *fil, void (*out)(char *));
|
||||||
|
/* load keys on file */
|
||||||
|
|
||||||
#endif /* TERM_H_ */
|
#endif /* TERM_H_ */
|
||||||
|
Reference in New Issue
Block a user