Changeset 497 for BAORadio/libindi
- Timestamp:
- Sep 21, 2010, 2:16:31 PM (14 years ago)
- Location:
- BAORadio/libindi/libindi
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
BAORadio/libindi/libindi/BAOTest/BAOtest_main.cpp
r496 r497 193 193 194 194 195 if (asks.find("s")!=string::npos) 196 { 197 strcpy(chaine, "ACK/STATUS\n"); 198 client_socket << chaine; 199 200 if (Affichage) std::cout << "MicrocontroÌ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; 217 200 218 201 if (Affichage) std::cout << "MicrocontroÌleur : " << chaine; … … 257 240 } 258 241 259 if (asks.find(" pa")!=string::npos)242 if (asks.find("z")!=string::npos) 260 243 { 261 244 -
BAORadio/libindi/libindi/drivers/telescope/BAO.cpp
r495 r497 234 234 Park=false; 235 235 Goto=false; 236 LastGotoOK=true; 236 237 237 238 TrackingMode=1; … … 879 880 static int memSocketsNumber=-1; 880 881 static unsigned int compt=100; 882 881 883 int pos; 882 884 … … 972 974 973 975 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 { 979 977 if (reponse.find("POS")!=string::npos) 980 978 { … … 996 994 else 997 995 { 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 1011 997 //réponse à la requête POSITION 1012 998 if (reponse.find("POS")!=string::npos) … … 1021 1007 Sockets[i].Connected=false; 1022 1008 } 1023 else 1009 else if (Sockets[i].ack_pos) 1024 1010 { 1025 1011 OnCoordSetSP.s = IPS_OK; … … 1037 1023 ParkSP.s = IPS_ALERT; 1038 1024 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) 1040 1027 { 1041 1028 ParkSP.s = IPS_OK; … … 1067 1054 Sockets[i].Connected=false; 1068 1055 } 1069 else 1056 else if (Sockets[i].ack_goto) 1070 1057 { 1071 OnCoordSetSP.s = IPS_OK; 1058 if (reponse.find("OK")!=string::npos) 1059 { 1060 OnCoordSetSP.s = IPS_OK; 1072 1061 1073 Sockets[i].GotoOk=true;1062 Sockets[i].GotoOk=true; 1074 1063 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()); 1076 1065 1077 lastRA = targetRA;1078 lastDEC = targetDEC;1066 lastRA = targetRA; 1067 lastDEC = targetDEC; 1079 1068 1080 //IDLog("We received JNow RA %s - DEC %s\n", RAStr, DecStr);*/1069 //IDLog("We received JNow RA %s - DEC %s\n", RAStr, DecStr);*/ 1081 1070 1082 EquatorialCoordsWNP.s = IPS_OK;1083 IDSetNumber (&EquatorialCoordsWNP, NULL);1071 EquatorialCoordsWNP.s = IPS_OK; 1072 IDSetNumber (&EquatorialCoordsWNP, NULL); 1084 1073 1085 // Fin du Goto pour toutes les antennes ?1074 // Fin du Goto pour toutes les antennes ? 1086 1075 1087 int num=0;1076 int num=0; 1088 1077 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 } 1093 1082 1094 if ((num == AntennesConnectees()) && (num>0))1095 {1096 LecturePosition=false;1083 if ((num == AntennesConnectees()) && (num>0)) 1084 { 1085 LecturePosition=false; 1097 1086 1098 InitAntennes(); 1087 InitAntennes(); 1088 1089 LastGotoOK=true; 1099 1090 1100 IDSetSwitch(&OnCoordSetSP, "GOTO OK !"); 1101 } 1091 IDSetSwitch(&OnCoordSetSP, "GOTO OK !"); 1092 } 1093 } 1102 1094 } 1103 1095 } … … 1175 1167 // Gestion du suivi 1176 1168 1177 if ( Goto)1169 if ((Goto) && (LastGotoOK)) 1178 1170 { 1179 1171 // Durée entre deux actualisations … … 1188 1180 if (JJ-JJAnc > delai) 1189 1181 { 1182 1183 LastGotoOK=false; 1184 1190 1185 ADDEC2Motor(targetRA, targetDEC); 1191 1186 … … 1222 1217 switch (Sockets[i].etape) 1223 1218 { 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 1312 1220 //Envoi de la commande POS 1313 1221 case 0 : … … 1328 1236 { 1329 1237 Sockets[i].AttenteExecution=0; 1238 Sockets[i].AnomaliesExecution=0; 1330 1239 Sockets[i].etape++; 1331 1240 i--; … … 1348 1257 Sockets[i].etape=3; 1349 1258 1350 if ( compt % 1000 == 0)1259 // if ( compt % 1000 == 0) 1351 1260 { 1352 IDSetSwitch(&OnCoordSetSP, "ERREUR 100 2: 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.", 1353 1262 Sockets[i].IP.c_str()); 1354 //Sockets[i].Connected=false;1263 Sockets[i].Connected=false; 1355 1264 } 1356 1265 } … … 1375 1284 if (Sockets[i].AttenteExecution>MAXATTENTE) 1376 1285 { 1377 Sockets[i].etape= 0;1286 Sockets[i].etape=2; 1378 1287 Sockets[i].AttenteExecution=0; 1379 1288 Sockets[i].AnomaliesExecution++; … … 1384 1293 Sockets[i].etape=3; 1385 1294 1386 if ( compt % 1000 == 0)1295 // if ( compt % 1000 == 0) 1387 1296 { 1388 IDSetSwitch(&OnCoordSetSP, "ERREUR 100 3: 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.", 1389 1298 Sockets[i].IP.c_str()); 1390 //Sockets[i].Connected=false;1299 Sockets[i].Connected=false; 1391 1300 } 1392 1301 } … … 1395 1304 break; 1396 1305 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 1397 1382 } 1398 1383 } … … 1410 1395 if (Sockets[i].sendalertes > 0) 1411 1396 { 1412 Sockets[i].etape= 3;1397 Sockets[i].etape=5; 1413 1398 1414 if ( compt % 1000 == 0)1399 // if ( compt % 1000 == 0) 1415 1400 { 1416 IDSetSwitch(&OnCoordSetSP, "Erreur 100 4: 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.", 1417 1402 Sockets[i].IP.c_str()); 1418 1403 1419 //Sockets[i].Connected=false;1404 Sockets[i].Connected=false; 1420 1405 } 1421 1406 } … … 1439 1424 { 1440 1425 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; 1444 1428 1445 1429 if (!GOTO(i, Sockets[i].Pos.x - TargetPosition.x, Sockets[i].Pos.y - TargetPosition.y )) Sockets[i].sendalertes++; … … 1450 1434 1451 1435 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 1484 1437 } 1485 1438 … … 1511 1464 Goto=true; 1512 1465 1466 LastGotoOK=false; 1467 1513 1468 LecturePosition=true; 1514 1469 … … 1529 1484 1530 1485 Goto=true; 1486 1487 LastGotoOK=false; 1531 1488 1532 1489 LecturePosition=true; … … 1720 1677 bool BAO::PARK(int numsocket) 1721 1678 { 1722 return COMMANDE(numsocket, (char*)" p", (char*)"");1679 return COMMANDE(numsocket, (char*)"z", (char*)""); 1723 1680 } 1724 1681 -
BAORadio/libindi/libindi/drivers/telescope/BAO.h
r495 r497 32 32 #define MAXATTENTE 40 //Si une commande ne recoit pas d'acknowledge. Alors refaire 40 tentatives en renvoyant la commande 33 33 #define MAXANOMALIES 2 //Si pas de réponse au bout de 80 tentatives -> erreur critique -> socket perdu ? 34 #define MAXANOMALIESGOTO 1000 34 35 35 36 struct Position … … 185 186 bool Goto; 186 187 bool BAOConnected; 188 bool LastGotoOK; 187 189 188 190 int fd; /* Telescope tty file descriptor */
Note: See TracChangeset
for help on using the changeset viewer.