#include "eltel.h" #include "../setbaud.c" /****************************************** High Level convert interface between program and connection for stearing scope. *******************************************/ /* --- the interfaces ---*/ #include "encoder.c" #include "serial.c" #include "parallel.c" /* ----------------------*/ int if_firststartup = 0; //these are for correction during guiding //It's only possible to make one step per //using key of handpad, or menu for //correction at a time. double if_gazcorrectionhs = 0.0; double if_galtcorrectionhs = 0.0; //these are for internal calculations, if //koordinates must be calculated for goto, and correction. //currently only IF_SERIAL uses this double if_azhs = 0.0; double if_alths = 0.0; double if_azarc = 0.0; double if_altarc = 0.0; double if_frhs = 0.0; double if_frarc = 0.0; long ifstartsecs = 0; long ifstartmsecs = 0; long ifcurmsecs = 0; double iffrmsecs = 0.0; void if_alert( char * txt ) { monitor_alert(txt); } void if_alert_type( void ) { monitor_alert("Invalid type of interface used"); } void if_alert_connection( void ) { monitor_alert("Error during connected operation"); } void if_msg_connection( void ) { monitor_alert("You must first start connection"); } void if_msg_koor( char * txt ) { monitor_alert(txt); } int _if_initAfterConnection( void ) { if(prog.skipstartupmotor){ if_firststartup = 1; return(1); } if( if_firststartup ) { return(1); } if(if_GoRight_Fast() == 0){ return(0); } sleep(5); if(if_StopMotors( ) == 0){ return(0); } if(if_GoUp_Fast( ) == 0){ return(0); } sleep(5); if(if_StopMotors() == 0){ return(0); } if_firststartup = 1; return(1); } double if_cAltRfFromScope( double d ) { if( ( cRfValues == NULL ) || ( ! scope.calcrefraction ) ){ return(d); } return(cAltRfFromScope(d)); } double if_cAltRfToScope( double d ) { if( ( cRfValues == NULL ) || ( ! scope.calcrefraction ) ){ return(d); } return(cAltRfToScope( d )); } /* this can be used by every interface waits microsecs */ void if_waitmicrosecs( long ms ) { struct timeval tv; struct timezone tz; long t,sec,usec; if( ms <= 0 ){ return; } gettimeofday(&tv,&tz); sec = tv.tv_sec; usec = tv.tv_usec; t = 0; while( t < ms ){ gettimeofday(&tv,&tz); if( ( usec != tv.tv_usec ) || ( sec != tv.tv_sec ) ){ t++; sec = tv.tv_sec; usec = tv.tv_usec; } } } /* this can be used by every interface waits millisecs */ void if_waitmillisecs( long ms ) { struct timeb tpa; long t; time_t sec; unsigned short msec; if(ms <= 0){ return; } ftime(&tpa); sec = tpa.time; msec = tpa.millitm; t = 0; while( t < ms ){ ftime(&tpa); if( ( msec != tpa.millitm ) || ( sec != tpa.time ) ){ t++; sec = tpa.time; msec = tpa.millitm; } } } int if_StartConnection( void ) { if(prog.connection){ return(1); } prog.guiderunning = 0; prog.motorrun = MNORUN; scope.azleft = -1; scope.altdown = -1; switch(prog.iftype){ case IF_SERIAL: if(serial_openConnection() == 0 ) { if_alert("Cannot start connection"); return(0); } prog.connection = 1; return( _if_initAfterConnection( ) ); case IF_PARALLEL: if(par_openConnection() == 0 ) { if_alert("Cannot start connection"); return(0); } prog.connection = 1; return( _if_initAfterConnection() ); default:break; } if_alert_type(); return(0); } int if_StopConnection( void ) { prog.guiderunning = 0; if(! prog.connection ) { return(1); } if(if_StopMotors() == 0){ return(0); } switch(prog.iftype){ case IF_SERIAL: if(serial_closeConnection() == 0 ) { if_alert("Error when ending connection"); return(0); } prog.connection = 0; prog.motorrun = MNORUN; return(1); case IF_PARALLEL: if(par_closeConnection() == 0 ) { if_alert("Error when ending connection"); return(0); } prog.connection = 0; prog.motorrun = MNORUN; return(1); default:break; } if_alert_type(); return(0); } int if_StopMotors( void ) { prog.guiderunning = 0; if(! prog.connection ){ if_msg_connection(); return(1); } if(! prog.motorrun ){ return(1); } switch(prog.iftype){ case IF_SERIAL: if(serial_stopMotors() == 0 ) { if_alert("Error when stopping motors"); return(0); } prog.motorrun = MNORUN; return(1); case IF_PARALLEL: if(par_stopMotors() == 0 ) { if_alert("Error when stopping motors"); return(0); } prog.motorrun = MNORUN; return(1); default:break; } if_alert_type(); return(0); } char * if_GetCurrentAzKoor( void ) { if(! prog.connection ){ if_msg_connection(); return(NULL); } switch(prog.iftype){ case IF_SERIAL: if( ( if_azhs = serial_getCurrentAzKoor()) < 0.0 ) { if(if_azhs == -1.0){ if_alert("Error when starting receiving of az-koordinates"); } else { if_alert("Error when getting current az-koordinates"); } return("000:00:00"); } if_azarc = if_azhs * scope.az_halfstepsize; return(DoubleToStrDegrees(if_azarc , 0)); case IF_PARALLEL: if( ( if_azhs = par_getCurrentAzKoor()) < 0.0 ) { if_alert("Invalid AZ-koordinates"); } if_azarc = if_azhs * scope.az_halfstepsize; return(DoubleToStrDegrees(if_azarc , 0)); default:break; } if_alert_type(); return(NULL); } char * if_GetCurrentAltKoor(void ) { if(! prog.connection ){ if_msg_connection(); return(NULL); } switch(prog.iftype){ case IF_SERIAL: if( ( if_alths = serial_getCurrentAltKoor()) < 0.0 ) { if( if_alths == -1.0){ if_alert("Error when starting receiving of alt-koordinates"); } else { if_alert("Error when getting current alt-koordinates"); } return("00:00:00"); } if_altarc = if_alths * scope.alt_halfstepsize; if_altarc = if_cAltRfFromScope( if_altarc ); return(DoubleToStrDegrees(if_altarc , 0)); case IF_PARALLEL: if( ( if_alths = par_getCurrentAltKoor()) < 0.0 ) { if_alert("Invalid ALT-koordinates"); } if_altarc = if_alths * scope.alt_halfstepsize; if_altarc = if_cAltRfFromScope( if_altarc ); return(DoubleToStrDegrees(if_altarc , 0)); default:break; } if_alert_type(); return(NULL); } char * if_GetCurrentFrKoor(void ) { if(! prog.connection ){ if_msg_connection(); return(NULL); } switch(prog.iftype){ case IF_SERIAL: if( ( if_frhs = serial_getCurrentFrKoor()) < 0.0 ) { if( if_frhs == -1.0){ if_alert("Error when starting receiving of fr-koordinates"); } else { if_alert("Error when getting current fr-koordinates"); } return("00:00:00"); } if_frarc = if_frhs * scope.fr_halfstepsize; return(DoubleToStrDegrees(if_frarc , 0)); case IF_PARALLEL: if( ( if_frhs = par_getCurrentFrKoor()) < 0.0 ) { if_alert("Invalid FR-koordinates"); } if_frarc = if_frhs * scope.fr_halfstepsize; return(DoubleToStrDegrees(if_frarc , 0)); default:break; } if_alert_type(); return(NULL); } int if_GoLeft_Fast( void ) { double speed; prog.guiderunning = 0; if(! prog.connection ){ if_msg_connection(); return(1); } if(if_StopMotors() == 0){ return(0); } scope.azleft = -1; switch(prog.iftype){ case IF_SERIAL: speed = scope.az_gotospeed; if(serial_CorrectionMode( SPEED_FAST, speed, 1, -1, 0, -1, 0 ) == 0 ){ if_alert_connection(); return(0); } prog.motorrun = MCORRECTION; prog.motorspeed = SPEED_FAST; return(1); case IF_PARALLEL: if(par_CorrectionMode( SPEED_FAST, scope.az_gotospeed, 1, -1, 0, -1, 0 ) == 0 ){ if_alert_connection(); return(0); } prog.motorrun = MCORRECTION; prog.motorspeed = SPEED_FAST; return(1); default:break; } if_alert_type(); return(0); } int if_GoUp_Fast( void ) { double speed; prog.guiderunning = 0; if(! prog.connection ){ if_msg_connection(); return(1); } if(if_StopMotors() == 0){ return(0); } scope.altdown = -1; switch(prog.iftype){ case IF_SERIAL: speed = scope.alt_gotospeed; if(serial_CorrectionMode( SPEED_FAST, -1, 0, speed, 0, -1, 0 ) == 0 ){ if_alert_connection(); return(0); } prog.motorrun = MCORRECTION; prog.motorspeed = SPEED_FAST; return(1); case IF_PARALLEL: if(par_CorrectionMode( SPEED_FAST, -1, 0, scope.alt_gotospeed, 0, -1, 0 ) == 0 ){ if_alert_connection(); return(0); } prog.motorrun = MCORRECTION; prog.motorspeed = SPEED_FAST; return(1); default:break; } if_alert_type(); return(0); } int if_GoDown_Fast(void ) { double speed; prog.guiderunning = 0; if(! prog.connection ){ if_msg_connection(); return(1); } if(if_StopMotors() == 0){ return(0); } scope.altdown = -1; switch(prog.iftype){ case IF_SERIAL: speed = scope.alt_gotospeed; if(serial_CorrectionMode( SPEED_FAST, -1, 0, speed, 1, -1, 0) == 0 ){ if_alert_connection(); return(0); } prog.motorrun = MCORRECTION; prog.motorspeed = SPEED_FAST; return(1); case IF_PARALLEL: if(par_CorrectionMode( SPEED_FAST, -1, 0, scope.alt_gotospeed, 1, -1, 0 ) == 0 ){ if_alert_connection(); return(0); } prog.motorrun = MCORRECTION; prog.motorspeed = SPEED_FAST; return(1); default:break; } if_alert_type(); return(0); } int if_GoRight_Fast( void ) { double speed; prog.guiderunning = 0; if(! prog.connection ){ if_msg_connection(); return(1); } if(if_StopMotors() == 0){ return(0); } scope.azleft = -1; switch(prog.iftype){ case IF_SERIAL: speed = scope.az_gotospeed; if(serial_CorrectionMode( SPEED_FAST, speed, 0, -1, 0, -1, 0 ) == 0 ){ if_alert_connection(); return(0); } prog.motorrun = MCORRECTION; prog.motorspeed = SPEED_FAST; return(1); case IF_PARALLEL: if(par_CorrectionMode( SPEED_FAST, scope.az_gotospeed, 0, -1, 0, -1, 0 ) == 0 ){ if_alert_connection(); return(0); } prog.motorrun = MCORRECTION; prog.motorspeed = SPEED_FAST; return(1); default:break; } if_alert_type(); return(0); } int if_GoLeft_Slow( void ) { double speed; prog.guiderunning = 0; if(! prog.connection ){ if_msg_connection(); return(1); } if( prog.motorrun == MGUIDE ){ if_gazcorrectionhs = if_gazcorrectionhs - guide.az_correctionhs; return(1); } if(if_StopMotors() == 0){ return(0); } scope.azleft = -1; switch(prog.iftype){ case IF_SERIAL: speed = scope.az_correctionspeed; if(serial_CorrectionMode( SPEED_SLOW, speed, 1, -1, 0, -1, 0 ) == 0 ){ if_alert_connection(); return(0); } prog.motorrun = MCORRECTION; prog.motorspeed = SPEED_SLOW; return(1); case IF_PARALLEL: if(par_CorrectionMode( SPEED_SLOW, scope.az_correctionspeed, 1, -1, 0, -1, 0 ) == 0 ){ if_alert_connection(); return(0); } prog.motorrun = MCORRECTION; prog.motorspeed = SPEED_SLOW; return(1); default:break; } if_alert_type(); return(0); } int if_GoUp_Slow( void ) { double speed; prog.guiderunning = 0; if(! prog.connection ){ if_msg_connection(); return(1); } if( prog.motorrun == MGUIDE ){ if_galtcorrectionhs = if_galtcorrectionhs + guide.alt_correctionhs; return(1); } if(if_StopMotors() == 0){ return(0); } scope.altdown = -1; switch(prog.iftype){ case IF_SERIAL: speed = scope.alt_correctionspeed; if(serial_CorrectionMode( SPEED_SLOW, -1, 0, speed, 0, -1, 0 ) == 0 ){ if_alert_connection(); return(0); } prog.motorrun = MCORRECTION; prog.motorspeed = SPEED_SLOW; return(1); case IF_PARALLEL: if(par_CorrectionMode( SPEED_SLOW, -1, 0, scope.alt_correctionspeed, 0, -1, 0 ) == 0 ){ if_alert_connection(); return(0); } prog.motorrun = MCORRECTION; prog.motorspeed = SPEED_SLOW; return(1); default:break; } if_alert_type(); return(0); } int if_GoDown_Slow( void ) { double speed; prog.guiderunning = 0; if(! prog.connection ){ if_msg_connection(); return(1); } if( prog.motorrun == MGUIDE ){ if_galtcorrectionhs = if_galtcorrectionhs - guide.alt_correctionhs; return(1); } if(if_StopMotors() == 0){ return(0); } scope.altdown = -1; switch(prog.iftype){ case IF_SERIAL: speed = scope.alt_correctionspeed; if(serial_CorrectionMode( SPEED_SLOW, -1, 0, speed, 1, -1, 0 ) == 0 ){ if_alert_connection(); return(0); } prog.motorrun = MCORRECTION; prog.motorspeed = SPEED_SLOW; return(1); case IF_PARALLEL: if(par_CorrectionMode( SPEED_SLOW, -1, 0, scope.alt_correctionspeed, 1, -1, 0 ) == 0 ){ if_alert_connection(); return(0); } prog.motorrun = MCORRECTION; prog.motorspeed = SPEED_SLOW; return(1); default:break; } if_alert_type(); return(0); } int if_GoRight_Slow( void ) { double speed; prog.guiderunning = 0; if(! prog.connection ){ if_msg_connection(); return(1); } if( prog.motorrun == MGUIDE ){ if_gazcorrectionhs = if_gazcorrectionhs + guide.az_correctionhs; return(1); } if(if_StopMotors() == 0){ return(0); } scope.azleft = -1; switch(prog.iftype){ case IF_SERIAL: speed = scope.az_correctionspeed; if(serial_CorrectionMode( SPEED_SLOW, speed, 0, -1, 0, -1, 0 ) == 0 ){ if_alert_connection(); return(0); } prog.motorrun = MCORRECTION; prog.motorspeed = SPEED_SLOW; return(1); case IF_PARALLEL: if(par_CorrectionMode( SPEED_SLOW, scope.az_correctionspeed, 0, -1, 0, -1, 0 ) == 0 ){ if_alert_connection(); return(0); } prog.motorrun = MCORRECTION; prog.motorspeed = SPEED_SLOW; return(1); default:break; } if_alert_type(); return(0); } int if_FrTurnRight(void ) { double speed; prog.guiderunning = 0; if(! prog.connection ){ if_msg_connection(); return(1); } if(if_StopMotors() == 0){ return(0); } switch(prog.iftype){ case IF_SERIAL: speed = scope.fr_gotospeed; if(serial_CorrectionMode( SPEED_FAST, -1, 0, -1, 0, speed, 0 ) == 0 ){ if_alert_connection(); return(0); } prog.motorrun = MFR; prog.motorspeed = SPEED_FAST; return(1); case IF_PARALLEL: if(par_CorrectionMode( SPEED_FAST, -1, 0, -1, 0, scope.fr_gotospeed, 0 ) == 0 ){ if_alert_connection(); return(0); } prog.motorrun = MFR; prog.motorspeed = SPEED_FAST; return(1); default:break; } if_alert_type(); return(0); } int if_FrTurnLeft( void ) { double speed; prog.guiderunning = 0; if(! prog.connection ){ if_msg_connection(); return(1); } if(if_StopMotors() == 0){ return(0); } switch(prog.iftype){ case IF_SERIAL: speed = scope.fr_gotospeed; if(serial_CorrectionMode( SPEED_FAST, -1, 0, -1, 0, speed, 1 ) == 0 ){ if_alert_connection(); return(0); } prog.motorrun = MFR; prog.motorspeed = SPEED_FAST; return(1); case IF_PARALLEL: if(par_CorrectionMode( SPEED_FAST, -1, 0, -1, 0, scope.fr_gotospeed, 1 ) == 0 ){ if_alert_connection(); return(0); } prog.motorrun = MFR; prog.motorspeed = SPEED_FAST; return(1); default:break; } if_alert_type(); return(0); } /* speed must be one of SPEED_SLOW, or SPEED_FAST az,alt,fr must indicate with 1 that this is used, otherwithe set to 0. azdir 0 = right 1 = left latdir 0 = up 1 = down frdir 0 = right 1 = left */ int if_Move( int speed,int az, int azdir,int alt, int altdir,int fr, int frdir ) { double azspeed,altspeed,frspeed; prog.guiderunning = 0; if(! prog.connection ){ if_msg_connection(); return(1); } if(if_StopMotors() == 0){ return(0); } azspeed = -1; altspeed = -1; frspeed = -1; if(az){ scope.azleft = -1; azspeed = scope.az_correctionspeed; if(speed == SPEED_FAST){ azspeed = scope.az_gotospeed; } } if(alt){ scope.altdown = -1; altspeed = scope.alt_correctionspeed; if(speed == SPEED_FAST){ altspeed = scope.alt_gotospeed; } } if(fr){ frspeed = scope.fr_correctionspeed; if(speed == SPEED_FAST){ frspeed = scope.fr_gotospeed; } } switch(prog.iftype){ case IF_SERIAL: if(serial_CorrectionMode( speed, azspeed, azdir, altspeed, altdir, frspeed, frdir ) == 0 ){ if_alert_connection(); return(0); } prog.motorrun = MCORRECTION; prog.motorspeed = speed; return(1); case IF_PARALLEL: if(par_CorrectionMode( speed, azspeed, azdir, altspeed, altdir, frspeed, frdir ) == 0 ){ if_alert_connection(); return(0); } prog.motorrun = MCORRECTION; prog.motorspeed = speed; return(1); default:break; } if_alert_type(); return(0); } int if_AltAzGoto(char *azstr, char *altstr) { double azarc,azhs; double altarc,alths; int res; prog.guiderunning = 0; if(! prog.connection ){ if_msg_connection(); return(1); } if(if_StopMotors() == 0){ return(0); } if( (azarc = StrDegreesToDouble( azstr, 0 )) < 0.0 ){ if_msg_koor("Invalid az-koordinate"); return(1); } if( (altarc = StrDegreesToDouble( altstr, 0 )) < 0.0 ){ if_msg_koor("Invalid alt-koordinate"); return(1); } azhs = azarc / scope.az_halfstepsize; alths = if_cAltRfToScope( altarc ) / scope.alt_halfstepsize; scope.azleft = -1; scope.altdown = -1; switch(prog.iftype){ case IF_SERIAL: res = serial_Goto( makeAbsoluteDouble( azhs ), makeAbsoluteDouble(alths) ); if( res == 1 ){ if_alert_connection(); return(0); } if( res == 2 ){ if_alert("Koordinates out of range"); return(0); } prog.motorrun = MGOTO; prog.motorspeed = SPEED_FAST; return(1); case IF_PARALLEL: if( par_Goto( makeAbsoluteDouble( azhs ), makeAbsoluteDouble(alths) ) == 0 ) { if_alert("Koordinates out of range"); return(0); } prog.motorrun = MGOTO; prog.motorspeed = SPEED_FAST; return(1); default:break; } if_alert_type(); return(0); } int if_AltAzOrigin(char *azstr, char *altstr ) { double azarc,azhs; double altarc,alths; prog.guiderunning = 0; if(! prog.connection ){ if_msg_connection(); return(1); } if(if_StopMotors() == 0){ return(0); } if( (azarc = StrDegreesToDouble( azstr, 0 )) < 0.0 ){ if_msg_koor("Invalid az-koordinate"); return(1); } if( (altarc = StrDegreesToDouble( altstr, 0 )) < 0.0 ){ if_msg_koor("Invalid alt-koordinate"); return(1); } azhs = azarc / scope.az_halfstepsize; alths = if_cAltRfToScope( altarc ) / scope.alt_halfstepsize; scope.azleft = -1; scope.altdown = -1; switch(prog.iftype){ case IF_SERIAL: if( serial_ResetKoors( azhs, alths ) == 0 ){ if_alert_connection(); return(0); } encoders_reset( azhs, alths ); return(1); case IF_PARALLEL: if( par_ResetKoors( azhs, alths ) == 0 ){ if_alert_connection(); return(0); } encoders_reset( azhs, alths ); return(1); default:break; } if_alert_type(); return(0); } int if_GuideInitialisation( void ) { double az,alt; double azhs,alths; RADEC radec; if( prog.guiderunning) { return(1); } if(! prog.connection ){ if_msg_connection(); return(1); } if(if_StopMotors() == 0){ return(0); } scope.azleft = -1; scope.altdown = -1; switch(prog.iftype){ case IF_SERIAL: if( ( azhs = serial_getCurrentAzKoor()) < 0.0 ) { if_alert("Error when getting current az-koordinates for guiding"); return(0); } if( ( alths = serial_getCurrentAltKoor()) < 0.0 ) { if_alert("Error when getting current alt-koordinates for guiding"); return(0); } break; case IF_PARALLEL: if( ( azhs = par_getCurrentAzKoor()) < 0.0 ) { if_alert("Invalid AZ-koordinates for guiding"); return(0); } if( ( alths = par_getCurrentAltKoor()) < 0.0 ) { if_alert("Invalid ALT-koordinates for guiding"); return(0); } break; default: if_alert_type(); return(0); } if_gazcorrectionhs = 0.0; if_galtcorrectionhs = 0.0; guide.frstep = 0; az = ( azhs * scope.az_halfstepsize ) / 3600.0; alt = if_cAltRfFromScope( alths * scope.alt_halfstepsize ) / 3600.0; guide.LAST = cCurrentStarTime( scope.longitude , scope.latitude, 0, 0, scope.utcadjust ); ifstartsecs = cCSTcurseconds; ifstartmsecs = cCSTmillisecs; ifcurmsecs = 0; iffrmsecs = 0.0; cRaDec( scope.latitude, az, alt, guide.LAST, &radec ); guide.ra = radec.ra; guide.dec = radec.dec; /* fr we must calculate extra, - currently no plan how to do this. */ guide.lastazhs = ( az * 3600.0 ) / scope.az_halfstepsize; guide.lastalths = if_cAltRfToScope( alt * 3600.0 ) / scope.alt_halfstepsize; guide.nextazhs = guide.lastazhs; guide.nextalths = guide.lastalths; prog.guiderunning = 1; prog.motorrun = MGUIDE; prog.motorspeed = SPEED_GUIDE; return(1); } int if_Guide( void ) { double az,alt; long curmsecs; AZALT azalt; if(! prog.guiderunning) { return(1); } guide.LAST = cCurrentStarTime( scope.longitude , scope.latitude, 0, 0, scope.utcadjust ); curmsecs = ifcurmsecs; ifcurmsecs = cCSTcurseconds - ifstartsecs; if(ifcurmsecs != 0){ ifcurmsecs = ifcurmsecs * 1000; } ifcurmsecs = ifcurmsecs + cCSTmillisecs - ifstartmsecs; curmsecs = ifcurmsecs - curmsecs; iffrmsecs = iffrmsecs + curmsecs; cAzAlt( scope.latitude, guide.ra, guide.dec, guide.LAST, &azalt ); guide.lastazhs = guide.nextazhs; guide.lastalths = guide.nextalths; guide.nextazhs = ( azalt.az * 3600.0 ) / scope.az_halfstepsize; guide.nextalths = if_cAltRfToScope( azalt.alt * 3600.0 ) / scope.alt_halfstepsize; guide.nextazhs = guide.nextazhs + if_gazcorrectionhs; /* @@@@@ testit*/ if(guide.nextazhs < 0 ){ guide.nextazhs = scope.hs_az360 + guide.nextazhs; } guide.nextalths = guide.nextalths + if_galtcorrectionhs; while(iffrmsecs >= scope.fr_msecperhs ){ iffrmsecs = iffrmsecs - scope.fr_msecperhs; if(scope.fruse){ guide.frstep++; } } scope.azleft = -1; scope.altdown = -1; switch(prog.iftype){ case IF_SERIAL: if(serial_Koorsapproach() == 0){ prog.guiderunning = 0; if_alert("Connectionerror during guiding"); return(0); } prog.motorrun = MGUIDE; prog.motorspeed = SPEED_GUIDE; return(1); case IF_PARALLEL: if(par_Koorsapproach() == 0){ prog.guiderunning = 0; if_alert("Error during guiding"); return(0); } prog.motorrun = MGUIDE; prog.motorspeed = SPEED_GUIDE; return(1); default:break; } if_alert_type(); return(0); } /* makes one step per motor ( az, alt, fr - set to 1 what you use, otherwise 0) to direction ( azleft, frleft 0 = right, 1 = left, altdown 0 = up, 1 = down ) function gets new halfstepvalues for az,alt, if answer if set to 1, and sets *azhs,*alths to this. In mostly case when using az,alt this should be use in every case, for knowing if step is ready done. For only using fr, this makes mostly no sense. This tests connection, only for serial interface. */ int if_Step( int answer, int az, int azleft, int alt, int altdown, int fr, int frleft, double * azhs, double * alths ) { prog.guiderunning = 0; if(if_StopMotors() == 0){ return(0); } switch(prog.iftype){ case IF_SERIAL: if(! prog.connection ){ if_msg_connection(); return(1); } return( serial_Step( answer, az, azleft, alt, altdown, fr, frleft, azhs, alths ) ); case IF_PARALLEL: return( par_Step( answer, az, azleft, alt, altdown, fr, frleft, azhs, alths ) ); default:break; } if_alert_type(); return(0); }