From 1ae087703da773305bb11ee5d70d8081cf94d826 Mon Sep 17 00:00:00 2001 From: wonkyhonky2024 Date: Tue, 13 May 2025 19:02:19 +0100 Subject: [PATCH] sync simulator state with widget --- .clang-format | 1 + Content/LinacLab/MyMyUserWidget.uasset | 4 +- Content/LinacLab/vt100_Blueprint.uasset | 4 +- MyProject.uproject | 38 ++++++------ .../Source/hstherac25/Private/Therac.h | 1 + .../Private/TheracAdapterComponent.cpp | 32 +++++++--- .../Public/TheracAdapterComponent.h | 60 ++++++++++++++----- 7 files changed, 92 insertions(+), 48 deletions(-) diff --git a/.clang-format b/.clang-format index 34cad14..4982587 100644 --- a/.clang-format +++ b/.clang-format @@ -23,3 +23,4 @@ PackConstructorInitializers: Never PointerAlignment: Middle QualifierAlignment: Right ShortNamespaceLines: 0 +SortIncludes: Never diff --git a/Content/LinacLab/MyMyUserWidget.uasset b/Content/LinacLab/MyMyUserWidget.uasset index feb2a24..4971e04 100644 --- a/Content/LinacLab/MyMyUserWidget.uasset +++ b/Content/LinacLab/MyMyUserWidget.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d66709ef9fbfc4c0e7d50f3c62dc930beedccdccd53b8367b2897c2f62a00ba3 -size 132543 +oid sha256:a08265d772d9ca487e5d2fe73ce684e19eb7da597b36fffd7e35e9b087c9722c +size 144396 diff --git a/Content/LinacLab/vt100_Blueprint.uasset b/Content/LinacLab/vt100_Blueprint.uasset index 029cd32..c46ad70 100644 --- a/Content/LinacLab/vt100_Blueprint.uasset +++ b/Content/LinacLab/vt100_Blueprint.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4b217590882d6f5cc5daae12dd70d1f70d247a8cfe9bfd01eb4e2e35ef7f1eed -size 85673 +oid sha256:72110e989b287b621f5e039512f74904695d6a75efadacacf6ebce43e12085a3 +size 106703 diff --git a/MyProject.uproject b/MyProject.uproject index d3a5014..26acdc5 100644 --- a/MyProject.uproject +++ b/MyProject.uproject @@ -1,23 +1,19 @@ { - "FileVersion": 3, - "EngineAssociation": "5.5", - "Category": "", - "Description": "", - "Modules": [ - { - "Name": "MyProject", - "Type": "Runtime", - "LoadingPhase": "Default" - } - ], - "Plugins": [ - { - "Name": "ModelingToolsEditorMode", - "Enabled": true - } - ], - "TargetPlatforms": [], - "AdditionalRootDirectories": [], - "AdditionalPluginDirectories": [], - "EpicSampleNameHash": "" + "FileVersion": 3, + "EngineAssociation": "5.5", + "Category": "", + "Description": "", + "Modules": [ + { + "Name": "MyProject", + "Type": "Runtime", + "LoadingPhase": "Default" + } + ], + "Plugins": [ + { + "Name": "ModelingToolsEditorMode", + "Enabled": true + } + ] } \ No newline at end of file diff --git a/Plugins/hstherac25/Source/hstherac25/Private/Therac.h b/Plugins/hstherac25/Source/hstherac25/Private/Therac.h index 4cd83d3..e7dbe5d 100644 --- a/Plugins/hstherac25/Source/hstherac25/Private/Therac.h +++ b/Plugins/hstherac25/Source/hstherac25/Private/Therac.h @@ -1,3 +1,4 @@ +#pragma once #include typedef enum ExtCallType { diff --git a/Plugins/hstherac25/Source/hstherac25/Private/TheracAdapterComponent.cpp b/Plugins/hstherac25/Source/hstherac25/Private/TheracAdapterComponent.cpp index caefa18..d1c9b96 100644 --- a/Plugins/hstherac25/Source/hstherac25/Private/TheracAdapterComponent.cpp +++ b/Plugins/hstherac25/Source/hstherac25/Private/TheracAdapterComponent.cpp @@ -8,6 +8,8 @@ #include #include #include +#include +#include #define LOCTEXT_NAMESPACE "TheracAdapter" @@ -16,7 +18,7 @@ UTheracAdapterComponent::UTheracAdapterComponent() { // Set this component to be initialized when the game starts, and to be ticked // every frame. You can turn these features off to improve performance if you // don't need them. - // PrimaryComponentTick.bCanEverTick = true; + PrimaryComponentTick.bCanEverTick = true; // ... } @@ -34,11 +36,18 @@ void UTheracAdapterComponent::BeginPlay() { : nullptr; */ Super::BeginPlay(); - wrappedComms = start_machine(); - auto si = FText::FromString(StaticCast( - request_state_info(wrappedComms, RequestActiveSubsystem) - )); - FMessageDialog::Open(EAppMsgType::Ok, si); + wrappedComms = start_machine(); + std::map hng = { + {&TreatmentOutcome, RequestTreatmentOutcome}, + {&ActiveSubsystem, RequestActiveSubsystem}, + {&TreatmentState, RequestTreatmentState}, + {&Reason, RequestReason}, + {&BeamMode, RequestBeamMode}, + {&BeamEnergy, RequestBeamEnergy} + }; + for (auto & [hnng, hnnng] : hng) { + compMap.Add(hnng, hnnng); + } // ... } @@ -50,6 +59,15 @@ void UTheracAdapterComponent::TickComponent( ) { Super::TickComponent(DeltaTime, TickType, ThisTickFunction); - // ... + auto rsi = [&](FText * f) { + return FText::FromString( + StaticCast(request_state_info(wrappedComms, *compMap.Find(f))) + ); + }; + + for (auto & [f, _] : compMap) { + // UE_LOGFMT(LogTemp, Warning, "what {dildo}", rsi(f).ToString()); + *f = rsi(f); + } } diff --git a/Plugins/hstherac25/Source/hstherac25/Public/TheracAdapterComponent.h b/Plugins/hstherac25/Source/hstherac25/Public/TheracAdapterComponent.h index ee4e9a3..f3725a2 100644 --- a/Plugins/hstherac25/Source/hstherac25/Public/TheracAdapterComponent.h +++ b/Plugins/hstherac25/Source/hstherac25/Public/TheracAdapterComponent.h @@ -2,31 +2,59 @@ #pragma once -#include "CoreMinimal.h" #include "Components/ActorComponent.h" +#include "CoreMinimal.h" #include +#include +#include #include "TheracAdapterComponent.generated.h" +UCLASS( + BlueprintType, + ClassGroup = (Custom), + meta = (BlueprintSpawnableComponent) +) +class HSTHERAC25_API UTheracAdapterComponent : public UActorComponent { + GENERATED_BODY() -UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) ) -class HSTHERAC25_API UTheracAdapterComponent : public UActorComponent -{ - GENERATED_BODY() + HsStablePtr wrappedComms; - HsStablePtr wrappedComms; + TMap compMap; -public: - // Sets default values for this component's properties - UTheracAdapterComponent(); +public: + // Sets default values for this component's properties + UTheracAdapterComponent(); + + UPROPERTY(BlueprintReadOnly, VisibleAnywhere) + FText TreatmentOutcome; + + UPROPERTY(BlueprintReadOnly, VisibleAnywhere) + FText ActiveSubsystem; + + // TPhase + UPROPERTY(BlueprintReadOnly, VisibleAnywhere) + FText TreatmentState; + + // TreatmentOutcome + UPROPERTY(BlueprintReadOnly, VisibleAnywhere) + FText Reason; + + UPROPERTY(BlueprintReadOnly, VisibleAnywhere) + FText BeamMode; + + UPROPERTY(BlueprintReadOnly, VisibleAnywhere) + FText BeamEnergy; protected: - // Called when the game starts - virtual void BeginPlay() override; + // Called when the game starts + virtual void BeginPlay() override; -public: - // Called every frame - virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override; - - +public: + // Called every frame + virtual void TickComponent( + float DeltaTime, + ELevelTick TickType, + FActorComponentTickFunction * ThisTickFunction + ) override; };