a LOT of time wasted fighting with dlls again
This commit is contained in:
BIN
Content/LinacLab/MyMyUserWidget.uasset
(Stored with Git LFS)
BIN
Content/LinacLab/MyMyUserWidget.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/LinacLab/vt100_Blueprint.uasset
(Stored with Git LFS)
BIN
Content/LinacLab/vt100_Blueprint.uasset
(Stored with Git LFS)
Binary file not shown.
@ -1,4 +1,4 @@
|
||||
#pragma once
|
||||
|
||||
#include <HsFFI.h>
|
||||
|
||||
typedef enum ExtCallType {
|
||||
|
@ -7,12 +7,9 @@
|
||||
#include <Internationalization/Internationalization.h>
|
||||
#include <Internationalization/Text.h>
|
||||
#include <Misc/MessageDialog.h>
|
||||
#include <Therac.h>
|
||||
#include <map>
|
||||
#include <Logging/StructuredLog.h>
|
||||
|
||||
#define LOCTEXT_NAMESPACE "TheracAdapter"
|
||||
|
||||
// Sets default values for this component's properties
|
||||
UTheracAdapterComponent::UTheracAdapterComponent() {
|
||||
// Set this component to be initialized when the game starts, and to be ticked
|
||||
@ -41,18 +38,25 @@ void UTheracAdapterComponent::UpdateSimulator(
|
||||
);
|
||||
}
|
||||
|
||||
void UTheracAdapterComponent::WrapSimulatorCall(
|
||||
EExtCallType ext_call_type,
|
||||
EBeamType beam_type,
|
||||
ECollimatorPosition collimator_position,
|
||||
int32 beam_energy
|
||||
) {}
|
||||
|
||||
// Called when the game starts
|
||||
void UTheracAdapterComponent::BeginPlay() {
|
||||
/*
|
||||
|
||||
FString BaseDir =
|
||||
IPluginManager::Get().FindPlugin("hstherac25")->GetBaseDir();
|
||||
FString LibraryPath =
|
||||
FPaths::Combine(*BaseDir, TEXT("Source/hstherac-hs/HSdll.dll"));
|
||||
FPaths::Combine(*BaseDir, TEXT("Source/hstherac-hs/hstherac25.dll"));
|
||||
|
||||
auto simulatorLibraryHandle =
|
||||
!LibraryPath.IsEmpty() ? FPlatformProcess::GetDllHandle(*LibraryPath)
|
||||
simulatorLibraryHandle = !LibraryPath.IsEmpty()
|
||||
? FPlatformProcess::GetDllHandle(*LibraryPath)
|
||||
: nullptr;
|
||||
*/
|
||||
|
||||
Super::BeginPlay();
|
||||
wrappedComms = start_machine();
|
||||
std::map<FText *, StateInfoRequest> hng = {
|
||||
@ -66,9 +70,27 @@ void UTheracAdapterComponent::BeginPlay() {
|
||||
for (auto & [hnng, hnnng] : hng) {
|
||||
compMap.Add(hnng, hnnng);
|
||||
}
|
||||
ExtCallTypeMap.Add("R", EExtCallType::ExtCallReset);
|
||||
ExtCallTypeMap.Add("P", EExtCallType::ExtCallProceed);
|
||||
|
||||
BeamTypeMap.Add("X", EBeamType::BeamTypeXRay);
|
||||
BeamTypeMap.Add("E", EBeamType::BeamTypeElectron);
|
||||
|
||||
CollimatorPositionMap.Add("X", ECollimatorPosition::CollimatorPositionXRay);
|
||||
CollimatorPositionMap.Add(
|
||||
"E",
|
||||
ECollimatorPosition::CollimatorPositionElectronBeam
|
||||
);
|
||||
|
||||
// ...
|
||||
}
|
||||
|
||||
void UTheracAdapterComponent::shutdownSimulator() {
|
||||
kill_machine();
|
||||
FPlatformProcess::FreeDllHandle(simulatorLibraryHandle);
|
||||
simulatorLibraryHandle = nullptr;
|
||||
}
|
||||
|
||||
// Called every frame
|
||||
void UTheracAdapterComponent::TickComponent(
|
||||
float DeltaTime,
|
||||
|
@ -13,13 +13,13 @@
|
||||
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"));
|
||||
|
||||
@ -55,6 +55,7 @@ void Fhstherac25Module::StartupModule() {
|
||||
)
|
||||
);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void Fhstherac25Module::ShutdownModule() {
|
||||
@ -63,8 +64,8 @@ void Fhstherac25Module::ShutdownModule() {
|
||||
// unloading the module.
|
||||
|
||||
// Free the dll handle
|
||||
FPlatformProcess::FreeDllHandle(simulatorLibraryHandle);
|
||||
simulatorLibraryHandle = nullptr;
|
||||
// FPlatformProcess::FreeDllHandle(simulatorLibraryHandle);
|
||||
// simulatorLibraryHandle = nullptr;
|
||||
}
|
||||
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
|
@ -5,10 +5,33 @@
|
||||
#include "Components/ActorComponent.h"
|
||||
#include "CoreMinimal.h"
|
||||
#include <HsFFI.h>
|
||||
// #include
|
||||
// <hstherac-hs/dist-newstyle/build/x86_64-windows/ghc-9.6.7/hstherac25-0.1.0.0/build/HsTherac25_stub.h>
|
||||
#include <Therac.h>
|
||||
#include <Internationalization/Text.h>
|
||||
#include "TheracAdapterComponent.generated.h"
|
||||
|
||||
UENUM()
|
||||
enum class EBeamType : uint8 {
|
||||
BeamTypeXRay = 1,
|
||||
BeamTypeElectron,
|
||||
};
|
||||
|
||||
UENUM()
|
||||
enum class ECollimatorPosition : uint8 {
|
||||
CollimatorPositionXRay = 1,
|
||||
CollimatorPositionElectronBeam,
|
||||
};
|
||||
|
||||
UENUM()
|
||||
enum class EExtCallType : uint8 {
|
||||
ExtCallSendMEOS = 1,
|
||||
ExtCallToggleDatentComplete,
|
||||
ExtCallToggleEditingTakingPlace,
|
||||
ExtCallReset,
|
||||
ExtCallProceed
|
||||
};
|
||||
|
||||
UCLASS(
|
||||
BlueprintType,
|
||||
ClassGroup = (Custom),
|
||||
@ -22,6 +45,16 @@ class HSTHERAC25_API UTheracAdapterComponent : public UActorComponent {
|
||||
|
||||
TMap<FText *, StateInfoRequest> compMap;
|
||||
|
||||
void * simulatorLibraryHandle;
|
||||
|
||||
void UpdateSimulator(
|
||||
ExtCallType ect,
|
||||
HsStablePtr wrapped_comms = nullptr,
|
||||
BeamType beam_type = BeamTypeUndefined,
|
||||
CollimatorPosition collimator_position = CollimatorPositionUndefined,
|
||||
HsInt beam_energy = 25000
|
||||
);
|
||||
|
||||
public:
|
||||
// Sets default values for this component's properties
|
||||
UTheracAdapterComponent();
|
||||
@ -46,17 +79,28 @@ public:
|
||||
UPROPERTY(BlueprintReadOnly, VisibleAnywhere)
|
||||
FText BeamEnergy;
|
||||
|
||||
void UpdateSimulator(
|
||||
ExtCallType ect,
|
||||
HsStablePtr wrapped_comms = nullptr,
|
||||
BeamType beam_type = BeamTypeUndefined,
|
||||
CollimatorPosition collimator_position = CollimatorPositionUndefined,
|
||||
HsInt beam_energy = 25000
|
||||
UPROPERTY(BlueprintReadOnly, VisibleAnywhere)
|
||||
TMap<FString, EBeamType> BeamTypeMap;
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, VisibleAnywhere)
|
||||
TMap<FString, EExtCallType> ExtCallTypeMap;
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, VisibleAnywhere)
|
||||
TMap<FString, ECollimatorPosition> CollimatorPositionMap;
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void WrapSimulatorCall(
|
||||
EExtCallType ext_call_type,
|
||||
EBeamType beam_type = EBeamType::BeamTypeXRay,
|
||||
ECollimatorPosition collimator_position =
|
||||
ECollimatorPosition::CollimatorPositionXRay,
|
||||
int32 beam_energy = 25000
|
||||
);
|
||||
|
||||
protected:
|
||||
// Called when the game starts
|
||||
virtual void BeginPlay() override;
|
||||
void shutdownSimulator();
|
||||
|
||||
public:
|
||||
// Called every frame
|
||||
|
@ -12,5 +12,5 @@ public:
|
||||
|
||||
private:
|
||||
/** Handle to the test dll we will load */
|
||||
void * simulatorLibraryHandle;
|
||||
// void * simulatorLibraryHandle;
|
||||
};
|
||||
|
@ -25,7 +25,7 @@ public class hstherac25 : ModuleRules
|
||||
|
||||
// "C:/ghcup/ghc/9.6.7/include",
|
||||
// "${workspaceFolder}/Plugins/hstherac25/Source/hstherac-hs/csrc",
|
||||
// "${workspaceFolder}/Plugins/hstherac25/Source/hstherac-hs/dist-newstyle/build/x86_64-windows/ghc-9.6.7/hstherac25-0.1.0.0/build"
|
||||
// Path.Combine(ModuleDirectory,"../hstherac-hs/dist-newstyle/build/x86_64-windows/ghc-9.6.7/hstherac25-0.1.0.0/build"),
|
||||
// ... add other private include paths required here ...
|
||||
}
|
||||
);
|
||||
@ -63,7 +63,7 @@ public class hstherac25 : ModuleRules
|
||||
// ... add any modules that your module loads dynamically here ...
|
||||
}
|
||||
);
|
||||
PublicAdditionalLibraries.Add(Path.Combine(ModuleDirectory, "../hstherac-hs", "HSdll.dll.a"));
|
||||
RuntimeDependencies.Add(Path.Combine(PluginDirectory, "Source/hstherac-hs/HSdll.dll"));
|
||||
PublicAdditionalLibraries.Add(Path.Combine(ModuleDirectory, "../hstherac-hs", "hstherac25.dll.a"));
|
||||
RuntimeDependencies.Add(Path.Combine(ModuleDirectory, "../hstherac-hs/hstherac25.dll"));
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
using UnrealBuildTool;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class MyProjectTarget : TargetRules
|
||||
{
|
||||
@ -10,6 +9,6 @@ public class MyProjectTarget : TargetRules
|
||||
Type = TargetType.Game;
|
||||
DefaultBuildSettings = BuildSettingsVersion.V5;
|
||||
|
||||
ExtraModuleNames.AddRange( new string[] { "MyProject" } );
|
||||
ExtraModuleNames.AddRange(new string[] { "MyProject", "hstherac25" });
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ public class MyProject : ModuleRules
|
||||
PrivateDependencyModuleNames.AddRange(new string[] { });
|
||||
|
||||
// Uncomment if you are using Slate UI
|
||||
PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
|
||||
PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore", "hstherac25" });
|
||||
|
||||
// Uncomment if you are using online features
|
||||
// PrivateDependencyModuleNames.Add("OnlineSubsystem");
|
||||
|
@ -16,7 +16,7 @@ void UMyUserWidget::NativeOnInitialized() {
|
||||
CR_TextBlock,
|
||||
ColX_TextBlock,
|
||||
ColY_TextBlock,
|
||||
WR_TextBlock,
|
||||
WN_TextBlock,
|
||||
AN_TextBlock
|
||||
};
|
||||
for (auto * n : arcaneNumbers) {
|
||||
|
@ -40,7 +40,7 @@ class MYPROJECT_API UMyUserWidget : public UUserWidget {
|
||||
UTextBlock * ColY_TextBlock;
|
||||
|
||||
UPROPERTY(meta = (BindWidget))
|
||||
UTextBlock * WR_TextBlock;
|
||||
UTextBlock * WN_TextBlock;
|
||||
|
||||
UPROPERTY(meta = (BindWidget))
|
||||
UTextBlock * AN_TextBlock;
|
||||
|
@ -1,7 +1,6 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
using UnrealBuildTool;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class MyProjectEditorTarget : TargetRules
|
||||
{
|
||||
@ -10,6 +9,6 @@ public class MyProjectEditorTarget : TargetRules
|
||||
Type = TargetType.Editor;
|
||||
DefaultBuildSettings = BuildSettingsVersion.V5;
|
||||
|
||||
ExtraModuleNames.AddRange( new string[] { "MyProject" } );
|
||||
ExtraModuleNames.AddRange(new string[] { "MyProject", "hstherac25" });
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user