Merge changes from release 2.0 branch
r2364 | ffr | 2008-02-20 09:00:24 +1100 (Wed, 20 Feb 2008) | 2 lines
This commit is contained in:
committed by
Douglas Clowes
parent
ed9f92c6ef
commit
f3d798689b
@@ -22,6 +22,7 @@
|
||||
#include <stptok.h>
|
||||
#include <countdriv.h>
|
||||
#include <nserver.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
extern char *trim(char *);
|
||||
/*===================================================================
|
||||
@@ -124,7 +125,6 @@ static int anstoHttpCheckResponse(pAnstoHttp self){
|
||||
/*-------------------------------------------------------------------*/
|
||||
static int anstoHttpGet(pAnstoHttp self, char *request){
|
||||
ghttp_status httpStatus;
|
||||
char *pPtr = NULL;
|
||||
|
||||
if(!anstoHttpGetPrepare(self,request)){
|
||||
return 0;
|
||||
@@ -153,7 +153,6 @@ static int anstoHttpGet(pAnstoHttp self, char *request){
|
||||
/*====================================================================*/
|
||||
static int AnstoHttpConfigure(pHistDriver self, SConnection *pCon,
|
||||
pStringDict pOpt, SicsInterp *pSics){
|
||||
char hmname[512];
|
||||
char confCommand[512], url[512];
|
||||
pAnstoHttp pPriv = NULL;
|
||||
int status, iInit;
|
||||
@@ -320,7 +319,6 @@ static int readStatus(pHistDriver pDriv){
|
||||
char line[132];
|
||||
char name[80], value[80];
|
||||
pAnstoHttp self = NULL;
|
||||
char *daqPtr = NULL, *daqValPtr = NULL;
|
||||
|
||||
self = (pAnstoHttp)pDriv->pPriv;
|
||||
assert(self != NULL);
|
||||
@@ -362,13 +360,14 @@ static int readStatus(pHistDriver pDriv){
|
||||
#define ANSTO_HS_STATUS_STARTING 4
|
||||
#define ANSTO_HS_STATUS_PAUSING 5
|
||||
#define ANSTO_HS_STATUS_STOPPING 6
|
||||
#define ANSTO_HS_STATUS_UNKNOWN 7
|
||||
#define ANSTO_HS_STATUS_REDO 8
|
||||
//
|
||||
static int AnstoHttpStatus_Base(pHistDriver self,SConnection *pCon,int *pextrastatus){ // pCon=NULL allowed
|
||||
pAnstoHttp pPriv = NULL;
|
||||
ghttp_status httpStatus;
|
||||
char daqStatus[20];
|
||||
int status, len;
|
||||
char *pPtr = NULL;
|
||||
int status;
|
||||
static int last_known_status=HWIdle; // assume idle initially
|
||||
|
||||
pPriv = (pAnstoHttp)self->pPriv;
|
||||
@@ -386,46 +385,47 @@ static int AnstoHttpStatus_Base(pHistDriver self,SConnection *pCon,int *pextrast
|
||||
ghttp_set_sync(pPriv->syncRequest,ghttp_async);
|
||||
ghttp_prepare(pPriv->syncRequest);
|
||||
if(status != 1){
|
||||
if (pextrastatus) *pextrastatus=ANSTO_HS_STATUS_INVALID;
|
||||
return HWFault;
|
||||
if (pextrastatus) *pextrastatus=ANSTO_HS_STATUS_INVALID;
|
||||
return HWFault;
|
||||
}
|
||||
pPriv->asyncRunning = 1;
|
||||
}
|
||||
httpStatus = ghttp_process(pPriv->syncRequest);
|
||||
switch(httpStatus){
|
||||
case ghttp_error:
|
||||
ghttp_close(pPriv->syncRequest);
|
||||
anstoHttpGetPrepare(pPriv,statusdaq);
|
||||
ghttp_prepare(pPriv->syncRequest);
|
||||
httpStatus = ghttp_process(pPriv->syncRequest);
|
||||
if(httpStatus != ghttp_done){
|
||||
strncpy(pPriv->hmError,"Reconnect", 511);
|
||||
pPriv->errorCode = SERVERERROR;
|
||||
if (pextrastatus) *pextrastatus=ANSTO_HS_STATUS_INVALID;
|
||||
pPriv->asyncRunning = 0; // MJL bug fix 9/03/07
|
||||
return HWFault;
|
||||
}
|
||||
break;
|
||||
case ghttp_not_done:
|
||||
// MJL this is not a problem, the server is just slow.
|
||||
// return HWRedo not HWBusy (original) or fault
|
||||
return HWRedo;
|
||||
break;
|
||||
case ghttp_done:
|
||||
pPriv->asyncRunning = 0;
|
||||
status = anstoHttpCheckResponse(pPriv);
|
||||
if(status != 1){
|
||||
if (pextrastatus) *pextrastatus=ANSTO_HS_STATUS_INVALID;
|
||||
return HWFault;
|
||||
}
|
||||
break;
|
||||
case ghttp_error:
|
||||
ghttp_close(pPriv->syncRequest);
|
||||
anstoHttpGetPrepare(pPriv,statusdaq);
|
||||
ghttp_prepare(pPriv->syncRequest);
|
||||
httpStatus = ghttp_process(pPriv->syncRequest);
|
||||
if(httpStatus != ghttp_done){
|
||||
strncpy(pPriv->hmError,"Reconnect", 511);
|
||||
pPriv->errorCode = SERVERERROR;
|
||||
pPriv->asyncRunning = 0; // MJL bug fix 9/03/07
|
||||
if (pextrastatus) *pextrastatus=ANSTO_HS_STATUS_INVALID;
|
||||
return HWFault;
|
||||
}
|
||||
break;
|
||||
case ghttp_not_done:
|
||||
// MJL this is not a problem, the server is just slow.
|
||||
// return HWRedo not HWBusy (original) or fault
|
||||
if (pextrastatus) *pextrastatus=ANSTO_HS_STATUS_REDO;
|
||||
return HWRedo;
|
||||
break;
|
||||
case ghttp_done:
|
||||
pPriv->asyncRunning = 0;
|
||||
status = anstoHttpCheckResponse(pPriv);
|
||||
if(status != 1){
|
||||
if (pextrastatus) *pextrastatus=ANSTO_HS_STATUS_INVALID;
|
||||
return HWFault;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
status = readStatus(self);
|
||||
if(status != 1){
|
||||
if (pextrastatus) *pextrastatus=ANSTO_HS_STATUS_INVALID;
|
||||
return HWFault;
|
||||
if (pextrastatus) *pextrastatus=ANSTO_HS_STATUS_INVALID;
|
||||
return HWFault;
|
||||
}
|
||||
|
||||
if(StringDictGet(self->pOption,"daq",daqStatus,20) != 1){
|
||||
@@ -461,21 +461,20 @@ static int AnstoHttpStatus_Base(pHistDriver self,SConnection *pCon,int *pextrast
|
||||
// otherwise HWIdle if it was in Paused or Stopped states.
|
||||
} else if(strstr(daqStatus,"Starting") != NULL){
|
||||
if (pextrastatus) *pextrastatus=ANSTO_HS_STATUS_STARTING;
|
||||
return last_known_status; // if started already, is already HWBusy
|
||||
return last_known_status; // if started already, is already HWBusy
|
||||
} else if(strstr(daqStatus,"Stopping") != NULL){
|
||||
if (pextrastatus) *pextrastatus=ANSTO_HS_STATUS_PAUSING;
|
||||
return last_known_status; // return HWBusy only if it was started before
|
||||
} else if(strstr(daqStatus,"Pausing") != NULL){
|
||||
if (pextrastatus) *pextrastatus=ANSTO_HS_STATUS_STOPPING;
|
||||
return last_known_status; // return HWBusy if it was started before
|
||||
return last_known_status; // return HWBusy only if it was started before
|
||||
} else if(strstr(daqStatus,"Pausing") != NULL){
|
||||
if (pextrastatus) *pextrastatus=ANSTO_HS_STATUS_PAUSING;
|
||||
return last_known_status; // return HWBusy if it was started before
|
||||
// bad or missing status??
|
||||
} else {
|
||||
if (pextrastatus) *pextrastatus=ANSTO_HS_STATUS_INVALID;
|
||||
pPriv->errorCode = BADSTATUS;
|
||||
snprintf(pPriv->hmError,511,"ERROR: invalid DAQ status %s",daqStatus);
|
||||
return HWFault;
|
||||
pPriv->errorCode = BADSTATUS;
|
||||
snprintf(pPriv->hmError,511,"ERROR: invalid DAQ status %s",daqStatus);
|
||||
if (pextrastatus) *pextrastatus=ANSTO_HS_STATUS_INVALID;
|
||||
return HWFault;
|
||||
}
|
||||
|
||||
return HWFault; // shouldn't get here
|
||||
}
|
||||
//
|
||||
@@ -502,7 +501,7 @@ static int AnstoHttpStatusWithRetries(pHistDriver self, int requiredstate,SConne
|
||||
int retcode,runloop;
|
||||
do
|
||||
{
|
||||
int extrastatus=ANSTO_HS_STATUS_INVALID;
|
||||
int extrastatus=ANSTO_HS_STATUS_UNKNOWN;
|
||||
// Request current status from the histogram server.
|
||||
// The server usually responds within milliseconds.
|
||||
retcode=AnstoHttpStatus_Base(self,pCon,&extrastatus);
|
||||
@@ -539,7 +538,7 @@ static int AnstoHttpStart(pHistDriver self, SConnection *pCon){
|
||||
status = anstoHttpGet(pPriv,startdaq);
|
||||
|
||||
if(status != 1){
|
||||
return HWFault;
|
||||
return HWFault;
|
||||
}
|
||||
AnstoHttpStatusWithRetries(self,ANSTO_HS_STATUS_STARTED,pCon);
|
||||
return OKOK;
|
||||
@@ -549,14 +548,13 @@ static int AnstoHttpHalt(pHistDriver self){ // hmm, why isn't there a pCon like
|
||||
pAnstoHttp pPriv = NULL;
|
||||
int status;
|
||||
char checkstatus[20]="false";
|
||||
int i;
|
||||
|
||||
pPriv = (pAnstoHttp)self->pPriv;
|
||||
assert(pPriv != NULL);
|
||||
|
||||
status = anstoHttpGet(pPriv,stopdaq);
|
||||
if(status != 1){
|
||||
return HWFault;
|
||||
return HWFault;
|
||||
}
|
||||
|
||||
//TODO check statuscheck flag
|
||||
@@ -578,7 +576,7 @@ static int AnstoHttpPause(pHistDriver self,SConnection *pCon){
|
||||
|
||||
status = anstoHttpGet(pPriv,pausedaq);
|
||||
if(status != 1){
|
||||
return HWFault;
|
||||
return HWFault;
|
||||
}
|
||||
pPriv->pause = 1;
|
||||
|
||||
@@ -596,7 +594,7 @@ static int AnstoHttpContinue(pHistDriver self, SConnection *pCon){
|
||||
|
||||
status = anstoHttpGet(pPriv,continuedaq); // which is the same as restarting
|
||||
if(status != 1){
|
||||
return HWFault;
|
||||
return HWFault;
|
||||
}
|
||||
pPriv->pause = 0;
|
||||
AnstoHttpStatusWithRetries(self,ANSTO_HS_STATUS_STARTED,pCon);
|
||||
@@ -606,7 +604,6 @@ static int AnstoHttpContinue(pHistDriver self, SConnection *pCon){
|
||||
static int AnstoHttpError(pHistDriver self, int *code,
|
||||
char *error, int errLen){
|
||||
pAnstoHttp pPriv = NULL;
|
||||
int status;
|
||||
|
||||
pPriv = (pAnstoHttp)self->pPriv;
|
||||
assert(pPriv != NULL);
|
||||
|
||||
Reference in New Issue
Block a user