- Implemented tcl: prefix which allows to execute a command in Tcl directly
- Fixed a stack overrun bug in macro.c - Fixed a killing bug in devser.c - Added node writing with offset to nxscript.c - Wrote a simulation driver for second generation HM's - Readded devexec commands to SICS - Readded Hipadaba initialisation to SICS - Fixed a bug in sinqhttprot.c which is triggered when a reconnect happens during a node based download of data. SKIPPED: psi/sinqhttpprot.c
This commit is contained in:
203
sicshipadaba.c
203
sicshipadaba.c
@@ -2255,71 +2255,6 @@ static int MakeHdbNode(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
static int MakeHdbScriptNode(SConnection * pCon, SicsInterp * pSics,
|
||||
void *pData, int argc, char *argv[])
|
||||
{
|
||||
int type = 0, i, length = 0;
|
||||
char *name = NULL;
|
||||
pHdb parent = NULL;
|
||||
pHdb child = NULL;
|
||||
pHdb current = NULL;
|
||||
char *urgv[] = { "5", NULL };
|
||||
char driver[] = { "hdb" };
|
||||
char buffer[512], buffer2[512];
|
||||
|
||||
|
||||
if (!SCMatchRights(pCon, usMugger)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (argc < 5) {
|
||||
SCWrite(pCon, "ERROR: not enough arguments to MakeHdbNode", eError);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* convert datatype
|
||||
*/
|
||||
strtolower(argv[4]);
|
||||
type = convertHdbType(argv[4]);
|
||||
if (type >= 7) {
|
||||
SCWrite(pCon,
|
||||
"ERROR: invalid type requested: none, int, float, text, intar, floatar, intvarar, floatvarar supported",
|
||||
eError);
|
||||
return 0;
|
||||
}
|
||||
if (type > 2) {
|
||||
if (argc < 6) {
|
||||
SCWrite(pCon, "ERROR: array length missing for array data type",
|
||||
eError);
|
||||
return 0;
|
||||
} else {
|
||||
length = atoi(argv[5]);
|
||||
}
|
||||
}
|
||||
|
||||
parent = FindHdbParent(NULL, argv[1], &name, pCon);
|
||||
if (parent == NULL) {
|
||||
return 0; /* error messages written inside FindHdbParent */
|
||||
}
|
||||
child = MakeSICSScriptPar(name, argv[3], argv[2],
|
||||
makeHdbValue(type, length));
|
||||
if (child == NULL) {
|
||||
SCWrite(pCon, "ERROR: out of memory creating node", eError);
|
||||
return 0;
|
||||
}
|
||||
|
||||
AddHipadabaChild(parent, child, pCon);
|
||||
/*
|
||||
* have it polled automatically
|
||||
*/
|
||||
addPollObject(poller, pCon, GetHipadabaPath(child), driver, 1, urgv);
|
||||
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
static int isNodeProtected(pHdb node)
|
||||
{
|
||||
@@ -2970,62 +2905,6 @@ static int RemoveHdbCallback(SConnection * pCon, SicsInterp * pSics,
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int LinkHdbNode(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
int argc, char *argv[])
|
||||
{
|
||||
pHdb node = NULL;
|
||||
char buffer[256];
|
||||
pObjectDescriptor pDes = NULL;
|
||||
|
||||
if (argc < 3) {
|
||||
SCWrite(pCon, "ERROR: need path and object name to link", eError);
|
||||
return 0;
|
||||
}
|
||||
if (!SCMatchRights(pCon, usMugger)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
node = GetHipadabaNode(root, argv[1]);
|
||||
if (node == NULL) {
|
||||
snprintf(buffer, 255, "ERROR: path %s NOT found!", argv[1]);
|
||||
SCWrite(pCon, buffer, eError);
|
||||
return 0;
|
||||
}
|
||||
|
||||
pDes = FindCommandDescriptor(pSics, argv[2]);
|
||||
if (pDes == NULL) {
|
||||
snprintf(buffer, 255, "ERROR: failed to find object %s", argv[2]);
|
||||
SCWrite(pCon, buffer, eError);
|
||||
return 0;
|
||||
}
|
||||
if (pDes->parNode == NULL) {
|
||||
snprintf(buffer, 255,
|
||||
"ERROR: Object %s does not use Hipadaba natively and thus cannot be linked",
|
||||
argv[2]);
|
||||
SCWrite(pCon, buffer, eError);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (pDes->parNode->mama != NULL) {
|
||||
snprintf(buffer, 255,
|
||||
"ERROR: Object %s is already linked somewhere else", argv[2]);
|
||||
SCWrite(pCon, buffer, eError);
|
||||
return 0;
|
||||
}
|
||||
|
||||
AddHipadabaChild(node, pDes->parNode, pCon);
|
||||
|
||||
if (argc > 3) {
|
||||
if (pDes->parNode->name != NULL) {
|
||||
free(pDes->parNode->name);
|
||||
}
|
||||
pDes->parNode->name = strdup(argv[3]);
|
||||
}
|
||||
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
}
|
||||
/*-------------------------------------------------------------------------*/
|
||||
static int isArrayNode(pHdb node)
|
||||
{
|
||||
@@ -3046,7 +2925,8 @@ static int HdbArrayNode(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
{
|
||||
pHdb node = NULL;
|
||||
pObjectDescriptor pDes = NULL;
|
||||
int length, idx;
|
||||
int length, idx, ival, i;
|
||||
double dval;
|
||||
hdbValue v;
|
||||
|
||||
if (argc < 4) {
|
||||
@@ -3057,7 +2937,7 @@ static int HdbArrayNode(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
return 0;
|
||||
}
|
||||
|
||||
node = GetHipadabaNode(root, argv[1]);
|
||||
node = FindHdbNode(NULL, argv[1], pCon);
|
||||
if (node == NULL) {
|
||||
SCPrintf(pCon, eError, "ERROR: path %s NOT found!", argv[1]);
|
||||
return 0;
|
||||
@@ -3076,6 +2956,30 @@ static int HdbArrayNode(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(strcmp(argv[2], "init") == 0){
|
||||
v = makeHdbValue(node->value.dataType, length);
|
||||
switch(node->value.dataType){
|
||||
case HIPINTAR:
|
||||
case HIPINTVARAR:
|
||||
ival = atoi(argv[3]);
|
||||
for(i = 0; i < v.arrayLength; i++){
|
||||
v.v.intArray[i] = ival;
|
||||
}
|
||||
break;
|
||||
case HIPFLOATAR:
|
||||
case HIPFLOATVARAR:
|
||||
dval = atof(argv[3]);
|
||||
for(i = 0; i < v.arrayLength; i++){
|
||||
v.v.intArray[i] = dval;
|
||||
}
|
||||
break;
|
||||
}
|
||||
UpdateHipadabaPar(node, v, pCon);
|
||||
ReleaseHdbValue(&v);
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
}
|
||||
|
||||
idx = atoi(argv[2]);
|
||||
if(idx < 0 || idx >= node->value.arrayLength ){
|
||||
SCPrintf(pCon,eError,"ERROR: %d is out of range 0 - %d",
|
||||
@@ -3285,55 +3189,6 @@ static hdbCallbackReturn CommandGetCallback(pHdb node, void *userData,
|
||||
return hdbContinue;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
static int SicsCommandNode(SConnection * pCon, SicsInterp * pSics,
|
||||
void *pData, int argc, char *argv[])
|
||||
{
|
||||
char *name = NULL;
|
||||
pHdbCallback kalle = NULL;
|
||||
pHdb parent = NULL, node = NULL;
|
||||
|
||||
if (argc < 3) {
|
||||
SCWrite(pCon, "ERROR: insufficent number of arguments to hcommand",
|
||||
eError);
|
||||
}
|
||||
if (!SCMatchRights(pCon, usMugger)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
parent = FindHdbParent(NULL, argv[1], &name, pCon);
|
||||
if (parent == NULL) {
|
||||
return 0; /* error message already written */
|
||||
}
|
||||
node = MakeHipadabaNode(name, HIPTEXT, 1);
|
||||
if (node == NULL) {
|
||||
SCWrite(pCon, "ERROR: out of memory in hcommand", eError);
|
||||
return 0;
|
||||
}
|
||||
node->value.v.text = strdup(argv[2]);
|
||||
node->value.arrayLength = strlen(argv[2]);
|
||||
SetHdbProperty(node, "sicscommand", argv[2]);
|
||||
|
||||
kalle = MakeHipadabaCallback(CommandSetCallback, NULL, NULL);
|
||||
if (kalle == NULL) {
|
||||
SCWrite(pCon, "ERROR: out of memory in hcommand", eError);
|
||||
return 0;
|
||||
}
|
||||
AppendHipadabaCallback(node, kalle);
|
||||
|
||||
kalle = MakeHipadabaCallback(CommandGetCallback, NULL, NULL);
|
||||
if (kalle == NULL) {
|
||||
SCWrite(pCon, "ERROR: out of memory in hcommand", eError);
|
||||
return 0;
|
||||
}
|
||||
AppendHipadabaCallback(node, kalle);
|
||||
|
||||
AddHipadabaChild(parent, node, pCon);
|
||||
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*======================= Property Functions ================================*/
|
||||
static int SetSICSHdbProperty(SConnection * pCon, SicsInterp * pSics,
|
||||
void *pData, int argc, char *argv[])
|
||||
@@ -3545,9 +3400,7 @@ int InstallSICSHipadaba(SConnection * pCon, SicsInterp * pSics,
|
||||
{
|
||||
|
||||
root = MakeHipadabaNode("/", HIPNONE, 0);
|
||||
AddCommand(pSics, "hmake", MakeHdbNode, NULL, NULL);
|
||||
AddCommand(pSics, "hfactory", HdbNodeFactory, NULL, NULL);
|
||||
AddCommand(pSics, "hmakescript", MakeHdbScriptNode, NULL, NULL);
|
||||
AddCommand(pSics, "hattach", SICSHdbAdapter, NULL, NULL);
|
||||
AddCommand(pSics, "hsubsamplehm", HdbSubSample, NULL, NULL);
|
||||
AddCommand(pSics, "hdel", DeleteHdbNode, NULL, NULL);
|
||||
@@ -3559,12 +3412,10 @@ int InstallSICSHipadaba(SConnection * pCon, SicsInterp * pSics,
|
||||
AddCommand(pSics, "hlist", ListHdbNode, NULL, NULL);
|
||||
AddCommand(pSics, "hnotify", AutoNotifyHdbNode, NULL, NULL);
|
||||
AddCommand(pSics, "hdelcb", RemoveHdbCallback, NULL, NULL);
|
||||
AddCommand(pSics, "hlink", LinkHdbNode, NULL, NULL);
|
||||
AddCommand(pSics, "hinfo", HdbNodeInfo, NULL, NULL);
|
||||
AddCommand(pSics, "hval", HdbNodeVal, NULL, NULL);
|
||||
AddCommand(pSics, "hchain", ChainHdbNode, NULL, NULL);
|
||||
AddCommand(pSics, "harray", HdbArrayNode, NULL, NULL);
|
||||
AddCommand(pSics, "hcommand", SicsCommandNode, NULL, NULL);
|
||||
AddCommand(pSics, "hsetprop", SetSICSHdbProperty, NULL, NULL);
|
||||
AddCommand(pSics, "hdelprop", DelSICSHdbProperty, NULL, NULL);
|
||||
AddCommand(pSics, "hgetprop", GetSICSHdbProperty, NULL, NULL);
|
||||
|
||||
Reference in New Issue
Block a user