status_t QClient::notifyCallback(uint32_t msg, uint32_t value) { if (msg > IQService::VPU_COMMAND_LIST_START && msg < IQService::VPU_COMMAND_LIST_END) { return vpuCommand(msg, value); } switch(msg) { case IQService::SECURING: securing(value); break; case IQService::UNSECURING: unsecuring(value); break; case IQService::SCREEN_REFRESH: return screenRefresh(); break; case IQService::EXTERNAL_ORIENTATION: setExtOrientation(value); break; case IQService::BUFFER_MIRRORMODE: setBufferMirrorMode(value); break; default: return NO_ERROR; } return NO_ERROR; }
void _astar_addToOpenList (PATHFINDER_POINT point) { astar_map [point.x][point.y].liste = ASTAR_OPENLIST; #ifdef ASTAR_DEBUG SCREEN_COLOR couleur; couleur.rouge = 0x00; couleur.vert = 0xff; couleur.bleu = 0xff; screenSetPixel (point.x, point.y, couleur); screenRefresh (); #endif }
status_t QClient::notifyCallback(uint32_t command, const Parcel* inParcel, Parcel* outParcel) { status_t ret = NO_ERROR; switch(command) { case IQService::SECURING: securing(mHwcContext, inParcel->readInt32()); break; case IQService::UNSECURING: unsecuring(mHwcContext, inParcel->readInt32()); break; case IQService::SCREEN_REFRESH: return screenRefresh(mHwcContext); break; case IQService::EXTERNAL_ORIENTATION: setExtOrientation(mHwcContext, inParcel->readInt32()); break; case IQService::BUFFER_MIRRORMODE: setBufferMirrorMode(mHwcContext, inParcel->readInt32()); break; case IQService::GET_DISPLAY_VISIBLE_REGION: ret = getDisplayVisibleRegion(mHwcContext, inParcel->readInt32(), outParcel); break; case IQService::CHECK_EXTERNAL_STATUS: isExternalConnected(mHwcContext, outParcel); break; case IQService::GET_DISPLAY_ATTRIBUTES: getDisplayAttributes(mHwcContext, inParcel, outParcel); break; case IQService::SET_HSIC_DATA: setHSIC(mHwcContext, inParcel); break; default: ret = NO_ERROR; } return ret; }
void astar (PATHFINDER_POINT start, PATHFINDER_POINT end) { _astar_init (); PATHFINDER_POINT currentNode; int i; currentNode.x = -1; currentNode.y = -1; currentNode.poids = 0; currentNode.malus = 0; #ifdef ASTAR_DEBUG2 printf ("Start : [%d, %d]\n", start.x, start.y); printf ("End : [%d, %d]\n", end.x, end.y); printf ("Distance : %f\n\n", pathfinderHeuristique (abs (end.x - start.x), abs (end.y - start.y))); #endif #ifdef ASTAR_DEBUG SCREEN_COLOR couleur; couleur.rouge = 0xff; couleur.vert = 0x00; couleur.bleu = 0x00; screenSetPixel (start.x, start.y, couleur); screenSetPixel (start.x + 1, start.y, couleur); screenSetPixel (start.x - 1, start.y, couleur); screenSetPixel (start.x, start.y + 1, couleur); screenSetPixel (start.x, start.y - 1, couleur); couleur.rouge = 0x00; couleur.vert = 0xff; couleur.bleu = 0x00; screenSetPixel (end.x, end.y, couleur); screenSetPixel (end.x + 1, end.y, couleur); screenSetPixel (end.x - 1, end.y, couleur); screenSetPixel (end.x, end.y + 1, couleur); screenSetPixel (end.x, end.y - 1, couleur); screenRefresh (); #endif _astar_addToOpenList (start); int cpt = 1; while (!_astar_isEmptyOpenList ()) // stopper la boucle si la liste ouverte est vide { #ifdef ASTAR_DEBUG2 printf ("\nItération n°%d : \n", cpt); #endif // a. Récupération du node avec le plus petit F contenu dans la liste ouverte. On le nommera CURRENT. currentNode = _astar_getCurrentNode (currentNode); #ifdef ASTAR_DEBUG2 printf ("Noeud étudié : [%d, %d] (f = %f)\n", currentNode.x, currentNode.y, astar_map [currentNode.x][currentNode.y].f); #endif cpt++; // if (cpt > 800 - 126 + 100) // return; // stopper la boucle si on ajoute le noeud d'arrivée à la liste fermée if (currentNode.x == end.x && currentNode.y == end.y) break; // b. Basculer CURRENT dans la liste fermée. _astar_addToCloseList (currentNode); // récupération des voisins de CURRENT #if PATHFINDER_WITH_DIAGONALE == TRUE PATHFINDER_POINT neighbours [8]; #else PATHFINDER_POINT neighbours [4]; #endif _astar_getNeighbours (currentNode, neighbours); #ifdef ASTAR_DEBUG2 printf ("Seuls les voisins suivants reste à étudier :\n"); #endif // Pour chacun des 8 nodes adjacents à CURRENT appliquer la méthode suivante: #if PATHFINDER_WITH_DIAGONALE == TRUE for (i = 0; i < 8; ++i) #else for (i = 0; i < 4; ++i) #endif { PATHFINDER_POINT neighbour = neighbours [i]; #ifdef ASTAR_DEBUG2 printf ("Voisin %d : [%d, %d]\n", i, neighbour.x, neighbour.y); #endif if (neighbour.x == -1 || neighbour.y == -1) continue; // Si le neighbour est un obstacle ou est dans la liste fermée ignorez-le et passer à l'analyse d'un autre neighbour. if (_astar_isOnCloseList (neighbour) || !fieldIsAccessible (neighbour.x, neighbour.y)) continue; #ifdef ASTAR_DEBUG2 printf ("Voisin %d : [%d, %d] (%f + %f = %f)\n", i, neighbour.x, neighbour.y, astar_map [neighbour.x][neighbour.y].g, astar_map [neighbour.x][neighbour.y].h, astar_map [neighbour.x][neighbour.y].f); #endif // on calcule le nouveau g int malus_terrain = fieldMalusTerrain (neighbour.x, neighbour.y); double newG = astar_map [currentNode.x][currentNode.y].g + neighbour.poids + neighbour.malus + malus_terrain; #ifdef ASTAR_DEBUG2 printf ("newG = %f\n", newG); #endif // Si il n'a jamais été analysé ou qu'on lui ait trouvé un meilleur G if (astar_map [neighbour.x][neighbour.y].g == 0.0 || newG <= astar_map [neighbour.x][neighbour.y].g) { astar_map [neighbour.x][neighbour.y].g = newG; if (astar_map [neighbour.x][neighbour.y].h == 0.0) { astar_map [neighbour.x][neighbour.y].h = pathfinderHeuristique (abs (neighbour.x - end.x), abs (neighbour.y - end.y)); } astar_map [neighbour.x][neighbour.y].f = astar_map [neighbour.x][neighbour.y].g + astar_map [neighbour.x][neighbour.y].h; astar_map [neighbour.x][neighbour.y].parent_x = currentNode.x; astar_map [neighbour.x][neighbour.y].parent_y = currentNode.y; _astar_addToOpenList (neighbour); #ifdef ASTAR_DEBUG2 printf ("Ajout ou modif voisin %d : [%d, %d] (%f + %f = %f)\n", i, neighbour.x, neighbour.y, astar_map [neighbour.x][neighbour.y].g, astar_map [neighbour.x][neighbour.y].h, astar_map [neighbour.x][neighbour.y].f); #endif } } } // on est sorti de la liste, on a deux solutions, soit la liste ouverte est vide dans ces cas là il // n'y a pas de solutions et on retoure directement finalPath; if (_astar_isEmptyOpenList ()) printf ("Pas de résultat\n"); // Soit on maintenant on construit le chemin à rebours; PATHFINDER_POINT lastNode = end; double angle = -1; double angle2; while (lastNode.x != start.x || lastNode.y != start.y) { PATHFINDER_POINT point1, point2; point1.x = lastNode.x; point1.y = lastNode.y; ASTAR_MAP_POINT point = astar_map [lastNode.x][lastNode.y]; #ifdef ASTAR_DEBUG2 printf ("[%d, %d]\n", lastNode.x * FIELD_RESOLUTION, lastNode.y * FIELD_RESOLUTION); #endif #ifdef ASTAR_DEBUG SCREEN_COLOR couleur; couleur.rouge = 0xff; couleur.vert = 0x00; couleur.bleu = 0xff; screenSetPixel (lastNode.x, lastNode.y, couleur); screenRefresh (); #endif lastNode.x = point.parent_x; lastNode.y = point.parent_y; point2.x = lastNode.x; point2.y = lastNode.y; angle2 = pathfinderAngle (point1, point2); if (angle == -1 || angle != angle2) { printf ("[%d, %d]\n", point1.x * FIELD_RESOLUTION, point1.y * FIELD_RESOLUTION); angle = angle2; } } printf ("Checkpoint [%d, %d]\n", start.x * FIELD_RESOLUTION, start.y * FIELD_RESOLUTION); }