1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
#include <iostream>
#include <string>
using namespace std ;
class Trame{
public:
Trame( string chainerecue ){
adresseDuModule = chainerecue.substr(0,2) ;
fonction = chainerecue.substr(2,2) ;
adresseDuRegistre = chainerecue.substr(4,4) ;
etatDuVentilateur = chainerecue.substr(8,4) ;
checksum = chainerecue.substr(12,4) ;
}
string getAdresseDuModule(){return adresseDuModule;}
string getFonction(){return fonction;}
string getAdresseDuRegistre(){return adresseDuRegistre;}
string getEtatDuVentilateur(){return etatDuVentilateur;}
string getChecksum(){return checksum;}
private:
string adresseDuModule;
string fonction;
string adresseDuRegistre;
string etatDuVentilateur;
string checksum;
};
int main()
{
Trame trame("030600020001E828");
cout << trame.getAdresseDuModule() << endl ;
cout << trame.getFonction() << endl ;
cout << trame.getAdresseDuRegistre() << endl ;
cout << trame.getEtatDuVentilateur() << endl ;
cout << trame.getChecksum() << endl ;
return 0 ;
} |
Partager