New TECS Version Sept. 2001 M.Z.
This commit is contained in:
@@ -11,11 +11,11 @@
|
||||
#include "tecs_data.h"
|
||||
|
||||
static char response[COC_RES_LEN];
|
||||
static char *rwCode="rwacs";
|
||||
static char *rdCode="rdacs";
|
||||
|
||||
pTecsClient TeccInit(char *startcmd, int port) {
|
||||
CocConn *conn;
|
||||
static char *rwCode="rwacs";
|
||||
static char *rdCode="rdacs";
|
||||
|
||||
NEW(conn, CocConn);
|
||||
if (startcmd[0]=='#') {
|
||||
@@ -64,22 +64,23 @@ int TeccSet(pTecsClient conn, float temp) {
|
||||
OnError: return(-1);
|
||||
}
|
||||
|
||||
int TeccQuitServer(pTecsClient conn) {
|
||||
int TeccQuitServer(pTecsClient conn, int kill) {
|
||||
int iret, cnt;
|
||||
|
||||
ERR_I(iret=CocCheck(conn));
|
||||
if (iret==0) {
|
||||
CocReset(conn);
|
||||
ERR_I(CocPutInt(conn, "quit", 1));
|
||||
ERR_I(CocDoIt(conn, response, sizeof(response)));
|
||||
cnt=50;
|
||||
while (iret==0 && cnt>0) {
|
||||
CocDelay(100);
|
||||
ERR_I(iret=CocCheck(conn));
|
||||
cnt--;
|
||||
}
|
||||
if (iret>0) return iret;
|
||||
CocReset(conn);
|
||||
ERR_I(CocPutInt(conn, "quit", 1+kill));
|
||||
ERR_I(iret=CocDoIt(conn, response, sizeof(response)));
|
||||
if (iret) ERR_MSG(response);
|
||||
cnt=50;
|
||||
while (iret==0 && cnt>0) {
|
||||
CocDelay(100);
|
||||
ERR_I(iret=CocCheck(conn));
|
||||
cnt--;
|
||||
}
|
||||
ERR_MSG("Does not quit within 5 seconds");
|
||||
if (iret==0) ERR_MSG("Does not quit within 5 seconds");
|
||||
return 0;
|
||||
OnError:
|
||||
return(-1);
|
||||
}
|
||||
@@ -121,6 +122,7 @@ void TeccClose(pTecsClient conn) {
|
||||
#define tecs_get_data_ tecs_get_data
|
||||
#define tecs_date_ tecs_date
|
||||
#define tecs_time_ tecs_time
|
||||
#define tecs_rights_ tecs_rights
|
||||
#endif
|
||||
|
||||
static pTecsClient conn=NULL;
|
||||
@@ -200,6 +202,16 @@ int tecs_init_(F_CHAR(startcmd), int *port, int startcmd_len) {
|
||||
OnError: return(-1);
|
||||
}
|
||||
|
||||
int tecs_rights_(int write) {
|
||||
if (write) {
|
||||
ERR_I(CocSendMagic(conn, rwCode));
|
||||
} else {
|
||||
ERR_I(CocSendMagic(conn, rdCode));
|
||||
}
|
||||
return(0);
|
||||
OnError: return(-1);
|
||||
}
|
||||
|
||||
int tecs_get_(float *temp) {
|
||||
ERR_I(TeccGet(conn, temp));
|
||||
return(0);
|
||||
@@ -227,9 +239,11 @@ void tecs_close_(void) {
|
||||
conn=NULL;
|
||||
}
|
||||
|
||||
int tecs_quit_server_(void) {
|
||||
ERR_I(TeccQuitServer(conn));
|
||||
return(0);
|
||||
int tecs_quit_server_(int *kill) {
|
||||
int iret;
|
||||
|
||||
ERR_I(iret=TeccQuitServer(conn, *kill));
|
||||
return(iret);
|
||||
OnError: return(-1);
|
||||
}
|
||||
|
||||
@@ -274,7 +288,11 @@ int DataDecode(float *data, int dataSize, char *coded, int *retSize) {
|
||||
dig1=decode[ch];
|
||||
if (dig1 < 0) { /* code is no 64-digit */
|
||||
if (ch=='\0' || ch==',') break;
|
||||
if (ch=='/') { data[i++] = DATA_UNDEF; }
|
||||
if (ch=='/') {
|
||||
data[i++] = DATA_UNDEF;
|
||||
} else if (ch=='.') {
|
||||
data[i++] = DATA_GAP;
|
||||
}
|
||||
} else {
|
||||
ch=coded[p++];
|
||||
dig2=decode[ch];
|
||||
@@ -304,13 +322,15 @@ int DataDecode(float *data, int dataSize, char *coded, int *retSize) {
|
||||
}
|
||||
|
||||
|
||||
int tecs_get_data_(F_CHAR(names), int *startTime, int *endTime, int *step, float data[], int *maxLen, int *width
|
||||
int tecs_get_data_(F_CHAR(names), int *startTime, int *endTime, int *step, int *tbase
|
||||
, float xdata[], float ydata[], int *maxLen, int *width
|
||||
, int retLen[], int names_len) {
|
||||
char nam[64];
|
||||
char str[128];
|
||||
char res[COC_RES_LEN];
|
||||
char *cod;
|
||||
int i, l, iret, retSize;
|
||||
float offset, fact, *py;
|
||||
int i, j, k, l, iret, retSize;
|
||||
|
||||
if (*endTime - *startTime > *step * (*maxLen-1)) {
|
||||
printf("maxLen too small\n");
|
||||
@@ -328,7 +348,21 @@ int tecs_get_data_(F_CHAR(names), int *startTime, int *endTime, int *step, float
|
||||
if (iret) ERR_MSG(response);
|
||||
cod=res;
|
||||
for (i=0; i < *width; i++) {
|
||||
ERR_I(l=DataDecode(data + i * *maxLen, *maxLen, cod, retLen+i));
|
||||
py = ydata + i * *maxLen;
|
||||
ERR_I(l=DataDecode(py, *maxLen, cod, retLen+i));
|
||||
if (retLen[i]>0) {
|
||||
fact = (float)(*endTime - *startTime) / retLen[i];
|
||||
}
|
||||
offset = *startTime - *tbase;
|
||||
k = i * *maxLen;
|
||||
for (j=0; j<retLen[i]; j++) {
|
||||
if (py[j] != DATA_GAP) {
|
||||
ydata[k] = py[j];
|
||||
xdata[k] = offset + j * fact;
|
||||
k++;
|
||||
}
|
||||
}
|
||||
retLen[i] = k - i * *maxLen;
|
||||
cod+=l;
|
||||
}
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user