diff --git a/arrayutil.c b/arrayutil.c new file mode 100644 index 00000000..9d9c458a --- /dev/null +++ b/arrayutil.c @@ -0,0 +1,46 @@ +/* + * arrayutil.c + * + * copyright: see file COPYRIGHT + * + * some utilities for dealing with arrays + * + * Created on: Mar 16, 2011 + * Author: koennecke + */ + +long sumWindow(int *data, int xstart, int xend, int xlength, + int ystart, int yend, int ylength) +{ + int i,j; + long result = 0; + int *row; + + if(xstart < 0 || xstart > xlength){ + return -2; + } + if(xend < 0 || xend > xlength){ + return -2; + } + if(xend < xstart){ + return -2; + } + if(ystart < 0 || ystart > ylength){ + return -2; + } + if(yend < 0 || yend > ylength){ + return -2; + } + if(yend < ystart){ + return -2; + } + + + for(j = ystart; j < yend; j++){ + row = data + j*xlength; + for(i = xstart; i < xend; i++){ + result += row[i]; + } + } + return result; +} diff --git a/arrayutil.h b/arrayutil.h new file mode 100644 index 00000000..c2e23f38 --- /dev/null +++ b/arrayutil.h @@ -0,0 +1,31 @@ +/* + * arrayutil.h + * + * copyright: GPL + * + * Start of some array processing utilities. This may go if + * a more generalized array handling gets implemented into + * SICS. + * + * Created on: Mar 16, 2011 + * Author: koennecke + */ + +#ifndef ARRAYUTIL_H_ +#define ARRAYUTIL_H_ + +/** + * sum data in a window + * @param data The data pointer + * @param xstart + * @param xend + * @param xlength length of x dimension + * @param ystart + * @param yend + * @param ylength size of y dimension + * @return a sum or -2 if the limits fail to make sense + */ +long sumWindow(int *data, int xstart, int xend, int xlength, + int ystart, int yend, int ylength); + +#endif /* ARRAYUTIL_H_ */ diff --git a/ascon.c b/ascon.c index 999a9455..3b976a57 100644 --- a/ascon.c +++ b/ascon.c @@ -495,6 +495,26 @@ int AsconStdHandler(Ascon * a) return AsconBaseHandler(a); } +/** + * Treat hex strings as terminators right. Note that this + * is limited to single character terminators. + */ +static void AsconCheckTerminators(Ascon *a) +{ + int c; + + if(a->sendTerminator != NULL && strstr(a->sendTerminator,"0x") != NULL){ + sscanf(a->sendTerminator,"%x",&c); + a->sendTerminator[0] = (char)c; + a->sendTerminator[1] = '\0'; + } + if(a->replyTerminator != NULL && strstr(a->replyTerminator,"0x") != NULL){ + sscanf(a->replyTerminator,"%x",&c); + a->replyTerminator[0] = (char)c; + a->replyTerminator[1] = '\0'; + } +} + int AsconInterpreteArgs(int argc, char *argv[], int parc, char *parn[], char *pars[]) { @@ -574,6 +594,7 @@ int AsconStdInit(Ascon *a, SConnection *con, int argc, char *argv[]) } else { a->separator = NULL; } + AsconCheckTerminators(a); return 1; } diff --git a/asynnet.c b/asynnet.c index a34254ea..ad7e9c85 100644 --- a/asynnet.c +++ b/asynnet.c @@ -43,7 +43,7 @@ #define DATASOCKET 1 #define MAXCONNECTIONS 1024 #define RBUFFERSIZE 262144 /* 256kb */ -#define WBUFFERSIZE 10*262144 /* 512kb */ +#define WBUFFERSIZE 20*262144 /* */ /*--------------------------------------------------------------------------*/ typedef struct { int socket; diff --git a/asynnet.h b/asynnet.h index a93fbfb9..9912b70f 100644 --- a/asynnet.h +++ b/asynnet.h @@ -2,9 +2,9 @@ * Asynchronous networking for SICS and other programs. This module centrally manages * a number of network connections for a client program. It is a layer between the * program and the network which manages non blocking network I/O. To this purpose, the - * client program has to call ANETprocess at convenient intervalls. This module + * client program has to call ANETprocess at convenient intervals. This module * has a couple of features: - * - Connections are abstracted to handles which are guranteed to be unique + * - Connections are abstracted to handles which are guaranteed to be unique * rather then socket numbers. Socket numbers may be reused by the OS. * - This module allows upper level code to figure out if a connection is still * connected or not. diff --git a/devser.c b/devser.c index 6ac0f16d..2418e24f 100644 --- a/devser.c +++ b/devser.c @@ -227,7 +227,6 @@ static int DevQueueTask(void *ds) DevAction *action; char *sendData; char *replyData = NULL; - if (devser->steps == 0) return 1; diff --git a/doc/user/tasub.htm b/doc/user/tasub.htm index 03a785c7..d5308ebf 100644 --- a/doc/user/tasub.htm +++ b/doc/user/tasub.htm @@ -16,9 +16,9 @@ On a triple axis instrument the parameters incoming energy, Q-position in 3D and Q-E variables ei, ki, ef, kf, en, qh, qk and ql can be driven as virtual motors in SICS.
--
Incident and scattered energies are defined by monochromator crystals. In order for the
calculations to work, some parameters need to be configured. Monochromator and analyzer
diff --git a/event.c b/event.c
index 34bd30f8..233dd792 100644
--- a/event.c
+++ b/event.c
@@ -70,6 +70,7 @@ static char *pEvent[] = {
"STATESTART",
"STATEEND",
"NEWTARGET",
+ "DIMCHANGE",
NULL
};
diff --git a/event.h b/event.h
index c0a01efb..ef9dbabf 100644
--- a/event.h
+++ b/event.h
@@ -1,5 +1,5 @@
-#line 102 "event.w"
+#line 103 "event.w"
/*----------------------------------------------------------------------------
E V E N T
@@ -18,7 +18,7 @@
int Text2Event(char *pText);
-#line 115 "event.w"
+#line 116 "event.w"
@@ -48,8 +48,9 @@
#define STSTART 21
#define STEND 22
#define NEWTARGET 23
+#define DIMCHANGE 24
-#line 117 "event.w"
+#line 118 "event.w"
/*----------------- event data structure for the NEWTARGET event ---------*/
@@ -59,7 +60,7 @@ typedef struct {
} NewTarget, *pNewTarget;
/*--------------- Signals for the Signalfunction of each task ------------*/
-#line 84 "event.w"
+#line 85 "event.w"
#define SICSINT 300
#define SICSBROADCAST 301
@@ -68,6 +69,6 @@ typedef struct {
#define COMLOG 304
#define CRONLIST 305
-#line 125 "event.w"
+#line 126 "event.w"
#endif
diff --git a/event.tex b/event.tex
index 563f1e35..34aef4fb 100644
--- a/event.tex
+++ b/event.tex
@@ -59,6 +59,7 @@ $\langle$VE {\footnotesize ?}$\rangle\equiv$
\mbox{}\verb@#define STSTART 21@\\
\mbox{}\verb@#define STEND 22@\\
\mbox{}\verb@#define NEWTARGET 23@\\
+\mbox{}\verb@#define DIMCHANGE 24@\\
\mbox{}\verb@@$\Diamond$
\end{list}
\vspace{-1ex}
diff --git a/event.w b/event.w
index 21a7a2ce..6f4ed0c0 100644
--- a/event.w
+++ b/event.w
@@ -42,6 +42,7 @@ if the event code is not known, else the apropriate event code.
#define STSTART 21
#define STEND 22
#define NEWTARGET 23
+#define DIMCHANGE 24
@}
\begin{description}
\item[VALUECHANGE] This is a variable changing its value. As event data a pointer to the
diff --git a/exebuf.c b/exebuf.c
index 905c9118..cb90be08 100644
--- a/exebuf.c
+++ b/exebuf.c
@@ -164,6 +164,44 @@ static pDynString findBlockEnd(pExeBuf self)
DeleteDynString(command);
return NULL;
}
+/*-----------------attempt at a faster version -------------------------------
+ * But this only saves on the ConcatChar side of things......
+ *
+ * */
+static pDynString findBlockEndExp(pExeBuf self)
+{
+ pDynString command = NULL;
+ char *buffer = NULL;
+ char *cStart, *cEnd;
+ int i, len;
+
+ assert(self);
+
+ command = CreateDynString(80, 80);
+ if (command == NULL) {
+ return NULL;
+ }
+ buffer = GetCharArray(self->bufferContent);
+ if (self->end != -1) {
+ self->start = self->end + 1;
+ }
+ cStart = buffer +self->start;
+ cEnd = strchr(cStart,'\n');
+ while(cEnd != NULL){
+ len = cEnd - cStart+1;
+ DynStringConcatBytes(command,cStart, len);
+ self->lineno++;
+ if (Tcl_CommandComplete(GetCharArray(command))) {
+ self->end += len;
+ return command;
+ }
+ cStart = cEnd+1;
+ cEnd = strchr(cStart,'\n');
+ }
+
+ DeleteDynString(command);
+ return NULL;
+}
/*---------------------------------------------------------------------*/
int exeBufProcess(pExeBuf self, SicsInterp * pSics,
diff --git a/histmem.c b/histmem.c
index a8fe06f2..094fdbef 100644
--- a/histmem.c
+++ b/histmem.c
@@ -1274,6 +1274,7 @@ int HistAction(SConnection * pCon, SicsInterp * pSics, void *pData,
iRet = HistConfigure(self, pCon, pSics);
if (iRet) {
self->iInit = 1;
+ InvokeCallBack(self->pCall,DIMCHANGE,NULL);
SCSendOK(pCon);
} else {
self->iInit = 0;
@@ -1657,6 +1658,7 @@ int HistAction(SConnection * pCon, SicsInterp * pSics, void *pData,
}
/* do it */
genTimeBinning(self->pDriv->data, (float) dStart, (float) dStep, iNum);
+ InvokeCallBack(self->pCall,DIMCHANGE,NULL);
SCparChange(pCon);
SCSendOK(pCon);
return 1;
@@ -1693,6 +1695,7 @@ int HistAction(SConnection * pCon, SicsInterp * pSics, void *pData,
return 0;
}
setTimeBin(self->pDriv->data, iNum, (float) dStep);
+ InvokeCallBack(self->pCall,DIMCHANGE,NULL);
self->iInit = 0;
SCSendOK(pCon);
return 1;
@@ -1705,6 +1708,7 @@ int HistAction(SConnection * pCon, SicsInterp * pSics, void *pData,
return 0;
}
clearTimeBinning(self->pDriv->data);
+ InvokeCallBack(self->pCall,DIMCHANGE,NULL);
SCSendOK(pCon);
return 1;
}
diff --git a/lld.c b/lld.c
index 82cf1c3e..9270fc35 100644
--- a/lld.c
+++ b/lld.c
@@ -498,8 +498,12 @@ void LLDnodeDelete(int List)
/* adjust links
*/
- Old->prev->next = Old->next;
- Old->next->prev = Old->prev;
+ if(Old->prev != NULL){
+ Old->prev->next = Old->next;
+ }
+ if(Old->next != NULL){
+ Old->next->prev = Old->prev;
+ }
/* adjust current node pointer
prevent it from pointing to the dummy tail node
diff --git a/make_gen b/make_gen
index 9acf4d4d..39fa66eb 100644
--- a/make_gen
+++ b/make_gen
@@ -36,7 +36,7 @@ SOBJ = network.o ifile.o conman.o SCinter.o splitter.o passwd.o \
moregress.o multicounter.o regresscter.o histregress.o \
sicshdbadapter.o polldriv.o sicspoll.o statemon.o hmslave.o \
nwatch.o asyncqueue.o asyncprotocol.o sicsobj.o frame.o\
- nxcopy.o nxinterhelper.o nxinter_wrap.o nxstack.o \
+ nxcopy.o nxinterhelper.o nxinter_wrap.o nxstack.o arrayutil.o \
sctdriveadapter.o sctdriveobj.o reflist.o singlex.o fourmess.o \
sgclib.o sgfind.o sgio.o sgsi.o sghkl.o singlediff.o singlebi.o \
singlenb.o simindex.o simidx.o uselect.o singletas.o motorsec.o \
diff --git a/nxdataset.c b/nxdataset.c
index 25034bc6..5992232e 100644
--- a/nxdataset.c
+++ b/nxdataset.c
@@ -396,8 +396,8 @@ pNXDS cutNXDataset(pNXDS source, int start[], int end[])
}
/*----------------------------------------------------------------------
- This recurses through all dimesnions, thereby skipping the summed one.
- At the end of the rescusion the actual summing is performed.
+ This recurses through all dimensions, thereby skipping the summed one.
+ At the end of the recursion the actual summing is performed.
----------------------------------------------------------------------*/
static void sumData(pNXDS source, pNXDS target, int sourceDim[],
int targetDim[], int targetDimCount, int dimNo,
diff --git a/nxscript.c b/nxscript.c
index 141e3bab..cdf4c575 100644
--- a/nxscript.c
+++ b/nxscript.c
@@ -547,7 +547,7 @@ static void putHdbOff(SConnection * pCon, SicsInterp * pSics, pNXScript self,
GetHipadabaPar(node, &v, pCon);
if(offset < 0 || offset > v.arrayLength){
- SCPrintf(pCon,eLogError,"ERROR: invalid offset %d speicified", offset );
+ SCPrintf(pCon,eLogError,"ERROR: invalid offset %d specified", offset );
return;
}
switch (v.dataType) {
@@ -924,6 +924,8 @@ static void putSlab(SConnection * pCon, SicsInterp * pSics, pNXScript self,
pHistMem mem = NULL;
HistInt *histData = NULL;
pSICSData data = NULL;
+ pCounter memsec = NULL;
+ pHdb node = NULL;
if (argc < 6) {
SCWrite(pCon, "ERROR: insufficient number of arguments to putslab",
@@ -956,11 +958,27 @@ static void putSlab(SConnection * pCon, SicsInterp * pSics, pNXScript self,
if (mem != NULL) {
histData = GetHistogramPointer(mem, pCon);
if (histData) {
- status = NXputslab(self->fileHandle, histData, start, size);
+ status = NXputslab(self->fileHandle, histData, start, size);
+ if (status == NX_OK) {
+ written = 1;
+ }
+ }
+ }
+
+ /*
+ * try to write second gen histogram data
+ */
+ memsec = (pCounter) FindCommandData(pSics, argv[5], "HistMemSec");
+ if(memsec != NULL){
+ node = GetHipadabaNode(memsec->pDes->parNode,"data");
+ if(data != NULL){
+ SCWrite(pCon,"ERROR: ?? data node to second gen HM not found", eError);
+ return;
+ }
+ status = NXputslab(self->fileHandle, node->value.v.intArray, start, size);
if (status == NX_OK) {
written = 1;
}
- }
}
/*
diff --git a/ofac.c b/ofac.c
index ef67fbc7..b70e3da1 100644
--- a/ofac.c
+++ b/ofac.c
@@ -100,6 +100,7 @@ static void InitIniCommands(SicsInterp * pInter)
PCMD("sicsprompt", SicsPrompt);
PCMD("SICSStatus", SICSStatus);
PCMD("sicstime", SICSTime);
+ PCMD("doubletime", SICSDoubleTime);
PCMD("SICSType", SICSType);
PCMD("Sics_Exitus", SicsExit);
PCMD("silent", SICSSilent);
diff --git a/script.c b/script.c
index e211ac1a..5568e3cf 100644
--- a/script.c
+++ b/script.c
@@ -415,7 +415,16 @@ int SICSTime(SConnection * pCon, SicsInterp * pSics, void *pData,
SCWrite(pCon, pBueffel, eValue);
return 1;
}
+/*-------------------------------------------------------------------------*/
+int SICSDoubleTime(SConnection * pCon, SicsInterp * pSics, void *pData,
+ int argc, char *argv[])
+{
+ double dtime;
+ dtime = DoubleTime();
+ SCPrintf(pCon,eValue,"%lf",dtime);
+ return 1;
+}
/*--------------------------------------------------------------------------
Kill a command from SICS
*/
diff --git a/sicshdbadapter.c b/sicshdbadapter.c
index e9114fee..a56b4d89 100644
--- a/sicshdbadapter.c
+++ b/sicshdbadapter.c
@@ -28,6 +28,7 @@
#include "sicshipadaba.h"
#include "sicshdbadapter.h"
#include "sicsdata.h"
+#include "HistMem.i"
#define PRIVNAM "priv"
/*==================== support code ====================================*/
@@ -337,6 +338,7 @@ static long totalSum(int *data, int length)
/*----------------------------------------------------------------------*/
typedef struct {
pHistMem pHM;
+ pHdb node;
} HMAdapter, *pHMAdapter;
/*-------------------------------------------------------------------------*/
static hdbCallbackReturn HMDataGetCallback(pHdb currentNode,
@@ -359,9 +361,21 @@ static hdbCallbackReturn HMDataGetCallback(pHdb currentNode,
currentNode->value.arrayLength = GetHistLength(pHMA->pHM);
currentNode->value.v.intArray =
(int *) GetHistogramPointer(pHMA->pHM, pCon);
+ NotifyHipadabaPar(pHMA->node, NULL);
return hdbContinue;
}
+/*----------------------------------------------------------------------*/
+static int DimCallback(int iEvent, void *eventData, void *userData)
+{
+ pHMAdapter pHMA = (pHMAdapter)userData;
+ if(iEvent == DIMCHANGE){
+ pHMA->node->value.arrayLength = GetHistLength(pHMA->pHM);
+ pHMA->node->value.v.intArray =
+ (int *) GetHistogramPointer(pHMA->pHM, pServ->dummyCon);
+ }
+ return 1;
+}
/*----------------------------------------------------------------------*/
static pHdb MakeHMDataNode(pHistMem pHM, char *name)
{
@@ -375,6 +389,7 @@ static pHdb MakeHMDataNode(pHistMem pHM, char *name)
return NULL;
}
pHMA->pHM = pHM;
+ pHMA->node = node;
node->value.doNotFree = 1;
node->value.v.intArray = (int *)GetHistogramPointer(pHM, pServ->dummyCon);
pCall = MakeHipadabaCallback(HMDataGetCallback, pHMA, free);
@@ -383,7 +398,7 @@ static pHdb MakeHMDataNode(pHistMem pHM, char *name)
}
AppendHipadabaCallback(node, pCall);
AppendHipadabaCallback(node, MakeReadOnlyCallback());
-
+ RegisterCallback(pHM->pCall,DIMCHANGE, DimCallback, pHMA, NULL);
return node;
}
diff --git a/sicshipadaba.c b/sicshipadaba.c
index 4ec7e9bc..064d4f03 100644
--- a/sicshipadaba.c
+++ b/sicshipadaba.c
@@ -35,6 +35,7 @@
#include "sicsobj.h"
#include