*** empty log message ***
This commit is contained in:
72
tecsdriv.c
72
tecsdriv.c
@@ -40,6 +40,7 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <sys/time.h>
|
||||
#include <tcl.h>
|
||||
#include "fortify.h"
|
||||
#include "conman.h"
|
||||
@@ -57,11 +58,10 @@
|
||||
#include "servlog.h"
|
||||
#include "sicsvar.h"
|
||||
#include "tecs/tecc.h"
|
||||
#include "tecs/util.h"
|
||||
#include "tecs/errhdl.h"
|
||||
extern pServer pServ;
|
||||
|
||||
typedef struct __EVDriver *pEVDriver;
|
||||
|
||||
#include "evdriver.i"
|
||||
|
||||
/*------------------------- The Driver ------------------------------------*/
|
||||
@@ -72,10 +72,13 @@
|
||||
/*-----------------------------------------------------------------------*/
|
||||
typedef struct {
|
||||
void *pData;
|
||||
char server[64];
|
||||
int iLastError;
|
||||
char *lastError;
|
||||
} TecsDriv, *pTecsDriv;
|
||||
int iLastError, port;
|
||||
char server[256];
|
||||
} TecsDriv, *pTecsDriv;
|
||||
|
||||
|
||||
static time_t lastGet=0;
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
int TecsWrapper(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
@@ -151,11 +154,19 @@
|
||||
{
|
||||
pTecsDriv pMe = NULL;
|
||||
int iRet;
|
||||
time_t now;
|
||||
|
||||
assert(self);
|
||||
pMe = (pTecsDriv)self->pPrivate;
|
||||
assert(pMe);
|
||||
|
||||
assert(pMe);
|
||||
|
||||
time(&now);
|
||||
if (now>lastGet) {
|
||||
lastGet=now;
|
||||
} else {
|
||||
SicsWait(1); /* avoid extensive network traffic */
|
||||
}
|
||||
|
||||
/* get temperature */
|
||||
iRet = TeccGet(pMe->pData, fPos);
|
||||
if(iRet < 0 )
|
||||
@@ -178,8 +189,7 @@
|
||||
|
||||
/* set temperature */
|
||||
iRet = TeccSet(pMe->pData, fVal);
|
||||
if(iRet != 1)
|
||||
{
|
||||
if(iRet < 0) {
|
||||
pMe->iLastError=1; /* severe */
|
||||
pMe->lastError = ErrMessage;
|
||||
return 0;
|
||||
@@ -196,7 +206,7 @@
|
||||
assert(pMe);
|
||||
|
||||
*iCode = pMe->iLastError;
|
||||
error=pMe->lastError;
|
||||
str_ncpy(error, pMe->lastError, iErrLen);
|
||||
return 1;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
@@ -243,7 +253,7 @@
|
||||
pMe = (pTecsDriv )self->pPrivate;
|
||||
assert(pMe);
|
||||
|
||||
pMe->pData = TeccInit(pMe->server);
|
||||
pMe->pData = TeccInit(pMe->server, pMe->port);
|
||||
if(pMe->pData==NULL)
|
||||
{
|
||||
pMe->iLastError = 1; /* severe */
|
||||
@@ -262,7 +272,7 @@
|
||||
pMe = (pTecsDriv )self->pPrivate;
|
||||
assert(pMe);
|
||||
|
||||
TeccClose(&pMe->pData);
|
||||
TeccClose(pMe->pData);
|
||||
pMe->pData=NULL;
|
||||
return 1;
|
||||
}
|
||||
@@ -288,7 +298,8 @@
|
||||
pEVDriver pNew = NULL;
|
||||
pTecsDriv pMe = NULL;
|
||||
pSicsVariable pInst = NULL;
|
||||
|
||||
char *pStart = NULL, *pBin=NULL, *pLog=NULL, *pPort=NULL;
|
||||
|
||||
pNew = CreateEVDriver(argc,argv);
|
||||
pMe = (pTecsDriv)malloc(sizeof(TecsDriv));
|
||||
memset(pMe,0,sizeof(TecsDriv));
|
||||
@@ -302,12 +313,45 @@
|
||||
/* initalise pTecsDriver */
|
||||
pMe->lastError = NULL;
|
||||
|
||||
/* get the start server option */
|
||||
pStart = IFindOption(pSICSOptions, "TecsStartCmd");
|
||||
if (pStart==NULL) return(NULL);
|
||||
str_copy(pMe->server, pStart);
|
||||
|
||||
/* get the port number for tecs */
|
||||
pMe->port=0;
|
||||
pPort = IFindOption(pSICSOptions, "TecsPort");
|
||||
if (pPort!=NULL) {
|
||||
pMe->port=atoi(pPort);
|
||||
}
|
||||
if (pMe->port==0) {
|
||||
pPort="9750";
|
||||
pMe->port=atoi(pPort);
|
||||
}
|
||||
str_append(pMe->server, " -p ");
|
||||
str_append(pMe->server, pPort);
|
||||
|
||||
/* get the instrument name */
|
||||
pInst = FindVariable(pServ->pSics,"instrument");
|
||||
if (pInst==NULL ||
|
||||
pInst->text==NULL ||
|
||||
strlen(pInst->text)>sizeof(pMe->server)-6) return NULL;
|
||||
sprintf(pMe->server,"tecs_%s", pInst->text);
|
||||
str_append(pMe->server, " -n tecs_");
|
||||
str_append(pMe->server, pInst->text);
|
||||
|
||||
/* add binDir option if present */
|
||||
pBin = IFindOption(pSICSOptions, "TecsBinDir");
|
||||
if (pBin!=NULL) {
|
||||
str_append(pMe->server, " -b ");
|
||||
str_append(pMe->server, pBin);
|
||||
}
|
||||
/* add logDir option if present */
|
||||
pLog = IFindOption(pSICSOptions, "TecsLogDir");
|
||||
if (pLog!=NULL) {
|
||||
str_append(pMe->server, " -d ");
|
||||
str_append(pMe->server, pLog);
|
||||
}
|
||||
str_append(pMe->server, " &");
|
||||
|
||||
/* initialise function pointers */
|
||||
pNew->SetValue = TecsRun;
|
||||
|
||||
Reference in New Issue
Block a user