feat: Migrating features from newer implementation

This commit is contained in:
2025-03-29 10:50:16 +01:00
parent 171a48eb71
commit 810264aa71
15 changed files with 982 additions and 538 deletions
+153 -46
View File
@@ -84,8 +84,11 @@
}
bool SPITObject::removeSPITObject(SPITObject* p_ptrSPITObject) {
if (p_ptrSPITObject == NULL) return false;
return removeSPITObject(p_ptrSPITObject->getID());
}
bool SPITObject::removeSPITObject(string p_SPITObjectID) {
{
auto i = s_SPITObjects.find(p_ptrSPITObject->getID());
auto i = s_SPITObjects.find(p_SPITObjectID);
if (i == s_SPITObjects.end()) {
return false;
}
@@ -95,8 +98,11 @@
}
bool SPITObject::removeSPITObjectRemote(SPITObject* p_ptrSPITObject) {
if (p_ptrSPITObject == NULL) return false;
return removeSPITObjectRemote(p_ptrSPITObject->getID());
}
bool SPITObject::removeSPITObjectRemote(string p_ptrSPITObject) {
{
auto i = s_SPITObjectsRemote.find(p_ptrSPITObject->getID());
auto i = s_SPITObjectsRemote.find(p_ptrSPITObject);
if (i == s_SPITObjectsRemote.end()) {
return false;
}
@@ -203,8 +209,44 @@
}
}
/**
* clears all unconfirmed SPITObjects not created by this SPIT_Client.
*/
void SPITObject::clearUnconfirmedSPITObjects() {
for (auto i = s_SPITObjects.begin(); i != s_SPITObjects.end(); i++) {
SPITObject* ptrSPITObject = i->second;
if (ptrSPITObject->getCreatedByClient() == false && ptrSPITObject->getConfirmed() == false) {
i = s_SPITObjects.erase(i);
delete ptrSPITObject;
}
if (i == s_SPITObjects.end()) {
break;
}
}
}
void SPITObject::eventProjectClosed() {
for (auto i = s_SPITObjects.begin(); i != s_SPITObjects.end(); i++) {
SPITObject* ptrSPITObject = i->second;
if (ptrSPITObject->getCreatedByClient() == true) {
continue;
}
i = s_SPITObjects.erase(i);
delete ptrSPITObject;
if (i == s_SPITObjects.end()) {
break;
}
}
//Remote
for (auto i = s_SPITObjectsRemote.begin(); i != s_SPITObjectsRemote.end(); i++) {
SPITObject* ptrSPITObject = i->second;
i = s_SPITObjectsRemote.erase(i);
delete ptrSPITObject;
if (i == s_SPITObjectsRemote.end()) {
break;
}
}
}
/**
* sets confirmed = false for all SPITObjects.<br>
* This should be called when the client has loaded a project.<br>
@@ -231,6 +273,7 @@ void SPITObject::initMembers() {
m_Delay = 0;
m_Duration = 0;
m_Fixed = false;
m_CreatedByClient = false;
m_FrameFadeInLength = 0;
m_FrameFadeOutLength = 0;
m_FrameLength = 0;
@@ -245,51 +288,112 @@ void SPITObject::initMembers() {
m_ValueFactor = 1000000; //Values are given in ppm -> 1000000 = 1/1;
m_ValueUse = 0x01;
}
/*
SPITObject::SPITObject(const SPITObject& orig) {
m_ActionAssigned = orig.getActionAssigned();
m_Confirmed = orig.getConfirmed();
m_Delay = orig.getDelay();
m_Duration = orig.getDuration();
m_Fixed = orig.getFixed();
m_FrameFadeInLength = orig.getFrameFadeInLength();
m_FrameFadeOutLength = orig.getFrameFadeOutLength();
m_FrameLength = orig.getFrameLength();
m_FrameStart = orig.getFrameStart();
m_Remark = orig.getRemark();
m_ID = orig.getID();
m_Name = orig.getName();
m_SPITTypeID = orig.getSPITTypeID();
m_ServerParams = orig.getServerParams();
m_ServerRemote = orig.getServerRemote();
m_Track = orig.getTrack();
m_ValueFactor = orig.getValueFactor();
m_ValueUse = orig.getValueUse();
}
*/
SPITObject::~SPITObject() {
}
SPITObject::~SPITObject() { }
void SPITObject::setMessageOP(SPIT_Message::ReportSPITObject* p_ReportSPITObject) {
//m_ActionAssigned = p_ReportSPITObject->getActionAssigned(); //Should only be set by the client
m_Confirmed = p_ReportSPITObject->getConfirmed();
m_Delay = p_ReportSPITObject->getDelay();
m_Duration = p_ReportSPITObject->getDuration();
m_Fixed = p_ReportSPITObject->getFixed();
m_FrameFadeInLength = p_ReportSPITObject->getFrameFadeInLength();
m_FrameFadeOutLength = p_ReportSPITObject->getFrameFadeOutLength();
m_FrameLength = p_ReportSPITObject->getFrameLength();
m_FrameStart = p_ReportSPITObject->getFrameStart();
m_Remark = p_ReportSPITObject->getRemark();
m_ID = p_ReportSPITObject->getID();
m_Name = p_ReportSPITObject->getName();
m_SPITTypeID = p_ReportSPITObject->getSPITTypeID();
m_ServerParams = p_ReportSPITObject->getServerParams();
m_ServerRemote = p_ReportSPITObject->getServerRemote();
m_Track = p_ReportSPITObject->getTrack();
m_ValueFactor = p_ReportSPITObject->getValueFactor();
m_ValueUse = p_ReportSPITObject->getValueUse();
bool SPITObject::setMessageOP(SPIT_Message::ReportSPITObject* p_ReportSPITObject) {
bool boolChangeAllowed;
bool boolChanged = false;
if (m_CreatedByClient == true && m_Fixed == true) {
boolChangeAllowed = false;
}
else {
boolChangeAllowed = true;
}
//Confirmation should be changable
if (m_CreatedByClient) {
//Server reports a client created SPITType -> the type is confirmed
m_Confirmed = true;
}
else {
//type is NOT client created -> the client has to confirm the SPITtype
m_Confirmed = p_ReportSPITObject->getConfirmed();
}
if (m_Delay != p_ReportSPITObject->getDelay()) {
if (boolChangeAllowed == false) throw new exception();
m_Delay = p_ReportSPITObject->getDelay();
boolChanged = true;
}
if (m_Duration != p_ReportSPITObject->getDuration()) {
if (boolChangeAllowed == false) throw new exception();
m_Duration = p_ReportSPITObject->getDuration();
boolChanged = true;
}
if (m_Fixed != p_ReportSPITObject->getFixed()) {
if (boolChangeAllowed == false) throw new exception();
m_Fixed = p_ReportSPITObject->getFixed();
boolChanged = true;
}
if (m_FrameFadeInLength != p_ReportSPITObject->getFrameFadeInLength()) {
if (boolChangeAllowed == false) throw new exception();
m_FrameFadeInLength = p_ReportSPITObject->getFrameFadeInLength();
boolChanged= true;
}
if (m_FrameFadeOutLength != p_ReportSPITObject->getFrameFadeOutLength()) {
if (boolChangeAllowed == false) throw new exception();
m_FrameFadeOutLength = p_ReportSPITObject->getFrameFadeOutLength();
boolChanged = true;
}
if (m_FrameLength != p_ReportSPITObject->getFrameLength()) {
if (boolChangeAllowed == false) throw new exception();
m_FrameLength = p_ReportSPITObject->getFrameLength();
boolChanged = true;
}
if (m_FrameStart != p_ReportSPITObject->getFrameStart()) {
if (boolChangeAllowed == false) throw new exception();
m_FrameStart = p_ReportSPITObject->getFrameStart();
boolChanged = true;
}
if (m_Remark != p_ReportSPITObject->getRemark()) {
if (boolChangeAllowed == false) throw new exception();
m_Remark = p_ReportSPITObject->getRemark();
boolChanged = true;
}
if (m_ID != p_ReportSPITObject->getID()) {
if (boolChangeAllowed == false) throw new exception();
m_ID = p_ReportSPITObject->getID();
boolChanged = true;
}
if (m_Name != p_ReportSPITObject->getName()) {
if (boolChangeAllowed == false) throw new exception();
m_Name = p_ReportSPITObject->getName();
boolChanged = true;
}
if (m_SPITTypeID != p_ReportSPITObject->getSPITTypeID()) {
if (boolChangeAllowed == false) throw new exception();
m_SPITTypeID = p_ReportSPITObject->getSPITTypeID();
boolChanged = true;
}
if (m_ServerParams != p_ReportSPITObject->getServerParams()) {
if (boolChangeAllowed == false) throw new exception();
m_ServerParams = p_ReportSPITObject->getServerParams();
boolChanged = true;
}
if (m_ServerRemote != p_ReportSPITObject->getServerRemote()) {
if (boolChangeAllowed == false) throw new exception();
m_ServerRemote = p_ReportSPITObject->getServerRemote();
boolChanged = true;
}
if (m_Track != p_ReportSPITObject->getTrack()) {
if (boolChangeAllowed == false) throw new exception();
m_Track = p_ReportSPITObject->getTrack();
boolChanged = true;
}
if (m_ValueFactor != p_ReportSPITObject->getValueFactor()) {
if (boolChangeAllowed == false) throw new exception();
m_ValueFactor = p_ReportSPITObject->getValueFactor();
boolChanged = true;
}
if (m_ValueUse != p_ReportSPITObject->getValueUse()) {
if (boolChangeAllowed == false) throw new exception();
m_ValueUse = p_ReportSPITObject->getValueUse();
boolChanged = true;
}
return boolChanged;
}
void SPITObject::fillMessageOP(SPIT_Message::ReportSPITObject* p_ReportSPITObject) {
@@ -319,6 +423,9 @@ void SPITObject::fillMessageOP(SPIT_Message::RemoveSPITObject* p_RemoveSPITObjec
void SPITObject::setID(string p_ID) {
m_ID = p_ID;
}
void SPITObject::setCreatedByClient(bool p_CreatedByClient) {
m_CreatedByClient = p_CreatedByClient;
}
/**
* This is used by the server and client to tell if the other side has registered the changes.