- removed functions with void *data in the interface
- added RemoveSetUpdateCallback
This commit is contained in:
@ -113,15 +113,37 @@ pHdbCallback MakeCheckPermissionCallback(int priv){
|
||||
return MakeHipadabaCallback(SICSCheckPermissionCallback, testPriv,free);
|
||||
}
|
||||
/*-------------------------------------------------------------------------------------*/
|
||||
static char *removeSetUpdateID = "removeSetUpdate";
|
||||
|
||||
void RemoveSetUpdateCallback(pHdb node) {
|
||||
hdbPtrMessage m;
|
||||
|
||||
m.type = killPtr;
|
||||
m.pPtr = removeSetUpdateID;
|
||||
InvokeCallbackChain(node, (pHdbMessage)&m);
|
||||
}
|
||||
/*-------------------------------------------------------------------------------------*/
|
||||
static hdbCallbackReturn SICSSetUpdateCallback(pHdb node, void *userData,
|
||||
pHdbMessage message){
|
||||
pHdbDataMessage mm = NULL;
|
||||
pHdbPtrMessage pm = NULL;
|
||||
int status;
|
||||
|
||||
pm = GetKillPtrMessage(message);
|
||||
if (pm != NULL) {
|
||||
if (pm->pPtr == removeSetUpdateID) {
|
||||
return hdbKill;
|
||||
}
|
||||
return hdbContinue;
|
||||
}
|
||||
mm = GetHdbSetMessage(message);
|
||||
if(mm == NULL){
|
||||
return hdbContinue;
|
||||
}
|
||||
UpdateHipadabaPar(node,*(mm->v),mm->callData);
|
||||
status = UpdateHipadabaPar(node,*(mm->v),mm->callData);
|
||||
if (status) {
|
||||
SCSendOK(mm->callData);
|
||||
}
|
||||
return hdbContinue;
|
||||
}
|
||||
/*-------------------------------------------------------------------------------------*/
|
||||
@ -249,7 +271,7 @@ static hdbCallbackReturn SICSFuncCallback(pHdb node, void *userData,
|
||||
nPar++;
|
||||
current = current->next;
|
||||
}
|
||||
func = (SICSOBJFunc)node->value.v.obj;
|
||||
func = (SICSOBJFunc)node->value.v.func;
|
||||
if(func != NULL){
|
||||
status = func((pSICSOBJ)userData,(SConnection *)mm->callData,
|
||||
node, par,nPar);
|
||||
@ -996,12 +1018,6 @@ pHdb MakeSICSHdbPar(char *name, int priv, hdbValue v){
|
||||
|
||||
return result;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
pHdb CreateSICSHdbPar(char *name, int priv, int dataType,
|
||||
int length, void *data){
|
||||
return MakeSICSHdbPar(name,priv,makeHdbData(dataType,
|
||||
length,data));
|
||||
}
|
||||
/*----------------------------------------------------------------------------*/
|
||||
pHdb MakeSICSHdbDriv(char *name, int priv, void *sicsObject, int dataType){
|
||||
pHdb result = NULL;
|
||||
@ -1120,12 +1136,6 @@ pHdb MakeSICSScriptPar(char *name, char *setScript, char *readScript,
|
||||
SetHdbProperty(result,"sicscommand",setScript);
|
||||
return result;
|
||||
}
|
||||
/*-------------------------------------------------------------------------*/
|
||||
pHdb CreateSICSScriptPar(char *name, char *setScript, char *readScript,
|
||||
int dataType, int length, void *data){
|
||||
return MakeSICSScriptPar(name,setScript,readScript,
|
||||
makeHdbData(dataType, length,data));
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
static void removeNodeFromUpdateList(pHdb node){
|
||||
pHdb current = NULL;
|
||||
@ -1393,7 +1403,7 @@ static int RemoveParNodeCallback(char *name, pDummy object, void *internalID) {
|
||||
m.type = killPtr;
|
||||
m.pPtr = internalID;
|
||||
if (object->pDescriptor->parNode) {
|
||||
InvokeCallbackChain(object->pDescriptor->parNode,(pHdbMessage)&m);
|
||||
RecurseCallbackChains(object->pDescriptor->parNode,(pHdbMessage)&m);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@ -1403,12 +1413,11 @@ void RemoveSICSInternalCallback(void *internalID) {
|
||||
|
||||
m.type = killPtr;
|
||||
m.pPtr = internalID;
|
||||
InvokeCallbackChain(GetHipadabaRoot(),(pHdbMessage)&m);
|
||||
RecurseCallbackChains(GetHipadabaRoot(),(pHdbMessage)&m);
|
||||
ForEachCommand(RemoveParNodeCallback, internalID);
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
int SICSHdbGetPar(void *obj, SConnection *pCon,
|
||||
char *path, int dataType, void *data, int length){
|
||||
int SICSHdbGetPar(void *obj, SConnection *pCon, char *path, hdbValue *v){
|
||||
pHdb par = NULL;
|
||||
int status;
|
||||
char buffer[256];
|
||||
@ -1432,16 +1441,14 @@ int SICSHdbGetPar(void *obj, SConnection *pCon,
|
||||
return SICSNOPAR;
|
||||
}
|
||||
|
||||
status = GetHdbPar(par,dataType,data,length,pCon);
|
||||
status = GetHipadabaPar(par,v,pCon);
|
||||
if(status < 0){
|
||||
return status;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
int SICSHdbUpdatePar(void *obj, SConnection *pCon,
|
||||
char *path, int dataType,void *data, int dataLength ){
|
||||
hdbValue v;
|
||||
int SICSHdbUpdatePar(void *obj, SConnection *pCon, char *path, hdbValue v){
|
||||
pHdb par = NULL;
|
||||
int status;
|
||||
char buffer[256];
|
||||
@ -1465,16 +1472,14 @@ int SICSHdbUpdatePar(void *obj, SConnection *pCon,
|
||||
return SICSNOPAR;
|
||||
}
|
||||
|
||||
status = UpdateHdbPar(par,dataType,data,dataLength,pCon);
|
||||
status = UpdateHipadabaPar(par,v,pCon);
|
||||
if(status < 0){
|
||||
return status;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
int SICSHdbSetPar(void *obj, SConnection *pCon,
|
||||
char *path, int dataType,void *data, int dataLength ){
|
||||
hdbValue v;
|
||||
int SICSHdbSetPar(void *obj, SConnection *pCon, char *path, hdbValue v){
|
||||
pHdb par = NULL;
|
||||
int status;
|
||||
char buffer[256];
|
||||
@ -1498,8 +1503,8 @@ int SICSHdbSetPar(void *obj, SConnection *pCon,
|
||||
return SICSNOPAR;
|
||||
}
|
||||
|
||||
status = SetHdbPar(par,dataType,data,dataLength,pCon);
|
||||
if(status < 0){
|
||||
status = SetHipadabaPar(par,v,pCon);
|
||||
if(status <= 0){
|
||||
return status;
|
||||
}
|
||||
return 1;
|
||||
@ -1586,7 +1591,7 @@ int ProcessSICSHdbPar(pHdb root, SConnection *pCon,
|
||||
status = SetHipadabaPar(parNode,input,pCon);
|
||||
ReleaseHdbValue(&input);
|
||||
if(status == 1){
|
||||
SCSendOK(pCon);
|
||||
/* SCSendOK(pCon); do not send OK. this has to be done by the callback */
|
||||
SCparChange(pCon);
|
||||
}
|
||||
return status;
|
||||
@ -1861,12 +1866,6 @@ int readHdbValue(hdbValue *v, char *data, char *error, int errlen){
|
||||
}
|
||||
break;
|
||||
case HIPOBJ:
|
||||
objData = FindCommandData(pServ->pSics,data,NULL);
|
||||
if(objData == NULL){
|
||||
snprintf(error,errlen,"object %s NOT found", data);
|
||||
return 0;
|
||||
}
|
||||
v->v.obj = objData;
|
||||
break;
|
||||
case HIPFUNC:
|
||||
break;
|
||||
@ -2116,7 +2115,8 @@ static int SetHdbNode(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
SCWrite(pCon,"ERROR: out of memory reading parameter",eError);
|
||||
return 0;
|
||||
}
|
||||
for(i = 2; i < argc; i++){
|
||||
DynStringConcat(parData, argv[2]);
|
||||
for(i = 3; i < argc; i++){
|
||||
DynStringConcat(parData," ");
|
||||
DynStringConcat(parData, argv[i]);
|
||||
}
|
||||
@ -2130,7 +2130,7 @@ static int SetHdbNode(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
status = SetHipadabaPar(targetNode,newValue,pCon);
|
||||
ReleaseHdbValue(&newValue);
|
||||
if(status == 1){
|
||||
SCSendOK(pCon);
|
||||
/* SCSendOK(pCon); sending ok has to be done by the callback. */
|
||||
}
|
||||
return status;
|
||||
}
|
||||
@ -2646,7 +2646,7 @@ static int RemoveHdbCallback(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
id = atoi(argv[1]);
|
||||
m.type = killID;
|
||||
m.ID = id;
|
||||
InvokeCallbackChain(root,(pHdbMessage)&m);
|
||||
RecurseCallbackChains(root,(pHdbMessage)&m);
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
}
|
||||
@ -2940,7 +2940,7 @@ static int SetSICSHdbProperty(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
SCWrite(pCon,"ERROR: node not found",eError);
|
||||
return 0;
|
||||
}
|
||||
Arg2Text(argc-3, &argv[3], buffer,512);
|
||||
Arg2Tcl(argc-3, &argv[3], buffer,512);
|
||||
SetHdbProperty(targetNode,argv[2], buffer);
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
@ -3116,7 +3116,7 @@ int InstallSICSHipadaba(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
AddCommand(pSics,"hcommand",SicsCommandNode, NULL, NULL);
|
||||
AddCommand(pSics,"hsetprop",SetSICSHdbProperty, NULL, NULL);
|
||||
AddCommand(pSics,"hgetprop",GetSICSHdbProperty, NULL, NULL);
|
||||
AddCommand(pSics,"hgetprop",GetSICSHdbProperty, NULL, NULL);
|
||||
AddCommand(pSics,"hgetpropval",GetSICSHdbPropertyVal, NULL, NULL);
|
||||
AddCommand(pSics,"hmatchprop",MatchHdbProperty, NULL, NULL);
|
||||
AddCommand(pSics,"hlistprop",ListSICSHdbProperty, NULL, NULL);
|
||||
|
||||
|
@ -54,11 +54,17 @@ pHdbCallback MakeReadOnlyCallback();
|
||||
pHdbCallback MakeCheckPermissionCallback(int priv);
|
||||
/**
|
||||
* make a callback which directly updates a
|
||||
* paramter after setting. Usefule for program parameters.
|
||||
* paramter after setting. Useful for program parameters.
|
||||
* @return a suitably initialized callback structure setting
|
||||
* program parameters
|
||||
*/
|
||||
pHdbCallback MakeSetUpdateCallback();
|
||||
/**
|
||||
* Remove a SetUpdate callback. This is useful for chaning the
|
||||
* behaviour of a node created with the hmake command
|
||||
* @param node the node
|
||||
*/
|
||||
void RemoveSetUpdateCallback(pHdb node);
|
||||
/**
|
||||
* make a callback which starts a parameter driving.
|
||||
* @param sicsObject The SICS object to drive.
|
||||
@ -149,19 +155,6 @@ pHdbCallback MakeMemSetCallback(float *address);
|
||||
* @return A new suitably configured Hdb parameter or NULL when out of memory.
|
||||
*/
|
||||
pHdb MakeSICSHdbPar(char *name, int priv, hdbValue v);
|
||||
/**
|
||||
* make a simple SICS hdb parameter. Setting it will call update immediately. Use
|
||||
* this for program parameters.
|
||||
* @param name The name of the parameter
|
||||
* @param priv The privilege required to change that parameter
|
||||
* @param dataType The datatype for the new parameter.
|
||||
* @param length The length of any arrays
|
||||
* @param data Data to initalise the parameter with. Can be NULL, then
|
||||
* no initialisation takes place.
|
||||
* @return A new suitably configured Hdb parameter or NULL when out of memory.
|
||||
*/
|
||||
pHdb CreateSICSHdbPar(char *name, int priv, int dataType,
|
||||
int length, void *data);
|
||||
/**
|
||||
* make a SICS hdb drivable parameter. Setting it will start the motor,
|
||||
* virtual motor or environment parameter. This will call StartDevice
|
||||
@ -198,21 +191,6 @@ pHdb MakeSICSROPar(char *name, hdbValue v);
|
||||
* @return A new suitably configured Hdb parameter or NULL when out of memory.
|
||||
*/
|
||||
pHdb MakeSICSScriptPar(char *name, char *setScript, char *readScript, hdbValue v);
|
||||
/**
|
||||
* make a SICS scriptable parameter. I.e. when this parameter is set or read,
|
||||
* appropriate scripts are invoked.
|
||||
* @param name The name of the parameter
|
||||
* @param setScript
|
||||
* @param readScript
|
||||
* @param name The name of the parameter
|
||||
* @param dataType The datatype for the new parameter.
|
||||
* @param length The length of any arrays
|
||||
* @param data Data to initalise the parameter with. Can be NULL, then
|
||||
* no initialisation takes place.
|
||||
* @return A new suitably configured Hdb parameter or NULL when out of memory.
|
||||
*/
|
||||
pHdb CreateSICSScriptPar(char *name, char *setScript, char *readScript,
|
||||
int dataType, int length, void *data);
|
||||
|
||||
/**
|
||||
* remove a SICS paramameter node and its children. In contrast to the
|
||||
@ -305,37 +283,28 @@ void RemoveSICSInternalCallback(void *internalID);
|
||||
* @param obj The object for which to get a parameter.
|
||||
* @param pCon The optional connection object to use for reporting errors.
|
||||
* @param path The path to the parameter.
|
||||
* @param dataType The datatype for the parameter.
|
||||
* @param data Target pointer to which to copy data too.
|
||||
* @param length The length of data
|
||||
* @param v the value
|
||||
* @return 1 on success, a negative error code else.
|
||||
*/
|
||||
int SICSHdbGetPar(void *obj, SConnection *pCon,
|
||||
char *path, int dataType, void *data, int length);
|
||||
int SICSHdbGetPar(void *obj, SConnection *pCon, char *path, hdbValue *v);
|
||||
/**
|
||||
* SICSHdbUpdatePar updates the value of a parameter.
|
||||
* @param obj The object for which to get a parameter.
|
||||
* @param pCon The optional connection object to use for reporting errors.
|
||||
* @param path The path to the parameter.
|
||||
* @param dataType The datatype for the parameter.
|
||||
* @param data Pointer from which to copy data.
|
||||
* @param length The length of data
|
||||
* @param v the value
|
||||
* @return 1 on success, a negative error code else.
|
||||
*/
|
||||
int SICSHdbUpdatePar(void *obj, SConnection *pCon,
|
||||
char *path, int dataType, void *data, int length);
|
||||
int SICSHdbUpdatePar(void *obj, SConnection *pCon, char *path, hdbValue v);
|
||||
/**
|
||||
* SICSHdbSetPar sets the value of a parameter.
|
||||
* @param obj The object for which to get a parameter.
|
||||
* @param pCon The optional connection object to use for reporting errors.
|
||||
* @param path The path to the parameter.
|
||||
* @param dataType The datatype for the parameter.
|
||||
* @param data Pointer from which to copy data.
|
||||
* @param length The length of data
|
||||
* @return 1 on success, a negative error code else.
|
||||
* @param v the value
|
||||
* @return positive on success, a negative error code else.
|
||||
*/
|
||||
int SICSHdbSetPar(void *obj, SConnection *pCon,
|
||||
char *path, int dataType, void *data, int length);
|
||||
int SICSHdbSetPar(void *obj, SConnection *pCon, char *path, hdbValue v);
|
||||
/**
|
||||
* query function if a parameter is read only.
|
||||
* @param node The ndoe to query
|
||||
|
Reference in New Issue
Block a user