Merged 2.4 branch

r2828 | ffr | 2009-11-25 09:56:49 +1100 (Wed, 25 Nov 2009) | 2 lines
This commit is contained in:
Ferdi Franceschini
2009-11-25 09:56:49 +11:00
committed by Douglas Clowes
parent c58ee9fbcb
commit 2ec6505ef8
71 changed files with 2237 additions and 1528 deletions

View File

@@ -26,6 +26,9 @@
#include <HistMem.i>
extern char *trim(char *);
extern pICallBack statemon_cbinterface;
int ANSTO_HTTP_PAUSE = 0;
int AnstoHttpPause(pHistDriver self,SConnection *pCon);
/*===================================================================
The request strings to append to the computer address
====================================================================*/
@@ -41,6 +44,7 @@ static char configure[] = {"/admin/configure.egi"};
static char preset[] = {"/admin/presethm.egi"};
static char dynamicsrvmodify[] = {"/admin/selectdynamicsrvmodify.egi?dynamicSRVmodifyparamname=%s&dynamicSRVmodifyparamvalue=%s"};
static char dynamicfatmodify[] = {"/admin/selectdynamicfatmodify.egi?dynamicFATmodifyparamname=%s&dynamicFATmodifyparamvalue=%s"};
static char devName[32] = "histmem";
/*====================================================================
error codes
======================================================================*/
@@ -71,6 +75,7 @@ typedef struct {
// the dictionary, even though a pointer to the dictionary isn't passed in.
// Hopefully this will not have any side effects.
pStringDict pOption;
pICallBack pCall;
}anstoHttp, *pAnstoHttp;
/*------------------------------------------------------------------*/
static int anstoHttpGetPrepare(pAnstoHttp self, char *request){
@@ -376,6 +381,7 @@ static int AnstoHttpStatus_Base(pHistDriver self,SConnection *pCon,int *pextrast
ghttp_status httpStatus;
char daqStatus[20];
int status;
pAnstoHttp pInternal = NULL;
static int last_known_status=HWIdle; // assume idle initially
pPriv = (pAnstoHttp)self->pPriv;
@@ -384,9 +390,10 @@ static int AnstoHttpStatus_Base(pHistDriver self,SConnection *pCon,int *pextrast
// 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){
/// return HWPause;
/// }
/* ffr reenabled because we now have AnstoHttpVeto()*/
if(pPriv->pause == 1){
return HWPause;
}
if(pPriv->asyncRunning == 0){
status = anstoHttpGetPrepare(pPriv,statusdaq);
@@ -446,13 +453,17 @@ static int AnstoHttpStatus_Base(pHistDriver self,SConnection *pCon,int *pextrast
//
// Basically we just diagnose whether the DAQ is running or not,
// but also return more detailed status via pextrastatus if supplied.
pInternal = (pAnstoHttp) self->pPriv;
if(strstr(daqStatus,"Started") != NULL){
if (last_known_status != HWBusy)
InvokeCallBack(statemon_cbinterface, STSTART, devName);
if (pextrastatus) *pextrastatus=ANSTO_HS_STATUS_STARTED;
return last_known_status=HWBusy;
} else if(strstr(daqStatus,"Paused") != NULL){
if (pextrastatus) *pextrastatus=ANSTO_HS_STATUS_PAUSED;
return last_known_status=HWIdle;
} else if(strstr(daqStatus,"Stopped") != NULL){
InvokeCallBack(statemon_cbinterface, STEND, devName);
if (pextrastatus) *pextrastatus=ANSTO_HS_STATUS_STOPPED;
return last_known_status=HWIdle;
//
@@ -519,7 +530,7 @@ static int AnstoHttpStatusWithRetries(pHistDriver self, int requiredstate,SConne
&&(bad_status_requests<MAX_BAD_STATUS_REQUESTS);
// Retry after a delay if status hasn't changed yet
// (DAE takes time to start up / shut down)
if (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();
do // make sure the yield in this loop gets called at least once
@@ -581,6 +592,10 @@ static int AnstoHttpVeto(pHistDriver self,SConnection *pCon)
pAnstoHttp pPriv = NULL;
int status;
char daqStatus[20];
if (ANSTO_HTTP_PAUSE) {
ANSTO_HTTP_PAUSE = 0;
return AnstoHttpPause(self, pCon);
}
StringDictGet(self->pOption,"daq",daqStatus,20);
if(strstr(daqStatus,"Stopped") != NULL){
@@ -597,6 +612,7 @@ static int AnstoHttpVeto(pHistDriver self,SConnection *pCon)
pPriv->pause = 1;
AnstoHttpStatusWithRetries(self,ANSTO_HS_STATUS_PAUSED,pCon);
InvokeCallBack(statemon_cbinterface, STPAUSE, devName);
return OKOK;
}
@@ -614,18 +630,20 @@ static int AnstoHttpNoVeto(pHistDriver self,SConnection *pCon)
}
pPriv->pause = 0;
AnstoHttpStatusWithRetries(self,ANSTO_HS_STATUS_STARTED,pCon);
InvokeCallBack(statemon_cbinterface, STCONTINUE, devName);
return OKOK;
}
int AnstoHttpPause(pHistDriver self,SConnection *pCon){
pAnstoHttp pPriv = NULL;
int status;
/* ffr revert to R2.3
char daqStatus[20];
StringDictGet(self->pOption,"daq",daqStatus,20);
if(strstr(daqStatus,"Stopped") != NULL){
return OKOK;
}
*/
pPriv = (pAnstoHttp)self->pPriv;
assert(pPriv != NULL);
@@ -633,7 +651,9 @@ int AnstoHttpPause(pHistDriver self,SConnection *pCon){
if(status != 1){
return HWFault;
}
pPriv->pause = 1;
/*ffr AnstoHttpVeto now provides pause()
pPriv->pause = 1;
*/
AnstoHttpStatusWithRetries(self,ANSTO_HS_STATUS_PAUSED,pCon);
@@ -856,6 +876,9 @@ static int AnstoHttpFreePrivate(pHistDriver self){
if(pPriv->syncRequest != NULL){
ghttp_request_destroy(pPriv->syncRequest);
}
if (pPriv->pCall != NULL) {
DeleteCallBackInterface(pPriv->pCall);
}
free(pPriv);
return 1;
}
@@ -864,6 +887,7 @@ static int AnstoHttpFreePrivate(pHistDriver self){
pHistDriver CreateAnstoHttpDriver(pStringDict pOption){
pHistDriver pNew = NULL;
pAnstoHttp pInternal = NULL;
pICallBack pCallNew = NULL;
/* create the general driver */
pNew = CreateHistDriver(pOption);
@@ -890,11 +914,18 @@ pHistDriver CreateAnstoHttpDriver(pStringDict pOption){
free(pInternal);
return NULL;
}
pCallNew = CreateCallBackInterface();
if (!pCallNew) {
free(pNew);
free(pInternal);
return NULL;
}
// Save a pointer to the string dictionary internally,
// for the use of those functions that require it and
// don't get a pOption passed in via the argument list.
pInternal->pOption=pOption;
pInternal->pCall = pCallNew;
/* configure all those functions */
pNew->Configure = AnstoHttpConfigure;
@@ -911,7 +942,7 @@ pHistDriver CreateAnstoHttpDriver(pStringDict pOption){
pNew->Preset = AnstoHttpPreset;
pNew->FreePrivate = AnstoHttpFreePrivate;
pNew->Pause = AnstoHttpVeto;
pNew->Continue = AnstoHttpNoVeto;
pNew->Continue = AnstoHttpContinue;
return pNew;
}
@@ -930,6 +961,22 @@ pHistDriver CreateAnstoHttpDriver(pStringDict pOption){
SCSendOK(pCon);
return 1;
}
if(strcmp(argv[1],"veto") == 0) {
if(!SCMatchRights(pCon,usUser)) {
return 0;
}
AnstoHttpVeto(self->pDriv,pCon);
SCSendOK(pCon);
return 1;
}
if(strcmp(argv[1],"noveto") == 0) {
if(!SCMatchRights(pCon,usUser)) {
return 0;
}
AnstoHttpNoVeto(self->pDriv,pCon);
SCSendOK(pCon);
return 1;
}
return HistAction(pCon, pSics, pData, argc, argv);
}