Remove superfluous trailing white space from C files

This commit is contained in:
Douglas Clowes
2014-05-16 15:48:41 +10:00
parent 1881907e00
commit 4c65f82116
91 changed files with 1313 additions and 1313 deletions

View File

@ -34,6 +34,6 @@ main(int argc, char *argv[]) {
} }
} }
gzclose(fp); gzclose(fp);
if (error==0) if (error==0)
printf("There were no errors.\n"); printf("There were no errors.\n");
} }

View File

@ -119,7 +119,7 @@ int camdriv_out(void *me, event_t Eo) {
} }
if (Eo.dr) { if (Eo.dr) {
printf("camdriv_out: symbol=%s, output=%s\n", event_names[Eo.dr], event_signatures[Eo.dr]); printf("camdriv_out: symbol=%s, output=%s\n", event_names[Eo.dr], event_signatures[Eo.dr]);
} }
return 1; return 1;
} }
@ -170,7 +170,7 @@ int main(int argc, char *argv[]) {
else if (strstr(argv[1], "help")) { else if (strstr(argv[1], "help")) {
usage(argv[0]); usage(argv[0]);
return 0; return 0;
} else } else
test = atoi(argv[1]); test = atoi(argv[1]);
if ((test < 1) || (test > tflag)) { if ((test < 1) || (test > tflag)) {
@ -180,11 +180,11 @@ int main(int argc, char *argv[]) {
} }
if (test & 1) if (test & 1)
ret = test_camrep2sym(); ret = test_camrep2sym();
if (test & 2) if (test & 2)
ret = test_trans_fn(); ret = test_trans_fn();
if (test & 4) if (test & 4)
ret = test_camdriv_event_io(); ret = test_camdriv_event_io();
if (ret) if (ret)

View File

@ -32,13 +32,13 @@ static void setTextSICSVar(char *VarName, char *value) {
/** /**
* @brief Update a SICS variable with the current status * @brief Update a SICS variable with the current status
* *
* @param input, status from device * @param input, status from device
* @param identifier, status query identifier * @param identifier, status query identifier
*/ */
void AO_istatus(int input, char *identifier) { void AO_istatus(int input, char *identifier) {
int testVal; int testVal;
if (strcasecmp(identifier, "QKK:TI1") == 0) { if (strcasecmp(identifier, "QKK:TI1") == 0) {
testVal = 48 & input; testVal = 48 & input;
if (testVal == 32) { // Fast shutter open if (testVal == 32) { // Fast shutter open

View File

@ -1,10 +1,10 @@
/*--------------------------------------------------------------------------- /*---------------------------------------------------------------------------
This is a motor driver which is implemented in Tcl. This means This is a motor driver which is implemented in Tcl. This means
this code is only a wrapper which calls Tcl functions to do the this code is only a wrapper which calls Tcl functions to do the
actual work. actual work.
The Tcl functions to implement the interface are called with the name The Tcl functions to implement the interface are called with the name
of the motor as first parameter followed by any additional parameters of the motor as first parameter followed by any additional parameters
such as the position to run to for run. Functions have to return the proper such as the position to run to for run. Functions have to return the proper
SICS return codes for a motor driver as integer numbers. SICS return codes for a motor driver as integer numbers.

View File

@ -1,6 +1,6 @@
/*--------------------------------------------------------------------------- /*---------------------------------------------------------------------------
This is a motor driver which is implemented in Tcl. This means This is a motor driver which is implemented in Tcl. This means
this code is only a wrapper which calls Tcl functions to do the this code is only a wrapper which calls Tcl functions to do the
actual work. actual work.
copyright: see file COPYRIGHT copyright: see file COPYRIGHT
@ -12,7 +12,7 @@
#include "stringdict.h" #include "stringdict.h"
typedef struct ___TclDriv { typedef struct ___TclDriv {
/* general motor driver interface /* general motor driver interface
fields. REQUIRED! fields. REQUIRED!
*/ */
float fUpper; /* upper limit */ float fUpper; /* upper limit */

View File

@ -1,18 +1,18 @@
/* /*
This is a histogram memory driver for the 2005-6 version of the This is a histogram memory driver for the 2005-6 version of the
histogram memory software based on RTAI-Linux and an embedded WWW-server histogram memory software based on RTAI-Linux and an embedded WWW-server
for communications. For all http work the ghttp library from the gnome for communications. For all http work the ghttp library from the gnome
project is used. project is used.
This HM is meant to be used in conjunction with a counter module This HM is meant to be used in conjunction with a counter module
chained through the hmcontrol module. No need to handle counters here chained through the hmcontrol module. No need to handle counters here
when hmcontrol can do the chaining. when hmcontrol can do the chaining.
copyright: see file COPYRIGHT copyright: see file COPYRIGHT
Mark Koennecke, January 2005 (original SINQ version) Mark Koennecke, January 2005 (original SINQ version)
Mark Lesha, 9 October 2006 (ANSTO version) Mark Lesha, 9 October 2006 (ANSTO version)
----------------------------------------------------------------------*/ ----------------------------------------------------------------------*/
#include <stdlib.h> #include <stdlib.h>
#include <assert.h> #include <assert.h>
@ -57,7 +57,7 @@ static char devName[32] = "histmem";
#define BADSTATUS -707 #define BADSTATUS -707
#define BADAUTH -708 #define BADAUTH -708
/*===================================================================== /*=====================================================================
our driver private data structure our driver private data structure
======================================================================*/ ======================================================================*/
typedef struct { typedef struct {
ghttp_request *syncRequest; ghttp_request *syncRequest;
@ -81,14 +81,14 @@ typedef struct {
static int anstoHttpGetPrepare(pAnstoHttp self, char *request){ static int anstoHttpGetPrepare(pAnstoHttp self, char *request){
char url[512]; char url[512];
ghttp_status httpStatus; ghttp_status httpStatus;
if(self->asyncRunning){ if(self->asyncRunning){
while((httpStatus = ghttp_process(self->syncRequest)) while((httpStatus = ghttp_process(self->syncRequest))
== ghttp_not_done){ == ghttp_not_done){
} }
self->asyncRunning = 0; self->asyncRunning = 0;
} }
self->errorCode = 0; self->errorCode = 0;
ghttp_clean(self->syncRequest); ghttp_clean(self->syncRequest);
memset(self->hmError,0,512*sizeof(char)); memset(self->hmError,0,512*sizeof(char));
@ -153,7 +153,7 @@ static int anstoHttpGet(pAnstoHttp self, char *request){
return 0; // MJL return here if failed return 0; // MJL return here if failed
ghttp_prepare(self->syncRequest); // MJL be sure to call ghttp_prepare before each ghttp_process ghttp_prepare(self->syncRequest); // MJL be sure to call ghttp_prepare before each ghttp_process
httpStatus = ghttp_process(self->syncRequest); httpStatus = ghttp_process(self->syncRequest);
} }
if(httpStatus != ghttp_done){ if(httpStatus != ghttp_done){
strncpy(self->hmError,"Reconnect", 511); strncpy(self->hmError,"Reconnect", 511);
self->errorCode = SERVERERROR; self->errorCode = SERVERERROR;
@ -173,10 +173,10 @@ static int AnstoHttpConfigure(pHistDriver self, SConnection *pCon,
int i; int i;
char *confData = NULL; char *confData = NULL;
ghttp_status httpStatus; ghttp_status httpStatus;
pPriv = (pAnstoHttp)self->pPriv; pPriv = (pAnstoHttp)self->pPriv;
assert(pPriv != NULL); assert(pPriv != NULL);
/* /*
* The HM computer address * The HM computer address
*/ */
@ -187,7 +187,7 @@ static int AnstoHttpConfigure(pHistDriver self, SConnection *pCon,
return 0; return 0;
} }
/* /*
* looser credentials * looser credentials
*/ */
if(StringDictGet(pOpt,"username",pPriv->userName, 131) != 1){ if(StringDictGet(pOpt,"username",pPriv->userName, 131) != 1){
@ -202,11 +202,11 @@ static int AnstoHttpConfigure(pHistDriver self, SConnection *pCon,
eError); eError);
return 0; return 0;
} }
/* actual configuration. Check for flag INIT in /* actual configuration. Check for flag INIT in
options. We do not need to configure, if the HM has configured options. We do not need to configure, if the HM has configured
itself already. What is does, these days. itself already. What is does, these days.
*/ */
status = StringDictGetAsNumber(pOpt,"init",&fVal); status = StringDictGetAsNumber(pOpt,"init",&fVal);
iInit = 0; iInit = 0;
if(status == 1) { if(status == 1) {
@ -214,7 +214,7 @@ static int AnstoHttpConfigure(pHistDriver self, SConnection *pCon,
iInit = 1; iInit = 1;
} }
} }
/* /*
actually do configure actually do configure
*/ */
@ -283,16 +283,16 @@ static int AnstoHttpConfigure(pHistDriver self, SConnection *pCon,
} }
return 1; return 1;
} }
} }
} }
} }
// MJL NOTE: Added extra init parameters here, these get committed // MJL NOTE: Added extra init parameters here, these get committed
// regardless of whether we are doing the first init or not // regardless of whether we are doing the first init or not
// (i.e. will get committed even if init=1). // (i.e. will get committed even if init=1).
// Need to do init on the histogram object (e.g. 'hm init') // Need to do init on the histogram object (e.g. 'hm init')
// in order to commit changed settings during operation. // in order to commit changed settings during operation.
// Specifically, this is important if FAT settings need to be // Specifically, this is important if FAT settings need to be
// modified during operation. To do this, the command // modified during operation. To do this, the command
// 'hm configure FAT_Xxxx vvv' needs to be performed, // 'hm configure FAT_Xxxx vvv' needs to be performed,
// where Xxxx is the name of the item in the FAT, and vvv is the desired value. // where Xxxx is the name of the item in the FAT, and vvv is the desired value.
@ -326,8 +326,8 @@ static int AnstoHttpConfigure(pHistDriver self, SConnection *pCon,
} }
} }
} while(pItem); } while(pItem);
return 1; return 1;
} }
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
static int readStatus(pHistDriver pDriv){ static int readStatus(pHistDriver pDriv){
@ -335,10 +335,10 @@ static int readStatus(pHistDriver pDriv){
char line[132]; char line[132];
char name[80], value[80]; char name[80], value[80];
pAnstoHttp self = NULL; pAnstoHttp self = NULL;
self = (pAnstoHttp)pDriv->pPriv; self = (pAnstoHttp)pDriv->pPriv;
assert(self != NULL); assert(self != NULL);
pPtr = ghttp_get_body(self->syncRequest); pPtr = ghttp_get_body(self->syncRequest);
if(pPtr == NULL){ if(pPtr == NULL){
strncpy(self->hmError,"No body in status response",131); strncpy(self->hmError,"No body in status response",131);
@ -386,7 +386,7 @@ static int AnstoHttpStatus_Base(pHistDriver self,SConnection *pCon,int *pextrast
int status; int status;
pAnstoHttp pInternal = NULL; pAnstoHttp pInternal = NULL;
static int last_known_status=HWIdle; // assume idle initially static int last_known_status=HWIdle; // assume idle initially
pPriv = (pAnstoHttp)self->pPriv; pPriv = (pAnstoHttp)self->pPriv;
assert(pPriv != NULL); assert(pPriv != NULL);
@ -438,8 +438,8 @@ static int AnstoHttpStatus_Base(pHistDriver self,SConnection *pCon,int *pextrast
} }
break; break;
} }
status = readStatus(self); status = readStatus(self);
if(status != 1){ if(status != 1){
if (pextrastatus) *pextrastatus=ANSTO_HS_STATUS_INVALID; if (pextrastatus) *pextrastatus=ANSTO_HS_STATUS_INVALID;
@ -532,7 +532,7 @@ static int AnstoHttpStatusWithRetries(pHistDriver self, int requiredstate,SConne
// Retry after a delay if status hasn't changed yet // Retry after a delay if status hasn't changed yet
// (DAE takes time to start up / shut down) // (DAE takes time to start up / shut down)
if (retcode != HWPause && runloop) // Only wait if we're going to loop, otherwise drop out immediately if (retcode != HWPause && runloop) // Only wait if we're going to loop, otherwise drop out immediately
{ {
long long start_time_us=get_localtime_us(); long long start_time_us=get_localtime_us();
do // make sure the yield in this loop gets called at least once do // make sure the yield in this loop gets called at least once
{ {
@ -557,7 +557,7 @@ static int AnstoHttpStart(pHistDriver self, SConnection *pCon){
assert(pPriv != NULL); assert(pPriv != NULL);
status = anstoHttpGet(pPriv,startdaq); status = anstoHttpGet(pPriv,startdaq);
if(status != 1){ if(status != 1){
return HWFault; return HWFault;
} }
@ -577,14 +577,14 @@ static int AnstoHttpHalt(pHistDriver self){ // hmm, why isn't there a pCon like
if(status != 1){ if(status != 1){
return HWFault; return HWFault;
} }
//TODO check statuscheck flag //TODO check statuscheck flag
StringDictGet(self->pOption,"statuscheck",checkstatus,20); StringDictGet(self->pOption,"statuscheck",checkstatus,20);
if (strcmp(checkstatus,"true") == 0) { if (strcmp(checkstatus,"true") == 0) {
AnstoHttpStatusWithRetries(self,ANSTO_HS_STATUS_STOPPED,NULL); // no pCon available :( AnstoHttpStatusWithRetries(self,ANSTO_HS_STATUS_STOPPED,NULL); // no pCon available :(
} }
return OKOK; return OKOK;
} }
/*---------------------------------------------------------------------*/ /*---------------------------------------------------------------------*/
@ -611,9 +611,9 @@ static int AnstoHttpVeto(pHistDriver self,SConnection *pCon)
return HWFault; return HWFault;
} }
pPriv->pause = 1; pPriv->pause = 1;
AnstoHttpStatusWithRetries(self,ANSTO_HS_STATUS_PAUSED,pCon); AnstoHttpStatusWithRetries(self,ANSTO_HS_STATUS_PAUSED,pCon);
return OKOK; return OKOK;
} }
static int AnstoHttpNoVeto(pHistDriver self,SConnection *pCon) static int AnstoHttpNoVeto(pHistDriver self,SConnection *pCon)
@ -653,9 +653,9 @@ int AnstoHttpPause(pHistDriver self,SConnection *pCon){
/*ffr AnstoHttpVeto now provides pause() /*ffr AnstoHttpVeto now provides pause()
pPriv->pause = 1; pPriv->pause = 1;
*/ */
AnstoHttpStatusWithRetries(self,ANSTO_HS_STATUS_PAUSED,pCon); AnstoHttpStatusWithRetries(self,ANSTO_HS_STATUS_PAUSED,pCon);
return OKOK; return OKOK;
} }
static int AnstoHttpPauseNoCon(pHistDriver self) { static int AnstoHttpPauseNoCon(pHistDriver self) {
@ -678,7 +678,7 @@ static int AnstoHttpContinue(pHistDriver self, SConnection *pCon){
return OKOK; return OKOK;
} }
/*---------------------------------------------------------------------*/ /*---------------------------------------------------------------------*/
static int AnstoHttpError(pHistDriver self, int *code, static int AnstoHttpError(pHistDriver self, int *code,
char *error, int errLen){ char *error, int errLen){
pAnstoHttp pPriv = NULL; pAnstoHttp pPriv = NULL;
@ -768,7 +768,7 @@ static int AnstoHttpGetHistogram(pHistDriver self, SConnection *pCon,
{ {
int size=((end-start)>(MAX_HTTP_REQUEST_BYTES/sizeof(int))) int size=((end-start)>(MAX_HTTP_REQUEST_BYTES/sizeof(int)))
?(MAX_HTTP_REQUEST_BYTES/sizeof(int)):(end-start); ?(MAX_HTTP_REQUEST_BYTES/sizeof(int)):(end-start);
// Send traditional SICS bank,start,end parameters to the server // Send traditional SICS bank,start,end parameters to the server
// bank is now ignored by the server though, and start and end // bank is now ignored by the server though, and start and end
// may be overridden by supplementary settings (see below). // may be overridden by supplementary settings (see below).
@ -794,27 +794,27 @@ static int AnstoHttpGetHistogram(pHistDriver self, SConnection *pCon,
} }
} }
} while(pItem); } while(pItem);
// Send our request // Send our request
status = anstoHttpGet(pPriv,command); status = anstoHttpGet(pPriv,command);
if(status != 1){ if(status != 1){
return HWFault; return HWFault;
} }
len = ghttp_get_body_len(pPriv->syncRequest); len = ghttp_get_body_len(pPriv->syncRequest);
if(len < (int) (size*sizeof(int))){ if(len < (int) (size*sizeof(int))){
pPriv->errorCode = BODYSHORT; pPriv->errorCode = BODYSHORT;
strncpy(pPriv->hmError,"Not enough data received from HM",511); strncpy(pPriv->hmError,"Not enough data received from HM",511);
return HWFault; return HWFault;
} }
hmdata = (HistInt *)ghttp_get_body(pPriv->syncRequest); hmdata = (HistInt *)ghttp_get_body(pPriv->syncRequest);
if(hmdata == NULL){ // MJL check ghttp_get_body for NULL return if(hmdata == NULL){ // MJL check ghttp_get_body for NULL return
pPriv->errorCode = NOBODY; pPriv->errorCode = NOBODY;
strncpy(pPriv->hmError,"No body in HM data response",511); strncpy(pPriv->hmError,"No body in HM data response",511);
return HWFault; return HWFault;
} }
// MJL removed the ntohl, our histogram server doesn't apply htonl, // MJL removed the ntohl, our histogram server doesn't apply htonl,
// so the data arrives in LE format. (Would have to buffer data // so the data arrives in LE format. (Would have to buffer data
// at the server otherwise...) // at the server otherwise...)
@ -836,10 +836,10 @@ static int AnstoHttpSetHistogram(pHistDriver self, SConnection *pCon,
pPriv = (pAnstoHttp)self->pPriv; pPriv = (pAnstoHttp)self->pPriv;
assert(pPriv != NULL); assert(pPriv != NULL);
pPriv->errorCode = NOTIMPLEMENTED; pPriv->errorCode = NOTIMPLEMENTED;
strncpy(pPriv->hmError,"Not implemented",511); strncpy(pPriv->hmError,"Not implemented",511);
return HWFault; return HWFault;
} }
/*---------------------------------------------------------------------*/ /*---------------------------------------------------------------------*/
static long AnstoHttpGetMonitor(pHistDriver self, int i, static long AnstoHttpGetMonitor(pHistDriver self, int i,
@ -874,7 +874,7 @@ static int AnstoHttpFreePrivate(pHistDriver self){
if(pPriv == NULL){ if(pPriv == NULL){
return 1; return 1;
} }
if(pPriv->syncRequest != NULL){ if(pPriv->syncRequest != NULL){
ghttp_request_destroy(pPriv->syncRequest); ghttp_request_destroy(pPriv->syncRequest);
} }
@ -882,7 +882,7 @@ static int AnstoHttpFreePrivate(pHistDriver self){
DeleteCallBackInterface(pPriv->pCall); DeleteCallBackInterface(pPriv->pCall);
} }
free(pPriv); free(pPriv);
return 1; return 1;
} }
/*-------------------------------------------------------------------*/ /*-------------------------------------------------------------------*/
@ -890,12 +890,12 @@ pHistDriver CreateAnstoHttpDriver(pStringDict pOption){
pHistDriver pNew = NULL; pHistDriver pNew = NULL;
pAnstoHttp pInternal = NULL; pAnstoHttp pInternal = NULL;
pICallBack pCallNew = NULL; pICallBack pCallNew = NULL;
/* create the general driver */ /* create the general driver */
pNew = CreateHistDriver(pOption); pNew = CreateHistDriver(pOption);
if(!pNew){ if(!pNew){
return NULL; return NULL;
} }
/* add our options */ /* add our options */
StringDictAddPair(pOption,"hmaddress","http://localhost:8080"); StringDictAddPair(pOption,"hmaddress","http://localhost:8080");
@ -922,7 +922,7 @@ pHistDriver CreateAnstoHttpDriver(pStringDict pOption){
free(pInternal); free(pInternal);
return NULL; return NULL;
} }
// Save a pointer to the string dictionary internally, // Save a pointer to the string dictionary internally,
// for the use of those functions that require it and // for the use of those functions that require it and
// don't get a pOption passed in via the argument list. // don't get a pOption passed in via the argument list.
@ -945,7 +945,7 @@ pHistDriver CreateAnstoHttpDriver(pStringDict pOption){
pNew->FreePrivate = AnstoHttpFreePrivate; pNew->FreePrivate = AnstoHttpFreePrivate;
pNew->Pause = AnstoHttpVeto; pNew->Pause = AnstoHttpVeto;
pNew->Continue = AnstoHttpContinue; pNew->Continue = AnstoHttpContinue;
return pNew; return pNew;
} }
@ -1006,7 +1006,7 @@ pHistDriver CreateAnstoHttpDriver(pStringDict pOption){
pHistMem pNew = NULL; pHistMem pNew = NULL;
char pBueffel[512]; char pBueffel[512];
int iRet; int iRet;
/* check no of arguments */ /* check no of arguments */
if(argc < 3) if(argc < 3)
{ {
@ -1014,7 +1014,7 @@ pHistDriver CreateAnstoHttpDriver(pStringDict pOption){
SCWrite(pCon,pBueffel,eError); SCWrite(pCon,pBueffel,eError);
return 0; return 0;
} }
/* make new HM */ /* make new HM */
strtolower(argv[2]); strtolower(argv[2]);
pNew = CreateHistMemory(argv[2]); pNew = CreateHistMemory(argv[2]);
@ -1023,11 +1023,11 @@ pHistDriver CreateAnstoHttpDriver(pStringDict pOption){
sprintf(pBueffel,"ERROR: failed to create Histogram Memory %s, driver %s may be invalid or no memory", sprintf(pBueffel,"ERROR: failed to create Histogram Memory %s, driver %s may be invalid or no memory",
argv[1], argv[2]); argv[1], argv[2]);
SCWrite(pCon,pBueffel,eError); SCWrite(pCon,pBueffel,eError);
return 0; return 0;
} }
StringDictAddPair(pNew->pDriv->pOption,"name",argv[1]); StringDictAddPair(pNew->pDriv->pOption,"name",argv[1]);
/* install HM as command */ /* install HM as command */
iRet = AddCommand(pSics,argv[1],ANSTO_HistAction,DeleteHistMemory,(void *)pNew); iRet = AddCommand(pSics,argv[1],ANSTO_HistAction,DeleteHistMemory,(void *)pNew);
if(!iRet) if(!iRet)

View File

@ -1,18 +1,18 @@
/* /*
This is a histogram mmeory driver for the 2005-6 version of the This is a histogram mmeory driver for the 2005-6 version of the
histogram mmeory software based on RTAI-Linux and an embedded WWW-server histogram mmeory software based on RTAI-Linux and an embedded WWW-server
for communications. For all http work the ghttp library from the gnome for communications. For all http work the ghttp library from the gnome
project is used. project is used.
This HM is meant to be used in conjunction with a counter module This HM is meant to be used in conjunction with a counter module
chained through the hmcontrol module. No need to handle counters here chained through the hmcontrol module. No need to handle counters here
when hmcontrol can do the chaining. when hmcontrol can do the chaining.
copyright: see file COPYRIGHT copyright: see file COPYRIGHT
Mark Koennecke, January 2005 (original SINQ version) Mark Koennecke, January 2005 (original SINQ version)
Mark Lesha, 9 October 2006 (ANSTO version)fs Mark Lesha, 9 October 2006 (ANSTO version)fs
----------------------------------------------------------------------*/ ----------------------------------------------------------------------*/
#ifndef ANSTOHTTP_H_ #ifndef ANSTOHTTP_H_
#define ANSTOHTTP_H_ #define ANSTOHTTP_H_

View File

@ -28,12 +28,12 @@ char *getParam(SConnection *pCon, Tcl_Interp *pTcl, char *params, char *parName,
SCWrite(pCon,pError, eError); SCWrite(pCon,pError, eError);
} }
return pPtr; return pPtr;
} }
/** \brief Lookup named host in /etc/hosts /** \brief Lookup named host in /etc/hosts
* \param *pCon (r) connection object. * \param *pCon (r) connection object.
* \param *hostName (r) name of host to look up * \param *hostName (r) name of host to look up
* \return * \return
* - host address on success * - host address on success
* - 0 on failure * - 0 on failure
*/ */
@ -101,10 +101,10 @@ int hostNamCmd(SConnection *pCon, SicsInterp *pInter, void *pData, int argc, cha
const char* hn; const char* hn;
//int iMacro; //int iMacro;
char hostaddr[132]; char hostaddr[132];
assert(pCon != NULL); assert(pCon != NULL);
assert(pInter != NULL); assert(pInter != NULL);
switch (argc) { switch (argc) {
case 2: case 2:
hn = getHostNam(pCon, argv[1]); hn = getHostNam(pCon, argv[1]);
@ -114,7 +114,7 @@ int hostNamCmd(SConnection *pCon, SicsInterp *pInter, void *pData, int argc, cha
SCWrite(pCon,"Insufficient arguments to hostNamCmd",eError); SCWrite(pCon,"Insufficient arguments to hostNamCmd",eError);
return 0; return 0;
} }
//iMacro = SCinMacro(pCon); //iMacro = SCinMacro(pCon);
//SCsetMacro(pCon,0); //SCsetMacro(pCon,0);
SCWrite(pCon,hostaddr,eValue); SCWrite(pCon,hostaddr,eValue);
@ -125,7 +125,7 @@ int hostNamCmd(SConnection *pCon, SicsInterp *pInter, void *pData, int argc, cha
/** \brief Lookup named port in /etc/services /** \brief Lookup named port in /etc/services
* \param *pCon (r) connection object. * \param *pCon (r) connection object.
* \param *portName (r) name of port to look up * \param *portName (r) name of port to look up
* \return * \return
* - port number on success * - port number on success
* - 0 on failure * - 0 on failure
*/ */
@ -192,10 +192,10 @@ int portNumCmd(SConnection *pCon, SicsInterp *pInter, void *pData, int argc, cha
int pn; int pn;
//int iMacro; //int iMacro;
char portNum[MAXNUMCHAR]; char portNum[MAXNUMCHAR];
assert(pCon != NULL); assert(pCon != NULL);
assert(pInter != NULL); assert(pInter != NULL);
switch (argc) { switch (argc) {
case 2: case 2:
pn = getPortNum(pCon, argv[1]); pn = getPortNum(pCon, argv[1]);
@ -205,7 +205,7 @@ int portNumCmd(SConnection *pCon, SicsInterp *pInter, void *pData, int argc, cha
SCWrite(pCon,"Insufficient arguments to portNumCmd",eError); SCWrite(pCon,"Insufficient arguments to portNumCmd",eError);
return 0; return 0;
} }
//iMacro = SCinMacro(pCon); //iMacro = SCinMacro(pCon);
//SCsetMacro(pCon,0); //SCsetMacro(pCon,0);
SCWrite(pCon,portNum,eValue); SCWrite(pCon,portNum,eValue);
@ -215,5 +215,5 @@ int portNumCmd(SConnection *pCon, SicsInterp *pInter, void *pData, int argc, cha
int AbortBatch(SConnection *pCon, SicsInterp *pInter, void *pData, int argc, char *argv[]) { int AbortBatch(SConnection *pCon, SicsInterp *pInter, void *pData, int argc, char *argv[]) {
SCSetInterrupt(pCon,eAbortBatch); SCSetInterrupt(pCon,eAbortBatch);
return TCL_ERROR; return TCL_ERROR;
} }

View File

@ -5,7 +5,7 @@
#define ERRLEN 256 #define ERRLEN 256
#define FAILURE 0 #define FAILURE 0
#define SUCCESS 1 #define SUCCESS 1
char *getParam(SConnection *pCon, Tcl_Interp *pTcl, char *params, char *parName, int mustHave ); char *getParam(SConnection *pCon, Tcl_Interp *pTcl, char *params, char *parName, int mustHave );
int hostNamCmd(SConnection *pCon, SicsInterp *pInter, void *pData, int argc, char *argv[]); int hostNamCmd(SConnection *pCon, SicsInterp *pInter, void *pData, int argc, char *argv[]);
int portNumCmd(SConnection *pCon, SicsInterp *pInter, void *pData, int argc, char *argv[]); int portNumCmd(SConnection *pCon, SicsInterp *pInter, void *pData, int argc, char *argv[]);
int getPortNum(SConnection *pCon, char *portName); int getPortNum(SConnection *pCon, char *portName);

View File

@ -1,6 +1,6 @@
/* /*
@file beamstopaction.c @file beamstopaction.c
@brief Proof of concept action object for Quokka beamstops. @brief Proof of concept action object for Quokka beamstops.
*/ */
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
@ -84,15 +84,15 @@ int ActNm2ID(char *actnm, char *actlist[], int numact) {
static void *AO_GetInterface(void *pData, int iID) { static void *AO_GetInterface(void *pData, int iID) {
pAction self = NULL; pAction self = NULL;
self = (pAction)pData; self = (pAction)pData;
assert(self); assert(self);
if(iID == DRIVEID){ if(iID == DRIVEID){
return self->pDrivInt; return self->pDrivInt;
} }
return NULL; return NULL;
} }
int AO_Wrapper(SConnection *pCon, SicsInterp *pSics, void *pData, int argc, char *argv[]) { int AO_Wrapper(SConnection *pCon, SicsInterp *pSics, void *pData, int argc, char *argv[]) {
char msg[128]="No message", output[256]; char msg[128]="No message", output[256];
@ -144,7 +144,7 @@ int AO_Wrapper(SConnection *pCon, SicsInterp *pSics, void *pData, int argc, char
} }
/* TODO allow plain output */ /* TODO allow plain output */
switch (msgType) { switch (msgType) {
case eValue: case eValue:
sprintf(output, "%s = %s", argv[0], msg); sprintf(output, "%s = %s", argv[0], msg);
SCWrite(pCon, output, eValue); SCWrite(pCon, output, eValue);
break; break;
@ -179,7 +179,7 @@ static long AO_StartAction(void *pData, SConnection *pCon, float fVal) {
if fVal == start then if fVal == start then
get actionsequence which matches the actionID get actionsequence which matches the actionID
send sequence send sequence
set currentAction = actionID, used by status set currentAction = actionID, used by status
*/ */
char msg[128]; char msg[128];
char cmd[AO_CMDLEN], reply[AO_CMDLEN]; char cmd[AO_CMDLEN], reply[AO_CMDLEN];
@ -222,14 +222,14 @@ if fVal == start then
debugmsg(pCon, self, "Start action"); debugmsg(pCon, self, "Start action");
self->fTarget = fVal; self->fTarget = fVal;
return OKOK; return OKOK;
} }
static int AO_CheckStatus(void *pData, SConnection *pCon) { static int AO_CheckStatus(void *pData, SConnection *pCon) {
pAction self =(pAction) pData; pAction self =(pAction) pData;
char cmd[AO_CMDLEN], reply[AO_CMDLEN]= " 0000000113 0007831721 0000000047 0000000000 0000000001\n:"; char cmd[AO_CMDLEN], reply[AO_CMDLEN]= " 0000000113 0007831721 0000000047 0000000000 0000000001\n:";
int devStatus, sicsStatus, comStatus, limswi, cmd_len; int devStatus, sicsStatus, comStatus, limswi, cmd_len;
int iSteps, iCounts, iFlags, iBG, iStopCode; int iSteps, iCounts, iFlags, iBG, iStopCode;
char msg[128]; char msg[128];
sprintf(cmd, "MG {F10.0} _TD%c,_TP%c,_TS%c,_BG%c,_SC%c", self->cf_axis,self->cf_axis,self->cf_axis,self->cf_axis,self->cf_axis); sprintf(cmd, "MG {F10.0} _TD%c,_TP%c,_TS%c,_BG%c,_SC%c", self->cf_axis,self->cf_axis,self->cf_axis,self->cf_axis,self->cf_axis);
debugmsg(pCon, self, cmd); debugmsg(pCon, self, cmd);
// comStatus = 1; // comStatus = 1;
@ -272,7 +272,7 @@ cmd_len = AO_CMDLEN;
return sicsStatus; return sicsStatus;
} }
/* @brief Check the device status and return the SICS status code /* @brief Check the device status and return the SICS status code
*/ */
static float AO_GetValue(void *pData, SConnection *pCon) { static float AO_GetValue(void *pData, SConnection *pCon) {
pAction self = (pAction) pData; pAction self = (pAction) pData;
@ -341,7 +341,7 @@ int ActionObjectFactory(SConnection *pCon, SicsInterp *pSics, void *pData, int a
return 0; return 0;
} }
printf("Create the %s action object on asyncqueue %s\n", argv[1], argv[2]); printf("Create the %s action object on asyncqueue %s\n", argv[1], argv[2]);
pNew = AO_Create(pCon, argv[2]); pNew = AO_Create(pCon, argv[2]);
if (pNew == NULL) { if (pNew == NULL) {

View File

@ -3,7 +3,7 @@
* *
* A SICS counter can manage several monitors, this is the driver * A SICS counter can manage several monitors, this is the driver
* for the beam monitor developed at ANSTO * for the beam monitor developed at ANSTO
* *
* Copyright: see file Copyright.txt * Copyright: see file Copyright.txt
* *
* Ferdi Franceschini July 2006 * Ferdi Franceschini July 2006
@ -57,7 +57,7 @@ typedef struct {
prs232 controller; prs232 controller;
int state; int state;
int errorCode; int errorCode;
char *errorMsg; /**< Points to memory for error messages */ char *errorMsg; /**< Points to memory for error messages */
char *host; char *host;
int iPort; int iPort;
float dummy_threshold; float dummy_threshold;
@ -135,7 +135,7 @@ static int checkConnection(pBeamMon self)
/* no data to read, otherwise OK */ /* no data to read, otherwise OK */
return SUCCESS; return SUCCESS;
} }
flog(self, "#::counter recv = %d, errno = %d:%s\n", status, errno, strerror(errno)); flog(self, "#::counter recv = %d, errno = %d:%s\n", status, errno, strerror(errno));
flog(self, "#::Channel Error!"); flog(self, "#::Channel Error!");
self->errorCode = BADREAD; self->errorCode = BADREAD;
return FAILURE; return FAILURE;
@ -253,7 +253,7 @@ static int MonWrite(pBeamMon self, char* text) {
status = writeRS232(self->controller, text, (int) len); status = writeRS232(self->controller, text, (int) len);
if (status != 1) { if (status != 1) {
flog(self, "#::MonWrite status = %d, errno = %d\n", status, errno); flog(self, "#::MonWrite status = %d, errno = %d\n", status, errno);
self->errorCode = status; self->errorCode = status;
if (status == BADSEND && errno == EPIPE) if (status == BADSEND && errno == EPIPE)
self->errorCode = NOTCONNECTED; self->errorCode = NOTCONNECTED;
@ -351,7 +351,7 @@ static int MonSend(CounterDriver *cntrData, char *pText, char *pReply, int iRepl
return status; return status;
if ((status = MonRead(self, pReply, &iReplyLen)) == SUCCESS) if ((status = MonRead(self, pReply, &iReplyLen)) == SUCCESS)
{ {
pReply[iReplyLen] = '\0'; pReply[iReplyLen] = '\0';
return SUCCESS; return SUCCESS;
} }
return status; return status;
@ -470,7 +470,7 @@ static void MonHandleInput(CounterDriver *cntrData, BUFFER* bp) {
* breaks input into lines terminated by <CR><LF> pairs and passes complete lines to MonHandleInput for processing. * breaks input into lines terminated by <CR><LF> pairs and passes complete lines to MonHandleInput for processing.
* *
* \param cntrData provides access to a monitor's data * \param cntrData provides access to a monitor's data
* \param timeout upper limit on time to wait for data to arrive * \param timeout upper limit on time to wait for data to arrive
*/ */
static void MonLookForInput(CounterDriver *cntrData, /*@unused@*/ int timeout) { static void MonLookForInput(CounterDriver *cntrData, /*@unused@*/ int timeout) {
BeamMon* self = NULL; BeamMon* self = NULL;
@ -548,8 +548,8 @@ static int MonGetStatus(CounterDriver *cntrData, float *fControl) {
case HWFault: case HWFault:
default: default:
return HWFault; return HWFault;
} }
} }
/** \brief Starts counting in the current mode and with the current preset /** \brief Starts counting in the current mode and with the current preset
* *
@ -586,12 +586,12 @@ static int MonStart(CounterDriver *cntrData) {
return FAILURE; return FAILURE;
} }
} }
/*@-duplicatequals@ for uint64 */ /*@-duplicatequals@ for uint64 */
/*@-formattype@ for uint64 */ /*@-formattype@ for uint64 */
(void) snprintf(str, sizeof(str), "SICS SET TERMINAL=%llu", (void) snprintf(str, sizeof(str), "SICS SET TERMINAL=%llu",
(uint64) cntrData->fPreset); (uint64) cntrData->fPreset);
/*@+formattype@*/ /*@+formattype@*/
/*@+duplicatequals@*/ /*@+duplicatequals@*/
status = MonSendBuffer(cntrData, str, &self->buffer); status = MonSendBuffer(cntrData, str, &self->buffer);
if (status != SUCCESS || strcasecmp(self->buffer.body, "OK") != 0) { if (status != SUCCESS || strcasecmp(self->buffer.body, "OK") != 0) {
self->errorCode = /* TODO */ 0; self->errorCode = /* TODO */ 0;
@ -625,7 +625,7 @@ static int MonPause(CounterDriver *cntrData) {
return SUCCESS; return SUCCESS;
} }
return FAILURE; return FAILURE;
} }
/* \brief Continues a paused counting operation. /* \brief Continues a paused counting operation.
* *
@ -646,7 +646,7 @@ static int MonContinue(CounterDriver *cntrData) {
return SUCCESS; return SUCCESS;
} }
return FAILURE; return FAILURE;
} }
/** \brief Cancels a counting operation. This is an emergency stop used when interrupting an operation. /** \brief Cancels a counting operation. This is an emergency stop used when interrupting an operation.
* \param *cntrData provides access to a monitor's data * \param *cntrData provides access to a monitor's data
@ -666,7 +666,7 @@ static int MonHalt(CounterDriver *cntrData) {
return SUCCESS; return SUCCESS;
} }
return FAILURE; return FAILURE;
} }
/** \brief Reads the counter and the monitors in the lCounts array. /** \brief Reads the counter and the monitors in the lCounts array.
* *
@ -686,10 +686,10 @@ static int MonReadValues(CounterDriver *cntrData) {
return SUCCESS; return SUCCESS;
} }
return FAILURE; return FAILURE;
} }
/* \brief Called when an error condition is reported by a counter operation. /* \brief Called when an error condition is reported by a counter operation.
* *
* \param *cntrData provides access to a monitor's data * \param *cntrData provides access to a monitor's data
* \param *iCode error code returned to logical counter. * \param *iCode error code returned to logical counter.
* \param *error error message * \param *error error message
@ -707,7 +707,7 @@ static int MonGetError(CounterDriver *cntrData, int *iCode, char *error, int iEr
} }
*iCode = self->errorCode; *iCode = self->errorCode;
flog(self, ".::MonGetError: %d", self->errorCode); flog(self, ".::MonGetError: %d", self->errorCode);
switch (*iCode) { switch (*iCode) {
case 0: case 0:
if (checkConnection(self) == FAILURE) { if (checkConnection(self) == FAILURE) {
if (self->errorCode == NOTCONNECTED) { if (self->errorCode == NOTCONNECTED) {
@ -749,9 +749,9 @@ static int MonGetError(CounterDriver *cntrData, int *iCode, char *error, int iEr
self->errorMsg = strdup(error); self->errorMsg = strdup(error);
self->errorCode = 0; self->errorCode = 0;
return SUCCESS; return SUCCESS;
} }
/* \brief Tries to fix problem associated with iCode error reported by MonGetError. /* \brief Tries to fix problem associated with iCode error reported by MonGetError.
* *
* \param *cntrData provides access to a monitor's data * \param *cntrData provides access to a monitor's data
* \param *iCode error code from MonGetError. * \param *iCode error code from MonGetError.
@ -773,8 +773,8 @@ static int MonTryAndFixIt(CounterDriver *cntrData, int iCode) {
if (initRS232(self->controller) == 1) if (initRS232(self->controller) == 1)
return COREDO; return COREDO;
return COTERM; return COTERM;
case BADREAD: case BADREAD:
case BADSEND: case BADSEND:
case TIMEOUT: case TIMEOUT:
case BADMEMORY: /* Won't happen if MonConnect sets the send terminator */ case BADMEMORY: /* Won't happen if MonConnect sets the send terminator */
case INCOMPLETE: case INCOMPLETE:
@ -795,11 +795,11 @@ static int MonSet(CounterDriver *cntrData, char *name, int iCter, float fVal) {
self = (BeamMon *) cntrData->pData; self = (BeamMon *) cntrData->pData;
flog(self, ".::MonSet(%s, %d, %f)", name, iCter, fVal); flog(self, ".::MonSet(%s, %d, %f)", name, iCter, fVal);
if(strcmp(name,"threshold") == 0){ if(strcmp(name,"threshold") == 0){
//TODO set threshold //TODO set threshold
self->dummy_threshold = fVal; self->dummy_threshold = fVal;
} }
else if(strcmp(name,"debug") == 0){ else if(strcmp(name,"debug") == 0){
//TODO set threshold //TODO set threshold
self->debug = fVal; self->debug = fVal;
} }
/* TODO*/ /* TODO*/
@ -811,11 +811,11 @@ static int MonGet(CounterDriver *cntrData, char *name, int iCter, float *fVal) {
self = (BeamMon *) cntrData->pData; self = (BeamMon *) cntrData->pData;
if(strcasecmp(name,"threshold") == 0){ if(strcasecmp(name,"threshold") == 0){
//TODO get threshold //TODO get threshold
*fVal = self->dummy_threshold; *fVal = self->dummy_threshold;
} }
else if(strcasecmp(name,"debug") == 0){ else if(strcasecmp(name,"debug") == 0){
//TODO get threshold //TODO get threshold
*fVal = self->debug; *fVal = self->debug;
} }
/* TODO*/ /* TODO*/
@ -903,7 +903,7 @@ static void KillMon(/*@null@*/ pCounterDriver cntrData) {
if(!pCntDriv) { if(!pCntDriv) {
free(newCtr); free(newCtr);
return NULL; return NULL;
} }
pCntDriv->GetStatus = MonGetStatus; pCntDriv->GetStatus = MonGetStatus;
pCntDriv->Start = MonStart; pCntDriv->Start = MonStart;

View File

@ -1,6 +1,6 @@
/* /*
* Abstraction of the counter device. * Abstraction of the counter device.
* *
*/ */
#include "device.h" #include "device.h"
#include "params.h" #include "params.h"

View File

@ -432,7 +432,7 @@ void process_form(int n, BUFFER* bp)
} }
state = 0; state = 0;
} }
} }
} }
/** /**
@ -440,7 +440,7 @@ void process_form(int n, BUFFER* bp)
* *
* \param n index of socket * \param n index of socket
* *
* Used after a command button to redirect to the display page. Uses * Used after a command button to redirect to the display page. Uses
* HTTP 303 REDIRECT to get the browser to display the page. * HTTP 303 REDIRECT to get the browser to display the page.
*/ */
void put_page_refresh(int n) void put_page_refresh(int n)
@ -493,7 +493,7 @@ void put_page_refresh(int n)
* *
* \param n index of socket * \param n index of socket
* *
* Used after a command button to redirect to the control form. Uses * Used after a command button to redirect to the control form. Uses
* HTTP 303 REDIRECT to get the browser to display the form. * HTTP 303 REDIRECT to get the browser to display the form.
*/ */
void put_form_refresh(int n) void put_form_refresh(int n)

View File

@ -43,7 +43,7 @@ typedef struct parameter_t
bool sync; bool sync;
/** source 0:default, 1:timebase_1, 2:timebase_2, 3:timebase_3 */ /** source 0:default, 1:timebase_1, 2:timebase_2, 3:timebase_3 */
int source; int source;
} PARAMETERS, *pPARAMETERS; } PARAMETERS, *pPARAMETERS;
bool param_set(pPARAMETERS pp, char* name, char* value); bool param_set(pPARAMETERS pp, char* name, char* value);

View File

@ -26,13 +26,13 @@ typedef enum terminal_mode_t
/** unknown or uninitialised */ /** unknown or uninitialised */
term_idle = 0, term_idle = 0,
/** telnet socket */ /** telnet socket */
term_tty, term_tty,
/** web page GET */ /** web page GET */
term_page, term_page,
/** web form POST */ /** web form POST */
term_form, term_form,
/** SOAP request */ /** SOAP request */
term_soap term_soap
} TERM_MODE; } TERM_MODE;
/** /**

View File

@ -33,7 +33,7 @@ char* make_timestamp(const struct timeval* tv)
double time_diff(struct timeval* later, struct timeval* earlier) double time_diff(struct timeval* later, struct timeval* earlier)
{ {
double delta = double delta =
((double) later->tv_sec - (double) earlier->tv_sec) ((double) later->tv_sec - (double) earlier->tv_sec)
+ 0.000001 * ((double) later->tv_usec - (double) earlier->tv_usec); + 0.000001 * ((double) later->tv_usec - (double) earlier->tv_usec);
return delta; return delta;

View File

@ -29,7 +29,7 @@ typedef struct buffer_t
* *
* Makes a string version of the time for printing. Uses * Makes a string version of the time for printing. Uses
* only the time of day to produce a string in the format * only the time of day to produce a string in the format
* HH:MM:SS.UUUUUU at microsecond resolution. * HH:MM:SS.UUUUUU at microsecond resolution.
* *
* Uses a circular set of internal static buffers allowing * Uses a circular set of internal static buffers allowing
* several calls without overwriting - useful for * several calls without overwriting - useful for

View File

@ -1,6 +1,6 @@
/* /*
* Abstraction of the counter device. * Abstraction of the counter device.
* *
*/ */
#include "device.h" #include "device.h"
#include "params.h" #include "params.h"

View File

@ -515,7 +515,7 @@ void process_form(int n, BUFFER* bp)
} }
state = 0; state = 0;
} }
} }
} }
/** /**
@ -523,7 +523,7 @@ void process_form(int n, BUFFER* bp)
* *
* \param n index of socket * \param n index of socket
* *
* Used after a command button to redirect to the display page. Uses * Used after a command button to redirect to the display page. Uses
* HTTP 303 REDIRECT to get the browser to display the page. * HTTP 303 REDIRECT to get the browser to display the page.
*/ */
void put_page_refresh(int n) void put_page_refresh(int n)
@ -576,7 +576,7 @@ void put_page_refresh(int n)
* *
* \param n index of socket * \param n index of socket
* *
* Used after a command button to redirect to the control form. Uses * Used after a command button to redirect to the control form. Uses
* HTTP 303 REDIRECT to get the browser to display the form. * HTTP 303 REDIRECT to get the browser to display the form.
*/ */
void put_form_refresh(int n) void put_form_refresh(int n)

View File

@ -675,11 +675,11 @@ void initMite(iBus *bus)
physicalBar1 = bus->get(kBusAddressPhysical,kPCI_BAR1); physicalBar1 = bus->get(kBusAddressPhysical,kPCI_BAR1);
// ***** 6602/6608 specific MITE initialization ***** // ***** 6602/6608 specific MITE initialization *****
// Hit the IO Window Base/Size Register 1 (IOWBSR1) in the MITE. We set the // Hit the IO Window Base/Size Register 1 (IOWBSR1) in the MITE. We set the
// address, enable the window and set the size of the window: // address, enable the window and set the size of the window:
Bar0.write32(0xC4, (physicalBar1 & 0xffffff00L) | 0x8C); Bar0.write32(0xC4, (physicalBar1 & 0xffffff00L) | 0x8C);
// Write to the IO Window Control Register 1 (IOWCR1) to make the IO window // Write to the IO Window Control Register 1 (IOWCR1) to make the IO window
// go to RAM memory space instead of the config space // go to RAM memory space instead of the config space
Bar0.write32(0xF4, 0); Bar0.write32(0xF4, 0);
@ -735,7 +735,7 @@ void initCard(pHWARE hware)
pci->tio_2->IO_Pin_32_33_Configuration_Register.writeIO_Pin_32_Select(0); //0='input' pci->tio_2->IO_Pin_32_33_Configuration_Register.writeIO_Pin_32_Select(0); //0='input'
pci->tio_2->IO_Pin_36_37_Configuration_Register.writeIO_Pin_36_Select(0); //0='input' pci->tio_2->IO_Pin_36_37_Configuration_Register.writeIO_Pin_36_Select(0); //0='input'
//Bind the first TIO to counters 0-3 on the IO connector, and //Bind the first TIO to counters 0-3 on the IO connector, and
//bind the second TIO to counters 4-7 //bind the second TIO to counters 4-7
pci->tio_1->Clock_Configuration_Register.writeCntr_Swap(0); pci->tio_1->Clock_Configuration_Register.writeCntr_Swap(0);
pci->tio_2->Clock_Configuration_Register.writeCntr_Swap(1); pci->tio_2->Clock_Configuration_Register.writeCntr_Swap(1);
@ -906,7 +906,7 @@ typedef struct device_private_t
int hware_ctor(const char* device_name, pHWARE* ptr) int hware_ctor(const char* device_name, pHWARE* ptr)
{ {
pHWARE hware = NULL; pHWARE hware = NULL;
hware = (DEVICE_PRIVATE*) malloc(sizeof(DEVICE_PRIVATE)); hware = (DEVICE_PRIVATE*) malloc(sizeof(DEVICE_PRIVATE));
*ptr = hware; *ptr = hware;
memset(hware, 0, sizeof(DEVICE_PRIVATE)); memset(hware, 0, sizeof(DEVICE_PRIVATE));

View File

@ -45,7 +45,7 @@ typedef struct parameter_t
int source; int source;
/** filter 0:none, 1:sync_TB3, 2:5uS, 3:1uS, 4:500nS, 5:100nS, 6:25nS */ /** filter 0:none, 1:sync_TB3, 2:5uS, 3:1uS, 4:500nS, 5:100nS, 6:25nS */
int filter; int filter;
} PARAMETERS, *pPARAMETERS; } PARAMETERS, *pPARAMETERS;
bool param_set(pPARAMETERS pp, const char* name, const char* value); bool param_set(pPARAMETERS pp, const char* name, const char* value);

View File

@ -26,13 +26,13 @@ typedef enum terminal_mode_t
/** unknown or uninitialised */ /** unknown or uninitialised */
term_idle = 0, term_idle = 0,
/** telnet socket */ /** telnet socket */
term_tty, term_tty,
/** web page GET */ /** web page GET */
term_page, term_page,
/** web form POST */ /** web form POST */
term_form, term_form,
/** SOAP request */ /** SOAP request */
term_soap term_soap
} TERM_MODE; } TERM_MODE;
/** /**

View File

@ -33,7 +33,7 @@ char* make_timestamp(const struct timeval* tv)
double time_diff(struct timeval* later, struct timeval* earlier) double time_diff(struct timeval* later, struct timeval* earlier)
{ {
double delta = double delta =
((double) later->tv_sec - (double) earlier->tv_sec) ((double) later->tv_sec - (double) earlier->tv_sec)
+ 0.000001 * ((double) later->tv_usec - (double) earlier->tv_usec); + 0.000001 * ((double) later->tv_usec - (double) earlier->tv_usec);
return delta; return delta;

View File

@ -29,7 +29,7 @@ typedef struct buffer_t
* *
* Makes a string version of the time for printing. Uses * Makes a string version of the time for printing. Uses
* only the time of day to produce a string in the format * only the time of day to produce a string in the format
* HH:MM:SS.UUUUUU at microsecond resolution. * HH:MM:SS.UUUUUU at microsecond resolution.
* *
* Uses a circular set of internal static buffers allowing * Uses a circular set of internal static buffers allowing
* several calls without overwriting - useful for * several calls without overwriting - useful for

View File

@ -38,7 +38,7 @@
$ @tasmad_disk:[mad.lib.sinq]sinq_olb StrMatch debug $ @tasmad_disk:[mad.lib.sinq]sinq_olb StrMatch debug
$ $
$ define/group sinq_olb mad_lib:sinq.olb $ define/group sinq_olb mad_lib:sinq.olb
$ @tasmad_disk:[mad.lib.sinq]sinq_olb StrMatch $ @tasmad_disk:[mad.lib.sinq]sinq_olb StrMatch
** **
** Updates: ** Updates:
** 1A01 12-Nov-1999 DM. Initial version. ** 1A01 12-Nov-1999 DM. Initial version.

View File

@ -1,5 +1,5 @@
/* @file aqp_opalstatus.c /* @file aqp_opalstatus.c
* @brief * @brief
* Implements a simple protocol to GET reactor status using an HTTP/1.1 GET. * Implements a simple protocol to GET reactor status using an HTTP/1.1 GET.
* It sets the UserAgent as SICS to avoid re-directs because we don't handle them. * It sets the UserAgent as SICS to avoid re-directs because we don't handle them.
* If the HTTP status is not OK then it returns the status in the data buffer. * If the HTTP status is not OK then it returns the status in the data buffer.
@ -17,7 +17,7 @@
#endif #endif
#define HOST "Host: neutron.ansto.gov.au\r\n" #define HOST "Host: neutron.ansto.gov.au\r\n"
enum replystates {START, HEADER, CHKHEADEREND, MSG}; enum replystates {START, HEADER, CHKHEADEREND, MSG};
static pAsyncProtocol OPAL_Protocol = NULL; static pAsyncProtocol OPAL_Protocol = NULL;
static int OPAL_Tx(pAsyncProtocol p, pAsyncTxn txn) { static int OPAL_Tx(pAsyncProtocol p, pAsyncTxn txn) {
@ -82,7 +82,7 @@ static int OPAL_Rx(pAsyncProtocol p, pAsyncTxn txn, int ch) {
} }
break; break;
case MSG: case MSG:
if (txn->inp_idx >= txn->inp_len) if (txn->inp_idx >= txn->inp_len)
ret = AQU_POP_CMD; ret = AQU_POP_CMD;
if (nlctr == 0 && ch != '\n') if (nlctr == 0 && ch != '\n')
txn->inp_buf[txn->inp_idx++] = ch; txn->inp_buf[txn->inp_idx++] = ch;

View File

@ -90,7 +90,7 @@
** Routines called: ** Routines called:
** AsynSrv_SendSpecCmnd ** AsynSrv_SendSpecCmnd
** Description: ** Description:
** AsynSrv_SendSpecCmnd is called to send the 4-byte "special" ** AsynSrv_SendSpecCmnd is called to send the 4-byte "special"
** command "-006" to the server to cause it to close its serial ports. ** command "-006" to the server to cause it to close its serial ports.
**--------------------------------------------------------------------- **---------------------------------------------------------------------
** int AsynSrv_Close (&asyn_info, force_flag) ** int AsynSrv_Close (&asyn_info, force_flag)
@ -237,7 +237,7 @@
** Routines called: ** Routines called:
** Same as AsynSrv_ChanClose ** Same as AsynSrv_ChanClose
** Description: ** Description:
** AsynSrv_SendSpecCmnd is called to send the 4-byte "special" ** AsynSrv_SendSpecCmnd is called to send the 4-byte "special"
** command "-004" to the server to cause it to close its serial ports. ** command "-004" to the server to cause it to close its serial ports.
**------------------------------------------------------------------------- **-------------------------------------------------------------------------
** int AsynSrv_GetLenTerm (&asyn_info, &rcve_buff, &rply, *len, &term) ** int AsynSrv_GetLenTerm (&asyn_info, &rcve_buff, &rply, *len, &term)
@ -428,7 +428,7 @@
** that the Terminal Server detected an ** that the Terminal Server detected an
** error. The reply is added to the ** error. The reply is added to the
** routine call stack for debug purposes. ** routine call stack for debug purposes.
** **
** ASYNSRV__BAD_RECV1 \ These are network errors whilst receiving ** ASYNSRV__BAD_RECV1 \ These are network errors whilst receiving
** ASYNSRV__BAD_RECV1_PIPE > the body of the response. They are ** ASYNSRV__BAD_RECV1_PIPE > the body of the response. They are
** ASYNSRV__BAD_RECV1_NET / equivalent to ASYNSRV__BAD_RECV, ** ASYNSRV__BAD_RECV1_NET / equivalent to ASYNSRV__BAD_RECV,
@ -447,7 +447,7 @@
** awaited and read in when it arrives. ** awaited and read in when it arrives.
** **
** For any of the following errors: ** For any of the following errors:
** ASYNSRV__BAD_SEND (Note: ASYNSRV__BAD_SEND_LEN and ** ASYNSRV__BAD_SEND (Note: ASYNSRV__BAD_SEND_LEN and
** ASYNSRV__BAD_SEND_PIPE ASYNSRV__BAD_RECV_LEN and ** ASYNSRV__BAD_SEND_PIPE ASYNSRV__BAD_RECV_LEN and
** ASYNSRV__BAD_SEND_NET ASYNSRV__BAD_REPLY ** ASYNSRV__BAD_SEND_NET ASYNSRV__BAD_REPLY
** ASYNSRV__BAD_SEND_UNKN do not cause a close) ** ASYNSRV__BAD_SEND_UNKN do not cause a close)
@ -553,10 +553,10 @@
** command which was sent. ** command which was sent.
** Note: ** Note:
** For any of the following errors: ** For any of the following errors:
** ASYNSRV__BAD_SEND ** ASYNSRV__BAD_SEND
** ASYNSRV__BAD_SEND_PIPE ** ASYNSRV__BAD_SEND_PIPE
** ASYNSRV__BAD_SEND_NET ** ASYNSRV__BAD_SEND_NET
** ASYNSRV__BAD_SEND_UNKN ** ASYNSRV__BAD_SEND_UNKN
** ASYNSRV__BAD_RECV ** ASYNSRV__BAD_RECV
** ASYNSRV__BAD_RECV_PIPE ** ASYNSRV__BAD_RECV_PIPE
** ASYNSRV__BAD_RECV_NET ** ASYNSRV__BAD_RECV_NET
@ -609,7 +609,7 @@
** Routines called: ** Routines called:
** Same as AsynSrv_ChanClose ** Same as AsynSrv_ChanClose
** Description: ** Description:
** AsynSrv_SendSpecCmnd is called to send the 4-byte "special" ** AsynSrv_SendSpecCmnd is called to send the 4-byte "special"
** command "-005" to the server to cause it to write its trace ** command "-005" to the server to cause it to write its trace
** buffer to disk. ** buffer to disk.
**============================================================================*/ **============================================================================*/
@ -744,7 +744,7 @@
} }
/*------------------------------------------------------ /*------------------------------------------------------
** Now find the table entry for the AsynSrvOpen call. ** Now find the table entry for the AsynSrvOpen call.
*/ */
for (j = 0; j < AsynSrv_n_active; j++) { for (j = 0; j < AsynSrv_n_active; j++) {
if ((AsynSrv_active[j] == asyn_info) && if ((AsynSrv_active[j] == asyn_info) &&
(AsynSrv_active[j]->skt == my_skt)) { (AsynSrv_active[j]->skt == my_skt)) {
@ -871,7 +871,7 @@
case '0': case '0':
my_eot[0] = txt_ptr[0]; my_eot[0] = txt_ptr[0];
break; break;
default: default:
AsynSrv_errcode = ASYNSRV__BAD_PAR; AsynSrv_errcode = ASYNSRV__BAD_PAR;
return False; return False;
} }
@ -941,7 +941,7 @@
case '0': case '0':
AsynSrv_eot[0] = txt_ptr[0]; AsynSrv_eot[0] = txt_ptr[0];
break; break;
default: default:
AsynSrv_errcode = ASYNSRV__BAD_PAR; AsynSrv_errcode = ASYNSRV__BAD_PAR;
return False; return False;
} }
@ -1336,7 +1336,7 @@
** Set short time-out (VMS systems only) ** Set short time-out (VMS systems only)
*/ */
#ifdef __VMS #ifdef __VMS
oto_len = sizeof (old_time_out); /* Save current time-out first */ oto_len = sizeof (old_time_out); /* Save current time-out first */
oto_status = getsockopt (my_skt, IPPROTO_TCP, UCX$C_TCP_PROBE_IDLE, oto_status = getsockopt (my_skt, IPPROTO_TCP, UCX$C_TCP_PROBE_IDLE,
old_time_out, &oto_len); old_time_out, &oto_len);

View File

@ -182,7 +182,7 @@ char *strevent(event_t E) {
* cm = cameram model event stream * cm = cameram model event stream
* cd = command event stream * cd = command event stream
* dr = driver event stream * dr = driver event stream
* *
* The next state is a 3-tuple as above. * The next state is a 3-tuple as above.
* *
* 0 = wildcard for components of current state. * 0 = wildcard for components of current state.

View File

@ -4,7 +4,7 @@
* types used in the state machine. * types used in the state machine.
* *
* \Author Ferdi Franceschini February 2013 * \Author Ferdi Franceschini February 2013
* *
* Copyright: see file Copyright.txt * Copyright: see file Copyright.txt
* *
* Deterministic Finite State machine transducer (Mealy) * Deterministic Finite State machine transducer (Mealy)

View File

@ -171,7 +171,7 @@ static int CAM_Rx(pAsyncProtocol p, pAsyncTxn txn, int ch) {
if (ch == '\r') if (ch == '\r')
ret = 1; ret = 1;
else if (ch == '\n') else if (ch == '\n')
ret = AQU_POP_CMD; ret = AQU_POP_CMD;
else if (txn->inp_idx < txn->inp_len) else if (txn->inp_idx < txn->inp_len)
txn->inp_buf[txn->inp_idx++] = ch; txn->inp_buf[txn->inp_idx++] = ch;
else else
@ -210,7 +210,7 @@ static int CamGetStatus(CounterDriver *cntrData, float *fControl) {
} }
/* \brief run_sm, call the state machine with the given input. /* \brief run_sm, call the state machine with the given input.
* \param self, driver context including current state * \param self, driver context including current state
* \param ev_sym, input event * \param ev_sym, input event
*/ */
static void run_sm(CamObj *self, enum event_codes ev_sym) { static void run_sm(CamObj *self, enum event_codes ev_sym) {
@ -267,7 +267,7 @@ int sendcfg(CamObj *self) {
/* TBD, other fields to be set /* TBD, other fields to be set
if(self->file.updatecfg) { if(self->file.updatecfg) {
sprintf(cfgCmd, "set camera, path=%s,basename=%s,startnumber=%d,imageformat=%s,experimentdetail=%s", sprintf(cfgCmd, "set camera, path=%s,basename=%s,startnumber=%d,imageformat=%s,experimentdetail=%s",
self->file.path, self->file.path,
self->file.basename, self->file.basename,
self->file.startnumber, self->file.startnumber,
self->file.imageformat, self->file.experimentdetail); self->file.imageformat, self->file.experimentdetail);
@ -689,7 +689,7 @@ int camdriv_out(void *me, event_t Eo) {
event_names[Eo.dr], event_signatures[Eo.dr]); event_names[Eo.dr], event_signatures[Eo.dr]);
SICSLogWrite(logmsg, eLog); SICSLogWrite(logmsg, eLog);
} }
} }
return 1; return 1;
} }
static int cb_state_timer(void *ctx, int mode) { static int cb_state_timer(void *ctx, int mode) {

View File

@ -1,15 +1,15 @@
/*--------------------------------------------------------------------------- /*---------------------------------------------------------------------------
D I L U U T I L D I L U U T I L
A few utility functions for talking to Dillution temperature controller A few utility functions for talking to Dillution temperature controller
CCO-510/ AVSI via the SINQ setup: TCP/IP--MAC--RS-232--DILLU. CCO-510/ AVSI via the SINQ setup: TCP/IP--MAC--RS-232--DILLU.
This controller is weird in that way, that is accepts temperatures as This controller is weird in that way, that is accepts temperatures as
resistance values in Ohms. Therefore a translation table is required resistance values in Ohms. Therefore a translation table is required
in order to convert from Kelvin to Ohms. in order to convert from Kelvin to Ohms.
Mark Koennecke, October 1997 Mark Koennecke, October 1997
----------------------------------------------------------------------------*/ ----------------------------------------------------------------------------*/
#ifndef SINQDILLU #ifndef SINQDILLU
#define SINQDILLU #define SINQDILLU
@ -17,7 +17,7 @@
#include "table.h" #include "table.h"
/*----------------------- ERRORCODES-------------------------------------- /*----------------------- ERRORCODES--------------------------------------
Most functions return a negative error code on failure. Error codes Most functions return a negative error code on failure. Error codes
defined are those defined for serialsinq plus a few additional ones: defined are those defined for serialsinq plus a few additional ones:
*/ */
#define DILLU__FILENOTFOUND -710 #define DILLU__FILENOTFOUND -710
@ -32,14 +32,14 @@
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
typedef struct __DILLU { typedef struct __DILLU {
void *pData; void *pData;
pSTable pTranstable; pSTable pTranstable;
int iReadOnly; int iReadOnly;
} DILLU; } DILLU;
typedef struct __DILLU *pDILLU; typedef struct __DILLU *pDILLU;
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
int DILLU_Open(pDILLU *pData,char *pHost, int iPort, int iChannel, int DILLU_Open(pDILLU *pData,char *pHost, int iPort, int iChannel,
int iMode, char *pTransFile); int iMode, char *pTransFile);
/***** creates an DILLU datastructure and opens a connection to the ITCL4 /***** creates an DILLU datastructure and opens a connection to the ITCL4
controller. Input Parameters are: controller. Input Parameters are:
@ -49,44 +49,44 @@
iMode: 1 for ReadOnly, 0 for normal mode iMode: 1 for ReadOnly, 0 for normal mode
pTransFile: name and path of the temperature ohms pTransFile: name and path of the temperature ohms
trnslation file. trnslation file.
Return values are 1 for success, a negative error code on Return values are 1 for success, a negative error code on
failure. failure.
*/ */
void DILLU_Close(pDILLU *pData); void DILLU_Close(pDILLU *pData);
/****** close a connection to an DILLU controller and frees its /****** close a connection to an DILLU controller and frees its
data structure. The only parameter is a pointer to the data data structure. The only parameter is a pointer to the data
structure for this controller. This pointer will be invalid after structure for this controller. This pointer will be invalid after
this call. this call.
*/ */
int DILLU_Config(pDILLU *pData, int iTmo); int DILLU_Config(pDILLU *pData, int iTmo);
/***** configure some aspects of a DILLU temperature controller. /***** configure some aspects of a DILLU temperature controller.
The parameter are: The parameter are:
- a pointer to the data structure for the controller as - a pointer to the data structure for the controller as
returned by Open_DILLU returned by Open_DILLU
- a value for the connection timeout - a value for the connection timeout
The function returns 1 on success, a negative error code on The function returns 1 on success, a negative error code on
failure. failure.
*/ */
int DILLU_Send(pDILLU *pData, char *pCommand, char *pReply, int iLen); int DILLU_Send(pDILLU *pData, char *pCommand, char *pReply, int iLen);
/******* send a the command in pCommand to the DILLU controller. /******* send a the command in pCommand to the DILLU controller.
A possible reply is returned in the buffer pReply. A possible reply is returned in the buffer pReply.
Maximum iLen characters are copied to pReply. Maximum iLen characters are copied to pReply.
The first parameter is a pointer to a DILLU data structure The first parameter is a pointer to a DILLU data structure
as returned by Open_DILLU. as returned by Open_DILLU.
Return values are 1 for success, a negative error code on Return values are 1 for success, a negative error code on
failure. failure.
*/ */
int DILLU_Read(pDILLU *pData, float *fVal); int DILLU_Read(pDILLU *pData, float *fVal);
/****** /******
Reads the current temperature at the controller Reads the current temperature at the controller
Return values are 1 for success, a negative error code on Return values are 1 for success, a negative error code on
failure. failure.
*/ */
@ -101,8 +101,8 @@
failure. failure.
*/ */
void DILLU_Error2Text(pDILLU *pData, int iCode, char *pError, int iLen); void DILLU_Error2Text(pDILLU *pData, int iCode, char *pError, int iLen);
#endif #endif

View File

@ -1,6 +1,6 @@
/*--------------------------------------------------------------------------- /*---------------------------------------------------------------------------
Fix file for David renaming lots of el734 error codes. Fix file for David renaming lots of el734 error codes.
Mark Koennecke, October 1998 Mark Koennecke, October 1998
----------------------------------------------------------------------------*/ ----------------------------------------------------------------------------*/
#ifndef EL734FIX #ifndef EL734FIX
@ -9,7 +9,7 @@
#define EL734__BAD_HOST ASYNSRV__BAD_HOST #define EL734__BAD_HOST ASYNSRV__BAD_HOST
#define EL734__BAD_BIND ASYNSRV__BAD_BIND #define EL734__BAD_BIND ASYNSRV__BAD_BIND
#define EL734__BAD_SENDLEN ASYNSRV__BAD_SEND_LEN #define EL734__BAD_SENDLEN ASYNSRV__BAD_SEND_LEN
#define EL734__BAD_SEND ASYNSRV__BAD_SEND #define EL734__BAD_SEND ASYNSRV__BAD_SEND
#define EL734__BAD_SEND_PIPE ASYNSRV__BAD_SEND_PIPE #define EL734__BAD_SEND_PIPE ASYNSRV__BAD_SEND_PIPE
#define EL734__BAD_SEND_UNKN ASYNSRV__BAD_SEND_UNKN #define EL734__BAD_SEND_UNKN ASYNSRV__BAD_SEND_UNKN

View File

@ -1,6 +1,6 @@
/*--------------------------------------------------------------------------- /*---------------------------------------------------------------------------
Fix file for David renaming lots of el734 error codes. Fix file for David renaming lots of el734 error codes.
Mark Koennecke, October 1998 Mark Koennecke, October 1998
----------------------------------------------------------------------------*/ ----------------------------------------------------------------------------*/
#ifndef EL737FIX #ifndef EL737FIX
@ -9,7 +9,7 @@
#define EL737__BAD_HOST ASYNSRV__BAD_HOST #define EL737__BAD_HOST ASYNSRV__BAD_HOST
#define EL737__BAD_BIND ASYNSRV__BAD_BIND #define EL737__BAD_BIND ASYNSRV__BAD_BIND
#define EL737__BAD_SENDLEN ASYNSRV__BAD_SEND_LEN #define EL737__BAD_SENDLEN ASYNSRV__BAD_SEND_LEN
#define EL737__BAD_SEND ASYNSRV__BAD_SEND #define EL737__BAD_SEND ASYNSRV__BAD_SEND
#define EL737__BAD_SEND_PIPE ASYNSRV__BAD_SEND_PIPE #define EL737__BAD_SEND_PIPE ASYNSRV__BAD_SEND_PIPE
#define EL737__BAD_SEND_UNKN ASYNSRV__BAD_SEND_UNKN #define EL737__BAD_SEND_UNKN ASYNSRV__BAD_SEND_UNKN
@ -25,7 +25,7 @@
#define EL737__BAD_RECV1_PIPE ASYNSRV__BAD_RECV1_PIPE #define EL737__BAD_RECV1_PIPE ASYNSRV__BAD_RECV1_PIPE
#define EL737__BAD_RECV1_NET ASYNSRV__BAD_RECV1_NET #define EL737__BAD_RECV1_NET ASYNSRV__BAD_RECV1_NET
#define EL737__BAD_CONNECT ASYNSRV__BAD_CONNECT #define EL737__BAD_CONNECT ASYNSRV__BAD_CONNECT
#define EL737__BAD_ID -99995 #define EL737__BAD_ID -99995
#define EL737__BAD_SNTX -99991 #define EL737__BAD_SNTX -99991
#define EL737__BAD_REPLY -99992 #define EL737__BAD_REPLY -99992
#define EL737__BAD_ADR -99993 #define EL737__BAD_ADR -99993

View File

@ -49,7 +49,7 @@
case -29: case -29:
strcpy(pBuffer,"EL734__BAD_PAR"); strcpy(pBuffer,"EL734__BAD_PAR");
break; break;
case -17: case -17:
strcpy(pBuffer,"EL734__BAD_RECV"); strcpy(pBuffer,"EL734__BAD_RECV");
break; break;
@ -100,6 +100,6 @@
break; break;
default: default:
strcpy(pBuffer,"Unknown EL734 error"); strcpy(pBuffer,"Unknown EL734 error");
break; break;
} }
} }

View File

@ -1,26 +1,26 @@
/*--------------------------------------------------------------------------- /*---------------------------------------------------------------------------
I T C L 4 U T I L I T C L 4 U T I L
A few utility functions for talking to a Oxford Instruments ITCL-4 A few utility functions for talking to a Oxford Instruments ITCL-4
temperature controller via the SINQ setup: TCP/IP--MAC--RS-232-- temperature controller via the SINQ setup: TCP/IP--MAC--RS-232--
ITC-4. ITC-4.
Mark Koennecke, Juli 1997 Mark Koennecke, Juli 1997
----------------------------------------------------------------------------*/ ----------------------------------------------------------------------------*/
#ifndef SINQITCL4 #ifndef SINQITCL4
#define SINQITCL4 #define SINQITCL4
/*----------------------- ERRORCODES-------------------------------------- /*----------------------- ERRORCODES--------------------------------------
Most functions return a negative error code on failure. Error codes Most functions return a negative error code on failure. Error codes
defined are those defined for serialsinq plus a few additional ones: defined are those defined for serialsinq plus a few additional ones:
*/ */
#define ITC4__BADCOM -501 #define ITC4__BADCOM -501
/* command not recognized */ /* command not recognized */
#define ITC4__BADPAR -502 #define ITC4__BADPAR -502
/* bad parameter to command */ /* bad parameter to command */
#define ITC4__BADMALLOC -503 #define ITC4__BADMALLOC -503
/* error allocating memory */ /* error allocating memory */
#define ITC4__BADREAD -504 #define ITC4__BADREAD -504
/* error analysing command string on Read */ /* error analysing command string on Read */
@ -40,7 +40,7 @@
int iReadOnly; int iReadOnly;
int i503; /* flag for model 503, understanding float*/ int i503; /* flag for model 503, understanding float*/
prs232 controller; prs232 controller;
} ITC4; } ITC4;
typedef struct __ITC4 *pITC4; typedef struct __ITC4 *pITC4;
@ -56,49 +56,49 @@
Return values are 1 for success, a negative error code on Return values are 1 for success, a negative error code on
failure. failure.
*/ */
void ITC4_Close(pITC4 *pData); void ITC4_Close(pITC4 *pData);
/****** close a connection to an ITC4controller and frees its /****** close a connection to an ITC4controller and frees its
data structure. The only parameter is a pointer to the data data structure. The only parameter is a pointer to the data
structure for this controller. This pointer will be invalid after structure for this controller. This pointer will be invalid after
this call. this call.
*/ */
int ITC4_Config(pITC4 *pData, int iTmo, int iRead, int ITC4_Config(pITC4 *pData, int iTmo, int iRead,
int iControl, float fDiv, float fMult); int iControl, float fDiv, float fMult);
/***** configure some aspects of a ITC4temperature controller. /***** configure some aspects of a ITC4temperature controller.
The parameter are: The parameter are:
- a pointer to the data structure for the controller as - a pointer to the data structure for the controller as
returned by OpenITCL4 returned by OpenITCL4
- a value for the connection timeout - a value for the connection timeout
- the temperature sensor to use for reading the - the temperature sensor to use for reading the
temperature. temperature.
- the temperature sensor used by the ITC4controller - the temperature sensor used by the ITC4controller
for regulating the temperature. for regulating the temperature.
- the divisor needed to calculate the real temperature - the divisor needed to calculate the real temperature
from the sensor. from the sensor.
The function returns 1 on success, a negative error code on The function returns 1 on success, a negative error code on
failure. failure.
*/ */
int ITC4_Send(pITC4 *pData, char *pCommand, char *pReply, int iLen); int ITC4_Send(pITC4 *pData, char *pCommand, char *pReply, int iLen);
/******* send a the command in pCommand to the ITC4controller. /******* send a the command in pCommand to the ITC4controller.
A possible reply is returned in the buffer pReply. A possible reply is returned in the buffer pReply.
Maximum iLen characters are copied to pReply. Maximum iLen characters are copied to pReply.
The first parameter is a pointer to a ITC4data structure The first parameter is a pointer to a ITC4data structure
as returned by OpenITCL4. as returned by OpenITCL4.
Return values are 1 for success, a negative error code on Return values are 1 for success, a negative error code on
failure. failure.
*/ */
int ITC4_Read(pITC4 *pData, float *fVal); int ITC4_Read(pITC4 *pData, float *fVal);
/******* reads the current actual temperature of the sensor /******* reads the current actual temperature of the sensor
configured by ConfigITC4for reading. The value is returned configured by ConfigITC4for reading. The value is returned
in fVal. The first parameter is a pointer to a ITCL4 in fVal. The first parameter is a pointer to a ITCL4
data structure as returned by OpenITCL4. data structure as returned by OpenITCL4.
Return values are 1 for success, a negative error code on Return values are 1 for success, a negative error code on
failure. failure.
*/ */
@ -112,14 +112,14 @@
Return values are 1 for success, a negative error code on Return values are 1 for success, a negative error code on
failure. failure.
*/ */
void ITC4_ErrorTxt(pITC4 *pData, int iCode, char *pError, int iLen); void ITC4_ErrorTxt(pITC4 *pData, int iCode, char *pError, int iLen);
/******* translates one of the negative error ITC4error codes /******* translates one of the negative error ITC4error codes
into text. Maximum iLen bytes will be copied to the into text. Maximum iLen bytes will be copied to the
buffer pError; buffer pError;
*/ */
#endif #endif

View File

@ -1,10 +1,10 @@
/*-------------------------------------------------------------------------- /*--------------------------------------------------------------------------
L A K E S H O R E 3 4 0 U T I L L A K E S H O R E 3 4 0 U T I L
A few utility functions for dealing with a LAKESHORE340 temperature controller A few utility functions for dealing with a LAKESHORE340 temperature controller
within the SINQ setup: host -- TCP/IP -- MAC --- RS-232. within the SINQ setup: host -- TCP/IP -- MAC --- RS-232.
Mark Koennecke, Juli 1997 Mark Koennecke, Juli 1997
Mark Lesha, January 2006 (based on ITC4 code) Mark Lesha, January 2006 (based on ITC4 code)
@ -87,7 +87,7 @@
printf("Busy or bad response received!\n"); printf("Busy or bad response received!\n");
return LAKESHORE340__BADREAD; return LAKESHORE340__BADREAD;
} }
int LAKESHORE340_ConfigureAndQueryGen(pLAKESHORE340 self, char *command, int LAKESHORE340_ConfigureAndQueryGen(pLAKESHORE340 self, char *command,
char *configandqueryparameters, char *configonlyparameters,char *diagnosis) char *configandqueryparameters, char *configonlyparameters,char *diagnosis)
/* Issue a command to the Lakeshore 340, if this works, */ /* Issue a command to the Lakeshore 340, if this works, */
@ -138,14 +138,14 @@
printf("Response was good.\n"); printf("Response was good.\n");
return 1; return 1;
} }
int LAKESHORE340_ConfigureAndQuery(pLAKESHORE340 self, char *command, int LAKESHORE340_ConfigureAndQuery(pLAKESHORE340 self, char *command,
char *parameters, char *diagnosis) char *parameters, char *diagnosis)
/* Use for config/query transactions that don't require index parameters in the query. */ /* Use for config/query transactions that don't require index parameters in the query. */
{ {
return LAKESHORE340_ConfigureAndQueryGen(self,command,"",parameters,diagnosis); return LAKESHORE340_ConfigureAndQueryGen(self,command,"",parameters,diagnosis);
} }
int LAKESHORE340_SetControl(pLAKESHORE340 self, int iControl) int LAKESHORE340_SetControl(pLAKESHORE340 self, int iControl)
{ {
/* Attempt to set the sensor used for temperature control. */ /* Attempt to set the sensor used for temperature control. */
@ -162,23 +162,23 @@
else else
return LAKESHORE340__BADPAR; return LAKESHORE340__BADPAR;
} }
int LAKESHORE340_Setup(pLAKESHORE340 self, int iControl) /* Operations common to both Open and Config functions */ int LAKESHORE340_Setup(pLAKESHORE340 self, int iControl) /* Operations common to both Open and Config functions */
{ {
int iRet; int iRet;
char pCommand[20]; char pCommand[20];
char pReply[132]; char pReply[132];
/* MJL enable RS232 debugging mode. */ /* MJL enable RS232 debugging mode. */
//setRS232Debug(self->controller,1); //setRS232Debug(self->controller,1);
//printf("***RS232 debug mode enabled for LAKESHORE340***\n");fflush(stdout); //printf("***RS232 debug mode enabled for LAKESHORE340***\n");fflush(stdout);
/* Setup the comms port (the baudrate etc. are probably just academic since */ /* Setup the comms port (the baudrate etc. are probably just academic since */
/* they must be correct if we have established comms, but the termination */ /* they must be correct if we have established comms, but the termination */
/* character setting is relevant - use just \r. */ /* character setting is relevant - use just \r. */
if ((iRet=LAKESHORE340_ConfigureAndQuery(self,"COMM","3,5,2","bad comms setup"))!=1) if ((iRet=LAKESHORE340_ConfigureAndQuery(self,"COMM","3,5,2","bad comms setup"))!=1)
return iRet; return iRet;
/* Reset the controller to power-on state. */ /* Reset the controller to power-on state. */
sprintf(pCommand,"*RST"); sprintf(pCommand,"*RST");
usleep(100000); // Required to meet Lakeshore340 spec. usleep(100000); // Required to meet Lakeshore340 spec.
@ -197,12 +197,12 @@
/* Basically this just makes sure comms is up. */ /* Basically this just makes sure comms is up. */
if ((iRet=LAKESHORE340_Check_Status(self))!=1) if ((iRet=LAKESHORE340_Check_Status(self))!=1)
return iRet; return iRet;
/* Check the POST status, it should be 0 and not 1. */ /* Check the POST status, it should be 0 and not 1. */
sprintf(pCommand,"*TST?"); sprintf(pCommand,"*TST?");
usleep(100000); // Required to meet Lakeshore340 spec. usleep(100000); // Required to meet Lakeshore340 spec.
if ((iRet=transactRS232(self->controller,pCommand,strlen(pCommand),pReply,79))<=0) if ((iRet=transactRS232(self->controller,pCommand,strlen(pCommand),pReply,79))<=0)
return iRet; return iRet;
if (strcmp(pReply,"0")!=0) if (strcmp(pReply,"0")!=0)
{ {
if (strcmp(pReply,"1")==0) if (strcmp(pReply,"1")==0)
@ -216,7 +216,7 @@
return LAKESHORE340__BADREAD; return LAKESHORE340__BADREAD;
} }
} }
/* Check that the controller is a gen-new-wine Lakeshore 340 */ /* Check that the controller is a gen-new-wine Lakeshore 340 */
/* There's also the *REV command to check the firmware revision, but */ /* There's also the *REV command to check the firmware revision, but */
/* that would be going too far ;) */ /* that would be going too far ;) */
@ -229,7 +229,7 @@
strcpy(self->pAns,pReply); strcpy(self->pAns,pReply);
return LAKESHORE340__NOLAKESHORE340; return LAKESHORE340__NOLAKESHORE340;
} }
/* Switch to remote operation - but leave the keypad unlocked */ /* Switch to remote operation - but leave the keypad unlocked */
if ((iRet=LAKESHORE340_ConfigureAndQuery(self,"MODE","2",""))!=1) if ((iRet=LAKESHORE340_ConfigureAndQuery(self,"MODE","2",""))!=1)
return iRet; return iRet;
@ -243,7 +243,7 @@
usleep(100000); // Required to meet Lakeshore340 spec. usleep(100000); // Required to meet Lakeshore340 spec.
if ((iRet=writeRS232(self->controller, pCommand,strlen(pCommand)))!=1) if ((iRet=writeRS232(self->controller, pCommand,strlen(pCommand)))!=1)
return iRet; return iRet;
/* Set up the front panel display on the Lakeshore 340. */ /* Set up the front panel display on the Lakeshore 340. */
/* Set 2 output fields, which we will use to display the set temp */ /* Set 2 output fields, which we will use to display the set temp */
/* and the actual temp at the controlling sensor selected. */ /* and the actual temp at the controlling sensor selected. */
@ -251,7 +251,7 @@
/* matches exactly and we can use LAKESHORE340_ConfigureAndQuery ;) */ /* matches exactly and we can use LAKESHORE340_ConfigureAndQuery ;) */
if ((iRet=LAKESHORE340_ConfigureAndQuery(self,"DISPLAY","4,060,1",""))!=1) if ((iRet=LAKESHORE340_ConfigureAndQuery(self,"DISPLAY","4,060,1",""))!=1)
return iRet; return iRet;
/* Set up the 4 fields on the front panel display to show both sensor temps. */ /* Set up the 4 fields on the front panel display to show both sensor temps. */
if ((iRet=LAKESHORE340_ConfigureAndQueryGen(self,"DISPFLD","1","A,1",""))!=1) if ((iRet=LAKESHORE340_ConfigureAndQueryGen(self,"DISPFLD","1","A,1",""))!=1)
return iRet; return iRet;
@ -261,7 +261,7 @@
return iRet; return iRet;
if ((iRet=LAKESHORE340_ConfigureAndQueryGen(self,"DISPFLD","4","D,1",""))!=1) if ((iRet=LAKESHORE340_ConfigureAndQueryGen(self,"DISPFLD","4","D,1",""))!=1)
return iRet; return iRet;
/* Set the sensor used for controlling temperature. */ /* Set the sensor used for controlling temperature. */
/* Sets sensor A when iControl==1 and sensor B when iControl==2. */ /* Sets sensor A when iControl==1 and sensor B when iControl==2. */
if ((LAKESHORE340_SetControl(self,iControl))!=1) if ((LAKESHORE340_SetControl(self,iControl))!=1)
@ -275,18 +275,18 @@
/* Don't bother setting the controller's date & time /* Don't bother setting the controller's date & time
(not easy to code and probably wouldn't be useful). */ (not easy to code and probably wouldn't be useful). */
/* Check the LAKESHORE340 operating status one last time */ /* Check the LAKESHORE340 operating status one last time */
if ((iRet=LAKESHORE340_Check_Status(self))!=1) if ((iRet=LAKESHORE340_Check_Status(self))!=1)
return iRet; return iRet;
return 1; /* Success */ return 1; /* Success */
} }
int LAKESHORE340_Open(pLAKESHORE340 *pData, char *pRS232, int iSensor, int iCTRL, int iMode) int LAKESHORE340_Open(pLAKESHORE340 *pData, char *pRS232, int iSensor, int iCTRL, int iMode)
{ {
pLAKESHORE340 self = NULL; pLAKESHORE340 self = NULL;
self = (pLAKESHORE340)malloc(sizeof(LAKESHORE340)); self = (pLAKESHORE340)malloc(sizeof(LAKESHORE340));
if(self == NULL) if(self == NULL)
{ {
@ -296,14 +296,14 @@
self->iControl = iCTRL; self->iControl = iCTRL;
self->iRead = iSensor; self->iRead = iSensor;
self->iReadOnly = iMode; self->iReadOnly = iMode;
/* The LAKESHORE340 doesn't require divisors or multipliers /* The LAKESHORE340 doesn't require divisors or multipliers
and they are always forced to 1.0 */ and they are always forced to 1.0 */
self->fDiv = 1.0; self->fDiv = 1.0;
self->fMult = 1.0; self->fMult = 1.0;
self->controller = NULL; self->controller = NULL;
self->controller = (prs232)FindCommandData(pServ->pSics,pRS232, self->controller = (prs232)FindCommandData(pServ->pSics,pRS232,
"RS232 Controller"); "RS232 Controller");
if(!self->controller){ if(!self->controller){
@ -315,35 +315,35 @@
return LAKESHORE340_Setup(self, self->iControl); return LAKESHORE340_Setup(self, self->iControl);
return 1; return 1;
} }
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
void LAKESHORE340_Close(pLAKESHORE340 *pData) void LAKESHORE340_Close(pLAKESHORE340 *pData)
{ {
pLAKESHORE340 self; pLAKESHORE340 self;
self = *pData; self = *pData;
if (!self) if (!self)
return; // Just in case return; // Just in case
/* Try to turn off the heater as a precaution. */ /* Try to turn off the heater as a precaution. */
LAKESHORE340_ConfigureAndQuery(self,"RANGE","0",""); LAKESHORE340_ConfigureAndQuery(self,"RANGE","0","");
/* switch off remote operation */ /* switch off remote operation */
/* Not sure if this is really necessary but do it just in case */ /* Not sure if this is really necessary but do it just in case */
LAKESHORE340_ConfigureAndQuery(self,"MODE","1",""); LAKESHORE340_ConfigureAndQuery(self,"MODE","1","");
return; return;
} }
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
int LAKESHORE340_Config(pLAKESHORE340 *pData, int iTmo, int iRead, int iControl, int LAKESHORE340_Config(pLAKESHORE340 *pData, int iTmo, int iRead, int iControl,
float fDiv,float fMult) float fDiv,float fMult)
{ {
pLAKESHORE340 self; pLAKESHORE340 self;
self = *pData; self = *pData;
return LAKESHORE340_Setup(self, iControl); return LAKESHORE340_Setup(self, iControl);
} }
/* --------------------------------------------------------------------------*/ /* --------------------------------------------------------------------------*/
int LAKESHORE340_Send(pLAKESHORE340 *pData, char *pCommand, char *pReply, int iLen) int LAKESHORE340_Send(pLAKESHORE340 *pData, char *pCommand, char *pReply, int iLen)
{ {
@ -351,7 +351,7 @@
pLAKESHORE340 self; pLAKESHORE340 self;
self = *pData; self = *pData;
/* Send command direct to the LAKESHORE340 */ /* Send command direct to the LAKESHORE340 */
/* Because the LAKESHORE340 only provides a response for query commands (those /* Because the LAKESHORE340 only provides a response for query commands (those
ending in a '?'), just perform a write for others and not a full transaction. */ ending in a '?'), just perform a write for others and not a full transaction. */
@ -371,7 +371,7 @@
usleep(100000); // Required to meet Lakeshore340 spec. usleep(100000); // Required to meet Lakeshore340 spec.
iRet=transactRS232(self->controller,pCommand,commandlen,pReply,iLen); iRet=transactRS232(self->controller,pCommand,commandlen,pReply,iLen);
} }
/* Check the LAKESHORE340 operating status after issuing the command, if it was successful */ /* Check the LAKESHORE340 operating status after issuing the command, if it was successful */
if (iRet>=1) if (iRet>=1)
iRet=LAKESHORE340_Check_Status(self); iRet=LAKESHORE340_Check_Status(self);
@ -409,19 +409,19 @@
default: default:
return LAKESHORE340__BADPAR; // But shouldn't happen return LAKESHORE340__BADPAR; // But shouldn't happen
} }
usleep(100000); // Required to meet Lakeshore340 spec. usleep(100000); // Required to meet Lakeshore340 spec.
if ((iRet=transactRS232(self->controller,pCommand,strlen(pCommand),pReply,79))<=0) if ((iRet=transactRS232(self->controller,pCommand,strlen(pCommand),pReply,79))<=0)
return iRet; return iRet;
iRet = sscanf(pReply,"%g",&fRead); // KRDG returns free-format exponentiated value iRet = sscanf(pReply,"%g",&fRead); // KRDG returns free-format exponentiated value
if(iRet != 1) // Not a number, probably an error response if(iRet != 1) // Not a number, probably an error response
{ {
return LAKESHORE340__BADREAD; return LAKESHORE340__BADREAD;
} }
*fVal = fRead; *fVal = fRead;
/* Check the LAKESHORE340 operating status after the read, and return */ /* Check the LAKESHORE340 operating status after the read, and return */
iRet=LAKESHORE340_Check_Status(self); iRet=LAKESHORE340_Check_Status(self);
return iRet; return iRet;
@ -441,25 +441,25 @@
{ {
return LAKESHORE340__READONLY; return LAKESHORE340__READONLY;
} }
/* Note we are using control loop #1 only for temperature control. */ /* Note we are using control loop #1 only for temperature control. */
sprintf(pCommand,"SETP 1,%1.1f",fVal); sprintf(pCommand,"SETP 1,%1.1f",fVal);
sprintf(pCommandRead,"SETP? 1"); // To read back and check the set value sprintf(pCommandRead,"SETP? 1"); // To read back and check the set value
/* try three times: send, read, test, if OK return, else resend. */ /* try three times: send, read, test, if OK return, else resend. */
/* MJL doesn't think this is necessary... left over from itc4 */ /* MJL doesn't think this is necessary... left over from itc4 */
for(i = 0; i < 3; i++) for(i = 0; i < 3; i++)
{ {
/* send SETP command, we don't get any response so use writeRS232 */ /* send SETP command, we don't get any response so use writeRS232 */
usleep(100000); // Required to meet Lakeshore340 spec. usleep(100000); // Required to meet Lakeshore340 spec.
if ((iRet=writeRS232(self->controller,pCommand,strlen(pCommand)))!=1) if ((iRet=writeRS232(self->controller,pCommand,strlen(pCommand)))!=1)
return iRet; return iRet;
/* read the set value again using the SETP? command */ /* read the set value again using the SETP? command */
usleep(100000); // Required to meet Lakeshore340 spec. usleep(100000); // Required to meet Lakeshore340 spec.
if ((iRet=transactRS232(self->controller,pCommandRead,strlen(pCommandRead),pReply,131))<=0) if ((iRet=transactRS232(self->controller,pCommandRead,strlen(pCommandRead),pReply,131))<=0)
return iRet; return iRet;
printf("SETP: Response %d characters: '%s'\n",iRet,pReply); printf("SETP: Response %d characters: '%s'\n",iRet,pReply);
if(pReply[0] == '-'&&strlen(pReply)>7) if(pReply[0] == '-'&&strlen(pReply)>7)
{ {
strcpy(self->pAns,pReply); strcpy(self->pAns,pReply);
return LAKESHORE340__BADCOM; return LAKESHORE340__BADCOM;
@ -500,7 +500,7 @@
pLAKESHORE340 self; pLAKESHORE340 self;
self = *pData; self = *pData;
switch(iCode) switch(iCode)
{ {
case LAKESHORE340__BADCOM: case LAKESHORE340__BADCOM:
@ -530,6 +530,6 @@
break; break;
default: default:
getRS232Error(iCode, pError,iLen); getRS232Error(iCode, pError,iLen);
break; break;
} }
} }

View File

@ -1,27 +1,27 @@
/*--------------------------------------------------------------------------- /*---------------------------------------------------------------------------
L A K E S H O R E 3 4 0 U T I L L A K E S H O R E 3 4 0 U T I L
A few utility functions for talking to a Lakeshore 340 A few utility functions for talking to a Lakeshore 340
temperature controller via the SINQ setup: TCP/IP--MAC--RS-232-- temperature controller via the SINQ setup: TCP/IP--MAC--RS-232--
LAKESHORE340. LAKESHORE340.
Mark Koennecke, Juli 1997 Mark Koennecke, Juli 1997
Mark Lesha, January 2006 (based on ITC4 code) Mark Lesha, January 2006 (based on ITC4 code)
----------------------------------------------------------------------------*/ ----------------------------------------------------------------------------*/
#ifndef SINQLAKESHORE340 #ifndef SINQLAKESHORE340
#define SINQLAKESHORE340 #define SINQLAKESHORE340
/*----------------------- ERRORCODES-------------------------------------- /*----------------------- ERRORCODES--------------------------------------
Most functions return a negative error code on failure. Error codes Most functions return a negative error code on failure. Error codes
defined are those defined for serialsinq plus a few additional ones: defined are those defined for serialsinq plus a few additional ones:
*/ */
#define LAKESHORE340__BADCOM -501 #define LAKESHORE340__BADCOM -501
/* command not recognized */ /* command not recognized */
#define LAKESHORE340__BADPAR -502 #define LAKESHORE340__BADPAR -502
/* bad parameter to command */ /* bad parameter to command */
#define LAKESHORE340__BADMALLOC -503 #define LAKESHORE340__BADMALLOC -503
/* error allocating memory */ /* error allocating memory */
#define LAKESHORE340__BADREAD -504 #define LAKESHORE340__BADREAD -504
/* error analysing command string on Read */ /* error analysing command string on Read */
@ -45,7 +45,7 @@
float fMult; float fMult;
int iReadOnly; int iReadOnly;
prs232 controller; prs232 controller;
} LAKESHORE340; } LAKESHORE340;
typedef struct __LAKESHORE340 *pLAKESHORE340; typedef struct __LAKESHORE340 *pLAKESHORE340;
@ -61,49 +61,49 @@
Return values are 1 for success, a negative error code on Return values are 1 for success, a negative error code on
failure. failure.
*/ */
void LAKESHORE340_Close(pLAKESHORE340 *pData); void LAKESHORE340_Close(pLAKESHORE340 *pData);
/****** close a connection to an LAKESHORE340controller and frees its /****** close a connection to an LAKESHORE340controller and frees its
data structure. The only parameter is a pointer to the data data structure. The only parameter is a pointer to the data
structure for this controller. This pointer will be invalid after structure for this controller. This pointer will be invalid after
this call. this call.
*/ */
int LAKESHORE340_Config(pLAKESHORE340 *pData, int iTmo, int iRead, int LAKESHORE340_Config(pLAKESHORE340 *pData, int iTmo, int iRead,
int iControl, float fDiv, float fMult); int iControl, float fDiv, float fMult);
/***** configure some aspects of a LAKESHORE340temperature controller. /***** configure some aspects of a LAKESHORE340temperature controller.
The parameter are: The parameter are:
- a pointer to the data structure for the controller as - a pointer to the data structure for the controller as
returned by LAKESHORE340_Open returned by LAKESHORE340_Open
- a value for the connection timeout - a value for the connection timeout
- the temperature sensor to use for reading the - the temperature sensor to use for reading the
temperature. temperature.
- the temperature sensor used by the LAKESHORE340controller - the temperature sensor used by the LAKESHORE340controller
for regulating the temperature. for regulating the temperature.
- the divisor needed to calculate the real temperature - the divisor needed to calculate the real temperature
from the sensor. from the sensor.
The function returns 1 on success, a negative error code on The function returns 1 on success, a negative error code on
failure. failure.
*/ */
int LAKESHORE340_Send(pLAKESHORE340 *pData, char *pCommand, char *pReply, int iLen); int LAKESHORE340_Send(pLAKESHORE340 *pData, char *pCommand, char *pReply, int iLen);
/******* send a the command in pCommand to the LAKESHORE340controller. /******* send a the command in pCommand to the LAKESHORE340controller.
A possible reply is returned in the buffer pReply. A possible reply is returned in the buffer pReply.
Maximum iLen characters are copied to pReply. Maximum iLen characters are copied to pReply.
The first parameter is a pointer to a LAKESHORE340data structure The first parameter is a pointer to a LAKESHORE340data structure
as returned by LAKESHORE340_Open. as returned by LAKESHORE340_Open.
Return values are 1 for success, a negative error code on Return values are 1 for success, a negative error code on
failure. failure.
*/ */
int LAKESHORE340_Read(pLAKESHORE340 *pData, float *fVal); int LAKESHORE340_Read(pLAKESHORE340 *pData, float *fVal);
/******* reads the current actual temperature of the sensor /******* reads the current actual temperature of the sensor
configured by ConfigLAKESHORE340for reading. The value is returned configured by ConfigLAKESHORE340for reading. The value is returned
in fVal. The first parameter is a pointer to a LAKESHORE340 in fVal. The first parameter is a pointer to a LAKESHORE340
data structure as returned by LAKESHORE340_Open. data structure as returned by LAKESHORE340_Open.
Return values are 1 for success, a negative error code on Return values are 1 for success, a negative error code on
failure. failure.
*/ */
@ -117,14 +117,14 @@
Return values are 1 for success, a negative error code on Return values are 1 for success, a negative error code on
failure.pEVInterface failure.pEVInterface
*/ */
void LAKESHORE340_ErrorTxt(pLAKESHORE340 *pData, int iCode, char *pError, int iLen); void LAKESHORE340_ErrorTxt(pLAKESHORE340 *pData, int iCode, char *pError, int iLen);
/******* translates one of the negative error LAKESHORE340error codes /******* translates one of the negative error LAKESHORE340error codes
into text. Maximum iLen bytes will be copied to the into text. Maximum iLen bytes will be copied to the
buffer pError; buffer pError;
*/ */
#endif #endif

View File

@ -1,10 +1,10 @@
/*-------------------------------------------------------------------------- /*--------------------------------------------------------------------------
L H 4 5 U T I L L H 4 5 U T I L
A few utility functions for dealing with a LH45 temperature controller A few utility functions for dealing with a LH45 temperature controller
within the SINQ setup: host -- TCP/IP -- MAC --- RS-232. within the SINQ setup: host -- TCP/IP -- MAC --- RS-232.
Mark Koennecke, Juli 1997 Mark Koennecke, Juli 1997
Mark Lesha, January 2006 (based on ITC4 code) Mark Lesha, January 2006 (based on ITC4 code)
@ -64,7 +64,7 @@ char *ReplyStart(char *pReply)
int iRet; int iRet;
char pCommand[20]; char pCommand[20];
char pReply[132],*pReplyStart; char pReply[132],*pReplyStart;
/* Check the status. It should read '03 REMOTE START' or possibly '03 REMOTE START,DEGASING'. */ /* Check the status. It should read '03 REMOTE START' or possibly '03 REMOTE START,DEGASING'. */
/* If there is any LH45 overload or other fault condition it will be detected here. */ /* If there is any LH45 overload or other fault condition it will be detected here. */
// printf("Checking LH45 status...");fflush(stdout); // printf("Checking LH45 status...");fflush(stdout);
@ -75,17 +75,17 @@ char *ReplyStart(char *pReply)
pReplyStart=ReplyStart(pReply); pReplyStart=ReplyStart(pReply);
usleep(500000); usleep(500000);
if(iRet <= 0) if(iRet <= 0)
{ {
//transactRS232(self->co/home/mrt/workspacentroller,"\nDEBUG: RS232 transaction bad.\n",28,pReply,79); //transactRS232(self->co/home/mrt/workspacentroller,"\nDEBUG: RS232 transaction bad.\n",28,pReply,79);
return iRet; return iRet;
} }
printf("Status is: '%s'\n",pReplyStart);fflush(stdout); printf("Status is: '%s'\n",pReplyStart);fflush(stdout);
int i; int i;
for(i=0;i<strlen(pReply);i++) for(i=0;i<strlen(pReply);i++)
printf("0x%02x ",((unsigned char *)pReply)[i]); printf("0x%02x ",((unsigned char *)pReply)[i]);
printf("\n"); printf("\n");
if (strncmp(pReplyStart,"03 REMOTE START",15)!=0) if (strncmp(pReplyStart,"03 REMOTE START",15)!=0)
{ {
//transactRS232(self->controller,"\nDEBUG: RS232 response bad\n",27,pReply,79); //transactRS232(self->controller,"\nDEBUG: RS232 response bad\n",27,pReply,79);
@ -96,17 +96,17 @@ char *ReplyStart(char *pReply)
//transactRS232(self->controller,"\nDEBUG: Status reply is good!\n",30,pReply,79); //transactRS232(self->controller,"\nDEBUG: Status reply is good!\n",30,pReply,79);
return 1; // 1 = no fault return 1; // 1 = no fault
} }
int LH45_Setup(pLH45 self, int iControl) /* Operations common to both Open and Config functions */ int LH45_Setup(pLH45 self, int iControl) /* Operations common to both Open and Config functions */
{ {
int iRet; int iRet;
char pCommand[20]; char pCommand[20];
//char pReply[132]; //char pReply[132];
/* MJL enable RS232 debugging mode. */ /* MJL enable RS232 debugging mode. */
//setRS232Debug(self->controller,1); //setRS232Debug(self->controller,1);
//printf("***RS232 debug mode enabled for LH45***\n");fflush(stdout); //printf("***RS232 debug mode enabled for LH45***\n");fflush(stdout);
/* switch to remote operation - although don't want it to initialise */ /* switch to remote operation - although don't want it to initialise */
/* NOTE: The Julabo does not provide any response for 'out' commands, /* NOTE: The Julabo does not provide any response for 'out' commands,
so we just use writeRS232 not transactRS232 for these */ so we just use writeRS232 not transactRS232 for these */
@ -116,19 +116,19 @@ char *ReplyStart(char *pReply)
usleep(500000); usleep(500000);
printf("OUT_MODE_05 1 is completed \n");fflush(stdout); printf("OUT_MODE_05 1 is completed \n");fflush(stdout);
if(iRet != 1) if(iRet != 1)
{ {
return iRet; return iRet;
} }
/* if(pReply[0] == '-') // Probably an error response /* if(pReply[0] == '-') // Probably an error response
{ {
strcpy(self->pAns,pReply); strcpy(self->pAns,pReply);
return LH45__BADCOM; return LH45__BADCOM;
} */ } */
/* Check the LH45 operating status */ /* Check the LH45 operating status */
if ((iRet=LH45_Check_Status(self))!=1) if ((iRet=LH45_Check_Status(self))!=1)
return iRet; return iRet;
/* Set heater sensor */ /* Set heater sensor */
/* For the LH45 there is a choice of internal or external sensor control, /* For the LH45 there is a choice of internal or external sensor control,
set internal when iControl==1 and external when iControl==2 */ set internal when iControl==1 and external when iControl==2 */
@ -139,32 +139,32 @@ char *ReplyStart(char *pReply)
if(iRet != 1) if(iRet != 1)
{ {
return LH45__BADCOM; return LH45__BADCOM;
} }
/* else if(pReply[0] == '-') // Probably an error response /* else if(pReply[0] == '-') // Probably an error response
{ {
strcpy(self->pAns,pReply); strcpy(self->pAns,pReply);
return LH45__BADCOM; return LH45__BADCOM;
} */ } */
self->iControl=iControl; // Store control sensor setting since it was assigned to the LH45 successfully self->iControl=iControl; // Store control sensor setting since it was assigned to the LH45 successfully
/* reset timeout - currently not being used */ /* reset timeout - currently not being used */
/* iRet = SerialConfig(&self->pData, 10); /* iRet = SerialConfig(&self->pData, 10);
if(iRet != 1) if(iRet != 1)
{ {
return iRet; return iRet;
} */ } */
/* Check the LH45 operating status one last time */ /* Check the LH45 operating status one last time */
if ((iRet=LH45_Check_Status(self))!=1) if ((iRet=LH45_Check_Status(self))!=1)
return iRet; return iRet;
return 1; /* Success */ return 1; /* Success */
} }
int LH45_Open(pLH45 *pData, char *pRS232, int iSensor, int iCTRL, int iMode) int LH45_Open(pLH45 *pData, char *pRS232, int iSensor, int iCTRL, int iMode)
{ {
pLH45 self = NULL; pLH45 self = NULL;
self = (pLH45)malloc(sizeof(LH45)); self = (pLH45)malloc(sizeof(LH45));
if(self == NULL) if(self == NULL)
{ {
@ -174,14 +174,14 @@ char *ReplyStart(char *pReply)
self->iControl = iCTRL; self->iControl = iCTRL;
self->iRead = iSensor; self->iRead = iSensor;
self->iReadOnly = iMode; self->iReadOnly = iMode;
/* The LH45 doesn't require divisors or multipliers /* The LH45 doesn't require divisors or multipliers
and they are always forced to 1.0 */ and they are always forced to 1.0 */
self->fDiv = 1.0; self->fDiv = 1.0;
self->fMult = 1.0; self->fMult = 1.0;
self->controller = NULL; self->controller = NULL;
self->controller = (prs232)FindCommandData(pServ->pSics,pRS232, self->controller = (prs232)FindCommandData(pServ->pSics,pRS232,
"RS232 Controller"); "RS232 Controller");
if(!self->controller){ if(!self->controller){
@ -192,7 +192,7 @@ char *ReplyStart(char *pReply)
if(!self->iReadOnly) if(!self->iReadOnly)
return LH45_Setup(self, self->iControl); return LH45_Setup(self, self->iControl);
return 1; return 1;
} }
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
void LH45_Close(pLH45 *pData) void LH45_Close(pLH45 *pData)
{ {
@ -204,7 +204,7 @@ char *ReplyStart(char *pReply)
self = *pData; self = *pData;
if (!self) if (!self)
return; // Just in case return; // Just in case
/* switch off remote operation */ /* switch off remote operation */
/* Not sure if this is really necessary but do it just in case */ /* Not sure if this is really necessary but do it just in case */
sprintf(pCommand,"OUT_MODE_05 0"); sprintf(pCommand,"OUT_MODE_05 0");
@ -213,19 +213,19 @@ char *ReplyStart(char *pReply)
/* Don't bother checking the status but record any error reply */ /* Don't bother checking the status but record any error reply */
/* if(pReply[0] == '-') // Probably an error response /* if(pReply[0] == '-') // Probably an error response
strcpy(self->pAns,pReply); */ strcpy(self->pAns,pReply); */
return; return;
} }
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
int LH45_Config(pLH45 *pData, int iTmo, int iRead, int iControl, int LH45_Config(pLH45 *pData, int iTmo, int iRead, int iControl,
float fDiv,float fMult) float fDiv,float fMult)
{ {
pLH45 self; pLH45 self;
self = *pData; self = *pData;
return LH45_Setup(self, iControl); return LH45_Setup(self, iControl);
} }
/* --------------------------------------------------------------------------*/ /* --------------------------------------------------------------------------*/
int LH45_Send(pLH45 *pData, char *pCommand, char *pReply, int iLen) int LH45_Send(pLH45 *pData, char *pCommand, char *pReply, int iLen)
{ {
@ -240,7 +240,7 @@ char *ReplyStart(char *pReply)
{ {
strcat(pCommand,"\r"); strcat(pCommand,"\r");
} */ } */
/* Send command direct to the LH45 */ /* Send command direct to the LH45 */
/* Because the Julabo LH45 only provides a response for the 'version', 'status' /* Because the Julabo LH45 only provides a response for the 'version', 'status'
and 'in' commands and not for the 'out' commands, just perform a write and 'in' commands and not for the 'out' commands, just perform a write
@ -262,8 +262,8 @@ char *ReplyStart(char *pReply)
} while(*pReplyStart++); } while(*pReplyStart++);
} }
if(iRet <= 0) if(iRet <= 0)
return iRet; return iRet;
/* Check the LH45 operating status after issuing the command, and return */ /* Check the LH45 operating status after issuing the command, and return */
iRet=LH45_Check_Status(self); iRet=LH45_Check_Status(self);
return iRet; return iRet;
@ -294,17 +294,17 @@ char *ReplyStart(char *pReply)
default: default:
return LH45__BADPAR; // But shouldn't happen return LH45__BADPAR; // But shouldn't happen
} }
iRet = transactRS232(self->controller, pCommand,strlen(pCommand), iRet = transactRS232(self->controller, pCommand,strlen(pCommand),
pReply,79); pReply,79);
pReplyStart=ReplyStart(pReply); pReplyStart=ReplyStart(pReply);
usleep(500000); usleep(500000);
if(iRet <= 0) if(iRet <= 0)
{ {
return iRet; return iRet;
} }
//sprintf(self->pAns,"The read value is '%s'\n and the command is: '%s' \n",pReply,pCommand); //sprintf(self->pAns,"The read value is '%s'\n and the command is: '%s' \n",pReply,pCommand);
//return LH45__FAULT; //return LH45__FAULT;
if(*pReplyStart == '-' && strlen(pReplyStart)>7) // Not a number (-XXX.X\r), probably an error response if(*pReplyStart == '-' && strlen(pReplyStart)>7) // Not a number (-XXX.X\r), probably an error response
@ -312,11 +312,11 @@ char *ReplyStart(char *pReply)
strcpy(self->pAns,pReplyStart); strcpy(self->pAns,pReplyStart);
return LH45__BADCOM; return LH45__BADCOM;
} }
iRet = sscanf(pReplyStart,"%f",&fRead); iRet = sscanf(pReplyStart,"%f",&fRead);
if (iRet == 1) if (iRet == 1)
*fVal = fRead; *fVal = fRead;
/* Check the LH45 operating status after the read, and return */ /* Check the LH45 operating status after the read, and return */
iRet=LH45_Check_Status(self); iRet=LH45_Check_Status(self);
return iRet; return iRet;
@ -336,27 +336,27 @@ char *ReplyStart(char *pReply)
{ {
return LH45__READONLY; return LH45__READONLY;
} }
sprintf(pCommand,"OUT_SP_00 %1.1f",fVal); sprintf(pCommand,"OUT_SP_00 %1.1f",fVal);
sprintf(pCommandRead,"IN_SP_00"); // To read back and check the set value sprintf(pCommandRead,"IN_SP_00"); // To read back and check the set value
/* try three times: send, read, test, if OK return, else resend. */ /* try three times: send, read, test, if OK return, else resend. */
for(i = 0; i < 3; i++) for(i = 0; i < 3; i++)
{ {
/* send command, since it's an 'out' we don't get any response, so use writeRS232 */ /* send command, since it's an 'out' we don't get any response, so use writeRS232 */
iRet = writeRS232(self->controller,pCommand,strlen(pCommand)); iRet = writeRS232(self->controller,pCommand,strlen(pCommand));
usleep(500000); usleep(500000);
//writeRS232(self->controller,pReply,strlen(pReply)); // MJL DEBUG //writeRS232(self->controller,pReply,strlen(pReply)); // MJL DEBUG
if(iRet != 1) if(iRet != 1)
{ {
return iRet; return iRet;
} }
/* if(pReply[0] == '-') // Probably an error response /* if(pReply[0] == '-') // Probably an error response
{ {
strcpy(self->pAns,pReply); strcpy(self->pAns,pReply);
return LH45__BADCOM; return LH45__BADCOM;
} */ } */
/* read the set value again using the 'in' command */ /* read the set value again using the 'in' command */
iRet = transactRS232(self->controller,pCommandRead,strlen(pCommandRead),pReply,131); iRet = transactRS232(self->controller,pCommandRead,strlen(pCommandRead),pReply,131);
pReplyStart=ReplyStart(pReply); pReplyStart=ReplyStart(pReply);
@ -365,7 +365,7 @@ char *ReplyStart(char *pReply)
if(iRet <= 0) if(iRet <= 0)
{ {
return iRet; return iRet;
} }
if(*pReplyStart == '-'&&strlen(pReplyStart)>7) // Not a number (-XXX.X\r), probably an error response if(*pReplyStart == '-'&&strlen(pReplyStart)>7) // Not a number (-XXX.X\r), probably an error response
{ {
strcpy(self->pAns,pReplyStart); strcpy(self->pAns,pReplyStart);
@ -405,7 +405,7 @@ char *ReplyStart(char *pReply)
pLH45 self; pLH45 self;
self = *pData; self = *pData;
switch(iCode) switch(iCode)
{ {
case LH45__BADCOM: case LH45__BADCOM:
@ -431,6 +431,6 @@ char *ReplyStart(char *pReply)
break; break;
default: default:
getRS232Error(iCode, pError,iLen); getRS232Error(iCode, pError,iLen);
break; break;
} }
} }

View File

@ -1,27 +1,27 @@
/*--------------------------------------------------------------------------- /*---------------------------------------------------------------------------
L H 4 5 U T I L L H 4 5 U T I L
A few utility functions for talking to a Julabo LH45 A few utility functions for talking to a Julabo LH45
temperature controller via the SINQ setup: TCP/IP--MAC--RS-232-- temperature controller via the SINQ setup: TCP/IP--MAC--RS-232--
LH45. LH45.
Mark Koennecke, Juli 1997 Mark Koennecke, Juli 1997
Mark Lesha, January 2006 (based on ITC4 code) Mark Lesha, January 2006 (based on ITC4 code)
----------------------------------------------------------------------------*/ ----------------------------------------------------------------------------*/
#ifndef SINQLH45 #ifndef SINQLH45
#define SINQLH45 #define SINQLH45
/*----------------------- ERRORCODES-------------------------------------- /*----------------------- ERRORCODES--------------------------------------
Most functions return a negative error code on failure. Error codes Most functions return a negative error code on failure. Error codes
defined are those defined for serialsinq plus a few additional ones: defined are those defined for serialsinq plus a few additional ones:
*/ */
#define LH45__BADCOM -501 #define LH45__BADCOM -501
/* command not recognized */ /* command not recognized */
#define LH45__BADPAR -502 #define LH45__BADPAR -502
/* bad parameter to command */ /* bad parameter to command */
#define LH45__BADMALLOC -503 #define LH45__BADMALLOC -503
/* error allocating memory */ /* error allocating memory */
#define LH45__BADREAD -504 #define LH45__BADREAD -504
/* error analysing command string on Read */ /* error analysing command string on Read */
@ -45,7 +45,7 @@
float fMult; float fMult;
int iReadOnly; int iReadOnly;
prs232 controller; prs232 controller;
} LH45; } LH45;
typedef struct __LH45 *pLH45; typedef struct __LH45 *pLH45;
@ -61,49 +61,49 @@
Return values are 1 for success, a negative error code on Return values are 1 for success, a negative error code on
failure. failure.
*/ */
void LH45_Close(pLH45 *pData); void LH45_Close(pLH45 *pData);
/****** close a connection to an LH45controller and frees its /****** close a connection to an LH45controller and frees its
data structure. The only parameter is a pointer to the data data structure. The only parameter is a pointer to the data
structure for this controller. This pointer will be invalid after structure for this controller. This pointer will be invalid after
this call. this call.
*/ */
int LH45_Config(pLH45 *pData, int iTmo, int iRead, int LH45_Config(pLH45 *pData, int iTmo, int iRead,
int iControl, float fDiv, float fMult); int iControl, float fDiv, float fMult);
/***** configure some aspects of a LH45temperature controller. /***** configure some aspects of a LH45temperature controller.
The parameter are: The parameter are:
- a pointer to the data structure for the controller as - a pointer to the data structure for the controller as
returned by LH45_Open returned by LH45_Open
- a value for the connection timeout - a value for the connection timeout
- the temperature sensor to use for reading the - the temperature sensor to use for reading the
temperature. temperature.
- the temperature sensor used by the LH45controller - the temperature sensor used by the LH45controller
for regulating the temperature. for regulating the temperature.
- the divisor needed to calculate the real temperature - the divisor needed to calculate the real temperature
from the sensor. from the sensor.
The function returns 1 on success, a negative error code on The function returns 1 on success, a negative error code on
failure. failure.
*/ */
int LH45_Send(pLH45 *pData, char *pCommand, char *pReply, int iLen); int LH45_Send(pLH45 *pData, char *pCommand, char *pReply, int iLen);
/******* send a the command in pCommand to the LH45controller. /******* send a the command in pCommand to the LH45controller.
A possible reply is returned in the buffer pReply. A possible reply is returned in the buffer pReply.
Maximum iLen characters are copied to pReply. Maximum iLen characters are copied to pReply.
The first parameter is a pointer to a LH45data structure The first parameter is a pointer to a LH45data structure
as returned by LH45_Open. as returned by LH45_Open.
Return values are 1 for success, a negative error code on Return values are 1 for success, a negative error code on
failure. failure.
*/ */
int LH45_Read(pLH45 *pData, float *fVal); int LH45_Read(pLH45 *pData, float *fVal);
/******* reads the current actual temperature of the sensor /******* reads the current actual temperature of the sensor
configured by ConfigLH45for reading. The value is returned configured by ConfigLH45for reading. The value is returned
in fVal. The first parameter is a pointer to a LH45 in fVal. The first parameter is a pointer to a LH45
data structure as returned by LH45_Open. data structure as returned by LH45_Open.
Return values are 1 for success, a negative error code on Return values are 1 for success, a negative error code on
failure. failure.
*/ */
@ -117,14 +117,14 @@
Return values are 1 for success, a negative error code on Return values are 1 for success, a negative error code on
failure. failure.
*/ */
void LH45_ErrorTxt(pLH45 *pData, int iCode, char *pError, int iLen); void LH45_ErrorTxt(pLH45 *pData, int iCode, char *pError, int iLen);
/******* translates one of the negative error LH45error codes /******* translates one of the negative error LH45error codes
into text. Maximum iLen bytes will be copied to the into text. Maximum iLen bytes will be copied to the
buffer pError; buffer pError;
*/ */
#endif #endif

View File

@ -235,7 +235,7 @@
/* ========= /* =========
*/ */
int len, i; int len, i;
for (i = 0; chr[i] != NIL; i++) chr[i] &= 0x7F; for (i = 0; chr[i] != NIL; i++) chr[i] &= 0x7F;
len = strlen (chr); len = strlen (chr);

View File

@ -5,16 +5,16 @@ Paul Barron, January 2008
RTU Modbus functions designed for use with the WEST4100 Temperature Controller. RTU Modbus functions designed for use with the WEST4100 Temperature Controller.
If another modbus device is required at ANSTO sections of this code will need If another modbus device is required at ANSTO sections of this code will need
to be modified. to be modified.
MBAP: Modbus Application Protocol Header MBAP: Modbus Application Protocol Header
PDU: Protocol Data Unit PDU: Protocol Data Unit
Modbus TCP Packet Format Modbus TCP Packet Format
| MBAP | PDU | | MBAP | PDU |
|Transact Identifier|Protocol Identifier|Length Field|Unit ID|Funct Code|Data| |Transact Identifier|Protocol Identifier|Length Field|Unit ID|Funct Code|Data|
| 2 Bytes | 2 Bytes | 2 Bytes | 1 Byte| 1 Byte | n | | 2 Bytes | 2 Bytes | 2 Bytes | 1 Byte| 1 Byte | n |
Paul Barron, January 2008 Paul Barron, January 2008
----------------------------------------------------------------------------*/ ----------------------------------------------------------------------------*/
@ -30,28 +30,28 @@ Paul Barron, January 2008
int ModbusTCPException(unsigned char *response); int ModbusTCPException(unsigned char *response);
int MsgGenModbusTCP(unsigned char *ModbusMsg, int ModbusMsgLength, unsigned char *TcpPacket, int MsgGenModbusTCP(unsigned char *ModbusMsg, int ModbusMsgLength, unsigned char *TcpPacket,
int *TcpPacketLength) int *TcpPacketLength)
{ {
unsigned char MBAPbyte1 = 1, MBAPbyte2 = 1; unsigned char MBAPbyte1 = 1, MBAPbyte2 = 1;
unsigned char lengthByte1, lengthByte2; unsigned char lengthByte1, lengthByte2;
int index; int index;
// Check if Device Address is Valid. This is based on RS485 having up to // Check if Device Address is Valid. This is based on RS485 having up to
// 32 devices, since we currently only have one device this won't be a problem. // 32 devices, since we currently only have one device this won't be a problem.
if ((ModbusMsg[0] > 32) || (ModbusMsg[0] < 1)) if ((ModbusMsg[0] > 32) || (ModbusMsg[0] < 1))
{ {
printf("Error: Modbus Address out of Range: %X\n",ModbusMsg[0]); printf("Error: Modbus Address out of Range: %X\n",ModbusMsg[0]);
return MODBUSTCP_BadDataAddress; return MODBUSTCP_BadDataAddress;
} }
// Check if Function code is Valid // Check if Function code is Valid
if ((ModbusMsg[1] > 16) || (ModbusMsg[1] < 1)) if ((ModbusMsg[1] > 16) || (ModbusMsg[1] < 1))
{ {
printf("Error: Modbus Function Code Invalid: %X\n",ModbusMsg[1]); printf("Error: Modbus Function Code Invalid: %X\n",ModbusMsg[1]);
return MODBUSTCP_BadFunction; return MODBUSTCP_BadFunction;
} }
// Calculate Legth Field // Calculate Legth Field
// Length should never be greater than 255 but just in case. // Length should never be greater than 255 but just in case.
if ((ModbusMsgLength)>255){ if ((ModbusMsgLength)>255){
@ -60,17 +60,17 @@ int MsgGenModbusTCP(unsigned char *ModbusMsg, int ModbusMsgLength, unsigned char
} }
else{ else{
lengthByte1=0; lengthByte1=0;
lengthByte2=ModbusMsgLength; lengthByte2=ModbusMsgLength;
} }
sprintf((char *)TcpPacket,"%c%c%c%c%c%c",MBAPbyte1,MBAPbyte2,0,0,lengthByte1,lengthByte2); sprintf((char *)TcpPacket,"%c%c%c%c%c%c",MBAPbyte1,MBAPbyte2,0,0,lengthByte1,lengthByte2);
for(index=0;index<=ModbusMsgLength;index++)sprintf((char *)&TcpPacket[index+6],"%c",ModbusMsg[index]); for(index=0;index<=ModbusMsgLength;index++)sprintf((char *)&TcpPacket[index+6],"%c",ModbusMsg[index]);
*TcpPacketLength=ModbusMsgLength+6; *TcpPacketLength=ModbusMsgLength+6;
return 1; return 1;
} }
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
@ -78,49 +78,49 @@ int transactModbusTCP(prs232 self, unsigned char *query, int queryLength, unsign
{ {
unsigned char TCPquery[40]; unsigned char TCPquery[40];
int iRet, index, TCPqueryLength; int iRet, index, TCPqueryLength;
// Generate the TCP message // Generate the TCP message
iRet=MsgGenModbusTCP(query,queryLength,TCPquery,&TCPqueryLength); iRet=MsgGenModbusTCP(query,queryLength,TCPquery,&TCPqueryLength);
// Send the message and Read the reply // Send the message and Read the reply
memset(response,0,responseLength); // puts zeros in reply up until reply length memset(response,0,responseLength); // puts zeros in reply up until reply length
if ((iRet=transactRS232(self,TCPquery,/*strlen(pCommand)*/12,response,20))<=0) if ((iRet=transactRS232(self,TCPquery,/*strlen(pCommand)*/12,response,20))<=0)
{ {
printf("Comms error!\n"); printf("Comms error!\n");
return iRet; // Comms problem return iRet; // Comms problem
} }
// Check that the response transact and protocol identifier are the same // Check that the response transact and protocol identifier are the same
if( (strncmp((char *)TCPquery,(char *)response,3)) == 0) if( (strncmp((char *)TCPquery,(char *)response,3)) == 0)
{ {
// Check that there is not a modbus error, see page 98 from WEST4100 User manual. // Check that there is not a modbus error, see page 98 from WEST4100 User manual.
if ( response[7] > 0x80 ) if ( response[7] > 0x80 )
{ {
iRet=ModbusTCPException(response); iRet=ModbusTCPException(response);
return iRet; return iRet;
} }
else else
{ {
// Return the modbus response minus the TCP Header // Return the modbus response minus the TCP Header
for(index=0;index<6;index++) for(index=0;index<6;index++)
response[index]=response[index+6]; response[index]=response[index+6];
return 1; return 1;
} }
return 1; // Success return 1; // Success
} }
return MODBUSTCP_TCPError; return MODBUSTCP_TCPError;
} }
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
int ModbusTCPException(unsigned char *response) int ModbusTCPException(unsigned char *response)
{ {
if(response[8] == 0x01){ if(response[8] == 0x01){
printf("Exception Code 01h: Illegal Function\n"); printf("Exception Code 01h: Illegal Function\n");
return MODBUSTCP_IllegalFunction; return MODBUSTCP_IllegalFunction;
}else if(response[8] == 0x02){ }else if(response[8] == 0x02){
printf("Exception Code 02h: Illegal Data Address\n"); printf("Exception Code 02h: Illegal Data Address\n");
@ -131,7 +131,7 @@ int ModbusTCPException(unsigned char *response)
}else{ }else{
printf("Error code is greater than 81h, 82h or 83h\n"); printf("Error code is greater than 81h, 82h or 83h\n");
return MODBUSTCP_UnsupportedError; return MODBUSTCP_UnsupportedError;
} }
} }
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/

View File

@ -2,7 +2,7 @@
M O D B U S T C P . H M O D B U S T C P . H
Modbus functions designed for use with the WEST4100 Temperature Controller. Modbus functions designed for use with the WEST4100 Temperature Controller.
Paul Barron, 2008 Paul Barron, 2008
----------------------------------------------------------------------------*/ ----------------------------------------------------------------------------*/
@ -11,9 +11,9 @@ Paul Barron, 2008
#include "rs232controller.h" #include "rs232controller.h"
// Own Codes // Own Codes
#define MODBUSTCP_BadFunction -8001 #define MODBUSTCP_BadFunction -8001
#define MODBUSTCP_BadDataAddress -8002 #define MODBUSTCP_BadDataAddress -8002
#define MODBUSTCP_IllegalFunction -8011 #define MODBUSTCP_IllegalFunction -8011
#define MODBUSTCP_IllegalDataAddress -8012 #define MODBUSTCP_IllegalDataAddress -8012
#define MODBUSTCP_IllegalDataValue -8013 #define MODBUSTCP_IllegalDataValue -8013
#define MODBUSTCP_UnsupportedError -8014 // Device returned a modbus error that is not 81, 82 or 83 #define MODBUSTCP_UnsupportedError -8014 // Device returned a modbus error that is not 81, 82 or 83
@ -22,7 +22,7 @@ Paul Barron, 2008
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
int transactModbusTCP(prs232 self, unsigned char *query, int queryLength, unsigned char *response, int responseLength); int transactModbusTCP(prs232 self, unsigned char *query, int queryLength, unsigned char *response, int responseLength);
#endif #endif

View File

@ -128,7 +128,7 @@
** decimal chars. ** decimal chars.
** term 1 The terminating character which was detected at the ** term 1 The terminating character which was detected at the
** end of the reply. This will be one of the ** end of the reply. This will be one of the
** characters specified in <terms>. ** characters specified in <terms>.
** rply <rply_len-1> The zero-terminated reply. This is effectively the ** rply <rply_len-1> The zero-terminated reply. This is effectively the
** reply as received with the terminating character ** reply as received with the terminating character
** replaced by '\0'. ** replaced by '\0'.
@ -143,7 +143,7 @@
** decimal chars. ** decimal chars.
** term 1 The terminating character which was detected at the ** term 1 The terminating character which was detected at the
** end of the reply. This will be one of the ** end of the reply. This will be one of the
** characters specified in <terms>. ** characters specified in <terms>.
** rply <rply_len-1> The zero-terminated reply. This is effectively the ** rply <rply_len-1> The zero-terminated reply. This is effectively the
** reply as received with the terminating character ** reply as received with the terminating character
** replaced by '\0'. ** replaced by '\0'.

View File

@ -55,7 +55,7 @@ int GalilReading(Ascon *a) {
} }
return 0; return 0;
} }
switch (chr) { switch (chr) {
case ' ': case ' ':
return AsconStdHandler(a); return AsconStdHandler(a);
@ -117,7 +117,7 @@ int GalilProtHandler(Ascon *a) {
void AddGalilProtocoll(){ void AddGalilProtocoll(){
AsconProtocol *prot = NULL; AsconProtocol *prot = NULL;
prot = calloc(sizeof(AsconProtocol), 1); prot = calloc(sizeof(AsconProtocol), 1);
prot->name = strdup("galil"); prot->name = strdup("galil");
prot->init = AsconStdInit; prot->init = AsconStdInit;

View File

@ -63,7 +63,7 @@ BYTE getHexCode(BYTE startPos, char *str){
} }
/** @brief Send the Hexdecimal string with CRC /** @brief Send the Hexdecimal string with CRC
*/ */
int LFGenWriteStart(Ascon *a) { int LFGenWriteStart(Ascon *a) {
@ -78,7 +78,7 @@ int LFGenWriteStart(Ascon *a) {
HEAD = getHexCode(0, curText); HEAD = getHexCode(0, curText);
LEN = getHexCode(2, curText); LEN = getHexCode(2, curText);
// buffer size, // buffer size,
pNewBuffer = (char *)malloc((LEN+2)*sizeof(char)); pNewBuffer = (char *)malloc((LEN+2)*sizeof(char));
bufInd=0; bufInd=0;
pNewBuffer[bufInd] = HEAD; pNewBuffer[bufInd] = HEAD;
@ -130,9 +130,9 @@ int LFConcatChar(pDynString self, char chr){
char *lfChr[2]; char *lfChr[2];
BYTE lfByte = (BYTE)chr; BYTE lfByte = (BYTE)chr;
sprintf(lfChr, "%02x", lfByte); sprintf(lfChr, "%02x", lfByte);
DynStringConcat(self, lfChr); DynStringConcat(self, lfChr);
return 1; return 1;
} }
@ -158,28 +158,28 @@ int LFGenReading(Ascon *a)
if (HEAD==0x96) { if (HEAD==0x96) {
break; break;
} }
} }
if (a->timeout > 0) { if (a->timeout > 0) {
if (DoubleTime() - a->start > 0.05) { if (DoubleTime() - a->start > 0.05) {
AsconError(a, "read timeout", 0); AsconError(a, "read timeout", 0);
/* a->state = AsconTimeout; */ /* a->state = AsconTimeout; */
return 0; return 0;
} }
} }
ret = AsconReadChar(a->fd, &chr); ret = AsconReadChar(a->fd, &chr);
} }
} }
// read LEN info // read LEN info
ret = AsconReadChar(a->fd, &chr); ret = AsconReadChar(a->fd, &chr);
if(ret<0) { if(ret<0) {
AsconError(a, "AsconReadChar failed in LEN reading in LFGenReading:", 0); AsconError(a, "AsconReadChar failed in LEN reading in LFGenReading:", 0);
//a->state = AsconReadDone; //a->state = AsconReadDone;
return 0; return 0;
} }
LEN = (BYTE)chr; LEN = (BYTE)chr;
if(LEN<2) { if(LEN<2) {
AsconError(a, "Reading Error from the LF AG1010 device, wrong LEN info", 0); AsconError(a, "Reading Error from the LF AG1010 device, wrong LEN info", 0);
a->state = AsconReadDone; a->state = AsconReadDone;
return 0; return 0;
@ -189,7 +189,7 @@ int LFGenReading(Ascon *a)
int ind=0; int ind=0;
lfchar[ind] = HEAD; ind++; lfchar[ind] = HEAD; ind++;
lfchar[ind] = LEN; ind++; lfchar[ind] = LEN; ind++;
// read all other chars // read all other chars
while(ind<LEN+2) { while(ind<LEN+2) {
ret = AsconReadChar(a->fd, &chr); ret = AsconReadChar(a->fd, &chr);

View File

@ -54,11 +54,11 @@ static double ieee2double(char ieee[4]) {
long mantissa; long mantissa;
double output; double output;
int exponent; int exponent;
mantissa = ((ieee[1] << 16) & 0x7FFFFF) mantissa = ((ieee[1] << 16) & 0x7FFFFF)
| ((ieee[2] << 8) & 0xFF00) | ((ieee[2] << 8) & 0xFF00)
| ((ieee[3] ) & 0xFF); | ((ieee[3] ) & 0xFF);
exponent = (ieee[0] & 0x7F) * 2 + ((ieee[1] >> 7) & 1); /* raw exponent */ exponent = (ieee[0] & 0x7F) * 2 + ((ieee[1] >> 7) & 1); /* raw exponent */
if (exponent == 0 && mantissa == 0) { if (exponent == 0 && mantissa == 0) {
return 0.0; return 0.0;
@ -287,7 +287,7 @@ int ModbusProtHandler(Ascon *a) {
void AddModbusProtocoll(){ void AddModbusProtocoll(){
AsconProtocol *prot = NULL; AsconProtocol *prot = NULL;
prot = calloc(sizeof(AsconProtocol), 1); prot = calloc(sizeof(AsconProtocol), 1);
prot->name = strdup("modbus"); prot->name = strdup("modbus");
prot->init = AsconStdInit; prot->init = AsconStdInit;

View File

@ -40,12 +40,12 @@ int OrdHVPSWriteStart(Ascon *a) {
char cmd[MAXARGLEN]; char cmd[MAXARGLEN];
int cmd_len, ci,cj,bi; int cmd_len, ci,cj,bi;
char *wrBArray, ch; char *wrBArray, ch;
// strcpy(wrBArray, GetCharArray(a->wrBuffer)); // strcpy(wrBArray, GetCharArray(a->wrBuffer));
wrBArray = GetCharArray(a->wrBuffer); wrBArray = GetCharArray(a->wrBuffer);
cmd_len = GetDynStringLength(a->wrBuffer); cmd_len = GetDynStringLength(a->wrBuffer);
for (ci=2, cj=0, bi=0; ci<MAXARGS && bi<cmd_len && cj < MAXARGLEN; ci++) { for (ci=2, cj=0, bi=0; ci<MAXARGS && bi<cmd_len && cj < MAXARGLEN; ci++) {
for (cj=0; (ch = wrBArray[bi]) != ' ' && bi<cmd_len; bi++, cj++) for (cj=0; (ch = wrBArray[bi]) != ' ' && bi<cmd_len; bi++, cj++)
cmdArgv[ci][cj] = ch; cmdArgv[ci][cj] = ch;
cmdArgv[ci][cj] = '\0'; cmdArgv[ci][cj] = '\0';
while (wrBArray[bi] == ' ' && bi < cmd_len) while (wrBArray[bi] == ' ' && bi < cmd_len)
@ -63,7 +63,7 @@ int OrdHVPSWriteStart(Ascon *a) {
// we also allow the third argument to be an explicit command/response format. // we also allow the third argument to be an explicit command/response format.
// This is in format "<cmd>-<resp>" where the command and response fields // This is in format "<cmd>-<resp>" where the command and response fields
// are format specifiers containing the required/expected ASCII letters // are format specifiers containing the required/expected ASCII letters
// in the command, and the format specifiers '%s' (string), // in the command, and the format specifiers '%s' (string),
// '%d' (integer 0-255), , '%B' (a board name e.g. x0-y15), // '%d' (integer 0-255), , '%B' (a board name e.g. x0-y15),
// '%P' (a pot name e.g. x0-y191), or '%A' (ack code as 'ACK'/'NAK'). // '%P' (a pot name e.g. x0-y191), or '%A' (ack code as 'ACK'/'NAK').
// Formats '%c' (a character) and '%x' (char as 2 hex digits) could be // Formats '%c' (a character) and '%x' (char as 2 hex digits) could be
@ -94,7 +94,7 @@ int OrdHVPSWriteStart(Ascon *a) {
return 0; return 0;
break; break;
} }
// Prepare the command string // Prepare the command string
char *pcmd=cmd; char *pcmd=cmd;
int nfmtspec=0; int nfmtspec=0;
while(*pcmdrspfmt!='-') while(*pcmdrspfmt!='-')
@ -120,7 +120,7 @@ int OrdHVPSWriteStart(Ascon *a) {
{ {
case 's': // probably never used case 's': // probably never used
pcmd+=sprintf(pcmd,"%s",cmdArgv[nfmtspec+2]); pcmd+=sprintf(pcmd,"%s",cmdArgv[nfmtspec+2]);
break; break;
case 'd': case 'd':
sscanf(cmdArgv[nfmtspec+2],"%d",&v1); sscanf(cmdArgv[nfmtspec+2],"%d",&v1);
pcmd+=sprintf(pcmd,"%c",(char)v1); pcmd+=sprintf(pcmd,"%c",(char)v1);
@ -179,7 +179,7 @@ int OrdFmtReply(char *rdBArray, int rsp_len, char *response, char *errmsg) {
/* /*
ffr If AsconStdHandler doesn't see a '\r' or '\n' and there are no more ffr If AsconStdHandler doesn't see a '\r' or '\n' and there are no more
chars to read, it leaves state=AsconReading and the rdBuffer char array chars to read, it leaves state=AsconReading and the rdBuffer char array
without a null terminator. So we assume that higher level code can tell without a null terminator. So we assume that higher level code can tell
if the response is OK and set the state and terminator. if the response is OK and set the state and terminator.
*/ */
DynStringConcatChar(a->rdBuffer, '\0'); DynStringConcatChar(a->rdBuffer, '\0');
@ -245,7 +245,7 @@ int OrdFmtReply(char *rdBArray, int rsp_len, char *response, char *errmsg) {
idx=0; idx=0;
idx=sprintf(errmsg,"Bad response format: "); idx=sprintf(errmsg,"Bad response format: ");
for (i = 0; i < rsp_len && idx < 31; ++i) { for (i = 0; i < rsp_len && idx < 31; ++i) {
if (response[i] < 32 || response[i] > 126) if (response[i] < 32 || response[i] > 126)
idx+=sprintf(&errmsg[idx], "%02Xh", response[i]); idx+=sprintf(&errmsg[idx], "%02Xh", response[i]);
else else
errmsg[idx++] = response[i]; errmsg[idx++] = response[i];
@ -267,7 +267,7 @@ int OrdHVPSReading(Ascon *a) {
int ret, rsp_len; int ret, rsp_len;
static int retries = MAXRETRY; static int retries = MAXRETRY;
char chr, errmsg[ERRMSGLEN], response[MAXARGLEN]; char chr, errmsg[ERRMSGLEN], response[MAXARGLEN];
ret = AsconReadChar(a->fd, &chr); ret = AsconReadChar(a->fd, &chr);
if (ret > 0 && chr == NAK && retries > 0) { if (ret > 0 && chr == NAK && retries > 0) {
AsconReadGarbage(a->fd); AsconReadGarbage(a->fd);

View File

@ -2,7 +2,7 @@
@file sct_protek.c @file sct_protek.c
@brief Protocol handler for Protek 608 multimeter @brief Protocol handler for Protek 608 multimeter
Reads the display bitmap and generates an ASCII string similar to the Reads the display bitmap and generates an ASCII string similar to the
following, following,
SD3:0.|SD4:1|SD5: |DUTY2:0|HOLD2:0|RANGE2:0|ZD2:0|DC2:0|SIGN2:0|AC2:0|CONT2:0|PW1:0|X1:0|B1:1|B0:1|B16:0|B8:0|B4:0|B2:0|DC1:1|SIGN1:1|AC1:0|LOBAT:0|MD5:0.|MD4:0|MD3:0|X2:0|X3:0|PLUS:0|MINUS:0|RS232C:1|AUTOOFF:0|X4:0|PULSE:0|STORE:0|AVG:0|MINUSPEAK:0|MIN:0|RECALL:0|REL:0|PLUSPEAK:0|MAX:0|GO/NG:0|REF:0|MINUSPER:0|PLUSPER:0|MD2:0|MD1:2|s1:0|DEGF1:0|Hz1:0|X5:0|F1:0|A1:0|OHM1:0|X6:0|DEGC1:0|S1:0|V1:1|k1:0|n1:0|m1:0|u1:0|M1:0|B8K:0|B16K:0|X7:0|X8:0|B4K:0|B2K:0|B1K:0|B512:0|B32:0|B64:0|B128:0|B256:0|M2:1|G2:0|m2:0|PERCENT2:0|k2:0|OHM2:1|V2:0|dBm2:0|X9:0|Hz2:0|A2:0|DEGK2:0|SD1:0|SD2:5|ROTSWITCH:0 SD3:0.|SD4:1|SD5: |DUTY2:0|HOLD2:0|RANGE2:0|ZD2:0|DC2:0|SIGN2:0|AC2:0|CONT2:0|PW1:0|X1:0|B1:1|B0:1|B16:0|B8:0|B4:0|B2:0|DC1:1|SIGN1:1|AC1:0|LOBAT:0|MD5:0.|MD4:0|MD3:0|X2:0|X3:0|PLUS:0|MINUS:0|RS232C:1|AUTOOFF:0|X4:0|PULSE:0|STORE:0|AVG:0|MINUSPEAK:0|MIN:0|RECALL:0|REL:0|PLUSPEAK:0|MAX:0|GO/NG:0|REF:0|MINUSPER:0|PLUSPER:0|MD2:0|MD1:2|s1:0|DEGF1:0|Hz1:0|X5:0|F1:0|A1:0|OHM1:0|X6:0|DEGC1:0|S1:0|V1:1|k1:0|n1:0|m1:0|u1:0|M1:0|B8K:0|B16K:0|X7:0|X8:0|B4K:0|B2K:0|B1K:0|B512:0|B32:0|B64:0|B128:0|B256:0|M2:1|G2:0|m2:0|PERCENT2:0|k2:0|OHM2:1|V2:0|dBm2:0|X9:0|Hz2:0|A2:0|DEGK2:0|SD1:0|SD2:5|ROTSWITCH:0
@ -461,7 +461,7 @@ int AsconProtek608Init(Ascon *a, SConnection *con, int argc, char *argv[])
void AddProtek608Protocol() void AddProtek608Protocol()
{ {
AsconProtocol *prot = NULL; AsconProtocol *prot = NULL;
prot = calloc(sizeof(AsconProtocol), 1); prot = calloc(sizeof(AsconProtocol), 1);
prot->name = strdup("protek608"); prot->name = strdup("protek608");
prot->init = AsconProtek608Init; prot->init = AsconProtek608Init;

View File

@ -6,7 +6,7 @@
"OK", when successful "OK", when successful
"ANSRFAMP: Set failed", on error "ANSRFAMP: Set failed", on error
Current should be ramped up in steps of 0.5A but it doesn't Current should be ramped up in steps of 0.5A but it doesn't
have to be ramped down. have to be ramped down.
Provides two commands (L)ist and (S)et Provides two commands (L)ist and (S)et
@ -102,7 +102,7 @@ int RFAmpWriteStart (Ascon *a)
AsconError(a, errMsg, 0); AsconError(a, errMsg, 0);
return 1; return 1;
} }
if (address < '1' || address > '9') { if (address < '1' || address > '9') {
snprintf(errMsg, ERRLEN, "ANSRFAMP: Invalid address %c, it should be between 1 and 9", address); snprintf(errMsg, ERRLEN, "ANSRFAMP: Invalid address %c, it should be between 1 and 9", address);
a->state = AsconWriteDone; a->state = AsconWriteDone;
a->noResponse = 1; a->noResponse = 1;
@ -253,12 +253,12 @@ int RFAmpReading (Ascon *a)
GetReplyFailed = 1; GetReplyFailed = 1;
break; break;
} else { } else {
DynStringReplace(a->rdBuffer, "OK", 0); DynStringReplace(a->rdBuffer, "OK", 0);
} }
*/ */
/* ffr Just report OK until we have a proper fix */ /* ffr Just report OK until we have a proper fix */
DynStringReplace(a->rdBuffer, "OK", 0); DynStringReplace(a->rdBuffer, "OK", 0);
a->state = AsconReadDone; a->state = AsconReadDone;
data->transactInProg = txNormalRead; data->transactInProg = txNormalRead;

View File

@ -58,11 +58,11 @@ static double ieee2double(unsigned char ieee[4]) {
long mantissa; long mantissa;
double output, norm = 1; double output, norm = 1;
int exponent, bias = 127; int exponent, bias = 127;
mantissa = ((ieee[1] << 16) & 0x7F0000) mantissa = ((ieee[1] << 16) & 0x7F0000)
| ((ieee[2] << 8) & 0xFF00) | ((ieee[2] << 8) & 0xFF00)
| ((ieee[3] ) & 0xFF); | ((ieee[3] ) & 0xFF);
exponent = (ieee[0] & 0x7F) * 2 + ((ieee[1] >> 7) & 1); /* raw exponent */ exponent = (ieee[0] & 0x7F) * 2 + ((ieee[1] >> 7) & 1); /* raw exponent */
if (exponent == 255) { if (exponent == 255) {
if (mantissa == 0) { if (mantissa == 0) {
@ -412,7 +412,7 @@ int TCPMBUtil(SConnection *pCon, SicsInterp *pSics, void *pData, int argc, char
{"double2ieee",1,{FUPAFLOAT}}, {"double2ieee",1,{FUPAFLOAT}},
{NULL} {NULL}
}; };
Arg2Text(argc, argv, cmdLine, 511); Arg2Text(argc, argv, cmdLine, 511);
iRet = EvaluateFuPa((pFuncTemplate)&CommandTemplate,iNumCmds,argc-1,&argv[1],&PaRes); iRet = EvaluateFuPa((pFuncTemplate)&CommandTemplate,iNumCmds,argc-1,&argv[1],&PaRes);
switch(iRet) { switch(iRet) {
@ -466,7 +466,7 @@ int TCPMBProtHandler(Ascon *a) {
void AddTCPMBProtocol(){ void AddTCPMBProtocol(){
AsconProtocol *prot = NULL; AsconProtocol *prot = NULL;
AddCommand(pServ->pSics, "fermi", TCPMBUtil, NULL, NULL); AddCommand(pServ->pSics, "fermi", TCPMBUtil, NULL, NULL);
prot = calloc(sizeof(AsconProtocol), 1); prot = calloc(sizeof(AsconProtocol), 1);
prot->name = strdup("tcpmodbus"); prot->name = strdup("tcpmodbus");

View File

@ -4,7 +4,7 @@
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
#include <errno.h> #include <errno.h>
#include <ascon.h> #include <ascon.h>
#include <ascon.i> #include <ascon.i>
@ -44,7 +44,7 @@ int USBTMC_ProtHandler(Ascon *a) {
void AddUSBTMCProtocoll(){ void AddUSBTMCProtocoll(){
AsconProtocol *prot = NULL; AsconProtocol *prot = NULL;
prot = calloc(sizeof(AsconProtocol), 1); prot = calloc(sizeof(AsconProtocol), 1);
prot->name = strdup("usbtmc"); prot->name = strdup("usbtmc");
prot->init = AsconStdInit; prot->init = AsconStdInit;

View File

@ -41,7 +41,7 @@ int VelSelProtHandler(Ascon *a)
void AddVelSelProtocol() void AddVelSelProtocol()
{ {
AsconProtocol *prot = NULL; AsconProtocol *prot = NULL;
prot = calloc(sizeof(AsconProtocol), 1); prot = calloc(sizeof(AsconProtocol), 1);
prot->name = strdup("astvelsel"); prot->name = strdup("astvelsel");
prot->init = AsconStdInit; prot->init = AsconStdInit;

View File

@ -1,12 +1,12 @@
/*------------------------------------------------------------------------- /*-------------------------------------------------------------------------
S E R I A L S I N Q S E R I A L S I N Q
Implementation file of the functions for talking with a RS--232 port Implementation file of the functions for talking with a RS--232 port
on a SINQ terminal server. This code has been adapted from code on a SINQ terminal server. This code has been adapted from code
provided by David Maden for the EL734 motor controller. A new version provided by David Maden for the EL734 motor controller. A new version
became necessary as the Dornier velocity selector supports a became necessary as the Dornier velocity selector supports a
completely different protocoll than the EL734. The basics, however, are completely different protocoll than the EL734. The basics, however, are
the same. the same.
Mark Koennecke, Juli 1997 Mark Koennecke, Juli 1997
Copyright: Copyright:
@ -90,7 +90,7 @@
struct RS__MsgStruct to_host; struct RS__MsgStruct to_host;
struct RS__RespStruct from_host; struct RS__RespStruct from_host;
SerialSleep pFunc; SerialSleep pFunc;
void *pData; void *pData;
struct AsynSrv__info sAsync; struct AsynSrv__info sAsync;
}; };
/*------------------- The default sleep function -----------------------*/ /*------------------- The default sleep function -----------------------*/
@ -115,9 +115,9 @@
//struct RS__RplyStruct *rply_ptr; //struct RS__RplyStruct *rply_ptr;
*pData = NULL; *pData = NULL;
/* /*
** allocate memory first ** allocate memory first
*/ */
*pData = malloc (sizeof (struct SerialInfo)); *pData = malloc (sizeof (struct SerialInfo));
if (*pData == NULL) { if (*pData == NULL) {
@ -138,7 +138,7 @@
} }
/* intialize data structures */ /* intialize data structures */
StrJoin (my_info->host, sizeof (my_info->host), pHost, ""); StrJoin (my_info->host, sizeof (my_info->host), pHost, "");
my_info->skt = my_info->sAsync.skt; my_info->skt = my_info->sAsync.skt;
my_info->port = iPort; my_info->port = iPort;
my_info->chan = iChannel; my_info->chan = iChannel;
@ -176,8 +176,8 @@
} }
my_info = *pData; my_info = *pData;
memset(my_info,0,sizeof(struct SerialInfo)); memset(my_info,0,sizeof(struct SerialInfo));
/* /*
**-------------------------- Set up the connection **-------------------------- Set up the connection
*/ */
@ -190,7 +190,7 @@
} }
/* intialize data structures */ /* intialize data structures */
StrJoin (my_info->host, sizeof (my_info->host), pHost, ""); StrJoin (my_info->host, sizeof (my_info->host), pHost, "");
my_info->skt = my_info->sAsync.skt; my_info->skt = my_info->sAsync.skt;
my_info->port = iPort; my_info->port = iPort;
my_info->chan = iChannel; my_info->chan = iChannel;
@ -209,10 +209,10 @@
int SerialConfig(void **pData, int iTmo) int SerialConfig(void **pData, int iTmo)
{ {
struct SerialInfo *my_info = NULL; struct SerialInfo *my_info = NULL;
my_info = (struct SerialInfo *)*pData; my_info = (struct SerialInfo *)*pData;
assert(my_info); assert(my_info);
if(iTmo < 100) if(iTmo < 100)
{ {
my_info->tmo = 1; my_info->tmo = 1;
@ -224,20 +224,20 @@
if(my_info->tmo > 9999)my_info->tmo = 9999; if(my_info->tmo > 9999)my_info->tmo = 9999;
} }
return 1; return 1;
} }
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
int GetSerialTmo(void **pData) int GetSerialTmo(void **pData)
{ {
struct SerialInfo *my_info = NULL; struct SerialInfo *my_info = NULL;
int iTmo; int iTmo;
my_info = (struct SerialInfo *)*pData; my_info = (struct SerialInfo *)*pData;
assert(my_info); assert(my_info);
iTmo = my_info->tmo*100-99; /* convert back to milli seconds */ iTmo = my_info->tmo*100-99; /* convert back to milli seconds */
return iTmo; return iTmo;
} }
int SerialGetTmo(void **pData) int SerialGetTmo(void **pData)
{ {
return GetSerialTmo(pData); return GetSerialTmo(pData);
@ -247,14 +247,14 @@
{ {
struct SerialInfo *my_info = NULL; struct SerialInfo *my_info = NULL;
// int iTmo; // int iTmo;
my_info = (struct SerialInfo *)*pData; my_info = (struct SerialInfo *)*pData;
assert(my_info); assert(my_info);
return my_info->skt; return my_info->skt;
return 1; return 1;
} }
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
int SerialClose(void **pData) int SerialClose(void **pData)
{ {
@ -295,14 +295,14 @@
int SerialATerm(void **pData, char *pTerm) int SerialATerm(void **pData, char *pTerm)
{ {
struct SerialInfo *my_info = NULL; struct SerialInfo *my_info = NULL;
my_info = (struct SerialInfo *)*pData; my_info = (struct SerialInfo *)*pData;
if(my_info == NULL) if(my_info == NULL)
{ {
printf("Serious Programming problem: data = NULL\n"); printf("Serious Programming problem: data = NULL\n");
return 0; return 0;
} }
/* only three characters in this field */ /* only three characters in this field */
if(strlen(pTerm) > 4) if(strlen(pTerm) > 4)
{ {
@ -310,39 +310,39 @@
} }
memset(my_info->pTerms,0,4); memset(my_info->pTerms,0,4);
strcpy(my_info->pTerms,pTerm); strcpy(my_info->pTerms,pTerm);
return 1; return 1;
} }
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
int SerialAGetTerm(void **pData, char *pTerm, int iTermLen) int SerialAGetTerm(void **pData, char *pTerm, int iTermLen)
{ {
struct SerialInfo *my_info = NULL; struct SerialInfo *my_info = NULL;
my_info = (struct SerialInfo *)*pData; my_info = (struct SerialInfo *)*pData;
assert(my_info); assert(my_info);
strncpy(pTerm,my_info->pTerms,iTermLen); strncpy(pTerm,my_info->pTerms,iTermLen);
return 1; return 1;
} }
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
int SerialSendTerm(void **pData, char *pTerm) int SerialSendTerm(void **pData, char *pTerm)
{ {
struct SerialInfo *my_info = NULL; struct SerialInfo *my_info = NULL;
my_info = (struct SerialInfo *)*pData; my_info = (struct SerialInfo *)*pData;
assert(my_info); assert(my_info);
/* only 0 characters in this field */ /* only 0 characters in this field */
if(strlen(pTerm) > 9) if(strlen(pTerm) > 9)
{ {
return 0; return 0;
} }
strcpy(my_info->pSendTerm,pTerm); strcpy(my_info->pSendTerm,pTerm);
return 1; return 1;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
int SerialSend(void **pData, char *pCommand) int SerialSend(void **pData, char *pCommand)
@ -400,16 +400,16 @@
}else { }else {
strcpy (cmnd_lst_ptr+4, txt_ptr); strcpy (cmnd_lst_ptr+4, txt_ptr);
/* make sure that the string is properly terminated */ /* make sure that the string is properly terminated */
if((strstr(txt_ptr,info_ptr->pSendTerm) == 0) && if((strstr(txt_ptr,info_ptr->pSendTerm) == 0) &&
(strlen(txt_ptr) > 0) ) (strlen(txt_ptr) > 0) )
{ {
strcpy(cmnd_lst_ptr+4+strlen(txt_ptr),info_ptr->pSendTerm); strcpy(cmnd_lst_ptr+4+strlen(txt_ptr),info_ptr->pSendTerm);
c_len = strlen(txt_ptr) + strlen(info_ptr->pSendTerm); c_len = strlen(txt_ptr) + strlen(info_ptr->pSendTerm);
} }
else else
{ {
c_len = strlen (txt_ptr); c_len = strlen (txt_ptr);
} }
sprintf (text, "%4.4d", c_len); sprintf (text, "%4.4d", c_len);
memcpy (cmnd_lst_ptr, text, 4); memcpy (cmnd_lst_ptr, text, 4);
cmnd_lst_ptr = cmnd_lst_ptr + c_len + 4; cmnd_lst_ptr = cmnd_lst_ptr + c_len + 4;
@ -445,7 +445,7 @@
int SerialReceive(void **pData, char *pBuffer, int iBufLen) int SerialReceive(void **pData, char *pBuffer, int iBufLen)
{ {
struct SerialInfo *info_ptr; struct SerialInfo *info_ptr;
int status;//, c_len, int status;//, c_len,
int size, max_size; //, ncmnds; int size, max_size; //, ncmnds;
int bytes_to_come, bytes_left; int bytes_to_come, bytes_left;
int iResult; int iResult;
@ -458,7 +458,7 @@
//long lMask = 0L; //long lMask = 0L;
//struct timeval tmo = {0,1}; //struct timeval tmo = {0,1};
/* /*
** Do nothing if no connection - the connection gets ** Do nothing if no connection - the connection gets
** closed if an error is detected. ** closed if an error is detected.
@ -478,7 +478,7 @@
if(status <= 0) if(status <= 0)
{ {
return SELECTFAIL; return SELECTFAIL;
} }
*/ */
/* try read the message length to come */ /* try read the message length to come */
@ -492,8 +492,8 @@
else if (status == -1) { else if (status == -1) {
iResult = EL734__BAD_RECV_NET; /* It's some other net problem */ iResult = EL734__BAD_RECV_NET; /* It's some other net problem */
} }
else else
{ {
iResult = EL734__BAD_RECV_NET; iResult = EL734__BAD_RECV_NET;
} }
AsynSrv_Close (&(info_ptr->sAsync),1); AsynSrv_Close (&(info_ptr->sAsync),1);
@ -564,11 +564,11 @@
return True; return True;
} }
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
int SerialReceiveWithTerm(void **pData, char *pBuffer, int SerialReceiveWithTerm(void **pData, char *pBuffer,
int iBufLen, char *cTerm ) int iBufLen, char *cTerm )
{ {
struct SerialInfo *info_ptr; struct SerialInfo *info_ptr;
int status;//, c_len, int status;//, c_len,
int size, max_size;//, ncmnds; int size, max_size;//, ncmnds;
int bytes_to_come, bytes_left; int bytes_to_come, bytes_left;
int iResult; int iResult;
@ -581,7 +581,7 @@
//long lMask = 0L; //long lMask = 0L;
//struct timeval tmo = {0,1}; //struct timeval tmo = {0,1};
/* /*
** Do nothing if no connection - the connection gets ** Do nothing if no connection - the connection gets
** closed if an error is detected. ** closed if an error is detected.
@ -601,7 +601,7 @@
if(status <= 0) if(status <= 0)
{ {
return SELECTFAIL; return SELECTFAIL;
} }
*/ */
/* try read the message length to come */ /* try read the message length to come */
@ -615,8 +615,8 @@
else if (status == -1) { else if (status == -1) {
iResult = EL734__BAD_RECV_NET; /* It's some other net problem */ iResult = EL734__BAD_RECV_NET; /* It's some other net problem */
} }
else else
{ {
iResult = EL734__BAD_RECV_NET; iResult = EL734__BAD_RECV_NET;
} }
AsynSrv_Close (&(info_ptr->sAsync),1); AsynSrv_Close (&(info_ptr->sAsync),1);
@ -687,7 +687,7 @@
} }
return True; return True;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
int SerialError(int iErr, char *pBuffer, int iBufLen) int SerialError(int iErr, char *pBuffer, int iBufLen)
{ {
@ -702,10 +702,10 @@
break; break;
case -301: case -301:
strncpy(pBuffer,"No reply found", iBufLen); strncpy(pBuffer,"No reply found", iBufLen);
break; break;
case -100: case -100:
strncpy(pBuffer,"No reply found", iBufLen); strncpy(pBuffer,"No reply found", iBufLen);
break; break;
case EL734__BAD_ADR: case EL734__BAD_ADR:
strncpy(pBuffer,"SERIAL__BAD_ADR",iBufLen); strncpy(pBuffer,"SERIAL__BAD_ADR",iBufLen);
break; break;
@ -745,7 +745,7 @@
case EL734__BAD_PAR: case EL734__BAD_PAR:
strncpy(pBuffer,"SERIAL__BAD_PAR",iBufLen); strncpy(pBuffer,"SERIAL__BAD_PAR",iBufLen);
break; break;
case EL734__BAD_RECV: case EL734__BAD_RECV:
strncpy(pBuffer,"SERIAL__BAD_RECV",iBufLen); strncpy(pBuffer,"SERIAL__BAD_RECV",iBufLen);
break; break;
@ -800,24 +800,24 @@
case OPENFAILURE: case OPENFAILURE:
strncpy(pBuffer, strncpy(pBuffer,
"FAILED to open connection to serial port server", iBufLen); "FAILED to open connection to serial port server", iBufLen);
break; break;
default: default:
strcpy(pBuffer,"Unknown SERIAL error"); strcpy(pBuffer,"Unknown SERIAL error");
break; break;
} }
return 1; return 1;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
int SerialWriteRead(void **pData, char *pCommand, int SerialWriteRead(void **pData, char *pCommand,
char *pBuffer, int iBufLen) char *pBuffer, int iBufLen)
{ {
struct SerialInfo *pInfo = NULL; struct SerialInfo *pInfo = NULL;
int iRet; int iRet;
time_t tTarget, tCurrent; time_t tTarget, tCurrent;
pInfo = (struct SerialInfo *)*pData; pInfo = (struct SerialInfo *)*pData;
/* write */ /* write */
iRet = SerialSend(pData,pCommand); iRet = SerialSend(pData,pCommand);
if(iRet != 1) if(iRet != 1)
@ -825,11 +825,11 @@
SerialError(iRet, pBuffer,iBufLen); SerialError(iRet, pBuffer,iBufLen);
return iRet; return iRet;
} }
/* check for answers for maximum time out */ /* check for answers for maximum time out */
tTarget = tCurrent = time(&tCurrent); tTarget = tCurrent = time(&tCurrent);
tTarget += pInfo->tmo*100 - 90; tTarget += pInfo->tmo*100 - 90;
while(tCurrent < tTarget) while(tCurrent < tTarget)
{ {
pInfo->pFunc(pInfo->pData, 100); pInfo->pFunc(pInfo->pData, 100);
@ -843,27 +843,27 @@
return iRet; return iRet;
} }
} }
else else
{ {
return 1; /* there is data read, we are done */ return 1; /* there is data read, we are done */
} }
tCurrent = time(&tCurrent); tCurrent = time(&tCurrent);
} }
return TIMEOUT; return TIMEOUT;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
int SerialNoReply(void **pData, char *pCommand) int SerialNoReply(void **pData, char *pCommand)
{ {
struct SerialInfo *pInfo = NULL; struct SerialInfo *pInfo = NULL;
int iRet, iOld, i; int iRet, iOld, i;
char pBuffer[30]; char pBuffer[30];
pInfo = (struct SerialInfo *)*pData; pInfo = (struct SerialInfo *)*pData;
iOld = pInfo->tmo; iOld = pInfo->tmo;
pInfo->tmo = 0; pInfo->tmo = 0;
/* write */ /* write */
iRet = SerialSend(pData,pCommand); iRet = SerialSend(pData,pCommand);
if(iRet != 1) if(iRet != 1)
@ -871,7 +871,7 @@
pInfo->tmo = iOld; pInfo->tmo = iOld;
return iRet; return iRet;
} }
/* try some time to find a TMO */ /* try some time to find a TMO */
for(i = 0 ; i < 10; i++) for(i = 0 ; i < 10; i++)
{ {
@ -888,19 +888,19 @@
} }
pInfo->tmo = iOld; pInfo->tmo = iOld;
return 1; return 1;
} }
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
void SetSerialSleep(void **pData, SerialSleep pFun, void *pUserData) void SetSerialSleep(void **pData, SerialSleep pFun, void *pUserData)
{ {
struct SerialInfo *pInfo = NULL; struct SerialInfo *pInfo = NULL;
// int iRet; // int iRet;
pInfo = (struct SerialInfo *)*pData; pInfo = (struct SerialInfo *)*pData;
pInfo->pFunc = pFun; pInfo->pFunc = pFun;
pInfo->pData = pUserData; pInfo->pData = pUserData;
} }

View File

@ -35,12 +35,12 @@
int SerialSend(void **pData, char *pCommand); int SerialSend(void **pData, char *pCommand);
int SerialReceive(void **pData, char *pBuffer, int iBufLen); int SerialReceive(void **pData, char *pBuffer, int iBufLen);
int SerialReceiveWithTerm(void **pData, char *pBuffer, int SerialReceiveWithTerm(void **pData, char *pBuffer,
int iBufLen,char *cTerm); int iBufLen,char *cTerm);
int SerialError(int iError, char *pError, int iErrLen); int SerialError(int iError, char *pError, int iErrLen);
int SerialWriteRead(void **pData, char *pCommand, int SerialWriteRead(void **pData, char *pCommand,
char *pBuffer, int iBufLen); char *pBuffer, int iBufLen);
int SerialNoReply(void **pData, char *pCommand); int SerialNoReply(void **pData, char *pCommand);
#line 175 "velodorn.w" #line 175 "velodorn.w"

View File

@ -48,7 +48,7 @@
pSINQHM CreateSINQHM(char *pHMComputer, int iMasterPort); pSINQHM CreateSINQHM(char *pHMComputer, int iMasterPort);
pSINQHM CopySINQHM(pSINQHM self); pSINQHM CopySINQHM(pSINQHM self);
void DeleteSINQHM(pSINQHM self); void DeleteSINQHM(pSINQHM self);
void SINQHMSetPar(pSINQHM self, int iRank, int iLength, int iBinWidth); void SINQHMSetPar(pSINQHM self, int iRank, int iLength, int iBinWidth);
void SINQHMSetPSD(pSINQHM self, int xSize, int xOff, int xFac, void SINQHMSetPSD(pSINQHM self, int xSize, int xOff, int xFac,
int ySize, int yOff, int yFac); int ySize, int yOff, int yFac);
@ -59,12 +59,12 @@
#line 155 "sinqhm.w" #line 155 "sinqhm.w"
int SINQHMConfigure(pSINQHM self, int iMode, int iRank, int iLength, int SINQHMConfigure(pSINQHM self, int iMode, int iRank, int iLength,
int iBinWidth, int iLowBin, int iCompress); int iBinWidth, int iLowBin, int iCompress);
int SINQHMConfigurePSD(pSINQHM self, int iMode, int SINQHMConfigurePSD(pSINQHM self, int iMode,
int xSize, int xOff, int xFac, int xSize, int xOff, int xFac,
int ySize, int yOff, int yFac, int ySize, int yOff, int yFac,
int iBinWidth, int iBinWidth,
float *iEdges, int iEdgeLength); float *iEdges, int iEdgeLength);
int SINQHMDeconfigure(pSINQHM self, int iHarsh); int SINQHMDeconfigure(pSINQHM self, int iHarsh);
@ -73,7 +73,7 @@
int *iLength, int *iClients); int *iLength, int *iClients);
int SINQHMDebug(pSINQHM self, int iLevel); int SINQHMDebug(pSINQHM self, int iLevel);
int SINQHMKill(pSINQHM self); int SINQHMKill(pSINQHM self);
#line 261 "sinqhm.w" #line 261 "sinqhm.w"
@ -84,12 +84,12 @@
int SINQHMStopDAQ(pSINQHM self); int SINQHMStopDAQ(pSINQHM self);
int SINQHMInhibitDAQ(pSINQHM self); int SINQHMInhibitDAQ(pSINQHM self);
int SINQHMContinueDAQ(pSINQHM self); int SINQHMContinueDAQ(pSINQHM self);
int SINQHMWrite(pSINQHM self, int iNum, int iStart, int iEnd, int SINQHMWrite(pSINQHM self, int iNum, int iStart, int iEnd,
void *pData); void *pData);
long SINQHMSize(pSINQHM self, int iNum, int iStart, int iEnd); long SINQHMSize(pSINQHM self, int iNum, int iStart, int iEnd);
int SINQHMRead(pSINQHM self, int iNum, int iStart, int iEnd, int SINQHMRead(pSINQHM self, int iNum, int iStart, int iEnd,
void *pData, int iDataLen); void *pData, int iDataLen);
int SINQHMProject(pSINQHM self, int code, int xStart, int nx, int SINQHMProject(pSINQHM self, int code, int xStart, int nx,
int yStart, int ny, void *pData, int iDataLen); int yStart, int ny, void *pData, int iDataLen);
int SINQHMZero(pSINQHM self, int iNum, int iStart, int iEnd); int SINQHMZero(pSINQHM self, int iNum, int iStart, int iEnd);

View File

@ -218,7 +218,7 @@
#define LWL_TOF_C9 (0x09000000) /* TOF-Mode 9 chan dgrm hdr */ #define LWL_TOF_C9 (0x09000000) /* TOF-Mode 9 chan dgrm hdr */
#define LWL_PSD_TSI 0x0E000000 /* PSD-Mode TSI datagram */ #define LWL_PSD_TSI 0x0E000000 /* PSD-Mode TSI datagram */
#define LWL_PSD_DATA 0x12000000 /* PSD-mode data datagram */ #define LWL_PSD_DATA 0x12000000 /* PSD-mode data datagram */
#define LWL_PSD_PWF 0x20000000 /* PSD-mode Power Fail bit */ #define LWL_PSD_PWF 0x20000000 /* PSD-mode Power Fail bit */
#define LWL_PSD_TIME 0x000fffff /* PSD-mode time stamp extraction #define LWL_PSD_TIME 0x000fffff /* PSD-mode time stamp extraction
mask */ mask */
@ -369,7 +369,7 @@
struct {uint sub_cmnd;} daq; struct {uint sub_cmnd;} daq;
struct {uint sub_code, struct {uint sub_code,
x_lo, x_lo,
nx, nx,
y_lo, y_lo,

View File

@ -1,11 +1,11 @@
/** /**
* This is an asynchronous protocol implementation for HTTP. * This is an asynchronous protocol implementation for HTTP.
* It includes special features to store binary data coming * It includes special features to store binary data coming
* from a SINQ http histogram memory in a sinqdata object. * from a SINQ http histogram memory in a sinqdata object.
* Which has to be specified on initialisation. * Which has to be specified on initialisation.
* *
* copyright: see file COPYRIGHT * copyright: see file COPYRIGHT
* *
* Mark Koennecke, June 2008 * Mark Koennecke, June 2008
*/ */
#include <ascon.h> #include <ascon.h>
@ -25,7 +25,7 @@ static int configRequest(Ascon *a){
pHttpProt pHttp = (pHttpProt)a->private; pHttpProt pHttp = (pHttpProt)a->private;
pDynString request; pDynString request;
char *uri = NULL; char *uri = NULL;
request = CreateDynString(64,64); request = CreateDynString(64,64);
if(request == NULL){ if(request == NULL){
AsconError(a,"Out of memory", 122); AsconError(a,"Out of memory", 122);
@ -36,7 +36,7 @@ static int configRequest(Ascon *a){
DynStringConcatChar(request,'/'); DynStringConcatChar(request,'/');
DynStringConcat(request,GetCharArray(a->wrBuffer)); DynStringConcat(request,GetCharArray(a->wrBuffer));
uri = GetCharArray(request); uri = GetCharArray(request);
ghttp_clean(pHttp->request); ghttp_clean(pHttp->request);
ghttp_set_type(pHttp->request,ghttp_type_get); ghttp_set_type(pHttp->request,ghttp_type_get);
ghttp_set_header(pHttp->request,"connection", "keep-alive"); ghttp_set_header(pHttp->request,"connection", "keep-alive");
@ -45,13 +45,13 @@ static int configRequest(Ascon *a){
return 0; return 0;
} }
if(pHttp->userName != NULL && pHttp->password != NULL){ if(pHttp->userName != NULL && pHttp->password != NULL){
ghttp_set_authinfo(pHttp->request, ghttp_set_authinfo(pHttp->request,
pHttp->userName, pHttp->password); pHttp->userName, pHttp->password);
} }
ghttp_set_sync(pHttp->request,ghttp_async); ghttp_set_sync(pHttp->request,ghttp_async);
ghttp_prepare(pHttp->request); ghttp_prepare(pHttp->request);
DeleteDynString(request); DeleteDynString(request);
return 1; return 1;
} }
/*---------------------------------------------------------------------*/ /*---------------------------------------------------------------------*/
@ -60,7 +60,7 @@ static void handleReply(Ascon *a){
int len, i, *dataPtr = NULL; int len, i, *dataPtr = NULL;
HistInt *hmData = NULL; HistInt *hmData = NULL;
pHttpProt pHttp = (pHttpProt)a->private; pHttpProt pHttp = (pHttpProt)a->private;
pPtr = ghttp_get_body(pHttp->request); pPtr = ghttp_get_body(pHttp->request);
len = ghttp_get_body_len(pHttp->request); len = ghttp_get_body_len(pHttp->request);
if(strstr(pPtr,"ERROR") != NULL){ if(strstr(pPtr,"ERROR") != NULL){
@ -96,7 +96,7 @@ static int HttpHandler(Ascon *a) {
int socke, selStat; int socke, selStat;
fd_set rmask; fd_set rmask;
struct timeval tmo = {0,0}; struct timeval tmo = {0,0};
switch (a->state) { switch (a->state) {
case AsconConnectStart: case AsconConnectStart:
a->state = AsconConnecting; a->state = AsconConnecting;
@ -161,7 +161,7 @@ static int HttpHandler(Ascon *a) {
break; break;
case ghttp_error: case ghttp_error:
/* /*
* A first error may not be an error but a * A first error may not be an error but a
* reconnect * reconnect
*/ */
ghttp_close(pHttp->request); ghttp_close(pHttp->request);
@ -178,7 +178,7 @@ static int HttpHandler(Ascon *a) {
break; break;
default: default:
return AsconStdHandler(a); return AsconStdHandler(a);
} }
return 1; return 1;
} }
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
@ -199,10 +199,10 @@ static void killHttp(void *data){
free(prot); free(prot);
} }
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
static int HttpProtInit(Ascon *a, SConnection *con, static int HttpProtInit(Ascon *a, SConnection *con,
int argc, char *argv[]){ int argc, char *argv[]){
pHttpProt pHttp = NULL; pHttpProt pHttp = NULL;
if(argc < 3){ if(argc < 3){
SCWrite(con,"ERROR: too few arguments in HttpProtInit", eError); SCWrite(con,"ERROR: too few arguments in HttpProtInit", eError);
return 0; return 0;
@ -238,7 +238,7 @@ static int HttpProtInit(Ascon *a, SConnection *con,
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
void AddHttpProtocoll(){ void AddHttpProtocoll(){
AsconProtocol *prot = NULL; AsconProtocol *prot = NULL;
prot = calloc(sizeof(AsconProtocol), 1); prot = calloc(sizeof(AsconProtocol), 1);
prot->name = strdup("sinqhttp"); prot->name = strdup("sinqhttp");
prot->init = HttpProtInit; prot->init = HttpProtInit;

View File

@ -253,14 +253,14 @@
}else { }else {
*nxt++ = '\\'; break; *nxt++ = '\\'; break;
} }
case '0': case '0':
case '1': case '1':
case '2': case '2':
case '3': case '3':
case '4': case '4':
case '5': case '5':
case '6': case '6':
case '7': case '7':
i = strspn (in, "01234567"); i = strspn (in, "01234567");
if (i > 3) { if (i > 3) {
sscanf (in, "%3o", &j); sscanf (in, "%3o", &j);
@ -273,7 +273,7 @@
in += i; in += i;
break; break;
}else { }else {
*nxt++ = '\\'; *nxt++ = '\\';
break; break;
} }
default: default:

View File

@ -1,35 +1,35 @@
/*--------------------------------------------------------------------------- /*---------------------------------------------------------------------------
A general purpose translation table and interpolation module. A general purpose translation table and interpolation module.
Interpolation tables are read from a file, which is meant to Interpolation tables are read from a file, which is meant to
contain pairs of val1 val2 per line. contain pairs of val1 val2 per line.
Mark Koennecke, October 1997 Mark Koennecke, October 1997
copyright: see copyright.h copyright: see copyright.h
-----------------------------------------------------------------------------*/ -----------------------------------------------------------------------------*/
#ifndef SICSTABLE #ifndef SICSTABLE
#define SICSTABLE #define SICSTABLE
typedef struct __SicsTable *pSTable; typedef struct __SicsTable *pSTable;
/*------------------------- live & death ----------------------------------*/ /*------------------------- live & death ----------------------------------*/
pSTable CreateTable(FILE *fd); pSTable CreateTable(FILE *fd);
/* /*
creates a new table from a given file. The file is meant to have creates a new table from a given file. The file is meant to have
been positioned to the first entry for the table in the file. been positioned to the first entry for the table in the file.
This leaves the caller free to examine a header, if any. This leaves the caller free to examine a header, if any.
*/ */
void DeleteTable(pSTable self); void DeleteTable(pSTable self);
/*------------------------- Interpolation --------------------------------*/ /*------------------------- Interpolation --------------------------------*/
int InterpolateVal1(pSTable pTable, float fKey, float *fResult); int InterpolateVal1(pSTable pTable, float fKey, float *fResult);
/* /*
Returns a result from the second column for a key from the Returns a result from the second column for a key from the
first column. first column.
*/ */
int InterpolateVal2(pSTable pTable, float fKey, float *fResult); int InterpolateVal2(pSTable pTable, float fKey, float *fResult);
/* /*
Returns a result from the first column for a key from the Returns a result from the first column for a key from the
second column. second column.
*/ */
#endif #endif

View File

@ -1,13 +1,13 @@
/*-------------------------------------------------------------------------- /*--------------------------------------------------------------------------
W E S T 4 1 0 0 U T I L . C W E S T 4 1 0 0 U T I L . C
A few utility functions for dealing with a WEST4100 temperature controller A few utility functions for dealing with a WEST4100 temperature controller
within the SINQ setup: host -- TCP/IP -- MAC --- RS-232. within the SINQ setup: host -- TCP/IP -- MAC --- RS-232.
Mark Koennecke, Juli 1997 Mark Koennecke, Juli 1997
Mark Lesha, January 2006 (based on ITC4 code) Mark Lesha, January 2006 (based on ITC4 code)
Paul Barron, January 2008 (Note: This is based on the old LAKESHORE340 code and Paul Barron, January 2008 (Note: This is based on the old LAKESHORE340 code and
not the new LS340 code written by Rodney Davies Feb 08) not the new LS340 code written by Rodney Davies Feb 08)
Copyright: Copyright:
@ -68,26 +68,26 @@
sprintf(pCommand,"%c%c%c%c%c%c",self->iAdr,0x01,0x00,0x05,0x00,0x01); sprintf(pCommand,"%c%c%c%c%c%c",self->iAdr,0x01,0x00,0x05,0x00,0x01);
if ((iRet=transactModbusTCP(self->controller,pCommand,6,pReply,79))<=0) if ((iRet=transactModbusTCP(self->controller,pCommand,6,pReply,79))<=0)
return iRet; return iRet;
if(pReply[3] != 0x0) if(pReply[3] != 0x0)
{ {
printf("Warning: Alarm 1 Activated\n"); printf("Warning: Alarm 1 Activated\n");
strcpy(self->pAns,pReply); strcpy(self->pAns,pReply);
return 1; return 1;
}else printf("OK\n"); }else printf("OK\n");
// Check Alarm 2 // Check Alarm 2
printf("%-9s %-23s","Checking:", "Status Alarm 2........"); printf("%-9s %-23s","Checking:", "Status Alarm 2........");
sprintf(pCommand,"%c%c%c%c%c%c",self->iAdr,0x01,0x00,0x06,0x00,0x01); sprintf(pCommand,"%c%c%c%c%c%c",self->iAdr,0x01,0x00,0x06,0x00,0x01);
if ((iRet=transactModbusTCP(self->controller,pCommand,6,pReply,79))<=0) if ((iRet=transactModbusTCP(self->controller,pCommand,6,pReply,79))<=0)
return iRet; return iRet;
if(pReply[3]!=0x0) if(pReply[3]!=0x0)
{ {
printf("Warning: Alarm 2 Activated\n"); printf("Warning: Alarm 2 Activated\n");
strcpy(self->pAns,pReply); strcpy(self->pAns,pReply);
return 1; return 1;
}else{ }else{
printf("OK\n"); printf("OK\n");
return 1; return 1;
} }
@ -97,34 +97,34 @@
printf("Bad response received!\n"); printf("Bad response received!\n");
return WEST4100__BADREAD; return WEST4100__BADREAD;
} }
/* -------------------------------------------------------------------------*/ /* -------------------------------------------------------------------------*/
int WEST4100_ConfigureAndQueryGen(pWEST4100 self, char *command, int fParAdr, float fVal, char *diagnosis) int WEST4100_ConfigureAndQueryGen(pWEST4100 self, char *command, int fParAdr, float fVal, char *diagnosis)
{ {
int iRet; int iRet;
unsigned char pCommandSet[79], pCommandCheck[79]; unsigned char pCommandSet[79], pCommandCheck[79];
unsigned char pReply[79]; unsigned char pReply[79];
unsigned char fParAdrHex[2],fValHex[2]; unsigned char fParAdrHex[2],fValHex[2];
// Convert int to hexstring // Convert int to hexstring
if((iRet=(int2hexstring((int)fParAdr,fParAdrHex)))==0) if((iRet=(int2hexstring((int)fParAdr,fParAdrHex)))==0)
return iRet; return iRet;
if((iRet=(int2hexstring((int)fVal,fValHex)))==0) if((iRet=(int2hexstring((int)fVal,fValHex)))==0)
return iRet; return iRet;
/* Construct a write command. */ /* Construct a write command. */
printf("%-9s %-23s","Setting: ",command); printf("%-9s %-23s","Setting: ",command);
sprintf(pCommandSet,"%c%c%c%c%c%c",self->iAdr,0x06, sprintf(pCommandSet,"%c%c%c%c%c%c",self->iAdr,0x06,
fParAdrHex[0],fParAdrHex[1],fValHex[0],fValHex[1]); fParAdrHex[0],fParAdrHex[1],fValHex[0],fValHex[1]);
/* Issue a write command. */ /* Issue a write command. */
if((iRet=transactModbusTCP(self->controller,pCommandSet,/*strlen(pCommand)*/6,pReply,79))!=1) if((iRet=transactModbusTCP(self->controller,pCommandSet,/*strlen(pCommand)*/6,pReply,79))!=1)
return iRet; return iRet;
printf("OK\n"); printf("OK\n");
/* Construct a read command to check that the paramater was set.*/ /* Construct a read command to check that the paramater was set.*/
printf("%-9s %-23s","Checking:",command); printf("%-9s %-23s","Checking:",command);
sprintf(pCommandCheck,"%c%c%c%c%c%c",self->iAdr,04,fParAdrHex[0],fParAdrHex[1],0x00,0x1); sprintf(pCommandCheck,"%c%c%c%c%c%c",self->iAdr,04,fParAdrHex[0],fParAdrHex[1],0x00,0x1);
/* Issue a read command .*/ /* Issue a read command .*/
if ((iRet=transactModbusTCP(self->controller,pCommandCheck,6,pReply,79))<=0) if ((iRet=transactModbusTCP(self->controller,pCommandCheck,6,pReply,79))<=0)
{ {
@ -132,7 +132,7 @@
printf("DEBUG: pReply='%s' len=%d \n",pReply,strlen(pReply)); printf("DEBUG: pReply='%s' len=%d \n",pReply,strlen(pReply));
return iRet; return iRet;
} }
// Check that the read data is the same as that was set // Check that the read data is the same as that was set
if ( (pCommandSet[4]!=pReply[3]) || (pCommandSet[5]!=pReply[4]) ) if ( (pCommandSet[4]!=pReply[3]) || (pCommandSet[5]!=pReply[4]) )
{ {
@ -146,25 +146,25 @@
printf("OK\n"); printf("OK\n");
return 1; return 1;
} }
/* -------------------------------------------------------------------------*/ /* -------------------------------------------------------------------------*/
int WEST4100_SetControl(pWEST4100 self, int iControl) int WEST4100_SetControl(pWEST4100 self, int iControl)
{ {
// Left over from lakeshore code, West only has 1 sensor to choose from. // Left over from lakeshore code, West only has 1 sensor to choose from.
return 1; return 1;
} }
/* -------------------------------------------------------------------------*/ /* -------------------------------------------------------------------------*/
int WEST4100_Setup(pWEST4100 self) int WEST4100_Setup(pWEST4100 self)
{ {
int iRet; int iRet;
unsigned char pCommand[40]; unsigned char pCommand[40];
unsigned char pReply[132]; unsigned char pReply[132];
//int fVal = 999999.; //int fVal = 999999.;
/* Check the WEST4100 status */ /* Check the WEST4100 status */
if ((iRet=WEST4100_Check_Status(self))!=1) if ((iRet=WEST4100_Check_Status(self))!=1)
return iRet; return iRet;
// Check the write status // Check the write status
printf("%-9s %-23s","Checking:", "Write Status.........."); printf("%-9s %-23s","Checking:", "Write Status..........");
sprintf(pCommand,"%c%c%c%c%c%c",self->iAdr,0x01,0x00,0x01,0x00,0x01); sprintf(pCommand,"%c%c%c%c%c%c",self->iAdr,0x01,0x00,0x01,0x00,0x01);
@ -179,15 +179,15 @@
}else if (pReply[3] == 0x00) }else if (pReply[3] == 0x00)
{ {
printf("Status is Write Disabled.\n"); printf("Status is Write Disabled.\n");
return WEST4100__READONLY; return WEST4100__READONLY;
} }
/* Check that the controller is a gen-new-wine WEST4100 */ /* Check that the controller is a gen-new-wine WEST4100 */
printf("%-9s %-23s","Checking:", "ID...................."); printf("%-9s %-23s","Checking:", "ID....................");
sprintf(pCommand,"%c%c%c%c%c%c",self->iAdr,0x03,0x00,122,0x00,0x01); sprintf(pCommand,"%c%c%c%c%c%c",self->iAdr,0x03,0x00,122,0x00,0x01);
if((iRet=transactModbusTCP(self->controller,pCommand,/*strlen*/6,pReply,79))!=1) if((iRet=transactModbusTCP(self->controller,pCommand,/*strlen*/6,pReply,79))!=1)
return iRet; return iRet;
if ((pReply[3]!=0x17) || (pReply[4]!=0xd4)) if ((pReply[3]!=0x17) || (pReply[4]!=0xd4))
{ {
printf("Error: Incorrect ID\n"); printf("Error: Incorrect ID\n");
@ -197,40 +197,40 @@
else printf("OK\n"); else printf("OK\n");
// Set Output Limit // Set Output Limit
if((iRet=WEST4100_ConfigureAndQueryGen(self,"Output Power to 40%..",20,40,""))!=1) if((iRet=WEST4100_ConfigureAndQueryGen(self,"Output Power to 40%..",20,40,""))!=1)
return iRet; return iRet;
// Set Alarm1 Limit // Set Alarm1 Limit
if((iRet=WEST4100_ConfigureAndQueryGen(self,"Alarm1 to 1600........",13,1600,""))!=1) if((iRet=WEST4100_ConfigureAndQueryGen(self,"Alarm1 to 1600........",13,1600,""))!=1)
return iRet; return iRet;
// Set Alarm2 Limit // Set Alarm2 Limit
if((iRet=WEST4100_ConfigureAndQueryGen(self,"Alarm2 to 0...........",14,0,""))!=1) if((iRet=WEST4100_ConfigureAndQueryGen(self,"Alarm2 to 0...........",14,0,""))!=1)
return iRet; return iRet;
// Set Upper Limit // Set Upper Limit
if((iRet=WEST4100_ConfigureAndQueryGen(self,"Upper Limit to 1800...",22,1800,""))!=1) if((iRet=WEST4100_ConfigureAndQueryGen(self,"Upper Limit to 1800...",22,1800,""))!=1)
return iRet; return iRet;
// Set Lower Limit // Set Lower Limit
if((iRet=WEST4100_ConfigureAndQueryGen(self,"Lower Limit to 0......",23,0,""))!=1) if((iRet=WEST4100_ConfigureAndQueryGen(self,"Lower Limit to 0......",23,0,""))!=1)
return iRet; return iRet;
// Set Ramp Rate // Set Ramp Rate
if((iRet=WEST4100_ConfigureAndQueryGen(self,"Ramp Rate to 0ff......",24,10000,""))!=1) if((iRet=WEST4100_ConfigureAndQueryGen(self,"Ramp Rate to 0ff......",24,10000,""))!=1)
return iRet; return iRet;
/* Check the WEST4100 operating status one last time */ /* Check the WEST4100 operating status one last time */
if ((iRet=WEST4100_Check_Status(self))!=1) if ((iRet=WEST4100_Check_Status(self))!=1)
return iRet; return iRet;
return 1; /* Success */ return 1; /* Success */
} }
/* -------------------------------------------------------------------------*/ /* -------------------------------------------------------------------------*/
int WEST4100_Open(pWEST4100 *pData, char *pRS232, int iAddress, int iTransaction) int WEST4100_Open(pWEST4100 *pData, char *pRS232, int iAddress, int iTransaction)
{ {
pWEST4100 self = NULL; pWEST4100 self = NULL;
self = (pWEST4100)malloc(sizeof(WEST4100)); self = (pWEST4100)malloc(sizeof(WEST4100));
if(self == NULL) if(self == NULL)
{ {
@ -241,7 +241,7 @@
self->iTransact = iTransaction; self->iTransact = iTransaction;
self->controller = NULL; self->controller = NULL;
self->controller = (prs232)FindCommandData(pServ->pSics,pRS232, self->controller = (prs232)FindCommandData(pServ->pSics,pRS232,
"RS232 Controller"); "RS232 Controller");
if(!self->controller){ if(!self->controller){
@ -250,27 +250,27 @@
} }
return WEST4100_Setup(self); return WEST4100_Setup(self);
} }
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
void WEST4100_Close(pWEST4100 *pData) void WEST4100_Close(pWEST4100 *pData)
{ {
pWEST4100 self; pWEST4100 self;
self = *pData; self = *pData;
if (!self) if (!self)
return; // Just in case return; // Just in case
return; return;
} }
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
int WEST4100_Config(pWEST4100 *pData, int iTmo, int iRead, int iControl) int WEST4100_Config(pWEST4100 *pData, int iTmo, int iRead, int iControl)
{ {
pWEST4100 self; pWEST4100 self;
self = *pData; self = *pData;
return 1; return 1;
} }
/* --------------------------------------------------------------------------*/ /* --------------------------------------------------------------------------*/
int WEST4100_Send(pWEST4100 *pData, char *pCommand, char *pReply, int iLen) int WEST4100_Send(pWEST4100 *pData, char *pCommand, char *pReply, int iLen)
{ {
@ -278,12 +278,12 @@
pWEST4100 self; pWEST4100 self;
self = *pData; self = *pData;
char *ptr = pCommand; char *ptr = pCommand;
unsigned int byte; unsigned int byte;
unsigned char pCommandHex[79]; unsigned char pCommandHex[79];
size_t i; size_t i;
// Convert char string command to hex string with every two characters concatenated to one array field // Convert char string command to hex string with every two characters concatenated to one array field
for (i=0;i<sizeof pCommandHex ;++i) for (i=0;i<sizeof pCommandHex ;++i)
{ {
@ -294,23 +294,23 @@
pCommandHex[i]=byte; pCommandHex[i]=byte;
ptr +=2; ptr +=2;
} }
// Issue hex command // Issue hex command
printf("%s ","Issuing Send: "); printf("%s ","Issuing Send: ");
if((iRet=transactModbusTCP(self->controller,pCommandHex,6,pReply,79))!=1){ if((iRet=transactModbusTCP(self->controller,pCommandHex,6,pReply,79))!=1){
printf("%-s","Response: "); printf("%-s","Response: ");
displayHexString(pReply); displayHexString(pReply);
return iRet; return iRet;
} }
printf("OK\n"); printf("OK\n");
printf("%-s","Response: "); printf("%-s","Response: ");
displayHexString(pReply); displayHexString(pReply);
/* Check the WEST4100 operating status after issuing the command, if it was successful */ /* Check the WEST4100 operating status after issuing the command, if it was successful */
if (iRet>=1) if (iRet>=1)
iRet=WEST4100_Check_Status(self); iRet=WEST4100_Check_Status(self);
return iRet; return iRet;
} }
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
@ -322,7 +322,7 @@
pWEST4100 self; pWEST4100 self;
self = *pData; self = *pData;
sprintf(pCommand,"%c%c%c%c%c%c",self->iAdr,04,0x0,0x1,0x0,0x1); sprintf(pCommand,"%c%c%c%c%c%c",self->iAdr,04,0x0,0x1,0x0,0x1);
if ((iRet=transactModbusTCP(self->controller,pCommand,6,pReply,79))<=0) if ((iRet=transactModbusTCP(self->controller,pCommand,6,pReply,79))<=0)
{ {
@ -332,15 +332,15 @@
} }
// Because a value read will never be greater than FF FF we can use a simple line to convert // Because a value read will never be greater than FF FF we can use a simple line to convert
fRead=(256*pReply[3])+pReply[4]; fRead=(256*pReply[3])+pReply[4];
if(fRead > 65535 || fRead < 0) // Not a number, probably an error response if(fRead > 65535 || fRead < 0) // Not a number, probably an error response
{ {
return WEST4100__BADREAD; return WEST4100__BADREAD;
} }
*fVal = fRead; *fVal = fRead;
return 1; return 1;
} }
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
@ -351,7 +351,7 @@
pWEST4100 self; pWEST4100 self;
self = *pData; self = *pData;
int2hexstring(parAddress,pAddress); int2hexstring(parAddress,pAddress);
sprintf(pCommand,"%c%c%c%c%c%c",self->iAdr,0x4,pAddress[0],pAddress[1],0x0,0x1); sprintf(pCommand,"%c%c%c%c%c%c",self->iAdr,0x4,pAddress[0],pAddress[1],0x0,0x1);
if ((iRet=transactModbusTCP(self->controller,pCommand,6,pReply,79))<=0) if ((iRet=transactModbusTCP(self->controller,pCommand,6,pReply,79))<=0)
@ -362,13 +362,13 @@
} }
// Because a value read will never be greater than FF FF we can use a simple line to convert // Because a value read will never be greater than FF FF we can use a simple line to convert
*parValue=(256*pReply[3])+pReply[4]; *parValue=(256*pReply[3])+pReply[4];
if(*parValue > 65535 || *parValue < 0) // Not a number, probably an error response if(*parValue > 65535 || *parValue < 0) // Not a number, probably an error response
{ {
return WEST4100__BADREAD; return WEST4100__BADREAD;
} }
return 1; return 1;
} }
/* -------------------------------------------------------------------------*/ /* -------------------------------------------------------------------------*/
@ -379,14 +379,14 @@
pWEST4100 self; pWEST4100 self;
self = *pData; self = *pData;
sprintf(displaytext,"Parameter Number %d...",parAddress); sprintf(displaytext,"Parameter Number %d...",parAddress);
if((iRet=WEST4100_ConfigureAndQueryGen(self,displaytext,parAddress,parValue,""))!=1) if((iRet=WEST4100_ConfigureAndQueryGen(self,displaytext,parAddress,parValue,""))!=1)
return iRet; return iRet;
if ((iRet=WEST4100_Check_Status(self))!=1) if ((iRet=WEST4100_Check_Status(self))!=1)
return iRet; return iRet;
return 1; return 1;
} }
/* -------------------------------------------------------------------------*/ /* -------------------------------------------------------------------------*/
@ -396,16 +396,16 @@
pWEST4100 self; pWEST4100 self;
self = *pData; self = *pData;
for(i = 0; i < 3; i++) for(i = 0; i < 3; i++)
{ {
// Set setpoint // Set setpoint
if((iRet=WEST4100_ConfigureAndQueryGen(self,"Setpoint...",0x02,fVal,""))!=1) if((iRet=WEST4100_ConfigureAndQueryGen(self,"Setpoint...",0x02,fVal,""))!=1)
return iRet; return iRet;
printf("SETP OK, checking status and returning.\n"); printf("SETP OK, checking status and returning.\n");
iRet=WEST4100_Check_Status(self); iRet=WEST4100_Check_Status(self);
return iRet; return iRet;
} }
printf("SETP failed!\n"); printf("SETP failed!\n");
@ -418,7 +418,7 @@ void WEST4100_ErrorTxt(pWEST4100 *pData,int iCode, char *pError, int iLen)
pWEST4100 self; pWEST4100 self;
self = *pData; self = *pData;
switch(iCode) switch(iCode)
{ {
case WEST4100__BADCOM: case WEST4100__BADCOM:
@ -448,25 +448,25 @@ void WEST4100_ErrorTxt(pWEST4100 *pData,int iCode, char *pError, int iLen)
break; break;
default: default:
getRS232Error(iCode, pError,iLen); getRS232Error(iCode, pError,iLen);
break; break;
} }
} }
/* -------------------------------------------------------------------------*/ /* -------------------------------------------------------------------------*/
int int2hexstring(int fVal, unsigned char *hexstring) int int2hexstring(int fVal, unsigned char *hexstring)
{ {
size_t k; size_t k;
int fValInt; int fValInt;
unsigned char temp[79]; unsigned char temp[79];
int result,remainder,index,index2; int result,remainder,index,index2;
fValInt=fVal; fValInt=fVal;
if(fValInt>65535) if(fValInt>65535)
{ {
printf("Value greater than FF FF"); printf("Value greater than FF FF");
return 0; return 0;
} }
// Convert integer to hex and putting each char in an array // Convert integer to hex and putting each char in an array
memset(temp,0,sizeof(temp)); memset(temp,0,sizeof(temp));
result=1; result=1;
@ -477,15 +477,15 @@ int int2hexstring(int fVal, unsigned char *hexstring)
fValInt=result; fValInt=result;
temp[k]=remainder; temp[k]=remainder;
} }
// Formatting a new array so that there is one byte per array field // Formatting a new array so that there is one byte per array field
if((k%2)==0) if((k%2)==0)
index2=k/2-1; index2=k/2-1;
else else
index2=k/2; index2=k/2;
if(fVal>255) if(fVal>255)
{ {
for(index=0;index2>=0;(index=index+2),index2--) for(index=0;index2>=0;(index=index+2),index2--)
{ {
hexstring[index2]=(temp[index+1]*16)+temp[index]; hexstring[index2]=(temp[index+1]*16)+temp[index];
@ -493,15 +493,15 @@ int int2hexstring(int fVal, unsigned char *hexstring)
}else{ }else{
hexstring[0]=0x0; hexstring[0]=0x0;
hexstring[1]=(temp[1]*16)+temp[0]; hexstring[1]=(temp[1]*16)+temp[0];
} }
return 1; return 1;
} }
/* -------------------------------------------------------------------------*/ /* -------------------------------------------------------------------------*/
void displayHexString(unsigned char *hexstring) void displayHexString(unsigned char *hexstring)
{ {
int i; int i;
for(i=0;(i<5)|(hexstring[i]!='\0');i++)printf("%02x ",hexstring[i]); for(i=0;(i<5)|(hexstring[i]!='\0');i++)printf("%02x ",hexstring[i]);
printf("\n"); printf("\n");
} }

View File

@ -1,29 +1,29 @@
/*--------------------------------------------------------------------------- /*---------------------------------------------------------------------------
W E S T 4 1 0 0 W E S T 4 1 0 0
A few utility functions for talking to a Lakeshore 340 A few utility functions for talking to a Lakeshore 340
temperature controller via the SINQ setup: TCP/IP--MAC--RS-232-- temperature controller via the SINQ setup: TCP/IP--MAC--RS-232--
WEST4100. WEST4100.
Mark Koennecke, Juli 1997 Mark Koennecke, Juli 1997
Mark Lesha, January 2006 (based on ITC4 code) Mark Lesha, January 2006 (based on ITC4 code)
Paul Barron, January 2008 (Note: This is based on the old LAKESHORE340 code and Paul Barron, January 2008 (Note: This is based on the old LAKESHORE340 code and
not the new LS340 code written by Rodney Davies Feb 08) not the new LS340 code written by Rodney Davies Feb 08)
----------------------------------------------------------------------------*/ ----------------------------------------------------------------------------*/
#ifndef SINQWEST4100 #ifndef SINQWEST4100
#define SINQWEST4100 #define SINQWEST4100
/*----------------------- ERRORCODES-------------------------------------- /*----------------------- ERRORCODES--------------------------------------
Most functions return a negative error code on failure. Error codes Most functions return a negative error code on failure. Error codes
defined are those defined for serialsinq plus a few additional ones: defined are those defined for serialsinq plus a few additional ones:
*/ */
#define WEST4100__BADCOM -501 #define WEST4100__BADCOM -501
/* command not recognized */ /* command not recognized */
#define WEST4100__BADPAR -502 #define WEST4100__BADPAR -502
/* bad parameter to command */ /* bad parameter to command */
#define WEST4100__BADMALLOC -503 #define WEST4100__BADMALLOC -503
/* error allocating memory */ /* error allocating memory */
#define WEST4100__BADREAD -504 #define WEST4100__BADREAD -504
/* error analysing command string on Read */ /* error analysing command string on Read */
@ -41,7 +41,7 @@
void *pData; void *pData;
char pAns[80]; char pAns[80];
prs232 controller; prs232 controller;
} WEST4100; } WEST4100;
typedef struct __WEST4100 *pWEST4100; typedef struct __WEST4100 *pWEST4100;
@ -57,49 +57,49 @@
Return values are 1 for success, a negative error code on Return values are 1 for success, a negative error code on
failure. failure.
*/ */
void WEST4100_Close(pWEST4100 *pData); void WEST4100_Close(pWEST4100 *pData);
/****** close a connection to an WEST4100controller and frees its /****** close a connection to an WEST4100controller and frees its
data structure. The only parameter is a pointer to the data data structure. The only parameter is a pointer to the data
structure for this controller. This pointer will be invalid after structure for this controller. This pointer will be invalid after
this call. this call.
*/ */
int WEST4100_Config(pWEST4100 *pData, int iTmo, int iRead, int WEST4100_Config(pWEST4100 *pData, int iTmo, int iRead,
int iControl); int iControl);
/***** configure some aspects of a WEST4100temperature controller. /***** configure some aspects of a WEST4100temperature controller.
The parameter are: The parameter are:
- a pointer to the data structure for the controller as - a pointer to the data structure for the controller as
returned by WEST4100_Open returned by WEST4100_Open
- a value for the connection timeout - a value for the connection timeout
- the temperature sensor to use for reading the - the temperature sensor to use for reading the
temperature. temperature.
- the temperature sensor used by the WEST4100controller - the temperature sensor used by the WEST4100controller
for regulating the temperature. for regulating the temperature.
- the divisor needed to calculate the real temperature - the divisor needed to calculate the real temperature
from the sensor. from the sensor.
The function returns 1 on success, a negative error code on The function returns 1 on success, a negative error code on
failure. failure.
*/ */
int WEST4100_Send(pWEST4100 *pData, char *pCommand, char *pReply, int iLen); int WEST4100_Send(pWEST4100 *pData, char *pCommand, char *pReply, int iLen);
/******* send a the command in pCommand to the WEST4100controller. /******* send a the command in pCommand to the WEST4100controller.
A possible reply is returned in the buffer pReply. A possible reply is returned in the buffer pReply.
Maximum iLen characters are copied to pReply. Maximum iLen characters are copied to pReply.
The first parameter is a pointer to a WEST4100data structure The first parameter is a pointer to a WEST4100data structure
as returned by WEST4100_Open. as returned by WEST4100_Open.
Return values are 1 for success, a negative error code on Return values are 1 for success, a negative error code on
failure. failure.
*/ */
int WEST4100_Read(pWEST4100 *pData, float *fVal); int WEST4100_Read(pWEST4100 *pData, float *fVal);
/******* reads the current actual temperature of the sensor /******* reads the current actual temperature of the sensor
configured by ConfigWEST4100for reading. The value is returned configured by ConfigWEST4100for reading. The value is returned
in fVal. The first parameter is a pointer to a WEST4100 in fVal. The first parameter is a pointer to a WEST4100
data structure as returned by WEST4100_Open. data structure as returned by WEST4100_Open.
Return values are 1 for success, a negative error code on Return values are 1 for success, a negative error code on
failure. failure.
*/ */
@ -113,18 +113,18 @@
Return values are 1 for success, a negative error code on Return values are 1 for success, a negative error code on
failure.pEVInterface failure.pEVInterface
*/ */
void WEST4100_ErrorTxt(pWEST4100 *pData, int iCode, char *pError, int iLen); void WEST4100_ErrorTxt(pWEST4100 *pData, int iCode, char *pError, int iLen);
/******* translates one of the negative error WEST4100error codes /******* translates one of the negative error WEST4100error codes
into text. Maximum iLen bytes will be copied to the into text. Maximum iLen bytes will be copied to the
buffer pError; buffer pError;
*/ */
int WEST4100_Query(pWEST4100 *pData, int parAddress, int *parValue); int WEST4100_Query(pWEST4100 *pData, int parAddress, int *parValue);
int WEST4100_Write(pWEST4100 *pData, int parAddress, int parValue); int WEST4100_Write(pWEST4100 *pData, int parAddress, int parValue);
int int2hexstring(int fVal, unsigned char *hexstring); int int2hexstring(int fVal, unsigned char *hexstring);
void displayHexString(unsigned char *hexstring); void displayHexString(unsigned char *hexstring);
#endif
#endif

View File

@ -1,7 +1,7 @@
/*-------------------------------------------------------------------------- /*--------------------------------------------------------------------------
H M _ A S I M H M _ A S I M
The ANSTO simulated histogramming memory driver include file The ANSTO simulated histogramming memory driver include file
Paul Hathaway, September 2004 Paul Hathaway, September 2004

View File

@ -4,7 +4,7 @@
/*-------------------------------------------------------------------------- /*--------------------------------------------------------------------------
H M _ T A N G O H M _ T A N G O
Header file for the ANSTO histogramming memory driver interfacing Header file for the ANSTO histogramming memory driver interfacing
a TANGO server a TANGO server
Based on anstohm.h (Andy Gotz, February 2004) Based on anstohm.h (Andy Gotz, February 2004)

View File

@ -3,11 +3,11 @@
A module creating a slightly modified HMControl object suitable for the A module creating a slightly modified HMControl object suitable for the
ANSTO HM. This works exactly the same as the existing HMControl, but ANSTO HM. This works exactly the same as the existing HMControl, but
has extra options (e.g. pausing HM's at the end of a count instead of has extra options (e.g. pausing HM's at the end of a count instead of
stopping them). stopping them).
copyright: see copyright.h copyright: see copyright.h
Mark Lesha, October 2006 Mark Lesha, October 2006
-------------------------------------------------------------------------*/ -------------------------------------------------------------------------*/
@ -54,7 +54,7 @@ static int HMCStatus_ANSTO(void *pData, SConnection *pCon)
// to support pause-on-count-terminate option for ANSTO HM, // to support pause-on-count-terminate option for ANSTO HM,
// and termination either by counter or by HM. // and termination either by counter or by HM.
{ {
int status,i; int status,i;
pHMcontrol self = NULL; pHMcontrol self = NULL;
self = (pHMcontrol)pData; self = (pHMcontrol)pData;
@ -66,7 +66,7 @@ static int HMCStatus_ANSTO(void *pData, SConnection *pCon)
if(status == HWIdle || status == HWFault) if(status == HWIdle || status == HWFault)
{ {
/* /*
stop counting on slaves when finished or when an error stop counting on slaves when finished or when an error
occurred. occurred.
*/ */
InvokeCallBack(self->pCall,COUNTEND,pCon); InvokeCallBack(self->pCall,COUNTEND,pCon);
@ -87,7 +87,7 @@ static int HMCStatus_ANSTO(void *pData, SConnection *pCon)
*/ */
self->pCount->Pause(self,pCon); self->pCount->Pause(self,pCon);
releaseMCntrLocks(self->slaveData[0]); releaseMCntrLocks(self->slaveData[0]);
ReleaseCountLock(self->pCount); // Release hmc ReleaseCountLock(self->pCount); // Release hmc
} else } else
self->pCount->Halt(self); self->pCount->Halt(self);
} }
@ -107,7 +107,7 @@ static int HMCStatus_ANSTO(void *pData, SConnection *pCon)
} }
/*----------------------------------------------------------------------*/ /*----------------------------------------------------------------------*/
int HMControlAction_ANSTO(SConnection *pCon, SicsInterp *pSics, int HMControlAction_ANSTO(SConnection *pCon, SicsInterp *pSics,
void *pData, int argc, char *argv[]) void *pData, int argc, char *argv[])
// This function extends HMControlAction by looking for an optional fifth // This function extends HMControlAction by looking for an optional fifth
// and sixth command argument, which are stored to the expanded command data. // and sixth command argument, which are stored to the expanded command data.
@ -147,7 +147,7 @@ int HMControlAction_ANSTO(SConnection *pCon, SicsInterp *pSics,
} }
/*----------------------------------------------------------------------*/ /*----------------------------------------------------------------------*/
int MakeHMControl_ANSTO(SConnection *pCon, SicsInterp *pSics, int MakeHMControl_ANSTO(SConnection *pCon, SicsInterp *pSics,
void *pData, int argc, char *argv[]) void *pData, int argc, char *argv[])
{ {
/* Start by making a plain vanilla HMControl object, */ /* Start by making a plain vanilla HMControl object, */

View File

@ -3,18 +3,18 @@
A module creating a slightly modified HMControl object suitable for the A module creating a slightly modified HMControl object suitable for the
ANSTO HM. This works exactly the same as the existing HMControl, but ANSTO HM. This works exactly the same as the existing HMControl, but
has extra options (e.g. pausing HM's at the end of a count instead of has extra options (e.g. pausing HM's at the end of a count instead of
stopping them). stopping them).
copyright: see copyright.h copyright: see copyright.h
Mark Lesha, October 2006 Mark Lesha, October 2006
-------------------------------------------------------------------------*/ -------------------------------------------------------------------------*/
#ifndef HMCONTROL_ANSTO_H_ #ifndef HMCONTROL_ANSTO_H_
#define HMCONTROL_ANSTO_H_ #define HMCONTROL_ANSTO_H_
typedef struct typedef struct
{ {
/* Data of the original HMControl object */ /* Data of the original HMControl object */
HMcontrol hmc; HMcontrol hmc;
@ -23,7 +23,7 @@ typedef struct
int Termination_Object; int Termination_Object;
} HMcontrol_ANSTO, *pHMcontrol_ANSTO; } HMcontrol_ANSTO, *pHMcontrol_ANSTO;
int MakeHMControl_ANSTO(SConnection *pCon, SicsInterp *pSics, int MakeHMControl_ANSTO(SConnection *pCon, SicsInterp *pSics,
void *pData, int argc, char *argv[]); void *pData, int argc, char *argv[]);
#endif /*HMCONTROL_ANSTO_H_*/ #endif /*HMCONTROL_ANSTO_H_*/

View File

@ -1,11 +1,11 @@
/*--------------------------------------------------------------------------- /*---------------------------------------------------------------------------
I T C 4 I T C 4
This is the implementation for a ITC4 object derived from an more general This is the implementation for a ITC4 object derived from an more general
environment controller. environment controller.
Mark Koennecke, August 1997 Mark Koennecke, August 1997
Copyright: Copyright:
Labor fuer Neutronenstreuung Labor fuer Neutronenstreuung
@ -56,15 +56,15 @@
int ITC4SetPar(pEVControl self, char *name, float fNew, SConnection *pCon) int ITC4SetPar(pEVControl self, char *name, float fNew, SConnection *pCon)
{ {
int iRet; int iRet;
/* check authorsisation */ /* check authorsisation */
if(!SCMatchRights(pCon,usUser)) if(!SCMatchRights(pCon,usUser))
{ {
SCWrite(pCon,"ERROR: you are not authorised to change this parameter", SCWrite(pCon,"ERROR: you are not authorised to change this parameter",
eError); eError);
return 0; return 0;
} }
/* just catch those three names which we understand */ /* just catch those three names which we understand */
if(strcmp(name,"sensor") == 0) if(strcmp(name,"sensor") == 0)
{ {
@ -164,7 +164,7 @@
{ {
int iRet; int iRet;
float fDiv; float fDiv;
/* just catch those two names which we understand */ /* just catch those two names which we understand */
if(strcmp(name,"sensor") == 0) if(strcmp(name,"sensor") == 0)
{ {
@ -204,7 +204,7 @@
{ {
char pBueffel[132]; char pBueffel[132];
int iRet; int iRet;
iRet = EVCList(self,pCon); iRet = EVCList(self,pCon);
sprintf(pBueffel,"%s.sensor = %d\n",self->pName, sprintf(pBueffel,"%s.sensor = %d\n",self->pName,
GetSensorITC4(self->pDriv)); GetSensorITC4(self->pDriv));
@ -221,7 +221,7 @@
sprintf(pBueffel,"%s.multiplicator = %f\n",self->pName, sprintf(pBueffel,"%s.multiplicator = %f\n",self->pName,
GetMultITC4(self->pDriv)); GetMultITC4(self->pDriv));
SCWrite(pCon,pBueffel,eValue); SCWrite(pCon,pBueffel,eValue);
return iRet; return iRet;
} }
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
int ITC4Wrapper(SConnection *pCon, SicsInterp *pSics, void *pData, int ITC4Wrapper(SConnection *pCon, SicsInterp *pSics, void *pData,
@ -232,17 +232,17 @@
int iRet; int iRet;
double fNum; double fNum;
float fVal; float fVal;
self = (pEVControl)pData; self = (pEVControl)pData;
assert(self); assert(self);
assert(pCon); assert(pCon);
assert(pSics); assert(pSics);
if(argc < 2) if(argc < 2)
{ {
return EVControlWrapper(pCon,pSics,pData,argc,argv); return EVControlWrapper(pCon,pSics,pData,argc,argv);
} }
strtolower(argv[1]); strtolower(argv[1]);
if((strcmp(argv[1],"sensor") == 0) || (strcmp(argv[1],"control") == 0) || if((strcmp(argv[1],"sensor") == 0) || (strcmp(argv[1],"control") == 0) ||
(strcmp(argv[1],"timeout") == 0) || (strcmp(argv[1],"divisor") == 0) || (strcmp(argv[1],"timeout") == 0) || (strcmp(argv[1],"divisor") == 0) ||
@ -256,7 +256,7 @@
sprintf(pBueffel,"ERROR: expected number, got %s",argv[2]); sprintf(pBueffel,"ERROR: expected number, got %s",argv[2]);
SCWrite(pCon,pBueffel,eError); SCWrite(pCon,pBueffel,eError);
return 0; return 0;
} }
return ITC4SetPar(self,argv[1],(float)fNum,pCon); return ITC4SetPar(self,argv[1],(float)fNum,pCon);
} }
else /* get case */ else /* get case */
@ -269,7 +269,7 @@
} }
} }
else if(strcmp(argv[1],"list") == 0) else if(strcmp(argv[1],"list") == 0)
{ {
return ITCList(self,pCon); return ITCList(self,pCon);
} }
else else
@ -277,5 +277,5 @@
return EVControlWrapper(pCon,pSics,pData,argc,argv); return EVControlWrapper(pCon,pSics,pData,argc,argv);
} }
/* not reached */ /* not reached */
return 0; return 0;
} }

View File

@ -1,7 +1,7 @@
/*------------------------------------------------------------------------- /*-------------------------------------------------------------------------
ITC 4 ITC 4
Support for Oxford Instruments ITC4 Temperature controllers for SICS. Support for Oxford Instruments ITC4 Temperature controllers for SICS.
The meaning and working of the functions defined is as desribed for a The meaning and working of the functions defined is as desribed for a
general environment controller. general environment controller.
@ -33,11 +33,11 @@
int ITC4Wrapper(SConnection *pCon, SicsInterp *pSics, void *pData, int ITC4Wrapper(SConnection *pCon, SicsInterp *pSics, void *pData,
int argc, char *argv[]); int argc, char *argv[]);
int ITC4SetPar(pEVControl self, char *name, float fNew, int ITC4SetPar(pEVControl self, char *name, float fNew,
SConnection *pCon); SConnection *pCon);
int ITC4GetPar(pEVControl self, char *name, float *fVal); int ITC4GetPar(pEVControl self, char *name, float *fVal);
int ITCList(pEVControl self, SConnection *pCon); int ITCList(pEVControl self, SConnection *pCon);
#endif #endif

View File

@ -3,11 +3,11 @@ SINQ makes heavy use of Oxford Instruments ITC4 temperature controllers. In
order to support them the following software components had to be defined in order to support them the following software components had to be defined in
addition to the basic environmet controller interfaces: addition to the basic environmet controller interfaces:
\begin{itemize} \begin{itemize}
\item ITC4driver, naturally. \item ITC4driver, naturally.
\item A ITC4-controller object as derivation of environment controller. ITC4 \item A ITC4-controller object as derivation of environment controller. ITC4
's allow you to select a sensor which you read as your standard sensor and a 's allow you to select a sensor which you read as your standard sensor and a
sensor which is used for automatic control. The ITC4 controller object adds sensor which is used for automatic control. The ITC4 controller object adds
just that additional functionality to the statndard environment controller. just that additional functionality to the statndard environment controller.
\end{itemize} \end{itemize}
The additional data, the selection of sensors, will be kept in the driver. The additional data, the selection of sensors, will be kept in the driver.
This serves also an example for implementing inheritance without C++. This serves also an example for implementing inheritance without C++.
@ -30,13 +30,13 @@ The driver interface:
@} @}
The ConfigITC4 is special. It has to be called to commit changes to the The ConfigITC4 is special. It has to be called to commit changes to the
driver read and control parameters. driver read and control parameters.
The ITC4 object interface: The ITC4 object interface:
@d itco @{ @d itco @{
int ITC4Wrapper(SConnection *pCon, SicsInterp *pSics, void *pData, int ITC4Wrapper(SConnection *pCon, SicsInterp *pSics, void *pData,
int argc, char *argv[]); int argc, char *argv[]);
int ITC4SetPar(pEVControl self, char *name, float fNew, int ITC4SetPar(pEVControl self, char *name, float fNew,
SConnection *pCon); SConnection *pCon);
int ITC4GetPar(pEVControl self, char *name, float *fVal); int ITC4GetPar(pEVControl self, char *name, float *fVal);
int ITCList(pEVControl self, SConnection *pCon); int ITCList(pEVControl self, SConnection *pCon);
@ -52,7 +52,7 @@ functions described above are just needed to implement the extra parameters.
@o itc4.h @{ @o itc4.h @{
/*------------------------------------------------------------------------- /*-------------------------------------------------------------------------
ITC 4 ITC 4
Support for Oxford Instruments ITC4 Temperature controllers for SICS. Support for Oxford Instruments ITC4 Temperature controllers for SICS.
The meaning and working of the functions defined is as desribed for a The meaning and working of the functions defined is as desribed for a
general environment controller. general environment controller.
@ -69,6 +69,6 @@ functions described above are just needed to implement the extra parameters.
/*------------------------- The ITC4 object ------------------------------*/ /*------------------------- The ITC4 object ------------------------------*/
@<itco@> @<itco@>
#endif #endif
@} @}

View File

@ -1,10 +1,10 @@
/*-------------------------------------------------------------------------- /*--------------------------------------------------------------------------
I T C 4 D R I V I T C 4 D R I V
This file contains the implementation of a driver for the Oxford This file contains the implementation of a driver for the Oxford
Instruments ITC4 Temperature controller. Instruments ITC4 Temperature controller.
Mark Koennecke, Juli 1997 Mark Koennecke, Juli 1997
Copyright: Copyright:
@ -49,7 +49,7 @@
typedef struct __EVDriver *pEVDriver; typedef struct __EVDriver *pEVDriver;
#include <evdriver.i> #include <evdriver.i>
/* Do we need these ? /* Do we need these ?
#include <sics.h> #include <sics.h>
#include <modriv.h> #include <modriv.h>
@ -64,8 +64,8 @@
pEVDriver CreateITC4Driver(int argc, char *argv[]); pEVDriver CreateITC4Driver(int argc, char *argv[]);
int ConfigITC4(pEVDriver self); int ConfigITC4(pEVDriver self);
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
typedef struct { typedef struct {
pITC4 pData; pITC4 pData;
@ -84,12 +84,12 @@
{ {
pITC4Driv pMe = NULL; pITC4Driv pMe = NULL;
int iRet; int iRet;
assert(self); assert(self);
pMe = (pITC4Driv)self->pPrivate; pMe = (pITC4Driv)self->pPrivate;
assert(pMe); assert(pMe);
iRet = ITC4_Read(&pMe->pData,fPos); iRet = ITC4_Read(&pMe->pData,fPos);
if(iRet != 1 ) if(iRet != 1 )
{ {
pMe->iLastError = iRet; pMe->iLastError = iRet;
@ -102,13 +102,13 @@
return 0; return 0;
} }
return 1; return 1;
} }
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
static int ITC4Run(pEVDriver self, float fVal) static int ITC4Run(pEVDriver self, float fVal)
{ {
pITC4Driv pMe = NULL; pITC4Driv pMe = NULL;
int iRet; int iRet;
assert(self); assert(self);
pMe = (pITC4Driv )self->pPrivate; pMe = (pITC4Driv )self->pPrivate;
assert(pMe); assert(pMe);
@ -125,7 +125,7 @@
static int ITC4Error(pEVDriver self, int *iCode, char *error, int iErrLen) static int ITC4Error(pEVDriver self, int *iCode, char *error, int iErrLen)
{ {
pITC4Driv pMe = NULL; pITC4Driv pMe = NULL;
assert(self); assert(self);
pMe = (pITC4Driv)self->pPrivate; pMe = (pITC4Driv)self->pPrivate;
assert(pMe); assert(pMe);
@ -137,7 +137,7 @@
} }
else else
{ {
ITC4_ErrorTxt(&pMe->pData,pMe->iLastError,error,iErrLen); ITC4_ErrorTxt(&pMe->pData,pMe->iLastError,error,iErrLen);
} }
return 1; return 1;
} }
@ -146,7 +146,7 @@
{ {
pITC4Driv pMe = NULL; pITC4Driv pMe = NULL;
int iRet; int iRet;
assert(self); assert(self);
pMe = (pITC4Driv )self->pPrivate; pMe = (pITC4Driv )self->pPrivate;
assert(pMe); assert(pMe);
@ -159,13 +159,13 @@
} }
return 1; return 1;
} }
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
static int ITC4Init(pEVDriver self) static int ITC4Init(pEVDriver self)
{ {
pITC4Driv pMe = NULL; pITC4Driv pMe = NULL;
int iRet; int iRet;
assert(self); assert(self);
pMe = (pITC4Driv )self->pPrivate; pMe = (pITC4Driv )self->pPrivate;
assert(pMe); assert(pMe);
@ -182,29 +182,29 @@
{ {
pMe->iLastError = iRet; pMe->iLastError = iRet;
return 0; return 0;
} }
} }
return 1; return 1;
} }
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
static int ITC4Close(pEVDriver self) static int ITC4Close(pEVDriver self)
{ {
pITC4Driv pMe = NULL; pITC4Driv pMe = NULL;
int iRet; int iRet;
assert(self); assert(self);
pMe = (pITC4Driv )self->pPrivate; pMe = (pITC4Driv )self->pPrivate;
assert(pMe); assert(pMe);
ITC4_Close(&pMe->pData); ITC4_Close(&pMe->pData);
return 1; return 1;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static int ITC4Fix(pEVDriver self, int iError) static int ITC4Fix(pEVDriver self, int iError)
{ {
pITC4Driv pMe = NULL; pITC4Driv pMe = NULL;
int iRet; int iRet;
assert(self); assert(self);
pMe = (pITC4Driv )self->pPrivate; pMe = (pITC4Driv )self->pPrivate;
assert(pMe); assert(pMe);
@ -230,11 +230,11 @@
if(iRet) if(iRet)
{ {
return DEVREDO; return DEVREDO;
} }
else else
{ {
return DEVFAULT; return DEVFAULT;
} }
break; break;
/* handable protocoll errors */ /* handable protocoll errors */
case EL734__BAD_TMO: case EL734__BAD_TMO:
@ -243,47 +243,47 @@
case -501: /* Bad_COM */ case -501: /* Bad_COM */
return DEVREDO; return DEVREDO;
case -504: /* Badly formatted */ case -504: /* Badly formatted */
return DEVREDO; return DEVREDO;
default: default:
return DEVFAULT; return DEVFAULT;
break; break;
} }
return DEVFAULT; return DEVFAULT;
} }
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
static int ITC4Halt(pEVDriver *self) static int ITC4Halt(pEVDriver *self)
{ {
assert(self); assert(self);
return 1; return 1;
} }
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
void KillITC4(void *pData) void KillITC4(void *pData)
{ {
pITC4Driv pMe = NULL; pITC4Driv pMe = NULL;
pMe = (pITC4Driv)pData; pMe = (pITC4Driv)pData;
assert(pMe); assert(pMe);
if(pMe->pHost) if(pMe->pHost)
{ {
free(pMe->pHost); free(pMe->pHost);
} }
free(pMe); free(pMe);
} }
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
pEVDriver CreateITC4Driver(int argc, char *argv[]) pEVDriver CreateITC4Driver(int argc, char *argv[])
{ {
pEVDriver pNew = NULL; pEVDriver pNew = NULL;
pITC4Driv pSim = NULL; pITC4Driv pSim = NULL;
/* check for arguments */ /* check for arguments */
if(argc < 3) if(argc < 3)
{ {
return NULL; return NULL;
} }
pNew = CreateEVDriver(argc,argv); pNew = CreateEVDriver(argc,argv);
pSim = (pITC4Driv)malloc(sizeof(ITC4Driv)); pSim = (pITC4Driv)malloc(sizeof(ITC4Driv));
memset(pSim,0,sizeof(ITC4Driv)); memset(pSim,0,sizeof(ITC4Driv));
@ -293,7 +293,7 @@
} }
pNew->pPrivate = pSim; pNew->pPrivate = pSim;
pNew->KillPrivate = KillITC4; pNew->KillPrivate = KillITC4;
/* initalise pITC4Driver */ /* initalise pITC4Driver */
pSim->iControl = atoi(argv[2]); pSim->iControl = atoi(argv[2]);
pSim->iRead = atoi(argv[1]); pSim->iRead = atoi(argv[1]);
@ -304,8 +304,8 @@
pSim->pHost = strdup(argv[0]); pSim->pHost = strdup(argv[0]);
pSim->iPort = 0; pSim->iPort = 0;
pSim->iChannel = 0; pSim->iChannel = 0;
/* initialise function pointers */ /* initialise function pointers */
pNew->SetValue = ITC4Run; pNew->SetValue = ITC4Run;
pNew->GetValue = GetITC4Pos; pNew->GetValue = GetITC4Pos;
@ -314,20 +314,20 @@
pNew->TryFixIt = ITC4Fix; pNew->TryFixIt = ITC4Fix;
pNew->Init = ITC4Init; pNew->Init = ITC4Init;
pNew->Close = ITC4Close; pNew->Close = ITC4Close;
return pNew; return pNew;
} }
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
int ConfigITC4(pEVDriver self) int ConfigITC4(pEVDriver self)
{ {
pITC4Driv pMe = NULL; pITC4Driv pMe = NULL;
int iRet; int iRet;
assert(self); assert(self);
pMe = (pITC4Driv )self->pPrivate; pMe = (pITC4Driv )self->pPrivate;
assert(pMe); assert(pMe);
iRet = ITC4_Config(&pMe->pData, pMe->iTmo, pMe->iRead, iRet = ITC4_Config(&pMe->pData, pMe->iTmo, pMe->iRead,
pMe->iControl,pMe->fDiv,pMe->fMult); pMe->iControl,pMe->fDiv,pMe->fMult);
if(iRet < 0) if(iRet < 0)
{ {
@ -341,7 +341,7 @@
{ {
pITC4Driv pMe = NULL; pITC4Driv pMe = NULL;
int iRet; int iRet;
assert(self); assert(self);
pMe = (pITC4Driv )self->pPrivate; pMe = (pITC4Driv )self->pPrivate;
assert(pMe); assert(pMe);
@ -349,7 +349,7 @@
if( (iSensor < 1) || (iSensor > 4) ) if( (iSensor < 1) || (iSensor > 4) )
{ {
return 0; return 0;
} }
pMe->iRead = iSensor; pMe->iRead = iSensor;
pMe->pData->iRead = iSensor; pMe->pData->iRead = iSensor;
return 1; return 1;
@ -359,7 +359,7 @@
{ {
pITC4Driv pMe = NULL; pITC4Driv pMe = NULL;
int iRet; int iRet;
assert(self); assert(self);
pMe = (pITC4Driv )self->pPrivate; pMe = (pITC4Driv )self->pPrivate;
assert(pMe); assert(pMe);
@ -367,7 +367,7 @@
if( (iSensor < 1) || (iSensor > 4) ) if( (iSensor < 1) || (iSensor > 4) )
{ {
return 0; return 0;
} }
pMe->iControl = iSensor; pMe->iControl = iSensor;
pMe->pData->iControl = iSensor; pMe->pData->iControl = iSensor;
return 1; return 1;
@ -377,7 +377,7 @@
{ {
pITC4Driv pMe = NULL; pITC4Driv pMe = NULL;
int iRet; int iRet;
assert(self); assert(self);
pMe = (pITC4Driv )self->pPrivate; pMe = (pITC4Driv )self->pPrivate;
assert(pMe); assert(pMe);
@ -385,7 +385,7 @@
if(iSensor < 10) if(iSensor < 10)
{ {
return 0; return 0;
} }
pMe->iTmo = iSensor; pMe->iTmo = iSensor;
return 1; return 1;
} }
@ -394,7 +394,7 @@
{ {
pITC4Driv pMe = NULL; pITC4Driv pMe = NULL;
int iRet; int iRet;
assert(self); assert(self);
pMe = (pITC4Driv )self->pPrivate; pMe = (pITC4Driv )self->pPrivate;
assert(pMe); assert(pMe);
@ -406,7 +406,7 @@
{ {
pITC4Driv pMe = NULL; pITC4Driv pMe = NULL;
int iRet; int iRet;
assert(self); assert(self);
pMe = (pITC4Driv )self->pPrivate; pMe = (pITC4Driv )self->pPrivate;
assert(pMe); assert(pMe);
@ -418,7 +418,7 @@
{ {
pITC4Driv pMe = NULL; pITC4Driv pMe = NULL;
int iRet; int iRet;
assert(self); assert(self);
pMe = (pITC4Driv )self->pPrivate; pMe = (pITC4Driv )self->pPrivate;
assert(pMe); assert(pMe);
@ -430,7 +430,7 @@
{ {
pITC4Driv pMe = NULL; pITC4Driv pMe = NULL;
int iRet; int iRet;
assert(self); assert(self);
pMe = (pITC4Driv )self->pPrivate; pMe = (pITC4Driv )self->pPrivate;
assert(pMe); assert(pMe);
@ -442,7 +442,7 @@
{ {
pITC4Driv pMe = NULL; pITC4Driv pMe = NULL;
int iRet; int iRet;
assert(self); assert(self);
pMe = (pITC4Driv )self->pPrivate; pMe = (pITC4Driv )self->pPrivate;
assert(pMe); assert(pMe);
@ -455,7 +455,7 @@
{ {
pITC4Driv pMe = NULL; pITC4Driv pMe = NULL;
int iRet; int iRet;
assert(self); assert(self);
pMe = (pITC4Driv )self->pPrivate; pMe = (pITC4Driv )self->pPrivate;
assert(pMe); assert(pMe);
@ -467,7 +467,7 @@
{ {
pITC4Driv pMe = NULL; pITC4Driv pMe = NULL;
int iRet; int iRet;
assert(self); assert(self);
pMe = (pITC4Driv )self->pPrivate; pMe = (pITC4Driv )self->pPrivate;
assert(pMe); assert(pMe);
@ -475,4 +475,4 @@
pMe->fMult = fDiv; pMe->fMult = fDiv;
return 1; return 1;
} }

View File

@ -1,12 +1,12 @@
/*--------------------------------------------------------------------------- /*---------------------------------------------------------------------------
L A K E S H O R E 3 4 0 L A K E S H O R E 3 4 0
This is the implementation for a LAKESHORE340 object derived from a more general This is the implementation for a LAKESHORE340 object derived from a more general
environment controller. environment controller.
Mark Koennecke, August 1997 Mark Koennecke, August 1997
Mark Lesha, January 2006 (based on ITC4 code) Mark Lesha, January 2006 (based on ITC4 code)
Copyright: Copyright:
Labor fuer Neutronenstreuung Labor fuer Neutronenstreuung
@ -57,15 +57,15 @@
int LAKESHORE340SetPar(pEVControl self, char *name, float fNew, SConnection *pCon) int LAKESHORE340SetPar(pEVControl self, char *name, float fNew, SConnection *pCon)
{ {
int iRet; int iRet;
/* check authorisation */ /* check authorisation */
if(!SCMatchRights(pCon,usUser)) if(!SCMatchRights(pCon,usUser))
{ {
SCWrite(pCon,"ERROR: you are not authorised to change this parameter", SCWrite(pCon,"ERROR: you are not authorised to change this parameter",
eError); eError);
return 0; return 0;
} }
/* just catch those three names which we understand */ /* just catch those three names which we understand */
if(strcmp(name,"sensor") == 0) if(strcmp(name,"sensor") == 0)
{ {
@ -167,7 +167,7 @@
{ {
int iRet; int iRet;
float fDiv; float fDiv;
/* just catch those two names which we understand */ /* just catch those two names which we understand */
if(strcmp(name,"sensor") == 0) if(strcmp(name,"sensor") == 0)
{ {
@ -207,7 +207,7 @@
{ {
char pBueffel[132]; char pBueffel[132];
int iRet; int iRet;
iRet = EVCList(self,pCon); iRet = EVCList(self,pCon);
sprintf(pBueffel,"%s.sensor = %d\n",self->pName, sprintf(pBueffel,"%s.sensor = %d\n",self->pName,
GetSensorLAKESHORE340(self->pDriv)); GetSensorLAKESHORE340(self->pDriv));
@ -224,7 +224,7 @@
sprintf(pBueffel,"%s.multiplicator = %f\n",self->pName, sprintf(pBueffel,"%s.multiplicator = %f\n",self->pName,
GetMultLAKESHORE340(self->pDriv)); GetMultLAKESHORE340(self->pDriv));
SCWrite(pCon,pBueffel,eValue); SCWrite(pCon,pBueffel,eValue);
return iRet; return iRet;
} }
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
int LAKESHORE340Wrapper(SConnection *pCon, SicsInterp *pSics, void *pData, int LAKESHORE340Wrapper(SConnection *pCon, SicsInterp *pSics, void *pData,
@ -235,17 +235,17 @@
int iRet; int iRet;
double fNum; double fNum;
float fVal; float fVal;
self = (pEVControl)pData; self = (pEVControl)pData;
assert(self); assert(self);
assert(pCon); assert(pCon);
assert(pSics); assert(pSics);
if(argc < 2) if(argc < 2)
{ {
return EVControlWrapper(pCon,pSics,pData,argc,argv); return EVControlWrapper(pCon,pSics,pData,argc,argv);
} }
strtolower(argv[1]); strtolower(argv[1]);
if((strcmp(argv[1],"sensor") == 0) || (strcmp(argv[1],"control") == 0) || if((strcmp(argv[1],"sensor") == 0) || (strcmp(argv[1],"control") == 0) ||
(strcmp(argv[1],"timeout") == 0) || (strcmp(argv[1],"divisor") == 0) || (strcmp(argv[1],"timeout") == 0) || (strcmp(argv[1],"divisor") == 0) ||
@ -259,7 +259,7 @@
sprintf(pBueffel,"ERROR: expected number, got %s",argv[2]); sprintf(pBueffel,"ERROR: expected number, got %s",argv[2]);
SCWrite(pCon,pBueffel,eError); SCWrite(pCon,pBueffel,eError);
return 0; return 0;
} }
return LAKESHORE340SetPar(self,argv[1],(float)fNum,pCon); return LAKESHORE340SetPar(self,argv[1],(float)fNum,pCon);
} }
else /* get case */ else /* get case */
@ -272,7 +272,7 @@
} }
} }
else if(strcmp(argv[1],"list") == 0) else if(strcmp(argv[1],"list") == 0)
{ {
return LAKESHORE340List(self,pCon); return LAKESHORE340List(self,pCon);
} }
else else
@ -280,5 +280,5 @@
return EVControlWrapper(pCon,pSics,pData,argc,argv); return EVControlWrapper(pCon,pSics,pData,argc,argv);
} }
/* not reached */ /* not reached */
return 0; return 0;
} }

View File

@ -1,7 +1,7 @@
/*------------------------------------------------------------------------- /*-------------------------------------------------------------------------
LAKESHORE 340 LAKESHORE 340
Support for Lakeshore 340 Temperature controllers for SICS. Support for Lakeshore 340 Temperature controllers for SICS.
The meaning and working of the functions defined is as desribed for a The meaning and working of the functions defined is as desribed for a
general environment controller. general environment controller.
@ -39,11 +39,11 @@
int LAKESHORE340Wrapper(SConnection *pCon, SicsInterp *pSics, void *pData, int LAKESHORE340Wrapper(SConnection *pCon, SicsInterp *pSics, void *pData,
int argc, char *argv[]); int argc, char *argv[]);
int LAKESHORE340SetPar(pEVControl self, char *name, float fNew, int LAKESHORE340SetPar(pEVControl self, char *name, float fNew,
SConnection *pCon); SConnection *pCon);
int LAKESHORE340GetPar(pEVControl self, char *name, float *fVal); int LAKESHORE340GetPar(pEVControl self, char *name, float *fVal);
int LAKESHORE340List(pEVControl self, SConnection *pCon); int LAKESHORE340List(pEVControl self, SConnection *pCon);
#endif #endif

View File

@ -1,12 +1,12 @@
/*--------------------------------------------------------------------------- /*---------------------------------------------------------------------------
L H 4 5 L H 4 5
This is the implementation for a LH45 object derived from an more general This is the implementation for a LH45 object derived from an more general
environment controller. environment controller.
Mark Koennecke, August 1997 Mark Koennecke, August 1997
Mark Lesha, January 2006 (based on ITC4 code) Mark Lesha, January 2006 (based on ITC4 code)
Copyright: Copyright:
Labor fuer Neutronenstreuung Labor fuer Neutronenstreuung
@ -57,15 +57,15 @@
int LH45SetPar(pEVControl self, char *name, float fNew, SConnection *pCon) int LH45SetPar(pEVControl self, char *name, float fNew, SConnection *pCon)
{ {
int iRet; int iRet;
/* check authorsisation */ /* check authorsisation */
if(!SCMatchRights(pCon,usUser)) if(!SCMatchRights(pCon,usUser))
{ {
SCWrite(pCon,"ERROR: you are not authorised to change this parameter", SCWrite(pCon,"ERROR: you are not authorised to change this parameter",
eError); eError);
return 0; return 0;
} }
/* just catch those three names which we understand */ /* just catch those three names which we understand */
if(strcmp(name,"sensor") == 0) if(strcmp(name,"sensor") == 0)
{ {
@ -167,7 +167,7 @@
{ {
int iRet; int iRet;
float fDiv; float fDiv;
/* just catch those two names which we understand */ /* just catch those two names which we understand */
if(strcmp(name,"sensor") == 0) if(strcmp(name,"sensor") == 0)
{ {
@ -207,7 +207,7 @@
{ {
char pBueffel[132]; char pBueffel[132];
int iRet; int iRet;
iRet = EVCList(self,pCon); iRet = EVCList(self,pCon);
sprintf(pBueffel,"%s.sensor = %d\n",self->pName, sprintf(pBueffel,"%s.sensor = %d\n",self->pName,
GetSensorLH45(self->pDriv)); GetSensorLH45(self->pDriv));
@ -224,7 +224,7 @@
sprintf(pBueffel,"%s.multiplicator = %f\n",self->pName, sprintf(pBueffel,"%s.multiplicator = %f\n",self->pName,
GetMultLH45(self->pDriv)); GetMultLH45(self->pDriv));
SCWrite(pCon,pBueffel,eValue); SCWrite(pCon,pBueffel,eValue);
return iRet; return iRet;
} }
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
int LH45Wrapper(SConnection *pCon, SicsInterp *pSics, void *pData, int LH45Wrapper(SConnection *pCon, SicsInterp *pSics, void *pData,
@ -235,17 +235,17 @@
int iRet; int iRet;
double fNum; double fNum;
float fVal; float fVal;
self = (pEVControl)pData; self = (pEVControl)pData;
assert(self); assert(self);
assert(pCon); assert(pCon);
assert(pSics); assert(pSics);
if(argc < 2) if(argc < 2)
{ {
return EVControlWrapper(pCon,pSics,pData,argc,argv); return EVControlWrapper(pCon,pSics,pData,argc,argv);
} }
strtolower(argv[1]); strtolower(argv[1]);
if((strcmp(argv[1],"sensor") == 0) || (strcmp(argv[1],"control") == 0) || if((strcmp(argv[1],"sensor") == 0) || (strcmp(argv[1],"control") == 0) ||
(strcmp(argv[1],"timeout") == 0) || (strcmp(argv[1],"divisor") == 0) || (strcmp(argv[1],"timeout") == 0) || (strcmp(argv[1],"divisor") == 0) ||
@ -259,7 +259,7 @@
sprintf(pBueffel,"ERROR: expected number, got %s",argv[2]); sprintf(pBueffel,"ERROR: expected number, got %s",argv[2]);
SCWrite(pCon,pBueffel,eError); SCWrite(pCon,pBueffel,eError);
return 0; return 0;
} }
return LH45SetPar(self,argv[1],(float)fNum,pCon); return LH45SetPar(self,argv[1],(float)fNum,pCon);
} }
else /* get case */ else /* get case */
@ -272,7 +272,7 @@
} }
} }
else if(strcmp(argv[1],"list") == 0) else if(strcmp(argv[1],"list") == 0)
{ {
return LH45List(self,pCon); return LH45List(self,pCon);
} }
else else
@ -280,5 +280,5 @@
return EVControlWrapper(pCon,pSics,pData,argc,argv); return EVControlWrapper(pCon,pSics,pData,argc,argv);
} }
/* not reached */ /* not reached */
return 0; return 0;
} }

View File

@ -1,7 +1,7 @@
/*------------------------------------------------------------------------- /*-------------------------------------------------------------------------
LH 45 LH 45
Support for Julabo LH45 Temperature controllers for SICS. Support for Julabo LH45 Temperature controllers for SICS.
The meaning and working of the functions defined is as desribed for a The meaning and working of the functions defined is as desribed for a
general environment controller. general environment controller.
@ -39,11 +39,11 @@
int LH45Wrapper(SConnection *pCon, SicsInterp *pSics, void *pData, int LH45Wrapper(SConnection *pCon, SicsInterp *pSics, void *pData,
int argc, char *argv[]); int argc, char *argv[]);
int LH45SetPar(pEVControl self, char *name, float fNew, int LH45SetPar(pEVControl self, char *name, float fNew,
SConnection *pCon); SConnection *pCon);
int LH45GetPar(pEVControl self, char *name, float *fVal); int LH45GetPar(pEVControl self, char *name, float *fVal);
int LH45List(pEVControl self, SConnection *pCon); int LH45List(pEVControl self, SConnection *pCon);
#endif #endif

View File

@ -4,7 +4,7 @@
This file contains the implementation of a driver for the Julabo This file contains the implementation of a driver for the Julabo
LH45 Temperature controller. LH45 Temperature controller.
Mark Koennecke, Juli 1997 Mark Koennecke, Juli 1997
Mark Lesha, January 2006 (based on ITC4 code) Mark Lesha, January 2006 (based on ITC4 code)
@ -50,7 +50,7 @@
typedef struct __EVDriver *pEVDriver; typedef struct __EVDriver *pEVDriver;
#include <evdriver.i> #include <evdriver.i>
/* Do we need these ? /* Do we need these ?
#include <sics.h> #include <sics.h>
#include <modriv.h> #include <modriv.h>
@ -65,8 +65,8 @@
pEVDriver CreateLH45Driver(int argc, char *argv[]); pEVDriver CreateLH45Driver(int argc, char *argv[]);
int ConfigLH45(pEVDriver self); int ConfigLH45(pEVDriver self);
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
typedef struct { typedef struct {
pLH45 pData; pLH45 pData;
@ -85,12 +85,12 @@
{ {
pLH45Driv pMe = NULL; pLH45Driv pMe = NULL;
int iRet; int iRet;
assert(self); assert(self);
pMe = (pLH45Driv)self->pPrivate; pMe = (pLH45Driv)self->pPrivate;
assert(pMe); assert(pMe);
iRet = LH45_Read(&pMe->pData,fPos); iRet = LH45_Read(&pMe->pData,fPos);
if(iRet <= 0 ) if(iRet <= 0 )
{ {
pMe->iLastError = iRet; pMe->iLastError = iRet;
@ -103,13 +103,13 @@
return 0; return 0;
} }
return 1; return 1;
} }
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
static int LH45Run(pEVDriver self, float fVal) static int LH45Run(pEVDriver self, float fVal)
{ {
pLH45Driv pMe = NULL; pLH45Driv pMe = NULL;
int iRet; int iRet;
assert(self); assert(self);
pMe = (pLH45Driv )self->pPrivate; pMe = (pLH45Driv )self->pPrivate;
assert(pMe); assert(pMe);
@ -126,7 +126,7 @@
static int LH45Error(pEVDriver self, int *iCode, char *error, int iErrLen) static int LH45Error(pEVDriver self, int *iCode, char *error, int iErrLen)
{ {
pLH45Driv pMe = NULL; pLH45Driv pMe = NULL;
assert(self); assert(self);
pMe = (pLH45Driv)self->pPrivate; pMe = (pLH45Driv)self->pPrivate;
assert(pMe); assert(pMe);
@ -138,7 +138,7 @@
} }
else else
{ {
LH45_ErrorTxt(&pMe->pData,pMe->iLastError,error,iErrLen); LH45_ErrorTxt(&pMe->pData,pMe->iLastError,error,iErrLen);
} }
return 1; return 1;
} }
@ -147,7 +147,7 @@
{ {
pLH45Driv pMe = NULL; pLH45Driv pMe = NULL;
int iRet; int iRet;
assert(self); assert(self);
pMe = (pLH45Driv )self->pPrivate; pMe = (pLH45Driv )self->pPrivate;
assert(pMe); assert(pMe);
@ -160,13 +160,13 @@
} }
return 1; return 1;
} }
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
static int LH45Init(pEVDriver self) static int LH45Init(pEVDriver self)
{ {
pLH45Driv pMe = NULL; pLH45Driv pMe = NULL;
int iRet; int iRet;
assert(self); assert(self);
pMe = (pLH45Driv )self->pPrivate; pMe = (pLH45Driv )self->pPrivate;
assert(pMe); assert(pMe);
@ -183,28 +183,28 @@
{ {
pMe->iLastError = iRet; pMe->iLastError = iRet;
return 0; return 0;
} }
} }
return 1; return 1;
} }
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
static int LH45Close(pEVDriver self) static int LH45Close(pEVDriver self)
{ {
pLH45Driv pMe = NULL; pLH45Driv pMe = NULL;
assert(self); assert(self);
pMe = (pLH45Driv )self->pPrivate; pMe = (pLH45Driv )self->pPrivate;
assert(pMe); assert(pMe);
LH45_Close(&pMe->pData); LH45_Close(&pMe->pData);
return 1; return 1;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static int LH45Fix(pEVDriver self, int iError) static int LH45Fix(pEVDriver self, int iError)
{ {
pLH45Driv pMe = NULL; pLH45Driv pMe = NULL;
int iRet; int iRet;
assert(self); assert(self);
pMe = (pLH45Driv )self->pPrivate; pMe = (pLH45Driv )self->pPrivate;
assert(pMe); assert(pMe);
@ -230,11 +230,11 @@
if(iRet) if(iRet)
{ {
return DEVREDO; return DEVREDO;
} }
else else
{ {
return DEVFAULT; return DEVFAULT;
} }
break; break;
/* handable protocoll errors */ /* handable protocoll errors */
case EL734__BAD_TMO: case EL734__BAD_TMO:
@ -243,47 +243,47 @@
case -501: /* Bad_COM */ case -501: /* Bad_COM */
return DEVREDO; return DEVREDO;
case -504: /* Badly formatted */ case -504: /* Badly formatted */
return DEVREDO; return DEVREDO;
default: default:
return DEVFAULT; return DEVFAULT;
break; break;
} }
return DEVFAULT; return DEVFAULT;
} }
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
// static int LH45Halt(pEVDriver *self) // static int LH45Halt(pEVDriver *self)
// { // {
// assert(self); // assert(self);
// //
// return 1; // return 1;
// } // }
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
void KillLH45(void *pData) void KillLH45(void *pData)
{ {
pLH45Driv pMe = NULL; pLH45Driv pMe = NULL;
pMe = (pLH45Driv)pData; pMe = (pLH45Driv)pData;
assert(pMe); assert(pMe);
if(pMe->pHost) if(pMe->pHost)
{ {
free(pMe->pHost); free(pMe->pHost);
} }
free(pMe); free(pMe);
} }
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
pEVDriver CreateLH45Driver(int argc, char *argv[]) pEVDriver CreateLH45Driver(int argc, char *argv[])
{ {
pEVDriver pNew = NULL; pEVDriver pNew = NULL;
pLH45Driv pSim = NULL; pLH45Driv pSim = NULL;
/* check for arguments */ /* check for arguments */
if(argc < 3) if(argc < 3)
{ {
return NULL; return NULL;
} }
pNew = CreateEVDriver(argc,argv); pNew = CreateEVDriver(argc,argv);
pSim = (pLH45Driv)malloc(sizeof(LH45Driv)); pSim = (pLH45Driv)malloc(sizeof(LH45Driv));
memset(pSim,0,sizeof(LH45Driv)); memset(pSim,0,sizeof(LH45Driv));
@ -293,23 +293,23 @@
} }
pNew->pPrivate = pSim; pNew->pPrivate = pSim;
pNew->KillPrivate = KillLH45; pNew->KillPrivate = KillLH45;
/* initalise pLH45Driver */ /* initalise pLH45Driver */
pSim->iControl = atoi(argv[2]); pSim->iControl = atoi(argv[2]);
pSim->iRead = atoi(argv[1]); pSim->iRead = atoi(argv[1]);
pSim->iLastError = 0; pSim->iLastError = 0;
pSim->iTmo = 10; pSim->iTmo = 10;
/* The LH45 doesn't require divisors or multipliers /* The LH45 doesn't require divisors or multipliers
and they are always forced to 1.0 */ and they are always forced to 1.0 */
pSim->fDiv = 1.0; pSim->fDiv = 1.0;
pSim->fMult = 1.0; pSim->fMult = 1.0;
pSim->pHost = strdup(argv[0]); pSim->pHost = strdup(argv[0]);
pSim->iPort = 0; pSim->iPort = 0;
pSim->iChannel = 0; pSim->iChannel = 0;
/* initialise function pointers */ /* initialise function pointers */
pNew->SetValue = LH45Run; pNew->SetValue = LH45Run;
pNew->GetValue = GetLH45Pos; pNew->GetValue = GetLH45Pos;
@ -318,20 +318,20 @@
pNew->TryFixIt = LH45Fix; pNew->TryFixIt = LH45Fix;
pNew->Init = LH45Init; pNew->Init = LH45Init;
pNew->Close = LH45Close; pNew->Close = LH45Close;
return pNew; return pNew;
} }
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
int ConfigLH45(pEVDriver self) int ConfigLH45(pEVDriver self)
{ {
pLH45Driv pMe = NULL; pLH45Driv pMe = NULL;
int iRet; int iRet;
assert(self); assert(self);
pMe = (pLH45Driv )self->pPrivate; pMe = (pLH45Driv )self->pPrivate;
assert(pMe); assert(pMe);
iRet = LH45_Config(&pMe->pData, pMe->iTmo, pMe->iRead, iRet = LH45_Config(&pMe->pData, pMe->iTmo, pMe->iRead,
pMe->iControl,pMe->fDiv,pMe->fMult); pMe->iControl,pMe->fDiv,pMe->fMult);
if(iRet < 0) if(iRet < 0)
{ {
@ -344,17 +344,17 @@
int SetSensorLH45(pEVDriver self, int iSensor) int SetSensorLH45(pEVDriver self, int iSensor)
{ {
pLH45Driv pMe = NULL; pLH45Driv pMe = NULL;
assert(self); assert(self);
pMe = (pLH45Driv )self->pPrivate; pMe = (pLH45Driv )self->pPrivate;
assert(pMe); assert(pMe);
/* The LH45 allows bath temp, external temp and tank temp to be read /* The LH45 allows bath temp, external temp and tank temp to be read
so allow iRead=1 to 3 for each of these respectively */ so allow iRead=1 to 3 for each of these respectively */
if( (iSensor < 1) || (iSensor > 3) ) if( (iSensor < 1) || (iSensor > 3) )
{ {
return 0; return 0;
} }
pMe->iRead = iSensor; pMe->iRead = iSensor;
pMe->pData->iRead = iSensor; pMe->pData->iRead = iSensor;
return 1; return 1;
@ -363,7 +363,7 @@
int SetControlLH45(pEVDriver self, int iSensor) int SetControlLH45(pEVDriver self, int iSensor)
{ {
pLH45Driv pMe = NULL; pLH45Driv pMe = NULL;
assert(self); assert(self);
pMe = (pLH45Driv )self->pPrivate; pMe = (pLH45Driv )self->pPrivate;
assert(pMe); assert(pMe);
@ -373,7 +373,7 @@
if( (iSensor < 1) || (iSensor > 2) ) if( (iSensor < 1) || (iSensor > 2) )
{ {
return 0; return 0;
} }
pMe->iControl = iSensor; pMe->iControl = iSensor;
pMe->pData->iControl = iSensor; pMe->pData->iControl = iSensor;
return 1; return 1;
@ -382,7 +382,7 @@
int SetTMOLH45(pEVDriver self, int iSensor) int SetTMOLH45(pEVDriver self, int iSensor)
{ {
pLH45Driv pMe = NULL; pLH45Driv pMe = NULL;
assert(self); assert(self);
pMe = (pLH45Driv )self->pPrivate; pMe = (pLH45Driv )self->pPrivate;
assert(pMe); assert(pMe);
@ -390,7 +390,7 @@
if(iSensor < 10) if(iSensor < 10)
{ {
return 0; return 0;
} }
pMe->iTmo = iSensor; pMe->iTmo = iSensor;
return 1; return 1;
} }
@ -398,7 +398,7 @@
int GetControlLH45(pEVDriver self) int GetControlLH45(pEVDriver self)
{ {
pLH45Driv pMe = NULL; pLH45Driv pMe = NULL;
assert(self); assert(self);
pMe = (pLH45Driv )self->pPrivate; pMe = (pLH45Driv )self->pPrivate;
assert(pMe); assert(pMe);
@ -409,7 +409,7 @@
int GetSensorLH45(pEVDriver self) int GetSensorLH45(pEVDriver self)
{ {
pLH45Driv pMe = NULL; pLH45Driv pMe = NULL;
assert(self); assert(self);
pMe = (pLH45Driv )self->pPrivate; pMe = (pLH45Driv )self->pPrivate;
assert(pMe); assert(pMe);
@ -420,7 +420,7 @@
int GetTMOLH45(pEVDriver self) int GetTMOLH45(pEVDriver self)
{ {
pLH45Driv pMe = NULL; pLH45Driv pMe = NULL;
assert(self); assert(self);
pMe = (pLH45Driv )self->pPrivate; pMe = (pLH45Driv )self->pPrivate;
assert(pMe); assert(pMe);
@ -431,7 +431,7 @@
float GetDivisorLH45(pEVDriver self) float GetDivisorLH45(pEVDriver self)
{ {
pLH45Driv pMe = NULL; pLH45Driv pMe = NULL;
assert(self); assert(self);
pMe = (pLH45Driv )self->pPrivate; pMe = (pLH45Driv )self->pPrivate;
assert(pMe); assert(pMe);
@ -442,7 +442,7 @@
int SetDivisorLH45(pEVDriver self, float fDiv) int SetDivisorLH45(pEVDriver self, float fDiv)
{ {
pLH45Driv pMe = NULL; pLH45Driv pMe = NULL;
assert(self); assert(self);
pMe = (pLH45Driv )self->pPrivate; pMe = (pLH45Driv )self->pPrivate;
assert(pMe); assert(pMe);
@ -455,7 +455,7 @@
float GetMultLH45(pEVDriver self) float GetMultLH45(pEVDriver self)
{ {
pLH45Driv pMe = NULL; pLH45Driv pMe = NULL;
assert(self); assert(self);
pMe = (pLH45Driv )self->pPrivate; pMe = (pLH45Driv )self->pPrivate;
assert(pMe); assert(pMe);
@ -466,13 +466,13 @@
int SetMultLH45(pEVDriver self, float fDiv) int SetMultLH45(pEVDriver self, float fDiv)
{ {
pLH45Driv pMe = NULL; pLH45Driv pMe = NULL;
assert(self); assert(self);
pMe = (pLH45Driv )self->pPrivate; pMe = (pLH45Driv )self->pPrivate;
assert(pMe); assert(pMe);
/* The LH45 doesn't need multiplier, force to 1.0 */ /* The LH45 doesn't need multiplier, force to 1.0 */
pMe->fMult = 1.0; /* fDiv */; pMe->fMult = 1.0; /* fDiv */;
return 1; return 1;
} }

View File

@ -1,5 +1,5 @@
/*------------------------------------------------------------------------- /*-------------------------------------------------------------------------
LS340 - LAKESHORE340 LS340 - LAKESHORE340
Support for the Lakeshore 340 Temperature Controller Support for the Lakeshore 340 Temperature Controller
The meaning and working of the functions defined is as desribed for a The meaning and working of the functions defined is as desribed for a
@ -85,7 +85,7 @@ typedef struct ls340_s {
float fValue; /* current temperature of control sensor in degrees K */ float fValue; /* current temperature of control sensor in degrees K */
float fTarget; /* requested target temperature */ float fTarget; /* requested target temperature */
int iSettleTime; /* settling time (sec) */ int iSettleTime; /* settling time (sec) */
float fTolerance; /* settline tolerance level 0..100 */ float fTolerance; /* settline tolerance level 0..100 */
bool isLocked; /* changes no longer permitted */ bool isLocked; /* changes no longer permitted */
unsigned long ulIdleDelay; /* idle timer timeout duration in milliseconds */ unsigned long ulIdleDelay; /* idle timer timeout duration in milliseconds */
unsigned long ulIdlePollRate; /* idle timer timeout duration in milliseconds */ unsigned long ulIdlePollRate; /* idle timer timeout duration in milliseconds */
@ -248,7 +248,7 @@ static void LS340State_Unknown(pStateMachine sm, pEvtEvent event) {
do { do {
pAsyncTxn pCmd = event->event.msg.cmd; pAsyncTxn pCmd = event->event.msg.cmd;
pCmd->inp_buf[pCmd->inp_idx] = '\0'; pCmd->inp_buf[pCmd->inp_idx] = '\0';
if (sm->mySubState == 1) { if (sm->mySubState == 1) {
/* IDN Request */ /* IDN Request */
char* p = strchr(pCmd->inp_buf, '\r'); char* p = strchr(pCmd->inp_buf, '\r');
@ -256,18 +256,18 @@ static void LS340State_Unknown(pStateMachine sm, pEvtEvent event) {
char line[132]; char line[132];
*p = '\0'; *p = '\0';
sprintf(line, "IDN: %s", pCmd->inp_buf); sprintf(line, "IDN: %s", pCmd->inp_buf);
SICSLogWrite(line, eLog); SICSLogWrite(line, eLog);
} }
#if 0 #if 0
sprintf(cmd, "RANGE 0"); /* ensure heater is off */ sprintf(cmd, "RANGE 0"); /* ensure heater is off */
LS340_SendCmd(priv, cmd, strlen(cmd), NULL); LS340_SendCmd(priv, cmd, strlen(cmd), NULL);
#endif #endif
sprintf(cmd, "CSET %d, %s, 1, %d, 1", priv->iPidLoop, priv->cValidSensors[priv->iCtrlSens], priv->iHeaterStatus); sprintf(cmd, "CSET %d, %s, 1, %d, 1", priv->iPidLoop, priv->cValidSensors[priv->iCtrlSens], priv->iHeaterStatus);
LS340_SendCmd(priv, cmd, strlen(cmd), NULL); LS340_SendCmd(priv, cmd, strlen(cmd), NULL);
sprintf(cmd, "CLIMIT? %d", priv->iPidLoop); sprintf(cmd, "CLIMIT? %d", priv->iPidLoop);
LS340_SendCmd(priv, cmd, strlen(cmd), fsm_msg_callback); LS340_SendCmd(priv, cmd, strlen(cmd), fsm_msg_callback);
sm->mySubState = 2; sm->mySubState = 2;
return; return;
@ -279,14 +279,14 @@ static void LS340State_Unknown(pStateMachine sm, pEvtEvent event) {
if (p) { if (p) {
char line[132]; char line[132];
*p = '\0'; *p = '\0';
sprintf(line, "CLIMIT (Unknown): %s", pCmd->inp_buf); sprintf(line, "CLIMIT (Unknown): %s", pCmd->inp_buf);
SICSLogWrite(line, eLog); SICSLogWrite(line, eLog);
sscanf(pCmd->inp_buf, "%f,%f,%f,%d,%d", &priv->fSetPointLimit, &priv->fPosSlope, &priv->fNegSlope, &priv->iMaxCurrent, &priv->iMaxRange); sscanf(pCmd->inp_buf, "%f,%f,%f,%d,%d", &priv->fSetPointLimit, &priv->fPosSlope, &priv->fNegSlope, &priv->iMaxCurrent, &priv->iMaxRange);
} }
sprintf(cmd, "SETP? %d", priv->iPidLoop); sprintf(cmd, "SETP? %d", priv->iPidLoop);
LS340_SendCmd(priv, cmd, strlen(cmd), fsm_msg_callback); LS340_SendCmd(priv, cmd, strlen(cmd), fsm_msg_callback);
sm->mySubState = 3; sm->mySubState = 3;
@ -300,14 +300,14 @@ static void LS340State_Unknown(pStateMachine sm, pEvtEvent event) {
if (p) { if (p) {
char line[132]; char line[132];
*p = '\0'; *p = '\0';
sprintf(line, "SETP: %s", pCmd->inp_buf); sprintf(line, "SETP: %s", pCmd->inp_buf);
SICSLogWrite(line, eLog); SICSLogWrite(line, eLog);
sscanf(pCmd->inp_buf, "%f", &priv->fSetPoint); sscanf(pCmd->inp_buf, "%f", &priv->fSetPoint);
priv->fTarget = priv->fSetPoint; /* Set target and setpoints to current values from controller */ priv->fTarget = priv->fSetPoint; /* Set target and setpoints to current values from controller */
} }
sprintf(cmd, "KRDG? %s", priv->cValidSensors[0]); sprintf(cmd, "KRDG? %s", priv->cValidSensors[0]);
LS340_SendCmd(priv, cmd, strlen(cmd), fsm_msg_callback); LS340_SendCmd(priv, cmd, strlen(cmd), fsm_msg_callback);
sm->mySubState = 4; sm->mySubState = 4;
@ -322,21 +322,21 @@ static void LS340State_Unknown(pStateMachine sm, pEvtEvent event) {
*p = '\0'; *p = '\0';
priv->fSensorValues[sm->mySubState-4] = atof(pCmd->inp_buf); priv->fSensorValues[sm->mySubState-4] = atof(pCmd->inp_buf);
if (sm->mySubState-4 == priv->iCtrlSens) { if (sm->mySubState-4 == priv->iCtrlSens) {
priv->fValue = priv->fSensorValues[sm->mySubState-4]; priv->fValue = priv->fSensorValues[sm->mySubState-4];
} }
sprintf(line, "KRDG? (Unknown) sensor %s = %8.2f", priv->cValidSensors[sm->mySubState-4], priv->fSensorValues[sm->mySubState-4]); sprintf(line, "KRDG? (Unknown) sensor %s = %8.2f", priv->cValidSensors[sm->mySubState-4], priv->fSensorValues[sm->mySubState-4]);
SICSLogWrite(line, eLog); SICSLogWrite(line, eLog);
} }
if (sm->mySubState >= priv->iNumSensors+3) { if (sm->mySubState >= priv->iNumSensors+3) {
fsm_change_state(sm, LS340State_Idle); fsm_change_state(sm, LS340State_Idle);
return; return;
} }
sm->mySubState++; sm->mySubState++;
sprintf(cmd, "KRDG? %s", priv->cValidSensors[sm->mySubState-4]); sprintf(cmd, "KRDG? %s", priv->cValidSensors[sm->mySubState-4]);
LS340_SendCmd(priv, cmd, strlen(cmd), fsm_msg_callback); LS340_SendCmd(priv, cmd, strlen(cmd), fsm_msg_callback);
return; return;
} }
} while (0); } while (0);
@ -353,9 +353,9 @@ static void LS340State_Unknown(pStateMachine sm, pEvtEvent event) {
} }
static void LS340State_Idle(pStateMachine sm, pEvtEvent event){ static void LS340State_Idle(pStateMachine sm, pEvtEvent event){
char cmd[CMDLEN]; char cmd[CMDLEN];
pEVDriver driv = (pEVDriver) sm->context; pEVDriver driv = (pEVDriver) sm->context;
pLS340Driv priv = (pLS340Driv) driv->pPrivate; pLS340Driv priv = (pLS340Driv) driv->pPrivate;
switch (event->event_type) { switch (event->event_type) {
@ -367,7 +367,7 @@ static void LS340State_Idle(pStateMachine sm, pEvtEvent event){
priv->ulIdleDelay, priv->ulIdleDelay,
fsm_tmr_callback, sm); fsm_tmr_callback, sm);
sprintf(cmd, "CLIMIT? %d", priv->iPidLoop); sprintf(cmd, "CLIMIT? %d", priv->iPidLoop);
LS340_SendCmd(priv, cmd, strlen(cmd), fsm_msg_callback); LS340_SendCmd(priv, cmd, strlen(cmd), fsm_msg_callback);
sm->mySubState = 1; sm->mySubState = 1;
@ -383,15 +383,15 @@ static void LS340State_Idle(pStateMachine sm, pEvtEvent event){
if (p) { if (p) {
char line[132]; char line[132];
*p = '\0'; *p = '\0';
sprintf(line, "CLIMIT (Idle): %s", pCmd->inp_buf); sprintf(line, "CLIMIT (Idle): %s", pCmd->inp_buf);
SICSLogWrite(line, eLog); SICSLogWrite(line, eLog);
sscanf(pCmd->inp_buf, "%f,%f,%f,%d,%d", &priv->fSetPointLimit, &priv->fPosSlope, &priv->fNegSlope, &priv->iMaxCurrent, &priv->iMaxRange); sscanf(pCmd->inp_buf, "%f,%f,%f,%d,%d", &priv->fSetPointLimit, &priv->fPosSlope, &priv->fNegSlope, &priv->iMaxCurrent, &priv->iMaxRange);
} }
sm->mySubState++; sm->mySubState++;
} else if (sm->mySubState >= 2 && sm->mySubState <= priv->iNumSensors+1) { } else if (sm->mySubState >= 2 && sm->mySubState <= priv->iNumSensors+1) {
/* KRDG? Requests */ /* KRDG? Requests */
char* p = strchr(pCmd->inp_buf, '\r'); char* p = strchr(pCmd->inp_buf, '\r');
@ -401,7 +401,7 @@ static void LS340State_Idle(pStateMachine sm, pEvtEvent event){
priv->fSensorValues[sm->mySubState-2] = atof(pCmd->inp_buf); priv->fSensorValues[sm->mySubState-2] = atof(pCmd->inp_buf);
if (sm->mySubState-2 == priv->iCtrlSens) priv->fValue = priv->fSensorValues[sm->mySubState-2]; if (sm->mySubState-2 == priv->iCtrlSens) priv->fValue = priv->fSensorValues[sm->mySubState-2];
sprintf(line, "KRDG? (Idle) sensor %s = %8.2f", priv->cValidSensors[sm->mySubState-2], priv->fSensorValues[sm->mySubState-2]); sprintf(line, "KRDG? (Idle) sensor %s = %8.2f", priv->cValidSensors[sm->mySubState-2], priv->fSensorValues[sm->mySubState-2]);
SICSLogWrite(line, eLog); SICSLogWrite(line, eLog);
} }
if (sm->mySubState >= priv->iNumSensors+1) { if (sm->mySubState >= priv->iNumSensors+1) {
@ -410,7 +410,7 @@ static void LS340State_Idle(pStateMachine sm, pEvtEvent event){
} }
sm->mySubState++; sm->mySubState++;
return; return;
} }
} while (0); } while (0);
@ -418,10 +418,10 @@ static void LS340State_Idle(pStateMachine sm, pEvtEvent event){
case eTimerEvent: case eTimerEvent:
priv->state_timer = NULL; priv->state_timer = NULL;
if (priv->controller) { if (priv->controller) {
char line[132]; char line[132];
sprintf(line, "LS340 eMode: = %d", priv->controller->eMode); sprintf(line, "LS340 eMode: = %d", priv->controller->eMode);
SICSLogWrite(line, eLog); SICSLogWrite(line, eLog);
} }
@ -437,19 +437,19 @@ static void LS340State_Idle(pStateMachine sm, pEvtEvent event){
} }
if (priv->fTarget < priv->fSetPoint) { if (priv->fTarget < priv->fSetPoint) {
priv->fSetPoint = priv->fTarget; /* set the setpoint to be the target */ priv->fSetPoint = priv->fTarget; /* set the setpoint to be the target */
priv->iHeaterStatus = 1; priv->iHeaterStatus = 1;
sprintf(cmd, "SETP %d, %8.2f", priv->iPidLoop, priv->fSetPoint); /* tell the Lakeshore to change the current setpoint to target */ sprintf(cmd, "SETP %d, %8.2f", priv->iPidLoop, priv->fSetPoint); /* tell the Lakeshore to change the current setpoint to target */
LS340_SendCmd(priv, cmd, strlen(cmd), NULL); LS340_SendCmd(priv, cmd, strlen(cmd), NULL);
fsm_change_state(sm, LS340State_Lowering); fsm_change_state(sm, LS340State_Lowering);
return; return;
} }
if (sm->mySubState >= 2 && sm->mySubState <= priv->iNumSensors+1) { if (sm->mySubState >= 2 && sm->mySubState <= priv->iNumSensors+1) {
char line[132]; char line[132];
sprintf(cmd, "KRDG? %s", priv->cValidSensors[sm->mySubState-2]); sprintf(cmd, "KRDG? %s", priv->cValidSensors[sm->mySubState-2]);
LS340_SendCmd(priv, cmd, strlen(cmd), fsm_msg_callback); LS340_SendCmd(priv, cmd, strlen(cmd), fsm_msg_callback);
sprintf(line, "eTimerEvent (Idle): Sent: %s", cmd); sprintf(line, "eTimerEvent (Idle): Sent: %s", cmd);
SICSLogWrite(line, eLog); SICSLogWrite(line, eLog);
} }
/* restart timer */ /* restart timer */
@ -471,7 +471,7 @@ static void LS340State_Raising(pStateMachine sm, pEvtEvent event){
char cmd[CMDLEN]; char cmd[CMDLEN];
switch (event->event_type) { switch (event->event_type) {
case eStateEvent: case eStateEvent:
if (priv->state_timer) if (priv->state_timer)
NetWatchRemoveTimer(priv->state_timer); NetWatchRemoveTimer(priv->state_timer);
@ -483,8 +483,8 @@ static void LS340State_Raising(pStateMachine sm, pEvtEvent event){
sprintf(cmd, "RANGE %d", priv->iRange); /* set the Range value > 0 turns heater on */ sprintf(cmd, "RANGE %d", priv->iRange); /* set the Range value > 0 turns heater on */
LS340_SendCmd(priv, cmd, strlen(cmd), NULL); LS340_SendCmd(priv, cmd, strlen(cmd), NULL);
sprintf(cmd, "CLIMIT? %d", priv->iPidLoop); sprintf(cmd, "CLIMIT? %d", priv->iPidLoop);
LS340_SendCmd(priv, cmd, strlen(cmd), fsm_msg_callback); LS340_SendCmd(priv, cmd, strlen(cmd), fsm_msg_callback);
sm->mySubState = 1; sm->mySubState = 1;
@ -500,9 +500,9 @@ static void LS340State_Raising(pStateMachine sm, pEvtEvent event){
if (p) { if (p) {
char line[132]; char line[132];
*p = '\0'; *p = '\0';
sprintf(line, "CLIMIT (Raising): %s", pCmd->inp_buf); sprintf(line, "CLIMIT (Raising): %s", pCmd->inp_buf);
SICSLogWrite(line, eLog); SICSLogWrite(line, eLog);
sscanf(pCmd->inp_buf, "%f,%f,%f,%d,%d", &priv->fSetPointLimit, &priv->fPosSlope, &priv->fNegSlope, &priv->iMaxCurrent, &priv->iMaxRange); sscanf(pCmd->inp_buf, "%f,%f,%f,%d,%d", &priv->fSetPointLimit, &priv->fPosSlope, &priv->fNegSlope, &priv->iMaxCurrent, &priv->iMaxRange);
} }
@ -510,7 +510,7 @@ static void LS340State_Raising(pStateMachine sm, pEvtEvent event){
sm->mySubState++; sm->mySubState++;
} else if (sm->mySubState >= 2 && sm->mySubState <= priv->iNumSensors+1) { } else if (sm->mySubState >= 2 && sm->mySubState <= priv->iNumSensors+1) {
/* KRDG? Requests */ /* KRDG? Requests */
char* p = strchr(pCmd->inp_buf, '\r'); char* p = strchr(pCmd->inp_buf, '\r');
if (p) { if (p) {
@ -519,12 +519,12 @@ static void LS340State_Raising(pStateMachine sm, pEvtEvent event){
priv->fSensorValues[sm->mySubState-2] = atof(pCmd->inp_buf); priv->fSensorValues[sm->mySubState-2] = atof(pCmd->inp_buf);
if (sm->mySubState-2 == priv->iCtrlSens) priv->fValue = priv->fSensorValues[sm->mySubState-2]; if (sm->mySubState-2 == priv->iCtrlSens) priv->fValue = priv->fSensorValues[sm->mySubState-2];
sprintf(line, "KRDG? (Raising) sensor %s = %8.2f", priv->cValidSensors[sm->mySubState-2], priv->fSensorValues[sm->mySubState-2]); sprintf(line, "KRDG? (Raising) sensor %s = %8.2f", priv->cValidSensors[sm->mySubState-2], priv->fSensorValues[sm->mySubState-2]);
SICSLogWrite(line, eLog); SICSLogWrite(line, eLog);
} }
sm->mySubState++; sm->mySubState++;
} }
/* restart timer */ /* restart timer */
@ -544,17 +544,17 @@ static void LS340State_Raising(pStateMachine sm, pEvtEvent event){
} }
if (priv->fTarget < priv->fSetPoint) { if (priv->fTarget < priv->fSetPoint) {
priv->fSetPoint = priv->fTarget; /* set the setpoint to be the target */ priv->fSetPoint = priv->fTarget; /* set the setpoint to be the target */
sprintf(cmd, "SETP %d, %8.2f", priv->iPidLoop, priv->fSetPoint); /* tell the Lakeshore to change the current setpoint to target */ sprintf(cmd, "SETP %d, %8.2f", priv->iPidLoop, priv->fSetPoint); /* tell the Lakeshore to change the current setpoint to target */
LS340_SendCmd(priv, cmd, strlen(cmd), NULL); LS340_SendCmd(priv, cmd, strlen(cmd), NULL);
fsm_change_state(sm, LS340State_Lowering); fsm_change_state(sm, LS340State_Lowering);
return; return;
} }
if (sm->mySubState > priv->iNumSensors+1) sm->mySubState = 2; if (sm->mySubState > priv->iNumSensors+1) sm->mySubState = 2;
if (sm->mySubState >= 2 && sm->mySubState <= priv->iNumSensors+1) { if (sm->mySubState >= 2 && sm->mySubState <= priv->iNumSensors+1) {
sprintf(cmd, "KRDG? %s", priv->cValidSensors[sm->mySubState-2]); sprintf(cmd, "KRDG? %s", priv->cValidSensors[sm->mySubState-2]);
LS340_SendCmd(priv, cmd, strlen(cmd), fsm_msg_callback); LS340_SendCmd(priv, cmd, strlen(cmd), fsm_msg_callback);
} }
return; return;
@ -569,12 +569,12 @@ static void LS340State_Raising(pStateMachine sm, pEvtEvent event){
static void LS340State_Lowering(pStateMachine sm, pEvtEvent event){ static void LS340State_Lowering(pStateMachine sm, pEvtEvent event){
pEVDriver driv = (pEVDriver) sm->context; pEVDriver driv = (pEVDriver) sm->context;
pLS340Driv priv = (pLS340Driv) driv->pPrivate; pLS340Driv priv = (pLS340Driv) driv->pPrivate;
char cmd[CMDLEN]; char cmd[CMDLEN];
switch (event->event_type) { switch (event->event_type) {
case eStateEvent: case eStateEvent:
if (priv->state_timer) if (priv->state_timer)
NetWatchRemoveTimer(priv->state_timer); NetWatchRemoveTimer(priv->state_timer);
@ -582,7 +582,7 @@ static void LS340State_Lowering(pStateMachine sm, pEvtEvent event){
sprintf(cmd, "RANGE %d", priv->iRange); /* set the Range value > 0 turns heater on */ sprintf(cmd, "RANGE %d", priv->iRange); /* set the Range value > 0 turns heater on */
LS340_SendCmd(priv, cmd, strlen(cmd), NULL); LS340_SendCmd(priv, cmd, strlen(cmd), NULL);
sprintf(cmd, "CLIMIT? %d", priv->iPidLoop); sprintf(cmd, "CLIMIT? %d", priv->iPidLoop);
LS340_SendCmd(priv, cmd, strlen(cmd), fsm_msg_callback); LS340_SendCmd(priv, cmd, strlen(cmd), fsm_msg_callback);
sm->mySubState = 1; sm->mySubState = 1;
@ -598,9 +598,9 @@ static void LS340State_Lowering(pStateMachine sm, pEvtEvent event){
if (p) { if (p) {
char line[132]; char line[132];
*p = '\0'; *p = '\0';
sprintf(line, "CLIMIT (lowering): %s", pCmd->inp_buf); sprintf(line, "CLIMIT (lowering): %s", pCmd->inp_buf);
SICSLogWrite(line, eLog); SICSLogWrite(line, eLog);
sscanf(pCmd->inp_buf, "%f,%f,%f,%d,%d", &priv->fSetPointLimit, &priv->fPosSlope, &priv->fNegSlope, &priv->iMaxCurrent, &priv->iMaxRange); sscanf(pCmd->inp_buf, "%f,%f,%f,%d,%d", &priv->fSetPointLimit, &priv->fPosSlope, &priv->fNegSlope, &priv->iMaxCurrent, &priv->iMaxRange);
} }
@ -608,9 +608,9 @@ static void LS340State_Lowering(pStateMachine sm, pEvtEvent event){
sm->mySubState++; sm->mySubState++;
} else if (sm->mySubState >= 2 && sm->mySubState <= priv->iNumSensors+1) { } else if (sm->mySubState >= 2 && sm->mySubState <= priv->iNumSensors+1) {
/* KRDG? Requests */ /* KRDG? Requests */
char* p = strchr(pCmd->inp_buf, '\r'); char* p = strchr(pCmd->inp_buf, '\r');
if (p) { if (p) {
char line[132]; char line[132];
@ -618,12 +618,12 @@ static void LS340State_Lowering(pStateMachine sm, pEvtEvent event){
priv->fSensorValues[sm->mySubState-2] = atof(pCmd->inp_buf); priv->fSensorValues[sm->mySubState-2] = atof(pCmd->inp_buf);
if (sm->mySubState-2 == priv->iCtrlSens) priv->fValue = priv->fSensorValues[sm->mySubState-2]; if (sm->mySubState-2 == priv->iCtrlSens) priv->fValue = priv->fSensorValues[sm->mySubState-2];
sprintf(line, "KRDG? (Lowering) sensor %s = %8.2f", priv->cValidSensors[sm->mySubState-2], priv->fSensorValues[sm->mySubState-2]); sprintf(line, "KRDG? (Lowering) sensor %s = %8.2f", priv->cValidSensors[sm->mySubState-2], priv->fSensorValues[sm->mySubState-2]);
SICSLogWrite(line, eLog); SICSLogWrite(line, eLog);
} }
sm->mySubState++; sm->mySubState++;
} }
/* restart timer */ /* restart timer */
@ -643,18 +643,18 @@ static void LS340State_Lowering(pStateMachine sm, pEvtEvent event){
if (priv->fTarget > priv->fSetPoint) { if (priv->fTarget > priv->fSetPoint) {
priv->fSetPoint = priv->fTarget; /* set the setpoint to be the target */ priv->fSetPoint = priv->fTarget; /* set the setpoint to be the target */
sprintf(cmd, "SETP %d, %8.2f", priv->iPidLoop, priv->fSetPoint); /* tell the Lakeshore to change the current setpoint to target */ sprintf(cmd, "SETP %d, %8.2f", priv->iPidLoop, priv->fSetPoint); /* tell the Lakeshore to change the current setpoint to target */
LS340_SendCmd(priv, cmd, strlen(cmd), NULL); LS340_SendCmd(priv, cmd, strlen(cmd), NULL);
fsm_change_state(sm, LS340State_Raising); fsm_change_state(sm, LS340State_Raising);
return; return;
} }
if (sm->mySubState > priv->iNumSensors+1) sm->mySubState = 2; if (sm->mySubState > priv->iNumSensors+1) sm->mySubState = 2;
if (sm->mySubState >= 2 && sm->mySubState <= priv->iNumSensors+1) { if (sm->mySubState >= 2 && sm->mySubState <= priv->iNumSensors+1) {
sprintf(cmd, "KRDG? %s", priv->cValidSensors[sm->mySubState-2]); sprintf(cmd, "KRDG? %s", priv->cValidSensors[sm->mySubState-2]);
LS340_SendCmd(priv, cmd, strlen(cmd), fsm_msg_callback); LS340_SendCmd(priv, cmd, strlen(cmd), fsm_msg_callback);
} }
@ -695,12 +695,12 @@ static int LS340SetValue( pEVDriver self, float fPos) {
} }
static int LS340Send(pEVDriver self, char *pCommand, char *pReply, int iLen) { static int LS340Send(pEVDriver self, char *pCommand, char *pReply, int iLen) {
int rsp_len; int rsp_len;
rsp_len = iLen; rsp_len = iLen;
LS340_SendReceive(self->pPrivate, pCommand, strlen(pCommand), pReply, &rsp_len); LS340_SendReceive(self->pPrivate, pCommand, strlen(pCommand), pReply, &rsp_len);
return 1; return 1;
} }
@ -853,12 +853,12 @@ static int LS340_PrepareTxn(pAsyncProtocol p, pAsyncTxn txn, const char* cmd, in
} }
memcpy(txn->out_buf, cmd, cmd_len); memcpy(txn->out_buf, cmd, cmd_len);
txn->out_len = cmd_len; txn->out_len = cmd_len;
if (txn->out_buf[txn->out_len-1] != '\r') { if (txn->out_buf[txn->out_len-1] != '\r') {
txn->out_buf[txn->out_len++] = '\r'; txn->out_buf[txn->out_len++] = '\r';
// txn->out_buf[txn->out_len++] = '\r'; // txn->out_buf[txn->out_len++] = '\r';
} }
// txn->out_buf[txn->out_len++] = '\0'; // txn->out_buf[txn->out_len++] = '\0';
return 1; return 1;
} }
@ -883,11 +883,11 @@ pEVDriver CreateLS340Driver(int argc, char *argv[])
pEVDriver self = NULL; pEVDriver self = NULL;
pLS340Driv priv = NULL; pLS340Driv priv = NULL;
/* tcl script eg: EvFactory new tc1 ls340 sertemp1 1 B /* tcl script eg: EvFactory new tc1 ls340 sertemp1 1 B
* Argv[] entering CreateLS340Driver - * Argv[] entering CreateLS340Driver -
* 0 - * 0 -
*/ */
if (argc < 1) if (argc < 1)
@ -933,17 +933,17 @@ pEVDriver CreateLS340Driver(int argc, char *argv[])
priv->fsm.event_name = event_name; priv->fsm.event_name = event_name;
priv->name = strdup(argv[3]); priv->name = strdup(argv[3]);
priv->iPidLoop = atoi(argv[5]); /* PID Loop 1..2 */ priv->iPidLoop = atoi(argv[5]); /* PID Loop 1..2 */
if (argc < 7) return NULL; if (argc < 7) return NULL;
strncpy(priv->cCtrlSensName, argv[6], strlen(argv[6])); /* control sensor name */ strncpy(priv->cCtrlSensName, argv[6], strlen(argv[6])); /* control sensor name */
if (strlen(priv->cCtrlSensName) > 0) { if (strlen(priv->cCtrlSensName) > 0) {
strncpy(priv->cValidSensors[0], priv->cCtrlSensName, strlen(priv->cCtrlSensName)); strncpy(priv->cValidSensors[0], priv->cCtrlSensName, strlen(priv->cCtrlSensName));
priv->iCtrlSens = 0; priv->iCtrlSens = 0;
d++; d++;
} }
/* parse out valid sensor names from argv[7] */ /* parse out valid sensor names from argv[7] */
for (i = d; i < NUM_INPUT_SENSORS; i++) { for (i = d; i < NUM_INPUT_SENSORS; i++) {
priv->cValidSensors[i][0] = 'X'; /* clear the list, first */ priv->cValidSensors[i][0] = 'X'; /* clear the list, first */
@ -958,19 +958,19 @@ pEVDriver CreateLS340Driver(int argc, char *argv[])
cname[0] = argv[7][i]; cname[0] = argv[7][i];
cname[1] = '\0'; cname[1] = '\0';
cname[2] = '\0'; cname[2] = '\0';
if (isdigit(argv[7][i+1]) > 0) { if (isdigit(argv[7][i+1]) > 0) {
cname[1] = argv[7][i+1]; cname[1] = argv[7][i+1];
i++; i++;
} }
v = 0; v = 0;
/* check to see if sensor is already in list */ /* check to see if sensor is already in list */
for (k = 0; k < NUM_INPUT_SENSORS; k++) { for (k = 0; k < NUM_INPUT_SENSORS; k++) {
if (priv->cValidSensors[k][0] == cname[0]) { if (priv->cValidSensors[k][0] == cname[0]) {
if (strcmp(priv->cValidSensors[k], cname) == 0) { if (strcmp(priv->cValidSensors[k], cname) == 0) {
v = 1; v = 1;
break; /* already in list, skip */ break; /* already in list, skip */
} }
/* C vs C2 */ /* C vs C2 */
if (priv->cValidSensors[k][1] == '\0' && isdigit(cname[1]) > 0) { if (priv->cValidSensors[k][1] == '\0' && isdigit(cname[1]) > 0) {
@ -985,12 +985,12 @@ pEVDriver CreateLS340Driver(int argc, char *argv[])
} }
} }
} }
if (v == 0) { /* not in list, so add it in! */ if (v == 0) { /* not in list, so add it in! */
strncpy(priv->cValidSensors[d], cname, strlen(cname)); strncpy(priv->cValidSensors[d], cname, strlen(cname));
d++; d++;
} }
} }
i++; i++;
} }
priv->iNumSensors = d; /* assign number of sensors found */ priv->iNumSensors = d; /* assign number of sensors found */
@ -1032,12 +1032,12 @@ int LS340Wrapper(SConnection *pCon, SicsInterp *pSics, void *pData,
{ {
return EVControlWrapper(pCon,pSics,pData,argc,argv); return EVControlWrapper(pCon,pSics,pData,argc,argv);
} }
if (strcasecmp("send", argv[1]) == 0) { if (strcasecmp("send", argv[1]) == 0) {
char cmd[CMDLEN]; char cmd[CMDLEN];
int cmd_len; int cmd_len;
char rsp[CMDLEN]; char rsp[CMDLEN];
int rsp_len; int rsp_len;
/* Managers only */ /* Managers only */
if (!SCMatchRights(pCon, usMugger)) { if (!SCMatchRights(pCon, usMugger)) {
return 0; return 0;
@ -1054,7 +1054,7 @@ int LS340Wrapper(SConnection *pCon, SicsInterp *pSics, void *pData,
return 1; return 1;
} }
/* assign control sensor index */ /* assign control sensor index */
if (strcasecmp("controlsensor", argv[1]) == 0) { if (strcasecmp("controlsensor", argv[1]) == 0) {
char cmd[64]; char cmd[64];
@ -1078,7 +1078,7 @@ int LS340Wrapper(SConnection *pCon, SicsInterp *pSics, void *pData,
SCWrite(pCon, line, eError); SCWrite(pCon, line, eError);
return 0; return 0;
} }
/* swap control sensor locations from [0] */ /* swap control sensor locations from [0] */
strncpy(cname, p, sizeof(cname)); strncpy(cname, p, sizeof(cname));
@ -1092,8 +1092,8 @@ int LS340Wrapper(SConnection *pCon, SicsInterp *pSics, void *pData,
break; break;
} }
} }
if (v > -1) { /* in list, swap values */ if (v > -1) { /* in list, swap values */
float temp; float temp;
@ -1104,8 +1104,8 @@ int LS340Wrapper(SConnection *pCon, SicsInterp *pSics, void *pData,
strcpy(priv->cValidSensors[v], priv->cCtrlSensName); strcpy(priv->cValidSensors[v], priv->cCtrlSensName);
strcpy(priv->cCtrlSensName, cname); strcpy(priv->cCtrlSensName, cname);
sprintf(cmd, "CSET %d, %s, 1, %d, 1", priv->iPidLoop, priv->cValidSensors[priv->iCtrlSens], priv->iHeaterStatus); sprintf(cmd, "CSET %d, %s, 1, %d, 1", priv->iPidLoop, priv->cValidSensors[priv->iCtrlSens], priv->iHeaterStatus);
LS340_SendCmd(priv, cmd, strlen(cmd), NULL); LS340_SendCmd(priv, cmd, strlen(cmd), NULL);
@ -1138,27 +1138,27 @@ int LS340Wrapper(SConnection *pCon, SicsInterp *pSics, void *pData,
char rsp[CMDLEN]; char rsp[CMDLEN];
snprintf(rsp, CMDLEN, "%s.setpoint = %8.2f", priv->name, priv->fSetPoint); snprintf(rsp, CMDLEN, "%s.setpoint = %8.2f", priv->name, priv->fSetPoint);
SCWrite(pCon, rsp, eValue); SCWrite(pCon, rsp, eValue);
return 1; return 1;
} }
if (strcasecmp("numsensors", argv[1]) == 0) { if (strcasecmp("numsensors", argv[1]) == 0) {
char rsp[CMDLEN]; char rsp[CMDLEN];
snprintf(rsp, CMDLEN, "%s.numsensors = %d", priv->name, priv->iNumSensors); snprintf(rsp, CMDLEN, "%s.numsensors = %d", priv->name, priv->iNumSensors);
SCWrite(pCon, rsp, eValue); SCWrite(pCon, rsp, eValue);
return 1; return 1;
} }
if (strcasecmp("pollingrate", argv[1]) == 0) { if (strcasecmp("pollingrate", argv[1]) == 0) {
char rsp[CMDLEN]; char rsp[CMDLEN];
if (argc > 2) { if (argc > 2) {
priv->ulIdlePollRate = (unsigned)atol(argv[2]); priv->ulIdlePollRate = (unsigned)atol(argv[2]);
priv->ulIdleDelay = priv->ulIdlePollRate / priv->iNumSensors+1; /* +1 to include CLIMIT query */ priv->ulIdleDelay = priv->ulIdlePollRate / priv->iNumSensors+1; /* +1 to include CLIMIT query */
fsm_change_state(&priv->fsm, LS340State_Unknown); fsm_change_state(&priv->fsm, LS340State_Unknown);
} }
snprintf(rsp, CMDLEN, "%s.pollingrate = %lu", priv->name, priv->ulIdlePollRate); snprintf(rsp, CMDLEN, "%s.pollingrate = %lu", priv->name, priv->ulIdlePollRate);
SCWrite(pCon, rsp, eValue); SCWrite(pCon, rsp, eValue);
return 1; return 1;
} }
@ -1166,7 +1166,7 @@ int LS340Wrapper(SConnection *pCon, SicsInterp *pSics, void *pData,
char rsp[CMDLEN]; char rsp[CMDLEN];
char cmd[CMDLEN]; char cmd[CMDLEN];
if (argc > 2) { if (argc > 2) {
priv->iHeaterStatus = atoi(argv[2]); priv->iHeaterStatus = atoi(argv[2]);
if (priv->iHeaterStatus == 1) { /* turn heater on */ if (priv->iHeaterStatus == 1) { /* turn heater on */
/* sprintf(cmd, "RANGE %d", priv->iRange); /* sprintf(cmd, "RANGE %d", priv->iRange);
LS340_SendCmd(priv, cmd, strlen(cmd), NULL); LS340_SendCmd(priv, cmd, strlen(cmd), NULL);
@ -1175,10 +1175,10 @@ int LS340Wrapper(SConnection *pCon, SicsInterp *pSics, void *pData,
sprintf(cmd, "RANGE 0"); /* turn heater off otherwise */ sprintf(cmd, "RANGE 0"); /* turn heater off otherwise */
LS340_SendCmd(priv, cmd, strlen(cmd), NULL); LS340_SendCmd(priv, cmd, strlen(cmd), NULL);
} }
} }
snprintf(rsp, CMDLEN, "%s.heateron = %d", priv->name, priv->iHeaterStatus); snprintf(rsp, CMDLEN, "%s.heateron = %d", priv->name, priv->iHeaterStatus);
SCWrite(pCon, rsp, eValue); SCWrite(pCon, rsp, eValue);
if (argc > 2) fsm_change_state(&priv->fsm, LS340State_Idle); /* move back to Idle state? */ if (argc > 2) fsm_change_state(&priv->fsm, LS340State_Idle); /* move back to Idle state? */
return 1; return 1;
} }
@ -1186,16 +1186,16 @@ int LS340Wrapper(SConnection *pCon, SicsInterp *pSics, void *pData,
char rsp[CMDLEN]; char rsp[CMDLEN];
char cmd[CMDLEN]; char cmd[CMDLEN];
if (argc > 2) { if (argc > 2) {
priv->iRange = atoi(argv[2]); priv->iRange = atoi(argv[2]);
if (priv->iRange > 0) priv->iHeaterStatus = 1; if (priv->iRange > 0) priv->iHeaterStatus = 1;
sprintf(cmd, "RANGE %d", priv->iRange); sprintf(cmd, "RANGE %d", priv->iRange);
LS340_SendCmd(priv, cmd, strlen(cmd), NULL); LS340_SendCmd(priv, cmd, strlen(cmd), NULL);
} }
snprintf(rsp, CMDLEN, "%s.range = %d", priv->name, priv->iRange); snprintf(rsp, CMDLEN, "%s.range = %d", priv->name, priv->iRange);
SCWrite(pCon, rsp, eValue); SCWrite(pCon, rsp, eValue);
return 1; return 1;
} }
@ -1206,13 +1206,13 @@ int LS340Wrapper(SConnection *pCon, SicsInterp *pSics, void *pData,
char rsp[CMDLEN]; char rsp[CMDLEN];
char senslist[132]; char senslist[132];
char temp[132]; char temp[132];
strcpy(senslist, ""); /* prepare string */ strcpy(senslist, ""); /* prepare string */
for (i = 0; i < priv->iNumSensors; i++) { for (i = 0; i < priv->iNumSensors; i++) {
sprintf(temp, "sensor%s", priv->cValidSensors[i]); sprintf(temp, "sensor%s", priv->cValidSensors[i]);
strcat(senslist, temp); strcat(senslist, temp);
if (i < priv->iNumSensors-1) strcat(senslist, ","); if (i < priv->iNumSensors-1) strcat(senslist, ",");
} }
snprintf(rsp, CMDLEN, "%s.sensorlist = %s", priv->name, senslist); snprintf(rsp, CMDLEN, "%s.sensorlist = %s", priv->name, senslist);
@ -1230,13 +1230,13 @@ int LS340Wrapper(SConnection *pCon, SicsInterp *pSics, void *pData,
name[0] = '\0'; name[0] = '\0';
name[1] = '\0'; name[1] = '\0';
name[2] = '\0'; name[2] = '\0';
if (strlen(argv[1]) == 7) { /* sensorA */ if (strlen(argv[1]) == 7) { /* sensorA */
name[0] = argv[1][6]; name[0] = argv[1][6];
} }
if (strlen(argv[1]) == 8) { /* sensorC1 */ if (strlen(argv[1]) == 8) { /* sensorC1 */
name[0] = argv[1][6]; name[0] = argv[1][6];
name[1] = argv[1][7]; name[1] = argv[1][7];
} }
@ -1261,12 +1261,12 @@ int LS340Wrapper(SConnection *pCon, SicsInterp *pSics, void *pData,
char rsp[CMDLEN]; char rsp[CMDLEN];
char senslist[132]; char senslist[132];
char temp[132]; char temp[132];
iRet = EVControlWrapper(pCon,pSics,pData,argc,argv); iRet = EVControlWrapper(pCon,pSics,pData,argc,argv);
if (iRet) { if (iRet) {
snprintf(rsp, CMDLEN, "%s.pidloop = %d", priv->name, priv->iPidLoop); snprintf(rsp, CMDLEN, "%s.pidloop = %d", priv->name, priv->iPidLoop);
SCWrite(pCon, rsp, eValue); SCWrite(pCon, rsp, eValue);
snprintf(rsp, CMDLEN, "%s.controlsensor = sensor%s", priv->name, priv->cValidSensors[priv->iCtrlSens]); snprintf(rsp, CMDLEN, "%s.controlsensor = sensor%s", priv->name, priv->cValidSensors[priv->iCtrlSens]);
SCWrite(pCon, rsp, eValue); SCWrite(pCon, rsp, eValue);
@ -1277,8 +1277,8 @@ int LS340Wrapper(SConnection *pCon, SicsInterp *pSics, void *pData,
for (i = 0; i < priv->iNumSensors; i++) { for (i = 0; i < priv->iNumSensors; i++) {
sprintf(temp, "sensor%s", priv->cValidSensors[i]); sprintf(temp, "sensor%s", priv->cValidSensors[i]);
strcat(senslist, temp); strcat(senslist, temp);
if (i < priv->iNumSensors-1) strcat(senslist, ","); if (i < priv->iNumSensors-1) strcat(senslist, ",");
} }
snprintf(rsp, CMDLEN, "%s.sensorlist = %s", priv->name, senslist); snprintf(rsp, CMDLEN, "%s.sensorlist = %s", priv->name, senslist);
@ -1294,7 +1294,7 @@ int LS340Wrapper(SConnection *pCon, SicsInterp *pSics, void *pData,
SCWrite(pCon, rsp, eValue); SCWrite(pCon, rsp, eValue);
snprintf(rsp, CMDLEN, "%s.setpoint = %8.2f", priv->name, priv->fSetPoint); snprintf(rsp, CMDLEN, "%s.setpoint = %8.2f", priv->name, priv->fSetPoint);
SCWrite(pCon, rsp, eValue); SCWrite(pCon, rsp, eValue);
snprintf(rsp, CMDLEN, "%s.target = %8.2f", priv->name, priv->fTarget); snprintf(rsp, CMDLEN, "%s.target = %8.2f", priv->name, priv->fTarget);
SCWrite(pCon, rsp, eValue); SCWrite(pCon, rsp, eValue);
snprintf(rsp, CMDLEN, "%s.setpointlimit = %8.2f", priv->name, priv->fSetPointLimit); snprintf(rsp, CMDLEN, "%s.setpointlimit = %8.2f", priv->name, priv->fSetPointLimit);

View File

@ -1,5 +1,5 @@
/*------------------------------------------------------------------------- /*-------------------------------------------------------------------------
LS340 - LAKESHORE 340 LS340 - LAKESHORE 340
Asynchronous state-machine based driver for controller LAKESHORE 340 Asynchronous state-machine based driver for controller LAKESHORE 340

View File

@ -42,11 +42,11 @@ extern int DMC2280MotionControl;
#define INST_READY_BIT (1 << 16) #define INST_READY_BIT (1 << 16)
#define LAMP_TEST_BIT (1 << 17) #define LAMP_TEST_BIT (1 << 17)
#define KEY_BOTH_BITS (KEY_ENABLED_BIT | KEY_DISABLED_BIT) #define KEY_BOTH_BITS (KEY_ENABLED_BIT | KEY_DISABLED_BIT)
#define SEC_BOTH_BITS (SEC_OPENED_BIT | SEC_CLOSED_BIT) #define SEC_BOTH_BITS (SEC_OPENED_BIT | SEC_CLOSED_BIT)
#define TER_BOTH_BITS (TER_OPENED_BIT | TER_CLOSED_BIT) #define TER_BOTH_BITS (TER_OPENED_BIT | TER_CLOSED_BIT)
#define MOTOR_BOTH_BITS (MOTOR_ENABLED_BIT | MOTOR_DISABLED_BIT) #define MOTOR_BOTH_BITS (MOTOR_ENABLED_BIT | MOTOR_DISABLED_BIT)
#define ACCESS_BOTH_BITS (ACCESS_LOCKED_BIT | ACCESS_UNLOCKED_BIT) #define ACCESS_BOTH_BITS (ACCESS_LOCKED_BIT | ACCESS_UNLOCKED_BIT)
static pAsyncProtocol LSS_Protocol = NULL; static pAsyncProtocol LSS_Protocol = NULL;
@ -198,10 +198,10 @@ static mxml_type_t xmlLoadStringCallback(mxml_node_t *node) {
sprintf(value, "NO VALUE"); sprintf(value, "NO VALUE");
type = mxmlElementGetAttr(node, "type"); type = mxmlElementGetAttr(node, "type");
if (type == NULL) if (type == NULL)
type = node->value.element.name; type = node->value.element.name;
@ -215,10 +215,10 @@ static mxml_type_t xmlLoadStringCallback(mxml_node_t *node) {
if (myType == (MXML_INTEGER)) if (myType == (MXML_INTEGER))
sprintf(value, "%d", node->value.integer); sprintf(value, "%d", node->value.integer);
if (myType == (MXML_TEXT)) if (myType == (MXML_TEXT))
sprintf(value, "%s", "text"); sprintf(value, "%s", "text");
if (myType == (MXML_REAL)) if (myType == (MXML_REAL))
sprintf(value, "%f", node->value.real); sprintf(value, "%f", node->value.real);
@ -226,14 +226,14 @@ static mxml_type_t xmlLoadStringCallback(mxml_node_t *node) {
sprintf(value, "%s", node->value.opaque); sprintf(value, "%s", node->value.opaque);
/* /*
if (node->value.text.string != NULL) { if (node->value.text.string != NULL) {
if (myType == (MXML_TEXT)) if (myType == (MXML_TEXT))
snprintf(value, 132, "[%c]", node->value.text.string); snprintf(value, 132, "[%c]", node->value.text.string);
} }
*/ */
sprintf(line, "xmlLoadStringCallback: [%s] [%s] [%s] [%s] [%s] [%s]", node->value.element.name, type, mxmlElementGetAttr(node, "description"), mxmlElementGetAttr(node, "time"), mxmlElementGetAttr(node, "tag"), value); sprintf(line, "xmlLoadStringCallback: [%s] [%s] [%s] [%s] [%s] [%s]", node->value.element.name, type, mxmlElementGetAttr(node, "description"), mxmlElementGetAttr(node, "time"), mxmlElementGetAttr(node, "tag"), value);
SICSLogWrite(line, eLog); SICSLogWrite(line, eLog);
return myType; return myType;
} }
@ -266,7 +266,7 @@ static int GetCallback(pAsyncTxn txn)
/* free memory from previous tree */ /* free memory from previous tree */
if (tree) { if (tree) {
mxmlDelete(tree); mxmlDelete(tree);
} }
@ -295,7 +295,7 @@ static int MyOneShotCallback(void* context, int mode)
{ {
char line[132]; char line[132];
pLSSController self = (pLSSController) context; pLSSController self = (pLSSController) context;
self->oneshot = 0; self->oneshot = 0;
AsyncUnitSendTxn(self->unit, "WRITE 0", 7, NULL, NULL, 132); AsyncUnitSendTxn(self->unit, "WRITE 0", 7, NULL, NULL, 132);
@ -316,7 +316,7 @@ static int MyTimerCallback(void* context, int mode)
/* disable READ-polling timer for now - wait for reply ... */ /* disable READ-polling timer for now - wait for reply ... */
NetWatchRemoveTimer(self->nw_tmr); NetWatchRemoveTimer(self->nw_tmr);
AsyncUnitSendTxn(self->unit, "READ", 4, GetCallback, self, 1024*1024); AsyncUnitSendTxn(self->unit, "READ", 4, GetCallback, self, 1024*1024);
sprintf(line, "lssmonitor.c: MyTimerCallback() -> AsyncUnitSendTxn(READ 1MB)"); sprintf(line, "lssmonitor.c: MyTimerCallback() -> AsyncUnitSendTxn(READ 1MB)");
@ -425,28 +425,28 @@ static int LSS_Action(SConnection *pCon, SicsInterp *pSics,
return OKOK; return OKOK;
} }
else if (argc == 2) { else if (argc == 2) {
if (strcasecmp(argv[1], "list") == 0) { if (strcasecmp(argv[1], "list") == 0) {
current = tree; current = tree;
for (node = mxmlWalkNext(current, tree, MXML_DESCEND); node != NULL; node = mxmlWalkNext(node, tree, MXML_DESCEND)) { for (node = mxmlWalkNext(current, tree, MXML_DESCEND); node != NULL; node = mxmlWalkNext(node, tree, MXML_DESCEND)) {
if (node->value.element.attrs) { if (node->value.element.attrs) {
if (mxmlElementGetAttr(node, "version") == NULL) { if (mxmlElementGetAttr(node, "version") == NULL) {
snprintf(line, 132, "%s.%s %s = %s (%s)", argv[0], mxmlElementGetAttr(node, "description"), mxmlElementGetAttr(node, "tag"), node->child->value.text.string, mxmlElementGetAttr(node, "time")); snprintf(line, 132, "%s.%s %s = %s (%s)", argv[0], mxmlElementGetAttr(node, "description"), mxmlElementGetAttr(node, "tag"), node->child->value.text.string, mxmlElementGetAttr(node, "time"));
SCWrite(pCon, line, eLog); SCWrite(pCon, line, eLog);
} }
} }
} }
return OKOK; return OKOK;
} }
/* search by sub string */ /* search by sub string */
if (findElement(pCon, argv[1]) > 0) { if (findElement(pCon, argv[1]) > 0) {
return OKOK; return OKOK;
} }
} }
snprintf(line, 132, "%s does not understand %s", argv[0], argv[1]); snprintf(line, 132, "%s does not understand %s", argv[0], argv[1]);
@ -480,13 +480,13 @@ static int LSS_Init(pLSSController self)
NetWatchRemoveTimer(self->nw_tmr); NetWatchRemoveTimer(self->nw_tmr);
AsyncUnitSendTxn(self->unit, "READ", 4, GetCallback, self, 1024*1024); AsyncUnitSendTxn(self->unit, "READ", 4, GetCallback, self, 1024*1024);
/* /*
NetWatchRegisterTimerPeriodic(&self->nw_tmr, NetWatchRegisterTimerPeriodic(&self->nw_tmr,
2000, 2000, 2000, 2000,
MyTimerCallback, MyTimerCallback,
self); self);
self->timeout=120000; self->timeout=120000;
*/ */
return 1; return 1;
} }
@ -494,7 +494,7 @@ static int LSS_Init(pLSSController self)
static void LSS_Kill(void* pData) static void LSS_Kill(void* pData)
{ {
/* free memory from previous tree */ /* free memory from previous tree */
if (tree) { if (tree) {
mxmlDelete(tree); mxmlDelete(tree);
} }
@ -537,10 +537,10 @@ int LSSFactory(SConnection *pCon, SicsInterp *pSics,
} }
/* /*
create data structure and open port create data structure and open port
*/ */
pNew = LSS_Create(argv[2]); pNew = LSS_Create(argv[2]);
if(!pNew) if(!pNew)
{ {
SCWrite(pCon,"ERROR: failed to create LSS in LSSFactory",eError); SCWrite(pCon,"ERROR: failed to create LSS in LSSFactory",eError);
@ -553,7 +553,7 @@ int LSSFactory(SConnection *pCon, SicsInterp *pSics,
sprintf(pError,"ERROR: failed to connect to %s",argv[2]); sprintf(pError,"ERROR: failed to connect to %s",argv[2]);
SCWrite(pCon,pError,eError); SCWrite(pCon,pError,eError);
} }
/* /*
for (i=0; i < sizeof(lss_parname)/sizeof(lss_parname[0]); i++) { for (i=0; i < sizeof(lss_parname)/sizeof(lss_parname[0]); i++) {
lssVar = VarCreate(LSS_UserPriv,veText,lss_parname[i]); lssVar = VarCreate(LSS_UserPriv,veText,lss_parname[i]);
LSS_GetState(pNew,lss_parname[i],&lssState); LSS_GetState(pNew,lss_parname[i],&lssState);

View File

@ -1,7 +1,7 @@
/*----------------------------------------------------------------------------- /*-----------------------------------------------------------------------------
Based on SINQ code 1996-2003 by Mark Koennecke Based on SINQ code 1996-2003 by Mark Koennecke
Modifications: Paul Hathaway April 2004 Modifications: Paul Hathaway April 2004
SimRun failure rate independent of polling rate SimRun failure rate independent of polling rate
Fault condition determined at initial drive command and reported Fault condition determined at initial drive command and reported
@ -15,7 +15,7 @@
Instrument definition file usage: Instrument definition file usage:
Motor motname ASIM lowerlimit upperlimit failpercent [speed] Motor motname ASIM lowerlimit upperlimit failpercent [speed]
----------------------------------------------------------------------------*/ ----------------------------------------------------------------------------*/
#include <stdlib.h> #include <stdlib.h>
#include <assert.h> #include <assert.h>
@ -41,11 +41,11 @@
/* ----------------------- Simulation -----------------------------------*/ /* ----------------------- Simulation -----------------------------------*/
/* #ifndef SICS_ANSTO_MOTOR_ASIM */ /* #ifndef SICS_ANSTO_MOTOR_ASIM */
#define SICS_ANSTO_MOTOR_ASIM #define SICS_ANSTO_MOTOR_ASIM
#define MAX_LONG 2147483647 #define MAX_LONG 2147483647
/* device internal status and error codes */ /* device internal status and error codes */
/* BUSY - motor in motion toward target /* BUSY - motor in motion toward target
* IDLE - movement complete, normal condition * IDLE - movement complete, normal condition
* FAULT - no motion, motor awaiting reset * FAULT - no motion, motor awaiting reset
* CRASH - no motion, unable to recover * CRASH - no motion, unable to recover
@ -61,9 +61,9 @@
#define SETPOS "setpos" #define SETPOS "setpos"
#define BUFFLEN 512 #define BUFFLEN 512
/* the first fields of ASIMDriv structure HAVE to be IDENTICAL to the /* the first fields of ASIMDriv structure HAVE to be IDENTICAL to the
* abstract motor driver structure in modriv.h (motor_driver.h) * abstract motor driver structure in modriv.h (motor_driver.h)
*/ */
typedef struct ___MoDriv { typedef struct ___MoDriv {
/* general motor driver interface fields. REQUIRED! */ /* general motor driver interface fields. REQUIRED! */
@ -77,11 +77,11 @@ typedef struct ___MoDriv {
int (*TryAndFixIt)(void *self,int iError, float fNew); int (*TryAndFixIt)(void *self,int iError, float fNew);
int (*Halt)(void *self); int (*Halt)(void *self);
int (*GetDriverPar)(void *self, char *name, float *value); int (*GetDriverPar)(void *self, char *name, float *value);
int (*SetDriverPar)(void *self,SConnection *pCon, char *name, int (*SetDriverPar)(void *self,SConnection *pCon, char *name,
float newValue); float newValue);
void (*ListDriverPar)(void *self, char *motorName, SConnection *pCon); void (*ListDriverPar)(void *self, char *motorName, SConnection *pCon);
void (*KillPrivate)(void *self); void (*KillPrivate)(void *self);
/* ASIM-specific fields */ /* ASIM-specific fields */
pMotor pMot; /**< Points to logical motor object */ pMotor pMot; /**< Points to logical motor object */
float fFailure; /* percent random failures */ float fFailure; /* percent random failures */
@ -150,7 +150,7 @@ static int SimStat(void *self);
pDriv->iRunningTime += ((long)tD - pDriv->iLastPollTime); pDriv->iRunningTime += ((long)tD - pDriv->iLastPollTime);
} }
pDriv->iLastPollTime = (long)tD; pDriv->iLastPollTime = (long)tD;
} }
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
static void UpdatePosition(ASIMDriv *pDriv) static void UpdatePosition(ASIMDriv *pDriv)
{ {
@ -186,9 +186,9 @@ static int SimStat(void *self);
case ASIM_FAULT: case ASIM_FAULT:
motCode = HWFault; motCode = HWFault;
break; break;
} }
return motCode; return motCode;
} }
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
static int SimRun(void *self, float fVal) static int SimRun(void *self, float fVal)
{ {
@ -200,25 +200,25 @@ static int SimStat(void *self);
float fDelta; float fDelta;
float fDuration; float fDuration;
time_t tD; time_t tD;
assert(self); assert(self);
pDriv = (ASIMDriv *)self; pDriv = (ASIMDriv *)self;
switch (pDriv->iStatus) switch (pDriv->iStatus)
{ {
case ASIM_IDLE: pDriv->iStatus = ASIM_BUSY; case ASIM_IDLE: pDriv->iStatus = ASIM_BUSY;
case ASIM_BUSY: break; case ASIM_BUSY: break;
default: pDriv->iStatus = ASIM_CRASH; default: pDriv->iStatus = ASIM_CRASH;
case ASIM_CRASH: case ASIM_CRASH:
case ASIM_FAULT: return HWFault; case ASIM_FAULT: return HWFault;
break; break;
} }
/* New run command */ /* New run command */
/* Determine desired distance and direction (fDiff >= 0.0)*/ /* Determine desired distance and direction (fDiff >= 0.0)*/
pDriv->fDestination = fVal; pDriv->fDestination = fVal;
fDiff = fVal - pDriv->fPos; fDiff = fVal - pDriv->fPos;
if(0.0 > fDiff) if(0.0 > fDiff)
{ {
fDiff = -fDiff; fDiff = -fDiff;
fDirection = -1.0; fDirection = -1.0;
@ -231,7 +231,7 @@ static int SimStat(void *self);
iSucceed = 1; iSucceed = 1;
else else
iSucceed = 0; iSucceed = 0;
/* Determine delta from actual target by fault mode */ /* Determine delta from actual target by fault mode */
if (0 == iSucceed) if (0 == iSucceed)
{ {
@ -242,14 +242,14 @@ static int SimStat(void *self);
pDriv->iFaultType = ASIM_HW_FAULT; pDriv->iFaultType = ASIM_HW_FAULT;
fDelta = -fDiff; fDelta = -fDiff;
} }
else else
{ {
if (TH_STALL_FAULT > fFault) if (TH_STALL_FAULT > fFault)
{ /* stall before 80% complete */ { /* stall before 80% complete */
pDriv->iFaultType = ASIM_STALL_FAULT; pDriv->iFaultType = ASIM_STALL_FAULT;
fDelta = (-1.0) * fDiff * (0.2 + SimRandom()/125.0); fDelta = (-1.0) * fDiff * (0.2 + SimRandom()/125.0);
} }
else else
{ /* position fault to +/- 10% */ { /* position fault to +/- 10% */
pDriv->iFaultType = ASIM_POS_FAULT; pDriv->iFaultType = ASIM_POS_FAULT;
fDelta = fDiff * SimRandom()/1000.0; fDelta = fDiff * SimRandom()/1000.0;
@ -266,9 +266,9 @@ static int SimStat(void *self);
/* Calculate target and time using speed */ /* Calculate target and time using speed */
if (pDriv->fSpeed >= MIN_SPEED) if (pDriv->fSpeed >= MIN_SPEED)
{ {
fDiff = fDiff + fDelta; fDiff = fDiff + fDelta;
fDuration = fDiff/(pDriv->fSpeed); fDuration = fDiff/(pDriv->fSpeed);
if (fDuration > MAX_LONG) if (fDuration > MAX_LONG)
pDriv->iDuration = 2000000000; pDriv->iDuration = 2000000000;
else else
pDriv->iDuration = (long)fDuration; pDriv->iDuration = (long)fDuration;
@ -282,14 +282,14 @@ static int SimStat(void *self);
pDriv->iRunningTime = 0; pDriv->iRunningTime = 0;
pDriv->iLastPollTime = time(&tD); pDriv->iLastPollTime = time(&tD);
pDriv->iTime = tD + pDriv->iDuration; pDriv->iTime = tD + pDriv->iDuration;
if(ASIM_BUSY==pDriv->iStatus) if(ASIM_BUSY==pDriv->iStatus)
return OKOK; return OKOK;
else else
return HWFault; return HWFault;
} /* SimRun */ } /* SimRun */
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
/* iErrLen fixed to 131 in fn [reportAndFixError] of <motor.c> /* iErrLen fixed to 131 in fn [reportAndFixError] of <motor.c>
* iCode reported to SimFix via [reportAndFixError] * iCode reported to SimFix via [reportAndFixError]
@ -298,27 +298,27 @@ static int SimStat(void *self);
{ {
int motCode = HWFault; int motCode = HWFault;
ASIMDriv *pDriv; ASIMDriv *pDriv;
assert(self); assert(self);
pDriv = (ASIMDriv *)self; pDriv = (ASIMDriv *)self;
switch (pDriv->iStatus) switch (pDriv->iStatus)
{ {
case ASIM_IDLE: motCode = HWIdle; break; case ASIM_IDLE: motCode = HWIdle; break;
case ASIM_BUSY: motCode = HWBusy; break; case ASIM_BUSY: motCode = HWBusy; break;
case ASIM_CRASH: case ASIM_CRASH:
case ASIM_FAULT: case ASIM_FAULT:
default: motCode = HWFault; break; default: motCode = HWFault; break;
} }
*iCode = pDriv->iFaultType; *iCode = pDriv->iFaultType;
switch (pDriv->iFaultType) switch (pDriv->iFaultType)
{ {
case ASIM_POS_FAULT: case ASIM_POS_FAULT:
strncpy(error,"ERROR: ASIM Position Fault",iErrLen); strncpy(error,"ERROR: ASIM Position Fault",iErrLen);
break; break;
case ASIM_NO_FAULT: case ASIM_NO_FAULT:
strncpy(error,"STATUS: ASIM No Fault",iErrLen); strncpy(error,"STATUS: ASIM No Fault",iErrLen);
break; break;
case ASIM_HW_FAULT: case ASIM_HW_FAULT:
@ -333,18 +333,18 @@ static int SimStat(void *self);
} }
assert(strlen(error)<131); assert(strlen(error)<131);
} /* SimError */ } /* SimError */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static int SimFix(void *self, int iError, float fNew) static int SimFix(void *self, int iError, float fNew)
{ {
ASIMDriv *pDriv; ASIMDriv *pDriv;
assert(self); assert(self);
pDriv = (ASIMDriv *)self; pDriv = (ASIMDriv *)self;
switch (pDriv->iStatus) switch (pDriv->iStatus)
{ {
case ASIM_IDLE: case ASIM_IDLE:
switch (pDriv->iFaultType) switch (pDriv->iFaultType)
{ {
case ASIM_POS_FAULT: return MOTOK; case ASIM_POS_FAULT: return MOTOK;
@ -354,11 +354,11 @@ static int SimStat(void *self);
default: return MOTFAIL; /* error: unknown fault type */ default: return MOTFAIL; /* error: unknown fault type */
} }
break; break;
case ASIM_BUSY: return MOTOK; break; case ASIM_BUSY: return MOTOK; break;
case ASIM_CRASH: return MOTFAIL; break; case ASIM_CRASH: return MOTFAIL; break;
case ASIM_FAULT: case ASIM_FAULT:
SimHalt(self); SimHalt(self);
if(TH_HW_FAULT >= SimRandom()) if(TH_HW_FAULT >= SimRandom())
{ {
pDriv->iStatus = ASIM_CRASH; pDriv->iStatus = ASIM_CRASH;
return MOTFAIL; return MOTFAIL;
@ -367,11 +367,11 @@ static int SimStat(void *self);
pDriv->iFaultType = ASIM_NO_FAULT; pDriv->iFaultType = ASIM_NO_FAULT;
return MOTOK; return MOTOK;
break; break;
default: default:
pDriv->iStatus = ASIM_CRASH; pDriv->iStatus = ASIM_CRASH;
pDriv->iFaultType = ASIM_HW_FAULT; pDriv->iFaultType = ASIM_HW_FAULT;
return MOTFAIL; return MOTFAIL;
} }
/* SICSLogWrite("Attempt fix for simulated motor",eHWError); */ /* SICSLogWrite("Attempt fix for simulated motor",eHWError); */
} /* SimFix */ } /* SimFix */
@ -381,7 +381,7 @@ static int SimStat(void *self);
int motCode = OKOK; int motCode = OKOK;
ASIMDriv *pDriv; ASIMDriv *pDriv;
assert(self); assert(self);
pDriv = (ASIMDriv *)self; pDriv = (ASIMDriv *)self;
UpdatePosition(pDriv); UpdatePosition(pDriv);
pDriv->iTime = 0; pDriv->iTime = 0;
@ -406,7 +406,7 @@ static int SimStat(void *self);
assert(self); assert(self);
pDriv = (ASIMDriv *)self; pDriv = (ASIMDriv *)self;
UpdatePosition(pDriv); UpdatePosition(pDriv);
switch (pDriv->iStatus) switch (pDriv->iStatus)
{ {
case ASIM_BUSY: motCode = HWBusy; break; case ASIM_BUSY: motCode = HWBusy; break;
@ -438,7 +438,7 @@ static int SimSetPar(void *self, SConnection *pCon, char *name, float newValue)
{ {
pDriv->fSpeed = newValue; pDriv->fSpeed = newValue;
iSuccess = 1; iSuccess = 1;
} }
return iSuccess; return iSuccess;
} }
@ -473,7 +473,7 @@ static void SimListPar(void *self, char *motorName, SConnection *pCon)
/* ASIMDriv *pDriv = (ASIMDriv *) self; /* ASIMDriv *pDriv = (ASIMDriv *) self;
char pBuffer[256]; char pBuffer[256];
*/ */
assert(self); assert(self);
assert(pCon); assert(pCon);
/* The logical motor does this for us /* The logical motor does this for us
@ -495,7 +495,7 @@ static void SimListPar(void *self, char *motorName, SConnection *pCon)
*/ */
return; return;
} }
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
MotorDriver *CreateASIM(SConnection *pCon, char *motor, char *params) MotorDriver *CreateASIM(SConnection *pCon, char *motor, char *params)
{ {
@ -503,10 +503,10 @@ MotorDriver *CreateASIM(SConnection *pCon, char *motor, char *params)
time_t tD; time_t tD;
char *pPtr = NULL; char *pPtr = NULL;
Tcl_Interp *interp; Tcl_Interp *interp;
assert(pCon); assert(pCon);
interp = InterpGetTcl(pServ->pSics); interp = InterpGetTcl(pServ->pSics);
/* allocate memory */ /* allocate memory */
pDriv = (ASIMDriv *)malloc(sizeof(ASIMDriv)); pDriv = (ASIMDriv *)malloc(sizeof(ASIMDriv));
if(!pDriv) if(!pDriv)
@ -531,13 +531,13 @@ MotorDriver *CreateASIM(SConnection *pCon, char *motor, char *params)
} }
sscanf(pPtr,"%s",pDriv->units); sscanf(pPtr,"%s",pDriv->units);
pDriv->fFailure = 0; pDriv->fFailure = 0;
/* calculate current position, initialise func pters */ /* calculate current position, initialise func pters */
pDriv->fPos = (pDriv->fUpper + pDriv->fLower)/2.0; pDriv->fPos = (pDriv->fUpper + pDriv->fLower)/2.0;
/* pDriv->name = strdup("SICS_ANSTO_MOTOR_ASIM"); */ /* pDriv->name = strdup("SICS_ANSTO_MOTOR_ASIM"); */
pDriv->name = malloc((1+strlen("SICS_ANSTO_MOTOR_ASIM"))*sizeof(char)); pDriv->name = malloc((1+strlen("SICS_ANSTO_MOTOR_ASIM"))*sizeof(char));
strcpy(pDriv->name,"SICS_ANSTO_MOTOR_ASIM"); strcpy(pDriv->name,"SICS_ANSTO_MOTOR_ASIM");
pDriv->GetPosition = SimGetPos; pDriv->GetPosition = SimGetPos;
pDriv->RunTo = SimRun; pDriv->RunTo = SimRun;
pDriv->GetStatus = SimStat; pDriv->GetStatus = SimStat;
@ -548,7 +548,7 @@ MotorDriver *CreateASIM(SConnection *pCon, char *motor, char *params)
pDriv->GetDriverPar = SimGetPar; pDriv->GetDriverPar = SimGetPar;
pDriv->ListDriverPar = SimListPar; pDriv->ListDriverPar = SimListPar;
pDriv->KillPrivate = SimKill; pDriv->KillPrivate = SimKill;
/* set default parameters */ /* set default parameters */
pDriv->fSpeed = 1.0; pDriv->fSpeed = 1.0;
pDriv->iTime = time(&tD); pDriv->iTime = time(&tD);
@ -559,7 +559,7 @@ MotorDriver *CreateASIM(SConnection *pCon, char *motor, char *params)
pDriv->fTarget = pDriv->fPos; pDriv->fTarget = pDriv->fPos;
pDriv->fDestination = pDriv->fPos; pDriv->fDestination = pDriv->fPos;
pDriv->iStatus = OKOK; pDriv->iStatus = OKOK;
srand( (unsigned)time( NULL ) ); srand( (unsigned)time( NULL ) );
return (MotorDriver *)pDriv; return (MotorDriver *)pDriv;

View File

@ -1671,7 +1671,7 @@ static int rspStatus(pDMC2280Driv self, const char* text) {
&iStopCode, &iTIzero, &iTIone, &iXQ0); &iStopCode, &iTIzero, &iTIone, &iXQ0);
if (iRet != 8) if (iRet != 8)
return 0; return 0;
/* TODO Put the following in specialised response handlers */ /* TODO Put the following in specialised response handlers */
if (self->ao_id[0] != '\0') { if (self->ao_id[0] != '\0') {
AO_istatus(iTIone, "QKK:TI1"); AO_istatus(iTIone, "QKK:TI1");
} }

View File

@ -17,7 +17,7 @@
int (*TryAndFixIt)(void *self, int iError,float fNew); int (*TryAndFixIt)(void *self, int iError,float fNew);
int (*Halt)(void *self); int (*Halt)(void *self);
int (*GetDriverPar)(void *self, char *name, float *value); int (*GetDriverPar)(void *self, char *name, float *value);
int (*SetDriverPar)(void *self,SConnection *pCon, char *name, int (*SetDriverPar)(void *self,SConnection *pCon, char *name,
float newValue); float newValue);
void (*ListDriverPar)(void *self, char *motorName, SConnection *pCon); void (*ListDriverPar)(void *self, char *motorName, SConnection *pCon);
void (*KillPrivate)(void *self); void (*KillPrivate)(void *self);

View File

@ -1282,7 +1282,7 @@ int NHQ200Wrapper(SConnection *pCon, SicsInterp *pSics, void *pData,
if (strcasecmp("rate", argv[1]) == 0) { if (strcasecmp("rate", argv[1]) == 0) {
char rsp[CMDLEN]; char rsp[CMDLEN];
if (argc > 2) { if (argc > 2) {
if (!SCMatchRights(pCon, usUser)) if (!SCMatchRights(pCon, usUser))
return 0; return 0;
if (priv->isLocked && !SCMatchRights(pCon, usMugger)) { if (priv->isLocked && !SCMatchRights(pCon, usMugger)) {
SCWrite(pCon, "object is locked", eError); SCWrite(pCon, "object is locked", eError);

View File

@ -107,8 +107,8 @@ static int ORHV_SendReceive(pORHVPSDriv priv,
int *rep_len) { int *rep_len) {
int status; int status;
if (!*cmd) if (!*cmd)
{ {
*reply='\0'; *reply='\0';
*rep_len=0; *rep_len=0;
return FAILURE; return FAILURE;
@ -302,7 +302,7 @@ static void ORHVState_Unknown(pStateMachine sm, pEvtEvent event) {
char line[132]; char line[132];
*p = '\0'; *p = '\0';
sprintf(line, "Version: %s", pCmd->inp_buf); sprintf(line, "Version: %s", pCmd->inp_buf);
SICSLogWrite(line, eLog); SICSLogWrite(line, eLog);
} }
ORHV_SendCmd(priv, "Hz", 2, fsm_msg_callback); ORHV_SendCmd(priv, "Hz", 2, fsm_msg_callback);
sm->mySubState = 2; sm->mySubState = 2;
@ -1051,7 +1051,7 @@ int ORHVPSWrapper(SConnection *pCon, SicsInterp *pSics, void *pData,
// we also allow the third argument to be an explicit command/response format. // we also allow the third argument to be an explicit command/response format.
// This is in format "<cmd>-<resp>" where the command and response fields // This is in format "<cmd>-<resp>" where the command and response fields
// are format specifiers containing the required/expected ASCII letters // are format specifiers containing the required/expected ASCII letters
// in the command, and the format specifiers '%s' (string), // in the command, and the format specifiers '%s' (string),
// '%d' (integer 0-255), , '%B' (a board name e.g. x0-y15), // '%d' (integer 0-255), , '%B' (a board name e.g. x0-y15),
// '%P' (a pot name e.g. x0-y191), or '%A' (ack code as 'ACK'/'NAK'). // '%P' (a pot name e.g. x0-y191), or '%A' (ack code as 'ACK'/'NAK').
// Formats '%c' (a character) and '%x' (char as 2 hex digits) could be // Formats '%c' (a character) and '%x' (char as 2 hex digits) could be
@ -1077,7 +1077,7 @@ int ORHVPSWrapper(SConnection *pCon, SicsInterp *pSics, void *pData,
case 'l': pcmdrspfmt="l%Bz-%A"; break; // Re-enable a board case 'l': pcmdrspfmt="l%Bz-%A"; break; // Re-enable a board
case 'J': pcmdrspfmt="Jz-J%dz"; break; // Check jumper settings case 'J': pcmdrspfmt="Jz-J%dz"; break; // Check jumper settings
} }
// Prepare the command string // Prepare the command string
char *pcmd=cmd; char *pcmd=cmd;
int nfmtspec=0; int nfmtspec=0;
while(*pcmdrspfmt!='-') while(*pcmdrspfmt!='-')
@ -1101,7 +1101,7 @@ int ORHVPSWrapper(SConnection *pCon, SicsInterp *pSics, void *pData,
{ {
case 's': // probably never used case 's': // probably never used
pcmd+=sprintf(pcmd,"%s",argv[nfmtspec+2]); pcmd+=sprintf(pcmd,"%s",argv[nfmtspec+2]);
break; break;
case 'd': case 'd':
sscanf(argv[nfmtspec+2],"%d",&v1); sscanf(argv[nfmtspec+2],"%d",&v1);
pcmd+=sprintf(pcmd,"%c",(char)v1); pcmd+=sprintf(pcmd,"%c",(char)v1);
@ -1366,7 +1366,7 @@ int ORHVPSWrapper(SConnection *pCon, SicsInterp *pSics, void *pData,
if (strcasecmp("rate", argv[1]) == 0) { if (strcasecmp("rate", argv[1]) == 0) {
char rsp[CMDLEN]; char rsp[CMDLEN];
if (argc > 2) { if (argc > 2) {
if (!SCMatchRights(pCon, usUser)) if (!SCMatchRights(pCon, usUser))
return 0; return 0;
if (priv->isLocked && !SCMatchRights(pCon, usMugger)) { if (priv->isLocked && !SCMatchRights(pCon, usMugger)) {
SCWrite(pCon, "object is locked", eError); SCWrite(pCon, "object is locked", eError);

View File

@ -1,7 +1,7 @@
/*--------------------------------------------------------------------------- /*---------------------------------------------------------------------------
REFL2T.c REFL2T.c
Paul Hathaway, Nick Hauser, Mark Koennecke, February 2004 Paul Hathaway, Nick Hauser, Mark Koennecke, February 2004
---------------------------------------------------------------------------*/ ---------------------------------------------------------------------------*/
#include <stdlib.h> #include <stdlib.h>
#include <assert.h> #include <assert.h>
@ -31,13 +31,13 @@ Paul Hathaway, Nick Hauser, Mark Koennecke, February 2004
/*====================================================================== /*======================================================================
The core of it all: The calculation of the settings for the various The core of it all: The calculation of the settings for the various
motors. motors.
========================================================================*/ ========================================================================*/
static int CalculateREFL(pRefl2T self, SConnection *pCon, float fNew) static int CalculateREFL(pRefl2T self, SConnection *pCon, float fNew)
{ {
float fDetPos, HeightOffset, DetLength; float fDetPos, HeightOffset, DetLength;
int iRet; int iRet;
/* assume: solid sample, horizontal beam, surface at height zero */ /* assume: solid sample, horizontal beam, surface at height zero */
/* read vals of motor coy */ /* read vals of motor coy */
@ -52,10 +52,10 @@ Paul Hathaway, Nick Hauser, Mark Koennecke, February 2004
/* calculate det height above beam axis */ /* calculate det height above beam axis */
/* add detector offset height */ /* add detector offset height */
fNew = DetLength * tan((double)(fNew * PI / 180.0)) + HeightOffset ; fNew = DetLength * tan((double)(fNew * PI / 180.0)) + HeightOffset ;
self->fTarget = fNew; self->fTarget = fNew;
return 1; return 1;
/* Replacement code using MotEntry structure /* Replacement code using MotEntry structure
self->toStart[MOTCOZ].pMot = self->aEngine[MOTCOZ]; self->toStart[MOTCOZ].pMot = self->aEngine[MOTCOZ];
@ -81,7 +81,7 @@ Paul Hathaway, Nick Hauser, Mark Koennecke, February 2004
{ {
return iRet; return iRet;
} }
/* start them all */ /* start them all */
/* for(i = 0; i < self->iStart; i++) /* for(i = 0; i < self->iStart; i++)
{*/ {*/
@ -94,13 +94,13 @@ Paul Hathaway, Nick Hauser, Mark Koennecke, February 2004
if(iRet != OKOK) if(iRet != OKOK)
{ {
return iRet; return iRet;
} }
} }
/* } */ /* } */
return OKOK; return OKOK;
} }
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
static int R2THalt(void *pData) static int R2THalt(void *pData)
{ {
@ -118,7 +118,7 @@ Paul Hathaway, Nick Hauser, Mark Koennecke, February 2004
if(pDriv != NULL) if(pDriv != NULL)
{ {
iRet = pDriv->Halt(self->aEngine[MOTCOZ].pMot); iRet = pDriv->Halt(self->aEngine[MOTCOZ].pMot);
} }
/* } */ /* } */
return OKOK; return OKOK;
} }
@ -130,7 +130,7 @@ Paul Hathaway, Nick Hauser, Mark Koennecke, February 2004
pRefl2T self = (pRefl2T) pData; pRefl2T self = (pRefl2T) pData;
SConnection *pDumCon = NULL; SConnection *pDumCon = NULL;
/* Define code for this function */ /* Define code for this function */
assert(self); assert(self);
pDumCon = SCCreateDummyConnection(pServ->pSics); pDumCon = SCCreateDummyConnection(pServ->pSics);
assert(pDumCon); assert(pDumCon);
@ -142,7 +142,7 @@ Paul Hathaway, Nick Hauser, Mark Koennecke, February 2004
{ {
return iRet; return iRet;
} }
/* check them all */ /* check them all */
/* for(i = 0; i < self->iStart; i++) /* for(i = 0; i < self->iStart; i++)
{*/ {*/
@ -156,39 +156,39 @@ Paul Hathaway, Nick Hauser, Mark Koennecke, February 2004
if(iRet != 1) if(iRet != 1)
{ {
return iRet; return iRet;
} }
} }
/* } */ /* } */
return 1; return 1;
} }
static float R2TGetValue(void *pData, SConnection *pCon) static float R2TGetValue(void *pData, SConnection *pCon)
{ {
pRefl2T self = (pRefl2T) pData; pRefl2T self = (pRefl2T) pData;
assert(self); assert(self);
return fResult; return fResult;
} }
static void *R2TGetInterface(void *pData, int iID) static void *R2TGetInterface(void *pData, int iID)
{ {
pRefl2T self = (pRefl2T) pData; pRefl2T self = (pRefl2T) pData;
assert(self); assert(self);
if(iID == DRIVEID) if(iID == DRIVEID)
{ {
return self->pDriv; return self->pDriv;
} }
return NULL; return NULL;
} }
static void Refl2TKill(void *pData) static void Refl2TKill(void *pData)
{ {
pRefl2T self = (pRefl2T) pData; pRefl2T self = (pRefl2T) pData;
if(self == NULL) if(self == NULL)
return; return;
@ -206,7 +206,7 @@ Paul Hathaway, Nick Hauser, Mark Koennecke, February 2004
/*-------------------------------------------------------------------------- /*--------------------------------------------------------------------------
Initialization: All is done from the Factory function. This takes an Tcl Initialization: All is done from the Factory function. This takes an Tcl
array as parameter which is supposed to hold the names of all motors. array as parameter which is supposed to hold the names of all motors.
This must fail if one of the motors cannot be accessed. This must fail if one of the motors cannot be accessed.
--------------------------------------------------------------------------*/ --------------------------------------------------------------------------*/
int Refl2TFactory(SConnection *pCon, SicsInterp *pSics, void *pData, int Refl2TFactory(SConnection *pCon, SicsInterp *pSics, void *pData,
int argc, char *argv[]) int argc, char *argv[])
@ -249,7 +249,7 @@ Paul Hathaway, Nick Hauser, Mark Koennecke, February 2004
SCWrite(pCon,"ERROR: no value for coz motr found",eError); SCWrite(pCon,"ERROR: no value for coz motr found",eError);
Refl2TKill(pNew); Refl2TKill(pNew);
return 0; return 0;
} }
pNew->aMot[MOTCOZ] = FindMotor(pSics,pMot); pNew->aMot[MOTCOZ] = FindMotor(pSics,pMot);
if(!pNew->aEngine[MOTCOZ]) if(!pNew->aEngine[MOTCOZ])
{ {
@ -265,7 +265,7 @@ Paul Hathaway, Nick Hauser, Mark Koennecke, February 2004
SCWrite(pCon,"ERROR: no value for coy motor found",eError); SCWrite(pCon,"ERROR: no value for coy motor found",eError);
Refl2TKill(pNew); Refl2TKill(pNew);
return 0; return 0;
} }
pNew->aEngine[MOTCOY] = FindMotor(pSics,pMot); pNew->aEngine[MOTCOY] = FindMotor(pSics,pMot);
if(!pNew->aEngine[MOTCOY]) if(!pNew->aEngine[MOTCOY])
{ {
@ -281,7 +281,7 @@ Paul Hathaway, Nick Hauser, Mark Koennecke, February 2004
SCWrite(pCon,"ERROR: no value for coz motor found",eError); SCWrite(pCon,"ERROR: no value for coz motor found",eError);
Refl2TKill(pNew); Refl2TKill(pNew);
return 0; return 0;
} }
pNew->aEngine[MOTSOZ] = FindMotor(pSics,pMot); pNew->aEngine[MOTSOZ] = FindMotor(pSics,pMot);
if(!pNew->aEngine[MOTSOZ]) if(!pNew->aEngine[MOTSOZ])
{ {
@ -389,7 +389,7 @@ Paul Hathaway, Nick Hauser, Mark Koennecke, February 2004
assert(pCon); assert(pCon);
assert(self); assert(self);
Tcl_DStringInit(&tString); Tcl_DStringInit(&tString);
sprintf(pBueffel, sprintf(pBueffel,
"%s.detectord %f \n", name, ObVal(self->aParameter,PARDDD)); "%s.detectord %f \n", name, ObVal(self->aParameter,PARDDD));
@ -399,5 +399,5 @@ Paul Hathaway, Nick Hauser, Mark Koennecke, February 2004
Tcl_DStringInit(&tString); Tcl_DStringInit(&tString);
sprintf(pBueffel, sprintf(pBueffel,
"%s.sampleoffset %f \n", name, ObVal(self->aParameter,PARDSO)); "%s.sampleoffset %f \n", name, ObVal(self->aParameter,PARDSO));
} }

View File

@ -6,7 +6,7 @@
#define MAXMOT = 3; #define MAXMOT = 3;
/* aMot is the array of motors that includes the /* aMot is the array of motors that includes the
1. sample stage height motor 1. sample stage height motor
2. detector x motor 2. detector x motor
3. detector z motor 3. detector z motor
@ -46,4 +46,4 @@
float fTarget; float fTarget;
int iLast; int iLast;
}MotEntry, *pMotEntry; }MotEntry, *pMotEntry;

View File

@ -35,11 +35,11 @@ extern int DMC2280MotionControl;
#define INST_READY_BIT (1 << 16) #define INST_READY_BIT (1 << 16)
#define LAMP_TEST_BIT (1 << 17) #define LAMP_TEST_BIT (1 << 17)
#define KEY_BOTH_BITS (KEY_ENABLED_BIT | KEY_DISABLED_BIT) #define KEY_BOTH_BITS (KEY_ENABLED_BIT | KEY_DISABLED_BIT)
#define SEC_BOTH_BITS (SEC_OPENED_BIT | SEC_CLOSED_BIT) #define SEC_BOTH_BITS (SEC_OPENED_BIT | SEC_CLOSED_BIT)
#define TER_BOTH_BITS (TER_OPENED_BIT | TER_CLOSED_BIT) #define TER_BOTH_BITS (TER_OPENED_BIT | TER_CLOSED_BIT)
#define MOTOR_BOTH_BITS (MOTOR_ENABLED_BIT | MOTOR_DISABLED_BIT) #define MOTOR_BOTH_BITS (MOTOR_ENABLED_BIT | MOTOR_DISABLED_BIT)
#define ACCESS_BOTH_BITS (ACCESS_LOCKED_BIT | ACCESS_UNLOCKED_BIT) #define ACCESS_BOTH_BITS (ACCESS_LOCKED_BIT | ACCESS_UNLOCKED_BIT)
static pAsyncProtocol PLC_Protocol = NULL; static pAsyncProtocol PLC_Protocol = NULL;
@ -503,10 +503,10 @@ int SafetyPLCFactory(SConnection *pCon, SicsInterp *pSics,
} }
/* /*
create data structure and open port create data structure and open port
*/ */
pNew = PLC_Create(argv[2]); pNew = PLC_Create(argv[2]);
if(!pNew) if(!pNew)
{ {
SCWrite(pCon,"ERROR: failed to create SafetyPLC in SafetyPLCFactory",eError); SCWrite(pCon,"ERROR: failed to create SafetyPLC in SafetyPLCFactory",eError);
@ -519,7 +519,7 @@ int SafetyPLCFactory(SConnection *pCon, SicsInterp *pSics,
sprintf(pError,"ERROR: failed to connect to %s",argv[2]); sprintf(pError,"ERROR: failed to connect to %s",argv[2]);
SCWrite(pCon,pError,eError); SCWrite(pCon,pError,eError);
} }
for (i=0; i < sizeof(plc_parname)/sizeof(plc_parname[0]); i++) { for (i=0; i < sizeof(plc_parname)/sizeof(plc_parname[0]); i++) {
plcVar = VarCreate(PLC_UserPriv,veText,plc_parname[i]); plcVar = VarCreate(PLC_UserPriv,veText,plc_parname[i]);
PLC_GetState(pNew,plc_parname[i],&plcState); PLC_GetState(pNew,plc_parname[i],&plcState);

View File

@ -39,8 +39,8 @@ static void SetModeNode(pSctEmon self, EVMode mode)
*/ */
static void *SCTEmonGetInterface(void *pData, int ID){ static void *SCTEmonGetInterface(void *pData, int ID){
pSctEmon self = NULL; pSctEmon self = NULL;
self = (pSctEmon)pData; self = (pSctEmon)pData;
assert(self); assert(self);
if (self->modeNode == NULL || self->tolNode == NULL || self->errNode == NULL) if (self->modeNode == NULL || self->tolNode == NULL || self->errNode == NULL)
@ -63,8 +63,8 @@ Convert mode string from the evmode textnode value to
------------------------------------------------------------------*/ ------------------------------------------------------------------*/
static EVMode SCTEmonGetMode(void *pData) static EVMode SCTEmonGetMode(void *pData)
{ {
pSctEmon self = NULL; pSctEmon self = NULL;
self = (pSctEmon)pData; self = (pSctEmon)pData;
assert(self); assert(self);
switch(self->modeNode->value.v.text[0]) { switch(self->modeNode->value.v.text[0]) {
@ -92,8 +92,8 @@ static EVMode SCTEmonGetMode(void *pData)
} }
} }
/*---------------------------------------------------------------- /*----------------------------------------------------------------
This routine can return 0 when a limit problem occurred This routine can return 0 when a limit problem occurred
OKOK when the motor was successfully started OKOK when the motor was successfully started
HWFault when a problem occured starting the device HWFault when a problem occured starting the device
Possible errors shall be printed to pCon Possible errors shall be printed to pCon
For real motors, this is supposed to try at least three times For real motors, this is supposed to try at least three times
@ -103,7 +103,7 @@ Reads value from the "isintolerance" node (1 or 0)
------------------------------------------------------------------*/ ------------------------------------------------------------------*/
static int SCTEmonIsInTolerance(void *pData) static int SCTEmonIsInTolerance(void *pData)
{ {
pSctEmon self = NULL; pSctEmon self = NULL;
pExeList pExe; pExeList pExe;
char pBueffel[512]; char pBueffel[512];
char monMode; char monMode;
@ -133,15 +133,15 @@ static int SCTEmonIsInTolerance(void *pData)
HWFault when a hardware problem ocurred HWFault when a hardware problem ocurred
HWPosFault when the hardware cannot reach a position HWPosFault when the hardware cannot reach a position
Errors are duly to be printed to pCon Errors are duly to be printed to pCon
For real motors CheckStatus again shall try hard to fix any For real motors CheckStatus again shall try hard to fix any
issues with the motor issues with the motor
The HandleError node value can be one of Lazy, Pause, Interrupt, Safe The HandleError node value can be one of Lazy, Pause, Interrupt, Safe
NOTE: emon ignores the returned iStatus value NOTE: emon ignores the returned iStatus value
------------------------------------------------------------------*/ ------------------------------------------------------------------*/
static int SCTEmonHandleError(void *pData) static int SCTEmonHandleError(void *pData)
{ {
pSctEmon self = NULL; pSctEmon self = NULL;
pExeList pExe; pExeList pExe;
int iRet, iHandler, iStatus; int iRet, iHandler, iStatus;
char monMode; char monMode;
@ -166,7 +166,7 @@ static int SCTEmonHandleError(void *pData)
PauseExecution(pExe); PauseExecution(pExe);
self->iPaused = 1; self->iPaused = 1;
//XXX nopause SetModeNode(self, EVPaused); //XXX nopause SetModeNode(self, EVPaused);
iStatus = 1; iStatus = 1;
} }
break; break;
case 'i': case 'i':
@ -180,7 +180,7 @@ static int SCTEmonHandleError(void *pData)
/*TODO Drive environment to a safevalue */ /*TODO Drive environment to a safevalue */
break; break;
default: default:
return 0; return 0;
} }
/* NOTE: emon ignores the return value */ /* NOTE: emon ignores the return value */
@ -190,7 +190,7 @@ static int SCTEmonHandleError(void *pData)
returns NULL on failure, a new datastructure else returns NULL on failure, a new datastructure else
------------------------------------------------------------------*/ ------------------------------------------------------------------*/
static pSctEmon SCTEMONMakeObject(){ static pSctEmon SCTEMONMakeObject(){
pSctEmon self = NULL; pSctEmon self = NULL;
self = calloc(sizeof(SctEmon),1); self = calloc(sizeof(SctEmon),1);
if(self == NULL){ if(self == NULL){
@ -214,7 +214,7 @@ static pSctEmon SCTEMONMakeObject(){
free(self); free(self);
return NULL; return NULL;
} }
self->pDes->GetInterface = SCTEmonGetInterface; self->pDes->GetInterface = SCTEmonGetInterface;
self->pEVI->GetMode = SCTEmonGetMode; self->pEVI->GetMode = SCTEmonGetMode;
self->pEVI->IsInTolerance = SCTEmonIsInTolerance; self->pEVI->IsInTolerance = SCTEmonIsInTolerance;
@ -246,33 +246,33 @@ int SctMakeEmonAdapter(SConnection *pCon, SicsInterp *pSics, void *object,
int argc, char *argv[]) { int argc, char *argv[]) {
pSctEmon pNew = NULL; pSctEmon pNew = NULL;
hdbCallback *cb; hdbCallback *cb;
if(argc < 5){ if(argc < 5){
SCWrite(pCon,"ERROR: not enough arguments for SctMakeEmonAdapter", eError); SCWrite(pCon,"ERROR: not enough arguments for SctMakeEmonAdapter", eError);
return 0; return 0;
} }
pNew = SCTEMONMakeObject(); pNew = SCTEMONMakeObject();
if(pNew == NULL){ if(pNew == NULL){
SCWrite(pCon,"ERROR: out of memory in SctMakeEmonAdapter", SCWrite(pCon,"ERROR: out of memory in SctMakeEmonAdapter",
eError); eError);
return 0; return 0;
} }
pNew->pName = strdup(argv[1]); pNew->pName = strdup(argv[1]);
pNew->modeNode = FindHdbNode(NULL,argv[2], pCon); pNew->modeNode = FindHdbNode(NULL,argv[2], pCon);
pNew->tolNode = FindHdbNode(NULL,argv[3], pCon); pNew->tolNode = FindHdbNode(NULL,argv[3], pCon);
pNew->errNode = FindHdbNode(NULL,argv[4], pCon); pNew->errNode = FindHdbNode(NULL,argv[4], pCon);
pNew->iPaused = 0; pNew->iPaused = 0;
/*XXX I'm guessing that SctEmonDeleteNode will be called when the /*XXX I'm guessing that SctEmonDeleteNode will be called when the
script context object is deleted. So the emon functions should check script context object is deleted. So the emon functions should check
if node == NULL before trying to do something */ if node == NULL before trying to do something */
cb = MakeHipadabaCallback(SctDummyCallback, pNew, SctEmonDeleteNode); cb = MakeHipadabaCallback(SctDummyCallback, pNew, SctEmonDeleteNode);
assert(cb); assert(cb);
AppendHipadabaCallback(pNew->modeNode, cb); AppendHipadabaCallback(pNew->modeNode, cb);
EVRegisterController(FindEMON(pSics),argv[1],pNew, pCon); EVRegisterController(FindEMON(pSics),argv[1],pNew, pCon);
return 1; return 1;
} }
/*---------------------------------------------------------------*/ /*---------------------------------------------------------------*/

View File

@ -407,7 +407,7 @@ static void RemoveCommands(SicsInterp *pSics){
/* create the motor */ /* create the motor */
strtolower(argv[1]); strtolower(argv[1]);
if(strcmp(argv[1],"dmc2280") == 0) { if(strcmp(argv[1],"dmc2280") == 0) {
pDriver = (MotorDriver *)CreateDMC2280(pCon,argv[0],argv[2]); pDriver = (MotorDriver *)CreateDMC2280(pCon,argv[0],argv[2]);
if(!pDriver){ if(!pDriver){
return NULL; return NULL;
} }
@ -415,7 +415,7 @@ static void RemoveCommands(SicsInterp *pSics){
if(!pNew) { if(!pNew) {
sprintf(pBueffel,"ERROR:SITE: Failure to create motor %s",argv[1]); sprintf(pBueffel,"ERROR:SITE: Failure to create motor %s",argv[1]);
SCWrite(pCon,pBueffel,eError); SCWrite(pCon,pBueffel,eError);
return NULL; return NULL;
} }
pNew->pActionRoutine = DMC2280Action; pNew->pActionRoutine = DMC2280Action;
} }
@ -428,7 +428,7 @@ static void RemoveCommands(SicsInterp *pSics){
if(!pNew) { if(!pNew) {
sprintf(pBueffel,"ERROR:SITE: Failure to create motor %s",argv[1]); sprintf(pBueffel,"ERROR:SITE: Failure to create motor %s",argv[1]);
SCWrite(pCon,pBueffel,eError); SCWrite(pCon,pBueffel,eError);
return NULL; return NULL;
} }
pNew->pActionRoutine = SimAction; pNew->pActionRoutine = SimAction;
} }
@ -456,14 +456,14 @@ static pCounterDriver CreateCounterDriverAnsto(SConnection *pCon,
/*-------------------------------------------------------------------*/ /*-------------------------------------------------------------------*/
static HistDriver *CreateAnstoHistMem(char *name, pStringDict pOptions){ static HistDriver *CreateAnstoHistMem(char *name, pStringDict pOptions){
HistDriver *pNew = NULL; HistDriver *pNew = NULL;
if(strcmp(name,"anstohttp") == 0){ if(strcmp(name,"anstohttp") == 0){
pNew = CreateAnstoHttpDriver(pOptions); pNew = CreateAnstoHttpDriver(pOptions);
} }
return pNew; return pNew;
} }
/*-------------------------------------------------------------------*/ /*-------------------------------------------------------------------*/
static pVelSelDriv CreateVelSelDriv(char *name, char *array, static pVelSelDriv CreateVelSelDriv(char *name, char *array,
Tcl_Interp *pTcl){ Tcl_Interp *pTcl){
pVelSelDriv pNew = NULL; pVelSelDriv pNew = NULL;
return pNew; return pNew;
@ -514,7 +514,7 @@ static pEVControl InstallEnvironmentController(SicsInterp *pSics,
} }
} }
} }
/* Added code for new Lakeshore 340 driver */ /* Added code for new Lakeshore 340 driver */
if(strcmp(argv[3],"west4100") == 0) { if(strcmp(argv[3],"west4100") == 0) {
pDriv = CreateWEST4100Driver(argc-4,&argv[4]); pDriv = CreateWEST4100Driver(argc-4,&argv[4]);
@ -595,7 +595,7 @@ pSite getSite(void)
we cannot go on if we do not even have enough memory to allocate we cannot go on if we do not even have enough memory to allocate
the site data structure the site data structure
*/ */
assert(siteANSTO); assert(siteANSTO);
/* /*
initializing function pointers initializing function pointers
*/ */
@ -603,7 +603,7 @@ pSite getSite(void)
siteANSTO->RemoveSiteCommands = RemoveCommands; siteANSTO->RemoveSiteCommands = RemoveCommands;
siteANSTO->CreateMotor = CreateMotorAnsto; siteANSTO->CreateMotor = CreateMotorAnsto;
siteANSTO->CreateCounterDriver = CreateCounterDriverAnsto; siteANSTO->CreateCounterDriver = CreateCounterDriverAnsto;
siteANSTO->CreateHistogramMemoryDriver = CreateAnstoHistMem; siteANSTO->CreateHistogramMemoryDriver = CreateAnstoHistMem;
siteANSTO->CreateVelocitySelector = CreateVelSelDriv; siteANSTO->CreateVelocitySelector = CreateVelSelDriv;
siteANSTO->CreateControllerDriver = CreateController; siteANSTO->CreateControllerDriver = CreateController;
siteANSTO->InstallEnvironmentController = InstallEnvironmentController; siteANSTO->InstallEnvironmentController = InstallEnvironmentController;
@ -620,13 +620,13 @@ pSite getSite(void)
char *dyn; char *dyn;
unsigned int l; unsigned int l;
int res; int res;
va_start(ap, fmt); va_start(ap, fmt);
l = vsnprintf(buf, sizeof buf, fmt, ap); l = vsnprintf(buf, sizeof buf, fmt, ap);
va_end(ap); va_end(ap);
if (l >= sizeof buf) { if (l >= sizeof buf) {
/* we have probably a C99 conforming snprintf and /* we have probably a C99 conforming snprintf and
need a larger buffer need a larger buffer
*/ */
dyn = malloc(l+1); dyn = malloc(l+1);
if (dyn != NULL) { if (dyn != NULL) {

View File

@ -47,7 +47,7 @@ static pMotor CreateMotor(SConnection *pCon, int argc, char *argv[]){
if(!pNew){ if(!pNew){
sprintf(pBueffel,"Failure to create motor %s",argv[1]); sprintf(pBueffel,"Failure to create motor %s",argv[1]);
SCWrite(pCon,pBueffel,eError); SCWrite(pCon,pBueffel,eError);
return NULL; return NULL;
} }
} }
return pNew; return pNew;
@ -62,7 +62,7 @@ static pCounterDriver CreateAnstoCounterDriver(SConnection *pCon,
/*-------------------------------------------------------------------*/ /*-------------------------------------------------------------------*/
static HistDriver *CreateHistMem(char *name, pStringDict pOptions){ static HistDriver *CreateHistMem(char *name, pStringDict pOptions){
HistDriver *pNew = NULL; HistDriver *pNew = NULL;
if(strcmp(name,"anstohm") == 0){ if(strcmp(name,"anstohm") == 0){
printf("try to CreateAnstoHM() ...\n"); printf("try to CreateAnstoHM() ...\n");
#ifdef __cplusplus #ifdef __cplusplus
@ -72,7 +72,7 @@ static HistDriver *CreateHistMem(char *name, pStringDict pOptions){
return pNew; return pNew;
} }
/*-------------------------------------------------------------------*/ /*-------------------------------------------------------------------*/
static pVelSelDriv CreateVelSelDriv(char *name, char *array, static pVelSelDriv CreateVelSelDriv(char *name, char *array,
Tcl_Interp *pTcl){ Tcl_Interp *pTcl){
pVelSelDriv pNew = NULL; pVelSelDriv pNew = NULL;
return pNew; return pNew;
@ -110,7 +110,7 @@ pSite getSite(void){
we cannot go on if we do not even have enough memory to allocate we cannot go on if we do not even have enough memory to allocate
the site data structure the site data structure
*/ */
assert(siteANSTO); assert(siteANSTO);
/* /*
initializing function pointers initializing function pointers
*/ */
@ -118,10 +118,10 @@ pSite getSite(void){
siteANSTO->RemoveSiteCommands = RemoveCommands; siteANSTO->RemoveSiteCommands = RemoveCommands;
siteANSTO->CreateMotor = CreateMotor; siteANSTO->CreateMotor = CreateMotor;
siteANSTO->CreateCounterDriver = CreateAnstoCounterDriver; siteANSTO->CreateCounterDriver = CreateAnstoCounterDriver;
siteANSTO->CreateHistogramMemoryDriver = CreateHistMem; siteANSTO->CreateHistogramMemoryDriver = CreateHistMem;
siteANSTO->CreateVelocitySelector = CreateVelSelDriv; siteANSTO->CreateVelocitySelector = CreateVelSelDriv;
siteANSTO->CreateControllerDriver = CreateController; siteANSTO->CreateControllerDriver = CreateController;
siteANSTO->InstallEnvironmentController = siteANSTO->InstallEnvironmentController =
InstallEnvironmentController; InstallEnvironmentController;
siteANSTO->ConfigureScan = ConfigureScan; siteANSTO->ConfigureScan = ConfigureScan;
siteANSTO->KillSite = KillSite; siteANSTO->KillSite = KillSite;

View File

@ -1,14 +1,14 @@
/*--------------------------------------------------------------------------- /*---------------------------------------------------------------------------
W E S T 4 1 0 0 . C W E S T 4 1 0 0 . C
This is the implementation for a WEST4100 object derived from a more general This is the implementation for a WEST4100 object derived from a more general
environment controller. environment controller.
Mark Koennecke, August 1997 Mark Koennecke, August 1997
Mark Lesha, January 2006 (based on ITC4 code) Mark Lesha, January 2006 (based on ITC4 code)
Paul Barron, January 2008 (Note: This is based on the old LAKESHORE340 code and Paul Barron, January 2008 (Note: This is based on the old LAKESHORE340 code and
not the new LS340 code written by Rodney Davies Feb 08) not the new LS340 code written by Rodney Davies Feb 08)
Copyright: Copyright:
Labor fuer Neutronenstreuung Labor fuer Neutronenstreuung
@ -74,15 +74,15 @@ int GetWorkingSetpointWEST4100(pEVDriver self);
int WEST4100SetPar(pEVControl self, char *name, float fNew, SConnection *pCon) int WEST4100SetPar(pEVControl self, char *name, float fNew, SConnection *pCon)
{ {
int iRet; int iRet;
/* check authorisation */ /* check authorisation */
if(!SCMatchRights(pCon,usUser)) if(!SCMatchRights(pCon,usUser))
{ {
SCWrite(pCon,"ERROR: you are not authorised to change this parameter", SCWrite(pCon,"ERROR: you are not authorised to change this parameter",
eError); eError);
return 0; return 0;
} }
/* just catch those three names which we understand */ /* just catch those three names which we understand */
if(strcmp(name,"setpoint") == 0) if(strcmp(name,"setpoint") == 0)
{ {
@ -102,7 +102,7 @@ int GetWorkingSetpointWEST4100(pEVDriver self);
SCSendOK(pCon); SCSendOK(pCon);
return 1; return 1;
} }
if(strcmp(name,"alarm1") == 0) if(strcmp(name,"alarm1") == 0)
{ {
iRet = SetAlarm1WEST4100(self->pDriv,(int)fNew); iRet = SetAlarm1WEST4100(self->pDriv,(int)fNew);
@ -121,7 +121,7 @@ int GetWorkingSetpointWEST4100(pEVDriver self);
SCSendOK(pCon); SCSendOK(pCon);
return 1; return 1;
} }
if(strcmp(name,"alarm2") == 0) if(strcmp(name,"alarm2") == 0)
{ {
iRet = SetAlarm2WEST4100(self->pDriv,(int)fNew); iRet = SetAlarm2WEST4100(self->pDriv,(int)fNew);
@ -140,7 +140,7 @@ int GetWorkingSetpointWEST4100(pEVDriver self);
SCSendOK(pCon); SCSendOK(pCon);
return 1; return 1;
} }
if(strcmp(name,"powerlimit") == 0) if(strcmp(name,"powerlimit") == 0)
{ {
iRet = SetPowerLimitWEST4100(self->pDriv,(int)fNew); iRet = SetPowerLimitWEST4100(self->pDriv,(int)fNew);
@ -159,7 +159,7 @@ int GetWorkingSetpointWEST4100(pEVDriver self);
SCSendOK(pCon); SCSendOK(pCon);
return 1; return 1;
} }
if(strcmp(name,"ramprate") == 0) if(strcmp(name,"ramprate") == 0)
{ {
iRet = SetRampRateWEST4100(self->pDriv,(int)fNew); iRet = SetRampRateWEST4100(self->pDriv,(int)fNew);
@ -178,7 +178,7 @@ int GetWorkingSetpointWEST4100(pEVDriver self);
SCSendOK(pCon); SCSendOK(pCon);
return 1; return 1;
} }
else else
return EVCSetPar(self,name,fNew,pCon); return EVCSetPar(self,name,fNew,pCon);
} }
@ -186,7 +186,7 @@ int GetWorkingSetpointWEST4100(pEVDriver self);
int WEST4100GetPar(pEVControl self, char *name, float *fNew) int WEST4100GetPar(pEVControl self, char *name, float *fNew)
{ {
int iRet; int iRet;
/* just catch those two names which we understand */ /* just catch those two names which we understand */
if(strcmp(name,"setpoint") == 0) if(strcmp(name,"setpoint") == 0)
{ {
@ -229,7 +229,7 @@ int GetWorkingSetpointWEST4100(pEVDriver self);
iRet = GetProcessValueWEST4100(self->pDriv); // Furnace only has 1 sensor iRet = GetProcessValueWEST4100(self->pDriv); // Furnace only has 1 sensor
*fNew = (float)iRet; *fNew = (float)iRet;
return 1; return 1;
} }
else else
return EVCGetPar(self,name,fNew); return EVCGetPar(self,name,fNew);
} }
@ -238,44 +238,44 @@ int GetWorkingSetpointWEST4100(pEVDriver self);
{ {
char pBueffel[132]; char pBueffel[132];
int iRet; int iRet;
iRet = EVCList(self,pCon); iRet = EVCList(self,pCon);
sprintf(pBueffel,"%s.NumSensors = %d",self->pName,1); sprintf(pBueffel,"%s.NumSensors = %d",self->pName,1);
SCWrite(pCon,pBueffel,eValue); SCWrite(pCon,pBueffel,eValue);
sprintf(pBueffel,"%s.ControlSensor = %s",self->pName,"SensorA"); sprintf(pBueffel,"%s.ControlSensor = %s",self->pName,"SensorA");
SCWrite(pCon,pBueffel,eValue); SCWrite(pCon,pBueffel,eValue);
sprintf(pBueffel,"%s.ModbusAddress = %d",self->pName,GetAddressWEST4100(self->pDriv)); sprintf(pBueffel,"%s.ModbusAddress = %d",self->pName,GetAddressWEST4100(self->pDriv));
SCWrite(pCon,pBueffel,eValue); SCWrite(pCon,pBueffel,eValue);
sprintf(pBueffel,"%s.TransactionNumber = %d",self->pName,GetTransactWEST4100(self->pDriv)); sprintf(pBueffel,"%s.TransactionNumber = %d",self->pName,GetTransactWEST4100(self->pDriv));
SCWrite(pCon,pBueffel,eValue); SCWrite(pCon,pBueffel,eValue);
sprintf(pBueffel,"%s.ProcessValue = %d",self->pName,GetProcessValueWEST4100(self->pDriv)); sprintf(pBueffel,"%s.ProcessValue = %d",self->pName,GetProcessValueWEST4100(self->pDriv));
SCWrite(pCon,pBueffel,eValue); SCWrite(pCon,pBueffel,eValue);
sprintf(pBueffel,"%s.Setpoint = %d",self->pName,GetSetpointWEST4100(self->pDriv)); sprintf(pBueffel,"%s.Setpoint = %d",self->pName,GetSetpointWEST4100(self->pDriv));
SCWrite(pCon,pBueffel,eValue); SCWrite(pCon,pBueffel,eValue);
sprintf(pBueffel,"%s.WorkingSetpoint = %d",self->pName,GetWorkingSetpointWEST4100(self->pDriv)); sprintf(pBueffel,"%s.WorkingSetpoint = %d",self->pName,GetWorkingSetpointWEST4100(self->pDriv));
SCWrite(pCon,pBueffel,eValue); SCWrite(pCon,pBueffel,eValue);
sprintf(pBueffel,"%s.Alarm1 = %d",self->pName,GetAlarm1WEST4100(self->pDriv)); sprintf(pBueffel,"%s.Alarm1 = %d",self->pName,GetAlarm1WEST4100(self->pDriv));
SCWrite(pCon,pBueffel,eValue); SCWrite(pCon,pBueffel,eValue);
sprintf(pBueffel,"%s.Alarm2 = %d",self->pName,GetAlarm2WEST4100(self->pDriv)); sprintf(pBueffel,"%s.Alarm2 = %d",self->pName,GetAlarm2WEST4100(self->pDriv));
SCWrite(pCon,pBueffel,eValue); SCWrite(pCon,pBueffel,eValue);
sprintf(pBueffel,"%s.PowerLimit = %d",self->pName,GetPowerLimitWEST4100(self->pDriv)); sprintf(pBueffel,"%s.PowerLimit = %d",self->pName,GetPowerLimitWEST4100(self->pDriv));
SCWrite(pCon,pBueffel,eValue); SCWrite(pCon,pBueffel,eValue);
sprintf(pBueffel,"%s.RampRate = %d",self->pName,GetRampRateWEST4100(self->pDriv)); sprintf(pBueffel,"%s.RampRate = %d",self->pName,GetRampRateWEST4100(self->pDriv));
SCWrite(pCon,pBueffel,eValue); SCWrite(pCon,pBueffel,eValue);
return iRet; return iRet;
} }
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
int WEST4100Wrapper(SConnection *pCon, SicsInterp *pSics, void *pData, int WEST4100Wrapper(SConnection *pCon, SicsInterp *pSics, void *pData,
@ -287,19 +287,19 @@ int GetWorkingSetpointWEST4100(pEVDriver self);
double fNum; double fNum;
float fVal; float fVal;
int fValue; int fValue;
self = (pEVControl)pData; self = (pEVControl)pData;
assert(self); assert(self);
assert(pCon); assert(pCon);
assert(pSics); assert(pSics);
if(argc < 2) if(argc < 2)
{ {
return EVControlWrapper(pCon,pSics,pData,argc,argv); return EVControlWrapper(pCon,pSics,pData,argc,argv);
} }
// Set or Get // Set or Get
strtolower(argv[1]); strtolower(argv[1]);
if( (strcmp(argv[1],"controlsensor") == 0) || (strcmp(argv[1],"sensorlist") == 0)){ if( (strcmp(argv[1],"controlsensor") == 0) || (strcmp(argv[1],"sensorlist") == 0)){
sprintf(pBueffel,"%s.%s = %s",self->pName,argv[1],"sensorA"); sprintf(pBueffel,"%s.%s = %s",self->pName,argv[1],"sensorA");
SCWrite(pCon,pBueffel,eValue); SCWrite(pCon,pBueffel,eValue);
return 1; return 1;
@ -317,7 +317,7 @@ int GetWorkingSetpointWEST4100(pEVDriver self);
sprintf(pBueffel,"ERROR: expected number, got %s",argv[2]); sprintf(pBueffel,"ERROR: expected number, got %s",argv[2]);
SCWrite(pCon,pBueffel,eError); SCWrite(pCon,pBueffel,eError);
return 0; return 0;
} }
return WEST4100SetPar(self,argv[1],(float)fNum,pCon); return WEST4100SetPar(self,argv[1],(float)fNum,pCon);
} }
else /* get case */ else /* get case */
@ -329,10 +329,10 @@ int GetWorkingSetpointWEST4100(pEVDriver self);
} }
} }
// Write or Query // Write or Query
else if(strcmp(argv[1],"parameter") == 0) else if(strcmp(argv[1],"parameter") == 0)
{ {
if(argc > 3) /* set case */ if(argc > 3) /* set case */
{ {
return WEST4100Write(self->pDriv,atoi(argv[2]),atoi(argv[3])); return WEST4100Write(self->pDriv,atoi(argv[2]),atoi(argv[3]));
} }
else /* get case */ else /* get case */
@ -345,7 +345,7 @@ int GetWorkingSetpointWEST4100(pEVDriver self);
} }
// List // List
else if(strcmp(argv[1],"list") == 0) else if(strcmp(argv[1],"list") == 0)
{ {
return WEST4100List(self,pCon); return WEST4100List(self,pCon);
} }
else else
@ -353,5 +353,5 @@ int GetWorkingSetpointWEST4100(pEVDriver self);
return EVControlWrapper(pCon,pSics,pData,argc,argv); return EVControlWrapper(pCon,pSics,pData,argc,argv);
} }
/* not reached */ /* not reached */
return 0; return 0;
} }

View File

@ -1,14 +1,14 @@
/*------------------------------------------------------------------------- /*-------------------------------------------------------------------------
W E S T 4 1 0 0 W E S T 4 1 0 0
Support for Lakeshore 340 Temperature controllers for SICS. Support for Lakeshore 340 Temperature controllers for SICS.
The meaning and working of the functions defined is as desribed for a The meaning and working of the functions defined is as desribed for a
general environment controller. general environment controller.
Mark Koennecke, Juli 1997 Mark Koennecke, Juli 1997
Mark Lesha, January 2006 (based on ITC4 code) Mark Lesha, January 2006 (based on ITC4 code)
Paul Barron, January 2008 (Note: This is based on the old LAKESHORE340 code and Paul Barron, January 2008 (Note: This is based on the old LAKESHORE340 code and
not the new LS340 code written by Rodney Davies Feb 08) not the new LS340 code written by Rodney Davies Feb 08)
copyright: see implementation file. copyright: see implementation file.
@ -31,11 +31,11 @@
int WEST4100Wrapper(SConnection *pCon, SicsInterp *pSics, void *pData, int WEST4100Wrapper(SConnection *pCon, SicsInterp *pSics, void *pData,
int argc, char *argv[]); int argc, char *argv[]);
int WEST4100SetPar(pEVControl self, char *name, float fNew, int WEST4100SetPar(pEVControl self, char *name, float fNew,
SConnection *pCon); SConnection *pCon);
int WEST4100GetPar(pEVControl self, char *name, float *fVal); int WEST4100GetPar(pEVControl self, char *name, float *fVal);
int WEST4100List(pEVControl self, SConnection *pCon); int WEST4100List(pEVControl self, SConnection *pCon);
#endif #endif

View File

@ -4,10 +4,10 @@
This file contains the implementation of a driver for the This file contains the implementation of a driver for the
Lakeshore 340 Temperature controller. Lakeshore 340 Temperature controller.
Mark Koennecke, Juli 1997 Mark Koennecke, Juli 1997
Mark Lesha, January 2006 (based on ITC4 code) Mark Lesha, January 2006 (based on ITC4 code)
Paul Barron, January 2008 (Note: This is based on the old LAKESHORE340 code and Paul Barron, January 2008 (Note: This is based on the old LAKESHORE340 code and
not the new LS340 code written by Rodney Davies Feb 08) not the new LS340 code written by Rodney Davies Feb 08)
Copyright: Copyright:
@ -52,7 +52,7 @@
typedef struct __EVDriver *pEVDriver; typedef struct __EVDriver *pEVDriver;
#include <evdriver.i> #include <evdriver.i>
/* Do we need these ? /* Do we need these ?
#include <sics.h> #include <sics.h>
#include <modriv.h> #include <modriv.h>
@ -67,8 +67,8 @@
pEVDriver CreateWEST4100Driver(int argc, char *argv[]); pEVDriver CreateWEST4100Driver(int argc, char *argv[]);
int ConfigWEST4100(pEVDriver self); int ConfigWEST4100(pEVDriver self);
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
typedef struct { typedef struct {
pWEST4100 pData; pWEST4100 pData;
@ -85,8 +85,8 @@
int iWorkingSetpoint; int iWorkingSetpoint;
int iAlarm1; int iAlarm1;
int iAlarm2; int iAlarm2;
int iPowerLimit; int iPowerLimit;
int iRampRate; int iRampRate;
int iTmo; int iTmo;
int iLastError; int iLastError;
} WEST4100Driv, *pWEST4100Driv; } WEST4100Driv, *pWEST4100Driv;
@ -95,12 +95,12 @@
{ {
pWEST4100Driv pMe = NULL; pWEST4100Driv pMe = NULL;
int iRet; int iRet;
assert(self); assert(self);
pMe = (pWEST4100Driv)self->pPrivate; pMe = (pWEST4100Driv)self->pPrivate;
assert(pMe); assert(pMe);
iRet = WEST4100_Read(&pMe->pData,fPos); iRet = WEST4100_Read(&pMe->pData,fPos);
if(iRet <= 0 ) if(iRet <= 0 )
{ {
pMe->iLastError = iRet; pMe->iLastError = iRet;
@ -113,13 +113,13 @@
return 0; return 0;
} }
return 1; return 1;
} }
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
static int WEST4100Run(pEVDriver self, float fVal) static int WEST4100Run(pEVDriver self, float fVal)
{ {
pWEST4100Driv pMe = NULL; pWEST4100Driv pMe = NULL;
int iRet; int iRet;
assert(self); assert(self);
pMe = (pWEST4100Driv )self->pPrivate; pMe = (pWEST4100Driv )self->pPrivate;
assert(pMe); assert(pMe);
@ -136,7 +136,7 @@
static int WEST4100Error(pEVDriver self, int *iCode, char *error, int iErrLen) static int WEST4100Error(pEVDriver self, int *iCode, char *error, int iErrLen)
{ {
pWEST4100Driv pMe = NULL; pWEST4100Driv pMe = NULL;
assert(self); assert(self);
pMe = (pWEST4100Driv)self->pPrivate; pMe = (pWEST4100Driv)self->pPrivate;
assert(pMe); assert(pMe);
@ -148,7 +148,7 @@
} }
else else
{ {
WEST4100_ErrorTxt(&pMe->pData,pMe->iLastError,error,iErrLen); WEST4100_ErrorTxt(&pMe->pData,pMe->iLastError,error,iErrLen);
} }
return 1; return 1;
} }
@ -157,7 +157,7 @@
{ {
pWEST4100Driv pMe = NULL; pWEST4100Driv pMe = NULL;
int iRet; int iRet;
assert(self); assert(self);
pMe = (pWEST4100Driv )self->pPrivate; pMe = (pWEST4100Driv )self->pPrivate;
assert(pMe); assert(pMe);
@ -170,13 +170,13 @@
} }
return 1; return 1;
} }
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
static int WEST4100Init(pEVDriver self) static int WEST4100Init(pEVDriver self)
{ {
pWEST4100Driv pMe = NULL; pWEST4100Driv pMe = NULL;
int iRet; int iRet;
assert(self); assert(self);
pMe = (pWEST4100Driv )self->pPrivate; pMe = (pWEST4100Driv )self->pPrivate;
assert(pMe); assert(pMe);
@ -193,29 +193,29 @@
{ {
pMe->iLastError = iRet; pMe->iLastError = iRet;
return 0; return 0;
} }
} }
return 1; return 1;
} }
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
static int WEST4100Close(pEVDriver self) static int WEST4100Close(pEVDriver self)
{ {
pWEST4100Driv pMe = NULL; pWEST4100Driv pMe = NULL;
//int iRet; //int iRet;
assert(self); assert(self);
pMe = (pWEST4100Driv )self->pPrivate; pMe = (pWEST4100Driv )self->pPrivate;
assert(pMe); assert(pMe);
WEST4100_Close(&pMe->pData); WEST4100_Close(&pMe->pData);
return 1; return 1;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static int WEST4100Fix(pEVDriver self, int iError) static int WEST4100Fix(pEVDriver self, int iError)
{ {
pWEST4100Driv pMe = NULL; pWEST4100Driv pMe = NULL;
int iRet; int iRet;
assert(self); assert(self);
pMe = (pWEST4100Driv )self->pPrivate; pMe = (pWEST4100Driv )self->pPrivate;
assert(pMe); assert(pMe);
@ -241,11 +241,11 @@
if(iRet) if(iRet)
{ {
return DEVREDO; return DEVREDO;
} }
else else
{ {
return DEVFAULT; return DEVFAULT;
} }
break; break;
/* handable protocoll errors */ /* handable protocoll errors */
case EL734__BAD_TMO: case EL734__BAD_TMO:
@ -254,20 +254,20 @@
case -501: /* Bad_COM */ case -501: /* Bad_COM */
return DEVREDO; return DEVREDO;
case -504: /* Badly formatted */ case -504: /* Badly formatted */
return DEVREDO; return DEVREDO;
default: default:
return DEVFAULT; return DEVFAULT;
break; break;
} }
return DEVFAULT; return DEVFAULT;
} }
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
#if 0 #if 0
static int WEST4100Halt(pEVDriver *self) static int WEST4100Halt(pEVDriver *self)
{ {
assert(self); assert(self);
return 1; return 1;
} }
#endif #endif
@ -275,28 +275,28 @@
void KillWEST4100(void *pData) void KillWEST4100(void *pData)
{ {
pWEST4100Driv pMe = NULL; pWEST4100Driv pMe = NULL;
pMe = (pWEST4100Driv)pData; pMe = (pWEST4100Driv)pData;
assert(pMe); assert(pMe);
if(pMe->pHost) if(pMe->pHost)
{ {
free(pMe->pHost); free(pMe->pHost);
} }
free(pMe); free(pMe);
} }
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
pEVDriver CreateWEST4100Driver(int argc, char *argv[]) pEVDriver CreateWEST4100Driver(int argc, char *argv[])
{ {
pEVDriver pNew = NULL; pEVDriver pNew = NULL;
pWEST4100Driv pSim = NULL; pWEST4100Driv pSim = NULL;
/* check for arguments */ /* check for arguments */
if(argc < 3) if(argc < 3)
{ {
return NULL; return NULL;
} }
pSim = (pWEST4100Driv)malloc(sizeof(WEST4100Driv)); pSim = (pWEST4100Driv)malloc(sizeof(WEST4100Driv));
if(!pSim) { if(!pSim) {
return NULL; return NULL;
@ -309,19 +309,19 @@
memset(pSim,0,sizeof(WEST4100Driv)); memset(pSim,0,sizeof(WEST4100Driv));
pNew->pPrivate = pSim; pNew->pPrivate = pSim;
pNew->KillPrivate = KillWEST4100; pNew->KillPrivate = KillWEST4100;
/* initalise pWEST4100Driver */ /* initalise pWEST4100Driver */
// This is where parameters are initialised using values from the configuration file eg. sertemp 1 2 // This is where parameters are initialised using values from the configuration file eg. sertemp 1 2
pSim->iAddress = atoi(argv[1]); pSim->iAddress = atoi(argv[1]);
pSim->iTransaction = atoi(argv[2]); pSim->iTransaction = atoi(argv[2]);
pSim->iLastError = 0; pSim->iLastError = 0;
pSim->iTmo = 10; pSim->iTmo = 10;
pSim->pHost = strdup(argv[0]); pSim->pHost = strdup(argv[0]);
pSim->iPort = 0; pSim->iPort = 0;
pSim->iChannel = 0; pSim->iChannel = 0;
/* initialise function pointers */ /* initialise function pointers */
pNew->SetValue = WEST4100Run; pNew->SetValue = WEST4100Run;
pNew->GetValue = GetWEST4100Pos; pNew->GetValue = GetWEST4100Pos;
@ -330,15 +330,15 @@
pNew->TryFixIt = WEST4100Fix; pNew->TryFixIt = WEST4100Fix;
pNew->Init = WEST4100Init; pNew->Init = WEST4100Init;
pNew->Close = WEST4100Close; pNew->Close = WEST4100Close;
return pNew; return pNew;
} }
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
int ConfigWEST4100(pEVDriver self) int ConfigWEST4100(pEVDriver self)
{ {
pWEST4100Driv pMe = NULL; pWEST4100Driv pMe = NULL;
int iRet; int iRet;
assert(self); assert(self);
pMe = (pWEST4100Driv )self->pPrivate; pMe = (pWEST4100Driv )self->pPrivate;
assert(pMe); assert(pMe);
@ -356,33 +356,33 @@
{ {
pWEST4100Driv pMe = NULL; pWEST4100Driv pMe = NULL;
// int iRet; // int iRet;
assert(self); assert(self);
pMe = (pWEST4100Driv )self->pPrivate; pMe = (pWEST4100Driv )self->pPrivate;
assert(pMe); assert(pMe);
if((parameterAddress>0 && parameterAddress<=35) || (parameterAddress>=122 && parameterAddress<=133)) if((parameterAddress>0 && parameterAddress<=35) || (parameterAddress>=122 && parameterAddress<=133))
return WEST4100_Query(&pMe->pData, parameterAddress, parameterValue); return WEST4100_Query(&pMe->pData, parameterAddress, parameterValue);
else else
printf("Parameter %d out of range.\n",parameterAddress); printf("Parameter %d out of range.\n",parameterAddress);
return 1; return 1;
} }
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
int WEST4100Write(pEVDriver self, int parameterAddress, int parameterValue) int WEST4100Write(pEVDriver self, int parameterAddress, int parameterValue)
{ {
pWEST4100Driv pMe = NULL; pWEST4100Driv pMe = NULL;
// int iRet; // int iRet;
assert(self); assert(self);
pMe = (pWEST4100Driv )self->pPrivate; pMe = (pWEST4100Driv )self->pPrivate;
assert(pMe); assert(pMe);
if((parameterAddress>0 && parameterAddress<=35) || (parameterAddress>=122 && parameterAddress<=133)) if((parameterAddress>0 && parameterAddress<=35) || (parameterAddress>=122 && parameterAddress<=133))
return WEST4100_Write(&pMe->pData, parameterAddress, parameterValue); return WEST4100_Write(&pMe->pData, parameterAddress, parameterValue);
else else
printf("Parameter %d out of range.\n",parameterAddress); printf("Parameter %d out of range.\n",parameterAddress);
return 0; return 0;
} }
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
@ -390,11 +390,11 @@
{ {
pWEST4100Driv pMe = NULL; pWEST4100Driv pMe = NULL;
// int iRet; // int iRet;
assert(self); assert(self);
pMe = (pWEST4100Driv )self->pPrivate; pMe = (pWEST4100Driv )self->pPrivate;
assert(pMe); assert(pMe);
return pMe->iAddress; return pMe->iAddress;
} }
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
@ -403,11 +403,11 @@
pWEST4100Driv pMe = NULL; pWEST4100Driv pMe = NULL;
// int iRet; // int iRet;
assert(self); assert(self);
pMe = (pWEST4100Driv )self->pPrivate; pMe = (pWEST4100Driv )self->pPrivate;
assert(pMe); assert(pMe);
return pMe->iTransaction; return pMe->iTransaction;
} }
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
@ -415,45 +415,45 @@
{ {
pWEST4100Driv pMe = NULL; pWEST4100Driv pMe = NULL;
int fVal; int fVal;
assert(self); assert(self);
pMe = (pWEST4100Driv )self->pPrivate; pMe = (pWEST4100Driv )self->pPrivate;
assert(pMe); assert(pMe);
WEST4100_Query(&pMe->pData, 1, &fVal); WEST4100_Query(&pMe->pData, 1, &fVal);
pMe->iProcessValue = fVal; pMe->iProcessValue = fVal;
return pMe->iProcessValue; return pMe->iProcessValue;
} }
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
int GetWorkingSetpointWEST4100(pEVDriver self) int GetWorkingSetpointWEST4100(pEVDriver self)
{ {
pWEST4100Driv pMe = NULL; pWEST4100Driv pMe = NULL;
int fVal; int fVal;
assert(self); assert(self);
pMe = (pWEST4100Driv )self->pPrivate; pMe = (pWEST4100Driv )self->pPrivate;
assert(pMe); assert(pMe);
WEST4100_Query(&pMe->pData, 21, &fVal); WEST4100_Query(&pMe->pData, 21, &fVal);
pMe->iWorkingSetpoint = fVal; pMe->iWorkingSetpoint = fVal;
return pMe->iWorkingSetpoint; return pMe->iWorkingSetpoint;
} }
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
int SetSetpointWEST4100(pEVDriver self, int Setpoint) int SetSetpointWEST4100(pEVDriver self, int Setpoint)
{ {
pWEST4100Driv pMe = NULL; pWEST4100Driv pMe = NULL;
int iRet; int iRet;
assert(self); assert(self);
pMe = (pWEST4100Driv )self->pPrivate; pMe = (pWEST4100Driv )self->pPrivate;
assert(pMe); assert(pMe);
iRet=WEST4100_Write(&pMe->pData, 2, Setpoint); iRet=WEST4100_Write(&pMe->pData, 2, Setpoint);
pMe->iSetpoint = Setpoint; pMe->iSetpoint = Setpoint;
return 1; return 1;
@ -463,29 +463,29 @@
{ {
pWEST4100Driv pMe = NULL; pWEST4100Driv pMe = NULL;
int fVal; int fVal;
assert(self); assert(self);
pMe = (pWEST4100Driv )self->pPrivate; pMe = (pWEST4100Driv )self->pPrivate;
assert(pMe); assert(pMe);
WEST4100_Query(&pMe->pData, 2, &fVal); WEST4100_Query(&pMe->pData, 2, &fVal);
pMe->iSetpoint = fVal; pMe->iSetpoint = fVal;
return pMe->iSetpoint; return pMe->iSetpoint;
} }
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
int SetRampRateWEST4100(pEVDriver self, int RampRate) int SetRampRateWEST4100(pEVDriver self, int RampRate)
{ {
pWEST4100Driv pMe = NULL; pWEST4100Driv pMe = NULL;
int iRet; int iRet;
assert(self); assert(self);
pMe = (pWEST4100Driv )self->pPrivate; pMe = (pWEST4100Driv )self->pPrivate;
assert(pMe); assert(pMe);
iRet=WEST4100_Write(&pMe->pData, 24, RampRate); iRet=WEST4100_Write(&pMe->pData, 24, RampRate);
pMe->iRampRate = RampRate; pMe->iRampRate = RampRate;
return 1; return 1;
@ -495,29 +495,29 @@
{ {
pWEST4100Driv pMe = NULL; pWEST4100Driv pMe = NULL;
int fVal; int fVal;
assert(self); assert(self);
pMe = (pWEST4100Driv )self->pPrivate; pMe = (pWEST4100Driv )self->pPrivate;
assert(pMe); assert(pMe);
WEST4100_Query(&pMe->pData, 24, &fVal); WEST4100_Query(&pMe->pData, 24, &fVal);
pMe->iRampRate = fVal; pMe->iRampRate = fVal;
return pMe->iRampRate; return pMe->iRampRate;
} }
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
int SetAlarm1WEST4100(pEVDriver self, int Alarm1) int SetAlarm1WEST4100(pEVDriver self, int Alarm1)
{ {
pWEST4100Driv pMe = NULL; pWEST4100Driv pMe = NULL;
int iRet; int iRet;
assert(self); assert(self);
pMe = (pWEST4100Driv )self->pPrivate; pMe = (pWEST4100Driv )self->pPrivate;
assert(pMe); assert(pMe);
iRet=WEST4100_Write(&pMe->pData, 13, Alarm1); iRet=WEST4100_Write(&pMe->pData, 13, Alarm1);
pMe->iAlarm1 = Alarm1; pMe->iAlarm1 = Alarm1;
return 1; return 1;
@ -527,29 +527,29 @@
{ {
pWEST4100Driv pMe = NULL; pWEST4100Driv pMe = NULL;
int fVal; int fVal;
assert(self); assert(self);
pMe = (pWEST4100Driv )self->pPrivate; pMe = (pWEST4100Driv )self->pPrivate;
assert(pMe); assert(pMe);
WEST4100_Query(&pMe->pData, 13, &fVal); WEST4100_Query(&pMe->pData, 13, &fVal);
pMe->iAlarm1 = fVal; pMe->iAlarm1 = fVal;
return pMe->iAlarm1; return pMe->iAlarm1;
} }
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
int SetAlarm2WEST4100(pEVDriver self, int Alarm2) int SetAlarm2WEST4100(pEVDriver self, int Alarm2)
{ {
pWEST4100Driv pMe = NULL; pWEST4100Driv pMe = NULL;
int iRet; int iRet;
assert(self); assert(self);
pMe = (pWEST4100Driv )self->pPrivate; pMe = (pWEST4100Driv )self->pPrivate;
assert(pMe); assert(pMe);
iRet=WEST4100_Write(&pMe->pData, 14, Alarm2); iRet=WEST4100_Write(&pMe->pData, 14, Alarm2);
pMe->iAlarm2 = Alarm2; pMe->iAlarm2 = Alarm2;
return 1; return 1;
@ -559,29 +559,29 @@
{ {
pWEST4100Driv pMe = NULL; pWEST4100Driv pMe = NULL;
int fVal; int fVal;
assert(self); assert(self);
pMe = (pWEST4100Driv )self->pPrivate; pMe = (pWEST4100Driv )self->pPrivate;
assert(pMe); assert(pMe);
WEST4100_Query(&pMe->pData, 14, &fVal); WEST4100_Query(&pMe->pData, 14, &fVal);
pMe->iAlarm2 = fVal; pMe->iAlarm2 = fVal;
return pMe->iAlarm2; return pMe->iAlarm2;
} }
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
int SetPowerLimitWEST4100(pEVDriver self, int PowerLimit) int SetPowerLimitWEST4100(pEVDriver self, int PowerLimit)
{ {
pWEST4100Driv pMe = NULL; pWEST4100Driv pMe = NULL;
int iRet; int iRet;
assert(self); assert(self);
pMe = (pWEST4100Driv )self->pPrivate; pMe = (pWEST4100Driv )self->pPrivate;
assert(pMe); assert(pMe);
iRet=WEST4100_Write(&pMe->pData, 20, PowerLimit); iRet=WEST4100_Write(&pMe->pData, 20, PowerLimit);
pMe->iPowerLimit = PowerLimit; pMe->iPowerLimit = PowerLimit;
return 1; return 1;
@ -591,14 +591,14 @@
{ {
pWEST4100Driv pMe = NULL; pWEST4100Driv pMe = NULL;
int fVal; int fVal;
assert(self); assert(self);
pMe = (pWEST4100Driv )self->pPrivate; pMe = (pWEST4100Driv )self->pPrivate;
assert(pMe); assert(pMe);
WEST4100_Query(&pMe->pData, 20, &fVal); WEST4100_Query(&pMe->pData, 20, &fVal);
pMe->iPowerLimit = fVal; pMe->iPowerLimit = fVal;
return pMe->iPowerLimit; return pMe->iPowerLimit;
} }