oddeleni a lazeni ELC1

This commit is contained in:
2024-02-01 15:07:33 +01:00
parent c0b36e9068
commit 5229f16c9d
23 changed files with 346 additions and 175 deletions

View File

@@ -1,38 +1,14 @@
#include <stdio.h>
#include "utils.h"
#include "licenceReader.h"
/// @brief hlavní funkce
/// @param argc
/// @param argv parametry pro generování licence
/// @return
int main5()
int main()
{
// unordered_map<string, string> arguments = getArguments(argc, argv);
// try
// {
// unordered_map<string, string> arguments = getArguments(argc, argv);
// LicenceGenerator generatorOld = LicenceGenerator(arguments["-uid"], arguments["-cid"], arguments["-csd"], arguments["-configFileName"]);
// generatorOld.createLicenceFile();
// system("pause");
// return SUCCES;
// }
// catch (...)
// {
// cerr << "Obecná chyba\n";
// }
// system("pause");
// return SUCCES;
try
{
int protocolId = 444;
LicenceReader licenceReader1 {};
InitStructure initStructure;
initStructure.licenceType = (int)LicenceType::EOS_EOV;
initStructure.licenceVersion = 1;
@@ -41,52 +17,77 @@ int main5()
initStructure.licenceFilePath = "";
initStructure.cid_csd_filePath = "";
cout << "-- verze #1: init a iterace" << "\n";
//verze #1: načtení kompletní licence a zobrazení
if (licenceReader1.init(2, initStructure))
// verze původní ELC 1
LicenceReader licenceReaderELC1{};
if (licenceReaderELC1.initread(1, initStructure)) //iniciacni nacteni
{
LicenceInfo21 info; // podle ELC a kompatibility určit strukuru (LicenceInfo11, LicenceInfo21, LicenceInfo31)
if (licenceReader1.getLicenceInfo(&info))
LicenceInfo1 info; // struktura pro ELC1. Nemá tam asi nic jiného smysl nez true/false
if (licenceReaderELC1.getLicenceInfo(&info))
{
if (info.licences.count(protocolId) > 0) cout << "Počet z vectoru pro : " << protocolId << ": " << info.licences.at(protocolId) << endl;
cout << "Všechny licenční body: " << endl;
for (const auto &pair : info.licences) { std::cout << "<" << pair.first << ", " << pair.second << ">" << endl; }
}
else cout << "Došlo k chybě: " << licenceReader1.error.message;
}
else
{
cout << "Došlo k chybě: " << licenceReader1.error.message;
}
cout << "\n" << "-- verze #2: init a iterace" << "\n";
//verze #2 : iterace pro kazdý bod zvlášť
LicenceReader licenceReader2 {};
if (licenceReader2.initread(2, initStructure))
{
LicenceItem21 info; // podle ELC a kompatibility určit strukuru (LicenceInfo11, LicenceInfo21, LicenceInfo31)
if (licenceReader2.getLicenceItemInfo(protocolId, &info))
{
std::cout << "Počet licenčních bodů pro " << info.protocolId << ": " << info.dataPointsCount << std::endl;
if (info.isValid)
cout << "Platna licence ELC1 \n";
else
cout << "Neplatna licence ELC1\n";
}
else
cout << "Došlo k chybě: " << licenceReader2.error.message;
cout << "CHYBA: " << licenceReaderELC1.error.message;
}
else
{
cout << "Došlo k chybě: " << licenceReader2.error.message;
cout << "CHYBA: " << licenceReaderELC1.error.message;
}
// verze ELC 2 pro jeden protokol
LicenceReader licenceReaderELC2{};
if (licenceReaderELC2.initread(2, initStructure)) //iniciacni nacteni
{
LicenceItem21 info; // podle ELC a kompatibility určit strukuru (LicenceInfo11, LicenceInfo21, LicenceInfo31)
int protocolId = 444;
if (licenceReaderELC2.getLicenceItemInfo(protocolId, &info))
{
cout << "Pocet licencních bodu pro " << info.protocolId << ": " << info.dataPointsCount << std::endl;
}
else
cout << "CHYBA: " << licenceReaderELC2.error.message;
}
else
{
cout << "CHYBA: " << licenceReaderELC2.error.message;
}
LicenceReader licenceReaderCompleteELC2{};
// verze ELC 2 kompletní načtení
if (licenceReaderCompleteELC2.init(2, initStructure)) //iniciacni nacteni
{
LicenceInfo21 info; // podle ELC a kompatibility určit strukuru (LicenceInfo11, LicenceInfo21, LicenceInfo31)
int protocolId = 333;
if (licenceReaderCompleteELC2.getLicenceInfo(&info))
{
if (info.licences.count(protocolId) > 0) cout << "Pocet bodu z vectoru pro protokol : " << protocolId << ": " << info.licences.at(protocolId) << "\n";
else cout << "Pro tento protokol nejsou definovay licencni body\n";
cout << "Vypis vsech licencnich bodu: " << endl;
for (const auto &pair : info.licences)
{
std::cout << "<" << pair.first << ", " << pair.second << ">" << endl;
}
}
else
cout << "CHYBA: " << licenceReaderCompleteELC2.error.message;
}
else
{
cout << "CHYBA: " << licenceReaderCompleteELC2.error.message;
}
}
catch (...)
{
cout << "Obecná chyba\n";
cout << "Obecna chyba\n";
}
system("pause");
// system("pause");
return SUCCES;
}