From cacc490e596a483822c3544b1d29e439bdeb9dbb Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Fri, 30 Nov 2012 09:24:22 +1100 Subject: [PATCH] work in progress --- sicslist.c | 47 +++++++++++++++++++++++++++++++++++++---------- simdriv.c | 7 +++++++ 2 files changed, 44 insertions(+), 10 deletions(-) diff --git a/sicslist.c b/sicslist.c index 9da82d6a..dbc4415a 100644 --- a/sicslist.c +++ b/sicslist.c @@ -25,9 +25,9 @@ static void listAllObjects(SConnection * pCon, SicsInterp * pSics) while (pCom != NULL) { Tcl_DStringAppend(&lst, pCom->pName, -1); pCom = pCom->pNext; - Tcl_DStringAppend(&lst, ",", -1); + Tcl_DStringAppend(&lst, " ", -1); //ffr "," -> " " } - Tcl_DStringAppend(&lst, "ENDLIST", -1); + Tcl_DStringAppend(&lst, " ", -1); SCWrite(pCon, Tcl_DStringValue(&lst), eValue); Tcl_DStringFree(&lst); } @@ -79,7 +79,7 @@ static void listAllObjectData(SConnection * pCon, char *name, pDummy data) prop = prop->pNext; } } - Tcl_DStringAppend(&lst, "ENDLIST", -1); + Tcl_DStringAppend(&lst, " ", -1); SCWrite(pCon, Tcl_DStringValue(&lst), eValue); Tcl_DStringFree(&lst); } @@ -169,6 +169,18 @@ static int printObjectData(SConnection * pCon, pDummy obj, char *key) } } +static int existsObjectData(SConnection * pCon, pDummy obj, char *key) +{ + char *ptr = NULL; + ptr = IFindOption(obj->pDescriptor->pKeys, key); + if (ptr != NULL) + SCPrintf(pCon, eValue, "%s", "true"); + else + SCPrintf(pCon, eValue, "%s", "false"); + + return 1; +} + /*----------------------------------------------------------------- * this function implements a set on top of a list. This means that * the list is first searched for the occurence of name. name is only @@ -203,7 +215,7 @@ static void listToString(int list, Tcl_DString * txt) pPtr = (char *) LLDnodePtr(list); if (pPtr != NULL) { Tcl_DStringAppend(txt, pPtr, -1); - Tcl_DStringAppend(txt, ",", -1); + Tcl_DStringAppend(txt, " ", -1); //ffr "," -> " " } status = LLDnodePtr2Next(list); } @@ -234,7 +246,7 @@ static void printKeyTypes(SicsInterp * pSics, SConnection * pCon, } pCom = pCom->pNext; } - LLDstringAppend(list, "ENDLIST"); + LLDstringAppend(list, " "); listToString(list, &result); SCWrite(pCon, Tcl_DStringValue(&result), eValue); @@ -271,11 +283,11 @@ static void printObjectsMatchingKeyVal(SicsInterp * pSics, } if (status == 1) { Tcl_DStringAppend(&result, pCom->pName, -1); - Tcl_DStringAppend(&result, ",", -1); + Tcl_DStringAppend(&result, " ", -1); //ffr "," -> " " } pCom = pCom->pNext; } - Tcl_DStringAppend(&result, "ENDLIST", -1); + Tcl_DStringAppend(&result, " ", -1); SCWrite(pCon, Tcl_DStringValue(&result), eValue); Tcl_DStringFree(&result); } @@ -395,7 +407,7 @@ static int printServer(SConnection * pCon) Tcl_DStringAppend(&txt, buffer, -1); current = current->pNext; } - Tcl_DStringAppend(&txt, "ENDLIST", -1); + Tcl_DStringAppend(&txt, " ", -1); SCWrite(pCon, Tcl_DStringValue(&txt), eValue); Tcl_DStringFree(&txt); return 1; @@ -465,11 +477,11 @@ static void printMatch(SConnection * pCon, SicsInterp * pSics, char *mask) while (current != NULL) { if (!match(mask, current->pName)) { Tcl_DStringAppend(&txt, current->pName, -1); - Tcl_DStringAppend(&txt, ",", -1); + Tcl_DStringAppend(&txt, " ", -1); //ffr "," -> " " } current = current->pNext; } - Tcl_DStringAppend(&txt, "ENDLIST", -1); + Tcl_DStringAppend(&txt, " ", -1); SCWrite(pCon, Tcl_DStringValue(&txt), eValue); Tcl_DStringFree(&txt); } @@ -518,6 +530,21 @@ int SicsList(SConnection * pCon, SicsInterp * pSics, void *pData, } } + if (strcmp(argv[1], "exists") == 0) { + if (argc < 4) { + SCWrite(pCon, "ERROR: not enough arguments", eError); + return 0; + } else { + pCom = FindCommand(pSics, argv[2]); + if (pCom == NULL) { + SCWrite(pCon, "ERROR: Object doesn't exist", eError); + return 0; + } else + return existsObjectData(pCon, (pDummy) pCom->pData, argv[3]); + } + } + + /* * object properties */ diff --git a/simdriv.c b/simdriv.c index a32e72c1..0f123a6a 100644 --- a/simdriv.c +++ b/simdriv.c @@ -244,6 +244,12 @@ static int SimSetPar(void *self, SConnection * pCon, char *name, return 0; } +static int SimGetTextPar(void *pData, char *name, char *textPar) +{ + snprintf(textPar, 8, "unknown"); + return 1; +} + /*---------------------------------------------------------------------------*/ void KillSIM(void *pData) { @@ -336,6 +342,7 @@ MotorDriver *CreateSIM(SConnection * pCon, int argc, char *argv[]) pDriv->fSpeed = .01; pDriv->iTime = 0; pDriv->KillPrivate = KillSIM; + pDriv->GetDriverTextPar = SimGetTextPar; /* check for optional speed paramter */ pCurrent = pCurrent->pNext;