refactor: moving SPIT-App parts to main app
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
class SAD_DetectedServer;
|
||||||
class I_SAD_Client {
|
class I_SAD_Client {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
@@ -20,7 +21,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_ProjectName, string p_ClientIP, bool p_IsIP4) = 0;
|
virtual void eventServerDetected(SAD_DetectedServer &server) = 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,6 +33,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 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(SAD_DetectedServer &server) = 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;
|
|
||||||
|
virtual void eventServerLost(SAD_DetectedServer &server) = 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,85 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* File: MySPITApp.h
|
|
||||||
* Author: Hagi
|
|
||||||
*
|
|
||||||
* Created on 17. April 2019, 18:24
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef MYSPITAPP_H
|
|
||||||
#define MYSPITAPP_H
|
|
||||||
|
|
||||||
#include "SPIT_Client.h"
|
|
||||||
#include <chrono>
|
|
||||||
#include <string>
|
|
||||||
#include "SPITType.h"
|
|
||||||
#include "SPITObject.h"
|
|
||||||
#include "SPITPlayer.h"
|
|
||||||
#include "SAD_DetectedServer.hpp"
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
class MyApp {
|
|
||||||
public:
|
|
||||||
MyApp();
|
|
||||||
// Client's infos is set by the client
|
|
||||||
static string s_ClientName;
|
|
||||||
static string s_ProjectName;
|
|
||||||
void init();
|
|
||||||
|
|
||||||
private:
|
|
||||||
SPIT_Client _SpitClient; // pointer to an instance of the SPIT_Client, which do the main work for you
|
|
||||||
|
|
||||||
// Server's project infos filled by eventProjectReport
|
|
||||||
static string m_ServerProjectID;
|
|
||||||
static string m_ServerProjectName;
|
|
||||||
static int m_ServerFramesPerSecond; // set when the server reports his project, see eventProjectReport
|
|
||||||
// liveSHOWsoftware will use 44100 frames per second as time resolution
|
|
||||||
// All times are given in frames,
|
|
||||||
|
|
||||||
public:
|
|
||||||
static void onServerEvent(SPIT_Client::ServerEvent event, const SAD_DetectedServer &p_DetectedServer);
|
|
||||||
static void onConnectionStatus(string p_ServerID, string p_ServerComputerName, string p_ServerName, int p_ServerStepTime, int p_ConnectionStatus, int p_OldConnectionStatus);
|
|
||||||
|
|
||||||
//----- Project -----
|
|
||||||
static void onStartProjectTransfer();
|
|
||||||
static void onEndProjectTransfer();
|
|
||||||
static void onProjectReport(string p_ProjectID, string p_ProjectName, int p_FramesPerSeoond);
|
|
||||||
static void onProjectClosed(string p_ProjectID);
|
|
||||||
|
|
||||||
//----- SPITType -----
|
|
||||||
static bool onCheckSpitTypeVeto(SPIT_Message::ReportSPITType* p_ReportSPITType);
|
|
||||||
static void onSpitType(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 onSpitTypeRemoteRemoved(const SPITType &p_SPITType);
|
|
||||||
|
|
||||||
//----- 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 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 onSpitObjectRemoteRemoved(const SPITType &p_SPITType, const SPITObject &p_SPITObject);
|
|
||||||
|
|
||||||
//----- Play SPITObjects -----
|
|
||||||
static void onPlay(string p_PlayerID, string p_PlayerName, char p_PlayerType, bool p_PlayerIsRunning, long long p_TimeFrames);
|
|
||||||
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 -----
|
|
||||||
// REMOTE only Server->Client RemoteObject's play status
|
|
||||||
static void onPlayRemoteObjectStatus(const SPITType &p_SPITType, const SPITObject &p_SPITObject, long long p_FrameInsideObject, int p_Value);
|
|
||||||
|
|
||||||
void sendRemoteObject(string p_SPITObjectID, int p_Valueppm = 0, char p_ValueFlag = 0x00);
|
|
||||||
//-----
|
|
||||||
void testLiveShowRemote();
|
|
||||||
|
|
||||||
//------ User's options normally should not be used, the server is master of things ------
|
|
||||||
public:
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* MYSPITAPP_H */
|
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "I_SAD_Client.hpp"
|
#include "I_SAD_Client.hpp"
|
||||||
|
#include <list>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <list>
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@@ -16,7 +16,6 @@ public:
|
|||||||
m_Name = orig.getName();
|
m_Name = orig.getName();
|
||||||
m_ComputerName = orig.getComputerName();
|
m_ComputerName = orig.getComputerName();
|
||||||
m_IP = orig.getIP();
|
m_IP = orig.getIP();
|
||||||
m_IPIsIP4 = orig.getIpIsIP4();
|
|
||||||
m_ClientIP = orig.getClientIP();
|
m_ClientIP = orig.getClientIP();
|
||||||
m_Port = orig.getPort();
|
m_Port = orig.getPort();
|
||||||
m_Additions = orig.getAdditions();
|
m_Additions = orig.getAdditions();
|
||||||
@@ -28,7 +27,6 @@ public:
|
|||||||
string m_Name;
|
string m_Name;
|
||||||
string m_ComputerName;
|
string m_ComputerName;
|
||||||
string m_IP;
|
string m_IP;
|
||||||
bool m_IPIsIP4;
|
|
||||||
string m_ClientIP;
|
string m_ClientIP;
|
||||||
string m_Port;
|
string m_Port;
|
||||||
string m_Additions;
|
string m_Additions;
|
||||||
@@ -42,11 +40,11 @@ public:
|
|||||||
string getName() const { return m_Name; }
|
string getName() const { return m_Name; }
|
||||||
string getComputerName() const { return m_ComputerName; }
|
string getComputerName() const { return m_ComputerName; }
|
||||||
string getIP() const { return m_IP; }
|
string getIP() const { return m_IP; }
|
||||||
bool getIpIsIP4() const { return m_IPIsIP4; }
|
|
||||||
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; }
|
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; }
|
||||||
@@ -57,7 +55,6 @@ private:
|
|||||||
void setAdditions(string p_Additions) { m_Additions = p_Additions; }
|
void setAdditions(string p_Additions) { m_Additions = p_Additions; }
|
||||||
void setProjectName(string p_ServerProjectName);
|
void setProjectName(string p_ServerProjectName);
|
||||||
|
|
||||||
void setIPIsIP4(bool p_IsIP4) { m_IPIsIP4 = p_IsIP4; }
|
|
||||||
bool getNew() const { return m_New; }
|
bool getNew() const { return m_New; }
|
||||||
bool getChanged() const { return m_Changed; }
|
bool getChanged() const { return m_Changed; }
|
||||||
bool getFoundAgain() const { return m_FoundAgain; }
|
bool getFoundAgain() const { return m_FoundAgain; }
|
||||||
@@ -67,15 +64,14 @@ private:
|
|||||||
|
|
||||||
// SAD_Client m_ThreadSend will send to Multicast addresses
|
// SAD_Client m_ThreadSend will send to Multicast addresses
|
||||||
void startCycleSAD() {
|
void startCycleSAD() {
|
||||||
m_IPIsIP4 = false;
|
|
||||||
m_Changed = false;
|
m_Changed = false;
|
||||||
m_FoundAgain = false;
|
m_FoundAgain = false;
|
||||||
m_New = false;
|
m_New = false;
|
||||||
}
|
}
|
||||||
//SAD_Client m_Thread_Send has paused in the meantime m_ThreadReceive may received messages from servers
|
|
||||||
void endCycleSAD() { }
|
|
||||||
private:
|
private:
|
||||||
static unordered_map<string, SAD_DetectedServer *> s_DetectedServers;
|
static unordered_map<string, SAD_DetectedServer *> s_DetectedServers;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static const int PARAMINDEX_PRECODE = 0;
|
static const int PARAMINDEX_PRECODE = 0;
|
||||||
static const int PARAMINDEX_SPITTASKID = 1;
|
static const int PARAMINDEX_SPITTASKID = 1;
|
||||||
@@ -93,12 +89,12 @@ public:
|
|||||||
* @param p_ServerID the id of the server, every instance of a SPITServer has an own id
|
* @param p_ServerID the id of the server, every instance of a SPITServer has an own id
|
||||||
* @param p_ServerParams the server's parameter
|
* @param p_ServerParams the server's parameter
|
||||||
*/
|
*/
|
||||||
static void addDetectedServer(bool p_IsIP4, string p_ServerID, string p_ServerParams[]);
|
static void addDetectedServer(string p_ServerID, string p_ServerParams[]);
|
||||||
/**
|
/**
|
||||||
* Used by SAD_Client to remove a SPITServer - don't use this manually
|
* Used by SAD_Client to remove a SPITServer - don't use this manually
|
||||||
* @param p_DetectedServer
|
* @param p_DetectedServer
|
||||||
*/
|
*/
|
||||||
static void removeDetectedServer(SAD_DetectedServer* p_DetectedServer);
|
static void removeDetectedServer(SAD_DetectedServer &server);
|
||||||
/**
|
/**
|
||||||
* Used by SAD_Client to clear all found SPITServers - don't use this manually
|
* Used by SAD_Client to clear all found SPITServers - don't use this manually
|
||||||
*/
|
*/
|
||||||
@@ -119,20 +115,5 @@ public:
|
|||||||
* @param p_ServerID the id of the SPITServer
|
* @param p_ServerID the id of the SPITServer
|
||||||
* @return the reference of the SAD_DetectedServer instance with getID() == p_ServerID
|
* @return the reference of the SAD_DetectedServer instance with getID() == p_ServerID
|
||||||
*/
|
*/
|
||||||
static const SAD_DetectedServer& getRefDetectedServer(string p_ServerID) {
|
static const SAD_DetectedServer &getRefDetectedServer(string p_ServerID);
|
||||||
SAD_DetectedServer* ptrDetectedServer = NULL;
|
|
||||||
{
|
|
||||||
auto i = s_DetectedServers.find(p_ServerID);
|
|
||||||
if (i != s_DetectedServers.end()) {
|
|
||||||
ptrDetectedServer = i->second;
|
|
||||||
}
|
|
||||||
if (ptrDetectedServer != NULL) {
|
|
||||||
return *ptrDetectedServer;
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new exception();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -14,8 +14,8 @@
|
|||||||
#ifndef SPITOBJECT_H
|
#ifndef SPITOBJECT_H
|
||||||
#define SPITOBJECT_H
|
#define SPITOBJECT_H
|
||||||
|
|
||||||
#include "SPIT_Message.h"
|
|
||||||
#include "SPITType.h"
|
#include "SPITType.h"
|
||||||
|
#include "SPIT_Message.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
@@ -25,9 +25,9 @@ class SPITObjectListener;
|
|||||||
|
|
||||||
class SPITObject {
|
class SPITObject {
|
||||||
private:
|
private:
|
||||||
|
|
||||||
static unordered_map<string, SPITObject *> s_SPITObjects;
|
static unordered_map<string, SPITObject *> s_SPITObjects;
|
||||||
static unordered_map<string, SPITObject *> s_SPITObjectsRemote;
|
static unordered_map<string, SPITObject *> s_SPITObjectsRemote;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static SPITObject *getSPITObject(string p_ID);
|
static SPITObject *getSPITObject(string p_ID);
|
||||||
static const SPITObject &getSPITObjectRef(string p_ID);
|
static const SPITObject &getSPITObjectRef(string p_ID);
|
||||||
@@ -56,6 +56,7 @@ public:
|
|||||||
SPITObject();
|
SPITObject();
|
||||||
// SPITObject(const SPITObject& orig);
|
// SPITObject(const SPITObject& orig);
|
||||||
~SPITObject();
|
~SPITObject();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
string m_ID;
|
string m_ID;
|
||||||
string m_Name;
|
string m_Name;
|
||||||
@@ -83,8 +84,8 @@ private:
|
|||||||
int m_PlayValue;
|
int m_PlayValue;
|
||||||
char m_PlayValueFlag;
|
char m_PlayValueFlag;
|
||||||
|
|
||||||
|
|
||||||
void initMembers();
|
void initMembers();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
string getID() const { return m_ID; }
|
string getID() const { return m_ID; }
|
||||||
string getName() const { return m_Name; }
|
string getName() const { return m_Name; }
|
||||||
@@ -135,12 +136,13 @@ public:
|
|||||||
SPITType *ptrSPITType;
|
SPITType *ptrSPITType;
|
||||||
if (m_ServerRemote == false) {
|
if (m_ServerRemote == false) {
|
||||||
ptrSPITType = SPITType::getSPITType(m_SPITTypeID);
|
ptrSPITType = SPITType::getSPITType(m_SPITTypeID);
|
||||||
if (ptrSPITType == NULL) return true;
|
if (ptrSPITType == NULL)
|
||||||
|
return true;
|
||||||
return ptrSPITType->getProjectIndepended();
|
return ptrSPITType->getProjectIndepended();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
ptrSPITType = SPITType::getSPITTypeRemote(m_SPITTypeID);
|
ptrSPITType = SPITType::getSPITTypeRemote(m_SPITTypeID);
|
||||||
if (ptrSPITType == NULL) return true;
|
if (ptrSPITType == NULL)
|
||||||
|
return true;
|
||||||
return ptrSPITType->getProjectIndepended();
|
return ptrSPITType->getProjectIndepended();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -171,6 +173,4 @@ public:
|
|||||||
void fillMessageOP(SPIT_Message::RemoveSPITObject *p_RemoveSPITObject);
|
void fillMessageOP(SPIT_Message::RemoveSPITObject *p_RemoveSPITObject);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif /* SPITOBJECT_H */
|
#endif /* SPITOBJECT_H */
|
||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,6 @@ public:
|
|||||||
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
|
||||||
PlaySPITType *addSPITType_Playing(string p_SPITTypeID); // 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
|
||||||
@@ -93,4 +92,3 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
#endif /* SPITPLAYER_H */
|
#endif /* SPITPLAYER_H */
|
||||||
|
|
||||||
|
|||||||
@@ -16,17 +16,17 @@
|
|||||||
#ifndef SPITSOCKET_H
|
#ifndef SPITSOCKET_H
|
||||||
#define SPITSOCKET_H
|
#define SPITSOCKET_H
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include "esp_netif.h"
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <netdb.h>
|
|
||||||
#include <arpa/inet.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include "Task.hpp"
|
#include "Task.hpp"
|
||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
|
#include "esp_netif.h"
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <netdb.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <string>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@@ -88,7 +88,6 @@ public:
|
|||||||
m_BoundClientFamily = 0;
|
m_BoundClientFamily = 0;
|
||||||
m_IsBound = false;
|
m_IsBound = false;
|
||||||
createSocket_UDP();
|
createSocket_UDP();
|
||||||
|
|
||||||
}
|
}
|
||||||
virtual ~SPITSocket() {
|
virtual ~SPITSocket() {
|
||||||
ESP_LOGD("UDP", "Shutting down ...");
|
ESP_LOGD("UDP", "Shutting down ...");
|
||||||
@@ -101,6 +100,7 @@ public:
|
|||||||
fos::Task::delayMs(100);
|
fos::Task::delayMs(100);
|
||||||
m_IsBound = false;
|
m_IsBound = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
string m_ServerIP;
|
string m_ServerIP;
|
||||||
string m_ServerPort;
|
string m_ServerPort;
|
||||||
@@ -164,4 +164,3 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
#endif /* SPITSOCKET_H */
|
#endif /* SPITSOCKET_H */
|
||||||
|
|
||||||
|
|||||||
@@ -54,8 +54,8 @@ public:
|
|||||||
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);
|
||||||
// SPITType(const SPITType& orig);
|
// SPITType(const SPITType& orig);
|
||||||
~SPITType();
|
~SPITType();
|
||||||
private:
|
|
||||||
|
|
||||||
|
private:
|
||||||
bool m_Confirmed;
|
bool m_Confirmed;
|
||||||
string m_ID;
|
string m_ID;
|
||||||
bool m_Fixed;
|
bool m_Fixed;
|
||||||
@@ -110,7 +110,6 @@ public:
|
|||||||
return m_ActionAssigned;
|
return m_ActionAssigned;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void setID(string p_ID);
|
void setID(string p_ID);
|
||||||
bool setGroupName(string p_GroupName);
|
bool setGroupName(string p_GroupName);
|
||||||
@@ -138,5 +137,4 @@ public:
|
|||||||
// static char* stringCopy(const char* p_String);
|
// static char* stringCopy(const char* p_String);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif /* SPITTYPE_H */
|
#endif /* SPITTYPE_H */
|
||||||
@@ -14,12 +14,12 @@
|
|||||||
#ifndef SPIT_CLIENT_H
|
#ifndef SPIT_CLIENT_H
|
||||||
#define SPIT_CLIENT_H
|
#define SPIT_CLIENT_H
|
||||||
|
|
||||||
#include "SPITSocket.h"
|
|
||||||
#include "SAD_DetectedServer.hpp"
|
#include "SAD_DetectedServer.hpp"
|
||||||
#include "SPIT_Message.h"
|
|
||||||
#include "SPITType.h"
|
|
||||||
#include "SPITObject.h"
|
#include "SPITObject.h"
|
||||||
#include "SPITPlayer.h"
|
#include "SPITPlayer.h"
|
||||||
|
#include "SPITSocket.h"
|
||||||
|
#include "SPITType.h"
|
||||||
|
#include "SPIT_Message.h"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -31,32 +31,38 @@ public:
|
|||||||
/** Maximal length of a SPITMessage*/
|
/** Maximal length of a SPITMessage*/
|
||||||
static const int MAXSPITMESSAGEBYTECOUNT = 512;
|
static const int MAXSPITMESSAGEBYTECOUNT = 512;
|
||||||
|
|
||||||
enum ServerEvent {
|
enum class ProjUpdate {
|
||||||
|
ServerLoaded,
|
||||||
|
StartTransfer,
|
||||||
|
EndTransfer,
|
||||||
|
ServerClosed,
|
||||||
|
};
|
||||||
|
enum class ServerEvent {
|
||||||
Detect,
|
Detect,
|
||||||
Lost,
|
Lost,
|
||||||
Changed,
|
Changed,
|
||||||
};
|
};
|
||||||
|
enum class ObjectEvent {
|
||||||
|
Created,
|
||||||
|
Changed,
|
||||||
|
Deleted
|
||||||
|
};
|
||||||
|
|
||||||
struct Callbacks {
|
struct Callbacks {
|
||||||
void(*onServerEvent)(ServerEvent event, const SAD_DetectedServer &p_DetectedServer);
|
void (*onServerEvent)(ServerEvent event, 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 (*onConnectionStatus)(string p_ServerID, string p_ServerComputerName, string p_ServerName, int p_ServerStepTime, int p_ConnectionStatus, int p_OldConnectionStatus){};
|
||||||
void(*onStartProjectTransfer)();
|
void (*onProjectUpdate)(ProjUpdate state, string projectId){};
|
||||||
void(*onEndProjectTransfer)();
|
|
||||||
void(*onProjectClosed)(string);
|
void (*onSpitType)(ObjectEvent event, const SPITType &p_SPITType){};
|
||||||
void(*onProjectReport)(string p_ProjectID, string p_ProjectName, int p_FramesPerSeoond);
|
void (*onSpitTypeRemote)(ObjectEvent event, const SPITType &p_SPITType){};
|
||||||
void(*onSpitType)(bool p_New, const SPITType &p_SPITType);
|
void (*onSpitObject)(ObjectEvent event, const SPITType &p_SPITType, const SPITObject &p_SPITObject){};
|
||||||
void(*onSpitTypeRemote)(bool p_New, const SPITType &p_SPITType);
|
void (*onSpitObjectRemote)(ObjectEvent event, const SPITType &p_SPITType, const SPITObject &p_SPITObject){};
|
||||||
void(*onSpitObject)(bool p_New, const SPITType &p_SPITType, const SPITObject &p_SPITObject);
|
|
||||||
void(*onSpitObjectRemote)(bool p_New, 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(*onSpitTypeRemoved)(const SPITType &p_SPITType);
|
void (*onPlaySpitType)(string p_PlayerID, string p_SPITTypeID, bool p_PlayerIsRunning, bool p_Started, bool p_Ended, double p_Value){};
|
||||||
void(*onSpitTypeRemoteRemoved)(const SPITType &p_SPITType);
|
void (*onPlayRemoteObjectStatus)(const SPITType &p_SPITType, const SPITObject &p_SPITObject, long long p_FrameInsideObject, int p_Value){};
|
||||||
void(*onSpitObjectRemoved)(const SPITType &p_SPITType, const SPITObject &p_SPITObject);
|
bool (*onCheckSpitTypeVeto)(SPIT_Message::ReportSPITType *p_ReportSPITType){};
|
||||||
void(*onSpitObjectRemoteRemoved)(const SPITType &p_SPITType, const SPITObject &p_SPITObject);
|
bool (*onCheckSpitObjectVeto)(SPIT_Message::ReportSPITObject *p_ReportSPITObject){};
|
||||||
void(*onPlay)(string p_PlayerID, string p_PlayerName, char p_PlayerType, bool p_PlayerIsRunning, long long p_TimeFrames);
|
|
||||||
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);
|
|
||||||
bool(*onCheckSpitTypeVeto)(SPIT_Message::ReportSPITType* p_ReportSPITType);
|
|
||||||
bool(*onCheckSpitObjectVeto)(SPIT_Message::ReportSPITObject* p_ReportSPITObject);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//----- Connection Status -----
|
//----- Connection Status -----
|
||||||
@@ -96,6 +102,7 @@ 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;
|
static int s_MAX_OVERTAKING_SPIT_MESSAGES;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Callbacks mCallbacks;
|
Callbacks mCallbacks;
|
||||||
|
|
||||||
@@ -184,10 +191,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_ProjectName, string p_ClientIP, bool p_IsIP4);
|
void eventServerDetected(SAD_DetectedServer &server);
|
||||||
/** 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_ProjectName, string p_ClientIP, bool p_IsIP4);
|
void eventServerLost(SAD_DetectedServer &server);
|
||||||
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);
|
void eventServerChanged(SAD_DetectedServer &server);
|
||||||
|
|
||||||
//--------------- Connection ---------------
|
//--------------- Connection ---------------
|
||||||
public:
|
public:
|
||||||
@@ -218,6 +225,7 @@ private:
|
|||||||
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);
|
||||||
void parseWatchdogAnswer(SPIT_Message::WatchdogAnswer *p_WatchdogAnswer);
|
void parseWatchdogAnswer(SPIT_Message::WatchdogAnswer *p_WatchdogAnswer);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/** Used internally*/
|
/** Used internally*/
|
||||||
void sendWatchdog();
|
void sendWatchdog();
|
||||||
@@ -227,6 +235,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
void parseReportSPITProject(SPIT_Message::ReportSPITProject *p_ReportSPITProject);
|
void parseReportSPITProject(SPIT_Message::ReportSPITProject *p_ReportSPITProject);
|
||||||
void parseCloseSPITProject(SPIT_Message::CloseSPITProject *p_CloseSPITProject);
|
void parseCloseSPITProject(SPIT_Message::CloseSPITProject *p_CloseSPITProject);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/** Returns the SPITServer's project ID - may be the same as the project's name*/
|
/** Returns the SPITServer's project ID - may be the same as the project's name*/
|
||||||
string getServerProjectID();
|
string getServerProjectID();
|
||||||
@@ -239,6 +248,7 @@ 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:
|
public:
|
||||||
static void sendProject(SPIT_Client *p_PtrSPIT_Client);
|
static void sendProject(SPIT_Client *p_PtrSPIT_Client);
|
||||||
|
|
||||||
@@ -270,11 +280,13 @@ public:
|
|||||||
* @return the pointer to the new SPITType.
|
* @return the pointer to the new SPITType.
|
||||||
*/
|
*/
|
||||||
SPITType *createSPITType(string p_ID, string p_GroupName, string p_Name, long long p_DefaultDelay, long long p_DefaultDuration, bool p_Fixed, bool p_ProjectIndepended);
|
SPITType *createSPITType(string p_ID, string p_GroupName, string p_Name, long long p_DefaultDelay, long long p_DefaultDuration, bool p_Fixed, bool p_ProjectIndepended);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// receive SPITTypes
|
// receive SPITTypes
|
||||||
void parseReportSPITType(SPIT_Message::ReportSPITType *p_ReportSPITType);
|
void parseReportSPITType(SPIT_Message::ReportSPITType *p_ReportSPITType);
|
||||||
void parseRemoveSPITType(SPIT_Message::RemoveSPITType *p_RemoveSPITType);
|
void parseRemoveSPITType(SPIT_Message::RemoveSPITType *p_RemoveSPITType);
|
||||||
int sendSPITTypeInternal(SPITType *p_SPITType);
|
int sendSPITTypeInternal(SPITType *p_SPITType);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* If a client wants to change a SPITType, he should send it to the server.<br>
|
* If a client wants to change a SPITType, he should send it to the server.<br>
|
||||||
@@ -290,13 +302,14 @@ public:
|
|||||||
* @return 0 = is sended, -1 = is not sended
|
* @return 0 = is sended, -1 = is not sended
|
||||||
*/
|
*/
|
||||||
int removeSPITType(string p_SPITTypeID);
|
int removeSPITType(string p_SPITTypeID);
|
||||||
public:
|
|
||||||
|
|
||||||
|
public:
|
||||||
//--------------- SPIT Objects ---------------
|
//--------------- SPIT Objects ---------------
|
||||||
private:
|
private:
|
||||||
void parseReportSPITObject(SPIT_Message::ReportSPITObject *p_ReportSPITObject);
|
void parseReportSPITObject(SPIT_Message::ReportSPITObject *p_ReportSPITObject);
|
||||||
void parseRemoveSPITObject(SPIT_Message::RemoveSPITObject *p_RemoveSPITObject);
|
void parseRemoveSPITObject(SPIT_Message::RemoveSPITObject *p_RemoveSPITObject);
|
||||||
int sendSPITObjectInternal(SPITObject *ptrSPITObject);
|
int sendSPITObjectInternal(SPITObject *ptrSPITObject);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* When the client changes a SPITObject (normally the client should not do this), then it should send the changes to the SPITServer.<br>
|
* When the client changes a SPITObject (normally the client should not do this), then it should send the changes to the SPITServer.<br>
|
||||||
@@ -312,8 +325,8 @@ public:
|
|||||||
* @return 0 = sended, -1 = not sended
|
* @return 0 = sended, -1 = not sended
|
||||||
*/
|
*/
|
||||||
int removeSPITObject(string p_SPITObjectID);
|
int removeSPITObject(string p_SPITObjectID);
|
||||||
public:
|
|
||||||
|
|
||||||
|
public:
|
||||||
//--------------- Play SPIT Objects ---------------
|
//--------------- Play SPIT Objects ---------------
|
||||||
private:
|
private:
|
||||||
void parsePlaySPITStart(SPIT_Message::PlaySPITStart *p_PlaySPITStart);
|
void parsePlaySPITStart(SPIT_Message::PlaySPITStart *p_PlaySPITStart);
|
||||||
@@ -335,8 +348,6 @@ private:
|
|||||||
void answerWatchdog() {
|
void answerWatchdog() {
|
||||||
sAnswered = true;
|
sAnswered = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* SPIT_CLIENT_H */
|
#endif /* SPIT_CLIENT_H */
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ static char nullChar[] = "\0";
|
|||||||
class SPIT_Message {
|
class SPIT_Message {
|
||||||
//----------- Header -----------
|
//----------- Header -----------
|
||||||
public:
|
public:
|
||||||
|
|
||||||
class Header {
|
class Header {
|
||||||
public:
|
public:
|
||||||
static const int BYTESLENGTH = 99;
|
static const int BYTESLENGTH = 99;
|
||||||
@@ -46,27 +45,13 @@ public:
|
|||||||
void initMembers();
|
void initMembers();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
const string getSPITID() const {
|
const string getSPITID() const { return m_SPITID; }
|
||||||
return m_SPITID;
|
int getSPITVersion() const { return m_SPITVersion; }
|
||||||
}
|
unsigned char getMessageNumber() const { return m_MessageNumber; }
|
||||||
int getSPITVersion() const {
|
int getBytesCount() const { return m_BytesCount; }
|
||||||
return m_SPITVersion;
|
const string getServerID() const { return m_ServerID; }
|
||||||
}
|
const string getClientID() const { return m_ClientID; }
|
||||||
unsigned char getMessageNumber() const {
|
int getOPFlag() const { return m_OPFlag; }
|
||||||
return m_MessageNumber;
|
|
||||||
}
|
|
||||||
int getBytesCount() const {
|
|
||||||
return m_BytesCount;
|
|
||||||
}
|
|
||||||
const string getServerID() const {
|
|
||||||
return m_ServerID;
|
|
||||||
}
|
|
||||||
const string getClientID() const {
|
|
||||||
return m_ClientID;
|
|
||||||
}
|
|
||||||
int getOPFlag() const {
|
|
||||||
return m_OPFlag;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Receive
|
// Receive
|
||||||
public:
|
public:
|
||||||
@@ -91,29 +76,30 @@ public:
|
|||||||
Header *m_Header;
|
Header *m_Header;
|
||||||
int m_ParseOffset;
|
int m_ParseOffset;
|
||||||
int m_BytesCount;
|
int m_BytesCount;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initMembers();
|
void initMembers();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~OPPart();
|
virtual ~OPPart();
|
||||||
// OPPart(const OPPart& orig);
|
// OPPart(const OPPart& orig);
|
||||||
Header* getHeader() const {
|
Header *getHeader() const { return m_Header; }
|
||||||
return m_Header;
|
int getBytesCount() const { return m_BytesCount; }
|
||||||
}
|
|
||||||
|
|
||||||
int getBytesCount() const {
|
|
||||||
return m_BytesCount;
|
|
||||||
}
|
|
||||||
const string getServerID() const {
|
const string getServerID() const {
|
||||||
if (m_Header == NULL) return "";
|
if (m_Header == NULL)
|
||||||
|
return "";
|
||||||
return m_Header->getServerID();
|
return m_Header->getServerID();
|
||||||
}
|
}
|
||||||
const string getClientID() const {
|
const string getClientID() const {
|
||||||
if (m_Header == NULL) return "";
|
if (m_Header == NULL)
|
||||||
|
return "";
|
||||||
return m_Header->getClientID();
|
return m_Header->getClientID();
|
||||||
}
|
}
|
||||||
|
|
||||||
int getOPFlag() const {
|
int getOPFlag() const {
|
||||||
if (m_Header == NULL) return -1;
|
if (m_Header == NULL)
|
||||||
|
return -1;
|
||||||
return m_Header->getOPFlag();
|
return m_Header->getOPFlag();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,7 +115,6 @@ public:
|
|||||||
virtual bool fillBytes(char *p_Bytes, int p_ByteCount) = 0;
|
virtual bool fillBytes(char *p_Bytes, int p_ByteCount) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//----------- SPIT_Message -----------
|
//----------- SPIT_Message -----------
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -150,7 +135,6 @@ public:
|
|||||||
static const char VALUEFLAG_INCREASE = 0x01; // increase the value
|
static const char VALUEFLAG_INCREASE = 0x01; // increase the value
|
||||||
static const char VALUEFLAG_DECREASE = 0x02; // decrease the value
|
static const char VALUEFLAG_DECREASE = 0x02; // decrease the value
|
||||||
|
|
||||||
|
|
||||||
SPIT_Message();
|
SPIT_Message();
|
||||||
virtual ~SPIT_Message();
|
virtual ~SPIT_Message();
|
||||||
// SPIT_Message(const SPIT_Message& orig);
|
// SPIT_Message(const SPIT_Message& orig);
|
||||||
@@ -170,19 +154,14 @@ public:
|
|||||||
SPIT_Message(char *p_MessageBytes, int p_MessageBytesLength);
|
SPIT_Message(char *p_MessageBytes, int p_MessageBytesLength);
|
||||||
|
|
||||||
// SPIT_Message(const SPIT_Message& orig);
|
// SPIT_Message(const SPIT_Message& orig);
|
||||||
const Header* getHeader() const {
|
const Header *getHeader() const { return m_Header; }
|
||||||
return m_Header;
|
|
||||||
}
|
|
||||||
int getOPFlag() const {
|
int getOPFlag() const {
|
||||||
if (m_Header == NULL) return -1;
|
if (m_Header == NULL)
|
||||||
|
return -1;
|
||||||
return m_Header->getOPFlag();
|
return m_Header->getOPFlag();
|
||||||
}
|
}
|
||||||
const OPPart* getOPPart() const {
|
const OPPart *getOPPart() const { return m_OPPart; }
|
||||||
return m_OPPart;
|
int getMesageByteCount() const { return m_MessageByteCount; }
|
||||||
}
|
|
||||||
int getMesageByteCount() const {
|
|
||||||
return m_MessageByteCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
OPPart *parse();
|
OPPart *parse();
|
||||||
|
|
||||||
@@ -192,9 +171,6 @@ public:
|
|||||||
bool fillBytes();
|
bool fillBytes();
|
||||||
const char *getMessageBytes();
|
const char *getMessageBytes();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//------------------------------ Connection ----------------------------------
|
//------------------------------ Connection ----------------------------------
|
||||||
|
|
||||||
//----------- Connect -----------
|
//----------- Connect -----------
|
||||||
@@ -212,6 +188,7 @@ public:
|
|||||||
string m_ServerIP;
|
string m_ServerIP;
|
||||||
int m_ServerPort;
|
int m_ServerPort;
|
||||||
void initMembers();
|
void initMembers();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
~Connect();
|
~Connect();
|
||||||
// Connect(const Connect& orig);
|
// Connect(const Connect& orig);
|
||||||
@@ -220,24 +197,12 @@ public:
|
|||||||
Connect(Header *p_Header);
|
Connect(Header *p_Header);
|
||||||
bool parse(char *p_Bytes, int p_ByteCount);
|
bool parse(char *p_Bytes, int p_ByteCount);
|
||||||
|
|
||||||
const string getClientComputerName() const {
|
const string getClientComputerName() const { return m_ClientComputerName; }
|
||||||
return m_ClientComputerName;
|
const string getClientName() const { return m_ClientName; }
|
||||||
}
|
const string getLoginName() const { return m_LoginName; }
|
||||||
const string getClientName() const {
|
const string getLoginPassword() const { return m_LoginPassword; }
|
||||||
return m_ClientName;
|
const string getServerIP() const { return m_ServerIP; }
|
||||||
}
|
int getServerPort() const { return m_ServerPort; }
|
||||||
const string getLoginName() const {
|
|
||||||
return m_LoginName;
|
|
||||||
}
|
|
||||||
const string getLoginPassword() const {
|
|
||||||
return m_LoginPassword;
|
|
||||||
}
|
|
||||||
const string getServerIP() const {
|
|
||||||
return m_ServerIP;
|
|
||||||
}
|
|
||||||
int getServerPort() const {
|
|
||||||
return m_ServerPort;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send
|
// Send
|
||||||
public:
|
public:
|
||||||
@@ -257,6 +222,7 @@ public:
|
|||||||
public:
|
public:
|
||||||
static const int OPFLAG = 2;
|
static const int OPFLAG = 2;
|
||||||
static const int BYTESLENGTH = 137;
|
static const int BYTESLENGTH = 137;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
string m_ServerComputerName;
|
string m_ServerComputerName;
|
||||||
string m_ServerName;
|
string m_ServerName;
|
||||||
@@ -264,6 +230,7 @@ public:
|
|||||||
int m_StepTime; // ms step size the Server will send play sequences
|
int m_StepTime; // ms step size the Server will send play sequences
|
||||||
|
|
||||||
void initMembers();
|
void initMembers();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
~ConnectAnswer();
|
~ConnectAnswer();
|
||||||
ConnectAnswer(const ConnectAnswer &orig);
|
ConnectAnswer(const ConnectAnswer &orig);
|
||||||
@@ -272,18 +239,10 @@ public:
|
|||||||
|
|
||||||
bool parse(char *p_Bytes, int p_ByteCount);
|
bool parse(char *p_Bytes, int p_ByteCount);
|
||||||
|
|
||||||
const string getServerComputerName() const {
|
const string getServerComputerName() const { return m_ServerComputerName; }
|
||||||
return m_ServerComputerName;
|
const string getServerName() const { return m_ServerName; }
|
||||||
}
|
bool getConnected() const { return m_Connected; }
|
||||||
const string getServerName() const {
|
int getStepTime() const { return m_StepTime; }
|
||||||
return m_ServerName;
|
|
||||||
}
|
|
||||||
bool getConnected() const {
|
|
||||||
return m_Connected;
|
|
||||||
}
|
|
||||||
int getStepTime() const {
|
|
||||||
return m_StepTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send
|
// Send
|
||||||
public:
|
public:
|
||||||
@@ -304,6 +263,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void initMembers();
|
void initMembers();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
~Disconnect();
|
~Disconnect();
|
||||||
Disconnect(const Disconnect &orig);
|
Disconnect(const Disconnect &orig);
|
||||||
@@ -323,8 +283,10 @@ public:
|
|||||||
public:
|
public:
|
||||||
static const int OPFLAG = 8;
|
static const int OPFLAG = 8;
|
||||||
static const int BYTESLENGTH = 4;
|
static const int BYTESLENGTH = 4;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initMembers();
|
void initMembers();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
~Watchdog();
|
~Watchdog();
|
||||||
Watchdog(const Watchdog &orig);
|
Watchdog(const Watchdog &orig);
|
||||||
@@ -344,6 +306,7 @@ public:
|
|||||||
public:
|
public:
|
||||||
static const int OPFLAG = 9;
|
static const int OPFLAG = 9;
|
||||||
static const int BYTESLENGTH = 4;
|
static const int BYTESLENGTH = 4;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initMembers();
|
void initMembers();
|
||||||
// Receive
|
// Receive
|
||||||
@@ -359,7 +322,6 @@ public:
|
|||||||
bool fillBytes(char *p_MessageBytes, int p_ByteCount);
|
bool fillBytes(char *p_MessageBytes, int p_ByteCount);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//------------------------------ SPITProject ----------------------------------
|
//------------------------------ SPITProject ----------------------------------
|
||||||
|
|
||||||
//----------- ReportSPITProject -----------
|
//----------- ReportSPITProject -----------
|
||||||
@@ -368,6 +330,7 @@ public:
|
|||||||
public:
|
public:
|
||||||
static const int OPFLAG = 11;
|
static const int OPFLAG = 11;
|
||||||
static const int BYTESLENGTH = 113;
|
static const int BYTESLENGTH = 113;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
string m_ProjectID;
|
string m_ProjectID;
|
||||||
string m_ProjectName;
|
string m_ProjectName;
|
||||||
@@ -404,10 +367,12 @@ public:
|
|||||||
public:
|
public:
|
||||||
static const int OPFLAG = 13;
|
static const int OPFLAG = 13;
|
||||||
static const int BYTESLENGTH = 45;
|
static const int BYTESLENGTH = 45;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
string m_ProjectID;
|
string m_ProjectID;
|
||||||
|
|
||||||
void initMembers();
|
void initMembers();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
~CloseSPITProject();
|
~CloseSPITProject();
|
||||||
CloseSPITProject(const CloseSPITProject &orig);
|
CloseSPITProject(const CloseSPITProject &orig);
|
||||||
@@ -430,8 +395,10 @@ public:
|
|||||||
public:
|
public:
|
||||||
static const int OPFLAG = 15;
|
static const int OPFLAG = 15;
|
||||||
static const int BYTESLENGTH = 4;
|
static const int BYTESLENGTH = 4;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initMembers();
|
void initMembers();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
~RequestProjectTransfer();
|
~RequestProjectTransfer();
|
||||||
RequestProjectTransfer(const RequestProjectTransfer &orig);
|
RequestProjectTransfer(const RequestProjectTransfer &orig);
|
||||||
@@ -453,6 +420,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void initMembers();
|
void initMembers();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
~StartProjectTransfer();
|
~StartProjectTransfer();
|
||||||
StartProjectTransfer(const StartProjectTransfer &orig);
|
StartProjectTransfer(const StartProjectTransfer &orig);
|
||||||
@@ -470,8 +438,10 @@ public:
|
|||||||
public:
|
public:
|
||||||
static const int OPFLAG = 17;
|
static const int OPFLAG = 17;
|
||||||
static const int BYTESLENGTH = 4;
|
static const int BYTESLENGTH = 4;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initMembers();
|
void initMembers();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
~EndProjectTransfer();
|
~EndProjectTransfer();
|
||||||
EndProjectTransfer(const EndProjectTransfer &orig);
|
EndProjectTransfer(const EndProjectTransfer &orig);
|
||||||
@@ -490,6 +460,7 @@ public:
|
|||||||
public:
|
public:
|
||||||
static const int OPFLAG = 21;
|
static const int OPFLAG = 21;
|
||||||
static const int BYTESLENGTH = 168;
|
static const int BYTESLENGTH = 168;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_Confirmed;
|
bool m_Confirmed;
|
||||||
string m_SPITTypeID;
|
string m_SPITTypeID;
|
||||||
@@ -502,6 +473,7 @@ public:
|
|||||||
long long m_Duration;
|
long long m_Duration;
|
||||||
|
|
||||||
void initMembers();
|
void initMembers();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
~ReportSPITType();
|
~ReportSPITType();
|
||||||
ReportSPITType(const ReportSPITType &orig);
|
ReportSPITType(const ReportSPITType &orig);
|
||||||
@@ -559,10 +531,12 @@ public:
|
|||||||
public:
|
public:
|
||||||
static const int OPFLAG = 23;
|
static const int OPFLAG = 23;
|
||||||
static const int BYTESLENGTH = 45;
|
static const int BYTESLENGTH = 45;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
string m_SPITTypeID;
|
string m_SPITTypeID;
|
||||||
|
|
||||||
void initMembers();
|
void initMembers();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
~RemoveSPITType();
|
~RemoveSPITType();
|
||||||
RemoveSPITType(const RemoveSPITType &orig);
|
RemoveSPITType(const RemoveSPITType &orig);
|
||||||
@@ -580,8 +554,6 @@ public:
|
|||||||
bool fillBytes(char *p_MessageBytes, int p_ByteCount);
|
bool fillBytes(char *p_MessageBytes, int p_ByteCount);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//---------------------------- SPITObjects ----------------------------------
|
//---------------------------- SPITObjects ----------------------------------
|
||||||
|
|
||||||
//----------- ReportSPITObject -----------
|
//----------- ReportSPITObject -----------
|
||||||
@@ -590,6 +562,7 @@ public:
|
|||||||
public:
|
public:
|
||||||
static const int OPFLAG = 31;
|
static const int OPFLAG = 31;
|
||||||
static const int BYTESLENGTH = 339;
|
static const int BYTESLENGTH = 339;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_Confirmed;
|
bool m_Confirmed;
|
||||||
string m_SPITObjectID;
|
string m_SPITObjectID;
|
||||||
@@ -611,6 +584,7 @@ public:
|
|||||||
bool m_ActionAssigned;
|
bool m_ActionAssigned;
|
||||||
|
|
||||||
void initMembers();
|
void initMembers();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
~ReportSPITObject();
|
~ReportSPITObject();
|
||||||
ReportSPITObject(const ReportSPITObject &orig);
|
ReportSPITObject(const ReportSPITObject &orig);
|
||||||
@@ -618,60 +592,24 @@ public:
|
|||||||
ReportSPITObject(Header *p_Header);
|
ReportSPITObject(Header *p_Header);
|
||||||
bool parse(char *p_Bytes, int p_ByteCount);
|
bool parse(char *p_Bytes, int p_ByteCount);
|
||||||
|
|
||||||
bool getConfirmed() const {
|
bool getConfirmed() const { return m_Confirmed; }
|
||||||
return m_Confirmed;
|
const string getID() const { return m_SPITObjectID; }
|
||||||
}
|
bool getFixed() const { return m_Fixed; }
|
||||||
const string getID() const {
|
bool getServerRemote() const { return m_ServerRemote; }
|
||||||
return m_SPITObjectID;
|
const string getName() const { return m_SPITObjectName; }
|
||||||
}
|
const string getSPITTypeID() const { return m_SPITTypeID; }
|
||||||
bool getFixed() const {
|
const string getServerParams() const { return m_ServerParams; }
|
||||||
return m_Fixed;
|
long long getFrameStart() const { return m_FrameStart; }
|
||||||
}
|
long long getFrameLength() const { return m_FrameLength; }
|
||||||
bool getServerRemote() const {
|
long long getFrameFadeInLength() const { return m_FrameFadeInLength; }
|
||||||
return m_ServerRemote;
|
long long getFrameFadeOutLength() const { return m_FrameFadeOutLength; }
|
||||||
}
|
int getValueFactor() const { return m_ValueFactor; }
|
||||||
const string getName() const {
|
char getValueUse() const { return m_ValueUse; }
|
||||||
return m_SPITObjectName;
|
int getTrack() const { return m_Track; }
|
||||||
}
|
const string getRemark() const { return m_Remark; }
|
||||||
const string getSPITTypeID() const {
|
long long getDelay() const { return m_Delay; }
|
||||||
return m_SPITTypeID;
|
long long getDuration() const { return m_Duration; }
|
||||||
}
|
bool getActionAssigned() const { return m_ActionAssigned; }
|
||||||
const string getServerParams() const {
|
|
||||||
return m_ServerParams;
|
|
||||||
}
|
|
||||||
long long getFrameStart() const {
|
|
||||||
return m_FrameStart;
|
|
||||||
}
|
|
||||||
long long getFrameLength() const {
|
|
||||||
return m_FrameLength;
|
|
||||||
}
|
|
||||||
long long getFrameFadeInLength() const {
|
|
||||||
return m_FrameFadeInLength;
|
|
||||||
}
|
|
||||||
long long getFrameFadeOutLength() const {
|
|
||||||
return m_FrameFadeOutLength;
|
|
||||||
}
|
|
||||||
int getValueFactor() const {
|
|
||||||
return m_ValueFactor;
|
|
||||||
}
|
|
||||||
char getValueUse() const {
|
|
||||||
return m_ValueUse;
|
|
||||||
}
|
|
||||||
int getTrack() const {
|
|
||||||
return m_Track;
|
|
||||||
}
|
|
||||||
const string getRemark() const {
|
|
||||||
return m_Remark;
|
|
||||||
}
|
|
||||||
long long getDelay() const {
|
|
||||||
return m_Delay;
|
|
||||||
}
|
|
||||||
long long getDuration() const {
|
|
||||||
return m_Duration;
|
|
||||||
}
|
|
||||||
bool getActionAssigned() const {
|
|
||||||
return m_ActionAssigned;
|
|
||||||
}
|
|
||||||
// Send
|
// Send
|
||||||
public:
|
public:
|
||||||
ReportSPITObject();
|
ReportSPITObject();
|
||||||
@@ -703,10 +641,12 @@ public:
|
|||||||
public:
|
public:
|
||||||
static const int OPFLAG = 33;
|
static const int OPFLAG = 33;
|
||||||
static const int BYTESLENGTH = 45;
|
static const int BYTESLENGTH = 45;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
string m_SPITObjectID;
|
string m_SPITObjectID;
|
||||||
|
|
||||||
void initMembers();
|
void initMembers();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
~RemoveSPITObject();
|
~RemoveSPITObject();
|
||||||
RemoveSPITObject(const RemoveSPITObject &orig);
|
RemoveSPITObject(const RemoveSPITObject &orig);
|
||||||
@@ -732,6 +672,7 @@ public:
|
|||||||
public:
|
public:
|
||||||
static const int OPFLAG = 37;
|
static const int OPFLAG = 37;
|
||||||
static const int BYTESLENGTH = 119;
|
static const int BYTESLENGTH = 119;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
string m_PlayerID;
|
string m_PlayerID;
|
||||||
string m_PlayerName;
|
string m_PlayerName;
|
||||||
@@ -740,6 +681,7 @@ public:
|
|||||||
long long m_Time; // Frames
|
long long m_Time; // Frames
|
||||||
|
|
||||||
void initMembers();
|
void initMembers();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
~PlaySPITStart();
|
~PlaySPITStart();
|
||||||
PlaySPITStart(const PlaySPITStart &orig);
|
PlaySPITStart(const PlaySPITStart &orig);
|
||||||
@@ -747,21 +689,11 @@ public:
|
|||||||
PlaySPITStart(Header *p_Header);
|
PlaySPITStart(Header *p_Header);
|
||||||
bool parse(char *p_Bytes, int p_ByteCount);
|
bool parse(char *p_Bytes, int p_ByteCount);
|
||||||
|
|
||||||
const string getPlayerID() const {
|
const string getPlayerID() const { return m_PlayerID; }
|
||||||
return m_PlayerID;
|
const string getPlayerName() const { return m_PlayerName; }
|
||||||
}
|
char getPlayerType() const { return m_PlayerType; }
|
||||||
const string getPlayerName() const {
|
bool getPlayerIsRunning() const { return m_PlayerIsRunning; }
|
||||||
return m_PlayerName;
|
long long getTime() const { return m_Time; }
|
||||||
}
|
|
||||||
char getPlayerType() const {
|
|
||||||
return m_PlayerType;
|
|
||||||
}
|
|
||||||
bool getPlayerIsRunning() const {
|
|
||||||
return m_PlayerIsRunning;
|
|
||||||
}
|
|
||||||
long long getTime() const {
|
|
||||||
return m_Time;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send
|
// Send
|
||||||
public:
|
public:
|
||||||
@@ -781,6 +713,7 @@ public:
|
|||||||
public:
|
public:
|
||||||
static const int OPFLAG = 38;
|
static const int OPFLAG = 38;
|
||||||
static const int BYTESLENGTH = 100;
|
static const int BYTESLENGTH = 100;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
string m_PlayerID;
|
string m_PlayerID;
|
||||||
string m_SPITObjectID;
|
string m_SPITObjectID;
|
||||||
@@ -790,6 +723,7 @@ public:
|
|||||||
char m_ValueFlag;
|
char m_ValueFlag;
|
||||||
|
|
||||||
void initMembers();
|
void initMembers();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
~PlaySPITObject();
|
~PlaySPITObject();
|
||||||
PlaySPITObject(const PlaySPITObject &orig);
|
PlaySPITObject(const PlaySPITObject &orig);
|
||||||
@@ -797,24 +731,12 @@ public:
|
|||||||
PlaySPITObject(Header *p_Header);
|
PlaySPITObject(Header *p_Header);
|
||||||
bool parse(char *p_Bytes, int p_ByteCount);
|
bool parse(char *p_Bytes, int p_ByteCount);
|
||||||
|
|
||||||
const string getPlayerID() const {
|
const string getPlayerID() const { return m_PlayerID; }
|
||||||
return m_PlayerID;
|
const string getSPITObjectID() const { return m_SPITObjectID; }
|
||||||
}
|
long long getFrameInsideObject() const { return m_FrameInsideObject; }
|
||||||
const string getSPITObjectID() const {
|
bool getPlayPrePosition() const { return m_PlayPrePosition; }
|
||||||
return m_SPITObjectID;
|
int getValue() const { return m_Value; }
|
||||||
}
|
char getValueFlag() const { return m_ValueFlag; }
|
||||||
long long getFrameInsideObject() const {
|
|
||||||
return m_FrameInsideObject;
|
|
||||||
}
|
|
||||||
bool getPlayPrePosition() const {
|
|
||||||
return m_PlayPrePosition;
|
|
||||||
}
|
|
||||||
int getValue() const {
|
|
||||||
return m_Value;
|
|
||||||
}
|
|
||||||
char getValueFlag() const {
|
|
||||||
return m_ValueFlag;
|
|
||||||
}
|
|
||||||
// Send
|
// Send
|
||||||
PlaySPITObject();
|
PlaySPITObject();
|
||||||
|
|
||||||
@@ -832,10 +754,12 @@ public:
|
|||||||
public:
|
public:
|
||||||
static const int OPFLAG = 39;
|
static const int OPFLAG = 39;
|
||||||
static const int BYTESLENGTH = 45;
|
static const int BYTESLENGTH = 45;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
string m_PlayerID;
|
string m_PlayerID;
|
||||||
|
|
||||||
void initMembers();
|
void initMembers();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
~PlaySPITEnd();
|
~PlaySPITEnd();
|
||||||
PlaySPITEnd(const PlaySPITEnd &orig);
|
PlaySPITEnd(const PlaySPITEnd &orig);
|
||||||
@@ -843,9 +767,7 @@ public:
|
|||||||
PlaySPITEnd(Header *p_Header);
|
PlaySPITEnd(Header *p_Header);
|
||||||
bool parse(char *p_Bytes, int p_ByteCount);
|
bool parse(char *p_Bytes, int p_ByteCount);
|
||||||
|
|
||||||
const string getPlayerID() const {
|
const string getPlayerID() const { return m_PlayerID; }
|
||||||
return m_PlayerID;
|
|
||||||
}
|
|
||||||
// Send
|
// Send
|
||||||
public:
|
public:
|
||||||
PlaySPITEnd();
|
PlaySPITEnd();
|
||||||
@@ -853,19 +775,20 @@ public:
|
|||||||
bool fillBytes(char *p_MessageBytes, int p_ByteCount);
|
bool fillBytes(char *p_MessageBytes, int p_ByteCount);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//----------- ReportPlayStatus -----------
|
//----------- ReportPlayStatus -----------
|
||||||
|
|
||||||
class ReportPlayStatus : public OPPart {
|
class ReportPlayStatus : public OPPart {
|
||||||
public:
|
public:
|
||||||
static const int OPFLAG = 40;
|
static const int OPFLAG = 40;
|
||||||
static const int BYTESLENGTH = 57;
|
static const int BYTESLENGTH = 57;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
string m_SPITObjectID;
|
string m_SPITObjectID;
|
||||||
long long m_FrameInsideObject; // Frames
|
long long m_FrameInsideObject; // Frames
|
||||||
int m_Value;
|
int m_Value;
|
||||||
|
|
||||||
void initMembers();
|
void initMembers();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
~ReportPlayStatus();
|
~ReportPlayStatus();
|
||||||
ReportPlayStatus(const ReportPlayStatus &orig);
|
ReportPlayStatus(const ReportPlayStatus &orig);
|
||||||
@@ -873,15 +796,9 @@ public:
|
|||||||
ReportPlayStatus(Header *p_Header);
|
ReportPlayStatus(Header *p_Header);
|
||||||
bool parse(char *p_Bytes, int p_ByteCount);
|
bool parse(char *p_Bytes, int p_ByteCount);
|
||||||
|
|
||||||
const string getID() const {
|
const string getID() const { return m_SPITObjectID; }
|
||||||
return m_SPITObjectID;
|
long long getFrameInsideObject() const { return m_FrameInsideObject; }
|
||||||
}
|
int getValue() const { return m_Value; }
|
||||||
long long getFrameInsideObject() const {
|
|
||||||
return m_FrameInsideObject;
|
|
||||||
}
|
|
||||||
int getValue() const {
|
|
||||||
return m_Value;
|
|
||||||
}
|
|
||||||
// Send
|
// Send
|
||||||
ReportPlayStatus();
|
ReportPlayStatus();
|
||||||
|
|
||||||
@@ -891,9 +808,6 @@ public:
|
|||||||
bool fillBytes(char *p_MessageBytes, int p_ByteCount);
|
bool fillBytes(char *p_MessageBytes, int p_ByteCount);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//----------------------- static helper functions ----------------------------
|
//----------------------- static helper functions ----------------------------
|
||||||
public:
|
public:
|
||||||
static bool isSystemLittleEndian();
|
static bool isSystemLittleEndian();
|
||||||
@@ -945,6 +859,3 @@ public:
|
|||||||
static char *createByteArray(const OPPart *p_OPPart, int *p_BytesCount);
|
static char *createByteArray(const OPPart *p_OPPart, int *p_BytesCount);
|
||||||
};
|
};
|
||||||
#endif /* SPIT_MESSAGE_H */
|
#endif /* SPIT_MESSAGE_H */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,452 +0,0 @@
|
|||||||
|
|
||||||
#include "MyApp.h"
|
|
||||||
#include "Task.hpp"
|
|
||||||
#include "esp_log.h"
|
|
||||||
#include "Semaphore.hpp"
|
|
||||||
#include "Queue.hpp"
|
|
||||||
#include <list>
|
|
||||||
|
|
||||||
const char *TAG = "SPIT";
|
|
||||||
|
|
||||||
MyApp::MyApp() :
|
|
||||||
_SpitClient (
|
|
||||||
s_ClientName, s_ProjectName,
|
|
||||||
{
|
|
||||||
.onServerEvent = onServerEvent,
|
|
||||||
.onConnectionStatus = onConnectionStatus,
|
|
||||||
.onStartProjectTransfer = onStartProjectTransfer,
|
|
||||||
.onEndProjectTransfer = onEndProjectTransfer,
|
|
||||||
.onProjectClosed = onProjectClosed,
|
|
||||||
.onProjectReport = onProjectReport,
|
|
||||||
.onSpitType = onSpitType,
|
|
||||||
.onSpitTypeRemote = onSpitTypeRemote,
|
|
||||||
.onSpitObject = onSpitObject,
|
|
||||||
.onSpitObjectRemote = onSpitObjectRemote,
|
|
||||||
.onSpitTypeRemoved = onSpitTypeRemoved,
|
|
||||||
.onSpitTypeRemoteRemoved = onSpitTypeRemoteRemoved,
|
|
||||||
.onSpitObjectRemoved = onSpitObjectRemoved,
|
|
||||||
.onSpitObjectRemoteRemoved = onSpitObjectRemoteRemoved,
|
|
||||||
.onPlay = onPlay,
|
|
||||||
.onPlaySpitType = onPlaySpitType,
|
|
||||||
.onPlayRemoteObjectStatus = onPlayRemoteObjectStatus,
|
|
||||||
.onCheckSpitTypeVeto = onCheckSpitTypeVeto,
|
|
||||||
.onCheckSpitObjectVeto = onCheckSpitObjectVeto,
|
|
||||||
}) {
|
|
||||||
}
|
|
||||||
|
|
||||||
string MyApp::m_ServerProjectID{};
|
|
||||||
string MyApp::m_ServerProjectName{};
|
|
||||||
int MyApp::m_ServerFramesPerSecond{44100}; // set when the server reports his project, see eventProjectReport
|
|
||||||
|
|
||||||
void MyApp::init() {
|
|
||||||
SPITType *ptrSPITType1Fix = _SpitClient.createSPITTypeFixed("MySPITAPP_Action1ID", "ActionGroupName", "Action1Name", 0, 0);
|
|
||||||
SPITType *ptrSPITType2Fix = _SpitClient.createSPITTypeFixed("MySPITAPP_Action2ID", "ActionGroupName", "Action2Name", 0, 0);
|
|
||||||
|
|
||||||
// When an action exist which should be done whenever a SPITObject with this SPITType is played,
|
|
||||||
// then you should 'setAssignedActionType' to true
|
|
||||||
_SpitClient.setActionSPITType(ptrSPITType1Fix->getID(), true);
|
|
||||||
_SpitClient.setActionSPITType(ptrSPITType2Fix->getID(), true);
|
|
||||||
_SpitClient.clientProjectLoaded();
|
|
||||||
_SpitClient.startServerAutoDetect();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MyApp::onServerEvent(SPIT_Client::ServerEvent event, const SAD_DetectedServer &p_DetectedServer) {
|
|
||||||
switch (event)
|
|
||||||
{
|
|
||||||
case SPIT_Client::ServerEvent::Detect:
|
|
||||||
ESP_LOGI(TAG, "SERVER DETECTED");
|
|
||||||
ESP_LOGI(TAG, " Name: %s", p_DetectedServer.getName().data());
|
|
||||||
ESP_LOGI(TAG, " ID: %s", p_DetectedServer.getID().data());
|
|
||||||
ESP_LOGI(TAG, " Computer: %s", p_DetectedServer.getComputerName().data());
|
|
||||||
ESP_LOGI(TAG, " IP: %s", p_DetectedServer.getIP().data());
|
|
||||||
ESP_LOGI(TAG, " Port: %s", p_DetectedServer.getPort().data());
|
|
||||||
ESP_LOGI(TAG, " Addition: %s", p_DetectedServer.getAdditions().data());
|
|
||||||
ESP_LOGI(TAG, " ClientIP: %s", p_DetectedServer.getClientIP().data());
|
|
||||||
break;
|
|
||||||
case SPIT_Client::ServerEvent::Lost:
|
|
||||||
ESP_LOGW(TAG, "Server lost Name: %s IP: %s", p_DetectedServer.getName().data(), p_DetectedServer.getIP().data());
|
|
||||||
|
|
||||||
break;
|
|
||||||
case SPIT_Client::ServerEvent::Changed:
|
|
||||||
ESP_LOGW(TAG, "Server lost Name: %s IP: %s", p_DetectedServer.getName().data(), p_DetectedServer.getIP().data());
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------
|
|
||||||
//---------- Connecting event ----------
|
|
||||||
|
|
||||||
void MyApp::onConnectionStatus(string p_ServerID, string p_ServerComputerName, string p_ServerName, int p_ServerStepTime, int p_ConnectionStatus, int p_OldConnectionStatus) {
|
|
||||||
ESP_LOGI(TAG, "MySPITApp: eventConnectionStatus %d ", p_ConnectionStatus);
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------
|
|
||||||
//---------- Server's Project events ------------------------
|
|
||||||
/**
|
|
||||||
* The Server reports his loaded project
|
|
||||||
* Called when
|
|
||||||
* a) the connection to the server is established.
|
|
||||||
* b) server load a new project
|
|
||||||
* c) server saves the project under a new name
|
|
||||||
* @param p_ProjectID the server project's id (maybe the filename of the project or a part o it or the same as p_ProjectName)
|
|
||||||
* @param p_ProjectName the server project's name
|
|
||||||
* @param p_FramesPerSeoond All times in SPIT are given in frames. FramesPerSecond can be used to convert frames to seconds....
|
|
||||||
*/
|
|
||||||
void MyApp::onProjectReport(string p_ProjectID, string p_ProjectName, int p_FramesPerSeoond) {
|
|
||||||
ESP_LOGI(TAG, "eventProjectReport ID: %s Name: %s FramesPerSecond: %d", p_ProjectID.data(), p_ProjectName.data(), p_FramesPerSeoond);
|
|
||||||
m_ServerProjectID = p_ProjectID;
|
|
||||||
m_ServerProjectName = p_ProjectName;
|
|
||||||
m_ServerFramesPerSecond = p_FramesPerSeoond;
|
|
||||||
// set the frames per second as the server - perhaps the client's time values have to be recalculated.
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when the server closes his project.
|
|
||||||
* @param p_ProjectID the id of the project
|
|
||||||
* The server loads only one project at time-> the ID is not actually necessary
|
|
||||||
*/
|
|
||||||
void MyApp::onProjectClosed(string p_ProjectID) {
|
|
||||||
ESP_LOGI(TAG, "eventProjectClosed ID: %s", p_ProjectID.data());
|
|
||||||
// If we don't save SPITServer's project specific information
|
|
||||||
// perhaps close all SPITObjects and RemoteSPITObjects to avoid conflicts, when the SPITServer loads a new project
|
|
||||||
// SPITObject::clearSPITObjects();
|
|
||||||
// SPITObject::clearSPITObjectsRemote();
|
|
||||||
}
|
|
||||||
|
|
||||||
// The server starts the transfer of its project, that means
|
|
||||||
// All SPITTypes and SPITObjects available on the server are transferred in the following.
|
|
||||||
void MyApp::onStartProjectTransfer() {
|
|
||||||
ESP_LOGI(TAG, "eventStartProjectTransfer");
|
|
||||||
}
|
|
||||||
// The transfer of the server's SPITTypes and SPITObjects is finished.
|
|
||||||
void MyApp::onEndProjectTransfer() {
|
|
||||||
ESP_LOGI(TAG, "eventEndProjectTransfer");
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------
|
|
||||||
//--------- SPITType events ----------
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The SPITCLientInterface (implemented by this) will be asked to veto the SPITType while SPIT_Client.parseReportSPITType.<br>
|
|
||||||
* @param p_ReportSPITType
|
|
||||||
* @return false = the SPITType is denied, true = the SPITType is accepted
|
|
||||||
*/
|
|
||||||
bool MyApp::onCheckSpitTypeVeto(SPIT_Message::ReportSPITType* p_ReportSPITType) {
|
|
||||||
if (p_ReportSPITType == NULL) return true;
|
|
||||||
SPITType* ptrSPITType;
|
|
||||||
ptrSPITType = SPITType::getSPITType(p_ReportSPITType->getID());
|
|
||||||
|
|
||||||
//Don't allow foreign SPITTypes
|
|
||||||
if (ptrSPITType == NULL) return false;
|
|
||||||
if (ptrSPITType->getCreatedByClient() == false) return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MyApp::onCheckSpitObjectVeto(SPIT_Message::ReportSPITObject* p_ReportSPITObject) {
|
|
||||||
if (p_ReportSPITObject == NULL) return true;
|
|
||||||
SPITType* ptrSPITType;
|
|
||||||
ptrSPITType = SPITType::getSPITType(p_ReportSPITObject->getSPITTypeID());
|
|
||||||
if (ptrSPITType == NULL) return false;
|
|
||||||
|
|
||||||
//Don't allow SPITObjects which refers to a SPITType which is not created by this client - other SPITTypes cannot be handled here
|
|
||||||
//if (ptrSPITType->getCreatedByClient() == false) return false;
|
|
||||||
|
|
||||||
// SPITObject* ptrSPITObject;
|
|
||||||
// ptrSPITObject = SPITObject::getSPITObject(p_ReportSPITOnject->getID());
|
|
||||||
//Don't allow foreign SPITTypes
|
|
||||||
// if (ptrSPITObject == NULL) return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when the server has created, loaded or changed a SPITType.
|
|
||||||
* May also occur when the server confirms a SPITType created or changed by the client.
|
|
||||||
* @param p_New true = server created a new SPITType
|
|
||||||
* false = server changed a existing SPITType
|
|
||||||
* @param p_SPITType a reference to a copy of the SPITType instance.
|
|
||||||
*/
|
|
||||||
void MyApp::onSpitType(bool p_New, const SPITType &p_SPITType) {
|
|
||||||
// fetch information of the SPITType
|
|
||||||
if (p_New) {
|
|
||||||
ESP_LOGD(TAG, "eventSPITType NEW");
|
|
||||||
} else {
|
|
||||||
ESP_LOGD(TAG, "eventSPITType CHANGED");
|
|
||||||
}
|
|
||||||
ESP_LOGI(TAG, " ID: %s GroupName: %s Name: %s confirmed: %d", p_SPITType.getID().data(), p_SPITType.getGroupName().data(), p_SPITType.getName().data(), p_SPITType.getConfirmed());
|
|
||||||
|
|
||||||
// Check your actions
|
|
||||||
// Whenever you provide an action for this SPITType take this over in your code.
|
|
||||||
// call _SpitClient.setActionSPITType(p_SPITType.getID(), true);
|
|
||||||
|
|
||||||
// for our little excample as described in loadClientProject we do following
|
|
||||||
// This may be redundand, because we defined the SPITTypes as fixed, so the server can't change them
|
|
||||||
// But foe all SPITTypes which are not fixed we need to setActionSPITType
|
|
||||||
|
|
||||||
// if ("MySPITAPP_Action1ID" == p_SPITType.getID()) {
|
|
||||||
// _SpitClient.setActionSPITType(p_SPITType.getID(), true);
|
|
||||||
// }
|
|
||||||
// if ("MySPITAPP_Action2ID" == p_SPITType.getID()) {
|
|
||||||
// _SpitClient.setActionSPITType(p_SPITType.getID(), true);
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Called when the server has created or changed a Remote SPITType.
|
|
||||||
* Remote SPITType are used in Remote SPITObjects. A Remote SPITObject is used to remote control the SPITServer.
|
|
||||||
* @param p_New true = server created a new SPITType / false = server changed a existing SPITType
|
|
||||||
*/
|
|
||||||
void MyApp::onSpitTypeRemote(bool p_New, const SPITType &p_SPITType) {
|
|
||||||
if (p_New) {
|
|
||||||
ESP_LOGD(TAG, "eventSPITTypeRemote NEW");
|
|
||||||
} else {
|
|
||||||
// we had to inform all Remote SPITObjects using the p_SPITType
|
|
||||||
// perhaps the SPITObject uses information from the SPITType
|
|
||||||
SPITObject *ptrSPITObject;
|
|
||||||
int intSPITObjectCount;
|
|
||||||
intSPITObjectCount = SPITObject::getSPITObjectRemoteCount();
|
|
||||||
for (int intObject = 0; intObject < intSPITObjectCount; intObject++) {
|
|
||||||
ptrSPITObject = SPITObject::getSPITObjectRemote(intObject);
|
|
||||||
if (ptrSPITObject == NULL)
|
|
||||||
continue;
|
|
||||||
if (ptrSPITObject->getSPITTypeID() == p_SPITType.getID()) {
|
|
||||||
// call ecentSPITObjectRemote
|
|
||||||
onSpitObjectRemote(false, p_SPITType, *ptrSPITObject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ESP_LOGD(TAG, "eventSPITTypeRemote CHANGED");
|
|
||||||
}
|
|
||||||
ESP_LOGD(TAG, "ID: %s GroupName: %s Name: %s confirmed: %d",
|
|
||||||
p_SPITType.getID().data(), p_SPITType.getGroupName().data(), p_SPITType.getName().data(), p_SPITType.getConfirmed());
|
|
||||||
// this is a remote SPITType, if you want you can list this for later remote use.
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when the server has removed a SPITType.
|
|
||||||
* After this function has been exited the SPITType is emeoved from the SPITType-List and the pointer is deleted.
|
|
||||||
* So use the pointer immediately or use the copyconstructor to make a copy for extended use.
|
|
||||||
* You have to release the copy yourself later (delete ptr...)
|
|
||||||
*/
|
|
||||||
void MyApp::onSpitTypeRemoved(const SPITType &p_SPITType) {
|
|
||||||
ESP_LOGD(TAG, "eventSPITType Removed");
|
|
||||||
ESP_LOGD(TAG, " ID: %s GroupName: %s Name: %s\n", p_SPITType.getID().data(), p_SPITType.getGroupName().data(), p_SPITType.getName().data());
|
|
||||||
|
|
||||||
// Check your actions
|
|
||||||
// take the removal of the SPITType over in your code
|
|
||||||
|
|
||||||
// CAUTION: Deleted SPIT types can be added later again (perhaps per UNDO on the SPITServer)
|
|
||||||
//-> don't remove your assigned action immediately - keep it to reassign it later
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Called when the server has removed a Remote SPITType.
|
|
||||||
* Remote SPITType are used in Remote SPITObjects. A Remote SPITObject is used to remote control the SPITServer.
|
|
||||||
* After this function has been exited the SPITType is emeoved from the Remote SPITType-List and the pointer is deleted.
|
|
||||||
* So use the pointer immediately or use the copyconstructor to make a copy for extended use.
|
|
||||||
* You have to release the copy yourself later (delete ptr...)
|
|
||||||
* @param p_SPITType a reference to a copy of the SPITType instance.
|
|
||||||
*/
|
|
||||||
void MyApp::onSpitTypeRemoteRemoved(const SPITType &p_SPITType) {
|
|
||||||
ESP_LOGD(TAG, "eventSPITTypeRemote Removed");
|
|
||||||
ESP_LOGD(TAG, " ID: %s GroupName: %s Name: %s\n", p_SPITType.getID().data(), p_SPITType.getGroupName().data(), p_SPITType.getName().data());
|
|
||||||
|
|
||||||
// This is a remote SPITType
|
|
||||||
// If you have listet this prior you should remove it from the list
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when the server has created, loaded or changed a SPITObject.
|
|
||||||
* May also occur when the server confirms a SPITObject created by the client, what the client should never do!!.
|
|
||||||
* @param p_New true = server created a new SPITObject
|
|
||||||
* false = server changed a existing SPITObject
|
|
||||||
* @param p_SPITType a reference to a copy of the associated SPITType instance.
|
|
||||||
* @param p_SPITObject a reference to a copy of the SPITObject instance.
|
|
||||||
*/
|
|
||||||
void MyApp::onSpitObject(bool p_New, const SPITType &p_SPITType, const SPITObject &p_SPITObject) {
|
|
||||||
if (p_New) {
|
|
||||||
ESP_LOGI(TAG, "eventSPITObject NEW");
|
|
||||||
} else {
|
|
||||||
ESP_LOGD(TAG, "eventSPITObject CHANGED");
|
|
||||||
}
|
|
||||||
ESP_LOGI(TAG, " ID: %s Name: %s -> SPITType: %s", p_SPITObject.getID().data(), p_SPITObject.getName().data(), p_SPITType.getName().data());
|
|
||||||
|
|
||||||
// check your actions
|
|
||||||
// Whenever you provide an action for this SPITObject take this over in your code.
|
|
||||||
// call _SpitClient.setActionSPITObject(p_SPITObject.getID(), true);
|
|
||||||
|
|
||||||
// for our little excample as described in loadClientProject:
|
|
||||||
// We have only actions for SPITTypes - means every SPITObject with the associated "Actionx"-SPITTypes will trigger the action when it is played
|
|
||||||
//-> no need to do something here, because setActionSPITType has been set prior and the SPITObject will automatically inherits this
|
|
||||||
// SPITObjects with other SPITTypes asscciated will trigger no actions
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Called when the server has created or changed a Remote SPITObject.
|
|
||||||
* A Remote SPITObject is used to remote control the SPITServer.
|
|
||||||
* @param p_New true = server created a new remote SPITObject
|
|
||||||
* false = server changed a existing remote SPITObject
|
|
||||||
* @param p_SPITType a reference to a copy of the associated SPITType instance.
|
|
||||||
* @param p_SPITObject a reference to a copy of the SPITObject instance.
|
|
||||||
*/
|
|
||||||
void MyApp::onSpitObjectRemote(bool p_New, const SPITType &p_SPITType, const SPITObject &p_SPITObject) {
|
|
||||||
if (p_New) {
|
|
||||||
ESP_LOGI(TAG, "eventSPITObjectRemote NEW");
|
|
||||||
} else {
|
|
||||||
ESP_LOGD(TAG, "eventSPITObjectRemote CHANGED");
|
|
||||||
}
|
|
||||||
ESP_LOGI(TAG, " ID: %s Name: %s -> SPITType: %s", p_SPITObject.getID().data(), p_SPITObject.getName().data(), p_SPITType.getName().data());
|
|
||||||
|
|
||||||
// This is a remote SPITObject which can be used to remote control the server.
|
|
||||||
// If you want you can list this for later use
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when the server has removed a SPITObject.
|
|
||||||
* After this function has been exited the SPITObject is emeoved from the SPITObject-List and the pointer is deleted.
|
|
||||||
* So use the pointer immediately or use the copyconstructor to make a copy for extended use.
|
|
||||||
* You have to release the copy yourself later (delete ptr...)
|
|
||||||
* @param p_SPITType a reference to a copy of the associated SPITType instance.
|
|
||||||
* @param p_SPITObject a reference to a copy of the SPITObject instance.
|
|
||||||
*/
|
|
||||||
void MyApp::onSpitObjectRemoved(const SPITType &p_SPITType, const SPITObject &p_SPITObject) {
|
|
||||||
ESP_LOGD(TAG, "eventSPITObject Removed");
|
|
||||||
ESP_LOGD(TAG, " ID: %s Name: %s\n", p_SPITObject.getID().data(), p_SPITObject.getName().data());
|
|
||||||
|
|
||||||
// Check your actions
|
|
||||||
// take the removal of the SPITObject over in your code
|
|
||||||
|
|
||||||
// CAUTION: Deleted SPITObjects can be added later again (perhaps per UNDO on the SPITServer)
|
|
||||||
//-> don't remove your assigned action immediately - keep it to reassign it later
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Called when the server has removed a Remote SPITObject.
|
|
||||||
* A Remote SPITObject is used to remote control the SPITServer.
|
|
||||||
* After this function has been exited the SPITObject is emeoved from the SPITObject-List and the pointer is deleted.
|
|
||||||
* So use the pointer immediately or use the copyconstructor to make a copy for extended use.
|
|
||||||
* You have to release the copy yourself later (delete ptr...)
|
|
||||||
* @param p_SPITType a reference to a copy of the associated SPITType instance.
|
|
||||||
* @param p_SPITObject a reference to a copy of the SPITObject instance.
|
|
||||||
*/
|
|
||||||
void MyApp::onSpitObjectRemoteRemoved(const SPITType &p_SPITType, const SPITObject &p_SPITObject) {
|
|
||||||
ESP_LOGD(TAG, "eventSPITObjectRemote Removed");
|
|
||||||
ESP_LOGD(TAG, " ID: %s Name: %s\n", p_SPITObject.getID().data(), p_SPITObject.getName().data());
|
|
||||||
|
|
||||||
// This is a remote SPITObject
|
|
||||||
// If you have listet this prior you should remove it from the list
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------
|
|
||||||
//---------------- Playing SPITObjects ----------------
|
|
||||||
// Following is called when the SPITServer play SPITObjects.
|
|
||||||
// For every step the server does following sequence occurs:
|
|
||||||
// a) eventPlay
|
|
||||||
// b) several eventPlayObject for each actual played SPITObjectin this step
|
|
||||||
// NEXT STAP of the server
|
|
||||||
// a) eventPlay
|
|
||||||
// b) several eventPlayObject for each actual played SPITObject in this step
|
|
||||||
// ...
|
|
||||||
|
|
||||||
// SPITServer may use several methods for playing SPITObjects.
|
|
||||||
// e.g. liveSHOWsoftware has the timeline and jingles which plays objects, where the timeline the main player is.
|
|
||||||
// SPIT distinguishes between the different players. All eventPlay... functions contain the information which player plays the SPIT object.
|
|
||||||
|
|
||||||
void MyApp::onPlay(string p_PlayerID, string p_PlayerName, char p_PlayerType, bool p_PlayerIsRunning, long long p_TimeFrames) {
|
|
||||||
ESP_LOGD(TAG, "eventPlay Player: %s Runs: %d Time: %lld", p_PlayerName.data(), p_PlayerIsRunning, p_TimeFrames);
|
|
||||||
|
|
||||||
switch (p_PlayerType) {
|
|
||||||
case SPIT_Client::PLAYERTYPE_MAIN:
|
|
||||||
// p_FrameTimes contains the position inside the server's project, we can use it like a timecode
|
|
||||||
int intMilliseconds;
|
|
||||||
intMilliseconds = (int)(((double)p_TimeFrames / (double)m_ServerFramesPerSecond) * 1000);
|
|
||||||
break;
|
|
||||||
case SPIT_Client::PLAYERTYPE_CONTINOUS:
|
|
||||||
// The olayer is playing only single Object sequences sometime during the project
|
|
||||||
break;
|
|
||||||
case SPIT_Client::PLAYERTYPE_DISCRETE:
|
|
||||||
// Only discrete values where submitted, e.g the fader position of remote faders.
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when the SPITServer plays a SPITObject. For every played SPITObject one eventPlayObject is called.
|
|
||||||
* You can decide here which action should be done or not.
|
|
||||||
*
|
|
||||||
* @param p_Started true = The SPITObject is newly played (e.g. in liveSHOWsoftware the cursor enters the SPITObject)
|
|
||||||
* @param p_Ended Das true = Playback of SPITObject finished (e.g. in liveSHOWsoftware the cursor has exited the SPIT object)
|
|
||||||
* @param p_SPITType the associated SPITType of p_SPITObject
|
|
||||||
* @param p_SPITObject the actual played or stopped SPITObject
|
|
||||||
* @param p_PlayObject contains information about the play status:
|
|
||||||
* frame where the cursor is inside the SPITObject
|
|
||||||
* whether the player is running or not
|
|
||||||
* the actual value of the SPITObject (in liveSHOWsoftware objects ma faded in or out or the main value is decreased, ..
|
|
||||||
*/
|
|
||||||
void MyApp::onPlaySpitType(string p_PlayerID, string p_SPITTypeID, bool p_PlayerIsRunning, bool p_Started, bool p_Ended, double p_Value) {
|
|
||||||
// double doubleValue = ((double)p_PlayObject.getValue() / 1000000) * ((double)p_PlayObject.getValueFactor() / 1000000);
|
|
||||||
|
|
||||||
ESP_LOGD(TAG, "eventPlayObject Player: %s is running: %d Object Started: %d Stopped: %d", p_PlayerID.data(), p_PlayerIsRunning, p_Started, p_Ended);
|
|
||||||
// ESP_LOGD(TAG, " SPITType: %s SPITObject: %s Position: %lld Value: %f\n", p_SPITTypeID.data(), p_SPITObject.getName().data(), p_PlayObject.getFrameInside(), doubleValue);
|
|
||||||
ESP_LOGD(TAG, " SPITType: %s Value: %f\n", p_SPITTypeID.data(), p_Value);
|
|
||||||
|
|
||||||
if (p_SPITTypeID == "MySPITAPP_Action1ID") { // do Action 1
|
|
||||||
// we can get some information about the play status
|
|
||||||
if (p_Started == true) {
|
|
||||||
ESP_LOGI(TAG, "MyApp AKTION 1 started Value: %f and running: %d", p_Value, p_PlayerIsRunning);
|
|
||||||
} else if (p_Ended == true) {
|
|
||||||
ESP_LOGI(TAG, "MyApp AKTION 1 ended"); // p_PlayObject.getFrameInside() is -1
|
|
||||||
} else {
|
|
||||||
ESP_LOGD(TAG, "MyApp AKTION 1 is played Value: %f and running: %d", p_Value, p_PlayerIsRunning);
|
|
||||||
}
|
|
||||||
} else if (p_SPITTypeID == "MySPITAPP_Action2ID") { // do Action 2
|
|
||||||
if (p_Started == true) {
|
|
||||||
ESP_LOGI(TAG, "AKTION 2 started Value: %f and running: %d", p_Value, p_PlayerIsRunning);
|
|
||||||
} else if (p_Ended == true) {
|
|
||||||
ESP_LOGI(TAG, "AKTION 2 ended"); // p_PlayObject.getFrameInside() is -1
|
|
||||||
} else {
|
|
||||||
ESP_LOGD(TAG, "AKTION 2 is played Value: %f and running: %d", p_Value, p_PlayerIsRunning);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------
|
|
||||||
//---------------- Remote Control SPITServer ----------------
|
|
||||||
// The SPITServer has sent all possibilities to control it remotely - remote SPITObjects - see eventSPITObjectRemote
|
|
||||||
// Some of them may control functionality with values (fader psotions for loudness of sound, ...).
|
|
||||||
// When the server changes one of these value objects, it sends an eventPlayRemoteObjectStatus.
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when a remote SpitObject which value function is changed by the server.
|
|
||||||
* This allows the Client to adjust its display for the remote command.
|
|
||||||
* @param p_SPITType the assigned remote SPITType of p_SPITObject
|
|
||||||
* @param p_SPITObject the remote SPITObject which is changed
|
|
||||||
* @param p_FrameInsideObject can be discarded
|
|
||||||
* @param p_Value the new value
|
|
||||||
*/
|
|
||||||
void MyApp::onPlayRemoteObjectStatus(const SPITType &p_SPITType, const SPITObject &p_SPITObject, long long p_FrameInsideObject, int p_Value) {
|
|
||||||
ESP_LOGD(TAG, "eventPlayRemoteObjectStatus RemoteSPITType: %s RemoteSPITObject: %s Position: %lld Value: %d", p_SPITType.getName().data(), p_SPITObject.getName().data(), p_FrameInsideObject, p_Value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Send a remote control command to the SPITServer.
|
|
||||||
* There may be different command types:
|
|
||||||
* a) Some don't use value e.g. go to next scene, olay a jingle, ..
|
|
||||||
* b) Some use values e.g. the main sound fader
|
|
||||||
* @param p_SPITObjectID the id of the remote SPITObject (this represents the remote control command)
|
|
||||||
* @param p_Valueppm the value in ppm
|
|
||||||
* in case a) the value is ignored
|
|
||||||
* in case b) the value is used
|
|
||||||
* @param p_ValueFlag indicates how the server should use p_Valueppm:
|
|
||||||
* VALUEFLAG_DIRECT (0x00) The server will overwrite his existing value with p_Value
|
|
||||||
* VALUEFLAG_INCREASE (0x01) The server increases his existing value by p_Valueppm
|
|
||||||
* VALUEFLAG_DECREASE (0x01) The server decreases his existing value by p_Valueppm
|
|
||||||
*/
|
|
||||||
void MyApp::sendRemoteObject(string p_SPITObjectID, int p_Valueppm, char p_ValueFlag) {
|
|
||||||
_SpitClient.sendRemoteObject(p_SPITObjectID, p_Valueppm, p_ValueFlag);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MyApp::testLiveShowRemote() {
|
|
||||||
// We jump to the next Scenebridge - no Value is needed
|
|
||||||
_SpitClient.sendRemoteObject("playControlStart");
|
|
||||||
}
|
|
||||||
@@ -29,7 +29,6 @@ SAD_DetectedServer::SAD_DetectedServer() {
|
|||||||
m_ClientIP = "";
|
m_ClientIP = "";
|
||||||
m_Port = "";
|
m_Port = "";
|
||||||
m_Additions = "";
|
m_Additions = "";
|
||||||
m_IPIsIP4 = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SAD_DetectedServer::setProjectName(string p_ServerProjectName) {
|
void SAD_DetectedServer::setProjectName(string p_ServerProjectName) {
|
||||||
@@ -47,77 +46,33 @@ void SAD_DetectedServer::cycleStart() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
void SAD_DetectedServer::cycleEnd(I_SAD_Client &sadClient) {
|
void SAD_DetectedServer::cycleEnd(I_SAD_Client &sadClient) {
|
||||||
list<SAD_DetectedServer*> o_LostServers;
|
for (auto &srv : s_DetectedServers) {
|
||||||
list<SAD_DetectedServer*> o_NewServers;
|
SAD_DetectedServer *ptrDetectedServer = srv.second;
|
||||||
list<SAD_DetectedServer*> o_ChangedServers;
|
|
||||||
SAD_DetectedServer* ptrDetectedServer;
|
|
||||||
{
|
|
||||||
for (auto i = s_DetectedServers.begin(); i != s_DetectedServers.end(); i++) {
|
|
||||||
ptrDetectedServer = i->second;
|
|
||||||
if (ptrDetectedServer->getFoundAgain() == false) {
|
if (ptrDetectedServer->getFoundAgain() == false) {
|
||||||
o_LostServers.push_back(ptrDetectedServer);
|
sadClient.eventServerLost(*ptrDetectedServer);
|
||||||
ptrDetectedServer->endCycleSAD();
|
removeDetectedServer(*ptrDetectedServer);
|
||||||
}
|
} else if (ptrDetectedServer->getNew()) {
|
||||||
else if (ptrDetectedServer->getNew()) {
|
|
||||||
o_NewServers.push_back(ptrDetectedServer);
|
|
||||||
ptrDetectedServer->setNew(false);
|
ptrDetectedServer->setNew(false);
|
||||||
ptrDetectedServer->endCycleSAD();
|
sadClient.eventServerDetected(*ptrDetectedServer);
|
||||||
}
|
} else if (ptrDetectedServer->getChanged()) {
|
||||||
else if (ptrDetectedServer->getChanged()) {
|
sadClient.eventServerChanged(*ptrDetectedServer);
|
||||||
o_ChangedServers.push_back(ptrDetectedServer);
|
|
||||||
ptrDetectedServer->endCycleSAD();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ptrDetectedServer->endCycleSAD();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Notify client interface about lost servers
|
|
||||||
for (auto i = o_LostServers.begin(); i != o_LostServers.end(); i++) {
|
|
||||||
ptrDetectedServer = *i;
|
|
||||||
sadClient.eventServerLost(ptrDetectedServer->getID(), ptrDetectedServer->getName(),
|
|
||||||
ptrDetectedServer->getComputerName(), ptrDetectedServer->getIP(), ptrDetectedServer->getPort(), ptrDetectedServer->getAdditions(),ptrDetectedServer->getProjectName(),
|
|
||||||
ptrDetectedServer->getClientIP(),
|
|
||||||
ptrDetectedServer->getIpIsIP4());
|
|
||||||
}
|
|
||||||
//Remove lost servers
|
|
||||||
for (auto i = o_LostServers.begin(); i != o_LostServers.end(); i++) {
|
|
||||||
ptrDetectedServer = *i;
|
|
||||||
removeDetectedServer(ptrDetectedServer);
|
|
||||||
}
|
|
||||||
o_LostServers.clear();
|
|
||||||
|
|
||||||
for (auto i = o_NewServers.begin(); i != o_NewServers.end(); i++) {
|
|
||||||
ptrDetectedServer = *i;
|
|
||||||
sadClient.eventServerDetected(ptrDetectedServer->getID(), ptrDetectedServer->getName(),
|
|
||||||
ptrDetectedServer->getComputerName(), ptrDetectedServer->getIP(), ptrDetectedServer->getPort(), ptrDetectedServer->getAdditions(),ptrDetectedServer->getProjectName(),
|
|
||||||
ptrDetectedServer->getClientIP(),
|
|
||||||
ptrDetectedServer->getIpIsIP4());
|
|
||||||
}
|
|
||||||
o_NewServers.clear();
|
|
||||||
for (auto i = o_ChangedServers.begin(); i != o_ChangedServers.end(); i++) {
|
|
||||||
ptrDetectedServer = *i;
|
|
||||||
sadClient.eventServerChanged(ptrDetectedServer->getID(), ptrDetectedServer->getName(),
|
|
||||||
ptrDetectedServer->getComputerName(), ptrDetectedServer->getIP(), ptrDetectedServer->getPort(), ptrDetectedServer->getAdditions(),ptrDetectedServer->getProjectName(),
|
|
||||||
ptrDetectedServer->getClientIP(),
|
|
||||||
ptrDetectedServer->getIpIsIP4());
|
|
||||||
}
|
|
||||||
o_ChangedServers.clear();
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* 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
|
||||||
* @param p_ServerID the id of the server, every instance of a SPITServer has an own id
|
* @param p_ServerID the id of the server, every instance of a SPITServer has an own id
|
||||||
* @param p_ServerParams the server's parameter
|
* @param p_ServerParams the server's parameter
|
||||||
*/
|
*/
|
||||||
void SAD_DetectedServer::addDetectedServer(bool p_IsIP4, string p_ServerID, string p_ServerParams[]) {
|
void SAD_DetectedServer::addDetectedServer(string p_ServerID, string p_ServerParams[]) {
|
||||||
SAD_DetectedServer *ptrDetectedServer;
|
SAD_DetectedServer *ptrDetectedServer;
|
||||||
{
|
{
|
||||||
auto i = s_DetectedServers.find(p_ServerID);
|
auto i = s_DetectedServers.find(p_ServerID);
|
||||||
if (i != s_DetectedServers.end()) {
|
if (i != s_DetectedServers.end()) {
|
||||||
ptrDetectedServer = i->second;
|
ptrDetectedServer = i->second;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
ptrDetectedServer = new SAD_DetectedServer();
|
ptrDetectedServer = new SAD_DetectedServer();
|
||||||
ptrDetectedServer->setID(p_ServerParams[PARAMINDEX_ID]);
|
ptrDetectedServer->setID(p_ServerParams[PARAMINDEX_ID]);
|
||||||
ptrDetectedServer->setNew(true);
|
ptrDetectedServer->setNew(true);
|
||||||
@@ -125,15 +80,8 @@ void SAD_DetectedServer::addDetectedServer(bool p_IsIP4, string p_ServerID, stri
|
|||||||
ptrDetectedServer->setFoundAgain();
|
ptrDetectedServer->setFoundAgain();
|
||||||
|
|
||||||
// second prefer IP4
|
// second prefer IP4
|
||||||
if (p_IsIP4 == true) {
|
|
||||||
ptrDetectedServer->setIP(p_ServerParams[PARAMINDEX_IP]);
|
|
||||||
ptrDetectedServer->setIPIsIP4(true);
|
|
||||||
ptrDetectedServer->setClientIP(p_ServerParams[PARAMINDEX_CLIENTIP]);
|
|
||||||
}
|
|
||||||
else if (ptrDetectedServer->getIpIsIP4() == false){
|
|
||||||
ptrDetectedServer->setIP(p_ServerParams[PARAMINDEX_IP]);
|
ptrDetectedServer->setIP(p_ServerParams[PARAMINDEX_IP]);
|
||||||
ptrDetectedServer->setClientIP(p_ServerParams[PARAMINDEX_CLIENTIP]);
|
ptrDetectedServer->setClientIP(p_ServerParams[PARAMINDEX_CLIENTIP]);
|
||||||
}
|
|
||||||
ptrDetectedServer->setName(p_ServerParams[PARAMINDEX_NAME]);
|
ptrDetectedServer->setName(p_ServerParams[PARAMINDEX_NAME]);
|
||||||
ptrDetectedServer->setComputerName(p_ServerParams[PARAMINDEX_COMPUTERNAME]);
|
ptrDetectedServer->setComputerName(p_ServerParams[PARAMINDEX_COMPUTERNAME]);
|
||||||
ptrDetectedServer->setPort(p_ServerParams[PARAMINDEX_PORT]);
|
ptrDetectedServer->setPort(p_ServerParams[PARAMINDEX_PORT]);
|
||||||
@@ -147,26 +95,21 @@ void SAD_DetectedServer::addDetectedServer(bool p_IsIP4, string p_ServerID, stri
|
|||||||
* Used by SAD_Client to remove a SPITServer - don't use this manually
|
* Used by SAD_Client to remove a SPITServer - don't use this manually
|
||||||
* @param p_DetectedServer
|
* @param p_DetectedServer
|
||||||
*/
|
*/
|
||||||
void SAD_DetectedServer::removeDetectedServer(SAD_DetectedServer* p_DetectedServer) {
|
void SAD_DetectedServer::removeDetectedServer(SAD_DetectedServer &server) {
|
||||||
SAD_DetectedServer* o_DetectedServer;
|
auto i = s_DetectedServers.find(server.getID());
|
||||||
{
|
|
||||||
auto i = s_DetectedServers.find(p_DetectedServer->getID());
|
|
||||||
if (i != s_DetectedServers.end()) {
|
if (i != s_DetectedServers.end()) {
|
||||||
o_DetectedServer = i->second;
|
SAD_DetectedServer *o_DetectedServer = i->second;
|
||||||
i = s_DetectedServers.erase(i);
|
i = s_DetectedServers.erase(i);
|
||||||
delete o_DetectedServer;
|
delete o_DetectedServer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used by SAD_Client to clear all found SPITServers - don't use this manually
|
* Used by SAD_Client to clear all found SPITServers - don't use this manually
|
||||||
*/
|
*/
|
||||||
void SAD_DetectedServer::clearDetectedServers() {
|
void SAD_DetectedServer::clearDetectedServers() {
|
||||||
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++) {
|
||||||
ptrDetectedServer = i->second;
|
SAD_DetectedServer *ptrDetectedServer = i->second;
|
||||||
i = s_DetectedServers.erase(i);
|
i = s_DetectedServers.erase(i);
|
||||||
delete ptrDetectedServer;
|
delete ptrDetectedServer;
|
||||||
if (i == s_DetectedServers.end()) {
|
if (i == s_DetectedServers.end()) {
|
||||||
@@ -174,4 +117,17 @@ void SAD_DetectedServer::clearDetectedServers() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const SAD_DetectedServer &SAD_DetectedServer::getRefDetectedServer(string p_ServerID) {
|
||||||
|
SAD_DetectedServer *ptrDetectedServer = nullptr;
|
||||||
|
|
||||||
|
auto i = s_DetectedServers.find(p_ServerID);
|
||||||
|
if (i != s_DetectedServers.end()) {
|
||||||
|
ptrDetectedServer = i->second;
|
||||||
|
}
|
||||||
|
if (ptrDetectedServer != NULL) {
|
||||||
|
return *ptrDetectedServer;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new exception();
|
||||||
}
|
}
|
||||||
@@ -69,21 +69,24 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool SPITObject::addSPITObject(SPITObject *p_ptrSPITObject) {
|
bool SPITObject::addSPITObject(SPITObject *p_ptrSPITObject) {
|
||||||
if (p_ptrSPITObject == NULL) return false;
|
if (p_ptrSPITObject == NULL)
|
||||||
|
return false;
|
||||||
{
|
{
|
||||||
s_SPITObjects[p_ptrSPITObject->getID()] = p_ptrSPITObject;
|
s_SPITObjects[p_ptrSPITObject->getID()] = p_ptrSPITObject;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool SPITObject::addSPITObjectRemote(SPITObject *p_ptrSPITObject) {
|
bool SPITObject::addSPITObjectRemote(SPITObject *p_ptrSPITObject) {
|
||||||
if (p_ptrSPITObject == NULL) return false;
|
if (p_ptrSPITObject == NULL)
|
||||||
|
return false;
|
||||||
{
|
{
|
||||||
s_SPITObjectsRemote[p_ptrSPITObject->getID()] = p_ptrSPITObject;
|
s_SPITObjectsRemote[p_ptrSPITObject->getID()] = p_ptrSPITObject;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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());
|
return removeSPITObject(p_ptrSPITObject->getID());
|
||||||
}
|
}
|
||||||
bool SPITObject::removeSPITObject(string p_SPITObjectID) {
|
bool SPITObject::removeSPITObject(string p_SPITObjectID) {
|
||||||
@@ -97,7 +100,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
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());
|
return removeSPITObjectRemote(p_ptrSPITObject->getID());
|
||||||
}
|
}
|
||||||
bool SPITObject::removeSPITObjectRemote(string p_ptrSPITObject) {
|
bool SPITObject::removeSPITObjectRemote(string p_ptrSPITObject) {
|
||||||
@@ -124,8 +128,7 @@
|
|||||||
unordered_map<string, SPITObject *>::iterator i = next(s_SPITObjects.begin(), p_Index);
|
unordered_map<string, SPITObject *>::iterator i = next(s_SPITObjects.begin(), p_Index);
|
||||||
ptrSPITObject = i->second;
|
ptrSPITObject = i->second;
|
||||||
return ptrSPITObject;
|
return ptrSPITObject;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -143,8 +146,7 @@
|
|||||||
unordered_map<string, SPITObject *>::iterator i = next(s_SPITObjects.begin(), p_Index);
|
unordered_map<string, SPITObject *>::iterator i = next(s_SPITObjects.begin(), p_Index);
|
||||||
ptrSPITObject = i->second;
|
ptrSPITObject = i->second;
|
||||||
return *ptrSPITObject;
|
return *ptrSPITObject;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
throw "SPITObject index out of range";
|
throw "SPITObject index out of range";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -156,8 +158,7 @@
|
|||||||
unordered_map<string, SPITObject *>::iterator i = next(s_SPITObjectsRemote.begin(), p_Index);
|
unordered_map<string, SPITObject *>::iterator i = next(s_SPITObjectsRemote.begin(), p_Index);
|
||||||
ptrSPITObject = i->second;
|
ptrSPITObject = i->second;
|
||||||
return ptrSPITObject;
|
return ptrSPITObject;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -175,8 +176,7 @@
|
|||||||
unordered_map<string, SPITObject *>::iterator i = next(s_SPITObjectsRemote.begin(), p_Index);
|
unordered_map<string, SPITObject *>::iterator i = next(s_SPITObjectsRemote.begin(), p_Index);
|
||||||
ptrSPITObject = i->second;
|
ptrSPITObject = i->second;
|
||||||
return *ptrSPITObject;
|
return *ptrSPITObject;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
throw "Remote SPITObject index out of range";
|
throw "Remote SPITObject index out of range";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -261,8 +261,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SPITObject::SPITObject() {
|
SPITObject::SPITObject() {
|
||||||
initMembers();
|
initMembers();
|
||||||
}
|
}
|
||||||
@@ -291,15 +289,13 @@ void SPITObject::initMembers() {
|
|||||||
|
|
||||||
SPITObject::~SPITObject() {}
|
SPITObject::~SPITObject() {}
|
||||||
|
|
||||||
|
|
||||||
bool SPITObject::setMessageOP(SPIT_Message::ReportSPITObject *p_ReportSPITObject) {
|
bool SPITObject::setMessageOP(SPIT_Message::ReportSPITObject *p_ReportSPITObject) {
|
||||||
bool boolChangeAllowed;
|
bool boolChangeAllowed;
|
||||||
bool boolChanged = false;
|
bool boolChanged = false;
|
||||||
|
|
||||||
if (m_CreatedByClient == true && m_Fixed == true) {
|
if (m_CreatedByClient == true && m_Fixed == true) {
|
||||||
boolChangeAllowed = false;
|
boolChangeAllowed = false;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
boolChangeAllowed = true;
|
boolChangeAllowed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -307,89 +303,104 @@ bool SPITObject::setMessageOP(SPIT_Message::ReportSPITObject* p_ReportSPITObject
|
|||||||
if (m_CreatedByClient) {
|
if (m_CreatedByClient) {
|
||||||
// Server reports a client created SPITType -> the type is confirmed
|
// Server reports a client created SPITType -> the type is confirmed
|
||||||
m_Confirmed = true;
|
m_Confirmed = true;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// type is NOT client created -> the client has to confirm the SPITtype
|
// 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 (m_Delay != p_ReportSPITObject->getDelay()) {
|
||||||
if (boolChangeAllowed == false) throw new exception();
|
if (boolChangeAllowed == false)
|
||||||
|
throw new exception();
|
||||||
m_Delay = p_ReportSPITObject->getDelay();
|
m_Delay = p_ReportSPITObject->getDelay();
|
||||||
boolChanged = true;
|
boolChanged = true;
|
||||||
}
|
}
|
||||||
if (m_Duration != p_ReportSPITObject->getDuration()) {
|
if (m_Duration != p_ReportSPITObject->getDuration()) {
|
||||||
if (boolChangeAllowed == false) throw new exception();
|
if (boolChangeAllowed == false)
|
||||||
|
throw new exception();
|
||||||
m_Duration = p_ReportSPITObject->getDuration();
|
m_Duration = p_ReportSPITObject->getDuration();
|
||||||
boolChanged = true;
|
boolChanged = true;
|
||||||
}
|
}
|
||||||
if (m_Fixed != p_ReportSPITObject->getFixed()) {
|
if (m_Fixed != p_ReportSPITObject->getFixed()) {
|
||||||
if (boolChangeAllowed == false) throw new exception();
|
if (boolChangeAllowed == false)
|
||||||
|
throw new exception();
|
||||||
m_Fixed = p_ReportSPITObject->getFixed();
|
m_Fixed = p_ReportSPITObject->getFixed();
|
||||||
boolChanged = true;
|
boolChanged = true;
|
||||||
}
|
}
|
||||||
if (m_FrameFadeInLength != p_ReportSPITObject->getFrameFadeInLength()) {
|
if (m_FrameFadeInLength != p_ReportSPITObject->getFrameFadeInLength()) {
|
||||||
if (boolChangeAllowed == false) throw new exception();
|
if (boolChangeAllowed == false)
|
||||||
|
throw new exception();
|
||||||
m_FrameFadeInLength = p_ReportSPITObject->getFrameFadeInLength();
|
m_FrameFadeInLength = p_ReportSPITObject->getFrameFadeInLength();
|
||||||
boolChanged = true;
|
boolChanged = true;
|
||||||
}
|
}
|
||||||
if (m_FrameFadeOutLength != p_ReportSPITObject->getFrameFadeOutLength()) {
|
if (m_FrameFadeOutLength != p_ReportSPITObject->getFrameFadeOutLength()) {
|
||||||
if (boolChangeAllowed == false) throw new exception();
|
if (boolChangeAllowed == false)
|
||||||
|
throw new exception();
|
||||||
m_FrameFadeOutLength = p_ReportSPITObject->getFrameFadeOutLength();
|
m_FrameFadeOutLength = p_ReportSPITObject->getFrameFadeOutLength();
|
||||||
boolChanged = true;
|
boolChanged = true;
|
||||||
}
|
}
|
||||||
if (m_FrameLength != p_ReportSPITObject->getFrameLength()) {
|
if (m_FrameLength != p_ReportSPITObject->getFrameLength()) {
|
||||||
if (boolChangeAllowed == false) throw new exception();
|
if (boolChangeAllowed == false)
|
||||||
|
throw new exception();
|
||||||
m_FrameLength = p_ReportSPITObject->getFrameLength();
|
m_FrameLength = p_ReportSPITObject->getFrameLength();
|
||||||
boolChanged = true;
|
boolChanged = true;
|
||||||
}
|
}
|
||||||
if (m_FrameStart != p_ReportSPITObject->getFrameStart()) {
|
if (m_FrameStart != p_ReportSPITObject->getFrameStart()) {
|
||||||
if (boolChangeAllowed == false) throw new exception();
|
if (boolChangeAllowed == false)
|
||||||
|
throw new exception();
|
||||||
m_FrameStart = p_ReportSPITObject->getFrameStart();
|
m_FrameStart = p_ReportSPITObject->getFrameStart();
|
||||||
boolChanged = true;
|
boolChanged = true;
|
||||||
}
|
}
|
||||||
if (m_Remark != p_ReportSPITObject->getRemark()) {
|
if (m_Remark != p_ReportSPITObject->getRemark()) {
|
||||||
if (boolChangeAllowed == false) throw new exception();
|
if (boolChangeAllowed == false)
|
||||||
|
throw new exception();
|
||||||
m_Remark = p_ReportSPITObject->getRemark();
|
m_Remark = p_ReportSPITObject->getRemark();
|
||||||
boolChanged = true;
|
boolChanged = true;
|
||||||
}
|
}
|
||||||
if (m_ID != p_ReportSPITObject->getID()) {
|
if (m_ID != p_ReportSPITObject->getID()) {
|
||||||
if (boolChangeAllowed == false) throw new exception();
|
if (boolChangeAllowed == false)
|
||||||
|
throw new exception();
|
||||||
m_ID = p_ReportSPITObject->getID();
|
m_ID = p_ReportSPITObject->getID();
|
||||||
boolChanged = true;
|
boolChanged = true;
|
||||||
}
|
}
|
||||||
if (m_Name != p_ReportSPITObject->getName()) {
|
if (m_Name != p_ReportSPITObject->getName()) {
|
||||||
if (boolChangeAllowed == false) throw new exception();
|
if (boolChangeAllowed == false)
|
||||||
|
throw new exception();
|
||||||
m_Name = p_ReportSPITObject->getName();
|
m_Name = p_ReportSPITObject->getName();
|
||||||
boolChanged = true;
|
boolChanged = true;
|
||||||
}
|
}
|
||||||
if (m_SPITTypeID != p_ReportSPITObject->getSPITTypeID()) {
|
if (m_SPITTypeID != p_ReportSPITObject->getSPITTypeID()) {
|
||||||
if (boolChangeAllowed == false) throw new exception();
|
if (boolChangeAllowed == false)
|
||||||
|
throw new exception();
|
||||||
m_SPITTypeID = p_ReportSPITObject->getSPITTypeID();
|
m_SPITTypeID = p_ReportSPITObject->getSPITTypeID();
|
||||||
boolChanged = true;
|
boolChanged = true;
|
||||||
}
|
}
|
||||||
if (m_ServerParams != p_ReportSPITObject->getServerParams()) {
|
if (m_ServerParams != p_ReportSPITObject->getServerParams()) {
|
||||||
if (boolChangeAllowed == false) throw new exception();
|
if (boolChangeAllowed == false)
|
||||||
|
throw new exception();
|
||||||
m_ServerParams = p_ReportSPITObject->getServerParams();
|
m_ServerParams = p_ReportSPITObject->getServerParams();
|
||||||
boolChanged = true;
|
boolChanged = true;
|
||||||
}
|
}
|
||||||
if (m_ServerRemote != p_ReportSPITObject->getServerRemote()) {
|
if (m_ServerRemote != p_ReportSPITObject->getServerRemote()) {
|
||||||
if (boolChangeAllowed == false) throw new exception();
|
if (boolChangeAllowed == false)
|
||||||
|
throw new exception();
|
||||||
m_ServerRemote = p_ReportSPITObject->getServerRemote();
|
m_ServerRemote = p_ReportSPITObject->getServerRemote();
|
||||||
boolChanged = true;
|
boolChanged = true;
|
||||||
}
|
}
|
||||||
if (m_Track != p_ReportSPITObject->getTrack()) {
|
if (m_Track != p_ReportSPITObject->getTrack()) {
|
||||||
if (boolChangeAllowed == false) throw new exception();
|
if (boolChangeAllowed == false)
|
||||||
|
throw new exception();
|
||||||
m_Track = p_ReportSPITObject->getTrack();
|
m_Track = p_ReportSPITObject->getTrack();
|
||||||
boolChanged = true;
|
boolChanged = true;
|
||||||
}
|
}
|
||||||
if (m_ValueFactor != p_ReportSPITObject->getValueFactor()) {
|
if (m_ValueFactor != p_ReportSPITObject->getValueFactor()) {
|
||||||
if (boolChangeAllowed == false) throw new exception();
|
if (boolChangeAllowed == false)
|
||||||
|
throw new exception();
|
||||||
m_ValueFactor = p_ReportSPITObject->getValueFactor();
|
m_ValueFactor = p_ReportSPITObject->getValueFactor();
|
||||||
boolChanged = true;
|
boolChanged = true;
|
||||||
}
|
}
|
||||||
if (m_ValueUse != p_ReportSPITObject->getValueUse()) {
|
if (m_ValueUse != p_ReportSPITObject->getValueUse()) {
|
||||||
if (boolChangeAllowed == false) throw new exception();
|
if (boolChangeAllowed == false)
|
||||||
|
throw new exception();
|
||||||
m_ValueUse = p_ReportSPITObject->getValueUse();
|
m_ValueUse = p_ReportSPITObject->getValueUse();
|
||||||
boolChanged = true;
|
boolChanged = true;
|
||||||
}
|
}
|
||||||
@@ -433,37 +444,43 @@ void SPITObject::setCreatedByClient(bool p_CreatedByClient) {
|
|||||||
* @return if m_Confirmed has changed
|
* @return if m_Confirmed has changed
|
||||||
*/
|
*/
|
||||||
bool SPITObject::setConfirmed(bool p_Confirmed) {
|
bool SPITObject::setConfirmed(bool p_Confirmed) {
|
||||||
if (m_Confirmed == p_Confirmed) return false;
|
if (m_Confirmed == p_Confirmed)
|
||||||
|
return false;
|
||||||
m_Confirmed = p_Confirmed;
|
m_Confirmed = p_Confirmed;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SPITObject::setName(string p_Name) {
|
bool SPITObject::setName(string p_Name) {
|
||||||
if (m_Name == p_Name) return false;
|
if (m_Name == p_Name)
|
||||||
|
return false;
|
||||||
m_Name = p_Name;
|
m_Name = p_Name;
|
||||||
m_Confirmed = false;
|
m_Confirmed = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool SPITObject::setRemark(string p_Remark) {
|
bool SPITObject::setRemark(string p_Remark) {
|
||||||
if (m_Remark == p_Remark) return false;
|
if (m_Remark == p_Remark)
|
||||||
|
return false;
|
||||||
m_Remark = p_Remark;
|
m_Remark = p_Remark;
|
||||||
m_Confirmed = false;
|
m_Confirmed = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool SPITObject::setServerParams(string p_ServerParams) {
|
bool SPITObject::setServerParams(string p_ServerParams) {
|
||||||
if (m_ServerParams == p_ServerParams) return false;
|
if (m_ServerParams == p_ServerParams)
|
||||||
|
return false;
|
||||||
m_ServerParams = p_ServerParams;
|
m_ServerParams = p_ServerParams;
|
||||||
m_Confirmed = false;
|
m_Confirmed = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool SPITObject::setSPITTypeID(string p_SPITTypeID) {
|
bool SPITObject::setSPITTypeID(string p_SPITTypeID) {
|
||||||
if (m_SPITTypeID == p_SPITTypeID) return false;
|
if (m_SPITTypeID == p_SPITTypeID)
|
||||||
|
return false;
|
||||||
m_SPITTypeID = p_SPITTypeID;
|
m_SPITTypeID = p_SPITTypeID;
|
||||||
m_Confirmed = false;
|
m_Confirmed = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool SPITObject::setServerRemote(bool p_BelongstoServer) {
|
bool SPITObject::setServerRemote(bool p_BelongstoServer) {
|
||||||
if (m_ServerRemote == p_BelongstoServer) return false;
|
if (m_ServerRemote == p_BelongstoServer)
|
||||||
|
return false;
|
||||||
m_ServerRemote = p_BelongstoServer;
|
m_ServerRemote = p_BelongstoServer;
|
||||||
m_Confirmed = false;
|
m_Confirmed = false;
|
||||||
return true;
|
return true;
|
||||||
@@ -475,79 +492,93 @@ bool SPITObject::setServerRemote(bool p_BelongstoServer) {
|
|||||||
* @return true = an action is assigned for the SPITType.
|
* @return true = an action is assigned for the SPITType.
|
||||||
*/
|
*/
|
||||||
bool SPITObject::setActionAssignedType(bool p_ActionAssigned) {
|
bool SPITObject::setActionAssignedType(bool p_ActionAssigned) {
|
||||||
if (m_ActionAssignedType == p_ActionAssigned) return false;
|
if (m_ActionAssignedType == p_ActionAssigned)
|
||||||
|
return false;
|
||||||
bool boolOldActionAssigend;
|
bool boolOldActionAssigend;
|
||||||
boolOldActionAssigend = getActionAssigned();
|
boolOldActionAssigend = getActionAssigned();
|
||||||
m_ActionAssignedType = p_ActionAssigned;
|
m_ActionAssignedType = p_ActionAssigned;
|
||||||
if (getActionAssigned() == boolOldActionAssigend) return false;
|
if (getActionAssigned() == boolOldActionAssigend)
|
||||||
|
return false;
|
||||||
m_Confirmed = false;
|
m_Confirmed = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool SPITObject::setActionAssigned(bool p_ActionAssigned) {
|
bool SPITObject::setActionAssigned(bool p_ActionAssigned) {
|
||||||
if (m_ActionAssigned == p_ActionAssigned) return false;
|
if (m_ActionAssigned == p_ActionAssigned)
|
||||||
|
return false;
|
||||||
bool boolOldActionAssigend;
|
bool boolOldActionAssigend;
|
||||||
boolOldActionAssigend = getActionAssigned();
|
boolOldActionAssigend = getActionAssigned();
|
||||||
m_ActionAssigned = p_ActionAssigned;
|
m_ActionAssigned = p_ActionAssigned;
|
||||||
if (getActionAssigned() == boolOldActionAssigend) return false;
|
if (getActionAssigned() == boolOldActionAssigend)
|
||||||
|
return false;
|
||||||
m_Confirmed = false;
|
m_Confirmed = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool SPITObject::setFixed(bool p_Fixed) {
|
bool SPITObject::setFixed(bool p_Fixed) {
|
||||||
if (m_Fixed == p_Fixed) return false;
|
if (m_Fixed == p_Fixed)
|
||||||
|
return false;
|
||||||
m_Fixed = p_Fixed;
|
m_Fixed = p_Fixed;
|
||||||
m_Confirmed = false;
|
m_Confirmed = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool SPITObject::setFrameStart(long long p_FrameStart) {
|
bool SPITObject::setFrameStart(long long p_FrameStart) {
|
||||||
if (m_FrameStart == p_FrameStart) return false;
|
if (m_FrameStart == p_FrameStart)
|
||||||
|
return false;
|
||||||
m_FrameStart = p_FrameStart;
|
m_FrameStart = p_FrameStart;
|
||||||
m_Confirmed = false;
|
m_Confirmed = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool SPITObject::setFrameLength(long long p_FrameLength) {
|
bool SPITObject::setFrameLength(long long p_FrameLength) {
|
||||||
if (m_FrameLength == p_FrameLength) return false;
|
if (m_FrameLength == p_FrameLength)
|
||||||
|
return false;
|
||||||
m_FrameLength = p_FrameLength;
|
m_FrameLength = p_FrameLength;
|
||||||
m_Confirmed = false;
|
m_Confirmed = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool SPITObject::setFrameFadeInLength(long long p_FrameFadeInLength) {
|
bool SPITObject::setFrameFadeInLength(long long p_FrameFadeInLength) {
|
||||||
if (m_FrameFadeInLength == p_FrameFadeInLength) return false;
|
if (m_FrameFadeInLength == p_FrameFadeInLength)
|
||||||
|
return false;
|
||||||
m_FrameFadeInLength = p_FrameFadeInLength;
|
m_FrameFadeInLength = p_FrameFadeInLength;
|
||||||
m_Confirmed = false;
|
m_Confirmed = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool SPITObject::setFrameFadeOutLength(long long p_FrameFadeOutLength) {
|
bool SPITObject::setFrameFadeOutLength(long long p_FrameFadeOutLength) {
|
||||||
if (m_FrameFadeOutLength == p_FrameFadeOutLength) return false;
|
if (m_FrameFadeOutLength == p_FrameFadeOutLength)
|
||||||
|
return false;
|
||||||
m_FrameFadeOutLength = p_FrameFadeOutLength;
|
m_FrameFadeOutLength = p_FrameFadeOutLength;
|
||||||
m_Confirmed = false;
|
m_Confirmed = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool SPITObject::setValueUse(char p_ValueUse) {
|
bool SPITObject::setValueUse(char p_ValueUse) {
|
||||||
if (m_ValueUse == p_ValueUse) return false;
|
if (m_ValueUse == p_ValueUse)
|
||||||
|
return false;
|
||||||
m_ValueUse = p_ValueUse;
|
m_ValueUse = p_ValueUse;
|
||||||
m_Confirmed = false;
|
m_Confirmed = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool SPITObject::setValueFactor(int p_ValueFactor) {
|
bool SPITObject::setValueFactor(int p_ValueFactor) {
|
||||||
if (m_ValueFactor == p_ValueFactor) return false;
|
if (m_ValueFactor == p_ValueFactor)
|
||||||
|
return false;
|
||||||
m_ValueFactor = p_ValueFactor;
|
m_ValueFactor = p_ValueFactor;
|
||||||
m_Confirmed = false;
|
m_Confirmed = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool SPITObject::setTrack(int p_Track) {
|
bool SPITObject::setTrack(int p_Track) {
|
||||||
if (m_Track == p_Track) return false;
|
if (m_Track == p_Track)
|
||||||
|
return false;
|
||||||
m_Track = p_Track;
|
m_Track = p_Track;
|
||||||
m_Confirmed = false;
|
m_Confirmed = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool SPITObject::setDelay(long long p_Delay) {
|
bool SPITObject::setDelay(long long p_Delay) {
|
||||||
if (m_Delay == p_Delay) return false;
|
if (m_Delay == p_Delay)
|
||||||
|
return false;
|
||||||
m_Delay = p_Delay;
|
m_Delay = p_Delay;
|
||||||
m_Confirmed = false;
|
m_Confirmed = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool SPITObject::setDuration(long long p_Duration) {
|
bool SPITObject::setDuration(long long p_Duration) {
|
||||||
if (m_Duration == p_Duration) return false;
|
if (m_Duration == p_Duration)
|
||||||
|
return false;
|
||||||
m_Duration = p_Duration;
|
m_Duration = p_Duration;
|
||||||
m_Confirmed = false;
|
m_Confirmed = false;
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ SPITPlayer* SPITPlayer::getSPITPlayer(string p_PlayerID) {
|
|||||||
s_SPITPlayers[p_PlayerID] = new SPITPlayer(p_PlayerID);
|
s_SPITPlayers[p_PlayerID] = new SPITPlayer(p_PlayerID);
|
||||||
}
|
}
|
||||||
i = s_SPITPlayers.find(p_PlayerID);
|
i = s_SPITPlayers.find(p_PlayerID);
|
||||||
if (i == s_SPITPlayers.end()) return NULL;
|
if (i == s_SPITPlayers.end())
|
||||||
|
return NULL;
|
||||||
return i->second;
|
return i->second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -58,7 +59,6 @@ SPITPlayer::~SPITPlayer() {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SPITPlayer::setIsRunning(bool p_IsRunning) {
|
void SPITPlayer::setIsRunning(bool p_IsRunning) {
|
||||||
@@ -92,13 +92,11 @@ SPITPlayer::PlaySPITType* SPITPlayer::addSPITType_Playing (string p_SPITTypeID)
|
|||||||
ptrPlaySPITType->setIsPlayed(true);
|
ptrPlaySPITType->setIsPlayed(true);
|
||||||
ptrPlaySPITType->setIsNew(true);
|
ptrPlaySPITType->setIsNew(true);
|
||||||
m_PlaySPITTypes[p_SPITTypeID] = ptrPlaySPITType;
|
m_PlaySPITTypes[p_SPITTypeID] = ptrPlaySPITType;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
ptrPlaySPITType = i->second;
|
ptrPlaySPITType = i->second;
|
||||||
ptrPlaySPITType->setIsPlayed(true);
|
ptrPlaySPITType->setIsPlayed(true);
|
||||||
}
|
}
|
||||||
return ptrPlaySPITType;
|
return ptrPlaySPITType;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SPITPlayer::startPlaySequence() {
|
void SPITPlayer::startPlaySequence() {
|
||||||
@@ -122,7 +120,6 @@ void SPITPlayer::endPlaySequence() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SPITPlayer::PlaySPITType::PlaySPITType() {
|
SPITPlayer::PlaySPITType::PlaySPITType() {
|
||||||
|
|||||||
@@ -15,11 +15,11 @@
|
|||||||
|
|
||||||
#include "SPITSocket.h"
|
#include "SPITSocket.h"
|
||||||
#include "Task.hpp"
|
#include "Task.hpp"
|
||||||
|
#include "esp/uuid.h"
|
||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
#include "esp_netif.h"
|
#include "esp_netif.h"
|
||||||
#include "esp/uuid.h"
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <unistd.h>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -239,7 +239,6 @@ int SPITSocket::receiveMessage(int p_InetFamily, char *p_Buffer, int p_BufferLen
|
|||||||
return intResult;
|
return intResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SPITSocket::IPAddress SPITSocket::getAdaptersInfo() {
|
SPITSocket::IPAddress SPITSocket::getAdaptersInfo() {
|
||||||
// iterate over active interfaces, and print out IPs
|
// iterate over active interfaces, and print out IPs
|
||||||
esp_netif_t *netif = NULL;
|
esp_netif_t *netif = NULL;
|
||||||
@@ -284,5 +283,6 @@ string getClientHostName() {
|
|||||||
if (hostname != nullptr) {
|
if (hostname != nullptr) {
|
||||||
stringHostName = hostname;
|
stringHostName = hostname;
|
||||||
}
|
}
|
||||||
return stringHostName;;
|
return stringHostName;
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
* Created on 8. April 2019, 08:40
|
* Created on 8. April 2019, 08:40
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "SPITType.h"
|
#include "SPITType.h"
|
||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
|
|
||||||
@@ -72,21 +71,24 @@ static const char * TAG = "SPIT";
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool SPITType::addSPITType(SPITType *p_ptrSpitType) {
|
bool SPITType::addSPITType(SPITType *p_ptrSpitType) {
|
||||||
if (p_ptrSpitType == NULL) return false;
|
if (p_ptrSpitType == NULL)
|
||||||
|
return false;
|
||||||
{
|
{
|
||||||
s_SPITTypes[p_ptrSpitType->getID()] = p_ptrSpitType;
|
s_SPITTypes[p_ptrSpitType->getID()] = p_ptrSpitType;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool SPITType::addSPITTypeRemote(SPITType *p_ptrSpitType) {
|
bool SPITType::addSPITTypeRemote(SPITType *p_ptrSpitType) {
|
||||||
if (p_ptrSpitType == NULL) return false;
|
if (p_ptrSpitType == NULL)
|
||||||
|
return false;
|
||||||
{
|
{
|
||||||
s_SPITTypesRemote[p_ptrSpitType->getID()] = p_ptrSpitType;
|
s_SPITTypesRemote[p_ptrSpitType->getID()] = p_ptrSpitType;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool SPITType::removeSPITType(SPITType *p_ptrSpitType) {
|
bool SPITType::removeSPITType(SPITType *p_ptrSpitType) {
|
||||||
if (p_ptrSpitType == NULL) return false;
|
if (p_ptrSpitType == NULL)
|
||||||
|
return false;
|
||||||
{
|
{
|
||||||
auto i = s_SPITTypes.find(p_ptrSpitType->getID());
|
auto i = s_SPITTypes.find(p_ptrSpitType->getID());
|
||||||
if (i == s_SPITTypes.end()) {
|
if (i == s_SPITTypes.end()) {
|
||||||
@@ -97,7 +99,8 @@ static const char * TAG = "SPIT";
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool SPITType::removeSPITTypeRemote(SPITType *p_ptrSpitType) {
|
bool SPITType::removeSPITTypeRemote(SPITType *p_ptrSpitType) {
|
||||||
if (p_ptrSpitType == NULL) return false;
|
if (p_ptrSpitType == NULL)
|
||||||
|
return false;
|
||||||
{
|
{
|
||||||
auto i = s_SPITTypesRemote.find(p_ptrSpitType->getID());
|
auto i = s_SPITTypesRemote.find(p_ptrSpitType->getID());
|
||||||
if (i == s_SPITTypesRemote.end()) {
|
if (i == s_SPITTypesRemote.end()) {
|
||||||
@@ -137,8 +140,7 @@ static const char * TAG = "SPIT";
|
|||||||
unordered_map<string, SPITType *>::iterator i = next(s_SPITTypes.begin(), p_Index);
|
unordered_map<string, SPITType *>::iterator i = next(s_SPITTypes.begin(), p_Index);
|
||||||
ptrSPITType = i->second;
|
ptrSPITType = i->second;
|
||||||
return *ptrSPITType;
|
return *ptrSPITType;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
throw "SPITType index out of range";
|
throw "SPITType index out of range";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -166,8 +168,7 @@ static const char * TAG = "SPIT";
|
|||||||
unordered_map<string, SPITType *>::iterator i = next(s_SPITTypesRemote.begin(), p_Index);
|
unordered_map<string, SPITType *>::iterator i = next(s_SPITTypesRemote.begin(), p_Index);
|
||||||
ptrSPITType = i->second;
|
ptrSPITType = i->second;
|
||||||
return *ptrSPITType;
|
return *ptrSPITType;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
throw "Remote SPITType index out of range";
|
throw "Remote SPITType index out of range";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -238,11 +239,6 @@ static const char * TAG = "SPIT";
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SPITType::SPITType() {
|
SPITType::SPITType() {
|
||||||
initMembers();
|
initMembers();
|
||||||
}
|
}
|
||||||
@@ -287,13 +283,10 @@ void SPITType::initMembers() {
|
|||||||
m_ServerRemote = false;
|
m_ServerRemote = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void SPITType::setCreatedByClient(bool p_CreatedByClient) {
|
void SPITType::setCreatedByClient(bool p_CreatedByClient) {
|
||||||
m_CreatedByClient = p_CreatedByClient;
|
m_CreatedByClient = p_CreatedByClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SPITType::setID(string p_ID) {
|
void SPITType::setID(string p_ID) {
|
||||||
m_ID = p_ID;
|
m_ID = p_ID;
|
||||||
}
|
}
|
||||||
@@ -304,49 +297,57 @@ void SPITType::setCreatedByClient(bool p_CreatedByClient) {
|
|||||||
* @return if m_Confirmed has changed
|
* @return if m_Confirmed has changed
|
||||||
*/
|
*/
|
||||||
bool SPITType::setConfirmed(bool p_Confirmed) {
|
bool SPITType::setConfirmed(bool p_Confirmed) {
|
||||||
if (m_Confirmed == p_Confirmed) return false;
|
if (m_Confirmed == p_Confirmed)
|
||||||
|
return false;
|
||||||
m_Confirmed = p_Confirmed;
|
m_Confirmed = p_Confirmed;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SPITType::setGroupName(string p_GroupName) {
|
bool SPITType::setGroupName(string p_GroupName) {
|
||||||
if (m_GroupName == p_GroupName) return false;
|
if (m_GroupName == p_GroupName)
|
||||||
|
return false;
|
||||||
m_GroupName = p_GroupName;
|
m_GroupName = p_GroupName;
|
||||||
m_Confirmed = false;
|
m_Confirmed = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool SPITType::setName(string p_Name) {
|
bool SPITType::setName(string p_Name) {
|
||||||
if (m_Name == p_Name) return false;
|
if (m_Name == p_Name)
|
||||||
|
return false;
|
||||||
m_Name = p_Name;
|
m_Name = p_Name;
|
||||||
m_Confirmed = false;
|
m_Confirmed = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool SPITType::setServerRemote(bool p_BelongstoServer) {
|
bool SPITType::setServerRemote(bool p_BelongstoServer) {
|
||||||
if (m_ServerRemote == p_BelongstoServer) return false;
|
if (m_ServerRemote == p_BelongstoServer)
|
||||||
|
return false;
|
||||||
m_ServerRemote = p_BelongstoServer;
|
m_ServerRemote = p_BelongstoServer;
|
||||||
m_Confirmed = false;
|
m_Confirmed = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool SPITType::setProjectIndepended(bool p_ProjectIndepended) {
|
bool SPITType::setProjectIndepended(bool p_ProjectIndepended) {
|
||||||
if (m_ServerProjectIndepended == p_ProjectIndepended) return false;
|
if (m_ServerProjectIndepended == p_ProjectIndepended)
|
||||||
|
return false;
|
||||||
m_ServerProjectIndepended = p_ProjectIndepended;
|
m_ServerProjectIndepended = p_ProjectIndepended;
|
||||||
m_Confirmed = false;
|
m_Confirmed = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool SPITType::setFixed(bool p_Fixed) {
|
bool SPITType::setFixed(bool p_Fixed) {
|
||||||
if (m_Fixed == p_Fixed) return false;
|
if (m_Fixed == p_Fixed)
|
||||||
|
return false;
|
||||||
m_Fixed = p_Fixed;
|
m_Fixed = p_Fixed;
|
||||||
m_Confirmed = false;
|
m_Confirmed = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool SPITType::setDefaultDelay(long long p_Delay) {
|
bool SPITType::setDefaultDelay(long long p_Delay) {
|
||||||
if (m_DefaultDelay == p_Delay) return false;
|
if (m_DefaultDelay == p_Delay)
|
||||||
|
return false;
|
||||||
m_DefaultDelay = p_Delay;
|
m_DefaultDelay = p_Delay;
|
||||||
m_Confirmed = false;
|
m_Confirmed = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool SPITType::setDefaultDuration(long long p_Duration) {
|
bool SPITType::setDefaultDuration(long long p_Duration) {
|
||||||
if (m_DefaultDuration == p_Duration) return false;
|
if (m_DefaultDuration == p_Duration)
|
||||||
|
return false;
|
||||||
m_DefaultDuration = p_Duration;
|
m_DefaultDuration = p_Duration;
|
||||||
m_Confirmed = false;
|
m_Confirmed = false;
|
||||||
return true;
|
return true;
|
||||||
@@ -359,7 +360,8 @@ void SPITType::setCreatedByClient(bool p_CreatedByClient) {
|
|||||||
* @return true = the m_ActionAssigned has changed.
|
* @return true = the m_ActionAssigned has changed.
|
||||||
*/
|
*/
|
||||||
bool SPITType::setActionAssigned(bool p_ActionAssigned) {
|
bool SPITType::setActionAssigned(bool p_ActionAssigned) {
|
||||||
if (m_ActionAssigned == p_ActionAssigned) return false;
|
if (m_ActionAssigned == p_ActionAssigned)
|
||||||
|
return false;
|
||||||
m_ActionAssigned = p_ActionAssigned;
|
m_ActionAssigned = p_ActionAssigned;
|
||||||
m_Confirmed = false;
|
m_Confirmed = false;
|
||||||
return true;
|
return true;
|
||||||
@@ -377,8 +379,7 @@ void SPITType::setCreatedByClient(bool p_CreatedByClient) {
|
|||||||
|
|
||||||
if (m_CreatedByClient == true && m_Fixed == true) {
|
if (m_CreatedByClient == true && m_Fixed == true) {
|
||||||
boolChangeAllowed = false;
|
boolChangeAllowed = false;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
boolChangeAllowed = true;
|
boolChangeAllowed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -386,48 +387,55 @@ void SPITType::setCreatedByClient(bool p_CreatedByClient) {
|
|||||||
if (m_CreatedByClient) {
|
if (m_CreatedByClient) {
|
||||||
// Server reports a client created SPITType -> the type is confirmed
|
// Server reports a client created SPITType -> the type is confirmed
|
||||||
m_Confirmed = true;
|
m_Confirmed = true;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// type is NOT client created -> the client has to confirm the SPITtype
|
// type is NOT client created -> the client has to confirm the SPITtype
|
||||||
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) throw new exception();
|
if (boolChangeAllowed == false)
|
||||||
|
throw new exception();
|
||||||
m_DefaultDelay = p_ReportSPITType->getDelay();
|
m_DefaultDelay = p_ReportSPITType->getDelay();
|
||||||
boolChanged = true;
|
boolChanged = true;
|
||||||
}
|
}
|
||||||
if (m_DefaultDuration != p_ReportSPITType->getDuration()) {
|
if (m_DefaultDuration != p_ReportSPITType->getDuration()) {
|
||||||
if (boolChangeAllowed == false) throw new exception();
|
if (boolChangeAllowed == false)
|
||||||
|
throw new exception();
|
||||||
m_DefaultDuration = p_ReportSPITType->getDuration();
|
m_DefaultDuration = p_ReportSPITType->getDuration();
|
||||||
boolChanged = true;
|
boolChanged = true;
|
||||||
}
|
}
|
||||||
if (m_Fixed != p_ReportSPITType->getFixed()) {
|
if (m_Fixed != p_ReportSPITType->getFixed()) {
|
||||||
if (boolChangeAllowed == false) throw new exception();
|
if (boolChangeAllowed == false)
|
||||||
|
throw new exception();
|
||||||
m_Fixed = p_ReportSPITType->getFixed();
|
m_Fixed = p_ReportSPITType->getFixed();
|
||||||
boolChanged = true;
|
boolChanged = true;
|
||||||
}
|
}
|
||||||
if (m_GroupName != p_ReportSPITType->getGroupName()) {
|
if (m_GroupName != p_ReportSPITType->getGroupName()) {
|
||||||
if (boolChangeAllowed == false) throw new exception();
|
if (boolChangeAllowed == false)
|
||||||
|
throw new exception();
|
||||||
m_GroupName = p_ReportSPITType->getGroupName();
|
m_GroupName = p_ReportSPITType->getGroupName();
|
||||||
boolChanged = true;
|
boolChanged = true;
|
||||||
}
|
}
|
||||||
if (m_ID != p_ReportSPITType->getID()) {
|
if (m_ID != p_ReportSPITType->getID()) {
|
||||||
if (boolChangeAllowed == false) throw new exception();
|
if (boolChangeAllowed == false)
|
||||||
|
throw new exception();
|
||||||
m_ID = p_ReportSPITType->getID();
|
m_ID = p_ReportSPITType->getID();
|
||||||
boolChanged = true;
|
boolChanged = true;
|
||||||
}
|
}
|
||||||
if (m_Name != p_ReportSPITType->getName()) {
|
if (m_Name != p_ReportSPITType->getName()) {
|
||||||
if (boolChangeAllowed == false) throw new exception();
|
if (boolChangeAllowed == false)
|
||||||
|
throw new exception();
|
||||||
m_Name = p_ReportSPITType->getName();
|
m_Name = p_ReportSPITType->getName();
|
||||||
boolChanged = true;
|
boolChanged = true;
|
||||||
}
|
}
|
||||||
if (m_ServerProjectIndepended != p_ReportSPITType->getServerProjectIndepended()) {
|
if (m_ServerProjectIndepended != p_ReportSPITType->getServerProjectIndepended()) {
|
||||||
if (boolChangeAllowed == false) throw new exception();
|
if (boolChangeAllowed == false)
|
||||||
|
throw new exception();
|
||||||
m_ServerProjectIndepended = p_ReportSPITType->getServerProjectIndepended();
|
m_ServerProjectIndepended = p_ReportSPITType->getServerProjectIndepended();
|
||||||
boolChanged = true;
|
boolChanged = true;
|
||||||
}
|
}
|
||||||
if (m_ServerRemote != p_ReportSPITType->getServerRemote()) {
|
if (m_ServerRemote != p_ReportSPITType->getServerRemote()) {
|
||||||
if (boolChangeAllowed == false) throw new exception();
|
if (boolChangeAllowed == false)
|
||||||
|
throw new exception();
|
||||||
m_ServerRemote = p_ReportSPITType->getServerRemote();
|
m_ServerRemote = p_ReportSPITType->getServerRemote();
|
||||||
boolChanged = true;
|
boolChanged = true;
|
||||||
}
|
}
|
||||||
|
|||||||
+151
-188
@@ -14,7 +14,6 @@
|
|||||||
* Created on 7. April 2019, 08:50
|
* Created on 7. April 2019, 08:50
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "SPIT_Client.h"
|
#include "SPIT_Client.h"
|
||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
|
|
||||||
@@ -41,7 +40,6 @@ SPIT_Client::~SPIT_Client() {
|
|||||||
disconnectInternal(CONNECTION_NONE);
|
disconnectInternal(CONNECTION_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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");
|
||||||
@@ -76,7 +74,6 @@ void SPIT_Client::clientProjectLoaded() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Virtual construct - means ActionAssigned for SPITTypes is is not implemented in SPITProtocol.<br>
|
* Virtual construct - means ActionAssigned for SPITTypes is is not implemented in SPITProtocol.<br>
|
||||||
* This can used to setActionAssigned to all SPITObjects with this SPITType.<br>
|
* This can used to setActionAssigned to all SPITObjects with this SPITType.<br>
|
||||||
@@ -90,13 +87,15 @@ void SPIT_Client::setActionSPITType(string p_SPITTypeID, bool p_ActionAssigned)
|
|||||||
SPITObject *ptrSPITObject;
|
SPITObject *ptrSPITObject;
|
||||||
{
|
{
|
||||||
ptrSPITType = SPITType::getSPITType(p_SPITTypeID);
|
ptrSPITType = SPITType::getSPITType(p_SPITTypeID);
|
||||||
if (ptrSPITType == NULL) return;
|
if (ptrSPITType == NULL)
|
||||||
|
return;
|
||||||
if (ptrSPITType->setActionAssigned(p_ActionAssigned) == true) {
|
if (ptrSPITType->setActionAssigned(p_ActionAssigned) == true) {
|
||||||
sendSPITTypeInternal(ptrSPITType);
|
sendSPITTypeInternal(ptrSPITType);
|
||||||
|
|
||||||
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) continue;
|
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);
|
||||||
@@ -116,7 +115,8 @@ void SPIT_Client::setActionSPITObject(string p_SPITObjectID, bool p_ActionAssign
|
|||||||
SPITObject *ptrSPITObject;
|
SPITObject *ptrSPITObject;
|
||||||
{
|
{
|
||||||
ptrSPITObject = SPITObject::getSPITObject(p_SPITObjectID);
|
ptrSPITObject = SPITObject::getSPITObject(p_SPITObjectID);
|
||||||
if (ptrSPITObject == NULL) return;
|
if (ptrSPITObject == NULL)
|
||||||
|
return;
|
||||||
if (ptrSPITObject->setActionAssigned(p_ActionAssigned) == true) {
|
if (ptrSPITObject->setActionAssigned(p_ActionAssigned) == true) {
|
||||||
sendSPITObjectInternal(ptrSPITObject);
|
sendSPITObjectInternal(ptrSPITObject);
|
||||||
}
|
}
|
||||||
@@ -140,7 +140,6 @@ void SPIT_Client::startServerAutoDetect() {
|
|||||||
}
|
}
|
||||||
abortSearch = false;
|
abortSearch = false;
|
||||||
sStartSad.give();
|
sStartSad.give();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -162,20 +161,16 @@ void SPIT_Client::stopServerAutoDetect() {
|
|||||||
* @param p_IP the selected ip address of the SPIT server
|
* @param p_IP the selected ip address of the SPIT server
|
||||||
* @param p_Port the port of the SPIT server
|
* @param p_Port the port of the SPIT server
|
||||||
* @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
|
|
||||||
*/
|
*/
|
||||||
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) {
|
void SPIT_Client::eventServerDetected(SAD_DetectedServer &server) {
|
||||||
try {
|
mCallbacks.onServerEvent(ServerEvent::Detect, server);
|
||||||
SAD_DetectedServer o_RefDetectedServer = SAD_DetectedServer::getRefDetectedServer(p_ID);
|
|
||||||
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) {
|
||||||
if (m_ServerID == o_RefDetectedServer.getID()) {
|
if (m_ServerID == server.getID()) {
|
||||||
stopServerAutoDetect();
|
stopServerAutoDetect();
|
||||||
ESP_LOGI(TAG, "reconnect to %s", o_RefDetectedServer.getIP().data());
|
ESP_LOGI(TAG, "reconnect to %s", server.getIP().data());
|
||||||
// ClientPort = "0" meeans use any port
|
// ClientPort = "0" meeans use any port
|
||||||
if (connect(o_RefDetectedServer.getIP(), o_RefDetectedServer.getPort(), o_RefDetectedServer.getClientIP(), "0")) {
|
if (connect(server.getIP(), server.getPort(), server.getClientIP(), "0")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -183,17 +178,12 @@ void SPIT_Client::eventServerDetected(string p_ID, string p_Name, string p_Compu
|
|||||||
|
|
||||||
// Stop auto detection because a suitable server was found
|
// Stop auto detection because a suitable server was found
|
||||||
stopServerAutoDetect();
|
stopServerAutoDetect();
|
||||||
ESP_LOGI(TAG, "connect to %s", o_RefDetectedServer.getIP().data());
|
ESP_LOGI(TAG, "connect to %s", server.getIP().data());
|
||||||
// ClientPort = "0" meeans use any port
|
// ClientPort = "0" meeans use any port
|
||||||
if (not connect(o_RefDetectedServer.getIP(), o_RefDetectedServer.getPort(), o_RefDetectedServer.getClientIP(), "0")) {
|
if (not connect(server.getIP(), server.getPort(), server.getClientIP(), "0")) {
|
||||||
// connection message could not be sent -> better to restart AutoDetection
|
// connection message could not be sent -> better to restart AutoDetection
|
||||||
startServerAutoDetect();
|
startServerAutoDetect();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
catch (...) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* If a SPITServer is not more found, this function is called.
|
* If a SPITServer is not more found, this function is called.
|
||||||
@@ -204,30 +194,15 @@ void SPIT_Client::eventServerDetected(string p_ID, string p_Name, string p_Compu
|
|||||||
* @param p_IP the selected ip address of the SPIT server
|
* @param p_IP the selected ip address of the SPIT server
|
||||||
* @param p_Port the port of the SPIT server
|
* @param p_Port the port of the SPIT server
|
||||||
* @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
|
|
||||||
*/
|
*/
|
||||||
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) {
|
void SPIT_Client::eventServerLost(SAD_DetectedServer &server) {
|
||||||
try {
|
mCallbacks.onServerEvent(ServerEvent::Lost, server);
|
||||||
SAD_DetectedServer o_RefDetectedServer = SAD_DetectedServer::getRefDetectedServer(p_ID);
|
|
||||||
mCallbacks.onServerEvent(ServerEvent::Lost, o_RefDetectedServer);
|
|
||||||
}
|
|
||||||
catch (...) {
|
|
||||||
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) {
|
void SPIT_Client::eventServerChanged(SAD_DetectedServer &server) {
|
||||||
try {
|
mCallbacks.onServerEvent(ServerEvent::Changed, server);
|
||||||
SAD_DetectedServer o_RefDetectedServer = SAD_DetectedServer::getRefDetectedServer(p_ID);
|
|
||||||
mCallbacks.onServerEvent(ServerEvent::Changed, o_RefDetectedServer);
|
|
||||||
// tryConnection(p_DetectedServer);
|
// tryConnection(p_DetectedServer);
|
||||||
}
|
}
|
||||||
catch (...) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// void MyApp::tryConnection(const SAD_DetectedServer& p_DetectedServer) {
|
// void MyApp::tryConnection(const SAD_DetectedServer& p_DetectedServer) {
|
||||||
// //fetch the infoemations from the p_DetectedServer
|
// //fetch the infoemations from the p_DetectedServer
|
||||||
@@ -279,7 +254,8 @@ void SPIT_Client::eventServerChanged(string p_ID, string p_Name, string p_Comput
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
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;
|
||||||
p_Header->setClientID(m_ID);
|
p_Header->setClientID(m_ID);
|
||||||
p_Header->setServerID(m_ServerID);
|
p_Header->setServerID(m_ServerID);
|
||||||
}
|
}
|
||||||
@@ -291,8 +267,10 @@ int SPIT_Client::sendSPITMessage(SPIT_Message::OPPart& spitMessageOPPart) {
|
|||||||
|
|
||||||
fillHeader(spitMessageOPPart.getHeader());
|
fillHeader(spitMessageOPPart.getHeader());
|
||||||
|
|
||||||
if (m_MessageNumber_Send == 255) m_MessageNumber_Send = 1;
|
if (m_MessageNumber_Send == 255)
|
||||||
else m_MessageNumber_Send++;
|
m_MessageNumber_Send = 1;
|
||||||
|
else
|
||||||
|
m_MessageNumber_Send++;
|
||||||
spitMessageOPPart.getHeader()->setMessageNumber(m_MessageNumber_Send);
|
spitMessageOPPart.getHeader()->setMessageNumber(m_MessageNumber_Send);
|
||||||
|
|
||||||
SPIT_Message *ptrSPIT_Message;
|
SPIT_Message *ptrSPIT_Message;
|
||||||
@@ -309,15 +287,15 @@ int SPIT_Client::sendSPITMessage(SPIT_Message::OPPart& spitMessageOPPart) {
|
|||||||
ESP_LOGD(TAG, "SPIT_Client::sendSPITMessage could not send message OPFlage: %d", ptrSPIT_Message->getOPFlag());
|
ESP_LOGD(TAG, "SPIT_Client::sendSPITMessage could not send message OPFlage: %d", ptrSPIT_Message->getOPFlag());
|
||||||
}
|
}
|
||||||
return intResult;
|
return intResult;
|
||||||
}
|
} catch (...) {
|
||||||
catch (...) {
|
|
||||||
ESP_LOGD(TAG, "Exception SPIT_Client::sendSPITMessage OPFlag: %d", ptrSPIT_Message->getOPFlag());
|
ESP_LOGD(TAG, "Exception SPIT_Client::sendSPITMessage OPFlag: %d", ptrSPIT_Message->getOPFlag());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool SPIT_Client::startReceiveSPITMessages() {
|
bool SPIT_Client::startReceiveSPITMessages() {
|
||||||
{
|
{
|
||||||
if (mSPITSocket->getBoundClientFamily() <= 0) return false;
|
if (mSPITSocket->getBoundClientFamily() <= 0)
|
||||||
|
return false;
|
||||||
m_StopReceiveSPITMessages = false;
|
m_StopReceiveSPITMessages = false;
|
||||||
m_ThreadReceive = new fos::TaskT<SPIT_Client &>(receiveSPITMessage, *this, "receiveTask", fos::Task::DefaultStackSize * 4);
|
m_ThreadReceive = new fos::TaskT<SPIT_Client &>(receiveSPITMessage, *this, "receiveTask", fos::Task::DefaultStackSize * 4);
|
||||||
}
|
}
|
||||||
@@ -325,7 +303,8 @@ bool SPIT_Client::startReceiveSPITMessages() {
|
|||||||
}
|
}
|
||||||
void SPIT_Client::stopReceiveSPITMessages() {
|
void SPIT_Client::stopReceiveSPITMessages() {
|
||||||
{
|
{
|
||||||
if (m_StopReceiveSPITMessages == true) return;
|
if (m_StopReceiveSPITMessages == true)
|
||||||
|
return;
|
||||||
m_StopReceiveSPITMessages = true;
|
m_StopReceiveSPITMessages = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -341,7 +320,8 @@ void SPIT_Client::receiveSPITMessage(SPIT_Client& rM) {
|
|||||||
intResult = rM.mSPITSocket->receiveMessage(rM.mSPITSocket->getBoundClientFamily(), buffer, MAXSPITMESSAGEBYTECOUNT, NULL);
|
intResult = rM.mSPITSocket->receiveMessage(rM.mSPITSocket->getBoundClientFamily(), buffer, MAXSPITMESSAGEBYTECOUNT, NULL);
|
||||||
if (intResult < 0) {
|
if (intResult < 0) {
|
||||||
if (rM.m_StopReceiveSPITMessages) {
|
if (rM.m_StopReceiveSPITMessages) {
|
||||||
return;;
|
return;
|
||||||
|
;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -396,7 +376,8 @@ void SPIT_Client::checkParseSPIT_Message(unique_ptr<SPIT_Message> p_SPITMessage)
|
|||||||
}
|
}
|
||||||
|
|
||||||
intNextMessageNumber = m_MessageNumber_Received + 1;
|
intNextMessageNumber = m_MessageNumber_Received + 1;
|
||||||
if (intNextMessageNumber > 255 || intNextMessageNumber < 1) intNextMessageNumber = 1;
|
if (intNextMessageNumber > 255 || intNextMessageNumber < 1)
|
||||||
|
intNextMessageNumber = 1;
|
||||||
|
|
||||||
if (intActualMessageNumber == intNextMessageNumber) {
|
if (intActualMessageNumber == intNextMessageNumber) {
|
||||||
m_MessageNumber_Received = intActualMessageNumber;
|
m_MessageNumber_Received = intActualMessageNumber;
|
||||||
@@ -407,7 +388,8 @@ void SPIT_Client::checkParseSPIT_Message(unique_ptr<SPIT_Message> p_SPITMessage)
|
|||||||
while (m_OvertakingSPIT_Messages.size() > 0) {
|
while (m_OvertakingSPIT_Messages.size() > 0) {
|
||||||
|
|
||||||
intNextMessageNumber = m_MessageNumber_Received + 1;
|
intNextMessageNumber = m_MessageNumber_Received + 1;
|
||||||
if (intNextMessageNumber > 255 || intNextMessageNumber < 1) intNextMessageNumber = 1;
|
if (intNextMessageNumber > 255 || intNextMessageNumber < 1)
|
||||||
|
intNextMessageNumber = 1;
|
||||||
|
|
||||||
ptrOvertakingSPIT_Message = *it;
|
ptrOvertakingSPIT_Message = *it;
|
||||||
intActualMessageNumber = (int)(ptrOvertakingSPIT_Message->getHeader()->getMessageNumber() & 0xFF);
|
intActualMessageNumber = (int)(ptrOvertakingSPIT_Message->getHeader()->getMessageNumber() & 0xFF);
|
||||||
@@ -418,14 +400,12 @@ void SPIT_Client::checkParseSPIT_Message(unique_ptr<SPIT_Message> p_SPITMessage)
|
|||||||
m_OvertakingSPIT_Messages.erase(it);
|
m_OvertakingSPIT_Messages.erase(it);
|
||||||
|
|
||||||
it = m_OvertakingSPIT_Messages.begin();
|
it = m_OvertakingSPIT_Messages.begin();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// p_SPITMessage has overtaken another message
|
// p_SPITMessage has overtaken another message
|
||||||
addOvertakingSPIT_Message(p_SPITMessage.get());
|
addOvertakingSPIT_Message(p_SPITMessage.get());
|
||||||
}
|
}
|
||||||
@@ -434,7 +414,8 @@ void SPIT_Client::checkParseSPIT_Message(unique_ptr<SPIT_Message> p_SPITMessage)
|
|||||||
int SPIT_Client::s_MAX_OVERTAKING_SPIT_MESSAGES = 10;
|
int SPIT_Client::s_MAX_OVERTAKING_SPIT_MESSAGES = 10;
|
||||||
|
|
||||||
void SPIT_Client::addOvertakingSPIT_Message(SPIT_Message *p_SPIT_Message) {
|
void SPIT_Client::addOvertakingSPIT_Message(SPIT_Message *p_SPIT_Message) {
|
||||||
if (p_SPIT_Message == nullptr) return;
|
if (p_SPIT_Message == nullptr)
|
||||||
|
return;
|
||||||
int intMessageNumber;
|
int intMessageNumber;
|
||||||
SPIT_Message *ptrOvertakingSPIT_Message;
|
SPIT_Message *ptrOvertakingSPIT_Message;
|
||||||
int intOvertakingMessageNumber;
|
int intOvertakingMessageNumber;
|
||||||
@@ -473,20 +454,16 @@ void SPIT_Client::parseSPIT_Message(unique_ptr<SPIT_Message> p_SPITMessage) {
|
|||||||
if (p_SPITMessage->getOPFlag() == SPIT_Message::ConnectAnswer::OPFLAG) {
|
if (p_SPITMessage->getOPFlag() == SPIT_Message::ConnectAnswer::OPFLAG) {
|
||||||
SPIT_Message::ConnectAnswer *o_ConnectAnswer = (SPIT_Message::ConnectAnswer *)p_SPITMessage->getOPPart();
|
SPIT_Message::ConnectAnswer *o_ConnectAnswer = (SPIT_Message::ConnectAnswer *)p_SPITMessage->getOPPart();
|
||||||
parseConnectAnswer(o_ConnectAnswer);
|
parseConnectAnswer(o_ConnectAnswer);
|
||||||
}
|
} else if (p_SPITMessage->getOPFlag() == SPIT_Message::Disconnect::OPFLAG) {
|
||||||
else if (p_SPITMessage->getOPFlag() == SPIT_Message::Disconnect::OPFLAG) {
|
|
||||||
SPIT_Message::Disconnect *o_Disconnect = (SPIT_Message::Disconnect *)p_SPITMessage->getOPPart();
|
SPIT_Message::Disconnect *o_Disconnect = (SPIT_Message::Disconnect *)p_SPITMessage->getOPPart();
|
||||||
parseDisconnect(o_Disconnect);
|
parseDisconnect(o_Disconnect);
|
||||||
}
|
} else if (p_SPITMessage->getOPFlag() == SPIT_Message::ReportSPITProject::OPFLAG) {
|
||||||
else if (p_SPITMessage->getOPFlag() == SPIT_Message::ReportSPITProject::OPFLAG) {
|
|
||||||
SPIT_Message::ReportSPITProject *o_ReportSPITProject = (SPIT_Message::ReportSPITProject *)p_SPITMessage->getOPPart();
|
SPIT_Message::ReportSPITProject *o_ReportSPITProject = (SPIT_Message::ReportSPITProject *)p_SPITMessage->getOPPart();
|
||||||
parseReportSPITProject(o_ReportSPITProject);
|
parseReportSPITProject(o_ReportSPITProject);
|
||||||
}
|
} else if (p_SPITMessage->getOPFlag() == SPIT_Message::Watchdog::OPFLAG) {
|
||||||
else if (p_SPITMessage->getOPFlag() == SPIT_Message::Watchdog::OPFLAG) {
|
|
||||||
SPIT_Message::Watchdog *o_Watchdog = (SPIT_Message::Watchdog *)p_SPITMessage->getOPPart();
|
SPIT_Message::Watchdog *o_Watchdog = (SPIT_Message::Watchdog *)p_SPITMessage->getOPPart();
|
||||||
parseWatchdog(o_Watchdog);
|
parseWatchdog(o_Watchdog);
|
||||||
}
|
} else if (p_SPITMessage->getOPFlag() == SPIT_Message::WatchdogAnswer::OPFLAG) {
|
||||||
else if (p_SPITMessage->getOPFlag() == SPIT_Message::WatchdogAnswer::OPFLAG) {
|
|
||||||
SPIT_Message::WatchdogAnswer *o_WatchdogAnswer = (SPIT_Message::WatchdogAnswer *)p_SPITMessage->getOPPart();
|
SPIT_Message::WatchdogAnswer *o_WatchdogAnswer = (SPIT_Message::WatchdogAnswer *)p_SPITMessage->getOPPart();
|
||||||
parseWatchdogAnswer(o_WatchdogAnswer);
|
parseWatchdogAnswer(o_WatchdogAnswer);
|
||||||
}
|
}
|
||||||
@@ -494,20 +471,16 @@ void SPIT_Client::parseSPIT_Message(unique_ptr<SPIT_Message> p_SPITMessage) {
|
|||||||
else if (p_SPITMessage->getOPFlag() == SPIT_Message::StartProjectTransfer::OPFLAG) {
|
else if (p_SPITMessage->getOPFlag() == SPIT_Message::StartProjectTransfer::OPFLAG) {
|
||||||
SPIT_Message::StartProjectTransfer *o_StartProjectTransfer = (SPIT_Message::StartProjectTransfer *)p_SPITMessage->getOPPart();
|
SPIT_Message::StartProjectTransfer *o_StartProjectTransfer = (SPIT_Message::StartProjectTransfer *)p_SPITMessage->getOPPart();
|
||||||
parseStartProjectTransfer(o_StartProjectTransfer);
|
parseStartProjectTransfer(o_StartProjectTransfer);
|
||||||
}
|
} else if (p_SPITMessage->getOPFlag() == SPIT_Message::CloseSPITProject::OPFLAG) {
|
||||||
else if (p_SPITMessage->getOPFlag() == SPIT_Message::CloseSPITProject::OPFLAG) {
|
|
||||||
SPIT_Message::CloseSPITProject *o_CloseSPITProjectr = (SPIT_Message::CloseSPITProject *)p_SPITMessage->getOPPart();
|
SPIT_Message::CloseSPITProject *o_CloseSPITProjectr = (SPIT_Message::CloseSPITProject *)p_SPITMessage->getOPPart();
|
||||||
parseCloseSPITProject(o_CloseSPITProjectr);
|
parseCloseSPITProject(o_CloseSPITProjectr);
|
||||||
}
|
} else if (p_SPITMessage->getOPFlag() == SPIT_Message::RequestProjectTransfer::OPFLAG) {
|
||||||
else if (p_SPITMessage->getOPFlag() == SPIT_Message::RequestProjectTransfer::OPFLAG) {
|
|
||||||
SPIT_Message::RequestProjectTransfer *o_RequestProjectTransfer = (SPIT_Message::RequestProjectTransfer *)p_SPITMessage->getOPPart();
|
SPIT_Message::RequestProjectTransfer *o_RequestProjectTransfer = (SPIT_Message::RequestProjectTransfer *)p_SPITMessage->getOPPart();
|
||||||
parseRequestProjectTransfer(o_RequestProjectTransfer);
|
parseRequestProjectTransfer(o_RequestProjectTransfer);
|
||||||
}
|
} else if (p_SPITMessage->getOPFlag() == SPIT_Message::StartProjectTransfer::OPFLAG) {
|
||||||
else if (p_SPITMessage->getOPFlag() == SPIT_Message::StartProjectTransfer::OPFLAG) {
|
|
||||||
SPIT_Message::StartProjectTransfer *o_StartProjectTransfer = (SPIT_Message::StartProjectTransfer *)p_SPITMessage->getOPPart();
|
SPIT_Message::StartProjectTransfer *o_StartProjectTransfer = (SPIT_Message::StartProjectTransfer *)p_SPITMessage->getOPPart();
|
||||||
parseStartProjectTransfer(o_StartProjectTransfer);
|
parseStartProjectTransfer(o_StartProjectTransfer);
|
||||||
}
|
} else if (p_SPITMessage->getOPFlag() == SPIT_Message::EndProjectTransfer::OPFLAG) {
|
||||||
else if (p_SPITMessage->getOPFlag() == SPIT_Message::EndProjectTransfer::OPFLAG) {
|
|
||||||
SPIT_Message::EndProjectTransfer *o_EndProjectTransfer = (SPIT_Message::EndProjectTransfer *)p_SPITMessage->getOPPart();
|
SPIT_Message::EndProjectTransfer *o_EndProjectTransfer = (SPIT_Message::EndProjectTransfer *)p_SPITMessage->getOPPart();
|
||||||
parseEndProjectTransfer(o_EndProjectTransfer);
|
parseEndProjectTransfer(o_EndProjectTransfer);
|
||||||
}
|
}
|
||||||
@@ -515,8 +488,7 @@ void SPIT_Client::parseSPIT_Message(unique_ptr<SPIT_Message> p_SPITMessage) {
|
|||||||
else if (p_SPITMessage->getOPFlag() == SPIT_Message::ReportSPITType::OPFLAG) {
|
else if (p_SPITMessage->getOPFlag() == SPIT_Message::ReportSPITType::OPFLAG) {
|
||||||
SPIT_Message::ReportSPITType *o_ReportSPITType = (SPIT_Message::ReportSPITType *)p_SPITMessage->getOPPart();
|
SPIT_Message::ReportSPITType *o_ReportSPITType = (SPIT_Message::ReportSPITType *)p_SPITMessage->getOPPart();
|
||||||
parseReportSPITType(o_ReportSPITType);
|
parseReportSPITType(o_ReportSPITType);
|
||||||
}
|
} else if (p_SPITMessage->getOPFlag() == SPIT_Message::RemoveSPITType::OPFLAG) {
|
||||||
else if (p_SPITMessage->getOPFlag() == SPIT_Message::RemoveSPITType::OPFLAG) {
|
|
||||||
SPIT_Message::RemoveSPITType *o_RemoveSPITType = (SPIT_Message::RemoveSPITType *)p_SPITMessage->getOPPart();
|
SPIT_Message::RemoveSPITType *o_RemoveSPITType = (SPIT_Message::RemoveSPITType *)p_SPITMessage->getOPPart();
|
||||||
parseRemoveSPITType(o_RemoveSPITType);
|
parseRemoveSPITType(o_RemoveSPITType);
|
||||||
}
|
}
|
||||||
@@ -524,8 +496,7 @@ void SPIT_Client::parseSPIT_Message(unique_ptr<SPIT_Message> p_SPITMessage) {
|
|||||||
else if (p_SPITMessage->getOPFlag() == SPIT_Message::ReportSPITObject::OPFLAG) {
|
else if (p_SPITMessage->getOPFlag() == SPIT_Message::ReportSPITObject::OPFLAG) {
|
||||||
SPIT_Message::ReportSPITObject *o_ReportSPITObject = (SPIT_Message::ReportSPITObject *)p_SPITMessage->getOPPart();
|
SPIT_Message::ReportSPITObject *o_ReportSPITObject = (SPIT_Message::ReportSPITObject *)p_SPITMessage->getOPPart();
|
||||||
parseReportSPITObject(o_ReportSPITObject);
|
parseReportSPITObject(o_ReportSPITObject);
|
||||||
}
|
} else if (p_SPITMessage->getOPFlag() == SPIT_Message::RemoveSPITObject::OPFLAG) {
|
||||||
else if (p_SPITMessage->getOPFlag() == SPIT_Message::RemoveSPITObject::OPFLAG) {
|
|
||||||
SPIT_Message::RemoveSPITObject *o_RemoveSPITObject = (SPIT_Message::RemoveSPITObject *)p_SPITMessage->getOPPart();
|
SPIT_Message::RemoveSPITObject *o_RemoveSPITObject = (SPIT_Message::RemoveSPITObject *)p_SPITMessage->getOPPart();
|
||||||
parseRemoveSPITObject(o_RemoveSPITObject);
|
parseRemoveSPITObject(o_RemoveSPITObject);
|
||||||
}
|
}
|
||||||
@@ -533,25 +504,20 @@ void SPIT_Client::parseSPIT_Message(unique_ptr<SPIT_Message> p_SPITMessage) {
|
|||||||
else if (p_SPITMessage->getOPFlag() == SPIT_Message::PlaySPITStart::OPFLAG) {
|
else if (p_SPITMessage->getOPFlag() == SPIT_Message::PlaySPITStart::OPFLAG) {
|
||||||
SPIT_Message::PlaySPITStart *o_PlaySPITStart = (SPIT_Message::PlaySPITStart *)p_SPITMessage->getOPPart();
|
SPIT_Message::PlaySPITStart *o_PlaySPITStart = (SPIT_Message::PlaySPITStart *)p_SPITMessage->getOPPart();
|
||||||
parsePlaySPITStart(o_PlaySPITStart);
|
parsePlaySPITStart(o_PlaySPITStart);
|
||||||
}
|
} else if (p_SPITMessage->getOPFlag() == SPIT_Message::PlaySPITObject::OPFLAG) {
|
||||||
else if (p_SPITMessage->getOPFlag() == SPIT_Message::PlaySPITObject::OPFLAG) {
|
|
||||||
SPIT_Message::PlaySPITObject *o_PlaySPITObject = (SPIT_Message::PlaySPITObject *)p_SPITMessage->getOPPart();
|
SPIT_Message::PlaySPITObject *o_PlaySPITObject = (SPIT_Message::PlaySPITObject *)p_SPITMessage->getOPPart();
|
||||||
parsePlaySPITObject(o_PlaySPITObject);
|
parsePlaySPITObject(o_PlaySPITObject);
|
||||||
}
|
} else if (p_SPITMessage->getOPFlag() == SPIT_Message::PlaySPITEnd::OPFLAG) {
|
||||||
else if (p_SPITMessage->getOPFlag() == SPIT_Message::PlaySPITEnd::OPFLAG) {
|
|
||||||
SPIT_Message::PlaySPITEnd *o_PlaySPITEnd = (SPIT_Message::PlaySPITEnd *)p_SPITMessage->getOPPart();
|
SPIT_Message::PlaySPITEnd *o_PlaySPITEnd = (SPIT_Message::PlaySPITEnd *)p_SPITMessage->getOPPart();
|
||||||
parsePlaySPITEnd(o_PlaySPITEnd);
|
parsePlaySPITEnd(o_PlaySPITEnd);
|
||||||
}
|
} else if (p_SPITMessage->getOPFlag() == SPIT_Message::ReportPlayStatus::OPFLAG) {
|
||||||
else if (p_SPITMessage->getOPFlag() == SPIT_Message::ReportPlayStatus::OPFLAG) {
|
|
||||||
SPIT_Message::ReportPlayStatus *o_ReportPlayStatus = (SPIT_Message::ReportPlayStatus *)p_SPITMessage->getOPPart();
|
SPIT_Message::ReportPlayStatus *o_ReportPlayStatus = (SPIT_Message::ReportPlayStatus *)p_SPITMessage->getOPPart();
|
||||||
parseReportPlayStatus(o_ReportPlayStatus);
|
parseReportPlayStatus(o_ReportPlayStatus);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
ESP_LOGD(TAG, "SPIT_Client::parseSPIT_Message: Unknown Message");
|
ESP_LOGD(TAG, "SPIT_Client::parseSPIT_Message: Unknown Message");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//----- Connection ------
|
//----- Connection ------
|
||||||
/**
|
/**
|
||||||
* Tries to connect to a SPITServer.<br>
|
* Tries to connect to a SPITServer.<br>
|
||||||
@@ -623,14 +589,12 @@ void SPIT_Client::disconnectInternal(int p_Cause) {
|
|||||||
switch (m_ConnectionStatus) {
|
switch (m_ConnectionStatus) {
|
||||||
case CONNECTION_LOST:
|
case CONNECTION_LOST:
|
||||||
break;
|
break;
|
||||||
case CONNECTION_NONE:
|
case CONNECTION_NONE: {
|
||||||
{
|
|
||||||
SPIT_Message::Disconnect sMDisconnect;
|
SPIT_Message::Disconnect sMDisconnect;
|
||||||
intResult = sendSPITMessage(sMDisconnect);
|
intResult = sendSPITMessage(sMDisconnect);
|
||||||
if (intResult < 0) {
|
if (intResult < 0) {
|
||||||
}
|
}
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
case CONNECTION_NONESERVER:
|
case CONNECTION_NONESERVER:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -648,7 +612,7 @@ void SPIT_Client::disconnectInternal(int p_Cause) {
|
|||||||
ESP_LOGD(TAG, "connection terminated by server");
|
ESP_LOGD(TAG, "connection terminated by server");
|
||||||
// call eventProjectClosed because this may not be sended by the server,
|
// call eventProjectClosed because this may not be sended by the server,
|
||||||
// when the connection is closed
|
// when the connection is closed
|
||||||
mCallbacks.onProjectClosed(m_ServerProjectID);
|
mCallbacks.onProjectUpdate(ProjUpdate::ServerClosed, m_ServerProjectID);
|
||||||
|
|
||||||
// Server has terminated the connection -> start a new game
|
// Server has terminated the connection -> start a new game
|
||||||
// _doReconnect = false;
|
// _doReconnect = false;
|
||||||
@@ -669,7 +633,8 @@ void SPIT_Client::parseConnectAnswer(SPIT_Message::ConnectAnswer* p_ConnectAnswe
|
|||||||
int intOldConnectionStatus;
|
int intOldConnectionStatus;
|
||||||
intOldConnectionStatus = m_ConnectionStatus;
|
intOldConnectionStatus = m_ConnectionStatus;
|
||||||
|
|
||||||
if (p_ConnectAnswer->getClientID() != m_ID) return;
|
if (p_ConnectAnswer->getClientID() != m_ID)
|
||||||
|
return;
|
||||||
|
|
||||||
m_ServerID = p_ConnectAnswer->getServerID();
|
m_ServerID = p_ConnectAnswer->getServerID();
|
||||||
m_ServerComputerName = p_ConnectAnswer->getServerComputerName();
|
m_ServerComputerName = p_ConnectAnswer->getServerComputerName();
|
||||||
@@ -678,8 +643,7 @@ void SPIT_Client::parseConnectAnswer(SPIT_Message::ConnectAnswer* p_ConnectAnswe
|
|||||||
|
|
||||||
if (p_ConnectAnswer->getConnected() == false) {
|
if (p_ConnectAnswer->getConnected() == false) {
|
||||||
disconnectInternal(CONNECTION_NONESERVER);
|
disconnectInternal(CONNECTION_NONESERVER);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
p_ConnectAnswer->getStepTime();
|
p_ConnectAnswer->getStepTime();
|
||||||
m_ConnectionStatus = CONNECTION_OK;
|
m_ConnectionStatus = CONNECTION_OK;
|
||||||
m_DisconnectedByServer = false;
|
m_DisconnectedByServer = false;
|
||||||
@@ -708,7 +672,6 @@ void SPIT_Client::parseDisconnect(SPIT_Message::Disconnect* p_Disconnect) {
|
|||||||
SPIT_Client::disconnectInternal(intCauseDisconnect);
|
SPIT_Client::disconnectInternal(intCauseDisconnect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//----- Watchdog ------
|
//----- Watchdog ------
|
||||||
/**
|
/**
|
||||||
* The SPIT server sends a watchdog message at regular intervals. The client responds immediately with WatchdogAnswer<br>
|
* The SPIT server sends a watchdog message at regular intervals. The client responds immediately with WatchdogAnswer<br>
|
||||||
@@ -731,7 +694,8 @@ void SPIT_Client::parseWatchdog(SPIT_Message::Watchdog* p_Watchdog) {
|
|||||||
* @param p_Watchdog
|
* @param p_Watchdog
|
||||||
*/
|
*/
|
||||||
void SPIT_Client::parseWatchdogAnswer(SPIT_Message::WatchdogAnswer *p_WatchdogAnswer) {
|
void SPIT_Client::parseWatchdogAnswer(SPIT_Message::WatchdogAnswer *p_WatchdogAnswer) {
|
||||||
answerWatchdog();; //is also done by parseSPIT_Message
|
answerWatchdog();
|
||||||
|
; // is also done by parseSPIT_Message
|
||||||
}
|
}
|
||||||
void SPIT_Client::sendWatchdog() {
|
void SPIT_Client::sendWatchdog() {
|
||||||
int intResult;
|
int intResult;
|
||||||
@@ -744,8 +708,7 @@ void SPIT_Client::sendWatchdog() {
|
|||||||
void SPIT_Client::eventWatchdogLost() {
|
void SPIT_Client::eventWatchdogLost() {
|
||||||
if (m_ConnectionStatus == CONNECTION_TRYCONNECTION) {
|
if (m_ConnectionStatus == CONNECTION_TRYCONNECTION) {
|
||||||
disconnectInternal(CONNECTION_NONESERVER);
|
disconnectInternal(CONNECTION_NONESERVER);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
disconnectInternal(CONNECTION_LOST);
|
disconnectInternal(CONNECTION_LOST);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -753,17 +716,17 @@ void SPIT_Client::eventWatchdogLost() {
|
|||||||
//----- 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;
|
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();
|
||||||
mCallbacks.onProjectReport(m_ServerProjectID, m_ServerProjectName, m_ServerFramesPerSecond);
|
mCallbacks.onProjectUpdate(ProjUpdate::ServerLoaded, m_ServerProjectID);
|
||||||
|
|
||||||
// Set all SPITTypes and SPITObjects confirmed = false
|
// Set all SPITTypes and SPITObjects confirmed = false
|
||||||
SPITType::setConfirmedFalse();
|
SPITType::setConfirmedFalse();
|
||||||
SPITObject::setConfirmedFalse();
|
SPITObject::setConfirmedFalse();
|
||||||
|
|
||||||
|
|
||||||
// Send RequestProjectTransfer
|
// Send RequestProjectTransfer
|
||||||
SPIT_Message::RequestProjectTransfer sMRequestProjectTransfer;
|
SPIT_Message::RequestProjectTransfer sMRequestProjectTransfer;
|
||||||
if (sendSPITMessage(sMRequestProjectTransfer) < 0) {
|
if (sendSPITMessage(sMRequestProjectTransfer) < 0) {
|
||||||
@@ -782,12 +745,12 @@ void SPIT_Client::parseReportSPITProject(SPIT_Message::ReportSPITProject* p_Repo
|
|||||||
}
|
}
|
||||||
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;
|
if (p_CloseSPITProject == NULL)
|
||||||
|
return;
|
||||||
string stringProjectID;
|
string stringProjectID;
|
||||||
mCallbacks.onProjectClosed(p_CloseSPITProject->getProjectID());
|
mCallbacks.onProjectUpdate(ProjUpdate::ServerClosed, p_CloseSPITProject->getProjectID());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string SPIT_Client::getServerProjectID() { return m_ServerProjectID; }
|
string SPIT_Client::getServerProjectID() { return m_ServerProjectID; }
|
||||||
string SPIT_Client::getServerProjectName() { return m_ServerProjectName; }
|
string SPIT_Client::getServerProjectName() { return m_ServerProjectName; }
|
||||||
int SPIT_Client::getServerFramesPerSecond() { return m_ServerFramesPerSecond; }
|
int SPIT_Client::getServerFramesPerSecond() { return m_ServerFramesPerSecond; }
|
||||||
@@ -807,7 +770,8 @@ void SPIT_Client::parseRequestProjectTransfer(SPIT_Message::RequestProjectTransf
|
|||||||
int intCount = SPITType::getSPITTypeCount();
|
int intCount = SPITType::getSPITTypeCount();
|
||||||
for (int i = 0; i < intCount; i++) {
|
for (int i = 0; i < intCount; i++) {
|
||||||
SPITType *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);
|
||||||
}
|
}
|
||||||
@@ -817,7 +781,8 @@ void SPIT_Client::parseRequestProjectTransfer(SPIT_Message::RequestProjectTransf
|
|||||||
int intCount = SPITObject::getSPITObjectCount();
|
int intCount = SPITObject::getSPITObjectCount();
|
||||||
for (int i = 0; i < intCount; i++) {
|
for (int i = 0; i < intCount; i++) {
|
||||||
SPITObject *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);
|
||||||
}
|
}
|
||||||
@@ -831,7 +796,6 @@ void SPIT_Client::parseRequestProjectTransfer(SPIT_Message::RequestProjectTransf
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* NEW IMPLEMENTATION
|
/* NEW IMPLEMENTATION
|
||||||
|
|
||||||
void SPIT_Client::parseRequestProjectTransfer(SPIT_Message::RequestProjectTransfer* p_RequestProjectTransfer) {
|
void SPIT_Client::parseRequestProjectTransfer(SPIT_Message::RequestProjectTransfer* p_RequestProjectTransfer) {
|
||||||
@@ -958,13 +922,12 @@ void SPIT_Client::sendProject(SPIT_Client* p_PtrSPIT_Client) {
|
|||||||
// //Send act
|
// //Send act
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SPIT_Client::parseStartProjectTransfer(SPIT_Message::StartProjectTransfer *p_StartProjectTransfer) {
|
void SPIT_Client::parseStartProjectTransfer(SPIT_Message::StartProjectTransfer *p_StartProjectTransfer) {
|
||||||
mCallbacks.onStartProjectTransfer();
|
mCallbacks.onProjectUpdate(ProjUpdate::StartTransfer, m_ServerProjectID);
|
||||||
}
|
}
|
||||||
void SPIT_Client::parseEndProjectTransfer(SPIT_Message::EndProjectTransfer *p_EndProjectTransfer) {
|
void SPIT_Client::parseEndProjectTransfer(SPIT_Message::EndProjectTransfer *p_EndProjectTransfer) {
|
||||||
SPITObject::clearUnconfirmedSPITObjects();
|
SPITObject::clearUnconfirmedSPITObjects();
|
||||||
mCallbacks.onEndProjectTransfer();
|
mCallbacks.onProjectUpdate(ProjUpdate::EndTransfer, m_ServerProjectID) ;
|
||||||
|
|
||||||
// Send SPIT_Message::ReportSPITProject after the m_SPITClientInterface is notfied of EndProjectTransfer
|
// Send SPIT_Message::ReportSPITProject after the m_SPITClientInterface is notfied of EndProjectTransfer
|
||||||
SPIT_Message::ReportSPITProject ptrSMReportSPITProject;
|
SPIT_Message::ReportSPITProject ptrSMReportSPITProject;
|
||||||
@@ -979,7 +942,8 @@ void SPIT_Client::parseEndProjectTransfer(SPIT_Message::EndProjectTransfer* p_En
|
|||||||
//----- SPIT Types ------
|
//----- SPIT Types ------
|
||||||
void SPIT_Client::parseReportSPITType(SPIT_Message::ReportSPITType *p_ReportSPITType) {
|
void SPIT_Client::parseReportSPITType(SPIT_Message::ReportSPITType *p_ReportSPITType) {
|
||||||
// printf("parse ReportSPITType ID %s Name %s \n",p_ReportSPITType->getID(), p_ReportSPITType->getName());
|
// printf("parse ReportSPITType ID %s Name %s \n",p_ReportSPITType->getID(), p_ReportSPITType->getName());
|
||||||
if (p_ReportSPITType == NULL) return;
|
if (p_ReportSPITType == NULL)
|
||||||
|
return;
|
||||||
SPITType *ptrSPITType;
|
SPITType *ptrSPITType;
|
||||||
bool boolNew = false;
|
bool boolNew = false;
|
||||||
bool boolChanged = false;
|
bool boolChanged = false;
|
||||||
@@ -994,8 +958,7 @@ void SPIT_Client::parseReportSPITType(SPIT_Message::ReportSPITType* p_ReportSPIT
|
|||||||
ptrSPITType = new SPITType();
|
ptrSPITType = new SPITType();
|
||||||
boolNew = true;
|
boolNew = true;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
ptrSPITType = SPITType::getSPITTypeRemote(p_ReportSPITType->getID());
|
ptrSPITType = SPITType::getSPITTypeRemote(p_ReportSPITType->getID());
|
||||||
if (ptrSPITType == NULL) {
|
if (ptrSPITType == NULL) {
|
||||||
ptrSPITType = new SPITType();
|
ptrSPITType = new SPITType();
|
||||||
@@ -1004,21 +967,20 @@ void SPIT_Client::parseReportSPITType(SPIT_Message::ReportSPITType* p_ReportSPIT
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
boolChanged = ptrSPITType->setMessageOP(p_ReportSPITType);
|
boolChanged = ptrSPITType->setMessageOP(p_ReportSPITType);
|
||||||
}
|
} catch (...) {
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto eventType = boolNew ? ObjectEvent::Created : ObjectEvent::Changed;
|
||||||
// add or change SPITType
|
// add or change SPITType
|
||||||
if (ptrSPITType->getServerRemote() == false) {
|
if (ptrSPITType->getServerRemote() == false) {
|
||||||
SPITType::addSPITType(ptrSPITType);
|
SPITType::addSPITType(ptrSPITType);
|
||||||
mCallbacks.onSpitType(boolNew, *ptrSPITType);
|
mCallbacks.onSpitType(eventType, *ptrSPITType);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
SPITType::addSPITTypeRemote(ptrSPITType);
|
SPITType::addSPITTypeRemote(ptrSPITType);
|
||||||
mCallbacks.onSpitTypeRemote(boolNew, *ptrSPITType);
|
mCallbacks.onSpitTypeRemote(eventType, *ptrSPITType);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ptrSPITType != NULL) {
|
if (ptrSPITType != NULL) {
|
||||||
@@ -1030,7 +992,8 @@ void SPIT_Client::parseReportSPITType(SPIT_Message::ReportSPITType* p_ReportSPIT
|
|||||||
}
|
}
|
||||||
void SPIT_Client::parseRemoveSPITType(SPIT_Message::RemoveSPITType *p_RemoveSPITType) {
|
void SPIT_Client::parseRemoveSPITType(SPIT_Message::RemoveSPITType *p_RemoveSPITType) {
|
||||||
// printf("parse RemoveSPITType %s\n", p_RemoveSPITType->getID());
|
// printf("parse RemoveSPITType %s\n", p_RemoveSPITType->getID());
|
||||||
if (p_RemoveSPITType == NULL) return;
|
if (p_RemoveSPITType == NULL)
|
||||||
|
return;
|
||||||
string stringSPITTypeID;
|
string stringSPITTypeID;
|
||||||
bool boolRemote = false;
|
bool boolRemote = false;
|
||||||
SPITType *ptrSPITType;
|
SPITType *ptrSPITType;
|
||||||
@@ -1040,13 +1003,11 @@ void SPIT_Client::parseRemoveSPITType(SPIT_Message::RemoveSPITType* p_RemoveSPIT
|
|||||||
ptrSPITType = SPITType::getSPITTypeRemote(stringSPITTypeID);
|
ptrSPITType = SPITType::getSPITTypeRemote(stringSPITTypeID);
|
||||||
if (ptrSPITType != NULL) {
|
if (ptrSPITType != NULL) {
|
||||||
boolRemote = true;
|
boolRemote = true;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
ptrSPITType = SPITType::getSPITType(stringSPITTypeID);
|
ptrSPITType = SPITType::getSPITType(stringSPITTypeID);
|
||||||
if (ptrSPITType != NULL) {
|
if (ptrSPITType != NULL) {
|
||||||
boolRemote = false;
|
boolRemote = false;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// No SPITType with stringSPITTypeID is listet
|
// No SPITType with stringSPITTypeID is listet
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1060,18 +1021,16 @@ void SPIT_Client::parseRemoveSPITType(SPIT_Message::RemoveSPITType* p_RemoveSPIT
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (boolRemote == false) {
|
if (boolRemote == false) {
|
||||||
mCallbacks.onSpitTypeRemoved(*ptrSPITType);
|
mCallbacks.onSpitType(ObjectEvent::Deleted, *ptrSPITType);
|
||||||
SPITType::removeSPITType(ptrSPITType);
|
SPITType::removeSPITType(ptrSPITType);
|
||||||
}
|
} else {
|
||||||
else {
|
mCallbacks.onSpitTypeRemote(ObjectEvent::Deleted, *ptrSPITType);
|
||||||
mCallbacks.onSpitTypeRemoteRemoved(*ptrSPITType);
|
|
||||||
SPITType::removeSPITTypeRemote(ptrSPITType);
|
SPITType::removeSPITTypeRemote(ptrSPITType);
|
||||||
}
|
}
|
||||||
delete ptrSPITType;
|
delete ptrSPITType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If a client has changed a SPITType, it should send it to the server to transmit the changes.<br>
|
* If a client has changed a SPITType, it should send it to the server to transmit the changes.<br>
|
||||||
* If the SPITType is a fixed one and not created by the client himself, then an eventSPITType can be sent from the server, which cancels the changes.<br>
|
* If the SPITType is a fixed one and not created by the client himself, then an eventSPITType can be sent from the server, which cancels the changes.<br>
|
||||||
@@ -1079,7 +1038,8 @@ void SPIT_Client::parseRemoveSPITType(SPIT_Message::RemoveSPITType* p_RemoveSPIT
|
|||||||
* @return 0 = is sended, -1 = is not sended
|
* @return 0 = is sended, -1 = is not sended
|
||||||
*/
|
*/
|
||||||
int SPIT_Client::sendSPITTypeInternal(SPITType *p_SPITType) {
|
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);
|
||||||
return sendSPITMessage(ptrSMReportSPITType);
|
return sendSPITMessage(ptrSMReportSPITType);
|
||||||
@@ -1091,11 +1051,13 @@ int SPIT_Client::sendSPITTypeInternal(SPITType* p_SPITType) {
|
|||||||
* @return true = changed, false = not changed maybe p_SPITType is NULL or the SPITType doesn't exists
|
* @return true = changed, false = not changed maybe p_SPITType is NULL or the SPITType doesn't exists
|
||||||
*/
|
*/
|
||||||
bool SPIT_Client::changeSPITType(SPITType *p_SPITType) {
|
bool SPIT_Client::changeSPITType(SPITType *p_SPITType) {
|
||||||
if (p_SPITType == NULL) return false;
|
if (p_SPITType == NULL)
|
||||||
|
return false;
|
||||||
SPITType *ptrSPITType;
|
SPITType *ptrSPITType;
|
||||||
{
|
{
|
||||||
ptrSPITType = SPITType::getSPITType(p_SPITType->getID());
|
ptrSPITType = SPITType::getSPITType(p_SPITType->getID());
|
||||||
if (ptrSPITType == NULL) return false;
|
if (ptrSPITType == NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
ptrSPITType->setDefaultDelay(p_SPITType->getDefaultDelay());
|
ptrSPITType->setDefaultDelay(p_SPITType->getDefaultDelay());
|
||||||
ptrSPITType->setDefaultDuration(p_SPITType->getDefaultDuration());
|
ptrSPITType->setDefaultDuration(p_SPITType->getDefaultDuration());
|
||||||
@@ -1104,7 +1066,7 @@ bool SPIT_Client::changeSPITType(SPITType* p_SPITType) {
|
|||||||
ptrSPITType->setName(p_SPITType->getName());
|
ptrSPITType->setName(p_SPITType->getName());
|
||||||
ptrSPITType->setProjectIndepended(p_SPITType->getProjectIndepended());
|
ptrSPITType->setProjectIndepended(p_SPITType->getProjectIndepended());
|
||||||
|
|
||||||
mCallbacks.onSpitType(false, *ptrSPITType);
|
mCallbacks.onSpitType(ObjectEvent::Changed, *ptrSPITType);
|
||||||
sendSPITTypeInternal(ptrSPITType);
|
sendSPITTypeInternal(ptrSPITType);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -1119,14 +1081,16 @@ bool SPIT_Client::changeSPITType(SPITType* p_SPITType) {
|
|||||||
* @return 0 = is sended, -1 = is not sended
|
* @return 0 = is sended, -1 = is not sended
|
||||||
*/
|
*/
|
||||||
int SPIT_Client::removeSPITType(string p_SPITTypeID) {
|
int SPIT_Client::removeSPITType(string p_SPITTypeID) {
|
||||||
if (p_SPITTypeID.length() <= 0) return -1;
|
if (p_SPITTypeID.length() <= 0)
|
||||||
|
return -1;
|
||||||
SPITType *ptrSPITType;
|
SPITType *ptrSPITType;
|
||||||
{
|
{
|
||||||
ptrSPITType = SPITType::getSPITType(p_SPITTypeID);
|
ptrSPITType = SPITType::getSPITType(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);
|
||||||
mCallbacks.onSpitTypeRemoved(*ptrSPITType);
|
mCallbacks.onSpitType(ObjectEvent::Deleted,*ptrSPITType);
|
||||||
SPITType::removeSPITType(ptrSPITType);
|
SPITType::removeSPITType(ptrSPITType);
|
||||||
delete ptrSPITType;
|
delete ptrSPITType;
|
||||||
return sendSPITMessage(sMRemoveSPITType);
|
return sendSPITMessage(sMRemoveSPITType);
|
||||||
@@ -1134,7 +1098,6 @@ int SPIT_Client::removeSPITType(string p_SPITTypeID) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SPITType *SPIT_Client::createSPITTypeFixed(string p_ID, string p_GroupName, string p_Name, long long p_DefaultDelay, long long p_DefaultDuration) {
|
SPITType *SPIT_Client::createSPITTypeFixed(string p_ID, string p_GroupName, string p_Name, long long p_DefaultDelay, long long p_DefaultDuration) {
|
||||||
return createSPITType(p_ID, p_GroupName, p_Name, p_DefaultDelay, p_DefaultDuration, true, true);
|
return createSPITType(p_ID, p_GroupName, p_Name, p_DefaultDelay, p_DefaultDuration, true, true);
|
||||||
}
|
}
|
||||||
@@ -1148,8 +1111,7 @@ SPITType* SPIT_Client::createSPITType(string p_ID, string p_GroupName, string p_
|
|||||||
ptrSPITType = new SPITType(p_ID, p_GroupName, p_Name, p_FIxed, p_ProjectIndepended, p_DefaultDelay, p_DefaultDuration);
|
ptrSPITType = new SPITType(p_ID, p_GroupName, p_Name, p_FIxed, p_ProjectIndepended, p_DefaultDelay, p_DefaultDuration);
|
||||||
ptrSPITType->setCreatedByClient(true);
|
ptrSPITType->setCreatedByClient(true);
|
||||||
boolNew = true;
|
boolNew = true;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
ptrSPITType->setID(p_ID);
|
ptrSPITType->setID(p_ID);
|
||||||
ptrSPITType->setGroupName(p_GroupName);
|
ptrSPITType->setGroupName(p_GroupName);
|
||||||
ptrSPITType->setName(p_Name);
|
ptrSPITType->setName(p_Name);
|
||||||
@@ -1160,8 +1122,10 @@ SPITType* SPIT_Client::createSPITType(string p_ID, string p_GroupName, string p_
|
|||||||
boolNew = false;
|
boolNew = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto eventType = boolNew ? ObjectEvent::Created : ObjectEvent::Changed;
|
||||||
SPITType::addSPITType(ptrSPITType);
|
SPITType::addSPITType(ptrSPITType);
|
||||||
mCallbacks.onSpitType(boolNew, *ptrSPITType);
|
mCallbacks.onSpitType(eventType, *ptrSPITType);
|
||||||
sendSPITTypeInternal(ptrSPITType);
|
sendSPITTypeInternal(ptrSPITType);
|
||||||
return ptrSPITType;
|
return ptrSPITType;
|
||||||
}
|
}
|
||||||
@@ -1170,7 +1134,8 @@ SPITType* SPIT_Client::createSPITType(string p_ID, string p_GroupName, string p_
|
|||||||
void SPIT_Client::parseReportSPITObject(SPIT_Message::ReportSPITObject *p_ReportSPITObject) {
|
void SPIT_Client::parseReportSPITObject(SPIT_Message::ReportSPITObject *p_ReportSPITObject) {
|
||||||
|
|
||||||
// printf("parse ReportSPITObject %s\n", p_ReportSPITObject->getID());
|
// printf("parse ReportSPITObject %s\n", p_ReportSPITObject->getID());
|
||||||
if (p_ReportSPITObject == NULL) return;
|
if (p_ReportSPITObject == NULL)
|
||||||
|
return;
|
||||||
SPITObject *ptrSPITObject;
|
SPITObject *ptrSPITObject;
|
||||||
SPITType *ptrSPITType;
|
SPITType *ptrSPITType;
|
||||||
bool boolNew = false;
|
bool boolNew = false;
|
||||||
@@ -1182,7 +1147,6 @@ void SPIT_Client::parseReportSPITObject(SPIT_Message::ReportSPITObject* p_Report
|
|||||||
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) {
|
if (ptrSPITType == NULL) {
|
||||||
// No associated SPITType found
|
// No associated SPITType found
|
||||||
if (ptrSPITObject != NULL) {
|
if (ptrSPITObject != NULL) {
|
||||||
@@ -1201,8 +1165,7 @@ void SPIT_Client::parseReportSPITObject(SPIT_Message::ReportSPITObject* p_Report
|
|||||||
|
|
||||||
ptrSPITObject = new SPITObject();
|
ptrSPITObject = new SPITObject();
|
||||||
boolNew = true;
|
boolNew = true;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// The user's app my veto the SPITType
|
// The user's app my veto the SPITType
|
||||||
if (mCallbacks.onCheckSpitObjectVeto(p_ReportSPITObject) == false) {
|
if (mCallbacks.onCheckSpitObjectVeto(p_ReportSPITObject) == false) {
|
||||||
// SpitObject exists and User APp denied the SPITObject -> remove the SPITObject without sending a message
|
// SpitObject exists and User APp denied the SPITObject -> remove the SPITObject without sending a message
|
||||||
@@ -1211,8 +1174,7 @@ void SPIT_Client::parseReportSPITObject(SPIT_Message::ReportSPITObject* p_Report
|
|||||||
return;
|
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());
|
||||||
@@ -1228,40 +1190,37 @@ void SPIT_Client::parseReportSPITObject(SPIT_Message::ReportSPITObject* p_Report
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
boolChanged = ptrSPITObject->setMessageOP(p_ReportSPITObject);
|
boolChanged = ptrSPITObject->setMessageOP(p_ReportSPITObject);
|
||||||
}
|
} catch (...) {
|
||||||
catch (...) {
|
|
||||||
// setMessageOP error - the SPITObject can't be changed, it may be fixed and crated by this client
|
// setMessageOP error - the SPITObject can't be changed, it may be fixed and crated by this client
|
||||||
sendSPITObjectInternal(ptrSPITObject);
|
sendSPITObjectInternal(ptrSPITObject);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (boolRemote == false) {
|
if (boolRemote == false) {
|
||||||
// set the virtual action assignment
|
// set the virtual action assignment
|
||||||
ptrSPITObject->setActionAssignedType(ptrSPITType->getActionAssigned());
|
ptrSPITObject->setActionAssignedType(ptrSPITType->getActionAssigned());
|
||||||
SPITObject::addSPITObject(ptrSPITObject);
|
SPITObject::addSPITObject(ptrSPITObject);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
SPITObject::addSPITObjectRemote(ptrSPITObject);
|
SPITObject::addSPITObjectRemote(ptrSPITObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto eventType = boolNew ? ObjectEvent::Created : ObjectEvent::Changed;
|
||||||
if (boolRemote) {
|
if (boolRemote) {
|
||||||
mCallbacks.onSpitObjectRemote(boolNew, *ptrSPITType, *ptrSPITObject);
|
mCallbacks.onSpitObjectRemote(eventType, *ptrSPITType, *ptrSPITObject);
|
||||||
}
|
} else {
|
||||||
else {
|
mCallbacks.onSpitObject(eventType, *ptrSPITType, *ptrSPITObject);
|
||||||
mCallbacks.onSpitObject(boolNew, *ptrSPITType, *ptrSPITObject);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ptrSPITObject->setConfirmed(true) == true || boolChanged == true) {
|
if (ptrSPITObject->setConfirmed(true) == true || boolChanged == true) {
|
||||||
// Confirmation has changed
|
// Confirmation has changed
|
||||||
sendSPITObjectInternal(ptrSPITObject);
|
sendSPITObjectInternal(ptrSPITObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void SPIT_Client::parseRemoveSPITObject(SPIT_Message::RemoveSPITObject *p_RemoveSPITObject) {
|
void SPIT_Client::parseRemoveSPITObject(SPIT_Message::RemoveSPITObject *p_RemoveSPITObject) {
|
||||||
// printf("parse RemoveSPITObject %s\n", p_RemoveSPITObject->getID());
|
// printf("parse RemoveSPITObject %s\n", p_RemoveSPITObject->getID());
|
||||||
if (p_RemoveSPITObject == NULL) return;
|
if (p_RemoveSPITObject == NULL)
|
||||||
|
return;
|
||||||
bool boolRemote = false;
|
bool boolRemote = false;
|
||||||
SPITObject *ptrSPITObject;
|
SPITObject *ptrSPITObject;
|
||||||
SPITType *ptrSPITType;
|
SPITType *ptrSPITType;
|
||||||
@@ -1273,29 +1232,26 @@ void SPIT_Client::parseRemoveSPITObject(SPIT_Message::RemoveSPITObject* p_Remove
|
|||||||
ptrSPITType = SPITType::getSPITTypeRemote(ptrSPITObject->getSPITTypeID());
|
ptrSPITType = SPITType::getSPITTypeRemote(ptrSPITObject->getSPITTypeID());
|
||||||
if (ptrSPITType != NULL) {
|
if (ptrSPITType != NULL) {
|
||||||
if (boolRemote) {
|
if (boolRemote) {
|
||||||
mCallbacks.onSpitObjectRemoteRemoved(*ptrSPITType, *ptrSPITObject);
|
mCallbacks.onSpitObjectRemote(ObjectEvent::Deleted, *ptrSPITType, *ptrSPITObject);
|
||||||
|
} else {
|
||||||
|
mCallbacks.onSpitObject(ObjectEvent::Deleted, *ptrSPITType, *ptrSPITObject);
|
||||||
}
|
}
|
||||||
else {
|
} else {
|
||||||
mCallbacks.onSpitObjectRemoved(*ptrSPITType, *ptrSPITObject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// No associated SPITType found
|
// No associated SPITType found
|
||||||
// delete the SPITObject without a notification
|
// delete the SPITObject without a notification
|
||||||
}
|
}
|
||||||
SPITObject::removeSPITObjectRemote(ptrSPITObject);
|
SPITObject::removeSPITObjectRemote(ptrSPITObject);
|
||||||
delete ptrSPITObject;
|
delete ptrSPITObject;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// call removeSPITObject, this will notify the server that the object is removed
|
// call removeSPITObject, this will notify the server that the object is removed
|
||||||
removeSPITObject(p_RemoveSPITObject->getID());
|
removeSPITObject(p_RemoveSPITObject->getID());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int SPIT_Client::sendSPITObjectInternal(SPITObject *ptrSPITObject) {
|
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);
|
||||||
|
|
||||||
@@ -1310,16 +1266,20 @@ int SPIT_Client::sendSPITObjectInternal(SPITObject* ptrSPITObject) {
|
|||||||
* @return true = SPITObject is changed, false = not changed, maybe p_SPITObject is NULL or the SPITObject doesn't exists
|
* @return true = SPITObject is changed, false = not changed, maybe p_SPITObject is NULL or the SPITObject doesn't exists
|
||||||
*/
|
*/
|
||||||
bool SPIT_Client::changeSPITObject(SPITObject *p_SPITObject) {
|
bool SPIT_Client::changeSPITObject(SPITObject *p_SPITObject) {
|
||||||
if (p_SPITObject == NULL) return false;
|
if (p_SPITObject == NULL)
|
||||||
|
return false;
|
||||||
SPITObject *ptrSPITObject;
|
SPITObject *ptrSPITObject;
|
||||||
SPITType *ptrSPITType;
|
SPITType *ptrSPITType;
|
||||||
{
|
{
|
||||||
ptrSPITObject = SPITObject::getSPITObject(p_SPITObject->getID());
|
ptrSPITObject = SPITObject::getSPITObject(p_SPITObject->getID());
|
||||||
if (ptrSPITObject == NULL) return false;
|
if (ptrSPITObject == NULL)
|
||||||
|
return false;
|
||||||
ptrSPITType = SPITType::getSPITType(p_SPITObject->getID());
|
ptrSPITType = SPITType::getSPITType(p_SPITObject->getID());
|
||||||
if(ptrSPITObject == NULL) return false;
|
if (ptrSPITObject == NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
ptrSPITObject->setActionAssigned(p_SPITObject->getActionAssigned());;
|
ptrSPITObject->setActionAssigned(p_SPITObject->getActionAssigned());
|
||||||
|
;
|
||||||
ptrSPITObject->setDelay(p_SPITObject->getDelay());
|
ptrSPITObject->setDelay(p_SPITObject->getDelay());
|
||||||
ptrSPITObject->setDuration(p_SPITObject->getDelay());
|
ptrSPITObject->setDuration(p_SPITObject->getDelay());
|
||||||
ptrSPITObject->setFixed(p_SPITObject->getFixed());
|
ptrSPITObject->setFixed(p_SPITObject->getFixed());
|
||||||
@@ -1335,7 +1295,7 @@ bool SPIT_Client::changeSPITObject(SPITObject* p_SPITObject) {
|
|||||||
ptrSPITObject->setValueFactor(p_SPITObject->getValueFactor());
|
ptrSPITObject->setValueFactor(p_SPITObject->getValueFactor());
|
||||||
ptrSPITObject->setValueUse(p_SPITObject->getValueUse());
|
ptrSPITObject->setValueUse(p_SPITObject->getValueUse());
|
||||||
|
|
||||||
mCallbacks.onSpitObject(false, *ptrSPITType, *ptrSPITObject);
|
mCallbacks.onSpitObject(ObjectEvent::Changed, *ptrSPITType, *ptrSPITObject);
|
||||||
sendSPITObjectInternal(ptrSPITObject);
|
sendSPITObjectInternal(ptrSPITObject);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -1351,18 +1311,21 @@ bool SPIT_Client::changeSPITObject(SPITObject* p_SPITObject) {
|
|||||||
* @return 0 = sended to the SPITServer, -1 = not sended to the SPITServer or nos SPITObject with id == p_SPITObjectID exists.
|
* @return 0 = sended to the SPITServer, -1 = not sended to the SPITServer or nos SPITObject with id == p_SPITObjectID exists.
|
||||||
*/
|
*/
|
||||||
int SPIT_Client::removeSPITObject(string p_SPITObjectID) {
|
int SPIT_Client::removeSPITObject(string p_SPITObjectID) {
|
||||||
if (p_SPITObjectID.length() <= 0) return -1;
|
if (p_SPITObjectID.length() <= 0)
|
||||||
|
return -1;
|
||||||
SPITType *ptrSPITType;
|
SPITType *ptrSPITType;
|
||||||
SPITObject *ptrSPITObject;
|
SPITObject *ptrSPITObject;
|
||||||
{
|
{
|
||||||
SPIT_Message::RemoveSPITObject sMRemoveSPITObject;
|
SPIT_Message::RemoveSPITObject sMRemoveSPITObject;
|
||||||
|
|
||||||
ptrSPITObject = SPITObject::getSPITObject(p_SPITObjectID);
|
ptrSPITObject = SPITObject::getSPITObject(p_SPITObjectID);
|
||||||
if (ptrSPITObject == NULL) return -1;
|
if (ptrSPITObject == NULL)
|
||||||
|
return -1;
|
||||||
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);
|
||||||
mCallbacks.onSpitObjectRemoved(*ptrSPITType, *ptrSPITObject);
|
mCallbacks.onSpitObject(ObjectEvent::Deleted, *ptrSPITType, *ptrSPITObject);
|
||||||
SPITObject::removeSPITObject(ptrSPITObject);
|
SPITObject::removeSPITObject(ptrSPITObject);
|
||||||
delete ptrSPITObject;
|
delete ptrSPITObject;
|
||||||
return sendSPITMessage(sMRemoveSPITObject);
|
return sendSPITMessage(sMRemoveSPITObject);
|
||||||
@@ -1370,7 +1333,6 @@ int SPIT_Client::removeSPITObject(string p_SPITObjectID) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//----- Play SPIT Objects ------
|
//----- Play SPIT Objects ------
|
||||||
|
|
||||||
void SPIT_Client::parsePlaySPITStart(SPIT_Message::PlaySPITStart *p_PlaySPITStart) {
|
void SPIT_Client::parsePlaySPITStart(SPIT_Message::PlaySPITStart *p_PlaySPITStart) {
|
||||||
@@ -1378,7 +1340,8 @@ void SPIT_Client::parsePlaySPITStart(SPIT_Message::PlaySPITStart* p_PlaySPITStar
|
|||||||
SPITPlayer *ptrSPITPlayer;
|
SPITPlayer *ptrSPITPlayer;
|
||||||
{
|
{
|
||||||
ptrSPITPlayer = SPITPlayer::getSPITPlayer(p_PlaySPITStart->getPlayerID());
|
ptrSPITPlayer = SPITPlayer::getSPITPlayer(p_PlaySPITStart->getPlayerID());
|
||||||
if (ptrSPITPlayer == NULL) return;
|
if (ptrSPITPlayer == NULL)
|
||||||
|
return;
|
||||||
ptrSPITPlayer->setIsRunning(p_PlaySPITStart->getPlayerIsRunning());
|
ptrSPITPlayer->setIsRunning(p_PlaySPITStart->getPlayerIsRunning());
|
||||||
ptrSPITPlayer->setName(p_PlaySPITStart->getPlayerName());
|
ptrSPITPlayer->setName(p_PlaySPITStart->getPlayerName());
|
||||||
ptrSPITPlayer->setType(p_PlaySPITStart->getPlayerType());
|
ptrSPITPlayer->setType(p_PlaySPITStart->getPlayerType());
|
||||||
@@ -1395,7 +1358,8 @@ void SPIT_Client::parsePlaySPITObject(SPIT_Message::PlaySPITObject* p_PlaySPITOb
|
|||||||
SPITObject *ptrSPITObject;
|
SPITObject *ptrSPITObject;
|
||||||
{
|
{
|
||||||
ptrSPITPlayer = SPITPlayer::getSPITPlayer(p_PlaySPITObject->getPlayerID());
|
ptrSPITPlayer = SPITPlayer::getSPITPlayer(p_PlaySPITObject->getPlayerID());
|
||||||
if (ptrSPITPlayer == NULL) return;
|
if (ptrSPITPlayer == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
// Fetch infoemations from SPITObject
|
// Fetch infoemations from SPITObject
|
||||||
ptrSPITObject = SPITObject::getSPITObject(p_PlaySPITObject->getSPITObjectID());
|
ptrSPITObject = SPITObject::getSPITObject(p_PlaySPITObject->getSPITObjectID());
|
||||||
@@ -1410,7 +1374,6 @@ void SPIT_Client::parsePlaySPITObject(SPIT_Message::PlaySPITObject* p_PlaySPITOb
|
|||||||
ptrPlaySPITType->setPlayerIsRunning(ptrSPITPlayer->getIsRunning());
|
ptrPlaySPITType->setPlayerIsRunning(ptrSPITPlayer->getIsRunning());
|
||||||
ptrPlaySPITType->addValue(((double)p_PlaySPITObject->getValue() / 1000000), ((double)ptrSPITObject->getValueFactor() / 1000000));
|
ptrPlaySPITType->addValue(((double)p_PlaySPITObject->getValue() / 1000000), ((double)ptrSPITObject->getValueFactor() / 1000000));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
void SPIT_Client::parsePlaySPITEnd(SPIT_Message::PlaySPITEnd *p_PlaySPITEnd) {
|
void SPIT_Client::parsePlaySPITEnd(SPIT_Message::PlaySPITEnd *p_PlaySPITEnd) {
|
||||||
// printf("parse PlaySPITEnd \n");
|
// printf("parse PlaySPITEnd \n");
|
||||||
@@ -1454,7 +1417,8 @@ void SPIT_Client::parsePlaySPITEnd(SPIT_Message::PlaySPITEnd* p_PlaySPITEnd) {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
ptrSPITPlayer = SPITPlayer::getSPITPlayer(p_PlaySPITEnd->getPlayerID());
|
ptrSPITPlayer = SPITPlayer::getSPITPlayer(p_PlaySPITEnd->getPlayerID());
|
||||||
if (ptrSPITPlayer == NULL) return;
|
if (ptrSPITPlayer == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
unordered_map<string, SPITPlayer::PlaySPITType *> *ptrPlaySPITTypes = ptrSPITPlayer->getPlaySPITTypes();
|
unordered_map<string, SPITPlayer::PlaySPITType *> *ptrPlaySPITTypes = ptrSPITPlayer->getPlaySPITTypes();
|
||||||
for (auto i = ptrPlaySPITTypes->begin(); i != ptrPlaySPITTypes->end(); i++) {
|
for (auto i = ptrPlaySPITTypes->begin(); i != ptrPlaySPITTypes->end(); i++) {
|
||||||
@@ -1478,7 +1442,6 @@ void SPIT_Client::parsePlaySPITEnd(SPIT_Message::PlaySPITEnd* p_PlaySPITEnd) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ptrSPITPlayer->endPlaySequence();
|
ptrSPITPlayer->endPlaySequence();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SPIT_Client::parseReportPlayStatus(SPIT_Message::ReportPlayStatus *p_ReportPlayStatus) {
|
void SPIT_Client::parseReportPlayStatus(SPIT_Message::ReportPlayStatus *p_ReportPlayStatus) {
|
||||||
@@ -1488,7 +1451,6 @@ void SPIT_Client::parseReportPlayStatus(SPIT_Message::ReportPlayStatus* p_Report
|
|||||||
SPITObject *ptrSPITObject = NULL;
|
SPITObject *ptrSPITObject = NULL;
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
ptrSPITObject = SPITObject::getSPITObjectRemote(p_ReportPlayStatus->getID());
|
ptrSPITObject = SPITObject::getSPITObjectRemote(p_ReportPlayStatus->getID());
|
||||||
if (ptrSPITObject == NULL) {
|
if (ptrSPITObject == NULL) {
|
||||||
ptrSPITObject = SPITObject::getSPITObject(p_ReportPlayStatus->getID());
|
ptrSPITObject = SPITObject::getSPITObject(p_ReportPlayStatus->getID());
|
||||||
@@ -1498,8 +1460,7 @@ void SPIT_Client::parseReportPlayStatus(SPIT_Message::ReportPlayStatus* p_Report
|
|||||||
}
|
}
|
||||||
if (ptrSPITObject->getServerRemote() == false) {
|
if (ptrSPITObject->getServerRemote() == false) {
|
||||||
ptrSPITType = SPITType::getSPITType(ptrSPITObject->getSPITTypeID());
|
ptrSPITType = SPITType::getSPITType(ptrSPITObject->getSPITTypeID());
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
ptrSPITType = SPITType::getSPITTypeRemote(ptrSPITObject->getSPITTypeID());
|
ptrSPITType = SPITType::getSPITTypeRemote(ptrSPITObject->getSPITTypeID());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1530,7 +1491,8 @@ void SPIT_Client::sendRemoteObject(string p_SPITObjectID, int p_Valueppm, char p
|
|||||||
SPITObject *ptrRemoteSPITObject;
|
SPITObject *ptrRemoteSPITObject;
|
||||||
{
|
{
|
||||||
ptrRemoteSPITObject = SPITObject::getSPITObjectRemote(p_SPITObjectID);
|
ptrRemoteSPITObject = SPITObject::getSPITObjectRemote(p_SPITObjectID);
|
||||||
if (ptrRemoteSPITObject == NULL) return;
|
if (ptrRemoteSPITObject == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
SPIT_Message::PlaySPITStart playSPITStart;
|
SPIT_Message::PlaySPITStart playSPITStart;
|
||||||
playSPITStart.setPlayerID(m_ID);
|
playSPITStart.setPlayerID(m_ID);
|
||||||
@@ -1623,7 +1585,7 @@ static constexpr int WATCHDOGTIME = 3000;
|
|||||||
intIndex++;
|
intIndex++;
|
||||||
}
|
}
|
||||||
stringParts[SAD_DetectedServer::PARAMINDEX_IP] = stringServerIP;
|
stringParts[SAD_DetectedServer::PARAMINDEX_IP] = stringServerIP;
|
||||||
SAD_DetectedServer::addDetectedServer(true, stringParts[SAD_DetectedServer::PARAMINDEX_ID], stringParts);
|
SAD_DetectedServer::addDetectedServer(stringParts[SAD_DetectedServer::PARAMINDEX_ID], stringParts);
|
||||||
}
|
}
|
||||||
fos::Task::delayMs(100);
|
fos::Task::delayMs(100);
|
||||||
SAD_DetectedServer::cycleEnd(instance);
|
SAD_DetectedServer::cycleEnd(instance);
|
||||||
@@ -1655,7 +1617,8 @@ static constexpr int WATCHDOGTIME = 3000;
|
|||||||
nextWdCheck = nextWdTrigger + WATCHDOGTIME;
|
nextWdCheck = nextWdTrigger + WATCHDOGTIME;
|
||||||
}
|
}
|
||||||
fos::Task::delayMs(25);
|
fos::Task::delayMs(25);
|
||||||
if(instance.m_StopReceiveSPITMessages) break;
|
if (instance.m_StopReceiveSPITMessages)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
+349
-6
@@ -27,6 +27,33 @@ struct {
|
|||||||
const char *changingPosition = /* <mqttPrefix>/ */ "watch/changingPosition";
|
const char *changingPosition = /* <mqttPrefix>/ */ "watch/changingPosition";
|
||||||
} MqttTopics;
|
} MqttTopics;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
const char *expectedServer = "";
|
||||||
|
struct {
|
||||||
|
const char *group = "CatasWatchMovement";
|
||||||
|
const char *startShuffle = "ActionStartShuffle";
|
||||||
|
const char *moveToX[6] = {
|
||||||
|
"ActionMoveTo1",
|
||||||
|
"ActionMoveTo2",
|
||||||
|
"ActionMoveTo3",
|
||||||
|
"ActionMoveTo4",
|
||||||
|
"ActionMoveTo5",
|
||||||
|
"ActionMoveTo6",
|
||||||
|
};
|
||||||
|
} Provided;
|
||||||
|
struct {
|
||||||
|
const char *changingPos = "ChangingPositionScene";
|
||||||
|
const char *inPosX[6] = {
|
||||||
|
"InPosition1Scene",
|
||||||
|
"InPosition2Scene",
|
||||||
|
"InPosition3Scene",
|
||||||
|
"InPosition4Scene",
|
||||||
|
"InPosition5Scene",
|
||||||
|
"InPosition6Scene",
|
||||||
|
};
|
||||||
|
} Expected;
|
||||||
|
} SpitTypes;
|
||||||
|
|
||||||
// ToDo:
|
// ToDo:
|
||||||
// - MQTT Integration
|
// - MQTT Integration
|
||||||
// - OTA
|
// - OTA
|
||||||
@@ -36,8 +63,8 @@ struct {
|
|||||||
|
|
||||||
#include "watchMain.hpp"
|
#include "watchMain.hpp"
|
||||||
|
|
||||||
string MyApp::s_ClientName = "CatasWatchDev";
|
string ClientName = "CatasWatchDev";
|
||||||
string MyApp::s_ProjectName = "CatastrphicProj";
|
string ProjectName = "CatastrphicProj";
|
||||||
|
|
||||||
extern "C" { // This switch allows the ROS C-implementation to find this main
|
extern "C" { // This switch allows the ROS C-implementation to find this main
|
||||||
void app_main(void);
|
void app_main(void);
|
||||||
@@ -59,8 +86,18 @@ enum class MoveType {
|
|||||||
Shuffle,
|
Shuffle,
|
||||||
Demo
|
Demo
|
||||||
};
|
};
|
||||||
|
enum class ResponseType {
|
||||||
|
StepAt,
|
||||||
|
StartMoving,
|
||||||
|
};
|
||||||
struct MoveCommand {
|
struct MoveCommand {
|
||||||
MoveType type;
|
MoveType type;
|
||||||
|
// 1..6
|
||||||
|
uint8_t pos;
|
||||||
|
};
|
||||||
|
struct Arrived {
|
||||||
|
ResponseType type;
|
||||||
|
// 1..6
|
||||||
uint8_t pos;
|
uint8_t pos;
|
||||||
};
|
};
|
||||||
struct PictoIllumCommand {
|
struct PictoIllumCommand {
|
||||||
@@ -68,6 +105,7 @@ struct PictoIllumCommand {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static fos::Queue<MoveCommand> commandQueue(8);
|
static fos::Queue<MoveCommand> commandQueue(8);
|
||||||
|
static fos::Queue<Arrived> responseQueue(8);
|
||||||
static fos::Queue<PictoIllumCommand> pictoIllumQue(2);
|
static fos::Queue<PictoIllumCommand> pictoIllumQue(2);
|
||||||
|
|
||||||
DeviceState activeState;
|
DeviceState activeState;
|
||||||
@@ -346,6 +384,7 @@ static void dmxSocketTask(int addrFamily) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fos::Semaphore etherActive;
|
fos::Semaphore etherActive;
|
||||||
|
fos::Semaphore spitProjectFinish;
|
||||||
|
|
||||||
/** Event handler for IP_EVENT_ETH_GOT_IP */
|
/** Event handler for IP_EVENT_ETH_GOT_IP */
|
||||||
static void got_ip_event_handler(void *arg, esp_event_base_t event_base,
|
static void got_ip_event_handler(void *arg, esp_event_base_t event_base,
|
||||||
@@ -587,9 +626,11 @@ void MovementTask() {
|
|||||||
"Running Stepper by %i steps with prof=%i a=%.2f w=%.2f",
|
"Running Stepper by %i steps with prof=%i a=%.2f w=%.2f",
|
||||||
delta, activeState.profile, activeState.accel, activeState.speed);
|
delta, activeState.profile, activeState.accel, activeState.speed);
|
||||||
pictoIllumQue.enqueue(std::make_unique<PictoIllumCommand>(0));
|
pictoIllumQue.enqueue(std::make_unique<PictoIllumCommand>(0));
|
||||||
|
responseQueue.enqueue(std::make_unique<Arrived>(ResponseType::StartMoving, 0));
|
||||||
stepper.moveBy(delta * std::numbers::pi / 3,
|
stepper.moveBy(delta * std::numbers::pi / 3,
|
||||||
activeState.profile, activeState.accel, activeState.speed);
|
activeState.profile, activeState.accel, activeState.speed);
|
||||||
pictoIllumQue.enqueue(std::make_unique<PictoIllumCommand>(newPos));
|
pictoIllumQue.enqueue(std::make_unique<PictoIllumCommand>(newPos));
|
||||||
|
responseQueue.enqueue(std::make_unique<Arrived>(ResponseType::StepAt, newPos));
|
||||||
activeState.pictogram = newPos;
|
activeState.pictogram = newPos;
|
||||||
}
|
}
|
||||||
} else if (cmd->type == MoveType::Demo) {
|
} else if (cmd->type == MoveType::Demo) {
|
||||||
@@ -616,19 +657,321 @@ void MovementTask() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
struct LocalSpitObj {
|
||||||
|
string iD;
|
||||||
|
string groupName;
|
||||||
|
string name;
|
||||||
|
};
|
||||||
|
std::map<string, MoveCommand> ProvidedSpitActions;
|
||||||
|
std::map<string, string> ExpectedObjects;
|
||||||
|
|
||||||
|
void onServerEvent(SPIT_Client::ServerEvent event, const SAD_DetectedServer &p_DetectedServer) {
|
||||||
|
switch (event) {
|
||||||
|
case SPIT_Client::ServerEvent::Detect:
|
||||||
|
ESP_LOGI(TAG, "SERVER DETECTED");
|
||||||
|
ESP_LOGI(TAG, " Name: %s", p_DetectedServer.getName().data());
|
||||||
|
ESP_LOGI(TAG, " ID: %s", p_DetectedServer.getID().data());
|
||||||
|
ESP_LOGI(TAG, " Computer: %s", p_DetectedServer.getComputerName().data());
|
||||||
|
ESP_LOGI(TAG, " IP: %s", p_DetectedServer.getIP().data());
|
||||||
|
ESP_LOGI(TAG, " Port: %s", p_DetectedServer.getPort().data());
|
||||||
|
ESP_LOGI(TAG, " Addition: %s", p_DetectedServer.getAdditions().data());
|
||||||
|
ESP_LOGI(TAG, " ClientIP: %s", p_DetectedServer.getClientIP().data());
|
||||||
|
break;
|
||||||
|
case SPIT_Client::ServerEvent::Lost:
|
||||||
|
ESP_LOGW(TAG, "Server lost Name: %s IP: %s", p_DetectedServer.getName().data(), p_DetectedServer.getIP().data());
|
||||||
|
|
||||||
|
break;
|
||||||
|
case SPIT_Client::ServerEvent::Changed:
|
||||||
|
ESP_LOGW(TAG, "Server lost Name: %s IP: %s", p_DetectedServer.getName().data(), p_DetectedServer.getIP().data());
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
// The transfer of the server's SPITTypes and SPITObjects is finished.
|
||||||
|
void onProjectUpdate(SPIT_Client::ProjUpdate state, string projectId) {
|
||||||
|
|
||||||
|
switch (state) {
|
||||||
|
case SPIT_Client::ProjUpdate::ServerLoaded:
|
||||||
|
ESP_LOGI(TAG, "eventProjectReport ID: %s ", projectId.data());
|
||||||
|
break;
|
||||||
|
case SPIT_Client::ProjUpdate::StartTransfer:
|
||||||
|
ESP_LOGI(TAG, "eventStartProjectTransfer");
|
||||||
|
break;
|
||||||
|
case SPIT_Client::ProjUpdate::EndTransfer:
|
||||||
|
ESP_LOGI(TAG, "eventEndProjectTransfer");
|
||||||
|
spitProjectFinish.give();
|
||||||
|
break;
|
||||||
|
case SPIT_Client::ProjUpdate::ServerClosed:
|
||||||
|
ESP_LOGI(TAG, "eventProjectClosed ID: %s", projectId.data());
|
||||||
|
// If we don't save SPITServer's project specific information
|
||||||
|
// perhaps close all SPITObjects and RemoteSPITObjects to avoid conflicts, when the SPITServer loads a new project
|
||||||
|
// SPITObject::clearSPITObjects();
|
||||||
|
// SPITObject::clearSPITObjectsRemote();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 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 onCheckSpitObjectVeto(SPIT_Message::ReportSPITObject *p_ReportSPITObject) {
|
||||||
|
if (p_ReportSPITObject == NULL)
|
||||||
|
return true;
|
||||||
|
SPITType *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 = SPITObject::getSPITObject(p_ReportSPITObject->getID());
|
||||||
|
// Don't allow foreign SPITTypes
|
||||||
|
if (ptrSPITObject == NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called when the server has created, loaded, changed or deleted a SPITType.
|
||||||
|
// May also occur when the server confirms a SPITType created or changed by the client.
|
||||||
|
void onSpitType(SPIT_Client::ObjectEvent event, const SPITType &p_SPITType) {
|
||||||
|
if (event == SPIT_Client::ObjectEvent::Created) {
|
||||||
|
// Whenever you provide an action for this SPITType take this over in your code.
|
||||||
|
// call _SpitClient.setActionSPITType(p_SPITType.getID(), true);
|
||||||
|
ESP_LOGI(TAG, "NEW SPIT-Type ID: %s GroupName: %s Name: %s confirmed: %d", p_SPITType.getID().data(), p_SPITType.getGroupName().data(), p_SPITType.getName().data(), p_SPITType.getConfirmed());
|
||||||
|
auto typeName = p_SPITType.getName();
|
||||||
|
if (ExpectedObjects.contains(typeName)) {
|
||||||
|
ExpectedObjects[typeName] = p_SPITType.getID();
|
||||||
|
}
|
||||||
|
} else if (event == SPIT_Client::ObjectEvent::Changed) {
|
||||||
|
ESP_LOGI(TAG, "SPIT-Type CHANGED ID: %s GroupName: %s Name: %s confirmed: %d", p_SPITType.getID().data(), p_SPITType.getGroupName().data(), p_SPITType.getName().data(), p_SPITType.getConfirmed());
|
||||||
|
} else if (event == SPIT_Client::ObjectEvent::Deleted) {
|
||||||
|
ESP_LOGI(TAG, "SPIT-Type Removed ID: %s GroupName: %s Name: %s\n", p_SPITType.getID().data(), p_SPITType.getGroupName().data(), p_SPITType.getName().data());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the server has created or changed a Remote SPITType.
|
||||||
|
* Remote SPITType are used in Remote SPITObjects. A Remote SPITObject is used to remote control the SPITServer.
|
||||||
|
* @param p_New true = server created a new SPITType / false = server changed a existing SPITType
|
||||||
|
*/
|
||||||
|
void onSpitTypeRemote(SPIT_Client::ObjectEvent event, const SPITType &p_SPITType) {
|
||||||
|
if (event == SPIT_Client::ObjectEvent::Created) {
|
||||||
|
ESP_LOGI(TAG, "NEW SPIT-REMOTE-Type ID: %s GroupName: %s Name: %s confirmed: %d", p_SPITType.getID().data(), p_SPITType.getGroupName().data(), p_SPITType.getName().data(), p_SPITType.getConfirmed());
|
||||||
|
} else if (event == SPIT_Client::ObjectEvent::Changed) {
|
||||||
|
// we had to inform all Remote SPITObjects using the p_SPITType
|
||||||
|
// perhaps the SPITObject uses information from the SPITType
|
||||||
|
SPITObject *ptrSPITObject;
|
||||||
|
int intSPITObjectCount;
|
||||||
|
intSPITObjectCount = SPITObject::getSPITObjectRemoteCount();
|
||||||
|
for (int intObject = 0; intObject < intSPITObjectCount; intObject++) {
|
||||||
|
ptrSPITObject = SPITObject::getSPITObjectRemote(intObject);
|
||||||
|
if (ptrSPITObject == NULL)
|
||||||
|
continue;
|
||||||
|
if (ptrSPITObject->getSPITTypeID() == p_SPITType.getID()) {
|
||||||
|
// call ecentSPITObjectRemote
|
||||||
|
// onSpitObjectRemote(SPIT_Client::ObjectEvent::Changed, p_SPITType, *ptrSPITObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ESP_LOGI(TAG, "SPIT-REMOTE-Type CHANGED ID: %s GroupName: %s Name: %s confirmed: %d", p_SPITType.getID().data(), p_SPITType.getGroupName().data(), p_SPITType.getName().data(), p_SPITType.getConfirmed());
|
||||||
|
} else if (event == SPIT_Client::ObjectEvent::Deleted) {
|
||||||
|
ESP_LOGD(TAG, "SPIT-REMOTE-Type Removed ID: %s GroupName: %s Name: %s\n", p_SPITType.getID().data(), p_SPITType.getGroupName().data(), p_SPITType.getName().data());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the server has created, loaded or changed a SPITObject.
|
||||||
|
* May also occur when the server confirms a SPITObject created by the client, what the client should never do!!.
|
||||||
|
* false = server changed a existing SPITObject
|
||||||
|
* @param p_SPITType a reference to a copy of the associated SPITType instance.
|
||||||
|
* @param p_SPITObject a reference to a copy of the SPITObject instance.
|
||||||
|
*/
|
||||||
|
void onSpitObject(SPIT_Client::ObjectEvent event, const SPITType &p_SPITType, const SPITObject &p_SPITObject) {
|
||||||
|
if (event == SPIT_Client::ObjectEvent::Created) {
|
||||||
|
ESP_LOGI(TAG, "NEW SPIT-Object ID: %s Name: %s -> SPITType: %s", p_SPITObject.getID().data(), p_SPITObject.getName().data(), p_SPITType.getName().data());
|
||||||
|
// check your actions
|
||||||
|
// Whenever you provide an action for this SPITObject take this over in your code.
|
||||||
|
// call _SpitClient.setActionSPITObject(p_SPITObject.getID(), true);
|
||||||
|
|
||||||
|
// for our little excample as described in loadClientProject:
|
||||||
|
// We have only actions for SPITTypes - means every SPITObject with the associated "Actionx"-SPITTypes will trigger the action when it is played
|
||||||
|
//-> no need to do something here, because setActionSPITType has been set prior and the SPITObject will automatically inherits this
|
||||||
|
// SPITObjects with other SPITTypes asscciated will trigger no actions
|
||||||
|
|
||||||
|
} else if (event == SPIT_Client::ObjectEvent::Changed) {
|
||||||
|
ESP_LOGI(TAG, "SPIT-Object CHANGED ID: %s Name: %s -> SPITType: %s", p_SPITObject.getID().data(), p_SPITObject.getName().data(), p_SPITType.getName().data());
|
||||||
|
} else if (event == SPIT_Client::ObjectEvent::Deleted) {
|
||||||
|
ESP_LOGD(TAG, "SPIT-Object Removed ID: %s Name: %s\n", p_SPITObject.getID().data(), p_SPITObject.getName().data());
|
||||||
|
// Check your actions
|
||||||
|
// take the removal of the SPITObject over in your code
|
||||||
|
|
||||||
|
// CAUTION: Deleted SPITObjects can be added later again (perhaps per UNDO on the SPITServer)
|
||||||
|
//-> don't remove your assigned action immediately - keep it to reassign it later
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Called when the server has created or changed a Remote SPITObject.
|
||||||
|
* A Remote SPITObject is used to remote control the SPITServer.
|
||||||
|
* @param p_New true = server created a new remote SPITObject
|
||||||
|
* false = server changed a existing remote SPITObject
|
||||||
|
* @param p_SPITType a reference to a copy of the associated SPITType instance.
|
||||||
|
* @param p_SPITObject a reference to a copy of the SPITObject instance.
|
||||||
|
*/
|
||||||
|
void onSpitObjectRemote(SPIT_Client::ObjectEvent event, const SPITType &p_SPITType, const SPITObject &p_SPITObject) {
|
||||||
|
if (event == SPIT_Client::ObjectEvent::Created) {
|
||||||
|
ESP_LOGI(TAG, "NEW SPIT-REMOTE-Object ID: %s Name: %s -> SPITType: %s", p_SPITObject.getID().data(), p_SPITObject.getName().data(), p_SPITType.getName().data());
|
||||||
|
// This is a remote SPITObject which can be used to remote control the server.
|
||||||
|
// If you want you can list this for later use
|
||||||
|
} else if (event == SPIT_Client::ObjectEvent::Changed) {
|
||||||
|
ESP_LOGI(TAG, "SPIT-REMOTE-Object CHANGED ID: %s Name: %s -> SPITType: %s", p_SPITObject.getID().data(), p_SPITObject.getName().data(), p_SPITType.getName().data());
|
||||||
|
} else if (event == SPIT_Client::ObjectEvent::Deleted) {
|
||||||
|
ESP_LOGD(TAG, "SPIT-REMOTE-Object Removed ID: %s Name: %s\n", p_SPITObject.getID().data(), p_SPITObject.getName().data());
|
||||||
|
// This is a remote SPITObject
|
||||||
|
// If you have listet this prior you should remove it from the list
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// SPITServer may use several methods for playing SPITObjects.
|
||||||
|
// e.g. liveSHOWsoftware has the timeline and jingles which plays objects, where the timeline the main player is.
|
||||||
|
// SPIT distinguishes between the different players. All eventPlay... functions contain the information which player plays the SPIT object.
|
||||||
|
void onPlay(string p_PlayerID, string p_PlayerName, char p_PlayerType, bool p_PlayerIsRunning, long long p_TimeFrames) {
|
||||||
|
ESP_LOGD(TAG, "eventPlay Player: %s Runs: %d Time: %lld", p_PlayerName.data(), p_PlayerIsRunning, p_TimeFrames);
|
||||||
|
|
||||||
|
switch (p_PlayerType) {
|
||||||
|
case SPIT_Client::PLAYERTYPE_MAIN:
|
||||||
|
// p_FrameTimes contains the position inside the server's project, we can use it like a timecode
|
||||||
|
// int intMilliseconds = (int)(((double)p_TimeFrames / (double)m_ServerFramesPerSecond) * 1000);
|
||||||
|
break;
|
||||||
|
case SPIT_Client::PLAYERTYPE_CONTINOUS:
|
||||||
|
// The olayer is playing only single Object sequences sometime during the project
|
||||||
|
break;
|
||||||
|
case SPIT_Client::PLAYERTYPE_DISCRETE:
|
||||||
|
// Only discrete values where submitted, e.g the fader position of remote faders.
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the SPITServer plays a SPITObject. For every played SPITObject one eventPlayObject is called.
|
||||||
|
* You can decide here which action should be done or not.
|
||||||
|
*/
|
||||||
|
void onPlaySpitType(string p_PlayerID, string spitTypeId, bool p_PlayerIsRunning, bool p_Started, bool p_Ended, double p_Value) {
|
||||||
|
// double doubleValue = ((double)p_PlayObject.getValue() / 1000000) * ((double)p_PlayObject.getValueFactor() / 1000000);
|
||||||
|
|
||||||
|
ESP_LOGD(TAG, "eventPlayObject Player: %s is running: %d Object Started: %d Stopped: %d", p_PlayerID.data(), p_PlayerIsRunning, p_Started, p_Ended);
|
||||||
|
// ESP_LOGD(TAG, " SPITType: %s SPITObject: %s Position: %lld Value: %f\n", spitTypeId.data(), p_SPITObject.getName().data(), p_PlayObject.getFrameInside(), doubleValue);
|
||||||
|
ESP_LOGD(TAG, " SPITType: %s Value: %f\n", spitTypeId.data(), p_Value);
|
||||||
|
|
||||||
|
if (!ProvidedSpitActions.contains(spitTypeId)) {
|
||||||
|
ESP_LOGE(TAG, "SPIT ID %s is not accepted", spitTypeId.c_str());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (p_Started == true) {
|
||||||
|
auto command = ProvidedSpitActions[spitTypeId];
|
||||||
|
ESP_LOGI(TAG, "Player: %s is running: %s Object", p_PlayerID.data(), spitTypeId.c_str());
|
||||||
|
commandQueue.enqueue(std::make_unique<MoveCommand>(command));
|
||||||
|
ESP_LOGI(TAG, "MyApp AKTION 1 started Value: %f and running: %d", p_Value, p_PlayerIsRunning);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a remote SpitObject which value function is changed by the server.
|
||||||
|
* This allows the Client to adjust its display for the remote command.
|
||||||
|
* @param p_SPITType the assigned remote SPITType of p_SPITObject
|
||||||
|
* @param p_SPITObject the remote SPITObject which is changed
|
||||||
|
* @param p_FrameInsideObject can be discarded
|
||||||
|
* @param p_Value the new value
|
||||||
|
*/
|
||||||
|
void onPlayRemoteObjectStatus(const SPITType &p_SPITType, const SPITObject &p_SPITObject, long long p_FrameInsideObject, int p_Value) {
|
||||||
|
ESP_EARLY_LOGI(TAG, "eventPlayRemoteObjectStatus RemoteSPITType: %s RemoteSPITObject: %s Position: %lld Value: %d", p_SPITType.getName().data(), p_SPITObject.getName().data(), p_FrameInsideObject, p_Value);
|
||||||
|
}
|
||||||
|
|
||||||
void SpitClientApp() {
|
void SpitClientApp() {
|
||||||
ESP_LOGI(TAG, "Starting SPIT task");
|
ESP_LOGI(TAG, "Starting SPIT task");
|
||||||
auto ptrMyApp = std::make_unique<MyApp>();
|
|
||||||
|
|
||||||
|
auto &provided = SpitTypes.Provided;
|
||||||
|
auto &expected = SpitTypes.Expected;
|
||||||
|
std::vector<LocalSpitObj> ProvidedObj;
|
||||||
|
ProvidedSpitActions[provided.startShuffle] = MoveCommand{.type = MoveType::Shuffle, .pos = 0};
|
||||||
|
ProvidedObj.push_back(LocalSpitObj{.iD = provided.startShuffle, .groupName = provided.group, .name = provided.startShuffle});
|
||||||
|
ExpectedObjects[expected.changingPos] = "";
|
||||||
|
for (size_t i = 0; i < 6; i++) {
|
||||||
|
ProvidedObj.push_back(LocalSpitObj{.iD = provided.moveToX[i], .groupName = provided.group, .name = provided.moveToX[i]});
|
||||||
|
ProvidedSpitActions[provided.moveToX[i]] = MoveCommand{.type = MoveType::StepTo, .pos = (uint8_t)(i + 1)};
|
||||||
|
ExpectedObjects[expected.inPosX[i]] = "";
|
||||||
|
}
|
||||||
|
|
||||||
// load a client project and start auto detection of SPITServers
|
SPIT_Client spitClient(ClientName, ProjectName,
|
||||||
ptrMyApp->init();
|
{
|
||||||
|
.onServerEvent = onServerEvent,
|
||||||
|
.onConnectionStatus = onConnectionStatus,
|
||||||
|
.onProjectUpdate = onProjectUpdate,
|
||||||
|
.onSpitType = onSpitType,
|
||||||
|
.onSpitTypeRemote = onSpitTypeRemote,
|
||||||
|
.onSpitObject = onSpitObject,
|
||||||
|
.onSpitObjectRemote = onSpitObjectRemote,
|
||||||
|
.onPlay = onPlay,
|
||||||
|
.onPlaySpitType = onPlaySpitType,
|
||||||
|
.onPlayRemoteObjectStatus = onPlayRemoteObjectStatus,
|
||||||
|
.onCheckSpitTypeVeto = onCheckSpitTypeVeto,
|
||||||
|
.onCheckSpitObjectVeto = onCheckSpitObjectVeto,
|
||||||
|
});
|
||||||
|
|
||||||
|
for (auto &obj : ProvidedObj) {
|
||||||
|
SPITType *ptrSPITType1Fix = spitClient.createSPITTypeFixed(obj.iD, obj.groupName, obj.name, 0, 0);
|
||||||
|
spitClient.setActionSPITType(ptrSPITType1Fix->getID(), true); // should be executed whenever a SPITObject with this SPITType is played
|
||||||
|
}
|
||||||
|
spitClient.clientProjectLoaded();
|
||||||
|
spitClient.startServerAutoDetect();
|
||||||
|
|
||||||
|
spitProjectFinish.take();
|
||||||
|
string serverProjectID = spitClient.getServerProjectID();
|
||||||
|
string serverProjectName = spitClient.getClientProjectName();
|
||||||
|
int serverFramesPerSecond = spitClient.getServerFramesPerSecond(); // set when the server reports his project, see eventProjectReport
|
||||||
|
ESP_LOGI(TAG, "eventProjectReport ID: %s Name: %s FramesPerSecond: %d", serverProjectID.data(), serverProjectName.data(), serverFramesPerSecond);
|
||||||
|
|
||||||
|
for (auto &&obj : ExpectedObjects) {
|
||||||
|
if (obj.second == "") {
|
||||||
|
ESP_LOGE(TAG, "No matching Remote ID for %s", obj.first.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
fos::Task::delayMs(10000);
|
fos::Task::delayMs(10000);
|
||||||
ESP_LOGI(TAG, "Test LiveShow");
|
ESP_LOGI(TAG, "Test LiveShow");
|
||||||
ptrMyApp->testLiveShowRemote(); //This is an excample how to remote control the liveSHOWsoftware
|
|
||||||
|
auto res = responseQueue.dequeue();
|
||||||
|
if (res->type == ResponseType::StartMoving) {
|
||||||
|
spitClient.sendRemoteObject(ExpectedObjects[expected.changingPos]);
|
||||||
|
} else if (res->type == ResponseType::StepAt) {
|
||||||
|
spitClient.sendRemoteObject(ExpectedObjects[expected.inPosX[res->pos - 1]]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+9
-1
@@ -36,7 +36,6 @@
|
|||||||
#include "Processor.hpp"
|
#include "Processor.hpp"
|
||||||
#include "nvsFunctions.hpp"
|
#include "nvsFunctions.hpp"
|
||||||
#include "mqttClient.hpp"
|
#include "mqttClient.hpp"
|
||||||
#include "MyApp.h"
|
|
||||||
|
|
||||||
// #include "esp_chip_info.h"
|
// #include "esp_chip_info.h"
|
||||||
// #include "esp_flash.h"
|
// #include "esp_flash.h"
|
||||||
@@ -52,3 +51,12 @@
|
|||||||
// #include <inttypes.h>
|
// #include <inttypes.h>
|
||||||
// #include <sys/param.h>
|
// #include <sys/param.h>
|
||||||
// #include <unistd.h>
|
// #include <unistd.h>
|
||||||
|
|
||||||
|
#include "SAD_DetectedServer.hpp"
|
||||||
|
#include "SPITObject.h"
|
||||||
|
#include "SPITPlayer.h"
|
||||||
|
#include "SPITType.h"
|
||||||
|
#include "SPIT_Client.h"
|
||||||
|
#include <chrono>
|
||||||
|
#include <string>
|
||||||
|
#include <map>
|
||||||
|
|||||||
Reference in New Issue
Block a user