Add motor runtime to motor stopped log message

This commit is contained in:
Douglas Clowes
2013-02-15 09:49:39 +11:00
parent 48bb76ac58
commit ba128520da

View File

@@ -40,6 +40,8 @@
#define DECADIC_CREEP (10)
#define SPEED_ON_MOVE 1
extern double DoubleTime(void);
/** \brief Used to ensure that the getDMCSetting function is called
* with valid values.
* \see getDMCSetting
@@ -181,7 +183,8 @@ struct __MoDriv {
double lastPosition; /**< Position at last position check */
int lastSteps;
int lastCounts;
double origPosition; /**< Position at last position check */
double origPosition; /**< Position at motor start */
double origTime; /**< Time at motor start */
int origSteps;
int origCounts;
double minRatio;
@@ -2234,6 +2237,7 @@ static void DMCState_MotorOn(pDMC2280Driv self, pEvtEvent event) {
cmdPosition(self, absolute);
self->subState = 2;
/* save pre-motion values for logging */
self->origTime = DoubleTime();
self->origPosition = self->currPosition;
self->origCounts = self->currCounts;
self->origSteps = self->currSteps;
@@ -2551,17 +2555,19 @@ static void DMCState_Moving(pDMC2280Driv self, pEvtEvent event) {
double units = self->currPosition - self->origPosition;
long int steps = self->currSteps - self->origSteps;
long int counts = self->currCounts - self->origCounts;
double time = DoubleTime() - self->origTime;
char line[CMDLEN];
snprintf(line, CMDLEN, "Motor=%s stopped: units=%.6f,"
" steps=%ld, counts=%ld, stepsPerX=%.6f,"
" minRatio=%.6f, maxRatio=%.6f",
" ratio=(%.6f-%.6f), time=%.3f",
self->name,
units,
steps,
counts,
(double) steps / units,
self->minRatio,
self->maxRatio);
self->maxRatio,
time);
SICSLogWrite(line, eStatus);
}
change_state(self, DMCState_OffTimer);