new tecs version M.Z.08.2001
This commit is contained in:
@@ -3,11 +3,11 @@
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include "err_handling.h"
|
||||
#include "myc_err.h"
|
||||
#include "coc_logfile.h"
|
||||
#include "coc_util.h"
|
||||
#include "coc_server.h"
|
||||
#include "tecs_lsc.h"
|
||||
#include "str_util.h"
|
||||
#include "myc_str.h"
|
||||
|
||||
#define MAX_PAR 16
|
||||
#define MAX_ARG 9
|
||||
@@ -46,15 +46,14 @@ char *LscCmd(SerChannel *ser, const char *cmds) {
|
||||
char *blank, *colon, *qu, *res;
|
||||
const char *p, *this, *next, *cmd_ptr, *retreq;
|
||||
const char *list[nLIST];
|
||||
char seg[SER_BUF_LEN], buf[SER_BUF_LEN], result[SER_BUF_LEN], par[SER_BUF_LEN];
|
||||
char seg[SER_BUF_LEN], result[SER_BUF_LEN], par[SER_BUF_LEN];
|
||||
char cmd[SER_BUF_LEN];
|
||||
char varname[32];
|
||||
Str_Buf sbuf;
|
||||
DeclStrBuf(sbuf, SER_BUF_LEN);
|
||||
int nres, i, j, response;
|
||||
|
||||
nres=0;
|
||||
response=0;
|
||||
str_link_buf(&sbuf, buf, sizeof(buf), STR_NOSEPARATOR);
|
||||
this=cmds;
|
||||
while (this!=NULL) {
|
||||
next=str_split(cmd, this, ';');
|
||||
@@ -67,13 +66,13 @@ char *LscCmd(SerChannel *ser, const char *cmds) {
|
||||
}
|
||||
cmd_ptr=sbuf.buf+sbuf.wrpos; /* pointer to command in buffer */
|
||||
p=str_split(seg, cmd, '[');
|
||||
ERR_I(str_put_str(&sbuf, seg));
|
||||
ERR_I(StrPut(&sbuf, seg, StrNONE));
|
||||
while (p!=NULL) { /* substitute variables */
|
||||
p=str_split(varname, p, ']');
|
||||
if (p==NULL) ERR_MSG("missing ']'");
|
||||
ERR_I(CocPutVar(serverVarList, &sbuf, varname, 0));
|
||||
ERR_I(CocPutVar(varname, &sbuf, StrNONE));
|
||||
p=str_split(seg, p, '[');
|
||||
ERR_I(str_put_str(&sbuf, seg));
|
||||
ERR_I(StrPut(&sbuf, seg, StrNONE));
|
||||
}
|
||||
ERR_I(str_copy(cmd, cmd_ptr));
|
||||
colon=strchr(cmd_ptr, ':');
|
||||
@@ -86,16 +85,15 @@ char *LscCmd(SerChannel *ser, const char *cmds) {
|
||||
}
|
||||
list[nres]=colon+1; nres++; assert(nres<=nLIST); /* pointer to parameters */
|
||||
list[nres]=cmd_ptr; nres++; assert(nres<=nLIST); /* pointer to command */
|
||||
ERR_I(str_put_str(&sbuf, ";"));
|
||||
ERR_I(StrPut(&sbuf, ";", StrNONE));
|
||||
cmd[blank-cmd_ptr]='?'; /* build query */
|
||||
if (colon==blank) colon++;
|
||||
cmd[colon-cmd_ptr]='\0';
|
||||
ERR_I(str_put_str(&sbuf, cmd)); /* put query */
|
||||
ERR_I(str_put_str(&sbuf, ";"));
|
||||
ERR_I(StrPut(&sbuf, cmd, ';')); /* put query */
|
||||
response=1;
|
||||
} else {
|
||||
qu=strchr(cmd, '?');
|
||||
ERR_I(str_put_str(&sbuf, ";"));
|
||||
ERR_I(StrPut(&sbuf, ";", StrNONE));
|
||||
if (qu!=NULL) { /* command is a query */
|
||||
response=1;
|
||||
if (retreq==NULL) {
|
||||
@@ -110,11 +108,11 @@ char *LscCmd(SerChannel *ser, const char *cmds) {
|
||||
}
|
||||
|
||||
if (!response) {
|
||||
ERR_I(str_put_str(&sbuf, "busy?"));
|
||||
ERR_I(StrPut(&sbuf, "busy?",'\0'));
|
||||
} else {
|
||||
buf[sbuf.wrpos-1]='\0'; /* strip off trailing ";" */
|
||||
sbuf.buf[sbuf.wrpos-1]='\0'; /* strip off trailing ";" */
|
||||
}
|
||||
ERR_P(res=SerCmd(ser, buf));
|
||||
ERR_P(res=SerCmd(ser, sbuf.buf));
|
||||
if (0==strncmp("?TMO", res, 4)) ERR_MSG("timeout");
|
||||
/*
|
||||
list[0..nres-1] contains a now:
|
||||
@@ -158,18 +156,19 @@ char *LscCmd(SerChannel *ser, const char *cmds) {
|
||||
}
|
||||
}
|
||||
if (retreq!=NULL) { /* query */
|
||||
str_link_buf(&sbuf, result, 0, ',');
|
||||
StrLink(&sbuf, result);
|
||||
str_split(par, retreq+1, ';');
|
||||
p=par;
|
||||
while (p!=NULL) {
|
||||
p=str_split(varname, p, ',');
|
||||
if (varname[0]!='\0') {
|
||||
if (p==NULL) { /* last element: get rest of line */
|
||||
sbuf.sep='\0';
|
||||
ERR_I(CocGetVar(varname, &sbuf, '\0'));
|
||||
} else {
|
||||
ERR_I(CocGetVar(varname, &sbuf, ','));
|
||||
}
|
||||
ERR_I(CocGetVar(serverVarList, &sbuf, varname, 0));
|
||||
} else {
|
||||
ERR_P(str_get_str(&sbuf, NULL));
|
||||
ERR_P(StrGet(&sbuf, varname, ','));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -177,3 +176,33 @@ char *LscCmd(SerChannel *ser, const char *cmds) {
|
||||
return(res);
|
||||
OnError: return(NULL);
|
||||
}
|
||||
|
||||
|
||||
char *LscReadStat(int stat) {
|
||||
if (stat &128) return("units overrange");
|
||||
if (stat & 64) return("units zero");
|
||||
if (stat & 32) return("temp overrange");
|
||||
if (stat & 16) return("temp underrange");
|
||||
if (stat & 2) return("old reading");
|
||||
if (stat & 1) return("invalid reading");
|
||||
return ("");
|
||||
}
|
||||
|
||||
static char
|
||||
*heaterStatus[7]={
|
||||
"",
|
||||
"heater supply over V",
|
||||
"heater supply under V",
|
||||
"heater output DAC error",
|
||||
"heater Ilimit DAC error",
|
||||
"open heater load",
|
||||
"heater load < 10 Ohm",
|
||||
};
|
||||
|
||||
char *LscHtrStat(int stat) {
|
||||
if (stat<0 || stat>sizeof(heaterStatus)) {
|
||||
return("unknown heater status");
|
||||
} else {
|
||||
return(heaterStatus[stat]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user