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