![]() |
Kart
1.1
BTS SN-IR La Salle Avignon 2018
|
Permet la réception des trames envoyées par le kart. Plus de détails...
#include <communication.h>
Connecteurs publics | |
void | recevoir () |
Signaux | |
void | nouvelEchantillon (Echantillon echantillon) |
Fonctions membres publiques | |
Communication (QObject *parent=0) | |
Constructeur par défaut. | |
~Communication () | |
Destructeur. | |
QString | getIdKart () |
void | setIdKart (QString idKart) |
Fonctions membres privées | |
void | creerPort () |
void | ouvrirPort () |
void | configurerPort () |
bool | verifierTrame (QString &donneesLues) |
void | extraireDonnees () |
void | fermerPort () |
Attributs privés | |
QextSerialPort * | port |
QString | idKart |
QString | trame |
Communication::Communication | ( | QObject * | parent = 0 | ) |
parent | QObject l'adresse de l'objet Qt parent |
Références configurerPort(), creerPort(), et ouvrirPort().
: QObject(parent), port(NULL), idKart("") { creerPort(); ouvrirPort(); configurerPort(); }
Références fermerPort().
{ fermerPort(); }
Communication::configurerPort | ( | ) | [private] |
Références port, et recevoir().
Référencé par Communication().
Communication::creerPort | ( | ) | [private] |
Référencé par Communication().
Communication::extraireDonnees | ( | ) | [private] |
Références CHAMP_CHARGE, CHAMP_COURANT, CHAMP_IDKART, CHAMP_TEMPERATURE, CHAMP_TENSION, CHAMP_VITESSE, Echantillon::chargeBatterie, Echantillon::courantBatterie, Echantillon::horodatage, Echantillon::idKart, idKart, nouvelEchantillon(), Echantillon::temperatureMoteur, Echantillon::tensionBatterie, trame, et Echantillon::vitesse.
Référencé par recevoir().
{ // Retire le \r trame.chop(1); // Retire le $ trame.remove(0, 1); QStringList champs = trame.split(","); qDebug() << Q_FUNC_INFO << champs; Echantillon echantillon; echantillon.idKart = champs.at(CHAMP_IDKART); echantillon.horodatage = QDateTime::currentDateTime(); echantillon.temperatureMoteur = champs.at(CHAMP_TEMPERATURE).toDouble(); echantillon.tensionBatterie = champs.at(CHAMP_TENSION).toDouble(); echantillon.courantBatterie = champs.at(CHAMP_COURANT).toDouble(); echantillon.vitesse = champs.at(CHAMP_VITESSE).toDouble(); echantillon.chargeBatterie = champs.at(CHAMP_CHARGE).toInt(); if(echantillon.idKart == idKart) { // Envoie le signal qui contient l'échantillon extrait emit nouvelEchantillon(echantillon); } }
Communication::fermerPort | ( | ) | [private] |
QString Communication::getIdKart | ( | ) |
Communication::nouvelEchantillon | ( | Echantillon | echantillon | ) | [signal] |
echantillon |
Référencé par extraireDonnees().
Communication::ouvrirPort | ( | ) | [private] |
Références port.
Référencé par Communication().
{ //Ouverture port droit ecriture lecture port->open(QIODevice::ReadWrite | QIODevice::Unbuffered); }
Communication::recevoir | ( | ) | [slot] |
Références extraireDonnees(), port, trame, et verifierTrame().
Référencé par configurerPort().
{ QByteArray donnees; while(port->bytesAvailable()) { donnees += port->readAll(); usleep(50000); } //qDebug() << Q_FUNC_INFO << donneesLues; QString donneesLues(donnees); qDebug() << Q_FUNC_INFO << donneesLues; if(verifierTrame(donneesLues)) { trame = donneesLues; extraireDonnees(); } }
void Communication::setIdKart | ( | QString | idKart | ) |
idKart |
Références idKart.
Référencé par IHMKart::arreterEssai(), et IHMKart::demarrerEssai().
Communication::verifierTrame | ( | QString & | donneesLues | ) | [private] |
donneesLues |
Référencé par recevoir().
{ if(donneesLues.startsWith("$")) { if(donneesLues.endsWith("\r")) { return true; } } return false; }
QString Communication::idKart [private] |
Référencé par extraireDonnees(), getIdKart(), et setIdKart().
QextSerialPort* Communication::port [private] |
Référencé par configurerPort(), creerPort(), fermerPort(), ouvrirPort(), et recevoir().
QString Communication::trame [private] |
Référencé par extraireDonnees(), et recevoir().