oddělení generatoru od readeru
This commit is contained in:
207
include/common/licenceCommon.h
Normal file
207
include/common/licenceCommon.h
Normal file
@@ -0,0 +1,207 @@
|
||||
#ifndef LICENCE_COMMON_H_
|
||||
#define LICENCE_COMMON_H_
|
||||
|
||||
//---------------- společná hlavička pro všechny licence ----------------
|
||||
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <stdint.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
#define XML_VERSION 1
|
||||
#define SOFTWARE_VERSION 1
|
||||
#define SUCCES 0;
|
||||
|
||||
const int cidSize = 32;
|
||||
const int csdSize = 32;
|
||||
const int generatorVersion = 1;
|
||||
|
||||
typedef uint8_t BYTE;
|
||||
typedef uint16_t WORD;
|
||||
typedef uint32_t DWORD;
|
||||
typedef uint32_t DATE;
|
||||
|
||||
enum class GeneralError
|
||||
{
|
||||
GeneralError = 1,
|
||||
FileOpenError = 2,
|
||||
FileReadError = 3,
|
||||
FileWriteError = 4,
|
||||
ELCNotImplemented = 5,
|
||||
LicenceTypeNotImplemented = 6,
|
||||
CompatibilityTypeNotImplemented = 7,
|
||||
ELCMismatch = 8,
|
||||
CRCMismatch = 9,
|
||||
EncryptError = 10,
|
||||
DecryptError = 11,
|
||||
ParamMissing = 12,
|
||||
IvanlidParam = 13
|
||||
};
|
||||
|
||||
enum class ELCType
|
||||
{
|
||||
ELC1 = 1,
|
||||
ELC2 = 2,
|
||||
ELC3 = 3
|
||||
};
|
||||
enum class ELCSubType
|
||||
{
|
||||
DEFAULT = 1
|
||||
}; // subtype = dataVersion
|
||||
enum class LicenceType
|
||||
{
|
||||
EOS_EOV,
|
||||
DDTS,
|
||||
DRT
|
||||
}; //
|
||||
enum class HeaderType
|
||||
{
|
||||
DEFAULT = 0
|
||||
}; ////subtype = version
|
||||
|
||||
enum class EncryptionType
|
||||
{
|
||||
CID_AES256 = 10,
|
||||
FIX_AES256 = 20
|
||||
};
|
||||
enum class BinaryType
|
||||
{
|
||||
FILE = 1,
|
||||
BASE64 = 2
|
||||
};
|
||||
enum class PlcType
|
||||
{
|
||||
WAGO = 1,
|
||||
TECO = 2
|
||||
};
|
||||
enum class FileNameGenerationType
|
||||
{
|
||||
DEFAULT = 1
|
||||
};
|
||||
|
||||
struct Mapping
|
||||
{
|
||||
std::map<string, LicenceType> licMapTypes = {{"EOV_OSV", LicenceType::EOS_EOV}, {"DDTS", LicenceType::DDTS}, {"DRT", LicenceType::DRT}};
|
||||
std::map<string, EncryptionType> licMapEncryption = {{"CID_AES256", EncryptionType::CID_AES256}, {"FIX_AES256", EncryptionType::FIX_AES256}};
|
||||
std::map<string, PlcType> licMapPlcType = {{"WAGO", PlcType::WAGO}, {"TECO", PlcType::TECO}};
|
||||
};
|
||||
|
||||
struct ErrorMessage
|
||||
{
|
||||
int code = 0;
|
||||
string message = "";
|
||||
};
|
||||
|
||||
struct LicenceIdentification
|
||||
{
|
||||
ELCType licElcType = ELCType::ELC2;
|
||||
LicenceType licLicenceType;
|
||||
string licTypeName = "";
|
||||
PlcType licPlcType;
|
||||
|
||||
uint8_t licenceVersion = 1; // verze licence, určuje kodování, pojmenování souborů
|
||||
uint8_t licenceIndex = 0;
|
||||
uint8_t revision;
|
||||
uint8_t licCompatibility = 1; // identikator hlavního ELC
|
||||
|
||||
uint16_t licItemsCount = 0;
|
||||
|
||||
string cid_cds_path = "";
|
||||
string licenceFilePath = "";
|
||||
};
|
||||
|
||||
// struct LicData
|
||||
// {
|
||||
// string station = "";
|
||||
// string distributor = "";
|
||||
// string licenceName = "";
|
||||
// string projectDescription = "";
|
||||
// string cid = ""; // CID z SD karty
|
||||
// string csd = ""; // CSD z SD karty
|
||||
// string uid = ""; // jedinečný identifikátor z jiného systému
|
||||
// pugi::xml_document *doc;
|
||||
// };
|
||||
|
||||
struct LicenceItem
|
||||
{
|
||||
int protocolId = -1;
|
||||
int dataPointsCount = 0;
|
||||
};
|
||||
|
||||
struct LicenceItem11
|
||||
{
|
||||
int protocolId = -1;
|
||||
int dataPointsCount = 0;
|
||||
};
|
||||
|
||||
struct LicenceItem21
|
||||
{
|
||||
int protocolId = -1;
|
||||
int dataPointsCount = 0;
|
||||
};
|
||||
|
||||
struct LicenceItem31
|
||||
{
|
||||
int protocolId = -1;
|
||||
int dataPointsCount = 0;
|
||||
};
|
||||
|
||||
struct LicenceInfo
|
||||
{
|
||||
int reqDataPointsCount = 0;
|
||||
map<int, int> licences = {};
|
||||
};
|
||||
|
||||
struct LicenceInfo11
|
||||
{
|
||||
int reqDataPointsCount = 0;
|
||||
map<int, int> licences = {};
|
||||
};
|
||||
|
||||
struct LicenceInfo21
|
||||
{
|
||||
int reqDataPointsCount = 0;
|
||||
map<int, int> licences = {};
|
||||
};
|
||||
|
||||
struct LicenceInfo31
|
||||
{
|
||||
int reqDataPointsCount = 0;
|
||||
map<int, int> licences = {};
|
||||
};
|
||||
|
||||
struct LicenceInfoGeneral
|
||||
{
|
||||
int reqDataPointsCount = 0;
|
||||
map<int, int> licences = {};
|
||||
};
|
||||
|
||||
class LicenceException : public std::exception
|
||||
{
|
||||
public:
|
||||
LicenceException(int errorCode, const std::string &errorMessage)
|
||||
: errorCode_(errorCode), errorMessage_(errorMessage) {}
|
||||
|
||||
const char *what() const noexcept override
|
||||
{
|
||||
return errorMessage_.c_str();
|
||||
}
|
||||
|
||||
int getErrorCode() const
|
||||
{
|
||||
return errorCode_;
|
||||
}
|
||||
|
||||
const std::string &getErrorMessage() const
|
||||
{
|
||||
return errorMessage_;
|
||||
}
|
||||
|
||||
private:
|
||||
int errorCode_;
|
||||
std::string errorMessage_;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user