a LOT of time wasted fighting with dlls again

This commit is contained in:
wonkyhonky2024
2025-05-14 22:29:33 +01:00
parent 1b44322325
commit 23691e77c2
13 changed files with 153 additions and 88 deletions

BIN
Content/LinacLab/MyMyUserWidget.uasset (Stored with Git LFS)

Binary file not shown.

BIN
Content/LinacLab/vt100_Blueprint.uasset (Stored with Git LFS)

Binary file not shown.

View File

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

View File

@ -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"));
simulatorLibraryHandle = !LibraryPath.IsEmpty()
? FPlatformProcess::GetDllHandle(*LibraryPath)
: nullptr;
auto 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,

View File

@ -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

View File

@ -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

View File

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

View File

@ -5,65 +5,65 @@ using System.IO;
public class hstherac25 : ModuleRules
{
public hstherac25(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
public hstherac25(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
PublicIncludePaths.AddRange(
new string[] {
PublicIncludePaths.AddRange(
new string[] {
// ... add public include paths required here ...
"C:/ghcup/ghc/9.6.7/include",
}
);
}
);
PrivateIncludePaths.AddRange(
new string[] {
"C:/ghcup/ghc/9.6.7/include",
PrivateIncludePaths.AddRange(
new string[] {
"C:/ghcup/ghc/9.6.7/include",
// "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 ...
}
);
);
PublicDependencyModuleNames.AddRange(
new string[]
{
"Core",
"MathCore",
"Projects",
PublicDependencyModuleNames.AddRange(
new string[]
{
"Core",
"MathCore",
"Projects",
"CoreUObject",
"Engine",
"UMG",
"AudioMixerCore",
"InputCore"
"Engine",
"UMG",
"AudioMixerCore",
"InputCore"
// ... add other public dependencies that you statically link with here ...
}
);
);
PrivateDependencyModuleNames.AddRange(
new string[]
{
PrivateDependencyModuleNames.AddRange(
new string[]
{
"Slate", "SlateCore"
// ... add private dependencies that you statically link with here ...
}
);
);
DynamicallyLoadedModuleNames.AddRange(
new string[]
{
DynamicallyLoadedModuleNames.AddRange(
new string[]
{
// ... 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"));
}
}

View File

@ -1,15 +1,14 @@
// Fill out your copyright notice in the Description page of Project Settings.
using UnrealBuildTool;
using System.Collections.Generic;
public class MyProjectTarget : TargetRules
{
public MyProjectTarget(TargetInfo Target) : base(Target)
{
Type = TargetType.Game;
DefaultBuildSettings = BuildSettingsVersion.V5;
public MyProjectTarget(TargetInfo Target) : base(Target)
{
Type = TargetType.Game;
DefaultBuildSettings = BuildSettingsVersion.V5;
ExtraModuleNames.AddRange( new string[] { "MyProject" } );
}
ExtraModuleNames.AddRange(new string[] { "MyProject", "hstherac25" });
}
}

View File

@ -4,20 +4,20 @@ using UnrealBuildTool;
public class MyProject : ModuleRules
{
public MyProject(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "UMG" });
public MyProject(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
PrivateDependencyModuleNames.AddRange(new string[] { });
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "UMG" });
// Uncomment if you are using Slate UI
PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
// Uncomment if you are using online features
// PrivateDependencyModuleNames.Add("OnlineSubsystem");
PrivateDependencyModuleNames.AddRange(new string[] { });
// To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true
}
// Uncomment if you are using Slate UI
PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore", "hstherac25" });
// Uncomment if you are using online features
// PrivateDependencyModuleNames.Add("OnlineSubsystem");
// To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true
}
}

View File

@ -16,7 +16,7 @@ void UMyUserWidget::NativeOnInitialized() {
CR_TextBlock,
ColX_TextBlock,
ColY_TextBlock,
WR_TextBlock,
WN_TextBlock,
AN_TextBlock
};
for (auto * n : arcaneNumbers) {

View File

@ -40,10 +40,10 @@ class MYPROJECT_API UMyUserWidget : public UUserWidget {
UTextBlock * ColY_TextBlock;
UPROPERTY(meta = (BindWidget))
UTextBlock * WR_TextBlock;
UTextBlock * WN_TextBlock;
UPROPERTY(meta = (BindWidget))
UTextBlock * AN_TextBlock;
void NativeOnInitialized() override;
void NativeOnInitialized() override;
};

View File

@ -1,15 +1,14 @@
// Fill out your copyright notice in the Description page of Project Settings.
using UnrealBuildTool;
using System.Collections.Generic;
public class MyProjectEditorTarget : TargetRules
{
public MyProjectEditorTarget(TargetInfo Target) : base(Target)
{
Type = TargetType.Editor;
DefaultBuildSettings = BuildSettingsVersion.V5;
public MyProjectEditorTarget(TargetInfo Target) : base(Target)
{
Type = TargetType.Editor;
DefaultBuildSettings = BuildSettingsVersion.V5;
ExtraModuleNames.AddRange( new string[] { "MyProject" } );
}
ExtraModuleNames.AddRange(new string[] { "MyProject", "hstherac25" });
}
}