Changeset 4488 for trunk/MagicSoft
- Timestamp:
- 08/04/04 16:44:33 (20 years ago)
- Location:
- trunk/MagicSoft/AMC/activemirrorcontrol/activemirrorcontrol
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/AMC/activemirrorcontrol/activemirrorcontrol/laseradjustthread.cpp
r4172 r4488 71 71 getSpot(); 72 72 73 // qsMsg.sprintf( "Spot at: % d,%d",74 // m_ iSpotX, m_iSpotY );73 // qsMsg.sprintf( "Spot at: %5.1f,%5.1f", 74 // m_dSpotX, m_dSpotY ); 75 75 // QThread::postEvent( m_pReceiver, new ThreadEvent( qsMsg ) ); 76 76 77 if( m_ iSpotX != -1)77 if( m_dSpotX != -1. ) 78 78 { 79 79 int x,y; … … 85 85 // check that the movement is in the allowed range 86 86 // of the motors (-2500 - 2500) 87 if( ( abs(x +m_pPanel->getX()) > 2500 )87 if( ( abs(x - m_pPanel->getX()) > 2500 ) 88 88 || 89 ( abs(y +m_pPanel->getY()) > 2500 ) )89 ( abs(y - m_pPanel->getY()) > 2500 ) ) 90 90 break; 91 91 … … 103 103 getSpot(); 104 104 getDistToRef(dX, dY); 105 int x,y; 106 calcSteps( x, y ); 105 107 106 108 pMotor->switchLaser( false ); 107 109 m_pPanel->setLaserOn( false ); 108 110 109 if( ( dX > 1.5) || (dY> 1.5) )111 if( (fabs(dX) > 1.5) || (fabs(dY) > 1.5) ) 110 112 { 111 113 AMCError aErr( IDS_ERROR_NO_CONVERGENCE ); … … 154 156 int iNumLEDs = 0; 155 157 156 m_ iCenterX = m_iCenterY = 1;158 m_dCenterX = m_dCenterY = 1.; 157 159 m_qlSpots.clear(); 158 160 … … 197 199 } 198 200 else 199 m_qlSpots.append( new VideoSpot( pActualSpot->getX(), pActualSpot->getY() ) );201 m_qlSpots.append( new VideoSpot( pActualSpot->getX(), pActualSpot->getY(), pActualSpot->getNumPixel()) ); 200 202 } 201 203 if( iNumLEDs != 0) 202 204 { 203 m_ iCenterX = (int) rint(dX / iNumLEDs);204 m_ iCenterY = (int) rint(dY / iNumLEDs);205 } 206 // qDebug("Center at: % d %d -- with %d LEDs",m_iCenterX, m_iCenterY, iNumLEDs );205 m_dCenterX = dX / iNumLEDs; 206 m_dCenterY = dY / iNumLEDs; 207 } 208 // qDebug("Center at: %5.1f %5.1f -- with %d LEDs",m_dCenterX, m_dCenterY, iNumLEDs ); 207 209 } 208 210 … … 210 212 void LaserAdjustThread::getDistToRef( double& p_dX, double& p_dY ) 211 213 { 212 int iRefX = m_pPanel->getLaserX();213 int iRefY = m_pPanel->getLaserY();214 double dRefX = m_pPanel->getLaserX(); 215 double dRefY = m_pPanel->getLaserY(); 214 216 215 217 // Adapt spot for shift of camera center. 216 int iDx, iDy;217 iDx = m_iCenterX - CAMERA_X;218 iDy = m_iCenterY - CAMERA_Y;219 m_ iSpotX -= iDx;220 m_ iSpotY -= iDy;221 // qDebug("Spot at x,y: % 4d %4d", m_iSpotX, m_iSpotY );218 double dDx, dDy; 219 dDx = m_dCenterX - CAMERA_X; 220 dDy = m_dCenterY - CAMERA_Y; 221 m_dSpotX -= dDx; 222 m_dSpotY -= dDy; 223 // qDebug("Spot at x,y: %5.1f %5.1f", m_dSpotX, m_dSpotY ); 222 224 223 225 // Now we calculate the distance of the real spot to the stored reference position 224 p_dX = (double) (iRefX - m_iSpotX);225 p_dY = (double) (iRefY - m_iSpotY);226 // qDebug("Dx Dy: % 4.0f %4.0f", dX,dY );226 p_dX = dRefX - m_dSpotX; 227 p_dY = dRefY - m_dSpotY; 228 // qDebug("Dx Dy: %5.1f %5.1f", p_dX, p_dY ); 227 229 } 228 230 … … 231 233 { 232 234 double dX, dY; 233 getDistToRef(dX, dY ); 234 235 double dAlpha1 = atan( m_pPanel->getSlopeX() ); 236 double dAlpha2 = atan( m_pPanel->getSlopeY() ); 237 // qDebug("alpha1, alpha2: %7.2f %7.2f", dAlpha1 * 180.0 / 3.1415, dAlpha2 * 180.0 / 3.1415 ); 238 double dSinA1 = sin( dAlpha1 ); 239 double dSinA2 = sin( dAlpha2 ); 240 double dCosA1 = cos( dAlpha1 ); 241 double dCosA2 = cos( dAlpha2 ); 242 243 double dFacX = dX - ( dY * dCosA2 / dSinA2 ); 244 dFacX /= ( dCosA1 - dSinA1 * dCosA2 / dSinA2 ); 245 double dFacY = (dY - dFacX * dSinA1) / dSinA2; 246 // qDebug("Factor x,y: %8.2f %8.2f", dFacX, dFacY ); 247 248 p_iX = (int) ( dFacX * m_pPanel->getConversionX() ); 249 p_iY = (int) ( dFacY * m_pPanel->getConversionY() ); 250 251 // convert number of steps to an even number 252 p_iX = (p_iX >> 1) << 1; 253 p_iY = (p_iY >> 1) << 1; 235 // if( m_pPanel->isReversed() ) 236 // getDistToRef(dY, dX ); 237 // else 238 getDistToRef( dX, dY ); 239 m_pPanel->calcSteps( dX, dY, p_iX, p_iY ); 254 240 255 241 qDebug("Steps till reference: %4d %4d", p_iX, p_iY ); 256 242 QCString qsMsg; 257 qsMsg.sprintf( "%3d %3d % 3d %3d %3d %3d %3d %3d %3d %3d%5d %5d",243 qsMsg.sprintf( "%3d %3d %5.1f %5.1f %5.1f %5.1f %5.1f %5.1f %5.1f %5.1f %5d %5d", 258 244 m_pPanel->i(), m_pPanel->j(), 259 m_ iCenterX, m_iCenterY,260 m_ iSpotX, m_iSpotY,245 m_dCenterX, m_dCenterY, 246 m_dSpotX, m_dSpotY, 261 247 m_pPanel->getLaserX(), m_pPanel->getLaserY(), 262 (int) rint(dX), (int) rint(dY), 263 p_iX, p_iY ); 248 dX, dY, p_iX, p_iY ); 264 249 QThread::postEvent( m_pReceiver, new ThreadEvent( qsMsg ) ); 265 250 } … … 310 295 { 311 296 VideoSpot* pSpot = m_qlSpots.first(); 312 m_ iSpotX = pSpot->getX();313 m_ iSpotY = pSpot->getY();297 m_dSpotX = pSpot->getX(); 298 m_dSpotY = pSpot->getY(); 314 299 } 315 300 else 316 301 { 317 m_ iSpotX = -1;318 m_ iSpotY = -1;302 m_dSpotX = -1.; 303 m_dSpotY = -1.; 319 304 if( m_qlSpots.count() == 0) 320 305 { -
trunk/MagicSoft/AMC/activemirrorcontrol/activemirrorcontrol/laseradjustthread.h
r3401 r4488 43 43 bool m_zOn; 44 44 /** */ 45 int m_iCenterX;45 double m_dCenterX; 46 46 /** */ 47 int m_iCenterY;47 double m_dCenterY; 48 48 /** */ 49 int m_iSpotX;49 double m_dSpotX; 50 50 /** */ 51 int m_iSpotY;51 double m_dSpotY; 52 52 /** No descriptions */ 53 53 QList<VideoSpot> m_qlSpotList;
Note:
See TracChangeset
for help on using the changeset viewer.