MJL 4/4/07 Added upload of any dictonary entries starting with 'read_data_' as HTTP options in data read reques to histogram server, allows read data source & format to be adjusted on-the-fly.

r1795 | mle | 2007-04-04 07:57:29 +1000 (Wed, 04 Apr 2007) | 2 lines
This commit is contained in:
Mark Lesha
2007-04-04 07:57:29 +10:00
committed by Douglas Clowes
parent b250273deb
commit 79ac59740f

View File

@@ -59,6 +59,12 @@ typedef struct {
int pause;
int failCount;
int asyncRunning;
// Keep a local copy of the dictionary pointer in our internal data structure.
// We initialize this pointer with the one passed in when the object is created.
// This is used to allow certain functions (like AnstoHttpGetHistogram) to access
// the dictionary, even though a pointer to the dictionary isn't passed in.
// Hopefully this will not have any side effects.
pStringDict pOption;
}anstoHttp, *pAnstoHttp;
/*------------------------------------------------------------------*/
static int anstoHttpGetPrepare(pAnstoHttp self, char *request){
@@ -631,7 +637,7 @@ static int AnstoHttpGetData(pHistDriver self,SConnection *pCon){
/*-------------------------------------------------------------------*/
static int AnstoHttpGetHistogram(pHistDriver self, SConnection *pCon,
int bank, int start, int end, HistInt *data){
char command[256];
char command[1024]; // can be quite long now, if read_data_xxx options are appended
HistInt *hmdata;
pAnstoHttp pPriv = NULL;
int status, len, i;
@@ -678,9 +684,33 @@ static int AnstoHttpGetHistogram(pHistDriver self, SConnection *pCon,
int size=((end-start)>(MAX_HTTP_REQUEST_BYTES/sizeof(int)))
?(MAX_HTTP_REQUEST_BYTES/sizeof(int)):(end-start);
snprintf(command,255,"%s?bank=%d&start=%d&end=%d",gethm,bank,
// Send traditional SICS bank,start,end parameters to the server
// bank is now ignored by the server though, and start and end
// may be overridden by supplementary settings (see below).
int ncommand=snprintf(command,1023,"%s?bank=%d&start=%d&end=%d",gethm,bank,
start,start+size);
// Now add specific items read_data_xxxx in the string dictionary
// to the HTTP request. These act to selectively override the
// default read-data configuration at the server, so we can select
// different dataypes and formats.
// We use the internally-stored dictionary pointer for this purpose,
// since one isn't provided in the argument list.
char *pcommand_build=command+ncommand;
char pValue[256];
const char *pItem=NULL;
do
{
pItem=StringDictGetNext(pPriv->pOption,pValue,256);
if (pItem)
{
if (strncasecmp(pItem,"read_data_",10)==0)
{
pcommand_build+=sprintf(pcommand_build,"&%s=%s",pItem,pValue);
}
}
} while(pItem);
// Send our request
status = anstoHttpGet(pPriv,command);
if(status != 1){
return HWFault;
@@ -796,6 +826,10 @@ pHistDriver CreateAnstoHttpDriver(pStringDict pOption){
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;
/* configure all those functions */
pNew->Configure = AnstoHttpConfigure;