mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-18 05:00:33 +01:00
element data : add terminal type enum and terminal function enum
This commit is contained in:
@@ -102,6 +102,22 @@ QDomElement ElementData::kindInfoToXml(QDomDocument &document)
|
|||||||
|
|
||||||
returned_elmt.appendChild(xml_count);
|
returned_elmt.appendChild(xml_count);
|
||||||
}
|
}
|
||||||
|
else if (m_type == ElementData::Terminale)
|
||||||
|
{
|
||||||
|
//type
|
||||||
|
auto xml_type = document.createElement("kindInformation");
|
||||||
|
xml_type.setAttribute("name", "type");
|
||||||
|
auto type_txt = document.createTextNode(terminalTypeToString(m_terminal_type));
|
||||||
|
xml_type.appendChild(type_txt);
|
||||||
|
returned_elmt.appendChild(xml_type);
|
||||||
|
|
||||||
|
//function
|
||||||
|
auto xml_func = document.createElement("kindInformation");
|
||||||
|
xml_func.setAttribute("name", "function");
|
||||||
|
auto func_txt = document.createTextNode(terminalFunctionToString(m_terminal_function));
|
||||||
|
xml_type.appendChild(xml_func);
|
||||||
|
returned_elmt.appendChild(xml_func);
|
||||||
|
}
|
||||||
|
|
||||||
return returned_elmt;
|
return returned_elmt;
|
||||||
}
|
}
|
||||||
@@ -118,12 +134,18 @@ bool ElementData::operator==(const ElementData &data) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (data.m_type == ElementData::Slave) {
|
else if (data.m_type == ElementData::Slave) {
|
||||||
if (data.m_slave_state != m_slave_state ||
|
if (data.m_slave_state != m_slave_state ||
|
||||||
data.m_slave_type != m_slave_type ||
|
data.m_slave_type != m_slave_type ||
|
||||||
data.m_contact_count != m_contact_count) {
|
data.m_contact_count != m_contact_count) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (data.m_type == ElementData::Terminale) {
|
||||||
|
if (data.m_terminal_type != m_terminal_type ||
|
||||||
|
data.m_terminal_function != m_terminal_function) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(data.m_informations != m_informations) {
|
if(data.m_informations != m_informations) {
|
||||||
return false;
|
return false;
|
||||||
@@ -281,10 +303,75 @@ ElementData::SlaveState ElementData::slaveStateFromString(const QString &string)
|
|||||||
return ElementData::NO;
|
return ElementData::NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString ElementData::terminalTypeToString(ElementData::TerminalType type)
|
||||||
|
{
|
||||||
|
switch (type) {
|
||||||
|
case ElementData::TTGeneric :
|
||||||
|
return QString("generic");
|
||||||
|
case ElementData::Fuse :
|
||||||
|
return QString("fuse");
|
||||||
|
case ElementData::Sectional:
|
||||||
|
return QString("sectional");
|
||||||
|
case ElementData::Diode:
|
||||||
|
return QString("didoe");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ElementData::TerminalType ElementData::terminalTypeFromString(const QString &string)
|
||||||
|
{
|
||||||
|
if (string == "generic") {
|
||||||
|
return ElementData::TTGeneric;
|
||||||
|
} else if (string == "fuse") {
|
||||||
|
return ElementData::Fuse;
|
||||||
|
} else if (string == "sectional") {
|
||||||
|
return ElementData::Sectional;
|
||||||
|
} else if (string == "diode") {
|
||||||
|
return ElementData::Diode;
|
||||||
|
}
|
||||||
|
|
||||||
|
qDebug() << "ElementData::terminalTypeFromString : string : "
|
||||||
|
<< string
|
||||||
|
<< " don't exist, return failsafe value 'generic'";
|
||||||
|
return ElementData::TTGeneric;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString ElementData::terminalFunctionToString(ElementData::TerminalFunction function)
|
||||||
|
{
|
||||||
|
switch (function) {
|
||||||
|
case ElementData::TFGeneric:
|
||||||
|
return QString("generic");
|
||||||
|
case ElementData::Phase:
|
||||||
|
return QString ("phase");
|
||||||
|
case ElementData::Neutral:
|
||||||
|
return QString("neutral");
|
||||||
|
case ElementData::PE:
|
||||||
|
return QString("pe");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ElementData::TerminalFunction ElementData::terminalFunctionFromString(const QString &string)
|
||||||
|
{
|
||||||
|
if (string == "generic") {
|
||||||
|
return ElementData::TFGeneric;
|
||||||
|
} else if (string == "phase") {
|
||||||
|
return ElementData::Phase;
|
||||||
|
} else if (string == "neutral") {
|
||||||
|
return ElementData::Neutral;
|
||||||
|
} else if (string == "pe") {
|
||||||
|
return ElementData::PE;
|
||||||
|
}
|
||||||
|
|
||||||
|
qDebug() << "ElementData::terminalFunctionFromString : string : "
|
||||||
|
<< string
|
||||||
|
<< " don't exist, return failsafe value 'generic'";
|
||||||
|
return ElementData::TFGeneric;
|
||||||
|
}
|
||||||
|
|
||||||
void ElementData::kindInfoFromXml(const QDomElement &xml_element)
|
void ElementData::kindInfoFromXml(const QDomElement &xml_element)
|
||||||
{
|
{
|
||||||
if (m_type == ElementData::Master ||
|
if (m_type == ElementData::Master ||
|
||||||
m_type == ElementData::Slave)
|
m_type == ElementData::Slave ||
|
||||||
|
m_type == ElementData::Terminale)
|
||||||
{
|
{
|
||||||
auto xml_kind = xml_element.firstChildElement("kindInformations");
|
auto xml_kind = xml_element.firstChildElement("kindInformations");
|
||||||
for (const auto &dom_elmt : QETXML::findInDomElement(xml_kind, "kindInformation"))
|
for (const auto &dom_elmt : QETXML::findInDomElement(xml_kind, "kindInformation"))
|
||||||
@@ -307,6 +394,13 @@ void ElementData::kindInfoFromXml(const QDomElement &xml_element)
|
|||||||
m_contact_count = dom_elmt.text().toInt();
|
m_contact_count = dom_elmt.text().toInt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (m_type == ElementData::Terminale) {
|
||||||
|
if (name == "type") {
|
||||||
|
m_terminal_type = terminalTypeFromString(dom_elmt.text());
|
||||||
|
} else if (name == "function") {
|
||||||
|
m_terminal_function = terminalFunctionFromString(dom_elmt.text());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2021 The QElectroTech Team
|
Copyright 2006-2021 The QElectroTech Team
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
@@ -66,6 +66,22 @@ class ElementData : public PropertiesInterface
|
|||||||
};
|
};
|
||||||
Q_ENUM(SlaveState)
|
Q_ENUM(SlaveState)
|
||||||
|
|
||||||
|
enum TerminalType {
|
||||||
|
TTGeneric,
|
||||||
|
Fuse,
|
||||||
|
Sectional,
|
||||||
|
Diode
|
||||||
|
};
|
||||||
|
Q_ENUM(TerminalType)
|
||||||
|
|
||||||
|
enum TerminalFunction {
|
||||||
|
TFGeneric,
|
||||||
|
Phase,
|
||||||
|
Neutral,
|
||||||
|
PE
|
||||||
|
};
|
||||||
|
Q_ENUM(TerminalFunction)
|
||||||
|
|
||||||
ElementData() {}
|
ElementData() {}
|
||||||
~ElementData() override {}
|
~ElementData() override {}
|
||||||
|
|
||||||
@@ -90,12 +106,24 @@ class ElementData : public PropertiesInterface
|
|||||||
static QString slaveStateToString(ElementData::SlaveState type);
|
static QString slaveStateToString(ElementData::SlaveState type);
|
||||||
static ElementData::SlaveState slaveStateFromString(const QString &string);
|
static ElementData::SlaveState slaveStateFromString(const QString &string);
|
||||||
|
|
||||||
|
static QString terminalTypeToString(ElementData::TerminalType type);
|
||||||
|
static ElementData::TerminalType terminalTypeFromString(const QString &string);
|
||||||
|
|
||||||
|
static QString terminalFunctionToString(ElementData::TerminalFunction function);
|
||||||
|
static ElementData::TerminalFunction terminalFunctionFromString(const QString &string);
|
||||||
|
|
||||||
// must be public, because this class is a private member
|
// must be public, because this class is a private member
|
||||||
// of Element/ element editor and they must access this data
|
// of Element/ element editor and they must access this data
|
||||||
ElementData::Type m_type = ElementData::Simple;
|
ElementData::Type m_type = ElementData::Simple;
|
||||||
|
|
||||||
ElementData::MasterType m_master_type = ElementData::Coil;
|
ElementData::MasterType m_master_type = ElementData::Coil;
|
||||||
|
|
||||||
ElementData::SlaveType m_slave_type = ElementData::SSimple;
|
ElementData::SlaveType m_slave_type = ElementData::SSimple;
|
||||||
ElementData::SlaveState m_slave_state = ElementData::NO;
|
ElementData::SlaveState m_slave_state = ElementData::NO;
|
||||||
|
|
||||||
|
ElementData::TerminalType m_terminal_type = ElementData::TTGeneric;
|
||||||
|
ElementData::TerminalFunction m_terminal_function = ElementData::TFGeneric;
|
||||||
|
|
||||||
int m_contact_count = 1;
|
int m_contact_count = 1;
|
||||||
DiagramContext m_informations;
|
DiagramContext m_informations;
|
||||||
NamesList m_names_list;
|
NamesList m_names_list;
|
||||||
|
|||||||
Reference in New Issue
Block a user