#ifndef __ELTEL_H #define __ELTEL_H #include #include #include #include /* #include */ #include "eltcp.h" #define SERVERTYPETCP 1 #define SERVERTYPEFIFO 2 typedef struct scopevalues { double hstepmaximumspeed; int calcrefraction; double temperature; double airpressure; double timerintct_goto; double timerintct_correction; double az_gotospeed; double alt_gotospeed; double az_correctionspeed; double alt_correctionspeed; double fr_gotospeed; double fr_correctionspeed; double mstimerintct_goto; double mstimerintct_correction; double msaz_gotospeed; double msalt_gotospeed; double msaz_correctionspeed; double msalt_correctionspeed; double msfr_gotospeed; double msfr_correctionspeed; double az_halfstepsize; double alt_halfstepsize; double fr_halfstepsize; long utcadjust; double latitude; double longitude; double northpole; double southpole; double hs_northpole; double hs_southpole; double hs_latitude; double hs_az90; double hs_az180; double hs_az270; double hs_az360; double hs_altub; double hs_altlb; double hs_alt90; double hs_alt180; double hs_fr90; double hs_fr180; double hs_fr270; double hs_fr360; double alt_horizontlimit; double alt_zenitlimit; double lastazhs; double lastalths; double lastfrhs; int fruse; double fr_msecperhs; int azleft; int altdown; } scopevalues; extern scopevalues scope; typedef struct guidevalues { long updatecounter; time_t updateseconds; double LAST; double ra; double dec; double lastazhs; double lastalths; double nextazhs; double nextalths; double az_correctionhs; double alt_correctionhs; int frstep; } guidevalues; extern guidevalues guide; typedef struct programvalues { int debug; int iftype; int guiderunning; int motorrun; int motorspeed; int connection; int looprun; int keypad; unsigned char event; unsigned char dummy; char objname[40]; char objtype[40]; char magnitude[10]; char azstr[20]; char altstr[20]; char frstr[20]; char rastr[20]; char decstr[20]; int objmark; int loopbusy; char eventstr[60]; pid_t pid; uid_t uid; int skipstartupmotor; } programvalues; extern programvalues prog; typedef struct servervalues { int start; pthread_t serverthread; int serverrun; char servicename[42]; char envname[42]; int initport; int timeoutread; int timeoutwrite; unsigned char event; SOCKNR sock; SOCKNR serversock; char fifoinfile[128]; char fifooutfile[128]; int servertype; } servervalues; extern servervalues server; typedef struct xephemfifovalues { pthread_t xefifothread; int xefiforun; int start; char fifoinfile[128]; char fifooutfile[128]; int fifooutloop; int fifooutloopsave; int keypadspecial; int fifooutloopbusy; } xephemfifovalues; extern xephemfifovalues xephem; typedef struct monitorvalues { pthread_t monitorthread; int start; int monitorrun; char objdbpath[128]; char objname[40]; char objtype[40]; char azstr[20]; char altstr[20]; char rastr[20]; char decstr[20]; } monitorvalues; extern monitorvalues monitor; typedef struct exfifovalues { int start; pthread_t exfifothread; char fifoinfile[128]; int fiforun; int invert; int follow; double azsteps; double altsteps; } exfifovalues; extern exfifovalues exfifo; typedef struct encodervalues { int type; int active; double azsighs; /*halfsteps per pulse ( numbers of halfsteps per 360 degr. / ENCODERAZSIGNALS360)*/ double altsighs; /*halfsteps per pulse ( numbers of halfsteps per 90 degr. / ENCODERALTSIGNALS90)*/ double aztolerance; /*ENCODERAZTOLERANCE*/ double alttolerance;/*ENCODERALTTOLERANCE*/ double azpulse; /*the current pulses for az*/ double altpulse; /*the current pulses for alt*/ double azpulse360; /*pulses used for 360degrees ENCODERAZSIGNALS350*/ double altpulse90; /*pulses used for 360degrees ENCODERALTSIGNALS90*/ unsigned char val; /*the raw inputsignals*/ int azleft; /*current direction of encoders*/ int altdown; double cazhs; /*current number of halfsteps*/ double calths; double correctazhs; /*corrected number of halfsteps, if comparison fails*/ double correctalths; int _altflag; int _azflag; double az_errcount; double alt_errcount; double debug_azhs[22]; double debug_alths[22]; int debugazcount; int debugaltcount; } encodervalues; extern encodervalues encoder; /* test.c */ /* ---------------------------------------*/ int test_CalculatedKoors( void ); void DebugCalculation( void ); /* interface.c */ /* ---------------------------------------*/ #define IF_SERIAL 1 #define IF_PARALLEL 2 #define IF_SERIALSUBSERIAL 0 #define IF_SERIALSUBPARALLEL 1 #define IF_PARALLELSUBRAW 0 #define IF_PARALLELSUBSMC 1 int if_StartConnection( void ); int if_StopConnection( void ); int if_AltAzGoto(char *azstr, char *altstr ); int if_AltAzOrigin(char *azstr, char *altstr ); char * if_GetCurrentAzKoor( void ); char * if_GetCurrentAltKoor( void ); char * if_GetCurrentFrKoor( void ); int if_GoLeft_Fast( void ); int if_GoUp_Fast( void ); int if_GoDown_Fast( void ); int if_GoRight_Fast( void ); int if_GoLeft_Slow( void ); int if_GoUp_Slow( void ); int if_GoDown_Slow( void ); int if_GoRight_Slow( void ); int if_FrTurnRight( void ); int if_FrTurnLeft( void ); int if_StopMotors( void ); int if_GuideInitialisation( void ); int if_Guide( void ); int if_Move( int speed,int az, int azdir,int alt, int altdir,int fr, int frdir ); int if_Step( int answer, int az, int azleft, int alt, int altdown, int fr, int frleft, double * azhs, double * alths ); void if_waitmillisecs( long ms ); void if_waitmicrosecs( long ms ); /* config.c */ /* -----------------------------------------*/ void cfg_init_defaultvalues( void ); int cfg_init_scopevalues( void ); int cfg_read_configfile( char *filename ); int cfg_check_conditions( void ); /* loop.c */ /* -----------------------------------------*/ int loop ( void ); void waitTillLoopFree( void ); void doLoopEvent( unsigned char event ); /*server.c */ /* -----------------------------------------*/ int serverstart( void ); void tcpshutdownserver( void ); /*xephemfifo.c */ /* -----------------------------------------*/ int xephemfifostart( void ); void sendCurrentKoorsToXephem( void ); int xephemfifooutloopstart( void ); /*exfifo.c */ /* -----------------------------------------*/ int exfifostart( void ); /*monitor.c */ /* -----------------------------------------*/ int monitorstart( void ); void monitor_alert( char *txt ); typedef int (* MONITORCALLBACK )(char *); /* encoder.c */ /*--------------------------------------*/ unsigned char read_parallelencoders( void ); unsigned char read_joystickencoders( void ); #endif