- added makeauxub to tasub
- fixes for MARS - extended maximize to honour maxpts and the in360 flag - added regression histmem driver
This commit is contained in:
73
maximize.c
73
maximize.c
@ -55,6 +55,7 @@
|
||||
pObjectDescriptor pDes;
|
||||
pCounter pCount;
|
||||
int i360;
|
||||
int maxpts;
|
||||
}Maxxii;
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
@ -167,10 +168,10 @@
|
||||
|
||||
/* search to the left until out of space or lCts < lMax/2. */
|
||||
SCWrite(pCon,"Searching for low angle boundary..",eWarning);
|
||||
for(i = MAXPTS/2; i >= 0; i--)
|
||||
for(i = self->maxpts/2; i >= 0; i--)
|
||||
{
|
||||
/* drive motor */
|
||||
fPos = fStart - (MAXPTS/2 - i)*fStep;
|
||||
fPos = fStart - (self->maxpts/2 - i)*fStep;
|
||||
fPos = in360(self,fPos);
|
||||
if(maxDrive(pVar,pVarName,fPos,pCon) != 1)
|
||||
{
|
||||
@ -218,7 +219,7 @@
|
||||
goto start;
|
||||
}
|
||||
/* no peak found or normal peak: continue at other side */
|
||||
if( (i < 1) || (y[MAXPTS/2] > lMax/2) )
|
||||
if( (i < 1) || (y[self->maxpts/2] > lMax/2) )
|
||||
{
|
||||
iSkip = 0;
|
||||
}
|
||||
@ -227,7 +228,7 @@
|
||||
/* next case: all of the peak in measured half:
|
||||
find max value and skip the right half
|
||||
*/
|
||||
for(i = MAXPTS/2; i > 0; i--)
|
||||
for(i = self->maxpts/2; i > 0; i--)
|
||||
{
|
||||
if(y[i] > lMax/2)
|
||||
{
|
||||
@ -246,10 +247,10 @@
|
||||
lMin = 100000;
|
||||
lMax = -100000;
|
||||
SCWrite(pCon,"Searching for high angle boundary..",eWarning);
|
||||
for(i = MAXPTS/2; i < MAXPTS; i++)
|
||||
for(i = self->maxpts/2; i < self->maxpts; i++)
|
||||
{
|
||||
/* drive motor */
|
||||
fPos = fStart + (i - MAXPTS/2) * fStep;
|
||||
fPos = fStart + (i - self->maxpts/2) * fStep;
|
||||
fPos = in360(self,fPos);
|
||||
if(maxDrive(pVar,pVarName,fPos,pCon) != 1)
|
||||
{
|
||||
@ -292,18 +293,18 @@
|
||||
iTop = i;
|
||||
iTop++;
|
||||
/* first case: peak is at high angle side */
|
||||
if( (i > MAXPTS-2) && (lMax*0.5 > lMin) )
|
||||
if( (i > self->maxpts-2) && (lMax*0.5 > lMin) )
|
||||
{
|
||||
goto start;
|
||||
}
|
||||
/* second case: no peak */
|
||||
if( (iTop > MAXPTS-2) )
|
||||
if( (iTop > self->maxpts-2) )
|
||||
{
|
||||
SCWrite(pCon,"ERROR: no peak found!",eError);
|
||||
return 0;
|
||||
}
|
||||
/* third case: normal peak */
|
||||
if(y[MAXPTS/2] >= 0.5*lMax)
|
||||
if(y[self->maxpts/2] >= 0.5*lMax)
|
||||
{
|
||||
iTop--;
|
||||
}
|
||||
@ -313,7 +314,7 @@
|
||||
*/
|
||||
else
|
||||
{
|
||||
for(i = MAXPTS/2; i < MAXPTS; i++)
|
||||
for(i = self->maxpts/2; i < self->maxpts; i++)
|
||||
{
|
||||
if(y[i] > lMax/2)
|
||||
{
|
||||
@ -325,7 +326,7 @@
|
||||
}
|
||||
} /* end of iSkip */
|
||||
|
||||
if( (iBot < 2) || (iTop > MAXPTS-2) || (lMax < lMin*2) )
|
||||
if( (iBot < 2) || (iTop > self->maxpts-2) || (lMax < lMin*2) )
|
||||
{
|
||||
SCWrite(pCon,"ERROR: no peak found!",eError);
|
||||
return 0;
|
||||
@ -420,6 +421,7 @@
|
||||
pNew->pDes = CreateDescriptor("Maximizer");
|
||||
pNew->pCount = pCom->pData;
|
||||
pNew->i360 = 0;
|
||||
pNew->maxpts = 100;
|
||||
|
||||
AddCommand(pSics,"max",MaximizeAction,MaxKill,pNew);
|
||||
return 1;
|
||||
@ -434,7 +436,7 @@
|
||||
double dVal;
|
||||
float fStep, fPreset;
|
||||
CounterMode eCount;
|
||||
int iRet;
|
||||
int iRet, iVal;
|
||||
|
||||
self = (pMax)pData;
|
||||
assert(self);
|
||||
@ -446,9 +448,56 @@
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* enough arguments ?*/
|
||||
if(argc < 5)
|
||||
{
|
||||
if(argc > 1)
|
||||
{
|
||||
strtolower(argv[1]);
|
||||
if(strcmp(argv[1],"in360") == 0)
|
||||
{
|
||||
if(argc > 2)
|
||||
{
|
||||
iVal = atoi(argv[2]);
|
||||
if(iVal != 0 && iVal != 1) {
|
||||
SCWrite(pCon,"ERROR: only 0, 1 allowed for in360",eError);
|
||||
return 0;
|
||||
}
|
||||
self->i360 = iVal;
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf(pBueffel,255,"max.in360 = %d", self->i360);
|
||||
SCWrite(pCon,pBueffel,eValue);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if(strcmp(argv[1],"maxpts") == 0)
|
||||
{
|
||||
if(argc > 2)
|
||||
{
|
||||
iVal = atoi(argv[2]);
|
||||
if(iVal < 10 || iVal > 100) {
|
||||
SCWrite(pCon,"ERROR: maxpst must be between 10 and 100",
|
||||
eError);
|
||||
return 0;
|
||||
}
|
||||
self->maxpts = iVal;
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf(pBueffel,255,"max.maxpts = %d", self->maxpts);
|
||||
SCWrite(pCon,pBueffel,eValue);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
SCWrite(pCon,"ERROR: Insufficient number of arguments to max",
|
||||
eError);
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user