refactoring message
This commit is contained in:
@@ -1 +1,2 @@
|
||||
build*
|
||||
.build*
|
||||
@@ -15,10 +15,11 @@
|
||||
#define SPITOBJECT_H
|
||||
|
||||
#include "SPITType.h"
|
||||
#include "SPIT_Message.h"
|
||||
#include "spit_message.hpp"
|
||||
#include "SpitRepo.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace spit;
|
||||
|
||||
class SPITObjectListener;
|
||||
|
||||
@@ -138,9 +139,9 @@ class SPITObject {
|
||||
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);
|
||||
bool setMessageOP(Message::ReportObject *p_ReportSPITObject);
|
||||
void fillMessageOP(Message::ReportObject &p_ReportSPITObject);
|
||||
void fillMessageOP(Message::RemoveObject &p_RemoveSPITObject);
|
||||
};
|
||||
|
||||
#endif /* SPITOBJECT_H */
|
||||
|
||||
@@ -15,10 +15,11 @@
|
||||
#define SPITTYPE_H
|
||||
|
||||
#include "SPITSocket.h"
|
||||
#include "SPIT_Message.h"
|
||||
#include "spit_message.hpp"
|
||||
#include "SpitRepo.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace spit;
|
||||
|
||||
class SPITTypeListener;
|
||||
|
||||
@@ -96,9 +97,9 @@ class SPITType {
|
||||
*/
|
||||
bool setActionAssigned(bool p_ActionAssigned);
|
||||
|
||||
bool setMessageOP(SPIT_Message::ReportSPITType &reportSpitType);
|
||||
void fillMessageOP(SPIT_Message::ReportSPITType &smReportSpitType) const;
|
||||
void fillMessageOP(SPIT_Message::RemoveSPITType &smRemoveSpitType) const;
|
||||
bool setMessageOP(Message::ReportType &reportSpitType);
|
||||
void fillMessageOP(Message::ReportType &smReportSpitType) const;
|
||||
void fillMessageOP(Message::RemoveType &smRemoveSpitType) const;
|
||||
};
|
||||
|
||||
#endif /* SPITTYPE_H */
|
||||
@@ -19,12 +19,13 @@
|
||||
#include "SPITPlayer.h"
|
||||
#include "SPITSocket.h"
|
||||
#include "SPITType.h"
|
||||
#include "SPIT_Message.h"
|
||||
#include "spit_message.hpp"
|
||||
#include "SpitRepo.hpp"
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
using namespace spit;
|
||||
|
||||
class SPIT_Client : I_SAD_Client {
|
||||
|
||||
@@ -112,7 +113,7 @@ class SPIT_Client : I_SAD_Client {
|
||||
|
||||
uint8_t m_MessageNumber_Send{1};
|
||||
int m_MessageNumber_Received{-1}; // set to -1 because the first received message will set the number (1..255)
|
||||
vector<unique_ptr<SPIT_Message>> m_OvertakingSPIT_Messages;
|
||||
vector<unique_ptr<Message>> m_OvertakingSPIT_Messages;
|
||||
|
||||
// Server's info filled by parseConnectAnswer
|
||||
string m_ServerID{};
|
||||
@@ -173,7 +174,7 @@ class SPIT_Client : I_SAD_Client {
|
||||
// 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:
|
||||
int sendSPITMessage(SPIT_Message::OPPart & spitMessageOPPart);
|
||||
int sendSPITMessage(Message::OPPart & spitMessageOPPart);
|
||||
|
||||
//--------------- ServerAutoDetection SAD ---------------
|
||||
public:
|
||||
@@ -209,13 +210,13 @@ class SPIT_Client : I_SAD_Client {
|
||||
private:
|
||||
void disconnectInternal(Connection 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(unique_ptr<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);
|
||||
void parseSPIT_Message(unique_ptr<Message> p_SPITMessage);
|
||||
void checkParseSPIT_Message(unique_ptr<Message> p_SPITMessage);
|
||||
void addOvertakingSPIT_Message(unique_ptr<Message> p_SPIT_Message);
|
||||
void parseConnectAnswer(Message::ConnectAnswer &p_ConnectAnswer);
|
||||
void parseDisconnect(Message::Disconnect &p_Disconnect);
|
||||
void parseWatchdog(Message::Watchdog &p_Watchdog);
|
||||
void parseWatchdogAnswer(Message::WatchdogAnswer &p_WatchdogAnswer);
|
||||
|
||||
public:
|
||||
/** Used internally*/
|
||||
@@ -224,8 +225,8 @@ class SPIT_Client : I_SAD_Client {
|
||||
void eventWatchdogLost();
|
||||
//--------------- SPIT Project ---------------
|
||||
private:
|
||||
void parseReportSPITProject(SPIT_Message::ReportSPITProject &p_ReportSPITProject);
|
||||
void parseCloseSPITProject(SPIT_Message::CloseSPITProject &p_CloseSPITProject);
|
||||
void parseReportSPITProject(Message::ReportProject &p_ReportSPITProject);
|
||||
void parseCloseSPITProject(Message::CloseProject &p_CloseSPITProject);
|
||||
|
||||
public:
|
||||
/** Returns the SPITServer's project ID - may be the same as the project's name*/
|
||||
@@ -236,9 +237,9 @@ class SPIT_Client : I_SAD_Client {
|
||||
int getServerFramesPerSecond();
|
||||
|
||||
private:
|
||||
void parseRequestProjectTransfer(SPIT_Message::RequestProjectTransfer &p_RequestProjectTransfer);
|
||||
void parseStartProjectTransfer(SPIT_Message::StartProjectTransfer &p_StartProjectTransfer);
|
||||
void parseEndProjectTransfer(SPIT_Message::EndProjectTransfer &p_EndProjectTransfer);
|
||||
void parseRequestProjectTransfer(Message::RequestProjectTransfer &p_RequestProjectTransfer);
|
||||
void parseStartProjectTransfer(Message::StartProjectTransfer &p_StartProjectTransfer);
|
||||
void parseEndProjectTransfer(Message::EndProjectTransfer &p_EndProjectTransfer);
|
||||
|
||||
public:
|
||||
static void sendProject(SPIT_Client *p_PtrSPIT_Client);
|
||||
@@ -274,8 +275,8 @@ class SPIT_Client : I_SAD_Client {
|
||||
|
||||
private:
|
||||
// receive SPITTypes
|
||||
void parseReportSPITType(SPIT_Message::ReportSPITType &p_ReportSPITType);
|
||||
void parseRemoveSPITType(SPIT_Message::RemoveSPITType &p_RemoveSPITType);
|
||||
void parseReportSPITType(Message::ReportType &p_ReportSPITType);
|
||||
void parseRemoveSPITType(Message::RemoveType &p_RemoveSPITType);
|
||||
int sendSPITTypeInternal(SPITType &p_SPITType);
|
||||
|
||||
public:
|
||||
@@ -297,8 +298,8 @@ class SPIT_Client : I_SAD_Client {
|
||||
public:
|
||||
//--------------- SPIT Objects ---------------
|
||||
private:
|
||||
void parseReportSPITObject(SPIT_Message::ReportSPITObject &p_ReportSPITObject);
|
||||
void parseRemoveSPITObject(SPIT_Message::RemoveSPITObject &p_RemoveSPITObject);
|
||||
void parseReportSPITObject(Message::ReportObject &p_ReportSPITObject);
|
||||
void parseRemoveSPITObject(Message::RemoveObject &p_RemoveSPITObject);
|
||||
int sendSPITObjectInternal(SPITObject *ptrSPITObject);
|
||||
|
||||
public:
|
||||
@@ -320,10 +321,10 @@ class SPIT_Client : I_SAD_Client {
|
||||
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);
|
||||
void parsePlaySPITStart(Message::PlayStart &p_PlaySPITStart);
|
||||
void parsePlaySPITObject(Message::PlayObject &p_PlaySPITObject);
|
||||
void parsePlaySPITEnd(Message::PlayEnd &p_PlaySPITEnd);
|
||||
void parseReportPlayStatus(Message::ReportPlayStatus &p_ReportPlayStatus);
|
||||
|
||||
public:
|
||||
//--------- Remote ----------
|
||||
|
||||
+133
-132
@@ -5,14 +5,12 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* File: SPIT_Message.h
|
||||
* File: Message.h
|
||||
* Author: Hagi
|
||||
*
|
||||
* Created on 3. April 2019, 08:51
|
||||
*/
|
||||
|
||||
#ifndef SPIT_MESSAGE_H
|
||||
#define SPIT_MESSAGE_H
|
||||
#pragma once
|
||||
|
||||
#include <cstdlib>
|
||||
#include <memory>
|
||||
@@ -23,7 +21,9 @@ using namespace std;
|
||||
|
||||
static const string SPITID = "#spit#";
|
||||
|
||||
class SPIT_Message {
|
||||
namespace spit {
|
||||
|
||||
class Message {
|
||||
//----------- Header -----------
|
||||
public:
|
||||
class Header {
|
||||
@@ -33,85 +33,86 @@ class SPIT_Message {
|
||||
Header();
|
||||
|
||||
private:
|
||||
string m_SPITID;
|
||||
int m_SPITVersion{SPITVERSION};
|
||||
unsigned char m_MessageNumber{};
|
||||
int m_BytesCount{BYTESLENGTH};
|
||||
string m_ServerID{};
|
||||
string m_ClientID{};
|
||||
int m_OPFlag{-1};
|
||||
int m_ParseOffset{};
|
||||
string mID;
|
||||
int mVersion{SPITVERSION};
|
||||
unsigned char mMessageNumber{};
|
||||
int mBytesCount{BYTESLENGTH};
|
||||
string mServerID{};
|
||||
string mClientID{};
|
||||
int mOpFlag{-1};
|
||||
int mParseOffset{};
|
||||
|
||||
public:
|
||||
string getSPITID() const { return m_SPITID; }
|
||||
int getSPITVersion() const { return m_SPITVersion; }
|
||||
unsigned char getMessageNumber() const { return m_MessageNumber; }
|
||||
int getBytesCount() const { return m_BytesCount; }
|
||||
string getServerID() const { return m_ServerID; }
|
||||
string getClientID() const { return m_ClientID; }
|
||||
int getOPFlag() const { return m_OPFlag; }
|
||||
string getSPITID() const { return mID; }
|
||||
int getSPITVersion() const { return mVersion; }
|
||||
unsigned char getMessageNumber() const { return mMessageNumber; }
|
||||
int getBytesCount() const { return mBytesCount; }
|
||||
string getServerID() const { return mServerID; }
|
||||
string getClientID() const { return mClientID; }
|
||||
int getType() const { return mOpFlag; }
|
||||
|
||||
// Receive
|
||||
bool parse(const std::vector<char> &message);
|
||||
|
||||
// Send
|
||||
Header(int p_SPITVersion, int p_OPFlag);
|
||||
void setMessageNumber(unsigned char p_MessageNumber) { m_MessageNumber = p_MessageNumber; }
|
||||
void setServerID(string p_ID) { m_ServerID = p_ID; }
|
||||
void setClientID(string p_ID) { m_ClientID = p_ID; }
|
||||
void setOPFlag(int p_OPFlag) { m_OPFlag = p_OPFlag; }
|
||||
Header(int p_SPITVersion, int pOpFlag);
|
||||
void setMessageNumber(unsigned char p_MessageNumber) { mMessageNumber = p_MessageNumber; }
|
||||
void setServerID(string p_ID) { mServerID = p_ID; }
|
||||
void setClientID(string p_ID) { mClientID = p_ID; }
|
||||
void setOPFlag(int pOpFlag) { mOpFlag = pOpFlag; }
|
||||
bool fillBytes(std::vector<char> &message);
|
||||
};
|
||||
|
||||
//----------- OPPart -----------
|
||||
public:
|
||||
class OPPart {
|
||||
|
||||
// Members
|
||||
protected:
|
||||
unique_ptr<Header> m_Header{};
|
||||
int m_ParseOffset{};
|
||||
int m_BytesCount;
|
||||
unique_ptr<Header> mHeader{};
|
||||
int mParseOffset{};
|
||||
int mBytesCount;
|
||||
|
||||
public:
|
||||
virtual ~OPPart();
|
||||
|
||||
Header *getHeader() const { return m_Header.get(); }
|
||||
int getBytesCount() const { return m_BytesCount; }
|
||||
Header *getHeader() const { return mHeader.get(); }
|
||||
int getBytesCount() const { return mBytesCount; }
|
||||
void setServerInfoInHeader(string clientId, string serverId) {
|
||||
if (!m_Header)
|
||||
if (!mHeader) {
|
||||
return;
|
||||
m_Header->setClientID(clientId);
|
||||
m_Header->setServerID(serverId);
|
||||
}
|
||||
mHeader->setClientID(clientId);
|
||||
mHeader->setServerID(serverId);
|
||||
}
|
||||
void setMessageNumber(uint8_t no) {
|
||||
if (!m_Header)
|
||||
if (!mHeader) {
|
||||
return;
|
||||
m_Header->setMessageNumber(no);
|
||||
}
|
||||
mHeader->setMessageNumber(no);
|
||||
}
|
||||
|
||||
const string getServerID() const {
|
||||
if (!m_Header) {
|
||||
if (!mHeader) {
|
||||
return "";
|
||||
}
|
||||
return m_Header->getServerID();
|
||||
return mHeader->getServerID();
|
||||
}
|
||||
const string getClientID() const {
|
||||
if (!m_Header) {
|
||||
if (!mHeader) {
|
||||
return "";
|
||||
}
|
||||
return m_Header->getClientID();
|
||||
return mHeader->getClientID();
|
||||
}
|
||||
|
||||
int getOPFlag() const {
|
||||
if (!m_Header) {
|
||||
int getType() const {
|
||||
if (!mHeader) {
|
||||
return -1;
|
||||
}
|
||||
return m_Header->getOPFlag();
|
||||
return mHeader->getType();
|
||||
}
|
||||
|
||||
// Receive
|
||||
OPPart(unique_ptr<Header> p_Header, int p_OPFlag, int size);
|
||||
OPPart(unique_ptr<Header> p_Header, int pOpFlag, int size);
|
||||
void setHeader(int opFlag);
|
||||
virtual bool parse(const std::vector<char> &message) = 0;
|
||||
|
||||
@@ -120,7 +121,7 @@ class SPIT_Message {
|
||||
virtual bool fillBytes(std::vector<char> &message) = 0;
|
||||
};
|
||||
|
||||
//----------- SPIT_Message -----------
|
||||
//----------- Message -----------
|
||||
|
||||
public:
|
||||
static constexpr int SPITVERSION = 1;
|
||||
@@ -140,7 +141,7 @@ class SPIT_Message {
|
||||
static constexpr char VALUEFLAG_INCREASE = 0x01; // increase the value
|
||||
static constexpr char VALUEFLAG_DECREASE = 0x02; // decrease the value
|
||||
|
||||
SPIT_Message() = default;
|
||||
Message() = default;
|
||||
|
||||
// Members
|
||||
private:
|
||||
@@ -148,18 +149,18 @@ class SPIT_Message {
|
||||
|
||||
// Receive
|
||||
public:
|
||||
SPIT_Message(std::vector<char> message);
|
||||
Message(std::vector<char> message);
|
||||
|
||||
const Header *getHeader() const { return m_OPPart->getHeader(); }
|
||||
int getOPFlag() const {
|
||||
int getType() const {
|
||||
if (!m_OPPart || !m_OPPart->getHeader()) {
|
||||
return -1;
|
||||
}
|
||||
return m_OPPart->getHeader()->getOPFlag();
|
||||
return m_OPPart->getHeader()->getType();
|
||||
}
|
||||
const OPPart *getOPPart() const { return m_OPPart.get(); }
|
||||
template<typename T>
|
||||
T &getOPPartAs() const { return *reinterpret_cast<T *>(m_OPPart.get()); }
|
||||
T &getAs() const { return *reinterpret_cast<T *>(m_OPPart.get()); }
|
||||
|
||||
private:
|
||||
bool parse(std::vector<char> message);
|
||||
@@ -294,9 +295,9 @@ class SPIT_Message {
|
||||
|
||||
//------------------------------ SPITProject ----------------------------------
|
||||
|
||||
//----------- ReportSPITProject -----------
|
||||
//----------- ReportProject -----------
|
||||
|
||||
class ReportSPITProject : public OPPart {
|
||||
class ReportProject : public OPPart {
|
||||
public:
|
||||
static constexpr int OPFLAG = 11;
|
||||
static constexpr int BYTESLENGTH = 113;
|
||||
@@ -308,22 +309,22 @@ class SPIT_Message {
|
||||
|
||||
// Receive
|
||||
public:
|
||||
ReportSPITProject(const ReportSPITProject &orig);
|
||||
ReportSPITProject(unique_ptr<Header> p_Header);
|
||||
ReportProject(const ReportProject &orig);
|
||||
ReportProject(unique_ptr<Header> p_Header);
|
||||
bool parse(const std::vector<char> &message);
|
||||
const string getProjectID() const { return m_ProjectID; }
|
||||
const string getProjectName() const { return m_ProjectName; }
|
||||
int getFramesPerSecond() const { return m_FramesPerSecond; }
|
||||
// Send
|
||||
ReportSPITProject(string p_ProjectID, string p_ProjectName);
|
||||
ReportProject(string p_ProjectID, string p_ProjectName);
|
||||
|
||||
void setFramesPerSecond(const int p_FramesPerSecond) { m_FramesPerSecond = p_FramesPerSecond; }
|
||||
bool fillBytes(std::vector<char> &message);
|
||||
};
|
||||
|
||||
//----------- CloseSPITProject -----------
|
||||
//----------- CloseProject -----------
|
||||
|
||||
class CloseSPITProject : public OPPart {
|
||||
class CloseProject : public OPPart {
|
||||
public:
|
||||
static constexpr int OPFLAG = 13;
|
||||
static constexpr int BYTESLENGTH = 45;
|
||||
@@ -332,15 +333,15 @@ class SPIT_Message {
|
||||
string m_ProjectID{};
|
||||
|
||||
public:
|
||||
CloseSPITProject(const CloseSPITProject &orig);
|
||||
CloseProject(const CloseProject &orig);
|
||||
// Receive
|
||||
CloseSPITProject(unique_ptr<Header> p_Header);
|
||||
CloseProject(unique_ptr<Header> p_Header);
|
||||
bool parse(const std::vector<char> &message);
|
||||
const string getProjectID() const {
|
||||
return m_ProjectID;
|
||||
}
|
||||
// Send
|
||||
CloseSPITProject(string projectID);
|
||||
CloseProject(string projectID);
|
||||
bool fillBytes(std::vector<char> &message);
|
||||
};
|
||||
|
||||
@@ -392,8 +393,8 @@ class SPIT_Message {
|
||||
|
||||
//---------------------------- SPIT_Types ----------------------------------
|
||||
|
||||
//----------- ReportSPITType -----------
|
||||
class ReportSPITType : public OPPart {
|
||||
//----------- ReportType -----------
|
||||
class ReportType : public OPPart {
|
||||
public:
|
||||
static constexpr int OPFLAG = 21;
|
||||
static constexpr int BYTESLENGTH = 168;
|
||||
@@ -406,13 +407,13 @@ class SPIT_Message {
|
||||
bool m_ServerProjectIndepended{};
|
||||
string m_SPITTypeGroupName{};
|
||||
string m_SPITTypeName{};
|
||||
long long m_Delay{};
|
||||
long long m_Duration{};
|
||||
uint64_t m_Delay{};
|
||||
uint64_t m_Duration{};
|
||||
|
||||
public:
|
||||
ReportSPITType(const ReportSPITType &orig);
|
||||
ReportType(const ReportType &orig);
|
||||
// Receive
|
||||
ReportSPITType(unique_ptr<Header> p_Header);
|
||||
ReportType(unique_ptr<Header> p_Header);
|
||||
bool parse(const std::vector<char> &message);
|
||||
|
||||
bool getConfirmed() const { return m_Confirmed; }
|
||||
@@ -422,11 +423,11 @@ class SPIT_Message {
|
||||
bool getServerProjectIndepended() const { return m_ServerProjectIndepended; }
|
||||
const string getGroupName() const { return m_SPITTypeGroupName; }
|
||||
const string getName() const { return m_SPITTypeName; }
|
||||
long long getDelay() const { return m_Delay; }
|
||||
long long getDuration() const { return m_Duration; }
|
||||
uint64_t getDelay() const { return m_Delay; }
|
||||
uint64_t getDuration() const { return m_Duration; }
|
||||
// Send
|
||||
|
||||
ReportSPITType();
|
||||
ReportType();
|
||||
void setConfirmed(bool p_Confirmed) { m_Confirmed = p_Confirmed; }
|
||||
void setID(string p_ID) { m_SPITTypeID = p_ID; }
|
||||
void setFixed(bool p_Fixed) { m_Fixed = p_Fixed; }
|
||||
@@ -434,15 +435,15 @@ class SPIT_Message {
|
||||
void setServerProjectIndepended(bool p_ProjectIndpended) { m_ServerProjectIndepended = p_ProjectIndpended; }
|
||||
void setGroupName(string p_GroupName) { m_SPITTypeGroupName = p_GroupName; }
|
||||
void setName(string p_Name) { m_SPITTypeName = p_Name; }
|
||||
void setDelay(long long p_Delay) { m_Delay = p_Delay; }
|
||||
void setDuration(long long p_Duration) { m_Duration = p_Duration; }
|
||||
void setDelay(uint64_t p_Delay) { m_Delay = p_Delay; }
|
||||
void setDuration(uint64_t p_Duration) { m_Duration = p_Duration; }
|
||||
|
||||
bool fillBytes(std::vector<char> &message);
|
||||
};
|
||||
|
||||
//----------- RemoveSPITType -----------
|
||||
//----------- RemoveType -----------
|
||||
|
||||
class RemoveSPITType : public OPPart {
|
||||
class RemoveType : public OPPart {
|
||||
public:
|
||||
static constexpr int OPFLAG = 23;
|
||||
static constexpr int BYTESLENGTH = 45;
|
||||
@@ -451,24 +452,24 @@ class SPIT_Message {
|
||||
string m_SPITTypeID{};
|
||||
|
||||
public:
|
||||
RemoveSPITType(const RemoveSPITType &orig);
|
||||
RemoveType(const RemoveType &orig);
|
||||
// Receive
|
||||
RemoveSPITType(unique_ptr<Header> p_Header);
|
||||
RemoveType(unique_ptr<Header> p_Header);
|
||||
bool parse(const std::vector<char> &message);
|
||||
|
||||
const string getID() const { return m_SPITTypeID; }
|
||||
|
||||
// Send
|
||||
RemoveSPITType();
|
||||
RemoveType();
|
||||
void setID(string p_ID) { m_SPITTypeID = p_ID; }
|
||||
bool fillBytes(std::vector<char> &message);
|
||||
};
|
||||
|
||||
//---------------------------- SPITObjects ----------------------------------
|
||||
|
||||
//----------- ReportSPITObject -----------
|
||||
//----------- ReportObject -----------
|
||||
|
||||
class ReportSPITObject : public OPPart {
|
||||
class ReportObject : public OPPart {
|
||||
public:
|
||||
static constexpr int OPFLAG = 31;
|
||||
static constexpr int BYTESLENGTH = 339;
|
||||
@@ -481,22 +482,22 @@ class SPIT_Message {
|
||||
string m_SPITObjectName{};
|
||||
string m_SPITTypeID{};
|
||||
string m_ServerParams{};
|
||||
long long m_FrameStart{};
|
||||
long long m_FrameLength{};
|
||||
long long m_FrameFadeInLength{};
|
||||
long long m_FrameFadeOutLength{};
|
||||
uint64_t m_FrameStart{};
|
||||
uint64_t m_FrameLength{};
|
||||
uint64_t m_FrameFadeInLength{};
|
||||
uint64_t m_FrameFadeOutLength{};
|
||||
int m_ValueFactor{};
|
||||
char m_ValueUse{VALUEUSE_DISCARD};
|
||||
int m_Track{};
|
||||
string m_Remark{};
|
||||
long long m_Delay{};
|
||||
long long m_Duration{};
|
||||
uint64_t m_Delay{};
|
||||
uint64_t m_Duration{};
|
||||
bool m_ActionAssigned{};
|
||||
|
||||
public:
|
||||
ReportSPITObject(const ReportSPITObject &orig);
|
||||
ReportObject(const ReportObject &orig);
|
||||
// Receive
|
||||
ReportSPITObject(unique_ptr<Header> p_Header);
|
||||
ReportObject(unique_ptr<Header> p_Header);
|
||||
bool parse(const std::vector<char> &message);
|
||||
|
||||
bool getConfirmed() const { return m_Confirmed; }
|
||||
@@ -506,20 +507,20 @@ class SPIT_Message {
|
||||
const string getName() const { return m_SPITObjectName; }
|
||||
const string getSPITTypeID() const { return m_SPITTypeID; }
|
||||
const string getServerParams() const { return m_ServerParams; }
|
||||
long long getFrameStart() const { return m_FrameStart; }
|
||||
long long getFrameLength() const { return m_FrameLength; }
|
||||
long long getFrameFadeInLength() const { return m_FrameFadeInLength; }
|
||||
long long getFrameFadeOutLength() const { return m_FrameFadeOutLength; }
|
||||
uint64_t getFrameStart() const { return m_FrameStart; }
|
||||
uint64_t getFrameLength() const { return m_FrameLength; }
|
||||
uint64_t getFrameFadeInLength() const { return m_FrameFadeInLength; }
|
||||
uint64_t getFrameFadeOutLength() const { return m_FrameFadeOutLength; }
|
||||
int getValueFactor() const { return m_ValueFactor; }
|
||||
char getValueUse() const { return m_ValueUse; }
|
||||
int getTrack() const { return m_Track; }
|
||||
const string getRemark() const { return m_Remark; }
|
||||
long long getDelay() const { return m_Delay; }
|
||||
long long getDuration() const { return m_Duration; }
|
||||
uint64_t getDelay() const { return m_Delay; }
|
||||
uint64_t getDuration() const { return m_Duration; }
|
||||
bool getActionAssigned() const { return m_ActionAssigned; }
|
||||
// Send
|
||||
public:
|
||||
ReportSPITObject();
|
||||
ReportObject();
|
||||
|
||||
void setConfirmed(bool p_Confirmed) { m_Confirmed = p_Confirmed; };
|
||||
void setID(string p_ID) { m_SPITObjectID = p_ID; };
|
||||
@@ -528,23 +529,23 @@ class SPIT_Message {
|
||||
void setName(string p_Name) { m_SPITObjectName = p_Name; };
|
||||
void setSPITTypeID(string p_ID) { m_SPITTypeID = p_ID; };
|
||||
void setServerParams(string p_Parameters) { m_ServerParams = p_Parameters; };
|
||||
void setFrameStart(long long p_StartTime) { m_FrameStart = p_StartTime; };
|
||||
void setFrameLength(long long p_Length) { m_FrameLength = p_Length; };
|
||||
void setFrameFadeInLength(long long p_FadeInTime) { m_FrameFadeInLength = p_FadeInTime; };
|
||||
void setFrameFadeOutLength(long long p_FadeOutTime) { m_FrameFadeOutLength = p_FadeOutTime; };
|
||||
void setFrameStart(uint64_t p_StartTime) { m_FrameStart = p_StartTime; };
|
||||
void setFrameLength(uint64_t p_Length) { m_FrameLength = p_Length; };
|
||||
void setFrameFadeInLength(uint64_t p_FadeInTime) { m_FrameFadeInLength = p_FadeInTime; };
|
||||
void setFrameFadeOutLength(uint64_t p_FadeOutTime) { m_FrameFadeOutLength = p_FadeOutTime; };
|
||||
void setValueFactor(int p_Volume) { m_ValueFactor = p_Volume; };
|
||||
void setValueUse(char p_ValueUse) { m_ValueUse = p_ValueUse; };
|
||||
void setTrack(int p_Track) { m_Track = p_Track; };
|
||||
void setRemark(string p_Description) { m_Remark = p_Description; };
|
||||
void setDelay(long long p_Delay);
|
||||
void setDuration(long long p_Duration);
|
||||
void setDelay(uint64_t p_Delay);
|
||||
void setDuration(uint64_t p_Duration);
|
||||
void setActionAssigned(bool p_ActionAssigned) { m_ActionAssigned = p_ActionAssigned; }
|
||||
bool fillBytes(std::vector<char> &message);
|
||||
};
|
||||
|
||||
//----------- RemoveSPITObject -----------
|
||||
//----------- RemoveObject -----------
|
||||
|
||||
class RemoveSPITObject : public OPPart {
|
||||
class RemoveObject : public OPPart {
|
||||
public:
|
||||
static constexpr int OPFLAG = 33;
|
||||
static constexpr int BYTESLENGTH = 45;
|
||||
@@ -553,24 +554,24 @@ class SPIT_Message {
|
||||
string m_SPITObjectID{};
|
||||
|
||||
public:
|
||||
RemoveSPITObject(const RemoveSPITObject &orig);
|
||||
RemoveObject(const RemoveObject &orig);
|
||||
// Receive
|
||||
RemoveSPITObject(unique_ptr<Header> p_Header);
|
||||
RemoveObject(unique_ptr<Header> p_Header);
|
||||
bool parse(const std::vector<char> &message);
|
||||
|
||||
const string getID() const { return m_SPITObjectID; }
|
||||
// Send
|
||||
public:
|
||||
RemoveSPITObject();
|
||||
RemoveObject();
|
||||
void setID(string p_ID) { m_SPITObjectID = p_ID; }
|
||||
bool fillBytes(std::vector<char> &message);
|
||||
};
|
||||
|
||||
//---------------------------- SPITPlayer ----------------------------------
|
||||
|
||||
//----------- PlaySPITStart -----------
|
||||
//----------- PlayStart -----------
|
||||
|
||||
class PlaySPITStart : public OPPart {
|
||||
class PlayStart : public OPPart {
|
||||
public:
|
||||
static constexpr int OPFLAG = 37;
|
||||
static constexpr int BYTESLENGTH = 119;
|
||||
@@ -580,30 +581,30 @@ class SPIT_Message {
|
||||
string m_PlayerName{};
|
||||
char m_PlayerType{};
|
||||
bool m_PlayerIsRunning{};
|
||||
long long m_Time; // Frames
|
||||
uint64_t m_Time; // Frames
|
||||
|
||||
public:
|
||||
PlaySPITStart(const PlaySPITStart &orig);
|
||||
PlayStart(const PlayStart &orig);
|
||||
// Receive
|
||||
PlaySPITStart(unique_ptr<Header> p_Header);
|
||||
PlayStart(unique_ptr<Header> p_Header);
|
||||
bool parse(const std::vector<char> &message);
|
||||
|
||||
const string getPlayerID() const { return m_PlayerID; }
|
||||
const string getPlayerName() const { return m_PlayerName; }
|
||||
char getPlayerType() const { return m_PlayerType; }
|
||||
bool getPlayerIsRunning() const { return m_PlayerIsRunning; }
|
||||
long long getTime() const { return m_Time; }
|
||||
uint64_t getTime() const { return m_Time; }
|
||||
|
||||
// Send
|
||||
PlaySPITStart(string p_PlayerID, string p_PlayerName, char p_PlayerType);
|
||||
PlayStart(string p_PlayerID, string p_PlayerName, char p_PlayerType);
|
||||
void setPlayerIsRunning(bool p_IsPlaying) { m_PlayerIsRunning = p_IsPlaying; }
|
||||
void setTime(long long p_Time) { m_Time = p_Time; }
|
||||
void setTime(uint64_t p_Time) { m_Time = p_Time; }
|
||||
bool fillBytes(std::vector<char> &message);
|
||||
};
|
||||
|
||||
//----------- PlaySPITObject -----------
|
||||
//----------- PlayObject -----------
|
||||
|
||||
class PlaySPITObject : public OPPart {
|
||||
class PlayObject : public OPPart {
|
||||
public:
|
||||
static constexpr int OPFLAG = 38;
|
||||
static constexpr int BYTESLENGTH = 100;
|
||||
@@ -611,37 +612,37 @@ class SPIT_Message {
|
||||
private:
|
||||
string m_PlayerID{};
|
||||
string m_SPITObjectID{};
|
||||
long long m_FrameInsideObject{}; // Frames
|
||||
uint64_t m_FrameInsideObject{}; // Frames
|
||||
bool m_PlayPrePosition{};
|
||||
int m_Value{};
|
||||
char m_ValueFlag{VALUEFLAG_DIRECT};
|
||||
|
||||
public:
|
||||
PlaySPITObject(const PlaySPITObject &orig);
|
||||
PlayObject(const PlayObject &orig);
|
||||
// Receive
|
||||
PlaySPITObject(unique_ptr<Header> p_Header);
|
||||
PlayObject(unique_ptr<Header> p_Header);
|
||||
bool parse(const std::vector<char> &message);
|
||||
|
||||
const string getPlayerID() const { return m_PlayerID; }
|
||||
const string getSPITObjectID() const { return m_SPITObjectID; }
|
||||
long long getFrameInsideObject() const { return m_FrameInsideObject; }
|
||||
uint64_t getFrameInsideObject() const { return m_FrameInsideObject; }
|
||||
bool getPlayPrePosition() const { return m_PlayPrePosition; }
|
||||
int getValue() const { return m_Value; }
|
||||
char getValueFlag() const { return m_ValueFlag; }
|
||||
// Send
|
||||
PlaySPITObject();
|
||||
PlayObject();
|
||||
|
||||
void setPlayerID(string p_PlayerID) { m_PlayerID = p_PlayerID; }
|
||||
void setID(string p_ID) { m_SPITObjectID = p_ID; }
|
||||
void setFrameInsideObject(long long p_TimeInside) { m_FrameInsideObject = p_TimeInside; }
|
||||
void setFrameInsideObject(uint64_t p_TimeInside) { m_FrameInsideObject = p_TimeInside; }
|
||||
void setPlayPrePosition(bool p_PlayOldPosition) { m_PlayPrePosition = p_PlayOldPosition; }
|
||||
void setValue(int p_Value) { m_Value = p_Value; }
|
||||
void setValueFlag(char p_ValueFlag) { m_ValueFlag = p_ValueFlag; }
|
||||
bool fillBytes(std::vector<char> &message);
|
||||
};
|
||||
|
||||
//----------- PlaySPITEnd -----------
|
||||
class PlaySPITEnd : public OPPart {
|
||||
//----------- PlayEnd -----------
|
||||
class PlayEnd : public OPPart {
|
||||
public:
|
||||
static constexpr int OPFLAG = 39;
|
||||
static constexpr int BYTESLENGTH = 45;
|
||||
@@ -650,19 +651,18 @@ class SPIT_Message {
|
||||
string m_PlayerID{};
|
||||
|
||||
public:
|
||||
PlaySPITEnd(const PlaySPITEnd &orig);
|
||||
PlayEnd(const PlayEnd &orig);
|
||||
// Receive
|
||||
PlaySPITEnd(unique_ptr<Header> p_Header);
|
||||
PlayEnd(unique_ptr<Header> p_Header);
|
||||
bool parse(const std::vector<char> &message);
|
||||
const string getPlayerID() const { return m_PlayerID; }
|
||||
|
||||
// Send
|
||||
PlaySPITEnd(string p_PlayerID);
|
||||
PlayEnd(string p_PlayerID);
|
||||
bool fillBytes(std::vector<char> &message);
|
||||
};
|
||||
|
||||
//----------- ReportPlayStatus -----------
|
||||
|
||||
class ReportPlayStatus : public OPPart {
|
||||
public:
|
||||
static constexpr int OPFLAG = 40;
|
||||
@@ -670,7 +670,7 @@ class SPIT_Message {
|
||||
|
||||
private:
|
||||
string m_SPITObjectID{};
|
||||
long long m_FrameInsideObject{}; // Frames
|
||||
uint64_t m_FrameInsideObject{};
|
||||
int m_Value{};
|
||||
|
||||
public:
|
||||
@@ -680,13 +680,13 @@ class SPIT_Message {
|
||||
bool parse(const std::vector<char> &message);
|
||||
|
||||
const string getID() const { return m_SPITObjectID; }
|
||||
long long getFrameInsideObject() const { return m_FrameInsideObject; }
|
||||
uint64_t getFrameInsideObject() const { return m_FrameInsideObject; }
|
||||
int getValue() const { return m_Value; }
|
||||
// Send
|
||||
ReportPlayStatus();
|
||||
|
||||
void setID(string p_ID);
|
||||
void setFrameInsideObject(long long p_TimeInside);
|
||||
void setFrameInsideObject(uint64_t p_TimeInside);
|
||||
void setValue(int p_Value);
|
||||
bool fillBytes(std::vector<char> &message);
|
||||
};
|
||||
@@ -695,11 +695,11 @@ class SPIT_Message {
|
||||
public:
|
||||
static bool isSystemLittleEndian();
|
||||
static optional<int> getInt(const std::vector<char> &message, int &offset);
|
||||
static optional<long long> getLong(const std::vector<char> &message, int &offset);
|
||||
static optional<uint64_t> getLong(const std::vector<char> &message, int &offset);
|
||||
static optional<bool> getBoolean(const std::vector<char> &message, int &offset);
|
||||
static optional<char> getByte(const std::vector<char> &message, int &offset);
|
||||
static int setInt(int value, std::vector<char> &message, int offset);
|
||||
static int setLong(long long value, std::vector<char> &message, int offset);
|
||||
static int setLong(uint64_t value, std::vector<char> &message, int offset);
|
||||
static int setBoolean(bool value, std::vector<char> &message, int offset);
|
||||
static int setByte(int value, std::vector<char> &message, int offset);
|
||||
|
||||
@@ -725,4 +725,5 @@ class SPIT_Message {
|
||||
*/
|
||||
static int setString(string p_String, std::vector<char> &message, int p_Offset, int p_Length);
|
||||
};
|
||||
#endif /* SPIT_MESSAGE_H */
|
||||
|
||||
}
|
||||
@@ -59,7 +59,7 @@ SPITObject::SPITObject(string p_ID) {
|
||||
m_ID = p_ID;
|
||||
}
|
||||
|
||||
bool SPITObject::setMessageOP(SPIT_Message::ReportSPITObject *p_ReportSPITObject) {
|
||||
bool SPITObject::setMessageOP(Message::ReportObject *p_ReportSPITObject) {
|
||||
bool boolChangeAllowed;
|
||||
bool boolChanged = false;
|
||||
|
||||
@@ -193,7 +193,7 @@ bool SPITObject::setMessageOP(SPIT_Message::ReportSPITObject *p_ReportSPITObject
|
||||
return boolChanged;
|
||||
}
|
||||
|
||||
void SPITObject::fillMessageOP(SPIT_Message::ReportSPITObject &p_ReportSPITObject) {
|
||||
void SPITObject::fillMessageOP(Message::ReportObject &p_ReportSPITObject) {
|
||||
p_ReportSPITObject.setActionAssigned(getActionAssigned()); // Action can be assigned to type or to this object
|
||||
p_ReportSPITObject.setConfirmed(m_Confirmed);
|
||||
p_ReportSPITObject.setDelay(m_Delay);
|
||||
@@ -213,7 +213,7 @@ void SPITObject::fillMessageOP(SPIT_Message::ReportSPITObject &p_ReportSPITObjec
|
||||
p_ReportSPITObject.setValueFactor(m_ValueFactor);
|
||||
p_ReportSPITObject.setValueUse(m_ValueUse);
|
||||
}
|
||||
void SPITObject::fillMessageOP(SPIT_Message::RemoveSPITObject &p_RemoveSPITObject) {
|
||||
void SPITObject::fillMessageOP(Message::RemoveObject &p_RemoveSPITObject) {
|
||||
p_RemoveSPITObject.setID(m_ID);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
#include "SPITType.h"
|
||||
#include "esp_log.h"
|
||||
|
||||
using namespace spit;
|
||||
|
||||
static const char *TAG = "SPIT";
|
||||
|
||||
void SPITType::eventProjectClosed(SpitRepo<SPITType> &repo, SpitRepo<SPITType> &remoteRepo) {
|
||||
@@ -144,7 +146,7 @@ bool SPITType::setActionAssigned(bool p_ActionAssigned) {
|
||||
* @return true = the SPITType is changed
|
||||
* false = the SPITType is NOT changed, because it is not allowed to change.
|
||||
*/
|
||||
bool SPITType::setMessageOP(SPIT_Message::ReportSPITType &reportSpitType) {
|
||||
bool SPITType::setMessageOP(Message::ReportType &reportSpitType) {
|
||||
bool boolChangeAllowed;
|
||||
bool boolChanged = false;
|
||||
|
||||
@@ -221,7 +223,7 @@ bool SPITType::setMessageOP(SPIT_Message::ReportSPITType &reportSpitType) {
|
||||
return boolChanged;
|
||||
}
|
||||
|
||||
void SPITType::fillMessageOP(SPIT_Message::ReportSPITType &smReportSpitType) const {
|
||||
void SPITType::fillMessageOP(Message::ReportType &smReportSpitType) const {
|
||||
smReportSpitType.setConfirmed(m_Confirmed);
|
||||
smReportSpitType.setDelay(m_DefaultDelay);
|
||||
smReportSpitType.setDuration(m_DefaultDuration);
|
||||
@@ -232,6 +234,6 @@ void SPITType::fillMessageOP(SPIT_Message::ReportSPITType &smReportSpitType) con
|
||||
smReportSpitType.setServerProjectIndepended(m_ServerProjectIndepended);
|
||||
smReportSpitType.setServerRemote(m_ServerRemote);
|
||||
}
|
||||
void SPITType::fillMessageOP(SPIT_Message::RemoveSPITType &smRemoveSpitType) const {
|
||||
void SPITType::fillMessageOP(Message::RemoveType &smRemoveSpitType) const {
|
||||
smRemoveSpitType.setID(m_ID);
|
||||
}
|
||||
|
||||
+104
-104
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* SPIt_Client handles the SPIT_Message transfer and
|
||||
* SPIt_Client handles the Message transfer and
|
||||
* fires eventxxx functions to the SPIT_ClientInterface (implemented by the user app).
|
||||
*
|
||||
* File: SPIT_Client.cpp
|
||||
@@ -39,9 +39,9 @@ SPIT_Client::~SPIT_Client() {
|
||||
void SPIT_Client::clientProjectClose() {
|
||||
if (m_ConnectionStatus == Connection::Ok) {
|
||||
ESP_LOGI(TAG, " ... tidy up ressources");
|
||||
SPIT_Message::CloseSPITProject closeSPITProject(m_ProjName);
|
||||
Message::CloseProject closeSPITProject(m_ProjName);
|
||||
if (sendSPITMessage(closeSPITProject) < 0) {
|
||||
ESP_LOGD(TAG, "SPIT_Client could not send Client's ReportSPITProject");
|
||||
ESP_LOGD(TAG, "SPIT_Client could not send Client's ReportProject");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -52,15 +52,15 @@ void SPIT_Client::clientProjectLoaded() {
|
||||
SPITObject::setConfirmedFalse(mSpitObjects);
|
||||
|
||||
if (m_ConnectionStatus == Connection::Ok) {
|
||||
// send ReportSPITProject to the server
|
||||
SPIT_Message::ReportSPITProject reportSPITProject(m_ProjName, m_ProjName);
|
||||
// send ReportProject to the server
|
||||
Message::ReportProject reportSPITProject(m_ProjName, m_ProjName);
|
||||
reportSPITProject.setFramesPerSecond(0);
|
||||
if (sendSPITMessage(reportSPITProject) < 0) {
|
||||
ESP_LOGD(TAG, "SPIT_CLient::clientProjectLoaded could not send Client's ReportSPITProject");
|
||||
ESP_LOGD(TAG, "SPIT_CLient::clientProjectLoaded could not send Client's ReportProject");
|
||||
}
|
||||
|
||||
// send RequestProjectTransfer
|
||||
SPIT_Message::RequestProjectTransfer sMRequestProjectTransfer;
|
||||
Message::RequestProjectTransfer sMRequestProjectTransfer;
|
||||
if (sendSPITMessage(sMRequestProjectTransfer) < 0) {
|
||||
ESP_LOGD(TAG, "SPIT_CLient::clientProjectLoaded could not send RequestProjectTransfer");
|
||||
}
|
||||
@@ -214,7 +214,7 @@ void SPIT_Client::eventServerChanged(SAD_DetectedServer &server) {
|
||||
// // } //Excample
|
||||
// }
|
||||
|
||||
int SPIT_Client::sendSPITMessage(SPIT_Message::OPPart &opPart) {
|
||||
int SPIT_Client::sendSPITMessage(Message::OPPart &opPart) {
|
||||
if (m_MessageNumber_Send == 255)
|
||||
m_MessageNumber_Send = 1;
|
||||
else
|
||||
@@ -222,9 +222,9 @@ int SPIT_Client::sendSPITMessage(SPIT_Message::OPPart &opPart) {
|
||||
opPart.setMessageNumber(m_MessageNumber_Send);
|
||||
opPart.setServerInfoInHeader(m_ID, m_ServerID);
|
||||
|
||||
int opFlag = opPart.getHeader()->getOPFlag();
|
||||
int opFlag = opPart.getHeader()->getType();
|
||||
try {
|
||||
auto spitMessage = SPIT_Message::createMessage(opPart);
|
||||
auto spitMessage = Message::createMessage(opPart);
|
||||
if (spitMessage.empty()) {
|
||||
return -1;
|
||||
}
|
||||
@@ -264,7 +264,7 @@ void SPIT_Client::receiveSPITMessage(SPIT_Client &rM) {
|
||||
continue;
|
||||
}
|
||||
auto vec = vector<char>(buffer, buffer + rdLen);
|
||||
auto spitMsg = make_unique<SPIT_Message>(vec);
|
||||
auto spitMsg = make_unique<Message>(vec);
|
||||
rM.parseSPIT_Message(move(spitMsg));
|
||||
// rM.checkParseSPIT_Message(move(spitMsg));
|
||||
}
|
||||
@@ -275,7 +275,7 @@ void SPIT_Client::resetMessageNumberReceived() {
|
||||
m_OvertakingSPIT_Messages.clear();
|
||||
}
|
||||
|
||||
void SPIT_Client::checkParseSPIT_Message(unique_ptr<SPIT_Message> p_SPITMessage) {
|
||||
void SPIT_Client::checkParseSPIT_Message(unique_ptr<Message> p_SPITMessage) {
|
||||
answerWatchdog();
|
||||
if (!p_SPITMessage || !p_SPITMessage->getHeader() || p_SPITMessage->getOPPart()) {
|
||||
ESP_LOGD(TAG, "SPIT_Client::parseSPIT_Message incomplete message");
|
||||
@@ -330,7 +330,7 @@ void SPIT_Client::checkParseSPIT_Message(unique_ptr<SPIT_Message> p_SPITMessage)
|
||||
}
|
||||
}
|
||||
|
||||
void SPIT_Client::addOvertakingSPIT_Message(unique_ptr<SPIT_Message> p_SPIT_Message) {
|
||||
void SPIT_Client::addOvertakingSPIT_Message(unique_ptr<Message> p_SPIT_Message) {
|
||||
if (!p_SPIT_Message) {
|
||||
return;
|
||||
}
|
||||
@@ -350,69 +350,69 @@ void SPIT_Client::addOvertakingSPIT_Message(unique_ptr<SPIT_Message> p_SPIT_Mess
|
||||
m_OvertakingSPIT_Messages.push_back(move(p_SPIT_Message));
|
||||
}
|
||||
|
||||
void SPIT_Client::parseSPIT_Message(unique_ptr<SPIT_Message> p_SPITMessage) {
|
||||
void SPIT_Client::parseSPIT_Message(unique_ptr<Message> p_SPITMessage) {
|
||||
answerWatchdog();
|
||||
if (!p_SPITMessage || !p_SPITMessage->getHeader() || !p_SPITMessage->getOPPart()) {
|
||||
ESP_LOGD(TAG, "SPIT_Client::parseSPIT_Message incomplete message");
|
||||
return;
|
||||
}
|
||||
|
||||
switch (p_SPITMessage->getOPFlag()) {
|
||||
switch (p_SPITMessage->getType()) {
|
||||
//----- Connection -----
|
||||
case SPIT_Message::ConnectAnswer::OPFLAG:
|
||||
parseConnectAnswer(p_SPITMessage->getOPPartAs<SPIT_Message::ConnectAnswer>());
|
||||
case Message::ConnectAnswer::OPFLAG:
|
||||
parseConnectAnswer(p_SPITMessage->getAs<Message::ConnectAnswer>());
|
||||
break;
|
||||
case SPIT_Message::Disconnect::OPFLAG:
|
||||
parseDisconnect(p_SPITMessage->getOPPartAs<SPIT_Message::Disconnect>());
|
||||
case Message::Disconnect::OPFLAG:
|
||||
parseDisconnect(p_SPITMessage->getAs<Message::Disconnect>());
|
||||
break;
|
||||
case SPIT_Message::ReportSPITProject::OPFLAG:
|
||||
parseReportSPITProject(p_SPITMessage->getOPPartAs<SPIT_Message::ReportSPITProject>());
|
||||
case Message::ReportProject::OPFLAG:
|
||||
parseReportSPITProject(p_SPITMessage->getAs<Message::ReportProject>());
|
||||
break;
|
||||
case SPIT_Message::Watchdog::OPFLAG:
|
||||
parseWatchdog(p_SPITMessage->getOPPartAs<SPIT_Message::Watchdog>());
|
||||
case Message::Watchdog::OPFLAG:
|
||||
parseWatchdog(p_SPITMessage->getAs<Message::Watchdog>());
|
||||
break;
|
||||
case SPIT_Message::WatchdogAnswer::OPFLAG:
|
||||
parseWatchdogAnswer(p_SPITMessage->getOPPartAs<SPIT_Message::WatchdogAnswer>());
|
||||
case Message::WatchdogAnswer::OPFLAG:
|
||||
parseWatchdogAnswer(p_SPITMessage->getAs<Message::WatchdogAnswer>());
|
||||
break;
|
||||
//----- SPIT Project -----
|
||||
case SPIT_Message::StartProjectTransfer::OPFLAG:
|
||||
parseStartProjectTransfer(p_SPITMessage->getOPPartAs<SPIT_Message::StartProjectTransfer>());
|
||||
case Message::StartProjectTransfer::OPFLAG:
|
||||
parseStartProjectTransfer(p_SPITMessage->getAs<Message::StartProjectTransfer>());
|
||||
break;
|
||||
case SPIT_Message::CloseSPITProject::OPFLAG:
|
||||
parseCloseSPITProject(p_SPITMessage->getOPPartAs<SPIT_Message::CloseSPITProject>());
|
||||
case Message::CloseProject::OPFLAG:
|
||||
parseCloseSPITProject(p_SPITMessage->getAs<Message::CloseProject>());
|
||||
break;
|
||||
case SPIT_Message::RequestProjectTransfer::OPFLAG:
|
||||
parseRequestProjectTransfer(p_SPITMessage->getOPPartAs<SPIT_Message::RequestProjectTransfer>());
|
||||
case Message::RequestProjectTransfer::OPFLAG:
|
||||
parseRequestProjectTransfer(p_SPITMessage->getAs<Message::RequestProjectTransfer>());
|
||||
break;
|
||||
case SPIT_Message::EndProjectTransfer::OPFLAG:
|
||||
parseEndProjectTransfer(p_SPITMessage->getOPPartAs<SPIT_Message::EndProjectTransfer>());
|
||||
case Message::EndProjectTransfer::OPFLAG:
|
||||
parseEndProjectTransfer(p_SPITMessage->getAs<Message::EndProjectTransfer>());
|
||||
break;
|
||||
//----- SPIT Types ------
|
||||
case SPIT_Message::ReportSPITType::OPFLAG:
|
||||
parseReportSPITType(p_SPITMessage->getOPPartAs<SPIT_Message::ReportSPITType>());
|
||||
case Message::ReportType::OPFLAG:
|
||||
parseReportSPITType(p_SPITMessage->getAs<Message::ReportType>());
|
||||
break;
|
||||
case SPIT_Message::RemoveSPITType::OPFLAG:
|
||||
parseRemoveSPITType(p_SPITMessage->getOPPartAs<SPIT_Message::RemoveSPITType>());
|
||||
case Message::RemoveType::OPFLAG:
|
||||
parseRemoveSPITType(p_SPITMessage->getAs<Message::RemoveType>());
|
||||
//----- SPIT Objects ------
|
||||
break;
|
||||
case SPIT_Message::ReportSPITObject::OPFLAG:
|
||||
parseReportSPITObject(p_SPITMessage->getOPPartAs<SPIT_Message::ReportSPITObject>());
|
||||
case Message::ReportObject::OPFLAG:
|
||||
parseReportSPITObject(p_SPITMessage->getAs<Message::ReportObject>());
|
||||
break;
|
||||
case SPIT_Message::RemoveSPITObject::OPFLAG:
|
||||
parseRemoveSPITObject(p_SPITMessage->getOPPartAs<SPIT_Message::RemoveSPITObject>());
|
||||
case Message::RemoveObject::OPFLAG:
|
||||
parseRemoveSPITObject(p_SPITMessage->getAs<Message::RemoveObject>());
|
||||
break;
|
||||
//----- Play SPIT Objects ------
|
||||
case SPIT_Message::PlaySPITStart::OPFLAG:
|
||||
parsePlaySPITStart(p_SPITMessage->getOPPartAs<SPIT_Message::PlaySPITStart>());
|
||||
case Message::PlayStart::OPFLAG:
|
||||
parsePlaySPITStart(p_SPITMessage->getAs<Message::PlayStart>());
|
||||
break;
|
||||
case SPIT_Message::PlaySPITObject::OPFLAG:
|
||||
parsePlaySPITObject(p_SPITMessage->getOPPartAs<SPIT_Message::PlaySPITObject>());
|
||||
case Message::PlayObject::OPFLAG:
|
||||
parsePlaySPITObject(p_SPITMessage->getAs<Message::PlayObject>());
|
||||
break;
|
||||
case SPIT_Message::PlaySPITEnd::OPFLAG:
|
||||
parsePlaySPITEnd(p_SPITMessage->getOPPartAs<SPIT_Message::PlaySPITEnd>());
|
||||
case Message::PlayEnd::OPFLAG:
|
||||
parsePlaySPITEnd(p_SPITMessage->getAs<Message::PlayEnd>());
|
||||
break;
|
||||
case SPIT_Message::ReportPlayStatus::OPFLAG:
|
||||
parseReportPlayStatus(p_SPITMessage->getOPPartAs<SPIT_Message::ReportPlayStatus>());
|
||||
case Message::ReportPlayStatus::OPFLAG:
|
||||
parseReportPlayStatus(p_SPITMessage->getAs<Message::ReportPlayStatus>());
|
||||
break;
|
||||
default:
|
||||
ESP_LOGD(TAG, "SPIT_Client::parseSPIT_Message: Unknown Message");
|
||||
@@ -437,7 +437,7 @@ bool SPIT_Client::connect(string p_ServerIP, string p_ServerPort, string p_Clien
|
||||
m_StopReceiveSPITMessages = true;
|
||||
return false;
|
||||
}
|
||||
SPIT_Message::Connect sMConnect(m_ComputerName, m_Name);
|
||||
Message::Connect sMConnect(m_ComputerName, m_Name);
|
||||
sMConnect.setLoginName(p_LoginName);
|
||||
sMConnect.setLoginPassword(p_LoginPassword);
|
||||
sMConnect.setServerIP(p_ServerIP);
|
||||
@@ -483,7 +483,7 @@ void SPIT_Client::disconnectInternal(Connection p_Cause) {
|
||||
case Connection::Lost:
|
||||
break;
|
||||
case Connection::None: {
|
||||
SPIT_Message::Disconnect sMDisconnect;
|
||||
Message::Disconnect sMDisconnect;
|
||||
sendSPITMessage(sMDisconnect);
|
||||
} break;
|
||||
case Connection::NoneServer:
|
||||
@@ -525,7 +525,7 @@ void SPIT_Client::disconnectInternal(Connection p_Cause) {
|
||||
}
|
||||
}
|
||||
|
||||
void SPIT_Client::parseConnectAnswer(SPIT_Message::ConnectAnswer &p_ConnectAnswer) {
|
||||
void SPIT_Client::parseConnectAnswer(Message::ConnectAnswer &p_ConnectAnswer) {
|
||||
if (p_ConnectAnswer.getClientID() != m_ID)
|
||||
return;
|
||||
|
||||
@@ -555,7 +555,7 @@ void SPIT_Client::parseConnectAnswer(SPIT_Message::ConnectAnswer &p_ConnectAnswe
|
||||
* The SPIT server was closed
|
||||
* @param p_Disconnect
|
||||
*/
|
||||
void SPIT_Client::parseDisconnect(SPIT_Message::Disconnect &p_Disconnect) {
|
||||
void SPIT_Client::parseDisconnect(Message::Disconnect &p_Disconnect) {
|
||||
Connection intCauseDisconnect = Connection::NoneServer;
|
||||
/*
|
||||
function<void()> o_Callable = bind(&SPIT_Client::disconnectInternal, this, intCauseDisconnect);
|
||||
@@ -572,9 +572,9 @@ void SPIT_Client::parseDisconnect(SPIT_Message::Disconnect &p_Disconnect) {
|
||||
* This is used to check if the other side is still present.
|
||||
* @param p_Watchdog
|
||||
*/
|
||||
void SPIT_Client::parseWatchdog(SPIT_Message::Watchdog &p_Watchdog) {
|
||||
void SPIT_Client::parseWatchdog(Message::Watchdog &p_Watchdog) {
|
||||
// ESP_LOGD(TAG, "parse Watchdog ");
|
||||
SPIT_Message::WatchdogAnswer o_WatchdogAnswer;
|
||||
Message::WatchdogAnswer o_WatchdogAnswer;
|
||||
sendSPITMessage(o_WatchdogAnswer);
|
||||
}
|
||||
/**
|
||||
@@ -583,12 +583,12 @@ void SPIT_Client::parseWatchdog(SPIT_Message::Watchdog &p_Watchdog) {
|
||||
* This is used to check if the other side is still present.
|
||||
* @param p_Watchdog
|
||||
*/
|
||||
void SPIT_Client::parseWatchdogAnswer(SPIT_Message::WatchdogAnswer &p_WatchdogAnswer) {
|
||||
void SPIT_Client::parseWatchdogAnswer(Message::WatchdogAnswer &p_WatchdogAnswer) {
|
||||
answerWatchdog(); // is also done by parseSPIT_Message
|
||||
}
|
||||
void SPIT_Client::sendWatchdog() {
|
||||
int intResult;
|
||||
SPIT_Message::Watchdog sMWatchdog;
|
||||
Message::Watchdog sMWatchdog;
|
||||
intResult = sendSPITMessage(sMWatchdog);
|
||||
if (intResult < 0) {
|
||||
ESP_LOGW("WDT", "Failed to send Watchdog msg");
|
||||
@@ -603,8 +603,8 @@ void SPIT_Client::eventWatchdogLost() {
|
||||
}
|
||||
|
||||
//----- SPIT Project ------
|
||||
void SPIT_Client::parseReportSPITProject(SPIT_Message::ReportSPITProject &p_ReportSPITProject) {
|
||||
ESP_LOGD(TAG, "parse ReportSPITProject");
|
||||
void SPIT_Client::parseReportSPITProject(Message::ReportProject &p_ReportSPITProject) {
|
||||
ESP_LOGD(TAG, "parse ReportProject");
|
||||
m_ServerProjectID = p_ReportSPITProject.getProjectID();
|
||||
m_ServerProjectName = p_ReportSPITProject.getProjectName();
|
||||
m_ServerFramesPerSecond = p_ReportSPITProject.getFramesPerSecond();
|
||||
@@ -615,21 +615,21 @@ void SPIT_Client::parseReportSPITProject(SPIT_Message::ReportSPITProject &p_Repo
|
||||
SPITObject::setConfirmedFalse(mSpitObjects);
|
||||
|
||||
// Send RequestProjectTransfer
|
||||
SPIT_Message::RequestProjectTransfer sMRequestProjectTransfer;
|
||||
Message::RequestProjectTransfer sMRequestProjectTransfer;
|
||||
if (sendSPITMessage(sMRequestProjectTransfer) < 0) {
|
||||
ESP_LOGD(TAG, "SPIT_Client::parseReportSPITProject could not send RequestProjectTransfer");
|
||||
}
|
||||
|
||||
// todo Don't send the ReportSPITProject here it should be sended after parseEndProjectTransfer
|
||||
// Send client's ReportSPITProject
|
||||
SPIT_Message::ReportSPITProject reportSPITProject(m_ProjName, m_ProjName);
|
||||
// todo Don't send the ReportProject here it should be sended after parseEndProjectTransfer
|
||||
// Send client's ReportProject
|
||||
Message::ReportProject reportSPITProject(m_ProjName, m_ProjName);
|
||||
reportSPITProject.setFramesPerSecond(0);
|
||||
if (sendSPITMessage(reportSPITProject) < 0) {
|
||||
ESP_LOGD(TAG, "SPIT_Client::parseReportSPITProject could not send Client's ReportSPITProject");
|
||||
ESP_LOGD(TAG, "SPIT_Client::parseReportSPITProject could not send Client's ReportProject");
|
||||
}
|
||||
}
|
||||
void SPIT_Client::parseCloseSPITProject(SPIT_Message::CloseSPITProject &p_CloseSPITProject) {
|
||||
ESP_LOGD(TAG, "parse CloseSPITProject");
|
||||
void SPIT_Client::parseCloseSPITProject(Message::CloseProject &p_CloseSPITProject) {
|
||||
ESP_LOGD(TAG, "parse CloseProject");
|
||||
string stringProjectID;
|
||||
mCallbacks.onProjectUpdate(ProjUpdate::ServerClosed, p_CloseSPITProject.getProjectID());
|
||||
SPITPlayer::clearPlayers();
|
||||
@@ -639,10 +639,10 @@ string SPIT_Client::getServerProjectID() { return m_ServerProjectID; }
|
||||
string SPIT_Client::getServerProjectName() { return m_ServerProjectName; }
|
||||
int SPIT_Client::getServerFramesPerSecond() { return m_ServerFramesPerSecond; }
|
||||
|
||||
void SPIT_Client::parseRequestProjectTransfer(SPIT_Message::RequestProjectTransfer &p_RequestProjectTransfer) {
|
||||
void SPIT_Client::parseRequestProjectTransfer(Message::RequestProjectTransfer &p_RequestProjectTransfer) {
|
||||
ESP_LOGD(TAG, "parse RequestProjectTransfer");
|
||||
// StartProjectTransfer
|
||||
SPIT_Message::StartProjectTransfer sMStartProjectTransfer;
|
||||
Message::StartProjectTransfer sMStartProjectTransfer;
|
||||
if (sendSPITMessage(sMStartProjectTransfer) < 0) {
|
||||
return;
|
||||
}
|
||||
@@ -667,19 +667,19 @@ void SPIT_Client::parseRequestProjectTransfer(SPIT_Message::RequestProjectTransf
|
||||
}
|
||||
|
||||
// EndProjectTransfer
|
||||
SPIT_Message::EndProjectTransfer sMEndProjectTransfer;
|
||||
Message::EndProjectTransfer sMEndProjectTransfer;
|
||||
sendSPITMessage(sMEndProjectTransfer);
|
||||
}
|
||||
|
||||
/* NEW IMPLEMENTATION
|
||||
|
||||
void SPIT_Client::parseRequestProjectTransfer(SPIT_Message::RequestProjectTransfer* p_RequestProjectTransfer) {
|
||||
void SPIT_Client::parseRequestProjectTransfer(Message::RequestProjectTransfer* p_RequestProjectTransfer) {
|
||||
// ESP_LOGD(TAG, "parse RequestProjectTransfer");
|
||||
thread* o_ThreadSend;
|
||||
o_ThreadSend = new thread(&this->sendProject, this);
|
||||
// int intResult;
|
||||
// SPIT_Message::StartProjectTransfer* ptrSMStartProjectTransfer;
|
||||
// SPIT_Message::EndProjectTransfer* ptrSMEndProjectTransfer;
|
||||
// Message::StartProjectTransfer* ptrSMStartProjectTransfer;
|
||||
// Message::EndProjectTransfer* ptrSMEndProjectTransfer;
|
||||
// int intCount;
|
||||
// SPITType* ptrSPITType;
|
||||
// SPITObject* ptrSPITObject;
|
||||
@@ -689,7 +689,7 @@ void SPIT_Client::parseRequestProjectTransfer(SPIT_Message::RequestProjectTransf
|
||||
// NotifyStartProjectTransfer_Client* o_RunnableStart = new NotifyStartProjectTransfer_Client(m_SPITClientInterface);
|
||||
// SPIT_Handler::addRunnable(o_RunnableStart);
|
||||
|
||||
// ptrSMStartProjectTransfer = new SPIT_Message::StartProjectTransfer();
|
||||
// ptrSMStartProjectTransfer = new Message::StartProjectTransfer();
|
||||
// intResult = sendSPITMessage(ptrSMStartProjectTransfer);
|
||||
// if (intResult < 0) {
|
||||
// return;
|
||||
@@ -723,7 +723,7 @@ void SPIT_Client::parseRequestProjectTransfer(SPIT_Message::RequestProjectTransf
|
||||
// }
|
||||
|
||||
// //EndProjectTransfer
|
||||
// ptrSMEndProjectTransfer = new SPIT_Message::EndProjectTransfer();
|
||||
// ptrSMEndProjectTransfer = new Message::EndProjectTransfer();
|
||||
// intResult = sendSPITMessage(ptrSMEndProjectTransfer);
|
||||
// if (intResult < 0) {
|
||||
// return;
|
||||
@@ -738,8 +738,8 @@ void SPIT_Client::parseRequestProjectTransfer(SPIT_Message::RequestProjectTransf
|
||||
|
||||
void SPIT_Client::sendProject(SPIT_Client *p_PtrSPIT_Client) {
|
||||
// int intResult;
|
||||
// SPIT_Message::StartProjectTransfer* ptrSMStartProjectTransfer;
|
||||
// SPIT_Message::EndProjectTransfer* ptrSMEndProjectTransfer;
|
||||
// Message::StartProjectTransfer* ptrSMStartProjectTransfer;
|
||||
// Message::EndProjectTransfer* ptrSMEndProjectTransfer;
|
||||
// int intCount;
|
||||
// SPITType* ptrSPITType;
|
||||
// SPITObject* ptrSPITObject;
|
||||
@@ -748,7 +748,7 @@ void SPIT_Client::sendProject(SPIT_Client *p_PtrSPIT_Client) {
|
||||
// NotifyStartProjectTransfer_Client* o_RunnableStart = new NotifyStartProjectTransfer_Client(p_PtrSPIT_Client->getSPITClientInterface());
|
||||
// SPIT_Handler::addRunnable(o_RunnableStart);
|
||||
|
||||
// ptrSMStartProjectTransfer = new SPIT_Message::StartProjectTransfer();
|
||||
// ptrSMStartProjectTransfer = new Message::StartProjectTransfer();
|
||||
// intResult = p_PtrSPIT_Client->sendSPITMessage(ptrSMStartProjectTransfer);
|
||||
// if (intResult < 0) {
|
||||
// return;
|
||||
@@ -785,7 +785,7 @@ void SPIT_Client::sendProject(SPIT_Client *p_PtrSPIT_Client) {
|
||||
// // }
|
||||
|
||||
// //EndProjectTransfer
|
||||
// ptrSMEndProjectTransfer = new SPIT_Message::EndProjectTransfer();
|
||||
// ptrSMEndProjectTransfer = new Message::EndProjectTransfer();
|
||||
// intResult = p_PtrSPIT_Client->sendSPITMessage(ptrSMEndProjectTransfer);
|
||||
// if (intResult < 0) {
|
||||
// return;
|
||||
@@ -797,24 +797,24 @@ void SPIT_Client::sendProject(SPIT_Client *p_PtrSPIT_Client) {
|
||||
// //Send act
|
||||
}
|
||||
|
||||
void SPIT_Client::parseStartProjectTransfer(SPIT_Message::StartProjectTransfer &p_StartProjectTransfer) {
|
||||
void SPIT_Client::parseStartProjectTransfer(Message::StartProjectTransfer &p_StartProjectTransfer) {
|
||||
mCallbacks.onProjectUpdate(ProjUpdate::StartTransfer, m_ServerProjectID);
|
||||
}
|
||||
void SPIT_Client::parseEndProjectTransfer(SPIT_Message::EndProjectTransfer &p_EndProjectTransfer) {
|
||||
void SPIT_Client::parseEndProjectTransfer(Message::EndProjectTransfer &p_EndProjectTransfer) {
|
||||
SPITObject::clearUnconfirmedSPITObjects(mSpitObjects);
|
||||
mCallbacks.onProjectUpdate(ProjUpdate::EndTransfer, m_ServerProjectID);
|
||||
|
||||
// Send SPIT_Message::ReportSPITProject after the m_SPITClientInterface is notfied of EndProjectTransfer
|
||||
SPIT_Message::ReportSPITProject reportSPITProject(m_ProjName, m_ProjName);
|
||||
// Send Message::ReportProject after the m_SPITClientInterface is notfied of EndProjectTransfer
|
||||
Message::ReportProject reportSPITProject(m_ProjName, m_ProjName);
|
||||
reportSPITProject.setFramesPerSecond(0);
|
||||
if (sendSPITMessage(reportSPITProject) < 0) {
|
||||
ESP_LOGD(TAG, "SPIT_Client::parseReportSPITProject could not send Client's ReportSPITProject");
|
||||
ESP_LOGD(TAG, "SPIT_Client::parseReportSPITProject could not send Client's ReportProject");
|
||||
}
|
||||
}
|
||||
|
||||
//----- SPIT Types ------
|
||||
void SPIT_Client::parseReportSPITType(SPIT_Message::ReportSPITType &p_ReportSPITType) {
|
||||
ESP_LOGD(TAG, "parse ReportSPITType ID %s Name %s",p_ReportSPITType.getID().c_str(), p_ReportSPITType.getName().c_str());
|
||||
void SPIT_Client::parseReportSPITType(Message::ReportType &p_ReportSPITType) {
|
||||
ESP_LOGD(TAG, "parse ReportType ID %s Name %s",p_ReportSPITType.getID().c_str(), p_ReportSPITType.getName().c_str());
|
||||
SPITType *ptrSPITType;
|
||||
bool boolNew = false;
|
||||
bool boolChanged = false;
|
||||
@@ -863,8 +863,8 @@ void SPIT_Client::parseReportSPITType(SPIT_Message::ReportSPITType &p_ReportSPIT
|
||||
}
|
||||
}
|
||||
}
|
||||
void SPIT_Client::parseRemoveSPITType(SPIT_Message::RemoveSPITType &p_RemoveSPITType) {
|
||||
ESP_LOGD(TAG, "parse RemoveSPITType %s", p_RemoveSPITType.getID().c_str());
|
||||
void SPIT_Client::parseRemoveSPITType(Message::RemoveType &p_RemoveSPITType) {
|
||||
ESP_LOGD(TAG, "parse RemoveType %s", p_RemoveSPITType.getID().c_str());
|
||||
bool boolRemote = false;
|
||||
string stringSPITTypeID = p_RemoveSPITType.getID();
|
||||
|
||||
@@ -903,7 +903,7 @@ void SPIT_Client::parseRemoveSPITType(SPIT_Message::RemoveSPITType &p_RemoveSPIT
|
||||
* @return 0 = is sended, -1 = is not sended
|
||||
*/
|
||||
int SPIT_Client::sendSPITTypeInternal(SPITType &p_SPITType) {
|
||||
SPIT_Message::ReportSPITType sMReportSPITType;
|
||||
Message::ReportType sMReportSPITType;
|
||||
p_SPITType.fillMessageOP(sMReportSPITType);
|
||||
return sendSPITMessage(sMReportSPITType);
|
||||
}
|
||||
@@ -949,7 +949,7 @@ int SPIT_Client::removeSPITType(string p_SPITTypeID) {
|
||||
ptrSPITType = mSpitTypes.getEntry(p_SPITTypeID);
|
||||
if (ptrSPITType == nullptr)
|
||||
return -1;
|
||||
SPIT_Message::RemoveSPITType sMRemoveSPITType;
|
||||
Message::RemoveType sMRemoveSPITType;
|
||||
ptrSPITType->fillMessageOP(sMRemoveSPITType);
|
||||
mCallbacks.onSpitType(ObjectEvent::Deleted, false, *ptrSPITType);
|
||||
mSpitTypes.removeEntry(*ptrSPITType);
|
||||
@@ -988,15 +988,15 @@ SPITType *SPIT_Client::createSPITType(string p_ID, string p_GroupName, string p_
|
||||
}
|
||||
|
||||
//----- SPIT Objects ------
|
||||
void SPIT_Client::parseReportSPITObject(SPIT_Message::ReportSPITObject &p_ReportSPITObject) {
|
||||
ESP_LOGD(TAG, "parse ReportSPITObject %s", p_ReportSPITObject.getID().c_str());
|
||||
void SPIT_Client::parseReportSPITObject(Message::ReportObject &p_ReportSPITObject) {
|
||||
ESP_LOGD(TAG, "parse ReportObject %s", p_ReportSPITObject.getID().c_str());
|
||||
SPITObject *ptrSPITObject;
|
||||
SPITType *ptrSPITType;
|
||||
bool boolNew = false;
|
||||
bool boolRemote = false;
|
||||
bool boolChanged = false;
|
||||
{
|
||||
ESP_LOGD(TAG, "parse ReportSPITObject %s / %s", p_ReportSPITObject.getID().c_str(), p_ReportSPITObject.getName().c_str());
|
||||
ESP_LOGD(TAG, "parse ReportObject %s / %s", p_ReportSPITObject.getID().c_str(), p_ReportSPITObject.getName().c_str());
|
||||
if (p_ReportSPITObject.getServerRemote() == false) {
|
||||
boolRemote = false;
|
||||
ptrSPITObject = mSpitObjects.getEntry(p_ReportSPITObject.getID());
|
||||
@@ -1068,8 +1068,8 @@ void SPIT_Client::parseReportSPITObject(SPIT_Message::ReportSPITObject &p_Report
|
||||
}
|
||||
}
|
||||
}
|
||||
void SPIT_Client::parseRemoveSPITObject(SPIT_Message::RemoveSPITObject &p_RemoveSPITObject) {
|
||||
ESP_LOGD(TAG, "parse RemoveSPITObject %s", p_RemoveSPITObject.getID().c_str());
|
||||
void SPIT_Client::parseRemoveSPITObject(Message::RemoveObject &p_RemoveSPITObject) {
|
||||
ESP_LOGD(TAG, "parse RemoveObject %s", p_RemoveSPITObject.getID().c_str());
|
||||
SPITObject *ptrSPITObject = mRemoteSpitObjects.getEntry(p_RemoveSPITObject.getID());
|
||||
if (ptrSPITObject != nullptr) {
|
||||
SPITType *ptrSPITType = mRemoteSpitTypes.getEntry(ptrSPITObject->getSPITTypeID());
|
||||
@@ -1086,7 +1086,7 @@ void SPIT_Client::parseRemoveSPITObject(SPIT_Message::RemoveSPITObject &p_Remove
|
||||
int SPIT_Client::sendSPITObjectInternal(SPITObject *ptrSPITObject) {
|
||||
if (ptrSPITObject == nullptr)
|
||||
return -1;
|
||||
SPIT_Message::ReportSPITObject sMReportSPITObject;
|
||||
Message::ReportObject sMReportSPITObject;
|
||||
ptrSPITObject->fillMessageOP(sMReportSPITObject);
|
||||
|
||||
return sendSPITMessage(sMReportSPITObject);
|
||||
@@ -1150,7 +1150,7 @@ int SPIT_Client::removeSPITObject(string p_SPITObjectID) {
|
||||
SPITType *ptrSPITType;
|
||||
SPITObject *ptrSPITObject;
|
||||
{
|
||||
SPIT_Message::RemoveSPITObject sMRemoveSPITObject;
|
||||
Message::RemoveObject sMRemoveSPITObject;
|
||||
|
||||
ptrSPITObject = mSpitObjects.getEntry(p_SPITObjectID);
|
||||
if (ptrSPITObject == nullptr)
|
||||
@@ -1168,8 +1168,8 @@ int SPIT_Client::removeSPITObject(string p_SPITObjectID) {
|
||||
|
||||
//----- Play SPIT Objects ------
|
||||
|
||||
void SPIT_Client::parsePlaySPITStart(SPIT_Message::PlaySPITStart &p_PlaySPITStart) {
|
||||
ESP_LOGD(TAG, "parse PlaySPITStart ID: %s Name: %s Running: %d", p_PlaySPITStart.getPlayerID().c_str(), p_PlaySPITStart.getPlayerName().c_str(), (int)p_PlaySPITStart.getPlayerIsRunning());
|
||||
void SPIT_Client::parsePlaySPITStart(Message::PlayStart &p_PlaySPITStart) {
|
||||
ESP_LOGD(TAG, "parse PlayStart ID: %s Name: %s Running: %d", p_PlaySPITStart.getPlayerID().c_str(), p_PlaySPITStart.getPlayerName().c_str(), (int)p_PlaySPITStart.getPlayerIsRunning());
|
||||
SPITPlayer &spitPlayer = SPITPlayer::getSPITPlayer(p_PlaySPITStart.getPlayerID());
|
||||
spitPlayer.setIsRunning(p_PlaySPITStart.getPlayerIsRunning());
|
||||
spitPlayer.setName(p_PlaySPITStart.getPlayerName());
|
||||
@@ -1179,7 +1179,7 @@ void SPIT_Client::parsePlaySPITStart(SPIT_Message::PlaySPITStart &p_PlaySPITStar
|
||||
|
||||
mCallbacks.onPlay(spitPlayer.getID(), spitPlayer.getName(), spitPlayer.getType(), spitPlayer.getIsRunning(), spitPlayer.getTime());
|
||||
}
|
||||
void SPIT_Client::parsePlaySPITObject(SPIT_Message::PlaySPITObject &p_PlaySPITObject) {
|
||||
void SPIT_Client::parsePlaySPITObject(Message::PlayObject &p_PlaySPITObject) {
|
||||
|
||||
SPITPlayer &ptrSPITPlayer = SPITPlayer::getSPITPlayer(p_PlaySPITObject.getPlayerID());
|
||||
SPITObject *ptrSPITObject = mSpitObjects.getEntry(p_PlaySPITObject.getSPITObjectID());
|
||||
@@ -1195,7 +1195,7 @@ void SPIT_Client::parsePlaySPITObject(SPIT_Message::PlaySPITObject &p_PlaySPITOb
|
||||
ptrPlaySPITType->addValue(((double)p_PlaySPITObject.getValue() / 1000000), ((double)ptrSPITObject->getValueFactor() / 1000000));
|
||||
}
|
||||
|
||||
void SPIT_Client::parsePlaySPITEnd(SPIT_Message::PlaySPITEnd &p_PlaySPITEnd) {
|
||||
void SPIT_Client::parsePlaySPITEnd(Message::PlayEnd &p_PlaySPITEnd) {
|
||||
SPITPlayer &ptrSPITPlayer = SPITPlayer::getSPITPlayer(p_PlaySPITEnd.getPlayerID());
|
||||
|
||||
auto &ptrPlaySPITTypes = ptrSPITPlayer.getPlaySPITTypes();
|
||||
@@ -1214,7 +1214,7 @@ void SPIT_Client::parsePlaySPITEnd(SPIT_Message::PlaySPITEnd &p_PlaySPITEnd) {
|
||||
ptrSPITPlayer.endPlaySequence();
|
||||
}
|
||||
|
||||
void SPIT_Client::parseReportPlayStatus(SPIT_Message::ReportPlayStatus &p_ReportPlayStatus) {
|
||||
void SPIT_Client::parseReportPlayStatus(Message::ReportPlayStatus &p_ReportPlayStatus) {
|
||||
SPITType *ptrSPITType = NULL;
|
||||
|
||||
SPITObject *ptrSPITObject = mRemoteSpitObjects.getEntry(p_ReportPlayStatus.getID());
|
||||
@@ -1257,12 +1257,12 @@ void SPIT_Client::sendRemoteObject(string p_SPITObjectID, int p_Valueppm, char p
|
||||
if (ptrRemoteSPITObject == nullptr)
|
||||
return;
|
||||
|
||||
SPIT_Message::PlaySPITStart playSPITStart(m_ID, m_ProjName, PLAYERTYPE_DISCRETE);
|
||||
Message::PlayStart playSPITStart(m_ID, m_ProjName, PLAYERTYPE_DISCRETE);
|
||||
playSPITStart.setPlayerIsRunning(false);
|
||||
playSPITStart.setTime(0);
|
||||
sendSPITMessage(playSPITStart);
|
||||
|
||||
SPIT_Message::PlaySPITObject playSPITObject;
|
||||
Message::PlayObject playSPITObject;
|
||||
playSPITObject.setID(ptrRemoteSPITObject->getID());
|
||||
playSPITObject.setPlayPrePosition(false);
|
||||
playSPITObject.setPlayerID(m_ID);
|
||||
@@ -1270,7 +1270,7 @@ void SPIT_Client::sendRemoteObject(string p_SPITObjectID, int p_Valueppm, char p
|
||||
playSPITObject.setValueFlag(p_ValueFlag);
|
||||
sendSPITMessage(playSPITObject);
|
||||
|
||||
SPIT_Message::PlaySPITEnd playSPITEnd(m_ID);
|
||||
Message::PlayEnd playSPITEnd(m_ID);
|
||||
sendSPITMessage(playSPITEnd);
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,5 @@
|
||||
UnitTestsFrame()
|
||||
target_link_libraries(${moduleName} PUBLIC
|
||||
fmt
|
||||
hwMock
|
||||
)
|
||||
@@ -0,0 +1,322 @@
|
||||
/**
|
||||
* @file TestableUTest.cpp
|
||||
* @author Gustice
|
||||
* @brief
|
||||
*
|
||||
* @copyright Copyright (c) 2024
|
||||
*/
|
||||
|
||||
#include "doctest/doctest.h"
|
||||
#include <fmt/core.h>
|
||||
#include <iostream>
|
||||
|
||||
#include "spit_message.hpp"
|
||||
|
||||
using namespace spit;
|
||||
|
||||
class SpitMessageFix {
|
||||
protected:
|
||||
};
|
||||
|
||||
void checkData(std::vector<char> a, std::vector<char> b) {
|
||||
CHECK(a.size() == b.size());
|
||||
for (size_t i = 0; i < b.size(); ++i) {
|
||||
CHECK_MESSAGE(a[i] == b[i],
|
||||
fmt::format("Mismatch at index, {} : a = 0x{:02x} , b = 0x{:02x}",
|
||||
i, (int)a[i], (int)b[i]));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE_FIXTURE(SpitMessageFix, "Connect Request") {
|
||||
std::vector<uint8_t> msg = {
|
||||
/*0000*/ 0x23, 0x73, 0x70, 0x69, 0x74, 0x23, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x63, 0x00, 0x00, 0x00, // #spit#......c...
|
||||
/*0010*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
|
||||
/*0020*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
|
||||
/*0030*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x62, 0x33, 0x63, 0x66, 0x32, 0x34, // .........db3cf24
|
||||
/*0040*/ 0x34, 0x2d, 0x36, 0x30, 0x35, 0x39, 0x2d, 0x34, 0x30, 0x65, 0x36, 0x2d, 0x61, 0x33, 0x35, 0x35, // 4-6059-40e6-a355
|
||||
/*0050*/ 0x2d, 0x32, 0x62, 0x66, 0x34, 0x34, 0x36, 0x37, 0x33, 0x32, 0x62, 0x30, 0x36, 0x00, 0x00, 0x00, // -2bf446732b06...
|
||||
/*0060*/ 0x00, 0x00, 0x01, 0x30, 0x01, 0x00, 0x00, 0x64, 0x65, 0x76, 0x70, 0x69, 0x00, 0x00, 0x00, 0x00, // ...0...devpi....
|
||||
/*0070*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
|
||||
/*0080*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
|
||||
/*0090*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
|
||||
/*00a0*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4d, 0x71, 0x74, 0x74, 0x53, 0x70, 0x69, 0x74, 0x42, // .......MqttSpitB
|
||||
/*00b0*/ 0x72, 0x69, 0x64, 0x67, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ridge...........
|
||||
/*00c0*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
|
||||
/*00d0*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
|
||||
/*00e0*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
|
||||
/*00f0*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
|
||||
/*0100*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
|
||||
/*0110*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
|
||||
/*0120*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
|
||||
/*0130*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
|
||||
/*0140*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
|
||||
/*0150*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
|
||||
/*0160*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x31, 0x37, 0x32, 0x2e, 0x31, 0x36, 0x2e, 0x31, 0x36, // .......172.16.16
|
||||
/*0170*/ 0x2e, 0x31, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .10.............
|
||||
/*0180*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, // ................
|
||||
/*0190*/ 0x3b, 0x00, 0x00 // ;..
|
||||
};
|
||||
std::vector<char> msgC(msg.begin(), msg.end());
|
||||
|
||||
{
|
||||
Message sut = Message(msgC);
|
||||
CHECK_EQ(sut.getType(), Message::Connect::OPFLAG);
|
||||
auto &pM = sut.getAs<Message::Connect>();
|
||||
|
||||
CHECK_EQ(pM.getClientComputerName(), "devpi");
|
||||
CHECK_EQ(pM.getClientName(), "MqttSpitBridge");
|
||||
CHECK_EQ(pM.getLoginName(), "");
|
||||
CHECK_EQ(pM.getLoginPassword(), "");
|
||||
CHECK_EQ(pM.getServerIP(), "172.16.16.10");
|
||||
CHECK_EQ(pM.getServerPort(), 15120);
|
||||
}
|
||||
|
||||
{
|
||||
Message::Connect sut("devpi", "MqttSpitBridge");
|
||||
sut.setLoginName("");
|
||||
sut.setLoginPassword("");
|
||||
sut.setServerIP("172.16.16.10");
|
||||
sut.setServerPort(15120);
|
||||
|
||||
sut.setMessageNumber(2);
|
||||
sut.setServerInfoInHeader("db3cf244-6059-40e6-a355-2bf446732b06", "");
|
||||
auto data = Message::createMessage(sut);
|
||||
|
||||
CHECK(data.size() == msg.size());
|
||||
for (size_t i = 0; i < msg.size(); ++i) {
|
||||
CHECK_MESSAGE(data[i] == msgC[i],
|
||||
fmt::format("Mismatch at index, {} : a = 0x{:02x} , b = 0x{:02x}",
|
||||
i, (int)data[i], (int)msg[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE_FIXTURE(SpitMessageFix, "Connect Response") {
|
||||
std::vector<uint8_t> msg = {
|
||||
/*0000*/ 0x23, 0x73, 0x70, 0x69, 0x74, 0x23, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x63, 0x00, 0x00, 0x00, // #spit#......c...
|
||||
/*0010*/ 0x34, 0x30, 0x35, 0x63, 0x37, 0x31, 0x30, 0x30, 0x2d, 0x36, 0x34, 0x65, 0x38, 0x2d, 0x34, 0x33, // 405c7100-64e8-43
|
||||
/*0020*/ 0x35, 0x64, 0x2d, 0x38, 0x61, 0x37, 0x62, 0x2d, 0x30, 0x30, 0x63, 0x35, 0x36, 0x32, 0x39, 0x66, // 5d-8a7b-00c5629f
|
||||
/*0030*/ 0x39, 0x63, 0x63, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x62, 0x33, 0x63, 0x66, 0x32, 0x34, // 9ccf.....db3cf24
|
||||
/*0040*/ 0x34, 0x2d, 0x36, 0x30, 0x35, 0x39, 0x2d, 0x34, 0x30, 0x65, 0x36, 0x2d, 0x61, 0x33, 0x35, 0x35, // 4-6059-40e6-a355
|
||||
/*0050*/ 0x2d, 0x32, 0x62, 0x66, 0x34, 0x34, 0x36, 0x37, 0x33, 0x32, 0x62, 0x30, 0x36, 0x00, 0x00, 0x00, // -2bf446732b06...
|
||||
/*0060*/ 0x00, 0x00, 0x02, 0x89, 0x00, 0x00, 0x00, 0x50, 0x31, 0x37, 0x67, 0x65, 0x6e, 0x31, 0x00, 0x00, // .......P17gen1..
|
||||
/*0070*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
|
||||
/*0080*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
|
||||
/*0090*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
|
||||
/*00a0*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c, 0x69, 0x76, 0x65, 0x53, 0x48, 0x4f, 0x57, 0x00, // .......liveSHOW.
|
||||
/*00b0*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
|
||||
/*00c0*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
|
||||
/*00d0*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
|
||||
/*00e0*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x01 // .......(....
|
||||
};
|
||||
std::vector<char> msgC(msg.begin(), msg.end());
|
||||
|
||||
{
|
||||
Message sut = Message(msgC);
|
||||
CHECK_EQ(sut.getType(), Message::ConnectAnswer::OPFLAG);
|
||||
auto &pM = sut.getAs<Message::ConnectAnswer>();
|
||||
|
||||
CHECK_EQ(pM.getServerComputerName(), "P17gen1");
|
||||
CHECK_EQ(pM.getServerName(), "liveSHOW");
|
||||
CHECK_EQ(pM.getConnected(), true);
|
||||
CHECK_EQ(pM.getStepTime(), 40);
|
||||
}
|
||||
|
||||
{
|
||||
Message::ConnectAnswer sut;
|
||||
sut.setServerComputerName("P17gen1");
|
||||
sut.setServerName("liveSHOW");
|
||||
sut.setConnected(true);
|
||||
sut.setStepTime(40);
|
||||
|
||||
sut.setMessageNumber(1);
|
||||
sut.setServerInfoInHeader("db3cf244-6059-40e6-a355-2bf446732b06", "405c7100-64e8-435d-8a7b-00c5629f9ccf");
|
||||
auto data = Message::createMessage(sut);
|
||||
checkData(data, msgC);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE_FIXTURE(SpitMessageFix, "Report Spit Type") {
|
||||
std::vector<uint8_t> msg = {
|
||||
/*0000*/ 0x23, 0x73, 0x70, 0x69, 0x74, 0x23, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x63, 0x00, 0x00, 0x00, // #spit#......c...
|
||||
/*0010*/ 0x34, 0x30, 0x35, 0x63, 0x37, 0x31, 0x30, 0x30, 0x2d, 0x36, 0x34, 0x65, 0x38, 0x2d, 0x34, 0x33, // 405c7100-64e8-43
|
||||
/*0020*/ 0x35, 0x64, 0x2d, 0x38, 0x61, 0x37, 0x62, 0x2d, 0x30, 0x30, 0x63, 0x35, 0x36, 0x32, 0x39, 0x66, // 5d-8a7b-00c5629f
|
||||
/*0030*/ 0x39, 0x63, 0x63, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x62, 0x33, 0x63, 0x66, 0x32, 0x34, // 9ccf.....db3cf24
|
||||
/*0040*/ 0x34, 0x2d, 0x36, 0x30, 0x35, 0x39, 0x2d, 0x34, 0x30, 0x65, 0x36, 0x2d, 0x61, 0x33, 0x35, 0x35, // 4-6059-40e6-a355
|
||||
/*0050*/ 0x2d, 0x32, 0x62, 0x66, 0x34, 0x34, 0x36, 0x37, 0x33, 0x32, 0x62, 0x30, 0x36, 0x00, 0x00, 0x00, // -2bf446732b06...
|
||||
/*0060*/ 0x00, 0x00, 0x15, 0xa8, 0x00, 0x00, 0x00, 0x01, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x6f, // ........ActionMo
|
||||
/*0070*/ 0x76, 0x65, 0x54, 0x6f, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // veTo1...........
|
||||
/*0080*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
|
||||
/*0090*/ 0x00, 0x01, 0x00, 0x01, 0x43, 0x61, 0x74, 0x61, 0x73, 0x57, 0x61, 0x74, 0x63, 0x68, 0x4d, 0x6f, // ....CatasWatchMo
|
||||
/*00a0*/ 0x76, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // vement..........
|
||||
/*00b0*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x63, 0x74, 0x69, 0x6f, // ...........Actio
|
||||
/*00c0*/ 0x6e, 0x4d, 0x6f, 0x76, 0x65, 0x54, 0x6f, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // nMoveTo1........
|
||||
/*00d0*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
|
||||
/*00e0*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
|
||||
/*00f0*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
|
||||
/*0100*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // ...........
|
||||
};
|
||||
std::vector<char> msgC(msg.begin(), msg.end());
|
||||
|
||||
{
|
||||
Message sut = Message(msgC);
|
||||
CHECK_EQ(sut.getType(), Message::ReportType::OPFLAG);
|
||||
auto &pM = sut.getAs<Message::ReportType>();
|
||||
|
||||
CHECK_EQ(pM.getConfirmed(), true);
|
||||
CHECK_EQ(pM.getID(), "ActionMoveTo1");
|
||||
CHECK_EQ(pM.getFixed(), true);
|
||||
CHECK_EQ(pM.getServerRemote(), false);
|
||||
CHECK_EQ(pM.getServerProjectIndepended(), true);
|
||||
CHECK_EQ(pM.getGroupName(), "CatasWatchMovement");
|
||||
CHECK_EQ(pM.getName(), "ActionMoveTo1");
|
||||
CHECK_EQ(pM.getDelay(), 0);
|
||||
CHECK_EQ(pM.getDuration(), 0);
|
||||
}
|
||||
|
||||
{
|
||||
Message::ReportType sut;
|
||||
sut.setConfirmed(true);
|
||||
sut.setID("ActionMoveTo1");
|
||||
sut.setFixed(true);
|
||||
sut.setServerRemote(false);
|
||||
sut.setServerProjectIndepended(true);
|
||||
sut.setGroupName("CatasWatchMovement");
|
||||
sut.setName("ActionMoveTo1");
|
||||
sut.setDelay(0);
|
||||
sut.setDuration(0);
|
||||
|
||||
sut.setMessageNumber(6);
|
||||
sut.setServerInfoInHeader("db3cf244-6059-40e6-a355-2bf446732b06", "405c7100-64e8-435d-8a7b-00c5629f9ccf");
|
||||
auto data = Message::createMessage(sut);
|
||||
|
||||
checkData(data, msgC);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE_FIXTURE(SpitMessageFix, "Report Spit Object") {
|
||||
std::vector<uint8_t> msg = {
|
||||
/*0000*/ 0x23, 0x73, 0x70, 0x69, 0x74, 0x23, 0x00, 0x01, 0x00, 0x00, 0x00, 0x15, 0x63, 0x00, 0x00, 0x00, // #spit#......c...
|
||||
/*0010*/ 0x34, 0x30, 0x35, 0x63, 0x37, 0x31, 0x30, 0x30, 0x2d, 0x36, 0x34, 0x65, 0x38, 0x2d, 0x34, 0x33, // 405c7100-64e8-43
|
||||
/*0020*/ 0x35, 0x64, 0x2d, 0x38, 0x61, 0x37, 0x62, 0x2d, 0x30, 0x30, 0x63, 0x35, 0x36, 0x32, 0x39, 0x66, // 5d-8a7b-00c5629f
|
||||
/*0030*/ 0x39, 0x63, 0x63, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x62, 0x33, 0x63, 0x66, 0x32, 0x34, // 9ccf.....db3cf24
|
||||
/*0040*/ 0x34, 0x2d, 0x36, 0x30, 0x35, 0x39, 0x2d, 0x34, 0x30, 0x65, 0x36, 0x2d, 0x61, 0x33, 0x35, 0x35, // 4-6059-40e6-a355
|
||||
/*0050*/ 0x2d, 0x32, 0x62, 0x66, 0x34, 0x34, 0x36, 0x37, 0x33, 0x32, 0x62, 0x30, 0x36, 0x00, 0x00, 0x00, // -2bf446732b06...
|
||||
/*0060*/ 0x00, 0x00, 0x1f, 0x53, 0x01, 0x00, 0x00, 0x01, 0x30, 0x30, 0x30, 0x30, 0x30, 0x6d, 0x68, 0x63, // ...S....00000mhc
|
||||
/*0070*/ 0x67, 0x65, 0x64, 0x30, 0x69, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, // ged0i00000000000
|
||||
/*0080*/ 0x30, 0x30, 0x30, 0x30, 0x30, 0x7a, 0x34, 0x30, 0x74, 0x63, 0x79, 0x6b, 0x63, 0x33, 0x00, 0x00, // 00000z40tcykc3..
|
||||
/*0090*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
|
||||
/*00a0*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
|
||||
/*00b0*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
|
||||
/*00c0*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
|
||||
/*00d0*/ 0x00, 0x00, 0x00, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x6f, 0x76, 0x65, 0x54, 0x6f, 0x31, // ...ActionMoveTo1
|
||||
/*00e0*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
|
||||
/*00f0*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0x69, 0x70, 0x00, // ............vip.
|
||||
/*0100*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
|
||||
/*0110*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
|
||||
/*0120*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
|
||||
/*0130*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6d, 0xfc, 0x12, 0x00, // ............m...
|
||||
/*0140*/ 0x00, 0x00, 0x00, 0x00, 0x4b, 0xd0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ....K...........
|
||||
/*0150*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x42, 0x0f, 0x00, // ............@B..
|
||||
/*0160*/ 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
|
||||
/*0170*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
|
||||
/*0180*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
|
||||
/*0190*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
|
||||
/*01a0*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
|
||||
/*01b0*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // ......
|
||||
};
|
||||
std::vector<char> msgC(msg.begin(), msg.end());
|
||||
|
||||
{
|
||||
Message sut = Message(msgC);
|
||||
CHECK_EQ(sut.getType(), Message::ReportObject::OPFLAG);
|
||||
auto &pM = sut.getAs<Message::ReportObject>();
|
||||
|
||||
CHECK_EQ(pM.getConfirmed(), true);
|
||||
CHECK_EQ(pM.getID(), "00000mhcged0i0000000000000000z40tcykc3");
|
||||
CHECK_EQ(pM.getFixed(), false);
|
||||
CHECK_EQ(pM.getServerRemote(), false);
|
||||
CHECK_EQ(pM.getName(), "");
|
||||
CHECK_EQ(pM.getSPITTypeID(), "ActionMoveTo1");
|
||||
CHECK_EQ(pM.getServerParams(), "vip");
|
||||
CHECK_EQ(pM.getFrameStart(), 1244269);
|
||||
CHECK_EQ(pM.getFrameLength(), 53323);
|
||||
CHECK_EQ(pM.getFrameFadeInLength(), 0);
|
||||
CHECK_EQ(pM.getFrameFadeOutLength(), 0);
|
||||
CHECK_EQ(pM.getValueFactor(), 1000000);
|
||||
CHECK_EQ(pM.getValueUse(), 0);
|
||||
CHECK_EQ(pM.getTrack(), 1);
|
||||
CHECK_EQ(pM.getRemark(), "");
|
||||
CHECK_EQ(pM.getDelay(), 0);
|
||||
CHECK_EQ(pM.getDuration(), 0);
|
||||
CHECK_EQ(pM.getActionAssigned(), false);
|
||||
}
|
||||
|
||||
{
|
||||
Message::ReportObject sut;
|
||||
sut.setConfirmed(true);
|
||||
sut.setID("00000mhcged0i0000000000000000z40tcykc3");
|
||||
sut.setFixed(false);
|
||||
sut.setServerRemote(false);
|
||||
sut.setName("");
|
||||
sut.setSPITTypeID("ActionMoveTo1");
|
||||
sut.setServerParams("vip");
|
||||
sut.setFrameStart(1244269);
|
||||
sut.setFrameLength(53323);
|
||||
sut.setFrameFadeInLength(0);
|
||||
sut.setFrameFadeOutLength(0);
|
||||
sut.setValueFactor(1000000);
|
||||
sut.setValueUse(0);
|
||||
sut.setTrack(1);
|
||||
sut.setRemark("");
|
||||
sut.setDelay(0);
|
||||
sut.setDuration(0);
|
||||
sut.setActionAssigned(false);
|
||||
|
||||
sut.setMessageNumber(21);
|
||||
sut.setServerInfoInHeader("db3cf244-6059-40e6-a355-2bf446732b06", "405c7100-64e8-435d-8a7b-00c5629f9ccf");
|
||||
auto data = Message::createMessage(sut);
|
||||
|
||||
checkData(data, msgC);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE_FIXTURE(SpitMessageFix, "Report Play Object") {
|
||||
std::vector<uint8_t> msg = {
|
||||
/*0000*/ 0x23, 0x73, 0x70, 0x69, 0x74, 0x23, 0x00, 0x01, 0x00, 0x00, 0x00, 0x83, 0x63, 0x00, 0x00, 0x00, // #spit#......c...
|
||||
/*0010*/ 0x34, 0x30, 0x35, 0x63, 0x37, 0x31, 0x30, 0x30, 0x2d, 0x36, 0x34, 0x65, 0x38, 0x2d, 0x34, 0x33, // 405c7100-64e8-43
|
||||
/*0020*/ 0x35, 0x64, 0x2d, 0x38, 0x61, 0x37, 0x62, 0x2d, 0x30, 0x30, 0x63, 0x35, 0x36, 0x32, 0x39, 0x66, // 5d-8a7b-00c5629f
|
||||
/*0030*/ 0x39, 0x63, 0x63, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x62, 0x33, 0x63, 0x66, 0x32, 0x34, // 9ccf.....db3cf24
|
||||
/*0040*/ 0x34, 0x2d, 0x36, 0x30, 0x35, 0x39, 0x2d, 0x34, 0x30, 0x65, 0x36, 0x2d, 0x61, 0x33, 0x35, 0x35, // 4-6059-40e6-a355
|
||||
/*0050*/ 0x2d, 0x32, 0x62, 0x66, 0x34, 0x34, 0x36, 0x37, 0x33, 0x32, 0x62, 0x30, 0x36, 0x00, 0x00, 0x00, // -2bf446732b06...
|
||||
/*0060*/ 0x00, 0x00, 0x28, 0x39, 0x00, 0x00, 0x00, 0x30, 0x30, 0x30, 0x30, 0x30, 0x6d, 0x38, 0x75, 0x65, // ..(9...00000m8ue
|
||||
/*0070*/ 0x64, 0x79, 0x79, 0x74, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, // dyyt000000000000
|
||||
/*0080*/ 0x30, 0x30, 0x30, 0x31, 0x66, 0x6a, 0x30, 0x76, 0x61, 0x38, 0x62, 0x6f, 0x6d, 0x00, 0x00, 0x00, // 0001fj0va8bom...
|
||||
/*0090*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // ............
|
||||
};
|
||||
std::vector<char> msgC(msg.begin(), msg.end());
|
||||
|
||||
{
|
||||
Message sut = Message(msgC);
|
||||
CHECK_EQ(sut.getType(), Message::ReportPlayStatus::OPFLAG);
|
||||
auto &pM = sut.getAs<Message::ReportPlayStatus>();
|
||||
|
||||
CHECK_EQ(pM.getID(), "00000m8uedyyt0000000000000001fj0va8bom");
|
||||
CHECK_EQ(pM.getFrameInsideObject(), 0);
|
||||
CHECK_EQ(pM.getValue(), 0);
|
||||
}
|
||||
|
||||
{
|
||||
Message::ReportPlayStatus sut;
|
||||
sut.setID("00000m8uedyyt0000000000000001fj0va8bom");
|
||||
sut.setFrameInsideObject(0);
|
||||
sut.setValue(0);
|
||||
|
||||
sut.setMessageNumber(131);
|
||||
sut.setServerInfoInHeader("db3cf244-6059-40e6-a355-2bf446732b06", "405c7100-64e8-435d-8a7b-00c5629f9ccf");
|
||||
auto data = Message::createMessage(sut);
|
||||
|
||||
checkData(data, msgC);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* @file uTestMain.cpp
|
||||
* @author Gustice
|
||||
* @brief
|
||||
*/
|
||||
|
||||
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
|
||||
#include "doctest/doctest.h"
|
||||
TEST_CASE("TestTest") {
|
||||
CHECK(true == true);
|
||||
}
|
||||
Reference in New Issue
Block a user