new vers.

This commit is contained in:
zolliker
2005-06-29 14:15:53 +00:00
parent a4d9b5e5cf
commit 371ec68262
10 changed files with 61 additions and 19 deletions

View File

@ -649,6 +649,7 @@ int CocHandleRequests(int tmo_msec, int fd) {
void CocCloseServer() {
CocClient *cl, *cl0;
if (cList) {
cl=cList->next;
while (cl!=NULL) {
close(cl->fd);
@ -657,5 +658,6 @@ void CocCloseServer() {
FREE(cl0);
}
FREE(cList);
}
close(mainFd);
}

View File

@ -11,7 +11,7 @@ static Instrument list[]={
{ "DMC", "pc4629.psi.ch", 9753, "dmc" , 1},
{ "MORPHEUS", "pc4120.psi.ch", 9753, "morpheus" , 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},
{ "TRICS", "trics.psi.ch", 9753, "trics" , 1},
{ "AMOR", "amor.psi.ch", 9753, "amor" , 1},

View File

@ -10,7 +10,7 @@
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 \
tecs_data.o $(LIBR_OBJ)
tecs_data.o logger_tecs.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 \
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
$(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
$(CC) $(CFLAGS) -o $@ $Q $(FORTIFYOBJ)
@ echo "$(PWD)/rstart"

View File

@ -35,6 +35,10 @@ int mycNow(void) {
return (int)(now-my_base);
}
time_t mycUnixTime(int myTime) {
return myTime+my_base;
}
int mycMsecSince(int since) {
#if __VMS
struct timeb now;

View File

@ -29,6 +29,8 @@ int mycTime(int date);
if day, month or year is undefined (zero)
*/
time_t mycUnixTime(int myTime);
/* the following subroutines are to be called from FORTRAN
integer function myc_now()

View File

@ -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;
struct timeval tmo, tmo0={0,0};
fd_set rmask;

View File

@ -3,7 +3,7 @@
#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
result is negative for timeout,

View File

@ -5,6 +5,9 @@
#include <signal.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "myc_mem.h"
#include "myc_err.h"
#include "coc_util.h"
@ -14,6 +17,7 @@
#include "myc_time.h"
#include "tecs_lsc.h"
#include "tecs_data.h"
#include "logger.h"
/* --- non ANSI signal --- */
#ifndef SIGPIPE
@ -170,7 +174,7 @@ static int
lockAlarm,
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 */
@ -2840,6 +2844,7 @@ int main(int argc, char *argv[]) {
int i, iret;
char *inistr;
char buf[256], opt;
char loggerDir[256];
signal(SIGPIPE, ignore_forever);
@ -3060,8 +3065,18 @@ int main(int argc, char *argv[]) {
str_copy(statusBuf, "starting up");
logfileStatusBuf(statusBuf);
if (logDir[0] == '/') {
str_copy(buf, logDir);
str_append(buf, serverId);
} 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);
CocDefStr(logfile, RD);
logfileOut(LOG_MAIN ,"\n");

View File

@ -8,6 +8,7 @@
#include "myc_time.h"
#include "coc_logfile.h"
#include "tecs_data.h"
#include "logger.h"
#define RUN_SIZE 1024
#define SET_LEN 1024
@ -34,6 +35,7 @@ typedef struct _Set {
float *var;
Run *runs;
Summary sum;
Logger *log;
} Set;
typedef struct {
@ -125,6 +127,7 @@ Set *CreateSet(Base *base, char *name, float *var, int step, int lifetime, int s
s->start = start;
s->step = step;
s->var = var;
s->log = LoggerMake(name, step);
ResetSum(&s->sum);
return s;
OnError:
@ -267,6 +270,7 @@ int DataPut(DataSet *set, int time, float value) {
int DataPutAll(DataBase *base, int time) {
Set *s;
char value[32];
if (base == NULL) {
s=database.head;
@ -276,6 +280,10 @@ int DataPutAll(DataBase *base, int time) {
while (s!=NULL) {
if (s->var!=NULL) {
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;
}

View File

@ -9,7 +9,7 @@ void term_reg_socket(int socket);
void term_unr_socket(int 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);
/* 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
*/
int term_get_key(char *key, int msecTmo);
int term_get_key(int *key, int msecTmo);
void term_clear(void);
int term_get_line(char *buf, int size, int *pos, char *prompt, fd_set *mask);
FILE *term_open_pref(char *head, char *mode);
/* open a user specific preferences file */
FILE *term_open_pref(int temp, char *head, char *mode);
/* open a user specific preferences or temporary file */
char *term_fgets(char *buf, int size, FILE *fil);
/* fgets without newline */
@ -38,4 +38,12 @@ void term_save_hist(int trimlast);
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_ */