feature: Project builds with integrated SPIT client (however with some exclusions)

This commit is contained in:
2025-02-15 22:18:06 +01:00
parent 500641a6e2
commit 4e94d7ad78
15 changed files with 257 additions and 910 deletions
+89 -284
View File
@@ -1,51 +1,13 @@
/*
* 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.cpp
* Author: Hagi
*
* Created on 17. April 2019, 06:24 pm
* Changed on 01. May 2020, 12:00 am
*
* Description:
* A SPITClient defines actions (functions) and connects to a SPITServer.
* The actions are assigned to SPITTypes.
* The client may create its own SPITTypes, which are sended to the server or receives SPITTypes from the server.
* Each SPIType can trigger exactly one action.
* The server may use this SPITTypes to create and play SPITObjects, he can create several SPITObjects from one SPITType.
* Each SPITObject is assigned exactly one SPITType.
* When the server plays a SPITObject, an event function (eventPlayObject) is called in the client.
* The client can then trigger the action for the assigned SPITType.
* --------------------------------------------------------------------------------------------------
* all event.. functions are executed by a single SPIT_Handler thread.
* -> The event functions are called singlethreaded one after the other.
* --------------------------------------------------------------------------------------------------
*/
#include "MyApp.h"
#include "Task.hpp"
#include "esp_log.h"
string MyApp::s_ClientName = "MySPITApp_Client"; //Name of this Client
string MyApp::s_ClientProjectName = "MySPITAppProject"; //Name of the client'loaded project
string MyApp::s_ClientProjectID = s_ClientProjectName; //ID of the client's project - maybe the same as the name or a specific id
const char * TAG = "SPIT";
#if defined(OS_WINDOWS)
//Win32 Main Function - application entry
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR lpCmdLine, INT nCmdShow) {
return main();
}
#endif
//UNIX and Win64 Main function - application entry
int main() {
MyApp* ptrMyApp;
//Create a MyApp instance
ptrMyApp = new MyApp();
void SpitClientApp() {
auto ptrMyApp = std::make_unique<MyApp>();
//load a client project
//the client project may belong to a server's project or may be independend of server's projects
@@ -61,41 +23,19 @@ int main() {
//autodetection of SPITServers ends automaticallay when this SPITClient is connected to a SPITServer
ptrMyApp->startServerAutoDetect();
//This application is multthreaded, in the background all is done by several threads
//all events are delegated to SPIT_Handler
//-> the eventxxx functions are called by the one and only SPIT_Handler's thread s_HandlerThread
//-> the eventxxx functions are called singlethreaded
//Normally MyApp will have a user interface to decide when the app has to be closed.
//Actual we have no user interface -> sleep a while
//We can put the actual thread to sleep, because the events are executed by the SPIT_Handler-Thread s_HandlerThread.
printf("---THE APPLICATION RUNS FOR 60 SECONDS AND STOPS AUTOMATICALLY---\n\n");
this_thread::sleep_for(chrono::milliseconds(30000));
ptrMyApp->testLiveShowRemote(); //This is an excample how to remote control the liveSHOWsoftware
this_thread::sleep_for(chrono::milliseconds(30000));
//perhaps you should save the client project
//close MyApp instance
delete ptrMyApp;
return 0;
while (true) {
fos::Task::delayMs(10000);
ptrMyApp->testLiveShowRemote(); //This is an excample how to remote control the liveSHOWsoftware
}
}
MyApp::MyApp() {
//create a new SPIT_Client instance
//the SPIT_Client will do the main work for you (receiving/sending SPIT_Messages ....)
m_SPIT_Client = new SPIT_Client(this);
//You need to give your application a descriptive name
m_SPIT_Client->setName(s_ClientName);
//The following members are set in loadClientProject function.
m_ClientProjectName = "";
m_ClientProjectID = ""; //id can be the same as the project name
m_ClientProjectID = "";
//The following members are set in the eventConnectionStatus
m_ServerID = "";
@@ -107,18 +47,11 @@ MyApp::MyApp() {
m_ServerProjectID = "";
m_ServerProjectName = "";
m_ServerFramesPerSecond = 44100; //is reset in eventProjectReport.
//perhaps you may save the value from the last connection and set it here
//liveSHOWsoftware will use 44100 frames per second as time resolution
//All times are given in frames,
//with this parameter you can convert the times into milliseconds/seconds ...
//Used to decide if a reconnection is tried after the connection is lost
//see eventServerDetected and eventConnectionStatus
m_FlagReconnect = false;
}
MyApp::~MyApp() {
//To close the connection and all other stuff delete the SPIT_Client instance
if (m_SPIT_Client != NULL) {
@@ -128,71 +61,40 @@ MyApp::~MyApp() {
//Following functions fullfill the SPIT_ClientInterface
//They are needed when the server sends his project, see eventProjectReport
//and they should be set in loadClientProject
string MyApp::getClientProjectID() {
return m_ClientProjectID;
}
//Following functions fullfill the SPIT_ClientInterface
//They are needed when the server sends his project, see eventProjectReport
string MyApp::getClientProjectName() {
return m_ClientProjectName;
}
void MyApp::loadClientProject() {
//----- close the actual client project -----
//inform the SPIT_Client that the actual project will close
//If there is actual no connection to the server nothing happens
//----- close current client project -----
if (m_SPIT_Client != NULL) {
m_SPIT_Client->clientProjectClose();
}
//close the project
//----- load new client project -----
// Add your loading code here
//If your application is a small one using only a few fixed actions
//you may keep the things simple and code all loading here
m_ClientProjectID = s_ClientProjectID; //maybe the same as s_ClientProjectName
m_ClientProjectName = s_ClientProjectName;
//Create SPITTypes for all functions of this client
//--- Excample ---
//the client owns two fixed functionality named "Action1" and "Action2"
if (m_SPIT_Client != NULL) {
//FIXED SPITTYPES
//Create SPITTypes for all discrete and unchangable functions of this client. Fixed means the server can't change or remove the SPITType.
//-> Create a SPITTypes according to the following patterns
//Excample "Action1"
SPITType* ptrSPITType1Fix;
ptrSPITType1Fix = m_SPIT_Client->createSPITTypeFixed("MySPITAPP_Action1ID", "MyActionGroupName", "FixedAction1", 0, 0);
//When an action exist which shpuld be done whenever a SPITObject with this SPITType is played, <br>
ptrSPITType1Fix = m_SPIT_Client->createSPITTypeFixed("MySPITAPP_Action1ID", "ActionGroupName", "Action1Name", 0, 0);
SPITType* ptrSPITType2Fix;
ptrSPITType2Fix = m_SPIT_Client->createSPITTypeFixed("MySPITAPP_Action2ID", "ActionGroupName", "Action2Name", 0, 0);
//When an action exist which should be done whenever a SPITObject with this SPITType is played, <br>
//then you should 'setAssignedActionType' to true
m_SPIT_Client->setActionSPITType(ptrSPITType1Fix->getID(), true);
//Excample "Action2"
SPITType* ptrSPITType2Fix;
ptrSPITType2Fix = m_SPIT_Client->createSPITTypeFixed("MySPITAPP_Action2ID", "MyActionGroupName", "FixedAction2", 0, 0);
//When an action exist which shpuld be done whenever a SPITObject with this SPITType is played, <br>
//then you should 'setAssignedActionType' to true
m_SPIT_Client->setActionSPITType(ptrSPITType2Fix->getID(), true);
//later in the eventPlayObject you can react with your action code for "Action1" and "Action2"
//CHANGABLE SPITYPES
//Create SPITTypes which are changable or temporarly, the server may change or delete them.
ptrSPITType2Fix = m_SPIT_Client->createSPITType("MySPITAPP_ActionTemp1ID", "MyActionGroupName", "TempAction1", 0, 0, false, true);
//When an action exist which shpuld be done whenever a SPITObject with this SPITType is played, <br>
//then you should 'setAssignedActionType' to true
m_SPIT_Client->setActionSPITType(ptrSPITType2Fix->getID(), true);
}
//--- End Excample ---
//----- inform the SPIT_Client that a new project is loaded -----
if (m_SPIT_Client != NULL) {
m_SPIT_Client->clientProjectLoaded();
}
}
//-----------------------------------------
@@ -223,33 +125,24 @@ void MyApp::stopServerAutoDetect() {
*/
void MyApp::eventServerDetected(const SAD_DetectedServer& p_DetectedServer) {
//fetch the infoemations from the p_DetectedServer
#if defined(DEBUGOUTPUT)
printf("mySPITApp\n");
printf("-----> SERVER DETECTED\n");
printf(" Name: %s\n", p_DetectedServer.getName().data());
printf(" ID: %s\n", p_DetectedServer.getID().data());
printf(" Computer: %s\n", p_DetectedServer.getComputerName().data());
printf(" IP: %s\n", p_DetectedServer.getIP().data());
printf(" Port: %s\n", p_DetectedServer.getPort().data());
printf(" Addition: %s\n", p_DetectedServer.getAdditions().data());
printf(" ClientIP: %s\n", p_DetectedServer.getClientIP().data());
printf("\n");
#endif
ESP_LOGD(TAG, "SERVER DETECTED");
ESP_LOGD(TAG, " Name: %s", p_DetectedServer.getName().data());
ESP_LOGD(TAG, " ID: %s", p_DetectedServer.getID().data());
ESP_LOGD(TAG, " Computer: %s", p_DetectedServer.getComputerName().data());
ESP_LOGD(TAG, " IP: %s", p_DetectedServer.getIP().data());
ESP_LOGD(TAG, " Port: %s", p_DetectedServer.getPort().data());
ESP_LOGD(TAG, " Addition: %s", p_DetectedServer.getAdditions().data());
ESP_LOGD(TAG, " ClientIP: %s", p_DetectedServer.getClientIP().data());
bool boolSuccess;
bool boolSuccess = false;
//---------- RECONNECTION ----------
//If a connection has been established and the connection is lost -> reconnect
boolSuccess = false;
if (m_FlagReconnect == true) {
//check if the server is the same as prior connected
if (m_ServerID == p_DetectedServer.getID()) {
//reconnect
if (m_SPIT_Client != NULL) {
stopServerAutoDetect();
#if defined(DEBUGOUTPUT)
printf("MySPITApp: reconnect to %s ", p_DetectedServer.getIP().data());
#endif
ESP_LOGI(TAG,"reconnect to %s", p_DetectedServer.getIP().data());
boolSuccess = m_SPIT_Client->connect(p_DetectedServer.getIP(), p_DetectedServer.getPort(), p_DetectedServer.getClientIP(), "0"); //ClientPort = "0" meeans use any port
if (boolSuccess == true) {
return;
@@ -258,33 +151,21 @@ void MyApp::eventServerDetected(const SAD_DetectedServer& p_DetectedServer) {
}
}
// --------------------------------------
// You have three Options to use the detected server
// OPTION 1 Use the first server found
// OPTION 2 Use the first server found that fulfills specific conditions
// OPTION 3 take a copy of the p_DetectedServer and do connection later
// SAD_DetectedServer o_DetectedServer = p_DetectedServer; //this will call the copy constructor
// ---------------------------------------
//Excample use the first detected LOOPBACK server, means the server runs on the same computer as this client
//if (p_DetectedServer.getIpIsLoopback() == true) { //omit the if condition if you want to use the first server found
boolSuccess = false;
//Stop auto detection because a suitable server was found
stopServerAutoDetect();
if (m_SPIT_Client != NULL) {
#if defined(DEBUGOUTPUT)
printf("MySPITApp: connect to %s ", p_DetectedServer.getIP().data());
#endif
boolSuccess = m_SPIT_Client->connect(p_DetectedServer.getIP(), p_DetectedServer.getPort(), p_DetectedServer.getClientIP(), "0"); //ClientPort = "0" meeans use any port
}
if (boolSuccess == false) {
//connection message could not be sent
//perhaps restart AutoDetection
startServerAutoDetect();
}
// } //Excample
if (p_DetectedServer.getIpIsLoopback() == true) { //omit the if condition if you want to use the first server found
return;
}
boolSuccess = false;
//Stop auto detection because a suitable server was found
stopServerAutoDetect();
if (m_SPIT_Client != NULL) {
ESP_LOGI(TAG,"connect to %s", p_DetectedServer.getIP().data());
boolSuccess = m_SPIT_Client->connect(p_DetectedServer.getIP(), p_DetectedServer.getPort(), p_DetectedServer.getClientIP(), "0"); //ClientPort = "0" meeans use any port
}
if (boolSuccess == false) {
//connection message could not be sent -> better to restart AutoDetection
startServerAutoDetect();
}
}
@@ -300,12 +181,7 @@ void MyApp::eventServerDetected(const SAD_DetectedServer& p_DetectedServer) {
* After this function call the copy of the SAD_DetectedServer will be deleted!!<br>
*/
void MyApp::eventServerLost(const SAD_DetectedServer& p_DetectedServer) {
#if defined(DEBUGOUTPUT)
printf("\n");
printf("-----> SERVER LOST\n");
printf("Name: %s IP: %s\n", p_DetectedServer.getName().data(), p_DetectedServer.getIP().data());
printf("\n");
#endif
ESP_LOGW(TAG, "Server lost Name: %s IP: %s", p_DetectedServer.getName().data(), p_DetectedServer.getIP().data());
}
@@ -313,19 +189,13 @@ void MyApp::eventServerLost(const SAD_DetectedServer& p_DetectedServer) {
//---------- Connecting event ----------
void MyApp::eventConnectionStatus(string p_ServerID, string p_ServerComputerName, string p_ServerName, int p_ServerStepTime, int p_ConnectionStatus, int p_OldConnectionStatus) {
#if defined(DEBUGOUTPUT)
printf("MySPITApp: eventConnectionStatus %d ", p_ConnectionStatus);
#endif
ESP_LOGD(TAG, "eventConnectionStatus %d ", p_ConnectionStatus);
switch(p_ConnectionStatus) {
case SPIT_Client::CONNECTION_NONE:
#if defined(DEBUGOUTPUT)
printf(" not connected\n");
#endif
ESP_LOGD(TAG, "not connected");
break;
case SPIT_Client::CONNECTION_NONESERVER:
#if defined(DEBUGOUTPUT)
printf(" connection terminated by server\n");
#endif
ESP_LOGD(TAG, "connection terminated by server");
//call eventProjectClosed because this may not be sended by the server,
//when the connstion is closed
eventProjectClosed(m_ServerProjectID);
@@ -335,9 +205,7 @@ void MyApp::eventConnectionStatus(string p_ServerID, string p_ServerComputerName
startServerAutoDetect();
break;
case SPIT_Client::CONNECTION_OK:
#if defined(DEBUGOUTPUT)
printf(" connection established\n");
#endif
ESP_LOGD(TAG, "connection established");
stopServerAutoDetect(); //normally you should stop the autodetection before you try a connection
//This is redundand
m_ServerID = p_ServerID;
@@ -350,9 +218,7 @@ void MyApp::eventConnectionStatus(string p_ServerID, string p_ServerComputerName
m_FlagReconnect = false;
break;
case SPIT_Client::CONNECTION_LOST:
#if defined(DEBUGOUTPUT)
printf(" connection lost\n");
#endif
ESP_LOGD(TAG, "connection lost");
//Maybe you want to reconnect, see eventServerDetected(...)
//We have lost the connection -> set the flag to true and start the autodetection to reconnect at eventServerDetected(...)
m_FlagReconnect = true;
@@ -376,10 +242,7 @@ void MyApp::eventConnectionStatus(string p_ServerID, string p_ServerComputerName
* @param p_FramesPerSeoond All times in SPIT are given in frames. FramesPerSecond can be used to convert frames to seconds....
*/
void MyApp::eventProjectReport(string p_ProjectID, string p_ProjectName, int p_FramesPerSeoond) {
#if defined(DEBUGOUTPUT)
printf("\n");
printf("MySPITApp: eventProjectReport ID: %s Name: %s FramesPerSecond: %d\n", p_ProjectID.data(), p_ProjectName.data(), p_FramesPerSeoond);
#endif
ESP_LOGD(TAG, "eventProjectReport ID: %s Name: %s FramesPerSecond: %d", p_ProjectID.data(), p_ProjectName.data(), p_FramesPerSeoond);
m_ServerProjectID = p_ProjectID;
m_ServerProjectName = p_ProjectName;
m_ServerFramesPerSecond = p_FramesPerSeoond;
@@ -388,18 +251,15 @@ void MyApp::eventProjectReport(string p_ProjectID, string p_ProjectName, int p_F
m_ServerFramesPerSecond = p_FramesPerSeoond;
//When the this client's project depends on the server's project -> load some specific informations here
}
/**
* Called when the server closes his project.<br>
* @param p_ProjectID the id of the project<br>
* The server loads only one project at time-> the ID is not actually necessary
*/
void MyApp::eventProjectClosed(string p_ProjectID) {
#if defined(DEBUGOUTPUT)
printf("MySPITApp: eventProjectClosed ID: %s\n", p_ProjectID.data());
printf("\n");
#endif
ESP_LOGD(TAG, "eventProjectClosed ID: %s", p_ProjectID.data());
//If we don't save SPITServer's project specific information
//perhaps close all SPITObjects and RemoteSPITObjects to avoid conflicts, when the SPITServer loads a new project
//SPITObject::clearSPITObjects();
@@ -413,23 +273,17 @@ void MyApp::eventProjectClosed(string p_ProjectID) {
* At the end eventEndProjectTransfer is called.
*/
void MyApp::eventStartProjectTransfer() {
#if defined(DEBUGOUTPUT)
printf("MySPITApp: eventStartProjectTransfer\n");
#endif
ESP_LOGD(TAG, "eventStartProjectTransfer");
}
/**
* The transfer of the server's SPITTypes and SPITObjects is finished.<br>
* AFter this all eventSPITType and eventSPITObject means that new types , objects are created or changed.
*/
void MyApp::eventEndProjectTransfer() {
#if defined(DEBUGOUTPUT)
printf("MySPITApp: eventEndProjectTransfer\n");
#endif
ESP_LOGD(TAG, "eventEndProjectTransfer");
}
//----------------------------------------------------
//--------- SPITType events ----------
@@ -475,19 +329,13 @@ void MyApp::eventSPITType(bool p_New, const SPITType& p_SPITType) {
//fetch information of the SPITType
if (p_New) {
//a new SPITType is created
#if defined(DEBUGOUTPUT)
printf("MySPITApp: eventSPITType NEW");
#endif
ESP_LOGD(TAG, "eventSPITType NEW");
}
else {
//an existing SPITType is changed
#if defined(DEBUGOUTPUT)
printf("MySPITApp: eventSPITType CHANGED");
#endif
ESP_LOGD(TAG, "eventSPITType CHANGED");
}
#if defined(DEBUGOUTPUT)
printf(" ID: %s GroupName: %s Name: %s confirmed: %d\n", p_SPITType.getID().data(), p_SPITType.getGroupName().data(), p_SPITType.getName().data(), p_SPITType.getConfirmed());
#endif
ESP_LOGD(TAG, " ID: %s GroupName: %s Name: %s confirmed: %d", p_SPITType.getID().data(), p_SPITType.getGroupName().data(), p_SPITType.getName().data(), p_SPITType.getConfirmed());
//Check your actions
//Whenever you provide an action for this SPITType take this over in your code.
@@ -515,9 +363,7 @@ void MyApp::eventSPITType(bool p_New, const SPITType& p_SPITType) {
*/
void MyApp::eventSPITTypeRemote(bool p_New, const SPITType& p_SPITType) {
if (p_New) {
#if defined(DEBUGOUTPUT)
printf("MySPITApp: eventSPITTypeRemote NEW");
#endif
ESP_LOGD(TAG, "eventSPITTypeRemote NEW");
}
else {
//we had to inform all Remote SPITObjects using the p_SPITType
@@ -533,13 +379,10 @@ void MyApp::eventSPITTypeRemote(bool p_New, const SPITType& p_SPITType) {
eventSPITObjectRemote(false, p_SPITType, *ptrSPITObject);
}
}
#if defined(DEBUGOUTPUT)
printf("MySPITApp: eventSPITTypeRemote CHANGED");
#endif
ESP_LOGD(TAG, "eventSPITTypeRemote CHANGED");
}
#if defined(DEBUGOUTPUT)
printf(" ID: %s GroupName: %s Name: %s confirmed: %d\n", p_SPITType.getID().data(), p_SPITType.getGroupName().data(), p_SPITType.getName().data(), p_SPITType.getConfirmed());
#endif
ESP_LOGD(TAG, "ID: %s GroupName: %s Name: %s confirmed: %d",
p_SPITType.getID().data(), p_SPITType.getGroupName().data(), p_SPITType.getName().data(), p_SPITType.getConfirmed());
//this is a remote SPITType, if you want you can list this for later remote use.
}
@@ -552,10 +395,8 @@ void MyApp::eventSPITTypeRemote(bool p_New, const SPITType& p_SPITType) {
* The reference is deleted after this function call!!
*/
void MyApp::eventSPITTypeRemoved(const SPITType& p_SPITType) {
#if defined(DEBUGOUTPUT)
printf("MySPITApp: eventSPITType Removed");
printf(" ID: %s GroupName: %s Name: %s\n", p_SPITType.getID().data(), p_SPITType.getGroupName().data(), p_SPITType.getName().data());
#endif
ESP_LOGD(TAG, "eventSPITType Removed");
ESP_LOGD(TAG, " ID: %s GroupName: %s Name: %s\n", p_SPITType.getID().data(), p_SPITType.getGroupName().data(), p_SPITType.getName().data());
//Check your actions
//take the removal of the SPITType over in your code
@@ -573,10 +414,8 @@ void MyApp::eventSPITTypeRemoved(const SPITType& p_SPITType) {
* The reference is deleted after this function call!!
*/
void MyApp::eventSPITTypeRemoteRemoved(const SPITType& p_SPITType) {
#if defined(DEBUGOUTPUT)
printf("MySPITApp: eventSPITTypeRemote Removed");
printf(" ID: %s GroupName: %s Name: %s\n", p_SPITType.getID().data(), p_SPITType.getGroupName().data(), p_SPITType.getName().data());
#endif
ESP_LOGD(TAG, "eventSPITTypeRemote Removed");
ESP_LOGD(TAG, " ID: %s GroupName: %s Name: %s\n", p_SPITType.getID().data(), p_SPITType.getGroupName().data(), p_SPITType.getName().data());
//This is a remote SPITType
//If you have listet this prior you should remove it from the list
@@ -626,18 +465,12 @@ void MyApp::eventSPITTypeRemoteRemoved(const SPITType& p_SPITType) {
*/
void MyApp::eventSPITObject(bool p_New, const SPITType& p_SPITType, const SPITObject& p_SPITObject) {
if (p_New) {
#if defined(DEBUGOUTPUT)
printf("MySPITApp: eventSPITObject NEW");
#endif
ESP_LOGD(TAG, "eventSPITObject NEW");
}
else {
#if defined(DEBUGOUTPUT)
printf("MySPITApp: eventSPITObject CHANGED");
#endif
ESP_LOGD(TAG, "eventSPITObject CHANGED");
}
#if defined(DEBUGOUTPUT)
printf(" ID: %s Name: %s -> SPITType: %s\n", p_SPITObject.getID().data(), p_SPITObject.getName().data(), p_SPITType.getName().data());
#endif
ESP_LOGD(TAG, " ID: %s Name: %s -> SPITType: %s", p_SPITObject.getID().data(), p_SPITObject.getName().data(), p_SPITType.getName().data());
//check your actions
//Whenever you provide an action for this SPITObject take this over in your code.
@@ -661,18 +494,12 @@ void MyApp::eventSPITObject(bool p_New, const SPITType& p_SPITType, const SPITOb
*/
void MyApp::eventSPITObjectRemote(bool p_New, const SPITType& p_SPITType, const SPITObject& p_SPITObject) {
if (p_New) {
#if defined(DEBUGOUTPUT)
printf("MySPITApp: eventSPITObjectRemote NEW");
#endif
ESP_LOGD(TAG, "eventSPITObjectRemote NEW");
}
else {
#if defined(DEBUGOUTPUT)
printf("MySPITApp: eventSPITObjectRemote CHANGED");
#endif
ESP_LOGD(TAG, "eventSPITObjectRemote CHANGED");
}
#if defined(DEBUGOUTPUT)
printf(" ID: %s Name: %s -> SPITType: %s\n", p_SPITObject.getID().data(), p_SPITObject.getName().data(), p_SPITType.getName().data());
#endif
ESP_LOGD(TAG, " ID: %s Name: %s -> SPITType: %s", p_SPITObject.getID().data(), p_SPITObject.getName().data(), p_SPITType.getName().data());
//This is a remote SPITObject which can be used to remote control the server.
//If you want you can list this for later use
@@ -689,11 +516,9 @@ void MyApp::eventSPITObjectRemote(bool p_New, const SPITType& p_SPITType, const
* The reference is deleted after this function call!!
*/
void MyApp::eventSPITObjectRemoved(const SPITType& p_SPITType, const SPITObject& p_SPITObject) {
#if defined(DEBUGOUTPUT)
printf("MySPITApp: eventSPITObject Removed");
printf(" ID: %s Name: %s\n", p_SPITObject.getID().data(), p_SPITObject.getName().data());
#endif
ESP_LOGD(TAG, "eventSPITObject Removed");
ESP_LOGD(TAG, " ID: %s Name: %s\n", p_SPITObject.getID().data(), p_SPITObject.getName().data());
//Check your actions
//take the removal of the SPITObject over in your code
@@ -712,11 +537,9 @@ void MyApp::eventSPITObjectRemoved(const SPITType& p_SPITType, const SPITObject&
* The reference is deleted after this function call!!
*/
void MyApp::eventSPITObjectRemoteRemoved(const SPITType& p_SPITType, const SPITObject& p_SPITObject) {
#if defined(DEBUGOUTPUT)
printf("MySPITApp: eventSPITObjectRemote Removed");
printf(" ID: %s Name: %s\n", p_SPITObject.getID().data(), p_SPITObject.getName().data());
#endif
ESP_LOGD(TAG, "eventSPITObjectRemote Removed");
ESP_LOGD(TAG, " ID: %s Name: %s\n", p_SPITObject.getID().data(), p_SPITObject.getName().data());
//This is a remote SPITObject
//If you have listet this prior you should remove it from the list
}
@@ -740,9 +563,7 @@ void MyApp::eventSPITObjectRemoteRemoved(const SPITType& p_SPITType, const SPITO
// SPIT distinguishes between the different players. All eventPlay... functions contain the information which player plays the SPIT object.
void MyApp::eventPlay(string p_PlayerID, string p_PlayerName, char p_PlayerType, bool p_PlayerIsRunning, long long p_TimeFrames) {
#if defined(DEBUGOUTPUT)
printf("MySPITApp: eventPlay Player: %s Runs: %d Time: %lld\n", p_PlayerName.data(), p_PlayerIsRunning, p_TimeFrames);
#endif
ESP_LOGD(TAG, "eventPlay Player: %s Runs: %d Time: %lld", p_PlayerName.data(), p_PlayerIsRunning, p_TimeFrames);
switch(p_PlayerType) {
case SPIT_Client::PLAYERTYPE_MAIN:
@@ -786,11 +607,9 @@ void MyApp::eventPlayObject(string p_PlayerID, bool p_Started, bool p_Ended, con
//in liveSHOWsoftware the player may play two different position in the SPITObject to mix them down, e.g. a SceneBridge is played
//We can get the second (pre played) position: p_PlayObject.getFrameInsidePrePosition();
#if defined(DEBUGOUTPUT)
printf("MySPITApp: eventPlayObject Player: %s is running: %d Object Started: %d Stopped: %d\n", p_PlayObject.getPlayerName().data(), p_PlayObject.getPlayerIsRunning(), p_Started, p_Ended);
printf(" SPITType: %s SPITObject: %s Position: %lld Value: %f\n", p_SPITType.getName().data(), p_SPITObject.getName().data(), p_PlayObject.getFrameInside(), doubleValue);
#endif
ESP_LOGD(TAG, "eventPlayObject Player: %s is running: %d Object Started: %d Stopped: %d", p_PlayObject.getPlayerName().data(), p_PlayObject.getPlayerIsRunning(), p_Started, p_Ended);
ESP_LOGD(TAG, " SPITType: %s SPITObject: %s Position: %lld Value: %f\n", p_SPITType.getName().data(), p_SPITObject.getName().data(), p_PlayObject.getFrameInside(), doubleValue);
//check for your actions to do
//In our little excample decribed in loadClientProject:
@@ -800,36 +619,24 @@ void MyApp::eventPlayObject(string p_PlayerID, bool p_Started, bool p_Ended, con
if (p_SPITType.getID() == "MySPITAPP_Action1ID") { //do Action 1
//we can get some information about the play status
if (p_Started == true) {
#if defined(DEBUGOUTPUT)
printf("MyApp AKTION 1 started Value: %f and running: %d\n", doubleValue, boolPLayerIsRunning);
#endif
ESP_LOGD(TAG, "MyApp AKTION 1 started Value: %f and running: %d", doubleValue, boolPLayerIsRunning);
}
else if (p_Ended == true) {
#if defined(DEBUGOUTPUT)
printf("MyApp AKTION 1 ended\n"); //p_PlayObject.getFrameInside() is -1
#endif
ESP_LOGD(TAG, "MyApp AKTION 1 ended"); //p_PlayObject.getFrameInside() is -1
}
else {
#if defined(DEBUGOUTPUT)
printf("MyApp AKTION 1 is played Value: %f and running: %d\n", doubleValue, boolPLayerIsRunning);
#endif
ESP_LOGD(TAG, "MyApp AKTION 1 is played Value: %f and running: %d", doubleValue, boolPLayerIsRunning);
}
}
else if (p_SPITType.getID() == "MySPITAPP_Action2ID") { //do Action 2
if (p_Started == true) {
#if defined(DEBUGOUTPUT)
printf("MyApp AKTION 2 started Value: %f and running: %d\n", doubleValue, boolPLayerIsRunning);
#endif
ESP_LOGD(TAG, "AKTION 2 started Value: %f and running: %d", doubleValue, boolPLayerIsRunning);
}
else if (p_Ended == true) {
#if defined(DEBUGOUTPUT)
printf("MyApp AKTION 2 ended\n"); //p_PlayObject.getFrameInside() is -1
#endif
ESP_LOGD(TAG, "AKTION 2 ended"); //p_PlayObject.getFrameInside() is -1
}
else {
#if defined(DEBUGOUTPUT)
printf("MyApp AKTION 2 is played Value: %f and running: %d\n", doubleValue, boolPLayerIsRunning);
#endif
ESP_LOGD(TAG, "AKTION 2 is played Value: %f and running: %d", doubleValue, boolPLayerIsRunning);
}
}
}
@@ -851,9 +658,7 @@ void MyApp::eventPlayObject(string p_PlayerID, bool p_Started, bool p_Ended, con
* @param p_Value the new value
*/
void MyApp::eventPlayRemoteObjectStatus(const SPITType& p_SPITType, const SPITObject& p_SPITObject, long long p_FrameInsideObject, int p_Value) {
#if defined(DEBUGOUTPUT)
printf("MySPITApp: eventPlayRemoteObjectStatus RemoteSPITType: %s RemoteSPITObject: %s Position: %lld Value: %d\n", p_SPITType.getName().data(), p_SPITObject.getName().data(), p_FrameInsideObject, p_Value);
#endif
ESP_LOGD(TAG, "eventPlayRemoteObjectStatus RemoteSPITType: %s RemoteSPITObject: %s Position: %lld Value: %d", p_SPITType.getName().data(), p_SPITObject.getName().data(), p_FrameInsideObject, p_Value);
}
/**