- Fix to hmdata.c for MARS
- Extended Hipadaba for commands
This commit is contained in:
31
hmdata.c
31
hmdata.c
@ -414,24 +414,23 @@ long sumHMDataRectangle(pHistMem hist, SConnection *pCon,
|
|||||||
iStart[0], iEnd[0]);
|
iStart[0], iEnd[0]);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
|
if(isInTOFMode(self)){
|
||||||
lSum = 0;
|
lSum = 0;
|
||||||
for(i = iStart[1]; i < iEnd[1]; i++){
|
for(i = iStart[0]; i < iEnd[0]; i++){
|
||||||
iIndex = i*self->iDim[0];
|
iIndex = i*self->iDim[1];
|
||||||
lRowSum = SumRow(self->localBuffer,iHistLength,
|
lRowSum = SumRow(self->localBuffer,iHistLength,
|
||||||
iIndex+iStart[0], iIndex+iEnd[0]);
|
|
||||||
lSum += lRowSum;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* This is wrong, see the bit about x and y somewhere
|
|
||||||
lSum = 0;
|
|
||||||
for(i = iStart[0]; i < iEnd[0]; i++){
|
|
||||||
iIndex = i*self->iDim[1];
|
|
||||||
lRowSum = SumRow(self->localBuffer,iHistLength,
|
|
||||||
iIndex+iStart[1], iIndex+iEnd[1]);
|
iIndex+iStart[1], iIndex+iEnd[1]);
|
||||||
lSum += lRowSum;
|
lSum += lRowSum;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
lSum = 0;
|
||||||
|
for(i = iStart[1]; i < iEnd[1]; i++){
|
||||||
|
iIndex = i*self->iDim[0];
|
||||||
|
lRowSum = SumRow(self->localBuffer,iHistLength,
|
||||||
|
iIndex+iStart[0], iIndex+iEnd[0]);
|
||||||
|
lSum += lRowSum;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
sprintf(pBueffel,
|
sprintf(pBueffel,
|
||||||
|
113
sicshipadaba.c
113
sicshipadaba.c
@ -2022,6 +2022,118 @@ static int ChainHdbNode(SConnection *pCon, SicsInterp *pSics, void *pData,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
static int CommandSetCallback(void *userData, void *callData, pHdb node,
|
||||||
|
hdbValue v){
|
||||||
|
SConnection *pCon = (SConnection *)callData;
|
||||||
|
pDynString cmd = NULL, par = NULL;
|
||||||
|
pHdb current = NULL;
|
||||||
|
int status;
|
||||||
|
|
||||||
|
if(pCon == NULL){
|
||||||
|
printf("Cannot invoke command without connection\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(v.dataType == HIPTEXT){
|
||||||
|
if(strstr(v.v.text,"start") != NULL) {
|
||||||
|
cmd = CreateDynString(64,64);
|
||||||
|
if(cmd == 0){
|
||||||
|
SCWrite(pCon,"ERROR: out of memory in CommandSetCallback",eError);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
DynStringCopy(cmd, node->value.v.text);
|
||||||
|
DynStringConcat(cmd," ");
|
||||||
|
current = node->child;
|
||||||
|
while(current != NULL){
|
||||||
|
par = formatValue(current->value);
|
||||||
|
if(par != NULL){
|
||||||
|
DynStringConcat(cmd, GetCharArray(par));
|
||||||
|
DynStringConcat(cmd," ");
|
||||||
|
DeleteDynString(par);
|
||||||
|
}
|
||||||
|
current = current->next;
|
||||||
|
}
|
||||||
|
status = SCInvoke(pCon, pServ->pSics,GetCharArray(cmd));
|
||||||
|
DeleteDynString(cmd);
|
||||||
|
return status;
|
||||||
|
} else {
|
||||||
|
SCWrite(pCon,"ERROR: this node only understands start as value",eError);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
static int CommandGetCallback(void *userData, void *callData, pHdb node,
|
||||||
|
hdbValue v){
|
||||||
|
hdbValue v2 = MakeHdbText("Nothing to get");
|
||||||
|
v = v2;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
/*--------------------------------------------------------------------------*/
|
||||||
|
static int SicsCommandNode(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||||
|
int argc, char *argv[]){
|
||||||
|
char buffer[512], buffer2[512], *pPtr = NULL;
|
||||||
|
pHdbCallback kalle = NULL;
|
||||||
|
pHdb parent = NULL, node = NULL;
|
||||||
|
|
||||||
|
if(argc < 3) {
|
||||||
|
SCWrite(pCon,"ERROR: insufficent number of arguments to hcommand",
|
||||||
|
eError);
|
||||||
|
}
|
||||||
|
if(!SCMatchRights(pCon,usMugger)){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* split off last path element */
|
||||||
|
strncpy(buffer,argv[1],511);
|
||||||
|
pPtr = strrchr(buffer,'/');
|
||||||
|
if(pPtr == NULL){
|
||||||
|
SCWrite(pCon,"ERROR: invalid path specification",
|
||||||
|
eError);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
*pPtr = '\0';
|
||||||
|
pPtr++;
|
||||||
|
if(strlen(pPtr) < 1) {
|
||||||
|
parent = root;
|
||||||
|
} else {
|
||||||
|
parent = GetHipadabaNode(root,buffer);
|
||||||
|
}
|
||||||
|
if(parent == NULL){
|
||||||
|
snprintf(buffer2,512,"ERROR: parent %s for new node does not exist",
|
||||||
|
buffer);
|
||||||
|
SCWrite(pCon,buffer2,eError);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
node = MakeHipadabaNode(pPtr, HIPTEXT, 1);
|
||||||
|
if(node == NULL){
|
||||||
|
SCWrite(pCon,"ERROR: out of memory in hcommand",eError);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
node->value.v.text = strdup(argv[2]);
|
||||||
|
node->value.arrayLength = strlen(argv[2]);
|
||||||
|
|
||||||
|
kalle = MakeHipadabaCallback(CommandSetCallback,NULL, NULL, -1,-1);
|
||||||
|
if(kalle == NULL){
|
||||||
|
SCWrite(pCon,"ERROR: out of memory in hcommand",eError);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
AppendHipadabaCallback(node,HCBSET, kalle);
|
||||||
|
|
||||||
|
kalle = MakeHipadabaCallback(CommandGetCallback,NULL, NULL, -1,-1);
|
||||||
|
if(kalle == NULL){
|
||||||
|
SCWrite(pCon,"ERROR: out of memory in hcommand",eError);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
AppendHipadabaCallback(node,HCBREAD, kalle);
|
||||||
|
|
||||||
|
AddHipadabaChild(parent,node,pCon);
|
||||||
|
|
||||||
|
SCSendOK(pCon);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
void killSICSHipadaba(){
|
void killSICSHipadaba(){
|
||||||
if(root != NULL){
|
if(root != NULL){
|
||||||
DeleteHipadabaNode(root,NULL);
|
DeleteHipadabaNode(root,NULL);
|
||||||
@ -2046,6 +2158,7 @@ int InstallSICSHipadaba(SConnection *pCon, SicsInterp *pSics, void *pData,
|
|||||||
AddCommand(pSics,"hinfo", HdbNodeInfo, NULL, NULL);
|
AddCommand(pSics,"hinfo", HdbNodeInfo, NULL, NULL);
|
||||||
AddCommand(pSics,"hval", HdbNodeVal, NULL, NULL);
|
AddCommand(pSics,"hval", HdbNodeVal, NULL, NULL);
|
||||||
AddCommand(pSics,"hchain", ChainHdbNode, NULL, NULL);
|
AddCommand(pSics,"hchain", ChainHdbNode, NULL, NULL);
|
||||||
|
AddCommand(pSics,"hcommand",SicsCommandNode, NULL, NULL);
|
||||||
|
|
||||||
InstallSICSPoll(pCon,pSics,pData,argc,argv);
|
InstallSICSPoll(pCon,pSics,pData,argc,argv);
|
||||||
poller = (pSicsPoll)FindCommandData(pSics,"sicspoll","SicsPoll");
|
poller = (pSicsPoll)FindCommandData(pSics,"sicspoll","SicsPoll");
|
||||||
|
Reference in New Issue
Block a user