TTPA (Mobile)  1.1
BTS SN-IR La Salle Avignon 2018
 Tout Classes Fichiers Fonctions Variables
Fonctions membres publiques | Attributs publics | Fonctions membres protégées | Attributs de paquetage | Fonctions membres privées | Attributs privés | Attributs privés statiques
Référence de la classe com.ttpa.iris.ttpamobile.IHMEcranPrincipal
Graphe d'héritage de com.ttpa.iris.ttpamobile.IHMEcranPrincipal:
Inheritance graph
[légende]
Graphe de collaboration de com.ttpa.iris.ttpamobile.IHMEcranPrincipal:
Collaboration graph
[légende]

Liste de tous les membres

Fonctions membres publiques

void onClick (View element)
void onProgressChanged (SeekBar seekBar, int progress, boolean fromUser)
void onStartTrackingTouch (SeekBar seekBar)
void onStopTrackingTouch (SeekBar seekBar)

Attributs publics

ParametreSeance parametresActuels = new ParametreSeance()

Fonctions membres protégées

void onCreate (Bundle savedInstanceState)

Attributs de paquetage

int idZonePrecedente = -1
int idZonePrecedenteObjectif = -1
int idZonePrecedenteRobot = -1
String strZoneObjectif = new String("ZONE 0")
int zoneObjectif = 0
String strZoneRobot = new String("ZONE 0")
int zoneRobot = 0
List< PeripheriqueBluetoothperipheriques
PeripheriqueBluetooth peripheriqueBluetoothEcran = null
PeripheriqueBluetooth peripheriqueBluetoothTable = null
PeripheriqueBluetooth peripheriqueBluetoothLanceur = null

Fonctions membres privées

void affecterMembresIHM ()
void rendreBoutonsIHMCliquables ()
void rendreBarresProgressionIHMUtilisables ()
void connexionBaseDeDonnees ()
void demarrageBluetooth ()
void modifierIHMBluetoothInsuffisant ()
void modifierIHMBluetoothSuffisant ()
void modifierIHMBluetoothOperationnel ()
void connexionPeripheriquesBluetooth ()
void deconnexionPeripheriquesBluetooth ()
void connexionPeripheriqueBluetoothEcran (BluetoothDevice appareilBluetooth)
void connexionPeripheriqueBluetoothTable (BluetoothDevice appareilBluetooth)
void connexionPeripheriqueBluetoothLanceur (BluetoothDevice appareilBluetooth)
boolean verifierConnexionAppareilsBluetoothRequis ()
void actualiserIHMAppareilsBluetooth (boolean tableEstConnectee, boolean lanceurEstConnecte, boolean ecranEstConnecte)
void actionnerSeance ()
void demarrerSeance ()
void pauserSeance ()
void reprendreSeance ()
void arreterSeance (boolean seanceAEnregistrer)
void appliquerParametresSeance ()
void modifierValeursParametresIHM ()
void attendre (int tempsMillisecondes)
void envoyerTramePeripheriqueBluetoothEcran (String trame)
void envoyerTrameConnexionPeripheriqueBluetoothEcran ()
void envoyerTrameParametrageSeancePeripheriqueBluetoothEcran ()
void envoyerTrameDebutSeancePeripheriqueBluetoothEcran ()
void envoyerTrameArretPeripheriqueBluetoothEcran ()
void ajouterJoueur ()
void creerListeJoueurs ()
void traiterDonneesRecues (String nomAppareilSource, String donnees)
void traiterDonneesRecuesLanceur (String donnees)
void traiterErreurRecueLanceur (String erreur)
void traiterDonneesRecuesTable (String donnees)
void calculerReussiteSeance (int zoneTouchee)
void incrementerBallesJouees ()
void envoyerTrameArretPeripheriqueBluetoothLanceur ()
void envoyerTrameArretPeripheriqueBluetoothTable ()
void envoyerTrameDebutSeancePeripheriqueBluetoothLanceur ()
void envoyerTrameRepriseSeancePeripheriqueBluetoothLanceur ()
void envoyerTramePeripheriqueBluetoothLanceur (String trame)
void selectionnerZone (final int typeSelection, int choixObjectif, int choixRobot)
void redirectionActiviteHistorique ()

Attributs privés

ImageButton boutonBluetooth
ImageButton boutonHistorique
ImageButton boutonParametres
ImageView voyantTable
ImageView voyantLanceur
ImageView voyantEcran
ImageView boutonActionSeance
ImageView boutonArreterSeance
Spinner spinnerListeJoueurs
ImageButton boutonAppliquerNomJoueur
SeekBar barreProgressionNombreBalles
TextView texteValeurNombreBalles
SeekBar barreProgressionFrequenceBalles
TextView texteValeurFrequenceBalles
SeekBar barreProgressionEffetBalles
TextView texteValeurEffetBalles
SeekBar barreProgressionPuissanceBalles
TextView texteValeurPuissanceBalles
SeekBar barreProgressionRotationLanceur
TextView texteValeurRotationLanceur
ServeurBDD serveurBDD
int etatSeance = ETAT_SEANCE_ARRETEE
Seance seanceEnCours
int ballesJouees
int ballesReussies
String nomJoueur
BluetoothAdapter adaptateurBluetooth = null
Set< BluetoothDevice > devices
final Handler handler

Attributs privés statiques

static final int COULEUR_BOUTON_VERT = Color.parseColor("#5eed7b")
static final int COULEUR_BOUTON_ORANGE = Color.parseColor("#f7bb31")
static final int COULEUR_BOUTON_GRIS = Color.parseColor("#c0c5c6")
static final int COULEUR_BOUTON_ROUGE = Color.parseColor("#ee5e5e")
static final int ETAT_SEANCE_ARRETEE = 0
static final int ETAT_SEANCE_DEMARREE = 1
static final int ETAT_SEANCE_PAUSE = 2
static final String NOM_PERIPHERIQUE_BLUETOOTH_ECRAN = "TTPA-Ecran"
static final String NOM_PERIPHERIQUE_BLUETOOTH_TABLE = "TTPA-Table"
static final String NOM_PERIPHERIQUE_BLUETOOTH_LANCEUR = "TTPA-Lanceur"
static final String TRAME_ENTETE = "$TTPA"
static final String TRAME_FIN = "\r\n"
static final String TRAME_ECRAN_DEBUT_SEANCE = ":START"
static final String TRAME_ECRAN_PAUSE_SEANCE = ":PAUSE"
static final String TRAME_ECRAN_REPRISE_SEANCE = ":RESUME"
static final String TRAME_ECRAN_FIN_SEANCE = ":FINSEANCE"
static final String TRAME_LANCEUR_PAUSE_SEANCE = ":PAUSE:" + TRAME_FIN
static final String TRAME_LANCEUR_REPRISE_SEANCE = ":RESUME:" + TRAME_FIN
static final String TRAME_LANCEUR_ARRET_SEANCE = ":STOP:" + TRAME_FIN
static final String TRAME_LANCEUR_PING = ":PING:" + TRAME_FIN
static final String TRAME_TABLE_ARRET_SEANCE = ":RESET"
static final int REQUEST_CODE_ENABLE_BLUETOOTH = 0
static final int SELECTION_ZONE_OBJECTIF = 0
static final int SELECTION_ZONE_ROBOT = 1

Description détaillée

Created by smaniotto on 05/04/18. Classe IHMEcranPrincipal définnissant le comportement du layout 'ecran_principal'.


Documentation des fonctions membres

Méthode actionnerSeance() permettant de démarrer ou d'arrêter une séance en fonction de l'état actuel.

