Changeset 677 for BAORadio/libindi


Ignore:
Timestamp:
May 21, 2012, 3:25:43 PM (13 years ago)
Author:
frichard
Message:

Sauvegarde de sécurité (problème de DD). Interfae graphique de BAOcontrol en QT

Location:
BAORadio/libindi/libindi
Files:
10 deleted
19 edited
1 moved

Legend:

Unmodified
Added
Removed
  • BAORadio/libindi/libindi/BAOTest/BAOtest_main.cpp

    r650 r677  
    1212#include <stdio.h>
    1313#include <stdlib.h>
    14 #include <net/if.h>
     14#include <net/if.h> 
    1515#include <sys/types.h>
    1616#include <sys/socket.h>
     
    114114        return atoi(str2.c_str());
    115115    }
    116 
     116 
    117117    return -1;
    118118}
  • BAORadio/libindi/libindi/Indi_Stellarium/src/Connection.cpp

    r623 r677  
    8888#endif
    8989
    90 Connection::Connection(Server &server, SOCKET fd) : Socket(server, fd)
     90Connection::Connection(Server2 &server, SOCKET fd) : Socket2(server, fd)
    9191{
    9292        read_buff_end = read_buff;
  • BAORadio/libindi/libindi/Indi_Stellarium/src/Connection.hpp

    r623 r677  
    2626#define _CONNECTION_HPP_
    2727
    28 #include "Socket.hpp"
     28#include "Socket2.hpp"
    2929
    3030//! TCP/IP connection to a client.
    31 class Connection : public Socket
     31class Connection : public Socket2
    3232{
    3333public:
    34         Connection(Server &server, SOCKET fd);
     34        Connection(Server2 &server, SOCKET fd);
    3535        long long int getServerMinusClientTime(void) const
    3636        {
  • BAORadio/libindi/libindi/Indi_Stellarium/src/Listener.hpp

    r623 r677  
    2626#define _LISTENER_HPP_
    2727
    28 #include "Socket.hpp"
     28#include "Socket2.hpp"
    2929
    3030//! Listens for connection attempts and adds new connections to the server.
     
    3434//! attempts. If a TCP/IP connection is established, the listener adds it
    3535//! to the list of connections maintained by the server.
    36 class Listener : public Socket
     36class Listener : public Socket2
    3737{
    3838public:
    3939        //! @param port TCP/IP port number
    40         Listener(Server &server, int port) : Socket(server, INVALID_SOCKET),
     40        Listener(Server2 &server, int port) : Socket2(server, INVALID_SOCKET),
    4141                                             port(port) {}
    4242       
  • BAORadio/libindi/libindi/Indi_Stellarium/src/Makefile

    r642 r677  
    1212
    1313
    14 TelescopeServerBAO_CPP = Connection.cpp Listener.cpp Socket.cpp socket.cpp filetools.cpp exception.c astro.cpp ClientSocket.cpp \
    15   Server.cpp ServerBAO.cpp LogFile.cpp MainBAO.cpp
     14TelescopeServerBAO_CPP = Connection.cpp Listener.cpp Socket2.cpp Server.cpp \
     15  ServerBAO.cpp LogFile.cpp MainBAO.cpp
    1616
    1717TelescopeServerBAO_O = $(TelescopeServerBAO_CPP:.cpp=.o)
     
    4444
    4545TelescopeServerBAO: $(TelescopeServerBAO_O)
    46         g++ $(LDFLAGS) $(TelescopeServerBAO_O) -o $@
     46        g++ $(LDFLAGS) -c -o ../src/astro.o ../../communs/astro.cpp
     47        g++ $(LDFLAGS) -c -o ../src/exception.o ../../communs/exception.cpp
     48        g++ $(LDFLAGS) -c -o ../src/filetools.o ../../communs/filetools.cpp
     49        g++ $(LDFLAGS) -c -o ../src/Socket.o ../../communs/Socket.cpp
     50        g++ $(LDFLAGS) -c -o ../src/ClientSocket.o ../../communs/ClientSocket.cpp
     51        g++ $(LDFLAGS) -c -o ../src/logs.o ../../communs/logs.cpp
     52        g++ $(LDFLAGS) -c -o ../src/alignement.o ../../communs/alignement.cpp
     53        g++ $(LDFLAGS) $(TelescopeServerBAO_O) astro.o exception.o filetools.o Socket.o ClientSocket.o logs.o alignement.o -o $@
    4754
    4855
  • BAORadio/libindi/libindi/Indi_Stellarium/src/Server.cpp

    r623 r677  
    2424
    2525#include "Server.hpp"
    26 #include "Socket.hpp"
     26#include "Socket2.hpp"
    2727#include "Listener.hpp"
    2828
    29 void Server::SocketList::clear(void)
     29void Server2::SocketList::clear(void)
    3030{
    3131        for (const_iterator it(begin()); it != end(); it++)
     
    3333                delete (*it);
    3434        }
    35         list<Socket*>::clear();
     35        list<Socket2*>::clear();
    3636}
    3737
    38 Server::Server(int port)
     38Server2::Server2(int port)
    3939{
    40         Socket *listener = new Listener(*this, port);
     40        Socket2 *listener = new Listener(*this, port);
    4141        socket_list.push_back(listener);
    4242}
    4343
    44 void Server::sendPosition(unsigned int ra_int, int dec_int, int status)
     44void Server2::sendPosition(unsigned int ra_int, int dec_int, int status)
    4545{
    4646        for (SocketList::const_iterator it(socket_list.begin());
     
    5252}
    5353
    54 void Server::step(long long int timeout_micros)
     54void Server2::step(long long int timeout_micros)
    5555{
    5656        fd_set read_fds, write_fds;
     
    9393}
    9494
    95 void Server::closeAcceptedConnections(void)
     95void Server2::closeAcceptedConnections(void)
    9696{
    9797        for (SocketList::iterator it(socket_list.begin());
  • BAORadio/libindi/libindi/Indi_Stellarium/src/Server.hpp

    r623 r677  
    2929using namespace std;
    3030
    31 class Socket;
     31class Socket2;
    3232
    3333//! Base class for telescope server classes. A true telescope server class
     
    4343//! Socket::prepareSelectFds() and Socket::handleSelectFds() for each connection
    4444//! in the list. These methods are reimplemented for each class.
    45 class Server
     45class Server2
    4646{
    4747public:
    48         Server(void) {}
    49         Server(int port);
    50         virtual ~Server(void) {}
     48        Server2(void) {}
     49        Server2(int port);
     50        virtual ~Server2(void) {}
    5151        virtual void step(long long int timeout_micros);
    5252       
     
    5858        //! Connection or any custom class that implements a serial port
    5959        //! connection (such as Lx200Connection and NexStarConnection).
    60         void addConnection(Socket *s)
     60        void addConnection(Socket2 *s)
    6161        {
    6262                if (s)
     
    7171        friend class Connection;
    7272       
    73         class SocketList : public list<Socket*>
     73        class SocketList : public list<Socket2*>
    7474        {
    7575                public:
  • BAORadio/libindi/libindi/Indi_Stellarium/src/ServerBAO.cpp

    r623 r677  
    2424
    2525#include "ServerBAO.hpp"
    26 #include "Socket.hpp" // GetNow
     26#include "Socket2.hpp" // GetNow
    2727
    2828#include <math.h>
    2929
    3030ServerDummy::ServerDummy(int port)
    31             :Server(port)
     31            :Server2(port)
    3232{
    3333        last_pos[0] = current_pos[0] = desired_pos[0] = 1.0;
     
    3737
    3838
    39         float a1, a2, a3;
    40 
    41         // Le choix de la couleur des caractÚres est adapté pour une fenêtre de terminal
    42         // ayant un fond blanc. pour un fond noir, mettre couleurs=2 dans le fichier params
    43 
    44         ChoixCouleurs=1;
    45 
    46 
    47         Affiche("\n\n\n\n\n \
    48      ******************************************\n \
    49      *           Serveur Stellarium           *\n \
    50      * Laboratoire de l'Accélérateur Linéaire *\n \
    51      *                                        *\n \
    52      *             v0.1  20/08/2011           *\n \
    53      *        franckrichard033@gmail.com      *\n \
    54      ******************************************\n\n\n", true);
    55 
    56         //Initialisation des variables globales et des pointeurs
    57 
    58 
    59         delaitransit  = 0;
    60         delaitracking = 0;
    61         lognum        = 0;
    62         numAntenne    = 0;
    63         numobjets     = 0;
    64         runnum        = 1;
    65 
    66         Pression      = 1013.0;
    67         Temperature   = 10.0;
    68 
    69         NoExit        = true;
    70         Transit       = false;
    71         run           = false;
    72         exitrun       = false;
    73 
    74         fd            = NULL;
    75         client_socket = NULL;
    76 
    77         // chaines de caractÚres et tableaux
    78 
    79         LatitudeChar  = "";
    80         LongitudeChar = "";
    81         Serveur       = "";
    82         Port          = "";
    83 
    84         Antennes      = new DefAntenne[MAXANTENNES];
    85         objets        = new DefObjets[MAXOBJETS];
    86 
    87         //on initalise aussi les tableaux
    88 
    89         for (int i=0; i<MAXANTENNES; i++)
    90         {
    91             Antennes[i].ok=0;
    92             Antennes[i].ip=0;
    93         }
    94 
    95         for (int i=0; i<MAXOBJETS; i++)
    96         {
    97             objets[i].JJ=0;
    98             objets[i].exec=false;
    99         }
    100 
    101         // Chargement du fichier contenant les paramÚtres
    102 
    103         if (!ChargementParametres("params"))
    104         {
    105             Erreur("Le fichier de configuration 'params' contient des erreurs ou n'existe pas.\n \
    106             Merci de vérifier.\n\n");
    107             exit(1);
    108         }
    109 
    110         // Conversion de la latitude et de la longitude en radians
    111 
    112         Decomposition(LatitudeChar, 0, &a1, &a2, &a3);
    113 
    114         double Latitude = (a1 + a2 / 60.0 + a3 / 3600.0) * Pidiv180;
    115 
    116         Decomposition(LongitudeChar, 1, &a1, &a2, &a3);
    117 
    118         double Longitude = Pi2 - ( a1 + a2 / 60.0 + a3 / 3600.0 ) * Pidiv180;
    119 
    120         // Transfert de la latitude, longitude, pression, température à la classe Astro
    121 
    122         DefinirLongitudeLatitude(Longitude, Latitude);
    123 
    124         DefinirPressionTemp(Pression, Temperature);
    125 
    126         // Ouverture du socket avec indi_BAO
    127 
    128         client_socket = new ClientSocket("localhost", atoi(Port.c_str()) );
    129 
    130         // On se connecte au pilote indi_BAO
    131 
    132         Connect(true);
    133 
     39       float a1, a2, a3;
     40
     41    // Le choix de la couleur des caractÚres est adapté pour une fenêtre de terminal
     42    // ayant un fond blanc. pour un fond noir, mettre couleurs = 2 dans le fichier params
     43
     44    ChoixCouleurs=1;
     45
     46    // Affichage de la version du programme
     47
     48    AfficherLog("\n\n\n\n\n \
     49 ******************************************\n \
     50 *             BAORadio Control           *\n \
     51 * Laboratoire de l'Accélérateur Linéaire *\n \
     52 *                                        *\n \
     53 *             v0.52 19/04/2012           *\n \
     54 *        franckrichard033@gmail.com      *\n \
     55 ******************************************\n\n\n", true);
     56
     57
     58    // Initialisation des variables globales et des pointeurs
     59    // pour la signification des variables, voir baocontrol.h
     60
     61
     62    delaitransit           = 0;
     63    delaitracking          = 0;
     64    lognum                 = 0;
     65    numAntennes            = 0;
     66    numobjets              = 0;
     67    numEtoiles             = 0;
     68    runnum                 = 1;
     69
     70    MethodeAlignement      = SIMPLE;
     71
     72    Pression               = 1013.0;
     73    Temperature            = 10.0;
     74
     75    NoExit                 = true;
     76    Transit                = false;
     77    run                    = false;
     78    exitrun                = false;
     79    ModificationAlignement = false;
     80
     81    fd                     = NULL;
     82    client_socket          = NULL;
     83
     84    // chaînes de caractÚres et tableaux
     85
     86    LatitudeChar           = "";
     87    LongitudeChar          = "";
     88    Serveur                = "";
     89    Port                   = "";
     90
     91    Antennes               = new DefAntenne[ MAXANTENNES ];
     92    objets                 = new DefObjets [ MAXOBJETS ];
     93    Etoiles                = new DefEtoiles[ MAXETOILES] ;
     94
     95
     96    // on initialise aussi les structures
     97
     98    for (int i=0; i<MAXANTENNES; i++)
     99    {
     100        Antennes[i].ok = 0;
     101        Antennes[i].ip = 0;
     102
     103        Antennes[i].AlignementAntenne = new Alignement();
     104    }
     105
     106    for (int i=0; i<MAXOBJETS; i++)
     107    {
     108        objets[i].JJ   = 0.0;
     109        objets[i].exec = false;
     110    }
     111
     112    for (int i=0; i<MAXETOILES; i++)
     113    {
     114        Etoiles[i].nom          = "";
     115        Etoiles[i].ad           = 0.0;
     116        Etoiles[i].de           = 0.0;
     117        Etoiles[i].az           = 0.0;
     118        Etoiles[i].ha           = 0.0;
     119        Etoiles[i].mag          = 0.0;
     120        Etoiles[i].selectionnee = false;
     121    }
     122
     123
     124    // Chargement du fichier contenant les paramÚtres de l'application BAOcontrol
     125    // La variable permet de récupérer le nom de l'utilisateur ayant ouvert la session sous linux
     126    // c'est dans le répertoire /home/USER/ que BAOcontrol cherche le fichier de paramÚtre baocontrol_params
     127
     128    if (!ChargementParametres("/home/" + (string)getenv("USER") + "/baocontrol_params"))
     129    {
     130        ErreurLog("Le fichier de configuration 'params' contient des erreurs ou n'existe pas.\n");
     131        ErreurLog("Il devrait se trouver dans le répertoire /home/" + (string)getenv("USER") +"\n");
     132        ErreurLog("Merci de vérifier...\n\n");
     133        exit(1);
     134    }
     135
     136
     137    // Conversion de la latitude et de la longitude en radians
     138
     139    Decomposition(LatitudeChar, 0, &a1, &a2, &a3);
     140
     141    double Latitude = (a1 + a2 / 60.0 + a3 / 3600.0) * Pidiv180;
     142
     143    Decomposition(LongitudeChar, 1, &a1, &a2, &a3);
     144
     145    double Longitude = Pi2 - ( a1 + a2 / 60.0 + a3 / 3600.0 ) * Pidiv180;
     146
     147
     148    // Transfert de la latitude, longitude, pression, température à la classe Astro
     149
     150    DefinirLongitudeLatitude(Longitude, Latitude);
     151
     152    DefinirPressionTemp(Pression, Temperature);
     153    // On lance les calculs (Temps sidéral local etc...)
     154
     155    CalculTSL();
     156
     157
     158    //Chargement du catalogue d'étoiles que l'on utilise pour l'alignement des antennes
     159
     160  /* if ( !ChargementCatalogueEtoiles("/home/" + (string)getenv("USER") + "/bao_catalogue.dat") )
     161    {
     162        ErreurLog("Le catalogue d'étoiles 'bao_catalogue' est introuvable.\n");
     163        ErreurLog("Il devrait se trouver dans le répertoire /home/" + (string)getenv("USER") +"\n");
     164        ErreurLog("Merci de vérifier...\n\n");
     165        exit(1);
     166    }
     167*/
     168
     169
     170    // Ouverture du socket avec indi_BAO
     171
     172    client_socket = new ClientSocket("localhost", atoi(Port.c_str()) );
     173
     174    // On se connecte au pilote indi_BAO
     175
     176   Connect(true);
    134177        // On lance la fenêtre graphique
    135178
     
    175218
    176219       
    177         Server::step(timeout_micros);
     220        Server2::step(timeout_micros);
    178221}
    179222
     
    449492{
    450493    string reponse, memreponse, decomp;
    451     bool test=false;
     494
     495    bool test = false;
     496
     497    // on récupÚre les messages provenant d'indi_BAO
    452498
    453499    *client_socket >> reponse;
    454500
    455    // printf("%s\n", reponse.c_str());
    456 
    457501    do
    458502    {
    459         if (reponse.find("message")!=string::npos)
     503        // s'il contient le mot message (et vient donc d'indi_BAO)
     504
     505        if (reponse.find("message") != string::npos)
    460506        {
    461507            // On ne garde que la partie intéressante
    462             // La partie suivant "message="...
     508            // La partie qui suit "message="...
     509
    463510            reponse = reponse.substr(reponse.find("message") + 9);
    464511
     512            // (on en garde une trace)
     513
    465514            memreponse = reponse;
    466515
    467             // ...jusqu'au "
    468             reponse=reponse.substr(0, reponse.find("\""));
     516            // ...on extrait le message jusqu'au caractÚre "
     517
     518            reponse = reponse.substr(0, reponse.find("\""));
    469519
    470520            // On récupÚre l'adresse ip de l'antenne qui nous parle
    471             // et on met à jour le tabmeau des états des antennes
    472 
    473             if (reponse.find(". (Antennes connectees")!=string::npos)
     521            // et on met à jour le tableau des états de l'antenne correspondante
     522            // Dans les messages d'indi_BAO, l'adresse ip précÚde les mots "Antennes connectées"
     523
     524            if (reponse.find(" (Antennes connectees")!=string::npos)
    474525            {
    475                 decomp=reponse.substr(0, reponse.find(". (Antennes connectees"));
    476                 decomp=decomp.substr(decomp.rfind(".")+1);
    477 
    478                 // si cette antenne est déjà connectée, on change son état
    479 
    480                 for (int i=0; i<numAntenne; i++)
    481                 {
    482                     if (atoi(decomp.c_str()) == Antennes[i].ip)
     526                decomp = reponse.substr(0, reponse.find(" (Antennes connectees"));
     527                decomp = decomp.substr(decomp.rfind(".")+1);
     528
     529                // si cette antenne est déjà connectée, on change son état si nécessaire
     530
     531                if ( atoi(decomp.c_str()) != 0 ) for (int i=0; i<numAntennes; i++)
    483532                    {
    484                         Antennes[i].ok=1;
    485                         test=true;
    486                         break;
     533                        // on a trouvé l'antenne correspondante
     534
     535                        if (atoi(decomp.c_str()) == Antennes[i].ip)
     536                        {
     537                            Antennes[i].ok = 1;
     538                            test = true;
     539                            break;
     540                        }
    487541                    }
    488                 }
    489 
    490                 // ou si c'est une nouvelle antenne, on l'ajoute au tableau
     542
     543                // ou si c'est une nouvelle antenne, on l'ajoute au tableau Antennes
    491544
    492545                if (!test)
    493546                {
    494                     Antennes[numAntenne].ip = atoi(decomp.c_str());
    495                     Antennes[numAntenne++].ok = 1;
     547                    Antennes[numAntennes].ip = atoi(decomp.c_str());
     548
     549                    Antennes[numAntennes++].ok = 1;
    496550                }
    497551            }
    498552
    499553            // erreur sur une antenne -> on change son état dans la fenêtre
    500 
    501             if  ((reponse.find("ALERTE antenne ")!=string::npos) ||
    502                     (reponse.find("Erreur sur l antenne ")!=string::npos))
     554            // on trouve les erreurs dans les messages d'indi_BAO formulée
     555            // de la façon suivante: "ALERTE antenne" ou bien "Erreur sur l antenne"
     556
     557            if  ((reponse.find("ALERTE antenne ") != string::npos) ||
     558                    (reponse.find("Erreur sur l antenne ") != string::npos))
    503559            {
    504560                decomp = reponse.substr(0, reponse.find(" :"));
    505561                decomp = decomp.substr(decomp.rfind(".") + 1);
    506562
    507                 for (int i=0; i<numAntenne; i++)
     563                for (int i=0; i<numAntennes; i++)
    508564                {
     565                    // On identifie l'antenne dans le tableau Antennes et on change son état
     566
    509567                    if (atoi(decomp.c_str()) == Antennes[i].ip)
    510568                    {
     
    514572            }
    515573
    516             // On sauvegarde le message dans le tableau logs
     574            // On sauvegarde le message dans le fichier logs mais on ne l'affiche pas
    517575
    518576            stringstream os;
     
    520578            os << lognum << " : " << reponse;
    521579
    522             Affiche(os.str() + "\n", false);
    523 
    524             if (lognum<MAXLOG-1) logs[lognum++] = os.str();
     580            AfficherLog(os.str() + "\n", false);
     581
     582            if ( lognum < MAXLOG - 1 ) logs[ lognum++ ] = os.str();
    525583
    526584            reponse = memreponse;
    527585        }
    528         else reponse="";
    529 
    530 
    531     } while ( reponse !="" );
    532 
    533      // on actualise la fenêtre
    534 
    535         Dessiner();
     586        else reponse = "";
     587
     588
     589    } while ( reponse != "" );
     590
     591    // on actualise la fenêtre
     592
     593    Dessiner();
    536594
    537595    // on envoie un message pour actualiser la fenêtre graphique
     
    545603***************************************************************************************/
    546604
    547 bool ServerDummy::VerifReponse(string reponseattendue)
     605bool ServerDummy::VerifReponse(string reponseattendue, string *retourreponse)
    548606{
    549607    string reponse = "";
     
    552610    bool   test = false;
    553611
     612
    554613    // TODO :La réponse du driver ne vient pas tout de suite et on peut recevoir
    555614    // des messages intermédiaires un peu étranges impliquant la fonction CONNECT, pourquoi ?
    556     // Là on lit les messages trois fois de suite pour essayer de voir passer le bon
     615    // Là on lit les messages cinq fois de suite pour essayer de voir passer le bon
    557616    // Essayer de voir si on ne peut pas faire mieux...
    558617
    559     for (int i=0; i<3 ;i++)
     618    if (retourreponse) *retourreponse = "";
     619
     620    for (int i=0; i<5 ; i++)
    560621    {
    561622        do
     
    567628            duree++;
    568629        }
    569         while (reponse.length() == 0 && duree<10 ); // on attend un message pendant 10 ms max
     630        while (reponse.length() == 0 && duree < MAX_DELAI_REPONSE ); // on attend un message pendant 10 ms max
    570631
    571632        // on ajoute tous les messages reçus dans memmreponse
     
    581642    }
    582643
     644
    583645    if (!test)
    584646    {
    585647        // réponse inconnue -> une erreur ?
    586648
    587         int pos = memreponse.find("message=");
    588 
    589         if ( pos != (int)string::npos )
     649       long  unsigned int pos = memreponse.find("message=");
     650
     651        if ( pos != string::npos )
    590652        {
    591653            memreponse = memreponse.substr(pos + 9);
    592654
    593655            memreponse = memreponse.substr(0, memreponse.find("\""));
    594 
    595             Erreur("Réponse du pilote indi_BAO :" + memreponse + "\n\n");
    596         }
    597 
    598         return false;
     656        }
     657
     658        if (memreponse != "")  ErreurLog("Réponse du pilote indi_BAO :" + memreponse + "\n\n");
     659
     660        return false;
     661    }
     662
     663    if (retourreponse)
     664    {
     665        long unsigned int pos = memreponse.find(reponseattendue);
     666
     667        if ( pos != string::npos )
     668        {
     669            memreponse = memreponse.substr(pos);
     670
     671            memreponse = memreponse.substr(0, memreponse.find("\""));
     672        }
     673
     674        *retourreponse = memreponse;
    599675    }
    600676
     
    647723
    648724
    649 
    650 
    651725/**************************************************************************************
    652726** Envoie la longitude et la latitude du lieu d'observation au pilote indi_BAO
     727** sous la forme de vecteurs xml
     728** (voir les particularités des drivers développés sous Indi)
     729**
    653730***************************************************************************************/
    654731
     
    656733{
    657734    // la communication avec le pilote indi_BAO
    658     // se fait par l'envoie de petit fichier xml
    659     // d'où le cÃŽté complexe des commandes
     735    // se fait par l'envoi de trames au format xml
    660736
    661737    try
     
    670746        *client_socket << "</newNumberVector>";
    671747
    672         if (!VerifReponse("name=\"GEOGRAPHIC_COORD\" state=\"Ok\""))
    673         {
    674             Erreur("ERREUR fct EnvoyerCoordGeographiques : pas de réponse du pilote indi_BAO.\n\n");
     748        if (!VerifReponse("name=\"GEOGRAPHIC_COORD\" state=\"Ok\"", NULL))
     749        {
     750            ErreurLog("ERREUR fct EnvoyerCoordGeographiques : pas de réponse du pilote indi_BAO.\n\n");
    675751
    676752            return false;
     
    682758    catch ( SocketException& e )
    683759    {
    684         Erreur("Exception was caught:" + e.description() + "\n");
    685         return false;
    686     }
    687 
    688     Affiche("Les coordonnées géographiques ont bien été envoyées au pilote indi_BAO\n\n", true);
     760        ErreurLog("Exception was caught:" + e.description() + "\n");
     761
     762        return false;
     763    }
     764
     765    AfficherLog("Les coordonnées géographiques ont bien été envoyées au pilote indi_BAO\n\n", true);
    689766
    690767    return true;
     
    692769
    693770
     771/**************************************************************************************
     772** Transmet la pression et la température au pilote indi_BAO
     773**
     774***************************************************************************************/
     775
     776bool ServerDummy::EnvoyerPressionTemperature()
     777{
     778    stringstream os;
     779
     780    try
     781    {
     782        *client_socket << "<newNumberVector device=\"BAO\" name=\"PRESSION_DATA\">";
     783        *client_socket << "<oneNumber name=\"Pression\">";
     784        os << Pression;
     785        *client_socket << os.str();
     786        os.str("");
     787        *client_socket << "</oneNumber>";
     788        *client_socket << "<oneNumber name=\"Temperature\">";
     789        os << Temperature;
     790        *client_socket << os.str();
     791        os.str("");
     792        *client_socket << "</oneNumber>";
     793        *client_socket << "</newNumberVector>";
     794
     795        if (!VerifReponse("name=\"PRESSION_DATA\" state=\"Ok\"", NULL))
     796        {
     797            ErreurLog("ERREUR fct EnvoyerPressionTemperature : pas de réponse du pilote indi_BAO.\n\n");
     798
     799            return false;
     800        }
     801    }
     802
     803    // un problÚme ?
     804
     805    catch ( SocketException& e )
     806    {
     807        ErreurLog("Exception was caught:" + e.description() + "\n");
     808
     809        return false;
     810    }
     811
     812    AfficherLog("La pression et la température ont bien été envoyées au pilote indi_BAO\n\n", true);
     813
     814    return true;
     815}
     816
     817/**************************************************************************************
     818** Envoie les paramÚtres delaitransit et delaitracking au pilote indi_BAO
     819** Ces paramÚtres définissent la durée (en sec) entre deux actualisations
     820** dans les modes tracking et transit
     821**
     822***************************************************************************************/
     823
     824bool ServerDummy::EnvoyerDelaisModesTransitEtTracking()
     825{
     826    stringstream os;
     827
     828    try
     829    {
     830        os << delaitransit;
     831        *client_socket << "<newNumberVector device=\"BAO\" name=\"DELAY1\">";
     832        *client_socket << "<oneNumber name=\"DELAY\">";
     833        *client_socket << os.str();
     834        *client_socket << "</oneNumber>";
     835        *client_socket << "</newNumberVector>";
     836        os.str("");
     837
     838        if (!VerifReponse("name=\"DELAY1\" state=\"Ok\"", NULL))
     839        {
     840            ErreurLog("ERREUR fct EnvoyerDelaisModesTransitEtTracking : pas de réponse du pilote indi_BAO.\n\n");
     841
     842            return false;
     843        }
     844
     845        os << delaitracking;
     846        *client_socket << "<newNumberVector device=\"BAO\" name=\"DELAY2\">";
     847        *client_socket << "<oneNumber name=\"DELAY\">";
     848        *client_socket << os.str();
     849        *client_socket << "</oneNumber>";
     850        *client_socket << "</newNumberVector>";
     851        os.str("");
     852
     853        if (!VerifReponse("name=\"DELAY2\" state=\"Ok\"", NULL))
     854        {
     855            ErreurLog("ERREUR fct EnvoyerDelaisModesTransitEtTracking : pas de réponse du pilote indi_BAO.\n\n");
     856
     857            return false;
     858        }
     859    }
     860
     861    // un problÚme ?
     862
     863    catch ( SocketException& e )
     864    {
     865        ErreurLog("Exception was caught:" + e.description() + "\n");
     866
     867        return false;
     868    }
     869
     870    return true;
     871}
     872
     873
     874
     875/**************************************************************************************
     876** Envoie la méthode d'alignement au pilote indi_bao
     877** Ce paramÚtre peut être SIMPLE, AFFINE ou TAKI
     878**
     879***************************************************************************************/
     880
     881bool ServerDummy::EnvoyerMethodeAlignement()
     882{
     883    stringstream os;
     884
     885    try
     886    {
     887        *client_socket << "<newSwitchVector device=\"BAO\" name=\"ALIGNMENT_SET\">";
     888        *client_socket << "<oneSwitch name=\"SIMPLE\">";
     889        (MethodeAlignement == SIMPLE) ? *client_socket << "On" : *client_socket << "Off";
     890        *client_socket << "</oneSwitch>";
     891        *client_socket << "<oneSwitch name=\"AFFINE\">";
     892        (MethodeAlignement == AFFINE) ? *client_socket << "On" : *client_socket << "Off";
     893        *client_socket << "</oneSwitch>";
     894        *client_socket << "<oneSwitch name=\"TAKI\">";
     895        (MethodeAlignement == TAKI)   ? *client_socket << "On" : *client_socket << "Off";
     896        *client_socket << "</oneSwitch>";
     897        *client_socket << "</newSwitchVector>";
     898
     899        if (!VerifReponse("name=\"ALIGNMENT_SET\" state=\"Ok\"", NULL))
     900        {
     901            ErreurLog("ERREUR fct EnvoyerMethodeAlignement : pas de réponse du pilote indi_BAO.\n\n");
     902
     903            return false;
     904        }
     905    }
     906
     907    // un problÚme ?
     908
     909    catch ( SocketException& e )
     910    {
     911        ErreurLog("Exception was caught:" + e.description() + "\n");
     912
     913        return false;
     914    }
     915
     916    return true;
     917}
     918
     919
     920/**************************************************************************************
     921** Envoie une commande aux antennes
     922** exemples : P, Z, A, Gf1000f0100
     923**
     924***************************************************************************************/
     925
     926bool ServerDummy::EnvoyerCommande(string commande)
     927{
     928    stringstream os;
     929
     930    try
     931    {
     932        *client_socket << "<newTextVector device=\"BAO\" name=\"COMMAND_SET\">";
     933        *client_socket << "<oneText name=\"COMMAND\">";
     934        *client_socket << commande;
     935        *client_socket << "</oneText>";
     936        *client_socket << "</newTextVector>";
     937
     938        if (!VerifReponse("name=\"COMMAND_SET\" state=\"Ok\"", NULL))
     939        {
     940            ErreurLog("ERREUR fct EnvoyerCommande : pas de réponse du pilote indi_BAO.\n\n");
     941
     942            return false;
     943        }
     944
     945    }
     946
     947
     948    // un problÚme ?
     949
     950    catch ( SocketException& e )
     951    {
     952        ErreurLog("Exception was caught:" + e.description() + "\n");
     953
     954        return false;
     955    }
     956
     957    return true;
     958}
     959
     960
    694961
    695962/**************************************************************************************
    696963** Place les antennes en position de repos
     964**
    697965***************************************************************************************/
    698966
     
    707975        *client_socket << "</newSwitchVector>";
    708976
    709         if (!VerifReponse("PARK OK"))
    710         {
    711             Erreur("La commande PARK a échoué.\n\n");;
     977        if (!VerifReponse("PARK OK", NULL))
     978        {
     979            ErreurLog("La commande PARK a échoué.\n\n");;
    712980
    713981            return false;
     
    716984    catch ( SocketException& e)
    717985    {
    718         Erreur("Exception was caught:" + e.description() + "\n");
    719         return false;
    720     }
    721 
    722     Affiche("Le pilote indi_BAO a bien reçu la commande PARK.\n\n", true);
     986        ErreurLog("Exception was caught:" + e.description() + "\n");
     987
     988        return false;
     989    }
     990
     991    AfficherLog("Le pilote indi_BAO a bien reçu la commande PARK.\n\n", true);
    723992
    724993    return true;
     
    729998/**************************************************************************************
    730999** Annule le mouvement en cours
     1000**
    7311001***************************************************************************************/
    7321002
     
    7411011        *client_socket << "</newSwitchVector>";
    7421012
    743         if (!VerifReponse("ABORT OK"))
    744         {
    745             Erreur("L'annulation a échoué.\n\n");
     1013        if (!VerifReponse("ABORT OK", NULL))
     1014        {
     1015            ErreurLog("L'annulation a échoué.\n\n");
    7461016
    7471017            return false;
     
    7501020    catch ( SocketException& e)
    7511021    {
    752         Erreur("Exception was caught:" + e.description() + "\n");
    753         return false;
    754     }
    755 
    756     Affiche("Le pilote indi_BAO a bien reçu la commande ABORT.\n\n", true);
     1022        ErreurLog("Exception was caught:" + e.description() + "\n");
     1023
     1024        return false;
     1025    }
     1026
     1027    AfficherLog("Le pilote indi_BAO a bien reçu la commande ABORT.\n\n", true);
    7571028
    7581029    return true;
     
    7601031
    7611032
    762 
    763 /**************************************************************************************
    764 ** Diriger l'antenne vers les coordonnées ar et dec et suivre l'objet
    765 ** en activant le mode transit ou tracking.
     1033/**************************************************************************************
     1034** Alignement de l'antenne ip
     1035**
     1036***************************************************************************************/
     1037
     1038bool ServerDummy::AlignementIP(string ip)
     1039{
     1040    try
     1041    {
     1042        *client_socket << "<newTextVector device=\"BAO\" name=\"ALIGNEMENT_IP\">";
     1043        *client_socket << "<oneText name=\"IP\">";
     1044        *client_socket << ip;
     1045        *client_socket << "</oneText>";
     1046        *client_socket << "</newTextVector>";
     1047
     1048
     1049        if (!VerifReponse("est maintenant prete pour l alignement", NULL))
     1050        {
     1051            ErreurLog("La sélection de l'antenne située à l'adresse ip a échoué.\n\n");
     1052
     1053            return false;
     1054        }
     1055    }
     1056    catch ( SocketException& e)
     1057    {
     1058        ErreurLog("Exception was caught:" + e.description() + "\n");
     1059
     1060        return false;
     1061    }
     1062
     1063    AfficherLog("Le pilote indi_BAO a bien sélectionné l'antenne situé à l'adresse ip pour l'alignement.\n\n", true);
     1064
     1065    return true;
     1066}
     1067
     1068
     1069/**************************************************************************************
     1070** Augmenter ou diminuer le delta en ascension droite ou en déclinaison
     1071**
     1072***************************************************************************************/
     1073
     1074bool ServerDummy::AlignementDelta(string delta, bool azimut)
     1075{
     1076    string Message = "";
     1077
     1078    try
     1079    {
     1080        if (azimut)
     1081        {
     1082            if (delta == "-1")
     1083            {   *client_socket << "<newSwitchVector device=\"BAO\" name=\"AZ\" >";
     1084                *client_socket << "<oneSwitch name=\"AZM\">";
     1085                *client_socket << "On";
     1086                *client_socket << "</oneSwitch>";
     1087                *client_socket << "</newSwitchVector>";
     1088            }
     1089            else
     1090            {
     1091                *client_socket << "<newSwitchVector device=\"BAO\" name=\"AZ\" >";
     1092                *client_socket << "<oneSwitch name=\"AZP\">";
     1093                *client_socket << "On";
     1094                *client_socket << "</oneSwitch>";
     1095                *client_socket << "</newSwitchVector>";
     1096            }
     1097
     1098            if (!VerifReponse("Delta", &Message))
     1099            {
     1100                ErreurLog("BAOcontrol:AlignementDelta a échoué.\n\n");
     1101
     1102                return false;
     1103            }
     1104        }
     1105        else
     1106        {
     1107            if (delta == "-1")
     1108            {
     1109                *client_socket << "<newSwitchVector device=\"BAO\" name=\"ALT_N\" >";
     1110                *client_socket << "<oneSwitch name=\"ALTN\">";
     1111                *client_socket << "On";
     1112                *client_socket << "</oneSwitch>";
     1113                *client_socket << "</newSwitchVector>";
     1114
     1115                if (!VerifReponse("Delta", &Message))
     1116                {
     1117                    ErreurLog("BAOcontrol:AlignementDelta a échoué.\n\n");
     1118
     1119                    return false;
     1120                }
     1121            }
     1122            else
     1123            {
     1124                *client_socket << "<newSwitchVector device=\"BAO\" name=\"ALT_P\" >";
     1125                *client_socket << "<oneSwitch name=\"ALTP\">";
     1126                *client_socket << "On";
     1127                *client_socket << "</oneSwitch>";
     1128                *client_socket << "</newSwitchVector>";
     1129
     1130                if (!VerifReponse("Delta", &Message))
     1131                {
     1132                    ErreurLog("BAOcontrol:AlignementDelta a échoué.\n\n");
     1133
     1134                    return false;
     1135                }
     1136            }
     1137        }
     1138
     1139        if (Message != "") AfficherLog(Message + "\n\n", true);
     1140    }
     1141    catch ( SocketException& e)
     1142    {
     1143        ErreurLog("Exception was caught:" + e.description() + "\n");
     1144
     1145        return false;
     1146    }
     1147
     1148//   AfficherLog("Le pilote indi_BAO a bien sélectionné l'antenne situé à l'adresse ip pour l'alignement.\n\n", true);
     1149
     1150    return true;
     1151}
     1152
     1153
     1154/**************************************************************************************
     1155** Validation de l'alignement sur l'étoile visée actuellement
     1156**
     1157***************************************************************************************/
     1158
     1159bool ServerDummy::ValidationAlignement()
     1160{
     1161    try
     1162    {
     1163        *client_socket << "<newSwitchVector device=\"BAO\" name=\"ALIGNMENT_OK\" >";
     1164        *client_socket << "<oneSwitch name=\"OK\">";
     1165        *client_socket << "On";
     1166        *client_socket << "</oneSwitch>";
     1167        *client_socket << "</newSwitchVector>";
     1168
     1169        if (!VerifReponse("alignement ont ete valides", NULL))
     1170        {
     1171            ErreurLog("L'alignement sur l'étoile n'a pu être validé.\n\n");
     1172
     1173            return false;
     1174        }
     1175    }
     1176    catch ( SocketException& e)
     1177    {
     1178        ErreurLog("Exception was caught:" + e.description() + "\n");
     1179
     1180        return false;
     1181    }
     1182
     1183    AfficherLog("L'alignement sur l'étoile a bien été validé.\n\n", true);
     1184
     1185    return true;
     1186}
     1187
     1188
     1189/**************************************************************************************
     1190** Sauvegarde de l'alignement
     1191**
     1192***************************************************************************************/
     1193
     1194bool ServerDummy::SauvegardeAlignement()
     1195{
     1196    try
     1197    {
     1198        *client_socket << "<newSwitchVector device=\"BAO\" name=\"ALIGNMENT_OK\" >";
     1199        *client_socket << "<oneSwitch name=\"SAUV\">";
     1200        *client_socket << "On";
     1201        *client_socket << "</oneSwitch>";
     1202        *client_socket << "</newSwitchVector>";
     1203
     1204        if (!VerifReponse("Les parametres de l alignement ont ete sauvegardes", NULL))
     1205        {
     1206            ErreurLog("La sauvegarde des paramÚtres de l'alignement a échoué.\n\n");
     1207
     1208            return false;
     1209        }
     1210    }
     1211    catch ( SocketException& e)
     1212    {
     1213        ErreurLog("Exception was caught:" + e.description() + "\n");
     1214
     1215        return false;
     1216    }
     1217
     1218    AfficherLog("Les paramÚtres de l'alignemeent ont bien été sauvegardés.\n\n", true);
     1219
     1220    return true;
     1221}
     1222
     1223
     1224
     1225/**************************************************************************************
     1226** Sauvegarde de l'alignement
     1227**
     1228***************************************************************************************/
     1229
     1230bool ServerDummy::ResetAlignement()
     1231{
     1232    try
     1233    {
     1234        *client_socket << "<newSwitchVector device=\"BAO\" name=\"ALIGNMENT_RESET\" >";
     1235        *client_socket << "<oneSwitch name=\"RESET\">";
     1236        *client_socket << "On";
     1237        *client_socket << "</oneSwitch>";
     1238        *client_socket << "</newSwitchVector>";
     1239
     1240        if (!VerifReponse("reinitialises", NULL))
     1241        {
     1242            ErreurLog("Impossible de réinitialiser les paramÚtres d'alignement de l'antenne.\n\n");
     1243
     1244            return false;
     1245        }
     1246    }
     1247    catch ( SocketException& e)
     1248    {
     1249        ErreurLog("Exception was caught:" + e.description() + "\n");
     1250
     1251        return false;
     1252    }
     1253
     1254    AfficherLog("Les paramÚtres d'alignement de l'antenne ont été réinitialisés.\n\n", true);
     1255
     1256    return true;
     1257}
     1258
     1259
     1260/**************************************************************************************
     1261** Sélection vitesse alignement
     1262**
     1263***************************************************************************************/
     1264
     1265bool ServerDummy::VitesseAlignement(int vit)
     1266{
     1267    string Message = "";
     1268
     1269    try
     1270    {
     1271        if (vit == 1)
     1272        {
     1273            *client_socket << "<newSwitchVector device=\"BAO\" name=\"RAQ\" >";
     1274            *client_socket << "<oneSwitch name=\"RAQ1\">";
     1275            *client_socket << "On";
     1276            *client_socket << "</oneSwitch>";
     1277            *client_socket << "</newSwitchVector>";
     1278
     1279            if (!VerifReponse("La vitesse de la raquette est fixee a 1x", &Message))
     1280            {
     1281                ErreurLog("Impossible de modifier la vitesse de la raquette.\n\n");
     1282
     1283                return false;
     1284            }
     1285        }
     1286        else
     1287        {
     1288            *client_socket << "<newSwitchVector device=\"BAO\" name=\"RAQ\" >";
     1289            *client_socket << "<oneSwitch name=\"RAQ10\">";
     1290            *client_socket << "On";
     1291            *client_socket << "</oneSwitch>";
     1292            *client_socket << "</newSwitchVector>";
     1293
     1294            if (!VerifReponse("La vitesse de la raquette est fixee a 10x", &Message))
     1295            {
     1296                ErreurLog("Impossible de modifier la vitesse de la raquette.\n\n");
     1297
     1298                return false;
     1299            }
     1300        }
     1301
     1302
     1303
     1304    }
     1305    catch ( SocketException& e)
     1306    {
     1307        ErreurLog("Exception was caught:" + e.description() + "\n");
     1308
     1309        return false;
     1310    }
     1311
     1312    if (Message != "") AfficherLog(Message +"\n\n", true);
     1313
     1314    return true;
     1315}
     1316
     1317/**************************************************************************************
     1318** Dirige l'antenne vers les coordonnées ar et dec et suit l'objet  en activant le mode
     1319** transit ou tracking.
     1320**
    7661321** si J2000 == true, cela signifie que les coordonnées ar et dec sont données dans le
    7671322** le systÚme de coordonnées J2000 (écliptique et équinoxe du 1 janvier 2000 à 0 h TU)
    768 ** Des calculs supplémentaires (précession, nutation, abérration) sont alors nécessaires
     1323** Des calculs supplémentaires (précession, nutation, aberration) sont alors réalisés
     1324** pour ramener les coordonnées horaires à l'écliptique et l'équinoxe de la date de
     1325** l'observation.
     1326**
    7691327***************************************************************************************/
    7701328
    7711329bool ServerDummy::Goto(string ar, string dec, bool Transit, bool J2000)
    7721330{
     1331    double arf, decf;
    7731332    float  ar1, ar2, ar3;
    7741333    float  dec1, dec2, dec3;
    775     double arf, decf;
    776 
    777 
    778 
    779      /*
    780      //Pour les tests
    781      ar="05:39:14.8";
    782      dec="23:19:24.1";
    783      printf("JJ=%10.10f\n", GetJJ());
    784      J2000=true;
    785      */
     1334
    7861335
    7871336    // Conversion de l'AD et de la déclinaison en radians
    7881337
    7891338    Decomposition(ar, 2, &ar1, &ar2, &ar3);
     1339
    7901340    Decomposition(dec, 0, &dec1, &dec2, &dec3);
    7911341
    7921342    arf  = ( ar1  + ar2 / 60.0  + ar3 / 3600.0 ) * 15.0 * Pidiv180;
     1343
    7931344    decf = ( fabs(dec1) + dec2 / 60.0 + dec3 / 3600.0 ) * Pidiv180;
    7941345
    795     if (dec[0]=='-') decf = -decf;
    796 
    797     // calculs pupplémentaires pour se ramener
     1346    if (dec[0] == '-') decf = -decf;
     1347
     1348    // Calculs supplémentaires pour ramener les coordonnées horaires
    7981349    // à l'époque de l'observation
    7991350
    800     if (J2000)
     1351    if ( J2000 )
    8011352    {
    8021353        Precession(&arf, &decf);
     
    8131364    // on en informe l'utilisateur
    8141365
    815     Affiche("Coordonnées apparentes de l'objet :\n", true);
    816 
    817     Affiche("AD=" + ar  + "   Dec=" + dec +"\n", true);
    818 
    819 
    820     /*
    821     //Tests
    822     Azimut(arf, decf, &azi, &hau);
    823 
    824     hau=RefractionAtmospherique(hau);
    825 
    826     Affiche("Coordonnées rectangulaires liées au lieu d'observation :\n", true);
    827 
    828     printf("Azimut = %s   Hauteur = %s\n", DHMS(azi*N180divPi,false).c_str(), DHMS(hau*N180divPi, false).c_str());
    829     */
     1366    AfficherLog("Coordonnées apparentes de l'objet :\n", true);
     1367
     1368    AfficherLog("AD=" + ar  + "   Dec=" + dec +"\n", true);
     1369
    8301370
    8311371    // On transmet les coordonnées au pilote BAO
     
    8351375        *client_socket << "<newSwitchVector device=\"BAO\" name=\"ON_COORD_SET\">";
    8361376        *client_socket << "<oneSwitch name=\"TRANSIT\">";
    837         if (Transit) *client_socket << "On";
    838         else *client_socket << "Off";
     1377        (Transit) ? *client_socket << "On" : *client_socket << "Off";
    8391378        *client_socket << "</oneSwitch>";
    8401379
    8411380        *client_socket << "<oneSwitch name=\"TRACKING\">";
    842         if (Transit)  *client_socket << "Off";
    843         else *client_socket << "On";
     1381        (Transit) ? *client_socket << "Off" : *client_socket << "On";
    8441382        *client_socket << "</oneSwitch>";
    8451383        *client_socket << "</newSwitchVector>";
    8461384
    847         if (!VerifReponse("name=\"ON_COORD_SET\""))
    848         {
    849             Erreur("Le changement de mode TRANSIT/TRACKING a échoué.\n\n");
     1385        if (!VerifReponse("name=\"ON_COORD_SET\"", NULL))
     1386        {
     1387            ErreurLog("Le changement de mode TRANSIT/TRACKING a échoué.\n\n");
    8501388
    8511389            return false;
     
    8611399        *client_socket << "</newNumberVector>";
    8621400
    863         if (!VerifReponse("name=\"EQUATORIAL_EOD_COORD_REQUEST\""))
    864         {
    865             Erreur("Le transfert des coordonnées de l'objet a échoué.\n\n");
     1401        if (!VerifReponse("name=\"EQUATORIAL_EOD_COORD_REQUEST\"", NULL))
     1402        {
     1403            ErreurLog("Le transfert des coordonnées de l'objet a échoué.\n\n");
    8661404
    8671405            return false;
     
    8701408    catch ( SocketException& e)
    8711409    {
    872         Erreur("Exception was caught:" + e.description() + "\n");
    873         return false;
    874     }
    875 
    876     Affiche("Les nouvelles coordonnées AD=" + ar + " Dec=" + dec, true);
    877     Affiche(" ont été envoyées au pilote indi_BAO.\n\n", true);
     1410        ErreurLog("Exception was caught:" + e.description() + "\n");
     1411
     1412        return false;
     1413    }
     1414
     1415    AfficherLog("Les nouvelles coordonnées AD=" + ar + " Dec=" + dec, true);
     1416    AfficherLog(" ont été envoyées au pilote indi_BAO.\n\n", true);
     1417
    8781418    return true;
    8791419}
    8801420
    881 
    882 
    8831421/**************************************************************************************
    8841422** Se connecte ou se déconnecte au pilote indi_BAO
     1423**
    8851424***************************************************************************************/
    8861425
     
    8911430        *client_socket << "<newSwitchVector device=\"BAO\" name=\"CONNECTION\">";
    8921431
    893         if (connect) *client_socket << "<oneSwitch name=\"CONNECT\">";
    894         else *client_socket << "<oneSwitch name=\"DISCONNECT\">";
     1432        (connect) ? *client_socket << "<oneSwitch name=\"CONNECT\">" : *client_socket << "<oneSwitch name=\"DISCONNECT\">";
    8951433
    8961434        *client_socket << "On";
     
    9001438        if (connect)
    9011439        {
    902             if (!VerifReponse("BAORadio is online"))
     1440            if (!VerifReponse("BAORadio is online", NULL))
    9031441            {
    904                 Erreur("La connexion a échoué.\n\n");
     1442                ErreurLog("La connexion a échoué.\n\n");
    9051443
    9061444                return false;
     
    9091447        else
    9101448        {
    911             if (!VerifReponse("BAORadio is offline"))
     1449            if (!VerifReponse("BAORadio is offline", NULL))
    9121450            {
    913                 Erreur("La déconnexion a échoué.\n\n");
     1451                ErreurLog("La déconnexion a échoué.\n\n");
    9141452
    9151453                return false;
     
    9201458    catch ( SocketException& e )
    9211459    {
    922         Erreur("Exception was caught:" + e.description() + "\n");
     1460        ErreurLog("Exception was caught:" + e.description() + "\n");
     1461
    9231462        return false;
    9241463    }
     
    9261465    if (connect)
    9271466    {
    928         Affiche("La connexion a été établie avec le pilote indi_BAO.\n\n", true);
     1467        AfficherLog("La connexion a été établie avec le pilote indi_BAO.\n\n", true);
     1468
     1469        // Au moment de la connexion avec le driver indi_BAO
     1470        // On transmet les paramÚtres du lieu de l'observation, le mode de suivi
     1471        // ainsi que la méthode d'alignement utilisée
     1472
     1473        usleep(500000);
    9291474
    9301475        EnvoyerCoordGeographiques();
     1476
     1477        EnvoyerPressionTemperature();
     1478
     1479        EnvoyerDelaisModesTransitEtTracking();
     1480
     1481        EnvoyerMethodeAlignement();
    9311482    }
    9321483    else
    9331484    {
    934         Affiche("BAOcontrol s'est bien déconnecté du pilote indi_BAO.\n\n", true);
     1485        AfficherLog("BAOcontrol s'est bien déconnecté du pilote indi_BAO.\n\n", true);
    9351486    }
    9361487
    9371488    return true;
    9381489}
    939 
    940 
    941 
    9421490
    9431491
     
    10611609bool ServerDummy::ChargementParametres(string fileName)
    10621610{
    1063     string section;
     1611     string section;
    10641612    string key;
    10651613    char * value;
     
    10671615
    10681616
    1069 
    1070     Affiche("Lecture du fichier de configuration 'params' :\n\n", true);
     1617    // Si le fichier n'existe pas -> on sort
     1618
     1619    if (!is_readable(fileName)) return false;
     1620
     1621
     1622    AfficherLog("Lecture du fichier de configuration 'params' :\n\n", true);
    10711623
    10721624
    10731625    /////////////////////////////////////////
    1074     // Rubrique Coodonnées géographiques
     1626    // Rubrique Coordonnées géographiques
    10751627
    10761628    section = "coordonnees geographiques";
     
    10821634    {
    10831635        LatitudeChar = (string)value;
    1084         delete [] value;
    1085         Affiche("latitude = " + LatitudeChar +"\n", true);
     1636        SAFEDELETE_TAB(value);
     1637        AfficherLog("latitude = " + LatitudeChar +"\n", true);
    10861638    }
    10871639    else
    10881640    {
    1089         Erreur("La latitude est incorrecte !\n");
     1641        ErreurLog("La latitude est incorrecte !\n");
     1642
    10901643        return false;
    10911644    }
     
    10981651    {
    10991652        LongitudeChar = (string)value;
    1100         delete [] value;
    1101         Affiche("longitude = " + LongitudeChar +"\n\n", true);
     1653        SAFEDELETE_TAB(value);
     1654        AfficherLog("longitude = " + LongitudeChar +"\n\n", true);
    11021655    }
    11031656    else
    11041657    {
    1105         Erreur("La longitude est incorrecte !\n");
     1658        ErreurLog("La longitude est incorrecte !\n");
     1659
    11061660        return false;
    11071661    }
     
    11181672    {
    11191673        Serveur = (string)value;
    1120         delete [] value;
    1121         Affiche("serveur = " + Serveur +"\n", true);
     1674        SAFEDELETE_TAB(value);
     1675        AfficherLog("serveur = " + Serveur +"\n", true);
    11221676    }
    11231677    else
    11241678    {
    1125         Erreur("Nom du serveur invalide !\n");
    1126         return false;
    1127     }
    1128 
     1679        ErreurLog("Nom du serveur invalide !\n");
     1680
     1681        return false;
     1682    }
     1683
     1684    /////////////////////////////////////////
     1685    // Port de connexion du serveur Indi
    11291686
    11301687    key = "port";
     
    11331690    {
    11341691        Port = (string)value;
    1135         delete [] value;
    1136         Affiche("port = " + Port +"\n\n", true);
     1692        SAFEDELETE_TAB(value);
     1693        AfficherLog("port = " + Port +"\n\n", true);
    11371694    }
    11381695    else
    11391696    {
    1140         Erreur("Numéro de port incorrect !\n");
     1697        ErreurLog("Numéro de port incorrect !\n");
     1698
    11411699        return false;
    11421700    }
     
    11531711    {
    11541712        Pression = atof(value);
    1155         delete [] value;
     1713        SAFEDELETE_TAB(value);
    11561714        os << "pression = " << Pression << endl;
    1157         Affiche(&os, true);
     1715        AfficherLog(&os, true);
    11581716    }
    11591717    else
    11601718    {
    1161         os << "La pression atmosph&rique est incorrecte !" << endl;
    1162         Erreur(&os);
     1719        os << "La pression atmosphérique est incorrecte !" << endl;
     1720        ErreurLog(&os);
     1721
    11631722        return false;
    11641723    }
     
    11681727    if (readINI(section.c_str(), key.c_str(), &value, fileName.c_str()))
    11691728    {
    1170         Temperature=atof(value);
    1171         delete [] value;
     1729        Temperature = atof(value);
     1730        SAFEDELETE_TAB(value);
    11721731        os << "température = " << Temperature << endl << endl;
    1173         Affiche(&os, true);
     1732        AfficherLog(&os, true);
    11741733    }
    11751734    else
    11761735    {
    1177         Erreur("La température est incorrecte !\n");
    1178         return false;
    1179     }
     1736        ErreurLog("La température est incorrecte !\n");
     1737
     1738        return false;
     1739    }
     1740
     1741    /////////////////////////////////////////
     1742    // Rubrique alignement
     1743
     1744    section = "alignement";
     1745
     1746    key = "methode_alignement";
     1747
     1748    if (readINI(section.c_str(), key.c_str(), &value, fileName.c_str()))
     1749    {
     1750        AfficherLog("methode d'alignement = " + (string)value + "\n", true);
     1751        switch (value[0])
     1752        {
     1753        case 's' :
     1754        case 'S' :
     1755            MethodeAlignement = SIMPLE;
     1756            break;
     1757
     1758        case 'a' :
     1759        case 'A' :
     1760            MethodeAlignement = AFFINE;
     1761            break;
     1762
     1763        case 't' :
     1764        case 'T' :
     1765            MethodeAlignement = TAKI;
     1766            break;
     1767        }
     1768
     1769        SAFEDELETE_TAB(value);
     1770    }
     1771    else
     1772    {
     1773        ErreurLog("Le paramÚtre methode_alignement est incorrect !\n");
     1774
     1775        return false;
     1776    }
     1777
    11801778
    11811779
     
    11901788    {
    11911789        Transit = (strstr(value, "transit") != NULL);
    1192         Affiche("mode suivi = " + (string)value + "\n", true);
    1193         delete [] value;
     1790        AfficherLog("mode suivi = " + (string)value + "\n", true);
     1791        SAFEDELETE_TAB(value);
    11941792    }
    11951793    else
    11961794    {
    1197         Erreur("Le paramÚtre mode est incorrect !\n");
     1795        ErreurLog("Le paramÚtre mode suivi est incorrect !\n");
     1796
    11981797        return false;
    11991798    }
     
    12051804    if (readINI(section.c_str(), key.c_str(), &value, fileName.c_str()))
    12061805    {
    1207         delaitransit=atoi(value);
    1208         delete [] value;
     1806        delaitransit = atoi(value);
     1807        SAFEDELETE_TAB(value);
    12091808        os << "delai transit = " << delaitransit << " sec" << endl;
    1210         Affiche(&os, true);
     1809        AfficherLog(&os, true);
    12111810    }
    12121811    else
    12131812    {
    1214         Erreur("Le paramÚtre delai_transit est incorrect !\n");
     1813        ErreurLog("Le paramÚtre delai_transit est incorrect !\n");
     1814
    12151815        return false;
    12161816    }
     
    12211821    if (readINI(section.c_str(), key.c_str(), &value, fileName.c_str()))
    12221822    {
    1223         delaitracking=atoi(value);
    1224         delete [] value;
     1823        delaitracking = atoi(value);
     1824        SAFEDELETE_TAB(value);
    12251825        os << "delai tracking = " << delaitracking << " sec" << endl << endl;
    1226         Affiche(&os, true);
     1826        AfficherLog(&os, true);
    12271827    }
    12281828    else
    12291829    {
    1230         Erreur("Le paramÚtre delai_tracking est incorrect !\n");
     1830        ErreurLog("Le paramÚtre delai_tracking est incorrect !\n");
     1831
    12311832        return false;
    12321833    }
     
    12431844    {
    12441845        ChoixCouleurs=atoi(value);
    1245         delete [] value;
     1846        SAFEDELETE_TAB(value);
    12461847    }
    12471848    else
    12481849    {
    12491850        /*os << "Le paramÚtre couleurs est incorrect !" << endl;
    1250         Erreur(os.str());
     1851        ErreurLog(os.str());
    12511852        return false;*/
    12521853    }
     
    12561857
    12571858
     1859
     1860/**************************************************************************************
     1861** Le fichier file existe-t-il et n'est-il pas vide ?
     1862**
     1863**************************************************************************************/
     1864
     1865bool ServerDummy::is_readable( const string & file )
     1866{
     1867    ifstream fichier( file.c_str() );
     1868    if (fichier.fail()) return false;
     1869
     1870    // sauvegarder la position courante
     1871
     1872 //   long pos = fichier.tellg();
     1873
     1874    // se placer en fin de fichier
     1875
     1876    fichier.seekg( 0 , ios_base::end );
     1877
     1878    // récupérer la nouvelle position = la taille du fichier
     1879
     1880    long size = fichier.tellg();
     1881
     1882    return (size > 0);
     1883}
     1884
     1885
  • BAORadio/libindi/libindi/Indi_Stellarium/src/ServerBAO.hpp

    r623 r677  
    3030#include <string.h>
    3131#include <sstream>
    32 #include "ClientSocket.h"
    33 #include "SocketException.h"
     32#include "../../communs/ClientSocket.h"
     33#include "../../communs/SocketException.h"
    3434#include <stdio.h>
    3535#include <stdlib.h>
    3636#include <pthread.h>
    3737#include <X11/Xlib.h>
    38 #include "filetools.h"
    39 #include "astro.h"
     38#include "../../communs/const.h"
     39#include "../../communs/astro.h"
     40#include "../../communs/logs.h"
     41#include "../../communs/alignement.h"
    4042#include "math.h"
    4143#include <time.h>
     
    4446
    4547
    46 // couleurs utilisées dans le terminal
    47 
    48 #define red1 "\033[0;31m"
    49 #define blue1 "\033[0;34m"
    50 #define green1 "\033[0;32m"
    51 #define black1 "\033[0;30m"
    52 #define grey1 "\033[1;30m"
    53 #define red2 "\033[1;31m"
    54 #define blue2 "\033[1;34m"
    55 #define green2 "\033[1;32m"
    56 #define black2 "\033[1;30m"
    57 #define grey2 "\033[1;37m"
    58 
    59 
    60 // limites des tableaux
    61 
    62 #define MAXLOG 1000
    63 #define MAXOBJETS 100
    64 #define MAXANTENNES 50
    65 
    66 
    67 //dimensions de la fenêtre graphique
    68 
    69 #define haut_fenetre 10+22*10
    70 #define larg_fenetre 605
    71 
    7248using namespace std;
    7349
    7450
     51// ParamÚtres des étoiles utilisées pour l'alignement des antennes
     52
     53struct DefEtoiles
     54{
     55    string nom;                         // Nom de l'objet
     56    string cons;                        // Nom de la constellation
     57    double ad;                          // Ascension droite J2000 de l'objet (en rad)
     58    double de;                          // déclinaison J2000 de l'objet (en rad)
     59    double az;                          // Azimut (en rad)
     60    double ha;                          // hauteur au-dessus de l'horizon (en rad)
     61    double mag;                         // magnitude
     62    bool   selectionnee;                // l'objet a-t-il été sélectionné pour calibrer l'antenne ?
     63};
     64
     65
     66
     67// structure définissant les paramÚtres des antennes
     68
    7569struct DefAntenne
    7670{
    77     unsigned char ip;                   // Adresse ip d'une antenne
     71    unsigned char ip;                   // Adresse ip d'une antenne. Seul le dernier nombre nous intéresse
    7872
    79     char ok;                            // actuellement disponible ?
     73    char ok;                            // actuellement disponible ?
     74                                        // 0 = antenne non connectée
     75                                        // 1 = antenne connectée fonctionnant normalement
     76                                        // 2 = antenne connectée mais présentant un défaut
     77
     78    Alignement *AlignementAntenne;      // Contient les paramÚtres d'alignement de l'antenne définie par cette structure 
    8079};
    8180
    82 // objets stockés dans le fichier de mouvements
     81
     82
     83// objets ou zone du ciel stockés dans le fichier des mouvements planifiés
     84// Se reporter à la notice de la commande run pour savoir comment utiliser ces fichiers de mouvement
    8385
    8486struct DefObjets
    8587{
    86     double JJ;                          // Jour julien où le télescope doit aller pointer vers l'objet
     88    double JJ;                          // Date julienne du début de l'observation de l'objet i défini dans le fichier de mouvements
    8789    double Duree;                       // Durée de l'observation de l'objet en sec
    88     string ad;                          // Ascension droite J2000 de l'objet
    89     string de;                          // déclinaison J2000 de l'objet
    90     bool exec;                          // En cours d'exécution ?
     90    string ad;                          // Ascension droite de l'objet dans le repÚre J2000
     91    string de;                          // Déclinaison de l'objet dans le repÚre J2000
     92    bool exec;                          // L'objet est-il actuellement observé ?
    9193};
    9294
     
    9496//! Telescope server class for a virtual telescope that requires no physical device.
    9597//! Useful for remote connection testing.
    96 class ServerDummy : public Server, public Astro
     98class ServerDummy : public Server2, public Astro, public Logs
    9799{
    98100public:
     
    108110        void rouler();
    109111        void LireReponse();
    110         bool VerifReponse(string reponseattendue);
     112        bool VerifReponse(string reponseattendue, string *Message);
    111113        void Update();
    112         bool EnvoyerCoordGeographiques();
    113         bool Park();
    114         bool Abort();
    115         bool Goto(string ar, string dec, bool Transit, bool J2000);
    116         bool Connect(bool connect);
     114     bool Connect(bool connect);
     115    bool EnvoyerCoordGeographiques();
     116    bool EnvoyerPressionTemperature();
     117    bool EnvoyerDelaisModesTransitEtTracking();
     118    bool EnvoyerMethodeAlignement();
     119    bool EnvoyerCommande(string commande);
     120    bool Park();
     121    bool Abort();
     122    bool Goto(string ar, string dec, bool Transit, bool J2000);
     123    bool AlignementAntenneIP(string ip);
     124   
     125    bool AlignementIP(string ip);
     126    bool AlignementDelta(string delta, bool azimut);
     127    bool ValidationAlignement();
     128    bool SauvegardeAlignement();
     129    bool ResetAlignement();
     130    bool VitesseAlignement(int vit);
    117131        bool Decomposition(string chaine, char type, float *a1, float *a2, float *a3);
    118132        int  readline (FILE * pfile, char *tab);
    119133        bool ChargementParametres(string fileName);
     134       
     135        bool is_readable( const string & file );
    120136       
    121137private:
     
    126142        long long int next_pos_time;
    127143
    128         // Variables globales
     144       // Variables globales
    129145
    130            XFontStruct * fd;                           // Police de caractÚres dans la fenêtre graphique
     146    XFontStruct * fd;                           // Police de caractÚres utilisée dans la fenêtre graphique
    131147
    132            char ChoixCouleurs;                         // 1-pour un terminal à fond blanc    2-pour un terminal à fond noir
     148    string logs[MAXLOG];                        // Sauvegarde de toutes les actions et réponses dans un tableau logs
    133149
    134            string logs[MAXLOG];                        // Sauvegarde de toutes les actions et réponses dans un tableau logs
     150    int delaitransit;                           // Délai entre deux actualisations de la position en mode transit
     151    int delaitracking;                          // Délai entre deux actualisations de la position en mode tracking
     152    int lognum;                                 // Nbre d'enregistrements dans le tableau logs
     153    int numAntennes;                            // Nbre d'antennes connectées
     154    int numobjets;                              // Nbre d'objets dans le dernier fichier de mouvements chargé
     155    int runnum;                                 // Numéro de l'objet actuellement visé dans le fichier de mouvement
     156    int numEtoiles;                             // Nbre d'étoiles utilisées pour la procédure d'alignement des antennes
     157    int MethodeAlignement;                      // Méthode d'alignement utilisée
    135158
    136            int delaitransit;                            // Délai entre deux actualisations de la position en mode transit
    137            int delaitracking;                           // Délai entre deux actualisations de la position en mode tracking
    138            int lognum;                                  // Nbre d'enregistrements dans le tableau logs
    139            int numAntenne;                              // Nbre d'antennes connectées
    140            int numobjets;                               // Nbre d'objets dans le dernier fichier de mouvements chargé
    141            int runnum;                                  // Numéro de l'objet actuellement visé dans le fichier de mouvement
    142159
    143            double Pression;                             // Pression atmosphérique en mBar
    144            double Temperature;                  // température de l'atmosphÚre
     160    double Pression;                            // Pression atmosphérique en mbar
     161    double Temperature;                         // température de l'atmosphÚre en °C
    145162
    146            bool NoExit;                         // A-t-on tapé exit pour sortir ? Permet de fermer le thread à ce moment-là
    147            bool Transit;                                // Si oui, le mode transit est activé, sinon, c'est le mode tracking
    148            bool run;                                    // execute actuellement un fichier de mouvements
    149            bool exitrun;                                // doit-on sortir du programme à la fin de l'execution de la commande run ?
    150            bool J2000;                                  // est-ce que les coordonnées du fichier de mouvements sont en coordonnées J2000 ?
     163    bool NoExit;                                // A-t-on tapé exit pour sortir ? Permet de fermer le thread à ce moment-là
     164    bool Transit;                               // Si oui, le mode transit est activé, sinon, c'est le mode tracking
     165    bool run;                                   // exécute actuellement un fichier de mouvements
     166    bool exitrun;                               // doit-on sortir du programme à la fin de l'exécution de la commande run ?
     167    bool J2000;                                 // est-ce que les coordonnées du fichier de mouvements sont en coordonnées J2000 ?
     168    bool ModificationAlignement;                // Est-ce que l'une des antennes est en cours d'alignement et est-ce qu'un paramÚtre
     169                                                // d'alignement à changé ?
    151170
    152            struct DefAntenne *Antennes;         // Sauvegarde de la situation actuelle de l'antenne i
    153            struct DefObjets  *objets;                   // Liste des objets chargés depuis un fichier de mouvements
     171    struct DefAntenne *Antennes;                // Sauvegarde de la situation actuelle de l'antenne i
     172    struct DefObjets  *objets;                  // Liste des objets chargés depuis un fichier de mouvements
     173    struct DefEtoiles *Etoiles;                 // Liste des étoiles servant à la procédure d'alignement des antennes
    154174
    155            string LatitudeChar;                 // Latitude du lieu d'observation. Chargée depuis le fichier de configuration
    156            string LongitudeChar;                        // Longitude du lieu d'observation. Chargée depuis le fichier de configuration
    157            string Serveur;                              // Nom ou IP du serveur faisant tourner indi_BAO. Par defaut c'est localhost
    158            string Port;                                 // Port utilisé pour connecter le serveur indi_BAO
     175    string LatitudeChar;                        // Latitude du lieu d'observation. Chargée depuis le fichier de configuration
     176    string LongitudeChar;                       // Longitude du lieu d'observation. Chargée depuis le fichier de configuration
     177    string Serveur;                             // Nom ou IP du serveur faisant tourner indi_BAO. Par defaut contient 'localhost'
     178    string Port;                                // Port utilisé pour connecter le serveur indi_BAO
    159179
    160            ClientSocket *client_socket;         // Socket permettant la connexion avec le pilote indi_BAO
     180    ClientSocket *client_socket;                // Socket permettant la connexion avec le pilote indi_BAO
    161181
    162            Display * d;                         // contexte graphique
    163            Window w;                                    // fenêtre graphique
    164            Pixmap db;                                   // copie de la fenêtre pour permettre une actualisation sans scintillement
    165            GC noir, vert, rouge, gris;                  // couleurs utilisées dans la fenêtre graphique
     182    Display * d;                                // contexte graphique
     183    Window w;                                   // fenêtre graphique
     184    Pixmap db;                                  // copie de la fenêtre pour permettre une actualisation sans scintillement
     185   
     186    GC noir, vert, rouge, gris;                 // couleurs utilisées dans la fenêtre graphique
    166187};
    167188
  • BAORadio/libindi/libindi/Indi_Stellarium/src/Socket2.hpp

    r667 r677  
    7171long long int GetNow(void);
    7272
    73 class Server;
     73class Server2;
    7474
    75 class Socket
     75class Socket2
    7676{
    7777public:
    78         virtual ~Socket(void) { hangup(); }
     78        virtual ~Socket2(void) { hangup(); }
    7979        void hangup(void);
    8080        virtual void prepareSelectFds(fd_set &read_fds, fd_set &write_fds, int &fd_max) = 0;
     
    8888       
    8989protected:
    90         Socket(Server &server, SOCKET fd) : server(server), fd(fd) {}
    91         Server & server;
     90        Socket2(Server2 &server, SOCKET fd) : server(server), fd(fd) {}
     91        Server2 & server;
    9292       
    9393#ifdef WIN32
     
    115115private:
    116116        // no copying
    117         Socket(const Socket&);
    118         const Socket &operator=(const Socket&);
     117        Socket2(const Socket2&);
     118        const Socket2 &operator=(const Socket2&);
    119119};
    120120
  • BAORadio/libindi/libindi/bao.sh

    r643 r677  
    1919cd libindi_build
    2020make clean
    21 cd ../BAOControl
     21cd ../BAOcontrol
    2222make clean
     23rm -f *.o *.cpp~ *.h~  BAOtest
    2324cd ../BAOTest
    2425make clean
     
    5152echo ;
    5253
    53 cd ../BAOControl
     54cd ../BAOcontrol
     55qmake -project
     56qmake
    5457make
    55 make install
     58cp BAOcontrol /usr/bin
    5659echo ;
    5760echo ;
     
    7073if  [ "$1" == "install" ] && [ "$2" == "config" ]
    7174then
    72 cp BAOControl/baocontrol_params "/home/"$USER
     75cp BAOcontrol/baocontrol_params "/home/"$USER
    7376echo "Le fichier baocontrol_params a été copié dans le répertoire /home/"$USER;
    74 cp BAOControl/bao_catalogue.dat "/home/"$USER
     77cp BAOcontrol/bao_catalogue.dat "/home/"$USER
    7578echo "Le fichier bao_catalogue.dat a été copié dans le répertoire /home/"$USER;
    7679fi
  • BAORadio/libindi/libindi/communs/ClientSocket.cpp

    r644 r677  
    6464
    6565        if (! Socket::connect((std::string)"192.168.0.1", 8000)) {
    66             std::cout << "connect impossible.\n";
     66            std::cout << "connect impossible 192.168.0.1.\n";
     67           // Socket::shutdown();
     68            if (! Socket::connect((std::string)"127.0.0.1", 8000)) {
     69            std::cout << "connect impossible 127.0.0.1.\n";
    6770            Socket::shutdown();
    68         } else {
     71            } else std::cout << "Reconnexion reussie.\n";
     72        }
     73         else {
    6974            std::cout << "Reconnexion reussie.\n";
    7075        }
  • BAORadio/libindi/libindi/communs/alignement.cpp

    r648 r677  
    4545    for (int i=0; i< MAXALIGNEMENTANTENNE; i++)
    4646    {
    47         ad[i]         = 0.0;
    48         de[i]         = 0.0;
    49         delta_ad[i]   = 0;
    50         delta_de[i]   = 0;
    51         tsl[i]        = 0.0;
     47        ad[i]                           = 0.0;
     48        de[i]                           = 0.0;
     49        delta_ad[i]                     = 0.0;
     50        delta_de[i]                     = 0.0;
     51        tsl[i]                          = 0.0;
     52        SelectionnePourCalculMatrice[i] = false;
    5253    }
    5354
     
    6061
    6162    delta_az_polar    = 0;
     63
     64    // Initialisation des deltas sur les axes az et ha
     65    // pour gérer la raquette hors procédure d'alignement
     66
     67    deltaAZ           = 0;
     68    deltaHA           = 0;
    6269
    6370    // Nbre de points (de mesures) actuellement disponibles pour
     
    161168    double temp[4][4];
    162169    double UnitVect[4][4];
    163 
     170   
    164171    temp[1][1] = p2.x - p1.x;
    165172    temp[2][1] = p3.x - p1.x;
     
    176183    UnitVect[2][1] = pow(UnitVect[1][1], 2.0) + pow(UnitVect[1][2], 2.0) + pow (UnitVect[1][3], 2.0);
    177184    UnitVect[2][2] = sqrt(UnitVect[2][1]);
     185    UnitVect[2][3] = 0.0;
    178186    if (UnitVect[2][2] != 0.0) UnitVect[2][3] = 1.0 / UnitVect[2][2];
    179187
    180     for (char i=1; i<=2; i++) for (char j=1; j<=3; j++) GETLMN[i][j] = temp[i][j];
     188    for (int i=1; i<=2; i++) for (int j=1; j<=3; j++) GETLMN[i][j] = temp[i][j];
    181189
    182190    GETLMN[3][1] = UnitVect[2][3] * UnitVect[1][1];
     
    192200***************************************************************************************/
    193201
    194 int Alignement::Calculer_Matrice_Taki(double x, double y, Coord a1, Coord a2, Coord a3, Coord m1, Coord m2, Coord m3)
     202int Alignement::Calculer_Matrice_Taki(double x, double y, Coord aa1, Coord aa2, Coord aa3, Coord mm1, Coord mm2, Coord mm3)
    195203{
    196204    double Det;
     
    198206    double EQLMN2[4][4];
    199207    double EQMI_T[4][4];
    200 
     208   
     209    Coord a1, a2, a3, m1, m2, m3;
     210   
     211    AzHa2XY(aa1.x, aa1.y, &a1.x, &a1.y);
     212    AzHa2XY(aa2.x, aa2.y, &a2.x, &a2.y);
     213    AzHa2XY(aa3.x, aa3.y, &a3.x, &a3.y);
     214
     215    AzHa2XY(mm1.x, mm1.y, &m1.x, &m1.y);
     216    AzHa2XY(mm2.x, mm2.y, &m2.x, &m2.y);
     217    AzHa2XY(mm3.x, mm3.y, &m3.x, &m3.y);
     218   
    201219    //construit les matrices EQLMN1 & 2
    202220
     221    Calculer_Matrice_LMN(m1, m2, m3);
     222
     223    for (int i=1; i<=3; i++) for (int j=1; j<=3; j++) EQLMN1[i][j]=GETLMN[i][j];
     224
    203225    Calculer_Matrice_LMN(a1, a2, a3);
    204226
    205     for (char i=1; i<=3; i++) for (char j=1; j<=3; j++) EQLMN1[i][j]=GETLMN[i][j];
    206 
    207     Calculer_Matrice_LMN(m1, m2, m3);
    208 
    209     for (char i=1; i<=3; i++) for (char j=1; j<=3; j++) EQLMN2[i][j]=GETLMN[i][j];
     227    for (int i=1; i<=3; i++) for (int j=1; j<=3; j++) EQLMN2[i][j]=GETLMN[i][j];
    210228
    211229    // Calcule le déterminant de EQLMN1
     
    266284    else
    267285    {
    268         return  PointSitueDansSurfaceTriangle(x, y, a1.x, a1.y, a2.x, a2.y, a3.x, a3.y);
     286        return  PointSitueDansSurfaceTriangle(x, y, aa1.x, aa1.y, aa2.x, aa2.y, aa3.x, aa3.y);
    269287    }
    270288}
     
    278296    // vect.z = 1
    279297
    280     result->x = VECT_OFFSET.x + ((vect.x * MATRICE[1][1]) + (vect.y * MATRICE[2][1]) + (vect.z * MATRICE[3][1]));
    281     result->y = VECT_OFFSET.y + ((vect.x * MATRICE[1][2]) + (vect.y * MATRICE[2][2]) + (vect.z * MATRICE[3][2]));
    282     result->z = VECT_OFFSET.z + ((vect.x * MATRICE[1][3]) + (vect.y * MATRICE[2][3]) + (vect.z * MATRICE[3][3]));
     298    result->x = -VECT_OFFSET.x + ((vect.x * MATRICE[1][1]) + (vect.y * MATRICE[2][1]) + (vect.z * MATRICE[3][1]));
     299    result->y = -VECT_OFFSET.y + ((vect.x * MATRICE[1][2]) + (vect.y * MATRICE[2][2]) + (vect.z * MATRICE[3][2]));
     300    result->z = -VECT_OFFSET.z + ((vect.x * MATRICE[1][3]) + (vect.y * MATRICE[2][3]) + (vect.z * MATRICE[3][3]));
    283301}
    284302
     
    307325***************************************************************************************/
    308326
    309 int Alignement::Calculer_Matrice_Affine( double x, double y, Coord a1, Coord a2, Coord a3, Coord m1, Coord m2, Coord m3)
     327int Alignement::Calculer_Matrice_Affine( double x, double y, Coord aa1, Coord aa2, Coord aa3, Coord mm1, Coord mm2, Coord mm3)
    310328{
    311329    double Det;
     
    314332    double EQMQ[4][4];
    315333
     334    Coord a1, a2, a3, m1, m2, m3, c1, c2;
     335   
     336    AzHa2XY(aa1.x, aa1.y, &a1.x, &a1.y);
     337    AzHa2XY(aa2.x, aa2.y, &a2.x, &a2.y);
     338    AzHa2XY(aa3.x, aa3.y, &a3.x, &a3.y);
     339
     340    AzHa2XY(mm1.x, mm1.y, &m1.x, &m1.y);
     341    AzHa2XY(mm2.x, mm2.y, &m2.x, &m2.y);
     342    AzHa2XY(mm3.x, mm3.y, &m3.x, &m3.y);
     343   
     344    /*c1.x=(a1.x+a2.x+a3.x)/3.0;
     345    c1.y=(a1.y+a2.y+a3.y)/3.0;
     346   
     347    c2.x=(m1.x+m2.x+m3.x)/3.0;
     348    c2.y=(m1.y+m2.y+m3.y)/3.0;
     349   
     350    a1.x-=c1.x;
     351    a1.y-=c1.y;
     352    a2.x-=c1.x;
     353    a2.y-=c1.y;
     354    a3.x-=c1.x;
     355    a3.y-=c1.y;
     356   
     357    m1.x-=c2.x;
     358    m1.y-=c2.y;
     359    m2.x-=c2.x;
     360    m2.y-=c2.y;
     361    m3.x-=c2.x;
     362    m3.y-=c2.y;*/
     363   
     364   
     365   
     366   
    316367    //Construit les matrices EQMP et EQMQ
    317368
     369    Calculer_Matrice_GETPQ(m1, m2, m3);
     370
     371    for (int i=1; i<=3; i++) for (int j=1; j<=3; j++) EQMP[i][j]=GETPQ[i][j];
     372
    318373    Calculer_Matrice_GETPQ(a1, a2, a3);
    319374
    320     for (char i=1; i<=3; i++) for (char j=1; j<=3; j++) EQMP[i][j]=GETPQ[i][j];
    321 
    322     Calculer_Matrice_GETPQ(m1, m2, m3);
    323 
    324     for (char i=1; i<=3; i++) for (char j=1; j<=3; j++) EQMQ[i][j]=GETPQ[i][j];
     375    for (int i=1; i<=3; i++) for (int j=1; j<=3; j++) EQMQ[i][j]=GETPQ[i][j];
    325376
    326377    // Calcule l'inverse de EQMP
     
    349400    MATRICE[2][1] = (EQMI[2][1] * EQMQ[1][1]) + (EQMI[2][2] * EQMQ[2][1]);
    350401    MATRICE[2][2] = (EQMI[2][1] * EQMQ[1][2]) + (EQMI[2][2] * EQMQ[2][2]);
    351 
     402   
     403   
     404   
    352405    // Calcul du vecteur offset sur le ciel
    353406
    354     VECT_OFFSET.x = m1.x - ((a1.x * MATRICE[1][1]) + (a1.y * MATRICE[2][1]));
    355     VECT_OFFSET.y = m1.y - ((a1.x * MATRICE[1][2]) + (a1.y * MATRICE[2][2]));
    356 
    357     return 1;
     407    VECT_OFFSET.x =0.0;//m1.x - ((a1.x * MATRICE[1][1]) + (a1.y * MATRICE[2][1]));
     408    VECT_OFFSET.y =0.0;//m1.y - ((a1.x * MATRICE[1][2]) + (a1.y * MATRICE[2][2]));
     409
     410   if (x + y == 0 )
     411    {
     412        return 0;
     413    }
     414    else
     415    {
     416        return  PointSitueDansSurfaceTriangle(x, y, aa1.x, aa1.y, aa2.x, aa2.y, aa3.x, aa3.y);
     417    }
    358418}
    359419
     
    531591
    532592
    533 
     593double Alignement::Determinant()
     594{
     595    double Det;
     596   
     597    Det = MATRICE[1][1] * ((MATRICE[2][2] * MATRICE[3][3]) - (MATRICE[3][2] * MATRICE[2][ 3]));
     598    Det = Det - (MATRICE[1][2] * ((MATRICE[2][1] * MATRICE[3][3]) - (MATRICE[3][1] * MATRICE[2][3])));
     599    Det = Det + (MATRICE[1][3] * ((MATRICE[2][1] * MATRICE[3][2]) - (MATRICE[3][1] * MATRICE[2][2])));
     600
     601    return Det;
     602}
     603
     604
     605
     606void Alignement::AzHa2XY(double az, double ha, double *x, double *y)
     607{
     608    double r = Pidiv2 - ha;
     609
     610    *x = r * cos(az);
     611
     612    *y = r * sin(az);
     613}
    534614
    535615/**************************************************************************************
     
    541621{
    542622    double ta;
    543 
    544     ta = (((px2 * py1) - (px1 * py2)) ) + (((px3 * py2) - (px2 * py3))  ) + (((px1 * py3) - (px3 * py1))  );
     623   
     624    double pxx1, pyy1, pxx2, pyy2, pxx3, pyy3;
     625
     626    AzHa2XY(px1, py1, &pxx1, &pyy1);
     627
     628    AzHa2XY(px2, py2, &pxx2, &pyy2);
     629   
     630    AzHa2XY(px3, py3, &pxx3, &pyy3);
     631   
     632    ta = (((pxx2 * pyy1) - (pxx1 * pyy2)) ) + (((pxx3 * pyy2) - (pxx2 * pyy3))  ) + (((pxx1 * pyy3) - (pxx3 * pyy1))  );
    545633
    546634    return  fabs(ta) / 2.0;
     
    571659    AfficherLog(os.str().c_str(), true);
    572660
    573     if ( DistanceAngulaireEntre2Points(px, py, px1, py1) > 1.2 ) return false;
     661  /* if ( DistanceAngulaireEntre2Points(px, py, px1, py1) > 1.2 ) return false;
    574662    if ( DistanceAngulaireEntre2Points(px, py, px2, py2) > 1.2 ) return false;
    575     if ( DistanceAngulaireEntre2Points(px, py, px3, py3) > 1.2 ) return false;
     663    if ( DistanceAngulaireEntre2Points(px, py, px3, py3) > 1.2 ) return false;*/
    576664
    577665    return ( fabs(ta - t1 - t2 - t3) < 1e-10 );
     
    591679void Alignement::CalculerMatriceCorrection(double ar, double dec)
    592680{
    593     Coord c1, c2, c3, c4, m1, m2, m3, m4;
    594 
    595     double a1, b1, a2, b2;
     681    Coord c1, c2, c3, m1, m2, m3;
     682
     683    double a1, b1, a2, b2, a3, b3, a4, b4, a5, b5;
    596684
    597685    int map[MAXALIGNEMENTANTENNE];
     
    599687    stringstream os;
    600688
    601     int best1 = 0;
    602     int best2 = 0;
    603     int best3 = 0;
     689    int best1 = -1;
     690    int best2 = -1;
     691    int best3 = -1;
    604692
    605693
     
    612700    case SIMPLE :
    613701    {
    614         best1 = 1;
    615         best2 = 2;
    616         best3 = 3;
     702        best1 = 0;
     703        best2 = 1;
     704        best3 = 2;
    617705
    618706        for (int i=0; i<MAXALIGNEMENTANTENNE; i++) map[i] = i;
     
    629717        distances = new double [nbrcorrections+1];
    630718
    631         os << "Coordonnées visees : ad=" << DHMS(ar*N180divPi,true) << "  de=" << DHMS(dec*N180divPi,false) << "\n";
    632 
    633         Azimut(VerifAngle(ar-GetTSL()), dec, &a2, &b2);
    634 
    635         for (int i=1; i<=nbrcorrections; i++)
     719        os << "Coordonnées visees : ad=" << DHMS(ar * 15.0,true) << "  de=" << DHMS(dec,false) << "\n";
     720
     721        Azimut(ar * 15.0 * Pidiv180, dec * Pidiv180, &a2, &b2);
     722
     723        for (int i=0; i<nbrcorrections; i++)
    636724        {
    637             Azimut(VerifAngle(ad[i]-tsl[i]),de[i], &a1, &b1);
     725            Azimut(VerifAngle(ad[i]- tsl[i] + GetTSL() ),de[i], &a1, &b1);
    638726
    639727            distances[i] = DistanceAngulaireEntre2Points(a1, b1, a2, b2);
     
    642730        }
    643731
    644         for (int i=1; i<=nbrcorrections; i++)
     732        for (int i=0; i<nbrcorrections; i++)
    645733        {
    646             for (int j=i+1; j<=nbrcorrections; j++)
     734            for (int j=i+1; j<nbrcorrections; j++)
    647735            {
    648                 if (distances[j]<distances[i])
     736                if ( distances[j] < distances[i] )
    649737                {
    650                     double bout=distances[i];
    651                     distances[i]=distances[j];
    652                     distances[j]=bout;
    653 
    654                     int bout2=map[i];
    655                     map[i]=map[j];
    656                     map[j]=bout2;
     738                    double bout  = distances[i];
     739                    distances[i] = distances[j];
     740                    distances[j] = bout;
     741
     742                    int bout2 = map[i];
     743                    map[i]    = map[j];
     744                    map[j]    = bout2;
    657745                }
    658746            }
    659747        }
    660748
    661         for (int i=1; i<=nbrcorrections; i++)
     749        for (int i=0; i<nbrcorrections; i++)
    662750        {
    663             os << "Point " << map[i] << "  d=" << distances[i] << "\n";
     751            os << "Point " << map[i] << "  d=" << distances[i] * N180divPi << "°\n";
    664752        }
    665 
    666         for (int i=1; i<=nbrcorrections; i++)
     753       
     754        for (int i=0; i<nbrcorrections; i++)
    667755        {
    668             for (int j=i+1; j<=nbrcorrections; j++)
     756            for (int j=i+1; j<nbrcorrections; j++)
    669757            {
    670                 for (int k=j+1; k<=nbrcorrections; k++)
     758                for (int k=j+1; k<nbrcorrections; k++)
    671759                {
    672                     double a,b;
    673 
    674760                    os << "Triangle : " << map[i] << " " << map[j] << " " << map[k]  << "\n";
    675761
     
    678764                    os << ": az=" << DHMS(a2*N180divPi, false) << "  ha=" <<  DHMS(b2*N180divPi, false) << "\n";
    679765
    680                     os << "Etoile " << i ;
    681 
    682                     Azimut(VerifAngle(ad[map[i]]-tsl[map[i]]), de[map[i]], &a, &b);
    683 
    684                     os << ": az=" << DHMS(a*N180divPi, false) << "  ha=" <<  DHMS(b*N180divPi, false) << "\n";
    685 
    686                     os << "Etoile " << j ;
    687 
    688                     Azimut(VerifAngle(ad[map[j]]-tsl[map[j]]), de[map[j]], &a, &b);
    689 
    690                     os << ": az=" << DHMS(a*N180divPi, false) << "  ha=" <<  DHMS(b*N180divPi, false) << "\n";
    691 
    692                     os << "Etoile " << k ;
    693 
    694                     Azimut(VerifAngle(ad[map[k]]-tsl[map[k]]), de[map[k]], &a, &b);
    695 
    696                     os << ": az=" << DHMS(a*N180divPi, false) << "  ha=" <<  DHMS(b*N180divPi, false) << "\n";
     766                    os << "Etoile " << map[i] ;
     767
     768                    Azimut(VerifAngle(ad[map[i]] - tsl[map[i]] + GetTSL()), de[map[i]], &a3, &b3);
     769
     770                    os << ": az=" << DHMS(a3*N180divPi, false) << "  ha=" <<  DHMS(b3*N180divPi, false) << "\n";
     771
     772                    os << "Etoile " << map[j] ;
     773
     774                    Azimut(VerifAngle(ad[map[j]] - tsl[map[j]] + GetTSL()), de[map[j]], &a4, &b4);
     775
     776                    os << ": az=" << DHMS(a4*N180divPi, false) << "  ha=" <<  DHMS(b4*N180divPi, false) << "\n";
     777
     778                    os << "Etoile " << map[k] ;
     779
     780                    Azimut(VerifAngle(ad[map[k]] - tsl[map[k]] + GetTSL()), de[map[k]], &a5, &b5);
     781
     782                    os << ": az=" << DHMS(a5*N180divPi, false) << "  ha=" <<  DHMS(b5*N180divPi, false) << "\n";
    697783
    698784                    AfficherLog(&os, true);
    699785
    700                     if (PointSitueDansSurfaceTriangle(VerifAngle(ar-GetTSL()), dec,
    701                                                       VerifAngle(ad[map[i]]-tsl[map[i]]), de[map[i]],
    702                                                       VerifAngle(ad[map[j]]-tsl[map[j]]), de[map[j]],
    703                                                       VerifAngle(ad[map[k]]-tsl[map[k]]), de[map[k]]))
     786                    if (PointSitueDansSurfaceTriangle(a2, b2,
     787                                                      a3, b3,
     788                                                      a4, b4,
     789                                                      a5, b5))
    704790                    {
    705791                        best1=i;
     
    721807
    722808
    723     if ( best1 == 0 && best2 == 0 && best3 == 0 )
     809    if ( best1 == -1 && best2 == -1 && best3 == -1 )
    724810    {
    725811        if (MethodeAlignement == AFFINE || MethodeAlignement == TAKI)
     
    738824        os << "\nUtilisation du triangle : " << map[best1] << " " << map[best2] << " " << map[best3]  << "\n" ;
    739825
    740         if (MethodeAlignement == SIMPLE)
     826       // if (MethodeAlignement == SIMPLE)
    741827        {
    742828            c1.x = VerifAngle(ad[map[best1]] - tsl[map[best1]] + GetTSL());
     
    752838            c3.z = 1.0;
    753839        }
    754         else
     840    /*    else
    755841        {
    756             c1.x = VerifAngle(ad[map[best1]] - tsl[map[best1]]);
     842            c1.x = VerifAngle(ad[map[best1]] - tsl[map[best1]] + GetTSL());
    757843            c1.y = de[map[best1]];
    758844            c1.z = 1.0;
    759845
    760             c2.x = VerifAngle(ad[map[best2]] - tsl[map[best2]]);
     846            c2.x = VerifAngle(ad[map[best2]] - tsl[map[best2]] + GetTSL());
    761847            c2.y = de[map[best2]];
    762848            c2.z = 1.0;
    763849
    764             c3.x = VerifAngle(ad[map[best3]] - tsl[map[best3]]);
     850            c3.x = VerifAngle(ad[map[best3]] - tsl[map[best3]] + GetTSL());
    765851            c3.y = de[map[best3]];
    766852            c3.z = 1.0;
    767         }
    768 
    769 
    770         os << "Point 1 :  ho=" << DHMS(c1.x * N180divPi, false);
    771         os <<  "   de=" << DHMS(c1.y *N180divPi, false) <<"\n";
    772         os << "Point 2 :  ho=" << DHMS(c2.x * N180divPi, false);
    773         os <<  "   de=" << DHMS(c2.y * N180divPi, false) <<"\n";
    774         os << "Point 3 :  ho=" << DHMS(c3.x * N180divPi, false);
    775         os <<  "   de=" << DHMS(c3.y * N180divPi, false) <<"\n\n";
    776 
    777 
    778         m1.x = VerifAngle(c1.x + (double)delta_ad[map[best1]] * PasDeltaAD);
    779         m1.y = c1.y + (double)delta_de[map[best1]] * PasDeltaDe;
     853        }*/
     854     
     855        m1.x = VerifAngle(delta_ad[map[best1]] - tsl[map[best1]] + GetTSL());
     856        m1.y = delta_de[map[best1]];
    780857        m1.z = 1.0;
    781858
    782         m2.x = VerifAngle(c2.x + (double)delta_ad[map[best2]] * PasDeltaAD);
    783         m2.y = c2.y + (double)delta_de[map[best2]] * PasDeltaDe;
     859        m2.x = VerifAngle(delta_ad[map[best2]] - tsl[map[best2]] + GetTSL());
     860        m2.y = delta_de[map[best2]];
    784861        m2.z = 1.0;
    785862
    786         m3.x = VerifAngle(c3.x + (double)delta_ad[map[best3]] * PasDeltaAD);
    787         m3.y = c3.y + (double)delta_de[map[best3]] * PasDeltaDe;
     863        m3.x = VerifAngle(delta_ad[map[best3]] - tsl[map[best3]] + GetTSL());
     864        m3.y = delta_de[map[best3]];
    788865        m3.z = 1.0;
    789866    }
     
    799876    case AFFINE:
    800877        os << "Methode d alignement AFFINE\n";
    801         Matrice_ok = Calculer_Matrice_Affine( VerifAngle( ar - GetTSL() ), dec, c1, c2, c3 ,m1, m2, m3);
     878        Matrice_ok = Calculer_Matrice_Affine( VerifAngle( ar * 15.0 * Pidiv180 ), dec * Pidiv180, c1, c2, c3 ,m1, m2, m3);
    802879        break;
    803880    case TAKI:
    804881        os << "Methode d alignement TAKI\n";
    805         Matrice_ok = Calculer_Matrice_Taki  ( VerifAngle( ar - GetTSL() ), dec, c1, c2, c3 ,m1, m2, m3);
     882        Matrice_ok = Calculer_Matrice_Taki  ( VerifAngle( ar * 15.0 * Pidiv180 ), dec * Pidiv180, c1, c2, c3 ,m1, m2, m3);
    806883        break;
    807884    }
     
    814891    os << MATRICE[1][2] << "   \t" << MATRICE[2][2] << "    \t" << MATRICE[3][2] << "\n";
    815892    os << MATRICE[1][3] << "   \t" << MATRICE[2][3] << "    \t" << MATRICE[3][3] << "\n";
    816 
    817 
    818 
    819 
    820 
     893    os << "\nDeterminant :" << Determinant() << "\n";
     894
     895
     896    for (int i=0; i<nbrcorrections; i++) SelectionnePourCalculMatrice[i] = false;
     897   
     898    SelectionnePourCalculMatrice[map[best1]] = true;
     899    SelectionnePourCalculMatrice[map[best2]] = true;
     900    SelectionnePourCalculMatrice[map[best3]] = true;
     901   
    821902
    822903    //Vérifications supp
     
    885966
    886967    // sauvegarder la position courante
    887     long pos = fichier.tellg();
     968   // long pos = fichier.tellg();
    888969    // se placer en fin de fichier
    889970    fichier.seekg( 0 , std::ios_base::end );
     
    908989    stringstream os, os2;
    909990
    910     char *delta_az_polar_data = NULL;
     991    char *delta_az = NULL;
     992
     993    char *delta_ha = NULL;
    911994
    912995    char *ad_data = NULL;
     
    9241007    char *tsl_data = NULL;
    9251008
    926 
    9271009    if (!is_readable(fileName)) return false;
    9281010
     
    9331015    // On sélectionne la bonne antenne (à partir de son adresse ip).
    9341016
    935     if (IP.rfind(".") != string::npos) IP = IP.substr(IP.rfind(".")+1);
    936 
    937 
    938     os << "Alignement antenne ip x.x.x." << IP;
    939 
    940 
    941     //nbrcorrections = 0; TODO semble poser un problÚme
    942 
    943 
    944     for (int j=1; j < MAXALIGNEMENTANTENNE; j++)
     1017    os << "Alignement antenne ip " << IP;
     1018
     1019
     1020    nbrcorrections = 0;
     1021   
     1022    for (int j=0; j < MAXALIGNEMENTANTENNE; j++)
    9451023    {
    9461024        os2 << "ad " << j;
     
    9811059            // -> on les applique...
    9821060
    983             nbrcorrections = j;
    984 
    985             if (delta_ad[j] != atol(delta_ad_data) || delta_de[j] != atol(delta_de_data))
     1061           
     1062
     1063            if (delta_ad[nbrcorrections] != atof(delta_ad_data) || delta_de[nbrcorrections] != atof(delta_de_data))
    9861064            {
    987                 ad[j] = atof(ad_data);
    988 
    989                 de[j] = atof(de_data);
    990 
    991                 delta_ad[j] = atol(delta_ad_data);
    992 
    993                 delta_de[j] = atol(delta_de_data);
    994 
    995                 tsl[j] = atof(tsl_data);
    996 
    997                 os2 << "Correction antenne ip=" << IP <<  " ad=" << ad[j] << " de=" << de[j] << " deltaAD=" << delta_ad[j] << " deltaDe=" << delta_de[j] << " tsl=" << tsl[j] << "\n";
     1065                ad[nbrcorrections] = atof(ad_data);
     1066
     1067                de[nbrcorrections] = atof(de_data);
     1068
     1069                delta_ad[nbrcorrections] = atof(delta_ad_data);
     1070
     1071                delta_de[nbrcorrections] = atof(delta_de_data);
     1072
     1073                tsl[nbrcorrections] = atof(tsl_data);
     1074
     1075                os2 << "Correction antenne ip=" << IP <<  " ad=" << ad[nbrcorrections] << " de=" << de[nbrcorrections] << " deltaAD=" <<
     1076                delta_ad[nbrcorrections] << " deltaDe=" << delta_de[nbrcorrections] << " tsl=" << tsl[nbrcorrections] << "\n";
    9981077
    9991078                AfficherLog(&os2, true);
    10001079
    10011080                modificationAlignement = true;
    1002             }
     1081               
     1082                nbrcorrections++;
     1083            }           
    10031084        }
    10041085
     
    10141095    }
    10151096
    1016     os2 << "delta_az_polar";
    1017 
    1018     readINI((char*)os.str().c_str(), (char*)os2.str().c_str(), &delta_az_polar_data,  (char*)fileName.c_str());
     1097    os2 << "delta_az";
     1098
     1099    readINI((char*)os.str().c_str(), (char*)os2.str().c_str(), &delta_az,  (char*)fileName.c_str());
    10191100
    10201101    os2.str("");
    10211102
    1022     if (delta_az_polar_data)
    1023     {
    1024         if ( delta_az_polar != atol(delta_az_polar_data) )
     1103    if (delta_az)
     1104    {
     1105        if ( deltaAZ != atol(delta_az) )
    10251106        {
    1026             delta_az_polar = atol(delta_az_polar_data);
     1107            deltaAZ = atol(delta_az);
    10271108
    10281109            modificationAlignement = true;
     
    10301111    }
    10311112
     1113    os2 << "delta_ha";
     1114
     1115    readINI((char*)os.str().c_str(), (char*)os2.str().c_str(), &delta_ha,  (char*)fileName.c_str());
     1116
     1117    os2.str("");
     1118
     1119    if (delta_ha)
     1120    {
     1121        if ( deltaHA != atol(delta_ha) )
     1122        {
     1123            deltaHA= atol(delta_ha);
     1124
     1125            modificationAlignement = true;
     1126        }
     1127    }
     1128
    10321129    os2 << "alignment_method";
    10331130
     
    10351132
    10361133    os2.str("");
    1037 
    1038     /*  char chaine[100];
    1039     sprintf(chaine, "************** %s\n",alignment_method_data);
    1040       cout << chaine;*/
    10411134
    10421135    if (alignment_method_data)
     
    11021195    }
    11031196
    1104     SAFEDELETE_TAB(delta_az_polar_data);
     1197    SAFEDELETE_TAB(delta_az);
     1198
     1199    SAFEDELETE_TAB(delta_ha);
    11051200
    11061201    SAFEDELETE_TAB(alignment_method_data);
     
    11301225    //Enregistrement des corrections des l'antennes
    11311226
    1132     os << "Alignement antenne ip x.x.x." << IP;
     1227
     1228    os << "Alignement antenne ip " << IP;
    11331229    section = os.str();
    11341230    os.str("");
    1135 
    1136     os << "delta_az_polar";
    1137     key     = os.str();
    1138     os.str("");
    1139     os << delta_az_polar;
    1140     value = os.str();
    1141     os.str("");
    1142 
    1143     writeINI((char*)section.c_str(), (char*)key.c_str(), (char*)value.c_str(), (char*)fileName.c_str());
    11441231
    11451232    os << "align";
     
    11591246    os.str("");
    11601247
    1161 
    11621248    writeINI((char*)section.c_str(), (char*)key.c_str(), (char*)value.c_str(), (char*)fileName.c_str());
    11631249
    1164     /*    char chaine[100];
    1165     sprintf(chaine, "s************** %i\n",MethodeAlignement);
    1166        cout << chaine;*/
    1167 
    1168 
    1169     for (int j = 1; j <= MAXALIGNEMENTANTENNE; j++)
     1250    os << "delta_az";
     1251    key     = os.str();
     1252    os.str("");
     1253    os << deltaAZ;
     1254    value = os.str();
     1255    os.str("");
     1256
     1257    writeINI((char*)section.c_str(), (char*)key.c_str(), (char*)value.c_str(), (char*)fileName.c_str());
     1258
     1259    os << "delta_ha";
     1260    key     = os.str();
     1261    os.str("");
     1262    os << deltaHA;
     1263    value = os.str();
     1264    os.str("");
     1265
     1266    writeINI((char*)section.c_str(), (char*)key.c_str(), (char*)value.c_str(), (char*)fileName.c_str());
     1267
     1268
     1269    for (int j = 0; j < MAXALIGNEMENTANTENNE; j++)
    11701270    {
    11711271        os << "ad " << j;
     
    11901290        key     = os.str();
    11911291        os.str("");
    1192         os << 0;
     1292        os << 0.0;
    11931293        value = os.str();
    11941294        os.str("");
     
    11991299        key     = os.str();
    12001300        os.str("");
    1201         os << 0;
     1301        os << 0.0;
    12021302        value = os.str();
    12031303        os.str("");
     
    12151315    }
    12161316
    1217 
    1218     for (int j = 1; j <= nbrcorrections; j++)
     1317    for (int j = 0; j < nbrcorrections; j++) if (ad[j]!=0.0 && de[j]!=0.0)
    12191318    {
    12201319        os << "ad " << j;
  • BAORadio/libindi/libindi/communs/alignement.h

    r644 r677  
    1111#ifndef Alignement_class
    1212#define Alignement_class
    13 
    1413
    1514#include <stdio.h>
     
    3433
    3534using namespace std;
    36 
    3735
    3836struct Coord
     
    9391
    9492    double Surface_Triangle(double px1, double py1, double px2, double py2, double px3, double py3);
     93    void AzHa2XY(double az, double ha, double *x, double *y);
    9594    bool PointSitueDansSurfaceTriangle(double px, double py, double px1, double py1, double px2, double py2, double px3, double py3);
     95   
     96    double Determinant();
    9697
    9798
     
    109110    long delta_az_polar;                        // Correction en azimut de l'orientation de l'étoile polaire
    110111    // C'est la premiÚre étape de l'alignement dans les mode AFFINE et TAKI
     112   
     113    long int deltaAZ;                           // delta en azimut et en hauteur pour une correction à la raquette
     114    long int deltaHA;                           // hors procédure d'alignement
     115   
     116    bool SelectionnePourCalculMatrice[MAXALIGNEMENTANTENNE];
    111117
    112118    double ad[MAXALIGNEMENTANTENNE];            // Coordonnées horaires d'un point de correction
     
    116122    double tsl[MAXALIGNEMENTANTENNE];           // Temps sidéral local où les mesures en ar et dec ont été faites
    117123
    118     long delta_ad[MAXALIGNEMENTANTENNE];        // nbre de pas ajoutés en ascension droite et en déclinaison pour centrer l'objet visé
     124    double delta_ad[MAXALIGNEMENTANTENNE];        // nbre de pas ajoutés en ascension droite et en déclinaison pour centrer l'objet visé
    119125
    120     long delta_de[MAXALIGNEMENTANTENNE];
     126    double delta_de[MAXALIGNEMENTANTENNE];
    121127
    122128    double MATRICE[4][4];                       // La matrices de correction calculée dans les trois modes d'alignement
  • BAORadio/libindi/libindi/communs/astro.cpp

    r644 r677  
    1919{
    2020    //Initialisation des variables
    21    
     21
    2222    Longitude = 0.0;                     // Cordonnées du lieu d'observation
    2323    Latitude  = 0.0;
    24    
     24
    2525    Annee     = 0.0;                     // Date et heure de l'observation
    2626    Mois      = 0.0;
     
    3030    Sec       = 0.0;
    3131    UTCP      = 0.0;                     // permet de gérer le fuseau horaire
    32                                          // mais semble inutile sous Linux
    33    
     32    // mais semble inutile sous Linux
     33
    3434    hs        = 0.0;                     // fraction du jour en cours avec hs=(heure+min/60+secs/3600)/24.
    3535    ep        = 0.0;                     // obliquité de l'écliptique
    3636    tsl       = 0.0;                     // temps sidéral local
    3737    JJ        = 0.0;                     // Jour Julien
    38    
    39     CorP      = 0.0;                     // Nutation en longitude 
     38
     39    CorP      = 0.0;                     // Nutation en longitude
    4040    CorEP     = 0.0;                     // Nutation en inclinaison
    41    
     41
    4242    Pression  = 1013.0;
    4343    Temp      = 0.0;
    44      
     44
    4545    LongitudeSoleil = 0.0;
    4646}
     
    106106double Astro::VerifDistance(double Angle)
    107107{
    108         Angle=VerifAngle(Angle);
    109         if (Angle>Pi) Angle=Pi2-Angle;
    110 
    111         return(Angle);
     108    Angle=VerifAngle(Angle);
     109    if (Angle>Pi) Angle=Pi2-Angle;
     110
     111    return(Angle);
    112112}
    113113
     
    115115/**************************************************************************************
    116116** Distance entre deux points situés sur une sphÚre
    117 ** 
     117**
    118118***************************************************************************************/
    119119
    120120double Astro::DistanceAngulaireEntre2Points(double az1, double ha1, double az2, double ha2)
    121121{
    122     return acos(sin(ha1) * sin(ha2) + cos(ha1) * cos(ha2) * cos(az2 - az1)); 
     122    return acos(sin(ha1) * sin(ha2) + cos(ha1) * cos(ha2) * cos(az2 - az1));
    123123}
    124124
     
    161161    a=mema;
    162162
    163     if (HMS) a=a / 15.0;
     163    if (HMS) a = a / 15.0;
    164164    a=fabs(a * 3600.0);
    165165    s=Arrondi(fmod(a, 60.0) * 10.0) / 10.0;
     
    190190}
    191191
     192/**************************************************************************************
     193** Décomposition et vérification des dates, heures, AD et déclinaisons
     194**
     195** type = 0 -> chaîne contient une déclinaison ou une latitude
     196** type = 1 -> "        "      une longitude
     197** type = 2 -> "        "      une AD ou une heure
     198** type = 3 -> "        "      une date
     199**
     200** Exemple de Décomposition("15:23:12", 2, a, b, c) retourne a=15, b=23, c=12
     201** si la chaîne a un format incorrect, la fct retourne false
     202**
     203***************************************************************************************/
     204
     205bool Astro::Decomposition(string chaine, char type, float *a1, float *a2, float *a3)
     206{
     207    string car, s;
     208
     209    float a, b, c;
     210
     211    // pour les heures et les coordonnées, on attend ":" comme caractÚre séparateur, sinon
     212    // on attend d'avoir des caractÚres "/" entre chaque éléments pour une date
     213
     214    (type == 3) ? car="/" : car=":";
     215
     216    // Y a-t-il 2 caractÚres ':' ou '/' dans la chaîne ?
     217    // C'est indispensable dans tous les cas
     218
     219    int test = 0;
     220
     221    for (size_t i=0; i<chaine.length(); i++) if (chaine[i] == car[0]) test++;
     222
     223    if (test<2) return false;
     224
     225    // Extraction des trois nombres
     226
     227    s = chaine.substr(0, chaine.find(car));
     228
     229    a = atoi(s.c_str());
     230
     231    s = chaine.substr(chaine.find(car) + 1, chaine.rfind(car) - chaine.find(car) - 1);
     232
     233    b = atoi(s.c_str());
     234
     235    s = chaine.substr(chaine.rfind(car)+1);
     236
     237    // 12.125454414 sec  -> 12.125 sec
     238
     239    c = Arrondi(atof(s.c_str()) * 100.0) / 100.0;
     240
     241    //vérification de la cohérence des infos contenues dans la chaîne
     242
     243    if (type < 3 )
     244    {
     245        // pour une déclinaison
     246        if (( type == 0 ) && ( a>90.0  || a<-90.0 )) return false;
     247        // pour une AD
     248        if (( type == 1 ) && ( a>360.0 || a<0.0   )) return false;
     249        // pour une heure
     250        if (( type == 2 ) && ( a>23.0  || a<0.0   )) return false;
     251        // pour les minutes
     252        if ( b < 0.0 || b> 59.0 ) return false;
     253        //pour les secondes
     254        if ( c < 0.0 || c>=60.0 ) return false;
     255    }
     256    else
     257    {
     258        //pour les jours
     259        if ( a < 0.0 || a > 31.0 ) return false;
     260        //pour les mois
     261        if ( b < 0.0 || b > 12.0 ) return false;
     262    }
     263
     264    if ( a1 != NULL ) *a1 = a;
     265    if ( a2 != NULL ) *a2 = b;
     266    if ( a3 != NULL ) *a3 = c;
     267
     268    return true;
     269}
    192270
    193271/**************************************************************************************
     
    215293
    216294    double PS =  0.00134 * cos(A * Pidiv180)
    217                 +0.00154 * cos(B * Pidiv180)
    218                 +0.00200 * cos(C * Pidiv180)
    219                 +0.00179 * sin(D * Pidiv180)
    220                 +0.00178 * sin(E * Pidiv180);
     295                 +0.00154 * cos(B * Pidiv180)
     296                 +0.00200 * cos(C * Pidiv180)
     297                 +0.00179 * sin(D * Pidiv180)
     298                 +0.00178 * sin(E * Pidiv180);
    221299
    222300
    223301    double LS = VerifAngle( (L + CC + PS) * Pidiv180);
    224    
     302
    225303    return LS;
    226304}
     
    233311***************************************************************************************/
    234312
    235 void Astro::CalculARDecSoleil(CoordonneesHoraires *Soleil)
     313void Astro::CalculARDecSoleil(CoordonneesHorairesDouble *Soleil)
    236314{
    237315    double ar;
    238316    double de;
    239    
     317
    240318    ar = atan( cos(ep) * sin(LongitudeSoleil) / cos(LongitudeSoleil));
    241    
     319
    242320    if ( cos(LongitudeSoleil) < 0.0) ar += Pi;
    243    
     321
    244322    de = asin( sin(ep) * sin(LongitudeSoleil));
    245323
    246     Soleil->ar = DHMS( VerifAngle(ar) * N180divPi, true );
    247    
    248     Soleil->dec = DHMS( de * N180divPi, false );
    249 }
    250    
     324    Soleil->ar = VerifAngle(ar);
     325
     326    Soleil->dec = de;
     327}
     328
    251329
    252330
     
    270348    double LP2 = 2.0 * LP;
    271349    double O2  = 2.0 * O;
    272    
     350
    273351    // Nutation en longitude
    274352
     
    286364           +0.0124 * sin(L2 - O)
    287365           +0.0114 * sin(LP2 - MP);
    288            
     366
    289367    //Nutation en inclinaison
    290368
     
    393471void Astro::CalculJJ(double Heure)
    394472{
    395     JJ = CalculJJ(Annee, Mois, Jour, Heure);   
     473    JJ = CalculJJ(Annee, Mois, Jour, Heure);
    396474}
    397475
     
    438516
    439517    c = (36525L * y) / 100;
    440    
     518
    441519    return b + c + e + day - 32167.5;
    442520}
     
    450528double Astro::TSL(double JJ, double HeureSiderale, double Longitude)
    451529{
    452     double T = (JJ - 2415020.0 ) / 36525.0;
     530    double T = (JJ /*- 66.185/3600.0/24.0*/ - 2415020.0 ) / 36525.0;
    453531    double rd = 0.276919398 + ( 100.0021359 + 0.000001075 * T ) * T;
    454532    rd += HeureSiderale;
     
    500578    double az = atan(a1 / sqrt((-a1*a1)+1.0));
    501579
    502     if (ac<0.0) az=Pi-az;
    503 
    504     *azi=VerifAngle(Pi+az);
    505     *hau=ht;
    506 }
     580    if (ac<0.0) az = Pi - az;
     581
     582    *azi = VerifAngle( Pi + az );
     583    *hau = ht;
     584}
     585
     586
     587/**************************************************************************************
     588** Calcule l'ascension droite et la déclinaison d'un objet situé à l'azimut az
     589** et à la déclinaison de
     590***************************************************************************************/
     591
     592void Astro::AzHa2ADDe(double az, double ha, double *AD, double *Dec)
     593{
     594    double sindel, del, habar, cosha, ha10;
     595
     596    sindel = sin(ha) * sin(Latitude) + cos(ha) * cos(Latitude) * cos(az);
     597
     598    del = asin(sindel);
     599
     600    if ( (sindel == 1.0) || ( sindel == -1.0) )
     601    {
     602        habar = 0.0;
     603    }
     604    else
     605    {
     606        if ( (sin(Latitude) == 1.0) || (sin(Latitude) == -1.0))
     607        {
     608            habar = az;
     609        }
     610        else
     611        {
     612            cosha = ( sin(ha) - sin(Latitude) * sindel ) / ( cos(Latitude) * cos(del) );
     613            if (cosha > 1.0  )  cosha =  1.0;
     614            if (cosha < -1.0 )  cosha = -1.0;
     615
     616            habar = acos(cosha);
     617        }
     618    }
     619
     620    if (sin(az) < 0.0)
     621    {
     622        ha10 = habar;
     623    }
     624    else
     625    {
     626        ha10 = Pi2 - habar ;
     627    }
     628
     629    *AD = VerifAngle( tsl - ha10 );
     630
     631    // if (*AD < 0.0) *AD += Pi2;
     632
     633    *Dec = del;
     634}
     635
     636
     637/**************************************************************************************
     638** Recherche l'azimut de l'objet suivi au moment où celui-ci passera sous les 30°
     639** et deviendra donc hors d'atteinte de l'instrument.
     640***************************************************************************************/
     641
     642void Astro::RechercheAzimutFinSuivi(double AD, double Dec, long int *azmin, long int *azmax)
     643{
     644    double az, ha;
     645    double min =  10000.0;
     646    double max = -10000.0;
     647
     648    CalculTSL();
     649
     650    for (int i=0; i < 120; i++)
     651    {
     652        tsl += i * 5.0 / 60.0 / 24.0 ;
     653
     654        Azimut( AD, Dec, &az, &ha);
     655
     656        if ( az > max ) max = az;
     657
     658        if ( az < min ) min = az;
     659
     660        if ( ha < HAUTMIN * Pidiv180) break;
     661    }
     662
     663    *azmin = (long int) Arrondi( min * (double)NBREPASCODEURSAZ / 360.0) - NBREPASCODEURSAZ;
     664
     665    *azmax = (long int) Arrondi( max * (double)NBREPASCODEURSAZ / 360.0) + NBREPASCODEURSAZ;
     666
     667    CalculTSL();
     668}
     669
    507670
    508671
     
    712875    int is, k, n, i, j, optic;
    713876    double zobs1, zobs2, hmok, pmbok, rhok, wlok, tol, wlsq, gb,
    714     a, gamma, tdc, psat, pwo, w, tempo, dn0, rdndr0, sk0,
    715     f0, rdndrt, zt, ft, dnts, rdndrp, zts, fts, rs,
    716     dns, rdndrs, zs, fs, refold, z0, zrange, fb, ff, fo,
    717     fe, h, r, sz, rg, dr, tg, dn, rdndr, t, f, refp, reft;
     877           a, gamma, tdc, psat, pwo, w, tempo, dn0, rdndr0, sk0,
     878           f0, rdndrt, zt, ft, dnts, rdndrp, zts, fts, rs,
     879           dns, rdndrs, zs, fs, refold, z0, zrange, fb, ff, fo,
     880           fe, h, r, sz, rg, dr, tg, dn, rdndr, t, f, refp, reft;
    718881
    719882    /* The refraction integrand */
  • BAORadio/libindi/libindi/communs/astro.h

    r645 r677  
    1313#include "../communs/const.h"
    1414#include "stdio.h"
     15#include "stdlib.h"
    1516#include <iostream>
    1617#include <string.h>
    1718#include <sstream>
    1819#include <iomanip>
     20#include "const.h"
    1921
    2022using namespace std;
     
    2729    string ar;                          // Coordonnées horaires d'un objet
    2830    string dec;
     31};
     32
     33struct CoordonneesHorairesDouble
     34{
     35    double ar;                          // Coordonnées horaires d'un objet
     36    double dec;
    2937};
    3038
     
    4553    string DHMS(double mema, bool HMS);
    4654    void   Azimut(double Ar, double De, double *azi, double *hau);
     55    void   AzHa2ADDe(double Az, double Ha, double *AD, double *Dec);
     56    void   RechercheAzimutFinSuivi(double AD, double Dec, long int *azmin, long int *azmax);
    4757    void   Precession(double *ar, double *de);
    4858    void   NutationEtoile(double *ar, double *de);
     
    5464    double CalculLongitudeSoleil();
    5565    double TSL(double JJ,double HeureSiderale,double Longitude);
     66    bool    Decomposition(string chaine, char type, float *a1, float *a2, float *a3);
    5667    void   Nutation();
    5768    void   Obliquite(double JJ);
     
    6778    float  slaRange(float angle );
    6879    double slaDrange(double angle );
    69     void   CalculARDecSoleil(CoordonneesHoraires *Soleil);
     80    void   CalculARDecSoleil(CoordonneesHorairesDouble *Soleil);
    7081   
    7182    double GetLatitude()    { return Latitude;  }
  • BAORadio/libindi/libindi/communs/const.h

    r648 r677  
    2727
    2828#define NBREPASCODEURSAZ  4000
     29
     30// Définition des limites autorisées pour l'azimut (en pas codeur)
     31
     32#define MAXAZCODEURS 3800
     33#define MINAZCODEURS -1680
     34
    2935
    3036
     
    7177// l'utilisateur agit sur les touches fléchées durant la procédure d'alignement des antennes
    7278
    73 #define PasDeltaAD 2.0 * MINUTE_ARC
    74 #define PasDeltaDe 2.0 * MINUTE_ARC
     79#define PasDeltaAD ( 2.0 * MINUTE_ARC )
     80#define PasDeltaDe ( 2.0 * MINUTE_ARC )
     81
     82#define PasDeltaHa ( 5.0 * MINUTE_ARC )
     83#define PasDeltaAz ( 5.0 * MINUTE_ARC )
    7584
    7685#define gmax(A,B) ((A)>(B)?(A):(B))
     
    125134// Délai maximum en ms d'attente de la réponse des micro-contrÎleurs
    126135
    127 #define MAX_DELAI_REPONSE 40
     136#define MAX_DELAI_REPONSE 60
    128137
    129138// Si une commande ne recoit pas d'acknowledge. Alors refaire 80 tentatives en renvoyant la commande
     
    137146// attendre plus de 2 mn pour considérer qu'une antenne n'est pas en mesure de faire un goto
    138147
    139 #define MAXANOMALIESGOTO 1500
     148#define MAXANOMALIESGOTO 2000
     149
     150// Durée (en sec) entre deux actualisations en mode tracking
     151
     152#define UPDATETRACKINGDELAY 1.0
     153
     154// Durée (en sec) entre deux actualisations en mode transit
     155
     156#define UPDATETRANSITDELAY ( 15.0 * 60.0 )
    140157
    141158
  • BAORadio/libindi/libindi/drivers/telescope/BAO.cpp

    r651 r677  
    2222const char *BASIC_GROUP    = "Main Control";            // Main Group
    2323const char *OPTIONS_GROUP  = "Options";                 // Options Group
    24 
     24const char *RAQ_GROUP      = "Raquette";                // Options Group
     25const char *ALIG_GROUP     = "Alignement";              // Options Group
    2526
    2627#define targetRA    EquatorialCoordsWN[0].value
    2728#define targetDEC   EquatorialCoordsWN[1].value
     29
    2830
    2931
     
    7678    // dans les modes transit et tracking
    7779
    78     ActualisationTMTransit  = 15.0 * 60.0;    // Délai entre 2 actualisations dans le mode transit (en sec)
    79 
    80     ActualisationTMTracking = 5.0;            //                "                 "        tracking
     80    ActualisationTMTransit  = UPDATETRANSITDELAY;          // Délai entre 2 actualisations dans le mode transit (en sec)
     81
     82    ActualisationTMTracking = UPDATETRACKINGDELAY;  //                "                 "        tracking
    8183
    8284    // cette variable vaut "true" lorsque le thread de l'aplication a été initialisé
     
    114116
    115117    Temp                  = 10.0;
     118
     119    // raquette
     120
     121    delta_az              = 0;
     122    delta_ha              = 0;
     123    VitesseRaquette       = 10;
     124    targetAlignmentIP     = -1;
    116125
    117126
     
    136145
    137146    AfficherLog("Indi server BAORadio...\n");
    138     AfficherLog("Driver Version: 0.51 (02-04-2012)\n");
     147    AfficherLog("Driver Version: 0.6 (19-05-2012)\n");
    139148
    140149    //connect_telescope();
     
    293302    IUFillSwitchVector(&OnCoordSetSP, OnCoordSetS, NARRAY(OnCoordSetS), mydev, "ON_COORD_SET", "On Set", BASIC_GROUP, IP_RW, ISR_1OFMANY, 0, IPS_IDLE);
    294303
     304    // Abort
     305    IUFillSwitch(&AbortSlewS[0], "ABORT", "Abort", ISS_OFF);
     306    IUFillSwitchVector(&AbortSlewSP, AbortSlewS, NARRAY(AbortSlewS), mydev, "ABORT_MOTION", "Abort", BASIC_GROUP, IP_RW, ISR_ATMOST1, 0, IPS_IDLE);
     307
     308    // Park
     309    IUFillSwitch(&ParkS[0], "PARK", "Park", ISS_OFF);
     310    IUFillSwitchVector(&ParkSP, ParkS, NARRAY(ParkS), mydev, "", "Park", BASIC_GROUP, IP_RW, ISR_ATMOST1, 0, IPS_IDLE);
     311
     312    // Object Name
     313    IUFillText(&ObjectT[0], "OBJECT_NAME", "Name", "--");
     314    IUFillTextVector(&ObjectTP, ObjectT, NARRAY(ObjectT), mydev, "OBJECT_INFO", "Object", BASIC_GROUP, IP_RW, 0, IPS_IDLE);
     315
     316    // Equatorial Coords - SET
     317    IUFillNumber(&EquatorialCoordsWN[0], "RA", "RA  H:M:S", "%10.6m",  0., 24., 0., 0.);
     318    IUFillNumber(&EquatorialCoordsWN[1], "DEC", "Dec D:M:S", "%10.6m", -90., 90., 0., 0.);
     319    IUFillNumberVector(&EquatorialCoordsWNP, EquatorialCoordsWN, NARRAY(EquatorialCoordsWN), mydev, "EQUATORIAL_EOD_COORD_REQUEST" , "Equatorial JNow", BASIC_GROUP, IP_WO, 0, IPS_IDLE);
     320
     321    //Command
     322    IUFillText(&CommandT[0], "COMMAND", "Command", "");
     323    IUFillTextVector(&CommandTP, CommandT, NARRAY(CommandT), mydev, "COMMAND_SET", "Command", BASIC_GROUP, IP_WO, 0, IPS_IDLE);
     324
     325
     326    // Alignement- bouton Alt+
     327    IUFillSwitch(&AlignementAltp[0], "ALTP", "Alt+", ISS_OFF);
     328    IUFillSwitchVector(&AlignementAltpP, AlignementAltp, NARRAY(AlignementAltp), mydev, "ALT_P", "Alt+", RAQ_GROUP, IP_RW, ISR_ATMOST1, 0, IPS_IDLE);
     329
     330    // Alignement- bouton Az
     331    IUFillSwitch(&AlignementAz[0], "AZM", "Az-", ISS_OFF);
     332    IUFillSwitch(&AlignementAz[1], "AZP", "Az+", ISS_OFF);
     333    IUFillSwitchVector(&AlignementAzP, AlignementAz, NARRAY(AlignementAz), mydev, "AZ", "Azimut", RAQ_GROUP, IP_RW, ISR_ATMOST1, 0, IPS_IDLE);
     334
     335
     336    // Alignement- bouton Alt-
     337    IUFillSwitch(&AlignementAltn[0], "ALTN", "Alt-", ISS_OFF);
     338    IUFillSwitchVector(&AlignementAltnP, AlignementAltn, NARRAY(AlignementAltn), mydev, "ALT_N", "Alt-", RAQ_GROUP, IP_RW, ISR_ATMOST1, 0, IPS_IDLE);
     339
     340    // Vitesse Raquette - bouton Az
     341    IUFillSwitch(&RaquetteN[0], "RAQ1", "1x", ISS_OFF);
     342    IUFillSwitch(&RaquetteN[1], "RAQ10", "10x", ISS_OFF);
     343    IUFillSwitchVector(&RaquetteNP, RaquetteN, NARRAY(RaquetteN), mydev, "RAQ", "Vitesse raquette", RAQ_GROUP, IP_RW, ISR_ATMOST1, 0, IPS_IDLE);
     344
     345
     346    // Alignement Coords - SET
     347    IUFillText(&AlignementIP[0], "IP", "IP", "");
     348    IUFillTextVector(&AlignementIPP, AlignementIP, NARRAY(AlignementIP), mydev, "ALIGNEMENT_IP", "Alignment IP", ALIG_GROUP, IP_WO, 0, IPS_IDLE);
     349
     350
     351    // Alignment validation
     352    IUFillSwitch(&AlignementOk[0], "OK", "Valider", ISS_OFF);
     353    IUFillSwitch(&AlignementOk[1], "SAUV", "Sauvegarder", ISS_OFF);
     354    IUFillSwitchVector(&AlignementOkP, AlignementOk, NARRAY(AlignementOk), mydev, "ALIGNMENT_OK", "Validation", ALIG_GROUP, IP_RW, ISR_1OFMANY, 0, IPS_IDLE);
     355
     356    // Alignment reset
     357    IUFillSwitch(&AlignementReset[0], "RESET", "Reset", ISS_OFF);
     358    IUFillSwitchVector(&AlignementResetP, AlignementReset, NARRAY(AlignementReset), mydev, "ALIGNMENT_RESET", "Reset", ALIG_GROUP, IP_RW, ISR_1OFMANY, 0, IPS_IDLE);
     359
    295360    // Alignment Set
    296361    IUFillSwitch(&AlignmentS[0], "SIMPLE", "Simple", ISS_ON);
    297362    IUFillSwitch(&AlignmentS[1], "AFFINE", "Affine", ISS_OFF);
    298363    IUFillSwitch(&AlignmentS[2], "TAKI", "Taki", ISS_OFF);
    299     IUFillSwitchVector(&AlignmentSP, AlignmentS, NARRAY(AlignmentS), mydev, "ALIGNMENT_SET", "Alignment", BASIC_GROUP, IP_RW, ISR_1OFMANY, 0, IPS_IDLE);
    300 
    301     // Abort
    302     IUFillSwitch(&AbortSlewS[0], "ABORT", "Abort", ISS_OFF);
    303     IUFillSwitchVector(&AbortSlewSP, AbortSlewS, NARRAY(AbortSlewS), mydev, "ABORT_MOTION", "Abort", BASIC_GROUP, IP_RW, ISR_ATMOST1, 0, IPS_IDLE);
    304 
    305     // Park
    306     IUFillSwitch(&ParkS[0], "PARK", "Park", ISS_OFF);
    307     IUFillSwitchVector(&ParkSP, ParkS, NARRAY(ParkS), mydev, "", "Park", BASIC_GROUP, IP_RW, ISR_ATMOST1, 0, IPS_IDLE);
    308 
    309     // Object Name
    310     IUFillText(&ObjectT[0], "OBJECT_NAME", "Name", "--");
    311     IUFillTextVector(&ObjectTP, ObjectT, NARRAY(ObjectT), mydev, "OBJECT_INFO", "Object", BASIC_GROUP, IP_RW, 0, IPS_IDLE);
    312 
    313     // Equatorial Coords - SET
    314     IUFillNumber(&EquatorialCoordsWN[0], "RA", "RA  H:M:S", "%10.6m",  0., 24., 0., 0.);
    315     IUFillNumber(&EquatorialCoordsWN[1], "DEC", "Dec D:M:S", "%10.6m", -90., 90., 0., 0.);
    316     IUFillNumberVector(&EquatorialCoordsWNP, EquatorialCoordsWN, NARRAY(EquatorialCoordsWN), mydev, "EQUATORIAL_EOD_COORD_REQUEST" , "Equatorial JNow", BASIC_GROUP, IP_WO, 0, IPS_IDLE);
    317 
    318     //Command
    319     IUFillText(&CommandT[0], "COMMAND", "Command", "");
    320     IUFillTextVector(&CommandTP, CommandT, NARRAY(CommandT), mydev, "COMMAND_SET", "Command", BASIC_GROUP, IP_WO, 0, IPS_IDLE);
     364    IUFillSwitchVector(&AlignmentSP, AlignmentS, NARRAY(AlignmentS), mydev, "ALIGNMENT_SET", "Alignment method", ALIG_GROUP, IP_RW, ISR_1OFMANY, 0, IPS_IDLE);
     365
    321366
    322367    // Geographic coord - SET
     
    326371
    327372    // Pression température - SET
    328     IUFillNumber(&PressionTempWN[0], "Pression", "Pression mb", "%10.6m",  0., 1500., 0., 0.);
    329     IUFillNumber(&PressionTempWN[1], "Temperature", "Temperature °c", "%10.6m", -50., +50., 0., 0.);
     373    IUFillNumber(&PressionTempWN[0], "Pression", "Pression mb", "%4.0f",  0., 1500., 0., 0.);
     374    IUFillNumber(&PressionTempWN[1], "Temperature", "Temperature °c", "%3.0f", -50., +50., 0., 0.);
    330375    IUFillNumberVector(&PressionTempWNP, PressionTempWN, NARRAY(PressionTempWN), mydev, "PRESSION_DATA" , "Pression, Temperature", OPTIONS_GROUP, IP_WO, 0, IPS_IDLE);
    331376
    332377    // Actualisation - SET
    333     IUFillNumber(&ActualisationN1[0], "DELAY", "Transit delay (s)", "%10.6m",  0., 3600., 0., 0.);
     378    IUFillNumber(&ActualisationN1[0], "DELAY", "Transit delay (s)", "%3.0f",  0., 3600., 0., 0.);
    334379    IUFillNumberVector(&ActualisationNP1, ActualisationN1, NARRAY(ActualisationN1), mydev, "DELAY1" , "", OPTIONS_GROUP, IP_WO, 0, IPS_IDLE);
    335380
    336     IUFillNumber(&ActualisationN2[0], "DELAY", "Tracking delay (s)", "%10.6m",  0., 3600., 0., 0.);
     381    IUFillNumber(&ActualisationN2[0], "DELAY", "Tracking delay (s)", "%3.0f",  0., 3600., 0., 0.);
    337382    IUFillNumberVector(&ActualisationNP2, ActualisationN2, NARRAY(ActualisationN2), mydev, "DELAY2" , "", OPTIONS_GROUP, IP_WO, 0, IPS_IDLE);
    338383}
     
    357402    IDDefText(&CommandTP, NULL);
    358403    IDDefSwitch(&OnCoordSetSP, NULL);
    359     IDDefSwitch(&AlignmentSP, NULL);
    360404    IDDefSwitch(&AbortSlewSP, NULL);
    361405    IDDefSwitch(&ParkSP, NULL);
     406
     407    // Raquette
     408    IDDefSwitch(&AlignementAltpP, NULL);
     409    IDDefSwitch(&AlignementAzP, NULL);
     410    IDDefSwitch(&AlignementAltnP, NULL);
     411
     412    //alignement
     413    IDDefSwitch(&RaquetteNP, NULL);
     414    IDDefText(&AlignementIPP, NULL);
     415    IDDefSwitch(&AlignementOkP, NULL);
     416    IDDefSwitch(&AlignementResetP, NULL);
     417    IDDefSwitch(&AlignmentSP, NULL);
    362418
    363419    // Options
     
    380436    OnCoordSetSP.s              = IPS_IDLE;
    381437    AlignmentSP.s               = IPS_IDLE;
     438    AlignementAltpP.s           = IPS_IDLE;
     439    AlignementAltnP.s           = IPS_IDLE;
     440    AlignementAzP.s             = IPS_IDLE;
     441    AlignementIPP.s             = IPS_IDLE;
     442    AlignementOkP.s             = IPS_IDLE;
     443    RaquetteNP.s                = IPS_IDLE;
     444    AlignementResetP.s          = IPS_IDLE;
    382445    AbortSlewSP.s               = IPS_IDLE;
    383446    ParkSP.s                    = IPS_IDLE;
     
    392455    IUResetSwitch(&OnCoordSetSP);
    393456    IUResetSwitch(&AlignmentSP);
     457    IUResetSwitch(&AlignementAltpP);
     458    IUResetSwitch(&AlignementAzP);
     459    IUResetSwitch(&AlignementAltnP);
     460    IUResetSwitch(&AlignementOkP);
     461    IUResetSwitch(&AlignementResetP);
     462    IUResetSwitch(&RaquetteNP);
    394463    IUResetSwitch(&AbortSlewSP);
    395464    IUResetSwitch(&ParkSP);
     
    397466    OnCoordSetS[0].s = ISS_ON;
    398467    AlignmentS[0].s = ISS_ON;
     468    AlignementAltp[0].s = ISS_OFF;
     469    AlignementAltn[0].s = ISS_OFF;
     470    AlignementAz[0].s = ISS_OFF;
     471    AlignementAz[1].s = ISS_OFF;
    399472    ConnectS[0].s = ISS_OFF;
    400473    ConnectS[1].s = ISS_ON;
     
    403476    IDSetSwitch(&OnCoordSetSP, NULL);
    404477    IDSetSwitch(&AlignmentSP, NULL);
     478    IDSetSwitch(&AlignementAltpP, NULL);
     479    IDSetSwitch(&AlignementAzP, NULL);
     480    IDSetSwitch(&AlignementAltnP, NULL);
     481    IDSetSwitch(&AlignementOkP, NULL);
     482    IDSetSwitch(&AlignementResetP, NULL);
     483    IDSetSwitch(&RaquetteNP, NULL);
    405484    IDSetSwitch(&AbortSlewSP, NULL);
    406485    IDSetSwitch(&ParkSP, NULL);
    407486    IDSetText(&ObjectTP, NULL);
    408487    IDSetText(&CommandTP, NULL);
     488    IDSetText(&AlignementIPP, NULL);
    409489    IDSetNumber(&EquatorialCoordsWNP, NULL);
    410490    IDSetNumber(&PressionTempWNP, NULL);
     
    454534
    455535    // ===================================
     536    // Adresse IP de l'antenne qu'il faut aligner
     537    // ===================================
     538    if (!strcmp (name, AlignementIPP.name))
     539    {
     540        if (IUUpdateText(&AlignementIPP, texts, names, n) < 0)
     541            return;
     542
     543        IText *eqp = IUFindText (&AlignementIPP, names[0]);
     544
     545        int i;
     546
     547        if (eqp == &AlignementIP[0])
     548        {
     549            string ip = texts[0];
     550
     551            bool IPvalide = false;
     552
     553            // est-ce que l'adresse ip correspond à l'adresse d'une antenne connectée ?
     554
     555            for ( i=1; i<SocketsNumber; i++) if (Sockets[i].Connected)
     556                {
     557                    if (Sockets[i].IP == ip) {
     558                        IPvalide = true;
     559                        break;
     560                    }
     561                }
     562
     563            if ( IPvalide )
     564            {
     565                targetAlignmentIP = i;
     566                AlignementIPP.s = IPS_OK ;
     567                IDSetText(&AlignementIPP, "L antenne %s est maintenant prete pour l alignement", Sockets[targetAlignmentIP].IP.c_str() );
     568
     569                Sockets[targetAlignmentIP].AlignementAntenne->AlignementEnCours = 1;
     570
     571                Sockets[targetAlignmentIP].AlignementAntenne->Matrice_ok = false;
     572            }
     573            else
     574            {
     575                targetAlignmentIP = -1;
     576                AlignementIPP.s = IPS_ALERT ;
     577                IDSetText(&AlignementIPP, "L antenne indiquee n est pas connectee !");
     578            }
     579        }
     580        return;
     581    }
     582
     583
     584    // ===================================
    456585    // Commands
    457586    // ===================================
     
    474603            if (chaine[0] == 'G')
    475604            {
     605                //commande goto
     606
    476607                for (int i = 1; i<=strlen(chaine); i++) chaine[i-1]=chaine[i];
    477                
    478                 IDLog(chaine);
     608
     609                IDLog(chaine);
    479610
    480611                for (int i = 1; i<SocketsNumber; i++ )
     
    484615                        result = COMMANDE(i, (char*)"G", chaine);
    485616                    }
     617                }
     618            }
     619            else if (chaine[0] == 'X')
     620            {
     621                if (targetAlignmentIP != -1)
     622                {
     623                    IDSetText(&CommandTP, "Position:/%05d/%05d\n", Sockets[targetAlignmentIP].Pos.x, Sockets[targetAlignmentIP].Pos.y );
     624
     625                    return;
     626                }
     627            }
     628            else if (chaine[0] == 'D')
     629            {
     630                if (targetAlignmentIP != -1)
     631                {
     632                    IDSetText(&CommandTP, "Deltas:/%05d/%05d\n", delta_az, delta_ha );
     633
     634                    return;
     635                }
     636            }
     637            else if (chaine[0] == 'C')
     638            {
     639                if (targetAlignmentIP != -1)
     640                {
     641                    stringstream os;
     642
     643                    double a, b;
     644
     645                    os << "Corrections:";
     646
     647                    Azimut( targetRA * 15.0 * Pidiv180,
     648                            targetDEC * Pidiv180, &a, &b);
     649                    os << a << ",";
     650                    os << b << ",";
     651
     652                    os << "/";
     653
     654                    for (int i=0; i<Sockets[targetAlignmentIP].AlignementAntenne->nbrcorrections; i++)
     655                    {
     656                        if (Sockets[targetAlignmentIP].AlignementAntenne->SelectionnePourCalculMatrice[i])
     657                        {
     658                            os << i << ",";
     659                        }
     660                    }
     661
     662                    os << "/";
     663
     664                    for (int i=0; i<Sockets[targetAlignmentIP].AlignementAntenne->nbrcorrections; i++)
     665                    {
     666                        if (Sockets[targetAlignmentIP].AlignementAntenne->tsl[i] != 0.0)
     667                        {
     668                            Azimut( Sockets[targetAlignmentIP].AlignementAntenne->ad[i]
     669                                    - Sockets[targetAlignmentIP].AlignementAntenne->tsl[i] + GetTSL(),
     670                                    Sockets[targetAlignmentIP].AlignementAntenne->de[i], &a, &b);
     671                            os << a << ",";
     672                            os << b << ",";
     673
     674                            Azimut( Sockets[targetAlignmentIP].AlignementAntenne->delta_ad[i]
     675                                    - Sockets[targetAlignmentIP].AlignementAntenne->tsl[i] + GetTSL(),
     676                                    Sockets[targetAlignmentIP].AlignementAntenne->delta_de[i]
     677                                    , &a, &b);
     678
     679                            os << a << ",";
     680                            os << b << ",";
     681                        }
     682                    }
     683
     684                    os << "/";
     685
     686                    for (int i=0; i<Sockets[targetAlignmentIP].AlignementAntenne->nbrcorrections; i++)
     687                    {
     688                        if (Sockets[targetAlignmentIP].AlignementAntenne->tsl[i] != 0.0 && Sockets[targetAlignmentIP].AlignementAntenne->Matrice_ok)
     689                        {
     690                            Azimut( Sockets[targetAlignmentIP].AlignementAntenne->ad[i]
     691                                    - Sockets[targetAlignmentIP].AlignementAntenne->tsl[i] + GetTSL(),
     692                                    Sockets[targetAlignmentIP].AlignementAntenne->de[i], &a, &b);
     693
     694                            Coord vect, r;
     695
     696                            if (Sockets[targetAlignmentIP].AlignementAntenne->MethodeAlignement == SIMPLE)
     697                            {
     698                                vect.x = cos(a) * cos(b);
     699                                vect.y = sin(a) * cos(b);
     700                                vect.z = sin(b);
     701
     702
     703                                // Application de la matrice SIMPLE
     704
     705                                Sockets[targetAlignmentIP].AlignementAntenne->AppliquerMatriceCorrectionSimple(&r, vect);
     706
     707
     708                                // Là on doit repasser des coordonnées rectangulaires
     709                                // aux coordonnées sphériques
     710
     711                                if (r.x != 0.0)
     712                                {
     713                                    a = atan( r.y / r.x );
     714
     715                                    if (r.x < 0) a += Pi;
     716                                }
     717                                else a = Pidiv2;
     718
     719                                b = asin(r.z);
     720                            }
     721                            else
     722                            {
     723                                double c, d;
     724
     725                                Sockets[targetAlignmentIP].AlignementAntenne->AzHa2XY(a, b, &c, &d);
     726                                vect.x = c;
     727                                vect.y = d;
     728                                vect.z = 1.0;
     729
     730                                AfficherLog("az=%5.2f ha=%5.2f x=%5.2f y=%5.2f\n", a, b, c, d);
     731                                // Application de la matrice SIMPLE
     732
     733                                Sockets[targetAlignmentIP].AlignementAntenne->AppliquerMatriceCorrectionAffine(&r, vect);
     734
     735
     736                                AfficherLog("r.x=%5.2f r.y=%5.2f d=%5.2f\n", r.x, r.y,sqrt(r.x*r.x+r.y*r.y));
     737                                a = atan(r.y/r.x);
     738                                if (r.x < 0) a += Pi;
     739
     740                                b= Pidiv2-(sqrt(r.x*r.x+r.y*r.y));
     741                            }
     742
     743
     744                            os << a << ",";
     745                            os << b << ",";
     746                        }
     747                    }
     748
     749
     750
     751
     752                    IDSetText(&CommandTP, os.str().c_str() );
     753
     754                    return;
    486755                }
    487756            }
     
    699968            targetDEC = newDEC;
    700969
     970            // Réinitialisation des deltas
     971
     972            delta_az = 0;
     973            delta_ha = 0;
     974
     975            if (targetAlignmentIP != -1 && Sockets[targetAlignmentIP].AlignementAntenne->AlignementEnCours != 0)
     976            {
     977                Sockets[targetAlignmentIP].AlignementAntenne->delta_ad[Sockets[targetAlignmentIP].AlignementAntenne->nbrcorrections] =
     978                    targetRA * 15.0 * Pidiv180;
     979
     980                Sockets[targetAlignmentIP].AlignementAntenne->delta_de[Sockets[targetAlignmentIP].AlignementAntenne->nbrcorrections] =
     981                    targetDEC * Pidiv180;
     982            }
     983           
     984            for (int i=0; i<SocketsNumber; i++) if (Sockets[i].Connected)
     985            {
     986              if ( Sockets[i].AlignementAntenne->AlignementEnCours == 0 )
     987              {
     988                Sockets[i].AlignementAntenne->CalculerMatriceCorrection(targetRA, targetDEC);
     989              }
     990            }
     991               
     992             
     993
    701994            // on les affiche dans les logs
    702995
     
    8731166        return;
    8741167
     1168
     1169
     1170    double az, ha, ad, de;
     1171
     1172    ad = targetRA * 15.0 * Pidiv180;
     1173
     1174    de = targetDEC * Pidiv180;
     1175
     1176    CalculTSL();
     1177
     1178    Azimut(ad, de, &az, &ha);
     1179
     1180    ha = RefractionAtmospherique(ha) ;
     1181
     1182
     1183
     1184
    8751185    // ===================================
    8761186    // Connect Switch
     
    9161226        MethodeAlignement = get_switch_index(&AlignmentSP) + 1 ;
    9171227
    918         /*char chaine[100];
    919         sprintf(chaine, "****************************************** %i\n", MethodeAlignement);
    920         AfficherLog(chaine);*/
    921 
    9221228        AlignmentSP.s = IPS_OK;
     1229        IUResetSwitch(&AlignmentSP);
    9231230        IDSetSwitch(&AlignmentSP, NULL);
    9241231
     
    9431250
    9441251    // ===================================
     1252    // Alignment Speed
     1253    // ===================================
     1254    if (!strcmp(name, RaquetteNP.name))
     1255    {
     1256        if (IUUpdateSwitch(&RaquetteNP, states, names, n) < 0)
     1257            return;
     1258
     1259        RaquetteNP.s = IPS_OK;
     1260
     1261        switch (get_switch_index(&RaquetteNP))
     1262        {
     1263        case 0 :
     1264            IUResetSwitch(&RaquetteNP);
     1265            IDSetSwitch(&RaquetteNP, "La vitesse de la raquette est fixee a 1x");
     1266            VitesseRaquette = 1;
     1267            break;
     1268        case 1 :
     1269            IUResetSwitch(&RaquetteNP);
     1270            IDSetSwitch(&RaquetteNP, "La vitesse de la raquette est fixee a 10x");
     1271            VitesseRaquette = 10;
     1272            break;
     1273        }
     1274
     1275        return;
     1276    }
     1277
     1278    // ===================================
     1279    // Alignment Reset
     1280    // ===================================
     1281    if (!strcmp(name, AlignementResetP.name))
     1282    {
     1283        if (IUUpdateSwitch(&AlignementResetP, states, names, n) < 0)
     1284            return;
     1285
     1286        if ( targetAlignmentIP < 0 )
     1287        {
     1288            AlignementResetP.s = IPS_ALERT;
     1289            IDSetSwitch(&AlignementResetP, "Veuillez indiquer l adresse IP de l antenne a calibrer");
     1290
     1291            return;
     1292        }
     1293
     1294        AlignementResetP.s = IPS_OK;
     1295        IDSetSwitch(&AlignementResetP, "Les parametres de l alignement de l antenne ont ete reinitialises");
     1296
     1297        Sockets[targetAlignmentIP].AlignementAntenne->InitAlignement();
     1298
     1299        sleep(1);
     1300
     1301        Sockets[targetAlignmentIP].AlignementAntenne->EnregistrementParametresAlignement(
     1302            Sockets[targetAlignmentIP].IP,
     1303            "/home/" + (string)getenv("USER") + "/AlignementAntennes.cfg");
     1304
     1305
     1306        IUResetSwitch(&AlignementResetP);
     1307        AlignementResetP.s = IPS_IDLE;
     1308        IDSetSwitch(&AlignementResetP, NULL);
     1309
     1310        return;
     1311    }
     1312
     1313
     1314
     1315    // ===================================
     1316    // Alignment buttons
     1317    // ===================================
     1318    if (!strcmp(name, AlignementAltpP.name))
     1319    {
     1320        if (IUUpdateSwitch(&AlignementAltpP, states, names, n) < 0)
     1321            return;
     1322
     1323        delta_ha += VitesseRaquette;
     1324
     1325        az  = VerifAngle(az + (double)delta_az * PasDeltaAz);
     1326
     1327        ha += (double)delta_ha * PasDeltaHa;
     1328
     1329        //   ISPoll();
     1330
     1331        AlignementAltpP.s = IPS_IDLE;
     1332
     1333        IDSetSwitch(&AlignementAltpP, "Delta en azimut = %s  delta en hauteur = %s  az = %s  ha = %s (Vitesse raquette = %d)\n",
     1334                    DHMS(delta_az * PasDeltaAz, false).c_str(),
     1335                    DHMS(delta_ha * PasDeltaHa, false).c_str(),
     1336                    DHMS(az * N180divPi, false).c_str(),
     1337                    DHMS(ha * N180divPi, false).c_str(),
     1338                    VitesseRaquette);
     1339        IUResetSwitch(&AlignementAltpP);
     1340
     1341        return;
     1342    }
     1343
     1344    if (!strcmp(name, AlignementAltnP.name))
     1345    {
     1346        if (IUUpdateSwitch(&AlignementAltnP, states, names, n) < 0)
     1347            return;
     1348
     1349        delta_ha -= VitesseRaquette;
     1350
     1351        az  = VerifAngle(az + (double)delta_az * PasDeltaAz);
     1352
     1353        ha += (double)delta_ha * PasDeltaHa;
     1354
     1355        //   ISPoll();
     1356
     1357        AlignementAltnP.s = IPS_IDLE;
     1358
     1359        IDSetSwitch(&AlignementAltnP, "Delta en azimut = %s  delta en hauteur = %s  az = %s  ha = %s (Vitesse raquette = %d)\n",
     1360                    DHMS(delta_az * PasDeltaAz, false).c_str(),
     1361                    DHMS(delta_ha * PasDeltaHa, false).c_str(),
     1362                    DHMS(az * N180divPi, false).c_str(),
     1363                    DHMS(ha * N180divPi, false).c_str(),
     1364                    VitesseRaquette);
     1365        IUResetSwitch(&AlignementAltnP);
     1366
     1367        return;
     1368    }
     1369
     1370    if (!strcmp(name, AlignementAzP.name))
     1371    {
     1372        if (IUUpdateSwitch(&AlignementAzP, states, names, n) < 0)
     1373            return;
     1374
     1375        switch (get_switch_index(&AlignementAzP))
     1376        {
     1377        case 0 :
     1378            delta_az -= VitesseRaquette;
     1379            break;
     1380        case 1 :
     1381            delta_az += VitesseRaquette;
     1382            break;
     1383        }
     1384
     1385        az  = VerifAngle(az + (double)delta_az * PasDeltaAz);
     1386
     1387        ha += (double)delta_ha * PasDeltaHa;
     1388
     1389        // ISPoll();
     1390
     1391        AlignementAzP.s = IPS_IDLE;
     1392
     1393        IDSetSwitch(&AlignementAzP, "Delta en azimut = %s  delta en hauteur = %s  az = %s  ha = %s (Vitesse raquette = %d)\n",
     1394                    DHMS(delta_az * PasDeltaAz, false).c_str(),
     1395                    DHMS(delta_ha * PasDeltaHa, false).c_str(),
     1396                    DHMS(az * N180divPi, false).c_str(),
     1397                    DHMS(ha * N180divPi, false).c_str(),
     1398                    VitesseRaquette);
     1399        IUResetSwitch(&AlignementAzP);
     1400
     1401        return;
     1402    }
     1403
     1404    if (!strcmp(name, AlignementOkP.name))
     1405    {
     1406        if (IUUpdateSwitch(&AlignementOkP, states, names, n) < 0)
     1407            return;
     1408
     1409        if ( targetAlignmentIP < 0 )
     1410        {
     1411            AlignementOkP.s = IPS_ALERT;
     1412            IDSetSwitch(&AlignementOkP, "Veuillez indiquer l adresse IP de l antenne a calibrer");
     1413
     1414            return;
     1415        }
     1416
     1417        AlignementOkP.s = IPS_OK;
     1418        IDSetSwitch(&AlignementOkP, NULL);
     1419
     1420        switch (get_switch_index(&AlignementOkP))
     1421        {
     1422            // Validation de l'alignement en cours...
     1423
     1424        case 0 :
     1425        {
     1426            float a, b, c;
     1427            double az, ha, ad, de, ad2, de2;
     1428
     1429            int num;
     1430
     1431            num = Sockets[targetAlignmentIP].AlignementAntenne->nbrcorrections;
     1432
     1433            ad = targetRA * 15.0 * Pidiv180;
     1434
     1435            Sockets[targetAlignmentIP].AlignementAntenne->ad[num] = ad;
     1436
     1437            de = targetDEC * Pidiv180;
     1438
     1439            Sockets[targetAlignmentIP].AlignementAntenne->de[num] = de;
     1440
     1441            CalculTSL();
     1442
     1443            Sockets[targetAlignmentIP].AlignementAntenne->tsl[num] = GetTSL();
     1444
     1445            Azimut(ad, de, &az, &ha);
     1446
     1447            //ha = RefractionAtmospherique(ha) ;
     1448
     1449            az  = VerifAngle(az + (double)delta_az * PasDeltaAz);
     1450
     1451            ha += (double)delta_ha * PasDeltaHa;
     1452
     1453            AzHa2ADDe(az, ha, &ad2, &de2);
     1454
     1455
     1456            Sockets[targetAlignmentIP].AlignementAntenne->delta_ad[num] = ad2;
     1457
     1458            Sockets[targetAlignmentIP].AlignementAntenne->delta_de[num] = de2;
     1459
     1460            stringstream os;
     1461
     1462            AfficherLog("Alignement de l antenne %s avec l objet situe en RA %s - DEC %s\n",
     1463                        Sockets[targetAlignmentIP].IP.c_str(),
     1464                        DHMS(targetRA * 15.0, true).c_str(),
     1465                        DHMS(targetDEC, false     ).c_str());
     1466
     1467            AfficherLog("ad1=%s de1=%s ad2=%s de2=%s\n",
     1468                        DHMS(ad  * N180divPi, true ).c_str(),
     1469                        DHMS(de  * N180divPi, false).c_str(),
     1470                        DHMS(ad2 * N180divPi, true ).c_str(),
     1471                        DHMS(de2 * N180divPi, false).c_str());
     1472
     1473            AfficherLog("delta_az=%s delta_ha=%s\n",
     1474                        DHMS(delta_az * PasDeltaAz, false).c_str(),
     1475                        DHMS(delta_ha * PasDeltaHa, false).c_str());
     1476
     1477            Sockets[targetAlignmentIP].AlignementAntenne->nbrcorrections++;
     1478
     1479            delta_az = 0;
     1480            delta_ha = 0;
     1481
     1482            IDSetSwitch(&AlignementOkP, "Les parametres de l alignement ont ete valides");
     1483
     1484        }
     1485        break;
     1486
     1487        // Sauvegarde de l'alignement en cours...
     1488
     1489        case 1 :
     1490        {
     1491            if  (Sockets[targetAlignmentIP].AlignementAntenne->nbrcorrections >=3 )
     1492            {
     1493                // IDLog("Calcul matrice\n", true);
     1494                Sockets[targetAlignmentIP].AlignementAntenne->AlignementEnCours = 0;
     1495                Sockets[targetAlignmentIP].AlignementAntenne->CalculerMatriceCorrection(targetRA, targetDEC);
     1496            }
     1497            else
     1498            {
     1499                Sockets[targetAlignmentIP].AlignementAntenne->Identity();
     1500
     1501                Sockets[targetAlignmentIP].AlignementAntenne->Matrice_ok = false;
     1502            }
     1503
     1504            IDSetSwitch(&AlignementOkP, "Les parametres de l alignement ont ete sauvegardes");
     1505
     1506            Sockets[targetAlignmentIP].AlignementAntenne->EnregistrementParametresAlignement(
     1507                Sockets[targetAlignmentIP].IP,
     1508                "/home/" + (string)getenv("USER") + "/AlignementAntennes.cfg");
     1509        }
     1510        break;
     1511        }
     1512
     1513
     1514        AlignementOkP.s = IPS_IDLE;
     1515        IUResetSwitch(&AlignementOkP);
     1516        IDSetSwitch(&AlignementOkP, NULL);
     1517
     1518        return;
     1519    }
     1520
     1521
     1522    // ===================================
    9451523    // Abort slew
    9461524    // ===================================
     
    10891667
    10901668
    1091 
    10921669/************************************************************************************
    10931670** Cette procédure, aprÚs avoir appliqué la matrice de rotation aux coordonnées de l'objet
     
    11281705                // On est bien dans le cas de l'alignement AFFINE ou Taki
    11291706
    1130                 if (Sockets[i].AlignementAntenne->MethodeAlignement ==  AFFINE ||
    1131                         Sockets[i].AlignementAntenne->MethodeAlignement ==  TAKI)
    1132                 {
    1133                     // On crée un vecteur avec pour coordonnées
    1134                     // x = Angle horaire de l'objet visé
    1135                     // y = déclinaison de l'objet
    1136                     // z = 1.0
    1137                     // Voir la documentation pour plus d'explications sur le calcul affine/taki
    1138 
    1139                     vect.x = VerifAngle( newRA2 - GetTSL() );
    1140                     vect.y = newDEC2;
    1141                     vect.z = 1.0;
    1142 
    1143                     // Message pour l'utilisateur et les logs
    1144 
    1145                     AfficherLog("Application de la matrice AFFINE/TAKI\nCoordonnees initiales: AD = %s  Dec = %s\n", DHMS(newRA2*N180divPi, true ).c_str(),
    1146                                 DHMS(newDEC2*N180divPi, false ).c_str());
    1147 
    1148                     // On applique la matrice de transformation
    1149 
    1150                     switch (Sockets[i].AlignementAntenne->MethodeAlignement)
    1151                     {
    1152                     case AFFINE :
    1153                         Sockets[i].AlignementAntenne->AppliquerMatriceCorrectionAffine(&result, vect);
    1154                         break;
    1155                     case TAKI   :
    1156                         Sockets[i].AlignementAntenne->AppliquerMatriceCorrectionTaki( &result, vect);
    1157                         break;
    1158                     }
    1159 
    1160                     // On récupÚre les nouvelles coordonnées. z ne nous intéresse pas
    1161 
    1162                     newRA  = VerifAngle(result.x + GetTSL());
    1163                     newDEC = result.y;
    1164 
    1165                     AfficherLog("Coordonnees finales: AD = %s  Dec = %s\n", DHMS(newRA*N180divPi, true ).c_str(),
    1166                                 DHMS(newDEC*N180divPi, false ).c_str());
    1167                 }
     1707                /* if ( Sockets[i].AlignementAntenne->MethodeAlignement ==  AFFINE ||
     1708                         Sockets[i].AlignementAntenne->MethodeAlignement ==  TAKI )
     1709                 {
     1710                     // On crée un vecteur avec pour coordonnées
     1711                     // x = Angle horaire de l'objet visé
     1712                     // y = déclinaison de l'objet
     1713                     // z = 1.0
     1714                     // Voir la documentation pour plus d'explications sur le calcul affine/taki
     1715
     1716                     vect.x = VerifAngle( newRA2 + GetTSL() );
     1717                     vect.y = newDEC2;
     1718                     vect.z = 1.0;
     1719
     1720                     // Message pour l'utilisateur et les logs
     1721
     1722                     AfficherLog("Application de la matrice AFFINE/TAKI\n", true);
     1723                     AfficherLog("Coordonnees initiales: AD = %s  Dec = %s\n", DHMS(newRA2*N180divPi, true ).c_str(),
     1724                                 DHMS(newDEC2*N180divPi, false ).c_str());
     1725
     1726                     // On applique la matrice de transformation
     1727
     1728                     switch (Sockets[i].AlignementAntenne->MethodeAlignement)
     1729                     {
     1730                     case AFFINE :
     1731                         Sockets[i].AlignementAntenne->AppliquerMatriceCorrectionAffine(&result, vect);
     1732                         break;
     1733                     case TAKI   :
     1734                         Sockets[i].AlignementAntenne->AppliquerMatriceCorrectionTaki( &result, vect);
     1735                         break;
     1736                     }
     1737
     1738                     // On récupÚre les nouvelles coordonnées. z ne nous intéresse pas
     1739
     1740                     newRA  = VerifAngle(result.x - GetTSL());
     1741                     newDEC = result.y;
     1742
     1743                     AfficherLog("Coordonnees finales: AD = %s  Dec = %s\n", DHMS(newRA*N180divPi, true ).c_str(),
     1744                                 DHMS(newDEC*N180divPi, false ).c_str());
     1745                 }*/
    11681746            }
    11691747            else
    11701748            {
    1171                 if (Sockets[i].AlignementAntenne->AlignementEnCours)
     1749                if (Sockets[i].AlignementAntenne->AlignementEnCours != 0)
    11721750                {
    11731751                    // Si la matrice n'est pas prête, c'est que la procédure d'alignement de l'antenne i n'est pas encore achevée.
     
    11771755                    // entre les deux programmes
    11781756
    1179                     newRA  = VerifAngle(newRA2  + Sockets[i].AlignementAntenne->delta_ad[Sockets[i].AlignementAntenne->nbrcorrections] * PasDeltaAD);
    1180                     newDEC = newDEC2 + Sockets[i].AlignementAntenne->delta_de[Sockets[i].AlignementAntenne->nbrcorrections] * PasDeltaDe;
    1181 
    1182                     AfficherLog("Alignement en cours.\nDelta RA=%i  delta Dec=%i\n", Sockets[i].AlignementAntenne->delta_ad[Sockets[i].AlignementAntenne->nbrcorrections], Sockets[i].AlignementAntenne->delta_de[Sockets[i].AlignementAntenne->nbrcorrections]);
    1183                     AfficherLog("Nouvelles Coordonnées AD =%s  Dec = %s\n", DHMS(newRA*N180divPi, true).c_str(), DHMS(newDEC*N180divPi, false).c_str());
     1757                    newRA  = Sockets[i].AlignementAntenne->delta_ad[Sockets[i].AlignementAntenne->nbrcorrections];
     1758                    newDEC = Sockets[i].AlignementAntenne->delta_de[Sockets[i].AlignementAntenne->nbrcorrections];
     1759
     1760                    AfficherLog("Alignement en cours.\n", true);
     1761
     1762                    AfficherLog("Nouvelles Coordonnées AD =%s  Dec = %s    Ncorrections=%i\n",
     1763                                DHMS(newRA*N180divPi, true).c_str(),
     1764                                DHMS(newDEC*N180divPi, false).c_str(),Sockets[i].AlignementAntenne->nbrcorrections);
    11841765                }
    11851766            }
     
    11931774            // avons vu plus haut
    11941775
    1195             if  (Sockets[i].AlignementAntenne->Matrice_ok && Sockets[i].AlignementAntenne->MethodeAlignement == SIMPLE)
     1776            if  (Sockets[i].AlignementAntenne->Matrice_ok /*&& Sockets[i].AlignementAntenne->MethodeAlignement == SIMPLE*/)
    11961777            {
    11971778                // AprÚs s'être assurer que nous utilisons la méthode SIMPLE et que la matrice de rotation est ok
    11981779
    1199                 AfficherLog("Application de la matrice SIMPLE\nCoordonnees initiales: Azi = %s  Haut = %s\n", DHMS(targetAz*N180divPi, false ).c_str(),
     1780                AfficherLog("Application de la matrice SIMPLE\n", true);
     1781                AfficherLog("Coordonnees initiales: Azi = %s  Haut = %s\n", DHMS(targetAz*N180divPi, false ).c_str(),
    12001782                            DHMS(targetAlt*N180divPi, false ).c_str());
    12011783
     
    12061788                // On reconnaît les formules de passage des coordonnées
    12071789                // sphériques aux coordonnées rectangulaires
    1208 
    1209 
    1210                 vect.x = cos(targetAz) * cos(targetAlt);
    1211                 vect.y = sin(targetAz) * cos(targetAlt);
    1212                 vect.z = sin(targetAlt);
    1213 
    1214 
    1215                 // Application de la matrice SIMPLE
    1216 
    1217                 Sockets[i].AlignementAntenne->AppliquerMatriceCorrectionSimple(&result, vect);
    1218 
    1219 
    1220                 // Là on doit repasser des coordonnées rectangulaires
    1221                 // aux coordonnées sphériques
    1222 
    1223                 if (result.x != 0.0)
     1790                if (Sockets[i].AlignementAntenne->MethodeAlignement == SIMPLE)
    12241791                {
    1225                     targetAz = atan( result.y / result.x );
    1226 
     1792                    vect.x = cos(targetAz) * cos(targetAlt);
     1793                    vect.y = sin(targetAz) * cos(targetAlt);
     1794                    vect.z = sin(targetAlt);
     1795
     1796                    Sockets[i].AlignementAntenne->AppliquerMatriceCorrectionSimple(&result, vect);
     1797
     1798
     1799                    // Là on doit repasser des coordonnées rectangulaires
     1800                    // aux coordonnées sphériques
     1801
     1802                    if (result.x != 0.0)
     1803                    {
     1804                        targetAz = atan( result.y / result.x );
     1805
     1806                        if (result.x < 0) targetAz += Pi;
     1807                    }
     1808                    else targetAz = Pidiv2;
     1809
     1810                    targetAz  = VerifAngle(targetAz);
     1811
     1812                    targetAlt = asin(result.z);
     1813
     1814                }
     1815                else
     1816                {
     1817                    Sockets[i].AlignementAntenne->AzHa2XY(targetAz, targetAlt, &vect.x, &vect.y);
     1818
     1819                    vect.z = 1.0;
     1820     
     1821
     1822             
     1823                    Sockets[i].AlignementAntenne->AppliquerMatriceCorrectionAffine(&result, vect);
     1824
     1825                    // Là on doit repasser des coordonnées rectangulaires
     1826                    // aux coordonnées sphériques
     1827
     1828
     1829
     1830                    targetAz = atan(result.y/result.x);
    12271831                    if (result.x < 0) targetAz += Pi;
     1832
     1833                    targetAlt= Pidiv2 - sqrt(result.x*result.x+result.y*result.y);
     1834
     1835
     1836                    AfficherLog("Coordonnees finales: Azi = %s  Haut = %s\n", DHMS(VerifAngle(targetAz)*N180divPi, false ).c_str(),
     1837                                DHMS(targetAlt*N180divPi, false ).c_str());
    12281838                }
    1229                 else targetAz = Pidiv2;
    1230 
    1231                 targetAz  = VerifAngle(targetAz);
    1232 
    1233                 targetAlt = asin(result.z);
    1234 
    1235 
    1236                 AfficherLog("Coordonnees finales: Azi = %s  Haut = %s\n", DHMS(targetAz*N180divPi, false ).c_str(),
    1237                             DHMS(targetAlt*N180divPi, false ).c_str());
    12381839            }
    12391840
     
    12421843            // Ne s'applique que pour les alignements AFFINE et TAKI
    12431844
    1244             if (Sockets[i].AlignementAntenne->MethodeAlignement != SIMPLE) targetAz += Sockets[i].AlignementAntenne->delta_az_polar * PasDeltaAD;
     1845            //if (Sockets[i].AlignementAntenne->MethodeAlignement != SIMPLE) targetAz += Sockets[i].AlignementAntenne->delta_az_polar * PasDeltaAD;
    12451846
    12461847            // Correction de la réfraction atmosphérique
     
    12671868            // Conversion des deux angles en pas codeurs
    12681869
    1269             /*  if ( targetAlt < HAUTMIN )
    1270               {
    1271                   // L'objet est trop bas ( < 30°). On annule le suivi...
    1272 
    1273                   IDSetSwitch(&OnCoordSetSP, "Erreur ! L objet suivi est situe a moins de 30 deg au-dessus de l horizon. Goto annule.");
    1274 
    1275                   Suivi = false;
    1276 
    1277                   RealisationGoto = false;
    1278 
    1279                   InitAntennes();
    1280 
    1281                   return;
    1282               }
    1283               else*/
     1870            if ( targetAlt < HAUTMIN )
     1871            {
     1872                // L'objet est trop bas ( < 30°). On annule le suivi...
     1873
     1874                IDSetSwitch(&OnCoordSetSP, "Erreur ! L objet suivi est situe a moins de 30 deg au-dessus de l horizon. Goto annule.");
     1875
     1876                Suivi = false;
     1877
     1878                RealisationGoto = false;
     1879
     1880                InitAntennes();
     1881
     1882                return;
     1883            }
     1884            else
    12841885            {
    12851886                // Si la hauteur est supérieure à 90°, on doit ajouter 180° à l'azimut et corriger
     
    12961897                // On applique la formule de Marc pour convertir la hauteur en nombre de pas codeur alt
    12971898
    1298                 Sockets[i].TargetPosition.y = (int) Arrondi( Alt2Motor( targetAlt ) );
     1899                Sockets[i].TargetPosition.y = (long int) Arrondi( Alt2Motor( targetAlt ) );
    12991900
    13001901                //4000 pas pour 360° sur l'axe az
    13011902
    1302                 Sockets[i].TargetPosition.x = (int) Arrondi( targetAz * (double)NBREPASCODEURSAZ / 360.0);
     1903                Sockets[i].TargetPosition.x = (long int) Arrondi( targetAz * (double)NBREPASCODEURSAZ / 360.0);
     1904
     1905                // On ajoute les deltas en AZ et en HA pour la raquette hors procédure d'alignement
     1906
     1907                Sockets[i].TargetPosition.x += delta_az;
     1908                Sockets[i].TargetPosition.y += delta_ha;
     1909
     1910
     1911                // est-ce que le transit de l'objet suivi va nous emmener à sortir de l'intervalle [MINAZCODEURS..MAXAZCODEURS] ?
     1912
     1913                if ( azmincodeur < MINAZCODEURS ) Sockets[i].TargetPosition.x += NBREPASCODEURSAZ;
     1914
     1915                if ( azmincodeur > MAXAZCODEURS ) Sockets[i].TargetPosition.x -= NBREPASCODEURSAZ;
     1916
     1917                // Corrections sup pour rester dans l'intervalle [-1693.. 3867]
     1918
     1919                if ( Sockets[i].TargetPosition.x > MAXAZCODEURS ) Sockets[i].TargetPosition.x -= NBREPASCODEURSAZ;
     1920
     1921                if ( Sockets[i].TargetPosition.x < MINAZCODEURS ) Sockets[i].TargetPosition.x += NBREPASCODEURSAZ;
    13031922
    13041923                // Message de debug
     
    13952014        // On charge les paramÚtres de correction des antennes toutes les demi-secondes
    13962015
     2016        /*
    13972017        if ( compt%500 == 0  && tv.tv_usec/1.0E6 > 0.5 )
    1398         {
    1399             for (int i=1; i<SocketsNumber; i++)
    1400             {
    1401                 if (Sockets[i].Connected)
     2018            {
     2019                for (int i=1; i<SocketsNumber; i++)
    14022020                {
    1403                     // Si l'antenne i est connectée, on charge les paramÚtres
    1404                     Sockets[i].AlignementAntenne->TransmettreParametresClasseAstro(Annee, Mois, Jour, Heu, Min, Sec, Longitude, Latitude, Pression, Temp);
    1405 
    1406                     if (Sockets[i].AlignementAntenne->MethodeAlignement == SIMPLE )
     2021                    if (Sockets[i].Connected)
    14072022                    {
    1408                         //AfficherLog("chargement simple\n");
    1409                         Sockets[i].AlignementAntenne->ChargementParametresAlignement(Sockets[i].IP, "/home/" + (string)getenv("USER") + "/AlignementAntennesSIMPLE.cfg", targetRA * 15 * Pidiv180, targetDEC * Pidiv180);
    1410                     }
    1411                     else
    1412                     {
     2023                        // Si l'antenne i est connectée, on charge les paramÚtres
     2024                        Sockets[i].AlignementAntenne->TransmettreParametresClasseAstro(Annee, Mois, Jour, Heu, Min, Sec, Longitude, Latitude, Pression, Temp);
     2025
    14132026                        // AfficherLog("chargement taki\n");
    1414                         Sockets[i].AlignementAntenne->ChargementParametresAlignement(Sockets[i].IP, "/home/" + (string)getenv("USER") + "/AlignementAntennesTAKI.cfg", targetRA * 15 * Pidiv180, targetDEC * Pidiv180);
     2027                        //  Sockets[i].AlignementAntenne->ChargementParametresAlignement(Sockets[i].IP, "/home/" + (string)getenv("USER") + "/AlignementAntennes.cfg", targetRA * 15 * Pidiv180, targetDEC * Pidiv180);
    14152028                    }
    14162029                }
    1417             }
    1418         }
     2030            }*/
    14192031    }
    14202032
     
    14342046            IDSetSwitch(&ConnectSP, "Connexion de l antenne %s (Antennes connectees : %i)",
    14352047                        Sockets[SocketsNumber-1].IP.c_str(), AntennesConnectees());
     2048
     2049            Sockets[SocketsNumber-1].AlignementAntenne->TransmettreParametresClasseAstro(GetAnnee(), GetMois(), GetJour(), GetHeure(), GetMin(), GetSec(), GetLongitude(), GetLatitude(), GetPression(), GetTemperature());
     2050
     2051
     2052            // Chargement des paramÚtres d'alignement de l'antenne
     2053
     2054            Sockets[SocketsNumber-1].AlignementAntenne->ChargementParametresAlignement(
     2055                Sockets[SocketsNumber-1].IP,
     2056                "/home/" + (string)getenv("USER") + "/AlignementAntennes.cfg",
     2057                targetRA * 15 * Pidiv180,
     2058                targetDEC * Pidiv180);
     2059
    14362060        }
    14372061
     
    22172841        IDSetSwitch (&ParkSP, NULL);
    22182842
     2843        // On cherche l'azimut de l'objet lorsque celui-ci passera en-dessous de 30°
     2844        // Cette recherche est nécessaire pour optimiser le suivi et éviter
     2845        // les rotations inutiles
     2846
     2847        RechercheAzimutFinSuivi(targetRA, targetDEC, &azmincodeur, &azmaxcodeur);
     2848
    22192849        // On prépare les antennes pour le prochain goto
    22202850
     
    22602890        IDSetSwitch (&AbortSlewSP, NULL);
    22612891        IDSetSwitch (&ParkSP, NULL);
     2892
     2893        // On cherche l'azimut de l'objet lorsque celui-ci passera en-dessous de 30°
     2894        // Cette recherche est nécessaire pour optimiser le suivi et éviter
     2895        // les rotations inutiles
     2896
     2897        RechercheAzimutFinSuivi(targetRA, targetDEC, &azmincodeur, &azmaxcodeur);
    22622898
    22632899        InitAntennes();
  • BAORadio/libindi/libindi/drivers/telescope/BAO.h

    r650 r677  
    152152   
    153153    void AfficherLog(const char* Message,...);
     154   
     155   
     156 
     157   
    154158
    155159
     
    164168    ISwitch OnCoordSetS[2];
    165169    ISwitch AlignmentS[3];
     170    ISwitch AlignementAltp[1];
     171    ISwitch AlignementAz[2];
     172    ISwitch AlignementAltn[1];
     173    ISwitch AlignementOk[2];
     174    ISwitch RaquetteN[2];
     175    ISwitch AlignementReset[1];
    166176    ISwitch AbortSlewS[1];
    167177    ISwitch ParkS[1];
     
    171181    IText ObjectT[1];
    172182    IText CommandT[1];
     183    IText AlignementIP[1];
    173184
    174185    /* Numbers */
     
    178189    INumber ActualisationN1[1];
    179190    INumber ActualisationN2[1];
     191   
    180192
    181193    /* Switch Vectors */
     
    183195    ISwitchVectorProperty OnCoordSetSP;
    184196    ISwitchVectorProperty AlignmentSP;
     197    ISwitchVectorProperty AlignementAltpP;
     198    ISwitchVectorProperty AlignementAzP;
     199    ISwitchVectorProperty AlignementAltnP;
     200    ISwitchVectorProperty AlignementOkP;
     201    ISwitchVectorProperty AlignementResetP;
     202    ISwitchVectorProperty RaquetteNP;
    185203    ISwitchVectorProperty AbortSlewSP;
    186204    ISwitchVectorProperty ParkSP;
     
    192210    INumberVectorProperty ActualisationNP1;
    193211    INumberVectorProperty ActualisationNP2;
    194 
    195 
     212   
    196213    /* Text Vectors */
    197214    ITextVectorProperty PortTP;
    198215    ITextVectorProperty ObjectTP;
    199216    ITextVectorProperty CommandTP;
     217    ITextVectorProperty AlignementIPP;
    200218
    201219
     
    229247    int    MethodeAlignement;            // Méthode d'alignement
    230248    BAO_STATUS  TrackingMode;            // Mode de suivi actuellement activé
     249   
     250    long int azmincodeur;
     251    long int azmaxcodeur; 
     252   
     253    int    targetAlignmentIP;
     254   
     255    long int VitesseRaquette;
     256    long int delta_az;
     257    long int delta_ha;
     258   
     259   
    231260};
    232261
  • BAORadio/libindi/libindi/result_recherche_bao

    r652 r677  
    1 
    2 
    3 Results from query to  NASA/IPAC Extragalactic Database (NED),
    4 which is operated by the Jet Propulsion Laboratory, California Institute of
    5 Technology, under contract with the National Aeronautics and Space Administration.
    6 This work was (partially) supported by the US National Virtual Observatory
    7 development project, which is funded by the National Science Foundation
    8 under cooperative agreement AST0122449 with The Johns Hopkins University.
    9 
    10 
    11 
    12 queryDateTime:2012-04-02T02:43:18PDT
    13 
    14 
    15 
    16 Main Information Table for MESSIER 031
    17 
    18 
    19 
    20 Equinox:J2000.0
    21 
    22 
    23 
    24 CoordSystem:Equatorial
    25 
    26 No.|Object Name|RA(deg)|DEC(deg)|Type|Velocity|Redshift|Redshift Flag|Magnitude and Filter|Distance (arcmin)|References|Notes|Photometry Points|Positions|Redshift Points|Diameter Points|Associations
    27 1|MESSIER 031| 10.68479 |  41.26906 |G|  -300|-0.001001 |    | 4.36||3374|18|138|8|26|7|2
     1<PARAM name="Error" >
     2<VALUE><![CDATA[Messages:
     3 
     4    The object name that you submitted is not currently recognized
     5    by the NED name interpreter.
     6 
     7    In general, naming conventions employ a prefix (usually an
     8    acronym for the first author(s) or the survey name) followed
     9    by a numerical string based on a tabular sequence or a position
     10    on the sky. For more specifics, see the document at
     11    http://vizier.u-strasbg.fr/Dic/iau-spec.htx
     12 
     13    Based on your input, we have listed below a number of
     14    possibilities that NED does recognize that reasonably may
     15    include your object/survey and its standardized naming
     16    convention in NED.
     17 
     18 
     19Use this format                    for this catalogue
     20---------------                    ----------------
     21   MAFFEI 2:[TH94] NN              Objects from 1994ApJ...421..122T
     22or MESSIER 051:[TH94] NN
     23or MESSIER 083:[TH94] NN
     24or NGC NNNN:[TH94] NN
     25   [T95] J0240-343A                Objects from 1995MNRAS.277..609T
     26or [T95] 11
     27   TOLOLO NNNNN                    Tololo catalogue
     28   MS 1358.4+6245:[T98] GN         Objects from 1998AJ....115....1T
     29or [YDG81] 1115+080:[T98] Gx
     30or [PBW92] B1422+231:[T98] Gx
     31   TON NNNN                        Tonantzintla catalogue
     32   [T99] GJHHMM-DDMM               Objects from 1999MNRAS.303..565T
     33or [T99] QJHHMM-DDMM
     34   [TH2001] A                      Objects from 2001ApJ...563..673T
     35   [T99a] NN                       Objects from 1999A&A...352L.103T
     36   [TH2002] NNN                    Objects from 2002MNRAS.333..423T
     37   NGC 0253:[TH85] N               Objects from 1985ApJ...299L..77T
     38   NGC 0253:[T2004] A              Objects from 2004AJ....127...10T
     39   HDF:[T2003] NNNN                Objects from 2003ApJ...596..748T
     40   NGC 6822:[T2006] ANN            Objects from 2006AJ....132.1372T
     41 
     42   SN 1995:[T97]                   Object  from 1997A&A...321...81T
     43Key:  A = alphabetic character
     44   :  a = optional alphabetic character
     45   :  B = Besselian 1950 designator
     46   :  b = galactic latitude
     47   : DD = degrees of Declination or day of month
     48   :  d = decimal degrees of Declination
     49   :  F = field/plate name
     50   :  G = galaxy OR galactic coordinates designator
     51   : HH = hours of Right Ascension
     52   :  h = decimal hours of Right Ascension
     53   :  J = Julian 2000 designator
     54   :  L = galactic longitude
     55   :  l = galactic longitude
     56   : MM = minutes of R.A. or time or arcminutes of Dec. or month
     57   :  m = decimal minutes of R.A. or time or arcminutes of Dec.
     58   :  N = numeric character
     59   : SS = seconds of R.A. or time or arcseconds of Dec.
     60   :  s = decimal seconds of R.A. or time or arcseconds of Dec.
     61   : YY = year (2-digit years imply 20th Century except Gamma-ray bursters)
     62   :  Z = integer part of redshift
     63   : zz = decimal portion of redshift
     64   :  + = plus OR minus sign
     65   :  - = dash OR minus sign
     66 
     67]]></VALUE>
     68</PARAM>
Note: See TracChangeset for help on using the changeset viewer.