refactor/bringup: Bringup full project
moving SPIT-App parts to main app LiveShowDemoProject added Debugging motor movements
This commit is contained in:
@@ -3,35 +3,37 @@
|
||||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
class SAD_DetectedServer;
|
||||
class I_SAD_Client {
|
||||
public:
|
||||
/**
|
||||
* 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>
|
||||
* 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>
|
||||
* 2.) If an IP4 address is available, it 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_Name the name of the SPIT server
|
||||
* @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_Port the port of the SPIT server
|
||||
* @param p_Addition sometimes server may have additional informations
|
||||
* @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;
|
||||
/**
|
||||
* 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>
|
||||
* @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_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_Port the port of the SPIT server
|
||||
* @param p_Addition sometimes server may have additional informations
|
||||
* @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(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;
|
||||
public:
|
||||
/**
|
||||
* 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>
|
||||
* 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>
|
||||
* 2.) If an IP4 address is available, it 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_Name the name of the SPIT server
|
||||
* @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_Port the port of the SPIT server
|
||||
* @param p_Addition sometimes server may have additional informations
|
||||
* @param p_IsIP4 the server ip is a ip4 address
|
||||
*/
|
||||
virtual void eventServerDetected(SAD_DetectedServer &server) = 0;
|
||||
/**
|
||||
* 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>
|
||||
* @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_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_Port the port of the SPIT server
|
||||
* @param p_Addition sometimes server may have additional informations
|
||||
* @param p_IsIP4 the server ip is a ip4 address
|
||||
*/
|
||||
virtual void eventServerChanged(SAD_DetectedServer &server) = 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
|
||||
|
||||
#include "I_SAD_Client.hpp"
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <list>
|
||||
|
||||
using namespace std;
|
||||
|
||||
class SAD_DetectedServer {
|
||||
|
||||
public:
|
||||
SAD_DetectedServer();
|
||||
SAD_DetectedServer(const SAD_DetectedServer& orig) {
|
||||
m_ID = orig.getID();
|
||||
m_Name = orig.getName();
|
||||
m_ComputerName = orig.getComputerName();
|
||||
m_IP = orig.getIP();
|
||||
m_IPIsIP4 = orig.getIpIsIP4();
|
||||
m_ClientIP = orig.getClientIP();
|
||||
m_Port = orig.getPort();
|
||||
m_Additions = orig.getAdditions();
|
||||
}
|
||||
~SAD_DetectedServer();
|
||||
|
||||
private:
|
||||
string m_ID;
|
||||
string m_Name;
|
||||
string m_ComputerName;
|
||||
string m_IP;
|
||||
bool m_IPIsIP4;
|
||||
string m_ClientIP;
|
||||
string m_Port;
|
||||
string m_Additions;
|
||||
string m_ServerProjectName;
|
||||
bool m_New;
|
||||
bool m_Changed;
|
||||
bool m_FoundAgain;
|
||||
|
||||
public:
|
||||
string getID() const { return m_ID; }
|
||||
string getName() const { return m_Name; }
|
||||
string getComputerName() const { return m_ComputerName; }
|
||||
string getIP() const { return m_IP; }
|
||||
bool getIpIsIP4() const { return m_IPIsIP4; }
|
||||
string getPort() const { return m_Port; }
|
||||
string getClientIP() const { return m_ClientIP; }
|
||||
string getAdditions() const { return m_Additions; }
|
||||
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);
|
||||
public:
|
||||
SAD_DetectedServer();
|
||||
SAD_DetectedServer(const SAD_DetectedServer &orig) {
|
||||
m_ID = orig.getID();
|
||||
m_Name = orig.getName();
|
||||
m_ComputerName = orig.getComputerName();
|
||||
m_IP = orig.getIP();
|
||||
m_ClientIP = orig.getClientIP();
|
||||
m_Port = orig.getPort();
|
||||
m_Additions = orig.getAdditions();
|
||||
}
|
||||
~SAD_DetectedServer();
|
||||
|
||||
void setIPIsIP4(bool p_IsIP4) { m_IPIsIP4 = p_IsIP4; }
|
||||
bool getNew() const { return m_New; }
|
||||
bool getChanged() const { return m_Changed; }
|
||||
bool getFoundAgain() const { return m_FoundAgain; }
|
||||
void setChanged() { m_Changed = true; }
|
||||
void setNew(bool p_New) { m_New = p_New; }
|
||||
void setFoundAgain() { m_FoundAgain = true; }
|
||||
private:
|
||||
string m_ID;
|
||||
string m_Name;
|
||||
string m_ComputerName;
|
||||
string m_IP;
|
||||
string m_ClientIP;
|
||||
string m_Port;
|
||||
string m_Additions;
|
||||
string m_ServerProjectName;
|
||||
bool m_New;
|
||||
bool m_Changed;
|
||||
bool m_FoundAgain;
|
||||
|
||||
//SAD_Client m_ThreadSend will send to Multicast addresses
|
||||
void startCycleSAD() {
|
||||
m_IPIsIP4 = false;
|
||||
m_Changed = false;
|
||||
m_FoundAgain = false;
|
||||
m_New = false;
|
||||
}
|
||||
//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);
|
||||
public:
|
||||
string getID() const { return m_ID; }
|
||||
string getName() const { return m_Name; }
|
||||
string getComputerName() const { return m_ComputerName; }
|
||||
string getIP() const { return m_IP; }
|
||||
string getPort() const { return m_Port; }
|
||||
string getClientIP() const { return m_ClientIP; }
|
||||
string getAdditions() const { return m_Additions; }
|
||||
string getProjectName() const { return m_ServerProjectName; }
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
SAD_DetectedServer* ptrDetectedServer = NULL;
|
||||
{
|
||||
auto i = s_DetectedServers.find(p_ServerID);
|
||||
if (i != s_DetectedServers.end()) {
|
||||
ptrDetectedServer = i->second;
|
||||
}
|
||||
if (ptrDetectedServer != NULL) {
|
||||
return *ptrDetectedServer;
|
||||
}
|
||||
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);
|
||||
|
||||
throw new exception();
|
||||
}
|
||||
}
|
||||
bool getNew() const { return m_New; }
|
||||
bool getChanged() const { return m_Changed; }
|
||||
bool getFoundAgain() const { return m_FoundAgain; }
|
||||
void setChanged() { m_Changed = true; }
|
||||
void setNew(bool p_New) { m_New = p_New; }
|
||||
void setFoundAgain() { m_FoundAgain = true; }
|
||||
|
||||
// SAD_Client m_ThreadSend will send to Multicast addresses
|
||||
void startCycleSAD() {
|
||||
m_Changed = false;
|
||||
m_FoundAgain = false;
|
||||
m_New = false;
|
||||
}
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
/*
|
||||
/*
|
||||
* File: SPITObject.h
|
||||
* Author: Hagi
|
||||
*
|
||||
@@ -14,8 +14,8 @@
|
||||
#ifndef SPITOBJECT_H
|
||||
#define SPITOBJECT_H
|
||||
|
||||
#include "SPIT_Message.h"
|
||||
#include "SPITType.h"
|
||||
#include "SPIT_Message.h"
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
@@ -24,153 +24,153 @@ using namespace std;
|
||||
class SPITObjectListener;
|
||||
|
||||
class SPITObject {
|
||||
private:
|
||||
|
||||
static unordered_map<string, SPITObject*> s_SPITObjects;
|
||||
static unordered_map<string, SPITObject*> s_SPITObjectsRemote;
|
||||
public:
|
||||
static SPITObject* getSPITObject(string p_ID);
|
||||
static const SPITObject& getSPITObjectRef(string p_ID);
|
||||
static bool addSPITObject(SPITObject* p_ptrSpitObject);
|
||||
static bool removeSPITObject(SPITObject* p_ptrSpitObject);
|
||||
static bool removeSPITObject(string p_SpitObjectID);
|
||||
static int getSPITObjectCount();
|
||||
static SPITObject* getSPITObject(int p_Index);
|
||||
static const SPITObject& getSPITObjectRef(int p_Index);
|
||||
static void clearSPITObjects();
|
||||
static void clearUnconfirmedSPITObjects();
|
||||
static void setConfirmedFalse();
|
||||
|
||||
static SPITObject* getSPITObjectRemote(string p_ID);
|
||||
static const SPITObject& getSPITObjectRemoteRef(string p_ID);
|
||||
static bool addSPITObjectRemote(SPITObject* p_ptrSpitObject);
|
||||
static bool removeSPITObjectRemote(SPITObject* p_ptrSpitObject);
|
||||
static bool removeSPITObjectRemote(string p_SpitObjectID);
|
||||
static int getSPITObjectRemoteCount();
|
||||
static SPITObject* getSPITObjectRemote(int p_Index);
|
||||
static const SPITObject& getSPITObjectRemoteRef(int p_Index);
|
||||
static void clearSPITObjectsRemote();
|
||||
private:
|
||||
static unordered_map<string, SPITObject *> s_SPITObjects;
|
||||
static unordered_map<string, SPITObject *> s_SPITObjectsRemote;
|
||||
|
||||
static void eventProjectClosed();
|
||||
|
||||
SPITObject();
|
||||
// SPITObject(const SPITObject& orig);
|
||||
~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;
|
||||
long long m_PlayTimeInsideFrames;
|
||||
int m_PlayValue;
|
||||
char m_PlayValueFlag;
|
||||
|
||||
|
||||
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; }
|
||||
|
||||
/**
|
||||
* 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>
|
||||
* true = the action is triggered on the server. The server waits for the client to play objects of this SPITType.
|
||||
*/
|
||||
bool getServerRemote() const { return m_ServerRemote; }
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
bool getConfirmed() const { return m_Confirmed; }
|
||||
bool getFixed() const { return m_Fixed; }
|
||||
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
|
||||
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; }
|
||||
public:
|
||||
static SPITObject *getSPITObject(string p_ID);
|
||||
static const SPITObject &getSPITObjectRef(string p_ID);
|
||||
static bool addSPITObject(SPITObject *p_ptrSpitObject);
|
||||
static bool removeSPITObject(SPITObject *p_ptrSpitObject);
|
||||
static bool removeSPITObject(string p_SpitObjectID);
|
||||
static int getSPITObjectCount();
|
||||
static SPITObject *getSPITObject(int p_Index);
|
||||
static const SPITObject &getSPITObjectRef(int p_Index);
|
||||
static void clearSPITObjects();
|
||||
static void clearUnconfirmedSPITObjects();
|
||||
static void setConfirmedFalse();
|
||||
|
||||
long long getDelay() const { return m_Delay; }
|
||||
long long getDuration() const { return m_Duration; }
|
||||
|
||||
bool getProjectIndepended() const {
|
||||
SPITType* ptrSPITType;
|
||||
if (m_ServerRemote == false) {
|
||||
ptrSPITType = SPITType::getSPITType(m_SPITTypeID);
|
||||
if (ptrSPITType == NULL) return true;
|
||||
return ptrSPITType->getProjectIndepended();
|
||||
}
|
||||
else {
|
||||
ptrSPITType = SPITType::getSPITTypeRemote(m_SPITTypeID);
|
||||
if (ptrSPITType == NULL) return true;
|
||||
return ptrSPITType->getProjectIndepended();
|
||||
}
|
||||
};
|
||||
static SPITObject *getSPITObjectRemote(string p_ID);
|
||||
static const SPITObject &getSPITObjectRemoteRef(string p_ID);
|
||||
static bool addSPITObjectRemote(SPITObject *p_ptrSpitObject);
|
||||
static bool removeSPITObjectRemote(SPITObject *p_ptrSpitObject);
|
||||
static bool removeSPITObjectRemote(string p_SpitObjectID);
|
||||
static int getSPITObjectRemoteCount();
|
||||
static SPITObject *getSPITObjectRemote(int p_Index);
|
||||
static const SPITObject &getSPITObjectRemoteRef(int p_Index);
|
||||
static void clearSPITObjectsRemote();
|
||||
|
||||
void setID(string p_ID);
|
||||
bool setConfirmed(bool p_Confirmed);
|
||||
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);
|
||||
static void eventProjectClosed();
|
||||
|
||||
bool setMessageOP(SPIT_Message::ReportSPITObject* p_ReportSPITObject);
|
||||
void fillMessageOP(SPIT_Message::ReportSPITObject* p_ReportSPITObject);
|
||||
void fillMessageOP(SPIT_Message::RemoveSPITObject* p_RemoveSPITObject);
|
||||
SPITObject();
|
||||
// SPITObject(const SPITObject& orig);
|
||||
~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;
|
||||
long long m_PlayTimeInsideFrames;
|
||||
int m_PlayValue;
|
||||
char m_PlayValueFlag;
|
||||
|
||||
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; }
|
||||
|
||||
/**
|
||||
* 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>
|
||||
* true = the action is triggered on the server. The server waits for the client to play objects of this SPITType.
|
||||
*/
|
||||
bool getServerRemote() const { return m_ServerRemote; }
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
bool getConfirmed() const { return m_Confirmed; }
|
||||
bool getFixed() const { return m_Fixed; }
|
||||
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
|
||||
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; }
|
||||
|
||||
long long getDelay() const { return m_Delay; }
|
||||
long long getDuration() const { return m_Duration; }
|
||||
|
||||
bool getProjectIndepended() const {
|
||||
SPITType *ptrSPITType;
|
||||
if (m_ServerRemote == false) {
|
||||
ptrSPITType = SPITType::getSPITType(m_SPITTypeID);
|
||||
if (ptrSPITType == NULL)
|
||||
return true;
|
||||
return ptrSPITType->getProjectIndepended();
|
||||
} else {
|
||||
ptrSPITType = SPITType::getSPITTypeRemote(m_SPITTypeID);
|
||||
if (ptrSPITType == NULL)
|
||||
return true;
|
||||
return ptrSPITType->getProjectIndepended();
|
||||
}
|
||||
};
|
||||
|
||||
void setID(string p_ID);
|
||||
bool setConfirmed(bool p_Confirmed);
|
||||
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 */
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
/*
|
||||
/*
|
||||
* File: SPITPLayer.h
|
||||
* Author: Hagi
|
||||
*
|
||||
@@ -18,79 +18,77 @@
|
||||
#include <unordered_map>
|
||||
|
||||
class SPITPlayer {
|
||||
|
||||
//----- PlayObject used in PlaySequences: PlaySPITStart, PlaySPITObject,..., PlaySPITEnd ------
|
||||
public:
|
||||
class PlaySPITType {
|
||||
public:
|
||||
PlaySPITType();
|
||||
PlaySPITType(SPITPlayer* p_SPITPlayer, string p_SPITObjectID);
|
||||
PlaySPITType(const PlaySPITType& orig);
|
||||
|
||||
string getSPITTypeID() const {
|
||||
return m_SPITTypeID;
|
||||
}
|
||||
|
||||
void startPlaySequence();
|
||||
bool getIsNew() const { return m_IsNew; }
|
||||
void setIsNew(bool p_IsNew) { m_IsNew = p_IsNew; }
|
||||
bool getIsPlayed() const { return m_IsPlayed; }
|
||||
void setIsPlayed(bool p_IsFound) { m_IsPlayed = p_IsFound; }
|
||||
string getPlayerID() const { return m_PlayerID; }
|
||||
string getPlayerName() const { return m_PlayerName; }
|
||||
bool getPlayerIsRunning() const { return m_PlayerRuns; }
|
||||
void setPlayerIsRunning(bool p_PlayerRuns) { m_PlayerRuns = p_PlayerRuns; }
|
||||
void setValue(double p_Value) { m_Value = p_Value; }
|
||||
void addValue(double p_Value, double p_ValueFactor) { m_Value += (p_Value * p_ValueFactor); }
|
||||
double getValue() const { return m_Value; }
|
||||
|
||||
private:
|
||||
string m_PlayerID;
|
||||
string m_PlayerName;
|
||||
bool m_PlayerRuns;
|
||||
string m_SPITTypeID;
|
||||
bool m_IsPlayed;
|
||||
bool m_IsNew;
|
||||
double m_Value;
|
||||
};
|
||||
|
||||
//----- SPITPlayer ------
|
||||
public:
|
||||
//list the SPITPlayers
|
||||
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 void clearPlayers();
|
||||
|
||||
SPITPlayer(string p_PlayerID);
|
||||
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
|
||||
|
||||
string getID() {
|
||||
return m_ID;
|
||||
}
|
||||
|
||||
unordered_map<string, PlaySPITType*>* getPlaySPITTypes();
|
||||
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; }
|
||||
|
||||
private:
|
||||
string m_ID;
|
||||
string m_Name;
|
||||
char m_Type;
|
||||
unordered_map<string, PlaySPITType*> m_PlaySPITTypes;
|
||||
bool m_IsRunning;
|
||||
long long m_TimeFrames;
|
||||
//----- PlayObject used in PlaySequences: PlaySPITStart, PlaySPITObject,..., PlaySPITEnd ------
|
||||
public:
|
||||
class PlaySPITType {
|
||||
public:
|
||||
PlaySPITType();
|
||||
PlaySPITType(SPITPlayer *p_SPITPlayer, string p_SPITObjectID);
|
||||
PlaySPITType(const PlaySPITType &orig);
|
||||
|
||||
string getSPITTypeID() const {
|
||||
return m_SPITTypeID;
|
||||
}
|
||||
|
||||
void startPlaySequence();
|
||||
bool getIsNew() const { return m_IsNew; }
|
||||
void setIsNew(bool p_IsNew) { m_IsNew = p_IsNew; }
|
||||
bool getIsPlayed() const { return m_IsPlayed; }
|
||||
void setIsPlayed(bool p_IsFound) { m_IsPlayed = p_IsFound; }
|
||||
string getPlayerID() const { return m_PlayerID; }
|
||||
string getPlayerName() const { return m_PlayerName; }
|
||||
bool getPlayerIsRunning() const { return m_PlayerRuns; }
|
||||
void setPlayerIsRunning(bool p_PlayerRuns) { m_PlayerRuns = p_PlayerRuns; }
|
||||
void setValue(double p_Value) { m_Value = p_Value; }
|
||||
void addValue(double p_Value, double p_ValueFactor) { m_Value += (p_Value * p_ValueFactor); }
|
||||
double getValue() const { return m_Value; }
|
||||
|
||||
private:
|
||||
string m_PlayerID;
|
||||
string m_PlayerName;
|
||||
bool m_PlayerRuns;
|
||||
string m_SPITTypeID;
|
||||
bool m_IsPlayed;
|
||||
bool m_IsNew;
|
||||
double m_Value;
|
||||
};
|
||||
|
||||
//----- SPITPlayer ------
|
||||
public:
|
||||
// list the SPITPlayers
|
||||
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 void clearPlayers();
|
||||
|
||||
SPITPlayer(string p_PlayerID);
|
||||
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
|
||||
|
||||
string getID() {
|
||||
return m_ID;
|
||||
}
|
||||
|
||||
unordered_map<string, PlaySPITType *> *getPlaySPITTypes();
|
||||
void setIsRunning(bool p_IsRunning) { m_IsRunning = p_IsRunning; }
|
||||
void setName(string p_Name) { m_Name = p_Name; }
|
||||
void setType(char p_Type) { m_Type = p_Type; }
|
||||
void setTime(long long p_Frames) { m_TimeFrames = p_Frames; }
|
||||
bool getIsRunning() { return m_IsRunning; }
|
||||
string getName() { return m_Name; }
|
||||
char getType() { return m_Type; }
|
||||
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 */
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
/*
|
||||
/*
|
||||
* SPITSocket is the base class for WindowsSocket, UnixSocket,.
|
||||
* Used by SPIT_Client and SAD_Client.
|
||||
* File: SPITSocket.h
|
||||
@@ -16,17 +16,17 @@
|
||||
#ifndef 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 "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;
|
||||
|
||||
@@ -35,133 +35,132 @@ string createGUID();
|
||||
/** Returns the name of the client's host computer*/
|
||||
string getClientHostName();
|
||||
|
||||
class SPITSocket{
|
||||
public:
|
||||
static const int FAMILY_IP4 = AF_INET;
|
||||
class SPITSocket {
|
||||
public:
|
||||
static const int FAMILY_IP4 = AF_INET;
|
||||
|
||||
/**
|
||||
* IPAddress class is used to fetch all available IP addresses of the computer
|
||||
* This is for internal usage
|
||||
*/
|
||||
struct IPAddress {
|
||||
public:
|
||||
IPAddress(const string& p_IPAddress, const string& p_SubnetMask)
|
||||
: m_IPAddress(p_IPAddress), m_SubnetMask(p_SubnetMask) { }
|
||||
const string m_IPAddress;
|
||||
const string m_SubnetMask;
|
||||
/**
|
||||
* IPAddress class is used to fetch all available IP addresses of the computer
|
||||
* This is for internal usage
|
||||
*/
|
||||
struct IPAddress {
|
||||
public:
|
||||
IPAddress(const string &p_IPAddress, const string &p_SubnetMask)
|
||||
: m_IPAddress(p_IPAddress), m_SubnetMask(p_SubnetMask) {}
|
||||
const string m_IPAddress;
|
||||
const string m_SubnetMask;
|
||||
|
||||
/**
|
||||
* Calculates the broadcast address from a ip4 address
|
||||
* @param p_IPAddress the ip4 address
|
||||
* @return returns the broadcast address
|
||||
*/
|
||||
string getBroadcastIP4() const {
|
||||
struct in_addr broadcast;
|
||||
unsigned long ulIPAddress;
|
||||
unsigned long ulSubnetMask;
|
||||
/**
|
||||
* Calculates the broadcast address from a ip4 address
|
||||
* @param p_IPAddress the ip4 address
|
||||
* @return returns the broadcast address
|
||||
*/
|
||||
string getBroadcastIP4() const {
|
||||
struct in_addr broadcast;
|
||||
unsigned long ulIPAddress;
|
||||
unsigned long ulSubnetMask;
|
||||
|
||||
ulIPAddress = inet_addr(m_IPAddress.data());
|
||||
ulSubnetMask = inet_addr(m_SubnetMask.data());
|
||||
broadcast.s_addr = ulIPAddress | ~ulSubnetMask;
|
||||
ulIPAddress = inet_addr(m_IPAddress.data());
|
||||
ulSubnetMask = inet_addr(m_SubnetMask.data());
|
||||
broadcast.s_addr = ulIPAddress | ~ulSubnetMask;
|
||||
|
||||
return inet_ntoa(broadcast);
|
||||
}
|
||||
};
|
||||
const IPAddress mOwnIp;
|
||||
static IPAddress getAdaptersInfo();
|
||||
bool createSocket_UDP();
|
||||
static const int INVALID_SOCKET = -1;
|
||||
return inet_ntoa(broadcast);
|
||||
}
|
||||
};
|
||||
const IPAddress mOwnIp;
|
||||
static IPAddress getAdaptersInfo();
|
||||
bool createSocket_UDP();
|
||||
static const int INVALID_SOCKET = -1;
|
||||
|
||||
private:
|
||||
int m_UDPSocketIP4;
|
||||
private:
|
||||
int m_UDPSocketIP4;
|
||||
|
||||
public:
|
||||
//-------- class --------------
|
||||
SPITSocket(IPAddress ip) : mOwnIp(ip) {
|
||||
m_UDPSocketIP4 = INVALID_SOCKET;
|
||||
|
||||
m_ServerIP = "";
|
||||
m_ServerPort = "";
|
||||
m_ClientIP = "";
|
||||
m_ClientPort = "";
|
||||
m_BoundClientPort = "";
|
||||
m_BoundClientFamily = 0;
|
||||
m_IsBound = false;
|
||||
createSocket_UDP();
|
||||
public:
|
||||
//-------- class --------------
|
||||
SPITSocket(IPAddress ip) : mOwnIp(ip) {
|
||||
m_UDPSocketIP4 = INVALID_SOCKET;
|
||||
|
||||
}
|
||||
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_ServerIP = "";
|
||||
m_ServerPort = "";
|
||||
m_ClientIP = "";
|
||||
m_ClientPort = "";
|
||||
m_BoundClientPort = "";
|
||||
m_BoundClientFamily = 0;
|
||||
m_IsBound = false;
|
||||
}
|
||||
private:
|
||||
string m_ServerIP;
|
||||
string m_ServerPort;
|
||||
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;
|
||||
createSocket_UDP();
|
||||
}
|
||||
virtual ~SPITSocket() {
|
||||
ESP_LOGD("UDP", "Shutting down ...");
|
||||
|
||||
public:
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to the server as set by setConnectionParams
|
||||
* @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;
|
||||
}
|
||||
if (m_UDPSocketIP4 != INVALID_SOCKET) {
|
||||
shutdown(m_UDPSocketIP4, 2);
|
||||
close(m_UDPSocketIP4);
|
||||
m_UDPSocketIP4 = INVALID_SOCKET;
|
||||
}
|
||||
fos::Task::delayMs(100);
|
||||
m_IsBound = false;
|
||||
}
|
||||
|
||||
int receiveMessage(int p_InetFamily, char* p_Buffer, int p_BufferLength, string* p_ServerIP);
|
||||
int setBroadcast(bool p_Broadcast);
|
||||
int bindSocket(string p_ServerIP, string p_ClientIP, string p_ClientPort);
|
||||
|
||||
// * Internal usage - don't use this manually
|
||||
// * Use sendMessage instead
|
||||
int sendMessageTo(int p_InetFamily, string p_ServerIP, string p_Port, const char* p_MessageBytes, int p_MessageLength);
|
||||
|
||||
string getServerIP() { return m_ServerIP; }
|
||||
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; }
|
||||
private:
|
||||
string m_ServerIP;
|
||||
string m_ServerPort;
|
||||
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:
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to the server as set by setConnectionParams
|
||||
* @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;
|
||||
}
|
||||
|
||||
int receiveMessage(int p_InetFamily, char *p_Buffer, int p_BufferLength, string *p_ServerIP);
|
||||
int setBroadcast(bool p_Broadcast);
|
||||
int bindSocket(string p_ServerIP, string p_ClientIP, string p_ClientPort);
|
||||
|
||||
// * Internal usage - don't use this manually
|
||||
// * Use sendMessage instead
|
||||
int sendMessageTo(int p_InetFamily, string p_ServerIP, string p_Port, const char *p_MessageBytes, int p_MessageLength);
|
||||
|
||||
string getServerIP() { return m_ServerIP; }
|
||||
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 */
|
||||
|
||||
|
||||
+111
-113
@@ -4,7 +4,7 @@
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
/*
|
||||
/*
|
||||
* File: SPITType.h
|
||||
* Author: Hagi
|
||||
*
|
||||
@@ -24,119 +24,117 @@ using namespace std;
|
||||
class SPITTypeListener;
|
||||
|
||||
class SPITType {
|
||||
private:
|
||||
static unordered_map<string, SPITType*> s_SPITTypes;
|
||||
static unordered_map<string, SPITType*> s_SPITTypesRemote;
|
||||
|
||||
public:
|
||||
static SPITType* getSPITType(string p_ID);
|
||||
static const SPITType& getSPITTypeRef(string p_ID);
|
||||
static bool addSPITType(SPITType* p_ptrSpitType);
|
||||
static bool removeSPITType(SPITType* p_ptrSpitType);
|
||||
static int getSPITTypeCount();
|
||||
static SPITType* getSPITType(int p_Index);
|
||||
static const SPITType& getSPITTypeRef(int p_Index);
|
||||
static void clearSPITTypes();
|
||||
static void setConfirmedFalse();
|
||||
private:
|
||||
static unordered_map<string, SPITType *> s_SPITTypes;
|
||||
static unordered_map<string, SPITType *> s_SPITTypesRemote;
|
||||
|
||||
static SPITType* getSPITTypeRemote(string p_ID);
|
||||
static const SPITType& getSPITTypeRemoteRef(string p_ID);
|
||||
static bool addSPITTypeRemote(SPITType* p_ptrSpitType);
|
||||
static bool removeSPITTypeRemote(SPITType* p_ptrSpitType);
|
||||
static int getSPITTypeRemoteCount();
|
||||
static SPITType* getSPITTypeRemote(int p_Index);
|
||||
static const SPITType& getSPITTypeRemoteRef(int p_Index);
|
||||
static void clearSPITTypesRemote();
|
||||
|
||||
static void eventProjectClosed();
|
||||
|
||||
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(const SPITType& orig);
|
||||
~SPITType();
|
||||
private:
|
||||
|
||||
bool m_Confirmed;
|
||||
string m_ID;
|
||||
bool m_Fixed;
|
||||
bool m_ServerRemote;
|
||||
bool m_ServerProjectIndepended;
|
||||
string m_GroupName;
|
||||
string m_Name;
|
||||
long long m_DefaultDelay;
|
||||
long long m_DefaultDuration;
|
||||
|
||||
bool m_CreatedByClient; //flag true = the SPITTyype is created by the client
|
||||
//false = the SPITType is received from the server
|
||||
|
||||
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
|
||||
|
||||
void initMembers();
|
||||
|
||||
public:
|
||||
string getID() const{ return m_ID; }
|
||||
string getGroupName() const { return m_GroupName; }
|
||||
string getName() const { return m_Name; }
|
||||
/**
|
||||
* 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>
|
||||
* true = the action is triggered on the server. The server waits for the client to play objects of this SPITType.
|
||||
*/
|
||||
bool getServerRemote() const {
|
||||
return m_ServerRemote;
|
||||
}
|
||||
|
||||
bool getProjectIndepended() const {
|
||||
return m_ServerProjectIndepended;
|
||||
}
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
bool getConfirmed() const { return m_Confirmed; }
|
||||
bool getFixed() const { return m_Fixed; }
|
||||
long long getDefaultDelay() const { return m_DefaultDelay; }
|
||||
long long getDefaultDuration() const { return m_DefaultDuration; }
|
||||
bool getCreatedByClient() const { return m_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 user has associated an action with this SPITType.
|
||||
*/
|
||||
bool getActionAssigned() const {
|
||||
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);
|
||||
|
||||
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);
|
||||
void fillMessageOP(SPIT_Message::ReportSPITType* p_ReportSPITType);
|
||||
void fillMessageOP(SPIT_Message::RemoveSPITType* p_RemoveSPITType);
|
||||
// static char* stringCopy(const char* p_String);
|
||||
public:
|
||||
static SPITType *getSPITType(string p_ID);
|
||||
static const SPITType &getSPITTypeRef(string p_ID);
|
||||
static bool addSPITType(SPITType *p_ptrSpitType);
|
||||
static bool removeSPITType(SPITType *p_ptrSpitType);
|
||||
static int getSPITTypeCount();
|
||||
static SPITType *getSPITType(int p_Index);
|
||||
static const SPITType &getSPITTypeRef(int p_Index);
|
||||
static void clearSPITTypes();
|
||||
static void setConfirmedFalse();
|
||||
|
||||
static SPITType *getSPITTypeRemote(string p_ID);
|
||||
static const SPITType &getSPITTypeRemoteRef(string p_ID);
|
||||
static bool addSPITTypeRemote(SPITType *p_ptrSpitType);
|
||||
static bool removeSPITTypeRemote(SPITType *p_ptrSpitType);
|
||||
static int getSPITTypeRemoteCount();
|
||||
static SPITType *getSPITTypeRemote(int p_Index);
|
||||
static const SPITType &getSPITTypeRemoteRef(int p_Index);
|
||||
static void clearSPITTypesRemote();
|
||||
|
||||
static void eventProjectClosed();
|
||||
|
||||
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(const SPITType& orig);
|
||||
~SPITType();
|
||||
|
||||
private:
|
||||
bool m_Confirmed;
|
||||
string m_ID;
|
||||
bool m_Fixed;
|
||||
bool m_ServerRemote;
|
||||
bool m_ServerProjectIndepended;
|
||||
string m_GroupName;
|
||||
string m_Name;
|
||||
long long m_DefaultDelay;
|
||||
long long m_DefaultDuration;
|
||||
|
||||
bool m_CreatedByClient; // flag true = the SPITTyype is created by the client
|
||||
// false = the SPITType is received from the server
|
||||
|
||||
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
|
||||
|
||||
void initMembers();
|
||||
|
||||
public:
|
||||
string getID() const { return m_ID; }
|
||||
string getGroupName() const { return m_GroupName; }
|
||||
string getName() const { return m_Name; }
|
||||
/**
|
||||
* 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>
|
||||
* true = the action is triggered on the server. The server waits for the client to play objects of this SPITType.
|
||||
*/
|
||||
bool getServerRemote() const {
|
||||
return m_ServerRemote;
|
||||
}
|
||||
|
||||
bool getProjectIndepended() const {
|
||||
return m_ServerProjectIndepended;
|
||||
}
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
bool getConfirmed() const { return m_Confirmed; }
|
||||
bool getFixed() const { return m_Fixed; }
|
||||
long long getDefaultDelay() const { return m_DefaultDelay; }
|
||||
long long getDefaultDuration() const { return m_DefaultDuration; }
|
||||
bool getCreatedByClient() const { return m_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 user has associated an action with this SPITType.
|
||||
*/
|
||||
bool getActionAssigned() const {
|
||||
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);
|
||||
|
||||
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);
|
||||
void fillMessageOP(SPIT_Message::ReportSPITType *p_ReportSPITType);
|
||||
void fillMessageOP(SPIT_Message::RemoveSPITType *p_RemoveSPITType);
|
||||
// static char* stringCopy(const char* p_String);
|
||||
};
|
||||
|
||||
|
||||
#endif /* SPITTYPE_H */
|
||||
@@ -4,7 +4,7 @@
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
/*
|
||||
/*
|
||||
* File: SPIT_Client.h
|
||||
* Author: Hagi
|
||||
*
|
||||
@@ -14,12 +14,12 @@
|
||||
#ifndef SPIT_CLIENT_H
|
||||
#define SPIT_CLIENT_H
|
||||
|
||||
#include "SPITSocket.h"
|
||||
#include "SAD_DetectedServer.hpp"
|
||||
#include "SPIT_Message.h"
|
||||
#include "SPITType.h"
|
||||
#include "SPITObject.h"
|
||||
#include "SPITPlayer.h"
|
||||
#include "SPITSocket.h"
|
||||
#include "SPITType.h"
|
||||
#include "SPIT_Message.h"
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
@@ -27,316 +27,327 @@ using namespace std;
|
||||
|
||||
class SPIT_Client : I_SAD_Client {
|
||||
|
||||
public:
|
||||
/** Maximal length of a SPITMessage*/
|
||||
static const int MAXSPITMESSAGEBYTECOUNT = 512;
|
||||
|
||||
enum ServerEvent {
|
||||
Detect,
|
||||
Lost,
|
||||
Changed,
|
||||
};
|
||||
public:
|
||||
/** Maximal length of a SPITMessage*/
|
||||
static const int MAXSPITMESSAGEBYTECOUNT = 512;
|
||||
|
||||
struct Callbacks {
|
||||
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(*onStartProjectTransfer)();
|
||||
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);
|
||||
};
|
||||
enum class ProjUpdate {
|
||||
ServerLoaded,
|
||||
StartTransfer,
|
||||
EndTransfer,
|
||||
ServerClosed,
|
||||
};
|
||||
enum class ServerEvent {
|
||||
Detect,
|
||||
Lost,
|
||||
Changed,
|
||||
};
|
||||
enum class ObjectEvent {
|
||||
Created,
|
||||
Changed,
|
||||
Deleted
|
||||
};
|
||||
|
||||
//----- Connection Status -----
|
||||
public:
|
||||
/** No Connection established.<br>Either no connect tried or disconnected*/
|
||||
static const int CONNECTION_NONE = 0;
|
||||
/** 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 ------
|
||||
public:
|
||||
/** 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.*/
|
||||
static const char PLAYERTYPE_MAIN = 0x02;
|
||||
/** continous player. This player plays SPIT objects sometime during the project.*/
|
||||
static const char PLAYERTYPE_CONTINOUS = 0x01;
|
||||
/** diescrete player. This player is used to transmit single discrete values.*/
|
||||
static const char PLAYERTYPE_DISCRETE = 0x00;
|
||||
struct Callbacks {
|
||||
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 (*onProjectUpdate)(ProjUpdate state, string projectId){};
|
||||
|
||||
//------ Value Flag ------
|
||||
//------ 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;
|
||||
void (*onSpitType)(ObjectEvent event, const SPITType &p_SPITType){};
|
||||
void (*onSpitTypeRemote)(ObjectEvent event, const SPITType &p_SPITType){};
|
||||
void (*onSpitObject)(ObjectEvent event, const SPITType &p_SPITType, const SPITObject &p_SPITObject){};
|
||||
void (*onSpitObjectRemote)(ObjectEvent event, const SPITType &p_SPITType, const SPITObject &p_SPITObject){};
|
||||
|
||||
//----- SPIT_Client -----
|
||||
public:
|
||||
SPIT_Client(string name, string projName, Callbacks calls);
|
||||
virtual ~SPIT_Client();
|
||||
static int s_MAX_OVERTAKING_SPIT_MESSAGES;
|
||||
private:
|
||||
Callbacks mCallbacks;
|
||||
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){};
|
||||
};
|
||||
|
||||
fos::TaskT<SPIT_Client&> * m_ThreadReceive{};
|
||||
bool m_StopReceiveSPITMessages;
|
||||
//----- Connection Status -----
|
||||
public:
|
||||
/** No Connection established.<br>Either no connect tried or disconnected*/
|
||||
static const int CONNECTION_NONE = 0;
|
||||
/** 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;
|
||||
|
||||
int m_ConnectionStatus;
|
||||
bool m_DisconnectedByServer{}; //flag true = when server disconnects
|
||||
string m_ID;
|
||||
string m_Name;
|
||||
string m_ProjName;
|
||||
string m_ComputerName;
|
||||
//------ PlayerType ------
|
||||
public:
|
||||
/** 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.*/
|
||||
static const char PLAYERTYPE_MAIN = 0x02;
|
||||
/** continous player. This player plays SPIT objects sometime during the project.*/
|
||||
static const char PLAYERTYPE_CONTINOUS = 0x01;
|
||||
/** diescrete player. This player is used to transmit single discrete values.*/
|
||||
static const char PLAYERTYPE_DISCRETE = 0x00;
|
||||
|
||||
string m_ClientProjectName;
|
||||
|
||||
unsigned char m_MessageNumber_Send;
|
||||
int m_MessageNumber_Received;
|
||||
vector<SPIT_Message*> m_OvertakingSPIT_Messages;
|
||||
//------ Value Flag ------
|
||||
//------ 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;
|
||||
|
||||
//Server's info filled by parseConnectAnswer
|
||||
string m_ServerID{};
|
||||
string m_ServerName{};
|
||||
string m_ServerComputerName{};
|
||||
int m_ServerStepTime{-1};
|
||||
|
||||
//--- Server Project ---
|
||||
string m_ServerProjectID;
|
||||
string m_ServerProjectName;
|
||||
int m_ServerFramesPerSecond;
|
||||
|
||||
public:
|
||||
/** The ID of the client.<br>Every client instance should set an unique id*/
|
||||
string getID() { return m_ID; }
|
||||
/** 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; }
|
||||
//----- SPIT_Client -----
|
||||
public:
|
||||
SPIT_Client(string name, string projName, Callbacks calls);
|
||||
virtual ~SPIT_Client();
|
||||
static int s_MAX_OVERTAKING_SPIT_MESSAGES;
|
||||
|
||||
//connected Server Infos
|
||||
/** The ID of the connected SPITServer*/
|
||||
string getServerID() { return m_ServerID; }
|
||||
/** The host computername of the connected SPITServer*/
|
||||
string getServerComputerName() { return m_ServerComputerName; }
|
||||
/** The name of the connected SPITServer*/
|
||||
string getServerName() { return m_ServerName; }
|
||||
private:
|
||||
Callbacks mCallbacks;
|
||||
|
||||
/** Expected Refreah Rate of the connectd SPITServer.<br>
|
||||
* When the server plays objects, it will do so at discrete time steps.<br>
|
||||
* Play events will take place in these time steps..
|
||||
*/
|
||||
int getServerStepTime() { return m_ServerStepTime; }
|
||||
|
||||
/** 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
|
||||
fos::TaskT<SPIT_Client &> *m_ThreadReceive{};
|
||||
bool m_StopReceiveSPITMessages;
|
||||
|
||||
int m_ConnectionStatus;
|
||||
bool m_DisconnectedByServer{}; // flag true = when server disconnects
|
||||
string m_ID;
|
||||
string m_Name;
|
||||
string m_ProjName;
|
||||
string m_ComputerName;
|
||||
|
||||
string m_ClientProjectName;
|
||||
|
||||
unsigned char m_MessageNumber_Send;
|
||||
int m_MessageNumber_Received;
|
||||
vector<SPIT_Message *> m_OvertakingSPIT_Messages;
|
||||
|
||||
// Server's info filled by parseConnectAnswer
|
||||
string m_ServerID{};
|
||||
string m_ServerName{};
|
||||
string m_ServerComputerName{};
|
||||
int m_ServerStepTime{-1};
|
||||
|
||||
//--- Server Project ---
|
||||
string m_ServerProjectID;
|
||||
string m_ServerProjectName;
|
||||
int m_ServerFramesPerSecond;
|
||||
|
||||
public:
|
||||
/** The ID of the client.<br>Every client instance should set an unique id*/
|
||||
string getID() { return m_ID; }
|
||||
/** 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
|
||||
/** The ID of the connected SPITServer*/
|
||||
string getServerID() { return m_ServerID; }
|
||||
/** The host computername of the connected SPITServer*/
|
||||
string getServerComputerName() { return m_ServerComputerName; }
|
||||
/** The name of the connected SPITServer*/
|
||||
string getServerName() { return m_ServerName; }
|
||||
|
||||
/** Expected Refreah Rate of the connectd SPITServer.<br>
|
||||
* When the server plays objects, it will do so at discrete time steps.<br>
|
||||
* Play events will take place in these time steps..
|
||||
*/
|
||||
int getServerStepTime() { return m_ServerStepTime; }
|
||||
|
||||
/** 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
|
||||
public:
|
||||
void fillHeader(SPIT_Message::Header* p_Header);
|
||||
int sendSPITMessage(SPIT_Message::OPPart& p_SPITMessageOPPart);
|
||||
public:
|
||||
void fillHeader(SPIT_Message::Header *p_Header);
|
||||
int sendSPITMessage(SPIT_Message::OPPart &p_SPITMessageOPPart);
|
||||
|
||||
//--------------- ServerAutoDetection SAD ---------------
|
||||
public:
|
||||
/** Starts the autodetection of SPITServers in the local network. If a connection is tried, the autodetection should be stopped before.*/
|
||||
void startServerAutoDetect();
|
||||
/** Stops the autodetection of SPITServers in the local network*/
|
||||
void stopServerAutoDetect();
|
||||
/** 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);
|
||||
/** 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 eventServerChanged(string p_ID, string p_Name, string p_ComputerName, string p_IP, string p_Port, string p_Addition, string p_ProjectName, string p_ClientIP, bool p_IsIP4);
|
||||
|
||||
//--------------- Connection ---------------
|
||||
public:
|
||||
/**
|
||||
* Tries a connection to the SPITServer
|
||||
* @param p_ServerIP ip address of the SPITServer
|
||||
* @param p_ServerPort port of the SPITServer
|
||||
* @param p_ClientIP IP of the client
|
||||
* @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_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>
|
||||
* 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 = "");
|
||||
/**
|
||||
* Terminates the connection to the SPITServer.
|
||||
*/
|
||||
void disconnect();
|
||||
|
||||
private:
|
||||
void disconnectInternal(int p_Cause);
|
||||
void resetMessageNumberReceived();
|
||||
void parseSPIT_Message(unique_ptr<SPIT_Message> p_SPITMessage);
|
||||
void checkParseSPIT_Message(unique_ptr<SPIT_Message> p_SPITMessage);
|
||||
void addOvertakingSPIT_Message(SPIT_Message* p_SPIT_Message);
|
||||
void parseConnectAnswer(SPIT_Message::ConnectAnswer* p_ConnectAnswer);
|
||||
void parseDisconnect(SPIT_Message::Disconnect* p_Disconnect);
|
||||
void parseWatchdog(SPIT_Message::Watchdog* p_Watchdog);
|
||||
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:
|
||||
void parseRequestProjectTransfer(SPIT_Message::RequestProjectTransfer* p_RequestProjectTransfer);
|
||||
void parseStartProjectTransfer(SPIT_Message::StartProjectTransfer* p_StartProjectTransfer);
|
||||
void parseEndProjectTransfer(SPIT_Message::EndProjectTransfer* p_EndProjectTransfer);
|
||||
public:
|
||||
static void sendProject(SPIT_Client* p_PtrSPIT_Client);
|
||||
|
||||
// --------------- SPIT Types ---------------
|
||||
public:
|
||||
/**
|
||||
* Creates a fixed SPITType for application actions that are always present and project independent.<br>
|
||||
* Fixed SPIT types cannot be changed or deleted by the server.<br>
|
||||
* 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);
|
||||
//--------------- ServerAutoDetection SAD ---------------
|
||||
public:
|
||||
/** Starts the autodetection of SPITServers in the local network. If a connection is tried, the autodetection should be stopped before.*/
|
||||
void startServerAutoDetect();
|
||||
/** Stops the autodetection of SPITServers in the local network*/
|
||||
void stopServerAutoDetect();
|
||||
/** Called every time a new SPITServer is detetced in the local network */
|
||||
void eventServerDetected(SAD_DetectedServer &server);
|
||||
/** Called every time a prior detected SPITServer is is no longer found.*/
|
||||
void eventServerLost(SAD_DetectedServer &server);
|
||||
void eventServerChanged(SAD_DetectedServer &server);
|
||||
|
||||
/**
|
||||
* Creates a SPITType for application actions.<br>
|
||||
* 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:
|
||||
//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 ---------------
|
||||
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);
|
||||
//--------------- Connection ---------------
|
||||
public:
|
||||
/**
|
||||
* Tries a connection to the SPITServer
|
||||
* @param p_ServerIP ip address of the SPITServer
|
||||
* @param p_ServerPort port of the SPITServer
|
||||
* @param p_ClientIP IP of the client
|
||||
* @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_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>
|
||||
* 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 = "");
|
||||
/**
|
||||
* Terminates the connection to the SPITServer.
|
||||
*/
|
||||
void disconnect();
|
||||
|
||||
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;
|
||||
}
|
||||
private:
|
||||
void disconnectInternal(int p_Cause);
|
||||
void resetMessageNumberReceived();
|
||||
void parseSPIT_Message(unique_ptr<SPIT_Message> p_SPITMessage);
|
||||
void checkParseSPIT_Message(unique_ptr<SPIT_Message> p_SPITMessage);
|
||||
void addOvertakingSPIT_Message(SPIT_Message *p_SPIT_Message);
|
||||
void parseConnectAnswer(SPIT_Message::ConnectAnswer *p_ConnectAnswer);
|
||||
void parseDisconnect(SPIT_Message::Disconnect *p_Disconnect);
|
||||
void parseWatchdog(SPIT_Message::Watchdog *p_Watchdog);
|
||||
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:
|
||||
void parseRequestProjectTransfer(SPIT_Message::RequestProjectTransfer *p_RequestProjectTransfer);
|
||||
void parseStartProjectTransfer(SPIT_Message::StartProjectTransfer *p_StartProjectTransfer);
|
||||
void parseEndProjectTransfer(SPIT_Message::EndProjectTransfer *p_EndProjectTransfer);
|
||||
|
||||
public:
|
||||
static void sendProject(SPIT_Client *p_PtrSPIT_Client);
|
||||
|
||||
// --------------- SPIT Types ---------------
|
||||
public:
|
||||
/**
|
||||
* Creates a fixed SPITType for application actions that are always present and project independent.<br>
|
||||
* Fixed SPIT types cannot be changed or deleted by the server.<br>
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* Creates a SPITType for application actions.<br>
|
||||
* 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:
|
||||
// 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 ---------------
|
||||
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 */
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user