MJL 13/10/06 Added support for dynamic FAT configuration changes
r1141 | mle | 2006-10-13 15:10:11 +1000 (Fri, 13 Oct 2006) | 2 lines
This commit is contained in:
committed by
Douglas Clowes
parent
1a5aeacb9e
commit
45f86cb928
@@ -93,6 +93,8 @@ static int anstoHttpCheckResponse(pAnstoHttp self){
|
||||
|
||||
self->failCount = 0;
|
||||
pPtr = ghttp_get_body(self->syncRequest);
|
||||
if(pPtr == NULL) // MJL check ghttp_get_body for NULL return
|
||||
return 1; // empty response is okay
|
||||
len = ghttp_get_body_len(self->syncRequest);
|
||||
if(len > 511){
|
||||
len = 510;
|
||||
@@ -123,7 +125,7 @@ static int anstoHttpGet(pAnstoHttp self, char *request){
|
||||
*/
|
||||
ghttp_prepare(self->syncRequest);
|
||||
httpStatus = ghttp_process(self->syncRequest);
|
||||
if(httpStatus != ghttp_done){
|
||||
if(httpStatus != ghttp_done){
|
||||
ghttp_close(self->syncRequest);
|
||||
anstoHttpGetPrepare(self,request);
|
||||
httpStatus = ghttp_process(self->syncRequest);
|
||||
@@ -133,7 +135,8 @@ static int anstoHttpGet(pAnstoHttp self, char *request){
|
||||
self->errorCode = SERVERERROR;
|
||||
return 0;
|
||||
} else {
|
||||
return anstoHttpCheckResponse(self);
|
||||
int crstat=anstoHttpCheckResponse(self);
|
||||
return crstat;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@@ -151,6 +154,10 @@ static int AnstoHttpConfigure(pHistDriver self, SConnection *pCon,
|
||||
pPriv = (pAnstoHttp)self->pPriv;
|
||||
assert(pPriv != NULL);
|
||||
|
||||
///SCWrite(pCon,"In AnstoHttpConfigure",eError); // MJL DEBUG
|
||||
|
||||
// Check for FAT value sets
|
||||
|
||||
/*
|
||||
* The HM computer address
|
||||
*/
|
||||
@@ -233,7 +240,7 @@ static int AnstoHttpConfigure(pHistDriver self, SConnection *pCon,
|
||||
confData);
|
||||
SCWrite(pCon,confCommand,eError);
|
||||
return 0;
|
||||
} else {
|
||||
} else if (confData) { // MJL check ghttp_get_body result for NULL
|
||||
if(strstr(confData,"ERROR") != NULL){
|
||||
snprintf(confCommand,511,"%s",confData);
|
||||
SCWrite(pCon,confCommand,eError);
|
||||
@@ -247,6 +254,47 @@ static int AnstoHttpConfigure(pHistDriver self, SConnection *pCon,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MJL NOTE: Added extra init parameters here, these get committed
|
||||
// regardless of whether we are doing the first init or not
|
||||
// (i.e. will get committed even if init=1).
|
||||
// Need to do init on the histogram object (e.g. 'hm init')
|
||||
// in order to commit changed settings during operation.
|
||||
// Specifically, this is important if FAT settings need to be
|
||||
// modified during operation. To do this, the command
|
||||
// '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.
|
||||
// If the requested FAT variable doesn't exist or cannot be modified
|
||||
// during operation, the set fails but no indication is given.
|
||||
//
|
||||
// Now, to find out what entries are FAT_Xxxx format,
|
||||
/// by traversing the dictionary list.
|
||||
char pValue[256];
|
||||
const char *pItem=NULL;
|
||||
do {
|
||||
pItem=StringDictGetNext(pOpt,pValue,256);
|
||||
if (pItem)
|
||||
{
|
||||
if (strncasecmp(pItem,"FAT_",4)==0)
|
||||
{
|
||||
// Try committing the setting to the histogram server
|
||||
SCWrite(pCon,"Commit to HS FAT:",eError); // MJL DEBUG
|
||||
SCWrite(pCon,(char *)pItem,eError); // MJL DEBUG
|
||||
SCWrite(pCon,pValue,eError); // MJL DEBUG
|
||||
|
||||
// Make special http request to set the FAT parameter
|
||||
char modify_FAT_http_request[1024];
|
||||
sprintf(modify_FAT_http_request,"/admin/selectdynamicfatmodify.egi?dynamicFATmodifyparamname=%s&dynamicFATmodifyparamvalue=%s",
|
||||
pItem+4,pValue);
|
||||
// Send the request. When one doesn't work, drop out of the loop.
|
||||
//SCWrite(pCon,"httpget",eError); // MJL DEBUG
|
||||
int status = anstoHttpGet(pPriv,modify_FAT_http_request);
|
||||
if(status != 1)
|
||||
return 0;
|
||||
//SCWrite(pCon,"Done httpget",eError); // MJL DEBUG
|
||||
}
|
||||
}
|
||||
} while(pItem);
|
||||
return 1;
|
||||
}
|
||||
/*--------------------------------------------------------------------*/
|
||||
@@ -308,7 +356,7 @@ static int AnstoHttpContinue(pHistDriver self, SConnection *pCon){
|
||||
return 1;
|
||||
}
|
||||
/*--------------------------------------------------------------------*/
|
||||
static int readStatus(pHistDriver pDriv){
|
||||
static int readStatus(pHistDriver pDriv, SConnection *pCon){
|
||||
char *pPtr = NULL, *pLinePtr;
|
||||
char line[132];
|
||||
char name[80], value[80];
|
||||
@@ -329,6 +377,8 @@ static int readStatus(pHistDriver pDriv){
|
||||
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));
|
||||
@@ -347,6 +397,8 @@ static int AnstoHttpStatus(pHistDriver self,SConnection *pCon){
|
||||
int status, len;
|
||||
char *pPtr = NULL;
|
||||
|
||||
///SCWrite(pCon,"In AnstoHttpStatus",eError); // MJL DEBUG
|
||||
|
||||
pPriv = (pAnstoHttp)self->pPriv;
|
||||
assert(pPriv != NULL);
|
||||
|
||||
@@ -390,24 +442,29 @@ static int AnstoHttpStatus(pHistDriver self,SConnection *pCon){
|
||||
}
|
||||
|
||||
|
||||
status = readStatus(self);
|
||||
status = readStatus(self,pCon);
|
||||
if(status != 1){
|
||||
return HWFault;
|
||||
}
|
||||
|
||||
// TO BE REMOVED!!!
|
||||
// MJL DEBUG
|
||||
return HWIdle;
|
||||
|
||||
//return HWIdle;
|
||||
|
||||
if(StringDictGet(self->pOption,"daq",daqStatus,20) != 1){
|
||||
///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,"1") != NULL){
|
||||
if(strstr(daqStatus,"Started") != NULL){
|
||||
///SCWrite(pCon,"DAQ Started.",eError); // MJL DEBUG
|
||||
return HWBusy;
|
||||
} else if(strstr(daqStatus,"0") != NULL){
|
||||
} else if(strstr(daqStatus,"Paused") != NULL){
|
||||
///SCWrite(pCon,"DAQ Paused.",eError); // MJL DEBUG
|
||||
return HWIdle;
|
||||
} else if(strstr(daqStatus,"Stopped") != NULL){
|
||||
///SCWrite(pCon,"DAQ Stopped.",eError); // MJL DEBUG
|
||||
return HWIdle;
|
||||
} else {
|
||||
pPriv->errorCode = BADSTATUS;
|
||||
@@ -486,9 +543,14 @@ static int AnstoHttpGetHistogram(pHistDriver self, SConnection *pCon,
|
||||
return HWFault;
|
||||
}
|
||||
hmdata = (HistInt *)ghttp_get_body(pPriv->syncRequest);
|
||||
if(hmdata == NULL){ // MJL check ghttp_get_body for NULL return
|
||||
pPriv->errorCode = NOBODY;
|
||||
strncpy(pPriv->hmError,"No body in HM data response",511);
|
||||
return HWFault;
|
||||
}
|
||||
for(i = 0; i < (end - start); i++){
|
||||
data[i] = ntohl(hmdata[i]);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/*--------------------------------------------------------------------*/
|
||||
|
||||
Reference in New Issue
Block a user