- Removed napi from SICS

- Added error fields to hwardware objects: motor, counter, histmem
- Optimised sinqhttpopt
- Added haddcheck which adds checks to hipadaba nodes. The current implementation
  only checks for selctions agaisnt the values property. Expand when more checks are
  required.


SKIPPED:
	psi/polterwrite.c
	psi/sinqhttpopt.c
	psi/tasinit.c
This commit is contained in:
koennecke
2013-08-14 09:50:22 +00:00
parent 255b83665c
commit 5a06bb9b90
35 changed files with 255 additions and 10598 deletions

View File

@@ -19,6 +19,10 @@
* Refactored to new callback system, Markus Zolliker, Mark Koennecke, March 2008
*
* Added start and finished messages to commands. Mark Koennecke, November 2008
*
* Added SicsValueCheckCallback and implemented first version of haddcheck.
* Mark Koennecke, July 2013
*
*/
#include <stdlib.h>
#include <string.h>
@@ -238,6 +242,51 @@ pHdbCallback MakeReadOnlyCallback()
{
return MakeHipadabaCallback(SICSReadOnlyCallback, NULL, NULL);
}
/*------------------------------------------------------------------------------------*/
static hdbCallbackReturn SICSValueCheckCallback(pHdb node, void *userData,
pHdbMessage message)
{
SConnection *pCon = NULL;
pHdbDataMessage mm = NULL;
char values[1024], *pPtr, pToken[80];
int status;
hdbValue v;
mm = GetHdbSetMessage(message);
if (mm == NULL) {
return hdbContinue;
}
pCon = (SConnection *) mm->callData;
v = *(mm->v);
status = GetHdbProperty(node,"values",values,sizeof(values));
if(status != 1 && pCon != NULL){
SCPrintf(pCon,eLogError,"ERROR: configuration error, no values on node %s",
node->name);
return hdbAbort;
}
if(v.dataType != HIPTEXT && pCon != NULL){
SCPrintf(pCon,eLogError,"ERROR: need text data for node %s",
node->name);
return hdbAbort;
}
pPtr = values;
while((pPtr = stptok(pPtr,pToken,sizeof(pToken),",")) != NULL){
if(strcmp(pToken,v.v.text) == 0) {
return hdbContinue;
}
}
if(pCon != NULL){
SCPrintf(pCon,eLogError,"ERROR: %s not allowed as value for %s, allowed are: %s",
v.v.text, node->name, values);
}
return hdbAbort;
}
/*-------------------------------------------------------------------------------------*/
static hdbCallbackReturn SICSDriveCallback(pHdb node, void *userData,
@@ -3767,7 +3816,38 @@ static int MatchHdbProperty(SConnection * pCon, SicsInterp * pSics,
}
return 1;
}
/*---------------------------------------------------------------------------*/
static int AddCheck(SConnection * pCon, SicsInterp * pSics,
void *pData, int argc, char *argv[])
{
pHdb node = NULL;
if(argc < 3) {
SCPrintf(pCon,eLogError, "ERROR: need at least node and key argument for %s",
argv[0]);
return 0;
}
node = FindHdbNode(NULL, argv[1],pCon);
if (node == NULL) {
SCPrintf(pCon,eLogError, "ERROR: node %s to add check to not found", argv[1]);
return 0;
}
strtolower(argv[2]);
if(strcmp(argv[2],"values") == 0) {
PrependHipadabaCallback(node,MakeHipadabaCallback(SICSValueCheckCallback,
NULL,NULL));
SCSendOK(pCon);
return 1;
} else {
SCPrintf(pCon,eLogError,"ERROR: key %s for %s not recognized",
argv[2], argv[0]);
return 0;
}
return 1;
}
/*======================= Factory Functions =================================*/
void killSICSHipadaba()
{
@@ -3810,6 +3890,7 @@ int InstallSICSHipadaba(SConnection * pCon, SicsInterp * pSics,
AddCommand(pSics, "hmatchprop", MatchHdbProperty, NULL, NULL);
AddCommand(pSics, "hlistprop", ListSICSHdbProperty, NULL, NULL);
AddCommand(pSics, "hcallnotify",CallNotify, NULL, NULL);
AddCommand(pSics, "haddcheck",AddCheck, NULL, NULL);
InstallSICSPoll(pCon, pSics, pData, argc, argv);
poller = (pSicsPoll) FindCommandData(pSics, "sicspoll", "SicsPoll");