- added the possiblity hardwire whether a parameter is saved or not
- return message contains now the called command name (shich might be an alias) instead of the original object name
This commit is contained in:
2
arrobj.c
2
arrobj.c
@ -237,7 +237,7 @@ static void ArrayObjParDef(void *object) {
|
||||
WrtObj(&context, item->name);
|
||||
}
|
||||
}
|
||||
ParName(item->name); ParAccess(usUser);
|
||||
ParName(item->name); ParSave(2); ParAccess(usUser);
|
||||
if (item->unit) {
|
||||
ParTail(item->unit);
|
||||
} else {
|
||||
|
28
pardef.c
28
pardef.c
@ -53,6 +53,7 @@ typedef struct Context {
|
||||
char combiName[80];
|
||||
char *grpFmt;
|
||||
int exact;
|
||||
char *callName; /* the called name of the object (different from obj->name in case of an alias) */
|
||||
} Context;
|
||||
|
||||
static char *loggerDir = NULL;
|
||||
@ -176,6 +177,7 @@ static void ParBegin(void) {
|
||||
}
|
||||
p->next = ctx;
|
||||
ctx = p;
|
||||
ctx->callName = NULL;
|
||||
}
|
||||
/*-------------------------------------------------------------------------*/
|
||||
static void ParEnd(void) {
|
||||
@ -201,6 +203,9 @@ static void ParDo(SConnection *con, ParData *o, ParAct a, char *parName) {
|
||||
ctx->par = NULL;
|
||||
ctx->grpFmt = NULL;
|
||||
ctx->obj = o;
|
||||
if (!ctx->callName) {
|
||||
ctx->callName = o->name;
|
||||
}
|
||||
o->pardef(o);
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
@ -388,6 +393,7 @@ static int ParExecute(SConnection *con, SicsInterp *sics, void *object, int argc
|
||||
char *setArgv[2];
|
||||
|
||||
ParBegin();
|
||||
ctx->callName = argv[0];
|
||||
ParSaveConn(o, con);
|
||||
|
||||
if (argc>1) ctx->thisPar = argv[1];
|
||||
@ -803,7 +809,7 @@ ParOp ParWhat(int numeric) {
|
||||
fprintf(ctx->saveFile, " %s unlog %s\n", ctx->obj->name, ctx->parName);
|
||||
}
|
||||
}
|
||||
if (ctx->par && ctx->par->saveIt) {
|
||||
if (ctx->par && ctx->par->saveIt == 1) {
|
||||
return FMT_OP;
|
||||
}
|
||||
break;
|
||||
@ -834,15 +840,17 @@ void ParOut(char *buf) {
|
||||
assert(ctx->fmt==NULL);
|
||||
switch (ctx->action) {
|
||||
case PAR_LIST:
|
||||
/*
|
||||
if (ctx->par->log) {
|
||||
snprintf(buffer, sizeof buffer, "%s", LoggerName(ctx->par->log));
|
||||
} else {
|
||||
*/
|
||||
if (ctx->parName[0] != '\0') {
|
||||
snprintf(buffer, sizeof buffer, "%s.%s", ctx->obj->name, ctx->parName);
|
||||
snprintf(buffer, sizeof buffer, "%s.%s", ctx->callName, ctx->parName);
|
||||
} else {
|
||||
snprintf(buffer, sizeof buffer, "%s", ctx->obj->name);
|
||||
}
|
||||
snprintf(buffer, sizeof buffer, "%s", ctx->callName);
|
||||
}
|
||||
|
||||
if (ctx->enumList) {
|
||||
i = strtol(buf, &endp, 0);
|
||||
if (endp != buf) {
|
||||
@ -857,7 +865,7 @@ void ParOut(char *buf) {
|
||||
j = i;
|
||||
while (p[i] >= '0' && p[i] <='9') i++;
|
||||
l = strlen(p);
|
||||
ln = strlen(buffer) - strlen(ctx->obj->name);
|
||||
ln = strlen(buffer) - strlen(ctx->callName);
|
||||
if (i != j && (buf[i] == '.' || buf[i] <= ' ')) {
|
||||
l += 16 - i - ln; /* decimal point or end of number at least 16 chars after object name */
|
||||
lp = strlen(p);
|
||||
@ -878,19 +886,21 @@ void ParOut(char *buf) {
|
||||
if (!ctx->par->log) {
|
||||
logged = " (not logged)";
|
||||
}
|
||||
if (ctx->par->saveIt) {
|
||||
if (ctx->par->saveIt == 1) {
|
||||
saved = " (saved)";
|
||||
} else if (ctx->par->saveIt == 2) {
|
||||
saved = " (saved by driver)";
|
||||
}
|
||||
}
|
||||
ParPrintf(NULL, eWarning, "%s %*s%*s%s%s", buffer, l, p, m, ctx->listTail, logged, saved);
|
||||
break;
|
||||
case PAR_SHOW:
|
||||
if (ctx->parName[0]) { p=" "; } else { p=""; }
|
||||
ParPrintf(NULL, eValue, "%s%s%s = %s", ctx->obj->name, p, ctx->parName, buf);
|
||||
ParPrintf(NULL, eValue, "%s%s%s = %s", ctx->callName, p, ctx->parName, buf);
|
||||
break;
|
||||
case PAR_SET:
|
||||
if (ctx->parName[0]) { p=" "; } else { p=""; }
|
||||
ParPrintf(NULL, eValue, "%s%s%s = %s", ctx->obj->name, p, ctx->parName, buf);
|
||||
ParPrintf(NULL, eValue, "%s%s%s = %s", ctx->callName, p, ctx->parName, buf);
|
||||
if (!ctx->obj->logPending) {
|
||||
ctx->obj->logPending = 1;
|
||||
TaskRegister(pServ->pTasker, ParLog, NULL, NULL, ctx->obj, 0); /* schedule ParLog */
|
||||
@ -947,6 +957,8 @@ void ParEnum(char *list[]) {
|
||||
void ParSave(int saveIt) {
|
||||
if (ctx->action == PAR_INIT) {
|
||||
ctx->doit = saveIt;
|
||||
} else if (ctx->action == PAR_SAVE && saveIt == 2 && ctx->par) {
|
||||
ctx->par->saveIt = 2;
|
||||
}
|
||||
}
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
Reference in New Issue
Block a user