- Added bridge functions to histmemsec to make it look more like histmem

- Modifed many modules using histmem to work also with histmemsec
- Extended tasker with task names and task groups
- There is a new taskobj which allows to list tasks and to interact with them.
- Task now supports running Tcl functions as tasks
- There is a new experimental sctcomtask module which allows to define communication
  tasks against a scriptcontext. This is a new feature which should facilitate
  writing sequential scripts using asynchronous communication.
- A fix to make spss7 work when there are no switches
- ORION support for single X. TRICS measures crystals hanging down, ORION
  standing up


SKIPPED:
	psi/ease.c
	psi/faverage.c
	psi/jvlprot.c
	psi/make_gen
	psi/pardef.c
	psi/polterwrite.c
	psi/psi.c
	psi/sinq.c
	psi/spss7.c
This commit is contained in:
koennecke
2012-12-20 11:32:33 +00:00
parent 4f560552c4
commit 86e246416b
57 changed files with 2025 additions and 290 deletions

View File

@@ -36,6 +36,7 @@
#include <macro.h>
#include "commandlog.h"
#include "arrayutil.h"
#include "HistMem.h"
#define MAX_HDB_PATH 1024
@@ -2503,6 +2504,50 @@ static int ZipGetHdbNode(SConnection * pCon, SicsInterp * pSics,
return status;
}
/*-----------------------------------------------------------------------------*/
static int ZipReadHdbNode(SConnection * pCon, SicsInterp * pSics,
void *pData, int argc, char *argv[])
{
pHdb targetNode = NULL;
char error[512], oriPath[512];
int status;
pDynString parData = NULL, result= NULL;
Protocol protocol = normal_protocol;
OutCode outCode;
if (argc < 2) {
SCWrite(pCon, "ERROR: need path to node", eError);
return 0;
}
strlcpy(oriPath, argv[1], 511);
targetNode = FindHdbNode(NULL, argv[1], pCon);
if (targetNode == NULL) {
return 0;
}
if(targetNode->value.dataType == HIPTEXT){
parData = formatValue(targetNode->value, targetNode);
if (parData == NULL) {
SCWrite(pCon, "ERROR: out of memory formatting data", eError);
return 0;
}
if ((protocol = isJSON(pCon)) == 1)
outCode = eHdbEvent;
else
outCode = eValue;
result = CreateDynString(128, 128);
formatNameValue(protocol, oriPath, GetCharArray(parData), result,
targetNode->value.dataType);
SCWrite(pCon, GetCharArray(result), outCode);
DeleteDynString(parData);
DeleteDynString(result);
} else {
status = sendZippedNodeData(targetNode, targetNode->value, pCon);
}
return status;
}
/*---------------------------------------------------------------------------*/
static int GetHdbNode(SConnection * pCon, SicsInterp * pSics, void *pData,
int argc, char *argv[])
@@ -2984,6 +3029,171 @@ static int isArrayNode(pHdb node)
return 0;
}
/*-------------------------------------------------------------------------*/
static int ArrayCopyNode(pHdb to, SConnection *pCon, int argc, char *argv[])
{
pHdb from = NULL;
int iStart, iLength;
hdbValue fromData;
from = FindHdbNode(NULL,argv[3],pCon);
if(from == NULL){
SCPrintf(pCon,eError,"ERROR: source node %s not found", argv[3]);
return 0;
}
if(!isArrayNode(from)){
SCPrintf(pCon,eError,"ERROR: %s is no array data node", argv[3]);
return 0;
}
iStart = 0;
iLength = from->value.arrayLength;
if(argc > 4) {
iStart = atoi(argv[4]);
if(iStart < 0) {
iStart = 0;
}
}
if(argc > 5) {
iLength = atoi(argv[5]);
if(iStart + iLength > from->value.arrayLength){
iLength = from->value.arrayLength - iStart - 1;
}
}
switch(from->value.dataType){
case HIPINTAR:
case HIPINTVARAR:
fromData = MakeHdbIntArray(iLength, from->value.v.intArray+iStart);
break;
case HIPFLOATAR:
case HIPFLOATVARAR:
fromData = MakeHdbFloatArray(iLength, from->value.v.floatArray+iStart);
break;
default:
assert(0);
/* cannot really happen */
}
if(!copyHdbValue(&fromData, &to->value)) {
SCPrintf(pCon,eError,"ERROR: cannot copy data from %s to %s because of data type mismatch",
argv[3],argv[1]);
return 0;
}
SCSendOK(pCon);
return 1;
}
/*-------------------------------------------------------------------------*/
static int ArrayCopyOldHM(pHdb to, SConnection *pCon, int argc, char *argv[])
{
pHistMem hm = NULL;
int iStart, iLength;
int *data = NULL;
hdbValue copyData;
hm = (pHistMem)FindCommandData(pServ->pSics, argv[3],"HistMem");
if(hm == NULL){
SCPrintf(pCon,eError,"ERROR: cannot find HM %s", argv[3]);
return 0;
}
iStart = 0;
iLength = GetHistLength(hm);
if(argc > 4){
iStart = atoi(argv[4]);
iLength -= iStart;
}
if(argc > 5){
iLength = atoi(argv[5]);
}
if(iStart < 0){
iStart = 0;
}
if(iStart + iLength > GetHistLength(hm)){
iLength = GetHistLength(hm) - iStart - 1;
}
data = GetHistogramPointer(hm,pCon);
if(data == NULL){
SCPrintf(pCon,eError, "ERROR: failed to retrive HM data for %s", argv[3]);
return 0;
}
copyData = MakeHdbIntArray(iLength, data + iStart);
if(!copyHdbValue(&copyData, &to->value)) {
SCPrintf(pCon,eError,"ERROR: cannot copy data from %s to %s because of data type mismatch",
argv[3],argv[1]);
return 0;
}
SCSendOK(pCon);
return 1;
}
/*-------------------------------------------------------------------------*/
static int ArrayCopyOldTB(pHdb to, SConnection *pCon, int argc, char *argv[])
{
pHistMem hm = NULL;
int iStart, iLength, timeLength, i;
const float *data = NULL;
double *ddata = NULL;
hdbValue copyData;
hm = (pHistMem)FindCommandData(pServ->pSics, argv[3],"HistMem");
if(hm == NULL){
SCPrintf(pCon,eError,"ERROR: cannot find HM %s", argv[3]);
return 0;
}
iStart = 0;
data = GetHistTimeBin(hm,&timeLength);
if(data == NULL){
SCPrintf(pCon,eError, "ERROR: failed to retrive time binning for HM %s", argv[3]);
return 0;
}
iLength = timeLength;
if(argc > 4){
iStart = atoi(argv[4]);
iLength -= iStart;
}
if(argc > 5){
iLength = atoi(argv[5]);
}
if(iStart < 0){
iStart = 0;
}
if(iStart + iLength > timeLength){
iLength = timeLength - iStart - 1;
}
ddata = malloc(iLength*sizeof(double));
if(ddata == NULL){
SCPrintf(pCon,eError,"ERROR: out of memory copying %s time binning to %s",
argv[3],argv[1]);
return 0;
}
for(i = 0; i < iLength; i++){
ddata[i] = data[iStart+i];
}
copyData = MakeHdbFloatArray(iLength, ddata);
if(!copyHdbValue(&copyData, &to->value)) {
SCPrintf(pCon,eError,
"ERROR: cannot copy data from %s to %s because of data type mismatch",
argv[3],argv[1]);
return 0;
}
free(ddata);
SCSendOK(pCon);
return 1;
}
/*-------------------------------------------------------------------------*/
static int HdbArrayNode(SConnection * pCon, SicsInterp * pSics, void *pData,
int argc, char *argv[])
{
@@ -3062,6 +3272,16 @@ static int HdbArrayNode(SConnection * pCon, SicsInterp * pSics, void *pData,
return 1;
}
if(strcmp(argv[2],"copynode") == 0){
return ArrayCopyNode(node, pCon, argc, argv);
}
if(strcmp(argv[2],"copyoldhm") == 0){
return ArrayCopyOldHM(node, pCon, argc, argv);
}
if(strcmp(argv[2],"copyoldtb") == 0){
return ArrayCopyOldTB(node, pCon, argc, argv);
}
idx = atoi(argv[2]);
if(idx < 0 || idx >= node->value.arrayLength ){
SCPrintf(pCon,eError,"ERROR: %d is out of range 0 - %d",
@@ -3078,7 +3298,6 @@ static int HdbArrayNode(SConnection * pCon, SicsInterp * pSics, void *pData,
node->value.v.floatArray[idx] = atof(argv[3]);
break;
}
NotifyHipadabaPar(node, pCon);
SCSendOK(pCon);
return 1;
}
@@ -3408,6 +3627,27 @@ static int ListSICSHdbProperty(SConnection * pCon, SicsInterp * pSics,
DeleteDynString(data);
return 1;
}
/*---------------------------------------------------------------------------*/
static int CallNotify(SConnection * pCon, SicsInterp * pSics,
void *pData, int argc, char *argv[])
{
pHdb node = NULL;
if(argc < 2) {
SCPrintf(pCon,eError, "ERROR: require path argument to %s", argv[0]);
return 0;
}
node = GetHipadabaNode(GetHipadabaRoot(), argv[1]);
if(node == NULL){
SCPrintf(pCon,eError,"ERROR: cannot find node %s to notify", argv[1]);
return 0;
}
NotifyHipadabaPar(node,pCon);
return 1;
}
/*---------------------------------------------------------------------------*/
static pHdb matchHdbProp(pHdb root, char *propname, char *buffer)
@@ -3432,7 +3672,6 @@ static pHdb matchHdbProp(pHdb root, char *propname, char *buffer)
return NULL;
}
/*---------------------------------------------------------------------------*/
static int MatchHdbProperty(SConnection * pCon, SicsInterp * pSics,
void *pData, int argc, char *argv[])
@@ -3495,6 +3734,7 @@ int InstallSICSHipadaba(SConnection * pCon, SicsInterp * pSics,
AddCommand(pSics, "hget", GetHdbNode, NULL, NULL);
AddCommand(pSics, "hval", GetHdbVal, NULL, NULL);
AddCommand(pSics, "hzipget", ZipGetHdbNode, NULL, NULL);
AddCommand(pSics, "hzipread", ZipReadHdbNode, NULL, NULL);
AddCommand(pSics, "hlist", ListHdbNode, NULL, NULL);
AddCommand(pSics, "hnotify", AutoNotifyHdbNode, NULL, NULL);
AddCommand(pSics, "hdelcb", RemoveHdbCallback, NULL, NULL);
@@ -3508,6 +3748,7 @@ int InstallSICSHipadaba(SConnection * pCon, SicsInterp * pSics,
AddCommand(pSics, "hgetpropval", GetSICSHdbPropertyVal, NULL, NULL);
AddCommand(pSics, "hmatchprop", MatchHdbProperty, NULL, NULL);
AddCommand(pSics, "hlistprop", ListSICSHdbProperty, NULL, NULL);
AddCommand(pSics, "hcallnotify",CallNotify, NULL, NULL);
InstallSICSPoll(pCon, pSics, pData, argc, argv);
poller = (pSicsPoll) FindCommandData(pSics, "sicspoll", "SicsPoll");