feat: Migrating features from newer implementation
This commit is contained in:
@@ -20,7 +20,7 @@ public:
|
|||||||
* @param p_Addition sometimes server may have additional informations
|
* @param p_Addition sometimes server may have additional informations
|
||||||
* @param p_IsIP4 the server ip is a ip4 address
|
* @param p_IsIP4 the server ip is a ip4 address
|
||||||
*/
|
*/
|
||||||
virtual void eventServerDetected(string p_ID, string p_Name, string p_ComputerName, string p_IP, string p_Port, string p_Addition, string p_CLientIP, bool p_IsIP4) = 0;
|
virtual void eventServerDetected(string p_ID, string p_Name, string p_ComputerName, string p_IP, string p_Port, string p_Addition, string p_ProjectName, string p_ClientIP, bool p_IsIP4) = 0;
|
||||||
/**
|
/**
|
||||||
* If a SPITServer is not more found, this function is called.
|
* If a SPITServer is not more found, this function is called.
|
||||||
* To do so the SAD_Client ServerAutoDetect has to be startet - see SAD_Client::startServerAutoDetect.<br>
|
* To do so the SAD_Client ServerAutoDetect has to be startet - see SAD_Client::startServerAutoDetect.<br>
|
||||||
@@ -32,5 +32,6 @@ public:
|
|||||||
* @param p_Addition sometimes server may have additional informations
|
* @param p_Addition sometimes server may have additional informations
|
||||||
* @param p_IsIP4 the server ip is a ip4 address
|
* @param p_IsIP4 the server ip is a ip4 address
|
||||||
*/
|
*/
|
||||||
virtual void eventServerLost(string p_ID, string p_Name, string p_ComputerName, string p_IP, string p_Port, string p_Addition, string p_CLientIP, bool p_IsIP4) = 0;
|
virtual void eventServerLost(string p_ID, string p_Name, string p_ComputerName, string p_IP, string p_Port, string p_Addition, string p_ProjectName, string p_ClientIP, bool p_IsIP4) = 0;
|
||||||
|
virtual void eventServerChanged(string p_ID, string p_Name, string p_ComputerName, string p_IP, string p_Port, string p_Addition, string p_ProjectName, string p_ClientIP, bool p_IsIP4) = 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -43,12 +43,8 @@ class MyApp {
|
|||||||
// All times are given in frames,
|
// All times are given in frames,
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//----- ServerAutoDetection -----
|
static void onServerEvent(SPIT_Client::ServerEvent event, const SAD_DetectedServer &p_DetectedServer);
|
||||||
static void onServerDetected(const SAD_DetectedServer &p_DetectedServer); // a SPITServer is detected
|
static void onConnectionStatus(string p_ServerID, string p_ServerComputerName, string p_ServerName, int p_ServerStepTime, int p_ConnectionStatus, int p_OldConnectionStatus);
|
||||||
static void onServerLost(const SAD_DetectedServer &p_DetectedServer); // a prior detected SPITServer is lost
|
|
||||||
|
|
||||||
//----- Connection -----
|
|
||||||
void eventConnectionStatus(string p_ServerID, string p_ServerComputerName, string p_ServerName, int p_ServerStepTime, int p_ConnectionStatus, int p_OldConnectionStatus);
|
|
||||||
|
|
||||||
//----- Project -----
|
//----- Project -----
|
||||||
static void onStartProjectTransfer();
|
static void onStartProjectTransfer();
|
||||||
@@ -57,12 +53,14 @@ class MyApp {
|
|||||||
static void onProjectClosed(string p_ProjectID);
|
static void onProjectClosed(string p_ProjectID);
|
||||||
|
|
||||||
//----- SPITType -----
|
//----- SPITType -----
|
||||||
|
static bool onCheckSpitTypeVeto(SPIT_Message::ReportSPITType* p_ReportSPITType);
|
||||||
static void onSpitType(bool p_New, const SPITType &p_SPITType);
|
static void onSpitType(bool p_New, const SPITType &p_SPITType);
|
||||||
static void onSpitTypeRemote(bool p_New, const SPITType &p_SPITType);
|
static void onSpitTypeRemote(bool p_New, const SPITType &p_SPITType);
|
||||||
static void onSpitTypeRemoved(const SPITType &p_SPITType);
|
static void onSpitTypeRemoved(const SPITType &p_SPITType);
|
||||||
static void onSpitTypeRemoteRemoved(const SPITType &p_SPITType);
|
static void onSpitTypeRemoteRemoved(const SPITType &p_SPITType);
|
||||||
|
|
||||||
//----- SPITObject -----
|
//----- SPITObject -----
|
||||||
|
static bool onCheckSpitObjectVeto(SPIT_Message::ReportSPITObject* p_ReportSPITObject);
|
||||||
static void onSpitObject(bool p_New, const SPITType &p_SPITType, const SPITObject &p_SPITObject);
|
static void onSpitObject(bool p_New, const SPITType &p_SPITType, const SPITObject &p_SPITObject);
|
||||||
static void onSpitObjectRemote(bool p_New, const SPITType &p_SPITType, const SPITObject &p_SPITObject);
|
static void onSpitObjectRemote(bool p_New, const SPITType &p_SPITType, const SPITObject &p_SPITObject);
|
||||||
static void onSpitObjectRemoved(const SPITType &p_SPITType, const SPITObject &p_SPITObject);
|
static void onSpitObjectRemoved(const SPITType &p_SPITType, const SPITObject &p_SPITObject);
|
||||||
@@ -70,7 +68,7 @@ class MyApp {
|
|||||||
|
|
||||||
//----- Play SPITObjects -----
|
//----- Play SPITObjects -----
|
||||||
static void onPlay(string p_PlayerID, string p_PlayerName, char p_PlayerType, bool p_PlayerIsRunning, long long p_TimeFrames);
|
static void onPlay(string p_PlayerID, string p_PlayerName, char p_PlayerType, bool p_PlayerIsRunning, long long p_TimeFrames);
|
||||||
static void onPlayObject(string p_PlayerID, bool p_Started, bool p_Stopped, const SPITType &p_SPITType, const SPITObject &p_SPITObject, const SPITPlayer::PlayObject &p_PlayObject);
|
static void onPlaySpitType(string p_PlayerID, string p_SPITTypeID, bool p_PlayerIsRunning, bool p_Started, bool p_Ended, double p_Value);
|
||||||
|
|
||||||
//----- Server changes status of one of his REMOTE SPITObjects -----
|
//----- Server changes status of one of his REMOTE SPITObjects -----
|
||||||
// REMOTE only Server->Client RemoteObject's play status
|
// REMOTE only Server->Client RemoteObject's play status
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ public:
|
|||||||
string m_ClientIP;
|
string m_ClientIP;
|
||||||
string m_Port;
|
string m_Port;
|
||||||
string m_Additions;
|
string m_Additions;
|
||||||
|
string m_ServerProjectName;
|
||||||
bool m_New;
|
bool m_New;
|
||||||
bool m_Changed;
|
bool m_Changed;
|
||||||
bool m_FoundAgain;
|
bool m_FoundAgain;
|
||||||
@@ -45,6 +46,7 @@ public:
|
|||||||
string getPort() const { return m_Port; }
|
string getPort() const { return m_Port; }
|
||||||
string getClientIP() const { return m_ClientIP; }
|
string getClientIP() const { return m_ClientIP; }
|
||||||
string getAdditions() const { return m_Additions; }
|
string getAdditions() const { return m_Additions; }
|
||||||
|
string getProjectName() const {return m_ServerProjectName;}
|
||||||
private:
|
private:
|
||||||
void setID(string p_ID) { m_ID = p_ID; }
|
void setID(string p_ID) { m_ID = p_ID; }
|
||||||
void setName(string p_Name) { m_Name = p_Name; }
|
void setName(string p_Name) { m_Name = p_Name; }
|
||||||
@@ -53,6 +55,7 @@ private:
|
|||||||
void setClientIP(string p_IP) { m_ClientIP = p_IP; }
|
void setClientIP(string p_IP) { m_ClientIP = p_IP; }
|
||||||
void setPort(string p_Port) { m_Port = p_Port; }
|
void setPort(string p_Port) { m_Port = p_Port; }
|
||||||
void setAdditions(string p_Additions) { m_Additions = p_Additions;}
|
void setAdditions(string p_Additions) { m_Additions = p_Additions;}
|
||||||
|
void setProjectName(string p_ServerProjectName);
|
||||||
|
|
||||||
void setIPIsIP4(bool p_IsIP4) { m_IPIsIP4 = p_IsIP4; }
|
void setIPIsIP4(bool p_IsIP4) { m_IPIsIP4 = p_IsIP4; }
|
||||||
bool getNew() const { return m_New; }
|
bool getNew() const { return m_New; }
|
||||||
@@ -67,6 +70,7 @@ private:
|
|||||||
m_IPIsIP4 = false;
|
m_IPIsIP4 = false;
|
||||||
m_Changed = false;
|
m_Changed = false;
|
||||||
m_FoundAgain = false;
|
m_FoundAgain = false;
|
||||||
|
m_New = false;
|
||||||
}
|
}
|
||||||
//SAD_Client m_Thread_Send has paused in the meantime m_ThreadReceive may received messages from servers
|
//SAD_Client m_Thread_Send has paused in the meantime m_ThreadReceive may received messages from servers
|
||||||
void endCycleSAD() { }
|
void endCycleSAD() { }
|
||||||
@@ -81,7 +85,8 @@ public:
|
|||||||
static const int PARAMINDEX_PORT = 5;
|
static const int PARAMINDEX_PORT = 5;
|
||||||
static const int PARAMINDEX_CLIENTIP = 6;
|
static const int PARAMINDEX_CLIENTIP = 6;
|
||||||
static const int PARAMINDEX_ADDITIONS = 7;
|
static const int PARAMINDEX_ADDITIONS = 7;
|
||||||
static const int PARAMINDEX_IP = 8;
|
static const int PARAMINDEX_SERVERPROJECTNAME = 8;
|
||||||
|
static const int PARAMINDEX_IP = 9;
|
||||||
/**
|
/**
|
||||||
* Used by SAD_Client to add a found SPITServer - don't use this manually
|
* 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_IsIP4 true = the server is reached via a IP4 address<br>false = the server is reahed via a IP6 address
|
||||||
|
|||||||
@@ -33,21 +33,26 @@ public:
|
|||||||
static const SPITObject& getSPITObjectRef(string p_ID);
|
static const SPITObject& getSPITObjectRef(string p_ID);
|
||||||
static bool addSPITObject(SPITObject* p_ptrSpitObject);
|
static bool addSPITObject(SPITObject* p_ptrSpitObject);
|
||||||
static bool removeSPITObject(SPITObject* p_ptrSpitObject);
|
static bool removeSPITObject(SPITObject* p_ptrSpitObject);
|
||||||
|
static bool removeSPITObject(string p_SpitObjectID);
|
||||||
static int getSPITObjectCount();
|
static int getSPITObjectCount();
|
||||||
static SPITObject* getSPITObject(int p_Index);
|
static SPITObject* getSPITObject(int p_Index);
|
||||||
static const SPITObject& getSPITObjectRef(int p_Index);
|
static const SPITObject& getSPITObjectRef(int p_Index);
|
||||||
static void clearSPITObjects();
|
static void clearSPITObjects();
|
||||||
|
static void clearUnconfirmedSPITObjects();
|
||||||
static void setConfirmedFalse();
|
static void setConfirmedFalse();
|
||||||
|
|
||||||
static SPITObject* getSPITObjectRemote(string p_ID);
|
static SPITObject* getSPITObjectRemote(string p_ID);
|
||||||
static const SPITObject& getSPITObjectRemoteRef(string p_ID);
|
static const SPITObject& getSPITObjectRemoteRef(string p_ID);
|
||||||
static bool addSPITObjectRemote(SPITObject* p_ptrSpitObject);
|
static bool addSPITObjectRemote(SPITObject* p_ptrSpitObject);
|
||||||
static bool removeSPITObjectRemote(SPITObject* p_ptrSpitObject);
|
static bool removeSPITObjectRemote(SPITObject* p_ptrSpitObject);
|
||||||
|
static bool removeSPITObjectRemote(string p_SpitObjectID);
|
||||||
static int getSPITObjectRemoteCount();
|
static int getSPITObjectRemoteCount();
|
||||||
static SPITObject* getSPITObjectRemote(int p_Index);
|
static SPITObject* getSPITObjectRemote(int p_Index);
|
||||||
static const SPITObject& getSPITObjectRemoteRef(int p_Index);
|
static const SPITObject& getSPITObjectRemoteRef(int p_Index);
|
||||||
static void clearSPITObjectsRemote();
|
static void clearSPITObjectsRemote();
|
||||||
|
|
||||||
|
static void eventProjectClosed();
|
||||||
|
|
||||||
SPITObject();
|
SPITObject();
|
||||||
// SPITObject(const SPITObject& orig);
|
// SPITObject(const SPITObject& orig);
|
||||||
~SPITObject();
|
~SPITObject();
|
||||||
@@ -59,6 +64,7 @@ private:
|
|||||||
string m_Remark;
|
string m_Remark;
|
||||||
bool m_Confirmed;
|
bool m_Confirmed;
|
||||||
bool m_Fixed;
|
bool m_Fixed;
|
||||||
|
bool m_CreatedByClient;
|
||||||
bool m_ServerRemote;
|
bool m_ServerRemote;
|
||||||
bool m_ActionAssigned;
|
bool m_ActionAssigned;
|
||||||
bool m_ActionAssignedType; //Virtual construct
|
bool m_ActionAssignedType; //Virtual construct
|
||||||
@@ -80,90 +86,68 @@ private:
|
|||||||
|
|
||||||
void initMembers();
|
void initMembers();
|
||||||
public:
|
public:
|
||||||
string getID() const {
|
string getID() const { return m_ID; }
|
||||||
return m_ID;
|
string getName() const { return m_Name; }
|
||||||
}
|
string getRemark() const { return m_Remark; }
|
||||||
string getName() const {
|
string getSPITTypeID() const { return m_SPITTypeID; }
|
||||||
return m_Name;
|
string getServerParams() const { return m_ServerParams; }
|
||||||
}
|
|
||||||
string getRemark() const {
|
|
||||||
return m_Remark;
|
|
||||||
}
|
|
||||||
string getSPITTypeID() const {
|
|
||||||
return m_SPITTypeID;
|
|
||||||
}
|
|
||||||
string getServerParams() const {
|
|
||||||
return m_ServerParams;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns if the SPITType triggers an action on the Server or on the client.
|
* Returns if the SPITType triggers an action on the Server or on the client.
|
||||||
* @return false = the action is triggered on the client The client waits for the server to play objects of this SPITType<br>
|
* @return false = the action is triggered on the client The client waits for the server to play objects of this SPITType<br>
|
||||||
* true = the action is triggered on the server. The server waits for the client to play objects of this SPITType.
|
* true = the action is triggered on the server. The server waits for the client to play objects of this SPITType.
|
||||||
*/
|
*/
|
||||||
bool getServerRemote() const {
|
bool getServerRemote() const { return m_ServerRemote; }
|
||||||
return m_ServerRemote;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is used by the server and client to tell if the other side has registered the changes.
|
* This is used by the server and client to tell if the other side has registered the changes.
|
||||||
* @return true = other side has registered the changes.
|
* @return true = other side has registered the changes.
|
||||||
*/
|
*/
|
||||||
bool getConfirmed() const {
|
bool getConfirmed() const { return m_Confirmed; }
|
||||||
return m_Confirmed;
|
bool getFixed() const { return m_Fixed; }
|
||||||
}
|
bool getCreatedByClient() { return m_CreatedByClient; }
|
||||||
bool getFixed() const {
|
|
||||||
return m_Fixed;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* This is a virtual construct - ActionAssignedType is not implemented in the SPITProtocol.<br>
|
* This is a virtual construct - ActionAssignedType is not implemented in the SPITProtocol.<br>
|
||||||
* This is used when an action is associated with a SPITType. <br>
|
* This is used when an action is associated with a SPITType. <br>
|
||||||
* Then this action is done for every SPITObject with the SPITType.
|
* Then this action is done for every SPITObject with the SPITType.
|
||||||
* @return true = an action is assigned for the SPITType.
|
* @return true = an action is assigned for the SPITType.
|
||||||
*/
|
*/
|
||||||
bool getActionAssignedType() const {
|
bool getActionAssignedType() const { return m_ActionAssignedType; }
|
||||||
return m_ActionAssignedType;
|
|
||||||
}
|
|
||||||
/** Returns if this SPITObject has an associated action or not.<br>
|
/** Returns if this SPITObject has an associated action or not.<br>
|
||||||
* @return true = the user has asscociated an action with this SPITObject or <br>
|
* @return true = the user has asscociated an action with this SPITObject or <br>
|
||||||
* the user has asscociated an action with the SPITType of this SPITObject
|
* the user has asscociated an action with the SPITType of this SPITObject
|
||||||
*/
|
*/
|
||||||
bool getActionAssigned() const {
|
bool getActionAssigned() const { return m_ActionAssigned || m_ActionAssignedType; }
|
||||||
return m_ActionAssigned || m_ActionAssignedType;
|
|
||||||
}
|
|
||||||
|
|
||||||
long long getFrameStart() const {
|
long long getFrameStart() const { return m_FrameStart; }
|
||||||
return m_FrameStart;
|
// contains the length of the SPITObject
|
||||||
}
|
long long getFrameLength() const { return m_FrameLength; }
|
||||||
long long getFrameLength() const {
|
long long getFrameFadeInLength() const { return m_FrameFadeInLength; }
|
||||||
return m_FrameLength;
|
long long getFrameFadeOutLength() const { return m_FrameFadeOutLength; }
|
||||||
}
|
char getValueUse() const { return m_ValueUse; }
|
||||||
long long getFrameFadeInLength() const {
|
int getValueFactor() const { return m_ValueFactor; }
|
||||||
return m_FrameFadeInLength;
|
int getTrack() const { return m_Track; }
|
||||||
}
|
|
||||||
long long getFrameFadeOutLength() const {
|
|
||||||
return m_FrameFadeOutLength;
|
|
||||||
}
|
|
||||||
char getValueUse() const {
|
|
||||||
return m_ValueUse;
|
|
||||||
}
|
|
||||||
int getValueFactor() const {
|
|
||||||
return m_ValueFactor;
|
|
||||||
}
|
|
||||||
int getTrack() const {
|
|
||||||
return m_Track;
|
|
||||||
}
|
|
||||||
|
|
||||||
long long getDelay() const {
|
long long getDelay() const { return m_Delay; }
|
||||||
return m_Delay;
|
long long getDuration() const { return m_Duration; }
|
||||||
}
|
|
||||||
long long getDuration() const {
|
|
||||||
return m_Duration;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
bool getProjectIndepended() const {
|
||||||
|
SPITType* ptrSPITType;
|
||||||
|
if (m_ServerRemote == false) {
|
||||||
|
ptrSPITType = SPITType::getSPITType(m_SPITTypeID);
|
||||||
|
if (ptrSPITType == NULL) return true;
|
||||||
|
return ptrSPITType->getProjectIndepended();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ptrSPITType = SPITType::getSPITTypeRemote(m_SPITTypeID);
|
||||||
|
if (ptrSPITType == NULL) return true;
|
||||||
|
return ptrSPITType->getProjectIndepended();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
void setID(string p_ID);
|
void setID(string p_ID);
|
||||||
bool setConfirmed(bool p_Confirmed);
|
bool setConfirmed(bool p_Confirmed);
|
||||||
|
void setCreatedByClient(bool p_CreatedByClient);
|
||||||
bool setName(string p_Name);
|
bool setName(string p_Name);
|
||||||
bool setRemark(string p_Remark);
|
bool setRemark(string p_Remark);
|
||||||
bool setServerParams(string p_ServerParams);
|
bool setServerParams(string p_ServerParams);
|
||||||
@@ -182,7 +166,7 @@ public:
|
|||||||
bool setDelay(long long p_Delay);
|
bool setDelay(long long p_Delay);
|
||||||
bool setDuration(long long p_Duration);
|
bool setDuration(long long p_Duration);
|
||||||
|
|
||||||
void setMessageOP(SPIT_Message::ReportSPITObject* p_ReportSPITObject);
|
bool setMessageOP(SPIT_Message::ReportSPITObject* p_ReportSPITObject);
|
||||||
void fillMessageOP(SPIT_Message::ReportSPITObject* p_ReportSPITObject);
|
void fillMessageOP(SPIT_Message::ReportSPITObject* p_ReportSPITObject);
|
||||||
void fillMessageOP(SPIT_Message::RemoveSPITObject* p_RemoveSPITObject);
|
void fillMessageOP(SPIT_Message::RemoveSPITObject* p_RemoveSPITObject);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -21,102 +21,39 @@ class SPITPlayer {
|
|||||||
|
|
||||||
//----- PlayObject used in PlaySequences: PlaySPITStart, PlaySPITObject,..., PlaySPITEnd ------
|
//----- PlayObject used in PlaySequences: PlaySPITStart, PlaySPITObject,..., PlaySPITEnd ------
|
||||||
public:
|
public:
|
||||||
class PlayObject {
|
class PlaySPITType {
|
||||||
public:
|
public:
|
||||||
PlayObject();
|
PlaySPITType();
|
||||||
PlayObject(SPITPlayer* p_SPITPlayer, string p_SPITObjectID);
|
PlaySPITType(SPITPlayer* p_SPITPlayer, string p_SPITObjectID);
|
||||||
PlayObject(const PlayObject& orig);
|
PlaySPITType(const PlaySPITType& orig);
|
||||||
|
|
||||||
string getSPITObjectID() const {
|
string getSPITTypeID() const {
|
||||||
return m_SPITObjectID;
|
return m_SPITTypeID;
|
||||||
}
|
}
|
||||||
|
|
||||||
void startPlaySequence();
|
void startPlaySequence();
|
||||||
bool getIsNew() const {
|
bool getIsNew() const { return m_IsNew; }
|
||||||
return m_IsNew;
|
void setIsNew(bool p_IsNew) { m_IsNew = p_IsNew; }
|
||||||
}
|
bool getIsPlayed() const { return m_IsPlayed; }
|
||||||
void setIsNew(bool p_IsNew) {
|
void setIsPlayed(bool p_IsFound) { m_IsPlayed = p_IsFound; }
|
||||||
m_IsNew = p_IsNew;
|
string getPlayerID() const { return m_PlayerID; }
|
||||||
}
|
string getPlayerName() const { return m_PlayerName; }
|
||||||
bool getIsPlayed() const {
|
bool getPlayerIsRunning() const { return m_PlayerRuns; }
|
||||||
return m_IsPlayed;
|
void setPlayerIsRunning(bool p_PlayerRuns) { m_PlayerRuns = p_PlayerRuns; }
|
||||||
}
|
void setValue(double p_Value) { m_Value = p_Value; }
|
||||||
void setIsPlayed(bool p_IsFound) {
|
void addValue(double p_Value, double p_ValueFactor) { m_Value += (p_Value * p_ValueFactor); }
|
||||||
m_IsPlayed = p_IsFound;
|
double getValue() const { return m_Value; }
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
string getPlayerID() const {
|
|
||||||
return m_PlayerID;
|
|
||||||
}
|
|
||||||
string getPlayerName() const {
|
|
||||||
return m_PlayerName;
|
|
||||||
}
|
|
||||||
bool getPlayerIsRunning() const {
|
|
||||||
return m_PlayerRuns;
|
|
||||||
}
|
|
||||||
void setPlayerIsRunning(bool p_PlayerRuns) {
|
|
||||||
m_PlayerRuns = p_PlayerRuns;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setValue(int p_Value, bool p_PlayPrePosition) {
|
|
||||||
if (p_PlayPrePosition) m_ValuePrePosition = p_Value;
|
|
||||||
else m_Value = p_Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
int getValue() const {
|
|
||||||
return m_ValuePrePosition + m_Value;
|
|
||||||
}
|
|
||||||
int getValueFadePrePosition() const {
|
|
||||||
return m_ValuePrePosition;
|
|
||||||
}
|
|
||||||
int getValueFade() const {
|
|
||||||
return m_Value;
|
|
||||||
}
|
|
||||||
void setValueFactor(int p_ValueFactor) {
|
|
||||||
m_ValueFactor = p_ValueFactor;
|
|
||||||
}
|
|
||||||
void setValueFlag(char p_ValueFlag) {
|
|
||||||
m_ValueFlag = p_ValueFlag;
|
|
||||||
}
|
|
||||||
int getValueFactor() const {
|
|
||||||
return m_ValueFactor;
|
|
||||||
}
|
|
||||||
char getValueFlag() const {
|
|
||||||
return m_ValueFlag;
|
|
||||||
}
|
|
||||||
void setFrameInside(long long p_FrameInside, bool p_PlayPrePosition) {
|
|
||||||
if (p_PlayPrePosition) m_FrameInsidePrePosition = p_FrameInside;
|
|
||||||
else m_FrameInside = p_FrameInside;
|
|
||||||
}
|
|
||||||
long long getFrameInside() const {
|
|
||||||
return m_FrameInside;
|
|
||||||
}
|
|
||||||
long long getFrameInsidePrePosition() const {
|
|
||||||
return m_FrameInsidePrePosition;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
string m_PlayerID;
|
string m_PlayerID;
|
||||||
string m_PlayerName;
|
string m_PlayerName;
|
||||||
bool m_PlayerRuns;
|
bool m_PlayerRuns;
|
||||||
string m_SPITObjectID;
|
string m_SPITTypeID;
|
||||||
bool m_IsPlayed;
|
bool m_IsPlayed;
|
||||||
bool m_IsNew;
|
bool m_IsNew;
|
||||||
|
double m_Value;
|
||||||
int m_Value;
|
|
||||||
int m_ValuePrePosition;
|
|
||||||
int m_ValueFactor;
|
|
||||||
char m_ValueFlag;
|
|
||||||
long long m_FrameInsidePrePosition;
|
|
||||||
long long m_FrameInside;
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//----- SPITPlayer ------
|
//----- SPITPlayer ------
|
||||||
public:
|
public:
|
||||||
//list the SPITPlayers
|
//list the SPITPlayers
|
||||||
@@ -124,46 +61,33 @@ public:
|
|||||||
static SPITPlayer* getSPITPlayer(string p_PlayerID); //if a player does not exist creates a new one
|
static SPITPlayer* getSPITPlayer(string p_PlayerID); //if a player does not exist creates a new one
|
||||||
static void clearPlayers();
|
static void clearPlayers();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SPITPlayer(string p_PlayerID);
|
SPITPlayer(string p_PlayerID);
|
||||||
virtual ~SPITPlayer();
|
virtual ~SPITPlayer();
|
||||||
|
|
||||||
|
|
||||||
void startPlaySequence(); //called by SPIT_Client::parsePlaySPITStart
|
void startPlaySequence(); //called by SPIT_Client::parsePlaySPITStart
|
||||||
PlayObject* addSPITObject_Playing (string p_SPITObjectID); //called by SPIT_Client::parsePlaySPITStart
|
PlaySPITType* addSPITType_Playing (string p_SPITTypeID); //called by SPIT_Client::parsePlaySPITStart
|
||||||
void endPlaySequence(); //called by SPIT_Client::parsePlaySPITEnd
|
void endPlaySequence(); //called by SPIT_Client::parsePlaySPITEnd
|
||||||
|
|
||||||
string getID() {
|
string getID() {
|
||||||
return m_ID;
|
return m_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
unordered_map<string, PlayObject*>* getPlayObjects();
|
unordered_map<string, PlaySPITType*>* getPlaySPITTypes();
|
||||||
|
|
||||||
void setIsRunning(bool p_IsRunning);
|
void setIsRunning(bool p_IsRunning);
|
||||||
bool getIsRunning() {
|
bool getIsRunning() { return m_IsRunning; }
|
||||||
return m_IsRunning;
|
|
||||||
}
|
|
||||||
void setName(string p_Name);
|
void setName(string p_Name);
|
||||||
string getName() {
|
string getName() { return m_Name; }
|
||||||
return m_Name;
|
|
||||||
}
|
|
||||||
void setType(char p_Type);
|
void setType(char p_Type);
|
||||||
char getType() {
|
char getType() { return m_Type; }
|
||||||
return m_Type;
|
|
||||||
}
|
|
||||||
void setTime(long long p_Frames);
|
void setTime(long long p_Frames);
|
||||||
long long getTime() {
|
long long getTime() { return m_TimeFrames; }
|
||||||
return m_TimeFrames;
|
|
||||||
}
|
|
||||||
|
|
||||||
PlayObject* getPlayObject(string p_SPITObjectID);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
string m_ID;
|
string m_ID;
|
||||||
string m_Name;
|
string m_Name;
|
||||||
char m_Type;
|
char m_Type;
|
||||||
unordered_map<string, PlayObject*> m_PlayObjects;
|
unordered_map<string, PlaySPITType*> m_PlaySPITTypes;
|
||||||
bool m_IsRunning;
|
bool m_IsRunning;
|
||||||
long long m_TimeFrames;
|
long long m_TimeFrames;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ public:
|
|||||||
|
|
||||||
int receiveMessage(int p_InetFamily, char* p_Buffer, int p_BufferLength, string* p_ServerIP);
|
int receiveMessage(int p_InetFamily, char* p_Buffer, int p_BufferLength, string* p_ServerIP);
|
||||||
int setBroadcast(bool p_Broadcast);
|
int setBroadcast(bool p_Broadcast);
|
||||||
int bindSocket(string p_ClientIP, string p_ClientPort);
|
int bindSocket(string p_ServerIP, string p_ClientIP, string p_ClientPort);
|
||||||
|
|
||||||
// * Internal usage - don't use this manually
|
// * Internal usage - don't use this manually
|
||||||
// * Use sendMessage instead
|
// * Use sendMessage instead
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ public:
|
|||||||
static const SPITType& getSPITTypeRemoteRef(int p_Index);
|
static const SPITType& getSPITTypeRemoteRef(int p_Index);
|
||||||
static void clearSPITTypesRemote();
|
static void clearSPITTypesRemote();
|
||||||
|
|
||||||
|
static void eventProjectClosed();
|
||||||
|
|
||||||
SPITType();
|
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);
|
SPITType(string p_ID, string p_GroupName, string p_Name, bool p_Fixed, bool p_ProjectIndepended,long long p_DefaultDelay, long long p_DefaultDuration);
|
||||||
@@ -138,6 +139,4 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* SPITTYPE_H */
|
#endif /* SPITTYPE_H */
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#include "SPITObject.h"
|
#include "SPITObject.h"
|
||||||
#include "SPITPlayer.h"
|
#include "SPITPlayer.h"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@@ -30,9 +31,15 @@ public:
|
|||||||
/** Maximal length of a SPITMessage*/
|
/** Maximal length of a SPITMessage*/
|
||||||
static const int MAXSPITMESSAGEBYTECOUNT = 512;
|
static const int MAXSPITMESSAGEBYTECOUNT = 512;
|
||||||
|
|
||||||
|
enum ServerEvent {
|
||||||
|
Detect,
|
||||||
|
Lost,
|
||||||
|
Changed,
|
||||||
|
};
|
||||||
|
|
||||||
struct Callbacks {
|
struct Callbacks {
|
||||||
void(*onServerDetect)(const SAD_DetectedServer &p_DetectedServer);
|
void(*onServerEvent)(ServerEvent event, const SAD_DetectedServer &p_DetectedServer);
|
||||||
void(*onServerLost)(const SAD_DetectedServer &p_DetectedServer);
|
void(*onConnectionStatus)(string p_ServerID, string p_ServerComputerName, string p_ServerName, int p_ServerStepTime, int p_ConnectionStatus, int p_OldConnectionStatus);
|
||||||
void(*onStartProjectTransfer)();
|
void(*onStartProjectTransfer)();
|
||||||
void(*onEndProjectTransfer)();
|
void(*onEndProjectTransfer)();
|
||||||
void(*onProjectClosed)(string);
|
void(*onProjectClosed)(string);
|
||||||
@@ -46,8 +53,10 @@ public:
|
|||||||
void(*onSpitObjectRemoved)(const SPITType &p_SPITType, const SPITObject &p_SPITObject);
|
void(*onSpitObjectRemoved)(const SPITType &p_SPITType, const SPITObject &p_SPITObject);
|
||||||
void(*onSpitObjectRemoteRemoved)(const SPITType &p_SPITType, const SPITObject &p_SPITObject);
|
void(*onSpitObjectRemoteRemoved)(const SPITType &p_SPITType, const SPITObject &p_SPITObject);
|
||||||
void(*onPlay)(string p_PlayerID, string p_PlayerName, char p_PlayerType, bool p_PlayerIsRunning, long long p_TimeFrames);
|
void(*onPlay)(string p_PlayerID, string p_PlayerName, char p_PlayerType, bool p_PlayerIsRunning, long long p_TimeFrames);
|
||||||
void(*onPlayObject)(string p_PlayerID, bool p_Started, bool p_Stopped, const SPITType &p_SPITType, const SPITObject &p_SPITObject, const SPITPlayer::PlayObject &p_PlayObject);
|
void(*onPlaySpitType)(string p_PlayerID, string p_SPITTypeID, bool p_PlayerIsRunning, bool p_Started, bool p_Ended, double p_Value);
|
||||||
void(*onPlayRemoteObjectStatus)(const SPITType &p_SPITType, const SPITObject &p_SPITObject, long long p_FrameInsideObject, int p_Value);
|
void(*onPlayRemoteObjectStatus)(const SPITType &p_SPITType, const SPITObject &p_SPITObject, long long p_FrameInsideObject, int p_Value);
|
||||||
|
bool(*onCheckSpitTypeVeto)(SPIT_Message::ReportSPITType* p_ReportSPITType);
|
||||||
|
bool(*onCheckSpitObjectVeto)(SPIT_Message::ReportSPITObject* p_ReportSPITObject);
|
||||||
};
|
};
|
||||||
|
|
||||||
//----- Connection Status -----
|
//----- Connection Status -----
|
||||||
@@ -86,6 +95,7 @@ public:
|
|||||||
public:
|
public:
|
||||||
SPIT_Client(string name, string projName, Callbacks calls);
|
SPIT_Client(string name, string projName, Callbacks calls);
|
||||||
virtual ~SPIT_Client();
|
virtual ~SPIT_Client();
|
||||||
|
static int s_MAX_OVERTAKING_SPIT_MESSAGES;
|
||||||
private:
|
private:
|
||||||
Callbacks mCallbacks;
|
Callbacks mCallbacks;
|
||||||
|
|
||||||
@@ -99,15 +109,18 @@ private:
|
|||||||
string m_ProjName;
|
string m_ProjName;
|
||||||
string m_ComputerName;
|
string m_ComputerName;
|
||||||
|
|
||||||
|
string m_ClientProjectName;
|
||||||
|
|
||||||
|
unsigned char m_MessageNumber_Send;
|
||||||
|
int m_MessageNumber_Received;
|
||||||
|
vector<SPIT_Message*> m_OvertakingSPIT_Messages;
|
||||||
|
|
||||||
//Server's info filled by parseConnectAnswer
|
//Server's info filled by parseConnectAnswer
|
||||||
string m_ServerID{};
|
string m_ServerID{};
|
||||||
string m_ServerName{};
|
string m_ServerName{};
|
||||||
string m_ServerComputerName{};
|
string m_ServerComputerName{};
|
||||||
int m_ServerStepTime{-1};
|
int m_ServerStepTime{-1};
|
||||||
|
|
||||||
unsigned char m_MessageNumber_Send;
|
|
||||||
int m_MessageNumber_Received;
|
|
||||||
|
|
||||||
//--- Server Project ---
|
//--- Server Project ---
|
||||||
string m_ServerProjectID;
|
string m_ServerProjectID;
|
||||||
string m_ServerProjectName;
|
string m_ServerProjectName;
|
||||||
@@ -115,25 +128,28 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
/** The ID of the client.<br>Every client instance should set an unique id*/
|
/** The ID of the client.<br>Every client instance should set an unique id*/
|
||||||
string getID();
|
string getID() { return m_ID; }
|
||||||
/** The name of the client, should be set by the user app*/
|
/** The name of the client, should be set by the user app*/
|
||||||
string getName();
|
string getName() { return m_Name; }
|
||||||
//----- Computer Params -----
|
//----- Computer Params -----
|
||||||
/** The name of the client's host computer*/
|
/** The name of the client's host computer*/
|
||||||
string getComputerName();
|
string getComputerName() { return m_ComputerName; }
|
||||||
|
void setClientProjectName(string p_ClientProjectName) { m_ClientProjectName = p_ClientProjectName; }
|
||||||
|
string getClientProjectName() { return m_ClientProjectName; }
|
||||||
|
|
||||||
//connected Server Infos
|
//connected Server Infos
|
||||||
/** The ID of the connected SPITServer*/
|
/** The ID of the connected SPITServer*/
|
||||||
string getServerID();
|
string getServerID() { return m_ServerID; }
|
||||||
/** The host computername of the connected SPITServer*/
|
/** The host computername of the connected SPITServer*/
|
||||||
string getServerComputerName();
|
string getServerComputerName() { return m_ServerComputerName; }
|
||||||
/** The name of the connected SPITServer*/
|
/** The name of the connected SPITServer*/
|
||||||
string getServerName();
|
string getServerName() { return m_ServerName; }
|
||||||
|
|
||||||
/** Expected Refreah Rate of the connectd SPITServer.<br>
|
/** Expected Refreah Rate of the connectd SPITServer.<br>
|
||||||
* When the server plays objects, it will do so at discrete time steps.<br>
|
* When the server plays objects, it will do so at discrete time steps.<br>
|
||||||
* Play events will take place in these time steps..
|
* Play events will take place in these time steps..
|
||||||
*/
|
*/
|
||||||
int getServerStepTime();
|
int getServerStepTime() { return m_ServerStepTime; }
|
||||||
|
|
||||||
/** Should be called when the client wants to close his project*/
|
/** Should be called when the client wants to close his project*/
|
||||||
void clientProjectClose();
|
void clientProjectClose();
|
||||||
@@ -155,11 +171,11 @@ private:
|
|||||||
bool startReceiveSPITMessages();
|
bool startReceiveSPITMessages();
|
||||||
void stopReceiveSPITMessages();
|
void stopReceiveSPITMessages();
|
||||||
static void receiveSPITMessage(SPIT_Client& rM);
|
static void receiveSPITMessage(SPIT_Client& rM);
|
||||||
int sendSPITMessage(SPIT_Message::OPPart& p_SPITMessageOPPart);
|
|
||||||
void fillHeader(SPIT_Message::Header* p_Header);
|
|
||||||
|
|
||||||
// Reconnect to the server when connection is lost see eventConnectionStatus and eventServerDetected
|
// Reconnect to the server when connection is lost see eventConnectionStatus and eventServerDetected
|
||||||
bool _doReconnect{}; // true = on eventServerDetected connect to the server identified by m_ServerID
|
bool _doReconnect{}; // true = on eventServerDetected connect to the server identified by m_ServerID
|
||||||
|
public:
|
||||||
|
void fillHeader(SPIT_Message::Header* p_Header);
|
||||||
|
int sendSPITMessage(SPIT_Message::OPPart& p_SPITMessageOPPart);
|
||||||
|
|
||||||
//--------------- ServerAutoDetection SAD ---------------
|
//--------------- ServerAutoDetection SAD ---------------
|
||||||
public:
|
public:
|
||||||
@@ -168,10 +184,10 @@ public:
|
|||||||
/** Stops the autodetection of SPITServers in the local network*/
|
/** Stops the autodetection of SPITServers in the local network*/
|
||||||
void stopServerAutoDetect();
|
void stopServerAutoDetect();
|
||||||
/** Called every time a new SPITServer is detetced in the local network */
|
/** Called every time a new SPITServer is detetced in the local network */
|
||||||
void eventServerDetected(string p_ID, string p_Name, string p_ComputerName, string p_IP, string p_Port, string p_Addition, string p_ClientIP, bool p_IsIP4);
|
void eventServerDetected(string p_ID, string p_Name, string p_ComputerName, string p_IP, string p_Port, string p_Addition, string p_ProjectName, string p_ClientIP, bool p_IsIP4);
|
||||||
/** Called every time a prior detected SPITServer is is no longer found.*/
|
/** Called every time a prior detected SPITServer is is no longer found.*/
|
||||||
void eventServerLost(string p_ID, string p_Name, string p_ComputerName, string p_IP, string p_Port, string p_Addition, string p_ClientIP, bool p_IsIP4);
|
void eventServerLost(string p_ID, string p_Name, string p_ComputerName, string p_IP, string p_Port, string p_Addition, string p_ProjectName, string p_ClientIP, bool p_IsIP4);
|
||||||
|
void eventServerChanged(string p_ID, string p_Name, string p_ComputerName, string p_IP, string p_Port, string p_Addition, string p_ProjectName, string p_ClientIP, bool p_IsIP4);
|
||||||
|
|
||||||
//--------------- Connection ---------------
|
//--------------- Connection ---------------
|
||||||
public:
|
public:
|
||||||
@@ -194,7 +210,10 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void disconnectInternal(int p_Cause);
|
void disconnectInternal(int p_Cause);
|
||||||
|
void resetMessageNumberReceived();
|
||||||
void parseSPIT_Message(unique_ptr<SPIT_Message> p_SPITMessage);
|
void parseSPIT_Message(unique_ptr<SPIT_Message> p_SPITMessage);
|
||||||
|
void checkParseSPIT_Message(unique_ptr<SPIT_Message> p_SPITMessage);
|
||||||
|
void addOvertakingSPIT_Message(SPIT_Message* p_SPIT_Message);
|
||||||
void parseConnectAnswer(SPIT_Message::ConnectAnswer* p_ConnectAnswer);
|
void parseConnectAnswer(SPIT_Message::ConnectAnswer* p_ConnectAnswer);
|
||||||
void parseDisconnect(SPIT_Message::Disconnect* p_Disconnect);
|
void parseDisconnect(SPIT_Message::Disconnect* p_Disconnect);
|
||||||
void parseWatchdog(SPIT_Message::Watchdog* p_Watchdog);
|
void parseWatchdog(SPIT_Message::Watchdog* p_Watchdog);
|
||||||
@@ -220,7 +239,8 @@ private:
|
|||||||
void parseRequestProjectTransfer(SPIT_Message::RequestProjectTransfer* p_RequestProjectTransfer);
|
void parseRequestProjectTransfer(SPIT_Message::RequestProjectTransfer* p_RequestProjectTransfer);
|
||||||
void parseStartProjectTransfer(SPIT_Message::StartProjectTransfer* p_StartProjectTransfer);
|
void parseStartProjectTransfer(SPIT_Message::StartProjectTransfer* p_StartProjectTransfer);
|
||||||
void parseEndProjectTransfer(SPIT_Message::EndProjectTransfer* p_EndProjectTransfer);
|
void parseEndProjectTransfer(SPIT_Message::EndProjectTransfer* p_EndProjectTransfer);
|
||||||
|
public:
|
||||||
|
static void sendProject(SPIT_Client* p_PtrSPIT_Client);
|
||||||
|
|
||||||
// --------------- SPIT Types ---------------
|
// --------------- SPIT Types ---------------
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ MyApp::MyApp() :
|
|||||||
_SpitClient (
|
_SpitClient (
|
||||||
s_ClientName, s_ProjectName,
|
s_ClientName, s_ProjectName,
|
||||||
{
|
{
|
||||||
.onServerDetect = onServerDetected,
|
.onServerEvent = onServerEvent,
|
||||||
.onServerLost = onServerLost,
|
.onConnectionStatus = onConnectionStatus,
|
||||||
.onStartProjectTransfer = onStartProjectTransfer,
|
.onStartProjectTransfer = onStartProjectTransfer,
|
||||||
.onEndProjectTransfer = onEndProjectTransfer,
|
.onEndProjectTransfer = onEndProjectTransfer,
|
||||||
.onProjectClosed = onProjectClosed,
|
.onProjectClosed = onProjectClosed,
|
||||||
@@ -27,10 +27,11 @@ MyApp::MyApp() :
|
|||||||
.onSpitObjectRemoved = onSpitObjectRemoved,
|
.onSpitObjectRemoved = onSpitObjectRemoved,
|
||||||
.onSpitObjectRemoteRemoved = onSpitObjectRemoteRemoved,
|
.onSpitObjectRemoteRemoved = onSpitObjectRemoteRemoved,
|
||||||
.onPlay = onPlay,
|
.onPlay = onPlay,
|
||||||
.onPlayObject = onPlayObject,
|
.onPlaySpitType = onPlaySpitType,
|
||||||
.onPlayRemoteObjectStatus = onPlayRemoteObjectStatus,
|
.onPlayRemoteObjectStatus = onPlayRemoteObjectStatus,
|
||||||
|
.onCheckSpitTypeVeto = onCheckSpitTypeVeto,
|
||||||
|
.onCheckSpitObjectVeto = onCheckSpitObjectVeto,
|
||||||
}) {
|
}) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
string MyApp::m_ServerProjectID{};
|
string MyApp::m_ServerProjectID{};
|
||||||
@@ -38,10 +39,8 @@ string MyApp::m_ServerProjectName{};
|
|||||||
int MyApp::m_ServerFramesPerSecond{44100}; // set when the server reports his project, see eventProjectReport
|
int MyApp::m_ServerFramesPerSecond{44100}; // set when the server reports his project, see eventProjectReport
|
||||||
|
|
||||||
void MyApp::init() {
|
void MyApp::init() {
|
||||||
SPITType *ptrSPITType1Fix;
|
SPITType *ptrSPITType1Fix = _SpitClient.createSPITTypeFixed("MySPITAPP_Action1ID", "ActionGroupName", "Action1Name", 0, 0);
|
||||||
ptrSPITType1Fix = _SpitClient.createSPITTypeFixed("MySPITAPP_Action1ID", "ActionGroupName", "Action1Name", 0, 0);
|
SPITType *ptrSPITType2Fix = _SpitClient.createSPITTypeFixed("MySPITAPP_Action2ID", "ActionGroupName", "Action2Name", 0, 0);
|
||||||
SPITType *ptrSPITType2Fix;
|
|
||||||
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,
|
// When an action exist which should be done whenever a SPITObject with this SPITType is played,
|
||||||
// then you should 'setAssignedActionType' to true
|
// then you should 'setAssignedActionType' to true
|
||||||
@@ -51,24 +50,37 @@ void MyApp::init() {
|
|||||||
_SpitClient.startServerAutoDetect();
|
_SpitClient.startServerAutoDetect();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyApp::onServerDetected(const SAD_DetectedServer &p_DetectedServer) {
|
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, "SERVER DETECTED");
|
||||||
ESP_LOGD(TAG, " Name: %s", p_DetectedServer.getName().data());
|
ESP_LOGI(TAG, " Name: %s", p_DetectedServer.getName().data());
|
||||||
ESP_LOGD(TAG, " ID: %s", p_DetectedServer.getID().data());
|
ESP_LOGI(TAG, " ID: %s", p_DetectedServer.getID().data());
|
||||||
ESP_LOGD(TAG, " Computer: %s", p_DetectedServer.getComputerName().data());
|
ESP_LOGI(TAG, " Computer: %s", p_DetectedServer.getComputerName().data());
|
||||||
ESP_LOGD(TAG, " IP: %s", p_DetectedServer.getIP().data());
|
ESP_LOGI(TAG, " IP: %s", p_DetectedServer.getIP().data());
|
||||||
ESP_LOGD(TAG, " Port: %s", p_DetectedServer.getPort().data());
|
ESP_LOGI(TAG, " Port: %s", p_DetectedServer.getPort().data());
|
||||||
ESP_LOGD(TAG, " Addition: %s", p_DetectedServer.getAdditions().data());
|
ESP_LOGI(TAG, " Addition: %s", p_DetectedServer.getAdditions().data());
|
||||||
ESP_LOGD(TAG, " ClientIP: %s", p_DetectedServer.getClientIP().data());
|
ESP_LOGI(TAG, " ClientIP: %s", p_DetectedServer.getClientIP().data());
|
||||||
}
|
break;
|
||||||
void MyApp::onServerLost(const SAD_DetectedServer &p_DetectedServer) {
|
case SPIT_Client::ServerEvent::Lost:
|
||||||
ESP_LOGW(TAG, "Server lost Name: %s IP: %s", p_DetectedServer.getName().data(), p_DetectedServer.getIP().data());
|
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 ----------
|
//---------- Connecting event ----------
|
||||||
|
|
||||||
void MyApp::eventConnectionStatus(string p_ServerID, string p_ServerComputerName, string p_ServerName, int p_ServerStepTime, int p_ConnectionStatus, int p_OldConnectionStatus) {
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------
|
//-----------------------------------------------------------
|
||||||
@@ -117,6 +129,41 @@ void MyApp::onEndProjectTransfer() {
|
|||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
//--------- SPITType events ----------
|
//--------- 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.
|
* 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.
|
* May also occur when the server confirms a SPITType created or changed by the client.
|
||||||
@@ -336,45 +383,29 @@ void MyApp::onPlay(string p_PlayerID, string p_PlayerName, char p_PlayerType, bo
|
|||||||
* whether the player is running or not
|
* 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, ..
|
* the actual value of the SPITObject (in liveSHOWsoftware objects ma faded in or out or the main value is decreased, ..
|
||||||
*/
|
*/
|
||||||
void MyApp::onPlayObject(string p_PlayerID, bool p_Started, bool p_Ended, const SPITType &p_SPITType, const SPITObject &p_SPITObject, const SPITPlayer::PlayObject &p_PlayObject) {
|
void MyApp::onPlaySpitType(string p_PlayerID, string p_SPITTypeID, bool p_PlayerIsRunning, bool p_Started, bool p_Ended, double p_Value) {
|
||||||
// p_PlayObject.getValue() contain the value in ppm (we can calculate value between 0.0 and 1.0)
|
// double doubleValue = ((double)p_PlayObject.getValue() / 1000000) * ((double)p_PlayObject.getValueFactor() / 1000000);
|
||||||
// p_SPITObject.getValueFactor() or redundand p_PlayObject.getValueFactor()
|
|
||||||
// contains the factor the above value should be multiplicated to get the end value.
|
|
||||||
double doubleValue = ((double)p_PlayObject.getValue() / 1000000) * ((double)p_PlayObject.getValueFactor() / 1000000);
|
|
||||||
|
|
||||||
// Other factors besides value may be of interest
|
ESP_LOGD(TAG, "eventPlayObject Player: %s is running: %d Object Started: %d Stopped: %d", p_PlayerID.data(), p_PlayerIsRunning, p_Started, p_Ended);
|
||||||
// p_PlayObject.getFrameInside() contains the play position inside the SPITObject
|
// ESP_LOGD(TAG, " SPITType: %s SPITObject: %s Position: %lld Value: %f\n", p_SPITTypeID.data(), p_SPITObject.getName().data(), p_PlayObject.getFrameInside(), doubleValue);
|
||||||
// p_SPITObject.getFrameLength() contains the length of the SPITObject
|
ESP_LOGD(TAG, " SPITType: %s Value: %f\n", p_SPITTypeID.data(), p_Value);
|
||||||
//-> we can calculate the position 0.0 to 1.0 where the Object is played
|
|
||||||
|
|
||||||
// in liveSHOWsoftware the player may play two different position in the SPITObject to mix them down, e.g. a SceneBridge is played
|
if (p_SPITTypeID == "MySPITAPP_Action1ID") { // do Action 1
|
||||||
// We can get the second (pre played) position: p_PlayObject.getFrameInsidePrePosition();
|
|
||||||
|
|
||||||
ESP_LOGD(TAG, "eventPlayObject Player: %s is running: %d Object Started: %d Stopped: %d", p_PlayObject.getPlayerName().data(), p_PlayObject.getPlayerIsRunning(), p_Started, p_Ended);
|
|
||||||
ESP_LOGD(TAG, " SPITType: %s SPITObject: %s Position: %lld Value: %f\n", p_SPITType.getName().data(), p_SPITObject.getName().data(), p_PlayObject.getFrameInside(), doubleValue);
|
|
||||||
|
|
||||||
// check for your actions to do
|
|
||||||
|
|
||||||
// In our little excample decribed in loadClientProject:
|
|
||||||
// We want to react to SPIT types, no matter which SPIT object is currently being played.
|
|
||||||
//-> check not the SPITObject itself but the associated SPITType
|
|
||||||
bool boolPLayerIsRunning = p_PlayObject.getPlayerIsRunning();
|
|
||||||
if (p_SPITType.getID() == "MySPITAPP_Action1ID") { // do Action 1
|
|
||||||
// we can get some information about the play status
|
// we can get some information about the play status
|
||||||
if (p_Started == true) {
|
if (p_Started == true) {
|
||||||
ESP_LOGI(TAG, "MyApp AKTION 1 started Value: %f and running: %d", doubleValue, boolPLayerIsRunning);
|
ESP_LOGI(TAG, "MyApp AKTION 1 started Value: %f and running: %d", p_Value, p_PlayerIsRunning);
|
||||||
} else if (p_Ended == true) {
|
} else if (p_Ended == true) {
|
||||||
ESP_LOGI(TAG, "MyApp AKTION 1 ended"); // p_PlayObject.getFrameInside() is -1
|
ESP_LOGI(TAG, "MyApp AKTION 1 ended"); // p_PlayObject.getFrameInside() is -1
|
||||||
} else {
|
} else {
|
||||||
ESP_LOGD(TAG, "MyApp AKTION 1 is played Value: %f and running: %d", doubleValue, boolPLayerIsRunning);
|
ESP_LOGD(TAG, "MyApp AKTION 1 is played Value: %f and running: %d", p_Value, p_PlayerIsRunning);
|
||||||
}
|
}
|
||||||
} else if (p_SPITType.getID() == "MySPITAPP_Action2ID") { // do Action 2
|
} else if (p_SPITTypeID == "MySPITAPP_Action2ID") { // do Action 2
|
||||||
if (p_Started == true) {
|
if (p_Started == true) {
|
||||||
ESP_LOGI(TAG, "AKTION 2 started Value: %f and running: %d", doubleValue, boolPLayerIsRunning);
|
ESP_LOGI(TAG, "AKTION 2 started Value: %f and running: %d", p_Value, p_PlayerIsRunning);
|
||||||
} else if (p_Ended == true) {
|
} else if (p_Ended == true) {
|
||||||
ESP_LOGI(TAG, "AKTION 2 ended"); // p_PlayObject.getFrameInside() is -1
|
ESP_LOGI(TAG, "AKTION 2 ended"); // p_PlayObject.getFrameInside() is -1
|
||||||
} else {
|
} else {
|
||||||
ESP_LOGD(TAG, "AKTION 2 is played Value: %f and running: %d", doubleValue, boolPLayerIsRunning);
|
ESP_LOGD(TAG, "AKTION 2 is played Value: %f and running: %d", p_Value, p_PlayerIsRunning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,14 +32,24 @@ SAD_DetectedServer::SAD_DetectedServer() {
|
|||||||
m_IPIsIP4 = false;
|
m_IPIsIP4 = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
void SAD_DetectedServer::cycleStart() {
|
void SAD_DetectedServer::cycleStart() {
|
||||||
for (auto i = s_DetectedServers.begin(); i != s_DetectedServers.end(); i++) {
|
for (auto i = s_DetectedServers.begin(); i != s_DetectedServers.end(); i++) {
|
||||||
i->second->startCycleSAD();
|
i->second->startCycleSAD();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void SAD_DetectedServer::cycleEnd(I_SAD_Client& sADClientInterface) {
|
void SAD_DetectedServer::cycleEnd(I_SAD_Client& sadClient) {
|
||||||
list<SAD_DetectedServer*> o_LostServers;
|
list<SAD_DetectedServer*> o_LostServers;
|
||||||
list<SAD_DetectedServer*> o_NewServers;
|
list<SAD_DetectedServer*> o_NewServers;
|
||||||
|
list<SAD_DetectedServer*> o_ChangedServers;
|
||||||
SAD_DetectedServer* ptrDetectedServer;
|
SAD_DetectedServer* ptrDetectedServer;
|
||||||
{
|
{
|
||||||
for (auto i = s_DetectedServers.begin(); i != s_DetectedServers.end(); i++) {
|
for (auto i = s_DetectedServers.begin(); i != s_DetectedServers.end(); i++) {
|
||||||
@@ -54,6 +64,7 @@ void SAD_DetectedServer::cycleEnd(I_SAD_Client& sADClientInterface) {
|
|||||||
ptrDetectedServer->endCycleSAD();
|
ptrDetectedServer->endCycleSAD();
|
||||||
}
|
}
|
||||||
else if (ptrDetectedServer->getChanged()) {
|
else if (ptrDetectedServer->getChanged()) {
|
||||||
|
o_ChangedServers.push_back(ptrDetectedServer);
|
||||||
ptrDetectedServer->endCycleSAD();
|
ptrDetectedServer->endCycleSAD();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -64,8 +75,8 @@ void SAD_DetectedServer::cycleEnd(I_SAD_Client& sADClientInterface) {
|
|||||||
//Notify client interface about lost servers
|
//Notify client interface about lost servers
|
||||||
for (auto i = o_LostServers.begin(); i != o_LostServers.end(); i++) {
|
for (auto i = o_LostServers.begin(); i != o_LostServers.end(); i++) {
|
||||||
ptrDetectedServer = *i;
|
ptrDetectedServer = *i;
|
||||||
sADClientInterface.eventServerLost(ptrDetectedServer->getID(), ptrDetectedServer->getName(),
|
sadClient.eventServerLost(ptrDetectedServer->getID(), ptrDetectedServer->getName(),
|
||||||
ptrDetectedServer->getComputerName(), ptrDetectedServer->getIP(), ptrDetectedServer->getPort(), ptrDetectedServer->getAdditions(),
|
ptrDetectedServer->getComputerName(), ptrDetectedServer->getIP(), ptrDetectedServer->getPort(), ptrDetectedServer->getAdditions(),ptrDetectedServer->getProjectName(),
|
||||||
ptrDetectedServer->getClientIP(),
|
ptrDetectedServer->getClientIP(),
|
||||||
ptrDetectedServer->getIpIsIP4());
|
ptrDetectedServer->getIpIsIP4());
|
||||||
}
|
}
|
||||||
@@ -78,13 +89,20 @@ void SAD_DetectedServer::cycleEnd(I_SAD_Client& sADClientInterface) {
|
|||||||
|
|
||||||
for (auto i = o_NewServers.begin(); i != o_NewServers.end(); i++) {
|
for (auto i = o_NewServers.begin(); i != o_NewServers.end(); i++) {
|
||||||
ptrDetectedServer = *i;
|
ptrDetectedServer = *i;
|
||||||
sADClientInterface.eventServerDetected(ptrDetectedServer->getID(), ptrDetectedServer->getName(),
|
sadClient.eventServerDetected(ptrDetectedServer->getID(), ptrDetectedServer->getName(),
|
||||||
ptrDetectedServer->getComputerName(), ptrDetectedServer->getIP(), ptrDetectedServer->getPort(), ptrDetectedServer->getAdditions(),
|
ptrDetectedServer->getComputerName(), ptrDetectedServer->getIP(), ptrDetectedServer->getPort(), ptrDetectedServer->getAdditions(),ptrDetectedServer->getProjectName(),
|
||||||
ptrDetectedServer->getClientIP(),
|
ptrDetectedServer->getClientIP(),
|
||||||
ptrDetectedServer->getIpIsIP4());
|
ptrDetectedServer->getIpIsIP4());
|
||||||
}
|
}
|
||||||
o_NewServers.clear();
|
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();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Used by SAD_Client to add a found SPITServer - don't use this manually
|
* Used by SAD_Client to add a found SPITServer - don't use this manually
|
||||||
@@ -120,6 +138,7 @@ void SAD_DetectedServer::addDetectedServer(bool p_IsIP4, string p_ServerID, stri
|
|||||||
ptrDetectedServer->setComputerName(p_ServerParams[PARAMINDEX_COMPUTERNAME]);
|
ptrDetectedServer->setComputerName(p_ServerParams[PARAMINDEX_COMPUTERNAME]);
|
||||||
ptrDetectedServer->setPort(p_ServerParams[PARAMINDEX_PORT]);
|
ptrDetectedServer->setPort(p_ServerParams[PARAMINDEX_PORT]);
|
||||||
ptrDetectedServer->setAdditions(p_ServerParams[PARAMINDEX_ADDITIONS]);
|
ptrDetectedServer->setAdditions(p_ServerParams[PARAMINDEX_ADDITIONS]);
|
||||||
|
ptrDetectedServer->setProjectName(p_ServerParams[PARAMINDEX_SERVERPROJECTNAME]);
|
||||||
|
|
||||||
s_DetectedServers[ptrDetectedServer->getID()] = ptrDetectedServer;
|
s_DetectedServers[ptrDetectedServer->getID()] = ptrDetectedServer;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,8 +84,11 @@
|
|||||||
}
|
}
|
||||||
bool SPITObject::removeSPITObject(SPITObject* p_ptrSPITObject) {
|
bool SPITObject::removeSPITObject(SPITObject* p_ptrSPITObject) {
|
||||||
if (p_ptrSPITObject == NULL) return false;
|
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()) {
|
if (i == s_SPITObjects.end()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -95,8 +98,11 @@
|
|||||||
}
|
}
|
||||||
bool SPITObject::removeSPITObjectRemote(SPITObject* p_ptrSPITObject) {
|
bool SPITObject::removeSPITObjectRemote(SPITObject* p_ptrSPITObject) {
|
||||||
if (p_ptrSPITObject == NULL) return false;
|
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()) {
|
if (i == s_SPITObjectsRemote.end()) {
|
||||||
return false;
|
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>
|
* sets confirmed = false for all SPITObjects.<br>
|
||||||
* This should be called when the client has loaded a project.<br>
|
* This should be called when the client has loaded a project.<br>
|
||||||
@@ -231,6 +273,7 @@ void SPITObject::initMembers() {
|
|||||||
m_Delay = 0;
|
m_Delay = 0;
|
||||||
m_Duration = 0;
|
m_Duration = 0;
|
||||||
m_Fixed = false;
|
m_Fixed = false;
|
||||||
|
m_CreatedByClient = false;
|
||||||
m_FrameFadeInLength = 0;
|
m_FrameFadeInLength = 0;
|
||||||
m_FrameFadeOutLength = 0;
|
m_FrameFadeOutLength = 0;
|
||||||
m_FrameLength = 0;
|
m_FrameLength = 0;
|
||||||
@@ -245,51 +288,112 @@ void SPITObject::initMembers() {
|
|||||||
m_ValueFactor = 1000000; //Values are given in ppm -> 1000000 = 1/1;
|
m_ValueFactor = 1000000; //Values are given in ppm -> 1000000 = 1/1;
|
||||||
m_ValueUse = 0x01;
|
m_ValueUse = 0x01;
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
SPITObject::SPITObject(const SPITObject& orig) {
|
SPITObject::~SPITObject() { }
|
||||||
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() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void SPITObject::setMessageOP(SPIT_Message::ReportSPITObject* p_ReportSPITObject) {
|
bool SPITObject::setMessageOP(SPIT_Message::ReportSPITObject* p_ReportSPITObject) {
|
||||||
//m_ActionAssigned = p_ReportSPITObject->getActionAssigned(); //Should only be set by the client
|
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();
|
m_Confirmed = p_ReportSPITObject->getConfirmed();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_Delay != p_ReportSPITObject->getDelay()) {
|
||||||
|
if (boolChangeAllowed == false) throw new exception();
|
||||||
m_Delay = p_ReportSPITObject->getDelay();
|
m_Delay = p_ReportSPITObject->getDelay();
|
||||||
|
boolChanged = true;
|
||||||
|
}
|
||||||
|
if (m_Duration != p_ReportSPITObject->getDuration()) {
|
||||||
|
if (boolChangeAllowed == false) throw new exception();
|
||||||
m_Duration = p_ReportSPITObject->getDuration();
|
m_Duration = p_ReportSPITObject->getDuration();
|
||||||
|
boolChanged = true;
|
||||||
|
}
|
||||||
|
if (m_Fixed != p_ReportSPITObject->getFixed()) {
|
||||||
|
if (boolChangeAllowed == false) throw new exception();
|
||||||
m_Fixed = p_ReportSPITObject->getFixed();
|
m_Fixed = p_ReportSPITObject->getFixed();
|
||||||
|
boolChanged = true;
|
||||||
|
}
|
||||||
|
if (m_FrameFadeInLength != p_ReportSPITObject->getFrameFadeInLength()) {
|
||||||
|
if (boolChangeAllowed == false) throw new exception();
|
||||||
m_FrameFadeInLength = p_ReportSPITObject->getFrameFadeInLength();
|
m_FrameFadeInLength = p_ReportSPITObject->getFrameFadeInLength();
|
||||||
|
boolChanged= true;
|
||||||
|
}
|
||||||
|
if (m_FrameFadeOutLength != p_ReportSPITObject->getFrameFadeOutLength()) {
|
||||||
|
if (boolChangeAllowed == false) throw new exception();
|
||||||
m_FrameFadeOutLength = p_ReportSPITObject->getFrameFadeOutLength();
|
m_FrameFadeOutLength = p_ReportSPITObject->getFrameFadeOutLength();
|
||||||
|
boolChanged = true;
|
||||||
|
}
|
||||||
|
if (m_FrameLength != p_ReportSPITObject->getFrameLength()) {
|
||||||
|
if (boolChangeAllowed == false) throw new exception();
|
||||||
m_FrameLength = p_ReportSPITObject->getFrameLength();
|
m_FrameLength = p_ReportSPITObject->getFrameLength();
|
||||||
|
boolChanged = true;
|
||||||
|
}
|
||||||
|
if (m_FrameStart != p_ReportSPITObject->getFrameStart()) {
|
||||||
|
if (boolChangeAllowed == false) throw new exception();
|
||||||
m_FrameStart = p_ReportSPITObject->getFrameStart();
|
m_FrameStart = p_ReportSPITObject->getFrameStart();
|
||||||
|
boolChanged = true;
|
||||||
|
}
|
||||||
|
if (m_Remark != p_ReportSPITObject->getRemark()) {
|
||||||
|
if (boolChangeAllowed == false) throw new exception();
|
||||||
m_Remark = p_ReportSPITObject->getRemark();
|
m_Remark = p_ReportSPITObject->getRemark();
|
||||||
|
boolChanged = true;
|
||||||
|
}
|
||||||
|
if (m_ID != p_ReportSPITObject->getID()) {
|
||||||
|
if (boolChangeAllowed == false) throw new exception();
|
||||||
m_ID = p_ReportSPITObject->getID();
|
m_ID = p_ReportSPITObject->getID();
|
||||||
|
boolChanged = true;
|
||||||
|
}
|
||||||
|
if (m_Name != p_ReportSPITObject->getName()) {
|
||||||
|
if (boolChangeAllowed == false) throw new exception();
|
||||||
m_Name = p_ReportSPITObject->getName();
|
m_Name = p_ReportSPITObject->getName();
|
||||||
|
boolChanged = true;
|
||||||
|
}
|
||||||
|
if (m_SPITTypeID != p_ReportSPITObject->getSPITTypeID()) {
|
||||||
|
if (boolChangeAllowed == false) throw new exception();
|
||||||
m_SPITTypeID = p_ReportSPITObject->getSPITTypeID();
|
m_SPITTypeID = p_ReportSPITObject->getSPITTypeID();
|
||||||
|
boolChanged = true;
|
||||||
|
}
|
||||||
|
if (m_ServerParams != p_ReportSPITObject->getServerParams()) {
|
||||||
|
if (boolChangeAllowed == false) throw new exception();
|
||||||
m_ServerParams = p_ReportSPITObject->getServerParams();
|
m_ServerParams = p_ReportSPITObject->getServerParams();
|
||||||
|
boolChanged = true;
|
||||||
|
}
|
||||||
|
if (m_ServerRemote != p_ReportSPITObject->getServerRemote()) {
|
||||||
|
if (boolChangeAllowed == false) throw new exception();
|
||||||
m_ServerRemote = p_ReportSPITObject->getServerRemote();
|
m_ServerRemote = p_ReportSPITObject->getServerRemote();
|
||||||
|
boolChanged = true;
|
||||||
|
}
|
||||||
|
if (m_Track != p_ReportSPITObject->getTrack()) {
|
||||||
|
if (boolChangeAllowed == false) throw new exception();
|
||||||
m_Track = p_ReportSPITObject->getTrack();
|
m_Track = p_ReportSPITObject->getTrack();
|
||||||
|
boolChanged = true;
|
||||||
|
}
|
||||||
|
if (m_ValueFactor != p_ReportSPITObject->getValueFactor()) {
|
||||||
|
if (boolChangeAllowed == false) throw new exception();
|
||||||
m_ValueFactor = p_ReportSPITObject->getValueFactor();
|
m_ValueFactor = p_ReportSPITObject->getValueFactor();
|
||||||
|
boolChanged = true;
|
||||||
|
}
|
||||||
|
if (m_ValueUse != p_ReportSPITObject->getValueUse()) {
|
||||||
|
if (boolChangeAllowed == false) throw new exception();
|
||||||
m_ValueUse = p_ReportSPITObject->getValueUse();
|
m_ValueUse = p_ReportSPITObject->getValueUse();
|
||||||
|
boolChanged = true;
|
||||||
|
}
|
||||||
|
return boolChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SPITObject::fillMessageOP(SPIT_Message::ReportSPITObject* p_ReportSPITObject) {
|
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) {
|
void SPITObject::setID(string p_ID) {
|
||||||
m_ID = 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.
|
* This is used by the server and client to tell if the other side has registered the changes.
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "SPITPlayer.h"
|
#include "SPITPlayer.h"
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
unordered_map<string, SPITPlayer*> SPITPlayer::s_SPITPlayers;
|
unordered_map<string, SPITPlayer*> SPITPlayer::s_SPITPlayers;
|
||||||
|
|
||||||
@@ -29,18 +30,17 @@ SPITPlayer* SPITPlayer::getSPITPlayer(string p_PlayerID) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SPITPlayer::clearPlayers() {
|
void SPITPlayer::clearPlayers() {
|
||||||
SPITPlayer* ptrSPITPlayer;
|
;
|
||||||
{
|
vector<SPITPlayer*> o_SPITPlayers;
|
||||||
for (auto i = s_SPITPlayers.begin(); i != s_SPITPlayers.end(); i++) {
|
for (auto i = s_SPITPlayers.begin(); i != s_SPITPlayers.end(); i++) {
|
||||||
ptrSPITPlayer = i->second;
|
SPITPlayer* ptrSPITPlayer = i->second;
|
||||||
i = s_SPITPlayers.erase(i);
|
o_SPITPlayers.push_back(ptrSPITPlayer);
|
||||||
|
}
|
||||||
|
for (auto i = o_SPITPlayers.begin(); i != o_SPITPlayers.end(); i++) {
|
||||||
|
SPITPlayer* ptrSPITPlayer = *i;
|
||||||
delete ptrSPITPlayer;
|
delete ptrSPITPlayer;
|
||||||
if (i == s_SPITPlayers.end()) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
o_SPITPlayers.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
SPITPlayer::SPITPlayer(string p_PlayerID) {
|
SPITPlayer::SPITPlayer(string p_PlayerID) {
|
||||||
@@ -48,19 +48,17 @@ SPITPlayer::SPITPlayer(string p_PlayerID) {
|
|||||||
s_SPITPlayers[p_PlayerID] = this;
|
s_SPITPlayers[p_PlayerID] = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SPITPlayer::~SPITPlayer() {
|
SPITPlayer::~SPITPlayer() {
|
||||||
{
|
PlaySPITType* ptrPlaySPITType;
|
||||||
PlayObject* ptrPlayObject;
|
for (auto i = m_PlaySPITTypes.begin(); i != m_PlaySPITTypes.end(); i++) {
|
||||||
for (auto i = m_PlayObjects.begin(); i != m_PlayObjects.end(); i++) {
|
ptrPlaySPITType = i->second;
|
||||||
ptrPlayObject = i->second;
|
i = m_PlaySPITTypes.erase(i);
|
||||||
i = m_PlayObjects.erase(i);
|
delete ptrPlaySPITType;
|
||||||
delete ptrPlayObject;
|
if (i == m_PlaySPITTypes.end()) {
|
||||||
if (i == m_PlayObjects.end()) {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SPITPlayer::setIsRunning(bool p_IsRunning) {
|
void SPITPlayer::setIsRunning(bool p_IsRunning) {
|
||||||
@@ -76,8 +74,8 @@ void SPITPlayer::setTime(long long p_Frames) {
|
|||||||
m_TimeFrames = p_Frames;
|
m_TimeFrames = p_Frames;
|
||||||
}
|
}
|
||||||
|
|
||||||
unordered_map<string, SPITPlayer::PlayObject*>* SPITPlayer::getPlayObjects() {
|
unordered_map<string, SPITPlayer::PlaySPITType*>* SPITPlayer::getPlaySPITTypes() {
|
||||||
return &m_PlayObjects;
|
return &m_PlaySPITTypes;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -85,72 +83,59 @@ unordered_map<string, SPITPlayer::PlayObject*>* SPITPlayer::getPlayObjects() {
|
|||||||
* @return true = new PlayObject added<br>
|
* @return true = new PlayObject added<br>
|
||||||
* false = PlayObject exists
|
* false = PlayObject exists
|
||||||
*/
|
*/
|
||||||
SPITPlayer::PlayObject* SPITPlayer::addSPITObject_Playing (string p_SPITObjectID) {
|
SPITPlayer::PlaySPITType* SPITPlayer::addSPITType_Playing (string p_SPITTypeID) {
|
||||||
PlayObject* ptrPlayObject;
|
PlaySPITType* ptrPlaySPITType;
|
||||||
{
|
|
||||||
auto i = m_PlayObjects.find(p_SPITObjectID);
|
auto i = m_PlaySPITTypes.find(p_SPITTypeID);
|
||||||
if (i == m_PlayObjects.end()) {
|
if (i == m_PlaySPITTypes.end()) {
|
||||||
ptrPlayObject = new PlayObject(this, p_SPITObjectID);
|
ptrPlaySPITType = new PlaySPITType(this, p_SPITTypeID);
|
||||||
ptrPlayObject->setIsPlayed(true);
|
ptrPlaySPITType->setIsPlayed(true);
|
||||||
ptrPlayObject->setIsNew(true);
|
ptrPlaySPITType->setIsNew(true);
|
||||||
m_PlayObjects[p_SPITObjectID] = ptrPlayObject;
|
m_PlaySPITTypes[p_SPITTypeID] = ptrPlaySPITType;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ptrPlayObject = i->second;
|
ptrPlaySPITType = i->second;
|
||||||
ptrPlayObject->setIsPlayed(true);
|
ptrPlaySPITType->setIsPlayed(true);
|
||||||
}
|
|
||||||
return ptrPlayObject;
|
|
||||||
}
|
}
|
||||||
|
return ptrPlaySPITType;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SPITPlayer::startPlaySequence() {
|
void SPITPlayer::startPlaySequence() {
|
||||||
PlayObject* ptrPlayObject;
|
PlaySPITType* ptrPlaySPITType;
|
||||||
{
|
for (auto i = m_PlaySPITTypes.begin(); i != m_PlaySPITTypes.end(); i++) {
|
||||||
for (auto i = m_PlayObjects.begin(); i != m_PlayObjects.end(); i++) {
|
ptrPlaySPITType = i->second;
|
||||||
ptrPlayObject = i->second;
|
ptrPlaySPITType->startPlaySequence();
|
||||||
ptrPlayObject->startPlaySequence();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
SPITPlayer::PlayObject* SPITPlayer::getPlayObject(string p_SPITObjectID) {
|
|
||||||
auto i = m_SPITObjectsPlaying.find(p_SPITObjectID);
|
|
||||||
if (i == m_SPITObjectsPlaying.end()) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
return i->second;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
void SPITPlayer::endPlaySequence() {
|
void SPITPlayer::endPlaySequence() {
|
||||||
PlayObject* ptrPlayObject;
|
PlaySPITType* ptrPlaySPITType;
|
||||||
{
|
|
||||||
for (auto i = m_PlayObjects.begin(); i != m_PlayObjects.end(); i++) {
|
for (auto i = m_PlaySPITTypes.begin(); i != m_PlaySPITTypes.end(); i++) {
|
||||||
ptrPlayObject = i->second;
|
ptrPlaySPITType = i->second;
|
||||||
if (ptrPlayObject->getIsPlayed() == false) {
|
if (ptrPlaySPITType->getIsPlayed() == false) {
|
||||||
i = m_PlayObjects.erase(i);
|
i = m_PlaySPITTypes.erase(i);
|
||||||
delete ptrPlayObject;
|
delete ptrPlaySPITType;
|
||||||
if (i == m_PlayObjects.end()) {
|
if (i == m_PlaySPITTypes.end()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SPITPlayer::PlaySPITType::PlaySPITType() {
|
||||||
|
|
||||||
SPITPlayer::PlayObject::PlayObject() {
|
|
||||||
}
|
}
|
||||||
SPITPlayer::PlayObject::PlayObject(SPITPlayer* p_SPITPlayer, string p_SPITObjectID) {
|
SPITPlayer::PlaySPITType::PlaySPITType(SPITPlayer* p_SPITPlayer, string p_SPITTypeID) {
|
||||||
m_SPITObjectID = p_SPITObjectID;
|
m_SPITTypeID = p_SPITTypeID;
|
||||||
m_PlayerID = p_SPITPlayer->getID();
|
m_PlayerID = p_SPITPlayer->getID();
|
||||||
m_PlayerName = p_SPITPlayer->getName();
|
m_PlayerName = p_SPITPlayer->getName();
|
||||||
startPlaySequence();
|
startPlaySequence();
|
||||||
m_IsNew = true;
|
m_IsNew = true;
|
||||||
}
|
}
|
||||||
SPITPlayer::PlayObject::PlayObject(const PlayObject& orig) {
|
SPITPlayer::PlaySPITType::PlaySPITType(const PlaySPITType& orig) {
|
||||||
m_SPITObjectID = orig.getSPITObjectID();
|
m_SPITTypeID = orig.getSPITTypeID();
|
||||||
m_IsPlayed = orig.getIsPlayed();
|
m_IsPlayed = orig.getIsPlayed();
|
||||||
m_IsNew = orig.getIsNew();
|
m_IsNew = orig.getIsNew();
|
||||||
|
|
||||||
@@ -158,21 +143,11 @@ SPITPlayer::PlayObject::PlayObject(const PlayObject& orig) {
|
|||||||
m_PlayerName = orig.getPlayerName();
|
m_PlayerName = orig.getPlayerName();
|
||||||
m_PlayerRuns = orig.getPlayerIsRunning();
|
m_PlayerRuns = orig.getPlayerIsRunning();
|
||||||
|
|
||||||
m_Value = orig.getValueFade();
|
m_Value = orig.getValue();
|
||||||
m_ValuePrePosition = getValueFadePrePosition();
|
|
||||||
m_ValueFactor = orig.getValueFactor();
|
|
||||||
m_ValueFlag = orig.getValueFlag();
|
|
||||||
m_FrameInsidePrePosition = orig.getFrameInsidePrePosition();
|
|
||||||
m_FrameInside = orig.getFrameInside();
|
|
||||||
}
|
}
|
||||||
void SPITPlayer::PlayObject::startPlaySequence() {
|
void SPITPlayer::PlaySPITType::startPlaySequence() {
|
||||||
m_IsPlayed = false;
|
m_IsPlayed = false;
|
||||||
m_IsNew = false;
|
m_IsNew = false;
|
||||||
|
|
||||||
m_FrameInside = -1;
|
|
||||||
m_FrameInsidePrePosition = -1;
|
|
||||||
m_Value = 0;
|
m_Value = 0;
|
||||||
m_ValuePrePosition = 0;
|
|
||||||
m_ValueFlag = 0x00;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,23 +43,26 @@ bool SPITSocket::createSocket_UDP() {
|
|||||||
} else {
|
} else {
|
||||||
intResult = setsockopt(m_UDPSocketIP4, SOL_SOCKET, SO_REUSEADDR, (void *)&intOptionValue4, sizeof(intOptionValue4));
|
intResult = setsockopt(m_UDPSocketIP4, SOL_SOCKET, SO_REUSEADDR, (void *)&intOptionValue4, sizeof(intOptionValue4));
|
||||||
}
|
}
|
||||||
|
if (intResult < 0) {
|
||||||
|
boolSuccess = false;
|
||||||
|
}
|
||||||
|
|
||||||
// // set the m_UDPSocketIP4 in NON BLOCKING mode because
|
if (boolSuccess == true) {
|
||||||
// // if the UDPSockets are in blocking mode the receiveMessage does not return in every constellation
|
struct timeval tv;
|
||||||
|
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));
|
||||||
|
|
||||||
|
// set the m_UDPSocketIP4 in NON BLOCKING mode because
|
||||||
|
// if the UDPSockets are in blocking mode the receiveMessage does not return in every constellation
|
||||||
// int intFlags;
|
// int intFlags;
|
||||||
// intFlags = fcntl(m_UDPSocketIP4, F_GETFL);
|
// intFlags = fcntl(m_UDPSocketIP4, F_GETFL);
|
||||||
// fcntl(m_UDPSocketIP4, F_SETFL, intFlags | O_NONBLOCK);
|
// fcntl(m_UDPSocketIP4, F_SETFL, intFlags | O_NONBLOCK);
|
||||||
|
|
||||||
struct timeval tv;
|
// int intBufferSize = 2046 * 512;
|
||||||
tv.tv_sec = 1; // seconds
|
// intResult = setsockopt(m_UDPSocketIP4, SOL_SOCKET, SO_RCVBUF, (void*)&intBufferSize, sizeof(intBufferSize));
|
||||||
tv.tv_usec = 0; // microseconds (0.0 sec)
|
// intResult = setsockopt(m_UDPSocketIP4, SOL_SOCKET, SO_SNDBUF, (void*)&intBufferSize, sizeof(intBufferSize));
|
||||||
|
|
||||||
// This sets the receive timeout
|
|
||||||
setsockopt(m_UDPSocketIP4, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
|
|
||||||
|
|
||||||
|
|
||||||
if (intResult < 0) {
|
|
||||||
boolSuccess = false;
|
|
||||||
}
|
}
|
||||||
return boolSuccess;
|
return boolSuccess;
|
||||||
}
|
}
|
||||||
@@ -72,7 +75,7 @@ bool SPITSocket::createSocket_UDP() {
|
|||||||
* @return -1 id bind fails, o if bind is ok
|
* @return -1 id bind fails, o if bind is ok
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
int SPITSocket::bindSocket(string p_ClientIP, string p_ClientPort) {
|
int SPITSocket::bindSocket(string p_ServerIP, string p_ClientIP, string p_ClientPort) {
|
||||||
addrinfo *clientAI;
|
addrinfo *clientAI;
|
||||||
struct sockaddr_in *ptrIP4SocketAddress;
|
struct sockaddr_in *ptrIP4SocketAddress;
|
||||||
struct sockaddr_in o_IP4SocketAddress;
|
struct sockaddr_in o_IP4SocketAddress;
|
||||||
@@ -193,7 +196,7 @@ int SPITSocket::sendMessageTo(int p_InetFamily, string p_ServerIP, string p_Serv
|
|||||||
intResult = -1;
|
intResult = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (intResult == -1) {
|
if (intResult < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -200,6 +200,30 @@ static const char * TAG = "SPIT";
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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>
|
* Sets confirmed = false for all SPITTypes.<br>
|
||||||
* This should be called when the client has loaded a project.<br>
|
* This should be called when the client has loaded a project.<br>
|
||||||
@@ -349,6 +373,7 @@ void SPITType::setCreatedByClient(bool p_CreatedByClient) {
|
|||||||
*/
|
*/
|
||||||
bool SPITType::setMessageOP(SPIT_Message::ReportSPITType* p_ReportSPITType) {
|
bool SPITType::setMessageOP(SPIT_Message::ReportSPITType* p_ReportSPITType) {
|
||||||
bool boolChangeAllowed;
|
bool boolChangeAllowed;
|
||||||
|
bool boolChanged = false;
|
||||||
|
|
||||||
if (m_CreatedByClient == true && m_Fixed == true) {
|
if (m_CreatedByClient == true && m_Fixed == true) {
|
||||||
boolChangeAllowed = false;
|
boolChangeAllowed = false;
|
||||||
@@ -367,38 +392,46 @@ void SPITType::setCreatedByClient(bool p_CreatedByClient) {
|
|||||||
m_Confirmed = p_ReportSPITType->getConfirmed();
|
m_Confirmed = p_ReportSPITType->getConfirmed();
|
||||||
}
|
}
|
||||||
if (m_DefaultDelay != p_ReportSPITType->getDelay()) {
|
if (m_DefaultDelay != p_ReportSPITType->getDelay()) {
|
||||||
if (boolChangeAllowed == false) return false;
|
if (boolChangeAllowed == false) throw new exception();
|
||||||
m_DefaultDelay = p_ReportSPITType->getDelay();
|
m_DefaultDelay = p_ReportSPITType->getDelay();
|
||||||
|
boolChanged = true;
|
||||||
}
|
}
|
||||||
if (m_DefaultDuration != p_ReportSPITType->getDuration()) {
|
if (m_DefaultDuration != p_ReportSPITType->getDuration()) {
|
||||||
if (boolChangeAllowed == false) return false;
|
if (boolChangeAllowed == false) throw new exception();
|
||||||
m_DefaultDuration = p_ReportSPITType->getDuration();
|
m_DefaultDuration = p_ReportSPITType->getDuration();
|
||||||
|
boolChanged = true;
|
||||||
}
|
}
|
||||||
if (m_Fixed != p_ReportSPITType->getFixed()) {
|
if (m_Fixed != p_ReportSPITType->getFixed()) {
|
||||||
if (boolChangeAllowed == false) return false;
|
if (boolChangeAllowed == false) throw new exception();
|
||||||
m_Fixed = p_ReportSPITType->getFixed();
|
m_Fixed = p_ReportSPITType->getFixed();
|
||||||
|
boolChanged = true;
|
||||||
}
|
}
|
||||||
if (m_GroupName != p_ReportSPITType->getGroupName()) {
|
if (m_GroupName != p_ReportSPITType->getGroupName()) {
|
||||||
if (boolChangeAllowed == false) return false;
|
if (boolChangeAllowed == false) throw new exception();
|
||||||
m_GroupName = p_ReportSPITType->getGroupName();
|
m_GroupName = p_ReportSPITType->getGroupName();
|
||||||
|
boolChanged = true;
|
||||||
}
|
}
|
||||||
if (m_ID != p_ReportSPITType->getID()) {
|
if (m_ID != p_ReportSPITType->getID()) {
|
||||||
if (boolChangeAllowed == false) return false;
|
if (boolChangeAllowed == false) throw new exception();
|
||||||
m_ID = p_ReportSPITType->getID();
|
m_ID = p_ReportSPITType->getID();
|
||||||
|
boolChanged = true;
|
||||||
}
|
}
|
||||||
if (m_Name != p_ReportSPITType->getName()) {
|
if (m_Name != p_ReportSPITType->getName()) {
|
||||||
if (boolChangeAllowed == false) return false;
|
if (boolChangeAllowed == false) throw new exception();
|
||||||
m_Name = p_ReportSPITType->getName();
|
m_Name = p_ReportSPITType->getName();
|
||||||
|
boolChanged = true;
|
||||||
}
|
}
|
||||||
if (m_ServerProjectIndepended != p_ReportSPITType->getServerProjectIndepended()) {
|
if (m_ServerProjectIndepended != p_ReportSPITType->getServerProjectIndepended()) {
|
||||||
if (boolChangeAllowed == false) return false;
|
if (boolChangeAllowed == false) throw new exception();
|
||||||
m_ServerProjectIndepended = p_ReportSPITType->getServerProjectIndepended();
|
m_ServerProjectIndepended = p_ReportSPITType->getServerProjectIndepended();
|
||||||
|
boolChanged = true;
|
||||||
}
|
}
|
||||||
if (m_ServerRemote != p_ReportSPITType->getServerRemote()) {
|
if (m_ServerRemote != p_ReportSPITType->getServerRemote()) {
|
||||||
if (boolChangeAllowed == false) return false;
|
if (boolChangeAllowed == false) throw new exception();
|
||||||
m_ServerRemote = p_ReportSPITType->getServerRemote();
|
m_ServerRemote = p_ReportSPITType->getServerRemote();
|
||||||
|
boolChanged = true;
|
||||||
}
|
}
|
||||||
return true;
|
return boolChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SPITType::fillMessageOP(SPIT_Message::ReportSPITType* ptrSMReportSPITType) {
|
void SPITType::fillMessageOP(SPIT_Message::ReportSPITType* ptrSMReportSPITType) {
|
||||||
|
|||||||
+452
-107
@@ -42,37 +42,10 @@ SPIT_Client::~SPIT_Client() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** The ID of the client. Every client instance should set an unique id.*/
|
|
||||||
string SPIT_Client::getID() { return m_ID; }
|
|
||||||
/** The name of the client's host computer*/
|
|
||||||
string SPIT_Client::getComputerName() { return m_ComputerName; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the name of the client. This should be done by the user app.
|
|
||||||
* @param p_Name the anme of the user's app
|
|
||||||
*/
|
|
||||||
/** The name of the client, as set by the user's app*/
|
|
||||||
string SPIT_Client::getName() { return m_Name; }
|
|
||||||
|
|
||||||
//connected Server Infos
|
|
||||||
/**If a connection is established. THis returns the SPITServer's ID*/
|
|
||||||
string SPIT_Client::getServerID() { return m_ServerID; }
|
|
||||||
/**If a connection is established. THis returns the SPITServer's computer/host name*/
|
|
||||||
string SPIT_Client::getServerComputerName() { return m_ServerComputerName; }
|
|
||||||
/**If a connection is established. THis returns the SPITServer's name*/
|
|
||||||
string SPIT_Client::getServerName() { return m_ServerName; }
|
|
||||||
|
|
||||||
/** Expected Refreah Rate of the connectd SPITServer.<br>
|
|
||||||
* When the server plays objects, it will do so at discrete time steps.<br>
|
|
||||||
* Play events will take place in these time steps..
|
|
||||||
*/
|
|
||||||
int SPIT_Client::getServerStepTime() { return m_ServerStepTime; }
|
|
||||||
|
|
||||||
void SPIT_Client::clientProjectClose() {
|
void SPIT_Client::clientProjectClose() {
|
||||||
if (m_ConnectionStatus == CONNECTION_OK) {
|
if (m_ConnectionStatus == CONNECTION_OK) {
|
||||||
ESP_LOGI(TAG, " ... tidy up ressources");
|
ESP_LOGI(TAG, " ... tidy up ressources");
|
||||||
SPIT_Message::CloseSPITProject sMCloseSPITProject;
|
SPIT_Message::CloseSPITProject sMCloseSPITProject;
|
||||||
fillHeader(sMCloseSPITProject.getHeader());
|
|
||||||
sMCloseSPITProject.setProjectID(m_ProjName);
|
sMCloseSPITProject.setProjectID(m_ProjName);
|
||||||
if (sendSPITMessage(sMCloseSPITProject) < 0) {
|
if (sendSPITMessage(sMCloseSPITProject) < 0) {
|
||||||
ESP_LOGD(TAG, "SPIT_Client could not send Client's ReportSPITProject");
|
ESP_LOGD(TAG, "SPIT_Client could not send Client's ReportSPITProject");
|
||||||
@@ -88,7 +61,6 @@ void SPIT_Client::clientProjectLoaded() {
|
|||||||
if (m_ConnectionStatus == CONNECTION_OK) {
|
if (m_ConnectionStatus == CONNECTION_OK) {
|
||||||
//send ReportSPITProject to the server
|
//send ReportSPITProject to the server
|
||||||
SPIT_Message::ReportSPITProject sMReportSPITProject;
|
SPIT_Message::ReportSPITProject sMReportSPITProject;
|
||||||
fillHeader(sMReportSPITProject.getHeader());
|
|
||||||
sMReportSPITProject.setProjectID(m_ProjName);
|
sMReportSPITProject.setProjectID(m_ProjName);
|
||||||
sMReportSPITProject.setProjectName(m_ProjName);
|
sMReportSPITProject.setProjectName(m_ProjName);
|
||||||
sMReportSPITProject.setFramesPerSecond(0);
|
sMReportSPITProject.setFramesPerSecond(0);
|
||||||
@@ -98,7 +70,6 @@ void SPIT_Client::clientProjectLoaded() {
|
|||||||
|
|
||||||
//send RequestProjectTransfer
|
//send RequestProjectTransfer
|
||||||
SPIT_Message::RequestProjectTransfer sMRequestProjectTransfer;
|
SPIT_Message::RequestProjectTransfer sMRequestProjectTransfer;
|
||||||
fillHeader(sMRequestProjectTransfer.getHeader());
|
|
||||||
if (sendSPITMessage(sMRequestProjectTransfer) < 0) {
|
if (sendSPITMessage(sMRequestProjectTransfer) < 0) {
|
||||||
ESP_LOGD(TAG, "SPIT_CLient::clientProjectLoaded could not send RequestProjectTransfer");
|
ESP_LOGD(TAG, "SPIT_CLient::clientProjectLoaded could not send RequestProjectTransfer");
|
||||||
}
|
}
|
||||||
@@ -125,7 +96,7 @@ void SPIT_Client::setActionSPITType(string p_SPITTypeID, bool p_ActionAssigned)
|
|||||||
|
|
||||||
for (int i = 0; i < SPITObject::getSPITObjectCount(); i++) {
|
for (int i = 0; i < SPITObject::getSPITObjectCount(); i++) {
|
||||||
ptrSPITObject = SPITObject::getSPITObject(i);
|
ptrSPITObject = SPITObject::getSPITObject(i);
|
||||||
if (ptrSPITObject == NULL) break;
|
if (ptrSPITObject == NULL) continue;
|
||||||
if (ptrSPITObject->getSPITTypeID() == ptrSPITType->getID()) {
|
if (ptrSPITObject->getSPITTypeID() == ptrSPITType->getID()) {
|
||||||
if (ptrSPITObject->setActionAssignedType(p_ActionAssigned) == true) {
|
if (ptrSPITObject->setActionAssignedType(p_ActionAssigned) == true) {
|
||||||
sendSPITObjectInternal(ptrSPITObject);
|
sendSPITObjectInternal(ptrSPITObject);
|
||||||
@@ -165,7 +136,7 @@ void SPIT_Client::startServerAutoDetect() {
|
|||||||
|
|
||||||
SAD_DetectedServer::clearDetectedServers();
|
SAD_DetectedServer::clearDetectedServers();
|
||||||
if (!sThread) {
|
if (!sThread) {
|
||||||
sThread = new fos::TaskT<SPIT_Client &>(SPIT_Client::processSocketTask, *this, "spitSock");
|
sThread = new fos::TaskT<SPIT_Client &>(SPIT_Client::processSocketTask, *this, "spitSock", fos::Task::DefaultStackSize*2 );
|
||||||
}
|
}
|
||||||
abortSearch = false;
|
abortSearch = false;
|
||||||
sStartSad.give();
|
sStartSad.give();
|
||||||
@@ -193,10 +164,10 @@ void SPIT_Client::stopServerAutoDetect() {
|
|||||||
* @param p_Addition sometimes server may have additional informations
|
* @param p_Addition sometimes server may have additional informations
|
||||||
* @param p_IsIP4 the server ip is a ip4 address
|
* @param p_IsIP4 the server ip is a ip4 address
|
||||||
*/
|
*/
|
||||||
void SPIT_Client::eventServerDetected(string p_ID, string p_Name, string p_ComputerName, string p_IP, string p_Port, string p_Addition, string p_ClientIP, bool p_IsIP4) {
|
void SPIT_Client::eventServerDetected(string p_ID, string p_Name, string p_ComputerName, string p_IP, string p_Port, string p_Addition, string p_ProjectName, string p_ClientIP, bool p_IsIP4) {
|
||||||
try {
|
try {
|
||||||
SAD_DetectedServer o_RefDetectedServer = SAD_DetectedServer::getRefDetectedServer(p_ID);
|
SAD_DetectedServer o_RefDetectedServer = SAD_DetectedServer::getRefDetectedServer(p_ID);
|
||||||
mCallbacks.onServerDetect(o_RefDetectedServer);
|
mCallbacks.onServerEvent(ServerEvent::Detect, o_RefDetectedServer);
|
||||||
|
|
||||||
// If a connection has been established and the connection is lost -> reconnect
|
// If a connection has been established and the connection is lost -> reconnect
|
||||||
if (_doReconnect) {
|
if (_doReconnect) {
|
||||||
@@ -235,16 +206,77 @@ void SPIT_Client::eventServerDetected(string p_ID, string p_Name, string p_Compu
|
|||||||
* @param p_Addition sometimes server may have additional informations
|
* @param p_Addition sometimes server may have additional informations
|
||||||
* @param p_IsIP4 the server ip is a ip4 address
|
* @param p_IsIP4 the server ip is a ip4 address
|
||||||
*/
|
*/
|
||||||
void SPIT_Client::eventServerLost(string p_ID, string p_Name, string p_ComputerName, string p_IP, string p_Port, string p_Addition, string p_ClientIP, bool p_IsIP4) {
|
void SPIT_Client::eventServerLost(string p_ID, string p_Name, string p_ComputerName, string p_IP, string p_Port, string p_Addition, string p_ProjectName, string p_ClientIP, bool p_IsIP4) {
|
||||||
try {
|
try {
|
||||||
SAD_DetectedServer o_RefDetectedServer = SAD_DetectedServer::getRefDetectedServer(p_ID);
|
SAD_DetectedServer o_RefDetectedServer = SAD_DetectedServer::getRefDetectedServer(p_ID);
|
||||||
mCallbacks.onServerLost(o_RefDetectedServer);
|
mCallbacks.onServerEvent(ServerEvent::Lost, o_RefDetectedServer);
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SPIT_Client::eventServerChanged(string p_ID, string p_Name, string p_ComputerName, string p_IP, string p_Port, string p_Addition, string p_ProjectName, string p_ClientIP, bool p_IsIP4) {
|
||||||
|
try {
|
||||||
|
SAD_DetectedServer o_RefDetectedServer = SAD_DetectedServer::getRefDetectedServer(p_ID);
|
||||||
|
mCallbacks.onServerEvent(ServerEvent::Changed, o_RefDetectedServer);
|
||||||
|
// tryConnection(p_DetectedServer);
|
||||||
|
}
|
||||||
|
catch (...) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// void MyApp::tryConnection(const SAD_DetectedServer& p_DetectedServer) {
|
||||||
|
// //fetch the infoemations from the p_DetectedServer
|
||||||
|
// bool boolPossibleConnect;
|
||||||
|
// bool boolSuccess;
|
||||||
|
|
||||||
|
// boolPossibleConnect = checkPossibleConnection(p_DetectedServer);
|
||||||
|
|
||||||
|
// if (boolPossibleConnect == false) return;
|
||||||
|
|
||||||
|
// // --------------------------------------
|
||||||
|
// // You have three Options to use the detected server
|
||||||
|
// // OPTION 1 Use the first server found
|
||||||
|
// // OPTION 2 Use the first server found that fulfills specific conditions
|
||||||
|
// // OPTION 3 take a copy of the p_DetectedServer and do connection later
|
||||||
|
// // SAD_DetectedServer o_DetectedServer = p_DetectedServer; //this will call the copy constructor
|
||||||
|
// // ---------------------------------------
|
||||||
|
|
||||||
|
// //Excample use the first detected LOOPBACK server, means the server runs on the same computer as this client
|
||||||
|
// //if (p_DetectedServer.getIpIsLoopback() == true) { //omit the if condition if you want to use the first server found
|
||||||
|
|
||||||
|
// boolSuccess = false;
|
||||||
|
// //Stop auto detection because a suitable server was found
|
||||||
|
// stopServerAutoDetect();
|
||||||
|
// if (m_SPIT_Client != NULL) {
|
||||||
|
// m_ServerProjectName = p_DetectedServer.getProjectName();
|
||||||
|
// m_ServerIP = p_DetectedServer.getIP();
|
||||||
|
|
||||||
|
// #if defined(DEBUGOUTPUT)
|
||||||
|
// printf("MySPITApp: connect to %s ", p_DetectedServer.getIP().data());
|
||||||
|
// #endif
|
||||||
|
// //Use the m_BoardNumber as login name
|
||||||
|
// string stringLoginName = "";
|
||||||
|
// string stringLoginPassword = "";
|
||||||
|
// boolSuccess = m_SPIT_Client->connect(p_DetectedServer.getIP(), p_DetectedServer.getPort(), p_DetectedServer.getClientIP(), stringLoginName, stringLoginPassword); //ClientPort = "0" meeans use any port
|
||||||
|
// }
|
||||||
|
// if (boolSuccess == false) {
|
||||||
|
// //connection message could not be sent
|
||||||
|
// //perhaps restart AutoDetection
|
||||||
|
// startServerAutoDetect();
|
||||||
|
// }
|
||||||
|
// else {
|
||||||
|
// //WAITING FOR CONNECTION ANSWER
|
||||||
|
// //If the Server is closed in the meantime no answer will return
|
||||||
|
// //-> connect(..) has started the watchdog
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // } //Excample
|
||||||
|
// }
|
||||||
|
|
||||||
void SPIT_Client::fillHeader(SPIT_Message::Header* p_Header) {
|
void SPIT_Client::fillHeader(SPIT_Message::Header* p_Header) {
|
||||||
if (p_Header == NULL) return;
|
if (p_Header == NULL) return;
|
||||||
@@ -257,6 +289,8 @@ int SPIT_Client::sendSPITMessage(SPIT_Message::OPPart& spitMessageOPPart) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fillHeader(spitMessageOPPart.getHeader());
|
||||||
|
|
||||||
if (m_MessageNumber_Send == 255) m_MessageNumber_Send = 1;
|
if (m_MessageNumber_Send == 255) m_MessageNumber_Send = 1;
|
||||||
else m_MessageNumber_Send++;
|
else m_MessageNumber_Send++;
|
||||||
spitMessageOPPart.getHeader()->setMessageNumber(m_MessageNumber_Send);
|
spitMessageOPPart.getHeader()->setMessageNumber(m_MessageNumber_Send);
|
||||||
@@ -312,11 +346,114 @@ void SPIT_Client::receiveSPITMessage(SPIT_Client& rM) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
auto ptrSPIT_Message = make_unique<SPIT_Message>(buffer, intResult);
|
auto ptrSPIT_Message = make_unique<SPIT_Message>(buffer, intResult);
|
||||||
|
unsigned int intActualMessageNumber = (int)(ptrSPIT_Message->getHeader()->getMessageNumber() & 0xFF);
|
||||||
rM.parseSPIT_Message(move(ptrSPIT_Message));
|
rM.parseSPIT_Message(move(ptrSPIT_Message));
|
||||||
|
// rM.checkParseSPIT_Message(move(ptrSPIT_Message));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SPIT_Client::resetMessageNumberReceived() {
|
||||||
|
SPIT_Message* ptrOvertakingSPIT_Message;
|
||||||
|
|
||||||
|
m_MessageNumber_Received = -1;
|
||||||
|
for (auto it = m_OvertakingSPIT_Messages.begin(); it != m_OvertakingSPIT_Messages.end(); it++) {
|
||||||
|
ptrOvertakingSPIT_Message = *it;
|
||||||
|
delete ptrOvertakingSPIT_Message;
|
||||||
|
// m_OvertakingSPIT_Messages.erase(it);
|
||||||
|
}
|
||||||
|
m_OvertakingSPIT_Messages.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SPIT_Client::checkParseSPIT_Message(unique_ptr<SPIT_Message> p_SPITMessage) {
|
||||||
|
answerWatchdog();
|
||||||
|
if (p_SPITMessage == NULL) {
|
||||||
|
ESP_LOGD(TAG, "SPIT_Client::parseSPIT_Message Parameter == NULL\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (p_SPITMessage->getHeader() == NULL) {
|
||||||
|
ESP_LOGD(TAG, "SPIT_Client::parseSPIT_Message no Header\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (p_SPITMessage->getOPPart() == NULL) {
|
||||||
|
ESP_LOGD(TAG, "SPIT_Client::parseSPIT_Message no OPPart\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int intActualMessageNumber;
|
||||||
|
int intNextMessageNumber;
|
||||||
|
SPIT_Message* ptrOvertakingSPIT_Message;
|
||||||
|
|
||||||
|
intActualMessageNumber = (int)(p_SPITMessage->getHeader()->getMessageNumber() & 0xFF);
|
||||||
|
|
||||||
|
if (intActualMessageNumber == 0) {
|
||||||
|
parseSPIT_Message(std::move(p_SPITMessage));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (m_MessageNumber_Received < 0) {
|
||||||
|
m_MessageNumber_Received = intActualMessageNumber;
|
||||||
|
parseSPIT_Message(std::move(p_SPITMessage));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
intNextMessageNumber = m_MessageNumber_Received +1;
|
||||||
|
if (intNextMessageNumber > 255 || intNextMessageNumber < 1) intNextMessageNumber = 1;
|
||||||
|
|
||||||
|
if (intActualMessageNumber == intNextMessageNumber) {
|
||||||
|
m_MessageNumber_Received = intActualMessageNumber;
|
||||||
|
parseSPIT_Message(std::move(p_SPITMessage));
|
||||||
|
|
||||||
|
//check overtaking messages
|
||||||
|
auto it = m_OvertakingSPIT_Messages.begin();
|
||||||
|
while (m_OvertakingSPIT_Messages.size() > 0) {
|
||||||
|
|
||||||
|
intNextMessageNumber = m_MessageNumber_Received +1;
|
||||||
|
if (intNextMessageNumber > 255 || intNextMessageNumber < 1) intNextMessageNumber = 1;
|
||||||
|
|
||||||
|
ptrOvertakingSPIT_Message = *it;
|
||||||
|
intActualMessageNumber = (int)(ptrOvertakingSPIT_Message->getHeader()->getMessageNumber() & 0xFF);
|
||||||
|
|
||||||
|
if (intActualMessageNumber == intNextMessageNumber) {
|
||||||
|
m_MessageNumber_Received = intActualMessageNumber;
|
||||||
|
// parseSPIT_Message(ptrOvertakingSPIT_Message);
|
||||||
|
m_OvertakingSPIT_Messages.erase(it);
|
||||||
|
|
||||||
|
it = m_OvertakingSPIT_Messages.begin();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//p_SPITMessage has overtaken another message
|
||||||
|
addOvertakingSPIT_Message(p_SPITMessage.get());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int SPIT_Client::s_MAX_OVERTAKING_SPIT_MESSAGES = 10;
|
||||||
|
|
||||||
|
void SPIT_Client::addOvertakingSPIT_Message(SPIT_Message* p_SPIT_Message) {
|
||||||
|
if (p_SPIT_Message == nullptr) return;
|
||||||
|
int intMessageNumber;
|
||||||
|
SPIT_Message* ptrOvertakingSPIT_Message;
|
||||||
|
int intOvertakingMessageNumber;
|
||||||
|
|
||||||
|
if (m_OvertakingSPIT_Messages.size() > s_MAX_OVERTAKING_SPIT_MESSAGES) {
|
||||||
|
printf("SPIT_Client receiveing: perhaps message lost !!!!!");
|
||||||
|
}
|
||||||
|
|
||||||
|
intMessageNumber = (int)(p_SPIT_Message->getHeader()->getMessageNumber() & 0xFF);
|
||||||
|
for (auto it = m_OvertakingSPIT_Messages.begin(); it != m_OvertakingSPIT_Messages.end(); it++) {
|
||||||
|
ptrOvertakingSPIT_Message = *it;
|
||||||
|
intOvertakingMessageNumber = (int)(ptrOvertakingSPIT_Message->getHeader()->getMessageNumber() & 0xFF);
|
||||||
|
if (intMessageNumber < intOvertakingMessageNumber) {
|
||||||
|
m_OvertakingSPIT_Messages.insert(it, p_SPIT_Message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_OvertakingSPIT_Messages.push_back(p_SPIT_Message);
|
||||||
|
}
|
||||||
|
|
||||||
void SPIT_Client::parseSPIT_Message(unique_ptr<SPIT_Message> p_SPITMessage) {
|
void SPIT_Client::parseSPIT_Message(unique_ptr<SPIT_Message> p_SPITMessage) {
|
||||||
answerWatchdog();
|
answerWatchdog();
|
||||||
@@ -431,14 +568,13 @@ bool SPIT_Client::connect(string p_ServerIP, string p_ServerPort, string p_Clien
|
|||||||
disconnect();
|
disconnect();
|
||||||
{
|
{
|
||||||
mSPITSocket->setConnectionParams(p_ServerIP, p_ServerPort, p_ClientIP, p_ClientPort);
|
mSPITSocket->setConnectionParams(p_ServerIP, p_ServerPort, p_ClientIP, p_ClientPort);
|
||||||
intResult = mSPITSocket->bindSocket(p_ClientIP, p_ClientPort);
|
intResult = mSPITSocket->bindSocket(p_ServerIP, p_ClientIP, p_ClientPort);
|
||||||
if (intResult < 0) {
|
if (intResult < 0) {
|
||||||
m_StopReceiveSPITMessages = true;
|
m_StopReceiveSPITMessages = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SPIT_Message::Connect sMConnect;
|
SPIT_Message::Connect sMConnect;
|
||||||
fillHeader(sMConnect.getHeader());
|
|
||||||
sMConnect.setClientComputerName(m_ComputerName);
|
sMConnect.setClientComputerName(m_ComputerName);
|
||||||
sMConnect.setClientName(m_Name);
|
sMConnect.setClientName(m_Name);
|
||||||
sMConnect.setLoginName(p_LoginName);
|
sMConnect.setLoginName(p_LoginName);
|
||||||
@@ -455,7 +591,12 @@ bool SPIT_Client::connect(string p_ServerIP, string p_ServerPort, string p_Clien
|
|||||||
m_StopReceiveSPITMessages = true;
|
m_StopReceiveSPITMessages = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
resetMessageNumberReceived();
|
||||||
|
int intOldConnectionStatus = m_ConnectionStatus;
|
||||||
|
|
||||||
m_ConnectionStatus = CONNECTION_TRYCONNECTION;
|
m_ConnectionStatus = CONNECTION_TRYCONNECTION;
|
||||||
|
mCallbacks.onConnectionStatus(m_ServerID, m_ServerComputerName, m_ServerName, m_ServerStepTime,
|
||||||
|
m_ConnectionStatus, intOldConnectionStatus);
|
||||||
|
|
||||||
//sleep a little to make sure that the reception of the messages is started
|
//sleep a little to make sure that the reception of the messages is started
|
||||||
fos::Task::delayMs(500);
|
fos::Task::delayMs(500);
|
||||||
@@ -485,7 +626,6 @@ void SPIT_Client::disconnectInternal(int p_Cause) {
|
|||||||
case CONNECTION_NONE:
|
case CONNECTION_NONE:
|
||||||
{
|
{
|
||||||
SPIT_Message::Disconnect sMDisconnect;
|
SPIT_Message::Disconnect sMDisconnect;
|
||||||
fillHeader(sMDisconnect.getHeader());
|
|
||||||
intResult = sendSPITMessage(sMDisconnect);
|
intResult = sendSPITMessage(sMDisconnect);
|
||||||
if (intResult < 0) {
|
if (intResult < 0) {
|
||||||
}
|
}
|
||||||
@@ -495,6 +635,8 @@ void SPIT_Client::disconnectInternal(int p_Cause) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
stopReceiveSPITMessages();
|
stopReceiveSPITMessages();
|
||||||
|
mCallbacks.onConnectionStatus(m_ServerID, m_ServerComputerName, m_ServerName, m_ServerStepTime,
|
||||||
|
m_ConnectionStatus, intOldConnectionStatus);
|
||||||
|
|
||||||
if (intOldConnectionStatus != CONNECTION_NONE && intOldConnectionStatus != CONNECTION_NONESERVER) {
|
if (intOldConnectionStatus != CONNECTION_NONE && intOldConnectionStatus != CONNECTION_NONESERVER) {
|
||||||
ESP_LOGI(TAG, "eventConnectionStatus %d ", m_ConnectionStatus);
|
ESP_LOGI(TAG, "eventConnectionStatus %d ", m_ConnectionStatus);
|
||||||
@@ -577,9 +719,8 @@ void SPIT_Client::parseDisconnect(SPIT_Message::Disconnect* p_Disconnect) {
|
|||||||
void SPIT_Client::parseWatchdog(SPIT_Message::Watchdog* p_Watchdog) {
|
void SPIT_Client::parseWatchdog(SPIT_Message::Watchdog* p_Watchdog) {
|
||||||
// printf("parse Watchdog \n");
|
// printf("parse Watchdog \n");
|
||||||
SPIT_Message::WatchdogAnswer o_WatchdogAnswer;
|
SPIT_Message::WatchdogAnswer o_WatchdogAnswer;
|
||||||
fillHeader(o_WatchdogAnswer.getHeader());
|
;
|
||||||
int intResult;
|
int intResult = sendSPITMessage(o_WatchdogAnswer);
|
||||||
intResult = sendSPITMessage(o_WatchdogAnswer);
|
|
||||||
if (intResult < 0) {
|
if (intResult < 0) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -595,19 +736,24 @@ void SPIT_Client::parseWatchdogAnswer(SPIT_Message::WatchdogAnswer* p_WatchdogAn
|
|||||||
void SPIT_Client::sendWatchdog() {
|
void SPIT_Client::sendWatchdog() {
|
||||||
int intResult;
|
int intResult;
|
||||||
SPIT_Message::Watchdog sMWatchdog;
|
SPIT_Message::Watchdog sMWatchdog;
|
||||||
fillHeader(sMWatchdog.getHeader());
|
|
||||||
intResult = sendSPITMessage(sMWatchdog);
|
intResult = sendSPITMessage(sMWatchdog);
|
||||||
if (intResult < 0) {
|
if (intResult < 0) {
|
||||||
ESP_LOGW("WDT", "Failed to send Watchdog msg");
|
ESP_LOGW("WDT", "Failed to send Watchdog msg");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void SPIT_Client::eventWatchdogLost() {
|
void SPIT_Client::eventWatchdogLost() {
|
||||||
|
if (m_ConnectionStatus == CONNECTION_TRYCONNECTION) {
|
||||||
|
disconnectInternal(CONNECTION_NONESERVER);
|
||||||
|
}
|
||||||
|
else {
|
||||||
disconnectInternal(CONNECTION_LOST);
|
disconnectInternal(CONNECTION_LOST);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//----- SPIT Project ------
|
//----- SPIT Project ------
|
||||||
void SPIT_Client::parseReportSPITProject(SPIT_Message::ReportSPITProject* p_ReportSPITProject) {
|
void SPIT_Client::parseReportSPITProject(SPIT_Message::ReportSPITProject* p_ReportSPITProject) {
|
||||||
// printf("parse ReportSPITProject \n");
|
// printf("parse ReportSPITProject \n");
|
||||||
|
if (p_ReportSPITProject == NULL) return;
|
||||||
m_ServerProjectID = p_ReportSPITProject->getProjectID();
|
m_ServerProjectID = p_ReportSPITProject->getProjectID();
|
||||||
m_ServerProjectName = p_ReportSPITProject->getProjectName();
|
m_ServerProjectName = p_ReportSPITProject->getProjectName();
|
||||||
m_ServerFramesPerSecond = p_ReportSPITProject->getFramesPerSecond();
|
m_ServerFramesPerSecond = p_ReportSPITProject->getFramesPerSecond();
|
||||||
@@ -620,24 +766,24 @@ void SPIT_Client::parseReportSPITProject(SPIT_Message::ReportSPITProject* p_Repo
|
|||||||
|
|
||||||
//Send RequestProjectTransfer
|
//Send RequestProjectTransfer
|
||||||
SPIT_Message::RequestProjectTransfer sMRequestProjectTransfer;
|
SPIT_Message::RequestProjectTransfer sMRequestProjectTransfer;
|
||||||
fillHeader(sMRequestProjectTransfer.getHeader());
|
|
||||||
if (sendSPITMessage(sMRequestProjectTransfer) < 0) {
|
if (sendSPITMessage(sMRequestProjectTransfer) < 0) {
|
||||||
printf("SPIT_Client::parseReportSPITProject could not send RequestProjectTransfer\n");
|
printf("SPIT_Client::parseReportSPITProject could not send RequestProjectTransfer\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// todo Don't send the ReportSPITProject here it should be sended after parseEndProjectTransfer
|
||||||
//Send client's ReportSPITProject
|
//Send client's ReportSPITProject
|
||||||
SPIT_Message::ReportSPITProject sMReportSPITProject;
|
SPIT_Message::ReportSPITProject sMReportSPITProject;
|
||||||
fillHeader(sMReportSPITProject.getHeader());
|
|
||||||
sMReportSPITProject.setProjectID(m_ProjName);
|
sMReportSPITProject.setProjectID(m_ProjName);
|
||||||
sMReportSPITProject.setProjectName(m_ProjName);
|
sMReportSPITProject.setProjectName(m_ProjName);
|
||||||
sMReportSPITProject.setFramesPerSecond(0);
|
sMReportSPITProject.setFramesPerSecond(0);
|
||||||
if (sendSPITMessage(sMReportSPITProject) < 0) {
|
if (sendSPITMessage(sMReportSPITProject) < 0) {
|
||||||
printf("SPIT_Client::parseReportSPITProject could not send Client's ReportSPITProject");
|
printf("SPIT_Client::parseReportSPITProject could not send Client's ReportSPITProject");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
void SPIT_Client::parseCloseSPITProject(SPIT_Message::CloseSPITProject* p_CloseSPITProject) {
|
void SPIT_Client::parseCloseSPITProject(SPIT_Message::CloseSPITProject* p_CloseSPITProject) {
|
||||||
// printf("parse CloseSPITProject \n");
|
// printf("parse CloseSPITProject \n");
|
||||||
|
if (p_CloseSPITProject == NULL) return;
|
||||||
|
string stringProjectID;
|
||||||
mCallbacks.onProjectClosed(p_CloseSPITProject->getProjectID());
|
mCallbacks.onProjectClosed(p_CloseSPITProject->getProjectID());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -648,24 +794,19 @@ int SPIT_Client::getServerFramesPerSecond() { return m_ServerFramesPerSecond; }
|
|||||||
|
|
||||||
void SPIT_Client::parseRequestProjectTransfer(SPIT_Message::RequestProjectTransfer* p_RequestProjectTransfer) {
|
void SPIT_Client::parseRequestProjectTransfer(SPIT_Message::RequestProjectTransfer* p_RequestProjectTransfer) {
|
||||||
// printf("parse RequestProjectTransfer \n");
|
// printf("parse RequestProjectTransfer \n");
|
||||||
int intResult;
|
|
||||||
int intCount;
|
|
||||||
SPITType* ptrSPITType;
|
|
||||||
SPITObject* ptrSPITObject;
|
|
||||||
|
|
||||||
//StartProjectTransfer
|
//StartProjectTransfer
|
||||||
SPIT_Message::StartProjectTransfer sMStartProjectTransfer;
|
SPIT_Message::StartProjectTransfer sMStartProjectTransfer;
|
||||||
fillHeader(sMStartProjectTransfer.getHeader());
|
fillHeader(sMStartProjectTransfer.getHeader());
|
||||||
intResult = sendSPITMessage(sMStartProjectTransfer);
|
int intResult = sendSPITMessage(sMStartProjectTransfer);
|
||||||
if (intResult < 0) {
|
if (intResult < 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
//send all listes SPITTypes
|
//send all listes SPITTypes
|
||||||
intCount = SPITType::getSPITTypeCount();
|
int intCount = SPITType::getSPITTypeCount();
|
||||||
for (int i = 0; i < intCount; i++) {
|
for (int i = 0; i < intCount; i++) {
|
||||||
ptrSPITType = SPITType::getSPITType(i);
|
SPITType* ptrSPITType = SPITType::getSPITType(i);
|
||||||
if (ptrSPITType == NULL) break;
|
if (ptrSPITType == NULL) break;
|
||||||
sendSPITTypeInternal(ptrSPITType);
|
sendSPITTypeInternal(ptrSPITType);
|
||||||
fos::Task::delayMs(10);
|
fos::Task::delayMs(10);
|
||||||
@@ -673,9 +814,9 @@ void SPIT_Client::parseRequestProjectTransfer(SPIT_Message::RequestProjectTransf
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
intCount = SPITObject::getSPITObjectCount();
|
int intCount = SPITObject::getSPITObjectCount();
|
||||||
for (int i = 0; i < intCount; i++) {
|
for (int i = 0; i < intCount; i++) {
|
||||||
ptrSPITObject = SPITObject::getSPITObject(i);
|
SPITObject* ptrSPITObject = SPITObject::getSPITObject(i);
|
||||||
if (ptrSPITObject == NULL) break;
|
if (ptrSPITObject == NULL) break;
|
||||||
sendSPITObjectInternal(ptrSPITObject);
|
sendSPITObjectInternal(ptrSPITObject);
|
||||||
fos::Task::delayMs(10);
|
fos::Task::delayMs(10);
|
||||||
@@ -688,13 +829,151 @@ void SPIT_Client::parseRequestProjectTransfer(SPIT_Message::RequestProjectTransf
|
|||||||
intResult = sendSPITMessage(sMEndProjectTransfer);
|
intResult = sendSPITMessage(sMEndProjectTransfer);
|
||||||
if (intResult < 0) {
|
if (intResult < 0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* NEW IMPLEMENTATION
|
||||||
|
|
||||||
|
void SPIT_Client::parseRequestProjectTransfer(SPIT_Message::RequestProjectTransfer* p_RequestProjectTransfer) {
|
||||||
|
// printf("parse RequestProjectTransfer \n");
|
||||||
|
thread* o_ThreadSend;
|
||||||
|
o_ThreadSend = new thread(&this->sendProject, this);
|
||||||
|
// int intResult;
|
||||||
|
// SPIT_Message::StartProjectTransfer* ptrSMStartProjectTransfer;
|
||||||
|
// SPIT_Message::EndProjectTransfer* ptrSMEndProjectTransfer;
|
||||||
|
// int intCount;
|
||||||
|
// SPITType* ptrSPITType;
|
||||||
|
// SPITObject* ptrSPITObject;
|
||||||
|
|
||||||
|
|
||||||
|
// //StartProjectTransfer
|
||||||
|
// NotifyStartProjectTransfer_Client* o_RunnableStart = new NotifyStartProjectTransfer_Client(m_SPITClientInterface);
|
||||||
|
// SPIT_Handler::addRunnable(o_RunnableStart);
|
||||||
|
|
||||||
|
// ptrSMStartProjectTransfer = new SPIT_Message::StartProjectTransfer();
|
||||||
|
// intResult = sendSPITMessage(ptrSMStartProjectTransfer);
|
||||||
|
// if (intResult < 0) {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// m_Watchdog->answerWatchdog();
|
||||||
|
// {
|
||||||
|
// //send all listes SPITTypes
|
||||||
|
// unique_lock<recursive_mutex> o_LockType(*SPITType::getMutex());
|
||||||
|
// intCount = SPITType::getSPITTypeCount();
|
||||||
|
// for (int i = 0; i < intCount; i++) {
|
||||||
|
// ptrSPITType = SPITType::getSPITType(i);
|
||||||
|
// if (ptrSPITType == NULL) continue;
|
||||||
|
// intResult = sendSPITTypeInternal(ptrSPITType);
|
||||||
|
// if (intResult < 0) return;
|
||||||
|
// m_Watchdog->answerWatchdog();
|
||||||
|
// this_thread::sleep_for(chrono::milliseconds(7));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// {
|
||||||
|
// unique_lock<recursive_mutex> o_LockObject(*SPITObject::getMutex());
|
||||||
|
// intCount = SPITObject::getSPITObjectCount();
|
||||||
|
// for (int i = 0; i < intCount; i++) {
|
||||||
|
// ptrSPITObject = SPITObject::getSPITObject(i);
|
||||||
|
// if (ptrSPITObject == NULL) continue;
|
||||||
|
// intResult = sendSPITObjectInternal(ptrSPITObject);
|
||||||
|
// if (intResult < 0) return;
|
||||||
|
// m_Watchdog->answerWatchdog();
|
||||||
|
// this_thread::sleep_for(chrono::milliseconds(7));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //EndProjectTransfer
|
||||||
|
// ptrSMEndProjectTransfer = new SPIT_Message::EndProjectTransfer();
|
||||||
|
// intResult = sendSPITMessage(ptrSMEndProjectTransfer);
|
||||||
|
// if (intResult < 0) {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// m_Watchdog->answerWatchdog();
|
||||||
|
// NotifyEndProjectTransfer_Client* o_RunnableEnd = new NotifyEndProjectTransfer_Client(m_SPITClientInterface);
|
||||||
|
// SPIT_Handler::addRunnable(o_RunnableEnd);
|
||||||
|
|
||||||
|
// //Send act
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
void SPIT_Client::sendProject(SPIT_Client* p_PtrSPIT_Client) {
|
||||||
|
// int intResult;
|
||||||
|
// SPIT_Message::StartProjectTransfer* ptrSMStartProjectTransfer;
|
||||||
|
// SPIT_Message::EndProjectTransfer* ptrSMEndProjectTransfer;
|
||||||
|
// int intCount;
|
||||||
|
// SPITType* ptrSPITType;
|
||||||
|
// SPITObject* ptrSPITObject;
|
||||||
|
|
||||||
|
// //StartProjectTransfer
|
||||||
|
// NotifyStartProjectTransfer_Client* o_RunnableStart = new NotifyStartProjectTransfer_Client(p_PtrSPIT_Client->getSPITClientInterface());
|
||||||
|
// SPIT_Handler::addRunnable(o_RunnableStart);
|
||||||
|
|
||||||
|
// ptrSMStartProjectTransfer = new SPIT_Message::StartProjectTransfer();
|
||||||
|
// intResult = p_PtrSPIT_Client->sendSPITMessage(ptrSMStartProjectTransfer);
|
||||||
|
// if (intResult < 0) {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // m_Watchdog->answerWatchdog();
|
||||||
|
// // {
|
||||||
|
// //send all listes SPITTypes
|
||||||
|
// // unique_lock<recursive_mutex> o_LockType(*SPITType::getMutex());
|
||||||
|
// intCount = SPITType::getSPITTypeCount();
|
||||||
|
// for (int i = 0; i < intCount; i++) {
|
||||||
|
// ptrSPITType = SPITType::getSPITType(i);
|
||||||
|
// if (ptrSPITType == NULL) continue;
|
||||||
|
// if (ptrSPITType->getCreatedByClient() == false) continue;
|
||||||
|
// intResult = p_PtrSPIT_Client->sendSPITTypeInternal(ptrSPITType);
|
||||||
|
// if (intResult < 0) return;
|
||||||
|
// // m_Watchdog->answerWatchdog();
|
||||||
|
// this_thread::sleep_for(chrono::milliseconds(7));
|
||||||
|
// }
|
||||||
|
// // }
|
||||||
|
|
||||||
|
// // {
|
||||||
|
// // unique_lock<recursive_mutex> o_LockObject(*SPITObject::getMutex());
|
||||||
|
// intCount = SPITObject::getSPITObjectCount();
|
||||||
|
// for (int i = 0; i < intCount; i++) {
|
||||||
|
// ptrSPITObject = SPITObject::getSPITObject(i);
|
||||||
|
// if (ptrSPITObject == NULL) continue;
|
||||||
|
// if (ptrSPITObject->getCreatedByClient() == false) continue;
|
||||||
|
// intResult = p_PtrSPIT_Client->sendSPITObjectInternal(ptrSPITObject);
|
||||||
|
// if (intResult < 0) return;
|
||||||
|
// // m_Watchdog->answerWatchdog();
|
||||||
|
// this_thread::sleep_for(chrono::milliseconds(7));
|
||||||
|
// }
|
||||||
|
// // }
|
||||||
|
|
||||||
|
// //EndProjectTransfer
|
||||||
|
// ptrSMEndProjectTransfer = new SPIT_Message::EndProjectTransfer();
|
||||||
|
// intResult = p_PtrSPIT_Client->sendSPITMessage(ptrSMEndProjectTransfer);
|
||||||
|
// if (intResult < 0) {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// // m_Watchdog->answerWatchdog();
|
||||||
|
// NotifyEndProjectTransfer_Client* o_RunnableEnd = new NotifyEndProjectTransfer_Client(p_PtrSPIT_Client->getSPITClientInterface());
|
||||||
|
// SPIT_Handler::addRunnable(o_RunnableEnd);
|
||||||
|
|
||||||
|
// //Send act
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void SPIT_Client::parseStartProjectTransfer(SPIT_Message::StartProjectTransfer* p_StartProjectTransfer) {
|
void SPIT_Client::parseStartProjectTransfer(SPIT_Message::StartProjectTransfer* p_StartProjectTransfer) {
|
||||||
mCallbacks.onStartProjectTransfer();
|
mCallbacks.onStartProjectTransfer();
|
||||||
}
|
}
|
||||||
void SPIT_Client::parseEndProjectTransfer(SPIT_Message::EndProjectTransfer* p_EndProjectTransfer) {
|
void SPIT_Client::parseEndProjectTransfer(SPIT_Message::EndProjectTransfer* p_EndProjectTransfer) {
|
||||||
|
SPITObject::clearUnconfirmedSPITObjects();
|
||||||
mCallbacks.onEndProjectTransfer();
|
mCallbacks.onEndProjectTransfer();
|
||||||
|
|
||||||
|
//Send SPIT_Message::ReportSPITProject after the m_SPITClientInterface is notfied of EndProjectTransfer
|
||||||
|
SPIT_Message::ReportSPITProject ptrSMReportSPITProject;
|
||||||
|
ptrSMReportSPITProject.setProjectID(m_ProjName);
|
||||||
|
ptrSMReportSPITProject.setProjectName(m_ProjName);
|
||||||
|
ptrSMReportSPITProject.setFramesPerSecond(0);
|
||||||
|
if (sendSPITMessage(ptrSMReportSPITProject) < 0) {
|
||||||
|
printf("SPIT_Client::parseReportSPITProject could not send Client's ReportSPITProject");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//----- SPIT Types ------
|
//----- SPIT Types ------
|
||||||
@@ -703,11 +982,15 @@ void SPIT_Client::parseReportSPITType(SPIT_Message::ReportSPITType* p_ReportSPIT
|
|||||||
if (p_ReportSPITType == NULL) return;
|
if (p_ReportSPITType == NULL) return;
|
||||||
SPITType* ptrSPITType;
|
SPITType* ptrSPITType;
|
||||||
bool boolNew = false;
|
bool boolNew = false;
|
||||||
|
bool boolChanged = false;
|
||||||
{
|
{
|
||||||
if (p_ReportSPITType->getServerRemote() == false) {
|
if (p_ReportSPITType->getServerRemote() == false) {
|
||||||
ptrSPITType = SPITType::getSPITType(p_ReportSPITType->getID());
|
ptrSPITType = SPITType::getSPITType(p_ReportSPITType->getID());
|
||||||
if (ptrSPITType == NULL) {
|
if (ptrSPITType == NULL) {
|
||||||
|
//The user's app my veto the SPITType
|
||||||
|
if (mCallbacks.onCheckSpitTypeVeto(p_ReportSPITType) == false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
ptrSPITType = new SPITType();
|
ptrSPITType = new SPITType();
|
||||||
boolNew = true;
|
boolNew = true;
|
||||||
}
|
}
|
||||||
@@ -719,7 +1002,10 @@ void SPIT_Client::parseReportSPITType(SPIT_Message::ReportSPITType* p_ReportSPIT
|
|||||||
boolNew = true;
|
boolNew = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ptrSPITType->setMessageOP(p_ReportSPITType) == false) {
|
try {
|
||||||
|
boolChanged = ptrSPITType->setMessageOP(p_ReportSPITType);
|
||||||
|
}
|
||||||
|
catch (...) {
|
||||||
//SPITType is not changable -> send back to the server
|
//SPITType is not changable -> send back to the server
|
||||||
sendSPITTypeInternal(ptrSPITType);
|
sendSPITTypeInternal(ptrSPITType);
|
||||||
return;
|
return;
|
||||||
@@ -736,7 +1022,7 @@ void SPIT_Client::parseReportSPITType(SPIT_Message::ReportSPITType* p_ReportSPIT
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ptrSPITType != NULL) {
|
if (ptrSPITType != NULL) {
|
||||||
if (ptrSPITType->setConfirmed(true) == true) {
|
if (ptrSPITType->setConfirmed(true) == true || boolChanged == true) {
|
||||||
sendSPITTypeInternal(ptrSPITType);
|
sendSPITTypeInternal(ptrSPITType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -796,7 +1082,6 @@ int SPIT_Client::sendSPITTypeInternal(SPITType* p_SPITType) {
|
|||||||
if (p_SPITType == NULL) return -1;
|
if (p_SPITType == NULL) return -1;
|
||||||
SPIT_Message::ReportSPITType ptrSMReportSPITType;
|
SPIT_Message::ReportSPITType ptrSMReportSPITType;
|
||||||
p_SPITType->fillMessageOP(&ptrSMReportSPITType);
|
p_SPITType->fillMessageOP(&ptrSMReportSPITType);
|
||||||
fillHeader(ptrSMReportSPITType.getHeader());
|
|
||||||
return sendSPITMessage(ptrSMReportSPITType);
|
return sendSPITMessage(ptrSMReportSPITType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -841,7 +1126,6 @@ int SPIT_Client::removeSPITType(string p_SPITTypeID) {
|
|||||||
if (ptrSPITType == NULL) return -1;
|
if (ptrSPITType == NULL) return -1;
|
||||||
SPIT_Message::RemoveSPITType sMRemoveSPITType;
|
SPIT_Message::RemoveSPITType sMRemoveSPITType;
|
||||||
ptrSPITType->fillMessageOP(&sMRemoveSPITType);
|
ptrSPITType->fillMessageOP(&sMRemoveSPITType);
|
||||||
fillHeader(sMRemoveSPITType.getHeader());
|
|
||||||
mCallbacks.onSpitTypeRemoved(*ptrSPITType);
|
mCallbacks.onSpitTypeRemoved(*ptrSPITType);
|
||||||
SPITType::removeSPITType(ptrSPITType);
|
SPITType::removeSPITType(ptrSPITType);
|
||||||
delete ptrSPITType;
|
delete ptrSPITType;
|
||||||
@@ -891,18 +1175,47 @@ void SPIT_Client::parseReportSPITObject(SPIT_Message::ReportSPITObject* p_Report
|
|||||||
SPITType* ptrSPITType;
|
SPITType* ptrSPITType;
|
||||||
bool boolNew = false;
|
bool boolNew = false;
|
||||||
bool boolRemote = false;
|
bool boolRemote = false;
|
||||||
|
bool boolChanged = false;
|
||||||
{
|
{
|
||||||
if (p_ReportSPITObject->getServerRemote() == false) {
|
if (p_ReportSPITObject->getServerRemote() == false) {
|
||||||
boolRemote = false;
|
boolRemote = false;
|
||||||
ptrSPITObject = SPITObject::getSPITObject(p_ReportSPITObject->getID());
|
ptrSPITObject = SPITObject::getSPITObject(p_ReportSPITObject->getID());
|
||||||
ptrSPITType = SPITType::getSPITType(p_ReportSPITObject->getSPITTypeID());
|
ptrSPITType = SPITType::getSPITType(p_ReportSPITObject->getSPITTypeID());
|
||||||
|
|
||||||
|
|
||||||
|
if (ptrSPITType == NULL) {
|
||||||
|
//No associated SPITType found
|
||||||
|
if (ptrSPITObject != NULL) {
|
||||||
|
//SpitObject exists but has no corresponding SPITType -> remove the SPITObject without sending a message
|
||||||
|
//Maybe the SPITObject has changed the SPITTypeID to a SPITTypeID of another board
|
||||||
|
SPITObject::removeSPITObject(ptrSPITObject);
|
||||||
|
delete ptrSPITObject;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (ptrSPITObject == NULL) {
|
||||||
|
//The user's app my veto the SPITType
|
||||||
|
if (mCallbacks.onCheckSpitObjectVeto(p_ReportSPITObject) == false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ptrSPITObject = new SPITObject();
|
||||||
|
boolNew = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//The user's app my veto the SPITType
|
||||||
|
if (mCallbacks.onCheckSpitObjectVeto(p_ReportSPITObject) == false) {
|
||||||
|
//SpitObject exists and User APp denied the SPITObject -> remove the SPITObject without sending a message
|
||||||
|
SPITObject::removeSPITObject(ptrSPITObject);
|
||||||
|
delete ptrSPITObject;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
boolRemote = true;
|
boolRemote = true;
|
||||||
ptrSPITObject = SPITObject::getSPITObjectRemote(p_ReportSPITObject->getID());
|
ptrSPITObject = SPITObject::getSPITObjectRemote(p_ReportSPITObject->getID());
|
||||||
ptrSPITType = SPITType::getSPITTypeRemote(p_ReportSPITObject->getSPITTypeID());
|
ptrSPITType = SPITType::getSPITTypeRemote(p_ReportSPITObject->getSPITTypeID());
|
||||||
}
|
|
||||||
if (ptrSPITType == NULL) {
|
if (ptrSPITType == NULL) {
|
||||||
//No associated SPITType found
|
//No associated SPITType found
|
||||||
return;
|
return;
|
||||||
@@ -911,8 +1224,17 @@ void SPIT_Client::parseReportSPITObject(SPIT_Message::ReportSPITObject* p_Report
|
|||||||
ptrSPITObject = new SPITObject();
|
ptrSPITObject = new SPITObject();
|
||||||
boolNew = true;
|
boolNew = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
boolChanged = ptrSPITObject->setMessageOP(p_ReportSPITObject);
|
||||||
|
}
|
||||||
|
catch (...) {
|
||||||
|
//setMessageOP error - the SPITObject can't be changed, it may be fixed and crated by this client
|
||||||
|
sendSPITObjectInternal(ptrSPITObject);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ptrSPITObject->setMessageOP(p_ReportSPITObject);
|
|
||||||
|
|
||||||
if (boolRemote == false) {
|
if (boolRemote == false) {
|
||||||
//set the virtual action assignment
|
//set the virtual action assignment
|
||||||
@@ -930,7 +1252,7 @@ void SPIT_Client::parseReportSPITObject(SPIT_Message::ReportSPITObject* p_Report
|
|||||||
mCallbacks.onSpitObject(boolNew, *ptrSPITType, *ptrSPITObject);
|
mCallbacks.onSpitObject(boolNew, *ptrSPITType, *ptrSPITObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ptrSPITObject->setConfirmed(true) == true) {
|
if (ptrSPITObject->setConfirmed(true) == true || boolChanged == true) {
|
||||||
//Confirmation has changed
|
//Confirmation has changed
|
||||||
sendSPITObjectInternal(ptrSPITObject);
|
sendSPITObjectInternal(ptrSPITObject);
|
||||||
}
|
}
|
||||||
@@ -976,7 +1298,6 @@ int SPIT_Client::sendSPITObjectInternal(SPITObject* ptrSPITObject) {
|
|||||||
if (ptrSPITObject == NULL) return -1;
|
if (ptrSPITObject == NULL) return -1;
|
||||||
SPIT_Message::ReportSPITObject ptrSMReportSPITObject;
|
SPIT_Message::ReportSPITObject ptrSMReportSPITObject;
|
||||||
ptrSPITObject->fillMessageOP(&ptrSMReportSPITObject);
|
ptrSPITObject->fillMessageOP(&ptrSMReportSPITObject);
|
||||||
fillHeader(ptrSMReportSPITObject.getHeader());
|
|
||||||
|
|
||||||
return sendSPITMessage(ptrSMReportSPITObject);
|
return sendSPITMessage(ptrSMReportSPITObject);
|
||||||
}
|
}
|
||||||
@@ -1041,7 +1362,6 @@ int SPIT_Client::removeSPITObject(string p_SPITObjectID) {
|
|||||||
ptrSPITType = SPITType::getSPITType(ptrSPITObject->getSPITTypeID());
|
ptrSPITType = SPITType::getSPITType(ptrSPITObject->getSPITTypeID());
|
||||||
if (ptrSPITType == NULL) return -1;
|
if (ptrSPITType == NULL) return -1;
|
||||||
ptrSPITObject->fillMessageOP(&sMRemoveSPITObject);
|
ptrSPITObject->fillMessageOP(&sMRemoveSPITObject);
|
||||||
fillHeader(sMRemoveSPITObject.getHeader());
|
|
||||||
mCallbacks.onSpitObjectRemoved(*ptrSPITType, *ptrSPITObject);
|
mCallbacks.onSpitObjectRemoved(*ptrSPITType, *ptrSPITObject);
|
||||||
SPITObject::removeSPITObject(ptrSPITObject);
|
SPITObject::removeSPITObject(ptrSPITObject);
|
||||||
delete ptrSPITObject;
|
delete ptrSPITObject;
|
||||||
@@ -1071,30 +1391,24 @@ void SPIT_Client::parsePlaySPITStart(SPIT_Message::PlaySPITStart* p_PlaySPITStar
|
|||||||
void SPIT_Client::parsePlaySPITObject(SPIT_Message::PlaySPITObject* p_PlaySPITObject) {
|
void SPIT_Client::parsePlaySPITObject(SPIT_Message::PlaySPITObject* p_PlaySPITObject) {
|
||||||
// printf("parse RPlaySPITObject Object:%s\n", p_PlaySPITObject->getSPITObjectID());
|
// printf("parse RPlaySPITObject Object:%s\n", p_PlaySPITObject->getSPITObjectID());
|
||||||
SPITPlayer* ptrSPITPlayer;
|
SPITPlayer* ptrSPITPlayer;
|
||||||
SPITPlayer::PlayObject* ptrPlayObject;
|
SPITPlayer::PlaySPITType* ptrPlaySPITType;
|
||||||
SPITObject* ptrSPITObject;
|
SPITObject* ptrSPITObject;
|
||||||
{
|
{
|
||||||
ptrSPITPlayer = SPITPlayer::getSPITPlayer(p_PlaySPITObject->getPlayerID());
|
ptrSPITPlayer = SPITPlayer::getSPITPlayer(p_PlaySPITObject->getPlayerID());
|
||||||
if (ptrSPITPlayer == NULL) return;
|
if (ptrSPITPlayer == NULL) return;
|
||||||
ptrPlayObject = ptrSPITPlayer->addSPITObject_Playing(p_PlaySPITObject->getSPITObjectID());
|
|
||||||
|
|
||||||
//Fetch infoemations from SPITObject
|
//Fetch infoemations from SPITObject
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
ptrSPITObject = SPITObject::getSPITObject(p_PlaySPITObject->getSPITObjectID());
|
ptrSPITObject = SPITObject::getSPITObject(p_PlaySPITObject->getSPITObjectID());
|
||||||
if (ptrSPITObject == NULL) {
|
if (ptrSPITObject == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (ptrPlayObject == NULL) {
|
ptrPlaySPITType = ptrSPITPlayer->addSPITType_Playing(ptrSPITObject->getSPITTypeID());
|
||||||
|
if (ptrPlaySPITType == NULL) {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ptrPlayObject->setPlayerIsRunning(ptrSPITPlayer->getIsRunning());
|
ptrPlaySPITType->setPlayerIsRunning(ptrSPITPlayer->getIsRunning());
|
||||||
ptrPlayObject->setFrameInside(p_PlaySPITObject->getFrameInsideObject(), p_PlaySPITObject->getPlayPrePosition());
|
ptrPlaySPITType->addValue(((double)p_PlaySPITObject->getValue()/1000000), ((double)ptrSPITObject->getValueFactor()/1000000));
|
||||||
ptrPlayObject->setValue(p_PlaySPITObject->getValue(), p_PlaySPITObject->getPlayPrePosition());
|
|
||||||
ptrPlayObject->setValueFactor(ptrSPITObject->getValueFactor());
|
|
||||||
ptrPlayObject->setValueFlag(p_PlaySPITObject->getValueFlag());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1102,44 +1416,69 @@ void SPIT_Client::parsePlaySPITEnd(SPIT_Message::PlaySPITEnd* p_PlaySPITEnd) {
|
|||||||
// printf("parse PlaySPITEnd \n");
|
// printf("parse PlaySPITEnd \n");
|
||||||
SPITPlayer* ptrSPITPlayer;
|
SPITPlayer* ptrSPITPlayer;
|
||||||
SPITType* ptrSPITType = NULL;
|
SPITType* ptrSPITType = NULL;
|
||||||
SPITObject* ptrSPITObject = NULL;
|
|
||||||
|
|
||||||
{
|
// {
|
||||||
|
// ptrSPITPlayer = SPITPlayer::getSPITPlayer(p_PlaySPITEnd->getPlayerID());
|
||||||
|
// if (ptrSPITPlayer == NULL) return;
|
||||||
|
|
||||||
|
// unordered_map<string, SPITPlayer::PlayObject*>* ptrPlayObjects;
|
||||||
|
// SPITPlayer::PlayObject* ptrPlayObject;
|
||||||
|
// bool boolStarted;
|
||||||
|
// bool boolStopped;
|
||||||
|
|
||||||
|
// ptrPlayObjects = ptrSPITPlayer->getPlayObjects();
|
||||||
|
// for (auto i = ptrPlayObjects->begin(); i != ptrPlayObjects->end(); i++) {
|
||||||
|
// ptrPlayObject = i->second;
|
||||||
|
// boolStarted = false;
|
||||||
|
// boolStopped = false;
|
||||||
|
// if (ptrPlayObject->getIsNew()) {
|
||||||
|
// boolStarted = true;
|
||||||
|
// }
|
||||||
|
// if (ptrPlayObject->getIsPlayed() == false) {
|
||||||
|
// boolStopped = true;
|
||||||
|
// }
|
||||||
|
// {
|
||||||
|
// ptrSPITObject = SPITObject::getSPITObject(ptrPlayObject->getSPITObjectID());
|
||||||
|
// if (ptrSPITObject == NULL) {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// ptrSPITType = SPITType::getSPITType(ptrSPITObject->getSPITTypeID());
|
||||||
|
// if (ptrSPITType == NULL) {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// mCallbacks.onPlaySpitType(ptrPlayObject->getPlayerID(), boolStarted, boolStopped, *ptrSPITType, *ptrSPITObject, *ptrPlayObject);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// ptrSPITPlayer->endPlaySequence();
|
||||||
|
// }
|
||||||
|
|
||||||
ptrSPITPlayer = SPITPlayer::getSPITPlayer(p_PlaySPITEnd->getPlayerID());
|
ptrSPITPlayer = SPITPlayer::getSPITPlayer(p_PlaySPITEnd->getPlayerID());
|
||||||
if (ptrSPITPlayer == NULL) return;
|
if (ptrSPITPlayer == NULL) return;
|
||||||
|
|
||||||
unordered_map<string, SPITPlayer::PlayObject*>* ptrPlayObjects;
|
unordered_map<string, SPITPlayer::PlaySPITType*>* ptrPlaySPITTypes = ptrSPITPlayer->getPlaySPITTypes();
|
||||||
SPITPlayer::PlayObject* ptrPlayObject;
|
for (auto i = ptrPlaySPITTypes->begin(); i != ptrPlaySPITTypes->end(); i++) {
|
||||||
bool boolStarted;
|
SPITPlayer::PlaySPITType* ptrPlaySPITType = i->second;
|
||||||
bool boolStopped;
|
bool boolStarted = false;
|
||||||
|
bool boolStopped = false;
|
||||||
ptrPlayObjects = ptrSPITPlayer->getPlayObjects();
|
if (ptrPlaySPITType->getIsNew()) {
|
||||||
for (auto i = ptrPlayObjects->begin(); i != ptrPlayObjects->end(); i++) {
|
|
||||||
ptrPlayObject = i->second;
|
|
||||||
boolStarted = false;
|
|
||||||
boolStopped = false;
|
|
||||||
if (ptrPlayObject->getIsNew()) {
|
|
||||||
boolStarted = true;
|
boolStarted = true;
|
||||||
}
|
}
|
||||||
if (ptrPlayObject->getIsPlayed() == false) {
|
if (ptrPlaySPITType->getIsPlayed() == false) {
|
||||||
boolStopped = true;
|
boolStopped = true;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
ptrSPITObject = SPITObject::getSPITObject(ptrPlayObject->getSPITObjectID());
|
ptrSPITType = SPITType::getSPITType(ptrPlaySPITType->getSPITTypeID());
|
||||||
if (ptrSPITObject == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ptrSPITType = SPITType::getSPITType(ptrSPITObject->getSPITTypeID());
|
|
||||||
if (ptrSPITType == NULL) {
|
if (ptrSPITType == NULL) {
|
||||||
return;
|
//set isplayed to false, the ptrPlayObject will be removed by ptrSPITPlayer->endPlaySequence()
|
||||||
|
ptrPlaySPITType->setIsPlayed(false);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
mCallbacks.onPlaySpitType(ptrPlaySPITType->getPlayerID(), ptrPlaySPITType->getSPITTypeID(), ptrPlaySPITType->getPlayerIsRunning(), boolStarted, boolStopped, ptrPlaySPITType->getValue() );
|
||||||
mCallbacks.onPlayObject(ptrPlayObject->getPlayerID(), boolStarted, boolStopped, *ptrSPITType, *ptrSPITObject, *ptrPlayObject);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ptrSPITPlayer->endPlaySequence();
|
ptrSPITPlayer->endPlaySequence();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SPIT_Client::parseReportPlayStatus(SPIT_Message::ReportPlayStatus* p_ReportPlayStatus) {
|
void SPIT_Client::parseReportPlayStatus(SPIT_Message::ReportPlayStatus* p_ReportPlayStatus) {
|
||||||
@@ -1151,10 +1490,19 @@ void SPIT_Client::parseReportPlayStatus(SPIT_Message::ReportPlayStatus* p_Report
|
|||||||
|
|
||||||
|
|
||||||
ptrSPITObject = SPITObject::getSPITObjectRemote(p_ReportPlayStatus->getID());
|
ptrSPITObject = SPITObject::getSPITObjectRemote(p_ReportPlayStatus->getID());
|
||||||
|
if (ptrSPITObject == NULL) {
|
||||||
|
ptrSPITObject = SPITObject::getSPITObject(p_ReportPlayStatus->getID());
|
||||||
if (ptrSPITObject == NULL) {
|
if (ptrSPITObject == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (ptrSPITObject->getServerRemote() == false) {
|
||||||
|
ptrSPITType = SPITType::getSPITType(ptrSPITObject->getSPITTypeID());
|
||||||
|
}
|
||||||
|
else {
|
||||||
ptrSPITType = SPITType::getSPITTypeRemote(ptrSPITObject->getSPITTypeID());
|
ptrSPITType = SPITType::getSPITTypeRemote(ptrSPITObject->getSPITTypeID());
|
||||||
|
}
|
||||||
|
|
||||||
if (ptrSPITType == NULL) {
|
if (ptrSPITType == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1185,7 +1533,6 @@ void SPIT_Client::sendRemoteObject(string p_SPITObjectID, int p_Valueppm, char p
|
|||||||
if (ptrRemoteSPITObject == NULL) return;
|
if (ptrRemoteSPITObject == NULL) return;
|
||||||
|
|
||||||
SPIT_Message::PlaySPITStart playSPITStart;
|
SPIT_Message::PlaySPITStart playSPITStart;
|
||||||
fillHeader(playSPITStart.getHeader());
|
|
||||||
playSPITStart.setPlayerID(m_ID);
|
playSPITStart.setPlayerID(m_ID);
|
||||||
playSPITStart.setPlayerName(m_ProjName);
|
playSPITStart.setPlayerName(m_ProjName);
|
||||||
playSPITStart.setPlayerIsRunning(false);
|
playSPITStart.setPlayerIsRunning(false);
|
||||||
@@ -1194,7 +1541,6 @@ void SPIT_Client::sendRemoteObject(string p_SPITObjectID, int p_Valueppm, char p
|
|||||||
sendSPITMessage(playSPITStart);
|
sendSPITMessage(playSPITStart);
|
||||||
|
|
||||||
SPIT_Message::PlaySPITObject playSPITObject;
|
SPIT_Message::PlaySPITObject playSPITObject;
|
||||||
fillHeader(playSPITObject.getHeader());
|
|
||||||
playSPITObject.setID(ptrRemoteSPITObject->getID());
|
playSPITObject.setID(ptrRemoteSPITObject->getID());
|
||||||
playSPITObject.setPlayPrePosition(false);
|
playSPITObject.setPlayPrePosition(false);
|
||||||
playSPITObject.setPlayerID(m_ID);
|
playSPITObject.setPlayerID(m_ID);
|
||||||
@@ -1203,7 +1549,6 @@ void SPIT_Client::sendRemoteObject(string p_SPITObjectID, int p_Valueppm, char p
|
|||||||
sendSPITMessage(playSPITObject);
|
sendSPITMessage(playSPITObject);
|
||||||
|
|
||||||
SPIT_Message::PlaySPITEnd playSPITEnd;
|
SPIT_Message::PlaySPITEnd playSPITEnd;
|
||||||
fillHeader(playSPITEnd.getHeader());
|
|
||||||
playSPITEnd.setPlayerID(m_ID);
|
playSPITEnd.setPlayerID(m_ID);
|
||||||
sendSPITMessage(playSPITEnd);
|
sendSPITMessage(playSPITEnd);
|
||||||
}
|
}
|
||||||
@@ -1223,7 +1568,7 @@ static constexpr int WATCHDOGTIME = 3000;
|
|||||||
string stringDatagram = SERVERAUTODETECT_PRECODE + SERVERAUTODETECT_SEPERATOR + SERVERAUTODETECT_TASKID;
|
string stringDatagram = SERVERAUTODETECT_PRECODE + SERVERAUTODETECT_SEPERATOR + SERVERAUTODETECT_TASKID;
|
||||||
int intDatagramLength = stringDatagram.length();
|
int intDatagramLength = stringDatagram.length();
|
||||||
string stringPart;
|
string stringPart;
|
||||||
string stringParts[9];
|
string stringParts[10];
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
sStartSad.take();
|
sStartSad.take();
|
||||||
@@ -1266,7 +1611,7 @@ static constexpr int WATCHDOGTIME = 3000;
|
|||||||
}
|
}
|
||||||
int intIndex = 0;
|
int intIndex = 0;
|
||||||
int intOldPos = 0;
|
int intOldPos = 0;
|
||||||
while (intIndex < 8) {
|
while (intIndex < SAD_DetectedServer::PARAMINDEX_IP) {
|
||||||
int intPos = stringMessage.find(SERVERAUTODETECT_SEPERATOR.data(), intOldPos);
|
int intPos = stringMessage.find(SERVERAUTODETECT_SEPERATOR.data(), intOldPos);
|
||||||
if (intPos == string::npos) {
|
if (intPos == string::npos) {
|
||||||
stringPart = "";
|
stringPart = "";
|
||||||
@@ -1277,7 +1622,7 @@ static constexpr int WATCHDOGTIME = 3000;
|
|||||||
stringParts[intIndex] = stringPart;
|
stringParts[intIndex] = stringPart;
|
||||||
intIndex++;
|
intIndex++;
|
||||||
}
|
}
|
||||||
stringParts[8] = stringServerIP;
|
stringParts[SAD_DetectedServer::PARAMINDEX_IP] = stringServerIP;
|
||||||
SAD_DetectedServer::addDetectedServer(true, stringParts[SAD_DetectedServer::PARAMINDEX_ID], stringParts);
|
SAD_DetectedServer::addDetectedServer(true, stringParts[SAD_DetectedServer::PARAMINDEX_ID], stringParts);
|
||||||
}
|
}
|
||||||
fos::Task::delayMs(100);
|
fos::Task::delayMs(100);
|
||||||
|
|||||||
Reference in New Issue
Block a user