refactor/bringup: Bringup full project
moving SPIT-App parts to main app LiveShowDemoProject added Debugging motor movements
This commit is contained in:
@@ -1,452 +0,0 @@
|
||||
|
||||
#include "MyApp.h"
|
||||
#include "Task.hpp"
|
||||
#include "esp_log.h"
|
||||
#include "Semaphore.hpp"
|
||||
#include "Queue.hpp"
|
||||
#include <list>
|
||||
|
||||
const char *TAG = "SPIT";
|
||||
|
||||
MyApp::MyApp() :
|
||||
_SpitClient (
|
||||
s_ClientName, s_ProjectName,
|
||||
{
|
||||
.onServerEvent = onServerEvent,
|
||||
.onConnectionStatus = onConnectionStatus,
|
||||
.onStartProjectTransfer = onStartProjectTransfer,
|
||||
.onEndProjectTransfer = onEndProjectTransfer,
|
||||
.onProjectClosed = onProjectClosed,
|
||||
.onProjectReport = onProjectReport,
|
||||
.onSpitType = onSpitType,
|
||||
.onSpitTypeRemote = onSpitTypeRemote,
|
||||
.onSpitObject = onSpitObject,
|
||||
.onSpitObjectRemote = onSpitObjectRemote,
|
||||
.onSpitTypeRemoved = onSpitTypeRemoved,
|
||||
.onSpitTypeRemoteRemoved = onSpitTypeRemoteRemoved,
|
||||
.onSpitObjectRemoved = onSpitObjectRemoved,
|
||||
.onSpitObjectRemoteRemoved = onSpitObjectRemoteRemoved,
|
||||
.onPlay = onPlay,
|
||||
.onPlaySpitType = onPlaySpitType,
|
||||
.onPlayRemoteObjectStatus = onPlayRemoteObjectStatus,
|
||||
.onCheckSpitTypeVeto = onCheckSpitTypeVeto,
|
||||
.onCheckSpitObjectVeto = onCheckSpitObjectVeto,
|
||||
}) {
|
||||
}
|
||||
|
||||
string MyApp::m_ServerProjectID{};
|
||||
string MyApp::m_ServerProjectName{};
|
||||
int MyApp::m_ServerFramesPerSecond{44100}; // set when the server reports his project, see eventProjectReport
|
||||
|
||||
void MyApp::init() {
|
||||
SPITType *ptrSPITType1Fix = _SpitClient.createSPITTypeFixed("MySPITAPP_Action1ID", "ActionGroupName", "Action1Name", 0, 0);
|
||||
SPITType *ptrSPITType2Fix = _SpitClient.createSPITTypeFixed("MySPITAPP_Action2ID", "ActionGroupName", "Action2Name", 0, 0);
|
||||
|
||||
// When an action exist which should be done whenever a SPITObject with this SPITType is played,
|
||||
// then you should 'setAssignedActionType' to true
|
||||
_SpitClient.setActionSPITType(ptrSPITType1Fix->getID(), true);
|
||||
_SpitClient.setActionSPITType(ptrSPITType2Fix->getID(), true);
|
||||
_SpitClient.clientProjectLoaded();
|
||||
_SpitClient.startServerAutoDetect();
|
||||
}
|
||||
|
||||
void MyApp::onServerEvent(SPIT_Client::ServerEvent event, const SAD_DetectedServer &p_DetectedServer) {
|
||||
switch (event)
|
||||
{
|
||||
case SPIT_Client::ServerEvent::Detect:
|
||||
ESP_LOGI(TAG, "SERVER DETECTED");
|
||||
ESP_LOGI(TAG, " Name: %s", p_DetectedServer.getName().data());
|
||||
ESP_LOGI(TAG, " ID: %s", p_DetectedServer.getID().data());
|
||||
ESP_LOGI(TAG, " Computer: %s", p_DetectedServer.getComputerName().data());
|
||||
ESP_LOGI(TAG, " IP: %s", p_DetectedServer.getIP().data());
|
||||
ESP_LOGI(TAG, " Port: %s", p_DetectedServer.getPort().data());
|
||||
ESP_LOGI(TAG, " Addition: %s", p_DetectedServer.getAdditions().data());
|
||||
ESP_LOGI(TAG, " ClientIP: %s", p_DetectedServer.getClientIP().data());
|
||||
break;
|
||||
case SPIT_Client::ServerEvent::Lost:
|
||||
ESP_LOGW(TAG, "Server lost Name: %s IP: %s", p_DetectedServer.getName().data(), p_DetectedServer.getIP().data());
|
||||
|
||||
break;
|
||||
case SPIT_Client::ServerEvent::Changed:
|
||||
ESP_LOGW(TAG, "Server lost Name: %s IP: %s", p_DetectedServer.getName().data(), p_DetectedServer.getIP().data());
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------
|
||||
//---------- Connecting event ----------
|
||||
|
||||
void MyApp::onConnectionStatus(string p_ServerID, string p_ServerComputerName, string p_ServerName, int p_ServerStepTime, int p_ConnectionStatus, int p_OldConnectionStatus) {
|
||||
ESP_LOGI(TAG, "MySPITApp: eventConnectionStatus %d ", p_ConnectionStatus);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------
|
||||
//---------- Server's Project events ------------------------
|
||||
/**
|
||||
* The Server reports his loaded project
|
||||
* Called when
|
||||
* a) the connection to the server is established.
|
||||
* b) server load a new project
|
||||
* c) server saves the project under a new name
|
||||
* @param p_ProjectID the server project's id (maybe the filename of the project or a part o it or the same as p_ProjectName)
|
||||
* @param p_ProjectName the server project's name
|
||||
* @param p_FramesPerSeoond All times in SPIT are given in frames. FramesPerSecond can be used to convert frames to seconds....
|
||||
*/
|
||||
void MyApp::onProjectReport(string p_ProjectID, string p_ProjectName, int p_FramesPerSeoond) {
|
||||
ESP_LOGI(TAG, "eventProjectReport ID: %s Name: %s FramesPerSecond: %d", p_ProjectID.data(), p_ProjectName.data(), p_FramesPerSeoond);
|
||||
m_ServerProjectID = p_ProjectID;
|
||||
m_ServerProjectName = p_ProjectName;
|
||||
m_ServerFramesPerSecond = p_FramesPerSeoond;
|
||||
// set the frames per second as the server - perhaps the client's time values have to be recalculated.
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the server closes his project.
|
||||
* @param p_ProjectID the id of the project
|
||||
* The server loads only one project at time-> the ID is not actually necessary
|
||||
*/
|
||||
void MyApp::onProjectClosed(string p_ProjectID) {
|
||||
ESP_LOGI(TAG, "eventProjectClosed ID: %s", p_ProjectID.data());
|
||||
// If we don't save SPITServer's project specific information
|
||||
// perhaps close all SPITObjects and RemoteSPITObjects to avoid conflicts, when the SPITServer loads a new project
|
||||
// SPITObject::clearSPITObjects();
|
||||
// SPITObject::clearSPITObjectsRemote();
|
||||
}
|
||||
|
||||
// The server starts the transfer of its project, that means
|
||||
// All SPITTypes and SPITObjects available on the server are transferred in the following.
|
||||
void MyApp::onStartProjectTransfer() {
|
||||
ESP_LOGI(TAG, "eventStartProjectTransfer");
|
||||
}
|
||||
// The transfer of the server's SPITTypes and SPITObjects is finished.
|
||||
void MyApp::onEndProjectTransfer() {
|
||||
ESP_LOGI(TAG, "eventEndProjectTransfer");
|
||||
}
|
||||
|
||||
//----------------------------------------------------
|
||||
//--------- SPITType events ----------
|
||||
|
||||
|
||||
/**
|
||||
* The SPITCLientInterface (implemented by this) will be asked to veto the SPITType while SPIT_Client.parseReportSPITType.<br>
|
||||
* @param p_ReportSPITType
|
||||
* @return false = the SPITType is denied, true = the SPITType is accepted
|
||||
*/
|
||||
bool MyApp::onCheckSpitTypeVeto(SPIT_Message::ReportSPITType* p_ReportSPITType) {
|
||||
if (p_ReportSPITType == NULL) return true;
|
||||
SPITType* ptrSPITType;
|
||||
ptrSPITType = SPITType::getSPITType(p_ReportSPITType->getID());
|
||||
|
||||
//Don't allow foreign SPITTypes
|
||||
if (ptrSPITType == NULL) return false;
|
||||
if (ptrSPITType->getCreatedByClient() == false) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MyApp::onCheckSpitObjectVeto(SPIT_Message::ReportSPITObject* p_ReportSPITObject) {
|
||||
if (p_ReportSPITObject == NULL) return true;
|
||||
SPITType* ptrSPITType;
|
||||
ptrSPITType = SPITType::getSPITType(p_ReportSPITObject->getSPITTypeID());
|
||||
if (ptrSPITType == NULL) return false;
|
||||
|
||||
//Don't allow SPITObjects which refers to a SPITType which is not created by this client - other SPITTypes cannot be handled here
|
||||
//if (ptrSPITType->getCreatedByClient() == false) return false;
|
||||
|
||||
// SPITObject* ptrSPITObject;
|
||||
// ptrSPITObject = SPITObject::getSPITObject(p_ReportSPITOnject->getID());
|
||||
//Don't allow foreign SPITTypes
|
||||
// if (ptrSPITObject == NULL) return false;
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the server has created, loaded or changed a SPITType.
|
||||
* May also occur when the server confirms a SPITType created or changed by the client.
|
||||
* @param p_New true = server created a new SPITType
|
||||
* false = server changed a existing SPITType
|
||||
* @param p_SPITType a reference to a copy of the SPITType instance.
|
||||
*/
|
||||
void MyApp::onSpitType(bool p_New, const SPITType &p_SPITType) {
|
||||
// fetch information of the SPITType
|
||||
if (p_New) {
|
||||
ESP_LOGD(TAG, "eventSPITType NEW");
|
||||
} else {
|
||||
ESP_LOGD(TAG, "eventSPITType CHANGED");
|
||||
}
|
||||
ESP_LOGI(TAG, " ID: %s GroupName: %s Name: %s confirmed: %d", p_SPITType.getID().data(), p_SPITType.getGroupName().data(), p_SPITType.getName().data(), p_SPITType.getConfirmed());
|
||||
|
||||
// Check your actions
|
||||
// Whenever you provide an action for this SPITType take this over in your code.
|
||||
// call _SpitClient.setActionSPITType(p_SPITType.getID(), true);
|
||||
|
||||
// for our little excample as described in loadClientProject we do following
|
||||
// This may be redundand, because we defined the SPITTypes as fixed, so the server can't change them
|
||||
// But foe all SPITTypes which are not fixed we need to setActionSPITType
|
||||
|
||||
// if ("MySPITAPP_Action1ID" == p_SPITType.getID()) {
|
||||
// _SpitClient.setActionSPITType(p_SPITType.getID(), true);
|
||||
// }
|
||||
// if ("MySPITAPP_Action2ID" == p_SPITType.getID()) {
|
||||
// _SpitClient.setActionSPITType(p_SPITType.getID(), true);
|
||||
// }
|
||||
}
|
||||
/**
|
||||
* Called when the server has created or changed a Remote SPITType.
|
||||
* Remote SPITType are used in Remote SPITObjects. A Remote SPITObject is used to remote control the SPITServer.
|
||||
* @param p_New true = server created a new SPITType / false = server changed a existing SPITType
|
||||
*/
|
||||
void MyApp::onSpitTypeRemote(bool p_New, const SPITType &p_SPITType) {
|
||||
if (p_New) {
|
||||
ESP_LOGD(TAG, "eventSPITTypeRemote NEW");
|
||||
} else {
|
||||
// we had to inform all Remote SPITObjects using the p_SPITType
|
||||
// perhaps the SPITObject uses information from the SPITType
|
||||
SPITObject *ptrSPITObject;
|
||||
int intSPITObjectCount;
|
||||
intSPITObjectCount = SPITObject::getSPITObjectRemoteCount();
|
||||
for (int intObject = 0; intObject < intSPITObjectCount; intObject++) {
|
||||
ptrSPITObject = SPITObject::getSPITObjectRemote(intObject);
|
||||
if (ptrSPITObject == NULL)
|
||||
continue;
|
||||
if (ptrSPITObject->getSPITTypeID() == p_SPITType.getID()) {
|
||||
// call ecentSPITObjectRemote
|
||||
onSpitObjectRemote(false, p_SPITType, *ptrSPITObject);
|
||||
}
|
||||
}
|
||||
ESP_LOGD(TAG, "eventSPITTypeRemote CHANGED");
|
||||
}
|
||||
ESP_LOGD(TAG, "ID: %s GroupName: %s Name: %s confirmed: %d",
|
||||
p_SPITType.getID().data(), p_SPITType.getGroupName().data(), p_SPITType.getName().data(), p_SPITType.getConfirmed());
|
||||
// this is a remote SPITType, if you want you can list this for later remote use.
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the server has removed a SPITType.
|
||||
* After this function has been exited the SPITType is emeoved from the SPITType-List and the pointer is deleted.
|
||||
* So use the pointer immediately or use the copyconstructor to make a copy for extended use.
|
||||
* You have to release the copy yourself later (delete ptr...)
|
||||
*/
|
||||
void MyApp::onSpitTypeRemoved(const SPITType &p_SPITType) {
|
||||
ESP_LOGD(TAG, "eventSPITType Removed");
|
||||
ESP_LOGD(TAG, " ID: %s GroupName: %s Name: %s\n", p_SPITType.getID().data(), p_SPITType.getGroupName().data(), p_SPITType.getName().data());
|
||||
|
||||
// Check your actions
|
||||
// take the removal of the SPITType over in your code
|
||||
|
||||
// CAUTION: Deleted SPIT types can be added later again (perhaps per UNDO on the SPITServer)
|
||||
//-> don't remove your assigned action immediately - keep it to reassign it later
|
||||
}
|
||||
/**
|
||||
* Called when the server has removed a Remote SPITType.
|
||||
* Remote SPITType are used in Remote SPITObjects. A Remote SPITObject is used to remote control the SPITServer.
|
||||
* After this function has been exited the SPITType is emeoved from the Remote SPITType-List and the pointer is deleted.
|
||||
* So use the pointer immediately or use the copyconstructor to make a copy for extended use.
|
||||
* You have to release the copy yourself later (delete ptr...)
|
||||
* @param p_SPITType a reference to a copy of the SPITType instance.
|
||||
*/
|
||||
void MyApp::onSpitTypeRemoteRemoved(const SPITType &p_SPITType) {
|
||||
ESP_LOGD(TAG, "eventSPITTypeRemote Removed");
|
||||
ESP_LOGD(TAG, " ID: %s GroupName: %s Name: %s\n", p_SPITType.getID().data(), p_SPITType.getGroupName().data(), p_SPITType.getName().data());
|
||||
|
||||
// This is a remote SPITType
|
||||
// If you have listet this prior you should remove it from the list
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the server has created, loaded or changed a SPITObject.
|
||||
* May also occur when the server confirms a SPITObject created by the client, what the client should never do!!.
|
||||
* @param p_New true = server created a new SPITObject
|
||||
* false = server changed a existing SPITObject
|
||||
* @param p_SPITType a reference to a copy of the associated SPITType instance.
|
||||
* @param p_SPITObject a reference to a copy of the SPITObject instance.
|
||||
*/
|
||||
void MyApp::onSpitObject(bool p_New, const SPITType &p_SPITType, const SPITObject &p_SPITObject) {
|
||||
if (p_New) {
|
||||
ESP_LOGI(TAG, "eventSPITObject NEW");
|
||||
} else {
|
||||
ESP_LOGD(TAG, "eventSPITObject CHANGED");
|
||||
}
|
||||
ESP_LOGI(TAG, " ID: %s Name: %s -> SPITType: %s", p_SPITObject.getID().data(), p_SPITObject.getName().data(), p_SPITType.getName().data());
|
||||
|
||||
// check your actions
|
||||
// Whenever you provide an action for this SPITObject take this over in your code.
|
||||
// call _SpitClient.setActionSPITObject(p_SPITObject.getID(), true);
|
||||
|
||||
// for our little excample as described in loadClientProject:
|
||||
// We have only actions for SPITTypes - means every SPITObject with the associated "Actionx"-SPITTypes will trigger the action when it is played
|
||||
//-> no need to do something here, because setActionSPITType has been set prior and the SPITObject will automatically inherits this
|
||||
// SPITObjects with other SPITTypes asscciated will trigger no actions
|
||||
}
|
||||
/**
|
||||
* Called when the server has created or changed a Remote SPITObject.
|
||||
* A Remote SPITObject is used to remote control the SPITServer.
|
||||
* @param p_New true = server created a new remote SPITObject
|
||||
* false = server changed a existing remote SPITObject
|
||||
* @param p_SPITType a reference to a copy of the associated SPITType instance.
|
||||
* @param p_SPITObject a reference to a copy of the SPITObject instance.
|
||||
*/
|
||||
void MyApp::onSpitObjectRemote(bool p_New, const SPITType &p_SPITType, const SPITObject &p_SPITObject) {
|
||||
if (p_New) {
|
||||
ESP_LOGI(TAG, "eventSPITObjectRemote NEW");
|
||||
} else {
|
||||
ESP_LOGD(TAG, "eventSPITObjectRemote CHANGED");
|
||||
}
|
||||
ESP_LOGI(TAG, " ID: %s Name: %s -> SPITType: %s", p_SPITObject.getID().data(), p_SPITObject.getName().data(), p_SPITType.getName().data());
|
||||
|
||||
// This is a remote SPITObject which can be used to remote control the server.
|
||||
// If you want you can list this for later use
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the server has removed a SPITObject.
|
||||
* After this function has been exited the SPITObject is emeoved from the SPITObject-List and the pointer is deleted.
|
||||
* So use the pointer immediately or use the copyconstructor to make a copy for extended use.
|
||||
* You have to release the copy yourself later (delete ptr...)
|
||||
* @param p_SPITType a reference to a copy of the associated SPITType instance.
|
||||
* @param p_SPITObject a reference to a copy of the SPITObject instance.
|
||||
*/
|
||||
void MyApp::onSpitObjectRemoved(const SPITType &p_SPITType, const SPITObject &p_SPITObject) {
|
||||
ESP_LOGD(TAG, "eventSPITObject Removed");
|
||||
ESP_LOGD(TAG, " ID: %s Name: %s\n", p_SPITObject.getID().data(), p_SPITObject.getName().data());
|
||||
|
||||
// Check your actions
|
||||
// take the removal of the SPITObject over in your code
|
||||
|
||||
// CAUTION: Deleted SPITObjects can be added later again (perhaps per UNDO on the SPITServer)
|
||||
//-> don't remove your assigned action immediately - keep it to reassign it later
|
||||
}
|
||||
/**
|
||||
* Called when the server has removed a Remote SPITObject.
|
||||
* A Remote SPITObject is used to remote control the SPITServer.
|
||||
* After this function has been exited the SPITObject is emeoved from the SPITObject-List and the pointer is deleted.
|
||||
* So use the pointer immediately or use the copyconstructor to make a copy for extended use.
|
||||
* You have to release the copy yourself later (delete ptr...)
|
||||
* @param p_SPITType a reference to a copy of the associated SPITType instance.
|
||||
* @param p_SPITObject a reference to a copy of the SPITObject instance.
|
||||
*/
|
||||
void MyApp::onSpitObjectRemoteRemoved(const SPITType &p_SPITType, const SPITObject &p_SPITObject) {
|
||||
ESP_LOGD(TAG, "eventSPITObjectRemote Removed");
|
||||
ESP_LOGD(TAG, " ID: %s Name: %s\n", p_SPITObject.getID().data(), p_SPITObject.getName().data());
|
||||
|
||||
// This is a remote SPITObject
|
||||
// If you have listet this prior you should remove it from the list
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
//---------------- Playing SPITObjects ----------------
|
||||
// Following is called when the SPITServer play SPITObjects.
|
||||
// For every step the server does following sequence occurs:
|
||||
// a) eventPlay
|
||||
// b) several eventPlayObject for each actual played SPITObjectin this step
|
||||
// NEXT STAP of the server
|
||||
// a) eventPlay
|
||||
// b) several eventPlayObject for each actual played SPITObject in this step
|
||||
// ...
|
||||
|
||||
// SPITServer may use several methods for playing SPITObjects.
|
||||
// e.g. liveSHOWsoftware has the timeline and jingles which plays objects, where the timeline the main player is.
|
||||
// SPIT distinguishes between the different players. All eventPlay... functions contain the information which player plays the SPIT object.
|
||||
|
||||
void MyApp::onPlay(string p_PlayerID, string p_PlayerName, char p_PlayerType, bool p_PlayerIsRunning, long long p_TimeFrames) {
|
||||
ESP_LOGD(TAG, "eventPlay Player: %s Runs: %d Time: %lld", p_PlayerName.data(), p_PlayerIsRunning, p_TimeFrames);
|
||||
|
||||
switch (p_PlayerType) {
|
||||
case SPIT_Client::PLAYERTYPE_MAIN:
|
||||
// p_FrameTimes contains the position inside the server's project, we can use it like a timecode
|
||||
int intMilliseconds;
|
||||
intMilliseconds = (int)(((double)p_TimeFrames / (double)m_ServerFramesPerSecond) * 1000);
|
||||
break;
|
||||
case SPIT_Client::PLAYERTYPE_CONTINOUS:
|
||||
// The olayer is playing only single Object sequences sometime during the project
|
||||
break;
|
||||
case SPIT_Client::PLAYERTYPE_DISCRETE:
|
||||
// Only discrete values where submitted, e.g the fader position of remote faders.
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the SPITServer plays a SPITObject. For every played SPITObject one eventPlayObject is called.
|
||||
* You can decide here which action should be done or not.
|
||||
*
|
||||
* @param p_Started true = The SPITObject is newly played (e.g. in liveSHOWsoftware the cursor enters the SPITObject)
|
||||
* @param p_Ended Das true = Playback of SPITObject finished (e.g. in liveSHOWsoftware the cursor has exited the SPIT object)
|
||||
* @param p_SPITType the associated SPITType of p_SPITObject
|
||||
* @param p_SPITObject the actual played or stopped SPITObject
|
||||
* @param p_PlayObject contains information about the play status:
|
||||
* frame where the cursor is inside the SPITObject
|
||||
* whether the player is running or not
|
||||
* the actual value of the SPITObject (in liveSHOWsoftware objects ma faded in or out or the main value is decreased, ..
|
||||
*/
|
||||
void MyApp::onPlaySpitType(string p_PlayerID, string p_SPITTypeID, bool p_PlayerIsRunning, bool p_Started, bool p_Ended, double p_Value) {
|
||||
// double doubleValue = ((double)p_PlayObject.getValue() / 1000000) * ((double)p_PlayObject.getValueFactor() / 1000000);
|
||||
|
||||
ESP_LOGD(TAG, "eventPlayObject Player: %s is running: %d Object Started: %d Stopped: %d", p_PlayerID.data(), p_PlayerIsRunning, p_Started, p_Ended);
|
||||
// ESP_LOGD(TAG, " SPITType: %s SPITObject: %s Position: %lld Value: %f\n", p_SPITTypeID.data(), p_SPITObject.getName().data(), p_PlayObject.getFrameInside(), doubleValue);
|
||||
ESP_LOGD(TAG, " SPITType: %s Value: %f\n", p_SPITTypeID.data(), p_Value);
|
||||
|
||||
if (p_SPITTypeID == "MySPITAPP_Action1ID") { // do Action 1
|
||||
// we can get some information about the play status
|
||||
if (p_Started == true) {
|
||||
ESP_LOGI(TAG, "MyApp AKTION 1 started Value: %f and running: %d", p_Value, p_PlayerIsRunning);
|
||||
} else if (p_Ended == true) {
|
||||
ESP_LOGI(TAG, "MyApp AKTION 1 ended"); // p_PlayObject.getFrameInside() is -1
|
||||
} else {
|
||||
ESP_LOGD(TAG, "MyApp AKTION 1 is played Value: %f and running: %d", p_Value, p_PlayerIsRunning);
|
||||
}
|
||||
} else if (p_SPITTypeID == "MySPITAPP_Action2ID") { // do Action 2
|
||||
if (p_Started == true) {
|
||||
ESP_LOGI(TAG, "AKTION 2 started Value: %f and running: %d", p_Value, p_PlayerIsRunning);
|
||||
} else if (p_Ended == true) {
|
||||
ESP_LOGI(TAG, "AKTION 2 ended"); // p_PlayObject.getFrameInside() is -1
|
||||
} else {
|
||||
ESP_LOGD(TAG, "AKTION 2 is played Value: %f and running: %d", p_Value, p_PlayerIsRunning);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
//---------------- Remote Control SPITServer ----------------
|
||||
// The SPITServer has sent all possibilities to control it remotely - remote SPITObjects - see eventSPITObjectRemote
|
||||
// Some of them may control functionality with values (fader psotions for loudness of sound, ...).
|
||||
// When the server changes one of these value objects, it sends an eventPlayRemoteObjectStatus.
|
||||
|
||||
/**
|
||||
* Called when a remote SpitObject which value function is changed by the server.
|
||||
* This allows the Client to adjust its display for the remote command.
|
||||
* @param p_SPITType the assigned remote SPITType of p_SPITObject
|
||||
* @param p_SPITObject the remote SPITObject which is changed
|
||||
* @param p_FrameInsideObject can be discarded
|
||||
* @param p_Value the new value
|
||||
*/
|
||||
void MyApp::onPlayRemoteObjectStatus(const SPITType &p_SPITType, const SPITObject &p_SPITObject, long long p_FrameInsideObject, int p_Value) {
|
||||
ESP_LOGD(TAG, "eventPlayRemoteObjectStatus RemoteSPITType: %s RemoteSPITObject: %s Position: %lld Value: %d", p_SPITType.getName().data(), p_SPITObject.getName().data(), p_FrameInsideObject, p_Value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a remote control command to the SPITServer.
|
||||
* There may be different command types:
|
||||
* a) Some don't use value e.g. go to next scene, olay a jingle, ..
|
||||
* b) Some use values e.g. the main sound fader
|
||||
* @param p_SPITObjectID the id of the remote SPITObject (this represents the remote control command)
|
||||
* @param p_Valueppm the value in ppm
|
||||
* in case a) the value is ignored
|
||||
* in case b) the value is used
|
||||
* @param p_ValueFlag indicates how the server should use p_Valueppm:
|
||||
* VALUEFLAG_DIRECT (0x00) The server will overwrite his existing value with p_Value
|
||||
* VALUEFLAG_INCREASE (0x01) The server increases his existing value by p_Valueppm
|
||||
* VALUEFLAG_DECREASE (0x01) The server decreases his existing value by p_Valueppm
|
||||
*/
|
||||
void MyApp::sendRemoteObject(string p_SPITObjectID, int p_Valueppm, char p_ValueFlag) {
|
||||
_SpitClient.sendRemoteObject(p_SPITObjectID, p_Valueppm, p_ValueFlag);
|
||||
}
|
||||
|
||||
void MyApp::testLiveShowRemote() {
|
||||
// We jump to the next Scenebridge - no Value is needed
|
||||
_SpitClient.sendRemoteObject("playControlStart");
|
||||
}
|
||||
@@ -4,174 +4,130 @@
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
/*
|
||||
/*
|
||||
* SAD_DetectedServer holds information about SPIT Server detected by ServerAutoDetection (SAD).
|
||||
* File: SAD_DetectedServer.cpp
|
||||
* Author: Hagi
|
||||
*
|
||||
*
|
||||
* Created on 4. Mai 2019, 13:51
|
||||
*/
|
||||
|
||||
#include "SAD_DetectedServer.hpp"
|
||||
#include "esp_log.h"
|
||||
|
||||
static const char * TAG = "SpitSrv";
|
||||
static const char *TAG = "SpitSrv";
|
||||
|
||||
unordered_map<string, SAD_DetectedServer*> SAD_DetectedServer::s_DetectedServers;
|
||||
unordered_map<string, SAD_DetectedServer *> SAD_DetectedServer::s_DetectedServers;
|
||||
|
||||
SAD_DetectedServer::~SAD_DetectedServer() {
|
||||
}
|
||||
//----- Detected Server -----
|
||||
SAD_DetectedServer::SAD_DetectedServer() {
|
||||
m_ID = "";
|
||||
m_Name = "";
|
||||
m_ComputerName = "";
|
||||
m_ClientIP = "";
|
||||
m_Port = "";
|
||||
m_Additions = "";
|
||||
m_IPIsIP4 = false;
|
||||
m_ID = "";
|
||||
m_Name = "";
|
||||
m_ComputerName = "";
|
||||
m_ClientIP = "";
|
||||
m_Port = "";
|
||||
m_Additions = "";
|
||||
}
|
||||
|
||||
void SAD_DetectedServer::setProjectName(string p_ServerProjectName) {
|
||||
if (m_ServerProjectName.compare(p_ServerProjectName) != 0) {
|
||||
if (m_New == false) {
|
||||
m_Changed = true;
|
||||
}
|
||||
}
|
||||
m_ServerProjectName = p_ServerProjectName;
|
||||
if (m_ServerProjectName.compare(p_ServerProjectName) != 0) {
|
||||
if (m_New == false) {
|
||||
m_Changed = true;
|
||||
}
|
||||
}
|
||||
m_ServerProjectName = p_ServerProjectName;
|
||||
}
|
||||
|
||||
void SAD_DetectedServer::cycleStart() {
|
||||
for (auto i = s_DetectedServers.begin(); i != s_DetectedServers.end(); i++) {
|
||||
i->second->startCycleSAD();
|
||||
}
|
||||
for (auto i = s_DetectedServers.begin(); i != s_DetectedServers.end(); i++) {
|
||||
i->second->startCycleSAD();
|
||||
}
|
||||
}
|
||||
void SAD_DetectedServer::cycleEnd(I_SAD_Client& sadClient) {
|
||||
list<SAD_DetectedServer*> o_LostServers;
|
||||
list<SAD_DetectedServer*> o_NewServers;
|
||||
list<SAD_DetectedServer*> o_ChangedServers;
|
||||
SAD_DetectedServer* ptrDetectedServer;
|
||||
{
|
||||
for (auto i = s_DetectedServers.begin(); i != s_DetectedServers.end(); i++) {
|
||||
ptrDetectedServer = i->second;
|
||||
if (ptrDetectedServer->getFoundAgain() == false) {
|
||||
o_LostServers.push_back(ptrDetectedServer);
|
||||
ptrDetectedServer->endCycleSAD();
|
||||
}
|
||||
else if (ptrDetectedServer->getNew()) {
|
||||
o_NewServers.push_back(ptrDetectedServer);
|
||||
ptrDetectedServer->setNew(false);
|
||||
ptrDetectedServer->endCycleSAD();
|
||||
}
|
||||
else if (ptrDetectedServer->getChanged()) {
|
||||
o_ChangedServers.push_back(ptrDetectedServer);
|
||||
ptrDetectedServer->endCycleSAD();
|
||||
}
|
||||
else {
|
||||
ptrDetectedServer->endCycleSAD();
|
||||
}
|
||||
}
|
||||
}
|
||||
//Notify client interface about lost servers
|
||||
for (auto i = o_LostServers.begin(); i != o_LostServers.end(); i++) {
|
||||
ptrDetectedServer = *i;
|
||||
sadClient.eventServerLost(ptrDetectedServer->getID(), ptrDetectedServer->getName(),
|
||||
ptrDetectedServer->getComputerName(), ptrDetectedServer->getIP(), ptrDetectedServer->getPort(), ptrDetectedServer->getAdditions(),ptrDetectedServer->getProjectName(),
|
||||
ptrDetectedServer->getClientIP(),
|
||||
ptrDetectedServer->getIpIsIP4());
|
||||
}
|
||||
//Remove lost servers
|
||||
for (auto i = o_LostServers.begin(); i != o_LostServers.end(); i++) {
|
||||
ptrDetectedServer = *i;
|
||||
removeDetectedServer(ptrDetectedServer);
|
||||
}
|
||||
o_LostServers.clear();
|
||||
|
||||
for (auto i = o_NewServers.begin(); i != o_NewServers.end(); i++) {
|
||||
ptrDetectedServer = *i;
|
||||
sadClient.eventServerDetected(ptrDetectedServer->getID(), ptrDetectedServer->getName(),
|
||||
ptrDetectedServer->getComputerName(), ptrDetectedServer->getIP(), ptrDetectedServer->getPort(), ptrDetectedServer->getAdditions(),ptrDetectedServer->getProjectName(),
|
||||
ptrDetectedServer->getClientIP(),
|
||||
ptrDetectedServer->getIpIsIP4());
|
||||
}
|
||||
o_NewServers.clear();
|
||||
for (auto i = o_ChangedServers.begin(); i != o_ChangedServers.end(); i++) {
|
||||
ptrDetectedServer = *i;
|
||||
sadClient.eventServerChanged(ptrDetectedServer->getID(), ptrDetectedServer->getName(),
|
||||
ptrDetectedServer->getComputerName(), ptrDetectedServer->getIP(), ptrDetectedServer->getPort(), ptrDetectedServer->getAdditions(),ptrDetectedServer->getProjectName(),
|
||||
ptrDetectedServer->getClientIP(),
|
||||
ptrDetectedServer->getIpIsIP4());
|
||||
}
|
||||
o_ChangedServers.clear();
|
||||
void SAD_DetectedServer::cycleEnd(I_SAD_Client &sadClient) {
|
||||
for (auto &srv : s_DetectedServers) {
|
||||
SAD_DetectedServer *ptrDetectedServer = srv.second;
|
||||
if (ptrDetectedServer->getFoundAgain() == false) {
|
||||
sadClient.eventServerLost(*ptrDetectedServer);
|
||||
removeDetectedServer(*ptrDetectedServer);
|
||||
} else if (ptrDetectedServer->getNew()) {
|
||||
ptrDetectedServer->setNew(false);
|
||||
sadClient.eventServerDetected(*ptrDetectedServer);
|
||||
} else if (ptrDetectedServer->getChanged()) {
|
||||
sadClient.eventServerChanged(*ptrDetectedServer);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Used by SAD_Client to add a found SPITServer - don't use this manually
|
||||
* @param p_IsIP4 true = the server is reached via a IP4 address<br>false = the server is reahed via a IP6 address
|
||||
* @param p_ServerID the id of the server, every instance of a SPITServer has an own id
|
||||
* @param p_ServerParams the server's parameter
|
||||
*/
|
||||
void SAD_DetectedServer::addDetectedServer(bool p_IsIP4, string p_ServerID, string p_ServerParams[]) {
|
||||
SAD_DetectedServer* ptrDetectedServer;
|
||||
{
|
||||
auto i = s_DetectedServers.find(p_ServerID);
|
||||
if (i != s_DetectedServers.end()) {
|
||||
ptrDetectedServer = i->second;
|
||||
}
|
||||
else {
|
||||
ptrDetectedServer = new SAD_DetectedServer();
|
||||
ptrDetectedServer->setID(p_ServerParams[PARAMINDEX_ID]);
|
||||
ptrDetectedServer->setNew(true);
|
||||
}
|
||||
ptrDetectedServer->setFoundAgain();
|
||||
|
||||
//second prefer IP4
|
||||
if (p_IsIP4 == true) {
|
||||
ptrDetectedServer->setIP(p_ServerParams[PARAMINDEX_IP]);
|
||||
ptrDetectedServer->setIPIsIP4(true);
|
||||
ptrDetectedServer->setClientIP(p_ServerParams[PARAMINDEX_CLIENTIP]);
|
||||
}
|
||||
else if (ptrDetectedServer->getIpIsIP4() == false){
|
||||
ptrDetectedServer->setIP(p_ServerParams[PARAMINDEX_IP]);
|
||||
ptrDetectedServer->setClientIP(p_ServerParams[PARAMINDEX_CLIENTIP]);
|
||||
}
|
||||
ptrDetectedServer->setName(p_ServerParams[PARAMINDEX_NAME]);
|
||||
ptrDetectedServer->setComputerName(p_ServerParams[PARAMINDEX_COMPUTERNAME]);
|
||||
ptrDetectedServer->setPort(p_ServerParams[PARAMINDEX_PORT]);
|
||||
ptrDetectedServer->setAdditions(p_ServerParams[PARAMINDEX_ADDITIONS]);
|
||||
ptrDetectedServer->setProjectName(p_ServerParams[PARAMINDEX_SERVERPROJECTNAME]);
|
||||
/**
|
||||
* Used by SAD_Client to add a found SPITServer - don't use this manually
|
||||
* @param p_IsIP4 true = the server is reached via a IP4 address<br>false = the server is reahed via a IP6 address
|
||||
* @param p_ServerID the id of the server, every instance of a SPITServer has an own id
|
||||
* @param p_ServerParams the server's parameter
|
||||
*/
|
||||
void SAD_DetectedServer::addDetectedServer(string p_ServerID, string p_ServerParams[]) {
|
||||
SAD_DetectedServer *ptrDetectedServer;
|
||||
{
|
||||
auto i = s_DetectedServers.find(p_ServerID);
|
||||
if (i != s_DetectedServers.end()) {
|
||||
ptrDetectedServer = i->second;
|
||||
} else {
|
||||
ptrDetectedServer = new SAD_DetectedServer();
|
||||
ptrDetectedServer->setID(p_ServerParams[PARAMINDEX_ID]);
|
||||
ptrDetectedServer->setNew(true);
|
||||
}
|
||||
ptrDetectedServer->setFoundAgain();
|
||||
|
||||
s_DetectedServers[ptrDetectedServer->getID()] = ptrDetectedServer;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Used by SAD_Client to remove a SPITServer - don't use this manually
|
||||
* @param p_DetectedServer
|
||||
*/
|
||||
void SAD_DetectedServer::removeDetectedServer(SAD_DetectedServer* p_DetectedServer) {
|
||||
SAD_DetectedServer* o_DetectedServer;
|
||||
{
|
||||
auto i = s_DetectedServers.find(p_DetectedServer->getID());
|
||||
if (i != s_DetectedServers.end()) {
|
||||
o_DetectedServer = i->second;
|
||||
i = s_DetectedServers.erase(i);
|
||||
delete o_DetectedServer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Used by SAD_Client to clear all found SPITServers - don't use this manually
|
||||
*/
|
||||
// second prefer IP4
|
||||
ptrDetectedServer->setIP(p_ServerParams[PARAMINDEX_IP]);
|
||||
ptrDetectedServer->setClientIP(p_ServerParams[PARAMINDEX_CLIENTIP]);
|
||||
ptrDetectedServer->setName(p_ServerParams[PARAMINDEX_NAME]);
|
||||
ptrDetectedServer->setComputerName(p_ServerParams[PARAMINDEX_COMPUTERNAME]);
|
||||
ptrDetectedServer->setPort(p_ServerParams[PARAMINDEX_PORT]);
|
||||
ptrDetectedServer->setAdditions(p_ServerParams[PARAMINDEX_ADDITIONS]);
|
||||
ptrDetectedServer->setProjectName(p_ServerParams[PARAMINDEX_SERVERPROJECTNAME]);
|
||||
|
||||
s_DetectedServers[ptrDetectedServer->getID()] = ptrDetectedServer;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Used by SAD_Client to remove a SPITServer - don't use this manually
|
||||
* @param p_DetectedServer
|
||||
*/
|
||||
void SAD_DetectedServer::removeDetectedServer(SAD_DetectedServer &server) {
|
||||
auto i = s_DetectedServers.find(server.getID());
|
||||
if (i != s_DetectedServers.end()) {
|
||||
SAD_DetectedServer *o_DetectedServer = i->second;
|
||||
i = s_DetectedServers.erase(i);
|
||||
delete o_DetectedServer;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Used by SAD_Client to clear all found SPITServers - don't use this manually
|
||||
*/
|
||||
void SAD_DetectedServer::clearDetectedServers() {
|
||||
SAD_DetectedServer* ptrDetectedServer;
|
||||
{
|
||||
for (auto i = s_DetectedServers.begin(); i != s_DetectedServers.end(); i++) {
|
||||
ptrDetectedServer = i->second;
|
||||
i = s_DetectedServers.erase(i);
|
||||
delete ptrDetectedServer;
|
||||
if (i == s_DetectedServers.end()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (auto i = s_DetectedServers.begin(); i != s_DetectedServers.end(); i++) {
|
||||
SAD_DetectedServer *ptrDetectedServer = i->second;
|
||||
i = s_DetectedServers.erase(i);
|
||||
delete ptrDetectedServer;
|
||||
if (i == s_DetectedServers.end()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const SAD_DetectedServer &SAD_DetectedServer::getRefDetectedServer(string p_ServerID) {
|
||||
SAD_DetectedServer *ptrDetectedServer = nullptr;
|
||||
|
||||
auto i = s_DetectedServers.find(p_ServerID);
|
||||
if (i != s_DetectedServers.end()) {
|
||||
ptrDetectedServer = i->second;
|
||||
}
|
||||
if (ptrDetectedServer != NULL) {
|
||||
return *ptrDetectedServer;
|
||||
}
|
||||
|
||||
throw new exception();
|
||||
}
|
||||
+507
-476
File diff suppressed because it is too large
Load Diff
@@ -4,150 +4,134 @@
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
/*
|
||||
/*
|
||||
* SPITPlayer describes a virtual SPIT Player.
|
||||
* File: SPITPLayer.cpp
|
||||
* Author: Hagi
|
||||
*
|
||||
*
|
||||
* Created on 30. April 2019, 11:44
|
||||
*/
|
||||
|
||||
#include "SPITPlayer.h"
|
||||
#include <vector>
|
||||
|
||||
unordered_map<string, SPITPlayer*> SPITPlayer::s_SPITPlayers;
|
||||
unordered_map<string, SPITPlayer *> SPITPlayer::s_SPITPlayers;
|
||||
|
||||
SPITPlayer* SPITPlayer::getSPITPlayer(string p_PlayerID) {
|
||||
{
|
||||
auto i = s_SPITPlayers.find(p_PlayerID);
|
||||
if (i == s_SPITPlayers.end()) {
|
||||
s_SPITPlayers[p_PlayerID] = new SPITPlayer(p_PlayerID);
|
||||
}
|
||||
i = s_SPITPlayers.find(p_PlayerID);
|
||||
if (i == s_SPITPlayers.end()) return NULL;
|
||||
return i->second;
|
||||
}
|
||||
SPITPlayer *SPITPlayer::getSPITPlayer(string p_PlayerID) {
|
||||
{
|
||||
auto i = s_SPITPlayers.find(p_PlayerID);
|
||||
if (i == s_SPITPlayers.end()) {
|
||||
s_SPITPlayers[p_PlayerID] = new SPITPlayer(p_PlayerID);
|
||||
}
|
||||
i = s_SPITPlayers.find(p_PlayerID);
|
||||
if (i == s_SPITPlayers.end())
|
||||
return NULL;
|
||||
return i->second;
|
||||
}
|
||||
}
|
||||
|
||||
void SPITPlayer::clearPlayers() {
|
||||
;
|
||||
vector<SPITPlayer*> o_SPITPlayers;
|
||||
for (auto i = s_SPITPlayers.begin(); i != s_SPITPlayers.end(); i++) {
|
||||
SPITPlayer* ptrSPITPlayer = i->second;
|
||||
o_SPITPlayers.push_back(ptrSPITPlayer);
|
||||
}
|
||||
for (auto i = o_SPITPlayers.begin(); i != o_SPITPlayers.end(); i++) {
|
||||
SPITPlayer* ptrSPITPlayer = *i;
|
||||
delete ptrSPITPlayer;
|
||||
}
|
||||
o_SPITPlayers.clear();
|
||||
;
|
||||
vector<SPITPlayer *> o_SPITPlayers;
|
||||
for (auto i = s_SPITPlayers.begin(); i != s_SPITPlayers.end(); i++) {
|
||||
SPITPlayer *ptrSPITPlayer = i->second;
|
||||
o_SPITPlayers.push_back(ptrSPITPlayer);
|
||||
}
|
||||
for (auto i = o_SPITPlayers.begin(); i != o_SPITPlayers.end(); i++) {
|
||||
SPITPlayer *ptrSPITPlayer = *i;
|
||||
delete ptrSPITPlayer;
|
||||
}
|
||||
o_SPITPlayers.clear();
|
||||
}
|
||||
|
||||
SPITPlayer::SPITPlayer(string p_PlayerID) {
|
||||
m_ID = p_PlayerID;
|
||||
s_SPITPlayers[p_PlayerID] = this;
|
||||
m_ID = p_PlayerID;
|
||||
s_SPITPlayers[p_PlayerID] = this;
|
||||
}
|
||||
|
||||
SPITPlayer::~SPITPlayer() {
|
||||
PlaySPITType* ptrPlaySPITType;
|
||||
for (auto i = m_PlaySPITTypes.begin(); i != m_PlaySPITTypes.end(); i++) {
|
||||
ptrPlaySPITType = i->second;
|
||||
i = m_PlaySPITTypes.erase(i);
|
||||
delete ptrPlaySPITType;
|
||||
if (i == m_PlaySPITTypes.end()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
PlaySPITType *ptrPlaySPITType;
|
||||
for (auto i = m_PlaySPITTypes.begin(); i != m_PlaySPITTypes.end(); i++) {
|
||||
ptrPlaySPITType = i->second;
|
||||
i = m_PlaySPITTypes.erase(i);
|
||||
delete ptrPlaySPITType;
|
||||
if (i == m_PlaySPITTypes.end()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SPITPlayer::setIsRunning(bool p_IsRunning) {
|
||||
m_IsRunning = p_IsRunning;
|
||||
}
|
||||
void SPITPlayer::setName(string p_Name) {
|
||||
m_Name = p_Name;
|
||||
}
|
||||
void SPITPlayer::setType(char p_Type) {
|
||||
m_Type = p_Type;
|
||||
}
|
||||
void SPITPlayer::setTime(long long p_Frames) {
|
||||
m_TimeFrames = p_Frames;
|
||||
}
|
||||
|
||||
unordered_map<string, SPITPlayer::PlaySPITType*>* SPITPlayer::getPlaySPITTypes() {
|
||||
return &m_PlaySPITTypes;
|
||||
unordered_map<string, SPITPlayer::PlaySPITType *> *SPITPlayer::getPlaySPITTypes() {
|
||||
return &m_PlaySPITTypes;
|
||||
}
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param p_SPITObjectID
|
||||
* @return true = new PlayObject added<br>
|
||||
* false = PlayObject exists
|
||||
* false = PlayObject exists
|
||||
*/
|
||||
SPITPlayer::PlaySPITType* SPITPlayer::addSPITType_Playing (string p_SPITTypeID) {
|
||||
PlaySPITType* ptrPlaySPITType;
|
||||
|
||||
auto i = m_PlaySPITTypes.find(p_SPITTypeID);
|
||||
if (i == m_PlaySPITTypes.end()) {
|
||||
ptrPlaySPITType = new PlaySPITType(this, p_SPITTypeID);
|
||||
ptrPlaySPITType->setIsPlayed(true);
|
||||
ptrPlaySPITType->setIsNew(true);
|
||||
m_PlaySPITTypes[p_SPITTypeID] = ptrPlaySPITType;
|
||||
}
|
||||
else {
|
||||
ptrPlaySPITType = i->second;
|
||||
ptrPlaySPITType->setIsPlayed(true);
|
||||
}
|
||||
return ptrPlaySPITType;
|
||||
|
||||
SPITPlayer::PlaySPITType *SPITPlayer::addSPITType_Playing(string p_SPITTypeID) {
|
||||
PlaySPITType *ptrPlaySPITType;
|
||||
|
||||
auto i = m_PlaySPITTypes.find(p_SPITTypeID);
|
||||
if (i == m_PlaySPITTypes.end()) {
|
||||
ptrPlaySPITType = new PlaySPITType(this, p_SPITTypeID);
|
||||
ptrPlaySPITType->setIsPlayed(true);
|
||||
ptrPlaySPITType->setIsNew(true);
|
||||
m_PlaySPITTypes[p_SPITTypeID] = ptrPlaySPITType;
|
||||
} else {
|
||||
ptrPlaySPITType = i->second;
|
||||
ptrPlaySPITType->setIsPlayed(true);
|
||||
}
|
||||
return ptrPlaySPITType;
|
||||
}
|
||||
|
||||
void SPITPlayer::startPlaySequence() {
|
||||
PlaySPITType* ptrPlaySPITType;
|
||||
for (auto i = m_PlaySPITTypes.begin(); i != m_PlaySPITTypes.end(); i++) {
|
||||
ptrPlaySPITType = i->second;
|
||||
ptrPlaySPITType->startPlaySequence();
|
||||
}
|
||||
PlaySPITType *ptrPlaySPITType;
|
||||
for (auto i = m_PlaySPITTypes.begin(); i != m_PlaySPITTypes.end(); i++) {
|
||||
ptrPlaySPITType = i->second;
|
||||
ptrPlaySPITType->startPlaySequence();
|
||||
}
|
||||
}
|
||||
|
||||
void SPITPlayer::endPlaySequence() {
|
||||
PlaySPITType* ptrPlaySPITType;
|
||||
|
||||
for (auto i = m_PlaySPITTypes.begin(); i != m_PlaySPITTypes.end(); i++) {
|
||||
ptrPlaySPITType = i->second;
|
||||
if (ptrPlaySPITType->getIsPlayed() == false) {
|
||||
i = m_PlaySPITTypes.erase(i);
|
||||
delete ptrPlaySPITType;
|
||||
if (i == m_PlaySPITTypes.end()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PlaySPITType *ptrPlaySPITType;
|
||||
|
||||
for (auto i = m_PlaySPITTypes.begin(); i != m_PlaySPITTypes.end(); i++) {
|
||||
ptrPlaySPITType = i->second;
|
||||
if (ptrPlaySPITType->getIsPlayed() == false) {
|
||||
i = m_PlaySPITTypes.erase(i);
|
||||
delete ptrPlaySPITType;
|
||||
if (i == m_PlaySPITTypes.end()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SPITPlayer::PlaySPITType::PlaySPITType() {
|
||||
}
|
||||
SPITPlayer::PlaySPITType::PlaySPITType(SPITPlayer* p_SPITPlayer, string p_SPITTypeID) {
|
||||
m_SPITTypeID = p_SPITTypeID;
|
||||
m_PlayerID = p_SPITPlayer->getID();
|
||||
m_PlayerName = p_SPITPlayer->getName();
|
||||
startPlaySequence();
|
||||
m_IsNew = true;
|
||||
SPITPlayer::PlaySPITType::PlaySPITType(SPITPlayer *p_SPITPlayer, string p_SPITTypeID) {
|
||||
m_SPITTypeID = p_SPITTypeID;
|
||||
m_PlayerID = p_SPITPlayer->getID();
|
||||
m_PlayerName = p_SPITPlayer->getName();
|
||||
startPlaySequence();
|
||||
m_IsNew = true;
|
||||
}
|
||||
SPITPlayer::PlaySPITType::PlaySPITType(const PlaySPITType& orig) {
|
||||
m_SPITTypeID = orig.getSPITTypeID();
|
||||
m_IsPlayed = orig.getIsPlayed();
|
||||
m_IsNew = orig.getIsNew();
|
||||
SPITPlayer::PlaySPITType::PlaySPITType(const PlaySPITType &orig) {
|
||||
m_SPITTypeID = orig.getSPITTypeID();
|
||||
m_IsPlayed = orig.getIsPlayed();
|
||||
m_IsNew = orig.getIsNew();
|
||||
|
||||
m_PlayerID = orig.getPlayerID();
|
||||
m_PlayerName = orig.getPlayerName();
|
||||
m_PlayerRuns = orig.getPlayerIsRunning();
|
||||
m_PlayerID = orig.getPlayerID();
|
||||
m_PlayerName = orig.getPlayerName();
|
||||
m_PlayerRuns = orig.getPlayerIsRunning();
|
||||
|
||||
m_Value = orig.getValue();
|
||||
m_Value = orig.getValue();
|
||||
}
|
||||
void SPITPlayer::PlaySPITType::startPlaySequence() {
|
||||
m_IsPlayed = false;
|
||||
m_IsNew = false;
|
||||
|
||||
m_Value = 0;
|
||||
m_IsPlayed = false;
|
||||
m_IsNew = false;
|
||||
|
||||
m_Value = 0;
|
||||
}
|
||||
@@ -15,11 +15,11 @@
|
||||
|
||||
#include "SPITSocket.h"
|
||||
#include "Task.hpp"
|
||||
#include "esp/uuid.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_netif.h"
|
||||
#include "esp/uuid.h"
|
||||
#include <unistd.h>
|
||||
#include <string>
|
||||
#include <unistd.h>
|
||||
using namespace std;
|
||||
|
||||
/**
|
||||
@@ -43,14 +43,14 @@ bool SPITSocket::createSocket_UDP() {
|
||||
} else {
|
||||
intResult = setsockopt(m_UDPSocketIP4, SOL_SOCKET, SO_REUSEADDR, (void *)&intOptionValue4, sizeof(intOptionValue4));
|
||||
}
|
||||
if (intResult < 0) {
|
||||
boolSuccess = false;
|
||||
}
|
||||
if (intResult < 0) {
|
||||
boolSuccess = false;
|
||||
}
|
||||
|
||||
if (boolSuccess == true) {
|
||||
struct timeval tv;
|
||||
tv.tv_sec = 1; // seconds
|
||||
tv.tv_usec = 0; // microseconds (0.0 sec)
|
||||
tv.tv_sec = 1; // seconds
|
||||
tv.tv_usec = 0; // microseconds (0.0 sec)
|
||||
// This sets the receive timeout
|
||||
setsockopt(m_UDPSocketIP4, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
|
||||
|
||||
@@ -61,8 +61,8 @@ bool SPITSocket::createSocket_UDP() {
|
||||
// fcntl(m_UDPSocketIP4, F_SETFL, intFlags | O_NONBLOCK);
|
||||
|
||||
// int intBufferSize = 2046 * 512;
|
||||
// intResult = setsockopt(m_UDPSocketIP4, SOL_SOCKET, SO_RCVBUF, (void*)&intBufferSize, sizeof(intBufferSize));
|
||||
// intResult = setsockopt(m_UDPSocketIP4, SOL_SOCKET, SO_SNDBUF, (void*)&intBufferSize, sizeof(intBufferSize));
|
||||
// intResult = setsockopt(m_UDPSocketIP4, SOL_SOCKET, SO_RCVBUF, (void*)&intBufferSize, sizeof(intBufferSize));
|
||||
// intResult = setsockopt(m_UDPSocketIP4, SOL_SOCKET, SO_SNDBUF, (void*)&intBufferSize, sizeof(intBufferSize));
|
||||
}
|
||||
return boolSuccess;
|
||||
}
|
||||
@@ -186,8 +186,8 @@ int SPITSocket::sendMessageTo(int p_InetFamily, string p_ServerIP, string p_Serv
|
||||
intResult = sendto(m_UDPSocketIP4, p_MessageBytes, p_MessageLength, 0, (const sockaddr *)&o_IP4SocketAddress, (socklen_t)intSocklen);
|
||||
if (intResult < 0) {
|
||||
printf("UnixSocket::sendMessageTo IP4 sendto %s FAILED %s\n", p_ServerIP.data(), strerror(errno));
|
||||
printf("UnixSocket::sendMessageTo ret=%d %s / %s / %d\n", intResult,
|
||||
p_ServerPort.data(), p_MessageBytes, p_MessageLength);
|
||||
printf("UnixSocket::sendMessageTo ret=%d %s / %s / %d\n", intResult,
|
||||
p_ServerPort.data(), p_MessageBytes, p_MessageLength);
|
||||
}
|
||||
freeaddrinfo(ptrAddressInfo);
|
||||
}
|
||||
@@ -196,23 +196,23 @@ int SPITSocket::sendMessageTo(int p_InetFamily, string p_ServerIP, string p_Serv
|
||||
intResult = -1;
|
||||
}
|
||||
|
||||
if (intResult < 0) {
|
||||
return -1;
|
||||
}
|
||||
if (intResult < 0) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/**
|
||||
* Call this for receiving a message
|
||||
* This will block until a message is received or the underlying socket is closed
|
||||
* @param p_InetFamily either AF_INET or AF_INET6<br>
|
||||
* The SPITSocket creates two udp sockets, one for IP4 and one for IP6
|
||||
* This parameter decides from which socket should a message recieved
|
||||
* @param p_Buffer the buffer containing the received message later.
|
||||
* @param p_BufferLength the size of the buffer
|
||||
* @param p_ServerIP a pointer to a string, when a messages is received the string will contain the ip address of the sender/server
|
||||
* if p_ServerIP is NULL - no detection of the server will be done.
|
||||
* @return
|
||||
*/
|
||||
/**
|
||||
* Call this for receiving a message
|
||||
* This will block until a message is received or the underlying socket is closed
|
||||
* @param p_InetFamily either AF_INET or AF_INET6<br>
|
||||
* The SPITSocket creates two udp sockets, one for IP4 and one for IP6
|
||||
* This parameter decides from which socket should a message recieved
|
||||
* @param p_Buffer the buffer containing the received message later.
|
||||
* @param p_BufferLength the size of the buffer
|
||||
* @param p_ServerIP a pointer to a string, when a messages is received the string will contain the ip address of the sender/server
|
||||
* if p_ServerIP is NULL - no detection of the server will be done.
|
||||
* @return
|
||||
*/
|
||||
int SPITSocket::receiveMessage(int p_InetFamily, char *p_Buffer, int p_BufferLength, string *p_ServerIP) {
|
||||
int intResult = -1;
|
||||
// ADDRINFO *AI;
|
||||
@@ -226,7 +226,7 @@ int SPITSocket::receiveMessage(int p_InetFamily, char *p_Buffer, int p_BufferLen
|
||||
}
|
||||
intSocklen = sizeof(o_IP4SocketAddress);
|
||||
memset(&o_IP4SocketAddress, 0, intSocklen);
|
||||
intResult = recvfrom(m_UDPSocketIP4, (void *)p_Buffer, p_BufferLength, 0 , (sockaddr *)&o_IP4SocketAddress, (socklen_t *)&intSocklen);
|
||||
intResult = recvfrom(m_UDPSocketIP4, (void *)p_Buffer, p_BufferLength, 0, (sockaddr *)&o_IP4SocketAddress, (socklen_t *)&intSocklen);
|
||||
if (intResult >= 0) {
|
||||
if (p_ServerIP != NULL) {
|
||||
char bufferIP4[INET_ADDRSTRLEN];
|
||||
@@ -239,7 +239,6 @@ int SPITSocket::receiveMessage(int p_InetFamily, char *p_Buffer, int p_BufferLen
|
||||
return intResult;
|
||||
}
|
||||
|
||||
|
||||
SPITSocket::IPAddress SPITSocket::getAdaptersInfo() {
|
||||
// iterate over active interfaces, and print out IPs
|
||||
esp_netif_t *netif = NULL;
|
||||
@@ -261,12 +260,12 @@ SPITSocket::IPAddress SPITSocket::getAdaptersInfo() {
|
||||
}
|
||||
|
||||
string createGUID() {
|
||||
// uuid_t id;
|
||||
// uuid_generate(id);
|
||||
// char *guid_string = new char[100];
|
||||
// uuid_unparse(id, guid_string);
|
||||
// string stringGUID = guid_string;
|
||||
// return stringGUID;
|
||||
// uuid_t id;
|
||||
// uuid_generate(id);
|
||||
// char *guid_string = new char[100];
|
||||
// uuid_unparse(id, guid_string);
|
||||
// string stringGUID = guid_string;
|
||||
// return stringGUID;
|
||||
|
||||
uuid_t uu;
|
||||
char uu_str[UUID_STR_LEN];
|
||||
@@ -274,15 +273,16 @@ string createGUID() {
|
||||
uuid_generate(uu);
|
||||
uuid_unparse(uu, uu_str);
|
||||
string stringGUID = uu_str;
|
||||
return stringGUID;
|
||||
return stringGUID;
|
||||
}
|
||||
/** The name of the client's host computer*/
|
||||
string getClientHostName() {
|
||||
string stringHostName = "";
|
||||
const char * hostname;
|
||||
esp_netif_get_hostname(esp_netif_get_default_netif(), &hostname);
|
||||
if (hostname != nullptr) {
|
||||
stringHostName = hostname;
|
||||
}
|
||||
return stringHostName;;
|
||||
string stringHostName = "";
|
||||
const char *hostname;
|
||||
esp_netif_get_hostname(esp_netif_get_default_netif(), &hostname);
|
||||
if (hostname != nullptr) {
|
||||
stringHostName = hostname;
|
||||
}
|
||||
return stringHostName;
|
||||
;
|
||||
}
|
||||
|
||||
+419
-411
@@ -4,447 +4,455 @@
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
/*
|
||||
/*
|
||||
* SPITType describes a SPIT Type
|
||||
* File: SPITType.cpp
|
||||
* Author: Hagi
|
||||
*
|
||||
*
|
||||
* Created on 8. April 2019, 08:40
|
||||
*/
|
||||
|
||||
|
||||
#include "SPITType.h"
|
||||
#include "esp_log.h"
|
||||
|
||||
static const char * TAG = "SPIT";
|
||||
static const char *TAG = "SPIT";
|
||||
|
||||
unordered_map<string, SPITType*> SPITType::s_SPITTypes;
|
||||
unordered_map<string, SPITType*> SPITType::s_SPITTypesRemote;
|
||||
|
||||
SPITType* SPITType::getSPITType(string p_ID) {
|
||||
{
|
||||
auto i = s_SPITTypes.find(p_ID);
|
||||
if (i == s_SPITTypes.end()) {
|
||||
return NULL;
|
||||
}
|
||||
return i->second;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Returns the reference of the SPITType with ID == p_ID.<br>
|
||||
* Throws an exception if no SPITType is not found.<br>
|
||||
* @param p_ID the ID
|
||||
* @return reference of the SPITType with ID == p_ID
|
||||
*/
|
||||
const SPITType& SPITType::getSPITTypeRef(string p_ID) {
|
||||
{
|
||||
auto i = s_SPITTypes.find(p_ID);
|
||||
if (i == s_SPITTypes.end()) {
|
||||
throw "SPITType no SPITType with given ID";
|
||||
}
|
||||
return *(i->second);
|
||||
}
|
||||
}
|
||||
unordered_map<string, SPITType *> SPITType::s_SPITTypes;
|
||||
unordered_map<string, SPITType *> SPITType::s_SPITTypesRemote;
|
||||
|
||||
SPITType* SPITType::getSPITTypeRemote(string p_ID) {
|
||||
{
|
||||
auto i = s_SPITTypesRemote.find(p_ID);
|
||||
if (i == s_SPITTypesRemote.end()) {
|
||||
return NULL;
|
||||
}
|
||||
return i->second;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Returns the reference of the remote SPITType with ID == p_ID.<br>
|
||||
* Throws an exception if no SPITType is not found.<br>
|
||||
* @param p_ID the ID
|
||||
* @return reference of the SPITType with ID == p_ID
|
||||
*/
|
||||
const SPITType& SPITType::getSPITTypeRemoteRef(string p_ID) {
|
||||
{
|
||||
auto i = s_SPITTypesRemote.find(p_ID);
|
||||
if (i == s_SPITTypesRemote.end()) {
|
||||
throw "Remote SPITType no SPITType with given ID";
|
||||
}
|
||||
return *(i->second);
|
||||
}
|
||||
}
|
||||
SPITType *SPITType::getSPITType(string p_ID) {
|
||||
{
|
||||
auto i = s_SPITTypes.find(p_ID);
|
||||
if (i == s_SPITTypes.end()) {
|
||||
return NULL;
|
||||
}
|
||||
return i->second;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Returns the reference of the SPITType with ID == p_ID.<br>
|
||||
* Throws an exception if no SPITType is not found.<br>
|
||||
* @param p_ID the ID
|
||||
* @return reference of the SPITType with ID == p_ID
|
||||
*/
|
||||
const SPITType &SPITType::getSPITTypeRef(string p_ID) {
|
||||
{
|
||||
auto i = s_SPITTypes.find(p_ID);
|
||||
if (i == s_SPITTypes.end()) {
|
||||
throw "SPITType no SPITType with given ID";
|
||||
}
|
||||
return *(i->second);
|
||||
}
|
||||
}
|
||||
|
||||
bool SPITType::addSPITType(SPITType* p_ptrSpitType) {
|
||||
if (p_ptrSpitType == NULL) return false;
|
||||
{
|
||||
s_SPITTypes[p_ptrSpitType->getID()] = p_ptrSpitType;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
bool SPITType::addSPITTypeRemote(SPITType* p_ptrSpitType) {
|
||||
if (p_ptrSpitType == NULL) return false;
|
||||
{
|
||||
s_SPITTypesRemote[p_ptrSpitType->getID()] = p_ptrSpitType;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
bool SPITType::removeSPITType(SPITType* p_ptrSpitType) {
|
||||
if (p_ptrSpitType == NULL) return false;
|
||||
{
|
||||
auto i = s_SPITTypes.find(p_ptrSpitType->getID());
|
||||
if (i == s_SPITTypes.end()) {
|
||||
return false;
|
||||
}
|
||||
i = s_SPITTypes.erase(i);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
bool SPITType::removeSPITTypeRemote(SPITType* p_ptrSpitType) {
|
||||
if (p_ptrSpitType == NULL) return false;
|
||||
{
|
||||
auto i = s_SPITTypesRemote.find(p_ptrSpitType->getID());
|
||||
if (i == s_SPITTypesRemote.end()) {
|
||||
return false;
|
||||
}
|
||||
i = s_SPITTypesRemote.erase(i);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
SPITType *SPITType::getSPITTypeRemote(string p_ID) {
|
||||
{
|
||||
auto i = s_SPITTypesRemote.find(p_ID);
|
||||
if (i == s_SPITTypesRemote.end()) {
|
||||
return NULL;
|
||||
}
|
||||
return i->second;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Returns the reference of the remote SPITType with ID == p_ID.<br>
|
||||
* Throws an exception if no SPITType is not found.<br>
|
||||
* @param p_ID the ID
|
||||
* @return reference of the SPITType with ID == p_ID
|
||||
*/
|
||||
const SPITType &SPITType::getSPITTypeRemoteRef(string p_ID) {
|
||||
{
|
||||
auto i = s_SPITTypesRemote.find(p_ID);
|
||||
if (i == s_SPITTypesRemote.end()) {
|
||||
throw "Remote SPITType no SPITType with given ID";
|
||||
}
|
||||
return *(i->second);
|
||||
}
|
||||
}
|
||||
|
||||
int SPITType::getSPITTypeCount() {
|
||||
return s_SPITTypes.size();
|
||||
}
|
||||
int SPITType::getSPITTypeRemoteCount() {
|
||||
return s_SPITTypesRemote.size();
|
||||
}
|
||||
SPITType* SPITType::getSPITType(int p_Index) {
|
||||
SPITType* ptrSPITType = NULL;
|
||||
{
|
||||
if (p_Index < s_SPITTypes.size()) {
|
||||
unordered_map<string, SPITType*>::iterator i = next(s_SPITTypes.begin(), p_Index);
|
||||
ptrSPITType = i->second;
|
||||
}
|
||||
return ptrSPITType;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Returns a reference to the SPITType at position p_Index.<br>
|
||||
* Throws an exception if p_Index is out of range.<br>
|
||||
* @param p_Index position
|
||||
* @return the reference of the SPITType at position.
|
||||
*/
|
||||
const SPITType& SPITType::getSPITTypeRef(int p_Index) {
|
||||
SPITType* ptrSPITType = NULL;
|
||||
{
|
||||
if (p_Index >= 0 && p_Index < s_SPITTypes.size()) {
|
||||
unordered_map<string, SPITType*>::iterator i = next(s_SPITTypes.begin(), p_Index);
|
||||
ptrSPITType = i->second;
|
||||
return *ptrSPITType;
|
||||
}
|
||||
else {
|
||||
throw "SPITType index out of range";
|
||||
}
|
||||
}
|
||||
}
|
||||
SPITType* SPITType::getSPITTypeRemote(int p_Index) {
|
||||
SPITType* ptrSPITType = NULL;
|
||||
{
|
||||
if (p_Index < s_SPITTypesRemote.size()) {
|
||||
unordered_map<string, SPITType*>::iterator i = next(s_SPITTypesRemote.begin(), p_Index);
|
||||
ptrSPITType = i->second;
|
||||
}
|
||||
return ptrSPITType;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Returns a reference to the remote SPITType at position p_Index.<br>
|
||||
* Throws an exception if p_Index is out of range.<br>
|
||||
* @param p_Index position
|
||||
* @return the reference of the SPITType at position.
|
||||
*/
|
||||
const SPITType& SPITType::getSPITTypeRemoteRef(int p_Index) {
|
||||
SPITType* ptrSPITType = NULL;
|
||||
{
|
||||
if (p_Index >= 0 && p_Index < s_SPITTypesRemote.size()) {
|
||||
unordered_map<string, SPITType*>::iterator i = next(s_SPITTypesRemote.begin(), p_Index);
|
||||
ptrSPITType = i->second;
|
||||
return *ptrSPITType;
|
||||
}
|
||||
else {
|
||||
throw "Remote SPITType index out of range";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SPITType::clearSPITTypes() {
|
||||
SPITType* ptrSPITType;
|
||||
{
|
||||
for (auto i = s_SPITTypes.begin(); i != s_SPITTypes.end(); i++) {
|
||||
ptrSPITType = i->second;
|
||||
i = s_SPITTypes.erase(i);
|
||||
delete ptrSPITType;
|
||||
if (i == s_SPITTypes.end()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
void SPITType::clearSPITTypesRemote() {
|
||||
SPITType* ptrSPITType;
|
||||
{
|
||||
for (auto i = s_SPITTypesRemote.begin(); i != s_SPITTypesRemote.end(); i++) {
|
||||
ptrSPITType = i->second;
|
||||
i = s_SPITTypesRemote.erase(i);
|
||||
delete ptrSPITType;
|
||||
if (i == s_SPITTypesRemote.end()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SPITType::eventProjectClosed() {
|
||||
SPITType* ptrSPITType;
|
||||
for (auto i = s_SPITTypes.begin(); i != s_SPITTypes.end(); i++) {
|
||||
ptrSPITType = i->second;
|
||||
if (ptrSPITType->getCreatedByClient() == true) {
|
||||
continue;
|
||||
}
|
||||
i = s_SPITTypes.erase(i);
|
||||
delete ptrSPITType;
|
||||
if (i == s_SPITTypes.end()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
//Remote
|
||||
for (auto i = s_SPITTypesRemote.begin(); i != s_SPITTypesRemote.end(); i++) {
|
||||
ptrSPITType = i->second;
|
||||
i = s_SPITTypesRemote.erase(i);
|
||||
delete ptrSPITType;
|
||||
if (i == s_SPITTypesRemote.end()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
bool SPITType::addSPITType(SPITType *p_ptrSpitType) {
|
||||
if (p_ptrSpitType == NULL)
|
||||
return false;
|
||||
{
|
||||
s_SPITTypes[p_ptrSpitType->getID()] = p_ptrSpitType;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
bool SPITType::addSPITTypeRemote(SPITType *p_ptrSpitType) {
|
||||
if (p_ptrSpitType == NULL)
|
||||
return false;
|
||||
{
|
||||
s_SPITTypesRemote[p_ptrSpitType->getID()] = p_ptrSpitType;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
bool SPITType::removeSPITType(SPITType *p_ptrSpitType) {
|
||||
if (p_ptrSpitType == NULL)
|
||||
return false;
|
||||
{
|
||||
auto i = s_SPITTypes.find(p_ptrSpitType->getID());
|
||||
if (i == s_SPITTypes.end()) {
|
||||
return false;
|
||||
}
|
||||
i = s_SPITTypes.erase(i);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
bool SPITType::removeSPITTypeRemote(SPITType *p_ptrSpitType) {
|
||||
if (p_ptrSpitType == NULL)
|
||||
return false;
|
||||
{
|
||||
auto i = s_SPITTypesRemote.find(p_ptrSpitType->getID());
|
||||
if (i == s_SPITTypesRemote.end()) {
|
||||
return false;
|
||||
}
|
||||
i = s_SPITTypesRemote.erase(i);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
int SPITType::getSPITTypeCount() {
|
||||
return s_SPITTypes.size();
|
||||
}
|
||||
int SPITType::getSPITTypeRemoteCount() {
|
||||
return s_SPITTypesRemote.size();
|
||||
}
|
||||
SPITType *SPITType::getSPITType(int p_Index) {
|
||||
SPITType *ptrSPITType = NULL;
|
||||
{
|
||||
if (p_Index < s_SPITTypes.size()) {
|
||||
unordered_map<string, SPITType *>::iterator i = next(s_SPITTypes.begin(), p_Index);
|
||||
ptrSPITType = i->second;
|
||||
}
|
||||
return ptrSPITType;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Returns a reference to the SPITType at position p_Index.<br>
|
||||
* Throws an exception if p_Index is out of range.<br>
|
||||
* @param p_Index position
|
||||
* @return the reference of the SPITType at position.
|
||||
*/
|
||||
const SPITType &SPITType::getSPITTypeRef(int p_Index) {
|
||||
SPITType *ptrSPITType = NULL;
|
||||
{
|
||||
if (p_Index >= 0 && p_Index < s_SPITTypes.size()) {
|
||||
unordered_map<string, SPITType *>::iterator i = next(s_SPITTypes.begin(), p_Index);
|
||||
ptrSPITType = i->second;
|
||||
return *ptrSPITType;
|
||||
} else {
|
||||
throw "SPITType index out of range";
|
||||
}
|
||||
}
|
||||
}
|
||||
SPITType *SPITType::getSPITTypeRemote(int p_Index) {
|
||||
SPITType *ptrSPITType = NULL;
|
||||
{
|
||||
if (p_Index < s_SPITTypesRemote.size()) {
|
||||
unordered_map<string, SPITType *>::iterator i = next(s_SPITTypesRemote.begin(), p_Index);
|
||||
ptrSPITType = i->second;
|
||||
}
|
||||
return ptrSPITType;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Returns a reference to the remote SPITType at position p_Index.<br>
|
||||
* Throws an exception if p_Index is out of range.<br>
|
||||
* @param p_Index position
|
||||
* @return the reference of the SPITType at position.
|
||||
*/
|
||||
const SPITType &SPITType::getSPITTypeRemoteRef(int p_Index) {
|
||||
SPITType *ptrSPITType = NULL;
|
||||
{
|
||||
if (p_Index >= 0 && p_Index < s_SPITTypesRemote.size()) {
|
||||
unordered_map<string, SPITType *>::iterator i = next(s_SPITTypesRemote.begin(), p_Index);
|
||||
ptrSPITType = i->second;
|
||||
return *ptrSPITType;
|
||||
} else {
|
||||
throw "Remote SPITType index out of range";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SPITType::clearSPITTypes() {
|
||||
SPITType *ptrSPITType;
|
||||
{
|
||||
for (auto i = s_SPITTypes.begin(); i != s_SPITTypes.end(); i++) {
|
||||
ptrSPITType = i->second;
|
||||
i = s_SPITTypes.erase(i);
|
||||
delete ptrSPITType;
|
||||
if (i == s_SPITTypes.end()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
void SPITType::clearSPITTypesRemote() {
|
||||
SPITType *ptrSPITType;
|
||||
{
|
||||
for (auto i = s_SPITTypesRemote.begin(); i != s_SPITTypesRemote.end(); i++) {
|
||||
ptrSPITType = i->second;
|
||||
i = s_SPITTypesRemote.erase(i);
|
||||
delete ptrSPITType;
|
||||
if (i == s_SPITTypesRemote.end()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SPITType::eventProjectClosed() {
|
||||
SPITType *ptrSPITType;
|
||||
for (auto i = s_SPITTypes.begin(); i != s_SPITTypes.end(); i++) {
|
||||
ptrSPITType = i->second;
|
||||
if (ptrSPITType->getCreatedByClient() == true) {
|
||||
continue;
|
||||
}
|
||||
i = s_SPITTypes.erase(i);
|
||||
delete ptrSPITType;
|
||||
if (i == s_SPITTypes.end()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Remote
|
||||
for (auto i = s_SPITTypesRemote.begin(); i != s_SPITTypesRemote.end(); i++) {
|
||||
ptrSPITType = i->second;
|
||||
i = s_SPITTypesRemote.erase(i);
|
||||
delete ptrSPITType;
|
||||
if (i == s_SPITTypesRemote.end()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets confirmed = false for all SPITTypes.<br>
|
||||
* This should be called when the client has loaded a project.<br>
|
||||
*/
|
||||
void SPITType::setConfirmedFalse() {
|
||||
SPITType *ptrSPITType;
|
||||
{
|
||||
for (auto i = s_SPITTypes.begin(); i != s_SPITTypes.end(); i++) {
|
||||
ptrSPITType = i->second;
|
||||
ptrSPITType->setConfirmed(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets confirmed = false for all SPITTypes.<br>
|
||||
* This should be called when the client has loaded a project.<br>
|
||||
*/
|
||||
void SPITType::setConfirmedFalse() {
|
||||
SPITType* ptrSPITType;
|
||||
{
|
||||
for (auto i = s_SPITTypes.begin(); i != s_SPITTypes.end(); i++) {
|
||||
ptrSPITType = i->second;
|
||||
ptrSPITType->setConfirmed(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
SPITType::SPITType() {
|
||||
initMembers();
|
||||
initMembers();
|
||||
}
|
||||
/*
|
||||
SPITType::SPITType(const SPITType& orig) {
|
||||
m_Confirmed = orig.getConfirmed();
|
||||
m_DefaultDelay = orig.getDefaultDelay();
|
||||
m_DefaultDuration = orig.getDefaultDuration();
|
||||
m_Fixed = orig.getFixed();
|
||||
m_GroupName = orig.getGroupName();
|
||||
m_ID = orig.getID();
|
||||
m_Name = orig.getName();
|
||||
m_ServerProjectIndepended = orig.getProjectIndepended();
|
||||
m_ServerRemote = orig.getServerRemote();
|
||||
m_Confirmed = orig.getConfirmed();
|
||||
m_DefaultDelay = orig.getDefaultDelay();
|
||||
m_DefaultDuration = orig.getDefaultDuration();
|
||||
m_Fixed = orig.getFixed();
|
||||
m_GroupName = orig.getGroupName();
|
||||
m_ID = orig.getID();
|
||||
m_Name = orig.getName();
|
||||
m_ServerProjectIndepended = orig.getProjectIndepended();
|
||||
m_ServerRemote = orig.getServerRemote();
|
||||
}
|
||||
*/
|
||||
SPITType::SPITType(string p_ID, string p_GroupName, string p_Name, bool p_Fixed, bool p_ProjectIndepended,long long p_DefaultDelay, long long p_DefaultDuration) {
|
||||
initMembers();
|
||||
m_ActionAssigned = false;
|
||||
m_Confirmed = false;
|
||||
m_ID = p_ID;
|
||||
m_GroupName = p_GroupName;
|
||||
m_Name = p_Name;
|
||||
m_Fixed = p_Fixed;
|
||||
m_ServerProjectIndepended = p_ProjectIndepended;
|
||||
m_DefaultDelay = p_DefaultDelay;
|
||||
m_DefaultDuration = p_DefaultDuration;
|
||||
SPITType::SPITType(string p_ID, string p_GroupName, string p_Name, bool p_Fixed, bool p_ProjectIndepended, long long p_DefaultDelay, long long p_DefaultDuration) {
|
||||
initMembers();
|
||||
m_ActionAssigned = false;
|
||||
m_Confirmed = false;
|
||||
m_ID = p_ID;
|
||||
m_GroupName = p_GroupName;
|
||||
m_Name = p_Name;
|
||||
m_Fixed = p_Fixed;
|
||||
m_ServerProjectIndepended = p_ProjectIndepended;
|
||||
m_DefaultDelay = p_DefaultDelay;
|
||||
m_DefaultDuration = p_DefaultDuration;
|
||||
}
|
||||
|
||||
SPITType::~SPITType() {
|
||||
}
|
||||
|
||||
void SPITType::initMembers() {
|
||||
m_Confirmed = false;
|
||||
m_DefaultDelay = 0;
|
||||
m_DefaultDuration = 0;
|
||||
m_Fixed = false;
|
||||
m_GroupName = "";
|
||||
m_ID = createGUID();
|
||||
m_Name = "";
|
||||
m_ServerProjectIndepended = false;
|
||||
m_ServerRemote = false;
|
||||
m_Confirmed = false;
|
||||
m_DefaultDelay = 0;
|
||||
m_DefaultDuration = 0;
|
||||
m_Fixed = false;
|
||||
m_GroupName = "";
|
||||
m_ID = createGUID();
|
||||
m_Name = "";
|
||||
m_ServerProjectIndepended = false;
|
||||
m_ServerRemote = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SPITType::setCreatedByClient(bool p_CreatedByClient) {
|
||||
m_CreatedByClient = p_CreatedByClient;
|
||||
m_CreatedByClient = p_CreatedByClient;
|
||||
}
|
||||
|
||||
void SPITType::setID(string p_ID) {
|
||||
m_ID = p_ID;
|
||||
}
|
||||
|
||||
void SPITType::setID(string p_ID) {
|
||||
m_ID = p_ID;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is used by the server and client to tell if the other side has registered the changes.
|
||||
* @param p_Confirmed
|
||||
* @return if m_Confirmed has changed
|
||||
*/
|
||||
bool SPITType::setConfirmed(bool p_Confirmed) {
|
||||
if (m_Confirmed == p_Confirmed) return false;
|
||||
m_Confirmed = p_Confirmed;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SPITType::setGroupName(string p_GroupName) {
|
||||
if (m_GroupName == p_GroupName) return false;
|
||||
m_GroupName = p_GroupName;
|
||||
m_Confirmed = false;
|
||||
return true;
|
||||
}
|
||||
bool SPITType::setName(string p_Name) {
|
||||
if (m_Name == p_Name) return false;
|
||||
m_Name = p_Name;
|
||||
m_Confirmed = false;
|
||||
return true;
|
||||
}
|
||||
bool SPITType::setServerRemote(bool p_BelongstoServer) {
|
||||
if (m_ServerRemote == p_BelongstoServer) return false;
|
||||
m_ServerRemote = p_BelongstoServer;
|
||||
m_Confirmed = false;
|
||||
return true;
|
||||
}
|
||||
bool SPITType::setProjectIndepended(bool p_ProjectIndepended) {
|
||||
if (m_ServerProjectIndepended == p_ProjectIndepended) return false;
|
||||
m_ServerProjectIndepended = p_ProjectIndepended;
|
||||
m_Confirmed = false;
|
||||
return true;
|
||||
}
|
||||
bool SPITType::setFixed(bool p_Fixed) {
|
||||
if (m_Fixed == p_Fixed) return false;
|
||||
m_Fixed = p_Fixed;
|
||||
m_Confirmed = false;
|
||||
return true;
|
||||
}
|
||||
bool SPITType::setDefaultDelay(long long p_Delay) {
|
||||
if (m_DefaultDelay == p_Delay) return false;
|
||||
m_DefaultDelay = p_Delay;
|
||||
m_Confirmed = false;
|
||||
return true;
|
||||
}
|
||||
bool SPITType::setDefaultDuration(long long p_Duration) {
|
||||
if (m_DefaultDuration == p_Duration) return false;
|
||||
m_DefaultDuration = p_Duration;
|
||||
m_Confirmed = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Virtual construct - means ActionAssigned for SPITTypes is is not implemented in SPITProtocol.<br>
|
||||
* This can used to setActionAssigned to all SPITObjects with this SPITType.<br>
|
||||
* This may be used in the case when the same action should be done for every SPITObject with this SPITType associated.<br>
|
||||
* @return true = the m_ActionAssigned has changed.
|
||||
*/
|
||||
bool SPITType::setActionAssigned(bool p_ActionAssigned) {
|
||||
if (m_ActionAssigned == p_ActionAssigned) return false;
|
||||
m_ActionAssigned = p_ActionAssigned;
|
||||
m_Confirmed = false;
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* This is used by the server and client to tell if the other side has registered the changes.
|
||||
* @param p_Confirmed
|
||||
* @return if m_Confirmed has changed
|
||||
*/
|
||||
bool SPITType::setConfirmed(bool p_Confirmed) {
|
||||
if (m_Confirmed == p_Confirmed)
|
||||
return false;
|
||||
m_Confirmed = p_Confirmed;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the content of the SPITType as received from the server
|
||||
* @param p_ReportSPITType
|
||||
* @return true = the SPITType is changed<br>
|
||||
* false = the SPITType is NOT changed, because it is not allowed to change.
|
||||
*/
|
||||
bool SPITType::setMessageOP(SPIT_Message::ReportSPITType* p_ReportSPITType) {
|
||||
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_ReportSPITType->getConfirmed();
|
||||
}
|
||||
if (m_DefaultDelay != p_ReportSPITType->getDelay()) {
|
||||
if (boolChangeAllowed == false) throw new exception();
|
||||
m_DefaultDelay = p_ReportSPITType->getDelay();
|
||||
boolChanged = true;
|
||||
}
|
||||
if (m_DefaultDuration != p_ReportSPITType->getDuration()) {
|
||||
if (boolChangeAllowed == false) throw new exception();
|
||||
m_DefaultDuration = p_ReportSPITType->getDuration();
|
||||
boolChanged = true;
|
||||
}
|
||||
if (m_Fixed != p_ReportSPITType->getFixed()) {
|
||||
if (boolChangeAllowed == false) throw new exception();
|
||||
m_Fixed = p_ReportSPITType->getFixed();
|
||||
boolChanged = true;
|
||||
}
|
||||
if (m_GroupName != p_ReportSPITType->getGroupName()) {
|
||||
if (boolChangeAllowed == false) throw new exception();
|
||||
m_GroupName = p_ReportSPITType->getGroupName();
|
||||
boolChanged = true;
|
||||
}
|
||||
if (m_ID != p_ReportSPITType->getID()) {
|
||||
if (boolChangeAllowed == false) throw new exception();
|
||||
m_ID = p_ReportSPITType->getID();
|
||||
boolChanged = true;
|
||||
}
|
||||
if (m_Name != p_ReportSPITType->getName()) {
|
||||
if (boolChangeAllowed == false) throw new exception();
|
||||
m_Name = p_ReportSPITType->getName();
|
||||
boolChanged = true;
|
||||
}
|
||||
if (m_ServerProjectIndepended != p_ReportSPITType->getServerProjectIndepended()) {
|
||||
if (boolChangeAllowed == false) throw new exception();
|
||||
m_ServerProjectIndepended = p_ReportSPITType->getServerProjectIndepended();
|
||||
boolChanged = true;
|
||||
}
|
||||
if (m_ServerRemote != p_ReportSPITType->getServerRemote()) {
|
||||
if (boolChangeAllowed == false) throw new exception();
|
||||
m_ServerRemote = p_ReportSPITType->getServerRemote();
|
||||
boolChanged = true;
|
||||
}
|
||||
return boolChanged;
|
||||
}
|
||||
|
||||
void SPITType::fillMessageOP(SPIT_Message::ReportSPITType* ptrSMReportSPITType) {
|
||||
ptrSMReportSPITType->setConfirmed(m_Confirmed);
|
||||
ptrSMReportSPITType->setDelay(m_DefaultDelay);
|
||||
ptrSMReportSPITType->setDuration(m_DefaultDuration);
|
||||
ptrSMReportSPITType->setFixed(m_Fixed);
|
||||
ptrSMReportSPITType->setGroupName(m_GroupName);
|
||||
ptrSMReportSPITType->setID(m_ID);
|
||||
ptrSMReportSPITType->setName(m_Name);
|
||||
ptrSMReportSPITType->setServerProjectIndepended(m_ServerProjectIndepended);
|
||||
ptrSMReportSPITType->setServerRemote(m_ServerRemote);
|
||||
}
|
||||
void SPITType::fillMessageOP(SPIT_Message::RemoveSPITType* ptrSMRemoveSPITType) {
|
||||
ptrSMRemoveSPITType->setID(m_ID);
|
||||
}
|
||||
bool SPITType::setGroupName(string p_GroupName) {
|
||||
if (m_GroupName == p_GroupName)
|
||||
return false;
|
||||
m_GroupName = p_GroupName;
|
||||
m_Confirmed = false;
|
||||
return true;
|
||||
}
|
||||
bool SPITType::setName(string p_Name) {
|
||||
if (m_Name == p_Name)
|
||||
return false;
|
||||
m_Name = p_Name;
|
||||
m_Confirmed = false;
|
||||
return true;
|
||||
}
|
||||
bool SPITType::setServerRemote(bool p_BelongstoServer) {
|
||||
if (m_ServerRemote == p_BelongstoServer)
|
||||
return false;
|
||||
m_ServerRemote = p_BelongstoServer;
|
||||
m_Confirmed = false;
|
||||
return true;
|
||||
}
|
||||
bool SPITType::setProjectIndepended(bool p_ProjectIndepended) {
|
||||
if (m_ServerProjectIndepended == p_ProjectIndepended)
|
||||
return false;
|
||||
m_ServerProjectIndepended = p_ProjectIndepended;
|
||||
m_Confirmed = false;
|
||||
return true;
|
||||
}
|
||||
bool SPITType::setFixed(bool p_Fixed) {
|
||||
if (m_Fixed == p_Fixed)
|
||||
return false;
|
||||
m_Fixed = p_Fixed;
|
||||
m_Confirmed = false;
|
||||
return true;
|
||||
}
|
||||
bool SPITType::setDefaultDelay(long long p_Delay) {
|
||||
if (m_DefaultDelay == p_Delay)
|
||||
return false;
|
||||
m_DefaultDelay = p_Delay;
|
||||
m_Confirmed = false;
|
||||
return true;
|
||||
}
|
||||
bool SPITType::setDefaultDuration(long long p_Duration) {
|
||||
if (m_DefaultDuration == p_Duration)
|
||||
return false;
|
||||
m_DefaultDuration = p_Duration;
|
||||
m_Confirmed = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Virtual construct - means ActionAssigned for SPITTypes is is not implemented in SPITProtocol.<br>
|
||||
* This can used to setActionAssigned to all SPITObjects with this SPITType.<br>
|
||||
* This may be used in the case when the same action should be done for every SPITObject with this SPITType associated.<br>
|
||||
* @return true = the m_ActionAssigned has changed.
|
||||
*/
|
||||
bool SPITType::setActionAssigned(bool p_ActionAssigned) {
|
||||
if (m_ActionAssigned == p_ActionAssigned)
|
||||
return false;
|
||||
m_ActionAssigned = p_ActionAssigned;
|
||||
m_Confirmed = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the content of the SPITType as received from the server
|
||||
* @param p_ReportSPITType
|
||||
* @return true = the SPITType is changed<br>
|
||||
* false = the SPITType is NOT changed, because it is not allowed to change.
|
||||
*/
|
||||
bool SPITType::setMessageOP(SPIT_Message::ReportSPITType *p_ReportSPITType) {
|
||||
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_ReportSPITType->getConfirmed();
|
||||
}
|
||||
if (m_DefaultDelay != p_ReportSPITType->getDelay()) {
|
||||
if (boolChangeAllowed == false)
|
||||
throw new exception();
|
||||
m_DefaultDelay = p_ReportSPITType->getDelay();
|
||||
boolChanged = true;
|
||||
}
|
||||
if (m_DefaultDuration != p_ReportSPITType->getDuration()) {
|
||||
if (boolChangeAllowed == false)
|
||||
throw new exception();
|
||||
m_DefaultDuration = p_ReportSPITType->getDuration();
|
||||
boolChanged = true;
|
||||
}
|
||||
if (m_Fixed != p_ReportSPITType->getFixed()) {
|
||||
if (boolChangeAllowed == false)
|
||||
throw new exception();
|
||||
m_Fixed = p_ReportSPITType->getFixed();
|
||||
boolChanged = true;
|
||||
}
|
||||
if (m_GroupName != p_ReportSPITType->getGroupName()) {
|
||||
if (boolChangeAllowed == false)
|
||||
throw new exception();
|
||||
m_GroupName = p_ReportSPITType->getGroupName();
|
||||
boolChanged = true;
|
||||
}
|
||||
if (m_ID != p_ReportSPITType->getID()) {
|
||||
if (boolChangeAllowed == false)
|
||||
throw new exception();
|
||||
m_ID = p_ReportSPITType->getID();
|
||||
boolChanged = true;
|
||||
}
|
||||
if (m_Name != p_ReportSPITType->getName()) {
|
||||
if (boolChangeAllowed == false)
|
||||
throw new exception();
|
||||
m_Name = p_ReportSPITType->getName();
|
||||
boolChanged = true;
|
||||
}
|
||||
if (m_ServerProjectIndepended != p_ReportSPITType->getServerProjectIndepended()) {
|
||||
if (boolChangeAllowed == false)
|
||||
throw new exception();
|
||||
m_ServerProjectIndepended = p_ReportSPITType->getServerProjectIndepended();
|
||||
boolChanged = true;
|
||||
}
|
||||
if (m_ServerRemote != p_ReportSPITType->getServerRemote()) {
|
||||
if (boolChangeAllowed == false)
|
||||
throw new exception();
|
||||
m_ServerRemote = p_ReportSPITType->getServerRemote();
|
||||
boolChanged = true;
|
||||
}
|
||||
return boolChanged;
|
||||
}
|
||||
|
||||
void SPITType::fillMessageOP(SPIT_Message::ReportSPITType *ptrSMReportSPITType) {
|
||||
ptrSMReportSPITType->setConfirmed(m_Confirmed);
|
||||
ptrSMReportSPITType->setDelay(m_DefaultDelay);
|
||||
ptrSMReportSPITType->setDuration(m_DefaultDuration);
|
||||
ptrSMReportSPITType->setFixed(m_Fixed);
|
||||
ptrSMReportSPITType->setGroupName(m_GroupName);
|
||||
ptrSMReportSPITType->setID(m_ID);
|
||||
ptrSMReportSPITType->setName(m_Name);
|
||||
ptrSMReportSPITType->setServerProjectIndepended(m_ServerProjectIndepended);
|
||||
ptrSMReportSPITType->setServerRemote(m_ServerRemote);
|
||||
}
|
||||
void SPITType::fillMessageOP(SPIT_Message::RemoveSPITType *ptrSMRemoveSPITType) {
|
||||
ptrSMRemoveSPITType->setID(m_ID);
|
||||
}
|
||||
|
||||
+1187
-1242
File diff suppressed because it is too large
Load Diff
+1812
-1752
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user