- 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);
|
return MakeHipadabaCallback(SICSCheckPermissionCallback, testPriv,free);
|
||||||
}
|
}
|
||||||
/*-------------------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------------------*/
|
||||||
static hdbCallbackReturn SICSSetUpdateCallback(pHdb node, void *userData,
|
static char *removeSetUpdateID = "removeSetUpdate";
|
||||||
pHdbMessage message){
|
|
||||||
pHdbDataMessage mm = NULL;
|
|
||||||
|
|
||||||
mm = GetHdbSetMessage(message);
|
void RemoveSetUpdateCallback(pHdb node) {
|
||||||
if(mm == NULL){
|
hdbPtrMessage m;
|
||||||
return hdbContinue;
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
status = UpdateHipadabaPar(node,*(mm->v),mm->callData);
|
||||||
|
if (status) {
|
||||||
|
SCSendOK(mm->callData);
|
||||||
}
|
}
|
||||||
UpdateHipadabaPar(node,*(mm->v),mm->callData);
|
|
||||||
return hdbContinue;
|
return hdbContinue;
|
||||||
}
|
}
|
||||||
/*-------------------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------------------*/
|
||||||
@ -249,7 +271,7 @@ static hdbCallbackReturn SICSFuncCallback(pHdb node, void *userData,
|
|||||||
nPar++;
|
nPar++;
|
||||||
current = current->next;
|
current = current->next;
|
||||||
}
|
}
|
||||||
func = (SICSOBJFunc)node->value.v.obj;
|
func = (SICSOBJFunc)node->value.v.func;
|
||||||
if(func != NULL){
|
if(func != NULL){
|
||||||
status = func((pSICSOBJ)userData,(SConnection *)mm->callData,
|
status = func((pSICSOBJ)userData,(SConnection *)mm->callData,
|
||||||
node, par,nPar);
|
node, par,nPar);
|
||||||
@ -996,12 +1018,6 @@ pHdb MakeSICSHdbPar(char *name, int priv, hdbValue v){
|
|||||||
|
|
||||||
return result;
|
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 MakeSICSHdbDriv(char *name, int priv, void *sicsObject, int dataType){
|
||||||
pHdb result = NULL;
|
pHdb result = NULL;
|
||||||
@ -1120,14 +1136,8 @@ pHdb MakeSICSScriptPar(char *name, char *setScript, char *readScript,
|
|||||||
SetHdbProperty(result,"sicscommand",setScript);
|
SetHdbProperty(result,"sicscommand",setScript);
|
||||||
return result;
|
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){
|
static void removeNodeFromUpdateList(pHdb node){
|
||||||
pHdb current = NULL;
|
pHdb current = NULL;
|
||||||
int status;
|
int status;
|
||||||
char *objName = NULL;
|
char *objName = NULL;
|
||||||
@ -1393,7 +1403,7 @@ static int RemoveParNodeCallback(char *name, pDummy object, void *internalID) {
|
|||||||
m.type = killPtr;
|
m.type = killPtr;
|
||||||
m.pPtr = internalID;
|
m.pPtr = internalID;
|
||||||
if (object->pDescriptor->parNode) {
|
if (object->pDescriptor->parNode) {
|
||||||
InvokeCallbackChain(object->pDescriptor->parNode,(pHdbMessage)&m);
|
RecurseCallbackChains(object->pDescriptor->parNode,(pHdbMessage)&m);
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -1403,12 +1413,11 @@ void RemoveSICSInternalCallback(void *internalID) {
|
|||||||
|
|
||||||
m.type = killPtr;
|
m.type = killPtr;
|
||||||
m.pPtr = internalID;
|
m.pPtr = internalID;
|
||||||
InvokeCallbackChain(GetHipadabaRoot(),(pHdbMessage)&m);
|
RecurseCallbackChains(GetHipadabaRoot(),(pHdbMessage)&m);
|
||||||
ForEachCommand(RemoveParNodeCallback, internalID);
|
ForEachCommand(RemoveParNodeCallback, internalID);
|
||||||
}
|
}
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
int SICSHdbGetPar(void *obj, SConnection *pCon,
|
int SICSHdbGetPar(void *obj, SConnection *pCon, char *path, hdbValue *v){
|
||||||
char *path, int dataType, void *data, int length){
|
|
||||||
pHdb par = NULL;
|
pHdb par = NULL;
|
||||||
int status;
|
int status;
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
@ -1432,16 +1441,14 @@ int SICSHdbGetPar(void *obj, SConnection *pCon,
|
|||||||
return SICSNOPAR;
|
return SICSNOPAR;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = GetHdbPar(par,dataType,data,length,pCon);
|
status = GetHipadabaPar(par,v,pCon);
|
||||||
if(status < 0){
|
if(status < 0){
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
int SICSHdbUpdatePar(void *obj, SConnection *pCon,
|
int SICSHdbUpdatePar(void *obj, SConnection *pCon, char *path, hdbValue v){
|
||||||
char *path, int dataType,void *data, int dataLength ){
|
|
||||||
hdbValue v;
|
|
||||||
pHdb par = NULL;
|
pHdb par = NULL;
|
||||||
int status;
|
int status;
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
@ -1465,16 +1472,14 @@ int SICSHdbUpdatePar(void *obj, SConnection *pCon,
|
|||||||
return SICSNOPAR;
|
return SICSNOPAR;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = UpdateHdbPar(par,dataType,data,dataLength,pCon);
|
status = UpdateHipadabaPar(par,v,pCon);
|
||||||
if(status < 0){
|
if(status < 0){
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
int SICSHdbSetPar(void *obj, SConnection *pCon,
|
int SICSHdbSetPar(void *obj, SConnection *pCon, char *path, hdbValue v){
|
||||||
char *path, int dataType,void *data, int dataLength ){
|
|
||||||
hdbValue v;
|
|
||||||
pHdb par = NULL;
|
pHdb par = NULL;
|
||||||
int status;
|
int status;
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
@ -1498,8 +1503,8 @@ int SICSHdbSetPar(void *obj, SConnection *pCon,
|
|||||||
return SICSNOPAR;
|
return SICSNOPAR;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = SetHdbPar(par,dataType,data,dataLength,pCon);
|
status = SetHipadabaPar(par,v,pCon);
|
||||||
if(status < 0){
|
if(status <= 0){
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
@ -1586,7 +1591,7 @@ int ProcessSICSHdbPar(pHdb root, SConnection *pCon,
|
|||||||
status = SetHipadabaPar(parNode,input,pCon);
|
status = SetHipadabaPar(parNode,input,pCon);
|
||||||
ReleaseHdbValue(&input);
|
ReleaseHdbValue(&input);
|
||||||
if(status == 1){
|
if(status == 1){
|
||||||
SCSendOK(pCon);
|
/* SCSendOK(pCon); do not send OK. this has to be done by the callback */
|
||||||
SCparChange(pCon);
|
SCparChange(pCon);
|
||||||
}
|
}
|
||||||
return status;
|
return status;
|
||||||
@ -1861,12 +1866,6 @@ int readHdbValue(hdbValue *v, char *data, char *error, int errlen){
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case HIPOBJ:
|
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;
|
break;
|
||||||
case HIPFUNC:
|
case HIPFUNC:
|
||||||
break;
|
break;
|
||||||
@ -2116,7 +2115,8 @@ static int SetHdbNode(SConnection *pCon, SicsInterp *pSics, void *pData,
|
|||||||
SCWrite(pCon,"ERROR: out of memory reading parameter",eError);
|
SCWrite(pCon,"ERROR: out of memory reading parameter",eError);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
for(i = 2; i < argc; i++){
|
DynStringConcat(parData, argv[2]);
|
||||||
|
for(i = 3; i < argc; i++){
|
||||||
DynStringConcat(parData," ");
|
DynStringConcat(parData," ");
|
||||||
DynStringConcat(parData, argv[i]);
|
DynStringConcat(parData, argv[i]);
|
||||||
}
|
}
|
||||||
@ -2130,7 +2130,7 @@ static int SetHdbNode(SConnection *pCon, SicsInterp *pSics, void *pData,
|
|||||||
status = SetHipadabaPar(targetNode,newValue,pCon);
|
status = SetHipadabaPar(targetNode,newValue,pCon);
|
||||||
ReleaseHdbValue(&newValue);
|
ReleaseHdbValue(&newValue);
|
||||||
if(status == 1){
|
if(status == 1){
|
||||||
SCSendOK(pCon);
|
/* SCSendOK(pCon); sending ok has to be done by the callback. */
|
||||||
}
|
}
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
@ -2646,7 +2646,7 @@ static int RemoveHdbCallback(SConnection *pCon, SicsInterp *pSics, void *pData,
|
|||||||
id = atoi(argv[1]);
|
id = atoi(argv[1]);
|
||||||
m.type = killID;
|
m.type = killID;
|
||||||
m.ID = id;
|
m.ID = id;
|
||||||
InvokeCallbackChain(root,(pHdbMessage)&m);
|
RecurseCallbackChains(root,(pHdbMessage)&m);
|
||||||
SCSendOK(pCon);
|
SCSendOK(pCon);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -2940,7 +2940,7 @@ static int SetSICSHdbProperty(SConnection *pCon, SicsInterp *pSics, void *pData,
|
|||||||
SCWrite(pCon,"ERROR: node not found",eError);
|
SCWrite(pCon,"ERROR: node not found",eError);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
Arg2Text(argc-3, &argv[3], buffer,512);
|
Arg2Tcl(argc-3, &argv[3], buffer,512);
|
||||||
SetHdbProperty(targetNode,argv[2], buffer);
|
SetHdbProperty(targetNode,argv[2], buffer);
|
||||||
SCSendOK(pCon);
|
SCSendOK(pCon);
|
||||||
return 1;
|
return 1;
|
||||||
@ -3116,7 +3116,7 @@ int InstallSICSHipadaba(SConnection *pCon, SicsInterp *pSics, void *pData,
|
|||||||
AddCommand(pSics,"hcommand",SicsCommandNode, NULL, NULL);
|
AddCommand(pSics,"hcommand",SicsCommandNode, NULL, NULL);
|
||||||
AddCommand(pSics,"hsetprop",SetSICSHdbProperty, NULL, NULL);
|
AddCommand(pSics,"hsetprop",SetSICSHdbProperty, NULL, NULL);
|
||||||
AddCommand(pSics,"hgetprop",GetSICSHdbProperty, 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,"hmatchprop",MatchHdbProperty, NULL, NULL);
|
||||||
AddCommand(pSics,"hlistprop",ListSICSHdbProperty, NULL, NULL);
|
AddCommand(pSics,"hlistprop",ListSICSHdbProperty, NULL, NULL);
|
||||||
|
|
||||||
|
@ -54,11 +54,17 @@ pHdbCallback MakeReadOnlyCallback();
|
|||||||
pHdbCallback MakeCheckPermissionCallback(int priv);
|
pHdbCallback MakeCheckPermissionCallback(int priv);
|
||||||
/**
|
/**
|
||||||
* make a callback which directly updates a
|
* 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
|
* @return a suitably initialized callback structure setting
|
||||||
* program parameters
|
* program parameters
|
||||||
*/
|
*/
|
||||||
pHdbCallback MakeSetUpdateCallback();
|
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.
|
* make a callback which starts a parameter driving.
|
||||||
* @param sicsObject The SICS object to drive.
|
* @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.
|
* @return A new suitably configured Hdb parameter or NULL when out of memory.
|
||||||
*/
|
*/
|
||||||
pHdb MakeSICSHdbPar(char *name, int priv, hdbValue v);
|
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,
|
* make a SICS hdb drivable parameter. Setting it will start the motor,
|
||||||
* virtual motor or environment parameter. This will call StartDevice
|
* 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.
|
* @return A new suitably configured Hdb parameter or NULL when out of memory.
|
||||||
*/
|
*/
|
||||||
pHdb MakeSICSScriptPar(char *name, char *setScript, char *readScript, hdbValue v);
|
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
|
* 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 obj The object for which to get a parameter.
|
||||||
* @param pCon The optional connection object to use for reporting errors.
|
* @param pCon The optional connection object to use for reporting errors.
|
||||||
* @param path The path to the parameter.
|
* @param path The path to the parameter.
|
||||||
* @param dataType The datatype for the parameter.
|
* @param v the value
|
||||||
* @param data Target pointer to which to copy data too.
|
|
||||||
* @param length The length of data
|
|
||||||
* @return 1 on success, a negative error code else.
|
* @return 1 on success, a negative error code else.
|
||||||
*/
|
*/
|
||||||
int SICSHdbGetPar(void *obj, SConnection *pCon,
|
int SICSHdbGetPar(void *obj, SConnection *pCon, char *path, hdbValue *v);
|
||||||
char *path, int dataType, void *data, int length);
|
|
||||||
/**
|
/**
|
||||||
* SICSHdbUpdatePar updates the value of a parameter.
|
* SICSHdbUpdatePar updates the value of a parameter.
|
||||||
* @param obj The object for which to get a parameter.
|
* @param obj The object for which to get a parameter.
|
||||||
* @param pCon The optional connection object to use for reporting errors.
|
* @param pCon The optional connection object to use for reporting errors.
|
||||||
* @param path The path to the parameter.
|
* @param path The path to the parameter.
|
||||||
* @param dataType The datatype for the parameter.
|
* @param v the value
|
||||||
* @param data Pointer from which to copy data.
|
|
||||||
* @param length The length of data
|
|
||||||
* @return 1 on success, a negative error code else.
|
* @return 1 on success, a negative error code else.
|
||||||
*/
|
*/
|
||||||
int SICSHdbUpdatePar(void *obj, SConnection *pCon,
|
int SICSHdbUpdatePar(void *obj, SConnection *pCon, char *path, hdbValue v);
|
||||||
char *path, int dataType, void *data, int length);
|
|
||||||
/**
|
/**
|
||||||
* SICSHdbSetPar sets the value of a parameter.
|
* SICSHdbSetPar sets the value of a parameter.
|
||||||
* @param obj The object for which to get a parameter.
|
* @param obj The object for which to get a parameter.
|
||||||
* @param pCon The optional connection object to use for reporting errors.
|
* @param pCon The optional connection object to use for reporting errors.
|
||||||
* @param path The path to the parameter.
|
* @param path The path to the parameter.
|
||||||
* @param dataType The datatype for the parameter.
|
* @param v the value
|
||||||
* @param data Pointer from which to copy data.
|
* @return positive on success, a negative error code else.
|
||||||
* @param length The length of data
|
|
||||||
* @return 1 on success, a negative error code else.
|
|
||||||
*/
|
*/
|
||||||
int SICSHdbSetPar(void *obj, SConnection *pCon,
|
int SICSHdbSetPar(void *obj, SConnection *pCon, char *path, hdbValue v);
|
||||||
char *path, int dataType, void *data, int length);
|
|
||||||
/**
|
/**
|
||||||
* query function if a parameter is read only.
|
* query function if a parameter is read only.
|
||||||
* @param node The ndoe to query
|
* @param node The ndoe to query
|
||||||
|
Reference in New Issue
Block a user