Merge branch 'develop' of ssh://gitorious.psi.ch/sinqdev/sics into develop
Conflicts: fourmess.c
This commit is contained in:
+46
-46
@@ -146,7 +146,7 @@ static void SetProp(Hdb * node, Hdb * cNode, char *key, char *value)
|
||||
{
|
||||
Hdb *propNode;
|
||||
char *val;
|
||||
|
||||
|
||||
val = GetPropAndNode(node, cNode, key, &propNode);
|
||||
if (value == NULL) {
|
||||
if (val != NULL) {
|
||||
@@ -176,7 +176,7 @@ int SctCommand(SConnection * con, SicsInterp * sics, void *object,
|
||||
Hdb *cNode = NULL;
|
||||
hdbValue v;
|
||||
SctController *controller;
|
||||
|
||||
|
||||
assert(sct == object);
|
||||
if (sct->nodes != NULL) {
|
||||
node = sct->nodes->node;
|
||||
@@ -187,7 +187,7 @@ int SctCommand(SConnection * con, SicsInterp * sics, void *object,
|
||||
argv[0]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* get path (pure sct command)
|
||||
*/
|
||||
@@ -339,7 +339,7 @@ int SctCallInContext(SConnection * con, char *script, Hdb * node,
|
||||
char *result = NULL;
|
||||
int iRet = 1;
|
||||
int verbose = controller->verbose;
|
||||
|
||||
|
||||
PushContext(node, controller);
|
||||
if (verbose) {
|
||||
SCPrintf(con, eLog, "%6.3f script: %s", secondsOfMinute(), script);
|
||||
@@ -417,7 +417,7 @@ static char *SctActionHandler(void *actionData, char *lastReply,
|
||||
int ret;
|
||||
char timeKey[50], timeVal[50];
|
||||
int iMacro;
|
||||
|
||||
|
||||
assert(data->name);
|
||||
if (queueData != NULL && queueData->conCtx != NULL) {
|
||||
con = queueData->conCtx;
|
||||
@@ -427,9 +427,9 @@ static char *SctActionHandler(void *actionData, char *lastReply,
|
||||
data->busy = 1;
|
||||
|
||||
/*
|
||||
* Check if this is a followup call.
|
||||
* If this is a followup call, the I/O system will have set the
|
||||
* property result to the data from the device. Read this now and
|
||||
* Check if this is a followup call.
|
||||
* If this is a followup call, the I/O system will have set the
|
||||
* property result to the data from the device. Read this now and
|
||||
* print it if diagnostics is required.
|
||||
*/
|
||||
script = NULL;
|
||||
@@ -451,11 +451,11 @@ static char *SctActionHandler(void *actionData, char *lastReply,
|
||||
}
|
||||
|
||||
/*
|
||||
* Make sure that the state property is set to the name of the property
|
||||
* which holds the name of the script to run at this stage.
|
||||
* When this is a followup, we use the content of the
|
||||
* state field as the property storing the next script to
|
||||
* run. If this is the start of a chain this is set to the
|
||||
* Make sure that the state property is set to the name of the property
|
||||
* which holds the name of the script to run at this stage.
|
||||
* When this is a followup, we use the content of the
|
||||
* state field as the property storing the next script to
|
||||
* run. If this is the start of a chain this is set to the
|
||||
* data->name which is mostly either read or write
|
||||
*/
|
||||
state = GetProp(node, controller->node, "state");
|
||||
@@ -463,16 +463,16 @@ static char *SctActionHandler(void *actionData, char *lastReply,
|
||||
state = data->name;
|
||||
SetProp(node, controller->node, "state", state);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Sometimes one wishes to call multiple scripts in succession
|
||||
* before returning into I/O. Such scripts then do not set the
|
||||
* send property. The loop is taking care of this. Not more
|
||||
* Sometimes one wishes to call multiple scripts in succession
|
||||
* before returning into I/O. Such scripts then do not set the
|
||||
* send property. The loop is taking care of this. Not more
|
||||
* then 10 scripts can be chained in this way.
|
||||
*/
|
||||
for (i = 0; i < 10; i++) {
|
||||
/*
|
||||
* read the script to invoke from the property living
|
||||
* read the script to invoke from the property living
|
||||
* in state
|
||||
*/
|
||||
script = GetProp(node, controller->node, state);
|
||||
@@ -552,8 +552,8 @@ static char *SctActionHandler(void *actionData, char *lastReply,
|
||||
l = blank - origScript;
|
||||
} else {
|
||||
l = strlen(origScript);
|
||||
}
|
||||
snprintf(eprop, sizeof eprop, "error_in_%s", origScript);
|
||||
}
|
||||
snprintf(eprop, sizeof eprop, "error_in_%.*s", (int)l, origScript);
|
||||
emsg = GetHdbProp(node, eprop);
|
||||
cnt = 0;
|
||||
if (emsg != NULL) {
|
||||
@@ -582,12 +582,12 @@ static char *SctActionHandler(void *actionData, char *lastReply,
|
||||
goto finish;
|
||||
}
|
||||
/*
|
||||
* The script executed OK.
|
||||
* The script executed OK.
|
||||
* The next state is the result
|
||||
*/
|
||||
state = result;
|
||||
/*
|
||||
* if the new state is idle, clean everything up
|
||||
* if the new state is idle, clean everything up
|
||||
* and terminate the script chain
|
||||
*/
|
||||
if (strcasecmp(state, "idle") == 0 || strcasecmp(state, "unpoll") == 0) {
|
||||
@@ -595,7 +595,7 @@ static char *SctActionHandler(void *actionData, char *lastReply,
|
||||
SetHdbProperty(node, "requested", NULL);
|
||||
if (!data->answered) {
|
||||
if (queueData->inMacro == 0) {
|
||||
/*
|
||||
/*
|
||||
* send an O.k. if there was no other reply on write's
|
||||
*/
|
||||
iMacro = SCinMacro(con);
|
||||
@@ -629,8 +629,8 @@ static char *SctActionHandler(void *actionData, char *lastReply,
|
||||
free(script);
|
||||
script = NULL;
|
||||
/*
|
||||
* If there is data to send, check it and do so. This also exits the
|
||||
* quick script loop by returning the data to send to Devser.
|
||||
* If there is data to send, check it and do so. This also exits the
|
||||
* quick script loop by returning the data to send to Devser.
|
||||
*/
|
||||
if (sct->sendCalled) {
|
||||
send = GetProp(node, controller->node, "send");
|
||||
@@ -653,8 +653,8 @@ static char *SctActionHandler(void *actionData, char *lastReply,
|
||||
SCPrintf(con, eLogError, "ERROR: too many quick scripts chained");
|
||||
finish:
|
||||
/*
|
||||
* This section is always called when the script chain ends: either due to
|
||||
* error or by successfull termination.
|
||||
* This section is always called when the script chain ends: either due to
|
||||
* error or by successfull termination.
|
||||
*/
|
||||
if (strcmp(data->name, "write") == 0) {
|
||||
if (GetHdbProp(node, "writestatus") != NULL) {
|
||||
@@ -712,7 +712,7 @@ static void SctEndData(void *d)
|
||||
{
|
||||
/* no kill, only decrement sync counter */
|
||||
SctData *data = d;
|
||||
|
||||
|
||||
if (data->syncid > 0) {
|
||||
SyncedDecr(data->syncid);
|
||||
data->syncid = SYNCED_NO_ID;
|
||||
@@ -720,7 +720,7 @@ static void SctEndData(void *d)
|
||||
}
|
||||
|
||||
/*
|
||||
* This is the callback for all nodes participating in the
|
||||
* This is the callback for all nodes participating in the
|
||||
* scriptcontext system
|
||||
*/
|
||||
static hdbCallbackReturn SctMainCallback(Hdb * node, void *userData,
|
||||
@@ -767,7 +767,7 @@ static hdbCallbackReturn SctMainCallback(Hdb * node, void *userData,
|
||||
con = mm->callData;
|
||||
geterror = GetHdbProp(node, "geterror");
|
||||
if (geterror != NULL) {
|
||||
snprintf(error,255,"ERROR: %s", geterror);
|
||||
snprintf(error,255,"ERROR: %s", geterror);
|
||||
SCWrite(con, error, eError);
|
||||
if (mm->v->dataType == HIPTEXT) {
|
||||
if (mm->v->v.text != NULL) {
|
||||
@@ -783,9 +783,9 @@ static hdbCallbackReturn SctMainCallback(Hdb * node, void *userData,
|
||||
return hdbContinue;
|
||||
}
|
||||
/*
|
||||
* This is the callback registered for nodes which
|
||||
* This is the callback registered for nodes which
|
||||
* are written too.
|
||||
*/
|
||||
*/
|
||||
static hdbCallbackReturn SctActionCallback(Hdb * node, void *userData,
|
||||
hdbMessage * msg)
|
||||
{
|
||||
@@ -805,7 +805,7 @@ static hdbCallbackReturn SctActionCallback(Hdb * node, void *userData,
|
||||
char path[MAX_HDB_PATH];
|
||||
char *sicsCommand;
|
||||
int iMacro;
|
||||
|
||||
|
||||
pm = GetKillPtrMessage(msg);
|
||||
if (pm != NULL) {
|
||||
if (data->controller == pm->pPtr) {
|
||||
@@ -859,7 +859,7 @@ static hdbCallbackReturn SctActionCallback(Hdb * node, void *userData,
|
||||
prio = WritePRIO;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* check for duplicate sets on a node.
|
||||
*/
|
||||
if (data->conCtx != NULL) {
|
||||
@@ -871,7 +871,7 @@ static hdbCallbackReturn SctActionCallback(Hdb * node, void *userData,
|
||||
GetCharArray(text));
|
||||
}
|
||||
/*
|
||||
* the node has already been queued for execution. But as we never
|
||||
* the node has already been queued for execution. But as we never
|
||||
* know if the script chain is already running, the only clean
|
||||
* solution is to requeue the node.
|
||||
*/
|
||||
@@ -958,7 +958,7 @@ static void SctKillData(void *d)
|
||||
SyncedDecr(data->syncid);
|
||||
data->syncid = SYNCED_NO_ID;
|
||||
}
|
||||
|
||||
|
||||
if (data->name) {
|
||||
free(data->name);
|
||||
data->name = NULL;
|
||||
@@ -1198,7 +1198,7 @@ void SctQueueNode(SctController * controller, Hdb * node,
|
||||
data->name = strdup(action);
|
||||
data->conCtx = NULL;
|
||||
data->answered = 1;
|
||||
|
||||
|
||||
data->syncid = SyncedIncr(0);
|
||||
data->busy = 1;
|
||||
if (DevQueue(data->controller->devser, data, prio,
|
||||
@@ -1258,7 +1258,7 @@ static void SctKillUpdatescript(void *d)
|
||||
}
|
||||
|
||||
/*
|
||||
* This is the callback for update scripts
|
||||
* This is the callback for update scripts
|
||||
*/
|
||||
static hdbCallbackReturn SctUpdatescriptCallback(Hdb * node,
|
||||
void *userData,
|
||||
@@ -1274,7 +1274,7 @@ static hdbCallbackReturn SctUpdatescriptCallback(Hdb * node,
|
||||
char path[MAX_HDB_PATH];
|
||||
pDynString text;
|
||||
char *arg;
|
||||
|
||||
|
||||
pm = GetKillPtrMessage(msg);
|
||||
if (pm != NULL) {
|
||||
if (us->controller == pm->pPtr) {
|
||||
@@ -1304,7 +1304,7 @@ static hdbCallbackReturn SctUpdatescriptCallback(Hdb * node,
|
||||
|
||||
script = GetProp(node, us->controller->node, us->name);
|
||||
if (script == NULL) script = us->name;
|
||||
|
||||
|
||||
text = formatValue(*(mm->v), node);
|
||||
arg = GetCharArray(text);
|
||||
arg = Arg2Tcl(1, &arg, NULL, 0);
|
||||
@@ -1536,7 +1536,7 @@ static int SctTransactCmd(pSICSOBJ ccmd, SConnection * con,
|
||||
st->controller = c;
|
||||
st->sent = 0;
|
||||
st->reply = NULL;
|
||||
|
||||
|
||||
DevQueue(c->devser, st, WritePRIO,
|
||||
TransactionHandler, SctTransactMatch, NULL, SctTransactInfo);
|
||||
while (st->sent != 2) {
|
||||
@@ -1616,7 +1616,7 @@ static int SctProcessCmd(pSICSOBJ ccmd, SConnection * con,
|
||||
data->conCtx = SCCopyConnection(con);
|
||||
data->busy = 1;
|
||||
data->inMacro = SCinMacro(con);
|
||||
|
||||
|
||||
startTime = time(NULL);
|
||||
DevQueue(c->devser, data, WritePRIO,
|
||||
SctWriteHandler, SctTransactMatch, NULL, SctDataInfo);
|
||||
@@ -1728,7 +1728,7 @@ static int SctTimeout(pSICSOBJ ccmd, SConnection * con,
|
||||
SctController *c;
|
||||
char *result;
|
||||
hdbValue *v = &cmdNode->child->value;
|
||||
|
||||
|
||||
c = (SctController *) ccmd->pPrivate;
|
||||
v->v.doubleValue = DevGetSetTimeout(c->devser, v->v.doubleValue, nPar);
|
||||
SCPrintf(con, eValue, "%.6g", v->v.doubleValue);
|
||||
@@ -1742,7 +1742,7 @@ static int SctReconnectInterval(pSICSOBJ ccmd, SConnection * con,
|
||||
char *result;
|
||||
hdbValue *v = &cmdNode->child->value;
|
||||
int interval;
|
||||
|
||||
|
||||
c = (SctController *) ccmd->pPrivate;
|
||||
if (nPar == 0) {
|
||||
interval = -1; /* read only */
|
||||
@@ -1906,11 +1906,11 @@ static int SctMakeController(SConnection * con, SicsInterp * sics,
|
||||
controller->devser = DevMake(con, argc - 2, argv + 2);
|
||||
if (!controller->devser)
|
||||
return 0;
|
||||
|
||||
|
||||
|
||||
SetHdbProperty(controller->node, "controllerName", objName);
|
||||
SetHdbProperty(controller->node, "sicsdev", objName);
|
||||
|
||||
|
||||
AddCommand(pServ->pSics, objName, InterInvokeSICSOBJ, KillSICSOBJ, ccmd);
|
||||
RegisterSICSOBJKillCmd(ccmd, objName);
|
||||
SetDescriptorKey(ccmd->pDes, "creationCommand", "0");
|
||||
|
||||
Reference in New Issue
Block a user