Modified Function Sort Split Ranking
This commit is contained in:
@ -23,6 +23,8 @@ public class DTFluxRemote : ModuleRules
|
||||
"HttpServer",
|
||||
"JsonUtilities",
|
||||
"Json",
|
||||
"DTFluxProjectSettings",
|
||||
"AvalancheMedia"
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@ -3,10 +3,13 @@
|
||||
|
||||
#include "DTFluxRemoteSubsystem.h"
|
||||
#include "DTFluxRemoteSubsystem.h"
|
||||
|
||||
#include "DTFluxGeneralSettings.h"
|
||||
#include "DTFluxRemoteModule.h"
|
||||
#include "DTFluxRemoteModule.h"
|
||||
#include "HttpServerModule.h"
|
||||
#include "IHttpRouter.h"
|
||||
#include "Rundown/AvaRundown.h"
|
||||
#include "Json.h"
|
||||
#include "Engine/Engine.h"
|
||||
#include "Misc/DateTime.h"
|
||||
@ -18,6 +21,16 @@ void UDTFluxRemoteSubsystem::Initialize(FSubsystemCollectionBase& Collection)
|
||||
|
||||
UE_LOG(logDTFluxRemote, Log, TEXT("DTFlux API Subsystem Initialized"));
|
||||
|
||||
#if WITH_EDITOR
|
||||
// S'abonner aux changements de settings
|
||||
if (UDTFluxGeneralSettings* Settings = GetMutableDefault<UDTFluxGeneralSettings>())
|
||||
{
|
||||
SettingsRundownChangedHandle = Settings->OnRemoteRundownChanged.AddUObject(
|
||||
this, &UDTFluxRemoteSubsystem::OnSettingsRundownChanged
|
||||
);
|
||||
}
|
||||
#endif
|
||||
LoadRundownFromSettings();
|
||||
// Auto-start server (optionnel)
|
||||
StartHTTPServer(63350);
|
||||
}
|
||||
@ -25,7 +38,22 @@ void UDTFluxRemoteSubsystem::Initialize(FSubsystemCollectionBase& Collection)
|
||||
void UDTFluxRemoteSubsystem::Deinitialize()
|
||||
{
|
||||
StopHTTPServer();
|
||||
|
||||
|
||||
#if WITH_EDITOR
|
||||
// Se désabonner du delegate
|
||||
if (UDTFluxGeneralSettings* Settings = GetMutableDefault<UDTFluxGeneralSettings>())
|
||||
{
|
||||
if (SettingsRundownChangedHandle.IsValid())
|
||||
{
|
||||
Settings->OnRemoteRundownChanged.Remove(SettingsRundownChangedHandle);
|
||||
SettingsRundownChangedHandle.Reset();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Décharger proprement le rundown
|
||||
UnloadCurrentRundown();
|
||||
UE_LOG(logDTFluxRemote, Log, TEXT("DTFlux API Subsystem Deinitialized"));
|
||||
|
||||
Super::Deinitialize();
|
||||
@ -64,9 +92,9 @@ bool UDTFluxRemoteSubsystem::StartHTTPServer(int32 Port)
|
||||
UE_LOG(logDTFluxRemote, Log, TEXT("DTFlux HTTP API Server started on port %d"), ServerPort);
|
||||
UE_LOG(logDTFluxRemote, Log, TEXT("Base URL: http://localhost:%d/dtflux/api/v1"), ServerPort);
|
||||
UE_LOG(logDTFluxRemote, Log, TEXT("Available routes:"));
|
||||
UE_LOG(logDTFluxRemote, Log, TEXT(" POST /dtflux/api/v1/title"));
|
||||
UE_LOG(logDTFluxRemote, Log, TEXT(" POST /dtflux/api/v1/title-bib"));
|
||||
UE_LOG(logDTFluxRemote, Log, TEXT(" POST /dtflux/api/v1/commands"));
|
||||
UE_LOG(logDTFluxRemote, Log, TEXT(" PUT /dtflux/api/v1/title"));
|
||||
UE_LOG(logDTFluxRemote, Log, TEXT(" PUT /dtflux/api/v1/title-bib"));
|
||||
UE_LOG(logDTFluxRemote, Log, TEXT(" PUT /dtflux/api/v1/commands"));
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -111,21 +139,21 @@ void UDTFluxRemoteSubsystem::SetupRoutes()
|
||||
// Route: POST /dtflux/api/v1/title
|
||||
TitleRouteHandle = HttpRouter->BindRoute(
|
||||
FHttpPath(TEXT("/dtflux/api/v1/title")),
|
||||
EHttpServerRequestVerbs::VERB_GET,
|
||||
EHttpServerRequestVerbs::VERB_PUT,
|
||||
FHttpRequestHandler::CreateUObject(this, &UDTFluxRemoteSubsystem::HandleTitleRequest)
|
||||
);
|
||||
|
||||
// Route: POST /dtflux/api/v1/title-bib
|
||||
TitleBibRouteHandle = HttpRouter->BindRoute(
|
||||
FHttpPath(TEXT("/dtflux/api/v1/title-bib")),
|
||||
EHttpServerRequestVerbs::VERB_GET,
|
||||
EHttpServerRequestVerbs::VERB_PUT,
|
||||
FHttpRequestHandler::CreateUObject(this, &UDTFluxRemoteSubsystem::HandleTitleBibRequest)
|
||||
);
|
||||
);
|
||||
|
||||
// Route: POST /dtflux/api/v1/commands
|
||||
CommandsRouteHandle = HttpRouter->BindRoute(
|
||||
FHttpPath(TEXT("/dtflux/api/v1/commands")),
|
||||
EHttpServerRequestVerbs::VERB_GET,
|
||||
EHttpServerRequestVerbs::VERB_PUT,
|
||||
FHttpRequestHandler::CreateUObject(this, &UDTFluxRemoteSubsystem::HandleCommandsRequest)
|
||||
);
|
||||
|
||||
@ -316,6 +344,56 @@ bool UDTFluxRemoteSubsystem::ParseCommandData(const TSharedPtr<FJsonObject>& Jso
|
||||
return true;
|
||||
}
|
||||
|
||||
void UDTFluxRemoteSubsystem::UnloadCurrentRundown()
|
||||
{
|
||||
}
|
||||
|
||||
void UDTFluxRemoteSubsystem::LoadRundownFromSettings()
|
||||
{
|
||||
const UDTFluxGeneralSettings* Settings = GetDefault<UDTFluxGeneralSettings>();
|
||||
if (!Settings)
|
||||
{
|
||||
UE_LOG(logDTFluxRemote, Warning, TEXT("Cannot access DTFlux settings"));
|
||||
return;
|
||||
}
|
||||
|
||||
TSoftObjectPtr<UAvaRundown> RundownAsset = Settings->RemoteTargetRundown;
|
||||
|
||||
if (RundownAsset.IsNull())
|
||||
{
|
||||
UE_LOG(logDTFluxRemote, Log, TEXT("No rundown specified in settings"));
|
||||
UnloadCurrentRundown();
|
||||
return;
|
||||
}
|
||||
|
||||
// Si c'est le même rundown, pas besoin de recharger
|
||||
if (RemotedRundown && RemotedRundown == RundownAsset.LoadSynchronous())
|
||||
{
|
||||
UE_LOG(logDTFluxRemote, Log, TEXT("Rundown already loaded: %s"), *RundownAsset.ToString());
|
||||
return;
|
||||
}
|
||||
|
||||
// Décharger l'ancien rundown d'abord
|
||||
UnloadCurrentRundown();
|
||||
|
||||
// Charger le nouveau rundown
|
||||
if (LoadRundown(RundownAsset))
|
||||
{
|
||||
UE_LOG(logDTFluxRemote, Log, TEXT("Successfully loaded rundown from settings: %s"), *RundownAsset.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOG(logDTFluxRemote, Error, TEXT("Failed to load rundown from settings: %s"), *RundownAsset.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
#if WITH_EDITOR
|
||||
void UDTFluxRemoteSubsystem::OnSettingsRundownChanged(const TSoftObjectPtr<UAvaRundown>& NewRundown)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// Manual processing functions for testing
|
||||
bool UDTFluxRemoteSubsystem::ProcessTitleData(const FString& JsonString)
|
||||
{
|
||||
@ -373,4 +451,7 @@ bool UDTFluxRemoteSubsystem::ProcessCommandData(const FString& JsonString)
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void UDTFluxRemoteSubsystem::LoadRundown
|
||||
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
#include "IHttpRouter.h"
|
||||
#include "DTFluxRemoteSubsystem.generated.h"
|
||||
|
||||
class UAvaRundown;
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnTitleReceived, const FDTFluxRemoteTitleData&, TitleData);
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnTitleBibReceived, const FDTFluxRemoteBibData&, TitleBibData);
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnCommandReceived, const FDTFluxRemoteCommandData&, CommandData);
|
||||
@ -73,10 +74,26 @@ private:
|
||||
|
||||
private:
|
||||
TSharedPtr<IHttpRouter> HttpRouter;
|
||||
TSoftObjectPtr<UAvaRundown> RemotedRundown;
|
||||
int32 ServerPort = 63350;
|
||||
bool bServerRunning = false;
|
||||
|
||||
FHttpRouteHandle TitleRouteHandle;
|
||||
FHttpRouteHandle TitleBibRouteHandle;
|
||||
FHttpRouteHandle CommandsRouteHandle;
|
||||
|
||||
void UnloadCurrentRundown();
|
||||
void LoadRundownFromSettings();
|
||||
void LoadRundown();
|
||||
|
||||
#if WITH_EDITOR
|
||||
FDelegateHandle SettingsRundownChangedHandle;
|
||||
#endif
|
||||
|
||||
|
||||
#if WITH_EDITOR
|
||||
// Callback pour les changements de settings
|
||||
UFUNCTION()
|
||||
void OnSettingsRundownChanged(const TSoftObjectPtr<UAvaRundown>& NewRundown);
|
||||
#endif
|
||||
};
|
||||
|
||||
@ -56,10 +56,11 @@ void UFTDFluxUtils::GetFullName(const int Bib, FText& OutFullName)
|
||||
UE_LOG(logDTFluxUtilities, Error, TEXT("DTFluxCoreSubsystem not available"));
|
||||
}
|
||||
|
||||
void UFTDFluxUtils::SortSplitRankingsByRank(TArray<FDTFluxSplitRanking>& Rankings)
|
||||
void UFTDFluxUtils::SortSplitRankingsByRank(TArray<FDTFluxSplitSensorInfo>& Rankings, TArray<FDTFluxSplitSensorInfo>& OutRankings)
|
||||
{
|
||||
Rankings.Sort([](const FDTFluxSplitRanking& A, const FDTFluxSplitRanking& B)
|
||||
{
|
||||
return A.Rank < B.Rank;
|
||||
});
|
||||
OutRankings = Rankings;
|
||||
}
|
||||
@ -71,7 +71,7 @@ public:
|
||||
static void GetFullName(const int Bib, FText& OutFullName);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="DTFlux|Utils")
|
||||
static void SortSplitRankingsByRank(TArray<FDTFluxSplitRanking>& Rankings);
|
||||
static void SortSplitRankingsByRank(TArray<FDTFluxSplitSensorInfo>& Rankings, TArray<FDTFluxSplitSensorInfo>& OutRankings);
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user