Contains kludge to present assumed histogram server statuses to the client in the list command. Will work, but should be improved to read real status instead (one day).

r1197 | mle | 2006-10-26 13:59:10 +1000 (Thu, 26 Oct 2006) | 2 lines
This commit is contained in:
Mark Lesha
2006-10-26 13:59:10 +10:00
committed by Douglas Clowes
parent 4f6054af3a
commit 7e43aa3e16

View File

@@ -298,65 +298,7 @@ static int AnstoHttpConfigure(pHistDriver self, SConnection *pCon,
return 1;
}
/*--------------------------------------------------------------------*/
static int AnstoHttpStart(pHistDriver self, SConnection *pCon){
pAnstoHttp pPriv = NULL;
int status;
pPriv = (pAnstoHttp)self->pPriv;
assert(pPriv != NULL);
status = anstoHttpGet(pPriv,startdaq);
if(status != 1){
return HWFault;
}
return 1;
}
/*---------------------------------------------------------------------*/
static int AnstoHttpHalt(pHistDriver self){
pAnstoHttp pPriv = NULL;
int status;
pPriv = (pAnstoHttp)self->pPriv;
assert(pPriv != NULL);
status = anstoHttpGet(pPriv,stopdaq);
if(status != 1){
return HWFault;
}
return 1;
}
/*---------------------------------------------------------------------*/
static int AnstoHttpPause(pHistDriver self,SConnection *pCon){
pAnstoHttp pPriv = NULL;
int status;
pPriv = (pAnstoHttp)self->pPriv;
assert(pPriv != NULL);
status = anstoHttpGet(pPriv,pausedaq);
if(status != 1){
return HWFault;
}
pPriv->pause = 1;
return 1;
}
/*---------------------------------------------------------------------*/
static int AnstoHttpContinue(pHistDriver self, SConnection *pCon){
pAnstoHttp pPriv = NULL;
int status;
pPriv = (pAnstoHttp)self->pPriv;
assert(pPriv != NULL);
status = anstoHttpGet(pPriv,continuedaq);
if(status != 1){
return HWFault;
}
pPriv->pause = 0;
return 1;
}
/*--------------------------------------------------------------------*/
static int readStatus(pHistDriver pDriv, SConnection *pCon){
static int readStatus(pHistDriver pDriv){
char *pPtr = NULL, *pLinePtr;
char line[132];
char name[80], value[80];
@@ -377,8 +319,6 @@ static int readStatus(pHistDriver pDriv, SConnection *pCon){
pLinePtr = line;
pLinePtr = stptok(pLinePtr,name,80,":");
pLinePtr = stptok(pLinePtr,value,80,":");
///SCWrite(pCon,name,eError); // MJL DEBUG
///SCWrite(pCon,value,eError); // MJL DEBUG
strtolower(name);
if(StringDictExists(pDriv->pOption,trim(name)) == 1){
StringDictUpdate(pDriv->pOption,trim(name),trim(value));
@@ -390,19 +330,32 @@ static int readStatus(pHistDriver pDriv, SConnection *pCon){
return 1;
}
/*---------------------------------------------------------------------*/
static int AnstoHttpStatus(pHistDriver self,SConnection *pCon){
// MJL we now force the status daq entry in the dictionary the explicit
// expected value ("Started", "Stopped" or "Paused"), whenever any
// of start, stop, pause or continue is done. I tried reading the status
// back from the server, but because it can respond slowly a delay would
// have been required, which is cumbersome.
// This way, the status read via the list command should be accurate
// provided there are no external factors involved (like users pushing
// start/stop/pause buttons on web page, etc.)
// It would be better to somehow force the status check so we would know
// that the daq entry in the dictonary really reflects the histogrammer
// status... we should discuss with Mark K sometime, maybe we can add this
// feature to the base code.
//
static int AnstoHttpStatus(pHistDriver self,SConnection *pCon){ // pCon=NULL allowed
pAnstoHttp pPriv = NULL;
ghttp_status httpStatus;
char daqStatus[20];
int status, len;
char *pPtr = NULL;
///SCWrite(pCon,"In AnstoHttpStatus",eError); // MJL DEBUG
///if (pCon) SCWrite(pCon,"In AnstoHttpStatus",eError); // MJL DEBUG
pPriv = (pAnstoHttp)self->pPriv;
assert(pPriv != NULL);
// MJL for the ANSTO histogram server we need status checking to occur
// MJL for the ANSTO histogram server we STILL need status checking to occur
// even when in paused mode (our pause mode has a different functionality).
// So the code below is removed.
/// if(pPriv->pause == 1){
@@ -414,6 +367,7 @@ static int AnstoHttpStatus(pHistDriver self,SConnection *pCon){
ghttp_set_sync(pPriv->syncRequest,ghttp_async);
ghttp_prepare(pPriv->syncRequest);
if(status != 1){
///if (pCon) SCWrite(pCon,"HWF1.",eError); // MJL DEBUG
return HWFault;
}
pPriv->asyncRunning = 1;
@@ -428,42 +382,46 @@ static int AnstoHttpStatus(pHistDriver self,SConnection *pCon){
if(httpStatus != ghttp_done){
strncpy(pPriv->hmError,"Reconnect", 511);
pPriv->errorCode = SERVERERROR;
///if (pCon) SCWrite(pCon,"HWF2.",eError); // MJL DEBUG
return HWFault;
pPriv->asyncRunning = 0;
}
break;
}
break;
case ghttp_not_done:
///if (pCon) SCWrite(pCon,"HWB.",eError); // MJL DEBUG
return HWBusy;
break;
case ghttp_done:
pPriv->asyncRunning = 0;
status = anstoHttpCheckResponse(pPriv);
if(status != 1){
///if (pCon) SCWrite(pCon,"HWF3.",eError); // MJL DEBUG
return HWFault;
}
break;
}
status = readStatus(self,pCon);
status = readStatus(self);
if(status != 1){
///if (pCon) SCWrite(pCon,"HWF4.",eError); // MJL DEBUG
return HWFault;
}
if(StringDictGet(self->pOption,"daq",daqStatus,20) != 1){
///SCWrite(pCon,"Field 'daq' not found!!!",eError); // MJL DEBUG
///if (pCon) SCWrite(pCon,"Field 'daq' not found!!!",eError); // MJL DEBUG
pPriv->errorCode = BADSTATUS;
strncpy(pPriv->hmError,"ERROR: status does not contain DAQ field",511);
return HWFault;
}
if(strstr(daqStatus,"Started") != NULL){
///SCWrite(pCon,"DAQ Started.",eError); // MJL DEBUG
///if (pCon) SCWrite(pCon,"DAQ Started.",eError); // MJL DEBUG
return HWBusy;
} else if(strstr(daqStatus,"Paused") != NULL){
///SCWrite(pCon,"DAQ Paused.",eError); // MJL DEBUG
///if (pCon) SCWrite(pCon,"DAQ Paused.",eError); // MJL DEBUG
return HWIdle;
} else if(strstr(daqStatus,"Stopped") != NULL){
///SCWrite(pCon,"DAQ Stopped.",eError); // MJL DEBUG
///if (pCon) SCWrite(pCon,"DAQ Stopped.",eError); // MJL DEBUG
return HWIdle;
} else {
pPriv->errorCode = BADSTATUS;
@@ -473,6 +431,73 @@ static int AnstoHttpStatus(pHistDriver self,SConnection *pCon){
return HWIdle;
}
/*--------------------------------------------------------------------*/
static int AnstoHttpStart(pHistDriver self, SConnection *pCon){
pAnstoHttp pPriv = NULL;
int status;
pPriv = (pAnstoHttp)self->pPriv;
assert(pPriv != NULL);
status = anstoHttpGet(pPriv,startdaq);
if(status != 1){
return HWFault;
}
// MJL force the daq status to the expected value...
StringDictUpdate(self->pOption, "daq", "Started");
return 1;
}
/*---------------------------------------------------------------------*/
static int AnstoHttpHalt(pHistDriver self){ // hmm, why isn't there a pCon like all the other ones...?
pAnstoHttp pPriv = NULL;
int status;
pPriv = (pAnstoHttp)self->pPriv;
assert(pPriv != NULL);
status = anstoHttpGet(pPriv,stopdaq);
if(status != 1){
return HWFault;
}
// MJL force the daq status to the expected value...
StringDictUpdate(self->pOption, "daq", "Stopped");
return 1;
}
/*---------------------------------------------------------------------*/
static int AnstoHttpPause(pHistDriver self,SConnection *pCon){
pAnstoHttp pPriv = NULL;
int status;
pPriv = (pAnstoHttp)self->pPriv;
assert(pPriv != NULL);
status = anstoHttpGet(pPriv,pausedaq);
if(status != 1){
return HWFault;
}
pPriv->pause = 1;
// MJL force the daq status to the expected value...
StringDictUpdate(self->pOption, "daq", "Paused");
return 1;
}
/*---------------------------------------------------------------------*/
static int AnstoHttpContinue(pHistDriver self, SConnection *pCon){
pAnstoHttp pPriv = NULL;
int status;
pPriv = (pAnstoHttp)self->pPriv;
assert(pPriv != NULL);
status = anstoHttpGet(pPriv,continuedaq);
if(status != 1){
return HWFault;
}
pPriv->pause = 0;
// MJL force the daq status to the expected value...
StringDictUpdate(self->pOption, "daq", "Started");
return 1;
}
/*---------------------------------------------------------------------*/
static int AnstoHttpError(pHistDriver self, int *code,
char *error, int errLen){