Commit a57f8684 authored by koennecke's avatar koennecke
Browse files

- Added the zebracounter which selects what is the counts per parameter

- Removed excessiove privavcy to the connection data structure in pardef.c
- Made mongolog generate more error output
parent 54ff94bf
......@@ -81,6 +81,7 @@ add_library(site
dumprot.c
collectprot.c
mpaprot.c
zebracounter.c
)
set_property(SOURCE epicsadapter.c PROPERTY COMPILE_FLAGS "-I{PROJECT_SOURCE_DIR} -I${EPICS_BASE}/include -I${EPICS_BASE}/include/os/Linux")
include_directories("." ".." "../sics" "hardsup")
......
......@@ -79,6 +79,7 @@ static void MongoCallback(unsigned int severity, const char *timeStamp,
if (!mongoc_collection_insert (collection, MONGOC_INSERT_NONE, doc, NULL, &error)) {
fprintf (stdout, "%s\n", error.message);
MongoClose(NULL);
Log(ERROR,"sys", "MongoDB error %s detected", error.message);
Log(FATAL,"sys", "Lost connection to mongo server at %s", mongoURL);
}
......
......@@ -448,9 +448,9 @@ void ParSaveConn(void *object, SConnection * con)
int rights;
rights = SCGetRights(con);
if (rights >= usMugger && rights <= usUser && con->sockHandle >= 0) {
if (rights >= usMugger && rights <= usUser && SCGetSockHandle(con) >= 0) {
if (o->conn != NULL) {
if (o->conn->ident != con->ident) {
if (SCGetIdent(o->conn) != SCGetIdent(con)) {
SCDeleteConnection(o->conn);
o->conn = SCCopyConnection(con);
}
......@@ -458,8 +458,8 @@ void ParSaveConn(void *object, SConnection * con)
o->conn = SCCopyConnection(con);
}
SCsetMacro(o->conn, 0);
if (o->conn->write != SCNormalWrite) {
o->conn->write = SCNormalWrite;
if (SCGetWriteFunc(o->conn) != SCNormalWrite) {
SCSetWriteFunc(o->conn,SCNormalWrite);
}
}
}
......
......@@ -121,6 +121,7 @@ static void AddPsiCommands(SicsInterp * pInter)
PCMD("cnvrt", CnvrtAction);
SCMD("MakeEpicsAdapter", MakeEpicsAdapter);
PCMD("zebraswap", ZebraSwap);
SCMD("MakeZebraCounter", MakeZebraCter);
/*
* Tcl 8.5 has implemented the clock command in tcl rather then C.
* This includes the same command, backported from Tcl 8.4
......
/*
* This is a special version of the second generation counter for ZEBRA.
* ZEBRA has two detector units. The analyser units detetcor is patched to
* the monitor channel 2. Thus sometimes the counts are normal, in index 0
* of the data, sometimes in counter 2. This special version takes care of
* this.
*
* copyright: see file COPYRIGHT
*
* Mark Koennecke, July 2018
*/
#include <sics.h>
#include <counter.h>
#include <sicshipadaba.h>
/*
in countersec.c in the sics kernel directory
*/
extern long SecCtrGetMonitor(pCounter self, int iNum, SConnection *pCon);
/*--------------------------------------------------------------------------*/
static long ZebraCtrGetCounts(pCounter self, SConnection *pCon)
{
int idx = 0;
pHdb node = NULL;
node = GetHipadabaNode(self->objectNode,"countidx");
assert(node != NULL);
idx = node->value.v.intValue;
return SecCtrGetMonitor(self,idx,pCon);
}
/*--------------------------------------------------------------------------*/
int MakeZebraCter(SConnection * pCon, SicsInterp * pSics, void *pData,
int argc, char *argv[])
{
pCounter pRes = NULL;
int status, length;
pHdb node, child;
if(argc < 2) {
SCWrite(pCon,"ERROR: need at least a name to create a counter",
eError);
return 0;
}
pRes = CreateSecCounter(pCon,"SingleCounter", argv[1], 8);
if(pRes == NULL){
return 0;
}
pRes->getCounts = ZebraCtrGetCounts;
child = MakeSICSHdbPar("countidx", usMugger, MakeHdbInt(0));
if (child != NULL) {
SetHdbProperty(child, "__save", "true");
AddHipadabaChild(pRes->objectNode, child, NULL);
}
status =
AddCommand(pSics, argv[1], InterInvokeSICSOBJ, DeleteCounter,
(void *) pRes);
if (status != 1) {
SCPrintf(pCon,eError, "ERROR: duplicate command %s not created", argv[1]);
return 0;
}
return 1;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment