oddělení, čištění, kontrola ELC1
This commit is contained in:
@@ -13,118 +13,10 @@ LicenceReader::LicenceReader()
|
||||
{
|
||||
}
|
||||
|
||||
// LicenceReader::LicenceReader(string uid, string cid, string csd, string dataFileName)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// if (dataFileName.empty())
|
||||
// throw std::runtime_error("Missing dataFileName par.");
|
||||
|
||||
// if (uid.empty() == false)
|
||||
// {
|
||||
// this->licData.uid = uid;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if (cid.empty())
|
||||
// throw std::runtime_error("Missing CID par.");
|
||||
// if (csd.empty())
|
||||
// throw std::runtime_error("Missing CSD par.");
|
||||
// }
|
||||
// }
|
||||
// catch (const std::exception &e)
|
||||
// {
|
||||
// this->argumentsCorrect = false;
|
||||
// std::cerr << "error: " << e.what() << endl;
|
||||
// return;
|
||||
// }
|
||||
|
||||
// this->configFileName = dataFileName;
|
||||
// this->licData.cid = cid;
|
||||
// this->licData.csd = csd;
|
||||
|
||||
// this->argumentsCorrect = true;
|
||||
|
||||
// if (processInputConfiguration() == false)
|
||||
// {
|
||||
// cerr << "Chyba: " << error.message << endl;
|
||||
// }
|
||||
// }
|
||||
|
||||
// LicenceReader::LicenceReader(int elcType, int licenceType, int licenceVersion, int licenceIndex, int compatibility)
|
||||
// {
|
||||
// this->licIdentification.licElcType = (ELCType)elcType;
|
||||
// this->licIdentification.licLicenceType = (LicenceType)licenceType;
|
||||
// this->licIdentification.licenceVersion = licenceVersion;
|
||||
// this->licIdentification.licenceIndex = licenceIndex;
|
||||
// this->licIdentification.licCompatibility = compatibility;
|
||||
// }
|
||||
|
||||
/// @brief inicializace generátoru a načtení licenčních bodů do obecné struktury
|
||||
/// @brief provede pouze inicialazaci čtecí třídy
|
||||
/// @param elcType
|
||||
/// @param licenceType
|
||||
/// @param licenceVersion
|
||||
/// @param licenceIndex
|
||||
/// @param compatibility
|
||||
/// @param initStructure
|
||||
/// @return
|
||||
bool LicenceReader::initread(int elcType, InitStructure &initStructure) // TOTO
|
||||
{
|
||||
try
|
||||
{
|
||||
elcSwitchType = elcType * 10 + licCompatibility;
|
||||
|
||||
if (init(elcType, initStructure))
|
||||
{
|
||||
switch (elcSwitchType)
|
||||
{
|
||||
case 11:
|
||||
{ // old eoseov
|
||||
Reader::Licence1 licenceELC1 = Reader::Licence1(this->licIdentification);
|
||||
this->licence1 = &licenceELC1;
|
||||
licenceELC1.cid_cdsPath = initStructure.cid_csd_filePath;
|
||||
licenceELC1.licenceFilePath = initStructure.licenceFilePath;
|
||||
|
||||
try
|
||||
{
|
||||
this->licence1->readLicence(&this->licenceInfo);
|
||||
}
|
||||
catch (const LicenceException &ex)
|
||||
{
|
||||
error.code = ex.getErrorCode();
|
||||
error.message = ex.getErrorMessage();
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 21:
|
||||
{
|
||||
Reader::Licence2 licenceELC2 = Reader::Licence2(this->licIdentification);
|
||||
this->licence2 = &licenceELC2;
|
||||
licenceELC2.cid_cdsPath = initStructure.cid_csd_filePath;
|
||||
licenceELC2.licenceFilePath = initStructure.licenceFilePath;
|
||||
this->licence2->readLicence(&this->licenceInfo);
|
||||
break;
|
||||
}
|
||||
case 31:
|
||||
{
|
||||
// LicenceELC31 licence = LicenceELC31(this->licIdentification);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
catch (const LicenceException &ex)
|
||||
{
|
||||
error.code = ex.getErrorCode();
|
||||
error.message = ex.getErrorMessage();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true; // TODO testy
|
||||
}
|
||||
|
||||
bool LicenceReader::init(int elcType, InitStructure &initStructure)
|
||||
{
|
||||
try
|
||||
@@ -151,7 +43,73 @@ bool LicenceReader::init(int elcType, InitStructure &initStructure)
|
||||
|
||||
elcSwitchType = elcType * 10 + licCompatibility;
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// @brief provede inicializaci čtecí třídy a zároveň načte licenční body do obecné struktury
|
||||
/// @param elcType
|
||||
/// @param licenceType
|
||||
/// @param licenceVersion
|
||||
/// @param licenceIndex
|
||||
/// @param compatibility
|
||||
/// @return
|
||||
bool LicenceReader::initread(int elcType, InitStructure &initStructure)
|
||||
{
|
||||
try
|
||||
{
|
||||
elcSwitchType = elcType * 10 + initStructure.compatibility;
|
||||
|
||||
if (init(elcType, initStructure))
|
||||
{
|
||||
switch (this->licIdentification.licElcType)
|
||||
{
|
||||
case ELCType::ELC1:
|
||||
{ // old eoseov
|
||||
Reader::Licence1 licenceELC1 = Reader::Licence1(this->licIdentification);
|
||||
this->licence1 = &licenceELC1;
|
||||
licenceELC1.cid_cdsPath = initStructure.cid_csd_filePath;
|
||||
licenceELC1.licenceFilePath = initStructure.licenceFilePath;
|
||||
|
||||
try
|
||||
{
|
||||
this->licence1->readLicence(&this->licenceInfo);
|
||||
}
|
||||
catch (const LicenceException &ex)
|
||||
{
|
||||
error.code = ex.getErrorCode();
|
||||
error.message = ex.getErrorMessage();
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ELCType::ELC2:
|
||||
{
|
||||
Reader::Licence2 licenceELC2 = Reader::Licence2(this->licIdentification);
|
||||
this->licence2 = &licenceELC2;
|
||||
licenceELC2.cid_cdsPath = initStructure.cid_csd_filePath;
|
||||
licenceELC2.licenceFilePath = initStructure.licenceFilePath;
|
||||
this->licence2->readLicence(&this->licenceInfo);
|
||||
break;
|
||||
}
|
||||
case ELCType::ELC3:
|
||||
{
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw LicenceException((int)GeneralError::ELCNotImplemented, "Toto ELC není implementováno");
|
||||
}
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
catch (const LicenceException &ex)
|
||||
{
|
||||
error.code = ex.getErrorCode();
|
||||
error.message = ex.getErrorMessage();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true; // TODO testy
|
||||
}
|
||||
|
||||
/// @brief vrací informace o licenčím bodu na základě id protocolu a předané návratové struktury
|
||||
@@ -162,28 +120,51 @@ bool LicenceReader::getLicenceItemInfo(int protocolId, void *returnItemStructure
|
||||
{
|
||||
try
|
||||
{
|
||||
switch (elcSwitchType)
|
||||
switch (this->licIdentification.licElcType)
|
||||
{
|
||||
case 11:
|
||||
case ELCType::ELC1:
|
||||
{
|
||||
LicenceInfo1 *resultPtr = static_cast<LicenceInfo1 *>(returnItemStructure);
|
||||
if (this->licenceInfo.licences.count(1)) resultPtr->isValid = true; //stare eov melo natvrdo "id" 1.
|
||||
else resultPtr->isValid = false;
|
||||
break;
|
||||
}
|
||||
case 21:
|
||||
{
|
||||
LicenceItem21 *resultPtr = static_cast<LicenceItem21 *>(returnItemStructure);
|
||||
resultPtr->protocolId = protocolId; // protocolId;
|
||||
if (this->licenceInfo.licences.count(protocolId))
|
||||
resultPtr->dataPointsCount = this->licenceInfo.licences.at(protocolId);
|
||||
if (!this->licIdentification.licCompatibility) // defaultní kompatibilita
|
||||
{
|
||||
LicenceELC1Info *resultPtr = static_cast<LicenceELC1Info *>(returnItemStructure);
|
||||
if (this->licenceInfo.licences.count(1)) // stare eov má natvrdo "id" 1.
|
||||
resultPtr->isValid = true;
|
||||
else
|
||||
resultPtr->isValid = false;
|
||||
}
|
||||
else
|
||||
resultPtr->dataPointsCount = 0;
|
||||
{
|
||||
LicenceException((int)GeneralError::CompatibilityTypeNotImplemented, "Kompatibilita není implementována.");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 31:
|
||||
case ELCType::ELC2:
|
||||
{
|
||||
if (!this->licIdentification.licCompatibility) // defaultní kompatibilita
|
||||
{
|
||||
LicenceELC2Item *resultPtr = static_cast<LicenceELC2Item *>(returnItemStructure);
|
||||
resultPtr->protocolId = protocolId; // protocolId;
|
||||
if (this->licenceInfo.licences.count(protocolId))
|
||||
resultPtr->dataPointsCount = this->licenceInfo.licences.at(protocolId);
|
||||
else
|
||||
resultPtr->dataPointsCount = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (this->licIdentification.licCompatibility)
|
||||
{
|
||||
case 1:
|
||||
// kod pro kompatibilitu 1
|
||||
break;
|
||||
default:
|
||||
LicenceException((int)GeneralError::CompatibilityTypeNotImplemented, "Kompatibilita není implementována.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ELCType::ELC3:
|
||||
{
|
||||
// LicenceELC31 licence = LicenceELC31(this->licIdentification);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@@ -211,66 +192,61 @@ bool LicenceReader::getLicenceInfo(void *returnStructure)
|
||||
{
|
||||
try
|
||||
{
|
||||
switch (elcSwitchType)
|
||||
switch (this->licIdentification.licElcType)
|
||||
{
|
||||
case 11:
|
||||
{ // old eoseov
|
||||
|
||||
LicenceInfo1 *resultPtr = static_cast<LicenceInfo1 *>(returnStructure);
|
||||
|
||||
if (this->licenceInfo.licences.count(1))
|
||||
case ELCType::ELC1:
|
||||
{ // old eoseov
|
||||
if (!this->licIdentification.licCompatibility) // defaultní kompatibilita
|
||||
{
|
||||
resultPtr->isValid = true;
|
||||
LicenceELC1Info *resultPtr = static_cast<LicenceELC1Info *>(returnStructure);
|
||||
|
||||
if (this->licenceInfo.licences.count(1)) // starý EOS má natvrdo "id" 1
|
||||
{
|
||||
resultPtr->isValid = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
resultPtr->isValid = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
resultPtr->isValid = false;
|
||||
switch (this->licIdentification.licCompatibility)
|
||||
{
|
||||
case 1:
|
||||
// kod pro kompatibilitu 1
|
||||
break;
|
||||
default:
|
||||
LicenceException((int)GeneralError::CompatibilityTypeNotImplemented, "Kompatibilita není implementována.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
case 21:
|
||||
case ELCType::ELC2:
|
||||
{
|
||||
|
||||
Reader::Licence2 licenceELC2 = Reader::Licence2(this->licIdentification);
|
||||
licenceELC2.readLicence(&this->licenceInfo);
|
||||
return licenceELC2.getLicenceInfo(returnStructure);
|
||||
|
||||
// catch (const LicenceException &ex)
|
||||
// {
|
||||
// error.code = ex.getErrorCode();
|
||||
// error.message = ex.getErrorMessage();
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// LicenceELC21 licence = LicenceELC21(this->licIdentification);
|
||||
// try
|
||||
// {
|
||||
// licence.readLicence(&this->licenceInfo);
|
||||
// return licence.getLicenceInfo(returnStructure);
|
||||
// }
|
||||
// catch (const LicenceException &ex)
|
||||
// {
|
||||
// error.code = ex.getErrorCode();
|
||||
// error.message = ex.getErrorMessage();
|
||||
// return false;
|
||||
// }
|
||||
if (!this->licIdentification.licCompatibility) // defaultní kompatibilita
|
||||
{
|
||||
Reader::Licence2 licenceELC2 = Reader::Licence2(this->licIdentification);
|
||||
licenceELC2.readLicence(&this->licenceInfo);
|
||||
licenceELC2.getLicenceInfo(returnStructure);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (this->licIdentification.licCompatibility)
|
||||
{
|
||||
case 1:
|
||||
// kod pro kompatibilitu 1
|
||||
break;
|
||||
default:
|
||||
LicenceException((int)GeneralError::CompatibilityTypeNotImplemented, "Kompatibilita není implementována.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 31:
|
||||
case ELCType::ELC3:
|
||||
{
|
||||
// LicenceELC31 licence = LicenceELC31(this->licIdentification);
|
||||
// try
|
||||
// {
|
||||
// licence.readLicence();
|
||||
// return licence.getLicenceInfo(returnStructure);
|
||||
// }
|
||||
// catch (const LicenceException &ex)
|
||||
// {
|
||||
// error.code = ex.getErrorCode();
|
||||
// error.message = ex.getErrorMessage();
|
||||
// return false;
|
||||
// }
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -281,6 +257,7 @@ bool LicenceReader::getLicenceInfo(void *returnStructure)
|
||||
error.message = ex.getErrorMessage();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
LicenceReader::~LicenceReader()
|
||||
|
||||
Reference in New Issue
Block a user