This commit is contained in:
wonkyhonky2024
2025-05-15 19:28:04 +01:00
parent 23691e77c2
commit ff30856c60
16 changed files with 109 additions and 33 deletions

View File

@ -1,4 +1,4 @@
#pragma once
#include <HsFFI.h>
typedef enum ExtCallType {

View File

@ -43,11 +43,19 @@ void UTheracAdapterComponent::WrapSimulatorCall(
EBeamType beam_type,
ECollimatorPosition collimator_position,
int32 beam_energy
) {}
) {
UpdateSimulator(
ExtCallType(ext_call_type),
wrappedComms,
BeamType(beam_type),
CollimatorPosition(collimator_position),
beam_energy
);
}
// Called when the game starts
void UTheracAdapterComponent::BeginPlay() {
/*
FString BaseDir =
IPluginManager::Get().FindPlugin("hstherac25")->GetBaseDir();
FString LibraryPath =
@ -56,7 +64,7 @@ void UTheracAdapterComponent::BeginPlay() {
simulatorLibraryHandle = !LibraryPath.IsEmpty()
? FPlatformProcess::GetDllHandle(*LibraryPath)
: nullptr;
*/
Super::BeginPlay();
wrappedComms = start_machine();
std::map<FText *, StateInfoRequest> hng = {
@ -70,6 +78,7 @@ void UTheracAdapterComponent::BeginPlay() {
for (auto & [hnng, hnnng] : hng) {
compMap.Add(hnng, hnnng);
}
ExtCallTypeMap.Add("T", EExtCallType::ExtCallSendMEOS);
ExtCallTypeMap.Add("R", EExtCallType::ExtCallReset);
ExtCallTypeMap.Add("P", EExtCallType::ExtCallProceed);
@ -84,13 +93,13 @@ void UTheracAdapterComponent::BeginPlay() {
// ...
}
/*
void UTheracAdapterComponent::shutdownSimulator() {
kill_machine();
FPlatformProcess::FreeDllHandle(simulatorLibraryHandle);
simulatorLibraryHandle = nullptr;
}
*/
// Called every frame
void UTheracAdapterComponent::TickComponent(
float DeltaTime,

View File

@ -13,16 +13,17 @@
void Fhstherac25Module::StartupModule() {
// This code will execute after your module is loaded into memory; the exact
// timing is specified in the .uplugin file per-module
/*
// Get the base directory of this plugin
FString BaseDir =
IPluginManager::Get().FindPlugin("hstherac25")->GetBaseDir();
// Add on the relative location of the third party dll and load it
/ FString LibraryPath;
FString LibraryPath;
#if PLATFORM_WINDOWS
LibraryPath = FPaths::Combine(*BaseDir, TEXT("Source/hstherac-hs/HSdll.dll"));
LibraryPath =
// FPaths::Combine(*BaseDir, TEXT("Binaries/Win64/hstherac25.dll"));
FPaths::Combine(*BaseDir, TEXT("Binaries/Win64/HSdll.dll"));
#elif PLATFORM_MAC
LibraryPath = FPaths::Combine(
*BaseDir,
@ -55,7 +56,6 @@ void Fhstherac25Module::StartupModule() {
)
);
}
*/
}
void Fhstherac25Module::ShutdownModule() {
@ -64,8 +64,9 @@ void Fhstherac25Module::ShutdownModule() {
// unloading the module.
// Free the dll handle
// FPlatformProcess::FreeDllHandle(simulatorLibraryHandle);
// simulatorLibraryHandle = nullptr;
kill_machine();
FPlatformProcess::FreeDllHandle(simulatorLibraryHandle);
simulatorLibraryHandle = nullptr;
}
#undef LOCTEXT_NAMESPACE

View File

@ -45,8 +45,6 @@ class HSTHERAC25_API UTheracAdapterComponent : public UActorComponent {
TMap<FText *, StateInfoRequest> compMap;
void * simulatorLibraryHandle;
void UpdateSimulator(
ExtCallType ect,
HsStablePtr wrapped_comms = nullptr,
@ -100,7 +98,8 @@ public:
protected:
// Called when the game starts
virtual void BeginPlay() override;
void shutdownSimulator();
// void shutdownSimulator();
public:
// Called every frame

View File

@ -12,5 +12,5 @@ public:
private:
/** Handle to the test dll we will load */
// void * simulatorLibraryHandle;
void * simulatorLibraryHandle;
};

View File

@ -63,7 +63,9 @@ public class hstherac25 : ModuleRules
// ... add any modules that your module loads dynamically here ...
}
);
PublicAdditionalLibraries.Add(Path.Combine(ModuleDirectory, "../hstherac-hs", "hstherac25.dll.a"));
RuntimeDependencies.Add(Path.Combine(ModuleDirectory, "../hstherac-hs/hstherac25.dll"));
// PublicAdditionalLibraries.Add(Path.Combine(PluginDirectory, "Source", "hstherac-hs", "hstherac25.dll.a"));
// RuntimeDependencies.Add(Path.Combine(PluginDirectory, "Source", "hstherac-hs", "hstherac25.dll"));
PublicAdditionalLibraries.Add(Path.Combine(PluginDirectory, "Source", "hstherac-hs", "HSdll.dll.a"));
RuntimeDependencies.Add(Path.Combine(PluginDirectory, "Source", "hstherac-hs", "HSdll.dll"));
}
}