- ascon.c: bug fix
- binprot.c: enhancements - devser.c, scriptcontext.c: introduced specifiaction of start time in poll
This commit is contained in:
+22
-14
@@ -338,13 +338,16 @@ int SctCallInContext(SConnection * con, char *script, Hdb * node,
|
||||
char *result = NULL;
|
||||
int iRet = 1;
|
||||
int verbose = controller->verbose;
|
||||
char path[MAX_HDB_PATH];
|
||||
|
||||
PushContext(node, controller);
|
||||
if (verbose) {
|
||||
SCPrintf(con, eLog, "%6.3f script: %s", secondsOfMinute(), script);
|
||||
GetHdbPath(node, path, sizeof path);
|
||||
SCPrintf(con, eLog, "%6.3f script: (on %s) %s", secondsOfMinute(), path, script);
|
||||
}
|
||||
if (controller->fd != NULL) {
|
||||
fprintf(controller->fd,"%6.3f script: %s\n", secondsOfMinute(), script);
|
||||
GetHdbPath(node, path, sizeof path);
|
||||
fprintf(controller->fd,"%6.3f script: (on %s) %s\n", secondsOfMinute(), path, script);
|
||||
}
|
||||
|
||||
MacroPush(con);
|
||||
@@ -551,7 +554,7 @@ static char *SctActionHandler(void *actionData, char *lastReply,
|
||||
l = blank - origScript;
|
||||
} else {
|
||||
l = strlen(origScript);
|
||||
}
|
||||
}
|
||||
snprintf(eprop, sizeof eprop, "error_in_%.*s", (int)l, origScript);
|
||||
emsg = GetHdbProp(node, eprop);
|
||||
cnt = 0;
|
||||
@@ -877,12 +880,13 @@ static hdbCallbackReturn SctActionCallback(Hdb * node, void *userData,
|
||||
* solution is to requeue the node.
|
||||
*/
|
||||
SCDeleteConnection(data->conCtx);
|
||||
} else {
|
||||
data->syncid = SyncedIncr(0);
|
||||
}
|
||||
data->conCtx = SCCopyConnection(con);
|
||||
data->answered = 0;
|
||||
data->inMacro = SCinMacro(con);
|
||||
tracePar(node->name,"Queued %s to %s",node->name, GetCharArray(text));
|
||||
data->syncid = SyncedIncr(0);
|
||||
data->busy = 1;
|
||||
DevQueue(data->controller->devser, data, prio,
|
||||
SctWriteHandler, SctMatch, SctEndData, SctDataInfo);
|
||||
@@ -980,7 +984,7 @@ static void SctKillCBData(void *d)
|
||||
}
|
||||
|
||||
int SctAddPollNode(SctController * controller, Hdb * node, double interval,
|
||||
DevPrio prio, char *action)
|
||||
double start, DevPrio prio, char *action)
|
||||
{
|
||||
SctData *data;
|
||||
hdbCallback *cb;
|
||||
@@ -1003,7 +1007,7 @@ int SctAddPollNode(SctController * controller, Hdb * node, double interval,
|
||||
data->name = strdup(action);
|
||||
|
||||
data->syncid = SyncedIncr(0);
|
||||
if (DevSchedule(controller->devser, data, prio, interval,
|
||||
if (DevScheduleS(controller->devser, data, prio, interval, start,
|
||||
SctActionHandler, SctMatch, SctKillData, SctDataInfo)) {
|
||||
return 1;
|
||||
} else {
|
||||
@@ -1016,15 +1020,17 @@ static int SctPollCmd(pSICSOBJ ccmd, SConnection * con,
|
||||
{
|
||||
Hdb *node;
|
||||
SctController *controller;
|
||||
double interval;
|
||||
double interval, start;
|
||||
char *path;
|
||||
DevPrio prio;
|
||||
char *action;
|
||||
char *prioText;
|
||||
|
||||
char *intervalText;
|
||||
int ii;
|
||||
|
||||
if (nPar < 1) {
|
||||
SCPrintf(con, eError,
|
||||
"ERROR: should be: %s poll <node> (<interval> <prio> <action>)",
|
||||
"ERROR: should be: %s poll <node> (<interval> <prio> <action> <start>)",
|
||||
ccmd->objectNode->name);
|
||||
return 0;
|
||||
}
|
||||
@@ -1043,15 +1049,16 @@ static int SctPollCmd(pSICSOBJ ccmd, SConnection * con,
|
||||
return 0;
|
||||
}
|
||||
action = ParText(cmdNode, "action", nPar, "read");
|
||||
start = ParValue(cmdNode, "start", nPar, 0.0);
|
||||
|
||||
if (SctAddPollNode(controller, node, interval, prio, action)) {
|
||||
if (SctAddPollNode(controller, node, interval, start, prio, action)) {
|
||||
SCPrintf(con, eValue,
|
||||
"%s poll registered on %s (%g sec, %s prio)",
|
||||
action, path, interval, prioText);
|
||||
"%s poll registered on %s (%g sec, %s prio, %g start)",
|
||||
action, path, interval, prioText, start);
|
||||
} else {
|
||||
SCPrintf(con, eValue,
|
||||
"%s poll on %s changed to %g sec, %s prio",
|
||||
action, path, interval, prioText);
|
||||
"%s poll on %s changed to %g sec, %s prio, %g start",
|
||||
action, path, interval, prioText, start);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@@ -1922,6 +1929,7 @@ static int SctMakeController(SConnection * con, SicsInterp * sics,
|
||||
AddSICSHdbPar(cmd, "interval", usMugger, MakeHdbFloat(5.0));
|
||||
AddSICSHdbPar(cmd, "prio", usMugger, MakeHdbText("read"));
|
||||
AddSICSHdbPar(cmd, "action", usMugger, MakeHdbText("read"));
|
||||
AddSICSHdbPar(cmd, "start", usMugger, MakeHdbFloat(0.0));
|
||||
|
||||
cmd = AddSICSHdbPar(controller->node,
|
||||
"unpoll", usMugger, MakeSICSFunc(SctUnpollCmd));
|
||||
|
||||
Reference in New Issue
Block a user