Changeset 497 for BAORadio/libindi


Ignore:
Timestamp:
Sep 21, 2010, 2:16:31 PM (14 years ago)
Author:
frichard
Message:

-Correction d'un bug concernant la gestion des erreurs générées par les antennes
-Actualisation du code pour qu'il soit conforme à la version 7 du document de travail

Location:
BAORadio/libindi/libindi
Files:
3 edited

Legend:

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

    r496 r497  
    193193         
    194194
    195                         if (asks.find("s")!=string::npos)
    196                         {
    197                             strcpy(chaine, "ACK/STATUS\n");
    198                             client_socket << chaine;
    199 
    200                             if (Affichage) std::cout <<  "Microcontrôleur : " << chaine;
    201 
    202                             if (Aleat)
    203                             {
    204                                 strcpy(chaine, "STATUS/READY\n");
    205                             }
    206                             else
    207                             {
    208                                 strcpy(chaine, "STATUS/BUSY\n");
    209                             }
    210                         }
    211 
    212                         if (asks.find("p")!=string::npos)
    213                         {
    214 
    215                             strcpy(chaine,"ACK/POSITION\n");
    216                             client_socket << chaine;
     195                        if (asks.find("p")!=string::npos)
     196                        {
     197
     198                           strcpy(chaine,"ACK/POSITION\n");
     199                           client_socket << chaine;
    217200
    218201                            if (Affichage) std::cout <<  "Microcontrôleur : " << chaine;
     
    257240                        }
    258241
    259                         if (asks.find("pa")!=string::npos)
     242                        if (asks.find("z")!=string::npos)
    260243                        {
    261244
  • BAORadio/libindi/libindi/drivers/telescope/BAO.cpp

    r495 r497  
    234234    Park=false;
    235235    Goto=false;
     236    LastGotoOK=true;
    236237   
    237238    TrackingMode=1;
     
    879880    static int memSocketsNumber=-1;
    880881    static unsigned int compt=100;
     882   
    881883    int pos;
    882884   
     
    972974           
    973975            if ((reponse.find("ACK")!=string::npos) && (reponse.find("NACK")==string::npos))
    974             {
    975               /*if (reponse.find("STATUS")!=string::npos)
    976               {
    977                 Sockets[i].ack_status=true;
    978               } else*/
     976            {         
    979977              if (reponse.find("POS")!=string::npos)
    980978              {
     
    996994            else
    997995            {
    998               //réponse à la requête STATUS
    999               /*if (reponse.find("STATUS")!=string::npos)
    1000               {
    1001                 if (reponse.find("READY")!=string::npos)
    1002                 {
    1003                   Sockets[i].status='R';
    1004                 }
    1005                 else if (reponse.find("BUSY")!=string::npos)
    1006                 {
    1007                   Sockets[i].status='B';
    1008                 }
    1009                
    1010               } else*/
     996             
    1011997              //réponse à la requête POSITION
    1012998              if (reponse.find("POS")!=string::npos)
     
    10211007                              Sockets[i].Connected=false;
    10221008                }
    1023                 else
     1009                else if (Sockets[i].ack_pos)
    10241010                {
    10251011                  OnCoordSetSP.s = IPS_OK;
     
    10371023                  ParkSP.s = IPS_ALERT;
    10381024                  IDSetSwitch(&ParkSP, "ALERTE antenne %s : erreur PARK !\n", Sockets[i].IP.c_str());
    1039                 } else if (reponse.find("OK")!=string::npos)
     1025                }
     1026                else if (reponse.find("OK")!=string::npos)
    10401027                {
    10411028                  ParkSP.s = IPS_OK;
     
    10671054                  Sockets[i].Connected=false;
    10681055                }
    1069                 else
     1056                else if (Sockets[i].ack_goto)
    10701057                {
    1071                   OnCoordSetSP.s = IPS_OK;
     1058                  if (reponse.find("OK")!=string::npos)
     1059                  {
     1060                    OnCoordSetSP.s = IPS_OK;
    10721061                 
    1073                   Sockets[i].GotoOk=true;
     1062                    Sockets[i].GotoOk=true;
    10741063                 
    1075                   IDSetSwitch(&ParkSP, "Antenne %s : GOTO OK.\n",  Sockets[i].IP.c_str());
     1064                    IDSetSwitch(&ParkSP, "Antenne %s : GOTO OK.\n",  Sockets[i].IP.c_str());
    10761065                 
    1077                   lastRA  = targetRA;
    1078                   lastDEC = targetDEC;
     1066                    lastRA  = targetRA;
     1067                    lastDEC = targetDEC;
    10791068                 
    1080                   //IDLog("We received JNow RA %s - DEC %s\n", RAStr, DecStr);*/
     1069                     //IDLog("We received JNow RA %s - DEC %s\n", RAStr, DecStr);*/
    10811070                 
    1082                   EquatorialCoordsWNP.s = IPS_OK;
    1083                   IDSetNumber (&EquatorialCoordsWNP, NULL);
     1071                    EquatorialCoordsWNP.s = IPS_OK;
     1072                    IDSetNumber (&EquatorialCoordsWNP, NULL);
    10841073                 
    1085                   // Fin du Goto pour toutes les antennes ?
     1074                    // Fin du Goto pour toutes les antennes ?
    10861075                 
    1087                   int num=0;
     1076                    int num=0;
    10881077                 
    1089                   for (int j=1; j<SocketsNumber; j++) if (Sockets[j].Connected)
    1090                   {
    1091                     if (Sockets[j].GotoOk) num++;
    1092                   }
     1078                    for (int j=1; j<SocketsNumber; j++) if (Sockets[j].Connected)
     1079                    {
     1080                      if (Sockets[j].GotoOk) num++;
     1081                    }
    10931082                 
    1094                   if ((num == AntennesConnectees()) && (num>0))
    1095                   {
    1096                     LecturePosition=false;
     1083                    if ((num == AntennesConnectees()) && (num>0))
     1084                    {
     1085                      LecturePosition=false;
    10971086                   
    1098                     InitAntennes();
     1087                      InitAntennes();
     1088                     
     1089                      LastGotoOK=true;
    10991090                   
    1100                     IDSetSwitch(&OnCoordSetSP, "GOTO OK !");
    1101                   }
     1091                      IDSetSwitch(&OnCoordSetSP, "GOTO OK !");
     1092                    }
     1093                  } 
    11021094                }
    11031095              }
     
    11751167      // Gestion du suivi
    11761168     
    1177       if (Goto)
     1169      if ((Goto) && (LastGotoOK))
    11781170      {
    11791171        // Durée entre deux actualisations
     
    11881180          if (JJ-JJAnc > delai)
    11891181          {
     1182           
     1183            LastGotoOK=false;
     1184           
    11901185            ADDEC2Motor(targetRA, targetDEC);
    11911186           
     
    12221217          switch (Sockets[i].etape)
    12231218          {
    1224             //Envoi des requêtes STATUS
    1225             /*case 0 :
    1226             {
    1227               Sockets[i].AttenteExecution=0;
    1228               Sockets[i].ack_status=false;
    1229               Sockets[i].status=0;
    1230              
    1231               if (!STATUS(i)) Sockets[i].sendalertes++;
    1232              
    1233               Sockets[i].etape++;
    1234             }
    1235             break;
    1236            
    1237             //vérification ack statuts
    1238             case 1 :
    1239             {
    1240               if (Sockets[i].ack_status)
    1241               {
    1242                 Sockets[i].AttenteExecution=0;
    1243                 Sockets[i].etape++;
    1244                 i--;
    1245               }
    1246               else
    1247               {
    1248                 // on réitÚre l'ordre précédent si rien ne se passe
    1249                
    1250                 Sockets[i].AttenteExecution++;
    1251                
    1252                 if (Sockets[i].AttenteExecution>MAXATTENTE)
    1253                 {
    1254                   Sockets[i].etape=0;
    1255                   Sockets[i].AttenteExecution=0;
    1256                   Sockets[i].AnomaliesExecution++;
    1257                 }
    1258                
    1259                 if (Sockets[i].AnomaliesExecution>MAXANOMALIES)
    1260                 {
    1261                   Sockets[i].etape=6;
    1262                  
    1263                   if ( compt % 1000 == 0)
    1264                   {
    1265                     IDSetSwitch(&OnCoordSetSP, "ERREUR 1000 : Erreur critique sur l antenne %s. Déconnexion de l antenne.",
    1266                                 Sockets[i].IP.c_str());
    1267                                
    1268                                 // Sockets[i].Connected=false;
    1269                   }
    1270                 }
    1271               }
    1272             }
    1273             break;
    1274            
    1275             //status ready ?
    1276             case 2 :
    1277             {
    1278               if (Sockets[i].status == 'R')
    1279               {
    1280                 Sockets[i].AttenteExecution=0;
    1281                 Sockets[i].etape++;
    1282                 i--;
    1283               }
    1284               else
    1285               {
    1286                 // on réitÚre l'ordre précédent si rien ne se passe
    1287                
    1288                 Sockets[i].AttenteExecution++;
    1289                
    1290                 if (Sockets[i].AttenteExecution>MAXATTENTE)
    1291                 {
    1292                   Sockets[i].etape=0;
    1293                   Sockets[i].AttenteExecution=0;
    1294                   Sockets[i].AnomaliesExecution++;
    1295                 }
    1296                
    1297                 if (Sockets[i].AnomaliesExecution>MAXANOMALIES)
    1298                 {
    1299                   Sockets[i].etape=6;
    1300                  
    1301                   if ( compt % 1000 == 0)
    1302                   {
    1303                     IDSetSwitch(&OnCoordSetSP, "ERREUR 1001 : Erreur critique sur l antenne %s. Déconnexion de l antenne.",
    1304                                 Sockets[i].IP.c_str());
    1305                                 //  Sockets[i].Connected=false;
    1306                   }
    1307                 }
    1308               }
    1309             }
    1310             break;*/
    1311            
     1219           
    13121220            //Envoi de la commande POS
    13131221            case 0 :
     
    13281236              {
    13291237                Sockets[i].AttenteExecution=0;
     1238                Sockets[i].AnomaliesExecution=0;
    13301239                Sockets[i].etape++;
    13311240                i--;
     
    13481257                  Sockets[i].etape=3;
    13491258                 
    1350                   if ( compt % 1000 == 0)
     1259                 // if ( compt % 1000 == 0)
    13511260                  {
    1352                     IDSetSwitch(&OnCoordSetSP, "ERREUR 1002 : Erreur critique sur l antenne %s. Déconnexion de l antenne.",
     1261                    IDSetSwitch(&OnCoordSetSP, "ERREUR 1001 : Erreur critique sur l antenne %s. Déconnexion de l antenne.",
    13531262                                Sockets[i].IP.c_str());
    1354                                 // Sockets[i].Connected=false;
     1263                                Sockets[i].Connected=false;
    13551264                  }
    13561265                }
     
    13751284                if (Sockets[i].AttenteExecution>MAXATTENTE)
    13761285                {
    1377                   Sockets[i].etape=0;
     1286                  Sockets[i].etape=2;
    13781287                  Sockets[i].AttenteExecution=0;
    13791288                  Sockets[i].AnomaliesExecution++;
     
    13841293                  Sockets[i].etape=3;
    13851294                 
    1386                   if ( compt % 1000 == 0)
     1295                 // if ( compt % 1000 == 0)
    13871296                  {
    1388                     IDSetSwitch(&OnCoordSetSP, "ERREUR 1003 : Erreur critique sur l antenne %s. Déconnexion de l antenne.",
     1297                    IDSetSwitch(&OnCoordSetSP, "ERREUR 1002 : Erreur critique sur l antenne %s. Déconnexion de l antenne.",
    13891298                                Sockets[i].IP.c_str());
    1390                                 // Sockets[i].Connected=false;
     1299                                Sockets[i].Connected=false;
    13911300                  }
    13921301                }
     
    13951304            break;
    13961305           
     1306            //ack goto  ?
     1307            case 4 :
     1308            {
     1309              if (Sockets[i].ack_goto)
     1310              {
     1311                Sockets[i].AttenteExecution=0;
     1312                Sockets[i].AnomaliesExecution=0;
     1313                Sockets[i].etape++;
     1314              }
     1315              else
     1316              {
     1317                // on réitÚre l'ordre précédent si rien ne se passe
     1318               
     1319                Sockets[i].AttenteExecution++;
     1320               
     1321                if (Sockets[i].AttenteExecution>MAXATTENTE)
     1322                {
     1323                  Sockets[i].etape=4;
     1324                  Sockets[i].AttenteExecution=0;
     1325                  Sockets[i].AnomaliesExecution++;
     1326                }
     1327               
     1328                if (Sockets[i].AnomaliesExecution>MAXANOMALIES)
     1329                {
     1330                  Sockets[i].etape=6;
     1331                 
     1332                 // if ( compt % 1000 == 0)
     1333                  {
     1334                    IDSetSwitch(&OnCoordSetSP, "ERREUR 1003 : Erreur critique sur l antenne %s. Déconnexion de l antenne.",
     1335                                Sockets[i].IP.c_str());
     1336                                Sockets[i].Connected=false;
     1337                  }
     1338                }
     1339              }
     1340            }
     1341            break;
     1342           
     1343            //goto ok  ?
     1344            case 5 :
     1345            {
     1346              if (Sockets[i].GotoOk)
     1347              {
     1348                Sockets[i].AttenteExecution=0;
     1349                Sockets[i].AnomaliesExecution=0;
     1350                Sockets[i].etape++;
     1351              }
     1352              else
     1353              {
     1354                // on réitÚre l'ordre précédent si rien ne se passe
     1355               
     1356                Sockets[i].AttenteExecution++;
     1357               
     1358                if (Sockets[i].AttenteExecution>MAXATTENTE)
     1359                {
     1360                  Sockets[i].etape=5;
     1361                  Sockets[i].AttenteExecution=0;
     1362                  Sockets[i].AnomaliesExecution++;
     1363                }
     1364               
     1365                if (Sockets[i].AnomaliesExecution>MAXANOMALIESGOTO)
     1366                {
     1367                  Sockets[i].etape=6;
     1368                 
     1369                 // if ( compt % 1000 == 0)
     1370                  {
     1371                    IDSetSwitch(&OnCoordSetSP, "ERREUR 1004 : Erreur critique sur l antenne %s. Déconnexion de l antenne.",
     1372                                Sockets[i].IP.c_str());
     1373                                Sockets[i].Connected=false;
     1374                               
     1375                               
     1376                  }
     1377                }
     1378              }
     1379            }
     1380            break;
     1381           
    13971382          }
    13981383        }
     
    14101395        if (Sockets[i].sendalertes > 0)
    14111396        {
    1412           Sockets[i].etape=3;
     1397          Sockets[i].etape=5;
    14131398         
    1414           if ( compt % 1000 == 0)
     1399        //  if ( compt % 1000 == 0)
    14151400          {
    1416             IDSetSwitch(&OnCoordSetSP, "Erreur 1004 : Anomalie détectée sur l antenne %s. Déconnexion de l antenne.",
     1401            IDSetSwitch(&OnCoordSetSP, "Erreur 1005 : Anomalie détectée sur l antenne %s. Déconnexion de l antenne.",
    14171402                        Sockets[i].IP.c_str());
    14181403                       
    1419                         //  Sockets[i].Connected=false;
     1404                        Sockets[i].Connected=false;
    14201405          }
    14211406        }
     
    14391424        {
    14401425          Sockets[i].ack_goto=false;
    1441          
    1442           //pour tester le programme de François, on envoie ces coordonnees sur sa demande
    1443           //if (!GOTO(i, 1000, -3000)) Sockets[i].sendalertes++;
     1426          Sockets[i].AttenteExecution=0;
     1427          Sockets[i].AnomaliesExecution=0;
    14441428         
    14451429          if (!GOTO(i, Sockets[i].Pos.x - TargetPosition.x, Sockets[i].Pos.y - TargetPosition.y )) Sockets[i].sendalertes++;
     
    14501434     
    14511435     
    1452       /*
    1453       switch (EquatorialCoordsWNP.s)
    1454       {
    1455         case IPS_IDLE:
    1456          
    1457           break;
    1458          
    1459         case IPS_BUSY:
    1460          
    1461           switch (currentSet)
    1462           {
    1463             case LX200_TRANSIT:
    1464               OnCoordSetSP.sp[LX200_TRANSIT].s = ISS_ON;
    1465               IDSetSwitch (&OnCoordSetSP, "Slew is complete.");
    1466               break;
    1467              
    1468             case LX200_TRACKING:
    1469               OnCoordSetSP.sp[LX200_TRACKING].s = ISS_ON;
    1470               IDSetSwitch (&OnCoordSetSP, "Slew is complete. Tracking...");
    1471               break;
    1472     }
    1473    
    1474     break;
    1475    
    1476             case IPS_OK:
    1477              
    1478               break;
    1479              
    1480             case IPS_ALERT:
    1481              
    1482               break;
    1483     }*/
     1436       
    14841437    }
    14851438   
     
    15111464        Goto=true;
    15121465       
     1466        LastGotoOK=false;
     1467       
    15131468        LecturePosition=true;
    15141469       
     
    15291484       
    15301485        Goto=true;
     1486       
     1487        LastGotoOK=false;
    15311488       
    15321489        LecturePosition=true;
     
    17201677  bool BAO::PARK(int numsocket)
    17211678  {
    1722     return COMMANDE(numsocket, (char*)"p", (char*)"");
     1679    return COMMANDE(numsocket, (char*)"z", (char*)"");
    17231680  }
    17241681 
  • BAORadio/libindi/libindi/drivers/telescope/BAO.h

    r495 r497  
    3232#define MAXATTENTE 40                //Si une commande ne recoit pas d'acknowledge. Alors refaire 40 tentatives en renvoyant la commande
    3333#define MAXANOMALIES 2               //Si pas de réponse au bout de 80 tentatives -> erreur critique -> socket perdu ?
     34#define MAXANOMALIESGOTO 1000
    3435
    3536struct Position
     
    185186    bool   Goto;
    186187    bool   BAOConnected;
     188    bool   LastGotoOK;
    187189   
    188190    int    fd;                          /* Telescope tty file descriptor */
Note: See TracChangeset for help on using the changeset viewer.