Add stepCount and moveTime to motor data

This commit is contained in:
Douglas Clowes
2013-07-15 16:45:17 +10:00
parent 627b840c38
commit 2a7d0a0699

View File

@@ -187,6 +187,8 @@ struct __MoDriv {
double origTime; /**< Time at motor start */ double origTime; /**< Time at motor start */
int origSteps; int origSteps;
int origCounts; int origCounts;
double moveStartTime;
double moveStopTime;
double minPosition; /**< min position during move */ double minPosition; /**< min position during move */
double maxPosition; /**< max position during move */ double maxPosition; /**< max position during move */
double minRatio; double minRatio;
@@ -2454,6 +2456,8 @@ static void DMCState_MotorOn(pDMC2280Driv self, pEvtEvent event) {
#endif #endif
self->minPosition = self->currPosition; self->minPosition = self->currPosition;
self->maxPosition = self->currPosition; self->maxPosition = self->currPosition;
self->stepCount = 0;
self->moveStartTime = DoubleTime();
if (self->testing) { if (self->testing) {
self->myNextState = NULL; self->myNextState = NULL;
if (self->backlash_offset != 0) { if (self->backlash_offset != 0) {
@@ -3027,7 +3031,7 @@ static void DMCState_StepMove(pDMC2280Driv self, pEvtEvent event) {
self->maxRatio = 0.0; self->maxRatio = 0.0;
/* begin moving */ /* begin moving */
cmdBegin(self); cmdBegin(self);
self->stepCount = 1; self->stepCount++;
self->subState = 1; self->subState = 1;
return; return;
case eTimerEvent: case eTimerEvent:
@@ -3069,6 +3073,7 @@ static void DMCState_StepMove(pDMC2280Driv self, pEvtEvent event) {
/* /*
* We get here when the motor stops normally * We get here when the motor stops normally
*/ */
self->moveStopTime = DoubleTime();
if (self->doSettle) { if (self->doSettle) {
self->doSettle = false; self->doSettle = false;
DMC_SetTimer(self, self->settle); DMC_SetTimer(self, self->settle);
@@ -3363,6 +3368,7 @@ static void DMCState_Moving(pDMC2280Driv self, pEvtEvent event) {
} }
/* We get here when the motor stops normally /* We get here when the motor stops normally
*/ */
self->moveStopTime = DoubleTime();
if (true /*self->debug*/) { if (true /*self->debug*/) {
double units = self->currPosition - self->origPosition; double units = self->currPosition - self->origPosition;
long int steps = self->currSteps - self->origSteps; long int steps = self->currSteps - self->origSteps;
@@ -5175,6 +5181,22 @@ int DMC2280Action(SConnection *pCon, SicsInterp *pSics, void *pData,
SCWrite(pCon, line, eValue); SCWrite(pCon, line, eValue);
return 1; return 1;
} }
else if(strcasecmp("stepCount", argv[1]) == 0) {
char line[132];
snprintf(line, 132, "%s.stepCount = %d",
self->name,
self->stepCount);
SCWrite(pCon, line, eValue);
return 1;
}
else if(strcasecmp("moveTime", argv[1]) == 0) {
char line[132];
snprintf(line, 132, "%s.moveTime = %.6f",
self->name,
self->moveStopTime - self->moveStartTime);
SCWrite(pCon, line, eValue);
return 1;
}
else if(strcasecmp("testing", argv[1]) == 0) { else if(strcasecmp("testing", argv[1]) == 0) {
if (argc > 2) { if (argc > 2) {
if (strcasecmp("on", argv[2]) == 0) { if (strcasecmp("on", argv[2]) == 0) {