First version of remoteobject. In the implementation of this, the following
sub problems were solved: - sicsget was not reporting geterrors on nodes properly - rwpuffer contained dirt after wrap - property change events were added to hipadaba - Some tuning of SICS output - The number of codes was wrong in outcode.c
This commit is contained in:
13
conman.c
13
conman.c
@ -1016,7 +1016,6 @@ int SCPureSockWrite(SConnection * self, char *buffer, int iOut)
|
|||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------
|
/*--------------------------------------------------------------------------
|
||||||
special for ClientLog. Do not use elsewhere without check
|
special for ClientLog. Do not use elsewhere without check
|
||||||
----------------------------------------------------------------------------*/
|
----------------------------------------------------------------------------*/
|
||||||
@ -1044,6 +1043,18 @@ int SCLogWrite(SConnection * self, char *buffer, int iOut)
|
|||||||
if(pPtr != pBueffel){
|
if(pPtr != pBueffel){
|
||||||
free(pPtr);
|
free(pPtr);
|
||||||
}
|
}
|
||||||
|
} else if(self->iProtocolID == 2) {
|
||||||
|
if (strlen(buffer) + 30 > 1024) {
|
||||||
|
pPtr = (char *) malloc((strlen(buffer) + 30) * sizeof(char));
|
||||||
|
memset(pPtr, 0, strlen(buffer) + 20);
|
||||||
|
} else {
|
||||||
|
pPtr = pBueffel;
|
||||||
|
}
|
||||||
|
sprintf(pPtr,"%s@@%s",buffer,pCode[iOut]);
|
||||||
|
testAndWriteSocket(self, pPtr, iOut);
|
||||||
|
if(pPtr != pBueffel){
|
||||||
|
free(pPtr);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
testAndWriteSocket(self, buffer, iOut);
|
testAndWriteSocket(self, buffer, iOut);
|
||||||
}
|
}
|
||||||
|
16
hipadaba.c
16
hipadaba.c
@ -22,6 +22,7 @@ static char update[] = { "update" };
|
|||||||
static char treeChange[] = { "treeChange" };
|
static char treeChange[] = { "treeChange" };
|
||||||
static char dataSearch[] = { "dataSearch" };
|
static char dataSearch[] = { "dataSearch" };
|
||||||
static char killNode[] = { "killNode" };
|
static char killNode[] = { "killNode" };
|
||||||
|
static char propertyChange[] = { "propertyChange" };
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
pHdbDataMessage GetHdbSetMessage(pHdbMessage toTest)
|
pHdbDataMessage GetHdbSetMessage(pHdbMessage toTest)
|
||||||
@ -77,6 +78,15 @@ pHdbMessage GetHdbKillNodeMessage(pHdbMessage toTest)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------------------*/
|
||||||
|
pHdbPropertyChange GetPropertyChangeMessage(pHdbMessage toTest)
|
||||||
|
{
|
||||||
|
if (toTest->type == propertyChange) {
|
||||||
|
return (pHdbPropertyChange)toTest;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/*================== internal functions ===================================*/
|
/*================== internal functions ===================================*/
|
||||||
void DeleteCallbackChain(pHdb node)
|
void DeleteCallbackChain(pHdb node)
|
||||||
{
|
{
|
||||||
@ -1140,6 +1150,8 @@ static int calcDataLength(pHdb node, int testLength)
|
|||||||
/*============================= Property Functions ==========================*/
|
/*============================= Property Functions ==========================*/
|
||||||
void SetHdbProperty(pHdb node, char *key, char *value)
|
void SetHdbProperty(pHdb node, char *key, char *value)
|
||||||
{
|
{
|
||||||
|
hdbPropertyChange propMes;
|
||||||
|
|
||||||
if (node != NULL && key != NULL && node->properties != NULL) {
|
if (node != NULL && key != NULL && node->properties != NULL) {
|
||||||
if (value == NULL) {
|
if (value == NULL) {
|
||||||
StringDictDelete(node->properties, key);
|
StringDictDelete(node->properties, key);
|
||||||
@ -1148,6 +1160,10 @@ void SetHdbProperty(pHdb node, char *key, char *value)
|
|||||||
} else {
|
} else {
|
||||||
StringDictAddPair(node->properties, key, value);
|
StringDictAddPair(node->properties, key, value);
|
||||||
}
|
}
|
||||||
|
propMes.type = propertyChange;
|
||||||
|
propMes.key = key;
|
||||||
|
propMes.value = value;
|
||||||
|
InvokeCallbackChain(node,(pHdbMessage)&propMes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
19
hipadaba.h
19
hipadaba.h
@ -26,6 +26,8 @@
|
|||||||
* Added support for properties, Mark Koennecke, January 2007
|
* Added support for properties, Mark Koennecke, January 2007
|
||||||
*
|
*
|
||||||
* Refactored callback handling, Markus Zolliker, Mark Koennecke, March 2008
|
* Refactored callback handling, Markus Zolliker, Mark Koennecke, March 2008
|
||||||
|
*
|
||||||
|
* Added property chnage events. Mark Koennecke, February 2015
|
||||||
*/
|
*/
|
||||||
#ifndef HIPADABA
|
#ifndef HIPADABA
|
||||||
#define HIPADABA
|
#define HIPADABA
|
||||||
@ -75,7 +77,8 @@ typedef struct __hipadaba {
|
|||||||
pStringDict properties;
|
pStringDict properties;
|
||||||
} Hdb, *pHdb;
|
} Hdb, *pHdb;
|
||||||
/*-------------- return values for callback functions -------------------------*/
|
/*-------------- return values for callback functions -------------------------*/
|
||||||
typedef enum { hdbContinue,
|
typedef enum {
|
||||||
|
hdbContinue,
|
||||||
hdbAbort,
|
hdbAbort,
|
||||||
hdbKill
|
hdbKill
|
||||||
} hdbCallbackReturn;
|
} hdbCallbackReturn;
|
||||||
@ -101,6 +104,12 @@ typedef struct {
|
|||||||
void *result;
|
void *result;
|
||||||
} hdbDataSearch, *pHdbDataSearch;
|
} hdbDataSearch, *pHdbDataSearch;
|
||||||
/*-------------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------------*/
|
||||||
|
typedef struct {
|
||||||
|
char *type;
|
||||||
|
char *key;
|
||||||
|
char *value;
|
||||||
|
} hdbPropertyChange, *pHdbPropertyChange;
|
||||||
|
/*-------------------------------------------------------------------------------*/
|
||||||
typedef hdbCallbackReturn(*hdbCallbackFunction) (pHdb currentNode,
|
typedef hdbCallbackReturn(*hdbCallbackFunction) (pHdb currentNode,
|
||||||
void *userData,
|
void *userData,
|
||||||
pHdbMessage message);
|
pHdbMessage message);
|
||||||
@ -156,6 +165,14 @@ pHdbDataSearch GetHdbDataSearchMessage(pHdbMessage toTest);
|
|||||||
* pointer if it is.
|
* pointer if it is.
|
||||||
*/
|
*/
|
||||||
pHdbMessage GetHdbKillNodeMessage(pHdbMessage toTest);
|
pHdbMessage GetHdbKillNodeMessage(pHdbMessage toTest);
|
||||||
|
/**
|
||||||
|
* Test a message if it is a property change message
|
||||||
|
* @param toTest The message to test.
|
||||||
|
* @return NULL if the message is no property chnage message or a message
|
||||||
|
* pointer if it is.
|
||||||
|
*/
|
||||||
|
pHdbPropertyChange GetPropertyChangeMessage(pHdbMessage toTest);
|
||||||
|
|
||||||
/*======================== Function protoypes: hdbData ========================*/
|
/*======================== Function protoypes: hdbData ========================*/
|
||||||
/**
|
/**
|
||||||
* make a hdbValue with the given datatype and length
|
* make a hdbValue with the given datatype and length
|
||||||
|
2
make_gen
2
make_gen
@ -46,7 +46,7 @@ SOBJ = network.o ifile.o conman.o SCinter.o splitter.o passwd.o \
|
|||||||
rwpuffer.o asynnet.o background.o countersec.o hdbtable.o velosec.o \
|
rwpuffer.o asynnet.o background.o countersec.o hdbtable.o velosec.o \
|
||||||
histmemsec.o sansbc.o sicsutil.o strlutil.o genbinprot.o trace.o\
|
histmemsec.o sansbc.o sicsutil.o strlutil.o genbinprot.o trace.o\
|
||||||
singlebinb.o taskobj.o sctcomtask.o tasmono.o multicountersec.o \
|
singlebinb.o taskobj.o sctcomtask.o tasmono.o multicountersec.o \
|
||||||
messagepipe.o sicsget.o
|
messagepipe.o sicsget.o remoteobject.o
|
||||||
|
|
||||||
MOTOROBJ = motor.o simdriv.o
|
MOTOROBJ = motor.o simdriv.o
|
||||||
COUNTEROBJ = countdriv.o simcter.o counter.o
|
COUNTEROBJ = countdriv.o simcter.o counter.o
|
||||||
|
25
motorsec.c
25
motorsec.c
@ -375,7 +375,7 @@ static float SecMotorGetValue(void *pData, SConnection * pCon)
|
|||||||
assert(pData);
|
assert(pData);
|
||||||
status = GetHdbProperty(self->pDescriptor->parNode,"geterror", error,sizeof(error));
|
status = GetHdbProperty(self->pDescriptor->parNode,"geterror", error,sizeof(error));
|
||||||
if(status == 1 && strcmp(error,"none") != 0) {
|
if(status == 1 && strcmp(error,"none") != 0) {
|
||||||
SCPrintf(pCon,eValue,"ERROR: Failed to read %s with %s", self->name, error);
|
SCPrintf(pCon,eError,"ERROR: Failed to read %s with %s", self->name, error);
|
||||||
return -9999999.99;
|
return -9999999.99;
|
||||||
}
|
}
|
||||||
status = GetHipadabaPar(self->pDescriptor->parNode, &v, pCon);
|
status = GetHipadabaPar(self->pDescriptor->parNode, &v, pCon);
|
||||||
@ -465,7 +465,7 @@ static hdbCallbackReturn SecMotorCallback(pHdb node, void *userData,
|
|||||||
pHdb child = NULL;
|
pHdb child = NULL;
|
||||||
pMotor self = NULL;
|
pMotor self = NULL;
|
||||||
float fHard, fVal, sign, zero;
|
float fHard, fVal, sign, zero;
|
||||||
char pBueffel[512], pError[132];
|
char pBueffel[512], pError[132], *pPtr = NULL;
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
self = (pMotor) userData;
|
self = (pMotor) userData;
|
||||||
@ -526,6 +526,8 @@ static hdbCallbackReturn SecMotorCallback(pHdb node, void *userData,
|
|||||||
ServerWriteGlobal(pBueffel, eError);
|
ServerWriteGlobal(pBueffel, eError);
|
||||||
SCSetInterrupt(pCon, eAbortBatch);
|
SCSetInterrupt(pCon, eAbortBatch);
|
||||||
self->pDrivInt->iErrorCount = 0;
|
self->pDrivInt->iErrorCount = 0;
|
||||||
|
child = GetHipadabaNode(self->pDescriptor->parNode, "status");
|
||||||
|
UpdateHipadabaPar(child, MakeHdbText("run"), pCon);
|
||||||
return hdbAbort;
|
return hdbAbort;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -547,6 +549,12 @@ static hdbCallbackReturn SecMotorCallback(pHdb node, void *userData,
|
|||||||
if (mm != NULL) {
|
if (mm != NULL) {
|
||||||
pCon = (SConnection *) mm->callData;
|
pCon = (SConnection *) mm->callData;
|
||||||
SecMotorGetPar(self, "hardposition", &fVal);
|
SecMotorGetPar(self, "hardposition", &fVal);
|
||||||
|
child = GetHipadabaNode(self->pDescriptor->parNode, "hardposition");
|
||||||
|
if((pPtr = GetHdbProp(child,"geterror")) != NULL){
|
||||||
|
SetHdbProperty(node,"geterror",pPtr);
|
||||||
|
} else {
|
||||||
|
SetHdbProperty(node,"geterror",NULL);
|
||||||
|
}
|
||||||
fVal = hardToSoftPosition(self, fVal);
|
fVal = hardToSoftPosition(self, fVal);
|
||||||
node->value.v.doubleValue = fVal;
|
node->value.v.doubleValue = fVal;
|
||||||
mm->v->v.doubleValue = fVal;
|
mm->v->v.doubleValue = fVal;
|
||||||
@ -561,6 +569,7 @@ static hdbCallbackReturn HardUpdateCallback(pHdb node, void *userData,
|
|||||||
pHdbMessage message)
|
pHdbMessage message)
|
||||||
{
|
{
|
||||||
pHdbDataMessage mm = NULL;
|
pHdbDataMessage mm = NULL;
|
||||||
|
pHdbPropertyChange pm = NULL;
|
||||||
pMotor self = (pMotor) userData;
|
pMotor self = (pMotor) userData;
|
||||||
float fVal;
|
float fVal;
|
||||||
hdbValue v;
|
hdbValue v;
|
||||||
@ -575,6 +584,18 @@ static hdbCallbackReturn HardUpdateCallback(pHdb node, void *userData,
|
|||||||
UpdateHipadabaPar(self->pDescriptor->parNode, v, mm->callData);
|
UpdateHipadabaPar(self->pDescriptor->parNode, v, mm->callData);
|
||||||
return hdbContinue;
|
return hdbContinue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
forward geterror
|
||||||
|
*/
|
||||||
|
pm = GetPropertyChangeMessage(message);
|
||||||
|
if(pm != NULL){
|
||||||
|
if(strstr(pm->key,"geterror") != NULL){
|
||||||
|
SetHdbProperty(self->pDescriptor->parNode,pm->key, pm->value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return hdbContinue;
|
return hdbContinue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -221,7 +221,6 @@ int InitServer(char *file, pServer * pServ)
|
|||||||
printf("Cannot find InterruptPort number in options file %s\n",
|
printf("Cannot find InterruptPort number in options file %s\n",
|
||||||
"This value is required!");
|
"This value is required!");
|
||||||
DeleteInterp(self->pSics);
|
DeleteInterp(self->pSics);
|
||||||
IFDeleteOptions(pSICSOptions);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
iRet = sscanf(pText, "%d", &iPort);
|
iRet = sscanf(pText, "%d", &iPort);
|
||||||
@ -234,6 +233,8 @@ int InitServer(char *file, pServer * pServ)
|
|||||||
}
|
}
|
||||||
/* install a secret fully priviledged entry point for ME */
|
/* install a secret fully priviledged entry point for ME */
|
||||||
AddUser("Achterbahn", "Kiel", usInternal);
|
AddUser("Achterbahn", "Kiel", usInternal);
|
||||||
|
/* install a secret entry point for remote objects */
|
||||||
|
AddUser("RemoteMaster","3ed4c656a15f0aa45e02fd5ec429225bb93b762e7eb06cc81a0b4f6c35c76184",usInternal);
|
||||||
|
|
||||||
/* install environment monitor */
|
/* install environment monitor */
|
||||||
self->pMonitor = GetEnvMon(self->pSics);
|
self->pMonitor = GetEnvMon(self->pSics);
|
||||||
|
1
ofac.c
1
ofac.c
@ -48,6 +48,7 @@ static void InitGeneral(void)
|
|||||||
INIT(AddSyncedProt);
|
INIT(AddSyncedProt);
|
||||||
INIT(MakeTrace);
|
INIT(MakeTrace);
|
||||||
INIT(InitTaskOBJ);
|
INIT(InitTaskOBJ);
|
||||||
|
INIT(RemoteObjectInit);
|
||||||
INIT(SiteInit); /* site specific initializations */
|
INIT(SiteInit); /* site specific initializations */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,5 +26,5 @@ static char *pCode[] = {
|
|||||||
"logerror",
|
"logerror",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
static int iNoCodes = 13;
|
static int iNoCodes = 15;
|
||||||
#endif
|
#endif
|
||||||
|
@ -290,7 +290,7 @@ static int ProtocolSet(SConnection * pCon, Protocol * pPro, char *pProName)
|
|||||||
SCSetWriteFunc(pCon, SCWriteJSON_String);
|
SCSetWriteFunc(pCon, SCWriteJSON_String);
|
||||||
SCSetWriteFunc(pMaster, SCWriteJSON_String);
|
SCSetWriteFunc(pMaster, SCWriteJSON_String);
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5: /* ACT */
|
||||||
SCSetWriteFunc(pMaster, SCACTWrite);
|
SCSetWriteFunc(pMaster, SCACTWrite);
|
||||||
SCSetWriteFunc(pCon, SCACTWrite);
|
SCSetWriteFunc(pCon, SCACTWrite);
|
||||||
break;
|
break;
|
||||||
|
1008
remoteobject.c
Normal file
1008
remoteobject.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -131,5 +131,6 @@ void RemoveRWBufferData(prwBuffer self, int count)
|
|||||||
if (self->startPtr >= self->endPtr) {
|
if (self->startPtr >= self->endPtr) {
|
||||||
self->startPtr = 0;
|
self->startPtr = 0;
|
||||||
self->endPtr = 0;
|
self->endPtr = 0;
|
||||||
|
memset(self->data,0,self->length*sizeof(char));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
36
sicsget.c
36
sicsget.c
@ -89,7 +89,11 @@ static int SICSGetCommand(SConnection * pCon, SicsInterp * pSics, void *pData,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SCPrintf(pCon,eError,"ERROR: value for %s not found", argv[1]);
|
if(v.dataType == HIPTEXT && strstr(v.v.text,"ERROR") != NULL){
|
||||||
|
SCPrintf(pCon,eError,v.v.text);
|
||||||
|
} else {
|
||||||
|
SCPrintf(pCon,eError,"ERROR: value for %s not found", argv[1]);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
ReleaseHdbValue(&v);
|
ReleaseHdbValue(&v);
|
||||||
@ -326,10 +330,20 @@ static int GetHdbFunc(void *ms, void *userData)
|
|||||||
{
|
{
|
||||||
pSSGMessage self = (pSSGMessage)ms;
|
pSSGMessage self = (pSSGMessage)ms;
|
||||||
pHdb node = NULL;
|
pHdb node = NULL;
|
||||||
|
char *geterror = NULL, error[512];
|
||||||
|
hdbValue ve;
|
||||||
|
|
||||||
node = FindHdbNode(NULL,self->name,NULL);
|
node = FindHdbNode(NULL,self->name,NULL);
|
||||||
if(node != NULL){
|
if(node != NULL){
|
||||||
cloneHdbValue(&node->value, self->v);
|
geterror = GetHdbProp(node,"geterror");
|
||||||
|
if(geterror != NULL){
|
||||||
|
snprintf(error,sizeof(error),"ERROR: %s",geterror);
|
||||||
|
ve = MakeHdbText(strdup(error));
|
||||||
|
cloneHdbValue(&ve, self->v);
|
||||||
|
ReleaseHdbValue(&ve);
|
||||||
|
} else {
|
||||||
|
cloneHdbValue(&node->value, self->v);
|
||||||
|
}
|
||||||
self->success = 1;
|
self->success = 1;
|
||||||
return MPSTOP;
|
return MPSTOP;
|
||||||
} else {
|
} else {
|
||||||
@ -381,14 +395,28 @@ static int GetDrivableFunc(void *ms, void *userData)
|
|||||||
pIDrivable pDriv = NULL;
|
pIDrivable pDriv = NULL;
|
||||||
float fVal;
|
float fVal;
|
||||||
hdbValue v;
|
hdbValue v;
|
||||||
|
int oldMacro;
|
||||||
|
|
||||||
data = FindCommandData(pServ->pSics, self->name,NULL);
|
data = FindCommandData(pServ->pSics, self->name,NULL);
|
||||||
if(data != NULL){
|
if(data != NULL){
|
||||||
pDriv = GetDrivableInterface(data);
|
pDriv = GetDrivableInterface(data);
|
||||||
if(pDriv != NULL){
|
if(pDriv != NULL){
|
||||||
|
/*
|
||||||
|
All this macro flag handling is there to get hold of a
|
||||||
|
error message stored in the Tcl interpreter if there is
|
||||||
|
one.
|
||||||
|
*/
|
||||||
|
oldMacro = SCinMacro(pServ->dummyCon);
|
||||||
|
SCsetMacro(pServ->dummyCon,1);
|
||||||
fVal = pDriv->GetValue(data,pServ->dummyCon);
|
fVal = pDriv->GetValue(data,pServ->dummyCon);
|
||||||
v = MakeHdbFloat(fVal);
|
SCsetMacro(pServ->dummyCon,oldMacro);
|
||||||
self->success = 1;
|
if(fVal < -900000) {
|
||||||
|
v = MakeHdbText(Tcl_GetStringResult(InterpGetTcl(pServ->pSics)));
|
||||||
|
self->success = 0;
|
||||||
|
} else {
|
||||||
|
v = MakeHdbFloat(fVal);
|
||||||
|
self->success = 1;
|
||||||
|
}
|
||||||
cloneHdbValue(&v,self->v);
|
cloneHdbValue(&v,self->v);
|
||||||
return MPSTOP;
|
return MPSTOP;
|
||||||
}
|
}
|
||||||
|
@ -339,6 +339,7 @@ static int MakeCommandNode(pHdb parent, char *name, SConnection * pCon,
|
|||||||
node->value.v.text = strdup(argv[3]);
|
node->value.v.text = strdup(argv[3]);
|
||||||
node->value.arrayLength = strlen(argv[3]);
|
node->value.arrayLength = strlen(argv[3]);
|
||||||
SetHdbProperty(node, "sicscommand", argv[3]);
|
SetHdbProperty(node, "sicscommand", argv[3]);
|
||||||
|
SetHdbProperty(node, "scriptcommand", "yes");
|
||||||
|
|
||||||
kalle = MakeHipadabaCallback(CommandSetCallback, NULL, NULL);
|
kalle = MakeHipadabaCallback(CommandSetCallback, NULL, NULL);
|
||||||
if (kalle == NULL) {
|
if (kalle == NULL) {
|
||||||
|
Reference in New Issue
Block a user