From 24ae9139a98511c255f3fea2d0a0db9c384da9cd Mon Sep 17 00:00:00 2001 From: timmmooney Date: Mon, 18 Nov 2013 16:07:32 +0000 Subject: [PATCH] cleanup, no change in function --- .../AerotechSrc/EnsembleTrajectoryScan.st | 56 +++++++------------ 1 file changed, 19 insertions(+), 37 deletions(-) diff --git a/motorApp/AerotechSrc/EnsembleTrajectoryScan.st b/motorApp/AerotechSrc/EnsembleTrajectoryScan.st index 43b03e1c..8897fdad 100644 --- a/motorApp/AerotechSrc/EnsembleTrajectoryScan.st +++ b/motorApp/AerotechSrc/EnsembleTrajectoryScan.st @@ -6,6 +6,10 @@ program EnsembleTrajectoryScan("P=13IDC:,R=traj1,M1=M1,M2=M2,M3=M3,M4=M4,M5=M5,M * iocInit() * ... * seq &EnsembleTrajectoryScan, "P=xxx:,R=traj1:,M1=m1,M2=m2,M3=m3,M4=m4,M5=m5,M6=m6,M7=m7,M8=m8,PORT=none" + * + * NAXES must be less than or equal to the value of MAX_AXES specified in EnsembleTrajectoryScan.h + * NELM must be less than or equal to the value of MAX_ELEMENTS specified below + * NPULSE must be less than or equal to the value of MAX_AXES specified below */ /* This sequencer program works with trajectoryScan.db. It implements @@ -65,7 +69,6 @@ option +r; #define READ_INTERVAL (1/10.) char stringOut[MAX_MESSAGE_STRING]; -char sbuf[MAX_MESSAGE_STRING]; char stringIn[MAX_MESSAGE_STRING]; char stringLast[MAX_MESSAGE_STRING]; char abortCommand[MAX_MESSAGE_STRING]; @@ -130,7 +133,6 @@ double position[MAX_AXES][MAX_ELEMENTS]; double velocity[MAX_AXES][MAX_ELEMENTS]; double motorStart[MAX_AXES]; double motorCurr[MAX_AXES]; -double dbuf[MAX_PULSES]; /* variables for constructing trajectory commands */ int movingMask; @@ -280,10 +282,6 @@ ss EnsembleTrajectoryScan { endPulses = nelements; pvPut(endPulses); } state monitor_inputs - - when(efTestAndClear(motorMDVSMon)) { - /* We don't use this. */ - } state monitor_inputs } /* Build trajectory */ @@ -297,7 +295,6 @@ ss EnsembleTrajectoryScan { epicsSnprintf(buildMessage, MSGSIZE, "Building..."); pvPut(buildMessage); - buildStatus = STATUS_SUCCESS; /* presume we'll be successful */ /* Initialize new trajectory */ /* If time mode is TIME_MODE_TOTAL then construct timeTrajectory and post it */ @@ -314,7 +311,7 @@ ss EnsembleTrajectoryScan { npoints = nelements; - /* calculate time at which motor should reach each trajectory point */ + /* calculate time from beginning of motion at which motor should reach each trajectory point */ realTimeTrajectory[0] = 0.; for (i=1; istatus = writeRead(ssId, pVar, pVar->stringOut, pVar->stringIn); } -#if 0 - /* Get the current motor positions, post them */ - %%getMotorPositions(ssId, pVar, pVar->motorCurrent); - for (j=0; jd = trajEval(ssId, pVar, pVar->motorReadbacks[0], pVar->scopeDataIntervalMS, pVar->nScopeDataPoints, - %% pVar->motorTrajectory[0], pVar->realTimeTrajectory, pVar->npoints, pVar->motorError[0]); + %%pVar->motorTrajectory[0], pVar->realTimeTrajectory, pVar->npoints, pVar->motorError[0]); #endif #if USE_DATAACQ @@ -948,7 +929,7 @@ static double rawToUser(int raw, double off, int dir, double res) { */ int sendReceiveCommand(SS_ID ssId, struct UserVar *pVar, char *cmd, char *callerReply, int checkProgram) { int i, i1, i2, i3, i4, cmdNum; - double d, d1, d2, d3, d4, d5, d6, d7, d8, d9; + double d1, d2, d3; char stringOut[MAX_MESSAGE_STRING], reply[MAX_MESSAGE_STRING]; int status, saveDebug; @@ -1001,6 +982,7 @@ int sendReceiveCommand(SS_ID ssId, struct UserVar *pVar, char *cmd, char *caller saveDebug = pVar->debugLevel; pVar->debugLevel = MAX(0, pVar->debugLevel - 1); + cmdNum = cmdDONE; if (strncmp(cmd, "VELOCITY ON", strlen("VELOCITY ON")) == 0) { cmdNum = cmdVELOCITY_ON; sprintf(stringOut, "IGLOBAL(%d) = %d", cmdVar, cmdVELOCITY_ON); @@ -1223,14 +1205,22 @@ int writeIntAndCheck(SS_ID ssId, struct UserVar *pVar, int n, int ival) { } +/* Not all Ensemble controllers support PSOARRAY commands. There doesn't seem to be a command + * that allows software to determine whether or not PSOARRAY commands are supported. + */ #define PSO_DISTANCE_ARRAY 1 + +/* For trajectories of unlimited length, PVT commands can be executed via sendReceiveCommand(), + * but this has not been reliable enough, so if PVT_BY_CONTROLLER, we send the whole trajectory + * to the controller via DGLOBAL variables. + */ #define PVT_BY_CONTROLLER 1 + /**************************************************************************************/ static int loadTrajectory(SS_ID ssId, struct UserVar *pVar) { - int i, j, k, n, status; + int i, j, n, status; char stringOut[MAX_MESSAGE_STRING], reply[MAX_MESSAGE_STRING]; - double position, p, v, t, dp, dt, dtime; - int dir; + double position, p, v, t, dp, dtime; int iGlobalIndex; int nPulses = 1 + pVar->endPulses - pVar->startPulses; int intPosition; @@ -1343,14 +1333,6 @@ static int loadTrajectory(SS_ID ssId, struct UserVar *pVar) { /* Program SCOPE commands */ pVar->nScopeDataPoints = pVar->npoints * 2.2; if (pVar->nScopeDataPoints > MAX_PULSES) pVar->nScopeDataPoints = MAX_PULSES; - for (j=0, dt=-1.; jmoveAxis[j]) { - if (pVar->epicsMotorACCL[j] > dt) { - dt = pVar->epicsMotorACCL[j]; - break; - } - } - } pVar->scopeDataIntervalMS = NINT(1000 * (pVar->time*1.1)/pVar->nScopeDataPoints); if (pVar->scopeDataIntervalMS < 1) pVar->scopeDataIntervalMS = 1; sprintf(stringOut, "SCOPEBUFFER %d", pVar->nScopeDataPoints);