refactor: moving SPIT-App parts to main app
This commit is contained in:
@@ -3,35 +3,37 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
class SAD_DetectedServer;
|
||||||
class I_SAD_Client {
|
class I_SAD_Client {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* If a new server was found by the ServerAutoDetect mechanism, this function is called.<br>
|
* If a new server was found by the ServerAutoDetect mechanism, this function is called.<br>
|
||||||
* 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>
|
||||||
* If a server can be reached via several IP addresses, the IP address is selected according to the following preference:<br>
|
* If a server can be reached via several IP addresses, the IP address is selected according to the following preference:<br>
|
||||||
* 1.) If a loopback address is available, it is used.<br>
|
* 1.) If a loopback address is available, it is used.<br>
|
||||||
* 2.) If an IP4 address is available, it is used.<br>
|
* 2.) If an IP4 address is available, it is used.<br>
|
||||||
* 3.) In the other cases the IP6 address is used.<br>
|
* 3.) In the other cases the IP6 address is used.<br>
|
||||||
* @param p_ID the id of the server (every started server should generate an id)
|
* @param p_ID the id of the server (every started server should generate an id)
|
||||||
* @param p_Name the name of the SPIT server
|
* @param p_Name the name of the SPIT server
|
||||||
* @param p_ComputerName the Hostname of the cpmputer on which the SPIT server is running
|
* @param p_ComputerName the Hostname of the cpmputer on which the SPIT server is running
|
||||||
* @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
|
* @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>
|
||||||
* @param p_ID the id of the server (every started server should generate an id)
|
* @param p_ID the id of the server (every started server should generate an id)
|
||||||
* @param p_Name the name of the SPIT server
|
* @param p_Name the name of the SPIT server
|
||||||
* @param p_ComputerName the Hostname of the cpmputer on which the SPIT server is running
|
* @param p_ComputerName the Hostname of the cpmputer on which the SPIT server is running
|
||||||
* @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
|
* @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,138 +1,119 @@
|
|||||||
#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;
|
||||||
|
|
||||||
class SAD_DetectedServer {
|
class SAD_DetectedServer {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SAD_DetectedServer();
|
SAD_DetectedServer();
|
||||||
SAD_DetectedServer(const SAD_DetectedServer& orig) {
|
SAD_DetectedServer(const SAD_DetectedServer &orig) {
|
||||||
m_ID = orig.getID();
|
m_ID = orig.getID();
|
||||||
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();
|
}
|
||||||
}
|
~SAD_DetectedServer();
|
||||||
~SAD_DetectedServer();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
string m_ID;
|
string m_ID;
|
||||||
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;
|
string m_ServerProjectName;
|
||||||
string m_ServerProjectName;
|
bool m_New;
|
||||||
bool m_New;
|
bool m_Changed;
|
||||||
bool m_Changed;
|
bool m_FoundAgain;
|
||||||
bool m_FoundAgain;
|
|
||||||
|
|
||||||
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; }
|
||||||
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:
|
|
||||||
void setID(string p_ID) { m_ID = p_ID; }
|
|
||||||
void setName(string p_Name) { m_Name = p_Name; }
|
|
||||||
void setComputerName(string p_ComputerName) { m_ComputerName = p_ComputerName; }
|
|
||||||
void setIP(string p_IP) { m_IP = p_IP; }
|
|
||||||
void setClientIP(string p_IP) { m_ClientIP = p_IP; }
|
|
||||||
void setPort(string p_Port) { m_Port = p_Port; }
|
|
||||||
void setAdditions(string p_Additions) { m_Additions = p_Additions;}
|
|
||||||
void setProjectName(string p_ServerProjectName);
|
|
||||||
|
|
||||||
void setIPIsIP4(bool p_IsIP4) { m_IPIsIP4 = p_IsIP4; }
|
private:
|
||||||
bool getNew() const { return m_New; }
|
void setID(string p_ID) { m_ID = p_ID; }
|
||||||
bool getChanged() const { return m_Changed; }
|
void setName(string p_Name) { m_Name = p_Name; }
|
||||||
bool getFoundAgain() const { return m_FoundAgain; }
|
void setComputerName(string p_ComputerName) { m_ComputerName = p_ComputerName; }
|
||||||
void setChanged() { m_Changed = true; }
|
void setIP(string p_IP) { m_IP = p_IP; }
|
||||||
void setNew(bool p_New) { m_New = p_New; }
|
void setClientIP(string p_IP) { m_ClientIP = p_IP; }
|
||||||
void setFoundAgain() { m_FoundAgain = true; }
|
void setPort(string p_Port) { m_Port = p_Port; }
|
||||||
|
void setAdditions(string p_Additions) { m_Additions = p_Additions; }
|
||||||
|
void setProjectName(string p_ServerProjectName);
|
||||||
|
|
||||||
//SAD_Client m_ThreadSend will send to Multicast addresses
|
bool getNew() const { return m_New; }
|
||||||
void startCycleSAD() {
|
bool getChanged() const { return m_Changed; }
|
||||||
m_IPIsIP4 = false;
|
bool getFoundAgain() const { return m_FoundAgain; }
|
||||||
m_Changed = false;
|
void setChanged() { m_Changed = true; }
|
||||||
m_FoundAgain = false;
|
void setNew(bool p_New) { m_New = p_New; }
|
||||||
m_New = false;
|
void setFoundAgain() { m_FoundAgain = true; }
|
||||||
}
|
|
||||||
//SAD_Client m_Thread_Send has paused in the meantime m_ThreadReceive may received messages from servers
|
|
||||||
void endCycleSAD() { }
|
|
||||||
private:
|
|
||||||
static unordered_map<string, SAD_DetectedServer*> s_DetectedServers;
|
|
||||||
public:
|
|
||||||
static const int PARAMINDEX_PRECODE = 0;
|
|
||||||
static const int PARAMINDEX_SPITTASKID = 1;
|
|
||||||
static const int PARAMINDEX_NAME = 2;
|
|
||||||
static const int PARAMINDEX_ID = 3;
|
|
||||||
static const int PARAMINDEX_COMPUTERNAME = 4;
|
|
||||||
static const int PARAMINDEX_PORT = 5;
|
|
||||||
static const int PARAMINDEX_CLIENTIP = 6;
|
|
||||||
static const int PARAMINDEX_ADDITIONS = 7;
|
|
||||||
static const int PARAMINDEX_SERVERPROJECTNAME = 8;
|
|
||||||
static const int PARAMINDEX_IP = 9;
|
|
||||||
/**
|
|
||||||
* Used by SAD_Client to add a found SPITServer - don't use this manually
|
|
||||||
* @param p_IsIP4 true = the server is reached via a IP4 address<br>false = the server is reahed via a IP6 address
|
|
||||||
* @param p_ServerID the id of the server, every instance of a SPITServer has an own id
|
|
||||||
* @param p_ServerParams the server's parameter
|
|
||||||
*/
|
|
||||||
static void addDetectedServer(bool p_IsIP4, string p_ServerID, string p_ServerParams[]);
|
|
||||||
/**
|
|
||||||
* Used by SAD_Client to remove a SPITServer - don't use this manually
|
|
||||||
* @param p_DetectedServer
|
|
||||||
*/
|
|
||||||
static void removeDetectedServer(SAD_DetectedServer* p_DetectedServer);
|
|
||||||
/**
|
|
||||||
* Used by SAD_Client to clear all found SPITServers - don't use this manually
|
|
||||||
*/
|
|
||||||
static void clearDetectedServers();
|
|
||||||
/**
|
|
||||||
* Used by SAD_Client internally - don't use this manually
|
|
||||||
*/
|
|
||||||
static void cycleStart();
|
|
||||||
/**
|
|
||||||
* Used by SAD_Client internally -don't use this manually
|
|
||||||
* @param p_SADClientInterface
|
|
||||||
*/
|
|
||||||
static void cycleEnd(I_SAD_Client& p_SADClientInterface);
|
|
||||||
|
|
||||||
/**
|
// SAD_Client m_ThreadSend will send to Multicast addresses
|
||||||
* Returns a reference of the DetectedServer with the id p_ServerID.<br>
|
void startCycleSAD() {
|
||||||
* If no DetectedServer is found an eyception is thrown.
|
m_Changed = false;
|
||||||
* @param p_ServerID the id of the SPITServer
|
m_FoundAgain = false;
|
||||||
* @return the reference of the SAD_DetectedServer instance with getID() == p_ServerID
|
m_New = false;
|
||||||
*/
|
}
|
||||||
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();
|
private:
|
||||||
}
|
static unordered_map<string, SAD_DetectedServer *> s_DetectedServers;
|
||||||
}
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
static const int PARAMINDEX_PRECODE = 0;
|
||||||
|
static const int PARAMINDEX_SPITTASKID = 1;
|
||||||
|
static const int PARAMINDEX_NAME = 2;
|
||||||
|
static const int PARAMINDEX_ID = 3;
|
||||||
|
static const int PARAMINDEX_COMPUTERNAME = 4;
|
||||||
|
static const int PARAMINDEX_PORT = 5;
|
||||||
|
static const int PARAMINDEX_CLIENTIP = 6;
|
||||||
|
static const int PARAMINDEX_ADDITIONS = 7;
|
||||||
|
static const int PARAMINDEX_SERVERPROJECTNAME = 8;
|
||||||
|
static const int PARAMINDEX_IP = 9;
|
||||||
|
/**
|
||||||
|
* Used by SAD_Client to add a found SPITServer - don't use this manually
|
||||||
|
* @param p_IsIP4 true = the server is reached via a IP4 address<br>false = the server is reahed via a IP6 address
|
||||||
|
* @param p_ServerID the id of the server, every instance of a SPITServer has an own id
|
||||||
|
* @param p_ServerParams the server's parameter
|
||||||
|
*/
|
||||||
|
static void addDetectedServer(string p_ServerID, string p_ServerParams[]);
|
||||||
|
/**
|
||||||
|
* Used by SAD_Client to remove a SPITServer - don't use this manually
|
||||||
|
* @param p_DetectedServer
|
||||||
|
*/
|
||||||
|
static void removeDetectedServer(SAD_DetectedServer &server);
|
||||||
|
/**
|
||||||
|
* Used by SAD_Client to clear all found SPITServers - don't use this manually
|
||||||
|
*/
|
||||||
|
static void clearDetectedServers();
|
||||||
|
/**
|
||||||
|
* Used by SAD_Client internally - don't use this manually
|
||||||
|
*/
|
||||||
|
static void cycleStart();
|
||||||
|
/**
|
||||||
|
* Used by SAD_Client internally -don't use this manually
|
||||||
|
* @param p_SADClientInterface
|
||||||
|
*/
|
||||||
|
static void cycleEnd(I_SAD_Client &p_SADClientInterface);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a reference of the DetectedServer with the id p_ServerID.<br>
|
||||||
|
* If no DetectedServer is found an eyception is thrown.
|
||||||
|
* @param p_ServerID the id of the SPITServer
|
||||||
|
* @return the reference of the SAD_DetectedServer instance with getID() == p_ServerID
|
||||||
|
*/
|
||||||
|
static const SAD_DetectedServer &getRefDetectedServer(string p_ServerID);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|
||||||
@@ -24,153 +24,153 @@ using namespace std;
|
|||||||
class SPITObjectListener;
|
class SPITObjectListener;
|
||||||
|
|
||||||
class SPITObject {
|
class SPITObject {
|
||||||
private:
|
private:
|
||||||
|
static unordered_map<string, SPITObject *> s_SPITObjects;
|
||||||
|
static unordered_map<string, SPITObject *> s_SPITObjectsRemote;
|
||||||
|
|
||||||
static unordered_map<string, SPITObject*> s_SPITObjects;
|
public:
|
||||||
static unordered_map<string, SPITObject*> s_SPITObjectsRemote;
|
static SPITObject *getSPITObject(string p_ID);
|
||||||
public:
|
static const SPITObject &getSPITObjectRef(string p_ID);
|
||||||
static SPITObject* getSPITObject(string p_ID);
|
static bool addSPITObject(SPITObject *p_ptrSpitObject);
|
||||||
static const SPITObject& getSPITObjectRef(string p_ID);
|
static bool removeSPITObject(SPITObject *p_ptrSpitObject);
|
||||||
static bool addSPITObject(SPITObject* p_ptrSpitObject);
|
static bool removeSPITObject(string p_SpitObjectID);
|
||||||
static bool removeSPITObject(SPITObject* p_ptrSpitObject);
|
static int getSPITObjectCount();
|
||||||
static bool removeSPITObject(string p_SpitObjectID);
|
static SPITObject *getSPITObject(int p_Index);
|
||||||
static int getSPITObjectCount();
|
static const SPITObject &getSPITObjectRef(int p_Index);
|
||||||
static SPITObject* getSPITObject(int p_Index);
|
static void clearSPITObjects();
|
||||||
static const SPITObject& getSPITObjectRef(int p_Index);
|
static void clearUnconfirmedSPITObjects();
|
||||||
static void clearSPITObjects();
|
static void setConfirmedFalse();
|
||||||
static void clearUnconfirmedSPITObjects();
|
|
||||||
static void setConfirmedFalse();
|
|
||||||
|
|
||||||
static SPITObject* getSPITObjectRemote(string p_ID);
|
static SPITObject *getSPITObjectRemote(string p_ID);
|
||||||
static const SPITObject& getSPITObjectRemoteRef(string p_ID);
|
static const SPITObject &getSPITObjectRemoteRef(string p_ID);
|
||||||
static bool addSPITObjectRemote(SPITObject* p_ptrSpitObject);
|
static bool addSPITObjectRemote(SPITObject *p_ptrSpitObject);
|
||||||
static bool removeSPITObjectRemote(SPITObject* p_ptrSpitObject);
|
static bool removeSPITObjectRemote(SPITObject *p_ptrSpitObject);
|
||||||
static bool removeSPITObjectRemote(string p_SpitObjectID);
|
static bool removeSPITObjectRemote(string p_SpitObjectID);
|
||||||
static int getSPITObjectRemoteCount();
|
static int getSPITObjectRemoteCount();
|
||||||
static SPITObject* getSPITObjectRemote(int p_Index);
|
static SPITObject *getSPITObjectRemote(int p_Index);
|
||||||
static const SPITObject& getSPITObjectRemoteRef(int p_Index);
|
static const SPITObject &getSPITObjectRemoteRef(int p_Index);
|
||||||
static void clearSPITObjectsRemote();
|
static void clearSPITObjectsRemote();
|
||||||
|
|
||||||
static void eventProjectClosed();
|
static void eventProjectClosed();
|
||||||
|
|
||||||
SPITObject();
|
SPITObject();
|
||||||
// SPITObject(const SPITObject& orig);
|
// SPITObject(const SPITObject& orig);
|
||||||
~SPITObject();
|
~SPITObject();
|
||||||
private:
|
|
||||||
string m_ID;
|
|
||||||
string m_Name;
|
|
||||||
string m_SPITTypeID;
|
|
||||||
string m_ServerParams;
|
|
||||||
string m_Remark;
|
|
||||||
bool m_Confirmed;
|
|
||||||
bool m_Fixed;
|
|
||||||
bool m_CreatedByClient;
|
|
||||||
bool m_ServerRemote;
|
|
||||||
bool m_ActionAssigned;
|
|
||||||
bool m_ActionAssignedType; //Virtual construct
|
|
||||||
long long m_FrameStart;
|
|
||||||
long long m_FrameLength;
|
|
||||||
long long m_FrameFadeInLength;
|
|
||||||
long long m_FrameFadeOutLength;
|
|
||||||
char m_ValueUse;
|
|
||||||
int m_ValueFactor;
|
|
||||||
int m_Track;
|
|
||||||
long long m_Delay;
|
|
||||||
long long m_Duration;
|
|
||||||
|
|
||||||
bool m_PlayPrePosition;
|
private:
|
||||||
long long m_PlayTimeInsideFrames;
|
string m_ID;
|
||||||
int m_PlayValue;
|
string m_Name;
|
||||||
char m_PlayValueFlag;
|
string m_SPITTypeID;
|
||||||
|
string m_ServerParams;
|
||||||
|
string m_Remark;
|
||||||
|
bool m_Confirmed;
|
||||||
|
bool m_Fixed;
|
||||||
|
bool m_CreatedByClient;
|
||||||
|
bool m_ServerRemote;
|
||||||
|
bool m_ActionAssigned;
|
||||||
|
bool m_ActionAssignedType; // Virtual construct
|
||||||
|
long long m_FrameStart;
|
||||||
|
long long m_FrameLength;
|
||||||
|
long long m_FrameFadeInLength;
|
||||||
|
long long m_FrameFadeOutLength;
|
||||||
|
char m_ValueUse;
|
||||||
|
int m_ValueFactor;
|
||||||
|
int m_Track;
|
||||||
|
long long m_Delay;
|
||||||
|
long long m_Duration;
|
||||||
|
|
||||||
|
bool m_PlayPrePosition;
|
||||||
|
long long m_PlayTimeInsideFrames;
|
||||||
|
int m_PlayValue;
|
||||||
|
char m_PlayValueFlag;
|
||||||
|
|
||||||
void initMembers();
|
void initMembers();
|
||||||
public:
|
|
||||||
string getID() const { return m_ID; }
|
|
||||||
string getName() const { return m_Name; }
|
|
||||||
string getRemark() const { return m_Remark; }
|
|
||||||
string getSPITTypeID() const { return m_SPITTypeID; }
|
|
||||||
string getServerParams() const { return m_ServerParams; }
|
|
||||||
|
|
||||||
/**
|
public:
|
||||||
* Returns if the SPITType triggers an action on the Server or on the client.
|
string getID() const { return m_ID; }
|
||||||
* @return false = the action is triggered on the client The client waits for the server to play objects of this SPITType<br>
|
string getName() const { return m_Name; }
|
||||||
* true = the action is triggered on the server. The server waits for the client to play objects of this SPITType.
|
string getRemark() const { return m_Remark; }
|
||||||
*/
|
string getSPITTypeID() const { return m_SPITTypeID; }
|
||||||
bool getServerRemote() const { return m_ServerRemote; }
|
string getServerParams() const { return m_ServerParams; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is used by the server and client to tell if the other side has registered the changes.
|
* Returns if the SPITType triggers an action on the Server or on the client.
|
||||||
* @return true = other side has registered the changes.
|
* @return false = the action is triggered on the client The client waits for the server to play objects of this SPITType<br>
|
||||||
*/
|
* true = the action is triggered on the server. The server waits for the client to play objects of this SPITType.
|
||||||
bool getConfirmed() const { return m_Confirmed; }
|
*/
|
||||||
bool getFixed() const { return m_Fixed; }
|
bool getServerRemote() const { return m_ServerRemote; }
|
||||||
bool getCreatedByClient() { return m_CreatedByClient; }
|
|
||||||
/**
|
|
||||||
* This is a virtual construct - ActionAssignedType is not implemented in the SPITProtocol.<br>
|
|
||||||
* This is used when an action is associated with a SPITType. <br>
|
|
||||||
* Then this action is done for every SPITObject with the SPITType.
|
|
||||||
* @return true = an action is assigned for the SPITType.
|
|
||||||
*/
|
|
||||||
bool getActionAssignedType() const { return m_ActionAssignedType; }
|
|
||||||
/** Returns if this SPITObject has an associated action or not.<br>
|
|
||||||
* @return true = the user has asscociated an action with this SPITObject or <br>
|
|
||||||
* the user has asscociated an action with the SPITType of this SPITObject
|
|
||||||
*/
|
|
||||||
bool getActionAssigned() const { return m_ActionAssigned || m_ActionAssignedType; }
|
|
||||||
|
|
||||||
long long getFrameStart() const { return m_FrameStart; }
|
/**
|
||||||
// contains the length of the SPITObject
|
* This is used by the server and client to tell if the other side has registered the changes.
|
||||||
long long getFrameLength() const { return m_FrameLength; }
|
* @return true = other side has registered the changes.
|
||||||
long long getFrameFadeInLength() const { return m_FrameFadeInLength; }
|
*/
|
||||||
long long getFrameFadeOutLength() const { return m_FrameFadeOutLength; }
|
bool getConfirmed() const { return m_Confirmed; }
|
||||||
char getValueUse() const { return m_ValueUse; }
|
bool getFixed() const { return m_Fixed; }
|
||||||
int getValueFactor() const { return m_ValueFactor; }
|
bool getCreatedByClient() { return m_CreatedByClient; }
|
||||||
int getTrack() const { return m_Track; }
|
/**
|
||||||
|
* This is a virtual construct - ActionAssignedType is not implemented in the SPITProtocol.<br>
|
||||||
|
* This is used when an action is associated with a SPITType. <br>
|
||||||
|
* Then this action is done for every SPITObject with the SPITType.
|
||||||
|
* @return true = an action is assigned for the SPITType.
|
||||||
|
*/
|
||||||
|
bool getActionAssignedType() const { return m_ActionAssignedType; }
|
||||||
|
/** Returns if this SPITObject has an associated action or not.<br>
|
||||||
|
* @return true = the user has asscociated an action with this SPITObject or <br>
|
||||||
|
* the user has asscociated an action with the SPITType of this SPITObject
|
||||||
|
*/
|
||||||
|
bool getActionAssigned() const { return m_ActionAssigned || m_ActionAssignedType; }
|
||||||
|
|
||||||
long long getDelay() const { return m_Delay; }
|
long long getFrameStart() const { return m_FrameStart; }
|
||||||
long long getDuration() const { return m_Duration; }
|
// contains the length of the SPITObject
|
||||||
|
long long getFrameLength() const { return m_FrameLength; }
|
||||||
|
long long getFrameFadeInLength() const { return m_FrameFadeInLength; }
|
||||||
|
long long getFrameFadeOutLength() const { return m_FrameFadeOutLength; }
|
||||||
|
char getValueUse() const { return m_ValueUse; }
|
||||||
|
int getValueFactor() const { return m_ValueFactor; }
|
||||||
|
int getTrack() const { return m_Track; }
|
||||||
|
|
||||||
bool getProjectIndepended() const {
|
long long getDelay() const { return m_Delay; }
|
||||||
SPITType* ptrSPITType;
|
long long getDuration() const { return m_Duration; }
|
||||||
if (m_ServerRemote == false) {
|
|
||||||
ptrSPITType = SPITType::getSPITType(m_SPITTypeID);
|
|
||||||
if (ptrSPITType == NULL) return true;
|
|
||||||
return ptrSPITType->getProjectIndepended();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ptrSPITType = SPITType::getSPITTypeRemote(m_SPITTypeID);
|
|
||||||
if (ptrSPITType == NULL) return true;
|
|
||||||
return ptrSPITType->getProjectIndepended();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
void setID(string p_ID);
|
bool getProjectIndepended() const {
|
||||||
bool setConfirmed(bool p_Confirmed);
|
SPITType *ptrSPITType;
|
||||||
void setCreatedByClient(bool p_CreatedByClient);
|
if (m_ServerRemote == false) {
|
||||||
bool setName(string p_Name);
|
ptrSPITType = SPITType::getSPITType(m_SPITTypeID);
|
||||||
bool setRemark(string p_Remark);
|
if (ptrSPITType == NULL)
|
||||||
bool setServerParams(string p_ServerParams);
|
return true;
|
||||||
bool setSPITTypeID(string p_GroupName);
|
return ptrSPITType->getProjectIndepended();
|
||||||
bool setServerRemote(bool p_BelongstoServer);
|
} else {
|
||||||
bool setActionAssignedType(bool p_ActionAssigned);
|
ptrSPITType = SPITType::getSPITTypeRemote(m_SPITTypeID);
|
||||||
bool setActionAssigned(bool p_ActionAssigned);
|
if (ptrSPITType == NULL)
|
||||||
bool setFixed(bool p_Fixed);
|
return true;
|
||||||
bool setFrameStart(long long p_FrameStart);
|
return ptrSPITType->getProjectIndepended();
|
||||||
bool setFrameLength(long long p_FrameLength);
|
}
|
||||||
bool setFrameFadeInLength(long long p_FrameFadeInLength);
|
};
|
||||||
bool setFrameFadeOutLength(long long p_FrameFadeOutLength);
|
|
||||||
bool setValueUse(char p_ValueUse);
|
|
||||||
bool setValueFactor(int p_ValueFactor);
|
|
||||||
bool setTrack(int p_Track);
|
|
||||||
bool setDelay(long long p_Delay);
|
|
||||||
bool setDuration(long long p_Duration);
|
|
||||||
|
|
||||||
bool setMessageOP(SPIT_Message::ReportSPITObject* p_ReportSPITObject);
|
void setID(string p_ID);
|
||||||
void fillMessageOP(SPIT_Message::ReportSPITObject* p_ReportSPITObject);
|
bool setConfirmed(bool p_Confirmed);
|
||||||
void fillMessageOP(SPIT_Message::RemoveSPITObject* p_RemoveSPITObject);
|
void setCreatedByClient(bool p_CreatedByClient);
|
||||||
|
bool setName(string p_Name);
|
||||||
|
bool setRemark(string p_Remark);
|
||||||
|
bool setServerParams(string p_ServerParams);
|
||||||
|
bool setSPITTypeID(string p_GroupName);
|
||||||
|
bool setServerRemote(bool p_BelongstoServer);
|
||||||
|
bool setActionAssignedType(bool p_ActionAssigned);
|
||||||
|
bool setActionAssigned(bool p_ActionAssigned);
|
||||||
|
bool setFixed(bool p_Fixed);
|
||||||
|
bool setFrameStart(long long p_FrameStart);
|
||||||
|
bool setFrameLength(long long p_FrameLength);
|
||||||
|
bool setFrameFadeInLength(long long p_FrameFadeInLength);
|
||||||
|
bool setFrameFadeOutLength(long long p_FrameFadeOutLength);
|
||||||
|
bool setValueUse(char p_ValueUse);
|
||||||
|
bool setValueFactor(int p_ValueFactor);
|
||||||
|
bool setTrack(int p_Track);
|
||||||
|
bool setDelay(long long p_Delay);
|
||||||
|
bool setDuration(long long p_Duration);
|
||||||
|
|
||||||
|
bool setMessageOP(SPIT_Message::ReportSPITObject *p_ReportSPITObject);
|
||||||
|
void fillMessageOP(SPIT_Message::ReportSPITObject *p_ReportSPITObject);
|
||||||
|
void fillMessageOP(SPIT_Message::RemoveSPITObject *p_RemoveSPITObject);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif /* SPITOBJECT_H */
|
#endif /* SPITOBJECT_H */
|
||||||
|
|
||||||
|
|||||||
@@ -19,78 +19,76 @@
|
|||||||
|
|
||||||
class SPITPlayer {
|
class SPITPlayer {
|
||||||
|
|
||||||
//----- PlayObject used in PlaySequences: PlaySPITStart, PlaySPITObject,..., PlaySPITEnd ------
|
//----- PlayObject used in PlaySequences: PlaySPITStart, PlaySPITObject,..., PlaySPITEnd ------
|
||||||
public:
|
public:
|
||||||
class PlaySPITType {
|
class PlaySPITType {
|
||||||
public:
|
public:
|
||||||
PlaySPITType();
|
PlaySPITType();
|
||||||
PlaySPITType(SPITPlayer* p_SPITPlayer, string p_SPITObjectID);
|
PlaySPITType(SPITPlayer *p_SPITPlayer, string p_SPITObjectID);
|
||||||
PlaySPITType(const PlaySPITType& orig);
|
PlaySPITType(const PlaySPITType &orig);
|
||||||
|
|
||||||
string getSPITTypeID() const {
|
string getSPITTypeID() const {
|
||||||
return m_SPITTypeID;
|
return m_SPITTypeID;
|
||||||
}
|
}
|
||||||
|
|
||||||
void startPlaySequence();
|
void startPlaySequence();
|
||||||
bool getIsNew() const { return m_IsNew; }
|
bool getIsNew() const { return m_IsNew; }
|
||||||
void setIsNew(bool p_IsNew) { m_IsNew = p_IsNew; }
|
void setIsNew(bool p_IsNew) { m_IsNew = p_IsNew; }
|
||||||
bool getIsPlayed() const { return m_IsPlayed; }
|
bool getIsPlayed() const { return m_IsPlayed; }
|
||||||
void setIsPlayed(bool p_IsFound) { m_IsPlayed = p_IsFound; }
|
void setIsPlayed(bool p_IsFound) { m_IsPlayed = p_IsFound; }
|
||||||
string getPlayerID() const { return m_PlayerID; }
|
string getPlayerID() const { return m_PlayerID; }
|
||||||
string getPlayerName() const { return m_PlayerName; }
|
string getPlayerName() const { return m_PlayerName; }
|
||||||
bool getPlayerIsRunning() const { return m_PlayerRuns; }
|
bool getPlayerIsRunning() const { return m_PlayerRuns; }
|
||||||
void setPlayerIsRunning(bool p_PlayerRuns) { m_PlayerRuns = p_PlayerRuns; }
|
void setPlayerIsRunning(bool p_PlayerRuns) { m_PlayerRuns = p_PlayerRuns; }
|
||||||
void setValue(double p_Value) { m_Value = p_Value; }
|
void setValue(double p_Value) { m_Value = p_Value; }
|
||||||
void addValue(double p_Value, double p_ValueFactor) { m_Value += (p_Value * p_ValueFactor); }
|
void addValue(double p_Value, double p_ValueFactor) { m_Value += (p_Value * p_ValueFactor); }
|
||||||
double getValue() const { return m_Value; }
|
double getValue() const { return m_Value; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
string m_PlayerID;
|
string m_PlayerID;
|
||||||
string m_PlayerName;
|
string m_PlayerName;
|
||||||
bool m_PlayerRuns;
|
bool m_PlayerRuns;
|
||||||
string m_SPITTypeID;
|
string m_SPITTypeID;
|
||||||
bool m_IsPlayed;
|
bool m_IsPlayed;
|
||||||
bool m_IsNew;
|
bool m_IsNew;
|
||||||
double m_Value;
|
double m_Value;
|
||||||
};
|
};
|
||||||
|
|
||||||
//----- SPITPlayer ------
|
//----- SPITPlayer ------
|
||||||
public:
|
public:
|
||||||
//list the SPITPlayers
|
// list the SPITPlayers
|
||||||
static unordered_map<string, SPITPlayer*> s_SPITPlayers; //all actual played objects
|
static unordered_map<string, SPITPlayer *> s_SPITPlayers; // all actual played objects
|
||||||
static SPITPlayer* getSPITPlayer(string p_PlayerID); //if a player does not exist creates a new one
|
static SPITPlayer *getSPITPlayer(string p_PlayerID); // if a player does not exist creates a new one
|
||||||
static void clearPlayers();
|
static void clearPlayers();
|
||||||
|
|
||||||
SPITPlayer(string p_PlayerID);
|
SPITPlayer(string p_PlayerID);
|
||||||
virtual ~SPITPlayer();
|
virtual ~SPITPlayer();
|
||||||
|
|
||||||
|
void startPlaySequence(); // called by SPIT_Client::parsePlaySPITStart
|
||||||
|
PlaySPITType *addSPITType_Playing(string p_SPITTypeID); // called by SPIT_Client::parsePlaySPITStart
|
||||||
|
void endPlaySequence(); // called by SPIT_Client::parsePlaySPITEnd
|
||||||
|
|
||||||
void startPlaySequence(); //called by SPIT_Client::parsePlaySPITStart
|
string getID() {
|
||||||
PlaySPITType* addSPITType_Playing (string p_SPITTypeID); //called by SPIT_Client::parsePlaySPITStart
|
return m_ID;
|
||||||
void endPlaySequence(); //called by SPIT_Client::parsePlaySPITEnd
|
}
|
||||||
|
|
||||||
string getID() {
|
unordered_map<string, PlaySPITType *> *getPlaySPITTypes();
|
||||||
return m_ID;
|
void setIsRunning(bool p_IsRunning);
|
||||||
}
|
bool getIsRunning() { return m_IsRunning; }
|
||||||
|
void setName(string p_Name);
|
||||||
|
string getName() { return m_Name; }
|
||||||
|
void setType(char p_Type);
|
||||||
|
char getType() { return m_Type; }
|
||||||
|
void setTime(long long p_Frames);
|
||||||
|
long long getTime() { return m_TimeFrames; }
|
||||||
|
|
||||||
unordered_map<string, PlaySPITType*>* getPlaySPITTypes();
|
private:
|
||||||
void setIsRunning(bool p_IsRunning);
|
string m_ID;
|
||||||
bool getIsRunning() { return m_IsRunning; }
|
string m_Name;
|
||||||
void setName(string p_Name);
|
char m_Type;
|
||||||
string getName() { return m_Name; }
|
unordered_map<string, PlaySPITType *> m_PlaySPITTypes;
|
||||||
void setType(char p_Type);
|
bool m_IsRunning;
|
||||||
char getType() { return m_Type; }
|
long long m_TimeFrames;
|
||||||
void setTime(long long p_Frames);
|
|
||||||
long long getTime() { return m_TimeFrames; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
string m_ID;
|
|
||||||
string m_Name;
|
|
||||||
char m_Type;
|
|
||||||
unordered_map<string, PlaySPITType*> m_PlaySPITTypes;
|
|
||||||
bool m_IsRunning;
|
|
||||||
long long m_TimeFrames;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#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;
|
||||||
|
|
||||||
@@ -35,133 +35,132 @@ string createGUID();
|
|||||||
/** Returns the name of the client's host computer*/
|
/** Returns the name of the client's host computer*/
|
||||||
string getClientHostName();
|
string getClientHostName();
|
||||||
|
|
||||||
class SPITSocket{
|
class SPITSocket {
|
||||||
public:
|
public:
|
||||||
static const int FAMILY_IP4 = AF_INET;
|
static const int FAMILY_IP4 = AF_INET;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IPAddress class is used to fetch all available IP addresses of the computer
|
* IPAddress class is used to fetch all available IP addresses of the computer
|
||||||
* This is for internal usage
|
* This is for internal usage
|
||||||
*/
|
*/
|
||||||
struct IPAddress {
|
struct IPAddress {
|
||||||
public:
|
public:
|
||||||
IPAddress(const string& p_IPAddress, const string& p_SubnetMask)
|
IPAddress(const string &p_IPAddress, const string &p_SubnetMask)
|
||||||
: m_IPAddress(p_IPAddress), m_SubnetMask(p_SubnetMask) { }
|
: m_IPAddress(p_IPAddress), m_SubnetMask(p_SubnetMask) {}
|
||||||
const string m_IPAddress;
|
const string m_IPAddress;
|
||||||
const string m_SubnetMask;
|
const string m_SubnetMask;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculates the broadcast address from a ip4 address
|
* Calculates the broadcast address from a ip4 address
|
||||||
* @param p_IPAddress the ip4 address
|
* @param p_IPAddress the ip4 address
|
||||||
* @return returns the broadcast address
|
* @return returns the broadcast address
|
||||||
*/
|
*/
|
||||||
string getBroadcastIP4() const {
|
string getBroadcastIP4() const {
|
||||||
struct in_addr broadcast;
|
struct in_addr broadcast;
|
||||||
unsigned long ulIPAddress;
|
unsigned long ulIPAddress;
|
||||||
unsigned long ulSubnetMask;
|
unsigned long ulSubnetMask;
|
||||||
|
|
||||||
ulIPAddress = inet_addr(m_IPAddress.data());
|
ulIPAddress = inet_addr(m_IPAddress.data());
|
||||||
ulSubnetMask = inet_addr(m_SubnetMask.data());
|
ulSubnetMask = inet_addr(m_SubnetMask.data());
|
||||||
broadcast.s_addr = ulIPAddress | ~ulSubnetMask;
|
broadcast.s_addr = ulIPAddress | ~ulSubnetMask;
|
||||||
|
|
||||||
return inet_ntoa(broadcast);
|
return inet_ntoa(broadcast);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const IPAddress mOwnIp;
|
const IPAddress mOwnIp;
|
||||||
static IPAddress getAdaptersInfo();
|
static IPAddress getAdaptersInfo();
|
||||||
bool createSocket_UDP();
|
bool createSocket_UDP();
|
||||||
static const int INVALID_SOCKET = -1;
|
static const int INVALID_SOCKET = -1;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_UDPSocketIP4;
|
int m_UDPSocketIP4;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//-------- class --------------
|
//-------- class --------------
|
||||||
SPITSocket(IPAddress ip) : mOwnIp(ip) {
|
SPITSocket(IPAddress ip) : mOwnIp(ip) {
|
||||||
m_UDPSocketIP4 = INVALID_SOCKET;
|
m_UDPSocketIP4 = INVALID_SOCKET;
|
||||||
|
|
||||||
m_ServerIP = "";
|
m_ServerIP = "";
|
||||||
m_ServerPort = "";
|
m_ServerPort = "";
|
||||||
m_ClientIP = "";
|
m_ClientIP = "";
|
||||||
m_ClientPort = "";
|
m_ClientPort = "";
|
||||||
m_BoundClientPort = "";
|
m_BoundClientPort = "";
|
||||||
m_BoundClientFamily = 0;
|
m_BoundClientFamily = 0;
|
||||||
m_IsBound = false;
|
|
||||||
createSocket_UDP();
|
|
||||||
|
|
||||||
}
|
|
||||||
virtual ~SPITSocket() {
|
|
||||||
ESP_LOGD("UDP", "Shutting down ...");
|
|
||||||
|
|
||||||
if (m_UDPSocketIP4 != INVALID_SOCKET) {
|
|
||||||
shutdown(m_UDPSocketIP4, 2);
|
|
||||||
close(m_UDPSocketIP4);
|
|
||||||
m_UDPSocketIP4 = INVALID_SOCKET;
|
|
||||||
}
|
|
||||||
fos::Task::delayMs(100);
|
|
||||||
m_IsBound = false;
|
m_IsBound = false;
|
||||||
}
|
createSocket_UDP();
|
||||||
private:
|
}
|
||||||
string m_ServerIP;
|
virtual ~SPITSocket() {
|
||||||
string m_ServerPort;
|
ESP_LOGD("UDP", "Shutting down ...");
|
||||||
string m_ClientIP;
|
|
||||||
string m_ClientPort; //port given by the user maybe "0"
|
|
||||||
string m_BoundClientPort; //port set after bind
|
|
||||||
int m_BoundClientFamily;
|
|
||||||
bool m_IsBound;
|
|
||||||
|
|
||||||
public:
|
if (m_UDPSocketIP4 != INVALID_SOCKET) {
|
||||||
/**
|
shutdown(m_UDPSocketIP4, 2);
|
||||||
* Sets the ip address and port for server and client.
|
close(m_UDPSocketIP4);
|
||||||
* @param p_ServerIP
|
m_UDPSocketIP4 = INVALID_SOCKET;
|
||||||
* @param p_ServerPort
|
}
|
||||||
* @param p_ClientIP
|
fos::Task::delayMs(100);
|
||||||
* @param p_ClientPort
|
m_IsBound = false;
|
||||||
*/
|
}
|
||||||
void setConnectionParams(string p_ServerIP, string p_ServerPort, string p_ClientIP, string p_ClientPort) {
|
|
||||||
m_ServerIP = p_ServerIP;
|
|
||||||
m_ServerPort = p_ServerPort;
|
|
||||||
m_ClientIP = p_ClientIP;
|
|
||||||
m_ClientPort = p_ClientPort;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
private:
|
||||||
* Send a message to the server as set by setConnectionParams
|
string m_ServerIP;
|
||||||
* @param p_MessageBytes byte buffer containing the message
|
string m_ServerPort;
|
||||||
* @param p_MessageLength length of the messaeg
|
string m_ClientIP;
|
||||||
* @return
|
string m_ClientPort; // port given by the user maybe "0"
|
||||||
*/
|
string m_BoundClientPort; // port set after bind
|
||||||
int sendMessage(const char* p_MessageBytes, int p_MessageLength) {
|
int m_BoundClientFamily;
|
||||||
if (m_ServerPort.length() <= 0)
|
bool m_IsBound;
|
||||||
return -1;
|
|
||||||
int intResult;
|
|
||||||
{
|
|
||||||
if (m_IsBound == false)
|
|
||||||
return -1;
|
|
||||||
intResult = sendMessageTo(m_BoundClientFamily, m_ServerIP, m_ServerPort, p_MessageBytes, p_MessageLength);
|
|
||||||
}
|
|
||||||
return intResult;
|
|
||||||
}
|
|
||||||
|
|
||||||
int receiveMessage(int p_InetFamily, char* p_Buffer, int p_BufferLength, string* p_ServerIP);
|
public:
|
||||||
int setBroadcast(bool p_Broadcast);
|
/**
|
||||||
int bindSocket(string p_ServerIP, string p_ClientIP, string p_ClientPort);
|
* Sets the ip address and port for server and client.
|
||||||
|
* @param p_ServerIP
|
||||||
|
* @param p_ServerPort
|
||||||
|
* @param p_ClientIP
|
||||||
|
* @param p_ClientPort
|
||||||
|
*/
|
||||||
|
void setConnectionParams(string p_ServerIP, string p_ServerPort, string p_ClientIP, string p_ClientPort) {
|
||||||
|
m_ServerIP = p_ServerIP;
|
||||||
|
m_ServerPort = p_ServerPort;
|
||||||
|
m_ClientIP = p_ClientIP;
|
||||||
|
m_ClientPort = p_ClientPort;
|
||||||
|
}
|
||||||
|
|
||||||
// * Internal usage - don't use this manually
|
/**
|
||||||
// * Use sendMessage instead
|
* Send a message to the server as set by setConnectionParams
|
||||||
int sendMessageTo(int p_InetFamily, string p_ServerIP, string p_Port, const char* p_MessageBytes, int p_MessageLength);
|
* @param p_MessageBytes byte buffer containing the message
|
||||||
|
* @param p_MessageLength length of the messaeg
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int sendMessage(const char *p_MessageBytes, int p_MessageLength) {
|
||||||
|
if (m_ServerPort.length() <= 0)
|
||||||
|
return -1;
|
||||||
|
int intResult;
|
||||||
|
{
|
||||||
|
if (m_IsBound == false)
|
||||||
|
return -1;
|
||||||
|
intResult = sendMessageTo(m_BoundClientFamily, m_ServerIP, m_ServerPort, p_MessageBytes, p_MessageLength);
|
||||||
|
}
|
||||||
|
return intResult;
|
||||||
|
}
|
||||||
|
|
||||||
string getServerIP() { return m_ServerIP; }
|
int receiveMessage(int p_InetFamily, char *p_Buffer, int p_BufferLength, string *p_ServerIP);
|
||||||
string getServerPort(){ return m_ServerPort; }
|
int setBroadcast(bool p_Broadcast);
|
||||||
string getClientIP() { return m_ClientIP; }
|
int bindSocket(string p_ServerIP, string p_ClientIP, string p_ClientPort);
|
||||||
string getClientPort() { return m_ClientPort; }
|
|
||||||
string getBoundClientPort() { return m_BoundClientPort; }
|
// * Internal usage - don't use this manually
|
||||||
void setBoundClientPort(string p_Port) { m_BoundClientPort = p_Port; }
|
// * Use sendMessage instead
|
||||||
void setBoundClientFamily(int p_Family) { m_BoundClientFamily = p_Family; }
|
int sendMessageTo(int p_InetFamily, string p_ServerIP, string p_Port, const char *p_MessageBytes, int p_MessageLength);
|
||||||
int getBoundClientFamily() { return m_BoundClientFamily; }
|
|
||||||
void setIsBound(bool p_IsBound) { m_IsBound = p_IsBound; }
|
string getServerIP() { return m_ServerIP; }
|
||||||
bool getIsBound() { return m_IsBound; }
|
string getServerPort() { return m_ServerPort; }
|
||||||
|
string getClientIP() { return m_ClientIP; }
|
||||||
|
string getClientPort() { return m_ClientPort; }
|
||||||
|
string getBoundClientPort() { return m_BoundClientPort; }
|
||||||
|
void setBoundClientPort(string p_Port) { m_BoundClientPort = p_Port; }
|
||||||
|
void setBoundClientFamily(int p_Family) { m_BoundClientFamily = p_Family; }
|
||||||
|
int getBoundClientFamily() { return m_BoundClientFamily; }
|
||||||
|
void setIsBound(bool p_IsBound) { m_IsBound = p_IsBound; }
|
||||||
|
bool getIsBound() { return m_IsBound; }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* SPITSOCKET_H */
|
#endif /* SPITSOCKET_H */
|
||||||
|
|
||||||
|
|||||||
@@ -24,119 +24,117 @@ using namespace std;
|
|||||||
class SPITTypeListener;
|
class SPITTypeListener;
|
||||||
|
|
||||||
class SPITType {
|
class SPITType {
|
||||||
private:
|
private:
|
||||||
static unordered_map<string, SPITType*> s_SPITTypes;
|
static unordered_map<string, SPITType *> s_SPITTypes;
|
||||||
static unordered_map<string, SPITType*> s_SPITTypesRemote;
|
static unordered_map<string, SPITType *> s_SPITTypesRemote;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static SPITType* getSPITType(string p_ID);
|
static SPITType *getSPITType(string p_ID);
|
||||||
static const SPITType& getSPITTypeRef(string p_ID);
|
static const SPITType &getSPITTypeRef(string p_ID);
|
||||||
static bool addSPITType(SPITType* p_ptrSpitType);
|
static bool addSPITType(SPITType *p_ptrSpitType);
|
||||||
static bool removeSPITType(SPITType* p_ptrSpitType);
|
static bool removeSPITType(SPITType *p_ptrSpitType);
|
||||||
static int getSPITTypeCount();
|
static int getSPITTypeCount();
|
||||||
static SPITType* getSPITType(int p_Index);
|
static SPITType *getSPITType(int p_Index);
|
||||||
static const SPITType& getSPITTypeRef(int p_Index);
|
static const SPITType &getSPITTypeRef(int p_Index);
|
||||||
static void clearSPITTypes();
|
static void clearSPITTypes();
|
||||||
static void setConfirmedFalse();
|
static void setConfirmedFalse();
|
||||||
|
|
||||||
static SPITType* getSPITTypeRemote(string p_ID);
|
static SPITType *getSPITTypeRemote(string p_ID);
|
||||||
static const SPITType& getSPITTypeRemoteRef(string p_ID);
|
static const SPITType &getSPITTypeRemoteRef(string p_ID);
|
||||||
static bool addSPITTypeRemote(SPITType* p_ptrSpitType);
|
static bool addSPITTypeRemote(SPITType *p_ptrSpitType);
|
||||||
static bool removeSPITTypeRemote(SPITType* p_ptrSpitType);
|
static bool removeSPITTypeRemote(SPITType *p_ptrSpitType);
|
||||||
static int getSPITTypeRemoteCount();
|
static int getSPITTypeRemoteCount();
|
||||||
static SPITType* getSPITTypeRemote(int p_Index);
|
static SPITType *getSPITTypeRemote(int p_Index);
|
||||||
static const SPITType& getSPITTypeRemoteRef(int p_Index);
|
static const SPITType &getSPITTypeRemoteRef(int p_Index);
|
||||||
static void clearSPITTypesRemote();
|
static void clearSPITTypesRemote();
|
||||||
|
|
||||||
static void eventProjectClosed();
|
static void eventProjectClosed();
|
||||||
|
|
||||||
SPITType();
|
SPITType();
|
||||||
SPITType(string p_ID, string p_GroupName, string p_Name, bool p_Fixed, bool p_ProjectIndepended,long long p_DefaultDelay, long long p_DefaultDuration);
|
SPITType(string p_ID, string p_GroupName, string p_Name, bool p_Fixed, bool p_ProjectIndepended, long long p_DefaultDelay, long long p_DefaultDuration);
|
||||||
// SPITType(const SPITType& orig);
|
// SPITType(const SPITType& orig);
|
||||||
~SPITType();
|
~SPITType();
|
||||||
private:
|
|
||||||
|
|
||||||
bool m_Confirmed;
|
private:
|
||||||
string m_ID;
|
bool m_Confirmed;
|
||||||
bool m_Fixed;
|
string m_ID;
|
||||||
bool m_ServerRemote;
|
bool m_Fixed;
|
||||||
bool m_ServerProjectIndepended;
|
bool m_ServerRemote;
|
||||||
string m_GroupName;
|
bool m_ServerProjectIndepended;
|
||||||
string m_Name;
|
string m_GroupName;
|
||||||
long long m_DefaultDelay;
|
string m_Name;
|
||||||
long long m_DefaultDuration;
|
long long m_DefaultDelay;
|
||||||
|
long long m_DefaultDuration;
|
||||||
|
|
||||||
bool m_CreatedByClient; //flag true = the SPITTyype is created by the client
|
bool m_CreatedByClient; // flag true = the SPITTyype is created by the client
|
||||||
//false = the SPITType is received from the server
|
// false = the SPITType is received from the server
|
||||||
|
|
||||||
bool m_ActionAssigned; //This is a virtual flag if user associates an action with a SPITType.
|
bool m_ActionAssigned; // This is a virtual flag if user associates an action with a SPITType.
|
||||||
//Can be used to setActionAssigned for all SPITObjects with this SPITType
|
// Can be used to setActionAssigned for all SPITObjects with this SPITType
|
||||||
|
|
||||||
void initMembers();
|
void initMembers();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
string getID() const{ return m_ID; }
|
string getID() const { return m_ID; }
|
||||||
string getGroupName() const { return m_GroupName; }
|
string getGroupName() const { return m_GroupName; }
|
||||||
string getName() const { return m_Name; }
|
string getName() const { return m_Name; }
|
||||||
/**
|
/**
|
||||||
* Returns if the SPITType triggers an action on the Server or on the client.
|
* Returns if the SPITType triggers an action on the Server or on the client.
|
||||||
* @return false = the action is triggered on the client The client waits for the server to play objects of this SPITType<br>
|
* @return false = the action is triggered on the client The client waits for the server to play objects of this SPITType<br>
|
||||||
* true = the action is triggered on the server. The server waits for the client to play objects of this SPITType.
|
* true = the action is triggered on the server. The server waits for the client to play objects of this SPITType.
|
||||||
*/
|
*/
|
||||||
bool getServerRemote() const {
|
bool getServerRemote() const {
|
||||||
return m_ServerRemote;
|
return m_ServerRemote;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool getProjectIndepended() const {
|
bool getProjectIndepended() const {
|
||||||
return m_ServerProjectIndepended;
|
return m_ServerProjectIndepended;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* This is used by the server and client to tell if the other side has registered the changes.
|
* This is used by the server and client to tell if the other side has registered the changes.
|
||||||
* @return true = other side has registered the changes.
|
* @return true = other side has registered the changes.
|
||||||
*/
|
*/
|
||||||
bool getConfirmed() const { return m_Confirmed; }
|
bool getConfirmed() const { return m_Confirmed; }
|
||||||
bool getFixed() const { return m_Fixed; }
|
bool getFixed() const { return m_Fixed; }
|
||||||
long long getDefaultDelay() const { return m_DefaultDelay; }
|
long long getDefaultDelay() const { return m_DefaultDelay; }
|
||||||
long long getDefaultDuration() const { return m_DefaultDuration; }
|
long long getDefaultDuration() const { return m_DefaultDuration; }
|
||||||
bool getCreatedByClient() const { return m_CreatedByClient; }
|
bool getCreatedByClient() const { return m_CreatedByClient; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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>
|
||||||
* This may be used in the case when the same action should be done for every SPITObject with this SPITType associated.<br>
|
* This may be used in the case when the same action should be done for every SPITObject with this SPITType associated.<br>
|
||||||
* @return true = the user has associated an action with this SPITType.
|
* @return true = the user has associated an action with this SPITType.
|
||||||
*/
|
*/
|
||||||
bool getActionAssigned() const {
|
bool getActionAssigned() const {
|
||||||
return m_ActionAssigned;
|
return m_ActionAssigned;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
void setID(string p_ID);
|
||||||
|
bool setGroupName(string p_GroupName);
|
||||||
|
bool setName(string p_Name);
|
||||||
|
bool setServerRemote(bool p_BelongstoServer);
|
||||||
|
bool setProjectIndepended(bool p_ProjectIndepeneded);
|
||||||
|
bool setConfirmed(bool p_Confirmed);
|
||||||
|
bool setFixed(bool p_Fixed);
|
||||||
|
bool setDefaultDelay(long long p_Delay);
|
||||||
|
bool setDefaultDuration(long long p_Duration);
|
||||||
|
|
||||||
public:
|
void setCreatedByClient(bool p_CreatedByClient);
|
||||||
void setID(string p_ID);
|
|
||||||
bool setGroupName(string p_GroupName);
|
|
||||||
bool setName(string p_Name);
|
|
||||||
bool setServerRemote(bool p_BelongstoServer);
|
|
||||||
bool setProjectIndepended(bool p_ProjectIndepeneded);
|
|
||||||
bool setConfirmed(bool p_Confirmed);
|
|
||||||
bool setFixed(bool p_Fixed);
|
|
||||||
bool setDefaultDelay(long long p_Delay);
|
|
||||||
bool setDefaultDuration(long long p_Duration);
|
|
||||||
|
|
||||||
void setCreatedByClient(bool p_CreatedByClient);
|
/**
|
||||||
|
* Virtual construct - means ActionAssigned for SPITTypes is is not implemented in SPITProtocol.<br>
|
||||||
|
* This can used to setActionAssigned to all SPITObjects with this SPITType.<br>
|
||||||
|
* This may be used in the case when the same action should be done for every SPITObject with this SPITType associated.<br>
|
||||||
|
* @return true = the m_ActionAssigned has changed.
|
||||||
|
*/
|
||||||
|
bool setActionAssigned(bool p_ActionAssigned);
|
||||||
|
|
||||||
/**
|
bool setMessageOP(SPIT_Message::ReportSPITType *p_ReportSPITType);
|
||||||
* Virtual construct - means ActionAssigned for SPITTypes is is not implemented in SPITProtocol.<br>
|
void fillMessageOP(SPIT_Message::ReportSPITType *p_ReportSPITType);
|
||||||
* This can used to setActionAssigned to all SPITObjects with this SPITType.<br>
|
void fillMessageOP(SPIT_Message::RemoveSPITType *p_RemoveSPITType);
|
||||||
* This may be used in the case when the same action should be done for every SPITObject with this SPITType associated.<br>
|
// static char* stringCopy(const char* p_String);
|
||||||
* @return true = the m_ActionAssigned has changed.
|
|
||||||
*/
|
|
||||||
bool setActionAssigned(bool p_ActionAssigned);
|
|
||||||
|
|
||||||
bool setMessageOP(SPIT_Message::ReportSPITType* p_ReportSPITType);
|
|
||||||
void fillMessageOP(SPIT_Message::ReportSPITType* p_ReportSPITType);
|
|
||||||
void fillMessageOP(SPIT_Message::RemoveSPITType* p_RemoveSPITType);
|
|
||||||
// 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>
|
||||||
|
|
||||||
@@ -27,316 +27,327 @@ using namespace std;
|
|||||||
|
|
||||||
class SPIT_Client : I_SAD_Client {
|
class SPIT_Client : I_SAD_Client {
|
||||||
|
|
||||||
public:
|
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 {
|
||||||
Detect,
|
ServerLoaded,
|
||||||
Lost,
|
StartTransfer,
|
||||||
Changed,
|
EndTransfer,
|
||||||
};
|
ServerClosed,
|
||||||
|
};
|
||||||
|
enum class ServerEvent {
|
||||||
|
Detect,
|
||||||
|
Lost,
|
||||||
|
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(*onProjectReport)(string p_ProjectID, string p_ProjectName, int p_FramesPerSeoond);
|
|
||||||
void(*onSpitType)(bool p_New, const SPITType &p_SPITType);
|
|
||||||
void(*onSpitTypeRemote)(bool p_New, const SPITType &p_SPITType);
|
|
||||||
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(*onSpitTypeRemoved)(const SPITType &p_SPITType);
|
|
||||||
void(*onSpitTypeRemoteRemoved)(const SPITType &p_SPITType);
|
|
||||||
void(*onSpitObjectRemoved)(const SPITType &p_SPITType, const SPITObject &p_SPITObject);
|
|
||||||
void(*onSpitObjectRemoteRemoved)(const SPITType &p_SPITType, const SPITObject &p_SPITObject);
|
|
||||||
void(*onPlay)(string p_PlayerID, string p_PlayerName, char p_PlayerType, bool p_PlayerIsRunning, long long p_TimeFrames);
|
|
||||||
void(*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 -----
|
void (*onSpitType)(ObjectEvent event, const SPITType &p_SPITType){};
|
||||||
public:
|
void (*onSpitTypeRemote)(ObjectEvent event, const SPITType &p_SPITType){};
|
||||||
/** No Connection established.<br>Either no connect tried or disconnected*/
|
void (*onSpitObject)(ObjectEvent event, const SPITType &p_SPITType, const SPITObject &p_SPITObject){};
|
||||||
static const int CONNECTION_NONE = 0;
|
void (*onSpitObjectRemote)(ObjectEvent event, const SPITType &p_SPITType, const SPITObject &p_SPITObject){};
|
||||||
/** Server has disconnected*/
|
|
||||||
static const int CONNECTION_NONESERVER = 1;
|
|
||||||
/** The connection is lost<br>Either because of a network crash or because the server no longer responds.*/
|
|
||||||
static const int CONNECTION_LOST = 2;
|
|
||||||
/** Connection to the serv er is established.*/
|
|
||||||
static const int CONNECTION_OK = 3;
|
|
||||||
/** A connection to the server is tried.*/
|
|
||||||
static const int CONNECTION_TRYCONNECTION = 4;
|
|
||||||
|
|
||||||
//------ PlayerType ------
|
void (*onPlay)(string p_PlayerID, string p_PlayerName, char p_PlayerType, bool p_PlayerIsRunning, long long p_TimeFrames){};
|
||||||
public:
|
void (*onPlaySpitType)(string p_PlayerID, string p_SPITTypeID, bool p_PlayerIsRunning, bool p_Started, bool p_Ended, double p_Value){};
|
||||||
/** continous main player, time value can be used like a timecode.<br>The time value is the position in server's project.<br>A server should use only one main player.*/
|
void (*onPlayRemoteObjectStatus)(const SPITType &p_SPITType, const SPITObject &p_SPITObject, long long p_FrameInsideObject, int p_Value){};
|
||||||
static const char PLAYERTYPE_MAIN = 0x02;
|
bool (*onCheckSpitTypeVeto)(SPIT_Message::ReportSPITType *p_ReportSPITType){};
|
||||||
/** continous player. This player plays SPIT objects sometime during the project.*/
|
bool (*onCheckSpitObjectVeto)(SPIT_Message::ReportSPITObject *p_ReportSPITObject){};
|
||||||
static const char PLAYERTYPE_CONTINOUS = 0x01;
|
};
|
||||||
/** diescrete player. This player is used to transmit single discrete values.*/
|
|
||||||
static const char PLAYERTYPE_DISCRETE = 0x00;
|
|
||||||
|
|
||||||
//------ Value Flag ------
|
//----- Connection Status -----
|
||||||
//------ used by sendRemoteObject
|
public:
|
||||||
public:
|
/** No Connection established.<br>Either no connect tried or disconnected*/
|
||||||
/**Set the given value directly*/
|
static const int CONNECTION_NONE = 0;
|
||||||
static const char VALUEFLAG_DIRECT = 0x00;
|
/** Server has disconnected*/
|
||||||
/**Increase the existing value by the given value.<br>This is usefull e.g. when instead of a fader a endless wheel is used*/
|
static const int CONNECTION_NONESERVER = 1;
|
||||||
static const char VALUEFLAG_INCREASE = 0x01;
|
/** The connection is lost<br>Either because of a network crash or because the server no longer responds.*/
|
||||||
/**Decrease the existing value by the given value.<br>This is usefull e.g. when instead of a fader a endless wheel is used*/
|
static const int CONNECTION_LOST = 2;
|
||||||
static const char VALUEFLAG_DECREASE = 0x02;
|
/** Connection to the serv er is established.*/
|
||||||
|
static const int CONNECTION_OK = 3;
|
||||||
|
/** A connection to the server is tried.*/
|
||||||
|
static const int CONNECTION_TRYCONNECTION = 4;
|
||||||
|
|
||||||
//----- SPIT_Client -----
|
//------ PlayerType ------
|
||||||
public:
|
public:
|
||||||
SPIT_Client(string name, string projName, Callbacks calls);
|
/** continous main player, time value can be used like a timecode.<br>The time value is the position in server's project.<br>A server should use only one main player.*/
|
||||||
virtual ~SPIT_Client();
|
static const char PLAYERTYPE_MAIN = 0x02;
|
||||||
static int s_MAX_OVERTAKING_SPIT_MESSAGES;
|
/** continous player. This player plays SPIT objects sometime during the project.*/
|
||||||
private:
|
static const char PLAYERTYPE_CONTINOUS = 0x01;
|
||||||
Callbacks mCallbacks;
|
/** diescrete player. This player is used to transmit single discrete values.*/
|
||||||
|
static const char PLAYERTYPE_DISCRETE = 0x00;
|
||||||
|
|
||||||
fos::TaskT<SPIT_Client&> * m_ThreadReceive{};
|
//------ Value Flag ------
|
||||||
bool m_StopReceiveSPITMessages;
|
//------ used by sendRemoteObject
|
||||||
|
public:
|
||||||
|
/**Set the given value directly*/
|
||||||
|
static const char VALUEFLAG_DIRECT = 0x00;
|
||||||
|
/**Increase the existing value by the given value.<br>This is usefull e.g. when instead of a fader a endless wheel is used*/
|
||||||
|
static const char VALUEFLAG_INCREASE = 0x01;
|
||||||
|
/**Decrease the existing value by the given value.<br>This is usefull e.g. when instead of a fader a endless wheel is used*/
|
||||||
|
static const char VALUEFLAG_DECREASE = 0x02;
|
||||||
|
|
||||||
int m_ConnectionStatus;
|
//----- SPIT_Client -----
|
||||||
bool m_DisconnectedByServer{}; //flag true = when server disconnects
|
public:
|
||||||
string m_ID;
|
SPIT_Client(string name, string projName, Callbacks calls);
|
||||||
string m_Name;
|
virtual ~SPIT_Client();
|
||||||
string m_ProjName;
|
static int s_MAX_OVERTAKING_SPIT_MESSAGES;
|
||||||
string m_ComputerName;
|
|
||||||
|
|
||||||
string m_ClientProjectName;
|
private:
|
||||||
|
Callbacks mCallbacks;
|
||||||
|
|
||||||
unsigned char m_MessageNumber_Send;
|
fos::TaskT<SPIT_Client &> *m_ThreadReceive{};
|
||||||
int m_MessageNumber_Received;
|
bool m_StopReceiveSPITMessages;
|
||||||
vector<SPIT_Message*> m_OvertakingSPIT_Messages;
|
|
||||||
|
|
||||||
//Server's info filled by parseConnectAnswer
|
int m_ConnectionStatus;
|
||||||
string m_ServerID{};
|
bool m_DisconnectedByServer{}; // flag true = when server disconnects
|
||||||
string m_ServerName{};
|
string m_ID;
|
||||||
string m_ServerComputerName{};
|
string m_Name;
|
||||||
int m_ServerStepTime{-1};
|
string m_ProjName;
|
||||||
|
string m_ComputerName;
|
||||||
|
|
||||||
//--- Server Project ---
|
string m_ClientProjectName;
|
||||||
string m_ServerProjectID;
|
|
||||||
string m_ServerProjectName;
|
|
||||||
int m_ServerFramesPerSecond;
|
|
||||||
|
|
||||||
public:
|
unsigned char m_MessageNumber_Send;
|
||||||
/** The ID of the client.<br>Every client instance should set an unique id*/
|
int m_MessageNumber_Received;
|
||||||
string getID() { return m_ID; }
|
vector<SPIT_Message *> m_OvertakingSPIT_Messages;
|
||||||
/** The name of the client, should be set by the user app*/
|
|
||||||
string getName() { return m_Name; }
|
|
||||||
//----- Computer Params -----
|
|
||||||
/** The name of the client's host computer*/
|
|
||||||
string getComputerName() { return m_ComputerName; }
|
|
||||||
void setClientProjectName(string p_ClientProjectName) { m_ClientProjectName = p_ClientProjectName; }
|
|
||||||
string getClientProjectName() { return m_ClientProjectName; }
|
|
||||||
|
|
||||||
//connected Server Infos
|
// Server's info filled by parseConnectAnswer
|
||||||
/** The ID of the connected SPITServer*/
|
string m_ServerID{};
|
||||||
string getServerID() { return m_ServerID; }
|
string m_ServerName{};
|
||||||
/** The host computername of the connected SPITServer*/
|
string m_ServerComputerName{};
|
||||||
string getServerComputerName() { return m_ServerComputerName; }
|
int m_ServerStepTime{-1};
|
||||||
/** The name of the connected SPITServer*/
|
|
||||||
string getServerName() { return m_ServerName; }
|
|
||||||
|
|
||||||
/** Expected Refreah Rate of the connectd SPITServer.<br>
|
//--- Server Project ---
|
||||||
* When the server plays objects, it will do so at discrete time steps.<br>
|
string m_ServerProjectID;
|
||||||
* Play events will take place in these time steps..
|
string m_ServerProjectName;
|
||||||
*/
|
int m_ServerFramesPerSecond;
|
||||||
int getServerStepTime() { return m_ServerStepTime; }
|
|
||||||
|
|
||||||
/** Should be called when the client wants to close his project*/
|
public:
|
||||||
void clientProjectClose();
|
/** The ID of the client.<br>Every client instance should set an unique id*/
|
||||||
/**
|
string getID() { return m_ID; }
|
||||||
* Should be called whenever the client has a project loaded
|
/** The name of the client, should be set by the user app*/
|
||||||
*/
|
string getName() { return m_Name; }
|
||||||
void clientProjectLoaded();
|
//----- Computer Params -----
|
||||||
|
/** The name of the client's host computer*/
|
||||||
|
string getComputerName() { return m_ComputerName; }
|
||||||
|
void setClientProjectName(string p_ClientProjectName) { m_ClientProjectName = p_ClientProjectName; }
|
||||||
|
string getClientProjectName() { return m_ClientProjectName; }
|
||||||
|
|
||||||
/**
|
// connected Server Infos
|
||||||
*
|
/** The ID of the connected SPITServer*/
|
||||||
* @param p_SPITTypeID
|
string getServerID() { return m_ServerID; }
|
||||||
* @param p_ActionAssigned
|
/** The host computername of the connected SPITServer*/
|
||||||
*/
|
string getServerComputerName() { return m_ServerComputerName; }
|
||||||
void setActionSPITType(string p_SPITTypeID, bool p_ActionAssigned);
|
/** The name of the connected SPITServer*/
|
||||||
void setActionSPITObject(string p_SPITObjectID, bool p_ActionAssigned);
|
string getServerName() { return m_ServerName; }
|
||||||
|
|
||||||
//--------------- SPITMessage ---------------
|
/** Expected Refreah Rate of the connectd SPITServer.<br>
|
||||||
private:
|
* When the server plays objects, it will do so at discrete time steps.<br>
|
||||||
bool startReceiveSPITMessages();
|
* Play events will take place in these time steps..
|
||||||
void stopReceiveSPITMessages();
|
*/
|
||||||
static void receiveSPITMessage(SPIT_Client& rM);
|
int getServerStepTime() { return m_ServerStepTime; }
|
||||||
// Reconnect to the server when connection is lost see eventConnectionStatus and eventServerDetected
|
|
||||||
|
/** Should be called when the client wants to close his project*/
|
||||||
|
void clientProjectClose();
|
||||||
|
/**
|
||||||
|
* Should be called whenever the client has a project loaded
|
||||||
|
*/
|
||||||
|
void clientProjectLoaded();
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param p_SPITTypeID
|
||||||
|
* @param p_ActionAssigned
|
||||||
|
*/
|
||||||
|
void setActionSPITType(string p_SPITTypeID, bool p_ActionAssigned);
|
||||||
|
void setActionSPITObject(string p_SPITObjectID, bool p_ActionAssigned);
|
||||||
|
|
||||||
|
//--------------- SPITMessage ---------------
|
||||||
|
private:
|
||||||
|
bool startReceiveSPITMessages();
|
||||||
|
void stopReceiveSPITMessages();
|
||||||
|
static void receiveSPITMessage(SPIT_Client &rM);
|
||||||
|
// Reconnect to the server when connection is lost see eventConnectionStatus and eventServerDetected
|
||||||
bool _doReconnect{}; // true = on eventServerDetected connect to the server identified by m_ServerID
|
bool _doReconnect{}; // true = on eventServerDetected connect to the server identified by m_ServerID
|
||||||
public:
|
public:
|
||||||
void fillHeader(SPIT_Message::Header* p_Header);
|
void fillHeader(SPIT_Message::Header *p_Header);
|
||||||
int sendSPITMessage(SPIT_Message::OPPart& p_SPITMessageOPPart);
|
int sendSPITMessage(SPIT_Message::OPPart &p_SPITMessageOPPart);
|
||||||
|
|
||||||
//--------------- ServerAutoDetection SAD ---------------
|
//--------------- ServerAutoDetection SAD ---------------
|
||||||
public:
|
public:
|
||||||
/** Starts the autodetection of SPITServers in the local network. If a connection is tried, the autodetection should be stopped before.*/
|
/** Starts the autodetection of SPITServers in the local network. If a connection is tried, the autodetection should be stopped before.*/
|
||||||
void startServerAutoDetect();
|
void startServerAutoDetect();
|
||||||
/** 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:
|
||||||
/**
|
/**
|
||||||
* Tries a connection to the SPITServer
|
* Tries a connection to the SPITServer
|
||||||
* @param p_ServerIP ip address of the SPITServer
|
* @param p_ServerIP ip address of the SPITServer
|
||||||
* @param p_ServerPort port of the SPITServer
|
* @param p_ServerPort port of the SPITServer
|
||||||
* @param p_ClientIP IP of the client
|
* @param p_ClientIP IP of the client
|
||||||
* @param p_ClientPort if "0" any free port will be used
|
* @param p_ClientPort if "0" any free port will be used
|
||||||
* @param p_LoginName maybe some SPITServer need a login - liveSHOWsoftware will not.
|
* @param p_LoginName maybe some SPITServer need a login - liveSHOWsoftware will not.
|
||||||
* @param p_LoginPassword maybe some SPITServer need a login - liveSHOWsoftware will not
|
* @param p_LoginPassword maybe some SPITServer need a login - liveSHOWsoftware will not
|
||||||
* @return true = the connection try is ok, SPITServer will answer with COnnectAnswer and an eventConnectionStatus will occur.<br>
|
* @return true = the connection try is ok, SPITServer will answer with COnnectAnswer and an eventConnectionStatus will occur.<br>
|
||||||
* false = something is going wrong. (client could not bind)
|
* false = something is going wrong. (client could not bind)
|
||||||
*/
|
*/
|
||||||
bool connect(string p_ServerIP, string p_ServerPort, string p_ClientIP, string p_ClientPort, string p_LoginName = "", string p_LoginPassword = "");
|
bool connect(string p_ServerIP, string p_ServerPort, string p_ClientIP, string p_ClientPort, string p_LoginName = "", string p_LoginPassword = "");
|
||||||
/**
|
/**
|
||||||
* Terminates the connection to the SPITServer.
|
* Terminates the connection to the SPITServer.
|
||||||
*/
|
*/
|
||||||
void disconnect();
|
void disconnect();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void disconnectInternal(int p_Cause);
|
void disconnectInternal(int p_Cause);
|
||||||
void resetMessageNumberReceived();
|
void resetMessageNumberReceived();
|
||||||
void parseSPIT_Message(unique_ptr<SPIT_Message> p_SPITMessage);
|
void parseSPIT_Message(unique_ptr<SPIT_Message> p_SPITMessage);
|
||||||
void checkParseSPIT_Message(unique_ptr<SPIT_Message> p_SPITMessage);
|
void checkParseSPIT_Message(unique_ptr<SPIT_Message> p_SPITMessage);
|
||||||
void addOvertakingSPIT_Message(SPIT_Message* p_SPIT_Message);
|
void addOvertakingSPIT_Message(SPIT_Message *p_SPIT_Message);
|
||||||
void parseConnectAnswer(SPIT_Message::ConnectAnswer* p_ConnectAnswer);
|
void parseConnectAnswer(SPIT_Message::ConnectAnswer *p_ConnectAnswer);
|
||||||
void parseDisconnect(SPIT_Message::Disconnect* p_Disconnect);
|
void parseDisconnect(SPIT_Message::Disconnect *p_Disconnect);
|
||||||
void parseWatchdog(SPIT_Message::Watchdog* p_Watchdog);
|
void parseWatchdog(SPIT_Message::Watchdog *p_Watchdog);
|
||||||
void parseWatchdogAnswer(SPIT_Message::WatchdogAnswer* p_WatchdogAnswer);
|
void parseWatchdogAnswer(SPIT_Message::WatchdogAnswer *p_WatchdogAnswer);
|
||||||
public:
|
|
||||||
/** Used internally*/
|
|
||||||
void sendWatchdog();
|
|
||||||
/** Used internally. When the connection to the SPITServer is lost an eventConnectionStatus will occur*/
|
|
||||||
void eventWatchdogLost();
|
|
||||||
//--------------- SPIT Project ---------------
|
|
||||||
private:
|
|
||||||
void parseReportSPITProject(SPIT_Message::ReportSPITProject* p_ReportSPITProject);
|
|
||||||
void parseCloseSPITProject(SPIT_Message::CloseSPITProject* p_CloseSPITProject);
|
|
||||||
public:
|
|
||||||
/** Returns the SPITServer's project ID - may be the same as the project's name*/
|
|
||||||
string getServerProjectID();
|
|
||||||
/** Returns the SPITServer's project name*/
|
|
||||||
string getServerProjectName();
|
|
||||||
/** Returns frame rate per second. This is the time resolution in which the server transmits time data. The unit of time data is always frames.*/
|
|
||||||
int getServerFramesPerSecond();
|
|
||||||
|
|
||||||
private:
|
public:
|
||||||
void parseRequestProjectTransfer(SPIT_Message::RequestProjectTransfer* p_RequestProjectTransfer);
|
/** Used internally*/
|
||||||
void parseStartProjectTransfer(SPIT_Message::StartProjectTransfer* p_StartProjectTransfer);
|
void sendWatchdog();
|
||||||
void parseEndProjectTransfer(SPIT_Message::EndProjectTransfer* p_EndProjectTransfer);
|
/** Used internally. When the connection to the SPITServer is lost an eventConnectionStatus will occur*/
|
||||||
public:
|
void eventWatchdogLost();
|
||||||
static void sendProject(SPIT_Client* p_PtrSPIT_Client);
|
//--------------- SPIT Project ---------------
|
||||||
|
private:
|
||||||
|
void parseReportSPITProject(SPIT_Message::ReportSPITProject *p_ReportSPITProject);
|
||||||
|
void parseCloseSPITProject(SPIT_Message::CloseSPITProject *p_CloseSPITProject);
|
||||||
|
|
||||||
// --------------- SPIT Types ---------------
|
public:
|
||||||
public:
|
/** Returns the SPITServer's project ID - may be the same as the project's name*/
|
||||||
/**
|
string getServerProjectID();
|
||||||
* Creates a fixed SPITType for application actions that are always present and project independent.<br>
|
/** Returns the SPITServer's project name*/
|
||||||
* Fixed SPIT types cannot be changed or deleted by the server.<br>
|
string getServerProjectName();
|
||||||
* These SPITTypes will be automatically added to the SPITType-List and sended to the server.
|
/** Returns frame rate per second. This is the time resolution in which the server transmits time data. The unit of time data is always frames.*/
|
||||||
* @param p_ID an unique of the SPITType, these are always the same per client approach. Different client approaches should use different ids.
|
int getServerFramesPerSecond();
|
||||||
* @param p_GroupName a name which groups the actions/SPITTypes
|
|
||||||
* @param p_Name the name of the Action/SPITType
|
|
||||||
* @param p_DefaultDelay maybe there is an default delay until the action starts, this is only used for graphical representations, 0 is allowd
|
|
||||||
* @param p_DefaultDuration maybe the action has a default duration, this is only used for graphical representations, 0 is allowd
|
|
||||||
* @return the pointer to the new SPITType.
|
|
||||||
*/
|
|
||||||
SPITType* createSPITTypeFixed(string p_ID, string p_GroupName, string p_Name, long long p_DefaultDelay, long long p_DefaultDuration);
|
|
||||||
|
|
||||||
/**
|
private:
|
||||||
* Creates a SPITType for application actions.<br>
|
void parseRequestProjectTransfer(SPIT_Message::RequestProjectTransfer *p_RequestProjectTransfer);
|
||||||
* These SPITTypes will be automatically added to the SPITType-List and sended to the server.
|
void parseStartProjectTransfer(SPIT_Message::StartProjectTransfer *p_StartProjectTransfer);
|
||||||
* @param p_ID an unique of the SPITType, these are always the same per client approach. Different client approaches should use different ids.
|
void parseEndProjectTransfer(SPIT_Message::EndProjectTransfer *p_EndProjectTransfer);
|
||||||
* @param p_GroupName a name which groups the actions/SPITTypes
|
|
||||||
* @param p_Name the name of the Action/SPITType
|
|
||||||
* @param p_DefaultDelay maybe there is an default delay until the action starts, this is only used for graphical representations, 0 is allowd
|
|
||||||
* @param p_DefaultDuration maybe the action has a default duration, this is only used for graphical representations, 0 is allowd
|
|
||||||
* @param p_Fixed true = the server is not allowed to change this SPITType, false = the server may change or delete this SPITType
|
|
||||||
* @param p_ProjectIndepended true = the SPITType belongs to a specific project, false = the SpitType always exists for every project
|
|
||||||
* @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);
|
|
||||||
private:
|
|
||||||
//receive SPITTypes
|
|
||||||
void parseReportSPITType(SPIT_Message::ReportSPITType* p_ReportSPITType);
|
|
||||||
void parseRemoveSPITType(SPIT_Message::RemoveSPITType* p_RemoveSPITType);
|
|
||||||
int sendSPITTypeInternal(SPITType* p_SPITType);
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* If a client wants to change a SPITType, he should send it to the server.<br>
|
|
||||||
* If the SPITTye is a fixed one and not created by the client himself, then an eventSPITType can be sent from the server, which cancels the change.<br>
|
|
||||||
* @param p_SPITTypeID the id of the SPITType to remove.
|
|
||||||
* @return 0 = is sended, -1 = is not sended
|
|
||||||
*/
|
|
||||||
bool changeSPITType(SPITType* p_SPITType);
|
|
||||||
/**
|
|
||||||
* If a client wants to remove a SPITType, he should send it to the server.<br>
|
|
||||||
* If the SPITTye is a fixed one and not created by the client himself, then an eventSPITType can be sent from the server, which cancels the deletion.<br>
|
|
||||||
* @param p_SPITTypeID the id of the SPITType to remove.
|
|
||||||
* @return 0 = is sended, -1 = is not sended
|
|
||||||
*/
|
|
||||||
int removeSPITType(string p_SPITTypeID);
|
|
||||||
public:
|
|
||||||
|
|
||||||
//--------------- SPIT Objects ---------------
|
public:
|
||||||
private:
|
static void sendProject(SPIT_Client *p_PtrSPIT_Client);
|
||||||
void parseReportSPITObject(SPIT_Message::ReportSPITObject* p_ReportSPITObject);
|
|
||||||
void parseRemoveSPITObject(SPIT_Message::RemoveSPITObject* p_RemoveSPITObject);
|
|
||||||
int sendSPITObjectInternal(SPITObject* ptrSPITObject);
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* When the client changes a SPITObject (normally the client should not do this), then it should send the changes to the SPITServer.<br>
|
|
||||||
* The SPITServer may discard the changes and an eventSPITObject occurs.<br>
|
|
||||||
* @param p_SPITObject the pointer to the changed SPITObject.
|
|
||||||
* @return 0 = sended, -1 = not sended
|
|
||||||
*/
|
|
||||||
bool changeSPITObject(SPITObject* p_SPITObject);
|
|
||||||
/**
|
|
||||||
* When the client removes a SPITObject (normally the client should not do this), then he should send it to the SPITServer.<br>
|
|
||||||
* The SPITServer may discard the deletion and an eventSPITObject occurs.<br>
|
|
||||||
* @param p_SPITObjectID the id of the SPITObject to remove.
|
|
||||||
* @return 0 = sended, -1 = not sended
|
|
||||||
*/
|
|
||||||
int removeSPITObject(string p_SPITObjectID);
|
|
||||||
public:
|
|
||||||
|
|
||||||
//--------------- Play SPIT Objects ---------------
|
// --------------- SPIT Types ---------------
|
||||||
private:
|
public:
|
||||||
void parsePlaySPITStart(SPIT_Message::PlaySPITStart* p_PlaySPITStart);
|
/**
|
||||||
void parsePlaySPITObject(SPIT_Message::PlaySPITObject* p_PlaySPITObject);
|
* Creates a fixed SPITType for application actions that are always present and project independent.<br>
|
||||||
void parsePlaySPITEnd(SPIT_Message::PlaySPITEnd* p_PlaySPITEnd);
|
* Fixed SPIT types cannot be changed or deleted by the server.<br>
|
||||||
void parseReportPlayStatus(SPIT_Message::ReportPlayStatus* p_ReportPlayStatus);
|
* These SPITTypes will be automatically added to the SPITType-List and sended to the server.
|
||||||
|
* @param p_ID an unique of the SPITType, these are always the same per client approach. Different client approaches should use different ids.
|
||||||
|
* @param p_GroupName a name which groups the actions/SPITTypes
|
||||||
|
* @param p_Name the name of the Action/SPITType
|
||||||
|
* @param p_DefaultDelay maybe there is an default delay until the action starts, this is only used for graphical representations, 0 is allowd
|
||||||
|
* @param p_DefaultDuration maybe the action has a default duration, this is only used for graphical representations, 0 is allowd
|
||||||
|
* @return the pointer to the new SPITType.
|
||||||
|
*/
|
||||||
|
SPITType *createSPITTypeFixed(string p_ID, string p_GroupName, string p_Name, long long p_DefaultDelay, long long p_DefaultDuration);
|
||||||
|
|
||||||
public:
|
/**
|
||||||
//--------- Remote ----------
|
* Creates a SPITType for application actions.<br>
|
||||||
void sendRemoteObject(string p_SPITObjectID, int p_Valueppm = 0, char p_ValueFlag = 0x00);
|
* These SPITTypes will be automatically added to the SPITType-List and sended to the server.
|
||||||
|
* @param p_ID an unique of the SPITType, these are always the same per client approach. Different client approaches should use different ids.
|
||||||
|
* @param p_GroupName a name which groups the actions/SPITTypes
|
||||||
|
* @param p_Name the name of the Action/SPITType
|
||||||
|
* @param p_DefaultDelay maybe there is an default delay until the action starts, this is only used for graphical representations, 0 is allowd
|
||||||
|
* @param p_DefaultDuration maybe the action has a default duration, this is only used for graphical representations, 0 is allowd
|
||||||
|
* @param p_Fixed true = the server is not allowed to change this SPITType, false = the server may change or delete this SPITType
|
||||||
|
* @param p_ProjectIndepended true = the SPITType belongs to a specific project, false = the SpitType always exists for every project
|
||||||
|
* @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);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void processSocketTask(SPIT_Client & instance);
|
// receive SPITTypes
|
||||||
fos::TaskT<SPIT_Client &>* sThread{};
|
void parseReportSPITType(SPIT_Message::ReportSPITType *p_ReportSPITType);
|
||||||
bool abortSearch{};
|
void parseRemoveSPITType(SPIT_Message::RemoveSPITType *p_RemoveSPITType);
|
||||||
bool sAnswered{};
|
int sendSPITTypeInternal(SPITType *p_SPITType);
|
||||||
static fos::Semaphore sStartSad;
|
|
||||||
SPITSocket * mSPITSocket;
|
|
||||||
void answerWatchdog() {
|
|
||||||
sAnswered = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* If a client wants to change a SPITType, he should send it to the server.<br>
|
||||||
|
* If the SPITTye is a fixed one and not created by the client himself, then an eventSPITType can be sent from the server, which cancels the change.<br>
|
||||||
|
* @param p_SPITTypeID the id of the SPITType to remove.
|
||||||
|
* @return 0 = is sended, -1 = is not sended
|
||||||
|
*/
|
||||||
|
bool changeSPITType(SPITType *p_SPITType);
|
||||||
|
/**
|
||||||
|
* If a client wants to remove a SPITType, he should send it to the server.<br>
|
||||||
|
* If the SPITTye is a fixed one and not created by the client himself, then an eventSPITType can be sent from the server, which cancels the deletion.<br>
|
||||||
|
* @param p_SPITTypeID the id of the SPITType to remove.
|
||||||
|
* @return 0 = is sended, -1 = is not sended
|
||||||
|
*/
|
||||||
|
int removeSPITType(string p_SPITTypeID);
|
||||||
|
|
||||||
|
public:
|
||||||
|
//--------------- SPIT Objects ---------------
|
||||||
|
private:
|
||||||
|
void parseReportSPITObject(SPIT_Message::ReportSPITObject *p_ReportSPITObject);
|
||||||
|
void parseRemoveSPITObject(SPIT_Message::RemoveSPITObject *p_RemoveSPITObject);
|
||||||
|
int sendSPITObjectInternal(SPITObject *ptrSPITObject);
|
||||||
|
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* When the client changes a SPITObject (normally the client should not do this), then it should send the changes to the SPITServer.<br>
|
||||||
|
* The SPITServer may discard the changes and an eventSPITObject occurs.<br>
|
||||||
|
* @param p_SPITObject the pointer to the changed SPITObject.
|
||||||
|
* @return 0 = sended, -1 = not sended
|
||||||
|
*/
|
||||||
|
bool changeSPITObject(SPITObject *p_SPITObject);
|
||||||
|
/**
|
||||||
|
* When the client removes a SPITObject (normally the client should not do this), then he should send it to the SPITServer.<br>
|
||||||
|
* The SPITServer may discard the deletion and an eventSPITObject occurs.<br>
|
||||||
|
* @param p_SPITObjectID the id of the SPITObject to remove.
|
||||||
|
* @return 0 = sended, -1 = not sended
|
||||||
|
*/
|
||||||
|
int removeSPITObject(string p_SPITObjectID);
|
||||||
|
|
||||||
|
public:
|
||||||
|
//--------------- Play SPIT Objects ---------------
|
||||||
|
private:
|
||||||
|
void parsePlaySPITStart(SPIT_Message::PlaySPITStart *p_PlaySPITStart);
|
||||||
|
void parsePlaySPITObject(SPIT_Message::PlaySPITObject *p_PlaySPITObject);
|
||||||
|
void parsePlaySPITEnd(SPIT_Message::PlaySPITEnd *p_PlaySPITEnd);
|
||||||
|
void parseReportPlayStatus(SPIT_Message::ReportPlayStatus *p_ReportPlayStatus);
|
||||||
|
|
||||||
|
public:
|
||||||
|
//--------- Remote ----------
|
||||||
|
void sendRemoteObject(string p_SPITObjectID, int p_Valueppm = 0, char p_ValueFlag = 0x00);
|
||||||
|
|
||||||
|
private:
|
||||||
|
static void processSocketTask(SPIT_Client &instance);
|
||||||
|
fos::TaskT<SPIT_Client &> *sThread{};
|
||||||
|
bool abortSearch{};
|
||||||
|
bool sAnswered{};
|
||||||
|
static fos::Semaphore sStartSad;
|
||||||
|
SPITSocket *mSPITSocket;
|
||||||
|
void answerWatchdog() {
|
||||||
|
sAnswered = true;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* SPIT_CLIENT_H */
|
#endif /* SPIT_CLIENT_H */
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -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");
|
|
||||||
}
|
|
||||||
@@ -15,163 +15,119 @@
|
|||||||
#include "SAD_DetectedServer.hpp"
|
#include "SAD_DetectedServer.hpp"
|
||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
|
|
||||||
static const char * TAG = "SpitSrv";
|
static const char *TAG = "SpitSrv";
|
||||||
|
|
||||||
unordered_map<string, SAD_DetectedServer*> SAD_DetectedServer::s_DetectedServers;
|
unordered_map<string, SAD_DetectedServer *> SAD_DetectedServer::s_DetectedServers;
|
||||||
|
|
||||||
SAD_DetectedServer::~SAD_DetectedServer() {
|
SAD_DetectedServer::~SAD_DetectedServer() {
|
||||||
}
|
}
|
||||||
//----- Detected Server -----
|
//----- Detected Server -----
|
||||||
SAD_DetectedServer::SAD_DetectedServer() {
|
SAD_DetectedServer::SAD_DetectedServer() {
|
||||||
m_ID = "";
|
m_ID = "";
|
||||||
m_Name = "";
|
m_Name = "";
|
||||||
m_ComputerName = "";
|
m_ComputerName = "";
|
||||||
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) {
|
||||||
if (m_ServerProjectName.compare(p_ServerProjectName) != 0) {
|
if (m_ServerProjectName.compare(p_ServerProjectName) != 0) {
|
||||||
if (m_New == false) {
|
if (m_New == false) {
|
||||||
m_Changed = true;
|
m_Changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_ServerProjectName = p_ServerProjectName;
|
m_ServerProjectName = p_ServerProjectName;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SAD_DetectedServer::cycleStart() {
|
void SAD_DetectedServer::cycleStart() {
|
||||||
for (auto i = s_DetectedServers.begin(); i != s_DetectedServers.end(); i++) {
|
for (auto i = s_DetectedServers.begin(); i != s_DetectedServers.end(); i++) {
|
||||||
i->second->startCycleSAD();
|
i->second->startCycleSAD();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void SAD_DetectedServer::cycleEnd(I_SAD_Client& 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;
|
if (ptrDetectedServer->getFoundAgain() == false) {
|
||||||
SAD_DetectedServer* ptrDetectedServer;
|
sadClient.eventServerLost(*ptrDetectedServer);
|
||||||
{
|
removeDetectedServer(*ptrDetectedServer);
|
||||||
for (auto i = s_DetectedServers.begin(); i != s_DetectedServers.end(); i++) {
|
} else if (ptrDetectedServer->getNew()) {
|
||||||
ptrDetectedServer = i->second;
|
ptrDetectedServer->setNew(false);
|
||||||
if (ptrDetectedServer->getFoundAgain() == false) {
|
sadClient.eventServerDetected(*ptrDetectedServer);
|
||||||
o_LostServers.push_back(ptrDetectedServer);
|
} else if (ptrDetectedServer->getChanged()) {
|
||||||
ptrDetectedServer->endCycleSAD();
|
sadClient.eventServerChanged(*ptrDetectedServer);
|
||||||
}
|
}
|
||||||
else if (ptrDetectedServer->getNew()) {
|
}
|
||||||
o_NewServers.push_back(ptrDetectedServer);
|
|
||||||
ptrDetectedServer->setNew(false);
|
|
||||||
ptrDetectedServer->endCycleSAD();
|
|
||||||
}
|
|
||||||
else if (ptrDetectedServer->getChanged()) {
|
|
||||||
o_ChangedServers.push_back(ptrDetectedServer);
|
|
||||||
ptrDetectedServer->endCycleSAD();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ptrDetectedServer->endCycleSAD();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//Notify client interface about lost servers
|
|
||||||
for (auto i = o_LostServers.begin(); i != o_LostServers.end(); i++) {
|
|
||||||
ptrDetectedServer = *i;
|
|
||||||
sadClient.eventServerLost(ptrDetectedServer->getID(), ptrDetectedServer->getName(),
|
|
||||||
ptrDetectedServer->getComputerName(), ptrDetectedServer->getIP(), ptrDetectedServer->getPort(), ptrDetectedServer->getAdditions(),ptrDetectedServer->getProjectName(),
|
|
||||||
ptrDetectedServer->getClientIP(),
|
|
||||||
ptrDetectedServer->getIpIsIP4());
|
|
||||||
}
|
|
||||||
//Remove lost servers
|
|
||||||
for (auto i = o_LostServers.begin(); i != o_LostServers.end(); i++) {
|
|
||||||
ptrDetectedServer = *i;
|
|
||||||
removeDetectedServer(ptrDetectedServer);
|
|
||||||
}
|
|
||||||
o_LostServers.clear();
|
|
||||||
|
|
||||||
for (auto i = o_NewServers.begin(); i != o_NewServers.end(); i++) {
|
|
||||||
ptrDetectedServer = *i;
|
|
||||||
sadClient.eventServerDetected(ptrDetectedServer->getID(), ptrDetectedServer->getName(),
|
|
||||||
ptrDetectedServer->getComputerName(), ptrDetectedServer->getIP(), ptrDetectedServer->getPort(), ptrDetectedServer->getAdditions(),ptrDetectedServer->getProjectName(),
|
|
||||||
ptrDetectedServer->getClientIP(),
|
|
||||||
ptrDetectedServer->getIpIsIP4());
|
|
||||||
}
|
|
||||||
o_NewServers.clear();
|
|
||||||
for (auto i = o_ChangedServers.begin(); i != o_ChangedServers.end(); i++) {
|
|
||||||
ptrDetectedServer = *i;
|
|
||||||
sadClient.eventServerChanged(ptrDetectedServer->getID(), ptrDetectedServer->getName(),
|
|
||||||
ptrDetectedServer->getComputerName(), ptrDetectedServer->getIP(), ptrDetectedServer->getPort(), ptrDetectedServer->getAdditions(),ptrDetectedServer->getProjectName(),
|
|
||||||
ptrDetectedServer->getClientIP(),
|
|
||||||
ptrDetectedServer->getIpIsIP4());
|
|
||||||
}
|
|
||||||
o_ChangedServers.clear();
|
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Used by SAD_Client to add a found SPITServer - don't use this manually
|
|
||||||
* @param p_IsIP4 true = the server is reached via a IP4 address<br>false = the server is reahed via a IP6 address
|
|
||||||
* @param p_ServerID the id of the server, every instance of a SPITServer has an own id
|
|
||||||
* @param p_ServerParams the server's parameter
|
|
||||||
*/
|
|
||||||
void SAD_DetectedServer::addDetectedServer(bool p_IsIP4, string p_ServerID, string p_ServerParams[]) {
|
|
||||||
SAD_DetectedServer* ptrDetectedServer;
|
|
||||||
{
|
|
||||||
auto i = s_DetectedServers.find(p_ServerID);
|
|
||||||
if (i != s_DetectedServers.end()) {
|
|
||||||
ptrDetectedServer = i->second;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ptrDetectedServer = new SAD_DetectedServer();
|
|
||||||
ptrDetectedServer->setID(p_ServerParams[PARAMINDEX_ID]);
|
|
||||||
ptrDetectedServer->setNew(true);
|
|
||||||
}
|
|
||||||
ptrDetectedServer->setFoundAgain();
|
|
||||||
|
|
||||||
//second prefer IP4
|
/**
|
||||||
if (p_IsIP4 == true) {
|
* Used by SAD_Client to add a found SPITServer - don't use this manually
|
||||||
ptrDetectedServer->setIP(p_ServerParams[PARAMINDEX_IP]);
|
* @param p_IsIP4 true = the server is reached via a IP4 address<br>false = the server is reahed via a IP6 address
|
||||||
ptrDetectedServer->setIPIsIP4(true);
|
* @param p_ServerID the id of the server, every instance of a SPITServer has an own id
|
||||||
ptrDetectedServer->setClientIP(p_ServerParams[PARAMINDEX_CLIENTIP]);
|
* @param p_ServerParams the server's parameter
|
||||||
}
|
*/
|
||||||
else if (ptrDetectedServer->getIpIsIP4() == false){
|
void SAD_DetectedServer::addDetectedServer(string p_ServerID, string p_ServerParams[]) {
|
||||||
ptrDetectedServer->setIP(p_ServerParams[PARAMINDEX_IP]);
|
SAD_DetectedServer *ptrDetectedServer;
|
||||||
ptrDetectedServer->setClientIP(p_ServerParams[PARAMINDEX_CLIENTIP]);
|
{
|
||||||
}
|
auto i = s_DetectedServers.find(p_ServerID);
|
||||||
ptrDetectedServer->setName(p_ServerParams[PARAMINDEX_NAME]);
|
if (i != s_DetectedServers.end()) {
|
||||||
ptrDetectedServer->setComputerName(p_ServerParams[PARAMINDEX_COMPUTERNAME]);
|
ptrDetectedServer = i->second;
|
||||||
ptrDetectedServer->setPort(p_ServerParams[PARAMINDEX_PORT]);
|
} else {
|
||||||
ptrDetectedServer->setAdditions(p_ServerParams[PARAMINDEX_ADDITIONS]);
|
ptrDetectedServer = new SAD_DetectedServer();
|
||||||
ptrDetectedServer->setProjectName(p_ServerParams[PARAMINDEX_SERVERPROJECTNAME]);
|
ptrDetectedServer->setID(p_ServerParams[PARAMINDEX_ID]);
|
||||||
|
ptrDetectedServer->setNew(true);
|
||||||
|
}
|
||||||
|
ptrDetectedServer->setFoundAgain();
|
||||||
|
|
||||||
s_DetectedServers[ptrDetectedServer->getID()] = ptrDetectedServer;
|
// second prefer IP4
|
||||||
}
|
ptrDetectedServer->setIP(p_ServerParams[PARAMINDEX_IP]);
|
||||||
}
|
ptrDetectedServer->setClientIP(p_ServerParams[PARAMINDEX_CLIENTIP]);
|
||||||
/**
|
ptrDetectedServer->setName(p_ServerParams[PARAMINDEX_NAME]);
|
||||||
* Used by SAD_Client to remove a SPITServer - don't use this manually
|
ptrDetectedServer->setComputerName(p_ServerParams[PARAMINDEX_COMPUTERNAME]);
|
||||||
* @param p_DetectedServer
|
ptrDetectedServer->setPort(p_ServerParams[PARAMINDEX_PORT]);
|
||||||
*/
|
ptrDetectedServer->setAdditions(p_ServerParams[PARAMINDEX_ADDITIONS]);
|
||||||
void SAD_DetectedServer::removeDetectedServer(SAD_DetectedServer* p_DetectedServer) {
|
ptrDetectedServer->setProjectName(p_ServerParams[PARAMINDEX_SERVERPROJECTNAME]);
|
||||||
SAD_DetectedServer* o_DetectedServer;
|
|
||||||
{
|
|
||||||
auto i = s_DetectedServers.find(p_DetectedServer->getID());
|
|
||||||
if (i != s_DetectedServers.end()) {
|
|
||||||
o_DetectedServer = i->second;
|
|
||||||
i = s_DetectedServers.erase(i);
|
|
||||||
delete o_DetectedServer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
s_DetectedServers[ptrDetectedServer->getID()] = ptrDetectedServer;
|
||||||
* Used by SAD_Client to clear all found SPITServers - don't use this manually
|
}
|
||||||
*/
|
}
|
||||||
|
/**
|
||||||
|
* Used by SAD_Client to remove a SPITServer - don't use this manually
|
||||||
|
* @param p_DetectedServer
|
||||||
|
*/
|
||||||
|
void SAD_DetectedServer::removeDetectedServer(SAD_DetectedServer &server) {
|
||||||
|
auto i = s_DetectedServers.find(server.getID());
|
||||||
|
if (i != s_DetectedServers.end()) {
|
||||||
|
SAD_DetectedServer *o_DetectedServer = i->second;
|
||||||
|
i = s_DetectedServers.erase(i);
|
||||||
|
delete o_DetectedServer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used by SAD_Client to clear all found SPITServers - don't use this manually
|
||||||
|
*/
|
||||||
void SAD_DetectedServer::clearDetectedServers() {
|
void SAD_DetectedServer::clearDetectedServers() {
|
||||||
SAD_DetectedServer* ptrDetectedServer;
|
for (auto i = s_DetectedServers.begin(); i != s_DetectedServers.end(); i++) {
|
||||||
{
|
SAD_DetectedServer *ptrDetectedServer = i->second;
|
||||||
for (auto i = s_DetectedServers.begin(); i != s_DetectedServers.end(); i++) {
|
i = s_DetectedServers.erase(i);
|
||||||
ptrDetectedServer = i->second;
|
delete ptrDetectedServer;
|
||||||
i = s_DetectedServers.erase(i);
|
if (i == s_DetectedServers.end()) {
|
||||||
delete ptrDetectedServer;
|
break;
|
||||||
if (i == s_DetectedServers.end()) {
|
}
|
||||||
break;
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
const SAD_DetectedServer &SAD_DetectedServer::getRefDetectedServer(string p_ServerID) {
|
||||||
}
|
SAD_DetectedServer *ptrDetectedServer = nullptr;
|
||||||
|
|
||||||
|
auto i = s_DetectedServers.find(p_ServerID);
|
||||||
|
if (i != s_DetectedServers.end()) {
|
||||||
|
ptrDetectedServer = i->second;
|
||||||
|
}
|
||||||
|
if (ptrDetectedServer != NULL) {
|
||||||
|
return *ptrDetectedServer;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new exception();
|
||||||
|
}
|
||||||
+500
-469
File diff suppressed because it is too large
Load Diff
@@ -15,67 +15,67 @@
|
|||||||
#include "SPITPlayer.h"
|
#include "SPITPlayer.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
unordered_map<string, SPITPlayer*> SPITPlayer::s_SPITPlayers;
|
unordered_map<string, SPITPlayer *> SPITPlayer::s_SPITPlayers;
|
||||||
|
|
||||||
SPITPlayer* SPITPlayer::getSPITPlayer(string p_PlayerID) {
|
SPITPlayer *SPITPlayer::getSPITPlayer(string p_PlayerID) {
|
||||||
{
|
{
|
||||||
auto i = s_SPITPlayers.find(p_PlayerID);
|
auto i = s_SPITPlayers.find(p_PlayerID);
|
||||||
if (i == s_SPITPlayers.end()) {
|
if (i == s_SPITPlayers.end()) {
|
||||||
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 i->second;
|
return NULL;
|
||||||
}
|
return i->second;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SPITPlayer::clearPlayers() {
|
void SPITPlayer::clearPlayers() {
|
||||||
;
|
;
|
||||||
vector<SPITPlayer*> o_SPITPlayers;
|
vector<SPITPlayer *> o_SPITPlayers;
|
||||||
for (auto i = s_SPITPlayers.begin(); i != s_SPITPlayers.end(); i++) {
|
for (auto i = s_SPITPlayers.begin(); i != s_SPITPlayers.end(); i++) {
|
||||||
SPITPlayer* ptrSPITPlayer = i->second;
|
SPITPlayer *ptrSPITPlayer = i->second;
|
||||||
o_SPITPlayers.push_back(ptrSPITPlayer);
|
o_SPITPlayers.push_back(ptrSPITPlayer);
|
||||||
}
|
}
|
||||||
for (auto i = o_SPITPlayers.begin(); i != o_SPITPlayers.end(); i++) {
|
for (auto i = o_SPITPlayers.begin(); i != o_SPITPlayers.end(); i++) {
|
||||||
SPITPlayer* ptrSPITPlayer = *i;
|
SPITPlayer *ptrSPITPlayer = *i;
|
||||||
delete ptrSPITPlayer;
|
delete ptrSPITPlayer;
|
||||||
}
|
}
|
||||||
o_SPITPlayers.clear();
|
o_SPITPlayers.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
SPITPlayer::SPITPlayer(string p_PlayerID) {
|
SPITPlayer::SPITPlayer(string p_PlayerID) {
|
||||||
m_ID = p_PlayerID;
|
m_ID = p_PlayerID;
|
||||||
s_SPITPlayers[p_PlayerID] = this;
|
s_SPITPlayers[p_PlayerID] = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
SPITPlayer::~SPITPlayer() {
|
SPITPlayer::~SPITPlayer() {
|
||||||
PlaySPITType* ptrPlaySPITType;
|
PlaySPITType *ptrPlaySPITType;
|
||||||
for (auto i = m_PlaySPITTypes.begin(); i != m_PlaySPITTypes.end(); i++) {
|
for (auto i = m_PlaySPITTypes.begin(); i != m_PlaySPITTypes.end(); i++) {
|
||||||
ptrPlaySPITType = i->second;
|
ptrPlaySPITType = i->second;
|
||||||
i = m_PlaySPITTypes.erase(i);
|
i = m_PlaySPITTypes.erase(i);
|
||||||
delete ptrPlaySPITType;
|
delete ptrPlaySPITType;
|
||||||
if (i == m_PlaySPITTypes.end()) {
|
if (i == m_PlaySPITTypes.end()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SPITPlayer::setIsRunning(bool p_IsRunning) {
|
void SPITPlayer::setIsRunning(bool p_IsRunning) {
|
||||||
m_IsRunning = p_IsRunning;
|
m_IsRunning = p_IsRunning;
|
||||||
}
|
}
|
||||||
void SPITPlayer::setName(string p_Name) {
|
void SPITPlayer::setName(string p_Name) {
|
||||||
m_Name = p_Name;
|
m_Name = p_Name;
|
||||||
}
|
}
|
||||||
void SPITPlayer::setType(char p_Type) {
|
void SPITPlayer::setType(char p_Type) {
|
||||||
m_Type = p_Type;
|
m_Type = p_Type;
|
||||||
}
|
}
|
||||||
void SPITPlayer::setTime(long long p_Frames) {
|
void SPITPlayer::setTime(long long p_Frames) {
|
||||||
m_TimeFrames = p_Frames;
|
m_TimeFrames = p_Frames;
|
||||||
}
|
}
|
||||||
|
|
||||||
unordered_map<string, SPITPlayer::PlaySPITType*>* SPITPlayer::getPlaySPITTypes() {
|
unordered_map<string, SPITPlayer::PlaySPITType *> *SPITPlayer::getPlaySPITTypes() {
|
||||||
return &m_PlaySPITTypes;
|
return &m_PlaySPITTypes;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -83,71 +83,68 @@ unordered_map<string, SPITPlayer::PlaySPITType*>* SPITPlayer::getPlaySPITTypes()
|
|||||||
* @return true = new PlayObject added<br>
|
* @return true = new PlayObject added<br>
|
||||||
* false = PlayObject exists
|
* false = PlayObject exists
|
||||||
*/
|
*/
|
||||||
SPITPlayer::PlaySPITType* SPITPlayer::addSPITType_Playing (string p_SPITTypeID) {
|
SPITPlayer::PlaySPITType *SPITPlayer::addSPITType_Playing(string p_SPITTypeID) {
|
||||||
PlaySPITType* ptrPlaySPITType;
|
PlaySPITType *ptrPlaySPITType;
|
||||||
|
|
||||||
auto i = m_PlaySPITTypes.find(p_SPITTypeID);
|
|
||||||
if (i == m_PlaySPITTypes.end()) {
|
|
||||||
ptrPlaySPITType = new PlaySPITType(this, p_SPITTypeID);
|
|
||||||
ptrPlaySPITType->setIsPlayed(true);
|
|
||||||
ptrPlaySPITType->setIsNew(true);
|
|
||||||
m_PlaySPITTypes[p_SPITTypeID] = ptrPlaySPITType;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ptrPlaySPITType = i->second;
|
|
||||||
ptrPlaySPITType->setIsPlayed(true);
|
|
||||||
}
|
|
||||||
return ptrPlaySPITType;
|
|
||||||
|
|
||||||
|
auto i = m_PlaySPITTypes.find(p_SPITTypeID);
|
||||||
|
if (i == m_PlaySPITTypes.end()) {
|
||||||
|
ptrPlaySPITType = new PlaySPITType(this, p_SPITTypeID);
|
||||||
|
ptrPlaySPITType->setIsPlayed(true);
|
||||||
|
ptrPlaySPITType->setIsNew(true);
|
||||||
|
m_PlaySPITTypes[p_SPITTypeID] = ptrPlaySPITType;
|
||||||
|
} else {
|
||||||
|
ptrPlaySPITType = i->second;
|
||||||
|
ptrPlaySPITType->setIsPlayed(true);
|
||||||
|
}
|
||||||
|
return ptrPlaySPITType;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SPITPlayer::startPlaySequence() {
|
void SPITPlayer::startPlaySequence() {
|
||||||
PlaySPITType* ptrPlaySPITType;
|
PlaySPITType *ptrPlaySPITType;
|
||||||
for (auto i = m_PlaySPITTypes.begin(); i != m_PlaySPITTypes.end(); i++) {
|
for (auto i = m_PlaySPITTypes.begin(); i != m_PlaySPITTypes.end(); i++) {
|
||||||
ptrPlaySPITType = i->second;
|
ptrPlaySPITType = i->second;
|
||||||
ptrPlaySPITType->startPlaySequence();
|
ptrPlaySPITType->startPlaySequence();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SPITPlayer::endPlaySequence() {
|
void SPITPlayer::endPlaySequence() {
|
||||||
PlaySPITType* ptrPlaySPITType;
|
PlaySPITType *ptrPlaySPITType;
|
||||||
|
|
||||||
for (auto i = m_PlaySPITTypes.begin(); i != m_PlaySPITTypes.end(); i++) {
|
|
||||||
ptrPlaySPITType = i->second;
|
|
||||||
if (ptrPlaySPITType->getIsPlayed() == false) {
|
|
||||||
i = m_PlaySPITTypes.erase(i);
|
|
||||||
delete ptrPlaySPITType;
|
|
||||||
if (i == m_PlaySPITTypes.end()) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
for (auto i = m_PlaySPITTypes.begin(); i != m_PlaySPITTypes.end(); i++) {
|
||||||
|
ptrPlaySPITType = i->second;
|
||||||
|
if (ptrPlaySPITType->getIsPlayed() == false) {
|
||||||
|
i = m_PlaySPITTypes.erase(i);
|
||||||
|
delete ptrPlaySPITType;
|
||||||
|
if (i == m_PlaySPITTypes.end()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SPITPlayer::PlaySPITType::PlaySPITType() {
|
SPITPlayer::PlaySPITType::PlaySPITType() {
|
||||||
}
|
}
|
||||||
SPITPlayer::PlaySPITType::PlaySPITType(SPITPlayer* p_SPITPlayer, string p_SPITTypeID) {
|
SPITPlayer::PlaySPITType::PlaySPITType(SPITPlayer *p_SPITPlayer, string p_SPITTypeID) {
|
||||||
m_SPITTypeID = p_SPITTypeID;
|
m_SPITTypeID = p_SPITTypeID;
|
||||||
m_PlayerID = p_SPITPlayer->getID();
|
m_PlayerID = p_SPITPlayer->getID();
|
||||||
m_PlayerName = p_SPITPlayer->getName();
|
m_PlayerName = p_SPITPlayer->getName();
|
||||||
startPlaySequence();
|
startPlaySequence();
|
||||||
m_IsNew = true;
|
m_IsNew = true;
|
||||||
}
|
}
|
||||||
SPITPlayer::PlaySPITType::PlaySPITType(const PlaySPITType& orig) {
|
SPITPlayer::PlaySPITType::PlaySPITType(const PlaySPITType &orig) {
|
||||||
m_SPITTypeID = orig.getSPITTypeID();
|
m_SPITTypeID = orig.getSPITTypeID();
|
||||||
m_IsPlayed = orig.getIsPlayed();
|
m_IsPlayed = orig.getIsPlayed();
|
||||||
m_IsNew = orig.getIsNew();
|
m_IsNew = orig.getIsNew();
|
||||||
|
|
||||||
m_PlayerID = orig.getPlayerID();
|
m_PlayerID = orig.getPlayerID();
|
||||||
m_PlayerName = orig.getPlayerName();
|
m_PlayerName = orig.getPlayerName();
|
||||||
m_PlayerRuns = orig.getPlayerIsRunning();
|
m_PlayerRuns = orig.getPlayerIsRunning();
|
||||||
|
|
||||||
m_Value = orig.getValue();
|
m_Value = orig.getValue();
|
||||||
}
|
}
|
||||||
void SPITPlayer::PlaySPITType::startPlaySequence() {
|
void SPITPlayer::PlaySPITType::startPlaySequence() {
|
||||||
m_IsPlayed = false;
|
m_IsPlayed = false;
|
||||||
m_IsNew = false;
|
m_IsNew = false;
|
||||||
|
|
||||||
m_Value = 0;
|
m_Value = 0;
|
||||||
}
|
}
|
||||||
@@ -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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -43,14 +43,14 @@ bool SPITSocket::createSocket_UDP() {
|
|||||||
} else {
|
} else {
|
||||||
intResult = setsockopt(m_UDPSocketIP4, SOL_SOCKET, SO_REUSEADDR, (void *)&intOptionValue4, sizeof(intOptionValue4));
|
intResult = setsockopt(m_UDPSocketIP4, SOL_SOCKET, SO_REUSEADDR, (void *)&intOptionValue4, sizeof(intOptionValue4));
|
||||||
}
|
}
|
||||||
if (intResult < 0) {
|
if (intResult < 0) {
|
||||||
boolSuccess = false;
|
boolSuccess = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (boolSuccess == true) {
|
if (boolSuccess == true) {
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
tv.tv_sec = 1; // seconds
|
tv.tv_sec = 1; // seconds
|
||||||
tv.tv_usec = 0; // microseconds (0.0 sec)
|
tv.tv_usec = 0; // microseconds (0.0 sec)
|
||||||
// This sets the receive timeout
|
// This sets the receive timeout
|
||||||
setsockopt(m_UDPSocketIP4, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
|
setsockopt(m_UDPSocketIP4, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
|
||||||
|
|
||||||
@@ -61,8 +61,8 @@ bool SPITSocket::createSocket_UDP() {
|
|||||||
// fcntl(m_UDPSocketIP4, F_SETFL, intFlags | O_NONBLOCK);
|
// fcntl(m_UDPSocketIP4, F_SETFL, intFlags | O_NONBLOCK);
|
||||||
|
|
||||||
// int intBufferSize = 2046 * 512;
|
// int intBufferSize = 2046 * 512;
|
||||||
// intResult = setsockopt(m_UDPSocketIP4, SOL_SOCKET, SO_RCVBUF, (void*)&intBufferSize, sizeof(intBufferSize));
|
// intResult = setsockopt(m_UDPSocketIP4, SOL_SOCKET, SO_RCVBUF, (void*)&intBufferSize, sizeof(intBufferSize));
|
||||||
// intResult = setsockopt(m_UDPSocketIP4, SOL_SOCKET, SO_SNDBUF, (void*)&intBufferSize, sizeof(intBufferSize));
|
// intResult = setsockopt(m_UDPSocketIP4, SOL_SOCKET, SO_SNDBUF, (void*)&intBufferSize, sizeof(intBufferSize));
|
||||||
}
|
}
|
||||||
return boolSuccess;
|
return boolSuccess;
|
||||||
}
|
}
|
||||||
@@ -187,7 +187,7 @@ int SPITSocket::sendMessageTo(int p_InetFamily, string p_ServerIP, string p_Serv
|
|||||||
if (intResult < 0) {
|
if (intResult < 0) {
|
||||||
printf("UnixSocket::sendMessageTo IP4 sendto %s FAILED %s\n", p_ServerIP.data(), strerror(errno));
|
printf("UnixSocket::sendMessageTo IP4 sendto %s FAILED %s\n", p_ServerIP.data(), strerror(errno));
|
||||||
printf("UnixSocket::sendMessageTo ret=%d %s / %s / %d\n", intResult,
|
printf("UnixSocket::sendMessageTo ret=%d %s / %s / %d\n", intResult,
|
||||||
p_ServerPort.data(), p_MessageBytes, p_MessageLength);
|
p_ServerPort.data(), p_MessageBytes, p_MessageLength);
|
||||||
}
|
}
|
||||||
freeaddrinfo(ptrAddressInfo);
|
freeaddrinfo(ptrAddressInfo);
|
||||||
}
|
}
|
||||||
@@ -196,23 +196,23 @@ int SPITSocket::sendMessageTo(int p_InetFamily, string p_ServerIP, string p_Serv
|
|||||||
intResult = -1;
|
intResult = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (intResult < 0) {
|
if (intResult < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Call this for receiving a message
|
* Call this for receiving a message
|
||||||
* This will block until a message is received or the underlying socket is closed
|
* This will block until a message is received or the underlying socket is closed
|
||||||
* @param p_InetFamily either AF_INET or AF_INET6<br>
|
* @param p_InetFamily either AF_INET or AF_INET6<br>
|
||||||
* The SPITSocket creates two udp sockets, one for IP4 and one for IP6
|
* The SPITSocket creates two udp sockets, one for IP4 and one for IP6
|
||||||
* This parameter decides from which socket should a message recieved
|
* This parameter decides from which socket should a message recieved
|
||||||
* @param p_Buffer the buffer containing the received message later.
|
* @param p_Buffer the buffer containing the received message later.
|
||||||
* @param p_BufferLength the size of the buffer
|
* @param p_BufferLength the size of the buffer
|
||||||
* @param p_ServerIP a pointer to a string, when a messages is received the string will contain the ip address of the sender/server
|
* @param p_ServerIP a pointer to a string, when a messages is received the string will contain the ip address of the sender/server
|
||||||
* if p_ServerIP is NULL - no detection of the server will be done.
|
* if p_ServerIP is NULL - no detection of the server will be done.
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
int SPITSocket::receiveMessage(int p_InetFamily, char *p_Buffer, int p_BufferLength, string *p_ServerIP) {
|
int SPITSocket::receiveMessage(int p_InetFamily, char *p_Buffer, int p_BufferLength, string *p_ServerIP) {
|
||||||
int intResult = -1;
|
int intResult = -1;
|
||||||
// ADDRINFO *AI;
|
// ADDRINFO *AI;
|
||||||
@@ -226,7 +226,7 @@ int SPITSocket::receiveMessage(int p_InetFamily, char *p_Buffer, int p_BufferLen
|
|||||||
}
|
}
|
||||||
intSocklen = sizeof(o_IP4SocketAddress);
|
intSocklen = sizeof(o_IP4SocketAddress);
|
||||||
memset(&o_IP4SocketAddress, 0, intSocklen);
|
memset(&o_IP4SocketAddress, 0, intSocklen);
|
||||||
intResult = recvfrom(m_UDPSocketIP4, (void *)p_Buffer, p_BufferLength, 0 , (sockaddr *)&o_IP4SocketAddress, (socklen_t *)&intSocklen);
|
intResult = recvfrom(m_UDPSocketIP4, (void *)p_Buffer, p_BufferLength, 0, (sockaddr *)&o_IP4SocketAddress, (socklen_t *)&intSocklen);
|
||||||
if (intResult >= 0) {
|
if (intResult >= 0) {
|
||||||
if (p_ServerIP != NULL) {
|
if (p_ServerIP != NULL) {
|
||||||
char bufferIP4[INET_ADDRSTRLEN];
|
char bufferIP4[INET_ADDRSTRLEN];
|
||||||
@@ -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;
|
||||||
@@ -261,12 +260,12 @@ SPITSocket::IPAddress SPITSocket::getAdaptersInfo() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
string createGUID() {
|
string createGUID() {
|
||||||
// uuid_t id;
|
// uuid_t id;
|
||||||
// uuid_generate(id);
|
// uuid_generate(id);
|
||||||
// char *guid_string = new char[100];
|
// char *guid_string = new char[100];
|
||||||
// uuid_unparse(id, guid_string);
|
// uuid_unparse(id, guid_string);
|
||||||
// string stringGUID = guid_string;
|
// string stringGUID = guid_string;
|
||||||
// return stringGUID;
|
// return stringGUID;
|
||||||
|
|
||||||
uuid_t uu;
|
uuid_t uu;
|
||||||
char uu_str[UUID_STR_LEN];
|
char uu_str[UUID_STR_LEN];
|
||||||
@@ -274,15 +273,16 @@ string createGUID() {
|
|||||||
uuid_generate(uu);
|
uuid_generate(uu);
|
||||||
uuid_unparse(uu, uu_str);
|
uuid_unparse(uu, uu_str);
|
||||||
string stringGUID = uu_str;
|
string stringGUID = uu_str;
|
||||||
return stringGUID;
|
return stringGUID;
|
||||||
}
|
}
|
||||||
/** The name of the client's host computer*/
|
/** The name of the client's host computer*/
|
||||||
string getClientHostName() {
|
string getClientHostName() {
|
||||||
string stringHostName = "";
|
string stringHostName = "";
|
||||||
const char * hostname;
|
const char *hostname;
|
||||||
esp_netif_get_hostname(esp_netif_get_default_netif(), &hostname);
|
esp_netif_get_hostname(esp_netif_get_default_netif(), &hostname);
|
||||||
if (hostname != nullptr) {
|
if (hostname != nullptr) {
|
||||||
stringHostName = hostname;
|
stringHostName = hostname;
|
||||||
}
|
}
|
||||||
return stringHostName;;
|
return stringHostName;
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|||||||
+408
-400
@@ -12,439 +12,447 @@
|
|||||||
* 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"
|
||||||
|
|
||||||
static const char * TAG = "SPIT";
|
static const char *TAG = "SPIT";
|
||||||
|
|
||||||
unordered_map<string, SPITType*> SPITType::s_SPITTypes;
|
unordered_map<string, SPITType *> SPITType::s_SPITTypes;
|
||||||
unordered_map<string, SPITType*> SPITType::s_SPITTypesRemote;
|
unordered_map<string, SPITType *> SPITType::s_SPITTypesRemote;
|
||||||
|
|
||||||
SPITType* SPITType::getSPITType(string p_ID) {
|
SPITType *SPITType::getSPITType(string p_ID) {
|
||||||
{
|
{
|
||||||
auto i = s_SPITTypes.find(p_ID);
|
auto i = s_SPITTypes.find(p_ID);
|
||||||
if (i == s_SPITTypes.end()) {
|
if (i == s_SPITTypes.end()) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return i->second;
|
return i->second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Returns the reference of the SPITType with ID == p_ID.<br>
|
* Returns the reference of the SPITType with ID == p_ID.<br>
|
||||||
* Throws an exception if no SPITType is not found.<br>
|
* Throws an exception if no SPITType is not found.<br>
|
||||||
* @param p_ID the ID
|
* @param p_ID the ID
|
||||||
* @return reference of the SPITType with ID == p_ID
|
* @return reference of the SPITType with ID == p_ID
|
||||||
*/
|
*/
|
||||||
const SPITType& SPITType::getSPITTypeRef(string p_ID) {
|
const SPITType &SPITType::getSPITTypeRef(string p_ID) {
|
||||||
{
|
{
|
||||||
auto i = s_SPITTypes.find(p_ID);
|
auto i = s_SPITTypes.find(p_ID);
|
||||||
if (i == s_SPITTypes.end()) {
|
if (i == s_SPITTypes.end()) {
|
||||||
throw "SPITType no SPITType with given ID";
|
throw "SPITType no SPITType with given ID";
|
||||||
}
|
}
|
||||||
return *(i->second);
|
return *(i->second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SPITType* SPITType::getSPITTypeRemote(string p_ID) {
|
SPITType *SPITType::getSPITTypeRemote(string p_ID) {
|
||||||
{
|
{
|
||||||
auto i = s_SPITTypesRemote.find(p_ID);
|
auto i = s_SPITTypesRemote.find(p_ID);
|
||||||
if (i == s_SPITTypesRemote.end()) {
|
if (i == s_SPITTypesRemote.end()) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return i->second;
|
return i->second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Returns the reference of the remote SPITType with ID == p_ID.<br>
|
* Returns the reference of the remote SPITType with ID == p_ID.<br>
|
||||||
* Throws an exception if no SPITType is not found.<br>
|
* Throws an exception if no SPITType is not found.<br>
|
||||||
* @param p_ID the ID
|
* @param p_ID the ID
|
||||||
* @return reference of the SPITType with ID == p_ID
|
* @return reference of the SPITType with ID == p_ID
|
||||||
*/
|
*/
|
||||||
const SPITType& SPITType::getSPITTypeRemoteRef(string p_ID) {
|
const SPITType &SPITType::getSPITTypeRemoteRef(string p_ID) {
|
||||||
{
|
{
|
||||||
auto i = s_SPITTypesRemote.find(p_ID);
|
auto i = s_SPITTypesRemote.find(p_ID);
|
||||||
if (i == s_SPITTypesRemote.end()) {
|
if (i == s_SPITTypesRemote.end()) {
|
||||||
throw "Remote SPITType no SPITType with given ID";
|
throw "Remote SPITType no SPITType with given ID";
|
||||||
}
|
}
|
||||||
return *(i->second);
|
return *(i->second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SPITType::addSPITType(SPITType* p_ptrSpitType) {
|
|
||||||
if (p_ptrSpitType == NULL) return false;
|
|
||||||
{
|
|
||||||
s_SPITTypes[p_ptrSpitType->getID()] = p_ptrSpitType;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bool SPITType::addSPITTypeRemote(SPITType* p_ptrSpitType) {
|
|
||||||
if (p_ptrSpitType == NULL) return false;
|
|
||||||
{
|
|
||||||
s_SPITTypesRemote[p_ptrSpitType->getID()] = p_ptrSpitType;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bool SPITType::removeSPITType(SPITType* p_ptrSpitType) {
|
|
||||||
if (p_ptrSpitType == NULL) return false;
|
|
||||||
{
|
|
||||||
auto i = s_SPITTypes.find(p_ptrSpitType->getID());
|
|
||||||
if (i == s_SPITTypes.end()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
i = s_SPITTypes.erase(i);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bool SPITType::removeSPITTypeRemote(SPITType* p_ptrSpitType) {
|
|
||||||
if (p_ptrSpitType == NULL) return false;
|
|
||||||
{
|
|
||||||
auto i = s_SPITTypesRemote.find(p_ptrSpitType->getID());
|
|
||||||
if (i == s_SPITTypesRemote.end()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
i = s_SPITTypesRemote.erase(i);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int SPITType::getSPITTypeCount() {
|
|
||||||
return s_SPITTypes.size();
|
|
||||||
}
|
|
||||||
int SPITType::getSPITTypeRemoteCount() {
|
|
||||||
return s_SPITTypesRemote.size();
|
|
||||||
}
|
|
||||||
SPITType* SPITType::getSPITType(int p_Index) {
|
|
||||||
SPITType* ptrSPITType = NULL;
|
|
||||||
{
|
|
||||||
if (p_Index < s_SPITTypes.size()) {
|
|
||||||
unordered_map<string, SPITType*>::iterator i = next(s_SPITTypes.begin(), p_Index);
|
|
||||||
ptrSPITType = i->second;
|
|
||||||
}
|
|
||||||
return ptrSPITType;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Returns a reference to the SPITType at position p_Index.<br>
|
|
||||||
* Throws an exception if p_Index is out of range.<br>
|
|
||||||
* @param p_Index position
|
|
||||||
* @return the reference of the SPITType at position.
|
|
||||||
*/
|
|
||||||
const SPITType& SPITType::getSPITTypeRef(int p_Index) {
|
|
||||||
SPITType* ptrSPITType = NULL;
|
|
||||||
{
|
|
||||||
if (p_Index >= 0 && p_Index < s_SPITTypes.size()) {
|
|
||||||
unordered_map<string, SPITType*>::iterator i = next(s_SPITTypes.begin(), p_Index);
|
|
||||||
ptrSPITType = i->second;
|
|
||||||
return *ptrSPITType;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw "SPITType index out of range";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
SPITType* SPITType::getSPITTypeRemote(int p_Index) {
|
|
||||||
SPITType* ptrSPITType = NULL;
|
|
||||||
{
|
|
||||||
if (p_Index < s_SPITTypesRemote.size()) {
|
|
||||||
unordered_map<string, SPITType*>::iterator i = next(s_SPITTypesRemote.begin(), p_Index);
|
|
||||||
ptrSPITType = i->second;
|
|
||||||
}
|
|
||||||
return ptrSPITType;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Returns a reference to the remote SPITType at position p_Index.<br>
|
|
||||||
* Throws an exception if p_Index is out of range.<br>
|
|
||||||
* @param p_Index position
|
|
||||||
* @return the reference of the SPITType at position.
|
|
||||||
*/
|
|
||||||
const SPITType& SPITType::getSPITTypeRemoteRef(int p_Index) {
|
|
||||||
SPITType* ptrSPITType = NULL;
|
|
||||||
{
|
|
||||||
if (p_Index >= 0 && p_Index < s_SPITTypesRemote.size()) {
|
|
||||||
unordered_map<string, SPITType*>::iterator i = next(s_SPITTypesRemote.begin(), p_Index);
|
|
||||||
ptrSPITType = i->second;
|
|
||||||
return *ptrSPITType;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw "Remote SPITType index out of range";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void SPITType::clearSPITTypes() {
|
|
||||||
SPITType* ptrSPITType;
|
|
||||||
{
|
|
||||||
for (auto i = s_SPITTypes.begin(); i != s_SPITTypes.end(); i++) {
|
|
||||||
ptrSPITType = i->second;
|
|
||||||
i = s_SPITTypes.erase(i);
|
|
||||||
delete ptrSPITType;
|
|
||||||
if (i == s_SPITTypes.end()) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void SPITType::clearSPITTypesRemote() {
|
|
||||||
SPITType* ptrSPITType;
|
|
||||||
{
|
|
||||||
for (auto i = s_SPITTypesRemote.begin(); i != s_SPITTypesRemote.end(); i++) {
|
|
||||||
ptrSPITType = i->second;
|
|
||||||
i = s_SPITTypesRemote.erase(i);
|
|
||||||
delete ptrSPITType;
|
|
||||||
if (i == s_SPITTypesRemote.end()) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void SPITType::eventProjectClosed() {
|
|
||||||
SPITType* ptrSPITType;
|
|
||||||
for (auto i = s_SPITTypes.begin(); i != s_SPITTypes.end(); i++) {
|
|
||||||
ptrSPITType = i->second;
|
|
||||||
if (ptrSPITType->getCreatedByClient() == true) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
i = s_SPITTypes.erase(i);
|
|
||||||
delete ptrSPITType;
|
|
||||||
if (i == s_SPITTypes.end()) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//Remote
|
|
||||||
for (auto i = s_SPITTypesRemote.begin(); i != s_SPITTypesRemote.end(); i++) {
|
|
||||||
ptrSPITType = i->second;
|
|
||||||
i = s_SPITTypesRemote.erase(i);
|
|
||||||
delete ptrSPITType;
|
|
||||||
if (i == s_SPITTypesRemote.end()) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets confirmed = false for all SPITTypes.<br>
|
|
||||||
* This should be called when the client has loaded a project.<br>
|
|
||||||
*/
|
|
||||||
void SPITType::setConfirmedFalse() {
|
|
||||||
SPITType* ptrSPITType;
|
|
||||||
{
|
|
||||||
for (auto i = s_SPITTypes.begin(); i != s_SPITTypes.end(); i++) {
|
|
||||||
ptrSPITType = i->second;
|
|
||||||
ptrSPITType->setConfirmed(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
bool SPITType::addSPITType(SPITType *p_ptrSpitType) {
|
||||||
|
if (p_ptrSpitType == NULL)
|
||||||
|
return false;
|
||||||
|
{
|
||||||
|
s_SPITTypes[p_ptrSpitType->getID()] = p_ptrSpitType;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bool SPITType::addSPITTypeRemote(SPITType *p_ptrSpitType) {
|
||||||
|
if (p_ptrSpitType == NULL)
|
||||||
|
return false;
|
||||||
|
{
|
||||||
|
s_SPITTypesRemote[p_ptrSpitType->getID()] = p_ptrSpitType;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bool SPITType::removeSPITType(SPITType *p_ptrSpitType) {
|
||||||
|
if (p_ptrSpitType == NULL)
|
||||||
|
return false;
|
||||||
|
{
|
||||||
|
auto i = s_SPITTypes.find(p_ptrSpitType->getID());
|
||||||
|
if (i == s_SPITTypes.end()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
i = s_SPITTypes.erase(i);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bool SPITType::removeSPITTypeRemote(SPITType *p_ptrSpitType) {
|
||||||
|
if (p_ptrSpitType == NULL)
|
||||||
|
return false;
|
||||||
|
{
|
||||||
|
auto i = s_SPITTypesRemote.find(p_ptrSpitType->getID());
|
||||||
|
if (i == s_SPITTypesRemote.end()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
i = s_SPITTypesRemote.erase(i);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int SPITType::getSPITTypeCount() {
|
||||||
|
return s_SPITTypes.size();
|
||||||
|
}
|
||||||
|
int SPITType::getSPITTypeRemoteCount() {
|
||||||
|
return s_SPITTypesRemote.size();
|
||||||
|
}
|
||||||
|
SPITType *SPITType::getSPITType(int p_Index) {
|
||||||
|
SPITType *ptrSPITType = NULL;
|
||||||
|
{
|
||||||
|
if (p_Index < s_SPITTypes.size()) {
|
||||||
|
unordered_map<string, SPITType *>::iterator i = next(s_SPITTypes.begin(), p_Index);
|
||||||
|
ptrSPITType = i->second;
|
||||||
|
}
|
||||||
|
return ptrSPITType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Returns a reference to the SPITType at position p_Index.<br>
|
||||||
|
* Throws an exception if p_Index is out of range.<br>
|
||||||
|
* @param p_Index position
|
||||||
|
* @return the reference of the SPITType at position.
|
||||||
|
*/
|
||||||
|
const SPITType &SPITType::getSPITTypeRef(int p_Index) {
|
||||||
|
SPITType *ptrSPITType = NULL;
|
||||||
|
{
|
||||||
|
if (p_Index >= 0 && p_Index < s_SPITTypes.size()) {
|
||||||
|
unordered_map<string, SPITType *>::iterator i = next(s_SPITTypes.begin(), p_Index);
|
||||||
|
ptrSPITType = i->second;
|
||||||
|
return *ptrSPITType;
|
||||||
|
} else {
|
||||||
|
throw "SPITType index out of range";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SPITType *SPITType::getSPITTypeRemote(int p_Index) {
|
||||||
|
SPITType *ptrSPITType = NULL;
|
||||||
|
{
|
||||||
|
if (p_Index < s_SPITTypesRemote.size()) {
|
||||||
|
unordered_map<string, SPITType *>::iterator i = next(s_SPITTypesRemote.begin(), p_Index);
|
||||||
|
ptrSPITType = i->second;
|
||||||
|
}
|
||||||
|
return ptrSPITType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Returns a reference to the remote SPITType at position p_Index.<br>
|
||||||
|
* Throws an exception if p_Index is out of range.<br>
|
||||||
|
* @param p_Index position
|
||||||
|
* @return the reference of the SPITType at position.
|
||||||
|
*/
|
||||||
|
const SPITType &SPITType::getSPITTypeRemoteRef(int p_Index) {
|
||||||
|
SPITType *ptrSPITType = NULL;
|
||||||
|
{
|
||||||
|
if (p_Index >= 0 && p_Index < s_SPITTypesRemote.size()) {
|
||||||
|
unordered_map<string, SPITType *>::iterator i = next(s_SPITTypesRemote.begin(), p_Index);
|
||||||
|
ptrSPITType = i->second;
|
||||||
|
return *ptrSPITType;
|
||||||
|
} else {
|
||||||
|
throw "Remote SPITType index out of range";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SPITType::clearSPITTypes() {
|
||||||
|
SPITType *ptrSPITType;
|
||||||
|
{
|
||||||
|
for (auto i = s_SPITTypes.begin(); i != s_SPITTypes.end(); i++) {
|
||||||
|
ptrSPITType = i->second;
|
||||||
|
i = s_SPITTypes.erase(i);
|
||||||
|
delete ptrSPITType;
|
||||||
|
if (i == s_SPITTypes.end()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void SPITType::clearSPITTypesRemote() {
|
||||||
|
SPITType *ptrSPITType;
|
||||||
|
{
|
||||||
|
for (auto i = s_SPITTypesRemote.begin(); i != s_SPITTypesRemote.end(); i++) {
|
||||||
|
ptrSPITType = i->second;
|
||||||
|
i = s_SPITTypesRemote.erase(i);
|
||||||
|
delete ptrSPITType;
|
||||||
|
if (i == s_SPITTypesRemote.end()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SPITType::eventProjectClosed() {
|
||||||
|
SPITType *ptrSPITType;
|
||||||
|
for (auto i = s_SPITTypes.begin(); i != s_SPITTypes.end(); i++) {
|
||||||
|
ptrSPITType = i->second;
|
||||||
|
if (ptrSPITType->getCreatedByClient() == true) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
i = s_SPITTypes.erase(i);
|
||||||
|
delete ptrSPITType;
|
||||||
|
if (i == s_SPITTypes.end()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Remote
|
||||||
|
for (auto i = s_SPITTypesRemote.begin(); i != s_SPITTypesRemote.end(); i++) {
|
||||||
|
ptrSPITType = i->second;
|
||||||
|
i = s_SPITTypesRemote.erase(i);
|
||||||
|
delete ptrSPITType;
|
||||||
|
if (i == s_SPITTypesRemote.end()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets confirmed = false for all SPITTypes.<br>
|
||||||
|
* This should be called when the client has loaded a project.<br>
|
||||||
|
*/
|
||||||
|
void SPITType::setConfirmedFalse() {
|
||||||
|
SPITType *ptrSPITType;
|
||||||
|
{
|
||||||
|
for (auto i = s_SPITTypes.begin(); i != s_SPITTypes.end(); i++) {
|
||||||
|
ptrSPITType = i->second;
|
||||||
|
ptrSPITType->setConfirmed(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SPITType::SPITType() {
|
SPITType::SPITType() {
|
||||||
initMembers();
|
initMembers();
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
SPITType::SPITType(const SPITType& orig) {
|
SPITType::SPITType(const SPITType& orig) {
|
||||||
m_Confirmed = orig.getConfirmed();
|
m_Confirmed = orig.getConfirmed();
|
||||||
m_DefaultDelay = orig.getDefaultDelay();
|
m_DefaultDelay = orig.getDefaultDelay();
|
||||||
m_DefaultDuration = orig.getDefaultDuration();
|
m_DefaultDuration = orig.getDefaultDuration();
|
||||||
m_Fixed = orig.getFixed();
|
m_Fixed = orig.getFixed();
|
||||||
m_GroupName = orig.getGroupName();
|
m_GroupName = orig.getGroupName();
|
||||||
m_ID = orig.getID();
|
m_ID = orig.getID();
|
||||||
m_Name = orig.getName();
|
m_Name = orig.getName();
|
||||||
m_ServerProjectIndepended = orig.getProjectIndepended();
|
m_ServerProjectIndepended = orig.getProjectIndepended();
|
||||||
m_ServerRemote = orig.getServerRemote();
|
m_ServerRemote = orig.getServerRemote();
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
SPITType::SPITType(string p_ID, string p_GroupName, string p_Name, bool p_Fixed, bool p_ProjectIndepended,long long p_DefaultDelay, long long p_DefaultDuration) {
|
SPITType::SPITType(string p_ID, string p_GroupName, string p_Name, bool p_Fixed, bool p_ProjectIndepended, long long p_DefaultDelay, long long p_DefaultDuration) {
|
||||||
initMembers();
|
initMembers();
|
||||||
m_ActionAssigned = false;
|
m_ActionAssigned = false;
|
||||||
m_Confirmed = false;
|
m_Confirmed = false;
|
||||||
m_ID = p_ID;
|
m_ID = p_ID;
|
||||||
m_GroupName = p_GroupName;
|
m_GroupName = p_GroupName;
|
||||||
m_Name = p_Name;
|
m_Name = p_Name;
|
||||||
m_Fixed = p_Fixed;
|
m_Fixed = p_Fixed;
|
||||||
m_ServerProjectIndepended = p_ProjectIndepended;
|
m_ServerProjectIndepended = p_ProjectIndepended;
|
||||||
m_DefaultDelay = p_DefaultDelay;
|
m_DefaultDelay = p_DefaultDelay;
|
||||||
m_DefaultDuration = p_DefaultDuration;
|
m_DefaultDuration = p_DefaultDuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
SPITType::~SPITType() {
|
SPITType::~SPITType() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SPITType::initMembers() {
|
void SPITType::initMembers() {
|
||||||
m_Confirmed = false;
|
m_Confirmed = false;
|
||||||
m_DefaultDelay = 0;
|
m_DefaultDelay = 0;
|
||||||
m_DefaultDuration = 0;
|
m_DefaultDuration = 0;
|
||||||
m_Fixed = false;
|
m_Fixed = false;
|
||||||
m_GroupName = "";
|
m_GroupName = "";
|
||||||
m_ID = createGUID();
|
m_ID = createGUID();
|
||||||
m_Name = "";
|
m_Name = "";
|
||||||
m_ServerProjectIndepended = false;
|
m_ServerProjectIndepended = false;
|
||||||
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) {
|
||||||
|
m_ID = p_ID;
|
||||||
|
}
|
||||||
|
|
||||||
void SPITType::setID(string p_ID) {
|
/**
|
||||||
m_ID = p_ID;
|
* This is used by the server and client to tell if the other side has registered the changes.
|
||||||
}
|
* @param p_Confirmed
|
||||||
|
* @return if m_Confirmed has changed
|
||||||
|
*/
|
||||||
|
bool SPITType::setConfirmed(bool p_Confirmed) {
|
||||||
|
if (m_Confirmed == p_Confirmed)
|
||||||
|
return false;
|
||||||
|
m_Confirmed = p_Confirmed;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
bool SPITType::setGroupName(string p_GroupName) {
|
||||||
* This is used by the server and client to tell if the other side has registered the changes.
|
if (m_GroupName == p_GroupName)
|
||||||
* @param p_Confirmed
|
return false;
|
||||||
* @return if m_Confirmed has changed
|
m_GroupName = p_GroupName;
|
||||||
*/
|
m_Confirmed = false;
|
||||||
bool SPITType::setConfirmed(bool p_Confirmed) {
|
return true;
|
||||||
if (m_Confirmed == p_Confirmed) return false;
|
}
|
||||||
m_Confirmed = p_Confirmed;
|
bool SPITType::setName(string p_Name) {
|
||||||
return true;
|
if (m_Name == p_Name)
|
||||||
}
|
return false;
|
||||||
|
m_Name = p_Name;
|
||||||
|
m_Confirmed = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool SPITType::setServerRemote(bool p_BelongstoServer) {
|
||||||
|
if (m_ServerRemote == p_BelongstoServer)
|
||||||
|
return false;
|
||||||
|
m_ServerRemote = p_BelongstoServer;
|
||||||
|
m_Confirmed = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool SPITType::setProjectIndepended(bool p_ProjectIndepended) {
|
||||||
|
if (m_ServerProjectIndepended == p_ProjectIndepended)
|
||||||
|
return false;
|
||||||
|
m_ServerProjectIndepended = p_ProjectIndepended;
|
||||||
|
m_Confirmed = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool SPITType::setFixed(bool p_Fixed) {
|
||||||
|
if (m_Fixed == p_Fixed)
|
||||||
|
return false;
|
||||||
|
m_Fixed = p_Fixed;
|
||||||
|
m_Confirmed = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool SPITType::setDefaultDelay(long long p_Delay) {
|
||||||
|
if (m_DefaultDelay == p_Delay)
|
||||||
|
return false;
|
||||||
|
m_DefaultDelay = p_Delay;
|
||||||
|
m_Confirmed = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool SPITType::setDefaultDuration(long long p_Duration) {
|
||||||
|
if (m_DefaultDuration == p_Duration)
|
||||||
|
return false;
|
||||||
|
m_DefaultDuration = p_Duration;
|
||||||
|
m_Confirmed = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool SPITType::setGroupName(string p_GroupName) {
|
/**
|
||||||
if (m_GroupName == p_GroupName) return false;
|
* Virtual construct - means ActionAssigned for SPITTypes is is not implemented in SPITProtocol.<br>
|
||||||
m_GroupName = p_GroupName;
|
* This can used to setActionAssigned to all SPITObjects with this SPITType.<br>
|
||||||
m_Confirmed = false;
|
* This may be used in the case when the same action should be done for every SPITObject with this SPITType associated.<br>
|
||||||
return true;
|
* @return true = the m_ActionAssigned has changed.
|
||||||
}
|
*/
|
||||||
bool SPITType::setName(string p_Name) {
|
bool SPITType::setActionAssigned(bool p_ActionAssigned) {
|
||||||
if (m_Name == p_Name) return false;
|
if (m_ActionAssigned == p_ActionAssigned)
|
||||||
m_Name = p_Name;
|
return false;
|
||||||
m_Confirmed = false;
|
m_ActionAssigned = p_ActionAssigned;
|
||||||
return true;
|
m_Confirmed = false;
|
||||||
}
|
return true;
|
||||||
bool SPITType::setServerRemote(bool p_BelongstoServer) {
|
}
|
||||||
if (m_ServerRemote == p_BelongstoServer) return false;
|
|
||||||
m_ServerRemote = p_BelongstoServer;
|
|
||||||
m_Confirmed = false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
bool SPITType::setProjectIndepended(bool p_ProjectIndepended) {
|
|
||||||
if (m_ServerProjectIndepended == p_ProjectIndepended) return false;
|
|
||||||
m_ServerProjectIndepended = p_ProjectIndepended;
|
|
||||||
m_Confirmed = false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
bool SPITType::setFixed(bool p_Fixed) {
|
|
||||||
if (m_Fixed == p_Fixed) return false;
|
|
||||||
m_Fixed = p_Fixed;
|
|
||||||
m_Confirmed = false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
bool SPITType::setDefaultDelay(long long p_Delay) {
|
|
||||||
if (m_DefaultDelay == p_Delay) return false;
|
|
||||||
m_DefaultDelay = p_Delay;
|
|
||||||
m_Confirmed = false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
bool SPITType::setDefaultDuration(long long p_Duration) {
|
|
||||||
if (m_DefaultDuration == p_Duration) return false;
|
|
||||||
m_DefaultDuration = p_Duration;
|
|
||||||
m_Confirmed = false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Virtual construct - means ActionAssigned for SPITTypes is is not implemented in SPITProtocol.<br>
|
* Set the content of the SPITType as received from the server
|
||||||
* This can used to setActionAssigned to all SPITObjects with this SPITType.<br>
|
* @param p_ReportSPITType
|
||||||
* This may be used in the case when the same action should be done for every SPITObject with this SPITType associated.<br>
|
* @return true = the SPITType is changed<br>
|
||||||
* @return true = the m_ActionAssigned has changed.
|
* false = the SPITType is NOT changed, because it is not allowed to change.
|
||||||
*/
|
*/
|
||||||
bool SPITType::setActionAssigned(bool p_ActionAssigned) {
|
bool SPITType::setMessageOP(SPIT_Message::ReportSPITType *p_ReportSPITType) {
|
||||||
if (m_ActionAssigned == p_ActionAssigned) return false;
|
bool boolChangeAllowed;
|
||||||
m_ActionAssigned = p_ActionAssigned;
|
bool boolChanged = false;
|
||||||
m_Confirmed = false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
if (m_CreatedByClient == true && m_Fixed == true) {
|
||||||
* Set the content of the SPITType as received from the server
|
boolChangeAllowed = false;
|
||||||
* @param p_ReportSPITType
|
} else {
|
||||||
* @return true = the SPITType is changed<br>
|
boolChangeAllowed = true;
|
||||||
* false = the SPITType is NOT changed, because it is not allowed to change.
|
}
|
||||||
*/
|
|
||||||
bool SPITType::setMessageOP(SPIT_Message::ReportSPITType* p_ReportSPITType) {
|
|
||||||
bool boolChangeAllowed;
|
|
||||||
bool boolChanged = false;
|
|
||||||
|
|
||||||
if (m_CreatedByClient == true && m_Fixed == true) {
|
// Confirmation should be changable
|
||||||
boolChangeAllowed = false;
|
if (m_CreatedByClient) {
|
||||||
}
|
// Server reports a client created SPITType -> the type is confirmed
|
||||||
else {
|
m_Confirmed = true;
|
||||||
boolChangeAllowed = true;
|
} else {
|
||||||
}
|
// type is NOT client created -> the client has to confirm the SPITtype
|
||||||
|
m_Confirmed = p_ReportSPITType->getConfirmed();
|
||||||
|
}
|
||||||
|
if (m_DefaultDelay != p_ReportSPITType->getDelay()) {
|
||||||
|
if (boolChangeAllowed == false)
|
||||||
|
throw new exception();
|
||||||
|
m_DefaultDelay = p_ReportSPITType->getDelay();
|
||||||
|
boolChanged = true;
|
||||||
|
}
|
||||||
|
if (m_DefaultDuration != p_ReportSPITType->getDuration()) {
|
||||||
|
if (boolChangeAllowed == false)
|
||||||
|
throw new exception();
|
||||||
|
m_DefaultDuration = p_ReportSPITType->getDuration();
|
||||||
|
boolChanged = true;
|
||||||
|
}
|
||||||
|
if (m_Fixed != p_ReportSPITType->getFixed()) {
|
||||||
|
if (boolChangeAllowed == false)
|
||||||
|
throw new exception();
|
||||||
|
m_Fixed = p_ReportSPITType->getFixed();
|
||||||
|
boolChanged = true;
|
||||||
|
}
|
||||||
|
if (m_GroupName != p_ReportSPITType->getGroupName()) {
|
||||||
|
if (boolChangeAllowed == false)
|
||||||
|
throw new exception();
|
||||||
|
m_GroupName = p_ReportSPITType->getGroupName();
|
||||||
|
boolChanged = true;
|
||||||
|
}
|
||||||
|
if (m_ID != p_ReportSPITType->getID()) {
|
||||||
|
if (boolChangeAllowed == false)
|
||||||
|
throw new exception();
|
||||||
|
m_ID = p_ReportSPITType->getID();
|
||||||
|
boolChanged = true;
|
||||||
|
}
|
||||||
|
if (m_Name != p_ReportSPITType->getName()) {
|
||||||
|
if (boolChangeAllowed == false)
|
||||||
|
throw new exception();
|
||||||
|
m_Name = p_ReportSPITType->getName();
|
||||||
|
boolChanged = true;
|
||||||
|
}
|
||||||
|
if (m_ServerProjectIndepended != p_ReportSPITType->getServerProjectIndepended()) {
|
||||||
|
if (boolChangeAllowed == false)
|
||||||
|
throw new exception();
|
||||||
|
m_ServerProjectIndepended = p_ReportSPITType->getServerProjectIndepended();
|
||||||
|
boolChanged = true;
|
||||||
|
}
|
||||||
|
if (m_ServerRemote != p_ReportSPITType->getServerRemote()) {
|
||||||
|
if (boolChangeAllowed == false)
|
||||||
|
throw new exception();
|
||||||
|
m_ServerRemote = p_ReportSPITType->getServerRemote();
|
||||||
|
boolChanged = true;
|
||||||
|
}
|
||||||
|
return boolChanged;
|
||||||
|
}
|
||||||
|
|
||||||
//Confirmation should be changable
|
void SPITType::fillMessageOP(SPIT_Message::ReportSPITType *ptrSMReportSPITType) {
|
||||||
if (m_CreatedByClient) {
|
ptrSMReportSPITType->setConfirmed(m_Confirmed);
|
||||||
//Server reports a client created SPITType -> the type is confirmed
|
ptrSMReportSPITType->setDelay(m_DefaultDelay);
|
||||||
m_Confirmed = true;
|
ptrSMReportSPITType->setDuration(m_DefaultDuration);
|
||||||
}
|
ptrSMReportSPITType->setFixed(m_Fixed);
|
||||||
else {
|
ptrSMReportSPITType->setGroupName(m_GroupName);
|
||||||
//type is NOT client created -> the client has to confirm the SPITtype
|
ptrSMReportSPITType->setID(m_ID);
|
||||||
m_Confirmed = p_ReportSPITType->getConfirmed();
|
ptrSMReportSPITType->setName(m_Name);
|
||||||
}
|
ptrSMReportSPITType->setServerProjectIndepended(m_ServerProjectIndepended);
|
||||||
if (m_DefaultDelay != p_ReportSPITType->getDelay()) {
|
ptrSMReportSPITType->setServerRemote(m_ServerRemote);
|
||||||
if (boolChangeAllowed == false) throw new exception();
|
}
|
||||||
m_DefaultDelay = p_ReportSPITType->getDelay();
|
void SPITType::fillMessageOP(SPIT_Message::RemoveSPITType *ptrSMRemoveSPITType) {
|
||||||
boolChanged = true;
|
ptrSMRemoveSPITType->setID(m_ID);
|
||||||
}
|
}
|
||||||
if (m_DefaultDuration != p_ReportSPITType->getDuration()) {
|
|
||||||
if (boolChangeAllowed == false) throw new exception();
|
|
||||||
m_DefaultDuration = p_ReportSPITType->getDuration();
|
|
||||||
boolChanged = true;
|
|
||||||
}
|
|
||||||
if (m_Fixed != p_ReportSPITType->getFixed()) {
|
|
||||||
if (boolChangeAllowed == false) throw new exception();
|
|
||||||
m_Fixed = p_ReportSPITType->getFixed();
|
|
||||||
boolChanged = true;
|
|
||||||
}
|
|
||||||
if (m_GroupName != p_ReportSPITType->getGroupName()) {
|
|
||||||
if (boolChangeAllowed == false) throw new exception();
|
|
||||||
m_GroupName = p_ReportSPITType->getGroupName();
|
|
||||||
boolChanged = true;
|
|
||||||
}
|
|
||||||
if (m_ID != p_ReportSPITType->getID()) {
|
|
||||||
if (boolChangeAllowed == false) throw new exception();
|
|
||||||
m_ID = p_ReportSPITType->getID();
|
|
||||||
boolChanged = true;
|
|
||||||
}
|
|
||||||
if (m_Name != p_ReportSPITType->getName()) {
|
|
||||||
if (boolChangeAllowed == false) throw new exception();
|
|
||||||
m_Name = p_ReportSPITType->getName();
|
|
||||||
boolChanged = true;
|
|
||||||
}
|
|
||||||
if (m_ServerProjectIndepended != p_ReportSPITType->getServerProjectIndepended()) {
|
|
||||||
if (boolChangeAllowed == false) throw new exception();
|
|
||||||
m_ServerProjectIndepended = p_ReportSPITType->getServerProjectIndepended();
|
|
||||||
boolChanged = true;
|
|
||||||
}
|
|
||||||
if (m_ServerRemote != p_ReportSPITType->getServerRemote()) {
|
|
||||||
if (boolChangeAllowed == false) throw new exception();
|
|
||||||
m_ServerRemote = p_ReportSPITType->getServerRemote();
|
|
||||||
boolChanged = true;
|
|
||||||
}
|
|
||||||
return boolChanged;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SPITType::fillMessageOP(SPIT_Message::ReportSPITType* ptrSMReportSPITType) {
|
|
||||||
ptrSMReportSPITType->setConfirmed(m_Confirmed);
|
|
||||||
ptrSMReportSPITType->setDelay(m_DefaultDelay);
|
|
||||||
ptrSMReportSPITType->setDuration(m_DefaultDuration);
|
|
||||||
ptrSMReportSPITType->setFixed(m_Fixed);
|
|
||||||
ptrSMReportSPITType->setGroupName(m_GroupName);
|
|
||||||
ptrSMReportSPITType->setID(m_ID);
|
|
||||||
ptrSMReportSPITType->setName(m_Name);
|
|
||||||
ptrSMReportSPITType->setServerProjectIndepended(m_ServerProjectIndepended);
|
|
||||||
ptrSMReportSPITType->setServerRemote(m_ServerRemote);
|
|
||||||
}
|
|
||||||
void SPITType::fillMessageOP(SPIT_Message::RemoveSPITType* ptrSMRemoveSPITType) {
|
|
||||||
ptrSMRemoveSPITType->setID(m_ID);
|
|
||||||
}
|
|
||||||
|
|||||||
+1121
-1158
File diff suppressed because it is too large
Load Diff
+1750
-1690
File diff suppressed because it is too large
Load Diff
+355
-12
@@ -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,20 +657,322 @@ 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,
|
||||||
|
});
|
||||||
|
|
||||||
while (true) {
|
for (auto &obj : ProvidedObj) {
|
||||||
fos::Task::delayMs(10000);
|
SPITType *ptrSPITType1Fix = spitClient.createSPITTypeFixed(obj.iD, obj.groupName, obj.name, 0, 0);
|
||||||
ESP_LOGI(TAG, "Test LiveShow");
|
spitClient.setActionSPITType(ptrSPITType1Fix->getID(), true); // should be executed whenever a SPITObject with this SPITType is played
|
||||||
ptrMyApp->testLiveShowRemote(); //This is an excample how to remote control the liveSHOWsoftware
|
}
|
||||||
}
|
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) {
|
||||||
|
fos::Task::delayMs(10000);
|
||||||
|
ESP_LOGI(TAG, "Test LiveShow");
|
||||||
|
|
||||||
|
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]]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void app_main(void) {
|
void app_main(void) {
|
||||||
@@ -651,7 +994,7 @@ void app_main(void) {
|
|||||||
static fos::TaskT<int> telnetSocket(telnetSocketTask, ipVersion, "tcpServer", 4096);
|
static fos::TaskT<int> telnetSocket(telnetSocketTask, ipVersion, "tcpServer", 4096);
|
||||||
static fos::TaskT<int> dmxNode(dmxSocketTask, ipVersion, "dmxNode", 4096);
|
static fos::TaskT<int> dmxNode(dmxSocketTask, ipVersion, "dmxNode", 4096);
|
||||||
// static Task otaUpdate(SystemFunctions::OtaTaskEntry, "otaTask", 8192);
|
// static Task otaUpdate(SystemFunctions::OtaTaskEntry, "otaTask", 8192);
|
||||||
static fos::Task spit(SpitClientApp,"SpitClient");
|
static fos::Task spit(SpitClientApp, "SpitClient");
|
||||||
|
|
||||||
auto &store = NvsApi::getInstance();
|
auto &store = NvsApi::getInstance();
|
||||||
auto logger = store.getValue(ConfigKeys.syslogDest);
|
auto logger = store.getValue(ConfigKeys.syslogDest);
|
||||||
|
|||||||
+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