- Currently disabled attempts at logging commands
- Added a warning for excessive data rates on monitors - Added statistics to devser and thus to scriptcontext - Added byte concatenation to dynstring - Added aborting for reflection generation to fourmess.c - Added data checksum testing to hipadaba, use for update tests - Fixed interrupt discovery in network.c, caused invalid interrupt codes which in turn confused sicscron which had to be fixed too. - Renamed ubcalc into ubcalcint in order to reclaim the ubcalc for Jurg - Added an a3offset to tasub in order to fix what I perceive an IS problem - Added support for the newer version of the Siemens SPS, the S7 - Added a not yet fully working sinqhttpopt driver which talks to http HM without libghttp SKIPPED: psi/delcam.c psi/make_gen psi/psi.c psi/sinq.c psi/sinq.h psi/sinqhttpopt.c psi/slsvme.c psi/spss7.c
This commit is contained in:
103
devser.c
103
devser.c
@ -22,6 +22,18 @@ struct DevSer {
|
||||
DevAction *actions; /* the action queue */
|
||||
DevAction *toKill; /* list of actions to be killed */
|
||||
int steps;
|
||||
double startTime; /* fields for statistics */
|
||||
double comCount;
|
||||
long nComCount;
|
||||
double comMax;
|
||||
long errorCount;
|
||||
int inError;
|
||||
double asconStart;
|
||||
double asconSum;
|
||||
double asconMax;
|
||||
long asconCount;
|
||||
int asconState, asconMaxState;
|
||||
int maxCount;
|
||||
};
|
||||
|
||||
static char *devPrio[NumberOfPRIO] = {
|
||||
@ -133,6 +145,80 @@ static DevAction *DevNextAction(DevSer * devser)
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
static void LogStart(DevSer *self)
|
||||
{
|
||||
if(self->startTime > 0){
|
||||
printf("DEVSER: there is something fucked up in LogStart. Investigate!\n");
|
||||
}
|
||||
self->startTime = DoubleTime();
|
||||
}
|
||||
static void LogResponse(DevSer *self, int error)
|
||||
{
|
||||
double responseTime;
|
||||
|
||||
if(self->startTime < 0){
|
||||
printf("DEVSER: there is something fucked up in LogResponse, Investigate!\n");
|
||||
self->startTime = -1;
|
||||
return;
|
||||
}
|
||||
responseTime = DoubleTime() - self->startTime;
|
||||
self->comCount += responseTime;
|
||||
if(responseTime > self->comMax){
|
||||
self->comMax = responseTime;
|
||||
}
|
||||
self->nComCount++;
|
||||
if(error == 1 && self->inError == 0){
|
||||
self->errorCount++;
|
||||
self->inError = 1;
|
||||
} else if(error == 0){
|
||||
self->inError = 0;
|
||||
}
|
||||
self->startTime = -1;
|
||||
}
|
||||
static void StartAscon(DevSer *self)
|
||||
{
|
||||
self->asconStart = DoubleTime();
|
||||
self->asconState = AsconLastState(self->ascon);
|
||||
}
|
||||
static void AsconLog(DevSer *self)
|
||||
{
|
||||
double used;
|
||||
|
||||
used = DoubleTime() - self->asconStart;
|
||||
self->asconSum += used;
|
||||
self->asconCount++;
|
||||
if(used > self->asconMax){
|
||||
self->asconMax = used;
|
||||
self->asconMaxState = self->asconState;
|
||||
}
|
||||
if(used > self->asconMax/2.){
|
||||
self->maxCount++;
|
||||
}
|
||||
}
|
||||
void DevStatistics(DevSer *devser, double *avg, double *max,
|
||||
long *errCount, int *errState)
|
||||
{
|
||||
if(devser->nComCount > 0){
|
||||
*avg = devser->comCount/devser->nComCount;
|
||||
} else {
|
||||
*avg = 0; /* no data!*/
|
||||
}
|
||||
*max = devser->comMax;
|
||||
*errCount = devser->errorCount;
|
||||
*errState = devser->inError;
|
||||
}
|
||||
void DevAsconStatistics(DevSer *self, double *avg, \
|
||||
double *max, int *maxState, int *longCount)
|
||||
{
|
||||
if(self->asconCount > 0){
|
||||
*avg = self->asconSum/self->asconCount;
|
||||
} else {
|
||||
*avg = .0;
|
||||
}
|
||||
*max = self->asconMax;
|
||||
*maxState = self->asconMaxState;
|
||||
*longCount = self->maxCount;
|
||||
}
|
||||
|
||||
static int DevQueueTask(void *ds)
|
||||
{
|
||||
@ -155,13 +241,26 @@ static int DevQueueTask(void *ds)
|
||||
}
|
||||
|
||||
while (action != NULL) {
|
||||
StartAscon(devser);
|
||||
status = AsconTask(devser->ascon);
|
||||
AsconLog(devser);
|
||||
if (status == AsconFailure) {
|
||||
replyData = AsconGetError(devser->ascon);
|
||||
/**
|
||||
* TODO: this may be a place to record the end time
|
||||
*/
|
||||
if(devser->startTime > 0){
|
||||
LogResponse(devser,1);
|
||||
} else {
|
||||
/* This is a follow up error and should not go into statistics */
|
||||
}
|
||||
} else if (status == AsconReady) {
|
||||
replyData = AsconRead(devser->ascon);
|
||||
if(replyData != NULL){
|
||||
LogResponse(devser,0);
|
||||
}
|
||||
} else {
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
if (devser->steps > 0) { /* debugging mode */
|
||||
devser->steps--;
|
||||
@ -169,6 +268,7 @@ static int DevQueueTask(void *ds)
|
||||
sendData = action->hdl(action->data, replyData, (status == AsconFailure));
|
||||
if (sendData != NULL) {
|
||||
AsconWrite(devser->ascon, sendData, 0);
|
||||
LogStart(devser);
|
||||
return 1;
|
||||
}
|
||||
if (devser->killCurrent) {
|
||||
@ -200,6 +300,7 @@ DevSer *DevMake(SConnection * con, int argc, char *argv[])
|
||||
devser->actions = NULL;
|
||||
devser->toKill = NULL;
|
||||
devser->steps = -1; /* no debugging by default */
|
||||
devser->startTime = -1;
|
||||
TaskRegister(pServ->pTasker, DevQueueTask, NULL, NULL, devser, 0);
|
||||
return devser;
|
||||
}
|
||||
|
Reference in New Issue
Block a user