Oddělení informace o licenci

This commit is contained in:
2024-04-12 12:15:37 +02:00
parent 2b7a68e64a
commit 671a764b04
8 changed files with 38 additions and 27 deletions

View File

@@ -29,7 +29,6 @@ uint32_t serialNumber {};
string date = "";
string oemID = "";
string name = "";
string licenceFileName = "";
bool isLoaded = false;
};
@@ -64,7 +63,6 @@ bool getCIDFromFile();
bool getCSDFromFile();
public:
SDCardData cardData;
bool isLoaded = false;
char cid[32] = {};
@@ -76,8 +74,6 @@ public:
SDCard();
SDCard(string cid, string csd);
SDCard(const string filesPath);
};
#endif

View File

@@ -50,7 +50,7 @@ public:
void createLicenceFile();
LicenceInfoGeneral licenceInfo {};
LicenceInfoGeneral licenceInfoGeneral {};
private:
LicenceIdentification licIdentification;

View File

@@ -23,6 +23,12 @@ struct InitStructure
string cid_csd_filePath = "";
};
/// @brief struktura pro informaci o licenci
struct LicenceInfo
{
string licenceFileName = "";
};
class LicenceReader
{
@@ -32,6 +38,7 @@ public:
bool argumentsCorrect = false;
ErrorMessage error;
SDCardInfo sdCardInfo {};
LicenceInfo licInfo {};
LicenceReader();
~LicenceReader();
@@ -39,13 +46,14 @@ public:
bool initread(int elcType, InitStructure &initStructure);
bool getLicenceInfo(void *returnStructure); //vrací informace o všech licenčních bodech základě předané návratové struktury
bool getLicenceItemInfo(int protocolId, void *returnItemStructure); //vrací informace o licenčím bodu na základě id protocolu a předané návratové struktury
LicenceInfoGeneral licenceInfo {}; //pole licencí
private:
Licence2 *licence2 {}; //interní struktura pro zpracování licence ELC2
Licence1 *licence1 {}; //interní struktura pro zpracování licence ELC1
LicenceIdentification licIdentification {};
string configFileName = "";
LicenceInfoGeneral licencesInfo {}; //pole licencí
};
#endif

Binary file not shown.

Binary file not shown.

View File

@@ -9,7 +9,7 @@
/// @param argc
/// @param argv parametry pro generování licence
/// @return
int main8(int argc, char *argv[])
int main7(int argc, char *argv[])
{
unordered_map<string, string> arguments = getArguments(argc, argv);
try

View File

@@ -67,7 +67,10 @@ int main()
cout << "date: " << licenceReaderELC2.sdCardInfo.date << "\n";
cout << "name: " << licenceReaderELC2.sdCardInfo.name << "\n";
cout << "oemID: " << licenceReaderELC2.sdCardInfo.oemID << "\n";
cout << "licenceFileName: " << licenceReaderELC2.sdCardInfo.licenceFileName << "\n";
cout << "název licenčního souboru: " << licenceReaderELC2.licInfo.licenceFileName << "\n";
// if (initStructure.compatibility == 1) //ukazka kompatibilita 1
// {

View File

@@ -75,7 +75,7 @@ bool LicenceReader::initread(int elcType, InitStructure &initStructure)
try
{
this->licence1->readLicence(&this->licenceInfo);
this->licence1->readLicence(&this->licencesInfo);
}
catch (const LicenceException &ex)
{
@@ -91,7 +91,7 @@ bool LicenceReader::initread(int elcType, InitStructure &initStructure)
this->licence2 = &licenceELC2;
licenceELC2.cid_cdsPath = initStructure.cid_csd_filePath;
licenceELC2.licenceFilePath = initStructure.licenceFilePath;
this->licence2->readLicence(&this->licenceInfo);
this->licence2->readLicence(&this->licencesInfo);
this->sdCardInfo.isLoaded = true;
this->sdCardInfo.serialNumber = this->licence2->sdCard.cardData.serialNumber;
@@ -99,7 +99,11 @@ bool LicenceReader::initread(int elcType, InitStructure &initStructure)
this->sdCardInfo.date = this->licence2->sdCard.cardData.date;
this->sdCardInfo.name = this->licence2->sdCard.cardData.name;
this->sdCardInfo.oemID = this->licence2->sdCard.cardData.oemID;
this->sdCardInfo.licenceFileName = this->licence2->licFileName;
this->licInfo.licenceFileName = this->licence2->licFileName;
//this->licenceInfo.
//this->sdCardInfo.licenceFileName = this->licence2->licFileName;
break;
}
@@ -140,7 +144,7 @@ bool LicenceReader::getLicenceItemInfo(int protocolId, void *returnItemStructure
if (!this->licIdentification.licCompatibility) // defaultní kompatibilita
{
LicenceELC1Info *resultPtr = static_cast<LicenceELC1Info *>(returnItemStructure);
if (this->licenceInfo.licences.count(1)) // stare eov má natvrdo "id" 1.
if (this->licencesInfo.licences.count(1)) // stare eov má natvrdo "id" 1.
resultPtr->isValid = true;
else
resultPtr->isValid = false;
@@ -157,8 +161,8 @@ bool LicenceReader::getLicenceItemInfo(int protocolId, void *returnItemStructure
{
LicenceELC2Item *resultPtr = static_cast<LicenceELC2Item *>(returnItemStructure);
resultPtr->protocolId = protocolId;
if (this->licenceInfo.licences.count(protocolId))
resultPtr->dataPointsCount = this->licenceInfo.licences.at(protocolId);
if (this->licencesInfo.licences.count(protocolId))
resultPtr->dataPointsCount = this->licencesInfo.licences.at(protocolId);
else
{
resultPtr->dataPointsCount = 0;
@@ -218,7 +222,7 @@ bool LicenceReader::getLicenceInfo(void *returnStructure)
{
LicenceELC1Info *resultPtr = static_cast<LicenceELC1Info *>(returnStructure);
if (this->licenceInfo.licences.count(1)) // starý EOS má natvrdo "id" 1
if (this->licencesInfo.licences.count(1)) // starý EOS má natvrdo "id" 1
{
resultPtr->isValid = true;
}
@@ -246,7 +250,7 @@ bool LicenceReader::getLicenceInfo(void *returnStructure)
if (!this->licIdentification.licCompatibility) // defaultní kompatibilita
{
Reader::Licence2 licenceELC2 = Reader::Licence2(this->licIdentification);
licenceELC2.readLicence(&this->licenceInfo);
licenceELC2.readLicence(&this->licencesInfo);
licenceELC2.getLicenceInfo(returnStructure);
}
else