Références com.ttpa.iris.ttpamobile.IHMEcranPrincipal.demarrerSeance(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.ETAT_SEANCE_ARRETEE, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.ETAT_SEANCE_DEMARREE, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.ETAT_SEANCE_PAUSE, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.etatSeance, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.idZonePrecedente, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.pauserSeance(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.reprendreSeance(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.SELECTION_ZONE_ROBOT, et com.ttpa.iris.ttpamobile.IHMEcranPrincipal.selectionnerZone().

Référencé par com.ttpa.iris.ttpamobile.IHMEcranPrincipal.onClick().

    {
        Log.d("IHMEcranPrincipal", "actionnerSeance() état : " + etatSeance);

        // Démarrer ou arrêter la séance selon son état actuel
        switch (etatSeance)
        {
            case ETAT_SEANCE_ARRETEE:
                // La séance n'est pas commencée, il faut la démarrer
                if(idZonePrecedente == -1) // Si les zones n'ont pas été selectionnées
                    selectionnerZone(SELECTION_ZONE_ROBOT, 0, 0);
                else // Sinon, on peut démarrer la séance
                {
                    demarrerSeance();
                    etatSeance = ETAT_SEANCE_DEMARREE;
                }
                break;
            case ETAT_SEANCE_DEMARREE:
                // La séance est en cours, il faut la metre en pause
                pauserSeance();
                etatSeance = ETAT_SEANCE_PAUSE;
                break;
            case ETAT_SEANCE_PAUSE:
                // La séance est en pause, il faut la reprendre
                reprendreSeance();
                etatSeance = ETAT_SEANCE_DEMARREE;
                break;
            default:
                break;
        }
    }
void com.ttpa.iris.ttpamobile.IHMEcranPrincipal.actualiserIHMAppareilsBluetooth ( boolean  tableEstConnectee,
boolean  lanceurEstConnecte,
boolean  ecranEstConnecte 
) [private]

Méthode actualiserIHMAppareilsBluetooth() permettant de modifier les voyants des appareils Bluetooth en fonction des appareils connectés

Références com.ttpa.iris.ttpamobile.IHMEcranPrincipal.voyantEcran, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.voyantLanceur, et com.ttpa.iris.ttpamobile.IHMEcranPrincipal.voyantTable.

Référencé par com.ttpa.iris.ttpamobile.IHMEcranPrincipal.verifierConnexionAppareilsBluetoothRequis().

    {
        if(tableEstConnectee)
            voyantTable.setImageResource(R.drawable.table_connectee);
        else
            voyantTable.setImageResource(R.drawable.table_deconnectee);

        if(lanceurEstConnecte)
            voyantLanceur.setImageResource(R.drawable.lanceur_connecte);
        else
            voyantLanceur.setImageResource(R.drawable.lanceur_deconnecte);

        if(ecranEstConnecte)
            voyantEcran.setImageResource(R.drawable.ecran_connecte);
        else
            voyantEcran.setImageResource(R.drawable.ecran_deconnecte);
    }

Méthode affecterMembresIHM() permettant l'affectation des membres de l'IHM (boutons, barres de progressions, textes, ...) aux attributs correspondants.

Références com.ttpa.iris.ttpamobile.IHMEcranPrincipal.barreProgressionEffetBalles, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.barreProgressionFrequenceBalles, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.barreProgressionNombreBalles, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.barreProgressionPuissanceBalles, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.barreProgressionRotationLanceur, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.boutonActionSeance, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.boutonAppliquerNomJoueur, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.boutonArreterSeance, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.boutonBluetooth, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.boutonHistorique, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.boutonParametres, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.spinnerListeJoueurs, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.texteValeurEffetBalles, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.texteValeurFrequenceBalles, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.texteValeurNombreBalles, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.texteValeurPuissanceBalles, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.texteValeurRotationLanceur, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.voyantEcran, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.voyantLanceur, et com.ttpa.iris.ttpamobile.IHMEcranPrincipal.voyantTable.

Référencé par com.ttpa.iris.ttpamobile.IHMEcranPrincipal.onCreate().

    {
        Log.d("IHMEcranPrincipal", "affecterMembresIHM()");

        //editTextNomJoueur = (EditText) findViewById(R.id.editTextNomJoueur);
        boutonAppliquerNomJoueur = (ImageButton) findViewById(R.id.boutonAppliquerNomJoueur);
        boutonBluetooth = (ImageButton) findViewById(R.id.boutonBluetooth);
        boutonHistorique = (ImageButton) findViewById(R.id.boutonHistorique);
        boutonParametres = (ImageButton) findViewById(R.id.boutonParametres);
        voyantTable = (ImageView) findViewById(R.id.voyantTable);
        voyantLanceur = (ImageView) findViewById(R.id.voyantLanceur);
        voyantEcran = (ImageView) findViewById(R.id.voyantEcran);
        boutonActionSeance = (ImageView) findViewById(R.id.boutonActionSeance);
        boutonArreterSeance = (ImageView) findViewById(R.id.boutonArreterSeance);
        barreProgressionNombreBalles = (SeekBar) findViewById(R.id.barreProgressionNombreBalles);
        texteValeurNombreBalles = (TextView) findViewById(R.id.texteValeurNombreBalles);
        barreProgressionFrequenceBalles = (SeekBar) findViewById(R.id.barreProgressionFrequenceBalles);
        texteValeurFrequenceBalles = (TextView) findViewById(R.id.texteValeurFrequenceBalles);
        barreProgressionEffetBalles = (SeekBar) findViewById(R.id.barreProgressionEffetBalles);
        texteValeurEffetBalles = (TextView) findViewById(R.id.texteValeurEffetBalles);
        barreProgressionPuissanceBalles = (SeekBar) findViewById(R.id.barreProgressionPuissanceBalles);
        texteValeurPuissanceBalles = (TextView) findViewById(R.id.texteValeurPuissanceBalles);
        barreProgressionRotationLanceur = (SeekBar) findViewById(R.id.barreProgressionRotationLanceur);
        texteValeurRotationLanceur = (TextView) findViewById(R.id.texteValeurRotationLanceur);
        spinnerListeJoueurs = (Spinner)findViewById(R.id.spinnerListeJoueurs);
        spinnerListeJoueurs.setContentDescription("La liste des joueurs");
    }

Méthode ajouterJoueur() ajoutant un joueur saisit à la base de données.

Références com.ttpa.iris.ttpamobile.IHMEcranPrincipal.creerListeJoueurs(), com.ttpa.iris.ttpamobile.ServeurBDD.insererJoueur(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.nomJoueur, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.onClick(), et com.ttpa.iris.ttpamobile.IHMEcranPrincipal.serveurBDD.

Référencé par com.ttpa.iris.ttpamobile.IHMEcranPrincipal.onClick().

    {
        AlertDialog.Builder ajoutJoueur = new AlertDialog.Builder(this);
        LayoutInflater factory = LayoutInflater.from(this);
        final View ajoutJoueurView = factory.inflate(R.layout.ajout_joueur, null);
        ajoutJoueur.setView(ajoutJoueurView);

        ajoutJoueur.setTitle("Ajouter un nouveau joueur");

        ajoutJoueur.setPositiveButton("Valider", new DialogInterface.OnClickListener()
        {
            public void onClick(DialogInterface dialog, int which)
            {
                //Lorsque l'on cliquera sur le bouton "OK", on récupère l'EditText correspondant à notre vue personnalisée (cad à alertDialogView)
                EditText nomJoueur = (EditText)ajoutJoueurView.findViewById(R.id.editTextNom);
                Joueur joueur = new Joueur(nomJoueur.getText().toString());
                long id = serveurBDD.insererJoueur(joueur);
                Log.d("IHMEcranPrincipal", "Nom joueur : " + nomJoueur.getText().toString() + " - id : " + id);
                Toast.makeText(getApplicationContext(), "Joueur " + nomJoueur.getText() + " ajouté", Toast.LENGTH_SHORT).show();
                creerListeJoueurs();
            }
        });

        ajoutJoueur.setNegativeButton("Annuler", new DialogInterface.OnClickListener()
        {
            public void onClick(DialogInterface dialog, int which)
            {

            }
        });

        ajoutJoueur.show();
    }

Méthode appliquerParametresSeance() appliquant les valeurs des paramètres à l'objet parametresActuels.

Références com.ttpa.iris.ttpamobile.IHMEcranPrincipal.barreProgressionEffetBalles, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.barreProgressionFrequenceBalles, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.barreProgressionNombreBalles, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.barreProgressionPuissanceBalles, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.barreProgressionRotationLanceur, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.ETAT_SEANCE_ARRETEE, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.etatSeance, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.nomJoueur, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.parametresActuels, com.ttpa.iris.ttpamobile.ParametreSeance.setEffetBalles(), com.ttpa.iris.ttpamobile.ParametreSeance.setFrequenceBalles(), com.ttpa.iris.ttpamobile.ParametreSeance.setIntensiteEffet(), com.ttpa.iris.ttpamobile.ParametreSeance.setNombreBalles(), com.ttpa.iris.ttpamobile.ParametreSeance.setNomJoueur(), com.ttpa.iris.ttpamobile.ParametreSeance.setPuissanceBalles(), et com.ttpa.iris.ttpamobile.ParametreSeance.setRotation().

Référencé par com.ttpa.iris.ttpamobile.IHMEcranPrincipal.demarrerSeance(), et com.ttpa.iris.ttpamobile.IHMEcranPrincipal.onCreate().

    {
        Log.d("IHMEcranPrincipal", "appliquerParametresSeance()");

        if(etatSeance == ETAT_SEANCE_ARRETEE)
        {
            parametresActuels.setNomJoueur(nomJoueur);
            parametresActuels.setNombreBalles((barreProgressionNombreBalles.getProgress() * 5) + 5); // 5 balles par palier, 5 balles minimum
            parametresActuels.setFrequenceBalles((barreProgressionFrequenceBalles.getProgress() * 5) + 30); // 5 balles par palier, 30 balles minimum

            String effet;
            int intensiteEffet = barreProgressionEffetBalles.getProgress() - 8;

            if (barreProgressionEffetBalles.getProgress() == 8)
            {
                effet = "Aucun";
                intensiteEffet = 1;
            }
            else if (barreProgressionEffetBalles.getProgress() < 8)
            {
                effet = "Coupé";
                intensiteEffet = 0 - intensiteEffet;
            }
            else
                effet = "Lifté";

            parametresActuels.setEffetBalles(effet);
            parametresActuels.setIntensiteEffet(intensiteEffet);
            parametresActuels.setPuissanceBalles(barreProgressionPuissanceBalles.getProgress() + 1); // 1 minimum (soit 10% minimum)
            parametresActuels.setRotation(barreProgressionRotationLanceur.getProgress() * 5); // 5° par pallier
        }
    }
void com.ttpa.iris.ttpamobile.IHMEcranPrincipal.arreterSeance ( boolean  seanceAEnregistrer) [private]

Méthode arreterSeance() permettant d'envoyer les trames correspondantes aux appareils Bluetooth du projet.

Références com.ttpa.iris.ttpamobile.IHMEcranPrincipal.barreProgressionEffetBalles, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.barreProgressionFrequenceBalles, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.barreProgressionNombreBalles, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.barreProgressionPuissanceBalles, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.barreProgressionRotationLanceur, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.boutonActionSeance, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.boutonArreterSeance, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.envoyerTrameArretPeripheriqueBluetoothEcran(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.envoyerTrameArretPeripheriqueBluetoothLanceur(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.envoyerTrameArretPeripheriqueBluetoothTable(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.ETAT_SEANCE_ARRETEE, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.etatSeance, com.ttpa.iris.ttpamobile.ServeurBDD.insererSeance(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.seanceEnCours, et com.ttpa.iris.ttpamobile.IHMEcranPrincipal.serveurBDD.

Référencé par com.ttpa.iris.ttpamobile.IHMEcranPrincipal.calculerReussiteSeance(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.incrementerBallesJouees(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.modifierIHMBluetoothInsuffisant(), et com.ttpa.iris.ttpamobile.IHMEcranPrincipal.onClick().

    {
        Log.d("IHMEcranPrincipal", "arreterSeance()");
        // Envoyer la trame d'arrêt à l'écran
        envoyerTrameArretPeripheriqueBluetoothEcran();

        // Envoyer la trame d'arrêt au lanceur
        envoyerTrameArretPeripheriqueBluetoothLanceur();

        // Envoyer la trame d'arrêt à la table
        envoyerTrameArretPeripheriqueBluetoothTable();

        if (seanceAEnregistrer)
        {
            // Enregistrer la séance dans la base de données
            serveurBDD.insererSeance(seanceEnCours);
        }

        // Changer l'icône du bouton d'action
        boutonActionSeance.setImageResource(R.drawable.bouton_demarrer);
        boutonActionSeance.setEnabled(true);

        // Changer l'état et la visibilité du bouton d'arrêt de séance
        boutonArreterSeance.setEnabled(false);
        boutonArreterSeance.setVisibility(View.INVISIBLE);

        // Changer l'état de la séance
        etatSeance = ETAT_SEANCE_ARRETEE;

        // Changer les états des barres de paramétrage
        barreProgressionNombreBalles.setEnabled(true);
        barreProgressionFrequenceBalles.setEnabled(true);
        barreProgressionEffetBalles.setEnabled(true);
        barreProgressionPuissanceBalles.setEnabled(true);
        barreProgressionRotationLanceur.setEnabled(true);
    }
void com.ttpa.iris.ttpamobile.IHMEcranPrincipal.attendre ( int  tempsMillisecondes) [private]

Méthode attendre() permettant d'attendre un temps données.

Paramètres:
tempsMillisecondes
    {
        Log.d("IHMEcranPrincipal", "attendre()");

        try
        {
            Thread.sleep(tempsMillisecondes);
        }
        catch (InterruptedException e)
        {
            e.printStackTrace();
        }
    }

Méthode calculerReussiteSeance() calculant le taux de réussite de la séance selon le nombre de balles ayant déjà touché l'objectif.

Paramètres:
zoneToucheeétant la zone de l'impacte

Références com.ttpa.iris.ttpamobile.IHMEcranPrincipal.arreterSeance(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.ballesJouees, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.ballesReussies, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.ETAT_SEANCE_DEMARREE, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.etatSeance, com.ttpa.iris.ttpamobile.Seance.getNombreBalles(), com.ttpa.iris.ttpamobile.Seance.getZoneObjectif(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.seanceEnCours, et com.ttpa.iris.ttpamobile.Seance.setTauxReussite().

Référencé par com.ttpa.iris.ttpamobile.IHMEcranPrincipal.traiterDonneesRecuesTable().

    {
        Log.d("IHMEcranPrincipal", "calculerReussiteSeance() zone touchée : " + zoneTouchee);

        if(etatSeance == ETAT_SEANCE_DEMARREE)
        {
            if (zoneTouchee != -1) // Si la balle a bien touché la table
            {
                if ((seanceEnCours.getZoneObjectif() != -1) && (seanceEnCours.getZoneObjectif() != 0)) { // Si l'objectif a été défini
                    if (zoneTouchee == seanceEnCours.getZoneObjectif()) // Si la zone touchée est la même que l'objectif
                        ballesReussies++;
                } else // Si aucun objectif n'a été défini: la table entière est l'objectif
                    ballesReussies++;
            }

            seanceEnCours.setTauxReussite((float) ballesReussies / (float) seanceEnCours.getNombreBalles() * 100);

            if (ballesJouees == seanceEnCours.getNombreBalles())
                arreterSeance(true);
        }
    }

Méthode connexionBaseDeDonnees() permettant la création puis la connexion à la base de données.

Références com.ttpa.iris.ttpamobile.ServeurBDD.open(), et com.ttpa.iris.ttpamobile.IHMEcranPrincipal.serveurBDD.

Référencé par com.ttpa.iris.ttpamobile.IHMEcranPrincipal.onCreate().

    {
        Log.d("IHMEcranPrincipal", "connexionBaseDeDonnees()");

        serveurBDD = new ServeurBDD(this);
        serveurBDD.open();
    }
void com.ttpa.iris.ttpamobile.IHMEcranPrincipal.connexionPeripheriqueBluetoothEcran ( BluetoothDevice  appareilBluetooth) [private]

Méthode connexionPeripheriqueBluetoothEcran() permettant la connexion Bluetooth à l'écran.

Paramètres:
appareilBluetoothétant le Bluetooth de l'écran

Références com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.connecter(), com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.estConnecte(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.handler, et com.ttpa.iris.ttpamobile.IHMEcranPrincipal.peripheriqueBluetoothEcran.

Référencé par com.ttpa.iris.ttpamobile.IHMEcranPrincipal.connexionPeripheriquesBluetooth().

    {
        Log.d("IHMEcranPrincipal", "connexionPeripheriqueBluetoothEcran()");

        peripheriqueBluetoothEcran = new PeripheriqueBluetooth(appareilBluetooth, handler);

        //Toast.makeText(getApplicationContext(), "Connexion à l'écran ...", Toast.LENGTH_SHORT).show();

        peripheriqueBluetoothEcran.connecter();

        //attendre(2000);

        if (peripheriqueBluetoothEcran.estConnecte())
            Toast.makeText(getApplicationContext(), "Ecran connecté !", Toast.LENGTH_SHORT).show();
    }
void com.ttpa.iris.ttpamobile.IHMEcranPrincipal.connexionPeripheriqueBluetoothLanceur ( BluetoothDevice  appareilBluetooth) [private]

Méthode connexionPeripheriqueBluetoothLanceur() permettant la connexion Bluetooth du lanceur.

Paramètres:
appareilBluetoothétant le Bluetooth du lanceur

Références com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.connecter(), com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.estConnecte(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.handler, et com.ttpa.iris.ttpamobile.IHMEcranPrincipal.peripheriqueBluetoothLanceur.

Référencé par com.ttpa.iris.ttpamobile.IHMEcranPrincipal.connexionPeripheriquesBluetooth().

    {
        Log.d("IHMEcranPrincipal", "connexionPeripheriqueBluetoothLanceur()");

        peripheriqueBluetoothLanceur = new PeripheriqueBluetooth(appareilBluetooth, handler);

        //Toast.makeText(getApplicationContext(), "Connexion au lanceur ...", Toast.LENGTH_SHORT).show();

        peripheriqueBluetoothLanceur.connecter();

        //attendre(2000);

        if (peripheriqueBluetoothLanceur.estConnecte())
            Toast.makeText(getApplicationContext(), "Lanceur connecté !", Toast.LENGTH_SHORT).show();
    }
void com.ttpa.iris.ttpamobile.IHMEcranPrincipal.connexionPeripheriqueBluetoothTable ( BluetoothDevice  appareilBluetooth) [private]

Méthode connexionPeripheriqueBluetoothTable() permettant la connexion Bluetooth à la table.

Paramètres:
appareilBluetoothétant le Bluetooth de la table

Références com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.connecter(), com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.estConnecte(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.handler, et com.ttpa.iris.ttpamobile.IHMEcranPrincipal.peripheriqueBluetoothTable.

Référencé par com.ttpa.iris.ttpamobile.IHMEcranPrincipal.connexionPeripheriquesBluetooth().

    {
        Log.d("IHMEcranPrincipal", "connexionPeripheriqueBluetoothTable()");

        peripheriqueBluetoothTable = new PeripheriqueBluetooth(appareilBluetooth, handler);

        //Toast.makeText(getApplicationContext(), "Connexion à la table ...", Toast.LENGTH_SHORT).show();

        peripheriqueBluetoothTable.connecter();

        //attendre(2000);

        if (peripheriqueBluetoothTable.estConnecte())
            Toast.makeText(getApplicationContext(), "Table connectée !", Toast.LENGTH_SHORT).show();
    }

Méthode connexionPeripheriquesBluetooth() permetant la connexion aux appareils Bluetooth du projet détectés.

Références com.ttpa.iris.ttpamobile.IHMEcranPrincipal.connexionPeripheriqueBluetoothEcran(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.connexionPeripheriqueBluetoothLanceur(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.connexionPeripheriqueBluetoothTable(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.deconnexionPeripheriquesBluetooth(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.devices, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.handler, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.NOM_PERIPHERIQUE_BLUETOOTH_ECRAN, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.NOM_PERIPHERIQUE_BLUETOOTH_LANCEUR, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.NOM_PERIPHERIQUE_BLUETOOTH_TABLE, et com.ttpa.iris.ttpamobile.IHMEcranPrincipal.peripheriques.

Référencé par com.ttpa.iris.ttpamobile.IHMEcranPrincipal.demarrageBluetooth().

    {
        Log.d("IHMEcranPrincipal", "connexionPeripheriquesBluetooth()");

        // Déconnexion de tous les appareils avant une possible connexion
        deconnexionPeripheriquesBluetooth();

        for (BluetoothDevice appareilBluetooth : devices)
        {
            //Toast.makeText(getApplicationContext(), "Périphérique = " + appareilBluetooth.getName(), Toast.LENGTH_SHORT).show();
            peripheriques.add(new PeripheriqueBluetooth(appareilBluetooth, handler));

            switch (appareilBluetooth.getName())
            {
                case NOM_PERIPHERIQUE_BLUETOOTH_ECRAN:
                    connexionPeripheriqueBluetoothEcran(appareilBluetooth);
                    break;
                case NOM_PERIPHERIQUE_BLUETOOTH_TABLE:
                    connexionPeripheriqueBluetoothTable(appareilBluetooth);
                    break;
                case NOM_PERIPHERIQUE_BLUETOOTH_LANCEUR:
                    connexionPeripheriqueBluetoothLanceur(appareilBluetooth);
                    break;
                default:
                    break;
            }
        }

        if(peripheriques.size() == 0)
        {
            Toast.makeText(getApplicationContext(), "Aucun périphérique détecté ! ", Toast.LENGTH_SHORT).show();
        }
    }

Méthode creerListeJoueurs() créant la liste des joueurs présents dans la base de données

Références com.ttpa.iris.ttpamobile.IHMEcranPrincipal.envoyerTrameConnexionPeripheriqueBluetoothEcran(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.ETAT_SEANCE_ARRETEE, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.etatSeance, com.ttpa.iris.ttpamobile.Joueur.getId(), com.ttpa.iris.ttpamobile.ServeurBDD.getIdJoueurParametres(), com.ttpa.iris.ttpamobile.ServeurBDD.getJoueur(), com.ttpa.iris.ttpamobile.ServeurBDD.getJoueurs(), com.ttpa.iris.ttpamobile.Joueur.getNom(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.nomJoueur, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.parametresActuels, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.serveurBDD, com.ttpa.iris.ttpamobile.ServeurBDD.setIdJoueurParametres(), com.ttpa.iris.ttpamobile.ParametreSeance.setNomJoueur(), et com.ttpa.iris.ttpamobile.IHMEcranPrincipal.spinnerListeJoueurs.

Référencé par com.ttpa.iris.ttpamobile.IHMEcranPrincipal.ajouterJoueur(), et com.ttpa.iris.ttpamobile.IHMEcranPrincipal.onCreate().

    {
        final List<Joueur> listeJoueurs = serveurBDD.getJoueurs();
        final List<String> noms = new ArrayList<String>();

        // le dernier joueur a avoir utilisé l'application
        int idJoueur = serveurBDD.getIdJoueurParametres();
        for(int i = 0; i < listeJoueurs.size(); i++)
        {
            Joueur joueur = listeJoueurs.get(i);
            if(joueur.getId() == idJoueur)
            {
                noms.add(joueur.getNom());
                break;
            }
        }
        for(int i = 0; i < listeJoueurs.size(); i++)
        {
            Joueur joueur = listeJoueurs.get(i);
            if(joueur.getId() == idJoueur)
                continue;
            noms.add(joueur.getNom());
        }

        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, noms);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        spinnerListeJoueurs.setAdapter(adapter);

        spinnerListeJoueurs.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener()
        {
            @Override
            public void onItemSelected(AdapterView<?> arg0, View arg1, int position, long id)
            {
                Joueur joueur = serveurBDD.getJoueur(noms.get(position));
                Log.d("IHMEcranPrincipal", "Nom joueur séléctionné : " + noms.get(position));
                // On conserve son id pour la prochaine session
                serveurBDD.setIdJoueurParametres(joueur.getId());
                nomJoueur = joueur.getNom();
                if(etatSeance == ETAT_SEANCE_ARRETEE)
                    parametresActuels.setNomJoueur(nomJoueur);

                // On envoi l'information à l'écran, si la séance n'a pas encore été démarrée
                envoyerTrameConnexionPeripheriqueBluetoothEcran();
            }

            @Override
            public void onNothingSelected(AdapterView<?> arg0)
            {
            }
        });
    }

Méthode demarrageBluetooth() permettant le déamrrage du Bluetooth puis la connexion automatique aux appareils du projet.

Références com.ttpa.iris.ttpamobile.IHMEcranPrincipal.adaptateurBluetooth, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.connexionPeripheriquesBluetooth(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.devices, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.modifierIHMBluetoothInsuffisant(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.peripheriques, et com.ttpa.iris.ttpamobile.IHMEcranPrincipal.REQUEST_CODE_ENABLE_BLUETOOTH.

Référencé par com.ttpa.iris.ttpamobile.IHMEcranPrincipal.onClick(), et com.ttpa.iris.ttpamobile.IHMEcranPrincipal.onCreate().

    {
        Log.d("IHMEcranPrincipal", "demarrageBluetooth()");

        adaptateurBluetooth = BluetoothAdapter.getDefaultAdapter();
        if (adaptateurBluetooth == null)
        {
            Toast.makeText(getApplicationContext(), "Bluetooth non activé !", Toast.LENGTH_SHORT).show();
            modifierIHMBluetoothInsuffisant();
        }
        else
        {
            if (!adaptateurBluetooth.isEnabled())
            {
                Toast.makeText(getApplicationContext(), "Bluetooth non activé !", Toast.LENGTH_SHORT).show();

                modifierIHMBluetoothInsuffisant();

                Intent activeBlueTooth = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
                startActivityForResult(activeBlueTooth, REQUEST_CODE_ENABLE_BLUETOOTH);
                //bluetoothAdapter.enable();
            }
            else
            {
                Toast.makeText(getApplicationContext(), "Bluetooth activé, recherche en cours...", Toast.LENGTH_LONG).show();

                // Recherche des périphériques connus
                peripheriques = new ArrayList<PeripheriqueBluetooth>();
                devices = adaptateurBluetooth.getBondedDevices();

                // Connexion aux appareils Bluetooth du projet détectés
                connexionPeripheriquesBluetooth();
            }
        }
    }

Méthode demarrerSeance() permettant d'envoyer les trames correspondantes aux appareils Bluetooth du projet.

Références com.ttpa.iris.ttpamobile.IHMEcranPrincipal.appliquerParametresSeance(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.ballesJouees, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.ballesReussies, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.barreProgressionEffetBalles, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.barreProgressionFrequenceBalles, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.barreProgressionNombreBalles, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.barreProgressionPuissanceBalles, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.barreProgressionRotationLanceur, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.boutonActionSeance, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.boutonArreterSeance, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.envoyerTrameDebutSeancePeripheriqueBluetoothEcran(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.envoyerTrameDebutSeancePeripheriqueBluetoothLanceur(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.envoyerTrameParametrageSeancePeripheriqueBluetoothEcran(), com.ttpa.iris.ttpamobile.ParametreSeance.getEffetComplet(), com.ttpa.iris.ttpamobile.ParametreSeance.getFrequenceBalles(), com.ttpa.iris.ttpamobile.ServeurBDD.getIdJoueurParametres(), com.ttpa.iris.ttpamobile.ParametreSeance.getIntensiteEffet(), com.ttpa.iris.ttpamobile.ParametreSeance.getNombreBalles(), com.ttpa.iris.ttpamobile.ParametreSeance.getPuissanceBalles(), com.ttpa.iris.ttpamobile.ParametreSeance.getRotation(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.parametresActuels, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.seanceEnCours, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.serveurBDD, com.ttpa.iris.ttpamobile.Seance.setIdJoueur(), com.ttpa.iris.ttpamobile.Seance.setZoneObjectif(), com.ttpa.iris.ttpamobile.Seance.setZoneRobot(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.zoneObjectif, et com.ttpa.iris.ttpamobile.IHMEcranPrincipal.zoneRobot.

Référencé par com.ttpa.iris.ttpamobile.IHMEcranPrincipal.actionnerSeance().

    {
        Log.d("IHMEcranPrincipal", "demarrerSeance()");

        // Lire les valeurs des paramètres actuels afin de les appliquer aux paramètres de la séance
        appliquerParametresSeance();

        // Envoyer la trame de paramétrage à l'écran, puis la trame de début de séance
        envoyerTrameDebutSeancePeripheriqueBluetoothEcran();

        envoyerTrameParametrageSeancePeripheriqueBluetoothEcran();

        // On applique les paramètres actuels à la séance en cours
        seanceEnCours = new Seance(parametresActuels.getFrequenceBalles(), parametresActuels.getNombreBalles(), parametresActuels.getEffetComplet(), parametresActuels.getIntensiteEffet(), parametresActuels.getPuissanceBalles(), parametresActuels.getRotation());
        seanceEnCours.setIdJoueur(serveurBDD.getIdJoueurParametres());
        seanceEnCours.setZoneObjectif(zoneObjectif);
        seanceEnCours.setZoneRobot(zoneRobot);

        // Mettre à zéro les statistiques
        ballesJouees = 0;
        ballesReussies = 0;

        // Envoyer la trame de départ au lanceur
        envoyerTrameDebutSeancePeripheriqueBluetoothLanceur();

        // Changer l'icône du bouton d'action
        boutonActionSeance.setImageResource(R.drawable.bouton_pause);

        // Changer l'état et la visibilité du bouton d'arrêt de séance
        boutonArreterSeance.setEnabled(true);
        boutonArreterSeance.setVisibility(View.VISIBLE);

        // Changer les états des barres de paramétrage
        barreProgressionNombreBalles.setEnabled(false);
        barreProgressionFrequenceBalles.setEnabled(false);
        barreProgressionEffetBalles.setEnabled(false);
        barreProgressionPuissanceBalles.setEnabled(false);
        barreProgressionRotationLanceur.setEnabled(false);
    }

Méthode envoyerTrameFinParametrageSeancePeripheriqueBluetoothEcran() envoyant la trame de fin de paramétrage à l'écran.

Références com.ttpa.iris.ttpamobile.IHMEcranPrincipal.envoyerTramePeripheriqueBluetoothEcran(), et com.ttpa.iris.ttpamobile.IHMEcranPrincipal.TRAME_ECRAN_DEBUT_SEANCE.

Référencé par com.ttpa.iris.ttpamobile.IHMEcranPrincipal.demarrerSeance().

    {
        Log.d("IHMEcranPrincipal", "envoyerTrameDebutSeancePeripheriqueBluetoothEcran()");

        envoyerTramePeripheriqueBluetoothEcran(TRAME_ECRAN_DEBUT_SEANCE);
    }

Méthode envoyerTrameDebutSeancePeripheriqueBluetoothLanceur() envoyant la trame de début de séance au lanceur.

Références com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.envoyer(), com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.estConnecte(), com.ttpa.iris.ttpamobile.ParametreSeance.getEffet(), com.ttpa.iris.ttpamobile.ParametreSeance.getFrequenceBalles(), com.ttpa.iris.ttpamobile.ParametreSeance.getIntensiteEffet(), com.ttpa.iris.ttpamobile.ParametreSeance.getNombreBalles(), com.ttpa.iris.ttpamobile.ParametreSeance.getPuissanceBalles(), com.ttpa.iris.ttpamobile.ParametreSeance.getRotation(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.parametresActuels, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.peripheriqueBluetoothLanceur, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.TRAME_ENTETE, et com.ttpa.iris.ttpamobile.IHMEcranPrincipal.TRAME_FIN.

Référencé par com.ttpa.iris.ttpamobile.IHMEcranPrincipal.demarrerSeance().

    {
        Log.d("IHMEcranPrincipal", "envoyerTrameDebutSeancePeripheriqueBluetoothLanceur()");

        if (peripheriqueBluetoothLanceur != null)
        {
            if (peripheriqueBluetoothLanceur.estConnecte())
            {
                String trame = TRAME_ENTETE + ":SET:" + parametresActuels.getEffet() + ":" + parametresActuels.getIntensiteEffet() + ":" + parametresActuels.getPuissanceBalles() + ":" + parametresActuels.getFrequenceBalles() + ":" + parametresActuels.getRotation() + ":" + parametresActuels.getNombreBalles() + TRAME_FIN;
                peripheriqueBluetoothLanceur.envoyer(trame);
                Log.d("IHMEcranPrincipal", "Trame départ séance Lanceur : " + trame);
            }
        }
    }

Méthode envoyerTrameRepriseSeancePeripheriqueBluetoothLanceur() envoyant la trame de dreprise de séance au lanceur.

Références com.ttpa.iris.ttpamobile.IHMEcranPrincipal.ballesJouees, com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.envoyer(), com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.estConnecte(), com.ttpa.iris.ttpamobile.ParametreSeance.getEffet(), com.ttpa.iris.ttpamobile.ParametreSeance.getFrequenceBalles(), com.ttpa.iris.ttpamobile.ParametreSeance.getIntensiteEffet(), com.ttpa.iris.ttpamobile.ParametreSeance.getNombreBalles(), com.ttpa.iris.ttpamobile.ParametreSeance.getPuissanceBalles(), com.ttpa.iris.ttpamobile.ParametreSeance.getRotation(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.parametresActuels, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.peripheriqueBluetoothLanceur, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.TRAME_ENTETE, et com.ttpa.iris.ttpamobile.IHMEcranPrincipal.TRAME_FIN.

    {
        Log.d("IHMEcranPrincipal", "envoyerTrameRepriseSeancePeripheriqueBluetoothLanceur()");

        if (peripheriqueBluetoothLanceur != null)
        {
            if (peripheriqueBluetoothLanceur.estConnecte())
            {
                String trame = TRAME_ENTETE + ":SET:" + parametresActuels.getEffet() + ":" + parametresActuels.getIntensiteEffet() + ":" + parametresActuels.getPuissanceBalles() + ":" + parametresActuels.getFrequenceBalles() + ":" + parametresActuels.getRotation() + ":" + (parametresActuels.getNombreBalles() - ballesJouees) + TRAME_FIN;
                peripheriqueBluetoothLanceur.envoyer(trame);
                Log.d("IHMEcranPrincipal", "Trame reprise séance Lanceur : " + trame);
            }
        }
    }

Méthode incrementerBallesJouees() permettant de traiter les nombre de balles jouées de la séance, et d'arrêter la séance si la dernière balle est en dehors.

Références com.ttpa.iris.ttpamobile.IHMEcranPrincipal.arreterSeance(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.ballesJouees, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.boutonActionSeance, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.ETAT_SEANCE_DEMARREE, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.etatSeance, com.ttpa.iris.ttpamobile.Seance.getNombreBalles(), et com.ttpa.iris.ttpamobile.IHMEcranPrincipal.seanceEnCours.

Référencé par com.ttpa.iris.ttpamobile.IHMEcranPrincipal.traiterDonneesRecuesTable().

    {
        Log.d("IHMEcranPrincipal", "incrementerBallesJouees()");

        if(etatSeance == ETAT_SEANCE_DEMARREE)
        {
            ++ballesJouees;

            if (ballesJouees == seanceEnCours.getNombreBalles())
            {
                boutonActionSeance.setEnabled(false);

                final Timer timerAsync = new Timer();
                final TimerTask timerTaskAsync = new TimerTask() {
                    @Override
                    public void run() {
                        runOnUiThread(new Runnable() {
                            @Override public void run() {
                                if(etatSeance == ETAT_SEANCE_DEMARREE)
                                    arreterSeance(true);

                                timerAsync.cancel();
                            }
                        });
                    }
                };
                timerAsync.schedule(timerTaskAsync, 2000, 2000);
            }
        }
    }

Méthode modifierIHMBluetoothInsuffisant() appellée lorsque le Bluetooth n'est pas activé ou que les appareils nécessaires ne sont pas présents/connectés

Références com.ttpa.iris.ttpamobile.IHMEcranPrincipal.arreterSeance(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.boutonActionSeance, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.boutonBluetooth, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.boutonParametres, et com.ttpa.iris.ttpamobile.IHMEcranPrincipal.COULEUR_BOUTON_ROUGE.

Référencé par com.ttpa.iris.ttpamobile.IHMEcranPrincipal.deconnexionPeripheriquesBluetooth(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.demarrageBluetooth(), et com.ttpa.iris.ttpamobile.IHMEcranPrincipal.verifierConnexionAppareilsBluetoothRequis().

    {
        Log.d("IHMEcranPrincipal", "modifierIHMBluetoothInsuffisant()");

        // Arrêter la séance en cours, sans enregistrer
        arreterSeance(false);

        // Modifier la couleur du bouton Bluetooth
        boutonBluetooth.setBackgroundColor(COULEUR_BOUTON_ROUGE);
        // Modifier la couleur du bouton réglages des zones
        boutonParametres.setBackgroundColor(COULEUR_BOUTON_ROUGE);
        // Autoriser le réglage des zones
        boutonParametres.setEnabled(false);
        // Changer l'icône du bouton d'action
        boutonActionSeance.setImageResource(R.drawable.bouton_demarrer_desactive);
        // Empêcher une séance d'être jouée
        boutonActionSeance.setEnabled(false);
    }

Méthode modifierIHMBluetoothOperationnel() appellée lorsque tous les appareils Bluetooth sont connectés.

Références com.ttpa.iris.ttpamobile.IHMEcranPrincipal.boutonActionSeance, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.boutonBluetooth, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.boutonParametres, et com.ttpa.iris.ttpamobile.IHMEcranPrincipal.COULEUR_BOUTON_VERT.

Référencé par com.ttpa.iris.ttpamobile.IHMEcranPrincipal.verifierConnexionAppareilsBluetoothRequis().

    {
        Log.d("IHMEcranPrincipal", "modifierIHMBluetoothOperationnel()");

        // Modifier la couleur du bouton Bluetooth
        boutonBluetooth.setBackgroundColor(COULEUR_BOUTON_VERT);
        // Modifier la couleur du bouton réglages des zones
        boutonParametres.setBackgroundColor(COULEUR_BOUTON_VERT);
        // Autoriser le réglage des zones
        boutonParametres.setEnabled(true);
        // Changer l'icône du bouton d'action
        boutonActionSeance.setImageResource(R.drawable.bouton_demarrer);
        // Autoriser le déroulement d'une séance
        boutonActionSeance.setEnabled(true);
    }

Méthode modifierIHMBluetoothSuffisant() appellée lorsque les appareils Bluetooth nécessaires sont connectés.

Références com.ttpa.iris.ttpamobile.IHMEcranPrincipal.boutonActionSeance, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.boutonBluetooth, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.boutonParametres, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.COULEUR_BOUTON_ORANGE, et com.ttpa.iris.ttpamobile.IHMEcranPrincipal.COULEUR_BOUTON_VERT.

Référencé par com.ttpa.iris.ttpamobile.IHMEcranPrincipal.verifierConnexionAppareilsBluetoothRequis().

    {
        Log.d("IHMEcranPrincipal", "modifierIHMBluetoothSuffisant()");

        // Modifier la couleur du bouton Bluetooth
        boutonBluetooth.setBackgroundColor(COULEUR_BOUTON_ORANGE);
        // Modifier la couleur du bouton réglages des zones
        boutonParametres.setBackgroundColor(COULEUR_BOUTON_VERT);
        // Autoriser le réglage des zones
        boutonParametres.setEnabled(true);
        // Changer l'icône du bouton d'action
        boutonActionSeance.setImageResource(R.drawable.bouton_demarrer);
        // Autoriser le déroulement d'une séance
        boutonActionSeance.setEnabled(true);
    }

Méthode modifierValeursParametresIHM() modifiant les valeurs des champs de paramètre en fonction de leur barre de progression correspondante.

Références com.ttpa.iris.ttpamobile.IHMEcranPrincipal.barreProgressionEffetBalles, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.barreProgressionFrequenceBalles, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.barreProgressionNombreBalles, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.barreProgressionPuissanceBalles, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.barreProgressionRotationLanceur, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.texteValeurEffetBalles, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.texteValeurFrequenceBalles, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.texteValeurNombreBalles, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.texteValeurPuissanceBalles, et com.ttpa.iris.ttpamobile.IHMEcranPrincipal.texteValeurRotationLanceur.

Référencé par com.ttpa.iris.ttpamobile.IHMEcranPrincipal.onCreate(), et com.ttpa.iris.ttpamobile.IHMEcranPrincipal.onProgressChanged().

    {
        Log.d("IHMEcranPrincipal", "modifierValeursParametresIHM()");

        texteValeurNombreBalles.setText(((barreProgressionNombreBalles.getProgress() * 5) + 5) + " balles"); // 5 balles par palier, 5 balles minimum
        texteValeurFrequenceBalles.setText(((barreProgressionFrequenceBalles.getProgress() * 5) + 30) + " balles/min"); // 5 balles par palier, 30 balles minimum

        String effet;
        int intensiteEffet = barreProgressionEffetBalles.getProgress() - 8;

        if (barreProgressionEffetBalles.getProgress() == 8)
            effet = "Aucun";
        else if (barreProgressionEffetBalles.getProgress() < 8)
        {
            effet = "Coupé";
            intensiteEffet = 0 - intensiteEffet;
        }
        else
            effet = "Lifté";

        switch(effet)
        {
            case "Aucun":
                texteValeurEffetBalles.setText(effet);
                break;
            default:
                texteValeurEffetBalles.setText(effet + " " + intensiteEffet); // 10% par palier
        }

        texteValeurPuissanceBalles.setText(((barreProgressionPuissanceBalles.getProgress() * 10) + 10) + "%"); // 10% par pallier, 10% minimum

        String stringRotation;
        int rotationActuelle = barreProgressionRotationLanceur.getProgress() * 5; // 5° par pallier

        if(rotationActuelle > 45)
            stringRotation = (rotationActuelle - 45) + "° à droite";
        else if(rotationActuelle < 45)
            stringRotation = (45 - rotationActuelle) + "° à gauche";
        else
            stringRotation = (rotationActuelle - 45) +  "°";

        texteValeurRotationLanceur.setText(stringRotation);
    }

Méthode onCLick pour la gestion de l'évènement d'un click.

Paramètres:
elementétant la vue sur laquelle l'utilisateur a cliqué.

Références com.ttpa.iris.ttpamobile.IHMEcranPrincipal.actionnerSeance(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.ajouterJoueur(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.arreterSeance(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.boutonActionSeance, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.boutonAppliquerNomJoueur, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.boutonArreterSeance, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.boutonBluetooth, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.boutonHistorique, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.boutonParametres, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.demarrageBluetooth(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.envoyerTrameConnexionPeripheriqueBluetoothEcran(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.nomJoueur, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.parametresActuels, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.redirectionActiviteHistorique(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.SELECTION_ZONE_ROBOT, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.selectionnerZone(), com.ttpa.iris.ttpamobile.ParametreSeance.setNomJoueur(), et com.ttpa.iris.ttpamobile.IHMEcranPrincipal.verifierConnexionAppareilsBluetoothRequis().

Référencé par com.ttpa.iris.ttpamobile.IHMEcranPrincipal.ajouterJoueur(), et com.ttpa.iris.ttpamobile.IHMEcranPrincipal.selectionnerZone().

    {
        Log.d("IHMEcranPrincipal", "onClick()");

        if(element == boutonAppliquerNomJoueur)
        {
            ajouterJoueur();
        }
        else if(element == boutonBluetooth)
        {
            if(!verifierConnexionAppareilsBluetoothRequis()) // Si tous les appareils Bluetooth ne sont pas connectés
            {
                //Toast.makeText(getApplicationContext(), "Attendre..", Toast.LENGTH_SHORT).show();
                demarrageBluetooth();
            }
        }
        else if(element == boutonHistorique)
        {
            Log.d("IHMEcranPrincipal", "onClick() boutonHistorique");

            // Redirection vers l'activité de l'historique des séances
            redirectionActiviteHistorique();
        }
        else if(element == boutonParametres)
        {
            // Gérer le click sur le bouton paramétres (engrenage)
            selectionnerZone(SELECTION_ZONE_ROBOT, 0, 0);
        }
        else if(element == boutonActionSeance)
        {
            Log.d("IHMEcranPrincipal", "onClick() boutonActionSeance");
            parametresActuels.setNomJoueur(nomJoueur);
            envoyerTrameConnexionPeripheriqueBluetoothEcran();
            actionnerSeance();
        }
        else if(element == boutonArreterSeance)
        {
            Log.d("IHMEcranPrincipal", "onClick() boutonArreterSeance");
            arreterSeance(false);
        }
    }
void com.ttpa.iris.ttpamobile.IHMEcranPrincipal.onCreate ( Bundle  savedInstanceState) [protected]

Références com.ttpa.iris.ttpamobile.IHMEcranPrincipal.affecterMembresIHM(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.appliquerParametresSeance(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.connexionBaseDeDonnees(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.creerListeJoueurs(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.demarrageBluetooth(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.modifierValeursParametresIHM(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.rendreBarresProgressionIHMUtilisables(), et com.ttpa.iris.ttpamobile.IHMEcranPrincipal.rendreBoutonsIHMCliquables().

    {
        Log.d("IHMEcranPrincipal", "onCreate()");

        super.onCreate(savedInstanceState);
        setContentView(R.layout.ecran_principal);

        // Affectation des membres de l'IHM
        affecterMembresIHM();

        // Modifier les valeurs des champs de paramètre de l'IHM en fonction des états des barres de progression
        modifierValeursParametresIHM();

        // Rendre les boutons présents dans l'IHM cliquables
        rendreBoutonsIHMCliquables();

        // Rendre les barres de progression présents dans l'IHM utilisables
        rendreBarresProgressionIHMUtilisables();

        // Connexion à la base de données
        connexionBaseDeDonnees();

        // Crée une liste des joueurs enregistrés
        creerListeJoueurs();

        // Appliquer les paramètres de séance actuels
        appliquerParametresSeance();

        // Démarrage du Bluetooth puis connexion aux appareils du projet détectés
        demarrageBluetooth();
    }
void com.ttpa.iris.ttpamobile.IHMEcranPrincipal.onProgressChanged ( SeekBar  seekBar,
int  progress,
boolean  fromUser 
)

Méthode onProgressChanged() appellée lorsqu'une barre de progression est modifiée.

Paramètres:
seekBarétant la barre de progression modifiée
progressétant le progrès actuel de la barre de progression modifiée
fromUser

Références com.ttpa.iris.ttpamobile.IHMEcranPrincipal.modifierValeursParametresIHM().

Méthode onStartTrackingTouch() appellée lorsqu'une barre de progression commence à être modifiée.

Paramètres:
seekBarétant la barre de progression modifiée
    {}

Méthode onStopTrackingTouch() appellée lorsqu'une barre de progression a fini d'être modifiée.

Paramètres:
seekBarétant la barre de progression modifiée
    {
        //appliquerParametresSeance();
    }

Méthode redirectionActiviteHistorique() démarrant l'activité IHMHistoriqueSeances permettant de visualiser l'historique des séances du joueur actuel.

Référencé par com.ttpa.iris.ttpamobile.IHMEcranPrincipal.onClick().

    {
        Log.d("IHMEcranPrincipal", "redirectionActiviteHistorique()");

        Intent intent = new Intent(IHMEcranPrincipal.this, IHMHistoriqueSeances.class);
        startActivity(intent);
    }
void com.ttpa.iris.ttpamobile.IHMEcranPrincipal.selectionnerZone ( final int  typeSelection,
int  choixObjectif,
int  choixRobot 
) [private]

Méthode selectionnerZone() affichant une boite de dialogue permettant de selectionner la zone du robot ou la zone de l'objectif.

Paramètres:
typeSelection
choixObjectif
choixRobot

Références com.ttpa.iris.ttpamobile.IHMEcranPrincipal.idZonePrecedente, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.idZonePrecedenteObjectif, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.idZonePrecedenteRobot, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.onClick(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.SELECTION_ZONE_OBJECTIF, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.SELECTION_ZONE_ROBOT, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.strZoneObjectif, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.strZoneRobot, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.zoneObjectif, et com.ttpa.iris.ttpamobile.IHMEcranPrincipal.zoneRobot.

Référencé par com.ttpa.iris.ttpamobile.IHMEcranPrincipal.actionnerSeance(), et com.ttpa.iris.ttpamobile.IHMEcranPrincipal.onClick().

    {
        Log.d("IHMEcranPrincipal", "selectionnerZone()");

        final AlertDialog.Builder selectionZone = new AlertDialog.Builder(this);
        LayoutInflater factory = LayoutInflater.from(this);
        final View selectionZoneView = factory.inflate(R.layout.zones, null);
        selectionZone.setView(selectionZoneView);

        List<Button> boutonsZone = new ArrayList<Button>();

        Button btnZone1 = (Button)selectionZoneView.findViewById(R.id.case1);
        boutonsZone.add(btnZone1);
        Button btnZone2 = (Button)selectionZoneView.findViewById(R.id.case2);
        boutonsZone.add(btnZone2);
        Button btnZone3 = (Button)selectionZoneView.findViewById(R.id.case3);
        boutonsZone.add(btnZone3);
        Button btnZone4 = (Button)selectionZoneView.findViewById(R.id.case4);
        boutonsZone.add(btnZone4);
        Button btnZone5 = (Button)selectionZoneView.findViewById(R.id.case5);
        boutonsZone.add(btnZone5);
        Button btnZone6 = (Button)selectionZoneView.findViewById(R.id.case6);
        boutonsZone.add(btnZone6);
        Button btnZone7 = (Button)selectionZoneView.findViewById(R.id.case7);
        boutonsZone.add(btnZone7);
        Button btnZone8 = (Button)selectionZoneView.findViewById(R.id.case8);
        boutonsZone.add(btnZone8);
        Button btnZone9 = (Button)selectionZoneView.findViewById(R.id.case9);
        boutonsZone.add(btnZone9);

        if(choixObjectif > 0)
        {
            Button btnZone = boutonsZone.get(choixObjectif - 1);
            btnZone.setBackgroundResource(R.drawable.case_cible);
        }
        if(choixRobot > 0)
        {
            Button btnZone = boutonsZone.get(choixRobot - 1);
            btnZone.setBackgroundResource(R.drawable.case_robot);
        }

        for(int i = 0; i < 9; i++)
        {
            Button btnZone = boutonsZone.get(i);

            // Changer l'icône de fond du bouton si la zone correspondante est actuellement occupée par le robot ou l'objectif
            if((i + 1) ==  zoneRobot) // i + 1 étant le numéro de zone actuel
                btnZone.setBackgroundResource(R.drawable.case_robot);

            /*if((i + 1) ==  zoneObjectif) // i + 1 étant le numéro de zone actuel
                btnZone.setBackgroundResource(R.drawable.case_cible);*/

            btnZone.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    Button myButton = (Button)selectionZoneView.findViewById(v.getId());
                    int zoneActuelle = Integer.parseInt(myButton.getText().toString().substring(myButton.getText().toString().length() - 1));

                    switch (typeSelection)
                    {
                        case SELECTION_ZONE_OBJECTIF:
                            idZonePrecedente = idZonePrecedenteObjectif;
                            break;
                        case SELECTION_ZONE_ROBOT:
                            idZonePrecedente = idZonePrecedenteRobot;
                            break;
                    }

                    if(idZonePrecedente != -1)
                    {
                        Button myButtonPrecedent = (Button)selectionZoneView.findViewById(idZonePrecedente);
                        int numeroZonePrecedente = Integer.parseInt(myButtonPrecedent.getText().toString().substring(myButtonPrecedent.getText().toString().length() - 1));

                        switch(typeSelection)
                        {
                            case SELECTION_ZONE_OBJECTIF:
                                if((v.getId() != idZonePrecedenteRobot) && (myButtonPrecedent.getId() != idZonePrecedenteRobot))
                                    myButtonPrecedent.setBackgroundResource(R.drawable.case_libre);
                                break;
                            /*case SELECTION_ZONE_ROBOT:
                                if(v.getId() != idZonePrecedenteObjectif)
                                    myButtonPrecedent.setBackgroundResource(R.drawable.case_libre);
                                break;*/
                            default:
                                myButtonPrecedent.setBackgroundResource(R.drawable.case_libre);
                                break;
                        }
                    }

                    switch (typeSelection)
                    {
                        case SELECTION_ZONE_OBJECTIF:
                            if (v.getId() != idZonePrecedenteRobot)
                                idZonePrecedenteObjectif = v.getId();
                            break;
                        case SELECTION_ZONE_ROBOT:
                            idZonePrecedenteRobot = v.getId();
                            break;
                    }

                    idZonePrecedente = v.getId();

                    if(typeSelection == SELECTION_ZONE_OBJECTIF)
                    {
                        // Vérifier si l'objectif ne tombe pas sur la zone du robot
                        if(zoneActuelle !=  zoneRobot)
                        {
                            if (strZoneObjectif == myButton.getText().toString())
                            {
                                myButton.setBackgroundResource(R.drawable.case_libre);
                                strZoneObjectif = "ZONE 0";
                            }
                            else
                            {
                                myButton.setBackgroundResource(R.drawable.case_cible);
                                strZoneObjectif = myButton.getText().toString();
                            }

                            Log.d("IHMEcranPrincipal", "Objectif : " + strZoneObjectif);
                        }
                    }
                    else if(typeSelection == SELECTION_ZONE_ROBOT)
                    {
                        if (strZoneRobot == myButton.getText().toString())
                        {
                            myButton.setBackgroundResource(R.drawable.case_libre);
                            strZoneRobot = "ZONE 0";
                        }
                        else
                        {
                            myButton.setBackgroundResource(R.drawable.case_robot);
                            strZoneRobot = myButton.getText().toString();
                        }

                        Log.d("IHMEcranPrincipal", "Robot : " + strZoneRobot);
                    }
                }
            });
        }

        if(typeSelection == SELECTION_ZONE_OBJECTIF)
            selectionZone.setTitle("Placer l'objectif");
        if(typeSelection == SELECTION_ZONE_ROBOT)
            selectionZone.setTitle("Placer le robot");

        selectionZone.setPositiveButton("Valider", new DialogInterface.OnClickListener()
        {
            public void onClick(DialogInterface dialog, int which)
            {
                if(typeSelection == SELECTION_ZONE_OBJECTIF)
                {
                    Log.d("IHMEcranPrincipal", "Zone objectif validée : " + strZoneObjectif);
                    zoneObjectif = Integer.parseInt(strZoneObjectif.substring(strZoneObjectif.length() - 1));
                }
                else if(typeSelection == SELECTION_ZONE_ROBOT)
                {
                    Log.d("IHMEcranPrincipal", "Zone robot validée : " + strZoneRobot);
                    zoneRobot = Integer.parseInt(strZoneRobot.substring(strZoneRobot.length() - 1));
                    // Puis sélectionner l'objectif
                    selectionnerZone(SELECTION_ZONE_OBJECTIF, 0, 0);
                }

                if (idZonePrecedente == -1)
                    idZonePrecedente = 0;
            }
        });

        selectionZone.setNegativeButton("Annuler", new DialogInterface.OnClickListener()
        {
            public void onClick(DialogInterface dialog, int which)
            {
                if(typeSelection == SELECTION_ZONE_OBJECTIF)
                {
                    strZoneObjectif = "";
                    zoneObjectif = 0;
                }
                else if(typeSelection == SELECTION_ZONE_ROBOT)
                {
                    strZoneRobot = "";
                    zoneRobot = 0;
                    // Puis sélectionner l'objectif
                    selectionnerZone(SELECTION_ZONE_OBJECTIF, 0, 0);
                }
            }
        });

        selectionZone.show();
    }
void com.ttpa.iris.ttpamobile.IHMEcranPrincipal.traiterDonneesRecues ( String  nomAppareilSource,
String  donnees 
) [private]

Méthode traiterDonneesRecues() permettant la traitement des données bluetooth reçues en fonction de l'appareil source de ces données.

Paramètres:
nomAppareilSourceétant l'appareil duquel on reçoit les données
donneesétant les données reçues

Références com.ttpa.iris.ttpamobile.IHMEcranPrincipal.NOM_PERIPHERIQUE_BLUETOOTH_LANCEUR, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.NOM_PERIPHERIQUE_BLUETOOTH_TABLE, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.traiterDonneesRecuesLanceur(), et com.ttpa.iris.ttpamobile.IHMEcranPrincipal.traiterDonneesRecuesTable().

    {
        Log.d("IHMEcranPrincipal", "traiterDonneesRecues()");

        switch (nomAppareilSource)
        {
            case NOM_PERIPHERIQUE_BLUETOOTH_LANCEUR:
                traiterDonneesRecuesLanceur(donnees);
                break;
            case NOM_PERIPHERIQUE_BLUETOOTH_TABLE:
                traiterDonneesRecuesTable(donnees);
                break;
            default:
                break;
        }
    }

Méthode traiterDonneesRecuesLanceur() permettant le traitement des données reçues par le lanceur.

Paramètres:
donneesétant les données reçues

Références com.ttpa.iris.ttpamobile.IHMEcranPrincipal.traiterErreurRecueLanceur(), et com.ttpa.iris.ttpamobile.IHMEcranPrincipal.TRAME_ENTETE.

Référencé par com.ttpa.iris.ttpamobile.IHMEcranPrincipal.traiterDonneesRecues().

    {
        Log.d("IHMEcranPrincipal", "traiterDonneesRecuesLanceur()");

        List<String> donneeRecue = new ArrayList<String>(Arrays.asList(donnees.split(":")));

        switch (donneeRecue.get(0))
        {
            case TRAME_ENTETE:
                if(donneeRecue.get(1).contains("ERREUR"))
                    traiterErreurRecueLanceur(donneeRecue.get(1));
                break;
            default:
                Log.e("IHMEcranPrincipal", "traiterDonneesRecuesLanceur() : trame non reconnue !");
        }
    }

Méthode traiterDonneesRecuesTable() permettant le traitement des données reçues par la table.

Paramètres:
donneesétant les données reçues

Références com.ttpa.iris.ttpamobile.IHMEcranPrincipal.calculerReussiteSeance(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.envoyerTramePeripheriqueBluetoothEcran(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.incrementerBallesJouees(), et com.ttpa.iris.ttpamobile.IHMEcranPrincipal.TRAME_ENTETE.

Référencé par com.ttpa.iris.ttpamobile.IHMEcranPrincipal.traiterDonneesRecues().

    {
        Log.d("IHMEcranPrincipal", "traiterDonneesRecuesTable()");

        List<String> donneeRecue = new ArrayList<String>(Arrays.asList(donnees.split(":")));

        switch (donneeRecue.get(0))
        {
            case TRAME_ENTETE:
                // Transferer la trame reçue à l'écran
                envoyerTramePeripheriqueBluetoothEcran(donnees);

                switch(donneeRecue.get(1))
                {
                    case "IMPACT":
                        if(Integer.parseInt(donneeRecue.get(2)) != 0) // Si l'impacte a eu lieu sur une des 9 zones et non sur le côté du lanceur
                            calculerReussiteSeance(Integer.parseInt(donneeRecue.get(2)));
                        else
                            incrementerBallesJouees();
                        break;
                    case "FAUTE":
                        calculerReussiteSeance(-1);
                }

                break;
            default:
                Log.e("IHMEcranPrincipal", "traiterDonneesRecuesTable() : trame non reconnue !");
        }
    }

Méthode traiterErreurRecueLanceur() permettant la gestion des erreurs en provenance du lanceur.

Paramètres:
erreurétant le code d'erreur reçu

Références com.ttpa.iris.ttpamobile.IHMEcranPrincipal.pauserSeance().

Référencé par com.ttpa.iris.ttpamobile.IHMEcranPrincipal.traiterDonneesRecuesLanceur().

    {
        Log.d("IHMEcranPrincipal", "traiterErreurRecueLanceur() code d'erreur : " + erreur);

        pauserSeance();
    }

Méthode verifierConnexionAppareilsBluetoothRequis() vérifiant si les appareils Bluetooth nécessaires au bon déroulement d'une séance sont détectés et connectés, puis modifie l'IHM en conséquent.

Renvoie:
booléen tous les appareils sont connectés ou non

Références com.ttpa.iris.ttpamobile.IHMEcranPrincipal.actualiserIHMAppareilsBluetooth(), com.ttpa.iris.ttpamobile.PeripheriqueBluetooth.estConnecte(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.modifierIHMBluetoothInsuffisant(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.modifierIHMBluetoothOperationnel(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.modifierIHMBluetoothSuffisant(), com.ttpa.iris.ttpamobile.IHMEcranPrincipal.peripheriqueBluetoothEcran, com.ttpa.iris.ttpamobile.IHMEcranPrincipal.peripheriqueBluetoothLanceur, et com.ttpa.iris.ttpamobile.IHMEcranPrincipal.peripheriqueBluetoothTable.

Référencé par com.ttpa.iris.ttpamobile.IHMEcranPrincipal.onClick().

    {
        Log.d("IHMEcranPrincipal", "verifierConnexionAppareilsBluetoothRequis()");

        boolean ecranEstDetecte = (peripheriqueBluetoothEcran!=null);
        boolean lanceurEstDetecte = (peripheriqueBluetoothLanceur != null);
        boolean tableEstDetectee = (peripheriqueBluetoothTable != null);
        boolean ecranEstConnecte = false;
        boolean lanceurEstConnecte = false;
        boolean tableEstConnectee = false;

        if(ecranEstDetecte)
            ecranEstConnecte = peripheriqueBluetoothEcran.estConnecte();

        if(lanceurEstDetecte)
            lanceurEstConnecte = peripheriqueBluetoothLanceur.estConnecte();

        if(tableEstDetectee)
            tableEstConnectee = peripheriqueBluetoothTable.estConnecte();

        actualiserIHMAppareilsBluetooth(tableEstConnectee, lanceurEstConnecte, ecranEstConnecte);

        boolean appareilsTousConnectes = ecranEstConnecte && lanceurEstConnecte && tableEstConnectee;
        boolean aucunAppareilConnecte = !ecranEstConnecte && !lanceurEstConnecte && !tableEstConnectee;

        if(appareilsTousConnectes) // Si tous les appareils sont connectés
        {
            modifierIHMBluetoothOperationnel();
            return true;
        }
        else if(aucunAppareilConnecte) // Si aucun appareil n'est connecté
        {
            modifierIHMBluetoothInsuffisant();
            return false;
        }
        else
        {
            modifierIHMBluetoothSuffisant(); // Si au moins un appareil est connecté
        }

        return false;
    }

Documentation des données membres

final int com.ttpa.iris.ttpamobile.IHMEcranPrincipal.COULEUR_BOUTON_GRIS = Color.parseColor("#c0c5c6") [static, private]
final int com.ttpa.iris.ttpamobile.IHMEcranPrincipal.COULEUR_BOUTON_ORANGE = Color.parseColor("#f7bb31") [static, private]
final int com.ttpa.iris.ttpamobile.IHMEcranPrincipal.COULEUR_BOUTON_ROUGE = Color.parseColor("#ee5e5e") [static, private]
final int com.ttpa.iris.ttpamobile.IHMEcranPrincipal.COULEUR_BOUTON_VERT = Color.parseColor("#5eed7b") [static, private]
String com.ttpa.iris.ttpamobile.IHMEcranPrincipal.strZoneObjectif = new String("ZONE 0") [package]
String com.ttpa.iris.ttpamobile.IHMEcranPrincipal.strZoneRobot = new String("ZONE 0") [package]
final String com.ttpa.iris.ttpamobile.IHMEcranPrincipal.TRAME_ECRAN_FIN_SEANCE = ":FINSEANCE" [static, private]
final String com.ttpa.iris.ttpamobile.IHMEcranPrincipal.TRAME_ENTETE = "$TTPA" [static, private]
final String com.ttpa.iris.ttpamobile.IHMEcranPrincipal.TRAME_FIN = "\r\n" [static, private]
final String com.ttpa.iris.ttpamobile.IHMEcranPrincipal.TRAME_LANCEUR_ARRET_SEANCE = ":STOP:" + TRAME_FIN [static, private]
final String com.ttpa.iris.ttpamobile.IHMEcranPrincipal.TRAME_LANCEUR_PAUSE_SEANCE = ":PAUSE:" + TRAME_FIN [static, private]
final String com.ttpa.iris.ttpamobile.IHMEcranPrincipal.TRAME_LANCEUR_PING = ":PING:" + TRAME_FIN [static, private]
final String com.ttpa.iris.ttpamobile.IHMEcranPrincipal.TRAME_LANCEUR_REPRISE_SEANCE = ":RESUME:" + TRAME_FIN [static, private]

La documentation de cette classe a été générée à partir du fichier suivant :
 Tout Classes Fichiers Fonctions Variables